index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  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 link type="primary" v-if="row.upgradeVersion==='1'" icon="el-icon-notification" @click="changeLog(row)"
  80. >修改记录</el-button>
  81. <el-button link type="primary" v-if="row.isMain==='0'" icon="el-icon-setting" @click="setMain(row)"
  82. >主路线</el-button>
  83. <el-button
  84. link
  85. icon="el-icon-copy-document"
  86. :disabled="false"
  87. @click="copyRow(row)"
  88. >升版</el-button
  89. >
  90. <el-button link icon="el-icon-copy-document" @click="bindProcessPop(row)"
  91. >绑定</el-button
  92. >
  93. </template>
  94. </avue-crud>
  95. <CommonTable
  96. ref="ctableRef"
  97. tableTitle="添加产品"
  98. tableType="MARTERIAL"
  99. @selected-sure="onSelectedFinish"
  100. />
  101. <CommonTable
  102. ref="commonRef"
  103. tableTitle="选择通用工艺"
  104. tableType="ROUTE_COMMON"
  105. @selected-sure="onCommonFinish"
  106. />
  107. <ExcelUpload ref="uploadRef" @finished="uploadFinished" />
  108. <el-dialog
  109. v-model="centerDialogVisible"
  110. title="重命名"
  111. width="500"
  112. align-center
  113. >
  114. <el-form :model="tmpForm" label-width="auto" style="max-width: 800px">
  115. <el-row>
  116. <el-col :span="12">
  117. <el-form-item label="工艺路线编号">
  118. <el-input v-model="tmpForm.processRouteCode" />
  119. </el-form-item>
  120. </el-col>
  121. <el-col :span="12">
  122. <el-form-item label="工艺路线名称">
  123. <el-input v-model="tmpForm.processRouteName" />
  124. </el-form-item>
  125. </el-col>
  126. </el-row>
  127. </el-form>
  128. <template #footer>
  129. <div class="dialog-footer">
  130. <el-button @click="centerDialogVisible = false">取消</el-button>
  131. <el-button type="primary" @click="renameRoute()"> 确定 </el-button>
  132. </div>
  133. </template>
  134. </el-dialog>
  135. <el-dialog
  136. v-model="productManagerVisible"
  137. title="编辑产品负责人"
  138. width="500"
  139. align-center
  140. >
  141. <el-form
  142. :model="form"
  143. label-width="auto"
  144. style="max-width: 800px"
  145. :rules="rules"
  146. >
  147. <el-form-item label="产品负责人" prop="productManager">
  148. <el-select
  149. v-model="form.productManager"
  150. placeholder="产品负责人"
  151. filterable
  152. >
  153. <el-option
  154. v-for="item in userList"
  155. :key="item.userName"
  156. :label="item.userName"
  157. :value="item.userName"
  158. />
  159. </el-select>
  160. </el-form-item>
  161. </el-form>
  162. <template #footer>
  163. <div class="dialog-footer">
  164. <el-button @click="sureCancelProductManager">取消</el-button>
  165. <el-button type="primary" @click="sureToEditProductManager">
  166. 确定
  167. </el-button>
  168. </div>
  169. </template>
  170. </el-dialog>
  171. <el-dialog
  172. v-model="dialog1.visible"
  173. :title="dialog1.title"
  174. width="900px"
  175. @close="dialog1.visible=false"
  176. :destroy-on-close="true"
  177. >
  178. <RouteChangeLog :targetRouteId="routeDeatil.id" />
  179. </el-dialog>
  180. <el-dialog
  181. v-model="dialog2.visible"
  182. :title="dialog2.title"
  183. width="900px"
  184. @close="dialog2.visible=false"
  185. :destroy-on-close="true"
  186. >
  187. <el-table :data="tableData" style="width: 100%" ref="singleTableRef" highlight-current-row @current-change="handleCurrentChange">
  188. <el-table-column type="index" width="50" />
  189. <el-table-column prop="id" label="id" width="180" v-if="false" />
  190. <el-table-column prop="processRouteName" label="工艺路线名称" width="180" />
  191. <el-table-column prop="processRouteCode" label="工艺路线编码" width="180" />
  192. <el-table-column prop="processRouteVersion" label="版本" />
  193. <el-table-column prop="prodtName" label="产品名称" />
  194. <el-table-column prop="prodtModel" label="产品规格" width="180" />
  195. </el-table>
  196. <template #footer>
  197. <div class="footer">
  198. <el-button type="primary" @click="copyProcess()" :loading="isLoading">复制</el-button>
  199. <el-button type="primary" @click="bindProcess(rowDetail)" :loading="loading">自定义</el-button>
  200. <el-button @click="dialog2.visible=false">取消</el-button>
  201. </div>
  202. </template>
  203. </el-dialog>
  204. </div>
  205. </template>
  206. <script setup>
  207. import { ref, getCurrentInstance } from "vue";
  208. import { useCrud } from "@/hooks/userCrud";
  209. import dictDataUtil from "@/common/configs/dictDataUtil";
  210. import { useDictionaryStore } from "@/store";
  211. import {
  212. copyList,
  213. copyProductRoute,
  214. copyRoute,
  215. editRouteWith,
  216. getMaxRouteVersion,
  217. updateMain
  218. } from "@/api/craft/route/index";
  219. import { getUserList } from "@/api/system/user/index";
  220. import RouteChangeLog from "@/views/base/craftManagement/route/components/routeChangeLog.vue";
  221. import {ElMessageBox} from "element-plus";
  222. const isLoading=ref(false);
  223. const loading=ref(false);
  224. // 数据字典相关
  225. const { dicts } = useDictionaryStore();
  226. const sureCancelProductManager = () => {
  227. productManagerVisible.value = false;
  228. dataList();
  229. form.value = {};
  230. };
  231. const tableData = ref([]);
  232. const currentRow = ref();
  233. const singleTableRef = ref(null);
  234. const handleCurrentChange = (val) => {
  235. currentRow.value = val
  236. }
  237. const setMain = (row) =>{
  238. ElMessageBox.confirm("是否将该工艺路线设置为主路线?", "提示", {
  239. confirmButtonText: "确定",
  240. cancelButtonText: "取消",
  241. type: "warning",}).then(async()=>{
  242. updateMain(row).then(
  243. (data)=>{
  244. ElMessage.success(data.msg);
  245. dataList();
  246. }
  247. )
  248. }
  249. )
  250. }
  251. const dialog1 = ref({
  252. title: "修改记录",
  253. visible: false,
  254. });
  255. const dialog2 = ref({
  256. title: "绑定",
  257. visible: false,
  258. });
  259. const routeData =ref({});
  260. // 传入一个url,后面不带/
  261. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  262. useCrud({
  263. src: "/api/v1/op/route",
  264. afterAdd:(routeData)=>{
  265. if(routeData.sourceRouteId){
  266. router.push({
  267. path: `/base/craftManagement/bindProcess/${routeData.id}/${routeData.prodtCode}`,
  268. });
  269. }
  270. }
  271. });
  272. const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  273. Methords; //增删改查
  274. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  275. const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
  276. // checkBtnPerm(ButtonPermKeys.PLAN.BTNS.order_add) :permission="permission"
  277. // const permission = reactive({
  278. // delBtn: checkPerm(buttonPermission.PLAN.BTNS.order_del),
  279. // addBtn: checkPerm(buttonPermission.PLAN.BTNS.order_add),
  280. // editBtn: checkPerm(buttonPermission.PLAN.BTNS.order_edit),
  281. // menu: true,
  282. // });
  283. const rowDetail = ref({});
  284. let centerDialogVisible = ref(false);
  285. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  286. const tmpForm = ref({});
  287. // 产品负责人相关
  288. const userList = ref([]);
  289. const currentPMRow = ref({});
  290. const productManagerVisible = ref(false);
  291. const showProductManager = (row, index) => {
  292. productManagerVisible.value = true;
  293. currentPMRow.value = row;
  294. form.value = row;
  295. };
  296. const rules = reactive({
  297. productManager: [
  298. { required: true, message: "产品管理员不能为空", trigger: "blur" },
  299. ],
  300. });
  301. const sureToEditProductManager = () => {
  302. editRouteWith(currentPMRow.value).then(() => {
  303. dataList();
  304. productManagerVisible.value = false;
  305. form.value = {};
  306. });
  307. };
  308. const copyProductProject =ref({});
  309. const copyProcess = () =>{
  310. if(!currentRow.value){
  311. ElMessage.error("未选择要复制工艺路线!");
  312. return;
  313. }
  314. isLoading.value = true;
  315. loading.value = true;
  316. copyProductProject.value.sourceId = currentRow.value.id;
  317. copyProductProject.value.targetId = rowDetail.value.id;
  318. copyProductRoute(copyProductProject.value).then(
  319. (data)=>{
  320. if(data.code==='200'){
  321. isLoading.value = false;
  322. loading.value = false;
  323. dialog2.value.visible = false;
  324. dataList();
  325. ElMessage.success(data.msg);
  326. }
  327. }
  328. ).finally(()=>{
  329. isLoading.value = false;
  330. loading.value = false;
  331. })
  332. }
  333. onMounted(() => {
  334. // console.log("crudRef", crudRef)
  335. dataList();
  336. getUserList({}).then((data) => {
  337. userList.value = data.data;
  338. });
  339. });
  340. /**
  341. * 上传excel相关
  342. */
  343. const uploadRef = ref(null);
  344. const uploadFinished = () => {
  345. // 上传完成后的刷新操作
  346. page.currentPage = 1;
  347. dataList();
  348. };
  349. const routeDeatil = ref({});
  350. const changeLog = (row) => {
  351. routeDeatil.value = row;
  352. dialog1.value.visible = true;
  353. }
  354. const doEdit = (row, index) => {
  355. row.prodtName1 = row.prodtName;
  356. crudRef.value && crudRef.value.rowEdit(row, index);
  357. };
  358. const importExcelData = () => {
  359. if (uploadRef.value) {
  360. uploadRef.value.show("/api/v1/op/route/import");
  361. }
  362. };
  363. // 选择产品相关
  364. const ctableRef = ref(null);
  365. const commonRef = ref(null);
  366. const onSelectedFinish = (selectedValue) => {
  367. // search.value.prodtName = selectedValue.materialName;
  368. form.value.prodtName = selectedValue.materialName;
  369. form.value.prodtName1 = selectedValue.materialName;
  370. form.value.prodtCode = selectedValue.materialCode;
  371. form.value.prodtModel = selectedValue.spec;
  372. };
  373. const onCommonFinish = (selectedValue) => {
  374. form.value.commonRouteId = selectedValue.id;
  375. form.value.commonRouteName = selectedValue.processRouteName;
  376. form.value.commonRouteCode = selectedValue.processRouteCode;
  377. };
  378. const startChooseProduct = () => {
  379. if (ctableRef.value) {
  380. ctableRef.value.startSelect();
  381. }
  382. };
  383. const startChooseRoute = () => {
  384. if (ctableRef.value) {
  385. commonRef.value.startSelect();
  386. }
  387. };
  388. // 已经绑定了工序的可以复制,跟后端HT商量只传id即可。
  389. const copyRow = (row) => {
  390. option.value.column.forEach((item)=>{
  391. if(item.prop==="commonRouteCode"||item.prop==="commonRouteName"){
  392. item.display=false;
  393. }
  394. }
  395. );
  396. if (row.usable == 0) {
  397. ElMessage.error("该路线未被绑定!");
  398. return;
  399. }
  400. getMaxRouteVersion(row.prodtCode).then((data)=>{
  401. if(data.code==='200'){
  402. form.value = Object.assign(form.value, row);
  403. form.value.processRouteVersion ='';
  404. if(data.data){
  405. form.value.processRouteVersion =(parseFloat(data.data)+1).toFixed(1);
  406. }
  407. form.value.prodtName1 = row.prodtName;
  408. crudRef.value.rowAdd();
  409. }
  410. }
  411. )
  412. };
  413. const renameRoute = () => {
  414. tmpForm.value.id;
  415. tmpForm.value.processRouteCode;
  416. tmpForm.value.processRouteName;
  417. copyRoute(tmpForm.value).then(() => {
  418. tmpForm.value.id = undefined;
  419. tmpForm.value.processRouteCode = undefined;
  420. tmpForm.value.processRouteName = undefined;
  421. page.currentPage = 1;
  422. dataList();
  423. });
  424. centerDialogVisible.value = false;
  425. };
  426. const router = useRouter();
  427. // 绑定工序
  428. const bindProcess = (row) => {
  429. router.push({
  430. path: `/base/craftManagement/bindProcess/${row.id}/${row.prodtCode}`,
  431. });
  432. };
  433. const bindProcessPop = (row) => {
  434. if(row.routeData){
  435. router.push({
  436. path: `/base/craftManagement/bindProcess/${row.id}/${row.prodtCode}`,
  437. });
  438. return;
  439. }
  440. copyList(row).then(
  441. (data)=>{
  442. tableData.value = data.data;
  443. console.log(tableData.value);
  444. if(!tableData.value||tableData.value.length==0){
  445. router.push({
  446. path: `/base/craftManagement/bindProcess/${row.id}/${row.prodtCode}`,
  447. });
  448. return;
  449. }
  450. rowDetail.value = row;
  451. dialog2.value.visible = true;
  452. }
  453. )
  454. };
  455. // 设置表格列或者其他自定义的option
  456. option.value = Object.assign(option.value, {
  457. searchEnter: true,
  458. selection: true,
  459. labelWidth: 150,
  460. menuWidth: 250,
  461. delBtn: false,
  462. searchLabelWidth: 110,
  463. editBtn: false,
  464. rowParentKey: "mainCode",
  465. column: [
  466. {
  467. label: "工艺路线名称",
  468. prop: "processRouteName",
  469. width: 150,
  470. search: true,
  471. overHidden: true,
  472. rules: [
  473. {
  474. required: true,
  475. message: "工艺路线名称不能为空",
  476. trigger: "blur",
  477. },
  478. ],
  479. },
  480. {
  481. label: "工艺路线编号",
  482. prop: "processRouteCode",
  483. search: true,
  484. width: 150,
  485. addDisplay: true,
  486. editDisabled: true,
  487. overHidden: true,
  488. display: false,
  489. },
  490. {
  491. label: "工艺路线类型",
  492. prop: "processRouteType",
  493. minWidth: 120,
  494. search: true,
  495. overHidden: true,
  496. rules: [
  497. {
  498. required: true,
  499. message: "工艺路线类型不能为空",
  500. trigger: "change",
  501. },
  502. ],
  503. type: "select",
  504. dicUrl: dictDataUtil.request_url + dictDataUtil.TYPE_CODE.routing_type,
  505. props: {
  506. label: "dictLabel",
  507. value: "dictValue",
  508. },
  509. },
  510. {
  511. label: "通用工艺id",
  512. prop: "commonRouteId",
  513. addDisplay: false,
  514. editDisplay: false,
  515. hide: true,
  516. width: 150,
  517. overHidden: true,
  518. },
  519. {
  520. label: "通用工艺名字",
  521. prop: "commonRouteName",
  522. editDisplay: false,
  523. width: 150,
  524. overHidden: true,
  525. click: () => {
  526. startChooseRoute();
  527. },
  528. },
  529. {
  530. label: "通用工艺编码",
  531. prop: "commonRouteCode",
  532. disabled: true,
  533. editDisplay: false,
  534. width: 150,
  535. overHidden: true,
  536. },
  537. {
  538. label: "执行文件和标准",
  539. prop: "executeFileStd",
  540. width: 180,
  541. addDisplay: true,
  542. editDisabled: true,
  543. overHidden: true,
  544. rules: [
  545. {
  546. required: true,
  547. message: "执行文件和标准不能为空",
  548. trigger: "blur",
  549. },
  550. ],
  551. },
  552. {
  553. label: "是否查看产品文档",
  554. prop: "documentShow",
  555. hide: true,
  556. type: "select",
  557. display: true,
  558. rules: [
  559. {
  560. required: true,
  561. trigger: "blur",
  562. },
  563. ],
  564. dicData: [
  565. {
  566. label: "是",
  567. value: 1,
  568. },
  569. {
  570. label: "否",
  571. value: 0,
  572. },
  573. ],
  574. value: 0,
  575. },
  576. {
  577. label: "产品名称",
  578. prop: "prodtName",
  579. overHidden: true,
  580. width: 150,
  581. search: true,
  582. editDisplay: false,
  583. addDisplay: false,
  584. rules: [
  585. {
  586. required: true,
  587. message: "请选择产品",
  588. trigger: "blur",
  589. },
  590. ],
  591. },
  592. {
  593. label: "产品名称",
  594. prop: "prodtName1",
  595. overHidden: true,
  596. hide: true,
  597. viewDisplay: false,
  598. width: 150,
  599. rules: [
  600. {
  601. required: true,
  602. message: "请选择产品",
  603. trigger: "blur",
  604. },
  605. ],
  606. readOnly: true,
  607. click: () => {
  608. startChooseProduct();
  609. },
  610. change: ({ value, column }) => {
  611. if (value != form.value.prodtName1) {
  612. startChooseProduct();
  613. }
  614. },
  615. },
  616. {
  617. label: "产品编号",
  618. prop: "prodtCode",
  619. overHidden: true,
  620. search: true,
  621. width: 150,
  622. disabled: true,
  623. },
  624. {
  625. label: "产品负责人",
  626. prop: "productManager",
  627. width: 120,
  628. slot: true,
  629. rules: [
  630. {
  631. required: true,
  632. message: "工艺路线类型不能为空",
  633. trigger: "change",
  634. },
  635. ],
  636. },
  637. {
  638. label: "产品型号",
  639. prop: "prodtModel",
  640. overHidden: true,
  641. search: true,
  642. minWidth: 200,
  643. disabled: true,
  644. },
  645. // 在产品那边绑定了工艺路线才是已绑定
  646. {
  647. label: "路线状态",
  648. prop: "usable",
  649. addDisplay: false,
  650. editDisplay: false,
  651. slot: true,
  652. width: 100,
  653. type: "radio",
  654. dicData: [
  655. {
  656. label: "已绑定",
  657. value: 1,
  658. },
  659. {
  660. label: "未绑定",
  661. value: 0,
  662. },
  663. ],
  664. },
  665. {
  666. label: "启用状态",
  667. prop: "enabled",
  668. addDisplay: false,
  669. // editDisplay: false,
  670. slot: true,
  671. width: 100,
  672. type: "radio",
  673. dicData: [
  674. {
  675. label: "未启用",
  676. value: 1,
  677. },
  678. {
  679. label: "启用",
  680. value: 0,
  681. },
  682. ],
  683. value: 0,
  684. },
  685. // 只有绑定了工序才可以复制。
  686. {
  687. label: "是否可复制",
  688. prop: "usable2",
  689. slot: true,
  690. width: 100,
  691. search: false,
  692. filterable: true,
  693. hide: true,
  694. addDisplay: false,
  695. editDisplay: false,
  696. type: "radio",
  697. dicData: [
  698. {
  699. label: "否",
  700. value: 0,
  701. },
  702. {
  703. label: "是",
  704. value: 1,
  705. },
  706. ],
  707. value: 0,
  708. },
  709. {
  710. label: "版本",
  711. prop: "processRouteVersion",
  712. addDisplay: true,
  713. editDisplay: true,
  714. value: "1.0",
  715. rules: [
  716. {
  717. required: true,
  718. message: "版本不能为空",
  719. trigger: "blur",
  720. },
  721. ],
  722. precision: 1,
  723. },
  724. {
  725. label: "来源版本",
  726. prop: "sourceVersion",
  727. display: false,
  728. },
  729. {
  730. label: "创建人",
  731. prop: "creator",
  732. addDisplay: false,
  733. editDisplay: false,
  734. overHidden: true,
  735. },
  736. {
  737. label: "创建时间",
  738. prop: "created",
  739. addDisplay: false,
  740. editDisplay: false,
  741. width: 150,
  742. overHidden: true,
  743. },
  744. {
  745. label: "主分支编码",
  746. prop: "mainCode",
  747. width: 150,
  748. hide: true,
  749. display: false,
  750. },
  751. ],
  752. });
  753. </script>