Просмотр исходного кода

工艺路线组件绑定合并

dengrui 2 недель назад
Родитель
Сommit
c98c93d0bf

+ 55 - 28
src/views/base/craftManagement/route/bindProcess.vue

@@ -95,27 +95,34 @@
         </el-scrollbar>
       </div>
       <div class="detailInfo">
-        <div v-if="selectIndex > -1 && !isChanged">
-          <avue-form
-            ref="formRef"
-            :option="formOption"
-            v-model="currentProcess"
-            style="padding: 10px; background-color: white"
-          >
-            <!-- <template #tbomUrl>
+        <el-scrollbar style="padding: 10px 0">
+          <template v-if="showEditStauts == false">
+            <div v-if="selectIndex > -1 && !isChanged">
+              <avue-form
+                ref="formRef"
+                :option="formOption"
+                v-model="currentProcess"
+                style="padding: 10px"
+              >
+                <!-- <template #tbomUrl>
               <FilesUpload
                 v-model:src="currentProcess.tbomUrl"
                 :show-tip="false"
               />
             </template>-->
-          </avue-form>
-          <div class="editProcces">
-            <el-button type="primary" :icon="Grid" @click="editProComponent"
-              >编辑工序组件</el-button
-            >
-          </div>
-        </div>
-        <div v-else class="tipContent">{{ tipContent }}</div>
+              </avue-form>
+              <div class="editProcces">
+                <el-button type="primary" :icon="Grid" @click="editProComponent"
+                  >编辑工序组件(会自行保存工序信息)</el-button
+                >
+              </div>
+            </div>
+            <div v-else class="tipContent">{{ tipContent }}</div>
+          </template>
+          <template v-else>
+            <ProcessComponent :key="showEditStauts" />
+          </template>
+        </el-scrollbar>
       </div>
     </div>
   </div>
@@ -137,15 +144,21 @@ import {
   saveProcessInRoute,
   updateProcess,
 } from "@/api/craft/route/index";
-import { v4 as uuidv4 } from "uuid";
+import ProcessComponent from "./components/processComponent.vue";
 import { formOption } from "./bindConfig";
 import { ElMessage } from "element-plus";
+const showEditStauts = ref(false);
+provide("showEditStauts", showEditStauts);
 const editStauts = ref(false);
 const router = useRouter();
 const route = useRoute();
 // 数据字典相关
 const { dicts } = useDictionaryStore();
 
+const prodtCode = route.params.prodtCode;
+provide("prodtCode", prodtCode);
+const routeId = route.params.routeId;
+provide("routeId", routeId);
 // 顶部====================
 const back = () => {
   router.back();
@@ -223,7 +236,8 @@ const clickFlowItem = (item, index) => {
   selectIndex.value = index;
   currentProcess.value = item.operationVO;
 };
-
+const opId = ref();
+provide("id", opId);
 const clickDelete = (index) => {
   list2.value.splice(index, 1);
   onUpdate();
@@ -256,19 +270,29 @@ const loadProcessesFlow = async () => {
 // 右侧具体信息====================
 const formRef = ref(null);
 const currentProcess = ref({});
+
 const tipContent = ref("");
 const handleSubmit = () => {};
 
 const editProComponent = async () => {
   // saveFlow();
   let res = await updateProcess(currentProcess.value);
-  ElMessage.success("保存成功");
-  router.push({
-    path: `/base/craftManagement/processCom/${currentProcess.value.id}/${route.params.prodtCode}/${route.params.routeId}`,
-    // query: { prodtCode: route.query.prodtCode, routeId: route.query.routeId },
-  });
-};
 
+  showEditStauts.value = true;
+};
+watch(isChanged, (val) => {
+  if (val == true) {
+    showEditStauts.value = false;
+  }
+});
+watch(selectIndex, (val) => {
+  if (val != -1) {
+    showEditStauts.value = false;
+  }
+});
+watch(currentProcess, (val) => {
+  opId.value = JSON.parse(JSON.stringify(val.id));
+});
 // 全局=======
 onMounted(() => {
   loadTreeData();
@@ -330,12 +354,11 @@ const getNameByDictType = (dictValue) => {
 }
 
 .flowBox {
-  flex: 1;
   display: flex;
   justify-content: center;
   overflow-y: auto;
+  padding: 0 10px;
   padding-top: 47px;
-  padding-bottom: 47px;
   .notice {
     position: absolute;
     width: 100%;
@@ -349,7 +372,6 @@ const getNameByDictType = (dictValue) => {
   }
   .flowContain {
     width: 400px;
-
     min-height: 200px;
   }
   .flowItem {
@@ -407,7 +429,7 @@ const getNameByDictType = (dictValue) => {
 }
 
 .detailInfo {
-  width: 320px;
+  flex: 1;
   height: 100%;
   border-left: 1px solid rgba(0, 0, 0, 0.1);
   .editProcces {
@@ -437,6 +459,11 @@ const getNameByDictType = (dictValue) => {
   margin-top: 20px;
   color: #e6a23c;
 }
+:deep(.el-collapse-item__wrap) {
+  background-color: #f5f7f9;
+  border-color: #f5f7f9 !important;
+  margin-top: -1px;
+}
 </style>
 
 <style>

+ 17 - 15
src/views/base/craftManagement/route/components/bottomTable.vue

@@ -78,9 +78,11 @@ const props = defineProps({
     type: String,
   },
 });
-
+const id = inject("id");
+const routeId = inject("routeId");
+const prodtCode = inject("prodtCode");
 const route = useRoute();
-const tableConfig = getTableConfig(route.params.id);
+const tableConfig = getTableConfig(id);
 
 // 传入一个url,后面不带/
 const { url, form, data, option, search, page, toDeleteIds, Methords, Utils } =
@@ -102,13 +104,13 @@ const startCreat = () => {
       bomVersion.value = data.value[0].recordVersion;
     }
 
-    if (!route.params.prodtCode) {
+    if (!prodtCode) {
       ElMessage.error("物料编号读取错误");
       return;
     }
     //根据物料编码和版本号获取对应的物料BOM
     let bomParam = {
-      materialCode: route.params.prodtCode,
+      materialCode: prodtCode,
     };
     getBomVersion(bomParam).then((res) => {
       let resListMap = [];
@@ -121,7 +123,7 @@ const startCreat = () => {
       });
       //查询参数
       let configParam = {};
-      configParam.materialCode = route.params.prodtCode;
+      configParam.materialCode = prodtCode;
       if (bomVersion.value) {
         configParam.bomVersion = bomVersion.value;
       }
@@ -154,7 +156,7 @@ const startCreat = () => {
     commonTableType.value = "ESOP";
     nextTick(() => {
       commonTableRef.value?.startSelect({
-        materialCode: route.params.prodtCode,
+        materialCode: prodtCode,
         enable: 1,
       });
       commonTableRef.value?.mergeOption({
@@ -209,12 +211,12 @@ const onSelectedFinish = (itemValue) => {
       recordItem.value.recordVersion = item.bomVersion;
       recordItem.value.num = item.bomMaterialNumber;
       recordItem.value.traceType = "S";
-      recordItem.value.operationId = route.params.id;
+      recordItem.value.operationId = id;
       recordItem.value.unit = item.unit;
       recordItem.value.isTrace = 1;
       itemRecordList.value.push(recordItem.value);
     });
-    itemRecord.value.operationId = route.params.id;
+    itemRecord.value.operationId = id;
     itemRecord.value.itemRecordList = Array.from(itemRecordList.value);
     addBatch(itemRecord.value).then((data) => {
       if (data.code == "200") {
@@ -241,7 +243,7 @@ const onSelectedFinish = (itemValue) => {
     form.value.unit = itemValue.unit;*/
     itemValue?.forEach((item, index) => {
       const recordItem = ref({});
-      recordItem.value.operationId = route.params.id;
+      recordItem.value.operationId = id;
       recordItem.value.checkName = item.checkName;
       recordItem.value.checkCode = item.checkCode;
       recordItem.value.content = item.content;
@@ -251,7 +253,7 @@ const onSelectedFinish = (itemValue) => {
       recordItem.value.unit = item.unit;
       checkList.value.push(recordItem.value);
     });
-    checkItem.value.operationId = route.params.id;
+    checkItem.value.operationId = id;
     checkItem.value.checkList = Array.from(checkList.value);
     addCheckBatch(checkItem.value).then((data) => {
       if (data.code == "200") {
@@ -279,7 +281,7 @@ const onSelectedFinish = (itemValue) => {
     form.value.title = itemValue.drawingTitle;*/
     itemValue?.forEach((item, index) => {
       const recordItem = ref({});
-      recordItem.value.operationId = route.params.id;
+      recordItem.value.operationId = id;
       recordItem.value.filePath = item.pdfPath;
       recordItem.value.showAppointPageNum = 1;
       recordItem.value.drawingCode = item.drawingCode;
@@ -288,7 +290,7 @@ const onSelectedFinish = (itemValue) => {
       recordItem.value.title = item.drawingTitle;
       esopList.value.push(recordItem.value);
     });
-    esopItem.value.operationId = route.params.id;
+    esopItem.value.operationId = id;
     esopItem.value.esopList = Array.from(esopList.value);
     addEsopBatch(esopItem.value).then((data) => {
       if (data.code == "200") {
@@ -319,7 +321,7 @@ const getSOAPpdf = (itemValue) => {
 };
 
 onMounted(() => {
-  search.value.operationId = route.params.id;
+  search.value.operationId = id;
   url.value = tableConfig[props.tableType].url;
   option.value = Object.assign(option.value, {
     addBtn: false,
@@ -329,7 +331,7 @@ onMounted(() => {
     column: tableConfig[props.tableType].column,
   });
   dataList();
-  getRouteMaxVersion(route.params.routeId).then(({ data }) => {
+  getRouteMaxVersion(routeId).then(({ data }) => {
     if (data) {
       bomVersion.value = data;
     }
@@ -350,7 +352,7 @@ watch(
       column: tableConfig[props.tableType].column,
     });
     dataList();
-    getRouteMaxVersion(route.params.routeId).then(({ data }) => {
+    getRouteMaxVersion(routeId).then(({ data }) => {
       if (data) {
         bomVersion.value = data;
       }

+ 14 - 10
src/views/base/craftManagement/route/components/processComponent.vue

@@ -4,15 +4,17 @@
     style="padding: 0; box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1)"
   >
     <div class="header">
-      <div class="title">绑定工序</div>
+      <div class="title">组件编辑</div>
       <el-space>
-        <el-button :icon="Back" size="small" @click="back">返回</el-button>
+        <el-button :icon="Back" size="small" @click="back"
+          >切换工序配置</el-button
+        >
         <el-button
           :type="isChanged ? 'danger' : 'primary'"
           :icon="Document"
           size="small"
           @click="save"
-          >保存</el-button
+          >保存组件编辑</el-button
         >
       </el-space>
     </div>
@@ -101,12 +103,14 @@ import {
 
 const router = useRouter();
 const route = useRoute();
-
+const opId = inject("id");
+const id = opId.value;
+const showEditStauts = inject("showEditStauts");
 //组件是否已经改变,如果改变了需要点击保存,才能展示下面的table
 const isChanged = ref(true);
 const isNoneedEdit = ref(false); //有些组件是不需要编辑的,所以下面也不展示table
 const loadTopList = () => {
-  getCompoentsList(route.params.id).then((res) => {
+  getCompoentsList(id).then((res) => {
     selectProComs.value = res.data || [];
     selectIndex.value = -1;
     isChanged.value = false;
@@ -114,23 +118,23 @@ const loadTopList = () => {
 };
 
 onMounted(async () => {
-  operationId.value = route.params.id;
+  operationId.value = id;
   await loadTopList();
 });
 
 // 顶部====================
 const back = () => {
-  router.back();
+  showEditStauts.value = false;
 };
 const operationId = ref("");
 provide("operationId", operationId);
 const save = async () => {
   for (let i = 0; i < selectProComs.value.length; i++) {
-    selectProComs.value[i].operationId = route.params.id;
+    selectProComs.value[i].operationId = id;
     selectProComs.value[i].sortNum = i;
   }
   let p = {
-    operationId: route.params.id,
+    operationId: id,
     dtos: selectProComs.value,
   };
   let res = await saveCompoents(p);
@@ -315,7 +319,7 @@ const getTipContent = (itemValue) => {
 }
 
 .binContainer {
-  height: calc(100vh - 280px);
+  height: calc(100vh - 360px);
   width: 100%;
   background-color: #f5f7f9;
   overflow-y: auto;

+ 6 - 4
src/views/base/craftManagement/route/components/setExcel/index.vue

@@ -74,6 +74,8 @@ import { getForm, add, deleteTemp } from "@/api/excel";
 const value1 = ref([]);
 const options = ref([]);
 const route = useRoute();
+const routeId = inject("routeId");
+const prodtCode = inject("prodtCode");
 //删除
 const deleteTep = async (id) => {
   const { data, code } = await deleteTemp({
@@ -89,8 +91,8 @@ const deleteTep = async (id) => {
 const onSelected = async () => {
   const { data, code } = await add({
     baseFormIds: value1.value,
-    operationId: route.fullPath.split("/")[4].split("?")[0],
-    materialCode: route.params.prodtCode,
+    operationId: routeId,
+    materialCode: prodtCode,
   });
   if (code == "200") {
     ElMessage.success("添加成功!");
@@ -119,7 +121,7 @@ const setValue1 = () => {
 };
 search.value = {
   ...search.value,
-  operationId: route.fullPath.split("/")[4].split("?")[0],
+  operationId: routeId,
 };
 const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
   Methords; //增删改查
@@ -132,7 +134,7 @@ const getTemplate = async () => {
   const { data } = await getForm({
     pageNo: 1,
     pageSize: 9999999,
-    materialCode: route.query.prodtCode,
+    materialCode: prodtCode,
   });
   options.value = [];
   data.records.forEach((element) => {