plan.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <!-- <patrolSearch @search="search"></patrolSearch> -->
  5. <seek-page
  6. :seekList="seekList"
  7. @search="search"
  8. :maxLength="4"
  9. style="margin-bottom: 15px"
  10. ></seek-page>
  11. <ele-pro-table
  12. ref="table"
  13. row-key="id"
  14. :columns="columns"
  15. :datasource="datasource"
  16. @columns-change="handleColumnChange"
  17. :cache-key="cacheKeyUrl"
  18. height="calc(100vh - 420px)"
  19. :page-size="defPageSize"
  20. >
  21. <template v-slot:toolbar>
  22. <el-button
  23. type="primary"
  24. size="mini"
  25. icon="el-icon-plus"
  26. @click="openEdit('add')"
  27. >新建临时计划</el-button
  28. >
  29. </template>
  30. <template v-slot:code="{ row }">
  31. <el-link
  32. type="primary"
  33. :underline="false"
  34. @click="openEdit('detail', row)"
  35. >
  36. {{ row.code }}
  37. </el-link>
  38. </template>
  39. <template v-slot:action="{ row }">
  40. <el-link
  41. type="primary"
  42. :underline="false"
  43. @click="openEdit('edit', row)"
  44. v-if="row.status != 2 && row.status != 3"
  45. >
  46. 修改
  47. </el-link>
  48. <el-link
  49. type="primary"
  50. :underline="false"
  51. v-if="row.dispatchType == 1 || (row.status != 2 && row.status != 3)"
  52. @click="openEdit('dispatch', row)"
  53. >
  54. 派单
  55. </el-link>
  56. <el-link
  57. type="primary"
  58. :underline="false"
  59. v-if="row.dispatchType == 1"
  60. @click="openEdit('dispatch', row, 'dispatchAll')"
  61. >
  62. 批量派单
  63. </el-link>
  64. <el-link
  65. type="primary"
  66. :underline="false"
  67. v-if="row.status == 2"
  68. @click="handleRevoke(row)"
  69. >
  70. 撤回
  71. </el-link>
  72. <el-popconfirm
  73. class="ele-action"
  74. title="确定要删除此条数据吗?"
  75. @confirm="deleteRow(row.id)"
  76. v-if="row.status != 2 && row.status != 3"
  77. >
  78. <template v-slot:reference>
  79. <el-link type="danger" :underline="false"> 删除 </el-link>
  80. </template>
  81. </el-popconfirm>
  82. </template>
  83. </ele-pro-table>
  84. </el-card>
  85. <programRulesDialog
  86. ref="programRulesDialogRef"
  87. @reload="reload"
  88. :pageName="pageName"
  89. :planType="planTypeList[pageName]"
  90. ></programRulesDialog>
  91. <batchRevokeDialog
  92. ref="batchRevokeDialogRef"
  93. :pageName="pageName"
  94. :planType="planTypeList[pageName]"
  95. @refresh="reload"
  96. ></batchRevokeDialog>
  97. </div>
  98. </template>
  99. <script>
  100. import dictMixins from '@/mixins/dictMixins';
  101. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  102. import {
  103. recordrulesplanPage,
  104. recordrulesplanDelete,
  105. recordrulesplanRevoke
  106. } from '@/api/recordRules/index';
  107. import programRulesDialog from './programRulesDialog.vue';
  108. import batchRevokeDialog from './batchRevokeDialog.vue';
  109. import { getteampage } from '@/api/main/index.js';
  110. import { getFactoryarea } from '@/api/factoryModel/index';
  111. export default {
  112. mixins: [dictMixins, tableColumnsMixin],
  113. components: {
  114. programRulesDialog,
  115. batchRevokeDialog
  116. },
  117. props: {
  118. pageName: {
  119. type: String,
  120. default: 'productionRecords'
  121. }
  122. },
  123. data() {
  124. return {
  125. planTypeList: {
  126. productionRecords: 2,
  127. steamInjectionInspectionRecord: 3,
  128. solidWasteRecord: 4,
  129. qualityTestRecords: 5,
  130. boilerOperationRecord: 6,
  131. QualityInspection: 7,
  132. HaulSlag: 8,
  133. TransportAsh: 9
  134. },
  135. columns: [
  136. {
  137. columnKey: 'index',
  138. label: '序号',
  139. type: 'index',
  140. width: 55,
  141. align: 'center',
  142. showOverflowTooltip: true,
  143. fixed: 'left'
  144. },
  145. {
  146. prop: 'code',
  147. label: '计划单号',
  148. align: 'center',
  149. minWidth: 160,
  150. slot: 'code'
  151. },
  152. {
  153. prop: 'name',
  154. label: '计划名称',
  155. align: 'center',
  156. showOverflowTooltip: true,
  157. minWidth: 110
  158. },
  159. {
  160. prop: 'ruleName',
  161. label: '记录规则名称',
  162. align: 'center',
  163. showOverflowTooltip: true,
  164. minWidth: 110
  165. },
  166. {
  167. prop: 'productLineName',
  168. label: '场站名称',
  169. align: 'center',
  170. showOverflowTooltip: true,
  171. minWidth: 110
  172. },
  173. {
  174. prop: 'teamName',
  175. label: '班组',
  176. align: 'center',
  177. showOverflowTooltip: true,
  178. minWidth: 110
  179. },
  180. {
  181. prop: '',
  182. label: '部门',
  183. align: 'center',
  184. showOverflowTooltip: true,
  185. minWidth: 110,
  186. formatter: (row) => {
  187. return [
  188. ...new Set(
  189. (row.executeUsers || [])
  190. .map((i) => i.groupName)
  191. .filter((i) => i)
  192. )
  193. ].join(',');
  194. }
  195. },
  196. {
  197. prop: '',
  198. label: '负责人',
  199. align: 'center',
  200. showOverflowTooltip: true,
  201. minWidth: 110,
  202. formatter: (row) => {
  203. return row.executeUsers.map((i) => i.userName).join(',');
  204. }
  205. },
  206. {
  207. prop: 'workshopName',
  208. label: '记录对象',
  209. align: 'center',
  210. showOverflowTooltip: true,
  211. formatter: (row) => {
  212. console.log(row);
  213. if (row.associatedObject == 1) {
  214. return row.workshopName;
  215. } else {
  216. return row.deviceName;
  217. }
  218. },
  219. minWidth: 110
  220. },
  221. {
  222. prop: 'dispatchType',
  223. label: '派单类型',
  224. align: 'center',
  225. showOverflowTooltip: true,
  226. minWidth: 110,
  227. formatter: (row) => {
  228. return row.dispatchType ? '多次' : '单次';
  229. }
  230. },
  231. {
  232. prop: 'status',
  233. label: '状态',
  234. align: 'center',
  235. showOverflowTooltip: true,
  236. minWidth: 110,
  237. formatter: (row) => {
  238. // 0-未派单,2-执行中,3-已完成,4-已撤回
  239. const statusMap = {
  240. 0: '未派单',
  241. 2: '执行中',
  242. 3: '已完成',
  243. 4: '已撤回'
  244. };
  245. return statusMap[row.status] || '';
  246. }
  247. },
  248. {
  249. prop: 'createUserName',
  250. label: '创建人',
  251. align: 'center',
  252. showOverflowTooltip: true,
  253. minWidth: 110
  254. },
  255. {
  256. prop: 'createTime',
  257. label: '创建时间',
  258. align: 'center',
  259. showOverflowTooltip: true,
  260. minWidth: 110
  261. },
  262. {
  263. columnKey: 'action',
  264. label: '操作',
  265. width: 220,
  266. align: 'center',
  267. resizable: false,
  268. fixed: 'right',
  269. slot: 'action',
  270. showOverflowTooltip: true
  271. }
  272. ],
  273. cacheKeyUrl: `pcs-2511241029-${this.pageName + ''}-plan`,
  274. teamList: [],
  275. productLineList: []
  276. };
  277. },
  278. computed: {
  279. seekList() {
  280. return [
  281. {
  282. label: '关键字',
  283. value: 'keyword',
  284. type: 'input',
  285. width: '280px',
  286. placeholder: '计划单号,计划名称,记录规则名称'
  287. },
  288. {
  289. label: '场站',
  290. value: 'productLineId',
  291. type: 'select',
  292. planList: this.productLineList,
  293. placeholder: '请选择'
  294. },
  295. {
  296. label: '班组',
  297. value: 'teamId',
  298. type: 'select',
  299. planList: this.teamList,
  300. placeholder: '请选择'
  301. },
  302. {
  303. label: '状态',
  304. value: 'status',
  305. type: 'select',
  306. placeholder: '请输入',
  307. planList: [
  308. { value: 0, label: '未派单' },
  309. { value: 2, label: '执行中' },
  310. { value: 3, label: '已完成' },
  311. { value: 4, label: '已撤回' }
  312. ]
  313. },
  314. {
  315. label: '创建时间:',
  316. value: 'createTime',
  317. type: 'date',
  318. dateType: 'datetimerange',
  319. placeholder: '',
  320. width: 380,
  321. valueAr: ['createTimeStart', 'createTimeEnd']
  322. }
  323. ];
  324. }
  325. },
  326. created() {
  327. this.requestDict('记录规则类型');
  328. getteampage({
  329. pageNum: 1,
  330. size: -1
  331. }).then((res) => {
  332. this.teamList =
  333. res.list.map((item) => {
  334. return {
  335. value: item.id,
  336. label: item.name
  337. };
  338. }) || [];
  339. });
  340. getFactoryarea({
  341. pageNum: 1,
  342. size: 999,
  343. type: 4
  344. }).then((res) => {
  345. console.log(res, 'res');
  346. this.productLineList =
  347. res.list.map((item) => {
  348. return {
  349. value: item.id,
  350. label: item.name
  351. };
  352. }) || [];
  353. });
  354. },
  355. methods: {
  356. // 刷新表格
  357. reload(where = {}) {
  358. this.$refs.table.reload({
  359. where
  360. });
  361. },
  362. /* 表格数据源 */
  363. datasource({ page, limit, where, order }) {
  364. // 参数
  365. const body = {
  366. ...where,
  367. ...order,
  368. pageNum: page,
  369. size: limit,
  370. planType: this.planTypeList[this.pageName]
  371. };
  372. return recordrulesplanPage(body);
  373. },
  374. search(where) {
  375. console.log('where', where);
  376. if (where.time) {
  377. where.createTimeStart = where.time[0];
  378. where.createTimeEnd = where.time[1];
  379. where.time = null;
  380. }
  381. this.reload(where);
  382. },
  383. openEdit(type, row = null, dispatchType) {
  384. this.$refs.programRulesDialogRef.open(
  385. type,
  386. row,
  387. this.getDictCode(
  388. '记录规则类型',
  389. this.pageName == 'productionRecords'
  390. ? '生产记录'
  391. : this.pageName == 'steamInjectionInspectionRecord'
  392. ? '注汽检查记录'
  393. : this.pageName == 'solidWasteRecord'
  394. ? '固废记录'
  395. : this.pageName == 'qualityTestRecords'
  396. ? '质量检查检测记录'
  397. : this.pageName == 'QualityInspection'
  398. ? '来煤质检记录'
  399. : this.pageName == 'HaulSlag'
  400. ? '拉渣记录'
  401. : this.pageName == 'TransportAsh'
  402. ? '拉灰记录'
  403. : '锅炉运行记录'
  404. ),
  405. dispatchType
  406. );
  407. },
  408. async deleteRow(id) {
  409. await recordrulesplanDelete([id]);
  410. this.$message.success('删除成功');
  411. this.reload();
  412. },
  413. async revoke(id) {
  414. await recordrulesplanRevoke({ id });
  415. this.$message.success('撤回成功');
  416. this.reload();
  417. },
  418. handleRevoke(row) {
  419. if (row.dispatchType == 1) {
  420. // 多次派单,打开批量撤回弹窗
  421. this.$refs.batchRevokeDialogRef.open(row.code);
  422. } else {
  423. // 单次派单,直接撤回
  424. this.$confirm('确定要撤回此条数据吗?', '提示', {
  425. confirmButtonText: '确定',
  426. cancelButtonText: '取消',
  427. type: 'warning'
  428. }).then(() => {
  429. this.revoke(row.id);
  430. }).catch(() => {});
  431. }
  432. }
  433. }
  434. };
  435. </script>
  436. <style></style>