Sfoglia il codice sorgente

1.工艺路线逻辑完善。2.全局字典获取方式修改。

jiaxiaoqiang 1 anno fa
parent
commit
c46c6e8878

+ 9 - 0
src/api/craft/route/index.ts

@@ -25,3 +25,12 @@ export function saveProcessInRoute(data: object) {
     data: data,
   });
 }
+
+// 保存xx关系表中的工序
+export function updateProcess(data: object) {
+  return request({
+    url: `/api/v1/op/operation/update`,
+    method: "post",
+    data: data,
+  });
+}

+ 5 - 0
src/plugins/permission.ts

@@ -1,6 +1,8 @@
 import router from "@/router";
 import { useUserStore } from "@/store/modules/user";
 import { usePermissionStore } from "@/store/modules/permission";
+import { useDictionaryStore } from "@/store/modules/dictionary";
+
 import NProgress from "@/utils/nprogress";
 
 export function setupPermission() {
@@ -16,6 +18,9 @@ export function setupPermission() {
         next({ path: "/" });
         NProgress.done();
       } else {
+        const dictStore = useDictionaryStore();
+        dictStore.checkDicts();
+
         const userStore = useUserStore();
         // const hasRoles =
         //   userStore.user.roles && userStore.user.roles.length > 0;

+ 39 - 38
src/store/modules/dictionary.ts

@@ -1,44 +1,45 @@
 import { store } from "@/store";
 import { defineStore } from "pinia";
+import { getUserDicts } from "@/api/auth";
 
-export const useDictionaryStore = defineStore("dictionaryStore", {
-  state: () => ({
-    /**
-     * 需要后端返回的type
-     */
-    types: [
-      "station_type",
-      "station_operate_type",
-      "applicable_platforms",
-      "material_properties",
-      "quality_testing_plan",
-      "material_level",
-      "packaging_method",
-      "quality_grade",
-      "selection_type",
-      "device_type",
-      "stage",
-      "danwei_type",
-      "process_type",
-      "workshop_section",
-      "skill_requirements",
-      "station_type",
-      "danwei_type",
-      "trace_type",
-      "skill_type",
-    ],
-    dicts: [],
-  }),
-  persist: {
-    enabled: true,
-    strategies: [
-      {
-        key: "dicts",
-        storage: localStorage,
-        paths: ["dicts"],
-      },
-    ],
-  },
+export const useDictionaryStore = defineStore("dictionaryStore", () => {
+  const types = [
+    "station_type",
+    "station_operate_type",
+    "applicable_platforms",
+    "material_properties",
+    "quality_testing_plan",
+    "material_level",
+    "packaging_method",
+    "quality_grade",
+    "selection_type",
+    "device_type",
+    "stage",
+    "danwei_type",
+    "process_type",
+    "workshop_section",
+    "skill_requirements",
+    "station_type",
+    "danwei_type",
+    "trace_type",
+    "skill_type",
+  ];
+  const dicts = ref<{ string?: any[] }>({});
+  function checkDicts() {
+    if (JSON.stringify(dicts.value) === "{}") {
+      getUserDicts(types).then((res) => {
+        if (res.data) {
+          dicts.value = res?.data ?? [];
+        }
+      });
+    }
+  }
+
+  return {
+    types,
+    dicts,
+    checkDicts,
+  };
 });
 
 export function useDictionaryStoreHook() {

+ 48 - 18
src/views/base/craftManagement/route/bindProcess.vue

@@ -6,10 +6,10 @@
     <div class="header">
       <div class="title">绑定工序</div>
       <el-space>
-        <el-button :icon="Back" size="small">返回</el-button>
-        <el-button type="primary" :icon="Download" size="small">下载</el-button>
+        <el-button :icon="Back" size="small" @click="back">返回</el-button>
+        <!--        <el-button type="primary" :icon="Download" size="small">下载</el-button>-->
         <el-button
-          type="primary"
+          :type="isChanged ? 'danger' : 'primary'"
           :icon="Document"
           size="small"
           @click="saveFlow"
@@ -55,7 +55,9 @@
           v-model="list2"
           :animation="150"
           group="people"
+          @update="onUpdate"
           style="min-width: 400px"
+          @add="onClone"
         >
           <div
             v-for="(item, index) in list2"
@@ -65,10 +67,7 @@
           >
             <div class="indexLabel">工序 {{ index + 1 }}</div>
             <div :class="getFlowNameClass(index)">
-              {{ item?.operationVO?.operationName }} 当前id:{{
-                item?.operationId
-              }}
-              下id:{{ item?.nextOperationId }}
+              {{ item?.operationVO?.operationName }}
             </div>
             <div>
               <Delete class="flowDelete" @click.stop="clickDelete(index)" />
@@ -78,12 +77,11 @@
         </VueDraggable>
       </div>
       <div class="detailInfo">
-        <div v-show="selectIndex > -1">
+        <div v-if="selectIndex > -1 && !isChanged">
           <avue-form
             ref="formRef"
             :option="formOption"
             v-model="currentProcess"
-            @submit="handleSubmit"
             style="padding: 10px; background-color: white"
           />
           <div class="editProcces">
@@ -92,6 +90,7 @@
             >
           </div>
         </div>
+        <div v-else class="tipContent">{{ tipContent }}</div>
       </div>
     </div>
   </div>
@@ -111,9 +110,12 @@ import { useCommonStoreHook, useDictionaryStoreHook } from "@/store";
 import {
   processesByRouteId,
   saveProcessInRoute,
+  updateProcess,
 } from "@/api/craft/route/index";
 import { v4 as uuidv4 } from "uuid";
 import { formOption } from "./bindConfig";
+import { ElMessage } from "element-plus";
+
 const router = useRouter();
 const route = useRoute();
 
@@ -121,12 +123,12 @@ const route = useRoute();
 const { dicts } = useDictionaryStoreHook();
 
 // 顶部====================
-const back = () => {};
+const back = () => {
+  router.back();
+};
 
 const download = () => {};
 
-const save = () => {};
-
 // 左侧工序树====================
 const activeNames = ref([0]);
 const handleChange = (val) => {};
@@ -155,6 +157,7 @@ const clone = (origin) => {
   };
 };
 
+// 保存中间的工序列表
 const saveFlow = async () => {
   for (let i = 0; i < list2.value.length; i++) {
     list2.value[i].operationSort = i;
@@ -184,15 +187,32 @@ const loadTreeData = () => {
 // 中间列表====================
 const list2 = ref([]);
 const selectIndex = ref(-1);
-
+const isChanged = ref(true); //如果中间列表发生了改变则不显示右侧信息
+// 点击中间列表事件,需要设置index和值
 const clickFlowItem = (item, index) => {
+  if (isChanged.value) {
+    ElMessage.warning("请先保存工序列表");
+    return;
+  }
   selectIndex.value = index;
-  console.log("clickFlowItem", item);
+  currentProcess.value = item.operationVO;
 };
 
 const clickDelete = (index) => {
   list2.value.splice(index, 1);
+  onUpdate();
+};
+
+const onClone = () => {
+  isChanged.value = true;
+  tipContent.value = "请先保存工序列表,再选择工序进行编辑";
+};
+
+const onUpdate = () => {
+  //   中间发生了改变调用
   selectIndex.value = -1;
+  isChanged.value = true;
+  tipContent.value = "请先保存工序列表,再选择工序进行编辑";
 };
 
 const getFlowNameClass = (index) => {
@@ -201,19 +221,23 @@ const getFlowNameClass = (index) => {
 
 const loadProcessesFlow = async () => {
   const res = await processesByRouteId(route.params.id);
-  console.log("processesByRouteId", res);
+
   list2.value = res.data ?? [];
-  if (selectIndex.value >= 0) {
-  }
+  isChanged.value = false;
+  tipContent.value = "请选择需要编辑的工序";
 };
 
 // 右侧具体信息====================
 const formRef = ref(null);
 const currentProcess = ref({});
+const tipContent = ref("");
 const handleSubmit = () => {};
 
 const editProComponent = async () => {
-  saveFlow();
+  // saveFlow();
+  let res = await updateProcess(currentProcess.value);
+  ElMessage.success("保存成功");
+  router.push(`/base/craftManagement/processCom/${currentProcess.value.id}`);
 };
 
 // 全局=======
@@ -362,6 +386,12 @@ const getNameByDictType = (dictValue) => {
   text-align: left;
   margin-left: 19px;
 }
+.tipContent {
+  width: 100%;
+  text-align: center;
+  margin-top: 20px;
+  color: #e6a23c;
+}
 </style>
 
 <style>

+ 1 - 0
src/views/base/craftManagement/route/components/bottomTable.vue

@@ -113,6 +113,7 @@ const imgUrlClick = (itemValue) => {
 };
 
 onMounted(() => {
+  search.value.operationId = route.params.id;
   url.value = tableConfig[props.tableType].url;
   option.value = Object.assign(option.value, {
     addBtn: false,

+ 26 - 17
src/views/base/craftManagement/route/components/processComponent.vue

@@ -7,7 +7,11 @@
       <div class="title">绑定工序</div>
       <el-space>
         <el-button :icon="Back" size="small" @click="back">返回</el-button>
-        <el-button type="primary" :icon="Document" size="small" @click="save"
+        <el-button
+          :type="isChanged ? 'danger' : 'primary'"
+          :icon="Document"
+          size="small"
+          @click="save"
           >保存</el-button
         >
       </el-space>
@@ -52,7 +56,7 @@
       </VueDraggable>
     </div>
     <div class="binContainer">
-      <div v-if="isChanged || selectIndex === -1">
+      <div v-if="isChanged || selectIndex === -1 || isNoneedEdit">
         <el-empty :image-size="200" :description="getTipContent()" />
       </div>
       <div v-else>
@@ -80,6 +84,7 @@ import { VueDraggable } from "vue-draggable-plus";
 import BottomTable from "@/views/base/craftManagement/route/components/bottomTable.vue";
 import { comTypes } from "@/views/base/craftManagement/route/components/configs";
 import { saveCompoents, getCompoentsList } from "@/api/craft/process/index";
+
 import { useCommonStoreHook, useDictionaryStoreHook } from "@/store";
 import {
   processesByRouteId,
@@ -91,7 +96,7 @@ const route = useRoute();
 
 //组件是否已经改变,如果改变了需要点击保存,才能展示下面的table
 const isChanged = ref(true);
-
+const isNoneedEdit = ref(false); //有些组件是不需要编辑的,所以下面也不展示table
 const loadTopList = () => {
   getCompoentsList(route.params.id).then((res) => {
     selectProComs.value = res.data || [];
@@ -105,7 +110,9 @@ onMounted(async () => {
 });
 
 // 顶部====================
-const back = () => {};
+const back = () => {
+  router.back();
+};
 
 const save = async () => {
   for (let i = 0; i < selectProComs.value.length; i++) {
@@ -127,20 +134,25 @@ const selectProComs = ref([]);
 const selectIndex = ref(-1);
 const currentCom = ref({});
 const handleCommand = (itme) => {
-  console.log(itme);
   selectProComs.value.push(itme);
   isChanged.value = true;
+  selectIndex.value = -1;
 };
 
 // 点击某一个改变下面的table
 const clickToolCom = (com, index) => {
+  // 如果上方组件更改了,提示先保存组件再操作
+  if (isChanged.value) {
+    ElMessage.warning("请先保存组件!!!");
+    return;
+  }
   selectIndex.value = index;
   currentCom.value = com;
   if (com.compentType === "mingpai" || com.compentType === "duomeiticaiji") {
-    isChanged.value = true;
+    isNoneedEdit.value = true;
   } else {
     tableType.value = com.compentType;
-    isChanged.value = false;
+    isNoneedEdit.value = false;
   }
 };
 
@@ -174,17 +186,14 @@ const saveSortData = () => {
 };
 
 const getTipContent = (itemValue) => {
-  let str = "";
-  if (isChanged.value) {
-    if (selectIndex.value === -1) {
-      str = "请先保存组件,然后再进行操作";
-    } else {
-      str = "标准组件无需编辑";
-    }
-  } else {
-    str = "请先选择组件";
+  if (isNoneedEdit.value) {
+    return "标准组件无需编辑";
+  }
+  if (selectIndex.value === -1 && isChanged.value) {
+    return "请先保存组件,然后再进行操作";
   }
-  return str;
+
+  return "请先选择组件";
 };
 </script>