index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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. </uni-easyinput>
  14. </uni-col>
  15. <uni-col :span="5" class="flex-row justify-end">
  16. <button
  17. class="mini-btn"
  18. type="primary"
  19. size="mini"
  20. @click="searchList">
  21. {{ $t("operation.search") }}
  22. </button>
  23. </uni-col>
  24. </uni-row>
  25. </template>
  26. <view class="list">
  27. <view class="item" v-for="(item, index) in dataList" :key="index">
  28. <view
  29. class="item-module flex-row align-center justify-between"
  30. :class="{
  31. tobeFilled: item.status == 0,
  32. }">
  33. <!-- 创建时间 -->
  34. <view class="module-name">
  35. {{ item.createTime ? formatDate(item.createTime) : "" }}
  36. </view>
  37. <!-- 工单状态 -->
  38. <view
  39. class="module-status"
  40. :class="{
  41. pending: item.status === 0, //待填写
  42. }">
  43. {{ fillStatusDict[item.status] }}
  44. </view>
  45. </view>
  46. <view class="item-content">
  47. <!-- 带班干部 -->
  48. <view class="item-title flex-row">
  49. <span class="item-title-width">{{ $t("ruiDu.shiftLeader") }}:</span>
  50. <span>{{ item.responsiblePersonNames }}</span>
  51. </view>
  52. <!-- 日报名称 -->
  53. <view class="item-title flex-row">
  54. <span class="item-title-width">{{ $t("ruiDu.reportName") }}:</span>
  55. <span>{{ item.reportName }}</span>
  56. </view>
  57. <!-- 项目 -->
  58. <view class="item-title flex-row">
  59. <span class="item-title-width">{{ $t("ruiDu.project") }}:</span>
  60. <span>{{ item.contractName }}</span>
  61. </view>
  62. <!-- 任务 -->
  63. <view class="item-title flex-row">
  64. <span class="item-title-width">{{ $t("ruiDu.task") }}:</span>
  65. <span>{{ item.taskName }}</span>
  66. </view>
  67. <!-- 创建时间 -->
  68. <view class="item-title flex-row">
  69. <span class="item-title-width"
  70. >{{ $t("operation.createTime") }}:</span
  71. >
  72. <span>{{
  73. item.createTime ? formatTime(item.createTime) : ""
  74. }}</span>
  75. </view>
  76. <!-- 填写时间 -->
  77. <view class="item-title flex-row">
  78. <span class="item-title-width"
  79. >{{ $t("operation.fillTime") }}:</span
  80. >
  81. <span>{{ item.fillTime ? formatTime(item.fillTime) : "" }}</span>
  82. </view>
  83. <view class="item-title flex-row align-center">
  84. <span class="item-title-width">{{ "审批状态" }}:</span>
  85. <span
  86. :class="[
  87. 'my-tag',
  88. item.auditStatus === 0
  89. ? 'my-tag-info'
  90. : item.auditStatus === 10
  91. ? 'my-tag-primary'
  92. : item.auditStatus === 20
  93. ? 'my-tag-success'
  94. : 'my-tag-danger',
  95. ]">
  96. {{
  97. item.auditStatus === 0
  98. ? "待提交"
  99. : item.auditStatus === 10
  100. ? "待审批"
  101. : item.auditStatus === 20
  102. ? "审批通过"
  103. : "审批拒绝"
  104. }}
  105. </span>
  106. </view>
  107. <view class="item-title flex-row align-center">
  108. <span class="item-title-width">{{ "非生产时间" }}:</span>
  109. <span
  110. :class="[
  111. 'my-tag',
  112. item.nonProductFlag ? 'my-tag-success' : 'my-tag-danger',
  113. ]">
  114. {{ item.nonProductFlag ? "已填写" : "未填写" }}
  115. </span>
  116. </view>
  117. </view>
  118. <view class="item-btn flex-row align-center justify-end">
  119. <!-- 状态:0(待填写),1(已完成),2(填写中),3(忽略) -->
  120. <!-- 查看 -->
  121. <button type="primary" plain="true" @click="navigatorDetail(item)">
  122. {{ $t("operation.view") }}
  123. </button>
  124. <!-- 填写 -->
  125. <button
  126. v-show="item.status === 0"
  127. type="primary"
  128. @click="navigatorEdit(item)">
  129. {{ $t("operation.fill") }}
  130. </button>
  131. <button
  132. v-show="item.auditStatus === 20 && rdNonProductFlag"
  133. type="primary"
  134. @click="navigatorEdit(item, 'true')">
  135. {{ $t("operation.time") }}
  136. </button>
  137. </view>
  138. </view>
  139. </view>
  140. </z-paging>
  141. </template>
  142. <script setup>
  143. import { ref, reactive, nextTick } from "vue";
  144. import { onShow } from "@dcloudio/uni-app";
  145. import dayjs from "dayjs";
  146. import { getRuiDuReportPage } from "@/api/ruiDu";
  147. import { useDataDictStore } from "@/store/modules/dataDict";
  148. import { getLoginUserInfo } from "@/api/login";
  149. // 获取字典项
  150. const { getStrDictOptions } = useDataDictStore();
  151. // 填写状态
  152. const fillStatusDict = reactive({});
  153. getStrDictOptions("operation_fill_order_status").map(item => {
  154. fillStatusDict[item.value] = item.label;
  155. });
  156. console.log("🚀 ~ getDataDictList ~ fillStatusDict:", fillStatusDict);
  157. const orderName = ref("");
  158. const placeholderStyle = ref("color:#797979;font-weight:500;font-size:16px");
  159. const inputStyles = reactive({
  160. backgroundColor: "#FFFFFF",
  161. color: "#797979",
  162. });
  163. const paging = ref(null);
  164. // v-model绑定的这个变量不要在分页请求结束中自己赋值,直接使用即可
  165. const dataList = ref([]);
  166. // @query所绑定的方法不要自己调用!!需要刷新列表数据时,只需要调用paging.value.reload()即可
  167. const queryList = (pageNo, pageSize) => {
  168. // 此处请求仅为演示,请替换为自己项目中的请求
  169. getRuiDuReportPage({
  170. pageNo,
  171. pageSize,
  172. })
  173. .then(res => {
  174. // 将请求结果通过complete传给z-paging处理,同时也代表请求结束,这一行必须调用
  175. paging.value.complete(res.data.list);
  176. })
  177. .catch(res => {
  178. // 如果请求失败写paging.value.complete(false);
  179. // 注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
  180. // 在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
  181. paging.value.complete(false);
  182. });
  183. };
  184. const searchList = () => {
  185. paging.value.reload();
  186. };
  187. const navigatorDetail = item => {
  188. uni.navigateTo({
  189. url: "/pages/ruiDu/detail?id=" + item.id,
  190. });
  191. };
  192. const navigatorEdit = (item, istime = "false") => {
  193. uni.navigateTo({
  194. url: "/pages/ruiDu/edit?id=" + item.id + "&istime=" + istime,
  195. });
  196. };
  197. const formatDate = time => {
  198. return dayjs(time).format("YYYY-MM-DD");
  199. };
  200. const formatTime = time => {
  201. return dayjs(time).format("YYYY-MM-DD HH:mm:ss");
  202. };
  203. onShow(() => {
  204. nextTick(() => {
  205. searchList();
  206. });
  207. });
  208. const rdNonProductFlag = ref(false);
  209. const getLoginUser = async () => {
  210. const response = await getLoginUserInfo();
  211. if (response.code === 0) {
  212. rdNonProductFlag.value = response.data.rdNonProductFlag;
  213. }
  214. };
  215. getLoginUser();
  216. </script>
  217. <style lang="scss" scoped>
  218. @import "@/style/work-order.scss";
  219. .search-row {
  220. height: 35px;
  221. background: #f3f5f9;
  222. .mini-btn {
  223. height: 35px;
  224. line-height: 35px;
  225. width: 100%;
  226. margin-left: 8px;
  227. }
  228. }
  229. .item {
  230. width: 100%;
  231. // height: 245px;
  232. min-height: 245px;
  233. // max-height: fit-content;
  234. background: #ffffff;
  235. border-radius: 6px;
  236. margin-top: 10px;
  237. }
  238. .my-tag {
  239. display: inline-block;
  240. padding: 0 9px;
  241. height: 24px;
  242. line-height: 22px; /* height - border*2 */
  243. font-size: 12px;
  244. border-radius: 4px;
  245. box-sizing: border-box;
  246. border: 1px solid;
  247. white-space: nowrap;
  248. margin-left: 12px;
  249. }
  250. /* 已填写 - 绿色 (Success) */
  251. .my-tag-success {
  252. background-color: #f0f9eb;
  253. border-color: #e1f3d8;
  254. color: #67c23a;
  255. }
  256. /* 未填写 - 红色 (Danger) */
  257. .my-tag-danger {
  258. background-color: #fef0f0;
  259. border-color: #fde2e2;
  260. color: #f56c6c;
  261. }
  262. .my-tag-primary {
  263. background-color: #ecf5ff;
  264. border-color: #d9ecff;
  265. color: #409eff;
  266. }
  267. /* 信息 - 灰色 (Info) */
  268. .my-tag-info {
  269. background-color: #f4f4f5;
  270. border-color: #e9e9eb;
  271. color: #909399;
  272. }
  273. </style>