index.vue 12 KB

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