index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. <template>
  2. <div class="mainContentBox">
  3. <avue-crud
  4. ref="crudRef"
  5. v-model:search="search"
  6. v-model="form"
  7. :data="data"
  8. :option="option"
  9. v-model:page="page"
  10. @row-save="createRow"
  11. @row-update="updateRow"
  12. @search-change="searchChange"
  13. @search-reset="resetChange"
  14. @size-change="dataList"
  15. @current-change="dataList"
  16. @selection-change="selectionChange"
  17. >
  18. <template #usable="{ row }">
  19. <el-tag v-if="row.usable == '1'" type="success">已绑定</el-tag>
  20. <el-tag v-else type="info">未绑定</el-tag>
  21. </template>
  22. <template #productManager-form="{ row }">
  23. <el-select
  24. v-model="form.productManager"
  25. placeholder="产品负责人"
  26. filterable
  27. >
  28. <el-option
  29. v-for="item in userList"
  30. :key="item.userName"
  31. :label="item.userName"
  32. :value="item.userName"
  33. />
  34. </el-select>
  35. </template>
  36. <!-- :disabled="row.usable == '1' ? false : true" -->
  37. <!--<template #menu-right="{}">
  38. <el-dropdown split-button
  39. >导入
  40. <template #dropdown>
  41. <el-dropdown-menu>
  42. <el-dropdown-item
  43. @click="downloadTemplate('/api/v1/op/route/template')"
  44. >
  45. <i-ep-download />下载模板
  46. </el-dropdown-item>
  47. <el-dropdown-item @click="importExcelData">
  48. <i-ep-top />导入数据
  49. </el-dropdown-item>
  50. </el-dropdown-menu>
  51. </template>
  52. </el-dropdown>
  53. </template>-->
  54. <template #menu="{ row }">
  55. <el-button
  56. link
  57. type="primary"
  58. icon="el-icon-edit"
  59. v-if="row.usable === 0"
  60. @click="doEdit(row, index)"
  61. >编辑</el-button
  62. >
  63. <el-button
  64. link
  65. type="primary"
  66. icon="el-icon-edit"
  67. v-else
  68. @click="showProductManager(row, index)"
  69. >编辑</el-button
  70. >
  71. <el-button
  72. link
  73. type="danger"
  74. icon="el-icon-edit"
  75. v-if="row.usable === 0"
  76. @click="deleteRow(row, index)"
  77. >删除</el-button
  78. >
  79. <el-button
  80. link
  81. icon="el-icon-copy-document"
  82. :disabled="false"
  83. @click="copyRow(row)"
  84. >复制</el-button
  85. >
  86. <el-button link icon="el-icon-copy-document" @click="bindProcess(row)"
  87. >绑定</el-button
  88. >
  89. </template>
  90. </avue-crud>
  91. <CommonTable
  92. ref="ctableRef"
  93. tableTitle="添加产品"
  94. tableType="MARTERIAL"
  95. @selected-sure="onSelectedFinish"
  96. />
  97. <CommonTable
  98. ref="commonRef"
  99. tableTitle="选择通用工艺"
  100. tableType="ROUTE_COMMON"
  101. @selected-sure="onCommonFinish"
  102. />
  103. <ExcelUpload ref="uploadRef" @finished="uploadFinished" />
  104. <el-dialog
  105. v-model="centerDialogVisible"
  106. title="重命名"
  107. width="500"
  108. align-center
  109. >
  110. <el-form :model="tmpForm" label-width="auto" style="max-width: 800px">
  111. <el-row>
  112. <el-col :span="12">
  113. <el-form-item label="工艺路线编号">
  114. <el-input v-model="tmpForm.processRouteCode" />
  115. </el-form-item>
  116. </el-col>
  117. <el-col :span="12">
  118. <el-form-item label="工艺路线名称">
  119. <el-input v-model="tmpForm.processRouteName" />
  120. </el-form-item>
  121. </el-col>
  122. </el-row>
  123. </el-form>
  124. <template #footer>
  125. <div class="dialog-footer">
  126. <el-button @click="centerDialogVisible = false">取消</el-button>
  127. <el-button type="primary" @click="renameRoute()"> 确定 </el-button>
  128. </div>
  129. </template>
  130. </el-dialog>
  131. <el-dialog
  132. v-model="productManagerVisible"
  133. title="编辑产品负责人"
  134. width="500"
  135. align-center
  136. >
  137. <el-form
  138. :model="form"
  139. label-width="auto"
  140. style="max-width: 800px"
  141. :rules="rules"
  142. >
  143. <el-form-item label="产品负责人" prop="productManager">
  144. <el-select
  145. v-model="form.productManager"
  146. placeholder="产品负责人"
  147. filterable
  148. >
  149. <el-option
  150. v-for="item in userList"
  151. :key="item.userName"
  152. :label="item.userName"
  153. :value="item.userName"
  154. />
  155. </el-select>
  156. </el-form-item>
  157. </el-form>
  158. <template #footer>
  159. <div class="dialog-footer">
  160. <el-button @click="sureCancelProductManager">取消</el-button>
  161. <el-button type="primary" @click="sureToEditProductManager">
  162. 确定
  163. </el-button>
  164. </div>
  165. </template>
  166. </el-dialog>
  167. </div>
  168. </template>
  169. <script setup>
  170. import { ref, getCurrentInstance } from "vue";
  171. import { useCrud } from "@/hooks/userCrud";
  172. import dictDataUtil from "@/common/configs/dictDataUtil";
  173. import { useDictionaryStore } from "@/store";
  174. import { copyRoute, editRouteWith } from "@/api/craft/route/index";
  175. import { getUserList } from "@/api/system/user/index";
  176. // 数据字典相关
  177. const { dicts } = useDictionaryStore();
  178. const sureCancelProductManager = () => {
  179. productManagerVisible.value = false;
  180. dataList();
  181. form.value = {};
  182. };
  183. // 传入一个url,后面不带/
  184. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  185. useCrud({
  186. src: "/api/v1/op/route",
  187. });
  188. const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  189. Methords; //增删改查
  190. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  191. const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
  192. // checkBtnPerm(ButtonPermKeys.PLAN.BTNS.order_add) :permission="permission"
  193. // const permission = reactive({
  194. // delBtn: checkPerm(buttonPermission.PLAN.BTNS.order_del),
  195. // addBtn: checkPerm(buttonPermission.PLAN.BTNS.order_add),
  196. // editBtn: checkPerm(buttonPermission.PLAN.BTNS.order_edit),
  197. // menu: true,
  198. // });
  199. let centerDialogVisible = ref(false);
  200. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  201. const tmpForm = ref({});
  202. // 产品负责人相关
  203. const userList = ref([]);
  204. const currentPMRow = ref({});
  205. const productManagerVisible = ref(false);
  206. const showProductManager = (row, index) => {
  207. productManagerVisible.value = true;
  208. currentPMRow.value = row;
  209. form.value = row;
  210. };
  211. const rules = reactive({
  212. productManager: [
  213. { required: true, message: "产品管理员不能为空", trigger: "blur" },
  214. ],
  215. });
  216. const sureToEditProductManager = () => {
  217. editRouteWith(currentPMRow.value).then(() => {
  218. dataList();
  219. productManagerVisible.value = false;
  220. form.value = {};
  221. });
  222. };
  223. onMounted(() => {
  224. // console.log("crudRef", crudRef)
  225. dataList();
  226. getUserList({}).then((data) => {
  227. userList.value = data.data;
  228. });
  229. });
  230. /**
  231. * 上传excel相关
  232. */
  233. const uploadRef = ref(null);
  234. const uploadFinished = () => {
  235. // 上传完成后的刷新操作
  236. page.currentPage = 1;
  237. dataList();
  238. };
  239. const doEdit = (row, index) => {
  240. row.prodtName1 = row.prodtName;
  241. crudRef.value && crudRef.value.rowEdit(row, index);
  242. };
  243. const importExcelData = () => {
  244. if (uploadRef.value) {
  245. uploadRef.value.show("/api/v1/op/route/import");
  246. }
  247. };
  248. // 选择产品相关
  249. const ctableRef = ref(null);
  250. const commonRef = ref(null);
  251. const onSelectedFinish = (selectedValue) => {
  252. // search.value.prodtName = selectedValue.materialName;
  253. form.value.prodtName = selectedValue.materialName;
  254. form.value.prodtName1 = selectedValue.materialName;
  255. form.value.prodtCode = selectedValue.materialCode;
  256. form.value.prodtModel = selectedValue.spec;
  257. };
  258. const onCommonFinish = (selectedValue) => {
  259. form.value.commonRouteId = selectedValue.id;
  260. form.value.commonRouteName = selectedValue.processRouteName;
  261. form.value.commonRouteCode = selectedValue.processRouteCode;
  262. };
  263. const startChooseProduct = () => {
  264. if (ctableRef.value) {
  265. ctableRef.value.startSelect();
  266. }
  267. };
  268. const startChooseRoute = () => {
  269. if (ctableRef.value) {
  270. commonRef.value.startSelect();
  271. }
  272. };
  273. // 已经绑定了工序的可以复制,跟后端HT商量只传id即可。
  274. const copyRow = (row) => {
  275. option.value.column[4].display = false;
  276. option.value.column[5].display = false;
  277. if (row.usable == 0) {
  278. ElMessage.error("该路线未被绑定!");
  279. return;
  280. }
  281. form.value = Object.assign(form.value, row);
  282. form.value.processRouteVersion = "";
  283. crudRef.value.rowAdd();
  284. };
  285. const renameRoute = () => {
  286. tmpForm.value.id;
  287. tmpForm.value.processRouteCode;
  288. tmpForm.value.processRouteName;
  289. copyRoute(tmpForm.value).then(() => {
  290. tmpForm.value.id = undefined;
  291. tmpForm.value.processRouteCode = undefined;
  292. tmpForm.value.processRouteName = undefined;
  293. page.currentPage = 1;
  294. dataList();
  295. });
  296. centerDialogVisible.value = false;
  297. };
  298. const router = useRouter();
  299. // 绑定工序
  300. const bindProcess = (row) => {
  301. router.push({
  302. path: `/base/craftManagement/bindProcess/${row.id}/${row.prodtCode}`,
  303. });
  304. };
  305. // 设置表格列或者其他自定义的option
  306. option.value = Object.assign(option.value, {
  307. selection: true,
  308. labelWidth: 150,
  309. menuWidth: 250,
  310. delBtn: false,
  311. searchLabelWidth: 110,
  312. editBtn: false,
  313. column: [
  314. {
  315. label: "工艺路线编号",
  316. prop: "processRouteCode",
  317. search: true,
  318. width: 150,
  319. addDisplay: true,
  320. editDisabled: true,
  321. overHidden: true,
  322. display: false,
  323. },
  324. {
  325. label: "工艺路线名称",
  326. prop: "processRouteName",
  327. width: 150,
  328. search: true,
  329. overHidden: true,
  330. rules: [
  331. {
  332. required: true,
  333. message: "工艺路线名称不能为空",
  334. trigger: "blur",
  335. },
  336. ],
  337. },
  338. {
  339. label: "工艺路线类型",
  340. prop: "processRouteType",
  341. minWidth: 120,
  342. search: true,
  343. overHidden: true,
  344. rules: [
  345. {
  346. required: true,
  347. message: "工艺路线类型不能为空",
  348. trigger: "change",
  349. },
  350. ],
  351. type: "select",
  352. dicUrl: dictDataUtil.request_url + dictDataUtil.TYPE_CODE.routing_type,
  353. props: {
  354. label: "dictLabel",
  355. value: "dictValue",
  356. },
  357. },
  358. {
  359. label: "通用工艺id",
  360. prop: "commonRouteId",
  361. addDisplay: false,
  362. editDisplay: false,
  363. hide: true,
  364. width: 150,
  365. overHidden: true,
  366. },
  367. {
  368. label: "通用工艺名字",
  369. prop: "commonRouteName",
  370. editDisplay: false,
  371. width: 150,
  372. overHidden: true,
  373. click: () => {
  374. startChooseRoute();
  375. },
  376. },
  377. {
  378. label: "通用工艺编码",
  379. prop: "commonRouteCode",
  380. disabled: true,
  381. editDisplay: false,
  382. width: 150,
  383. overHidden: true,
  384. },
  385. {
  386. label: "执行文件和标准",
  387. prop: "executeFileStd",
  388. width: 180,
  389. addDisplay: true,
  390. editDisabled: true,
  391. overHidden: true,
  392. rules: [
  393. {
  394. required: true,
  395. message: "执行文件和标准不能为空",
  396. trigger: "blur",
  397. },
  398. ],
  399. },
  400. {
  401. label: "是否查看产品文档",
  402. prop: "documentShow",
  403. hide: true,
  404. type: "select",
  405. display: true,
  406. rules: [
  407. {
  408. required: true,
  409. trigger: "blur",
  410. },
  411. ],
  412. dicData: [
  413. {
  414. label: "是",
  415. value: 1,
  416. },
  417. {
  418. label: "否",
  419. value: 0,
  420. },
  421. ],
  422. value: 0,
  423. },
  424. {
  425. label: "产品名称",
  426. prop: "prodtName",
  427. overHidden: true,
  428. width: 150,
  429. search: true,
  430. editDisplay: false,
  431. addDisplay: false,
  432. rules: [
  433. {
  434. required: true,
  435. message: "请选择产品",
  436. trigger: "blur",
  437. },
  438. ],
  439. },
  440. {
  441. label: "产品名称",
  442. prop: "prodtName1",
  443. overHidden: true,
  444. hide: true,
  445. viewDisplay: false,
  446. width: 150,
  447. rules: [
  448. {
  449. required: true,
  450. message: "请选择产品",
  451. trigger: "blur",
  452. },
  453. ],
  454. readOnly: true,
  455. click: () => {
  456. startChooseProduct();
  457. },
  458. change: ({ value, column }) => {
  459. if (value != form.value.prodtName1) {
  460. startChooseProduct();
  461. }
  462. },
  463. },
  464. {
  465. label: "产品编号",
  466. prop: "prodtCode",
  467. overHidden: true,
  468. search: true,
  469. width: 150,
  470. disabled: true,
  471. },
  472. {
  473. label: "产品负责人",
  474. prop: "productManager",
  475. width: 120,
  476. slot: true,
  477. rules: [
  478. {
  479. required: true,
  480. message: "工艺路线类型不能为空",
  481. trigger: "change",
  482. },
  483. ],
  484. },
  485. {
  486. label: "产品型号",
  487. prop: "prodtModel",
  488. overHidden: true,
  489. search: true,
  490. minWidth: 200,
  491. disabled: true,
  492. },
  493. // 在产品那边绑定了工艺路线才是已绑定
  494. {
  495. label: "路线状态",
  496. prop: "usable",
  497. addDisplay: false,
  498. editDisplay: false,
  499. slot: true,
  500. width: 100,
  501. type: "radio",
  502. dicData: [
  503. {
  504. label: "已绑定",
  505. value: 1,
  506. },
  507. {
  508. label: "未绑定",
  509. value: 0,
  510. },
  511. ],
  512. },
  513. {
  514. label: "启用状态",
  515. prop: "enabled",
  516. addDisplay: false,
  517. // editDisplay: false,
  518. slot: true,
  519. width: 100,
  520. type: "radio",
  521. dicData: [
  522. {
  523. label: "未启用",
  524. value: 1,
  525. },
  526. {
  527. label: "启用",
  528. value: 0,
  529. },
  530. ],
  531. value: 0,
  532. },
  533. // 只有绑定了工序才可以复制。
  534. {
  535. label: "是否可复制",
  536. prop: "usable2",
  537. slot: true,
  538. width: 100,
  539. search: false,
  540. filterable: true,
  541. hide: true,
  542. addDisplay: false,
  543. editDisplay: false,
  544. type: "radio",
  545. dicData: [
  546. {
  547. label: "否",
  548. value: 0,
  549. },
  550. {
  551. label: "是",
  552. value: 1,
  553. },
  554. ],
  555. value: 0,
  556. },
  557. {
  558. label: "版本",
  559. prop: "processRouteVersion",
  560. addDisplay: true,
  561. editDisplay: true,
  562. value: "1.0",
  563. rules: [
  564. {
  565. required: true,
  566. message: "版本不能为空",
  567. trigger: "blur",
  568. },
  569. ],
  570. precision: 1,
  571. },
  572. {
  573. label: "创建人",
  574. prop: "creator",
  575. addDisplay: false,
  576. editDisplay: false,
  577. overHidden: true,
  578. },
  579. {
  580. label: "创建时间",
  581. prop: "created",
  582. addDisplay: false,
  583. editDisplay: false,
  584. width: 150,
  585. overHidden: true,
  586. },
  587. ],
  588. });
  589. </script>