Explorar el Código

feat: 添加置空功能等

jiaxing.liao hace 3 semanas
padre
commit
75d609c8ba

+ 1 - 1
auto-imports.d.ts

@@ -6,5 +6,5 @@
 // biome-ignore lint: disable
 export {}
 declare global {
-
+  const ElMessageBox: typeof import('element-plus/es')['ElMessageBox']
 }

+ 18 - 17
src/components/mindmap/Mindmap.vue

@@ -39,8 +39,6 @@ const props = withDefaults(
   defineProps<{
     data?: any;
     readonly?: boolean;
-    // 1工程bom 2制造bom
-    type?: string;
   }>(),
   {
     readonly: false,
@@ -76,11 +74,23 @@ watch(
 );
 
 watch(
-  () => props.readonly,
-  (val) => {
-    mindmap.value?.setMode(val ? "readonly" : "edit");
+  () => [props.readonly, mindmap.value],
+  () => {
+    // 只读
+    if(props.readonly) {
+      // @ts-ignore
+      mindmap.value?.keyCommand.pause();
+    } else {
+      // @ts-ignore
+      mindmap.value?.keyCommand.recovery();
+      // @ts-ignore
+      mindmap.value?.keyCommand.removeShortcut("Del");
+    }
+  },
+  {
+    immediate: true
   }
-);
+)
 
 onMounted(() => {
   // 默认配置
@@ -96,18 +106,14 @@ onMounted(() => {
     layout: config?.layout || "logicalStructure",
     // 拖拽限制
     beforeDragStart: ([node]: any[]) => {
-      console.log("dran start", node.nodeData);
       const data = node?.nodeData.data;
 
-      return data?.is_disable;
+      return data?.is_disable || props.readonly;
     },
-    // 只读
-    readonly: !!props.readonly,
     isUseCustomNodeContent: true,
     customCreateNodeContent: (node: any) => {
       const sourceData = node.nodeData;
       const data = sourceData.data;
-      console.log("node data", data);
       const App = defineComponent({
         render() {
           return (
@@ -209,13 +215,8 @@ onMounted(() => {
       return div;
     },
   } as any);
-  // 制造bom因此新增
-  if(props.type == '2') {
-    // @ts-ignore TODO 临时隐藏Tab新增功能
-    instance.keyCommand.removeShortcut("Tab");
-  }
   
-  // @ts-ignore TODO 临时隐藏Del删除功能
+  // @ts-ignore 临时隐藏Del删除功能
   instance.keyCommand.removeShortcut("Del");
 
   // 事件监听

+ 73 - 11
src/pages/excel/ConfigDrawer.vue

@@ -9,7 +9,7 @@
       ref="form"
       label-position="top"
       :model="formData"
-      :disabled="nodeData?.is_disable"
+      :disabled="nodeData?.is_disable || readonly"
       scroll-to-error
     >
       <el-row :gutter="12">
@@ -65,7 +65,7 @@
         <el-col :span="12">
           <el-form-item label="产品类别" name="product_category">
             <el-select
-              :disabled="!!originFormData?.erp_code"
+              :disabled="!!originFormData?.erp_code && !isEmpty"
               v-model="formData.product_category"
               placeholder="请选择"
             >
@@ -85,7 +85,20 @@
         <!-- 制造工艺 -->
         <el-col :span="12">
           <el-form-item label="制造工艺" name="process">
-            <el-input placeholder="请输入" v-model="formData.process" />
+            <el-select
+              v-model="formData.process"
+              placeholder="请选择"
+            >
+              <el-option
+                v-for="item in processOptions.map((item) => ({
+                  label: item,
+                  value: item,
+                }))"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+              />
+            </el-select>
           </el-form-item>
         </el-col>
 
@@ -118,7 +131,7 @@
         <el-col :span="12" v-if="type == '2'">
           <el-form-item label="制造区域" prop="manufacture_area">
             <el-select
-              :disabled="!!originFormData?.erp_code"
+              :disabled="!!originFormData?.erp_code && !isEmpty"
               v-model="formData.manufacture_area"
               placeholder="请选择"
             >
@@ -139,7 +152,7 @@
         <el-col :span="12" v-if="type == '2'">
           <el-form-item label="制造单元" prop="manufacture_report">
             <el-select
-              :disabled="!!originFormData?.erp_code"
+              :disabled="!!originFormData?.erp_code && !isEmpty"
               v-model="formData.manufacture_report"
               placeholder="请选择"
             >
@@ -175,18 +188,25 @@
               <el-button
                 type="text"
                 :icon="CirclePlus"
-                :disabled="layerIndex === 1 || !!originFormData?.erp_code"
+                :disabled="layerIndex === 1 || (!!originFormData?.erp_code && !isEmpty) || erpCodeDisabled"
                 @click="openRecomendModal"
               >
                 推荐
               </el-button>
               <el-button
                 type="text"
-                :disabled="!!originFormData?.erp_code"
+                :disabled="(!!originFormData?.erp_code && !isEmpty) || erpCodeDisabled"
                 @click="handleGenratorErpCode"
               >
                 生成
               </el-button>
+              <el-button
+                type="text"
+                v-if="!!originFormData?.erp_code"
+                @click="handleEmptyErpCode"
+              >
+                置空
+              </el-button>
             </div>
           </el-form-item>
         </el-col>
@@ -195,7 +215,7 @@
         <el-col :span="12">
           <el-form-item label="自制/外购/支给(M/P/C)" prop="part_type">
             <el-select
-              :disabled="!!originFormData?.erp_code"
+              :disabled="!!originFormData?.erp_code && !isEmpty"
               v-model="formData.part_type"
               placeholder="请选择"
               @change="handlePartTypeChange"
@@ -214,7 +234,7 @@
         <el-col :span="12">
           <el-form-item label="零件属性" name="part_attribute">
             <el-select
-              :disabled="!!originFormData?.erp_code"
+              :disabled="!!originFormData?.erp_code && !isEmpty"
               v-model="formData.part_attribute"
               placeholder="请先选择M/P/C类型"
             >
@@ -524,14 +544,14 @@
     </el-form>
     <template #footer>
       <el-button @click="visible = false">取消</el-button>
-      <el-button type="primary" @click="handleSubmit">确定</el-button>
+      <el-button v-if="!readonly" type="primary" @click="handleSubmit">确定</el-button>
     </template>
   </el-drawer>
   <TableModal ref="recomendRef" @ok="handleRecomend" />
 </template>
 
 <script setup lang="ts">
-import { ref, defineExpose, defineEmits, computed } from "vue";
+import { ref, defineExpose, defineEmits, computed, defineProps } from "vue";
 import { ElMessage, type FormInstance } from "element-plus";
 import { cloneDeep } from "lodash-es";
 import { CirclePlus } from "@element-plus/icons-vue";
@@ -541,6 +561,17 @@ import { useRoute } from "vue-router";
 
 const route = useRoute();
 const type = (route.query?.type as string) ?? "1"; // 1工程bom 2制造bom
+defineProps<{
+  readonly: boolean;
+}>();
+// 置空
+const isEmpty = ref(false);
+
+// 置空操作
+const handleEmptyErpCode = () => {
+  formData.value.erp_code = "";
+  isEmpty.value = true;
+}
 
 const keyMap = {
   gridorders: "序号",
@@ -645,6 +676,29 @@ const procuctTypeOptions = [
 // 制造区域
 const manufatureAreaOptions = ["大连工厂", "孝感工厂"];
 
+// 制造工艺
+const processOptions = [
+  "普通注塑",
+  "嵌件注塑",
+  "加饰注塑",
+  "机器人喷涂",
+  "往复机喷涂",
+  "手工喷涂",
+  "丝网印刷",
+  "吸塑",
+  "PUR",
+  "产线装配",
+  "焊接",
+  "镭雕",
+  "移印",
+  "冲切",
+  "热压",
+  "CNC",
+  "手工装配",
+  "整理",
+  "打磨",
+]
+
 const visible = ref(false);
 const layerIndex = ref(0);
 const formData = ref<Record<string, any>>({
@@ -670,10 +724,18 @@ const recomendRef = ref<{
   open: (partName: string, partType: string) => void;
 }>();
 
+// 1.工程BOM只有P,C件这两个按钮才可以操作
+// 2.制造BOM只有M件,这两个按钮才可以操作
+const erpCodeDisabled = computed(() => {
+  if(type === "1") return formData.value.part_type === "M" || !formData.value.part_type;
+  if(type === "2") return formData.value.part_type !== "M" || !formData.value.part_type;
+});
+
 const editType = ref<"add" | "edit">("edit");
 const open = (node: any, type?: "add" | "edit", layer?: number) => {
   layerIndex.value = node?._node?.layerIndex || layer;
   visible.value = true;
+  isEmpty.value = false;
   nodeData.value = cloneDeep(node.data);
   editType.value = type || !node?.id ? "add" : "edit";
   form.value?.resetFields();

+ 16 - 4
src/pages/excel/MindmapModal.vue

@@ -41,12 +41,13 @@
         </el-form-item>
       </el-form>
       <div class="flex items-center gap-4px">
+        <span class="text-12px text-green mr-12px">最新版本号:{{ latestVersion || '-'}}</span>
         <span class="text-12px mr-12px font-bold text-#f56c6c">{{ type == '1' ? '工程BOM' : '制造BOM'}}编辑</span>
         <span class="text-12px text-yellow mr-12px">当前版本号:{{ version || '-'}}</span>
         <el-button type="primary" link @click="handleSave" class="mr-8px"
           ><img class="w-1em mr-4px" :src="saveImg" alt="" />保存</el-button
         >
-        <el-tooltip content="添加" v-if="type == '1'">
+        <el-tooltip content="添加" v-if="type == '1' && !readonly">
           <el-button
             type="default"
             circle
@@ -54,7 +55,7 @@
             @click="addNode"
           />
         </el-tooltip>
-        <el-tooltip content="删除" v-if="type == '1'">
+        <el-tooltip content="删除" v-if="type == '1' && !readonly">
           <el-button
             type="default"
             circle
@@ -101,6 +102,7 @@
         v-model:data="data"
         ref="mindmapRef"
         :type="type"
+        :readonly="type == '2' || readonly"
         @node-dbl-click="handleNodeDbClick"
         @data-change="handleDataChange"
       />
@@ -109,7 +111,7 @@
     </div> -->
   </div>
 
-  <ConfigDrawer ref="configDrawerRef" @ok="handleConfigOk" />
+  <ConfigDrawer ref="configDrawerRef" @ok="handleConfigOk" :readonly="readonly" />
 </template>
 
 <script setup lang="ts">
@@ -122,6 +124,9 @@ import {
   onMounted,
   onBeforeUnmount,
   defineEmits,
+  inject,
+  computed,
+  type Ref,
 } from 'vue';
 import {
   Aim,
@@ -152,12 +157,14 @@ const props = defineProps<{
   type?: string;
 }>();
 
+const latestVersion = inject<Ref<string>>('latestVersion');
 const visible = ref(!!props.defaultOpen);
 const mindmapRef = ref<MindMapInstance>();
 const configDrawerRef = ref();
 const formRef = ref<FormInstance>();
 const emit = defineEmits(['refresh']);
 // const editBomStore = useEditBomStore();
+
 const data = ref(
   props?.defaultData || {
     id: 'root',
@@ -168,6 +175,11 @@ const data = ref(
   }
 );
 
+// 当前版本号与最新版本号不一致时,禁止修改
+const readonly = computed(() => {
+  return props.version != latestVersion?.value;
+})
+
 // 1、初次读取本地缓存配置
 const defaultConfig = JSON.parse(
   localStorage.getItem('mindmap-config') || '{}'
@@ -456,7 +468,7 @@ defineExpose({
 
 const handlePressDel = (e: KeyboardEvent) => {
   // 删除节点
-  if (e.key === 'Delete' && visible.value && props.type == '1') {
+  if (e.key === 'Delete' && visible.value && props.type == '1' && !readonly.value) {
     e.preventDefault();
     removeNode();
   }

+ 25 - 25
src/pages/mindmap/index.vue

@@ -11,7 +11,7 @@
 </template>
 
 <script setup lang="ts">
-import { onMounted, ref } from 'vue';
+import { onMounted, ref, provide } from 'vue';
 import MindmapModal from '../excel/MindmapModal.vue';
 import { useRoute } from 'vue-router';
 // import { isEqual } from 'lodash-es';
@@ -25,11 +25,14 @@ const route = useRoute();
 const mindmapData = ref<any>();
 const version = route.query?.version as string;
 const type = route.query?.type as string;
+const latestVersion = ref<string>();
+
+// 最新版本
+provide('latestVersion', latestVersion);
 
 const getData = () => {
   if (!route.query?.id) return;
-  // const cache = sessionStorage.getItem(route.query.id as string);
-  // const cacheData = cache ? JSON.parse(cache) : undefined;
+
   const loading = window.parent?.BpmTools?.program
     ? ElLoading.service({
         lock: true,
@@ -45,16 +48,11 @@ const getData = () => {
     },
     (res: any) => {
       loading?.close();
-      // if (cacheData && res?.data && !isEqual(cacheData, res?.data)) {
-      //   ElMessageBox.confirm('当前存在编辑未保存的数据,是否加载缓存数据?')
-      //     .then(() => {
-      //       mindmapData.value = cacheData;
-      //     })
-      //     .catch(() => {
-      //       mindmapData.value = res?.data;
-      //     });
-      // } else if (res?.code) {
-      if (res?.data) mindmapData.value = res.data;
+
+      if (res?.data) {
+        mindmapData.value = res.data;
+        latestVersion.value = res.data?.latestversion;
+      }
       // }
     }
   );
@@ -65,12 +63,13 @@ onMounted(() => {
   // fetch(`https://sl-yf-bommgr-admin-dev.shalu.com/api/module/Invoke`, {
   //   method: 'POST',
   //   headers: {
-  //     Authorization: 'bpm_client_1425496253931720704',
+  //     Authorization: 'bpm_client_1440422226754015232',
   //     'content-type': 'application/json;charset=UTF-8',
   //   },
   //   body: JSON.stringify({
   //     interfaceCode: 'Common.getBOMAiImageData',
-  //     bom_id: '7f492047-5127-45fc-9398-b5effd640f79',
+  //     bom_id: '4f9ed4bb-3f5b-4ec8-a0f4-a2626e17877f',
+  //     version: '2'
   //   }),
   // })
   //   .then((res) => res.json())
@@ -79,17 +78,18 @@ onMounted(() => {
   //     const cache = sessionStorage.getItem('7f492047-5127-45fc-9398-b5effd640f79');
   //     const cacheData = cache ? JSON.parse(cache) : undefined;
   //     console.log('res', res, cacheData);
-  //     if (cacheData && res?.data && !isEqual(cacheData, res?.data)) {
-  //       ElMessageBox.confirm(
-  //         '当前存在编辑未保存的数据,是否加载缓存数据?'
-  //       ).then(() => {
-  //         mindmapData.value = cacheData;
-  //       }).catch(() => {
-  //         mindmapData.value = res?.data;
-  //       });
-  //     } else if (res?.code) {
+  //     // if (cacheData && res?.data && !isEqual(cacheData, res?.data)) {
+  //     //   ElMessageBox.confirm(
+  //     //     '当前存在编辑未保存的数据,是否加载缓存数据?'
+  //     //   ).then(() => {
+  //     //     mindmapData.value = cacheData;
+  //     //   }).catch(() => {
+  //     //     mindmapData.value = res?.data;
+  //     //   });
+  //     // } else if (res?.code) {
   //       mindmapData.value = res?.data;
-  //     }
+  //       latestVersion.value = res.data?.latestversion;
+  //     // }
   //   });
 
   getData();

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 1 - 1
stats.html