index.vue 11 KB

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