batchRevokeDialog.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. <template>
  2. <u-popup :show="visible" mode="center" :round="20" :closeOnClickOverlay="false" :zIndex="99999"
  3. @close="handleCancel" class="batch-revoke-popup">
  4. <view class="popup-content">
  5. <view class="popup-header">
  6. <text class="popup-title">批量撤回工单</text>
  7. <view class="close-btn" @click="handleCancel">×</view>
  8. </view>
  9. <!-- 工单列表(使用myCard) -->
  10. <scroll-view class="popup-body" scroll-y @scrolltolower="loadMore">
  11. <view v-for="(item, idx) in workOrderList" :key="item.id">
  12. <myCard :item="item" :index="idx + 1" :columns="cardColumns" :title="item.code"
  13. :status="getStatusText(item.status)" :showRadio="true" selectionMode="multiple"
  14. :checkboxValue="selectedIds" @radioChange="onRadioChange"
  15. @checkboxChange="onCheckboxChange" :showDetail="false" />
  16. </view>
  17. <view v-if="loading && workOrderList.length === 0" class="empty-tip">
  18. <u-empty text="加载中..." mode="loading"></u-empty>
  19. </view>
  20. <view v-if="!loading && workOrderList.length === 0" class="empty-tip">
  21. <u-empty text="暂无工单数据"></u-empty>
  22. </view>
  23. <view class="loadmore-text" v-if="!isEnd && workOrderList.length > 0">加载更多...</view>
  24. <view class="loadmore-text" v-if="isEnd && workOrderList.length > 0">没有更多了</view>
  25. </scroll-view>
  26. <view class="popup-footer">
  27. <u-button type="default" @click="handleCancel">取消</u-button>
  28. <u-button type="primary" :loading="revokeLoading" @click="handleBatchRevoke">
  29. 批量撤回
  30. </u-button>
  31. </view>
  32. </view>
  33. <u-toast ref="uToast"></u-toast>
  34. </u-popup>
  35. </template>
  36. <script>
  37. import myCard from './myCard.vue';
  38. import {
  39. producetaskrulerecordQueryRecordWorkOrderPage,
  40. batchRevokeOrder,
  41. } from '@/api/recordRules/index';
  42. export default {
  43. components: {
  44. myCard
  45. },
  46. props: {
  47. pageName: {
  48. type: String,
  49. default: 'productionRecords',
  50. },
  51. },
  52. data() {
  53. return {
  54. visible: false,
  55. revokeLoading: false,
  56. planCode: 0,
  57. selectedIds: [], // 多选选中的id数组
  58. workOrderList: [],
  59. page: 1,
  60. size: 10,
  61. isEnd: false,
  62. loading: false,
  63. searchForm: {
  64. keyword: '',
  65. productLineId: '',
  66. teamId: '',
  67. status: '',
  68. },
  69. dateRange: [],
  70. teamList: [],
  71. productLineList: [],
  72. statusList: [{
  73. value: 0,
  74. label: '未报工'
  75. },
  76. {
  77. value: 1,
  78. label: '执行中'
  79. },
  80. {
  81. value: 2,
  82. label: '已执行'
  83. },
  84. ],
  85. // myCard的列配置(与原来表格列对应)
  86. cardColumns: [
  87. [{
  88. label: '计划单号',
  89. prop: 'planCode',
  90. className: 'perce100'
  91. }],
  92. [{
  93. label: '记录规则名称',
  94. prop: 'ruleName',
  95. className: 'perce100'
  96. }],
  97. [{
  98. label: '场站名称',
  99. prop: 'productLineName',
  100. className: 'perce50'
  101. },
  102. {
  103. label: '班组',
  104. prop: 'teamName',
  105. className: 'perce50'
  106. },
  107. ],
  108. [{
  109. label: '工单生成时间',
  110. prop: 'createTime',
  111. className: 'perce100'
  112. }],
  113. [{
  114. label: '执行人',
  115. prop: 'executeUsers',
  116. className: 'perce100',
  117. formatter: (row) => row.executeUsers?.map(i => i.userName).join(',') || '',
  118. }],
  119. ],
  120. planTypeList: {
  121. productionRecords: 2,
  122. steamInjectionInspectionRecord: 3,
  123. solidWasteRecord: 4,
  124. qualityTestRecords: 5,
  125. QualityInspection: 7,
  126. boilerOperationRecord: 6,
  127. HaulSlag: 8,
  128. TransportAsh: 9,
  129. },
  130. };
  131. },
  132. created() {
  133. // this.loadTeamList();
  134. // this.loadProductLineList();
  135. },
  136. methods: {
  137. open(planCode) {
  138. this.visible = true;
  139. this.planCode = planCode;
  140. this.selectedIds = [];
  141. this.workOrderList = [];
  142. this.page = 1;
  143. this.isEnd = false;
  144. this.searchForm = {
  145. keyword: '',
  146. productLineId: '',
  147. teamId: '',
  148. status: ''
  149. };
  150. this.dateRange = [];
  151. this.loadWorkOrders();
  152. },
  153. setMode(mode) {
  154. this.selectedIds = [];
  155. },
  156. onCheckboxChange({
  157. checked,
  158. item,
  159. }) {
  160. if (checked) {
  161. this.selectedIds.push(item.id)
  162. } else {
  163. this.selectedIds = this.selectedIds.filter(id => id != item.id)
  164. }
  165. },
  166. async loadWorkOrders() {
  167. if (this.loading || this.isEnd) return;
  168. this.loading = true;
  169. try {
  170. const params = {
  171. pageNum: this.page,
  172. size: this.size,
  173. keyword: this.searchForm.keyword || this.planCode,
  174. productLineId: this.searchForm.productLineId,
  175. teamId: this.searchForm.teamId,
  176. status: this.searchForm.status !== '' ? this.searchForm.status : 1,
  177. planType: this.planTypeList[this.pageName],
  178. };
  179. if (this.dateRange && this.dateRange.length === 2) {
  180. params.createTimeStart = this.dateRange[0];
  181. params.createTimeEnd = this.dateRange[1];
  182. }
  183. const res = await producetaskrulerecordQueryRecordWorkOrderPage(params);
  184. const list = res.list || [];
  185. if (this.page === 1) {
  186. this.workOrderList = list;
  187. } else {
  188. this.workOrderList.push(...list);
  189. }
  190. this.isEnd = list.length < this.size || (this.workOrderList.length >= (res.total || 0));
  191. this.page++;
  192. } catch (error) {
  193. this.$refs.uToast.show({
  194. type: 'error',
  195. message: '加载工单失败'
  196. });
  197. } finally {
  198. this.loading = false;
  199. }
  200. },
  201. handleSearch() {
  202. this.page = 1;
  203. this.workOrderList = [];
  204. this.isEnd = false;
  205. this.loadWorkOrders();
  206. },
  207. loadMore() {
  208. if (!this.isEnd && !this.loading) this.loadWorkOrders();
  209. },
  210. getStatusText(status) {
  211. const map = {
  212. 0: '未报工',
  213. 1: '执行中',
  214. 2: '已执行'
  215. };
  216. return map[status] || '';
  217. },
  218. handleCancel() {
  219. this.visible = false;
  220. this.selectedIds = [];
  221. },
  222. async handleBatchRevoke() {
  223. const ids = this.selectedIds
  224. if (ids.length === 0) {
  225. this.$refs.uToast.show({
  226. type: 'warning',
  227. message: '请至少选择一个工单'
  228. });
  229. return;
  230. }
  231. this.revokeLoading = true;
  232. try {
  233. await batchRevokeOrder(ids);
  234. this.$refs.uToast.show({
  235. type: 'success',
  236. message: `成功撤回 ${ids.length} 个工单`
  237. });
  238. this.visible = false;
  239. this.$emit('refresh');
  240. } catch (error) {
  241. console.log(error)
  242. this.$refs.uToast.show({
  243. type: 'error',
  244. message: '撤回失败,请重试'
  245. });
  246. } finally {
  247. this.revokeLoading = false;
  248. }
  249. },
  250. },
  251. };
  252. </script>
  253. <style lang="scss" scoped>
  254. .batch-revoke-popup {
  255. .popup-content {
  256. width: 90vw;
  257. max-width: 700px;
  258. height: 85vh;
  259. background: #f5f7fb;
  260. border-radius: 32rpx;
  261. display: flex;
  262. flex-direction: column;
  263. overflow: hidden;
  264. }
  265. .popup-header {
  266. display: flex;
  267. justify-content: space-between;
  268. align-items: center;
  269. padding: 30rpx;
  270. background: #fff;
  271. border-bottom: 2rpx solid #eef2f6;
  272. .popup-title {
  273. font-size: 36rpx;
  274. font-weight: bold;
  275. }
  276. .close-btn {
  277. font-size: 60rpx;
  278. color: #8e9aae;
  279. }
  280. }
  281. .mode-switch {
  282. display: flex;
  283. background: #fff;
  284. padding: 16rpx 30rpx;
  285. border-bottom: 2rpx solid #eef2f6;
  286. .mode-item {
  287. flex: 1;
  288. text-align: center;
  289. font-size: 28rpx;
  290. padding: 12rpx 0;
  291. border-radius: 48rpx;
  292. background: #f5f7fb;
  293. color: #8e9aae;
  294. margin-right: 20rpx;
  295. &.active {
  296. background: $theme-color;
  297. color: #fff;
  298. }
  299. &:last-child {
  300. margin-right: 0;
  301. }
  302. }
  303. }
  304. .search-wrapper {
  305. background: #fff;
  306. padding: 20rpx 30rpx;
  307. border-bottom: 2rpx solid #eef2f6;
  308. .search-form {
  309. display: flex;
  310. flex-wrap: wrap;
  311. gap: 20rpx;
  312. >* {
  313. flex: 1;
  314. min-width: 200rpx;
  315. }
  316. .search_btn {
  317. width: 140rpx;
  318. background: $theme-color;
  319. color: #fff;
  320. border-radius: 48rpx;
  321. }
  322. }
  323. }
  324. .popup-body {
  325. flex: 1;
  326. overflow-y: auto;
  327. padding: 20rpx 24rpx;
  328. }
  329. .empty-tip {
  330. margin-top: 100rpx;
  331. }
  332. .loadmore-text {
  333. text-align: center;
  334. font-size: 26rpx;
  335. color: #aaa;
  336. padding: 24rpx 0 40rpx;
  337. }
  338. .popup-footer {
  339. display: flex;
  340. padding: 20rpx 30rpx 30rpx;
  341. border-top: 2rpx solid #eef2f6;
  342. gap: 20rpx;
  343. background: #fff;
  344. .u-button {
  345. flex: 1;
  346. border-radius: 48rpx;
  347. }
  348. }
  349. }
  350. </style>