index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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:save')"
  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-document"
  100. @click="openHistory(row)"
  101. >
  102. 历史版本
  103. </el-link>
  104. <el-popconfirm
  105. v-if="
  106. row.status != 1 &&
  107. [0, 3].includes(row.approvalStatus) &&
  108. $hasPermission('main:producerouting:delete')
  109. "
  110. class="ele-action"
  111. title="确定要删除当前工序吗?"
  112. @confirm="remove(row)"
  113. >
  114. <template v-slot:reference>
  115. <el-link type="danger" :underline="false" icon="el-icon-delete">
  116. 删除
  117. </el-link>
  118. </template>
  119. </el-popconfirm>
  120. </template>
  121. </ele-pro-table>
  122. </el-card>
  123. <importDialog
  124. :defModule="'producerouting'"
  125. ref="importDialogRef"
  126. :fileUrl="'/main/producerouting/downLoadTemplate'"
  127. fileName="工艺路线模板"
  128. @success="reload"
  129. />
  130. <!-- 编辑弹窗 -->
  131. <user-edit
  132. :visible.sync="showEdit"
  133. :data="current"
  134. @done="reload"
  135. ref="userEdit"
  136. />
  137. <!-- 历史版本弹框 -->
  138. <historyModal ref="historyRefs"></historyModal>
  139. <UserDetail
  140. :visible.sync="detailEdit"
  141. :data="current"
  142. @close="detailEdit = false"
  143. ref="UserDetailRef"
  144. ></UserDetail>
  145. <process-submit-dialog
  146. api-fun-name="purchaseinquiryStatusAPI"
  147. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  148. v-if="processSubmitDialogFlag"
  149. :isNotNeedProcess="true"
  150. ref="processSubmitDialogRef"
  151. @reload="reload"
  152. :apiFunName="'produceroutingRelease'"
  153. ></process-submit-dialog>
  154. </div>
  155. </template>
  156. <script>
  157. import tabMixins from '@/mixins/tableColumnsMixin';
  158. import UserSearch from './components/user-search.vue';
  159. import UserEdit from './components/user-edit.vue';
  160. import UserDetail from './components/user-detail.vue';
  161. import historyModal from './components/historyModal.vue';
  162. import route from '@/api/technology/route';
  163. import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';
  164. import { reviewStatus } from '@/enum/dict';
  165. import importDialog from '@/components/upload/import-dialogNew.vue';
  166. export default {
  167. name: 'technologyRoute',
  168. mixins: [tabMixins],
  169. components: {
  170. UserSearch,
  171. UserEdit,
  172. UserDetail,
  173. historyModal,
  174. processSubmitDialog,
  175. importDialog
  176. },
  177. data() {
  178. return {
  179. isUpdate: false,
  180. // 表格列配置
  181. columns: [
  182. {
  183. columnKey: 'index',
  184. label: '序号',
  185. type: 'index',
  186. width: 55,
  187. align: 'center',
  188. showOverflowTooltip: true,
  189. fixed: 'left'
  190. },
  191. // {
  192. // slot: 'routeType',
  193. // label: '类型',
  194. // align: 'center',
  195. // showOverflowTooltip: true
  196. // },
  197. {
  198. prop: 'code',
  199. label: '工艺路线编码',
  200. showOverflowTooltip: true,
  201. align: 'center',
  202. minWidth: 110,
  203. slot: 'code'
  204. },
  205. {
  206. prop: 'name',
  207. label: '工艺路线名称',
  208. showOverflowTooltip: true,
  209. align: 'center',
  210. minWidth: 110
  211. },
  212. {
  213. prop: 'version',
  214. label: '工艺路线版本',
  215. align: 'center',
  216. showOverflowTooltip: true,
  217. minWidth: 110
  218. },
  219. // {
  220. // prop: 'produceVersionName',
  221. // label: '工艺类型',
  222. // align: 'center',
  223. // showOverflowTooltip: true
  224. // },
  225. {
  226. //修改此prop名称时,请同步修改columnKey属性和下方selectType方法
  227. prop: 'status',
  228. label: '状态',
  229. align: 'center',
  230. slot: 'status',
  231. showOverflowTooltip: true,
  232. minWidth: 110,
  233. filters: [
  234. { text: '草稿', value: -1 },
  235. { text: '失效', value: 0 },
  236. { text: '生效', value: 1 }
  237. ],
  238. filterMultiple: false,
  239. columnKey: 'status'
  240. },
  241. {
  242. prop: 'approvalStatus',
  243. label: '审核状态',
  244. align: 'center',
  245. showOverflowTooltip: true,
  246. minWidth: 100,
  247. formatter: (_row, _column, cellValue) => {
  248. return reviewStatus[_row.approvalStatus];
  249. }
  250. },
  251. {
  252. prop: 'factoriesName',
  253. label: '所属工厂',
  254. align: 'center',
  255. showOverflowTooltip: true
  256. },
  257. {
  258. align: 'center',
  259. prop: 'createTime',
  260. label: '创建时间',
  261. showOverflowTooltip: true,
  262. minWidth: 110
  263. },
  264. {
  265. columnKey: 'action',
  266. label: '操作',
  267. width: 280,
  268. align: 'left',
  269. resizable: false,
  270. slot: 'action'
  271. }
  272. ],
  273. // 表格选中数据
  274. selection: [],
  275. // 当前编辑数据
  276. current: null,
  277. processSubmitDialogFlag: false,
  278. // 是否显示编辑弹窗
  279. showEdit: false,
  280. detailEdit: false,
  281. statusList: [
  282. { label: '草稿', value: -1 },
  283. { label: '失效', value: 0 },
  284. { label: '生效', value: 1 }
  285. ],
  286. loading: false,
  287. cacheKeyUrl: 'fb92f8df-technology-route'
  288. };
  289. },
  290. computed: {
  291. // 是否开启响应式布局
  292. clientEnvironmentId() {
  293. return this.$store.state.user.info.clientEnvironmentId;
  294. }
  295. },
  296. methods: {
  297. selectType(value) {
  298. let where = {};
  299. if (value.status.length > 0) {
  300. where['status'] = value.status[0];
  301. }
  302. this.reload(where);
  303. },
  304. /* 表格数据源 */
  305. async datasource({ page, limit, where, order }) {
  306. const res = await route.list({
  307. ...where,
  308. ...order,
  309. pageNum: page,
  310. size: limit
  311. });
  312. return res;
  313. },
  314. importDialog() {
  315. this.$refs.importDialogRef.open();
  316. },
  317. checkStatus(row) {
  318. let obj = this.statusList.find((it) => it.value == row.status);
  319. return obj.label;
  320. },
  321. /* 刷新表格 */
  322. reload(where) {
  323. this.$refs.table.reload({ page: 1, where: where });
  324. },
  325. /* 打开编辑弹窗 */
  326. openEdit(row) {
  327. this.current = row;
  328. this.showEdit = true;
  329. if (row?.id) {
  330. this.$refs.userEdit.isUpdate = true;
  331. } else {
  332. this.$refs.userEdit.isUpdate = false;
  333. }
  334. this.$refs.userEdit.$refs.form &&
  335. this.$refs.userEdit.$refs.form.clearValidate();
  336. },
  337. /* 打开历史版本 */
  338. openHistory(row) {
  339. this.$refs.historyRefs.open(row);
  340. },
  341. /* 删除 */
  342. remove(row) {
  343. const loading = this.$loading({ lock: true });
  344. route
  345. .delete(row.id)
  346. .then((msg) => {
  347. loading.close();
  348. this.$message.success('删除' + msg);
  349. this.reload();
  350. })
  351. .catch((e) => {
  352. loading.close();
  353. // this.$message.error(e.message);
  354. });
  355. },
  356. /* 批量删除 */
  357. removeBatch() {
  358. if (!this.selection.length) {
  359. this.$message.error('请至少选择一条数据');
  360. return;
  361. }
  362. this.$confirm('确定要删除选中的工序吗?', '提示', {
  363. type: 'warning'
  364. })
  365. .then(() => {
  366. const loading = this.$loading({ lock: true });
  367. producetask
  368. .delete(this.selection.map((d) => d.id))
  369. .then((msg) => {
  370. loading.close();
  371. this.$message.success('删除' + msg);
  372. this.reload();
  373. })
  374. .catch((e) => {
  375. loading.close();
  376. // this.$message.error(e.message);
  377. });
  378. })
  379. .catch(() => {});
  380. },
  381. approve(res) {
  382. this.processSubmitDialogFlag = true;
  383. this.$nextTick(() => {
  384. let params = {
  385. businessId: res.id,
  386. businessKey: 'routing_approve',
  387. formCreateUserId: res.createUserId,
  388. routingId: res.id,
  389. variables: {
  390. businessCode: res.code,
  391. businessName: res.name,
  392. businessType: ' 版本:' + res.version
  393. }
  394. };
  395. this.$refs.processSubmitDialogRef.init(params);
  396. });
  397. },
  398. // 刷新数据
  399. refreshData() {
  400. this.loading = true;
  401. route
  402. .syncRouting()
  403. .then((res) => {
  404. if (res == '0') {
  405. this.loading = false;
  406. this.$message.success('数据刷新成功!');
  407. this.reload();
  408. }
  409. })
  410. .catch((e) => {
  411. this.loading = false;
  412. });
  413. },
  414. openDetail(row) {
  415. this.current = row;
  416. //
  417. // this.$refs.userEdit.datasource(this.current.id);
  418. this.detailEdit = true;
  419. }
  420. }
  421. };
  422. </script>