浏览代码

产品管理

liuhairui 1 年之前
父节点
当前提交
0147589341
共有 2 个文件被更改,包括 170 次插入96 次删除
  1. 44 15
      src/view/yunyin/chanpinziliao/chanpinziliao.vue
  2. 126 81
      src/view/yunyin/shengchanguanli/components/addGongYi.vue

+ 44 - 15
src/view/yunyin/chanpinziliao/chanpinziliao.vue

@@ -576,14 +576,19 @@
 
         <layout>
         <!--    左侧树侧形结构-->
-        <layout-sider :resize-directions="['right']" :width="190" style="margin-right: 10px;">
-          <div class="JKWTree-tree" style="height: 200px">
-            <h3> 产品管理</h3>
-            <el-tree :data="treeData" @node-click="handleNodeClick" @node-expand="handleNodeExpand">
-              <template #default="{node,data}">{{data['客户编号']}}【{{data['客户名称']}}】</template>
-            </el-tree>
-          </div>
-        </layout-sider>
+          <layout-sider :resize-directions="['right']" :width="190" style="margin-right: 10px;">
+            <div class="JKWTree-tree" style="height: 200px">
+              <h3> 产品管理</h3>
+              <!--            <el-tree :data="treeData" @node-click="handleNodeClick" @node-expand="handleNodeExpand">-->
+              <!--              <template #default="{node,data}">{{data['客户编号']}}【{{data['客户名称']}}】</template>-->
+              <!--            </el-tree>-->
+              <el-tree :data="treeData" node-key="label" @node-click="handleNodeClick" @node-expand="handleNodeExpand">
+                <template #default="{ node, data }">
+                  {{ node.label }}
+                </template>
+              </el-tree>
+            </div>
+          </layout-sider>
 
         <!--  右侧内容区域 -->
         <layout-content >
@@ -2439,8 +2444,25 @@ const hscstzCancel = () => {hscstzlist.value = false;};
 const treeData = ref({})
 const getCustomdata = async () => {
   try {
-    const data  = await getCustom()
-    treeData.value = data.data;
+    // const data  = await getCustom()
+    // console.log("左侧菜单列表↓")
+    // console.log(data)
+    // treeData.value = data.data;
+    const response = await getCustom();
+    console.log("左侧菜单列表↓");
+    console.log(response);
+    const formattedData = [];
+    for (const category in response.data) {
+      const categoryNode = {
+        label: category, // 使用分类名称作为节点标签
+        children: response.data[category].map(item => ({
+          label: `${item['客户编号']}【${item['客户名称']}】`, // 将客户信息格式化为节点标签
+          ...item // 保留原始数据,可能在后面需要使用
+        }))
+      };
+      formattedData.push(categoryNode);
+    }
+    treeData.value = formattedData;
   } catch (error) {
     console.error('Error fetching custom data:', error);
   }
@@ -2451,6 +2473,11 @@ getCustomdata()
 const tableData = reactive([])
 const _custom_code = ref(null)
 const handleNodeClick = async (node) => {
+  if(node.label === '印刷产品' || node.label === '糊盒产品'){
+    tableData.splice(0);
+    return false;
+  }
+  console.log(node.客户编号)
   _custom_code.value = node.客户编号;
   //清空搜索框
   searchInfo.value = '';
@@ -2476,6 +2503,8 @@ const tableRowClick = async (row) => {
   _product_code.value = row.产品编号;
   _kehu_code.value = row.产品名称;
   const res = await getProductData({product_code:_product_code.value});
+  console.log(row.产品编号 + "--->下方表格获取数据")
+  console.log(res)
   yjtableData.splice(0, yjtableData.length, ...res.data.yjData);
   gytableData.splice(0, gytableData.length, ...res.data.gyData);
   ybtableData.splice(0, ybtableData.length, ...res.data.ybData);
@@ -2678,7 +2707,7 @@ const addcpyj_onclick = () => {
 	  gdyj_clearFormData();
 	  add_gdyjdialogFormVisible.value = true
 	}
-	
+
 }
 //印件代号Tab或回车
 // const openSearchModal = (code) => {
@@ -2835,7 +2864,7 @@ const add_gdyjenterDialog = () => {
 		  type: 'error',
 		  message: '失败'
 		})
-	}	
+	}
   });
 
 }
@@ -3056,7 +3085,7 @@ const selectSHNode = (node,check) => {
    console.log(node.level)
    if(node.level==1){
    	console.log(node.label)
-	
+
    }
    if(node.level==2){
    	add_gyformData.标准损耗=node.sys_bh
@@ -3135,9 +3164,9 @@ const addgyenterDialog = () => {
   		  type: 'error',
   		  message: '失败'
   		})
-  	}	
+  	}
   });
-  
+
 }
 //工艺新增取消
 const addgycloseDialog = () => {

+ 126 - 81
src/view/yunyin/shengchanguanli/components/addGongYi.vue

@@ -38,7 +38,7 @@
               <el-input  v-model="form['工序名称']"  style="width: 300px;" id="工序名称"   @keydown="add_gyzlent($event, '车间名称', '工序名称', '设备编号')" />
             </el-form-item>
             <el-form-item label="计损色数"  class="mab" prop="keyOrder" label-width=" 80">
-              <el-input disabled v-model="form['计损色数']" style="width: 90px;"/>
+              <el-input  v-model="form['计损色数']" style="width: 90px;"/>
             </el-form-item>
           </div>
           <el-form-item label="设备编号:"  class="mab" prop="remark">
@@ -114,9 +114,9 @@
           :props="{children: 'children',label: 'label', value: 'value'}"
           style="border: 1px solid #ececec; padding: 10px;height: 400px;overflow: auto;"
           node-key="value"
-          :default-expanded-keys="['标准工艺']"
       >
       </el-tree>
+<!--         :default-expanded-keys="['标准工艺']"-->
     </el-dialog>
 
 <!--    工序损耗列表-->
@@ -152,11 +152,11 @@ const id = ref()
 const gxList = ref([])
 const yjList = ref()
 const cjList = ref([
-  {
-    label: '标准工艺',
-    value: '标准工艺',
-    children: []
-  }
+  // {
+  //   label: '标准工艺',
+  //   value: '标准工艺',
+  //   children: []
+  // }
 ])
 const gdzl_MachineList_address = ref()
 import { useUserStore } from '@/pinia/modules/user'
@@ -180,22 +180,31 @@ const add_gyzlent = async (event,id1,id2,id3) => {
     cjdisplay.value = true
   }
 
-  if (id2 === '车间名称' &&  event.key=== 'Enter') {
-    form['工艺名称'] = form['车间名称']
-    form['设备编号'] = []
-    //通过车间名称查询机台
-    const MachineList_jitai = await gdzl_MachineList({address:form['车间名称']});
-    gdzl_MachineList_address.value = MachineList_jitai.data;
-    form['shdh'] = ''
-    form['工序损耗名称'] = ''
-  }
-  if (id2 === '工序损耗' &&  event.key==='Tab' || id2 === '工序损耗' && event.key=== 'Enter') {
+  // if (id2 === '车间名称' &&  event.key=== 'Enter') {
+  //   form['设备编号'] = []
+  //   //通过车间名称查询机台
+  //   const MachineList_jitai = await gdzl_MachineList({address:form['车间名称']});
+  //   gdzl_MachineList_address.value = MachineList_jitai.data;
+  //   form['shdh'] = ''
+  //   form['工序损耗名称'] = ''
+  // }
+  if (id2 === '工序损耗' &&  event.key==='Tab') {
     if(form['车间名称']){
       await getGxshList();
-      if (gxshList.value[0].children.length > 1) {
-        gxshdisplay.value = true
-      }
+      // if (gxshList.value[0].children.length > 1) {
+      //   gxshdisplay.value = true
+      // }
+    }
+  }
+  if (id2 === '工序名称' &&  event.key==='Tab') {
+    console.log(213)
+    if(form['工艺名称'] === undefined){
+      form['工艺名称'] = '';
+    }
+    if(form['工序名称'] === undefined){
+      form['工序名称'] = '';
     }
+    form['工序损耗名称'] = `${form['工艺名称']} ${form['工序名称']}`;
   }
   if (event.keyCode === 13 || event.keyCode === 40) { // Enter 或向下箭头
     if(id3!=''){
@@ -222,22 +231,42 @@ const add_gyzlent = async (event,id1,id2,id3) => {
 }
 
 const open = async (gdbh, gxlist) => {
-  visible.value = true
+  Object.keys(form).forEach(key => {
+    form[key] = '';
+  });
 
+  visible.value = true
   id.value = gdbh
   const res = await PrintDetailList({workOrder: id.value})
-  const chejian = await getDepartName()
-  if (chejian && Array.isArray(chejian.data) && chejian.data.length === 0) {
-  } else {
-    cjList.value = [
-      {
-        label: '标准工艺',
-        value: '标准工艺',
-        children: []
-      }
-    ]
-    initChejian(chejian.data['标准工艺'])
+  const apiData = await getDepartName()
+  console.log(apiData)
+  function transformDataToTreeFormat(data) {
+    return Object.entries(data).map(([key, value]) => {
+      // key是车间名称,value是车间内的操作列表
+      const children = Object.entries(value).map(([workshop, operations]) => ({
+        label: workshop,
+        children: operations.map(operation => ({
+          label: operation,
+          value: operation // 可以根据需要添加更多属性
+        }))
+      }));
+      return { label: key, children };
+    });
   }
+  // 使用ref来管理转换后的数据
+  cjList.value = ref(transformDataToTreeFormat(apiData.data));
+
+  // if (chejian && Array.isArray(chejian.data) && chejian.data.length === 0) {
+  // } else {
+  //   cjList.value = [
+  //     {
+  //       label: '标准工艺',
+  //       value: '标准工艺',
+  //       children: []
+  //     }
+  //   ]
+  //   initChejian(chejian.data['标准工艺'])
+  // }
   yjList.value = res.data
   gxList.value = gxlist
 }
@@ -245,22 +274,30 @@ const open = async (gdbh, gxlist) => {
 //工序损耗列表
 const gxshList = ref([])
 const getGxshList = async ()=>{
-  const WastageList_data = await WastageList({search: form['车间名称']})
+  const WastageList_data = await WastageList({process: form.工艺名称})
   console.log(WastageList_data)
-  gxshList.value = [{
-    label: form['车间名称'],
-    value: form['车间名称'],
-    children: []
-  }]
-  if (WastageList_data.data.length === 0) return
-  if (WastageList_data.data.length > 1) {
-    gxshList.value[0].children = WastageList_data.data.map(item => {
-      return { label: `${item.编号} - ${item.名称}`, label2: item.名称, UniqId: item.UniqId, value: item.编号 }
+  if(WastageList_data.data === null || WastageList_data.data === ''){
+    form['shdh'] = '';
+    ElMessage({
+      type: 'warning',
+      message: '未获取到工序损耗'
     })
-  } else {
-    form['shdh'] = WastageList_data.data[0].编号;
-    form['工序损耗名称'] = WastageList_data.data[0].名称;
   }
+  form['shdh'] = WastageList_data.data
+  // gxshList.value = [{
+  //   label: form['车间名称'],
+  //   value: form['车间名称'],
+  //   children: []
+  // }]
+  // if (WastageList_data.data.length === 0) return
+  // if (WastageList_data.data.length > 1) {
+  //   gxshList.value[0].children = WastageList_data.data.map(item => {
+  //     return { label: `${item.编号} - ${item.名称}`, label2: item.名称, UniqId: item.UniqId, value: item.编号 }
+  //   })
+  // } else {
+  //   form['shdh'] = WastageList_data.data[0].编号;
+  //   form['工序损耗名称'] = WastageList_data.data[0].名称;
+  // }
 }
 //点击工序损耗列表数据
 const gxshselectHandle = async (node)=>{
@@ -271,54 +308,62 @@ const gxshselectHandle = async (node)=>{
   }
 }
 const selectHandle = async (node)=>{
-  if (node.children && node.children.length> 0) return
-  function findParentInTree(tree, targetValue) {
-    for (let node of tree) {
-      // 如果找到了目标值,返回当前节点作为上级
-      if (node.value === targetValue) {
-        return node;
-      }
-      // 如果当前节点有子节点,递归地在子节点中查找
-      if (node.children && node.children.length > 0) {
-        let parent = findParentInTree(node.children, targetValue);
-        if (parent) return parent
-      }
-    }
-    // 如果没有找到目标值或其上级,返回null
-    return null;
-  }
-  const _node = findParentInTree(cjList.value, node.value)
-  if(_node.parent){
-    form['车间名称'] = _node.parent
+  // if (node.children && node.children.length> 0) return
+  // function findParentInTree(tree, targetValue) {
+  //   for (let node of tree) {
+  //     // 如果找到了目标值,返回当前节点作为上级
+  //     if (node.value === targetValue) {
+  //       return node;
+  //     }
+  //     // 如果当前节点有子节点,递归地在子节点中查找
+  //     if (node.children && node.children.length > 0) {
+  //       let parent = findParentInTree(node.children, targetValue);
+  //       if (parent) return parent
+  //     }
+  //   }
+  //   // 如果没有找到目标值或其上级,返回null
+  //   return null;
+  // }
+  // const _node = findParentInTree(cjList.value, node.value)
+  // if(_node.parent){
+  //   form['车间名称'] = _node.parent
+  // }else{
+  //   form['车间名称'] = _node.label
+  // }
+  // form['工艺名称'] = _node.label
+
+  console.log(node)
+  if(node.value){
+    form['工艺名称'] = node.value
+    form['工序损耗名称'] = node.value
+    cjdisplay.value = false
   }else{
-    form['车间名称'] = _node.label
+    form['车间名称'] = node.label
   }
-  form['工艺名称'] = _node.label
   form['设备编号'] = []
   //通过车间名称查询机台
   const MachineList_jitai = await gdzl_MachineList({address:form['车间名称']});
   gdzl_MachineList_address.value = MachineList_jitai.data;
   form['shdh'] = ''
-  form['工序损耗名称'] = ''
   //通过车间名称查询工序损耗
   await getGxshList()
-  cjdisplay.value = false
-}
 
-const initChejian = (data) => {
-  Object.keys(data).map( (name, index)=>{
-    const tmp = {
-      label: name, value: name, children: []
-    }
-    data[name].map(item => {
-      tmp.children.push({
-        label: item, value: item,parent: name,
-      })
-    })
-    cjList.value[0].children.push(tmp)
-  })
 }
 
+// const initChejian = (data) => {
+//   Object.keys(data).map( (name, index)=>{
+//     const tmp = {
+//       label: name, value: name, children: []
+//     }
+//     data[name].map(item => {
+//       tmp.children.push({
+//         label: item, value: item,parent: name,
+//       })
+//     })
+//     cjList.value[0].children.push(tmp)
+//   })
+// }
+
 const changeHandle = (v) => {
   const no = '0' + v.no
   let list = gxList.value.map(item => {