process.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <view class="process-list">
  3. <view class="search-row">
  4. <input class="search-input" v-model="searchName" placeholder="事故事件名称" />
  5. <button class="search-btn" @click="handleSearch">搜索</button>
  6. </view>
  7. <u-list @scrolltolower="loadMore" class="list-content">
  8. <view v-for="(item, idx) in listData" :key="item.id" class="card-wrapper">
  9. <myCard :item="item" :index="idx + 1" :btnList="getBtnList(item)" :columns="processColumns"
  10. :title="item.acdntName" :status="getStatusLabel(item.approvalStatus)" @goDetail="goDetail"
  11. @handleProcess="handleProcess(item)" />
  12. </view>
  13. <view style="height: 20rpx"></view>
  14. <view v-if="loading" class="load-more">加载中...</view>
  15. <view v-if="isEnd && listData.length > 0" class="load-more">没有更多了</view>
  16. <u-empty v-if="!loading && listData.length === 0" text="暂无待处理事故" />
  17. </u-list>
  18. <!-- 弹窗 -->
  19. <processDialog ref="processDialogRef" @reload="reloadList" />
  20. <accidentDialog ref="dialogRef" @reload="reloadList" />
  21. <ba-tree-picker ref="treePicker" key="dept" :multiple="false" @select-change="onDeptConfirm" title="选择部门"
  22. :localdata="deptList" valueKey="id" textKey="name" />
  23. <u-toast ref="uToast" />
  24. </view>
  25. </template>
  26. <script>
  27. import myCard from "@/components/myCard.vue";
  28. import processDialog from "./processDialog.vue";
  29. import accidentDialog from "./accidentDialog.vue";
  30. import baTreePicker from "@/components/ba-tree-picker/ba-tree-picker.vue";
  31. import {
  32. pageApproved
  33. } from "@/api/accidentReport/index.js";
  34. import {
  35. listOrganizations
  36. } from "@/api/common.js";
  37. import {
  38. reviewStatusEnum
  39. } from "@/enum/dict";
  40. export default {
  41. components: {
  42. myCard,
  43. processDialog,
  44. accidentDialog,
  45. baTreePicker
  46. },
  47. data() {
  48. return {
  49. searchName: "",
  50. deptId: null,
  51. deptName: "责任单位",
  52. deptList: [],
  53. listData: [],
  54. page: 1,
  55. size: 10,
  56. isEnd: false,
  57. loading: false,
  58. processColumns: [
  59. [{
  60. prop: "acdntCode",
  61. label: "编码",
  62. className: "perce100"
  63. }],
  64. [{
  65. prop: "dutyUnitName",
  66. label: "责任单位",
  67. className: "perce50"
  68. },
  69. {
  70. prop: "acdntPlace",
  71. label: "地点",
  72. className: "perce50"
  73. },
  74. ],
  75. [{
  76. prop: "occurrenceTime",
  77. label: "发生时间",
  78. className: "perce100"
  79. }],
  80. [{
  81. prop: "ascertainedStatus",
  82. label: "事故原因",
  83. className: "perce50",
  84. formatter: (row) =>
  85. row.ascertainedStatus == 1 ? "已查清" : "未查清",
  86. },
  87. {
  88. prop: "responsibilityStatus",
  89. label: "责任人员",
  90. className: "perce50",
  91. formatter: (row) =>
  92. row.responsibilityStatus == 1 ? "已处理" : "未处理",
  93. },
  94. ],
  95. [{
  96. prop: "correctiveMeasuresStatus",
  97. label: "整改措施",
  98. className: "perce33",
  99. formatter: (row) =>
  100. row.correctiveMeasuresStatus == 1 ? "已落实" : "未落实",
  101. },
  102. {
  103. prop: "personnelEducationStatus",
  104. label: "人员教育",
  105. className: "perce50",
  106. formatter: (row) =>
  107. row.personnelEducationStatus == 1 ? "已教育" : "未教育",
  108. },
  109. ],
  110. [{
  111. label: "操作",
  112. prop: "action",
  113. type: "action",
  114. className: "perce100",
  115. }, ],
  116. ],
  117. };
  118. },
  119. mounted() {
  120. this.loadDeptList();
  121. this.getList();
  122. },
  123. methods: {
  124. async loadDeptList() {
  125. try {
  126. const res = await listOrganizations({});
  127. this.deptList = res || [];
  128. } catch (e) {}
  129. },
  130. showDeptPicker() {
  131. this.$refs.treePicker._show();
  132. },
  133. onDeptConfirm(data) {
  134. const id = data[0];
  135. this.deptId = id;
  136. const find = (list) => {
  137. for (const item of list) {
  138. if (item.id === id) return item.name;
  139. if (item.children) {
  140. const f = find(item.children);
  141. if (f) return f;
  142. }
  143. }
  144. return null;
  145. };
  146. this.deptName = find(this.deptList) || "责任单位";
  147. this.page = 1;
  148. this.isEnd = false;
  149. this.getList();
  150. },
  151. getStatusLabel(status) {
  152. return reviewStatusEnum.find(item => item.value == status).label
  153. },
  154. getBtnList(item) {
  155. return [
  156. {
  157. name: "处理",
  158. apiName: "handleProcess",
  159. btnType: "primary",
  160. judge: [{
  161. fn: () => true
  162. }],
  163. },
  164. ];
  165. },
  166. goDetail(item) {
  167. this.$refs.dialogRef.open(item, "view");
  168. },
  169. handleProcess(item) {
  170. this.$refs.processDialogRef.open(item);
  171. },
  172. handleSearch() {
  173. this.page = 1;
  174. this.isEnd = false;
  175. this.getList();
  176. },
  177. reloadList() {
  178. this.page = 1;
  179. this.isEnd = false;
  180. this.getList();
  181. },
  182. async getList() {
  183. if (this.loading || this.isEnd) return;
  184. this.loading = true;
  185. try {
  186. const params = {
  187. pageNum: this.page,
  188. size: this.size,
  189. acdntName: this.searchName || undefined,
  190. dutyUnitId: this.deptId || undefined,
  191. };
  192. const res = await pageApproved(params);
  193. const list = res.list || [];
  194. if (this.page === 1) this.listData = list;
  195. else this.listData = this.listData.concat(list);
  196. this.isEnd =
  197. list.length < this.size || this.listData.length >= res.count;
  198. this.page += 1;
  199. } catch (e) {
  200. this.$refs.uToast.show({
  201. type: "error",
  202. message: e.message
  203. });
  204. } finally {
  205. this.loading = false;
  206. }
  207. },
  208. loadMore() {
  209. if (!this.isEnd && !this.loading) this.getList();
  210. },
  211. },
  212. };
  213. </script>
  214. <style lang="scss" scoped>
  215. .process-list {
  216. .search-row {
  217. display: flex;
  218. align-items: center;
  219. gap: 12rpx;
  220. padding: 16rpx 20rpx;
  221. background: #fff;
  222. border-radius: 24rpx;
  223. margin-bottom: 16rpx;
  224. .search-input {
  225. flex: 1;
  226. height: 60rpx;
  227. background: #f5f7fb;
  228. border-radius: 48rpx;
  229. padding: 0 20rpx;
  230. font-size: 26rpx;
  231. }
  232. .dept-btn {
  233. display: flex;
  234. align-items: center;
  235. height: 60rpx;
  236. padding: 0 20rpx;
  237. background: #e8edf4;
  238. border-radius: 48rpx;
  239. color: #2979ff;
  240. font-size: 24rpx;
  241. gap: 4rpx;
  242. .arrow {
  243. font-size: 18rpx;
  244. }
  245. }
  246. .search-btn {
  247. height: 60rpx;
  248. padding: 0 28rpx;
  249. background: $theme-color;
  250. border-radius: 48rpx;
  251. color: #fff;
  252. font-size: 26rpx;
  253. line-height: 60rpx;
  254. }
  255. }
  256. .list-content {
  257. height: calc(100vh - 300rpx);
  258. }
  259. .card-wrapper {
  260. margin-top: 16rpx;
  261. }
  262. .load-more {
  263. text-align: center;
  264. font-size: 26rpx;
  265. color: #aaa;
  266. padding: 20rpx 0;
  267. }
  268. }
  269. </style>