index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <z-paging class="page" ref="paging" v-model="dataList" @query="queryList">
  3. <!-- z-paging默认铺满全屏,此时页面所有view都应放在z-paging标签内,否则会被盖住 -->
  4. <!-- 需要固定在页面顶部的view请通过slot="top"插入,包括自定义的导航栏 -->
  5. <template #top>
  6. <uni-row class="search-row flex-row align-center justify-between">
  7. <uni-col :span="19">
  8. <uni-easyinput
  9. v-model="orderName"
  10. :styles="inputStyles"
  11. :placeholderStyle="placeholderStyle"
  12. :placeholder="$t('operation.searchText')"
  13. >
  14. </uni-easyinput>
  15. </uni-col>
  16. <uni-col :span="5" class="flex-row justify-end">
  17. <button
  18. class="mini-btn"
  19. type="primary"
  20. size="mini"
  21. @click="searchList"
  22. >
  23. {{ $t("operation.search") }}
  24. </button>
  25. </uni-col>
  26. </uni-row>
  27. </template>
  28. <view class="list">
  29. <view class="item" v-for="(item, index) in dataList" :key="index">
  30. <view
  31. class="item-module flex-row align-center justify-between"
  32. :class="{
  33. tobeFilled: item.status == 0,
  34. }"
  35. >
  36. <!-- 创建时间 -->
  37. <view class="module-name">
  38. {{ item.createTime ? formatDate(item.createTime) : "" }}
  39. </view>
  40. <!-- 工单状态 -->
  41. <view
  42. class="module-status"
  43. :class="{
  44. pending: item.status == 0, //待填写
  45. }"
  46. >
  47. {{ fillStatusDict[item.status] }}
  48. </view>
  49. </view>
  50. <view class="item-content">
  51. <!-- 带班干部 -->
  52. <view class="item-title flex-row">
  53. <span class="item-title-width"
  54. >{{ $t("ruiDu.shiftLeader") }}:</span
  55. >
  56. <span>{{ item.responsiblePersonNames }}</span>
  57. </view>
  58. <!-- 日报名称 -->
  59. <view class="item-title flex-row">
  60. <span class="item-title-width"
  61. >{{ $t("ruiDu.reportName") }}:</span
  62. >
  63. <span>{{ item.reportName }}</span>
  64. </view>
  65. <!-- 项目 -->
  66. <view class="item-title flex-row">
  67. <span class="item-title-width"
  68. >{{ $t("ruiDu.project") }}:</span
  69. >
  70. <span>{{ item.contractName }}</span>
  71. </view>
  72. <!-- 任务 -->
  73. <view class="item-title flex-row">
  74. <span class="item-title-width"
  75. >{{ $t("ruiDu.task") }}:</span
  76. >
  77. <span>{{ item.taskName }}</span>
  78. </view>
  79. <!-- 创建时间 -->
  80. <view class="item-title flex-row">
  81. <span class="item-title-width">{{ $t("operation.createTime") }}:</span>
  82. <span>{{
  83. item.createTime ? formatTime(item.createTime) : ""
  84. }}</span>
  85. </view>
  86. <!-- 填写时间 -->
  87. <view class="item-title flex-row">
  88. <span class="item-title-width"
  89. >{{ $t("operation.fillTime") }}:</span
  90. >
  91. <span>{{
  92. item.fillTime ? formatTime(item.fillTime) : ""
  93. }}</span>
  94. </view>
  95. </view>
  96. <view class="item-btn flex-row align-center justify-end">
  97. <!-- 状态:0(待填写),1(已完成),2(填写中),3(忽略) -->
  98. <!-- 查看 -->
  99. <button
  100. type="primary"
  101. plain="true"
  102. @click="navigatorDetail(item)"
  103. >
  104. {{ $t("operation.view") }}
  105. </button>
  106. <!-- 填写 -->
  107. <button
  108. type="primary"
  109. @click="navigatorEdit(item)"
  110. >
  111. {{ $t("operation.fill") }}
  112. </button>
  113. </view>
  114. </view>
  115. </view>
  116. </z-paging>
  117. </template>
  118. <script setup>
  119. import { ref, reactive, nextTick } from "vue";
  120. import { onShow } from "@dcloudio/uni-app";
  121. import dayjs from "dayjs";
  122. import {
  123. getRuiDuReportPage,
  124. } from "@/api/ruiDu";
  125. import { getUserId, getDeptId } from "@/utils/auth.js";
  126. import { useDataDictStore } from "@/store/modules/dataDict";
  127. // 获取字典项
  128. const { getStrDictOptions } = useDataDictStore();
  129. // 填写状态
  130. const fillStatusDict = reactive({});
  131. getStrDictOptions("operation_fill_order_status").map((item) => {
  132. fillStatusDict[item.value] = item.label;
  133. });
  134. console.log("🚀 ~ getDataDictList ~ fillStatusDict:", fillStatusDict);
  135. const orderName = ref("");
  136. const placeholderStyle = ref("color:#797979;font-weight:500;font-size:16px");
  137. const inputStyles = reactive({
  138. backgroundColor: "#FFFFFF",
  139. color: "#797979",
  140. });
  141. const paging = ref(null);
  142. // v-model绑定的这个变量不要在分页请求结束中自己赋值,直接使用即可
  143. const dataList = ref([]);
  144. // @query所绑定的方法不要自己调用!!需要刷新列表数据时,只需要调用paging.value.reload()即可
  145. const queryList = (pageNo, pageSize) => {
  146. // 此处请求仅为演示,请替换为自己项目中的请求
  147. getRuiDuReportPage({
  148. pageNo,
  149. pageSize,
  150. })
  151. .then((res) => {
  152. // 将请求结果通过complete传给z-paging处理,同时也代表请求结束,这一行必须调用
  153. paging.value.complete(res.data.list);
  154. })
  155. .catch((res) => {
  156. // 如果请求失败写paging.value.complete(false);
  157. // 注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
  158. // 在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
  159. paging.value.complete(false);
  160. });
  161. };
  162. const searchList = () => {
  163. paging.value.reload();
  164. };
  165. const navigatorDetail = (item) => {
  166. console.log("item", item);
  167. uni.navigateTo({
  168. url:
  169. "/pages/ruiDu/detail?id=" + item.id,
  170. });
  171. };
  172. const navigatorEdit = (item) => {
  173. console.log("item", item);
  174. uni.navigateTo({
  175. url:
  176. "/pages/ruiDu/edit?id=" + item.id,
  177. });
  178. };
  179. const formatDate = (time) => {
  180. return dayjs(time).format("YYYY-MM-DD");
  181. };
  182. const formatTime = (time) => {
  183. return dayjs(time).format("YYYY-MM-DD HH:mm:ss");
  184. };
  185. onShow(() => {
  186. nextTick(() => {
  187. searchList();
  188. });
  189. });
  190. </script>
  191. <style lang="scss" scoped>
  192. @import "@/style/work-order.scss";
  193. .search-row {
  194. height: 35px;
  195. background: #f3f5f9;
  196. .mini-btn {
  197. height: 35px;
  198. line-height: 35px;
  199. width: 100%;
  200. margin-left: 8px;
  201. }
  202. }
  203. .item {
  204. width: 100%;
  205. // height: 245px;
  206. min-height: 245px;
  207. // max-height: fit-content;
  208. background: #ffffff;
  209. border-radius: 6px;
  210. margin-top: 10px;
  211. }
  212. </style>