Преглед изворни кода

质检计划 质检工单 禅道bug 2473 2448 2233 2235 2237 2261 修复

jingshuyong пре 10 месеци
родитељ
комит
d1d3e70fc5

+ 9 - 0
src/api/inspectionProject/index.js

@@ -56,3 +56,12 @@ export async function removeItem(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// 复制
+export async function copyItem(id) {
+  const res = await request.get('/qms/inspection_item/copy/' + id);
+  if (res.data.code == 0) {
+    return res.data.message;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 17 - 6
src/api/login/index.js

@@ -4,7 +4,7 @@ import { setToken } from '@/utils/token-util';
 /**
  * 登录
  */
-export async function login (data) {
+export async function login(data) {
   const res = await request.post('/main/user/login', data);
   if (res.data.code == 0) {
     setToken(res.data.data.token, data.remember);
@@ -15,7 +15,7 @@ export async function login (data) {
 /**
  * 获取用户信息
  */
-export async function getLoginUser (data) {
+export async function getLoginUser(data) {
   const res = await request.get('/system/account/getLoginUser', data);
   if (res.data.code == 0) {
     return res.data.data;
@@ -25,7 +25,7 @@ export async function getLoginUser (data) {
 /**
  * 获取验证码
  */
-export async function getCaptcha () {
+export async function getCaptcha() {
   const res = await request.get('/captcha');
   if (res.data.code === 0) {
     return res.data.data;
@@ -33,20 +33,31 @@ export async function getCaptcha () {
   return Promise.reject(new Error(res.data.message));
 }
 
-
 // 生成编码
-export async function getCode (code) {
+export async function getCode(code) {
   const res = await request.get(`/main/codemanage/getCode/` + code, {});
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// 批量生产编码
+export async function getCodeList(code, params) {
+  const res = await request.get(`/main/codemanage/getCodeList/` + code, {
+    params
+  });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
 /**
  * 获取当前登陆用户数据权限部门数据
  * @param
  */
-export async function getCurrentUserAuthorityDeptAPI () {
+export async function getCurrentUserAuthorityDeptAPI() {
   const res = await request.post('/main/user/getCurrentUserAuthorityDepts');
   if (res.data.code == 0) {
     return res.data.data;

+ 9 - 0
src/api/main/index.js

@@ -40,3 +40,12 @@ export async function queryProductionLine () {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// 产线数据
+export async function queryProportionDefectiveTypes () {
+  const res = await request.post(`/qms/quality_work_order/queryProportionDefectiveTypes`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 208 - 186
src/views/home/data.js

@@ -2,204 +2,226 @@
 const dayjs = require('dayjs');
 // 获取本月日期列表的函数
 function getDatesInMonth() {
-    let year=dayjs().year()
-    let month=dayjs().month()
-    const dates = [];
-    const startDate = dayjs(new Date(year, month, 1));
-    const endDate = dayjs(new Date(year, month + 1, 1)).subtract(1, 'day');
-    let currentDate = startDate;
-    while (currentDate.isBefore(endDate) || currentDate.isSame(endDate, 'day')) {
-        dates.push(currentDate.format('YYYY-MM-DD'));
-        currentDate = currentDate.add(1, 'day');
-    }
-    return dates;
+  let year = dayjs().year();
+  let month = dayjs().month();
+  const dates = [];
+  const startDate = dayjs(new Date(year, month, 1));
+  const endDate = dayjs(new Date(year, month + 1, 1)).subtract(1, 'day');
+  let currentDate = startDate;
+  while (currentDate.isBefore(endDate) || currentDate.isSame(endDate, 'day')) {
+    dates.push(currentDate.format('YYYY-MM-DD'));
+    currentDate = currentDate.add(1, 'day');
+  }
+  return dates;
 }
 export const userList = [
-
-    {
-        columnKey: 'index',
-        label: '序号',
-        type: 'index',
-        width: 55,
-        align: 'center',
-        showOverflowTooltip: true,
-        fixed: 'left'
-    },
-
-    {
-        prop: 'name',
-        label: '姓名',
-        width: 100,
-        align: 'center',
-        showOverflowTooltip: true,
-    },
-    {
-        prop: 'jobNumber',
-        label: '工号',
-        width: 120,
-        align: 'center',
-        showOverflowTooltip: true,
-    },
-    {
-        prop: 'qualified',
-        label: '合格率',
-        align: 'center',
-        slot: 'qualified'
-    }
-
+  {
+    columnKey: 'index',
+    label: '序号',
+    type: 'index',
+    width: 55,
+    align: 'center',
+    showOverflowTooltip: true,
+    fixed: 'left'
+  },
+
+  {
+    prop: 'name',
+    label: '姓名',
+    width: 100,
+    align: 'center',
+    showOverflowTooltip: true
+  },
+  {
+    prop: 'jobNumber',
+    label: '工号',
+    width: 120,
+    align: 'center',
+    showOverflowTooltip: true
+  },
+  {
+    prop: 'qualified',
+    label: '合格率',
+    align: 'center',
+    slot: 'qualified'
+  }
 ];
 export const unacceptedProduct = [
-    {
-        columnKey: 'index',
-        label: '序号',
-        type: 'index',
-        width: 55,
-        align: 'center',
-        showOverflowTooltip: true,
-        fixed: 'left'
-    },
-
+  {
+    columnKey: 'index',
+    label: '序号',
+    type: 'index',
+    width: 55,
+    align: 'center',
+    showOverflowTooltip: true,
+    fixed: 'left'
+  },
+
+  {
+    prop: 'name',
+    label: '类型',
+    width: 120,
+    align: 'center',
+    showOverflowTooltip: true
+  },
+  {
+    prop: 'jobNumber',
+    label: '编码',
+    width: 180,
+    align: 'center',
+    showOverflowTooltip: true
+  },
+  {
+    prop: 'qualified',
+    label: '不良原因',
+    align: 'center'
+  },
+  {
+    prop: 'qualified2',
+    width: 150,
+    label: '申请人',
+    align: 'center'
+  },
+  {
+    prop: 'qualified3',
+    width: 120,
+    label: '操作',
+    align: 'center'
+  }
+];
 
-    {
-        prop: 'name',
-        label: '类型',
-        width: 120,
-        align: 'center',
-        showOverflowTooltip: true,
+export const barOption = (data, itemStyle = {}) => {
+  return {
+    tooltip: {
+      formatter: '{b}:{c}' + '%',
+      trigger: 'item'
     },
-    {
-        prop: 'jobNumber',
-        label: '编码',
-        width: 180,
-        align: 'center',
-        showOverflowTooltip: true,
+    color: ['#398f4e'],
+    xAxis: {
+      type: 'category',
+      data: data.map((item) => item.name),
+      axisLabel: {
+        fontSize: window.innerHeight * 0.012
+      }
     },
-    {
-        prop: 'qualified',
-        label: '不良原因',
-        align: 'center',
+    yAxis: {
+      type: 'value'
     },
-    {
-        prop: 'qualified2',
-        width: 150,
-        label: '申请人',
-        align: 'center',
+    series: [
+      {
+        // showBackground: true,
+        barWidth: '20%',
+        data: data.map((item) => item.value),
+        type: 'bar',
+        // backgroundStyle: {
+        //     // color: 'rgba(180, 180, 180, 0.2)',
+        //     // shadowColor: 'rgba(0, 0, 0, 0.5)',
+        //     // shadowBlur: 10
+        // },
+        itemStyle,
+        label: {
+          show: true, // 开启显示
+          position: 'top', // 在柱状图的顶部显示标签
+          formatter: '{c}%', // 数据内容,默认为'{c}',即系列数据中的值
+          textStyle: {
+            fontSize: 17 // 标签字体大小
+          }
+        }
+      }
+    ]
+  };
+};
+
+export const preOption = (
+  data,
+  radius = ['45%', '60%'],
+  labelLineShow = true,
+  labelPosition = 'outside'
+) => {
+  return {
+    color: ['#398f4e', '#458ef7', '#fdc537', '#fe6869', '#975fe6'],
+    tooltip: {
+      formatter: '{b}:{c}' + '%',
+      trigger: 'item'
     },
-    {
-        prop: 'qualified3',
-        width: 120,
-        label: '操作',
-        align: 'center',
-    }
-
-];
-
-export const barOption = (data, itemStyle = {}) => {
-    return {
-        tooltip: {
-            formatter: '{b}:{c}' + '%',
-            trigger: 'item'
-        },
-        color: ['#398f4e',],
-        xAxis: {
-            type: 'category',
-            data: data.map(item => item.name),
-            axisLabel: {
-                fontSize: window.innerHeight * 0.012,
-
-            }
-
-        },
-        yAxis: {
-            type: 'value'
+    legend: {
+      orient: 'vertical',
+      left: 'left',
+      left: '10%',
+      top: '25%',
+      itemGap: window.innerHeight * 0.018,
+      textStyle: {
+        fontSize: window.innerHeight * 0.014
+      }
+    },
+    series: [
+      {
+        center: ['60%', '50%'],
+        label: {
+          position: labelPosition,
+          show: true,
+          formatter: '{c}' + '%',
+          fontSize: window.innerHeight * 0.014
+          // color:"#fff"
         },
-        series: [
-            {
-                // showBackground: true,
-                barWidth: '20%',
-                data: data.map(item => item.value),
-                type: 'bar',
-                // backgroundStyle: {
-                //     // color: 'rgba(180, 180, 180, 0.2)',
-                //     // shadowColor: 'rgba(0, 0, 0, 0.5)',
-                //     // shadowBlur: 10
-                // },
-                itemStyle
-            }
-        ]
-    }
-}
-
-export const preOption = (data, radius = ['45%', '60%'], labelLineShow = true, labelPosition = 'outside') => {
-    return {
-        color: ['#398f4e', '#458ef7', '#fdc537', '#fe6869', '#975fe6'],
-        tooltip: {
-            formatter: '{b}:{c}' + '%',
-            trigger: 'item'
+        labelLine: {
+          show: labelLineShow
         },
-        legend: {
-            orient: 'vertical',
-            left: 'left',
-            left: '10%',
-            top: '25%',
-            itemGap: window.innerHeight * 0.018,
-            textStyle: {
-                fontSize: window.innerHeight * 0.014,
-            }
+        type: 'pie',
+        radius,
+        itemStyle: {
+          borderWidth: 0,
+          shadowBlur: 10,
+          shadowColor: 'rgba(0, 0, 0, 0.5)'
         },
-        series: [
-            {
-                center: ['60%', '50%'],
-                label: {
-                    position: labelPosition,
-                    show: true,
-                    formatter: '{c}' + '%',
-                    fontSize: window.innerHeight * 0.014,
-                    // color:"#fff"
-                },
-                labelLine: {
-                    show: labelLineShow
-                },
-                type: 'pie',
-                radius,
-                itemStyle: {
-                    borderWidth: 0,
-                    shadowBlur: 10,
-                    shadowColor: 'rgba(0, 0, 0, 0.5)'
-                },
-                data
-            }
-        ]
-    }
-}
+        data
+      }
+    ]
+  };
+};
 
 export const lineOption = (data, type) => {
+  console.log(getDatesInMonth(), 'getDatesInMonth');
+
+  let timeData =
+    type == 1
+      ? [
+          '一月',
+          '二月',
+          '三月',
+          '四月',
+          '五月',
+          '六月',
+          '七月',
+          '八月',
+          '九月',
+          '十月',
+          '十一月',
+          '十二月'
+        ]
+      : type == 2
+      ? getDatesInMonth()
+      : ['周一', '周二', '周三', '周四', '周五', '周六', '周日'];
+  return {
+    tooltip: {
+      formatter: (item) => {
+        return (
+          item.seriesName + ' ' + item.name + '合格率:' + item.value + '%'
+        );
+      },
+      trigger: 'item'
+    },
 
-
-console.log(getDatesInMonth(),'getDatesInMonth')
-
-    let timeData = type == 1 ? ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'] : type == 2 ?getDatesInMonth():['周一', '周二', '周三', '周四', '周五', '周六', '周日']
-    return {
-
-        tooltip: {
-            formatter: (item) => {
-                return item.seriesName + " " + item.name + "合格率:" + item.value + '%'
-            },
-            trigger: 'item'
-        },
-
-
-        xAxis: {
-            type: 'category',
-            axisLabel: {
-                fontSize: window.innerHeight * 0.012,
-
-            },
-            data: timeData
-        },
-        yAxis: {
-            type: 'value'
-        },
-        series: data
-    }
-}
+    xAxis: {
+      type: 'category',
+      axisLabel: {
+        fontSize: window.innerHeight * 0.012
+      },
+      data: timeData
+    },
+    yAxis: {
+      type: 'value'
+    },
+    series: data
+  };
+};

+ 7 - 4
src/views/home/index.vue

@@ -110,7 +110,8 @@ import {
   queryHomePage,
   queryFactory,
   queryTeam,
-  queryProductionLine
+  queryProductionLine,
+  queryProportionDefectiveTypes
 } from '@/api/main';
 import dictMixins from '@/mixins/dictMixins';
 import {
@@ -211,12 +212,14 @@ export default {
       );
     },
     async queryProductionLine() {
-      const data = await queryProductionLine();
+      // const data = await queryProductionLine();
+      const data = await queryProportionDefectiveTypes();
+      console.log(data,'data data 33')
       this.lineQualifiedOption = barOption(
         data.map((item) => {
           return {
-            value: item.qualificationRate,
-            name: item.productionLineName
+            value: item.unQualifiedNumber,
+            name: item.categoryLevelClassName
           };
         }),
         {

+ 3 - 2
src/views/inspectionPlan/components/edit.vue

@@ -845,7 +845,7 @@
             weight
           });
         }
-        console.log('数据1221212121 list list',list);
+        console.log('数据1221212121 list list', list);
         this.$refs.table12.setData(list);
       },
 
@@ -1000,7 +1000,8 @@
         let res = await getTemplateListByPlanId({
           planId: id,
           pageNum: this.schemePagination.currentPage,
-          size: this.schemePagination.pageSize
+          // size: this.schemePagination.pageSize
+          size: 100000
         });
         console.log(res.list, 'fffffffffffffff方案--------------------------');
         this.schemeList = res?.list || [];

+ 124 - 86
src/views/inspectionPlan/components/new-edit.vue

@@ -118,7 +118,9 @@
             ref="table12"
             :columns="tableColumns"
             :datasource="sourceList"
+            :needPage="false"
             @selection-change="handleSelectionChange"
+            height="500"
           >
             <template
               v-slot:toolbar
@@ -249,7 +251,7 @@
             ref="showSampleListTable"
             :data="paginatedSampleList"
             tooltip-effect="dark"
-            :max-height="300"
+            height="500"
             border
             row-key="sampleCode"
           >
@@ -270,7 +272,7 @@
               ></el-table-column>
             </template>
           </el-table>
-          <el-pagination
+          <!-- <el-pagination
             v-show="activeName === '2' && sampleList.length > 0"
             @size-change="handleSampleSizeChange"
             @current-change="handleSampleCurrentChange"
@@ -280,7 +282,7 @@
             layout="total, sizes, prev, pager, next, jumper"
             :total="samplePagination.total"
             style="margin-top: 10px"
-          ></el-pagination>
+          ></el-pagination> -->
         </el-tab-pane>
         <el-tab-pane label="质检方案" name="3">
           <el-button
@@ -295,7 +297,7 @@
             ref="showSchemeListTable"
             :data="paginatedSchemeList"
             tooltip-effect="dark"
-            :max-height="300"
+            height="500"
             border
             row-key="id"
           >
@@ -388,7 +390,7 @@
               </template>
             </el-table-column>
           </el-table>
-          <el-pagination
+          <!-- <el-pagination
             v-show="activeName === '3' && schemeList.length > 0"
             @size-change="handleSchemeSizeChange"
             @current-change="handleSchemeCurrentChange"
@@ -398,7 +400,7 @@
             layout="total, sizes, prev, pager, next, jumper"
             :total="schemePagination.total"
             style="margin-top: 10px"
-          ></el-pagination>
+          ></el-pagination> -->
         </el-tab-pane>
       </el-tabs>
     </el-row>
@@ -435,7 +437,7 @@
   import baseInfo from './new-baseInfo.vue';
   // 质检方案的弹窗
   import inspectionTemplateDialog from '@/views/inspectionTemplate/components/inspectionTemplateDialog.vue';
-  import { getCode } from '@/api/login';
+  import { getCode, getCodeList } from '@/api/login';
   import { save, update, planIssued } from '@/api/inspectionPlan';
   import {
     getQualityTemplateList,
@@ -637,14 +639,18 @@
     watch: {
       // 样品清单
       sampleList: {
-        handler(newVal) {
+        handler: async function (newVal) {
           // 计算重量跟数量
           this.calculate(newVal);
-          newVal.map(async (el) => {
-            if (!el.sampleCode) {
-              el.sampleCode = await this.getSampleCode();
-            }
-          });
+          if (newVal && newVal.length > 0 && !newVal[0].sampleCode) {
+            let count = newVal ? newVal.length : 0;
+            const codeList = await this.batchCodes(count);
+            newVal.map(async (el, index) => {
+              if (!el.sampleCode) {
+                el.sampleCode = codeList[index];
+              }
+            });
+          }
         },
         deep: true,
         immediate: true
@@ -716,7 +722,8 @@
             label: '供应商代号',
             prop: 'supplierCode',
             align: 'center',
-            width: '120'
+            width: '120',
+            showOverflowTooltip: true
           },
           { label: '刻码', prop: 'engrave', align: 'center' },
           { label: '重量', prop: 'weight', align: 'center' },
@@ -759,33 +766,36 @@
       //分页后的来源列表
       paginatedSourceList() {
         console.log('分页', this.sourceList);
-        const { currentPage, pageSize } = this.sourcePagination;
-        const start = (currentPage - 1) * pageSize;
-        const end = start + pageSize;
-        return this.sourceList.slice(start, end);
+        // const { currentPage, pageSize } = this.sourcePagination;
+        // const start = (currentPage - 1) * pageSize;
+        // const end = start + pageSize;
+        // return this.sourceList.slice(start, end);
+        return this.sourceList;
       },
 
       // 分页后的样品列表
       paginatedSampleList() {
-        if (this.rowIds && this.isSampleList) {
-          console.log(this.sampleList, 'sampleList');
-          return this.sampleList;
-        }
-        const { currentPage, pageSize } = this.samplePagination;
-        const start = (currentPage - 1) * pageSize;
-        const end = start + pageSize;
-        return this.sampleList.slice(start, end);
+        return this.sampleList;
+        // if (this.rowIds && this.isSampleList) {
+        //   console.log(this.sampleList, 'sampleList');
+        //   return this.sampleList;
+        // }
+        // const { currentPage, pageSize } = this.samplePagination;
+        // const start = (currentPage - 1) * pageSize;
+        // const end = start + pageSize;
+        // return this.sampleList.slice(start, end);
       },
       // 分页后的质检方案列表
       paginatedSchemeList() {
-        if (this.rowIds && this.isScheme) {
-          console.log(this.schemeList, 'test');
-          return this.schemeList;
-        }
-        const { currentPage, pageSize } = this.schemePagination;
-        const start = (currentPage - 1) * pageSize;
-        const end = start + pageSize;
-        return this.schemeList.slice(start, end);
+        // if (this.rowIds && this.isScheme) {
+        //   console.log(this.schemeList, 'test');
+        //   return this.schemeList;
+        // }
+        // const { currentPage, pageSize } = this.schemePagination;
+        // const start = (currentPage - 1) * pageSize;
+        // const end = start + pageSize;
+        // return this.schemeList.slice(start, end);
+        return this.schemeList;
       }
     },
 
@@ -1268,21 +1278,22 @@
         return list;
       },
       async getSampleList(id) {
-        let res = await getSampleListByPlanId({
-          planId: id,
-          pageNum: this.samplePagination.currentPage,
-          size: this.samplePagination.pageSize
-        });
+        // console.log('执行?')
+        // let res = await getSampleListByPlanId({
+        //   planId: id,
+        //   pageNum: this.samplePagination.currentPage,
+        //   size: this.samplePagination.pageSize
+        // });
 
-        this.sampleList = res?.list || [];
-        this.samplePagination.total = res.count;
+        // this.sampleList = res?.list || [];
+        // this.samplePagination.total = res.count;
 
         let newRes = await getSampleListByPlanId({
           planId: id,
           pageNum: 1,
           size: -1
         });
-
+        this.sampleList = newRes?.list || [];
         this.newSampleList = newRes?.list || [];
       },
 
@@ -1290,7 +1301,8 @@
         let res = await getTemplateListByPlanId({
           planId: id,
           pageNum: this.schemePagination.currentPage,
-          size: this.schemePagination.pageSize
+          // size: this.schemePagination.pageSize,
+          size: 100000
         });
         this.schemeList = res?.list || [];
         this.schemePagination.total = res.count;
@@ -1681,6 +1693,7 @@
               oldItem.qualitySampleTemplateList = JSON.parse(
                 JSON.stringify(this.schemeList)
               );
+
               for (let i = 0; i < count; i++) {
                 ProductSampleList.push({
                   ...oldItem,
@@ -1721,23 +1734,35 @@
         }
       },
 
+      // 批量生成编码 4444444 getCodeList
+      async batchCodes(count) {
+        if (count <= 0) return;
+        let params = { count };
+        const res = await getCodeList('sample_code', params);
+        return res;
+      },
+
       //更新样品清单数据
       async updatePackingList(list) {
+        console.log('进来了没有 pppppp');
         // 计量类型1是数量,2是重量
-        if (this.baseForm.inspectionStandards == 1) {
-          this.createSampleList(list);
-        }
-
+        // if (this.baseForm.inspectionStandards == 1) {
+        //   this.createSampleList(list);
+        //   return;
+        // }
+        let count = list ? list.length : 0;
+        const codeList = await this.batchCodes(count);
         if (this.baseForm.inspectionStandards == 2) {
           for (let i = 0; i < list.length; i++) {
-            list[i].sampleCode = await this.getSampleCode();
+            // list[i].sampleCode = await this.getSampleCode();
+            list[i].sampleCode = codeList[i];
           }
           // this.updatePackingList(list, this.form.total);
           // this.handleWeightFullSample(this.form.total);
         }
 
         console.log(this.baseForm.inspectionStandards);
-
+        console.log(list, 'list +++++++++++ 00000000000');
         this.sampleList = list;
         this.baseForm.sampleNumber = list.length;
         this.samplePagination.currentPage = 1;
@@ -2153,9 +2178,11 @@
         const result = [];
         let remainingCount = sampleCount;
         console.log(remainingCount, 'remainingCount ========');
+        let count = Math.ceil(remainingCount);
+        const codeList = await this.batchCodes(count);
+        let codeIdx = 0;
         // 尽可能均匀地从各条目取样
         while (remainingCount > 0) {
-          
           // 按剩余可取样比例排序
           items.sort(
             (a, b) =>
@@ -2166,28 +2193,38 @@
           let distributed = false;
 
           for (const item of items) {
+            console.log(
+              remainingCount,
+              'remainingCount remainingCount remainingCount'
+            );
             let values = remainingCount > 1 ? 1 : remainingCount;
             // sampleQuantity = remainingCount > 1 ? 1 : remainingCount;
-            console.log(sampleQuantity, 'sampleQuantity ----');
+            // console.log(sampleQuantity, 'sampleQuantity ----');
             if (
               (!isUnitMismatch && remainingCount > 0) ||
               (item.remainingQuantity >= sampleQuantity && remainingCount > 0)
             ) {
               // 添加到结果数组
               this.samplePagination.total = 0;
-              let sampleCode = await this.getSampleCode();
+              // let sampleCode = await this.getSampleCode();
+              let sampleCode = codeList[codeIdx];
               if (
                 this.conditionType == 1 &&
                 this.baseForm.inspectionStandards == 1
               ) {
-                console.log('进来1')
-                result.push({ ...item, measureQuantity: values, sampleCode });
+                console.log('进来1');
+                result.push({
+                  ...item,
+                  //  measureQuantity: values,
+                  measureQuantity: 1,
+                  sampleCode
+                });
               } else if (
                 this.conditionType == 2 &&
                 (this.baseForm.inspectionStandards == 1 ||
                   this.baseForm.inspectionStandards == 2)
               ) {
-                console.log('进来2')
+                console.log('进来2');
                 let weight = (item.weight / item.maxPossible).toFixed(2);
                 result.push({
                   ...item,
@@ -2202,7 +2239,8 @@
               if (!isUnitMismatch) {
                 item.remainingQuantity -= sampleQuantity;
               }
-              remainingCount--;
+              remainingCount = (remainingCount - 1).toFixed(2);
+              codeIdx++;
               distributed = true;
             }
           }
@@ -2605,7 +2643,7 @@
         if (this.btnType != 'issued') {
           this.baseForm.sampleNumber = '';
         }
-
+        console.log(this.baseForm, 'this.baseForm 0000000000000');
         if (this.baseForm.type == '3') {
           console.log(this.sourceList, this.dimensionType, '更改检验方式223');
           if (
@@ -2725,8 +2763,8 @@
               }
               // ***
               //抽检计量整样小样或者抽检计重小样
-              // if (!this.validateMeasureQuantity(measureQ, unit, sampleCount))
-              //   return;
+              if (!this.validateMeasureQuantity(measureQ, unit, sampleCount))
+                return;
               if (unit === 'KG' && !this.validateWeight(measureQ, sampleCount))
                 return; // 若计量单位为重量,还需验证总重量是否足够
               console.log('getNewFullSampleList');
@@ -2736,8 +2774,8 @@
               } else {
                 console.log('2222222222222 --', Math.ceil(sampleCount));
                 await this.getNewFullSampleList(
-                  // Math.ceil(sampleCount),
-                  sampleCount,
+                  Math.ceil(sampleCount),
+                  // sampleCount,
                   measureQ,
                   unit,
                   specifications
@@ -2803,32 +2841,32 @@
       },
 
       validateMeasureQuantity(measureQ, unit, sampleCount) {
-        // if (this.conditionType == 2 && measureQ <= 0) {
-        //   this.$message.info('取样计量数量必须大于0');
-        //   return false;
-        // }
+        if (this.conditionType == 2 && measureQ <= 0) {
+          this.$message.info('取样计量数量必须大于0');
+          return false;
+        }
 
-        // const totalQuantity = this.selectedList.reduce(
-        //   (sum, item) => sum + item.measureQuantity,
-        //   0
-        // );
-        // if (
-        //   (this.selectedList[0].measureUnit === unit ||
-        //     this.conditionType == 1) &&
-        //   measureQ * sampleCount > totalQuantity
-        // ) {
-        //   this.$message.info('取样计量数量不能大于总计量数量');
-        //   return false;
-        // }
-        // console.log(this.selectedList,'33333333333')
-        // console.log(measureQ,'measureQ 0000')
-        // const invalidItem = this.selectedList.find(
-        //   (item) => item.measureQuantity < measureQ
-        // );
-        // if (invalidItem) {
-        //   this.$message.info('条目计量数量小于取样计量数量');
-        //   return false;
-        // }
+        const totalQuantity = this.selectedList.reduce(
+          (sum, item) => sum + item.measureQuantity,
+          0
+        );
+        if (
+          (this.selectedList[0].measureUnit === unit ||
+            this.conditionType == 1) &&
+          measureQ * sampleCount > totalQuantity
+        ) {
+          this.$message.info('取样计量数量不能大于总计量数量');
+          return false;
+        }
+        console.log(this.selectedList, '33333333333');
+        console.log(measureQ, 'measureQ 0000');
+        const invalidItem = this.selectedList.find(
+          (item) => item.measureQuantity < measureQ
+        );
+        if (invalidItem) {
+          this.$message.info('条目计量数量小于取样计量数量');
+          return false;
+        }
 
         return true;
       },

+ 26 - 1
src/views/inspectionProject/index.vue

@@ -84,6 +84,17 @@
 
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
+          <el-popconfirm
+            class="ele-action"
+            title="确定要复制当前质检吗?"
+            @confirm="copy(row)"
+          >
+            <template v-slot:reference>
+              <el-link type="primary" :underline="false" icon="el-icon-tickets">
+                复制
+              </el-link>
+            </template>
+          </el-popconfirm>
           <el-link
             type="primary"
             :underline="false"
@@ -131,7 +142,7 @@
   import UserEdit from './components/user-edit.vue';
   import importDialog from '@/components/upload/import-dialog.vue';
 
-  import { getList, removeItem } from '@/api/inspectionProject';
+  import { getList, removeItem, copyItem } from '@/api/inspectionProject';
   import dictMixins from '@/mixins/dictMixins';
   export default {
     name: 'inspectionProject',
@@ -301,6 +312,20 @@
             loading.close();
           });
       },
+      // 复制
+      copy(row) {
+        console.log(row,'33333')
+        const loading = this.$loading({ lock: true });
+        copyItem(row.id)
+          .then((msg) => {
+            loading.close();
+            this.$message.success('复制成功');
+            this.reload();
+          })
+          .catch((e) => {
+            loading.close();
+          });
+      },
       /* 批量删除 */
       removeBatch() {
         if (!this.selection.length) {

+ 8 - 6
src/views/inspectionTemplate/index.vue

@@ -225,12 +225,16 @@
     },
     async created() {
       const res = await this.requestDict('质检计划类型');
-    
+      console.log(res, 'res 000');
       this.typeList = res.map((item) => {
-        let values = Object.keys(item);
+        // let values = Object.keys(item);
+        // return {
+        //   value: Number(values[0]),
+        //   label: item[values[0]]
+        // };
         return {
-          value: Number(values[0]),
-          label: item[values[0]]
+          value: item.dictCode,
+          label: item.dictValue
         };
       });
 
@@ -244,8 +248,6 @@
         planList: this.typeList
       });
       this.renderFlag = true;
-
-   
     },
     methods: {
       // 获取数据列表

+ 53 - 58
src/views/inspectionWork/components/baseInfo.vue

@@ -159,9 +159,8 @@
         </el-col>
       </el-row>
       <el-row>
-        <el-col :span="6">
+        <!-- <el-col :span="6">
           <el-form-item label="合格数:" prop="qualifiedNumber">
-            <!--  :disabled="btnType == 'detail'" -->
             <el-input
               type="number"
               :min="0"
@@ -175,7 +174,6 @@
         </el-col>
         <el-col :span="6">
           <el-form-item label="不合格数:" prop="noQualifiedNumber">
-            <!--  :disabled="btnType == 'detail'" -->
             <el-input
               type="number"
               :min="0"
@@ -186,7 +184,7 @@
               placeholder="请输入"
             ></el-input>
           </el-form-item>
-        </el-col>
+        </el-col> -->
         <el-col :span="6">
           <el-form-item label="合格率:" prop="qualificationRate">
             <el-input v-model="form.qualificationRate" disabled />
@@ -197,6 +195,42 @@
             <el-input v-model="form.noQualificationRate" disabled />
           </el-form-item>
         </el-col>
+        <el-col :span="6">
+          <el-form-item label="检验方式:" prop="qualityMode">
+            <!-- <DictSelection dictName="取样类型" v-model="form.qualityMode" :disabled="qualityType == 1"></DictSelection> -->
+            <el-select
+              @change="changeQualityMode"
+              style="width: 100%"
+              v-model="form.qualityMode"
+              placeholder="请选择"
+            >
+              <!-- :disabled="
+                parseInt(qualityType1) == 1 || parseInt(qualityType1) == 3
+              " -->
+              <el-option
+                v-for="item in qualityModeList"
+                :label="item.label"
+                :value="item.value"
+                :key="item.value"
+              ></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <!-- <el-form-item label="质检结果:" prop="qualityResults" v-if="form.qualityMode == 2"> -->
+          <el-form-item label="质检结果:" prop="qualityResults">
+            <!--    :disabled="btnType == 'detail'" -->
+            <el-select
+              v-model="form.qualityResults"
+              placeholder="请选择"
+              style="width: 100%"
+              disabled
+            >
+              <el-option label="合格" :value="1" />
+              <el-option label="不合格" :value="2" />
+            </el-select>
+          </el-form-item>
+        </el-col>
       </el-row>
       <el-row>
         <el-col :span="6">
@@ -218,25 +252,14 @@
             />
           </el-form-item>
         </el-col>
-        <el-col :span="6">
-          <el-form-item label="检验方式:" prop="qualityMode">
-            <!-- <DictSelection dictName="取样类型" v-model="form.qualityMode" :disabled="qualityType == 1"></DictSelection> -->
-            <el-select
-              @change="changeQualityMode"
-              style="width: 100%"
-              v-model="form.qualityMode"
-              placeholder="请选择"
-            >
-              <!-- :disabled="
-                parseInt(qualityType1) == 1 || parseInt(qualityType1) == 3
-              " -->
-              <el-option
-                v-for="item in qualityModeList"
-                :label="item.label"
-                :value="item.value"
-                :key="item.value"
-              ></el-option>
-            </el-select>
+        <el-col :span="12">
+          <el-form-item label="备注:" prop="remark">
+            <el-input
+              type="textarea"
+              v-model="form.remark"
+              placeholder="请输入"
+              :disabled="btnType == 'detail'"
+            />
           </el-form-item>
         </el-col>
         <!-- <el-col :span="6" v-if="btnType != 'detail'">
@@ -280,22 +303,6 @@
             ></el-input>
           </el-form-item>
         </el-col> -->
-
-        <el-col :span="6">
-          <!-- <el-form-item label="质检结果:" prop="qualityResults" v-if="form.qualityMode == 2"> -->
-          <el-form-item label="质检结果:" prop="qualityResults">
-            <!--    :disabled="btnType == 'detail'" -->
-            <el-select
-              v-model="form.qualityResults"
-              placeholder="请选择"
-              style="width: 100%"
-              disabled
-            >
-              <el-option label="合格" :value="1" />
-              <el-option label="不合格" :value="2" />
-            </el-select>
-          </el-form-item>
-        </el-col>
       </el-row>
       <el-row>
         <el-col :span="6" v-if="parseInt(qualityType1) == 2">
@@ -350,16 +357,6 @@
             />
           </el-form-item>
         </el-col> -->
-        <el-col :span="6">
-          <el-form-item label="备注:" prop="remark">
-            <el-input
-              type="textarea"
-              v-model="form.remark"
-              placeholder="请输入"
-              :disabled="btnType == 'detail'"
-            />
-          </el-form-item>
-        </el-col>
         <el-col :span="8">
           <el-form-item label="附件:" prop="accessory">
             <fileUpload
@@ -456,12 +453,12 @@
           productName: [
             { required: true, message: '请选择产品', trigger: 'change' }
           ],
-          qualifiedNumber: [
-            { required: true, message: '请输入合格数', trigger: 'blur' }
-          ],
-          noQualifiedNumber: [
-            { required: true, message: '请输入不合格数', trigger: 'blur' }
-          ],
+          // qualifiedNumber: [
+          //   { required: true, message: '请输入合格数', trigger: 'blur' }
+          // ],
+          // noQualifiedNumber: [
+          //   { required: true, message: '请输入不合格数', trigger: 'blur' }
+          // ],
           qualityTime: [
             { required: true, message: '请选择质检时间', trigger: 'blur' }
           ],
@@ -471,9 +468,7 @@
           qualityId: [
             { required: true, message: '请选择质检人', trigger: 'change' }
           ],
-          qualityResults: [
-            { required: true, message: '', trigger: 'change' }
-          ],
+          qualityResults: [{ required: true, message: '', trigger: 'change' }],
           inspectionStandards: [
             { required: true, message: '请选择检验标准', trigger: 'change' }
           ]

+ 38 - 16
src/views/inspectionWork/components/newQualityContentTabs.vue

@@ -32,8 +32,10 @@
           :datasource="datasource"
           @selection-change="handleSelectionChange"
           :initLoad="false"
-          :pagination="true"
+          :needPage="false"
+          height="500px"
         >
+          <!-- :pagination="true" -->
           <template
             v-slot:toolbar
             v-if="form.qualityMode == 2 && type != 'detail'"
@@ -178,7 +180,7 @@
           ref="showSampleListTable"
           :data="paginatedSampleList"
           tooltip-effect="dark"
-          :max-height="300"
+          height="500"
           border
           row-key="id"
         >
@@ -189,9 +191,9 @@
             align="center"
             fixed="left"
           ></el-table-column>
-          <template v-for="column in tableColumns">
+          <template v-for="(column, index) in tableColumns">
             <el-table-column
-              :key="column.prop"
+              :key="index"
               :label="column.label"
               :prop="column.prop"
               :fixed="column.fixed"
@@ -333,7 +335,7 @@
             </template>
           </el-table-column>
         </el-table>
-        <el-pagination
+        <!-- <el-pagination
           @size-change="handleSampleSizeChange"
           @current-change="handleSampleCurrentChange"
           :current-page="samplePagination.currentPage"
@@ -341,7 +343,7 @@
           :page-size="samplePagination.pageSize"
           layout="total, sizes, prev, pager, next, jumper"
           :total="sampleList.length"
-        />
+        /> -->
       </el-tab-pane>
       <!--  -->
       <el-tab-pane label="质检方案" name="3">
@@ -356,7 +358,7 @@
         <el-table
           :data="paginatedSchemeList"
           tooltip-effect="dark"
-          :max-height="300"
+          height="500"
           border
           row-key="id"
         >
@@ -392,7 +394,12 @@
             prop="inspectionName"
             align="center"
           ></el-table-column>
-          <el-table-column label="工艺参数" show-overflow-tooltip prop="defaultValue" align="center">
+          <el-table-column
+            label="工艺参数"
+            show-overflow-tooltip
+            prop="defaultValue"
+            align="center"
+          >
             <template slot-scope="scope">
               <div style="display: flex; justify-content: center">
                 <span>{{ scope.row.symbol }}</span>
@@ -697,8 +704,19 @@
             width: 120,
             showOverflowTooltip: true
           },
-          { label: '批次号', prop: 'batchNo', align: 'center', width: 120 },
-          { label: '发货条码', prop: 'barcodes', align: 'center' },
+          {
+            label: '批次号',
+            prop: 'batchNo',
+            align: 'center',
+            width: 120,
+            showOverflowTooltip: true
+          },
+          {
+            label: '发货条码',
+            prop: 'barcodes',
+            align: 'center',
+            showOverflowTooltip: true
+          },
           {
             label: '包装编码',
             prop: 'packageNo',
@@ -729,7 +747,8 @@
             label: '供应商代号',
             prop: 'supplierCode',
             align: 'center',
-            width: '120'
+            width: '120',
+            showOverflowTooltip: true
           },
           { label: '刻码', prop: 'engrave', align: 'center' },
           { label: '重量', prop: 'weight', align: 'center' },
@@ -763,10 +782,11 @@
       },
       // 分页后的样品列表
       paginatedSampleList() {
-        const { currentPage, pageSize } = this.samplePagination;
-        const start = (currentPage - 1) * pageSize;
-        const end = start + pageSize;
-        return this.sampleList?.slice(start, end);
+        // const { currentPage, pageSize } = this.samplePagination;
+        // const start = (currentPage - 1) * pageSize;
+        // const end = start + pageSize;
+        // return this.sampleList?.slice(start, end);
+        return this.sampleList;
       },
       // 分页后的质检方案列表
       paginatedSchemeList() {
@@ -801,10 +821,12 @@
     },
     methods: {
       async datasource({ page, limit, where }) {
+        console.log('执行33');
         const res = await queryQualityInventory({
           ...where,
           pageNum: page,
-          size: limit
+          // size: limit
+          size: -1
         });
         if (res.list.length == 0) {
           return res;

+ 64 - 18
src/views/inspectionWork/edit.vue

@@ -134,7 +134,7 @@
   // import QualityContentTabs from './components/QualityContentTabs.vue';
   import QualityContentTabs from './components/newQualityContentTabs.vue';
 
-  import { getCode } from '@/api/login';
+  import { getCode, getCodeList } from '@/api/login';
   import {
     save,
     update,
@@ -257,11 +257,30 @@
       // 样品清单
       sampleList: {
         handler(newVal) {
+          if (!newVal || newVal.length == 0) {
+            return;
+          }
+          console.log('11111111111');
           // 计算重量跟数量
           this.calculate(newVal);
         },
         deep: true,
         immediate: true
+      },
+
+      form: {
+        handler(newVal) {
+          console.log(newVal,'newVal 新的form')
+        },
+        deep: true,
+        immediate: true
+      },
+      'form.qualityResults': {
+        handler(newVal, oldVal) {
+          if (!newVal && oldVal) {
+            this.form.qualityResults = oldVal;
+          }
+        }
       }
     },
 
@@ -292,6 +311,7 @@
           }
         });
         console.log(list, 'list 3333');
+
         // 计算合格率和不合格率(百分比形式)
         let sampleQualificationRate = '';
         let sampleNoQualificationRate = '';
@@ -318,6 +338,8 @@
             sampleNoQualificationRate = sampleNoQualificationRate + '%';
           }
         }
+        console.log(sampleQuantity, 'sampleQuantity 1');
+        console.log(sampleQualifiedNumber, 'sampleQualifiedNumber 2');
         let resultsTotal = this.form.total - sampleQuantity;
         if (sampleQuantity == sampleQualifiedNumber) {
           this.$set(this.form, 'qualifiedNumber', resultsTotal);
@@ -351,6 +373,8 @@
           'sampleNoQualifiedNumber',
           sampleNoQualifiedNumber
         );
+
+        console.log(this.form, '000000000000000000');
       },
       //切换检验方式
       changeModel(val, flag) {
@@ -522,8 +546,11 @@
         let currentNum = sampleCount - list.length;
         let currentNum1 = sampleCount;
         // console.log(this.selectedList);
-
-        for (const item of list) {
+        let count = list ? list.length : 0;
+        const codeList = await this.batchCodes(count);
+        for (const [index, item] of list.entries()) {
+          console.log(index, 'index');
+          console.log(item, 'item');
           const qualitySampleTemplateList = item.qualitySampleTemplateList
             ?.length
             ? JSON.parse(JSON.stringify(item.qualitySampleTemplateList))
@@ -540,7 +567,8 @@
             dataList.push({
               ...item,
               measureQuantity: item.measureQuantity, //作为计量数量
-              sampleCode: await this.getSampleCode(),
+              // sampleCode: await this.getSampleCode(),
+              sampleCode: codeList[index],
               qualitySampleTemplateList
             });
           }
@@ -554,14 +582,15 @@
         this.$message.closeAll();
         this.$message('正在生成样品清单');
 
-        // 计量类型1是数量,2是重量
-        if (this.form.inspectionStandards == 1) {
-          this.createSampleList(list);
-        }
-        if (this.form.inspectionStandards == 2) {
-          this.updatePackingList(list, this.form.total);
-          // this.handleWeightFullSample(this.form.total);
-        }
+        // // 计量类型1是数量,2是重量
+        // if (this.form.inspectionStandards == 1) {
+        //   this.createSampleList(list);
+        // }
+        // if (this.form.inspectionStandards == 2) {
+        //   this.updatePackingList(list, this.form.total);
+        //   // this.handleWeightFullSample(this.form.total);
+        // }
+        this.updatePackingList(list, this.form.total);
       },
 
       //输入取样数量
@@ -875,6 +904,7 @@
               return; // 若计量单位为重量,还需验证总重量是否足够
             await this.getNewFullSampleList(
               Math.ceil(sampleCount),
+              // sampleCount,
               measureQ,
               unit,
               specifications
@@ -1022,6 +1052,7 @@
       },
 
       async getQueryQualityInventory() {
+        console.log(']]]]]]]]]]');
         const res = await queryQualityInventory({
           qualityWorkerId: this.$route.query.id,
           size: -1
@@ -1441,7 +1472,10 @@
 
         const result = [];
         let remainingCount = sampleCount;
-
+        console.log(remainingCount, 'remainingCount ========');
+        let count = Math.ceil(remainingCount);
+        const codeList = await this.batchCodes(count);
+        let codeIdx = 0;
         // 尽可能均匀地从各条目取样
         while (remainingCount > 0) {
           // 按剩余可取样比例排序
@@ -1454,7 +1488,7 @@
           let distributed = false;
 
           for (const item of items) {
-            let values = remainingCount > 1 ? 1 : remainingCount;
+            // let values = remainingCount > 1 ? 1 : remainingCount;
             if (
               !isUnitMismatch ||
               (item.remainingQuantity >= sampleQuantity && remainingCount > 0)
@@ -1472,14 +1506,17 @@
                 qualitySampleTemplateList = item.qualitySampleTemplateList;
               }
               // 添加到结果数组
-              let sampleCode = await this.getSampleCode();
+              // let sampleCode = await this.getSampleCode();
+              let sampleCode = codeList[codeIdx];
               if (
                 this.form.conditionType == 1 &&
                 this.form.inspectionStandards == 1
               ) {
+                // console.log('进来1', values);
                 result.push({
                   ...item,
-                  measureQuantity: values,
+                  // measureQuantity: values,
+                  measureQuantity: 1,
                   sampleCode,
                   qualitySampleTemplateList
                 });
@@ -1488,6 +1525,7 @@
                 (this.form.inspectionStandards == 1 ||
                   this.form.inspectionStandards == 2)
               ) {
+                console.log('进来2');
                 let weight = (item.weight / item.maxPossible).toFixed(2);
                 result.push({
                   ...item,
@@ -1502,7 +1540,8 @@
               if (!isUnitMismatch) {
                 item.remainingQuantity -= sampleQuantity;
               }
-              remainingCount--;
+              remainingCount = (remainingCount - 1).toFixed(2);
+              codeIdx++;
               distributed = true;
             }
           }
@@ -1657,6 +1696,7 @@
       },
 
       async handleWeightFullSample(sampleCount, specifications) {
+        console.log('执行没有');
         const dataList = [];
         let currentNum = sampleCount - this.selectedList.length;
         let currentNum1 = sampleCount;
@@ -1722,7 +1762,13 @@
         this.sampleList = dataList;
         this.sampleNumber = this.sampleList.length;
       },
-
+      // 批量生成编码 4444444 getCodeList
+      async batchCodes(count) {
+        if (count <= 0) return;
+        let params = { count };
+        const res = await getCodeList('sample_code', params);
+        return res;
+      },
       //计算合格率
       countQualityResults() {
         let sampleList = this.sampleList; //样品清单

+ 8 - 5
src/views/inspectionWork/index.vue

@@ -32,10 +32,13 @@
         <!--          <div v-else><el-tag size="mini">自建</el-tag></div>-->
         <!--        </template>-->
         <template v-slot:sourceCode="{ row }">
-          <div v-if="row.qualityType == 1">{{ row.qualityPlanCode }}</div>
+          <!-- <div v-if="row.qualityType == 1">{{ row.qualityPlanCode }}</div>
           <div v-if="row.qualityType == 2">{{ row.workOrderCode }}</div>
           <div v-if="row.qualityType == 3">{{ row.qualityPlanCode }}</div>
-          <div v-if="row.qualityType == 6">{{ row.qualityPlanCode }}</div>
+          <div v-if="row.qualityType == 6">{{ row.qualityPlanCode }}</div> -->
+          <div>{{
+            row.qualityPlanCode ? row.qualityPlanCode : row.workOrderCode
+          }}</div>
         </template>
 
         <template v-slot:files="scope">
@@ -224,13 +227,13 @@
             showOverflowTooltip: true
           },
           {
-            prop: 'qualityName', 
+            prop: 'qualityName',
             label: '质检人',
             align: 'center',
             width: 120,
             showOverflowTooltip: true,
-            formatter:(row)=>{
-              if(row.qualityName){
+            formatter: (row) => {
+              if (row.qualityName) {
                 return row.qualityName;
               }
               return row.qualityNames || '';