index.vue 9.7 KB

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