index.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305
  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. const { isShowTable, tableType } = toRefs(useCommonStoreHook());
  360. const updateTitle = ref("生产随工单");
  361. const workshopName = ref("");
  362. const router = useRouter();
  363. const workOderShow = ref(false);
  364. const ExDataObj = ref({});
  365. const excelData = ref([]);
  366. const showProExcel = async (id) => {
  367. const { data, code } = await getProExcel(id);
  368. if (code == "200") {
  369. ExDataObj.value = data;
  370. workOderShow.value = true;
  371. } else {
  372. ExDataObj.value = {};
  373. workOderShow.value = false;
  374. }
  375. };
  376. const scrap =(val)=>{
  377. scrapWorkOrder({workOrderId:val}).then(
  378. (res)=>{
  379. if(res.code==='200'){
  380. ElMessage.success("操作成功");
  381. dataList();
  382. }
  383. }
  384. )
  385. }
  386. const exportDataZip = async (id) => {
  387. exportDataInfo(1, id).then((response) => {
  388. console.log(response);
  389. try {
  390. const decoder = new TextDecoder("utf-8");
  391. const jsonString = decoder.decode(response.data);
  392. const jsonObject = JSON.parse(jsonString);
  393. const { code, msg } = jsonObject;
  394. if (code != "200") {
  395. ElMessage.error(msg);
  396. }
  397. } catch (e) {
  398. downFile(response);
  399. }
  400. });
  401. };
  402. const downFile = (response) => {
  403. const fileData = response.data;
  404. const fileName = decodeURI(
  405. response.headers["content-disposition"].split(";")[1].split("=")[1]
  406. );
  407. const fileType =
  408. "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8";
  409. const blob = new Blob([fileData], { type: fileType });
  410. const downloadUrl = window.URL.createObjectURL(blob);
  411. const downloadLink = document.createElement("a");
  412. downloadLink.href = downloadUrl;
  413. downloadLink.download = fileName;
  414. document.body.appendChild(downloadLink);
  415. downloadLink.click();
  416. document.body.removeChild(downloadLink);
  417. window.URL.revokeObjectURL(downloadUrl);
  418. };
  419. const toShowExcel = (item) => {
  420. ExDataObj.value = item;
  421. workOderShow.value = true;
  422. };
  423. const closeShow = () => {
  424. workOderShow.value = false;
  425. };
  426. const test = () => {
  427. isShowTable.value = true;
  428. tableType.value = tableType.value == 1 ? 2 : 1;
  429. };
  430. const processRouteType = ref("");
  431. const permission = ref({});
  432. const disabledDate = (time) => {
  433. return time.getTime() < Date.now(); // 8.64e7 毫秒数代表一天
  434. };
  435. const jumpPage = (workOrderCode, type) => {
  436. if (type === 1) {
  437. router.push("/requisition?workOrderCode=" + workOrderCode);
  438. } else {
  439. router.push("/plan/prepare?workOrderCode=" + workOrderCode);
  440. }
  441. };
  442. const dialog = reactive({
  443. title: "订单选择",
  444. visible: false,
  445. });
  446. const dialog1 = reactive({
  447. title: "工艺选择",
  448. visible: false,
  449. });
  450. const dialog2 = reactive({
  451. title: "车间选择",
  452. visible: false,
  453. });
  454. const dialog3 = reactive({
  455. title: "产线选择",
  456. visible: false,
  457. });
  458. const dialog4 = reactive({
  459. title: "产品管号",
  460. visible: false,
  461. });
  462. const dialog5 = reactive({
  463. title: "排程确认",
  464. visible: false,
  465. });
  466. const dialog6 = reactive({
  467. title: "检验任务",
  468. visible: false,
  469. });
  470. const dialog7 = reactive({
  471. title: "前置工单选择",
  472. visible: false,
  473. });
  474. const dialog8 = reactive({
  475. title: "生产随工单列表",
  476. visible: false,
  477. });
  478. const apsType = ref(0);
  479. const aps = (id) => {
  480. apsType.value = 0;
  481. formData.workOrderIds = [id];
  482. dialog5.visible = true;
  483. };
  484. const showSeqPage = (workOrderCode) => {
  485. form.value = workOrderCode;
  486. dialog4.visible = true;
  487. };
  488. const showCheckTask = (workOrderCode) => {
  489. form.value = workOrderCode;
  490. dialog6.visible = true;
  491. };
  492. const distribute = (id) => {
  493. ElMessageBox.confirm("当前操作不可逆,确定下发工单吗?")
  494. .then(() => {
  495. distributeWorkOrder(id).then((data) => {
  496. ElMessage.success(data.msg);
  497. dataList();
  498. });
  499. })
  500. .catch(() => {
  501. // catch error
  502. });
  503. };
  504. const lockOrUnLockWorkOrder = (id, status) => {
  505. let message = status === "4" ? "解冻" : "冻结";
  506. ElMessageBox.confirm("当前操作不可逆,确定" + message + "工单吗?")
  507. .then(() => {
  508. loading.value = true;
  509. lockWorkOrder({ id: id, workOrderState: status }).then((data) => {
  510. loading.value = false;
  511. ElMessage.success(data.msg);
  512. dataList();
  513. });
  514. })
  515. .catch(() => {
  516. // catch error
  517. });
  518. };
  519. const loading = ref(false);
  520. const excelWork = ref({});
  521. const workOrderData = (id) => {
  522. loading.value = true;
  523. excelWork.value.workOrderId = id;
  524. excelWorkOrder(excelWork.value).then((data) => {
  525. if (data.code === "200") {
  526. loading.value = false;
  527. ElMessage.success(data.msg);
  528. dataList();
  529. } else {
  530. loading.value = false;
  531. ElMessage.error(data.msg);
  532. }
  533. });
  534. };
  535. const revoke = (id) => {
  536. ElMessageBox.confirm("当前操作不可逆,确定撤销工单吗?")
  537. .then(() => {
  538. loading.value = true;
  539. revokeWorkOrder(id).then((data) => {
  540. if (data.code === "200") {
  541. loading.value = false;
  542. ElMessage.success(data.msg);
  543. dataList();
  544. } else {
  545. loading.value = false;
  546. ElMessage.error(data.msg);
  547. }
  548. });
  549. })
  550. .catch(() => {
  551. // catch error
  552. });
  553. };
  554. const allData = ref([]);
  555. const getAllData = async () => {
  556. const { data, code } = await getWorkshopData({
  557. pageNo: 1,
  558. pageSize: 999999,
  559. });
  560. allData.value = data.records;
  561. };
  562. const setWorkShop = () => {
  563. allData.value.forEach((item) => {
  564. if (item.name == workshopName.value) {
  565. workShopInfo(item);
  566. }
  567. });
  568. };
  569. const handleEdit = (row, index) => {
  570. workshopName.value = row.workshopName;
  571. crudRef.value && crudRef.value.rowEdit(row, index);
  572. setWorkShop();
  573. };
  574. const aps1 = () => {
  575. apsType.value = 1;
  576. formData.workOrderIds = toDeleteIds;
  577. dialog5.visible = true;
  578. };
  579. const dataFormRef = ref(ElForm);
  580. const schedulingTypes = ref([]);
  581. const apsPriority = ref([]);
  582. const formData = reactive({
  583. apsTime: null,
  584. priority: "1",
  585. apsModel: "0",
  586. workOrderId: 0,
  587. });
  588. const rules = reactive({
  589. priority: [{ required: true, message: "请选择优先级", trigger: "blur" }],
  590. apsTime: [{ required: true, message: "排程时间不能为空", trigger: "blur" }],
  591. apsModel: [{ required: true, message: "排程类型不能为空", trigger: "blur" }],
  592. });
  593. const handleSubmit = () => {
  594. dataFormRef.value.validate((isValid) => {
  595. if (isValid) {
  596. apsWorkOrder(formData).then((data) => {
  597. if (data.code === "200") {
  598. ElMessage.success(data.msg);
  599. dialog5.visible = false;
  600. dataList();
  601. } else {
  602. ElMessage.error(data.msg);
  603. }
  604. });
  605. }
  606. });
  607. };
  608. const workOrderInfoClick = (value) => {
  609. if (value) {
  610. form.value.frontWorkOrderCode = value.join(",");
  611. }
  612. dialog7.visible = false;
  613. };
  614. const orderInfo = (value) => {
  615. form.value.orderCode = value.orderCode;
  616. form.value.orderName = value.orderName;
  617. form.value.materialCode = value.materialCode;
  618. form.value.materialName = value.materialName;
  619. form.value.materialModel = value.materialModel;
  620. form.value.priority = value.priority;
  621. form.value.orderType = value.orderType;
  622. form.value.processRouteId = "";
  623. form.value.processRouteCode = "";
  624. form.value.processRouteName = "";
  625. form.value.processRouteVersion = "";
  626. form.value.productLineId = "";
  627. form.value.productLineName = "";
  628. form.value.workshopName = "";
  629. form.value.workshopCode = "";
  630. form.value.workshopName = "";
  631. dialog.visible = false;
  632. };
  633. const lineInfo = (value) => {
  634. form.value.productLineId = value.id;
  635. form.value.productLineName = value.name;
  636. dialog3.visible = false;
  637. };
  638. const workShopInfo = (value) => {
  639. if (
  640. form.value.workshopCode &&
  641. value.code &&
  642. form.value.workshopCode !== value.code
  643. ) {
  644. form.value.productLineId = "";
  645. form.value.productLineName = "";
  646. }
  647. form.value.workshopName = value.id;
  648. form.value.workshopCode = value.code;
  649. form.value.workshopName = value.name;
  650. dialog2.visible = false;
  651. };
  652. const routeInfo = (value) => {
  653. form.value.processRouteId = value.id;
  654. form.value.processRouteCode = value.processRouteCode;
  655. form.value.processRouteName = value.processRouteName;
  656. form.value.processRouteVersion = value.processRouteVersion;
  657. console.log("ddddd", value.opGroups);
  658. option.value.column.forEach((item) => {
  659. if (item.prop === "opGroup") {
  660. item.dicData = value.opGroups;
  661. item.disabled = false;
  662. }
  663. if (item.prop === "opType") {
  664. item.disabled = false;
  665. }
  666. });
  667. dialog1.visible = false;
  668. };
  669. const opGroupList = ref([]);
  670. // 传入一个url,后面不带/
  671. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  672. useCrud({
  673. src: "/api/v1/plan/workOrder",
  674. });
  675. const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  676. Methords; //增删改查
  677. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  678. const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
  679. const opGroupShow = ref(true);
  680. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  681. const groupStri = ref({});
  682. const switchOp = [
  683. {
  684. label: "否",
  685. value: 0,
  686. },
  687. {
  688. label: "是",
  689. value: 1,
  690. },
  691. ];
  692. // 设置表格列或者其他自定义的option
  693. option.value = Object.assign(option.value, {
  694. searchEnter: true,
  695. delBtn: false,
  696. selection: true,
  697. viewBtn: false,
  698. editBtn: false,
  699. labelWidth: 120,
  700. column: [
  701. {
  702. label: "生产批号",
  703. prop: "workOrderCode",
  704. search: true,
  705. display: false,
  706. width: 125,
  707. overHidden: true,
  708. },
  709. {
  710. label: "订单编号",
  711. prop: "orderCode",
  712. search: true,
  713. width: 125,
  714. overHidden: true,
  715. rules: [
  716. {
  717. required: true,
  718. message: "订单编号不能为空",
  719. trigger: "trigger",
  720. },
  721. ],
  722. click: ({ value, column }) => {
  723. if (column.boxType) {
  724. dialog.visible = true;
  725. }
  726. },
  727. change: ({ value, column }) => {
  728. if (column.boxType) {
  729. if (value != form.value.orderCode) {
  730. dialog.visible = true;
  731. }
  732. }
  733. },
  734. },
  735. {
  736. label: "订单名称",
  737. prop: "orderName",
  738. search: true,
  739. disabled: true,
  740. width: 125,
  741. overHidden: true,
  742. },
  743. {
  744. label: "订单类型",
  745. prop: "orderType",
  746. type: "select", //类型为下拉选择框
  747. width: 100,
  748. rules: [
  749. {
  750. required: true,
  751. message: "订单类型不能为空",
  752. trigger: "trigger",
  753. },
  754. ],
  755. overHidden: true,
  756. dicUrl: dictDataUtil.request_url + dictDataUtil.TYPE_CODE.plan_order_type,
  757. props: {
  758. label: "dictLabel",
  759. value: "dictValue",
  760. },
  761. change: ({ value, column }) => {
  762. if (
  763. form.value.opType &&
  764. form.value.workOrderCode &&
  765. form.value.orderCode
  766. ) {
  767. // 只有新增的时候需要调用,编辑的时候可能只限编辑先工序
  768. if (column.boxType && column.boxType === "add") {
  769. getOrderType(value);
  770. }
  771. }
  772. },
  773. },
  774. {
  775. label: "产品编号",
  776. width: 125,
  777. overHidden: true,
  778. search: true,
  779. disabled: true,
  780. prop: "materialCode",
  781. },
  782. {
  783. label: "产品名称",
  784. width: 125,
  785. overHidden: true,
  786. search: true,
  787. disabled: true,
  788. prop: "materialName",
  789. },
  790. {
  791. label: "产品规格",
  792. width: 125,
  793. search: true,
  794. overHidden: true,
  795. disabled: true,
  796. prop: "materialModel",
  797. },
  798. {
  799. label: "质量等级",
  800. prop: "hOrder",
  801. type: "select", //类型为下拉选择框
  802. width: 100,
  803. overHidden: true,
  804. dicUrl: dictDataUtil.request_url + dictDataUtil.TYPE_CODE.quality_grade,
  805. props: {
  806. label: "dictLabel",
  807. value: "dictValue",
  808. },
  809. rules: [
  810. {
  811. required: true,
  812. message: "质量等级不能为空",
  813. trigger: "trigger",
  814. },
  815. ],
  816. },
  817. {
  818. label: "优先级",
  819. prop: "priority",
  820. display: false,
  821. width: "80",
  822. type: "select", //类型为下拉选择框
  823. dicUrl:
  824. dictDataUtil.request_url + dictDataUtil.TYPE_CODE.plan_order_priority,
  825. props: {
  826. label: "dictLabel",
  827. value: "dictValue",
  828. },
  829. },
  830. {
  831. label: "状态",
  832. prop: "workOrderState",
  833. search: true,
  834. width: "80",
  835. display: false,
  836. type: "select", //类型为下拉选择框
  837. dicUrl:
  838. dictDataUtil.request_url + dictDataUtil.TYPE_CODE.plan_work_order_state,
  839. props: {
  840. label: "dictLabel",
  841. value: "dictValue",
  842. },
  843. },
  844. {
  845. label: "工艺路线",
  846. prop: "processRouteName",
  847. width: 125,
  848. overHidden: true,
  849. rules: [
  850. {
  851. required: true,
  852. message: "工艺路线不能为空",
  853. trigger: "trigger",
  854. },
  855. ],
  856. click: ({ value, column }) => {
  857. if (column.boxType) {
  858. if (!form.value.materialCode) {
  859. ElMessage({
  860. message: "请先选择订单",
  861. type: "warning",
  862. });
  863. return;
  864. }
  865. processRouteType.value = form.value.orderType === "2" ? "FG" : "ZC";
  866. dialog1.visible = true;
  867. }
  868. },
  869. change: ({ value, column }) => {
  870. //form.value.opType = ''
  871. if (column.boxType) {
  872. if (value != form.value.processRouteName) {
  873. dialog1.visible = true;
  874. }
  875. }
  876. },
  877. },
  878. {
  879. label: "工序分组",
  880. prop: "opType",
  881. width: "100",
  882. disabled: true,
  883. type: "select", //类型为下拉选择框
  884. dicUrl: dictDataUtil.request_url + dictDataUtil.TYPE_CODE.op_group,
  885. props: {
  886. label: "dictLabel",
  887. value: "dictValue",
  888. },
  889. click: ({ value, column }) => {
  890. if (column.boxType) {
  891. if (!form.value.orderType) {
  892. ElMessage({
  893. message: "请先选择订单类型",
  894. type: "warning",
  895. });
  896. return;
  897. }
  898. }
  899. },
  900. change: ({ value, column }) => {
  901. option.value.column.forEach((item) => {
  902. if (value) {
  903. if (column.boxType === "edit") {
  904. if (item.prop === "opType") {
  905. item.disabled = false;
  906. }
  907. }
  908. if (item.prop === "frontWorkOrderCode" || item.prop === "opGroup") {
  909. if (value === "2") {
  910. item.display = false;
  911. }
  912. if (item.prop === "opGroup") {
  913. if (value === "1") {
  914. item.display = true;
  915. item.disabled = false;
  916. groupStri.value.workSection = "HGX";
  917. groupStri.value.procecssRouteId = form.value.processRouteId;
  918. workOrderGroupStr(groupStri.value).then((data) => {
  919. opGroupList.value = data.data;
  920. if (item.prop === "opGroup") {
  921. item.dicData = data.data;
  922. }
  923. });
  924. }
  925. if (value === "0") {
  926. item.display = true;
  927. item.disabled = false;
  928. groupStri.value.workSection = "QGX";
  929. groupStri.value.procecssRouteId = form.value.processRouteId;
  930. workOrderGroupStr(groupStri.value).then((data) => {
  931. opGroupList.value = data.data;
  932. if (item.prop === "opGroup") {
  933. item.dicData = data.data;
  934. }
  935. });
  936. }
  937. }
  938. if (item.prop === "frontWorkOrderCode") {
  939. if (value === "1") {
  940. item.display = true;
  941. item.disabled = false;
  942. }
  943. if (value === "0") {
  944. item.display = false;
  945. item.disabled = false;
  946. }
  947. }
  948. }
  949. }
  950. });
  951. // 只有新增的时候需要调用,编辑的时候可能只限编辑先工序
  952. if (column.boxType && column.boxType === "add") {
  953. getOpGroup(value);
  954. }
  955. },
  956. rules: [
  957. {
  958. required: true,
  959. message: "工序分组不能为空",
  960. trigger: "trigger",
  961. },
  962. ],
  963. },
  964. {
  965. label: "是否重要订单",
  966. slot: true,
  967. headerAlign: "center",
  968. prop: "isImportant",
  969. width: 100,
  970. addDisplay: false,
  971. editDisplay: false,
  972. },
  973. {
  974. label: "工单编号",
  975. prop: "workOrderCode",
  976. rules: [
  977. {
  978. required: true,
  979. message: "工单编号不能为空",
  980. trigger: "trigger",
  981. },
  982. ],
  983. },
  984. {
  985. label: "分组标识",
  986. prop: "opGroup",
  987. width: "100",
  988. display: false,
  989. disabled: true,
  990. type: "select", //类型为下拉选择框
  991. dicData: opGroupList.value,
  992. props: {
  993. label: "name",
  994. value: "name",
  995. },
  996. rules: [
  997. {
  998. required: true,
  999. message: "分组标识不能为空",
  1000. trigger: "trigger",
  1001. },
  1002. ],
  1003. },
  1004. {
  1005. label: "前置工单",
  1006. prop: "frontWorkOrderCode",
  1007. width: "100",
  1008. display: false,
  1009. overHidden: true,
  1010. rules: [
  1011. {
  1012. required: true,
  1013. message: "前置工单不能为空",
  1014. trigger: "trigger",
  1015. },
  1016. ],
  1017. click: ({ value, column }) => {
  1018. if (column.boxType) {
  1019. dialog7.visible = true;
  1020. }
  1021. },
  1022. },
  1023. {
  1024. label: "工艺版本",
  1025. width: 100,
  1026. overHidden: true,
  1027. prop: "processRouteVersion",
  1028. display: false,
  1029. html: true,
  1030. formatter: (val) => {
  1031. return (
  1032. '<b class="el-tag el-tag--success el-tag--light">' +
  1033. val.processRouteVersion +
  1034. "</b>"
  1035. );
  1036. },
  1037. },
  1038. {
  1039. label: "生产车间",
  1040. prop: "workshopName",
  1041. width: 120,
  1042. overHidden: true,
  1043. rules: [
  1044. {
  1045. required: true,
  1046. message: "生产车间不能为空",
  1047. trigger: "trigger",
  1048. },
  1049. ],
  1050. click: ({ value, column }) => {
  1051. if (column.boxType) {
  1052. dialog2.visible = true;
  1053. }
  1054. if (column.boxType == "edit") {
  1055. form.value.productLineName = "";
  1056. }
  1057. },
  1058. change: ({ value, column }) => {
  1059. if (column.boxType) {
  1060. if (value != form.value.workshopName) {
  1061. dialog2.visible = true;
  1062. }
  1063. }
  1064. },
  1065. },
  1066. {
  1067. label: "产线名称",
  1068. prop: "productLineName",
  1069. width: 120,
  1070. overHidden: true,
  1071. rules: [
  1072. {
  1073. required: true,
  1074. message: "产线名称不能为空",
  1075. trigger: "trigger",
  1076. },
  1077. ],
  1078. click: ({ value, column }) => {
  1079. if (column.boxType) {
  1080. if (!form.value.workshopName) {
  1081. ElMessage({
  1082. message: "请先选择生产车间",
  1083. type: "warning",
  1084. });
  1085. return;
  1086. }
  1087. dialog3.visible = true;
  1088. }
  1089. },
  1090. change: ({ value, column }) => {
  1091. if (column.boxType) {
  1092. if (value != form.value.productLineName) {
  1093. dialog3.visible = true;
  1094. }
  1095. }
  1096. },
  1097. },
  1098. /* {
  1099. label: "检验批号",
  1100. prop: "produceCode",
  1101. width: "100",
  1102. },*/
  1103. {
  1104. label: "开始时间",
  1105. prop: "planStartWhen",
  1106. width: 180,
  1107. overHidden: true,
  1108. display: false,
  1109. },
  1110. {
  1111. label: "结束时间",
  1112. prop: "planStartEnd",
  1113. width: 180,
  1114. display: false,
  1115. overHidden: true,
  1116. },
  1117. {
  1118. label: "管号最小值",
  1119. prop: "seqMin",
  1120. type: "number",
  1121. min: 1,
  1122. max: 99999,
  1123. blur: () => {
  1124. countPlanNum();
  1125. },
  1126. rules: [
  1127. {
  1128. required: true,
  1129. message: "管号最小值不能为空",
  1130. trigger: "trigger",
  1131. },
  1132. ],
  1133. },
  1134. {
  1135. label: "管号最大值",
  1136. prop: "seqMax",
  1137. type: "number",
  1138. min: 1,
  1139. max: 99999,
  1140. blur: () => {
  1141. countPlanNum();
  1142. },
  1143. rules: [
  1144. {
  1145. required: true,
  1146. message: "管号最大值不能为空",
  1147. trigger: "trigger",
  1148. },
  1149. ],
  1150. },
  1151. {
  1152. label: "工单数量",
  1153. prop: "planNum",
  1154. width: 85,
  1155. disabled: true,
  1156. },
  1157. {
  1158. label: "检验批号",
  1159. width: 85,
  1160. display: false,
  1161. prop: "checkCode",
  1162. },
  1163. {
  1164. label: "完成数量",
  1165. width: 85,
  1166. display: false,
  1167. prop: "completeNum",
  1168. },
  1169. {
  1170. label: "下线数量",
  1171. width: 85,
  1172. display: false,
  1173. prop: "beforeNum",
  1174. },
  1175. {
  1176. label: "报废数量",
  1177. width: 85,
  1178. display: false,
  1179. prop: "scrapNum",
  1180. },
  1181. // {
  1182. // label: "首检数量",
  1183. // width: 85,
  1184. // prop: "firstCheckNum",
  1185. // value: 0,
  1186. // },
  1187. {
  1188. label: "已检数量",
  1189. width: 85,
  1190. display: false,
  1191. prop: "firstCheckAlreadyNum",
  1192. },
  1193. {
  1194. label: "创建时间",
  1195. width: 180,
  1196. display: false,
  1197. prop: "created",
  1198. },
  1199. {
  1200. label: "创建人",
  1201. width: 90,
  1202. display: false,
  1203. prop: "creator",
  1204. },
  1205. {
  1206. label: "数据包地址",
  1207. width: 90,
  1208. display: false,
  1209. prop: "packageUrl",
  1210. hide: true,
  1211. },
  1212. {
  1213. label: "水汽",
  1214. prop: "waterVapor",
  1215. span: 12,
  1216. type: "switch",
  1217. dicData: switchOp,
  1218. value: 0,
  1219. },
  1220. {
  1221. label: "DPA",
  1222. prop: "dpa",
  1223. span: 12,
  1224. type: "switch",
  1225. dicData: switchOp,
  1226. value: 0,
  1227. },
  1228. {
  1229. label: "备注",
  1230. prop: "remark",
  1231. width: 100,
  1232. overHidden: true,
  1233. minRows: 2, //最小行/最小值
  1234. type: "textarea", //类型为多行文本域框
  1235. maxlength: 20, //最大输入长度
  1236. },
  1237. ],
  1238. });
  1239. onMounted(() => {
  1240. getAllData();
  1241. dataList();
  1242. queryDictDataByType("order_scheduling_type").then((data) => {
  1243. schedulingTypes.value = data.data;
  1244. });
  1245. queryDictDataByType("aps_priority").then((data) => {
  1246. apsPriority.value = data.data;
  1247. });
  1248. permission.value = {
  1249. delBtn: checkPerm(ButtonPermKeys.PLAN.BTNS.work_order_del),
  1250. addBtn: checkPerm(ButtonPermKeys.PLAN.BTNS.work_order_add),
  1251. editBtn: checkPerm(buttonPermission.PLAN.BTNS.work_order_edit),
  1252. };
  1253. });
  1254. // 选择完前工序或者后工序后获取这个
  1255. const getOpGroup = (value) => {
  1256. getJobInfo(form.value.orderCode, value + "", form.value.orderType).then(
  1257. (res) => {
  1258. form.value.workOrderCode = res.data;
  1259. }
  1260. );
  1261. };
  1262. const getOrderType = (value) => {
  1263. getJobInfo(form.value.orderCode, form.value.opType, value + "").then(
  1264. (res) => {
  1265. form.value.workOrderCode = res.data;
  1266. }
  1267. );
  1268. };
  1269. // 输入完最大值和最小值计算工单数量
  1270. const countPlanNum = () => {
  1271. if (form.value.seqMax && form.value.seqMin) {
  1272. form.value.planNum = form.value.seqMax - form.value.seqMin + 1;
  1273. }
  1274. };
  1275. const changeItem = (row) => {
  1276. updateWorkOrderInfo(row).then(() => {
  1277. ElMessage.success("操作成功");
  1278. dataList();
  1279. });
  1280. };
  1281. </script>