index.vue 9.1 KB

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