index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <!-- 搜索表单 -->
  5. <user-search @search="reload" />
  6. <!-- 数据表格 -->
  7. <ele-pro-table
  8. ref="table"
  9. :columns="columns"
  10. :datasource="datasource"
  11. :selection.sync="selection"
  12. row-key="id"
  13. :page-size="this.$store.state.tablePageSize"
  14. @columns-change="handleColumnChange"
  15. :cache-key="cacheKeyUrl"
  16. @filter-change="selectType"
  17. >
  18. <!-- 表头工具栏 -->
  19. <template v-slot:toolbar>
  20. <el-button
  21. size="small"
  22. type="primary"
  23. icon="el-icon-plus"
  24. class="ele-btn-icon"
  25. @click="openEdit(null)"
  26. v-if="$hasPermission('main:producerouting:save')"
  27. >新增</el-button
  28. >
  29. <el-button
  30. size="small"
  31. type="primary"
  32. icon="el-icon-refresh-left"
  33. class="ele-btn-icon"
  34. @click="refreshData"
  35. :loading="loading"
  36. v-if="clientEnvironmentId == 1"
  37. >刷新</el-button
  38. >
  39. <el-button
  40. size="small"
  41. type="primary"
  42. icon="el-icon-download"
  43. class="ele-btn-icon"
  44. @click="importDialog"
  45. v-if="$hasPermission('main:producerouting:import')"
  46. >
  47. 导入
  48. </el-button>
  49. </template>
  50. <template v-slot:code="{ row }">
  51. <el-link type="primary" :underline="false" @click="openDetail(row)">
  52. {{ row.code }}</el-link
  53. >
  54. </template>
  55. <!-- 状态列 -->
  56. <template v-slot:status="{ row }">
  57. {{ checkStatus(row) }}
  58. </template>
  59. <template v-slot:routeType="{ row }">
  60. {{
  61. row.routeType == 2
  62. ? '委外'
  63. : row.routeType == 1
  64. ? '生产'
  65. : row.routeType == 3
  66. ? '质检'
  67. : ''
  68. }}
  69. </template>
  70. <!-- 操作列 -->
  71. <template v-slot:action="{ row }">
  72. <el-link
  73. type="primary"
  74. :underline="false"
  75. icon="el-icon-edit"
  76. @click="openEdit(row)"
  77. v-if="
  78. [0, 3].includes(row.approvalStatus) &&
  79. $hasPermission('main:producerouting:update')
  80. "
  81. >
  82. 修改
  83. </el-link>
  84. <el-link
  85. type="primary"
  86. :underline="false"
  87. icon="el-icon-edit"
  88. @click="approve(row)"
  89. v-if="
  90. [0, 3].includes(row.approvalStatus) &&
  91. $hasPermission('main:producerouting:update')
  92. "
  93. >
  94. 发布
  95. </el-link>
  96. <el-link
  97. type="primary"
  98. :underline="false"
  99. icon="el-icon-finished"
  100. @click="alteration(row)"
  101. v-if="row.approvalStatus == 2"
  102. >
  103. 变更
  104. </el-link>
  105. <el-link
  106. type="primary"
  107. :underline="false"
  108. icon="el-icon-document"
  109. @click="openHistory(row)"
  110. >
  111. 历史版本
  112. </el-link>
  113. <el-popconfirm
  114. v-if="
  115. row.status != 1 &&
  116. [0, 3].includes(row.approvalStatus) &&
  117. $hasPermission('main:producerouting:delete')
  118. "
  119. class="ele-action"
  120. title="确定要删除当前工序吗?"
  121. @confirm="remove(row)"
  122. >
  123. <template v-slot:reference>
  124. <el-link type="danger" :underline="false" icon="el-icon-delete">
  125. 删除
  126. </el-link>
  127. </template>
  128. </el-popconfirm>
  129. </template>
  130. </ele-pro-table>
  131. </el-card>
  132. <importDialog
  133. :defModule="'producerouting'"
  134. ref="importDialogRef"
  135. :fileUrl="'/main/producerouting/downLoadTemplate'"
  136. fileName="工艺路线模板"
  137. @success="reload"
  138. />
  139. <!-- 编辑弹窗 -->
  140. <user-edit
  141. :visible.sync="showEdit"
  142. :data="current"
  143. @done="reload"
  144. :isUpdate="isUpdate"
  145. ref="userEdit"
  146. />
  147. <!-- 历史版本弹框 -->
  148. <historyModal ref="historyRefs"></historyModal>
  149. <UserDetail
  150. :visible.sync="detailEdit"
  151. :data="current"
  152. @close="detailEdit = false"
  153. ref="UserDetailRef"
  154. ></UserDetail>
  155. <process-submit-dialog
  156. api-fun-name="purchaseinquiryStatusAPI"
  157. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  158. v-if="processSubmitDialogFlag"
  159. :isNotNeedProcess="true"
  160. ref="processSubmitDialogRef"
  161. @reload="reload"
  162. :apiFunName="'produceroutingRelease'"
  163. ></process-submit-dialog>
  164. </div>
  165. </template>
  166. <script>
  167. import tabMixins from '@/mixins/tableColumnsMixin';
  168. import UserSearch from './components/user-search.vue';
  169. import UserEdit from './components/user-edit.vue';
  170. import UserDetail from './components/user-detail.vue';
  171. import historyModal from './components/historyModal.vue';
  172. import route from '@/api/technology/route';
  173. import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';
  174. import { reviewStatus } from '@/enum/dict';
  175. import importDialog from '@/components/upload/import-dialogNew.vue';
  176. export default {
  177. name: 'technologyRoute',
  178. mixins: [tabMixins],
  179. components: {
  180. UserSearch,
  181. UserEdit,
  182. UserDetail,
  183. historyModal,
  184. processSubmitDialog,
  185. importDialog
  186. },
  187. data() {
  188. return {
  189. isUpdate: false,
  190. // 表格列配置
  191. columns: [
  192. {
  193. columnKey: 'index',
  194. label: '序号',
  195. type: 'index',
  196. width: 55,
  197. align: 'center',
  198. showOverflowTooltip: true,
  199. fixed: 'left'
  200. },
  201. // {
  202. // slot: 'routeType',
  203. // label: '类型',
  204. // align: 'center',
  205. // showOverflowTooltip: true
  206. // },
  207. {
  208. prop: 'sort',
  209. label: '排序',
  210. showOverflowTooltip: true,
  211. align: 'center',
  212. width: 110
  213. },
  214. {
  215. prop: 'code',
  216. label: '工艺路线编码',
  217. showOverflowTooltip: true,
  218. align: 'center',
  219. minWidth: 110,
  220. slot: 'code'
  221. },
  222. {
  223. prop: 'name',
  224. label: '工艺路线名称',
  225. showOverflowTooltip: true,
  226. align: 'center',
  227. minWidth: 110
  228. },
  229. {
  230. prop: 'version',
  231. label: '工艺路线版本',
  232. align: 'center',
  233. showOverflowTooltip: true,
  234. minWidth: 110
  235. },
  236. // {
  237. // prop: 'produceVersionName',
  238. // label: '工艺类型',
  239. // align: 'center',
  240. // showOverflowTooltip: true
  241. // },
  242. {
  243. //修改此prop名称时,请同步修改columnKey属性和下方selectType方法
  244. prop: 'status',
  245. label: '状态',
  246. align: 'center',
  247. slot: 'status',
  248. showOverflowTooltip: true,
  249. minWidth: 110,
  250. filters: [
  251. { text: '草稿', value: -1 },
  252. { text: '失效', value: 0 },
  253. { text: '生效', value: 1 }
  254. ],
  255. filterMultiple: false,
  256. columnKey: 'status'
  257. },
  258. {
  259. prop: 'approvalStatus',
  260. label: '审核状态',
  261. align: 'center',
  262. showOverflowTooltip: true,
  263. minWidth: 100,
  264. formatter: (_row, _column, cellValue) => {
  265. return reviewStatus[_row.approvalStatus];
  266. }
  267. },
  268. {
  269. prop: 'factoriesName',
  270. label: '所属工厂',
  271. align: 'center',
  272. showOverflowTooltip: true
  273. },
  274. {
  275. align: 'center',
  276. prop: 'createTime',
  277. label: '创建时间',
  278. showOverflowTooltip: true,
  279. minWidth: 110
  280. },
  281. {
  282. columnKey: 'action',
  283. label: '操作',
  284. width: 280,
  285. align: 'left',
  286. resizable: false,
  287. slot: 'action'
  288. }
  289. ],
  290. // 表格选中数据
  291. selection: [],
  292. // 当前编辑数据
  293. current: null,
  294. processSubmitDialogFlag: false,
  295. // 是否显示编辑弹窗
  296. showEdit: false,
  297. detailEdit: false,
  298. statusList: [
  299. { label: '草稿', value: -1 },
  300. { label: '失效', value: 0 },
  301. { label: '生效', value: 1 }
  302. ],
  303. loading: false,
  304. cacheKeyUrl: 'fb92f8df-technology-route'
  305. };
  306. },
  307. computed: {
  308. // 是否开启响应式布局
  309. clientEnvironmentId() {
  310. return this.$store.state.user.info.clientEnvironmentId;
  311. }
  312. },
  313. methods: {
  314. selectType(value) {
  315. let where = {};
  316. if (value.status.length > 0) {
  317. where['status'] = value.status[0];
  318. }
  319. this.reload(where);
  320. },
  321. /* 表格数据源 */
  322. async datasource({ page, limit, where, order }) {
  323. const res = await route.list({
  324. ...where,
  325. ...order,
  326. pageNum: page,
  327. size: limit
  328. });
  329. return res;
  330. },
  331. importDialog() {
  332. this.$refs.importDialogRef.open();
  333. },
  334. checkStatus(row) {
  335. let obj = this.statusList.find((it) => it.value == row.status);
  336. return obj.label;
  337. },
  338. /* 刷新表格 */
  339. reload(where) {
  340. this.$refs.table.reload({ page: 1, where: where });
  341. },
  342. /* 打开编辑弹窗 */
  343. openEdit(row) {
  344. this.current = row;
  345. this.showEdit = true;
  346. if (row?.id) {
  347. this.$refs.userEdit.isUpdate = true;
  348. } else {
  349. this.$refs.userEdit.isUpdate = false;
  350. }
  351. this.$refs.userEdit.$refs.form &&
  352. this.$refs.userEdit.$refs.form.clearValidate();
  353. },
  354. /* 打开历史版本 */
  355. openHistory(row) {
  356. this.$refs.historyRefs.open(row);
  357. },
  358. /* 删除 */
  359. remove(row) {
  360. const loading = this.$loading({ lock: true });
  361. route
  362. .delete(row.id)
  363. .then((msg) => {
  364. loading.close();
  365. this.$message.success('删除' + msg);
  366. this.reload();
  367. })
  368. .catch((e) => {
  369. loading.close();
  370. // this.$message.error(e.message);
  371. });
  372. },
  373. //变更
  374. alteration(row) {
  375. console.log();
  376. let param = {
  377. id: row.id
  378. };
  379. route
  380. .taskinstanceChange(param)
  381. .then((msg) => {
  382. // loading.close();
  383. this.$message.success('变更' + msg);
  384. this.reload();
  385. })
  386. .catch((e) => {
  387. loading.close();
  388. // this.$message.error(e.message);
  389. });
  390. },
  391. /* 批量删除 */
  392. removeBatch() {
  393. if (!this.selection.length) {
  394. this.$message.error('请至少选择一条数据');
  395. return;
  396. }
  397. this.$confirm('确定要删除选中的工序吗?', '提示', {
  398. type: 'warning'
  399. })
  400. .then(() => {
  401. const loading = this.$loading({ lock: true });
  402. producetask
  403. .delete(this.selection.map((d) => d.id))
  404. .then((msg) => {
  405. loading.close();
  406. this.$message.success('删除' + msg);
  407. this.reload();
  408. })
  409. .catch((e) => {
  410. loading.close();
  411. // this.$message.error(e.message);
  412. });
  413. })
  414. .catch(() => {});
  415. },
  416. approve(res) {
  417. this.processSubmitDialogFlag = true;
  418. this.$nextTick(() => {
  419. let params = {
  420. businessId: res.id,
  421. businessKey: 'routing_approve',
  422. formCreateUserId: res.createUserId,
  423. routingId: res.id,
  424. variables: {
  425. businessCode: res.code,
  426. businessName: res.name,
  427. businessType: ' 版本:' + res.version
  428. }
  429. };
  430. this.$refs.processSubmitDialogRef.init(params);
  431. });
  432. },
  433. // 刷新数据
  434. refreshData() {
  435. this.loading = true;
  436. route
  437. .syncRouting()
  438. .then((res) => {
  439. if (res == '0') {
  440. this.loading = false;
  441. this.$message.success('数据刷新成功!');
  442. this.reload();
  443. }
  444. })
  445. .catch((e) => {
  446. this.loading = false;
  447. });
  448. },
  449. openDetail(row) {
  450. this.current = row;
  451. //
  452. // this.$refs.userEdit.datasource(this.current.id);
  453. this.detailEdit = true;
  454. }
  455. }
  456. };
  457. </script>