index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  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. @row-del="deleteRow"
  13. @search-change="searchChange"
  14. @search-reset="resetChange"
  15. @size-change="dataList"
  16. @current-change="dataList"
  17. @selection-change="selectionChange"
  18. :before-open="beforeOpenDialog"
  19. >
  20. <template #menu-left="{ size }">
  21. <el-button
  22. :disabled="toDeleteIds.length < 1"
  23. type="danger"
  24. icon="el-icon-delete"
  25. :size="size"
  26. @click="multipleDelete"
  27. >删除111</el-button
  28. >
  29. </template>
  30. <template #menu="{ size, row, index }">
  31. <el-button
  32. icon="el-icon-refresh"
  33. text
  34. @click="queryDiffList(row.id)"
  35. type="primary"
  36. :size="size"
  37. >同步</el-button>
  38. </template>
  39. <template #customFieldName-form="scope">
  40. <el-select
  41. v-model="customFieldNameValues"
  42. multiple
  43. filterable
  44. allow-create
  45. default-first-option
  46. :reserve-keyword="false"
  47. placeholder="请输入名称,按回车创建"
  48. @change="customFieldChange"
  49. >
  50. <el-option
  51. v-for="item in customFieldOptions"
  52. :key="item.value"
  53. :label="item.value"
  54. :value="item.value"
  55. />
  56. </el-select>
  57. </template>
  58. <template #menu-right="{}">
  59. <el-dropdown split-button
  60. >导入
  61. <template #dropdown>
  62. <el-dropdown-menu>
  63. <el-dropdown-item
  64. @click="downloadTemplate('/api/v1/op/baseOperation/template')"
  65. >
  66. <i-ep-download />下载模板
  67. </el-dropdown-item>
  68. <el-dropdown-item @click="importExcelData">
  69. <i-ep-top />导入数据
  70. </el-dropdown-item>
  71. </el-dropdown-menu>
  72. </template>
  73. </el-dropdown>
  74. <!-- <el-button
  75. class="ml-3"
  76. @click="exportData('/api/v1/plan/order/export')"
  77. >
  78. <template #icon> <i-ep-download /> </template>导出
  79. </el-button> -->
  80. </template>
  81. </avue-crud>
  82. <ExcelUpload ref="uploadRef" @finished="uploadFinished" />
  83. <el-dialog
  84. v-model="dialog.visible"
  85. :title="dialog.title"
  86. width="950px"
  87. @close="dialog.visible = false"
  88. >
  89. <div style="width:100%;height:10px;color:#fa0303;">已经开始生产的工艺路线,请到工艺路线中进行单个更改!!!</div>
  90. <difference :diffList="diffList" @syncList="clickSyncList"/>
  91. <template #footer>
  92. <div class="dialog-footer">
  93. <el-button type="primary" @click="handleSubmit">同 步</el-button>
  94. <el-button @click="dialog.visible = false">取 消</el-button>
  95. </div>
  96. </template>
  97. </el-dialog>
  98. </div>
  99. </template>
  100. <script setup>
  101. import { ref, getCurrentInstance } from "vue";
  102. import { useCrud } from "@/hooks/userCrud";
  103. import { useCommonStoreHook, useDictionaryStore } from "@/store";
  104. import { syncOperation, checkSyncList} from "@/api/craft/process";
  105. import difference from "./component/difference.vue";
  106. // 数据字典相关
  107. const { dicts } = useDictionaryStore();
  108. const dialog = reactive({
  109. title: "差异列表",
  110. visible: false,
  111. });
  112. // 传入一个url,后面不带/
  113. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  114. useCrud({
  115. src: "/api/v1/op/baseOperation",
  116. });
  117. const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  118. Methords; //增删改查
  119. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  120. const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
  121. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  122. const clickObjId = ref(null)
  123. const clickSyncRouteList = ref([])
  124. onMounted(() => {
  125. // console.log("crudRef", crudRef)
  126. dataList();
  127. });
  128. const clickSyncList = (list) => {
  129. clickSyncRouteList.value = list;
  130. }
  131. const handleSubmit = ()=>{
  132. if(clickSyncRouteList.value.length > 0){
  133. syncOperation({"baseId": clickObjId.value,"routeIds":clickSyncRouteList.value}).then((data)=>{
  134. if(data.code === '200'){
  135. clickSyncRouteList.value = []
  136. dialog.visible = false;
  137. ElMessage.success(data.msg);
  138. }else{
  139. ElMessage.error(data.msg);
  140. }
  141. });
  142. }else{
  143. ElMessage.error("请选择需要同步的数据");
  144. }
  145. }
  146. const diffList = ref([]);
  147. /**
  148. * 上传excel相关
  149. */
  150. const uploadRef = ref(null);
  151. const uploadFinished = () => {
  152. // 上传完成后的刷新操作
  153. page.currentPage = 1;
  154. dataList();
  155. };
  156. const importExcelData = () => {
  157. if (uploadRef.value) {
  158. uploadRef.value.show("/api/v1/op/baseOperation/import");
  159. }
  160. };
  161. // 设置表格列或者其他自定义的option
  162. const switchOp = [
  163. {
  164. label: "否",
  165. value: 0,
  166. },
  167. {
  168. label: "是",
  169. value: 1,
  170. },
  171. ];
  172. // 自定义工序项目字段名称相关方法
  173. const customFieldNameValues = ref([]);
  174. const customFieldOptions = [];
  175. const customFieldChange = (val) => {
  176. let result = Array.from(val);
  177. result = result.map((item) => {
  178. return {
  179. value: item,
  180. isSelected: true,
  181. };
  182. });
  183. form.value.customFieldName = JSON.stringify(result);
  184. };
  185. const queryDiffList = (id) =>{
  186. clickObjId.value = id;
  187. checkSyncList(id).then((data)=>{
  188. if(data.data){
  189. diffList.value = []
  190. dialog.visible = true
  191. data.data.forEach((item)=>{
  192. diffList.value.push(item)
  193. })
  194. }
  195. });
  196. }
  197. const beforeOpenDialog = (done, type, loading) => {
  198. if (
  199. type === "edit" &&
  200. form.value.customFieldName &&
  201. JSON.parse(form.value.customFieldName)?.length > 0
  202. ) {
  203. customFieldOptions.value = JSON.parse(form.value.customFieldName);
  204. customFieldNameValues.value = customFieldOptions.value.map(
  205. (item) => item.value
  206. );
  207. }
  208. done();
  209. };
  210. option.value = Object.assign(option.value, {
  211. searchEnter: true,
  212. selection: true,
  213. labelWidth: 120,
  214. column: [
  215. {
  216. label: "工序名称",
  217. prop: "operationName",
  218. span: 12,
  219. search: true,
  220. rules: [
  221. {
  222. required: true,
  223. message: "工序名称不能为空",
  224. trigger: "blur",
  225. },
  226. ],
  227. },
  228. {
  229. label: "工序编码",
  230. prop: "operationCode",
  231. span: 12,
  232. search: true,
  233. display: false,
  234. },
  235. {
  236. label: "工段",
  237. prop: "workSection",
  238. type: "select",
  239. search: true,
  240. dicData: dicts.workshop_section,
  241. props: {
  242. label: "dictLabel",
  243. value: "dictValue",
  244. },
  245. span: 12,
  246. rules: [
  247. {
  248. required: true,
  249. message: "请选择工段",
  250. trigger: "change",
  251. },
  252. ],
  253. },
  254. {
  255. label: "工序类型",
  256. prop: "operationType",
  257. type: "select",
  258. search: true,
  259. dicData: dicts.process_type,
  260. props: {
  261. label: "dictLabel",
  262. value: "dictValue",
  263. },
  264. span: 12,
  265. rules: [
  266. {
  267. required: true,
  268. message: "请选择工序类型",
  269. trigger: "change",
  270. },
  271. ],
  272. },
  273. {
  274. label: "工艺条件",
  275. prop: "processAsk",
  276. span: 12,
  277. rules: [
  278. {
  279. required: true,
  280. message: "工艺条件不能为空",
  281. trigger: "blur",
  282. },
  283. ],
  284. },
  285. {
  286. label: "技能要求",
  287. prop: "skillAsk",
  288. span: 12,
  289. type: "select",
  290. search: true,
  291. filterable: true,
  292. dicData: dicts.skill_requirements,
  293. props: {
  294. label: "dictLabel",
  295. value: "dictValue",
  296. },
  297. rules: [
  298. {
  299. required: true,
  300. message: "请选择技能要求",
  301. trigger: "change",
  302. },
  303. ],
  304. },
  305. {
  306. label: "后置时间(分)",
  307. prop: "forceTime",
  308. type: "number",
  309. span: 12,
  310. rules: [
  311. {
  312. required: true,
  313. message: "后置时间不能为空",
  314. trigger: "blur",
  315. },
  316. ],
  317. },
  318. /*{
  319. label: "标准机时",
  320. prop: "timeingNum",
  321. type: "number",
  322. span: 12,
  323. rules: [
  324. {
  325. required: true,
  326. message: "标准机时不能为空",
  327. trigger: "blur",
  328. },
  329. ],
  330. },*/
  331. {
  332. label: "标准工时(分)",
  333. prop: "standardWorktime",
  334. type: "number",
  335. span: 12,
  336. rules: [
  337. {
  338. required: true,
  339. message: "标准工时不能为空",
  340. trigger: "blur",
  341. },
  342. ],
  343. },
  344. // {
  345. // label: '岗位',
  346. // prop: 'type',
  347. // type: 'select',
  348. // dicData: [
  349. // {
  350. // label: '岗位1',
  351. // value: 'position1',
  352. // },
  353. // ],
  354. // props: {
  355. // label: 'label',
  356. // value: 'value',
  357. // },
  358. // span: 12,
  359. // },
  360. {
  361. label: "工位类型",
  362. prop: "stanType",
  363. search: true,
  364. type: "select",
  365. dicData: dicts.station_type,
  366. props: {
  367. label: "dictLabel",
  368. value: "dictValue",
  369. },
  370. span: 12,
  371. row: true,
  372. rules: [
  373. {
  374. required: true,
  375. message: "请选择工位类型",
  376. trigger: "blur",
  377. },
  378. ],
  379. },
  380. {
  381. label: "方法",
  382. prop: "method",
  383. span: 12,
  384. },
  385. {
  386. label: "试验规程编号",
  387. prop: "testPlanCode",
  388. span: 12,
  389. },
  390. {
  391. label: "是否可跳过",
  392. prop: "skipped",
  393. span: 8,
  394. hide: true,
  395. type: "switch",
  396. dicData: switchOp,
  397. value: 0,
  398. },
  399. {
  400. label: "是否关键工序",
  401. prop: "keyProcesses",
  402. span: 8,
  403. type: "switch",
  404. dicData: switchOp,
  405. value: 0,
  406. },
  407. {
  408. label: "是否特殊工序",
  409. prop: "isSpecial",
  410. span: 8,
  411. type: "switch",
  412. dicData: switchOp,
  413. value: 0,
  414. },
  415. {
  416. label: "是否禁用",
  417. prop: "enabled",
  418. hide: true,
  419. span: 8,
  420. type: "switch",
  421. dicData: switchOp,
  422. value: 0,
  423. },
  424. // {
  425. // label: "是否外协",
  426. // prop: "externalCooperation",
  427. // span: 8,
  428. // hide: true,
  429. // type: "switch",
  430. // dicData: switchOp,
  431. // value: 0,
  432. // },
  433. /*{
  434. label: "是否首检",
  435. prop: "firstCheck",
  436. span: 8,
  437. hide: true,
  438. type: "switch",
  439. dicData: switchOp,
  440. value: 0,
  441. },*/
  442. /*{
  443. label: "是否巡检",
  444. prop: "inspection",
  445. span: 8,
  446. hide: true,
  447. type: "switch",
  448. dicData: switchOp,
  449. value: 0,
  450. },
  451. {
  452. label: "是否自检",
  453. prop: "selfCheck",
  454. span: 8,
  455. hide: true,
  456. type: "switch",
  457. dicData: switchOp,
  458. value: 0,
  459. },*/
  460. {
  461. label: "批量报工",
  462. prop: "batchReport",
  463. span: 8,
  464. hide: true,
  465. type: "switch",
  466. dicData: switchOp,
  467. value: 1,
  468. },
  469. // {
  470. // label: "是否工艺数量",
  471. // prop: "common",
  472. // span: 8,
  473. // hide: true,
  474. // type: "switch",
  475. // dicData: switchOp,
  476. // value: 0,
  477. // },
  478. // {
  479. // label: "是否分批",
  480. // prop: "batch",
  481. // span: 8,
  482. // hide: true,
  483. // type: "switch",
  484. // dicData: switchOp,
  485. // value: 0,
  486. // },
  487. {
  488. label: "是否合批",
  489. prop: "merge",
  490. span: 8,
  491. hide: true,
  492. type: "switch",
  493. dicData: switchOp,
  494. value: 0,
  495. //联动隐藏
  496. control: (val, form) => {
  497. return {
  498. mergeNum: {
  499. display: val == 1 ? true : false,
  500. },
  501. };
  502. },
  503. },
  504. {
  505. label: "是否自定义名称",
  506. prop: "customEnable",
  507. span: 8,
  508. hide: true,
  509. type: "switch",
  510. dicData: switchOp,
  511. value: 0,
  512. //联动隐藏
  513. control: (val, form) => {
  514. return {
  515. customFieldName: {
  516. display: val == 1 ? true : false,
  517. },
  518. };
  519. },
  520. },
  521. {
  522. label: "自定义工序项目字段名称",
  523. prop: "customFieldName",
  524. hide: true,
  525. span: 24,
  526. },
  527. /*{
  528. label: "是否委外",
  529. prop: "outsourcing",
  530. span: 8,
  531. hide: true,
  532. type: "switch",
  533. dicData: switchOp,
  534. // click: ({ column,value }) => {
  535. // if(value == 0){
  536. // console.log('column',column)
  537. // }
  538. // },
  539. //联动隐藏
  540. control: (val, form) => {
  541. return {
  542. outTime: {
  543. display: val == 1 ? true : false,
  544. },
  545. };
  546. },
  547. value: 0,
  548. },*/
  549. {
  550. label: "合批数量",
  551. prop: "mergeNum",
  552. span: 5,
  553. hide: true,
  554. display: false,
  555. value: 0,
  556. },
  557. {
  558. label: "分批数量",
  559. prop: "batchNum",
  560. span: 5,
  561. display: false,
  562. hide: true,
  563. value: 0,
  564. // slot:true, // 自定义列
  565. },
  566. {
  567. label: "委外时间",
  568. prop: "outTime",
  569. span: 5,
  570. display: false,
  571. hide: true,
  572. value: 0,
  573. // slot:true, // 自定义列
  574. },
  575. {
  576. label: "工序描述",
  577. prop: "operationDesc",
  578. hide: true,
  579. span: 24,
  580. type: "textarea",
  581. },
  582. /*{
  583. label: "备注",
  584. prop: "remark",
  585. hide: true,
  586. span: 24,
  587. type: "textarea",
  588. },*/
  589. ],
  590. });
  591. </script>