index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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. >
  19. <template #usable="{ row }">
  20. <el-tag v-if="row.usable == '1'" type="success">已绑定</el-tag>
  21. <el-tag v-else type="info">未绑定</el-tag>
  22. </template>
  23. <!-- :disabled="row.usable == '1' ? false : true" -->
  24. <!--<template #menu-right="{}">
  25. <el-dropdown split-button
  26. >导入
  27. <template #dropdown>
  28. <el-dropdown-menu>
  29. <el-dropdown-item
  30. @click="downloadTemplate('/api/v1/op/route/template')"
  31. >
  32. <i-ep-download />下载模板
  33. </el-dropdown-item>
  34. <el-dropdown-item @click="importExcelData">
  35. <i-ep-top />导入数据
  36. </el-dropdown-item>
  37. </el-dropdown-menu>
  38. </template>
  39. </el-dropdown>
  40. </template>-->
  41. <template #menu="{ row }">
  42. <el-button
  43. link
  44. icon="el-icon-copy-document"
  45. :disabled="false"
  46. @click="copyRow(row)"
  47. >复制</el-button
  48. >
  49. <el-button link icon="el-icon-copy-document" @click="bindProcess(row)"
  50. >绑定</el-button
  51. >
  52. </template>
  53. </avue-crud>
  54. <CommonTable
  55. ref="ctableRef"
  56. tableTitle="添加产品"
  57. tableType="MARTERIAL"
  58. @selected-sure="onSelectedFinish"
  59. />
  60. <CommonTable
  61. ref="commonRef"
  62. tableTitle="选择通用工艺"
  63. tableType="ROUTE_COMMON"
  64. @selected-sure="onCommonFinish"
  65. />
  66. <ExcelUpload ref="uploadRef" @finished="uploadFinished" />
  67. <el-dialog
  68. v-model="centerDialogVisible"
  69. title="重命名"
  70. width="500"
  71. align-center
  72. >
  73. <el-form :model="tmpForm" label-width="auto" style="max-width: 800px">
  74. <el-row>
  75. <el-col :span="12">
  76. <el-form-item label="工艺路线编号">
  77. <el-input v-model="tmpForm.processRouteCode" />
  78. </el-form-item>
  79. </el-col>
  80. <el-col :span="12">
  81. <el-form-item label="工艺路线名称">
  82. <el-input v-model="tmpForm.processRouteName" />
  83. </el-form-item>
  84. </el-col>
  85. </el-row>
  86. </el-form>
  87. <template #footer>
  88. <div class="dialog-footer">
  89. <el-button @click="centerDialogVisible = false">取消</el-button>
  90. <el-button type="primary" @click="renameRoute()"> 确定 </el-button>
  91. </div>
  92. </template>
  93. </el-dialog>
  94. </div>
  95. </template>
  96. <script setup>
  97. import { ref, getCurrentInstance } from "vue";
  98. import { useCrud } from "@/hooks/userCrud";
  99. import ButtonPermKeys from "@/common/configs/buttonPermission";
  100. import dictDataUtil from "@/common/configs/dictDataUtil";
  101. import { useDictionaryStore } from "@/store";
  102. import { copyRoute } from "@/api/craft/route/index";
  103. // 数据字典相关
  104. const { dicts } = useDictionaryStore();
  105. const testDebunce = () => {
  106. console.log("执行了事件");
  107. };
  108. // 传入一个url,后面不带/
  109. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  110. useCrud({
  111. src: "/api/v1/op/route",
  112. });
  113. const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  114. Methords; //增删改查
  115. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  116. const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
  117. // checkBtnPerm(ButtonPermKeys.PLAN.BTNS.order_add) :permission="permission"
  118. // const permission = reactive({
  119. // delBtn: checkPerm(buttonPermission.PLAN.BTNS.order_del),
  120. // addBtn: checkPerm(buttonPermission.PLAN.BTNS.order_add),
  121. // editBtn: checkPerm(buttonPermission.PLAN.BTNS.order_edit),
  122. // menu: true,
  123. // });
  124. let centerDialogVisible = ref(false);
  125. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  126. const tmpForm = ref({});
  127. onMounted(() => {
  128. // console.log("crudRef", crudRef)
  129. dataList();
  130. });
  131. /**
  132. * 上传excel相关
  133. */
  134. const uploadRef = ref(null);
  135. const uploadFinished = () => {
  136. // 上传完成后的刷新操作
  137. page.currentPage = 1;
  138. dataList();
  139. };
  140. const importExcelData = () => {
  141. if (uploadRef.value) {
  142. uploadRef.value.show("/api/v1/op/route/import");
  143. }
  144. };
  145. // 选择产品相关
  146. const ctableRef = ref(null);
  147. const commonRef = ref(null);
  148. const onSelectedFinish = (selectedValue) => {
  149. // search.value.prodtName = selectedValue.materialName;
  150. form.value.prodtName = selectedValue.materialName;
  151. form.value.prodtCode = selectedValue.materialCode;
  152. form.value.prodtModel = selectedValue.spec;
  153. };
  154. const onCommonFinish = (selectedValue) => {
  155. form.value.commonRouteId = selectedValue.id;
  156. form.value.commonRouteName = selectedValue.processRouteName;
  157. form.value.commonRouteCode = selectedValue.processRouteCode;
  158. };
  159. const startChooseProduct = () => {
  160. if (ctableRef.value) {
  161. ctableRef.value.startSelect();
  162. }
  163. };
  164. const startChooseRoute = () => {
  165. if (ctableRef.value) {
  166. commonRef.value.startSelect();
  167. }
  168. };
  169. // 已经绑定了工序的可以复制,跟后端HT商量只传id即可。
  170. const copyRow = (row) => {
  171. option.value.column[4].display = false;
  172. option.value.column[5].display = false;
  173. if (row.usable == 0) {
  174. ElMessage.error("该路线未被绑定!");
  175. return;
  176. }
  177. form.value = Object.assign(form.value, row);
  178. form.value.processRouteVersion = "";
  179. crudRef.value.rowAdd();
  180. };
  181. const renameRoute = () => {
  182. tmpForm.value.id;
  183. tmpForm.value.processRouteCode;
  184. tmpForm.value.processRouteName;
  185. copyRoute(tmpForm.value).then(() => {
  186. tmpForm.value.id = undefined;
  187. tmpForm.value.processRouteCode = undefined;
  188. tmpForm.value.processRouteName = undefined;
  189. page.currentPage = 1;
  190. dataList();
  191. });
  192. centerDialogVisible.value = false;
  193. };
  194. const router = useRouter();
  195. // 绑定工序
  196. const bindProcess = (row) => {
  197. router.push({
  198. path: `/base/craftManagement/bindProcess/${row.id}/${row.prodtCode}`,
  199. });
  200. };
  201. // 设置表格列或者其他自定义的option
  202. option.value = Object.assign(option.value, {
  203. selection: true,
  204. labelWidth: 110,
  205. searchLabelWidth: 110,
  206. column: [
  207. {
  208. label: "工艺路线编号",
  209. prop: "processRouteCode",
  210. search: true,
  211. width: 150,
  212. addDisplay: true,
  213. editDisabled: true,
  214. overHidden: true,
  215. rules: [
  216. {
  217. required: true,
  218. message: "工艺路线名称不能为空",
  219. trigger: "blur",
  220. },
  221. ],
  222. },
  223. {
  224. label: "工艺路线名称",
  225. prop: "processRouteName",
  226. width: 150,
  227. search: true,
  228. overHidden: true,
  229. rules: [
  230. {
  231. required: true,
  232. message: "工艺路线名称不能为空",
  233. trigger: "blur",
  234. },
  235. ],
  236. },
  237. {
  238. label: "工艺路线类型",
  239. prop: "processRouteType",
  240. minWidth: 120,
  241. search: true,
  242. overHidden: true,
  243. rules: [
  244. {
  245. required: true,
  246. message: "工艺路线类型不能为空",
  247. trigger: "change",
  248. },
  249. ],
  250. type: "select",
  251. dicUrl: dictDataUtil.request_url + dictDataUtil.TYPE_CODE.routing_type,
  252. props: {
  253. label: "dictLabel",
  254. value: "dictValue",
  255. },
  256. },
  257. {
  258. label: "通用工艺id",
  259. prop: "commonRouteId",
  260. addDisplay: false,
  261. editDisplay: false,
  262. hide: true,
  263. width: 150,
  264. overHidden: true,
  265. },
  266. {
  267. label: "通用工艺名字",
  268. prop: "commonRouteName",
  269. editDisplay: false,
  270. width: 150,
  271. overHidden: true,
  272. click: () => {
  273. startChooseRoute();
  274. },
  275. },
  276. {
  277. label: "通用工艺编码",
  278. prop: "commonRouteCode",
  279. disabled: true,
  280. editDisplay: false,
  281. width: 150,
  282. overHidden: true,
  283. },
  284. {
  285. label: "产品名称",
  286. prop: "prodtName",
  287. overHidden: true,
  288. width: 150,
  289. search: true,
  290. rules: [
  291. {
  292. required: true,
  293. message: "请选择产品",
  294. trigger: "blur",
  295. },
  296. ],
  297. readOnly: true,
  298. click: () => {
  299. startChooseProduct();
  300. },
  301. },
  302. {
  303. label: "产品编号",
  304. prop: "prodtCode",
  305. overHidden: true,
  306. search: true,
  307. width: 150,
  308. disabled: true,
  309. },
  310. {
  311. label: "产品型号",
  312. prop: "prodtModel",
  313. overHidden: true,
  314. search: true,
  315. minWidth: 200,
  316. disabled: true,
  317. },
  318. // 在产品那边绑定了工艺路线才是已绑定
  319. {
  320. label: "路线状态",
  321. prop: "usable",
  322. addDisplay: false,
  323. editDisplay: false,
  324. slot: true,
  325. width: 100,
  326. type: "radio",
  327. dicData: [
  328. {
  329. label: "已绑定",
  330. value: 1,
  331. },
  332. {
  333. label: "未绑定",
  334. value: 0,
  335. },
  336. ],
  337. },
  338. {
  339. label: "启用状态",
  340. prop: "enabled",
  341. addDisplay: false,
  342. // editDisplay: false,
  343. slot: true,
  344. width: 100,
  345. type: "radio",
  346. dicData: [
  347. {
  348. label: "未启用",
  349. value: 1,
  350. },
  351. {
  352. label: "启用",
  353. value: 0,
  354. },
  355. ],
  356. value: 0,
  357. },
  358. // 只有绑定了工序才可以复制。
  359. {
  360. label: "是否可复制",
  361. prop: "usable2",
  362. slot: true,
  363. width: 100,
  364. search: false,
  365. filterable: true,
  366. hide: true,
  367. addDisplay: false,
  368. editDisplay: false,
  369. type: "radio",
  370. dicData: [
  371. {
  372. label: "否",
  373. value: 0,
  374. },
  375. {
  376. label: "是",
  377. value: 1,
  378. },
  379. ],
  380. value: 0,
  381. },
  382. {
  383. label: "版本",
  384. prop: "processRouteVersion",
  385. addDisplay: true,
  386. editDisplay: true,
  387. value: "1.0",
  388. rules: [
  389. {
  390. required: true,
  391. message: "版本不能为空",
  392. trigger: "blur",
  393. },
  394. ],
  395. },
  396. {
  397. label: "创建人",
  398. prop: "creator",
  399. addDisplay: false,
  400. editDisplay: false,
  401. overHidden: true,
  402. },
  403. {
  404. label: "创建时间",
  405. prop: "created",
  406. addDisplay: false,
  407. editDisplay: false,
  408. width: 150,
  409. overHidden: true,
  410. },
  411. ],
  412. });
  413. </script>