plan.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. :cache-key="cacheKeyUrl"
  17. autoAmendPage
  18. >
  19. <template v-slot:toolbar>
  20. <el-button
  21. type="primary"
  22. size="mini"
  23. icon="el-icon-plus"
  24. @click="openEdit('add')"
  25. >新建临时计划</el-button
  26. >
  27. </template>
  28. <template v-slot:code="{ row }">
  29. <el-link
  30. type="primary"
  31. :underline="false"
  32. @click="openEdit('detail', row)"
  33. >
  34. {{ row.code }}
  35. </el-link>
  36. </template>
  37. <template v-slot:action="{ row }">
  38. <el-link
  39. type="primary"
  40. :underline="false"
  41. @click="openEdit('edit', row)"
  42. v-if="row.status != 2 && row.status != 3"
  43. >
  44. 修改
  45. </el-link>
  46. <el-link
  47. type="primary"
  48. :underline="false"
  49. v-if="row.status != 2 && row.status != 3"
  50. @click="openEdit('dispatch', row)"
  51. >
  52. 派单
  53. </el-link>
  54. <el-popconfirm
  55. v-if="row.status == 2"
  56. class="ele-action"
  57. title="确定要撤回此条数据吗?"
  58. @confirm="revoke(row.id)"
  59. >
  60. <template v-slot:reference>
  61. <el-link type="primary" :underline="false"> 撤回 </el-link>
  62. </template>
  63. </el-popconfirm>
  64. <el-popconfirm
  65. class="ele-action"
  66. title="确定要删除此条数据吗?"
  67. @confirm="deleteRow(row.id)"
  68. v-if="row.status != 2 && row.status != 3"
  69. >
  70. <template v-slot:reference>
  71. <el-link type="danger" :underline="false"> 删除 </el-link>
  72. </template>
  73. </el-popconfirm>
  74. </template>
  75. </ele-pro-table>
  76. </el-card>
  77. <programRulesDialog
  78. ref="programRulesDialogRef"
  79. @reload="reload"
  80. ></programRulesDialog>
  81. </div>
  82. </template>
  83. <script>
  84. import dictMixins from '@/mixins/dictMixins';
  85. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  86. import {
  87. recordrulesplanPage,
  88. recordrulesplanDelete,
  89. recordrulesplanRevoke
  90. } from '@/api/recordRules/index';
  91. import programRulesDialog from './programRulesDialog.vue';
  92. import patrolSearch from './patrol-search.vue';
  93. export default {
  94. mixins: [dictMixins, tableColumnsMixin],
  95. components: {
  96. programRulesDialog,
  97. patrolSearch
  98. },
  99. data() {
  100. return {
  101. columns: [
  102. {
  103. columnKey: 'index',
  104. label: '序号',
  105. type: 'index',
  106. width: 55,
  107. align: 'center',
  108. showOverflowTooltip: true,
  109. fixed: 'left'
  110. },
  111. {
  112. prop: 'code',
  113. label: '计划单号',
  114. align: 'center',
  115. minWidth: 160,
  116. slot: 'code'
  117. },
  118. {
  119. prop: 'name',
  120. label: '计划名称',
  121. align: 'center',
  122. showOverflowTooltip: true,
  123. minWidth: 110
  124. },
  125. {
  126. prop: 'ruleName',
  127. label: '记录规则名称',
  128. align: 'center',
  129. showOverflowTooltip: true,
  130. minWidth: 110
  131. },
  132. {
  133. prop: '',
  134. label: '记录部门',
  135. align: 'center',
  136. showOverflowTooltip: true,
  137. minWidth: 110,
  138. formatter: (row) => {
  139. if (row.type == 0) {
  140. return [
  141. ...new Set(
  142. (row.executeUser || [])
  143. .map((i) => i.groupName)
  144. .filter((i) => i)
  145. )
  146. ].join(',');
  147. }
  148. return '';
  149. }
  150. },
  151. {
  152. prop: '',
  153. label: '负责人',
  154. align: 'center',
  155. showOverflowTooltip: true,
  156. minWidth: 110,
  157. formatter: (row) => {
  158. if (row.type == 0) {
  159. return row.executeUser.map((i) => i.userName).join(',');
  160. }
  161. return '';
  162. }
  163. },
  164. {
  165. prop: 'executeUser',
  166. label: '班组',
  167. align: 'center',
  168. showOverflowTooltip: true,
  169. minWidth: 110,
  170. formatter: (row) => {
  171. if (row.type == 1) {
  172. return row.executeUser.map((i) => i.teamName).join(',');
  173. }
  174. return '';
  175. }
  176. },
  177. {
  178. prop: 'workshopName',
  179. label: '记录对象',
  180. align: 'center',
  181. showOverflowTooltip: true,
  182. minWidth: 110
  183. },
  184. // {
  185. // prop: 'autoOrder',
  186. // label: '自动派单',
  187. // align: 'center',
  188. // showOverflowTooltip: true,
  189. // minWidth: 110,
  190. // formatter: (row) => {
  191. // return row.autoOrder ? '是' : '否';
  192. // }
  193. // },
  194. {
  195. prop: 'status',
  196. label: '状态',
  197. align: 'center',
  198. showOverflowTooltip: true,
  199. minWidth: 110,
  200. formatter: (row) => {
  201. // 0-未派单,2-执行中,3-已完成,4-已撤回
  202. const statusMap = {
  203. 0: '未派单',
  204. 2: '执行中',
  205. 3: '已完成',
  206. 4: '已撤回'
  207. };
  208. return statusMap[row.status] || '';
  209. }
  210. },
  211. {
  212. prop: 'createUserName',
  213. label: '创建人',
  214. align: 'center',
  215. showOverflowTooltip: true,
  216. minWidth: 110
  217. },
  218. {
  219. prop: 'createTime',
  220. label: '创建时间',
  221. align: 'center',
  222. showOverflowTooltip: true,
  223. minWidth: 110
  224. },
  225. {
  226. columnKey: 'action',
  227. label: '操作',
  228. width: 220,
  229. align: 'center',
  230. resizable: false,
  231. fixed: 'right',
  232. slot: 'action',
  233. showOverflowTooltip: true
  234. }
  235. ],
  236. cacheKeyUrl: 'mes-2511211519-batchrecord-workorder-plan'
  237. };
  238. },
  239. computed: {
  240. seekList() {
  241. return [
  242. {
  243. label: '计划单号',
  244. value: 'code',
  245. type: 'input',
  246. placeholder: '请输入'
  247. },
  248. {
  249. label: '计划名称',
  250. value: 'name',
  251. type: 'input',
  252. placeholder: '请输入'
  253. },
  254. // {
  255. // label: '计划配置单号',
  256. // value: 'configCode',
  257. // type: 'input',
  258. // placeholder: '请输入',
  259. // labelWidth: 110
  260. // },
  261. {
  262. label: '状态',
  263. value: 'status',
  264. type: 'select',
  265. placeholder: '请输入',
  266. planList: [
  267. { value: 0, label: '未派单' },
  268. { value: 2, label: '执行中' },
  269. { value: 3, label: '已完成' },
  270. { value: 4, label: '已撤回' }
  271. ]
  272. },
  273. {
  274. label: '生成时间',
  275. value: 'time',
  276. type: 'date',
  277. dateType: 'daterange'
  278. }
  279. ];
  280. }
  281. },
  282. created() {},
  283. methods: {
  284. // 刷新表格
  285. reload(where = {}) {
  286. this.$refs.table.reload({
  287. where
  288. });
  289. },
  290. /* 表格数据源 */
  291. datasource({ page, limit, where, order }) {
  292. // 参数
  293. const body = {
  294. ...where,
  295. ...order,
  296. pageNum: page,
  297. size: limit
  298. };
  299. return recordrulesplanPage(body);
  300. },
  301. search(where) {
  302. console.log('where', where);
  303. if (where.time) {
  304. where.createTimeStart = where.time[0];
  305. where.createTimeEnd = where.time[1];
  306. where.time = null;
  307. }
  308. this.reload(where);
  309. },
  310. openEdit(type, row = null) {
  311. this.$refs.programRulesDialogRef.open(type, row);
  312. },
  313. async deleteRow(id) {
  314. await recordrulesplanDelete([id]);
  315. this.$message.success('删除成功');
  316. this.reload();
  317. },
  318. async revoke(id) {
  319. await recordrulesplanRevoke({ id });
  320. this.$message.success('撤回成功');
  321. this.reload();
  322. }
  323. }
  324. };
  325. </script>
  326. <style></style>