index.vue 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312
  1. <template>
  2. <div class="mainContentBox">
  3. <avue-crud
  4. ref="crudRef"
  5. v-model:search="search"
  6. v-loading="loading"
  7. v-model="form"
  8. :data="data"
  9. :option="option"
  10. v-model:page="page"
  11. :permission="permission"
  12. @row-save="createRow"
  13. @row-update="updateRow"
  14. @row-del="deleteRow"
  15. @search-change="searchChange"
  16. @search-reset="resetChange"
  17. @size-change="dataList"
  18. @current-change="dataList"
  19. @selection-change="selectionChange"
  20. >
  21. <template #isImportant="scope">
  22. <el-switch
  23. :active-value="1"
  24. :inactive-value="0"
  25. inline-prompt
  26. active-text="是"
  27. inactive-text="否"
  28. v-model="scope.row.isImportant"
  29. @click="changeItem(scope.row)"
  30. class="ml-2"
  31. style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
  32. />
  33. </template>
  34. <template #menu-left="{ size }">
  35. <el-button
  36. :disabled="toDeleteIds.length < 1"
  37. type="danger"
  38. icon="el-icon-delete"
  39. :size="size"
  40. @click="multipleDelete"
  41. >删除</el-button
  42. >
  43. <el-button
  44. :disabled="toDeleteIds.length < 1"
  45. type="primary"
  46. icon="el-icon-primary"
  47. :size="size"
  48. @click="aps1"
  49. >批量排程</el-button
  50. >
  51. </template>
  52. <template #menu="{ size, row, index }">
  53. <el-button
  54. v-hasPerm="[buttonPermission.PLAN.BTNS.work_order_edit]"
  55. v-if="
  56. row.workOrderState === '0' ||
  57. row.workOrderState === '1' ||
  58. row.workOrderState === '2'
  59. "
  60. type="primary"
  61. link
  62. size="small"
  63. @click="handleEdit(row, 0)"
  64. ><i-ep-edit />编辑
  65. </el-button>
  66. <el-button
  67. @click="aps(row.id)"
  68. icon="el-icon-setting"
  69. text
  70. v-hasPerm="[buttonPermission.PLAN.BTNS.work_order_aps]"
  71. v-if="
  72. row.workOrderState === '0' ||
  73. row.workOrderState === '1' ||
  74. row.workOrderState === '2'
  75. "
  76. type="primary"
  77. :size="size"
  78. >排程</el-button
  79. >
  80. <el-button
  81. icon="el-icon-setting"
  82. text
  83. v-hasPerm="[buttonPermission.PLAN.BTNS.work_order_lock]"
  84. v-if="row.workOrderState === '4'"
  85. @click="lockOrUnLockWorkOrder(row.id, 5)"
  86. type="primary"
  87. :size="size"
  88. >冻结</el-button
  89. >
  90. <el-button
  91. icon="el-icon-setting"
  92. text
  93. v-if="row.workOrderState === '5'"
  94. v-hasPerm="[buttonPermission.PLAN.BTNS.work_order_lock]"
  95. @click="lockOrUnLockWorkOrder(row.id, 4)"
  96. type="primary"
  97. :size="size"
  98. >解冻</el-button
  99. >
  100. <el-button
  101. icon="el-icon-setting"
  102. text
  103. v-if="row.workOrderState === '2'"
  104. @click="distribute(row.id)"
  105. type="primary"
  106. v-hasPerm="[buttonPermission.PLAN.BTNS.work_order_aps]"
  107. :size="size"
  108. >下发</el-button
  109. >
  110. <el-button
  111. icon="el-icon-setting"
  112. text
  113. @click="showSeqPage(row)"
  114. type="primary"
  115. :size="size"
  116. >产品管号</el-button
  117. >
  118. <el-button
  119. icon="el-icon-delete"
  120. text
  121. v-if="row.workOrderState === '3'"
  122. @click="revoke(row.id)"
  123. type="primary"
  124. :size="size"
  125. >撤销</el-button
  126. >
  127. <!-- <el-button
  128. icon="el-icon-setting"
  129. text
  130. @click="showCheckTask(row)"
  131. type="primary"
  132. :size="size"
  133. >检验任务</el-button
  134. > -->
  135. <el-button
  136. icon="el-icon-setting"
  137. text
  138. @click="jumpPage(row.workOrderCode, 2)"
  139. type="primary"
  140. :size="size"
  141. >生产准备</el-button
  142. >
  143. <el-button
  144. icon="el-icon-setting"
  145. text
  146. @click="showProExcel(row.id)"
  147. type="primary"
  148. v-if="row.workOrderState > 3"
  149. :size="size"
  150. >生产随工单</el-button
  151. >
  152. <el-button
  153. icon="el-icon-setting"
  154. text
  155. @click="exportDataZip(row.id)"
  156. type="primary"
  157. v-if="row.workOrderState === '6'"
  158. :size="size"
  159. >生产数据包</el-button
  160. >
  161. <el-button
  162. icon="el-icon-setting"
  163. text
  164. @click="scrap(row.id)"
  165. type="primary"
  166. v-if="row.workOrderState === '4'"
  167. :size="size"
  168. v-hasPerm="[buttonPermission.PLAN.BTNS.work_order_scrap]"
  169. >报废</el-button
  170. >
  171. <!-- <el-button
  172. icon="el-icon-notebook"
  173. text
  174. v-if="row.workOrderState === '6'"
  175. @click="workOrderData(row.id)"
  176. type="primary"
  177. v-hasPerm="[buttonPermission.PLAN.BTNS.work_order_data]"
  178. :size="size"
  179. >生成生产随工单</el-button
  180. >-->
  181. <!-- <el-button
  182. icon="el-icon-download"
  183. text
  184. v-if="row.workOrderState === '6'&&row.packageUrl!=='0'"
  185. @click="downloadTemplate('/api/v1/plan/workOrder/zip/'+row.id)"
  186. type="primary"
  187. v-hasPerm="[buttonPermission.PLAN.BTNS.work_order_downLoad]"
  188. :size="size">下载数据包</el-button>-->
  189. </template>
  190. </avue-crud>
  191. <el-dialog
  192. v-model="dialog.visible"
  193. :title="dialog.title"
  194. width="80%"
  195. @close="dialog.visible = false"
  196. >
  197. <order-page queryType="1" @order-info="orderInfo" />
  198. </el-dialog>
  199. <el-dialog
  200. v-model="dialog1.visible"
  201. :title="dialog1.title"
  202. width="80%"
  203. @close="dialog1.visible = false"
  204. >
  205. <choice-route-page
  206. :processRouteType="processRouteType"
  207. :material-code="form.materialCode"
  208. @route-info="routeInfo"
  209. />
  210. </el-dialog>
  211. <el-dialog
  212. v-model="dialog2.visible"
  213. :title="dialog2.title"
  214. width="80%"
  215. @close="dialog2.visible = false"
  216. >
  217. <choice-workshop-page @work-shop-info="workShopInfo" />
  218. </el-dialog>
  219. <el-dialog
  220. v-model="dialog3.visible"
  221. :title="dialog3.title"
  222. width="80%"
  223. @close="dialog3.visible = false"
  224. >
  225. <choice-line-page
  226. :parentCode="form.workshopCode"
  227. :materialCode="form.materialCode"
  228. @line-info="lineInfo"
  229. />
  230. </el-dialog>
  231. <el-dialog
  232. v-model="dialog4.visible"
  233. :title="dialog4.title"
  234. width="950px"
  235. @close="dialog4.visible = false"
  236. >
  237. <work-order-seq :workOrderInfo="form" />
  238. </el-dialog>
  239. <el-dialog
  240. v-model="dialog6.visible"
  241. :append-to-body="true"
  242. :title="dialog6.title"
  243. width="1100px"
  244. @close="dialog6.visible = false"
  245. >
  246. <check-task :workOrderInfo="form" />
  247. </el-dialog>
  248. <el-dialog
  249. v-model="dialog5.visible"
  250. :title="dialog5.title"
  251. width="450px"
  252. @close="dialog5.visible = false"
  253. >
  254. <el-form
  255. ref="dataFormRef"
  256. :model="formData"
  257. :rules="rules"
  258. label-width="150px"
  259. >
  260. <el-form-item label="排程时间" prop="apsTime">
  261. <el-date-picker
  262. v-model="formData.apsTime"
  263. type="date"
  264. style="width: 200px"
  265. :disabled-date="disabledDate"
  266. placeholder="请选择时间"
  267. format="YYYY/MM/DD"
  268. value-format="YYYY-MM-DD"
  269. />
  270. <!-- <el-input width="250px" v-model="formData.apsTime" type="date" format="YYYY-MM-DD" value-format="YYYY-MM-DD"/>-->
  271. </el-form-item>
  272. <el-form-item label="优先级" prop="priority" v-if="apsType === 1">
  273. <el-select
  274. v-model="formData.priority"
  275. placeholder="排程类型"
  276. style="width: 200px"
  277. >
  278. <el-option
  279. v-for="item in apsPriority"
  280. :label="item.dictLabel"
  281. :value="item.dictValue"
  282. :key="item.dictValue"
  283. />
  284. </el-select>
  285. </el-form-item>
  286. <el-form-item label="排程类型" prop="apsModel">
  287. <el-select
  288. v-model="formData.apsModel"
  289. placeholder="排程类型"
  290. style="width: 200px"
  291. >
  292. <el-option
  293. v-for="item in schedulingTypes"
  294. :label="item.dictLabel"
  295. :value="item.dictValue"
  296. :key="item.dictValue"
  297. />
  298. </el-select>
  299. </el-form-item>
  300. </el-form>
  301. <template #footer>
  302. <div class="dialog-footer">
  303. <el-button type="primary" @click="handleSubmit">确 定</el-button>
  304. <el-button @click="dialog5.visible = false">取 消</el-button>
  305. </div>
  306. </template>
  307. </el-dialog>
  308. <!-- 生产随工单 -->
  309. <el-dialog
  310. v-model="workOderShow"
  311. :title="updateTitle"
  312. @close="workOderShow = false"
  313. append-to-body
  314. fullscreen
  315. >
  316. <ExcelShowingSGD :data="ExDataObj" @close="closeShow" />
  317. </el-dialog>
  318. <el-dialog
  319. v-model="dialog7.visible"
  320. :title="dialog7.title"
  321. width="950px"
  322. @close="dialog7.visible = false"
  323. >
  324. <work-order-page
  325. queryType="2"
  326. @order-info="workOrderInfoClick"
  327. multipleKey="workOrderCode"
  328. />
  329. </el-dialog>
  330. </div>
  331. </template>
  332. <script setup>
  333. import { ref, getCurrentInstance } from "vue";
  334. import { useCrud } from "@/hooks/userCrud";
  335. import buttonPermission from "@/common/configs/buttonPermission";
  336. import ExcelShowingSGD from "./components/ExcelShowingSGD.vue";
  337. import {
  338. apsWorkOrder,
  339. distributeWorkOrder,
  340. revokeWorkOrder,
  341. lockWorkOrder,
  342. exportOrder,
  343. excelWorkOrder,
  344. workOrderGroupStr, scrapWorkOrder,
  345. } from "@/api/order";
  346. import { useCommonStoreHook } from "@/store";
  347. import dictDataUtil from "@/common/configs/dictDataUtil";
  348. import ChoiceRoutePage from "./components/choice-route-page.vue";
  349. import ChoiceWorkshopPage from "./components/choice-workshop-page.vue";
  350. import WorkOrderSeq from "./components/work-order-seq.vue";
  351. import CheckTask from "./components/check-task.vue";
  352. import { checkPerm } from "@/directive/permission";
  353. import { queryDictDataByType } from "@/api/system/dict";
  354. import { getProExcel } from "@/api/excel";
  355. import { exportDataInfo } from "@/api/order";
  356. import { getJobInfo, getWorkshopData } from "@/api/report";
  357. import ButtonPermKeys from "@/common/configs/buttonPermission";
  358. import { updateWorkOrderInfo } from "@/api/plan";
  359. import {ElMessageBox} from "element-plus";
  360. const { isShowTable, tableType } = toRefs(useCommonStoreHook());
  361. const updateTitle = ref("生产随工单");
  362. const workshopName = ref("");
  363. const router = useRouter();
  364. const workOderShow = ref(false);
  365. const ExDataObj = ref({});
  366. const excelData = ref([]);
  367. const showProExcel = async (id) => {
  368. const { data, code } = await getProExcel(id);
  369. if (code == "200") {
  370. ExDataObj.value = data;
  371. workOderShow.value = true;
  372. } else {
  373. ExDataObj.value = {};
  374. workOderShow.value = false;
  375. }
  376. };
  377. const scrap =(val)=>{
  378. ElMessageBox.confirm("报废后所有操作不可回退, 是否确认报废?", "提示", {
  379. confirmButtonText: "确定",
  380. cancelButtonText: "取消",
  381. type: "warning",
  382. }).then(async () => {
  383. scrapWorkOrder({workOrderId:val}).then(
  384. (res)=>{
  385. if(res.code==='200'){
  386. ElMessage.success("操作成功");
  387. dataList();
  388. }
  389. }
  390. )
  391. });
  392. }
  393. const exportDataZip = async (id) => {
  394. exportDataInfo(1, id).then((response) => {
  395. console.log(response);
  396. try {
  397. const decoder = new TextDecoder("utf-8");
  398. const jsonString = decoder.decode(response.data);
  399. const jsonObject = JSON.parse(jsonString);
  400. const { code, msg } = jsonObject;
  401. if (code != "200") {
  402. ElMessage.error(msg);
  403. }
  404. } catch (e) {
  405. downFile(response);
  406. }
  407. });
  408. };
  409. const downFile = (response) => {
  410. const fileData = response.data;
  411. const fileName = decodeURI(
  412. response.headers["content-disposition"].split(";")[1].split("=")[1]
  413. );
  414. const fileType =
  415. "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8";
  416. const blob = new Blob([fileData], { type: fileType });
  417. const downloadUrl = window.URL.createObjectURL(blob);
  418. const downloadLink = document.createElement("a");
  419. downloadLink.href = downloadUrl;
  420. downloadLink.download = fileName;
  421. document.body.appendChild(downloadLink);
  422. downloadLink.click();
  423. document.body.removeChild(downloadLink);
  424. window.URL.revokeObjectURL(downloadUrl);
  425. };
  426. const toShowExcel = (item) => {
  427. ExDataObj.value = item;
  428. workOderShow.value = true;
  429. };
  430. const closeShow = () => {
  431. workOderShow.value = false;
  432. };
  433. const test = () => {
  434. isShowTable.value = true;
  435. tableType.value = tableType.value == 1 ? 2 : 1;
  436. };
  437. const processRouteType = ref("");
  438. const permission = ref({});
  439. const disabledDate = (time) => {
  440. return time.getTime() < Date.now(); // 8.64e7 毫秒数代表一天
  441. };
  442. const jumpPage = (workOrderCode, type) => {
  443. if (type === 1) {
  444. router.push("/requisition?workOrderCode=" + workOrderCode);
  445. } else {
  446. router.push("/plan/prepare?workOrderCode=" + workOrderCode);
  447. }
  448. };
  449. const dialog = reactive({
  450. title: "订单选择",
  451. visible: false,
  452. });
  453. const dialog1 = reactive({
  454. title: "工艺选择",
  455. visible: false,
  456. });
  457. const dialog2 = reactive({
  458. title: "车间选择",
  459. visible: false,
  460. });
  461. const dialog3 = reactive({
  462. title: "产线选择",
  463. visible: false,
  464. });
  465. const dialog4 = reactive({
  466. title: "产品管号",
  467. visible: false,
  468. });
  469. const dialog5 = reactive({
  470. title: "排程确认",
  471. visible: false,
  472. });
  473. const dialog6 = reactive({
  474. title: "检验任务",
  475. visible: false,
  476. });
  477. const dialog7 = reactive({
  478. title: "前置工单选择",
  479. visible: false,
  480. });
  481. const dialog8 = reactive({
  482. title: "生产随工单列表",
  483. visible: false,
  484. });
  485. const apsType = ref(0);
  486. const aps = (id) => {
  487. apsType.value = 0;
  488. formData.workOrderIds = [id];
  489. dialog5.visible = true;
  490. };
  491. const showSeqPage = (workOrderCode) => {
  492. form.value = workOrderCode;
  493. dialog4.visible = true;
  494. };
  495. const showCheckTask = (workOrderCode) => {
  496. form.value = workOrderCode;
  497. dialog6.visible = true;
  498. };
  499. const distribute = (id) => {
  500. ElMessageBox.confirm("当前操作不可逆,确定下发工单吗?")
  501. .then(() => {
  502. distributeWorkOrder(id).then((data) => {
  503. ElMessage.success(data.msg);
  504. dataList();
  505. });
  506. })
  507. .catch(() => {
  508. // catch error
  509. });
  510. };
  511. const lockOrUnLockWorkOrder = (id, status) => {
  512. let message = status === "4" ? "解冻" : "冻结";
  513. ElMessageBox.confirm("当前操作不可逆,确定" + message + "工单吗?")
  514. .then(() => {
  515. loading.value = true;
  516. lockWorkOrder({ id: id, workOrderState: status }).then((data) => {
  517. loading.value = false;
  518. ElMessage.success(data.msg);
  519. dataList();
  520. });
  521. })
  522. .catch(() => {
  523. // catch error
  524. });
  525. };
  526. const loading = ref(false);
  527. const excelWork = ref({});
  528. const workOrderData = (id) => {
  529. loading.value = true;
  530. excelWork.value.workOrderId = id;
  531. excelWorkOrder(excelWork.value).then((data) => {
  532. if (data.code === "200") {
  533. loading.value = false;
  534. ElMessage.success(data.msg);
  535. dataList();
  536. } else {
  537. loading.value = false;
  538. ElMessage.error(data.msg);
  539. }
  540. });
  541. };
  542. const revoke = (id) => {
  543. ElMessageBox.confirm("当前操作不可逆,确定撤销工单吗?")
  544. .then(() => {
  545. loading.value = true;
  546. revokeWorkOrder(id).then((data) => {
  547. if (data.code === "200") {
  548. loading.value = false;
  549. ElMessage.success(data.msg);
  550. dataList();
  551. } else {
  552. loading.value = false;
  553. ElMessage.error(data.msg);
  554. }
  555. });
  556. })
  557. .catch(() => {
  558. // catch error
  559. });
  560. };
  561. const allData = ref([]);
  562. const getAllData = async () => {
  563. const { data, code } = await getWorkshopData({
  564. pageNo: 1,
  565. pageSize: 999999,
  566. });
  567. allData.value = data.records;
  568. };
  569. const setWorkShop = () => {
  570. allData.value.forEach((item) => {
  571. if (item.name == workshopName.value) {
  572. workShopInfo(item);
  573. }
  574. });
  575. };
  576. const handleEdit = (row, index) => {
  577. workshopName.value = row.workshopName;
  578. crudRef.value && crudRef.value.rowEdit(row, index);
  579. setWorkShop();
  580. };
  581. const aps1 = () => {
  582. apsType.value = 1;
  583. formData.workOrderIds = toDeleteIds;
  584. dialog5.visible = true;
  585. };
  586. const dataFormRef = ref(ElForm);
  587. const schedulingTypes = ref([]);
  588. const apsPriority = ref([]);
  589. const formData = reactive({
  590. apsTime: null,
  591. priority: "1",
  592. apsModel: "0",
  593. workOrderId: 0,
  594. });
  595. const rules = reactive({
  596. priority: [{ required: true, message: "请选择优先级", trigger: "blur" }],
  597. apsTime: [{ required: true, message: "排程时间不能为空", trigger: "blur" }],
  598. apsModel: [{ required: true, message: "排程类型不能为空", trigger: "blur" }],
  599. });
  600. const handleSubmit = () => {
  601. dataFormRef.value.validate((isValid) => {
  602. if (isValid) {
  603. apsWorkOrder(formData).then((data) => {
  604. if (data.code === "200") {
  605. ElMessage.success(data.msg);
  606. dialog5.visible = false;
  607. dataList();
  608. } else {
  609. ElMessage.error(data.msg);
  610. }
  611. });
  612. }
  613. });
  614. };
  615. const workOrderInfoClick = (value) => {
  616. if (value) {
  617. form.value.frontWorkOrderCode = value.join(",");
  618. }
  619. dialog7.visible = false;
  620. };
  621. const orderInfo = (value) => {
  622. form.value.orderCode = value.orderCode;
  623. form.value.orderName = value.orderName;
  624. form.value.materialCode = value.materialCode;
  625. form.value.materialName = value.materialName;
  626. form.value.materialModel = value.materialModel;
  627. form.value.priority = value.priority;
  628. form.value.orderType = value.orderType;
  629. form.value.processRouteId = "";
  630. form.value.processRouteCode = "";
  631. form.value.processRouteName = "";
  632. form.value.processRouteVersion = "";
  633. form.value.productLineId = "";
  634. form.value.productLineName = "";
  635. form.value.workshopName = "";
  636. form.value.workshopCode = "";
  637. form.value.workshopName = "";
  638. dialog.visible = false;
  639. };
  640. const lineInfo = (value) => {
  641. form.value.productLineId = value.id;
  642. form.value.productLineName = value.name;
  643. dialog3.visible = false;
  644. };
  645. const workShopInfo = (value) => {
  646. if (
  647. form.value.workshopCode &&
  648. value.code &&
  649. form.value.workshopCode !== value.code
  650. ) {
  651. form.value.productLineId = "";
  652. form.value.productLineName = "";
  653. }
  654. form.value.workshopName = value.id;
  655. form.value.workshopCode = value.code;
  656. form.value.workshopName = value.name;
  657. dialog2.visible = false;
  658. };
  659. const routeInfo = (value) => {
  660. form.value.processRouteId = value.id;
  661. form.value.processRouteCode = value.processRouteCode;
  662. form.value.processRouteName = value.processRouteName;
  663. form.value.processRouteVersion = value.processRouteVersion;
  664. console.log("ddddd", value.opGroups);
  665. option.value.column.forEach((item) => {
  666. if (item.prop === "opGroup") {
  667. item.dicData = value.opGroups;
  668. item.disabled = false;
  669. }
  670. if (item.prop === "opType") {
  671. item.disabled = false;
  672. }
  673. });
  674. dialog1.visible = false;
  675. };
  676. const opGroupList = ref([]);
  677. // 传入一个url,后面不带/
  678. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  679. useCrud({
  680. src: "/api/v1/plan/workOrder",
  681. });
  682. const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  683. Methords; //增删改查
  684. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  685. const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
  686. const opGroupShow = ref(true);
  687. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  688. const groupStri = ref({});
  689. const switchOp = [
  690. {
  691. label: "否",
  692. value: 0,
  693. },
  694. {
  695. label: "是",
  696. value: 1,
  697. },
  698. ];
  699. // 设置表格列或者其他自定义的option
  700. option.value = Object.assign(option.value, {
  701. searchEnter: true,
  702. delBtn: false,
  703. selection: true,
  704. viewBtn: false,
  705. editBtn: false,
  706. labelWidth: 120,
  707. column: [
  708. {
  709. label: "生产批号",
  710. prop: "workOrderCode",
  711. search: true,
  712. display: false,
  713. width: 125,
  714. overHidden: true,
  715. },
  716. {
  717. label: "订单编号",
  718. prop: "orderCode",
  719. search: true,
  720. width: 125,
  721. overHidden: true,
  722. rules: [
  723. {
  724. required: true,
  725. message: "订单编号不能为空",
  726. trigger: "trigger",
  727. },
  728. ],
  729. click: ({ value, column }) => {
  730. if (column.boxType) {
  731. dialog.visible = true;
  732. }
  733. },
  734. change: ({ value, column }) => {
  735. if (column.boxType) {
  736. if (value != form.value.orderCode) {
  737. dialog.visible = true;
  738. }
  739. }
  740. },
  741. },
  742. {
  743. label: "订单名称",
  744. prop: "orderName",
  745. search: true,
  746. disabled: true,
  747. width: 125,
  748. overHidden: true,
  749. },
  750. {
  751. label: "订单类型",
  752. prop: "orderType",
  753. type: "select", //类型为下拉选择框
  754. width: 100,
  755. rules: [
  756. {
  757. required: true,
  758. message: "订单类型不能为空",
  759. trigger: "trigger",
  760. },
  761. ],
  762. overHidden: true,
  763. dicUrl: dictDataUtil.request_url + dictDataUtil.TYPE_CODE.plan_order_type,
  764. props: {
  765. label: "dictLabel",
  766. value: "dictValue",
  767. },
  768. change: ({ value, column }) => {
  769. if (
  770. form.value.opType &&
  771. form.value.workOrderCode &&
  772. form.value.orderCode
  773. ) {
  774. // 只有新增的时候需要调用,编辑的时候可能只限编辑先工序
  775. if (column.boxType && column.boxType === "add") {
  776. getOrderType(value);
  777. }
  778. }
  779. },
  780. },
  781. {
  782. label: "产品编号",
  783. width: 125,
  784. overHidden: true,
  785. search: true,
  786. disabled: true,
  787. prop: "materialCode",
  788. },
  789. {
  790. label: "产品名称",
  791. width: 125,
  792. overHidden: true,
  793. search: true,
  794. disabled: true,
  795. prop: "materialName",
  796. },
  797. {
  798. label: "产品规格",
  799. width: 125,
  800. search: true,
  801. overHidden: true,
  802. disabled: true,
  803. prop: "materialModel",
  804. },
  805. {
  806. label: "质量等级",
  807. prop: "hOrder",
  808. type: "select", //类型为下拉选择框
  809. width: 100,
  810. overHidden: true,
  811. dicUrl: dictDataUtil.request_url + dictDataUtil.TYPE_CODE.quality_grade,
  812. props: {
  813. label: "dictLabel",
  814. value: "dictValue",
  815. },
  816. rules: [
  817. {
  818. required: true,
  819. message: "质量等级不能为空",
  820. trigger: "trigger",
  821. },
  822. ],
  823. },
  824. {
  825. label: "优先级",
  826. prop: "priority",
  827. display: false,
  828. width: "80",
  829. type: "select", //类型为下拉选择框
  830. dicUrl:
  831. dictDataUtil.request_url + dictDataUtil.TYPE_CODE.plan_order_priority,
  832. props: {
  833. label: "dictLabel",
  834. value: "dictValue",
  835. },
  836. },
  837. {
  838. label: "状态",
  839. prop: "workOrderState",
  840. search: true,
  841. width: "80",
  842. display: false,
  843. type: "select", //类型为下拉选择框
  844. dicUrl:
  845. dictDataUtil.request_url + dictDataUtil.TYPE_CODE.plan_work_order_state,
  846. props: {
  847. label: "dictLabel",
  848. value: "dictValue",
  849. },
  850. },
  851. {
  852. label: "工艺路线",
  853. prop: "processRouteName",
  854. width: 125,
  855. overHidden: true,
  856. rules: [
  857. {
  858. required: true,
  859. message: "工艺路线不能为空",
  860. trigger: "trigger",
  861. },
  862. ],
  863. click: ({ value, column }) => {
  864. if (column.boxType) {
  865. if (!form.value.materialCode) {
  866. ElMessage({
  867. message: "请先选择订单",
  868. type: "warning",
  869. });
  870. return;
  871. }
  872. processRouteType.value = form.value.orderType === "2" ? "FG" : "ZC";
  873. dialog1.visible = true;
  874. }
  875. },
  876. change: ({ value, column }) => {
  877. //form.value.opType = ''
  878. if (column.boxType) {
  879. if (value != form.value.processRouteName) {
  880. dialog1.visible = true;
  881. }
  882. }
  883. },
  884. },
  885. {
  886. label: "工序分组",
  887. prop: "opType",
  888. width: "100",
  889. disabled: true,
  890. type: "select", //类型为下拉选择框
  891. dicUrl: dictDataUtil.request_url + dictDataUtil.TYPE_CODE.op_group,
  892. props: {
  893. label: "dictLabel",
  894. value: "dictValue",
  895. },
  896. click: ({ value, column }) => {
  897. if (column.boxType) {
  898. if (!form.value.orderType) {
  899. ElMessage({
  900. message: "请先选择订单类型",
  901. type: "warning",
  902. });
  903. return;
  904. }
  905. }
  906. },
  907. change: ({ value, column }) => {
  908. option.value.column.forEach((item) => {
  909. if (value) {
  910. if (column.boxType === "edit") {
  911. if (item.prop === "opType") {
  912. item.disabled = false;
  913. }
  914. }
  915. if (item.prop === "frontWorkOrderCode" || item.prop === "opGroup") {
  916. if (value === "2") {
  917. item.display = false;
  918. }
  919. if (item.prop === "opGroup") {
  920. if (value === "1") {
  921. item.display = true;
  922. item.disabled = false;
  923. groupStri.value.workSection = "HGX";
  924. groupStri.value.procecssRouteId = form.value.processRouteId;
  925. workOrderGroupStr(groupStri.value).then((data) => {
  926. opGroupList.value = data.data;
  927. if (item.prop === "opGroup") {
  928. item.dicData = data.data;
  929. }
  930. });
  931. }
  932. if (value === "0") {
  933. item.display = true;
  934. item.disabled = false;
  935. groupStri.value.workSection = "QGX";
  936. groupStri.value.procecssRouteId = form.value.processRouteId;
  937. workOrderGroupStr(groupStri.value).then((data) => {
  938. opGroupList.value = data.data;
  939. if (item.prop === "opGroup") {
  940. item.dicData = data.data;
  941. }
  942. });
  943. }
  944. }
  945. if (item.prop === "frontWorkOrderCode") {
  946. if (value === "1") {
  947. item.display = true;
  948. item.disabled = false;
  949. }
  950. if (value === "0") {
  951. item.display = false;
  952. item.disabled = false;
  953. }
  954. }
  955. }
  956. }
  957. });
  958. // 只有新增的时候需要调用,编辑的时候可能只限编辑先工序
  959. if (column.boxType && column.boxType === "add") {
  960. getOpGroup(value);
  961. }
  962. },
  963. rules: [
  964. {
  965. required: true,
  966. message: "工序分组不能为空",
  967. trigger: "trigger",
  968. },
  969. ],
  970. },
  971. {
  972. label: "是否重要订单",
  973. slot: true,
  974. headerAlign: "center",
  975. prop: "isImportant",
  976. width: 100,
  977. addDisplay: false,
  978. editDisplay: false,
  979. },
  980. {
  981. label: "工单编号",
  982. prop: "workOrderCode",
  983. rules: [
  984. {
  985. required: true,
  986. message: "工单编号不能为空",
  987. trigger: "trigger",
  988. },
  989. ],
  990. },
  991. {
  992. label: "分组标识",
  993. prop: "opGroup",
  994. width: "100",
  995. display: false,
  996. disabled: true,
  997. type: "select", //类型为下拉选择框
  998. dicData: opGroupList.value,
  999. props: {
  1000. label: "name",
  1001. value: "name",
  1002. },
  1003. rules: [
  1004. {
  1005. required: true,
  1006. message: "分组标识不能为空",
  1007. trigger: "trigger",
  1008. },
  1009. ],
  1010. },
  1011. {
  1012. label: "前置工单",
  1013. prop: "frontWorkOrderCode",
  1014. width: "100",
  1015. display: false,
  1016. overHidden: true,
  1017. rules: [
  1018. {
  1019. required: true,
  1020. message: "前置工单不能为空",
  1021. trigger: "trigger",
  1022. },
  1023. ],
  1024. click: ({ value, column }) => {
  1025. if (column.boxType) {
  1026. dialog7.visible = true;
  1027. }
  1028. },
  1029. },
  1030. {
  1031. label: "工艺版本",
  1032. width: 100,
  1033. overHidden: true,
  1034. prop: "processRouteVersion",
  1035. display: false,
  1036. html: true,
  1037. formatter: (val) => {
  1038. return (
  1039. '<b class="el-tag el-tag--success el-tag--light">' +
  1040. val.processRouteVersion +
  1041. "</b>"
  1042. );
  1043. },
  1044. },
  1045. {
  1046. label: "生产车间",
  1047. prop: "workshopName",
  1048. width: 120,
  1049. overHidden: true,
  1050. rules: [
  1051. {
  1052. required: true,
  1053. message: "生产车间不能为空",
  1054. trigger: "trigger",
  1055. },
  1056. ],
  1057. click: ({ value, column }) => {
  1058. if (column.boxType) {
  1059. dialog2.visible = true;
  1060. }
  1061. if (column.boxType == "edit") {
  1062. form.value.productLineName = "";
  1063. }
  1064. },
  1065. change: ({ value, column }) => {
  1066. if (column.boxType) {
  1067. if (value != form.value.workshopName) {
  1068. dialog2.visible = true;
  1069. }
  1070. }
  1071. },
  1072. },
  1073. {
  1074. label: "产线名称",
  1075. prop: "productLineName",
  1076. width: 120,
  1077. overHidden: true,
  1078. rules: [
  1079. {
  1080. required: true,
  1081. message: "产线名称不能为空",
  1082. trigger: "trigger",
  1083. },
  1084. ],
  1085. click: ({ value, column }) => {
  1086. if (column.boxType) {
  1087. if (!form.value.workshopName) {
  1088. ElMessage({
  1089. message: "请先选择生产车间",
  1090. type: "warning",
  1091. });
  1092. return;
  1093. }
  1094. dialog3.visible = true;
  1095. }
  1096. },
  1097. change: ({ value, column }) => {
  1098. if (column.boxType) {
  1099. if (value != form.value.productLineName) {
  1100. dialog3.visible = true;
  1101. }
  1102. }
  1103. },
  1104. },
  1105. /* {
  1106. label: "检验批号",
  1107. prop: "produceCode",
  1108. width: "100",
  1109. },*/
  1110. {
  1111. label: "开始时间",
  1112. prop: "planStartWhen",
  1113. width: 180,
  1114. overHidden: true,
  1115. display: false,
  1116. },
  1117. {
  1118. label: "结束时间",
  1119. prop: "planStartEnd",
  1120. width: 180,
  1121. display: false,
  1122. overHidden: true,
  1123. },
  1124. {
  1125. label: "管号最小值",
  1126. prop: "seqMin",
  1127. type: "number",
  1128. min: 1,
  1129. max: 99999,
  1130. blur: () => {
  1131. countPlanNum();
  1132. },
  1133. rules: [
  1134. {
  1135. required: true,
  1136. message: "管号最小值不能为空",
  1137. trigger: "trigger",
  1138. },
  1139. ],
  1140. },
  1141. {
  1142. label: "管号最大值",
  1143. prop: "seqMax",
  1144. type: "number",
  1145. min: 1,
  1146. max: 99999,
  1147. blur: () => {
  1148. countPlanNum();
  1149. },
  1150. rules: [
  1151. {
  1152. required: true,
  1153. message: "管号最大值不能为空",
  1154. trigger: "trigger",
  1155. },
  1156. ],
  1157. },
  1158. {
  1159. label: "工单数量",
  1160. prop: "planNum",
  1161. width: 85,
  1162. disabled: true,
  1163. },
  1164. {
  1165. label: "检验批号",
  1166. width: 85,
  1167. display: false,
  1168. prop: "checkCode",
  1169. },
  1170. {
  1171. label: "完成数量",
  1172. width: 85,
  1173. display: false,
  1174. prop: "completeNum",
  1175. },
  1176. {
  1177. label: "下线数量",
  1178. width: 85,
  1179. display: false,
  1180. prop: "beforeNum",
  1181. },
  1182. {
  1183. label: "报废数量",
  1184. width: 85,
  1185. display: false,
  1186. prop: "scrapNum",
  1187. },
  1188. // {
  1189. // label: "首检数量",
  1190. // width: 85,
  1191. // prop: "firstCheckNum",
  1192. // value: 0,
  1193. // },
  1194. {
  1195. label: "已检数量",
  1196. width: 85,
  1197. display: false,
  1198. prop: "firstCheckAlreadyNum",
  1199. },
  1200. {
  1201. label: "创建时间",
  1202. width: 180,
  1203. display: false,
  1204. prop: "created",
  1205. },
  1206. {
  1207. label: "创建人",
  1208. width: 90,
  1209. display: false,
  1210. prop: "creator",
  1211. },
  1212. {
  1213. label: "数据包地址",
  1214. width: 90,
  1215. display: false,
  1216. prop: "packageUrl",
  1217. hide: true,
  1218. },
  1219. {
  1220. label: "水汽",
  1221. prop: "waterVapor",
  1222. span: 12,
  1223. type: "switch",
  1224. dicData: switchOp,
  1225. value: 0,
  1226. },
  1227. {
  1228. label: "DPA",
  1229. prop: "dpa",
  1230. span: 12,
  1231. type: "switch",
  1232. dicData: switchOp,
  1233. value: 0,
  1234. },
  1235. {
  1236. label: "备注",
  1237. prop: "remark",
  1238. width: 100,
  1239. overHidden: true,
  1240. minRows: 2, //最小行/最小值
  1241. type: "textarea", //类型为多行文本域框
  1242. maxlength: 20, //最大输入长度
  1243. },
  1244. ],
  1245. });
  1246. onMounted(() => {
  1247. getAllData();
  1248. dataList();
  1249. queryDictDataByType("order_scheduling_type").then((data) => {
  1250. schedulingTypes.value = data.data;
  1251. });
  1252. queryDictDataByType("aps_priority").then((data) => {
  1253. apsPriority.value = data.data;
  1254. });
  1255. permission.value = {
  1256. delBtn: checkPerm(ButtonPermKeys.PLAN.BTNS.work_order_del),
  1257. addBtn: checkPerm(ButtonPermKeys.PLAN.BTNS.work_order_add),
  1258. editBtn: checkPerm(buttonPermission.PLAN.BTNS.work_order_edit),
  1259. };
  1260. });
  1261. // 选择完前工序或者后工序后获取这个
  1262. const getOpGroup = (value) => {
  1263. getJobInfo(form.value.orderCode, value + "", form.value.orderType).then(
  1264. (res) => {
  1265. form.value.workOrderCode = res.data;
  1266. }
  1267. );
  1268. };
  1269. const getOrderType = (value) => {
  1270. getJobInfo(form.value.orderCode, form.value.opType, value + "").then(
  1271. (res) => {
  1272. form.value.workOrderCode = res.data;
  1273. }
  1274. );
  1275. };
  1276. // 输入完最大值和最小值计算工单数量
  1277. const countPlanNum = () => {
  1278. if (form.value.seqMax && form.value.seqMin) {
  1279. form.value.planNum = form.value.seqMax - form.value.seqMin + 1;
  1280. }
  1281. };
  1282. const changeItem = (row) => {
  1283. updateWorkOrderInfo(row).then(() => {
  1284. ElMessage.success("操作成功");
  1285. dataList();
  1286. });
  1287. };
  1288. </script>