Kaynağa Gözat

工序报工 bug修改

longfenglin 1 yıl önce
ebeveyn
işleme
285b55f527

+ 209 - 0
src/mixins/tableColumnsMixin.js

@@ -0,0 +1,209 @@
+import request from '@/utils/request';
+
+export default {
+  data() {
+    return {
+      newColumns: []
+    };
+  },
+  created() {
+    //从服务器获取缓存列表配置
+    this.getTabColumns();
+    // 创建防抖函数并绑定this
+    this.debouncedHandleColumnChange = this.debounce(
+      this.handleColumnChangeImpl,
+      1000
+    );
+  },
+  methods: {
+    // 实际的列变更处理逻辑
+    handleColumnChangeImpl() {
+      try {
+        const list = this.getStorage(this.cacheKeyUrl + 'Cols');
+        if (list) {
+          this.saveColumns(list);
+        }
+      } catch (error) {
+        console.error('处理列配置出错:', error);
+      }
+    },
+
+    // 列表变化回调
+    handleColumnChange() {
+      this.debouncedHandleColumnChange();
+    },
+
+    // 获取table-column配置
+    async getTabColumns() {
+      const res = await this.getByTableId(this.cacheKeyUrl);
+      if (res?.columnConfig?.length > 0) {
+        //对比接口返回和本地columns
+        let { nlist, type } = this.columnsContrast(res.columnConfig);
+        //有更新则更新服务缓存配置
+        if (type) {
+          this.saveColumns(nlist);
+        }
+        this.setStorage(this.cacheKeyUrl + 'Cols', nlist);
+        // 更新列
+        if (this._computedWatchers && this._computedWatchers.columns) {
+          // console.log('columns 是计算属性');
+          this.columnsVersion++;
+        } else {
+          // console.log('columns 是 data 属性');
+          this.columns = [...this.columns];
+          this.newColumns = [...this.newColumns];
+        }
+      }
+    },
+    //服务器和本地配置columns对比
+    columnsContrast(list) {
+      const key = 'label';
+      var updateType = 0;
+      let sList = list.filter((d, i, r) => {
+        return d[key];
+      });
+      let devColumns =
+        this.newColumns?.length > 0 ? this.newColumns : this.columns;
+      let dList = devColumns.filter((d, i, r) => {
+        return d[key] && d[key] !== '序号';
+      });
+      const keysA = new Set(sList.map((item) => item[key]));
+      const keysB = new Set(dList.map((item) => item[key]));
+      // 本地 比 缓存服务端 多的对象(新增)
+      const added = dList.filter((item) => {
+        return !keysA.has(item[key]) && (item.prop || item.label === '操作');
+      });
+      // 本地 比 缓存服务端 少的对象(删除)
+      const removed = sList.filter((item) => !keysB.has(item[key]));
+      const removedPropSet = new Set(removed.map((item) => item[key]));
+      // 删除 缓存中 中被移除的对象
+      const keptA = list.filter((item) => !removedPropSet.has(item[key]));
+      added.forEach((item) => {
+        //新增columns字段prop参数为必填
+        if (item.prop) {
+          item.id = item.prop;
+        } else if (item.columnKey) {
+          item.id = item.columnKey;
+        }
+        item.checked = true;
+      });
+
+      if (added.length > 0 || removed.length > 0) {
+        updateType = 1;
+      }
+
+      // 更新项:key 存在但内容变化
+      const dMap = new Map(dList.map((item) => [item[key], item]));
+      const updated = keptA.map((sItem) => {
+        const dItem = dMap.get(sItem[key]);
+        if (dItem && dItem.prop && sItem.prop !== dItem.prop) {
+          updateType = 1;
+          // 记录旧值和新值
+          const oldValue = sItem.prop;
+          const newValue = dItem.prop;
+          // 遍历所有属性,动态替换匹配旧值的字段
+          const updatedItem = { ...sItem };
+          Object.keys(updatedItem).forEach((k) => {
+            if (updatedItem[k] === oldValue) {
+              updatedItem[k] = newValue;
+            }
+          });
+          return updatedItem;
+        }
+        return sItem;
+      });
+
+      // 合并保留的对象和新增的对象
+      return { nlist: [...updated, ...added], type: updateType };
+    },
+
+    // 提交columns配置
+    async saveColumns(e) {
+      const data = {
+        tableId: this.cacheKeyUrl,
+        columnConfig: e
+      };
+      const msg = await this.saveTableConfig(data);
+      // console.log('列配置保存成功:', msg);
+      return msg;
+    },
+
+    //获取localstorage缓存
+    setStorage(key, value) {
+      try {
+        localStorage.setItem(key, JSON.stringify(value));
+      } catch (e) {
+        console.log('LocalStorage 存储错误:', e);
+        if (e.name === 'QuotaExceededError') {
+          this.clearCacheByPrefix(); //缓存不足,清除
+          localStorage.setItem(key, JSON.stringify(value));
+        }
+      }
+    },
+
+    //缓存不足清除缓存
+    clearCacheByPrefix() {
+      const prefix = 'Cols'; // 标识后缀
+      Object.keys(localStorage).forEach((key) => {
+        if (key.endsWith(prefix)) {
+          localStorage.removeItem(key);
+          // console.log(`已清除缓存: ${key}`);
+        }
+      });
+      // console.log('缓存清除完成');
+    },
+
+    //设置localstorage缓存
+    getStorage(key) {
+      try {
+        const value = localStorage.getItem(key);
+        return value ? JSON.parse(value) : null;
+      } catch (e) {
+        console.error('LocalStorage 解析错误:', e);
+        return null;
+      }
+    },
+
+    //防抖函数
+    debounce(fn, delay) {
+      let timer = null;
+      return (...args) => {
+        clearTimeout(timer);
+        timer = setTimeout(() => {
+          fn.apply(this, args);
+        }, delay);
+      };
+    },
+
+    //获取column记录接口
+    async getByTableId(key) {
+      try {
+        const res = await request.get(
+          `/sys/table-config/getByTableId/${key}`,
+          {}
+        );
+        if (res.data.code == 0) {
+          return res.data.data;
+        }
+      } catch (error) {
+        console.error('获取列配置失败:', error);
+      }
+    },
+
+    // 添加column记录接口
+    async saveTableConfig(data) {
+      try {
+        const res = await request({
+          url: '/sys/table-config/save',
+          method: 'post',
+          data
+        });
+        if (res.data.code == 0) {
+          return res.data.data;
+        }
+      } catch (error) {
+        console.error('保存列配置失败:', error);
+      }
+    }
+  }
+};

+ 20 - 0
src/utils/index.js

@@ -142,3 +142,23 @@ export function pushZero (num) {
 export function tableIndex (index, page, size) {
   return index + 1 + size * (page - 1)
 }
+
+  // 时间戳转化为年月日时分秒
+ export function timestampToDateTime(timestamp) {
+  const date = new Date(parseInt(timestamp));
+  const year = date.getFullYear();
+  const month = date.getMonth() + 1; // 月份从0开始,所以需要加1
+  const day = date.getDate();
+  const hours = date.getHours();
+  const minutes = date.getMinutes();
+  const seconds = date.getSeconds();
+
+  // 格式化输出,补零操作
+  const formattedMonth = month < 10 ? '0' + month : month;
+  const formattedDay = day < 10 ? '0' + day : day;
+  const formattedHours = hours < 10 ? '0' + hours : hours;
+  const formattedMinutes = minutes < 10 ? '0' + minutes : minutes;
+  const formattedSeconds = seconds < 10 ? '0' + seconds : seconds;
+
+  return `${year}-${formattedMonth}-${formattedDay} ${formattedHours}:${formattedMinutes}:${formattedSeconds}`;
+}

+ 2 - 1
src/views/produce/components/feeding/components/instanceBom.vue

@@ -93,8 +93,9 @@
 
       <el-table-column
         v-if="clientEnvironmentId == 3 && workInfo.singleReport ==1"
-        :label="currentTaskDiagram.isFirstTask == 1 ? '物料重量' : '上道重量'"
+        :label="currentTaskDiagram.isFirstTask == 1 ? '物料重量' : '上道工序重量'"
         type="weightUnit"
+        width="120"
       >
         <template slot-scope="{ row, $index }">
           <div v-if="currentTaskDiagram.isFirstTask == 1">

+ 2 - 1
src/views/produce/components/feeding/components/semiProductBom.vue

@@ -74,8 +74,9 @@
 
       <el-table-column
          v-if="clientEnvironmentId == 3 && workInfo.singleReport == 1"
-        :label="currentTaskDiagram.isFirstTask == 1 ? '物料重量' : '上道重量'"
+        :label="currentTaskDiagram.isFirstTask == 1 ? '物料重量' : '上道工序重量'"
         type="weightUnit"
+        width="120"
       >
         <template slot-scope="{ row, $index }">
           <div v-if="currentTaskDiagram.isFirstTask == 1">

+ 24 - 11
src/views/produce/components/footBtn.vue

@@ -52,7 +52,7 @@ export default {
       ],
       btnList2: [
         {
-          name: '质检',
+          name: '取样质检',
           type: 'inspection',
           bjColor: '#FBD114'
         },
@@ -121,15 +121,21 @@ export default {
     }
   },
   watch: {
-    // taskObj(val) {
-    //   if (this.clientEnvironmentId == 2 && val.type == 3) {
-    //     this.btnList[1].name = '质检';
-    //     this.btnList[1].type = 'inspection';
-    //   } else {
-    //     this.btnList[1].name = '投料';
-    //     this.btnList[1].type = 'feed';
-    //   }
-    // },
+    taskObj(val) {
+      // if (this.clientEnvironmentId == 2 && val.type == 3) {
+      //   this.btnList[1].name = '质检';
+      //   this.btnList[1].type = 'inspection';
+      // } else {
+      //   this.btnList[1].name = '投料';
+      //   this.btnList[1].type = 'feed';
+      // }
+      if(this.clientEnvironmentId == 3 && (this.taskObj.type == 3||this.taskObj.type == 6)){
+          let index=this.btnList2.findIndex(obj => obj.name == '取样质检');
+          if( index !==-1){
+            this.btnList2.splice(0, 1);
+          }
+      }
+    },
     type: {
       handler(v) {
 
@@ -159,7 +165,14 @@ export default {
 
   },
 
-  created() { },
+  created() { 
+
+  },
+  mounted(){
+      // if(this.clientEnvironmentId == 3 && (this.taskObj.type == 3||this.taskObj.type == 6)){
+      //     this.btnList2.splice(0, 1);
+      // }
+  },
   methods: {
     footClick(type) {
       this.$emit('footBtn', type);

+ 2 - 1
src/views/produce/components/inspection/components/instanceBom.vue

@@ -91,8 +91,9 @@
 
       <el-table-column
         v-if="clientEnvironmentId == 3 && workInfo.singleReport ==1"
-        :label="currentTaskDiagram.isFirstTask == 1 ? '物料重量' : '上道重量'"
+        :label="currentTaskDiagram.isFirstTask == 1 ? '物料重量' : '上道工序重量'"
         type="weightUnit"
+        width="180"
       >
         <template slot-scope="{ row, $index }">
           <div v-if="currentTaskDiagram.isFirstTask == 1">

+ 2 - 1
src/views/produce/components/inspection/components/semiProductJobBomPL.vue

@@ -272,9 +272,10 @@
       <el-table-column
         v-if="singleReport == 1"
         :label="
-          item.currentTaskDiagram.isFirstTask == 1 ? '物料重量' : '上道重量'
+          item.currentTaskDiagram.isFirstTask == 1 ? '物料重量' : '上道工序重量'
         "
         prop="weightUnit"
+        width="120"
       >
         <template slot-scope="{ row, $index }">
           <div v-if="item.currentTaskDiagram.isFirstTask == 1">

+ 4 - 1
src/views/produce/components/jobBooking/components/semiProductJobBom.vue

@@ -354,6 +354,7 @@ export default {
       deep: true,
       handler(newVal) {
         this.deviceList = newVal;
+        console.log(newVal,'1111121547646549896498')
         this.changeHeatNumber();
       }
     },
@@ -462,10 +463,12 @@ export default {
     },
 
     handleInput() {
+      console.log(12354987498498)
       let arr = JSON.parse(JSON.stringify(this.list));
       this.sumweight(arr);
       this.sunTj();
-      this.$set(this, 'list', arr);
+      console.log('arr11111112222',arr)
+      console.log('this.list33333',this.list)
     },
 
     changeHeatNumber() {

+ 2 - 1
src/views/produce/components/jobBooking/components/semiProductJobBomPL.vue

@@ -272,9 +272,10 @@
       <el-table-column
         v-if="singleReport == 1"
         :label="
-          item.currentTaskDiagram.isFirstTask == 1 ? '物料重量' : '上道重量'
+          item.currentTaskDiagram.isFirstTask == 1 ? '物料重量' : '上道工序重量'
         "
         prop="weightUnit"
+        width="120"
       >
         <template slot-scope="{ row, $index }">
           <div v-if="item.currentTaskDiagram.isFirstTask == 1">

+ 4 - 4
src/views/produce/components/jobBooking/details.vue

@@ -50,12 +50,12 @@
           " pattern="job" :revolvingDiskList="objData.revolvingDiskList"></revolvingDiskBom>
 
 
-          <!-- //单报工 -->
+          <!-- //单报工 -->
           <semiProductJobBom v-if="
             objData.semiProductList &&
             (objData.semiProductList.length != 0)  &&
             objData.singleReport == 1
-          " :list="objData.semiProductList" :item="objData" :isDetails="true" :singleReport="objData.singleReport">
+          " :list="objData.semiProductList" :item="objData" :isDetails="true" :singleReport="objData.singleReport" :equipmentList="objData.equipmentList">
           </semiProductJobBom>
 
           <!-- 批量报工 -->
@@ -66,10 +66,10 @@
           " :list="objData.semiProductList" :item="objData" :isDetails="true" :singleReport="objData.singleReport">
           </semiProductJobBomPL>
 
-          <oneJobQualityBom v-if="
+          <!-- <oneJobQualityBom v-if="
             objData.semiProductList &&
             (objData.semiProductList.length != 0) && (taskType == 6) && clientEnvironmentId == 3 && objData.singleReport == 1
-          " :list="objData.semiProductList" :item="objData" :isDetails="true"></oneJobQualityBom>
+          " :list="objData.semiProductList" :item="objData" :isDetails="true"></oneJobQualityBom> -->
 
           <oneJobQualityBomPL v-if="taskType == 6 && clientEnvironmentId == 3 && objData.singleReport == 0"
             :list="objData.semiProductList" :item="objData" :isDetails="true"></oneJobQualityBomPL>

+ 5 - 7
src/views/produce/components/jobBooking/index.vue

@@ -32,7 +32,7 @@
         <workOrderBom :item="item"></workOrderBom>
 
         <!-- 报工时间 -->
-        <div v-if="item.currentTaskDiagram.type == 1">
+        <div>
           <div class="title_box rx-bc">
             <div class="name">报工时间</div>
           </div>
@@ -68,16 +68,13 @@
         </revolvingDiskBom>
 
         <!-- 单件 报告信息 -->
-
         <semiProductJobBom :singleReport="item.singleReport" v-if="
           item.semiProductList &&
           item.semiProductList.length != 0 &&
           taskObj.type != 4 &&
-          taskObj.type != 6 &&
           item.singleReport == 1
         " :item="item" :list="item.semiProductList" :equipmentList="item.equipmentList"></semiProductJobBom>
 
-
         <!-- <checkbox :tableData="item.semiProductList" ></checkbox> -->
         <!-- :itemData="item" @tableDataFn="tableDataFn" -->
         <!-- 批量 -->
@@ -89,13 +86,13 @@
           item.singleReport == 0
         " :item="item" :list="item.semiProductList" :equipmentList="item.equipmentList"></semiProductJobBomPL>
 
-        <semiProductJobBom v-if="
+        <!-- <semiProductJobBom v-if="
           item.pickOutInList &&
           item.pickOutInList.length != 0 &&
           taskObj.type == 6 &&
           item.singleReport == 1
         " :item="item" :list="item.pickOutInList">
-        </semiProductJobBom>
+        </semiProductJobBom> -->
 
 
         <oneJobQualityBomPL v-if="
@@ -324,6 +321,7 @@ export default {
 
             if (this.taskObj.type == 6 && this.clientEnvironmentId == 3) {
               obj.semiProductList = obj.pickOutInList;
+              obj.pickOutInList=[]
             }
 
             if (
@@ -561,7 +559,7 @@ console.log('4444444444',this.List)
         });
       }
 
-      let arr = this.List.filter((L) => L.executorTime)
+      let arr = this.List.filter((L) => L.workReportInfo.executorTime)
 
       if (!arr.length) {
         this.loading.close();

+ 16 - 4
src/views/produce/components/outsourcing/index.vue

@@ -33,15 +33,15 @@
                         style="width: 260px;"></el-input>
                 </el-form-item>
                 <!-- v-if="attributeData.isFirstTask != 1" -->
-                <el-form-item label="直接入库:" borderBottom prop="isInWarehouse" >
+                <el-form-item label="直接入库:" borderBottom prop="warehouseId" >
                     <div style="display: flex;">
                         <div style="font-size: 15px;" v-if="attributeData.clientEnvironmentId == 2">是</div>
                         <!-- <el-checkbox-group v-model="isInWarehouse" size="15px" v-if="attributeData.clientEnvironmentId != 2 ">
                             <el-checkbox labelSize="15px" iconSize="10px" activeColor="#157A2C" name="true"
                                 label="是"></el-checkbox>
                         </el-checkbox-group> -->
-                        <el-checkbox labelSize="15px" iconSize="10px" v-model="isInWarehouse" activeColor="#157A2C" name="true"
-                                label="是" v-if="attributeData.clientEnvironmentId != 2 "></el-checkbox>
+                        <!-- <el-checkbox labelSize="15px" iconSize="10px" v-model="isInWarehouse" activeColor="#157A2C" name="true"
+                                label="是" v-if="attributeData.clientEnvironmentId != 2 "></el-checkbox> -->
                         <el-select v-if="attributeData.clientEnvironmentId == 2 || isInWarehouse" v-model="attributeData.warehouseId" placeholder="请选择" style="width: 222px;">
                             <el-option v-for="item in warehouseList" :key="item.id" :label="item.name"
                                 :value="item.id">
@@ -118,6 +118,18 @@ export default {
                 type: [
                     { required: true, message: '请选择委外类型', trigger: 'blur' },
                 ],
+                formedNumLast: [
+                    { required: true, message: '请输入委外数量', trigger: 'blur' },
+                ],
+                taskIds: [
+                    { required: true, message: '请选择', trigger: 'blur' },
+                ],
+                sceneText: [
+                    { required: true, message: '请选择委外场景', trigger: 'blur' },
+                ],
+                warehouseId: [
+                    { required: true, message: '请选择', trigger: 'blur' },
+                ],
                 requireDeliveryTime: [
                     { required: true, message: '请选择计划交期时间', trigger: 'blur' },
                 ]
@@ -220,7 +232,7 @@ export default {
         confirm() {
             this.$refs.form.validate((valid) => {
                 if (valid) {
-                    console.log(this.attributeData);
+                    console.log(this.attributeData,'11111187887877');
                     this.$emit('changePlugIn', this.attributeData);
                 } else {
                     console.log('error submit!!');

+ 3 - 1
src/views/produce/components/outsourcing/outsourceList.vue

@@ -8,7 +8,9 @@
 			<el-descriptions>
 				<el-descriptions-item label="委外名称">{{ outObj.name }}</el-descriptions-item>
 				<el-descriptions-item label="委外类型">{{ outObj.type == 4 ? '带料委外' : '无料委外' }}</el-descriptions-item>
-				<el-descriptions-item label="直接入库">{{ outObj.isInWarehouse == 1 ? '是' : '否' }}</el-descriptions-item>
+				<!-- <el-descriptions-item label="直接入库">{{ outObj.isInWarehouse == 1 ? '是' : '否' }}</el-descriptions-item> -->
+				<el-descriptions-item label="直接入库">{{ '是' }}</el-descriptions-item>
+
 			</el-descriptions>
 
 		</div>

+ 8 - 3
src/views/produce/components/produceOrder.vue

@@ -3,8 +3,8 @@
 
     <ele-pro-table ref="table" :columns="columns" height="calc(100vh - 280px)" width="100%" :datasource="datasource"
       :selection.sync="selection" @selection-change="handleSelectionChange" @cell-click="cellClick"
-      cache-key="produceOrderZ" highlight-current-row @select="cellClick" :need-page="false"
-      @sort-change="onSortChange">
+      highlight-current-row @select="cellClick" :need-page="false"
+      @sort-change="onSortChange" @columns-change="handleColumnChange" :cache-key="cacheKeyUrl">
       <!-- <template v-slot:toolbar>
         <div class="rx-bc">
           <div class="c_title">工单列表 </div>
@@ -57,8 +57,10 @@
 import { workorderPage2 } from '@/api/produce/workOrder.js';
 import routings from './routings.vue';
 import { isFullscreen } from 'ele-admin';
+import tableColumnsMixin from '@/mixins/tableColumnsMixin';
 export default {
   components: { routings },
+  mixins: [tableColumnsMixin],
   data() {
     return {
       loading: false,
@@ -69,12 +71,15 @@ export default {
 
       code: '',
 
-      internalIsFullscreen: isFullscreen() // 初始值
+      internalIsFullscreen: isFullscreen(), // 初始值
+      cacheKeyUrl:'mes-145878-mes-produce',
+      columnsVersion:0
     };
   },
   computed: {
     // 表格列配置
     columns() {
+      this.columnsVersion++
       return [
         {
           width: 45,