yusheng 8 mesi fa
parent
commit
bded7a5f1c

+ 64 - 0
src/api/inspectionProjectRequest/index.js

@@ -0,0 +1,64 @@
+import request from '@/utils/request';
+
+// 列表
+
+export async function getList(params) {
+  const res = await request.get(`/qms/requestentrust/page`, { params });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+//收样
+
+export async function sampleCollection(data) {
+  const res = await request.put(`/qms/requestentrust/sampleCollection`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+//修改
+export async function updateRequestentrust(data) {
+  const res = await request.put(`/qms/requestentrust/update`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+//派单
+export async function dispatch(data) {
+  const res = await request.put(`/qms/requestentrust/dispatch`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+// 获取详情
+export async function getById(id) {
+  const res = await request.get(`/qms/requestentrust/getById/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+// 检查是否责任人
+export async function verificationQualityInspector(id) {
+  const res = await request.post(
+    `/qms/requestentrust/verificationQualityInspector/${id}`
+  );
+  return res.data.code;
+}
+
+// 删除
+export async function removeItem(data) {
+  const res = await request.delete('/qms/requestentrust/delete', {
+    data
+  });
+  if (res.data.code == 0) {
+    return res.data.message;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 11 - 47
src/api/inspectionProjectTask/index.js

@@ -43,63 +43,27 @@ export async function qualityInspectionItemRequest(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
-
-// 编辑
-export async function update(data) {
-  const res = await request.post(`/qms/inspection_item/update`, data);
-  if (res.data.code == 0) {
-    return res.data.message;
-  }
-  return Promise.reject(new Error(res.data.message));
-}
-
-// 获取详情
-export async function getById(id) {
-  const res = await request.get(`/qms/taskmonad/getById/${id}`);
+//任务报工
+export async function exeTaskReportWork(data) {
+  const res = await request.post(`/qms/taskmonad/exeReportWork`, data);
   if (res.data.code == 0) {
     return res.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
-
-// 批量导入文件
-export async function importFile(data) {
-  const res = await request.post('/qms/inspection_item/importBatch', data);
-  if (res.data.code == 0) {
-    return res.data.data;
-  }
-  return Promise.reject(res.data); //报错处理
-}
-
-// 删除
-export async function removeItem(data) {
-  const res = await request.delete('/qms/inspection_item/delete', {
-    data
-  });
+//请托报工
+export async function exeEntrustReportWork(data) {
+  const res = await request.post(`/qms/requestentrust/exeReportWork`, data);
   if (res.data.code == 0) {
-    return res.data.message;
+    return res.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
-
-// 复制
-export async function copyItem(id) {
-  const res = await request.get('/qms/inspection_item/copy/' + id);
+// 获取详情
+export async function getById(id) {
+  const res = await request.get(`/qms/taskmonad/getById/${id}`);
   if (res.data.code == 0) {
-    return res.data.message;
+    return res.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
-
-//下载模板
-export async function downImportTemplate() {
-  const res = await request.post(
-    '/qms/inspection_item/importTemplate',
-    {},
-    {
-      responseType: 'blob'
-    }
-  );
-  console.log(res.data, '***********');
-  download(res.data, '质检项导入模板.xlsx');
-}

+ 5 - 0
src/styles/index.scss

@@ -3,3 +3,8 @@ $--ele-font-path: '~ele-admin/es/style/fonts';
 @import '~ele-admin/es/style/themes/dynamic.scss';
 @import '~ele-admin/es/style/index.scss';
 @import './transition/index.scss';
+table th .is-required::before{
+    content: "*";
+    color: red;
+    margin-right: 4px;
+} 

+ 16 - 34
src/views/inspectionPlan/components/new-edit.vue

@@ -125,7 +125,7 @@
             @columns-change="handleColumnChange"
             :cache-key="cacheKeyUrl"
           >
-            <template
+            <!-- <template
               v-slot:toolbar
               v-if="this.baseForm.qualityMode == 2 && btnType != 'detail'"
             >
@@ -136,7 +136,7 @@
                   <el-dropdown-item command="2">取小样</el-dropdown-item>
                 </el-dropdown-menu>
               </el-dropdown>
-            </template>
+            </template> -->
             <template v-slot:toolkit v-if="this.baseForm.qualityMode == 2">
               <el-row>
                 <el-form
@@ -247,7 +247,7 @@
             </template>
           </ele-pro-table>
         </el-tab-pane>
-        <el-tab-pane label="样品清单" name="2">
+        <!-- <el-tab-pane label="样品清单" name="2">
           <el-table
             v-show="activeName === '2'"
             v-if="sampleList.length > 0"
@@ -275,18 +275,8 @@
               ></el-table-column>
             </template>
           </el-table>
-          <!-- <el-pagination
-            v-show="activeName === '2' && sampleList.length > 0"
-            @size-change="handleSampleSizeChange"
-            @current-change="handleSampleCurrentChange"
-            :current-page="samplePagination.currentPage"
-            :page-sizes="[10, 20, 50, 100]"
-            :page-size="samplePagination.pageSize"
-            layout="total, sizes, prev, pager, next, jumper"
-            :total="samplePagination.total"
-            style="margin-top: 10px"
-          ></el-pagination> -->
-        </el-tab-pane>
+
+        </el-tab-pane> -->
         <el-tab-pane label="质检方案" name="3">
           <el-button
             @click="addInspectionTemplate(baseForm.type)"
@@ -393,17 +383,7 @@
               </template>
             </el-table-column>
           </el-table>
-          <!-- <el-pagination
-            v-show="activeName === '3' && schemeList.length > 0"
-            @size-change="handleSchemeSizeChange"
-            @current-change="handleSchemeCurrentChange"
-            :current-page="schemePagination.currentPage"
-            :page-sizes="[10, 20, 50, 100]"
-            :page-size="schemePagination.pageSize"
-            layout="total, sizes, prev, pager, next, jumper"
-            :total="schemePagination.total"
-            style="margin-top: 10px"
-          ></el-pagination> -->
+       
         </el-tab-pane>
       </el-tabs>
     </el-row>
@@ -853,10 +833,10 @@
       calculate(list) {
         let sampleQuantity = 0; // 样品数量
         let sampleWeight = 0; // 样品重量
-        list.forEach((el) => {
-          sampleQuantity += el.measureQuantity - 0;
-          sampleWeight += el.weight - 0;
-        });
+        // list.forEach((el) => {
+        //   sampleQuantity += el.measureQuantity - 0;
+        //   sampleWeight += el.weight - 0;
+        // });
         this.$set(this.baseForm, 'sampleQuantity', sampleQuantity); // 样品数量
         this.$set(this.baseForm, 'sampleWeight', sampleWeight); // 样品重量
       },
@@ -1178,6 +1158,7 @@
         return list;
       },
       async getSampleList(id) {
+        return
         let newRes = await getSampleListByPlanId({
           planId: id,
           pageNum: 1,
@@ -1554,6 +1535,7 @@
 
       //更新样品清单数据
       async updatePackingList(list) {
+        return
         console.log('进来了没有 pppppp');
         // 计量类型1是数量,2是重量
         // if (this.baseForm.inspectionStandards == 1) {
@@ -2143,10 +2125,10 @@
         });
       },
       handleIssued() {
-        if (this.sampleList.length == 0) {
-          this.$message.warning('样品清单为空!先进行修改操作再下发!');
-          return;
-        }
+        // if (this.sampleList.length == 0) {
+        //   this.$message.warning('样品清单为空!先进行修改操作再下发!');
+        //   return;
+        // }
         this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
           if (!valid) {
             return false;

+ 17 - 0
src/views/inspectionProjectEntrusted/index.vue

@@ -0,0 +1,17 @@
+<template>
+  <inspectionProjectRequest pageName="inspectionProjectEntrusted"></inspectionProjectRequest>
+</template>
+
+<script>
+  import inspectionProjectRequest from '@/views/inspectionProjectRequest/index.vue';
+  export default {
+    components: {
+      inspectionProjectRequest
+    },
+    data() {
+      return {};
+    },
+    created() {},
+    methods: {}
+  };
+</script>

+ 1 - 1
src/views/inspectionProjectRequest/components/search.vue

@@ -15,7 +15,7 @@
       seekList() {
         return [
           {
-            label: '任务单号:',
+            label: '请托单号:',
             value: 'code',
             type: 'input',
             placeholder: '请输入'

+ 130 - 0
src/views/inspectionProjectRequest/components/transfer.vue

@@ -0,0 +1,130 @@
+<template>
+  <el-dialog :visible.sync="transferVisible" width="35%" @close="close">
+    <el-form ref="form" :model="form" label-width="150px" :rules="rules">
+      <el-form-item label="执行部门:" prop="executeDeptId">
+        <deptSelect v-model="form.executeDeptId" @changeGroup="searchDeptNodeClick" />
+      </el-form-item>
+
+      <el-form-item label="执行人员:" prop="executeUserId">
+        <el-select
+          v-model="form.executeUserId"
+          @change="changeExecutor"
+          filterable
+          style="width: 100%"
+        >
+          <el-option
+            v-for="item in executorList"
+            :key="item.id"
+            :value="item.id"
+            :label="item.name"
+          ></el-option>
+        </el-select>
+      </el-form-item>
+    </el-form>
+
+    <span slot="footer" class="dialog-footer">
+      <el-button @click="close">取 消 </el-button>
+      <el-button type="primary" @click="consfirm">确 定</el-button>
+    </span>
+  </el-dialog>
+</template>
+
+<script>
+  import deptSelect from '@/components/CommomSelect/dept-select.vue';
+  import { dispatch } from '@/api/inspectionProjectRequest';
+  import { getUserPage } from '@/api/system/organization';
+
+  export default {
+    name: 'Transfer',
+    props: {
+      transferVisible: {
+        type: Boolean,
+        default: false
+      },
+      id: {
+        type: String,
+        default: ''
+      }
+    },
+    components: {
+      deptSelect
+    },
+    data() {
+      return {
+        form: {
+          id: '',
+          executeDeptId: '',
+          executeDeptName: '',
+          executeUserId: '',
+          executeUserName: ''
+        },
+        rules: {
+          executeDeptId: [
+            { required: true, message: '请选择执行部门', trigger: 'change' }
+          ],
+          executeUserId: [
+            { required: true, message: '请选择执行人员:', trigger: 'change' }
+          ]
+        },
+        executorList: []
+      };
+    },
+    methods: {
+      searchDeptNodeClick(info, row) {
+        console.log(info, row);
+
+        if (info) {
+          const params = { groupId: info };
+          this.form.executeDeptId = info;
+          this.form.executeDeptName = row.name;
+          this.getUserList(params);
+        } else {
+          this.form.executeUserId = null;
+          this.form.executeUserName = null;
+          this.executorList = [];
+        }
+      },
+      // 获取审核人列表、巡点检人员
+      async getUserList(params) {
+        try {
+          let data = { pageNum: 1, size: -1 };
+          // 如果传了参数就是获取巡点检人员数据
+          if (params) {
+            data = Object.assign(data, params);
+          }
+          const res = await getUserPage(data);
+          this.executorList = res.list;
+          this.form.executeUserId = null;
+          this.form.executeUserName = null;
+        } catch (error) {}
+      },
+      changeExecutor(val) {
+        console.log(val);
+
+        if (val) {
+          this.form.qualityId = val;
+          this.form.executeUserName = this.executorList.find(
+            (item) => item.id === val
+          ).name;
+        }
+      },
+      consfirm() {
+        this.$refs.form.validate(async (valid) => {
+          if (valid) {
+            await dispatch(this.form);
+            this.$emit('success');
+          }
+        });
+        console.log(this.form);
+      },
+      close() {
+        this.$emit('update:transferVisible', false);
+      }
+    },
+    created() {
+      this.form.id = this.id;
+    }
+  };
+</script>
+
+<style lang="scss" scoped></style>

+ 221 - 57
src/views/inspectionProjectRequest/index.vue

@@ -22,51 +22,167 @@
           {{ getDictValue('取样类型', row.qualityMode) }}
         </template>
 
+        <template v-slot:code="{ row }">
+          <el-link
+            type="primary"
+            :underline="false"
+            @click="report(row, 'detail')"
+            >{{ row.code }}</el-link
+          >
+        </template>
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
           <el-link
             type="primary"
             :underline="false"
             icon="el-icon-edit"
-            @click="sampleCollection(row)"
-            v-if="row.status == 0"
+            @click="openEdit(row)"
+            v-if="
+              [0, 3].includes(row.approvalStatus) &&
+              pageName == 'inspectionProjectRequest'
+            "
           >
-            收样
+            编辑
           </el-link>
           <el-link
             type="primary"
             :underline="false"
+            v-if="
+              [0, 3].includes(row.approvalStatus) &&
+              pageName == 'inspectionProjectRequest'
+            "
+            @click="approvalSubmit(row)"
+            >提交</el-link
+          >
+          <el-link
+            type="primary"
+            :underline="false"
+            v-if="
+              [2].includes(row.approvalStatus) &&
+              pageName == 'inspectionProjectEntrusted' &&
+              row.status == 0
+            "
+            @click="sampleCollection(row)"
+            >收样</el-link
+          >
+          <el-link
+            type="primary"
+            :underline="false"
+            v-if="
+              [2].includes(row.approvalStatus) &&
+              pageName == 'inspectionProjectEntrusted' &&
+              row.status == 1
+            "
+            @click="report(row,'edit')"
+            >报工</el-link
+          >
+          <el-link
+            type="primary"
+            :underline="false"
+            v-if="
+              [2].includes(row.approvalStatus) &&
+              pageName == 'inspectionProjectEntrusted' &&
+              row.status == 1
+            "
+            @click="openTransfer(row)"
+            >转派</el-link
+          >
+          <el-link
+            type="danger"
+            :underline="false"
             icon="el-icon-edit"
-            @click="openEdit(row)"
-            v-if="row.status == 1"
+            @click="remove(row)"
+            v-if="
+              [0, 3].includes(row.approvalStatus) &&
+              pageName == 'inspectionProjectRequest'
+            "
           >
-            报工
+            删除
           </el-link>
         </template>
       </ele-pro-table>
     </el-card>
     <!-- 编辑弹窗 -->
-    <edit ref="edit" />
+    <inspectionProjectTaskSend
+      ref="inspectionProjectTaskSendRef"
+      @reload="reload"
+    />
+    <!-- 编辑弹窗 -->
+    <inspectionProjectReport
+      ref="inspectionProjectReportRef"
+      @reload="reload"
+    />
+    <processSubmitDialog
+      :processSubmitDialogFlag.sync="processSubmitDialogFlag"
+      v-if="processSubmitDialogFlag"
+      ref="processSubmitDialogRef"
+      @reload="reload"
+    ></processSubmitDialog>
+    <Transfer
+      v-if="transferVisible"
+      :transferVisible.sync="transferVisible"
+      @success="transferConfirm"
+      :id="transferId"
+    ></Transfer>
   </div>
 </template>
 
 <script>
   import search from './components/search.vue';
-  // import edit from './components/inspectionProjectTaskSend.vue';
+  import Transfer from './components/transfer.vue';
+
   import tabMixins from '@/mixins/tableColumnsMixin';
-  import { getList, sampleCollection } from '@/api/inspectionProjectTask';
+  import inspectionProjectTaskSend from '@/views/inspectionProjectTask/components/inspectionProjectTaskSend.vue';
+  import inspectionProjectReport from '@/views/inspectionWork/components/inspectionProjectReport.vue';
+
+  import {
+    getList,
+    sampleCollection,
+    getById,
+    verificationQualityInspector,
+    removeItem
+  } from '@/api/inspectionProjectRequest';
   import dictMixins from '@/mixins/dictMixins';
+  import { reviewStatus } from '@/enum/dict';
+  import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';
+
   export default {
     components: {
-      search
-      // edit
+      search,
+      inspectionProjectTaskSend,
+      processSubmitDialog,
+      inspectionProjectReport,
+      Transfer
+    },
+    props: {
+      cacheKeyUrl: {
+        type: String,
+        default: 'qsm-c2e9664a-inspectionProjectRequest'
+      },
+      pageName: {
+        type: String,
+        default: 'inspectionProjectRequest'
+      }
     },
     mixins: [dictMixins, tabMixins],
     data() {
       return {
-        cacheKeyUrl: 'qsm-c2e9664a-inspectionProjectTask',
+        processSubmitDialogFlag: false,
+        transferVisible: false,
+
+        transferId: '',
         // 表格列配置
-        columns: [
+        columns: []
+      };
+    },
+    created() {
+      this.requestDict('质检计划类型');
+      this.requestDict('取样类型');
+      this.getColumns();
+    },
+    methods: {
+      getColumns() {
+        this.columns = [
           {
             columnKey: 'index',
             label: '序号',
@@ -78,6 +194,7 @@
           },
           {
             prop: 'code',
+            slot: 'code',
             label: '请托单号',
             showOverflowTooltip: true,
             align: 'center',
@@ -212,9 +329,25 @@
             minWidth: 110,
             label: '状态',
             align: 'center',
-     
+            formatter: (row) => {
+              return row.status == 0
+                ? '待收样'
+                : row.status == 1
+                ? '未报工'
+                : '已报工';
+            },
             showOverflowTooltip: true
           },
+          {
+            prop: 'approvalStatus',
+            label: '审核状态',
+            align: 'center',
+            minWidth: 110,
+            showOverflowTooltip: true,
+            formatter: (_row, _column, cellValue) => {
+              return reviewStatus[_row.approvalStatus];
+            }
+          },
           {
             prop: 'createUserName',
             minWidth: 110,
@@ -229,17 +362,35 @@
             align: 'center',
             showOverflowTooltip: true
           },
+          {
+            prop: 'approvalUserName',
+            minWidth: 110,
+            label: '审核人',
+            align: 'center',
+            isNone: this.pageName != 'inspectionProjectEntrusted',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'approvalTime',
+            minWidth: 110,
+            label: '审核时间',
+            align: 'center',
+            isNone: this.pageName != 'inspectionProjectEntrusted',
+            showOverflowTooltip: true
+          },
           {
             prop: 'sampleReceiverName',
             minWidth: 110,
             label: '收样人',
             align: 'center',
+            isNone: this.pageName != 'inspectionProjectEntrusted',
             showOverflowTooltip: true
           },
           {
             prop: 'sampleReceiverTime',
             minWidth: 110,
             label: '收样时间',
+            isNone: this.pageName != 'inspectionProjectEntrusted',
             align: 'center',
             showOverflowTooltip: true
           },
@@ -253,14 +404,24 @@
             fixed: 'right',
             showOverflowTooltip: true
           }
-        ]
-      };
-    },
-    created() {
-      this.requestDict('质检计划类型');
-      this.requestDict('取样类型');
-    },
-    methods: {
+        ].filter((item) => !item.isNone);
+      },
+      approvalSubmit(res) {
+        this.processSubmitDialogFlag = true;
+        this.$nextTick(() => {
+          let params = {
+            businessId: res.id,
+            businessKey: 'quality_inspection_item_entrustment',
+            formCreateUserId: res.createUserId,
+            variables: {
+              businessCode: res.code,
+              businessName: res.name,
+              businessType: '请托'
+            }
+          };
+          this.$refs.processSubmitDialogRef.init(params);
+        });
+      },
       /*回显类型 */
 
       /* 表格数据源 */
@@ -276,24 +437,51 @@
         this.$refs.table.reload({ page: 1, where: where });
       },
 
-      uploadFile() {
-        this.$refs.importDialogRef.open();
+      /* 打开编辑弹窗 */
+      openEdit(row) {
+        this.$refs.inspectionProjectTaskSendRef.open(
+          row,
+          '2',
+          'inspectionProjectRequest'
+        );
+      },
+      /* 报工 */
+      async report(row, type) {
+        const code = await verificationQualityInspector(row.id);
+        if (code == '-1') {
+          return;
+        }
+        const res = await getById(row.id);
+        this.$refs.inspectionProjectReportRef.open(
+          { workData: res, list: res.templateList },
+          type,
+          'inspectionProjectRequest'
+        );
       },
-      sampleCollection(row) {
+      async sampleCollection(row) {
+        const code = await verificationQualityInspector(row.id);
+        if (code == '-1') {
+          return;
+        }
+
         sampleCollection({ id: row.id }).then((res) => {
           this.$message.success('收样成功');
-
           this.reload();
         });
       },
-      /* 打开编辑弹窗 */
-      openEdit(row) {
-        this.current = row;
-        this.showEdit = true;
-        this.$refs.userEdit.$refs.form &&
-          this.$refs.userEdit.$refs.form.clearValidate();
+      async openTransfer(row) {
+        const code = await verificationQualityInspector(row.id);
+        if (code == '-1') {
+          return;
+        }
+        this.transferVisible = true;
+        this.transferId = row.id;
+      },
+      transferConfirm() {
+        this.transferVisible = false;
+        this.$message.success('转派成功');
+        this.reload();
       },
-
       /* 删除 */
       remove(row) {
         const loading = this.$loading({ lock: true });
@@ -307,30 +495,6 @@
           .catch((e) => {
             loading.close();
           });
-      },
-
-      /* 批量删除 */
-      removeBatch() {
-        if (!this.selection.length) {
-          this.$message.error('请至少选择一条数据');
-          return;
-        }
-        this.$confirm('确定要删除选中的质检吗?', '提示', {
-          type: 'warning'
-        })
-          .then(() => {
-            const loading = this.$loading({ lock: true });
-            removeItem(this.selection.map((d) => d.id))
-              .then((msg) => {
-                loading.close();
-                this.$message.success('删除' + msg);
-                this.reload();
-              })
-              .catch((e) => {
-                loading.close();
-              });
-          })
-          .catch(() => {});
       }
     }
   };

+ 37 - 9
src/views/inspectionProjectTask/components/inspectionProjectTaskSend.vue

@@ -15,6 +15,8 @@
       :columns="tableColumns"
       :datasource="list"
       :selection.sync="selection"
+      rowKey="id"
+      ref="table"
     ></ele-pro-table>
     <header-title title="派单信息"></header-title>
     <el-form
@@ -97,6 +99,10 @@
     qualityInspectionItemRequest
   } from '@/api/inspectionProjectTask';
   import { getById } from '@/api/inspectionWork';
+  import {
+    getById as getQualityInspectionItemById,
+    updateRequestentrust
+  } from '@/api/inspectionProjectRequest';
   import { inspectionProjectStatus } from '@/enum/dict.js';
   import deptSelect from '@/components/CommomSelect/dept-select.vue';
   import { getUserPage } from '@/api/system/organization';
@@ -118,6 +124,7 @@
     data() {
       return {
         type: 1,
+        pgaeName: '',
         form: { ...defaultForm },
         executorList: [],
         selection: [],
@@ -136,7 +143,7 @@
             columnKey: 'selection',
             align: 'center',
             selectable: (row, index) => {
-              return row.status == 0;
+              return row.status == 0 || this.templateIdS.includes(row.id);
             }
           },
           {
@@ -211,7 +218,7 @@
             { required: true, message: '请选择人员', trigger: 'blur' }
           ]
         },
-
+        templateIdS: [],
         loading: false,
         visible: false
       };
@@ -219,13 +226,26 @@
 
     created() {},
     methods: {
-      open(row, type) {
+      async open(row, type, pgaeName) {
         this.type = type;
+        this.pgaeName = pgaeName;
         this.visible = true;
-        getById(row.id).then((res) => {
-          let data = res.data;
-          this.form.qualityWorkOrderId = data.id;
-          this.list = data.templateList;
+        this.templateIdS = [];
+        if (pgaeName == 'inspectionProjectRequest') {
+          this.form = await getQualityInspectionItemById(row.id);
+          this.getUserList({ groupId: this.form.executeDeptId }, true);
+          if (this.form.templateList.length) {
+            this.templateIdS = this.form.templateList.map((item) => item.id);
+          }
+        } else {
+          this.form.qualityWorkOrderId = row.id;
+        }
+        //获取工单质检方案
+        await getById(this.form.qualityWorkOrderId).then((res) => {
+          this.list = res.data.templateList;
+          this.$nextTick(() => {
+            this.$refs.table.setSelectedRowKeys(this.templateIdS);
+          });
         });
       },
       searchDeptNodeClick(info, row) {
@@ -241,7 +261,7 @@
         }
       },
       // 获取人员
-      async getUserList(params) {
+      async getUserList(params, init) {
         try {
           let data = { pageNum: 1, size: -1 };
 
@@ -250,6 +270,9 @@
           }
           const res = await getUserPage(data);
           this.executorList = res.list;
+          if (init) {
+            return;
+          }
           this.form.executeUserId = null;
           this.form.executeUserName = null;
         } catch (error) {}
@@ -274,7 +297,12 @@
           let api =
             this.type == 1
               ? qualityInspectionItemDispatching
-              : qualityInspectionItemRequest;
+              : this.type == 2
+              ? this.pgaeName == 'inspectionProjectRequest'
+                ? updateRequestentrust
+                : qualityInspectionItemRequest
+              : '';
+
           api({
             ...this.form,
             detailList: this.selection.map((item) => {

+ 19 - 36
src/views/inspectionProjectTask/index.vue

@@ -21,7 +21,14 @@
         <template v-slot:qualityMode="{ row }">
           {{ getDictValue('取样类型', row.qualityMode) }}
         </template>
-
+        <template v-slot:code="{ row }">
+          <el-link
+            type="primary"
+            :underline="false"
+            @click="report(row, 'detail')"
+            >{{ row.code }}</el-link
+          >
+        </template>
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
           <el-link
@@ -37,7 +44,7 @@
             type="primary"
             :underline="false"
             icon="el-icon-edit"
-            @click="openEdit(row)"
+            @click="report(row, 'edit')"
             v-if="row.status == 1"
           >
             报工
@@ -63,8 +70,6 @@
     getById
   } from '@/api/inspectionProjectTask';
   import dictMixins from '@/mixins/dictMixins';
-import { workOrder } from '@/api/aps';
-import list from '@/i18n/lang/zh_CN/list';
   export default {
     components: {
       search,
@@ -87,6 +92,7 @@ import list from '@/i18n/lang/zh_CN/list';
           },
           {
             prop: 'code',
+            slot: 'code',
             label: '质检任务单号',
             showOverflowTooltip: true,
             align: 'center',
@@ -261,7 +267,7 @@ import list from '@/i18n/lang/zh_CN/list';
       this.requestDict('质检计划类型');
       this.requestDict('取样类型');
     },
-    
+
     methods: {
       /*回显类型 */
 
@@ -278,9 +284,6 @@ import list from '@/i18n/lang/zh_CN/list';
         this.$refs.table.reload({ page: 1, where: where });
       },
 
-      uploadFile() {
-        this.$refs.importDialogRef.open();
-      },
       sampleCollection(row) {
         sampleCollection({ id: row.id }).then((res) => {
           this.$message.success('收样成功');
@@ -288,11 +291,15 @@ import list from '@/i18n/lang/zh_CN/list';
           this.reload();
         });
       },
-      /* 打开编辑弹窗 */
-      async openEdit(row) {
+      /* 报工 */
+      async report(row, type) {
         const res = await getById(row.id);
-      
-        this.$refs.inspectionProjectReportRef.open({workData:res.data,list:res.data.templateList}, 'edit');
+
+        this.$refs.inspectionProjectReportRef.open(
+          { workData: res.data, list: res.data.templateList },
+          type,
+          'inspectionProjectTask'
+        );
       },
 
       /* 删除 */
@@ -308,30 +315,6 @@ import list from '@/i18n/lang/zh_CN/list';
           .catch((e) => {
             loading.close();
           });
-      },
-
-      /* 批量删除 */
-      removeBatch() {
-        if (!this.selection.length) {
-          this.$message.error('请至少选择一条数据');
-          return;
-        }
-        this.$confirm('确定要删除选中的质检吗?', '提示', {
-          type: 'warning'
-        })
-          .then(() => {
-            const loading = this.$loading({ lock: true });
-            removeItem(this.selection.map((d) => d.id))
-              .then((msg) => {
-                loading.close();
-                this.$message.success('删除' + msg);
-                this.reload();
-              })
-              .catch((e) => {
-                loading.close();
-              });
-          })
-          .catch(() => {});
       }
     }
   };

+ 73 - 12
src/views/inspectionWork/components/inspectionProjectReport.vue

@@ -1,7 +1,7 @@
 <!-- 用户编辑弹窗 -->
 <template>
   <ele-modal
-    title="质检项工单报工"
+    :title="title + (type == 'detail' ? '详情' : '报工')"
     :visible.sync="visible"
     :before-close="handleClose"
     :close-on-click-modal="false"
@@ -26,7 +26,12 @@
         {{ getDictValue('取样类型', row.qualityMode) }}
       </template>
       <template v-slot:hours="{ row }">
-        <el-input v-model="row.hours" placeholder="请输入" type="number">
+        <el-input
+          v-model="row.hours"
+          placeholder="请输入"
+          type="number"
+          :disabled="type == 'detail'"
+        >
         </el-input>
       </template>
       <template v-slot:accessory="{ row }">
@@ -38,6 +43,7 @@
           placeholder="请输入"
           type="number"
           @input="formSampleQuantityChange"
+          :disabled="type == 'detail'"
         >
         </el-input>
       </template>
@@ -47,6 +53,7 @@
           @input="formSampleNoQualifiedNumberChange"
           placeholder="请输入"
           type="number"
+          :disabled="type == 'detail'"
         >
         </el-input>
       </template>
@@ -63,7 +70,11 @@
         {{ getDictValue('质检标准类型', row.qualityStandardType) }}
       </template>
       <template v-slot:executionMethod="{ row }">
-        <el-select v-model="row.executionMethod" style="width: 100%">
+        <el-select
+          v-model="row.executionMethod"
+          style="width: 100%"
+          :disabled="type == 'detail'"
+        >
           <el-option :value="1" label="常规检验"></el-option>
           <el-option :value="2" label="实验"></el-option>
         </el-select>
@@ -178,10 +189,15 @@
           </el-option>
         </el-select>
       </template>
+      <template v-slot:isRequired="{ column }">
+        <span class="is-required">{{ column.label }}</span>
+      </template>
     </ele-pro-table>
     <template v-slot:footer>
       <el-button @click="handleClose">取消</el-button>
-      <el-button type="primary" @click="handleConfirm"> 确认 </el-button>
+      <el-button type="primary" @click="handleConfirm" v-if="type != 'detail'">
+        确认
+      </el-button>
     </template>
   </ele-modal>
 </template>
@@ -191,7 +207,10 @@
   import detailMixins from '../mixins/detailMixins';
   import toolButtom from './toolButtom.vue';
   import { handleInput } from './unit.js';
-
+  import {
+    exeTaskReportWork,
+    exeEntrustReportWork
+  } from '@/api/inspectionProjectTask';
   export default {
     mixins: [dictMixins, detailMixins],
 
@@ -200,8 +219,8 @@
     data() {
       return {
         handleInput,
-        type: 'add',
-        title: '',
+        type: 'report',
+        title: '质检项工单',
         visible: false,
         form: {},
         tableData: [],
@@ -471,6 +490,7 @@
             prop: 'qualityResultContent',
             align: 'center',
             slot: 'qualityResultContent',
+            headerSlot: 'isRequired',
             label: '质检内容',
             showOverflowTooltip: true
           },
@@ -584,7 +604,8 @@
             label: '让步接收'
           }
         ],
-        sList: [] //质检工具筛选
+        sList: [], //质检工具筛选
+        pageName: ''
       };
     },
     computed: {
@@ -605,8 +626,16 @@
       this.requestDict('质检标准类型');
     },
     methods: {
-      async open({ workData, row, list }, type) {
+      async open({ workData, row, list }, type, pageName) {
         this.tableData = [];
+        this.pageName = pageName;
+        this.type = type;
+        if (pageName == 'inspectionProjectTask') {
+          this.title = '质检项任务单';
+        }
+        if (pageName == 'inspectionProjectRequest') {
+          this.title = '质检项受托单';
+        }
         if (type == 'report') {
           let data = { ...workData, ...row };
           data.sampleQuantity = row.sampleQuantity || data.remainingSampleCount;
@@ -615,9 +644,15 @@
           this.tableData.forEach((item, index) => {
             item.executionMethod = item.executionMethod || 1;
           });
+          if (row.sampleQuantity) {
+            this.form.remainingSampleCount =
+              row.sampleQuantity + this.form.remainingSampleCount;
+          }
         } else {
           this.$set(this, 'form', JSON.parse(JSON.stringify(workData)));
           this.tableData = JSON.parse(JSON.stringify(list));
+          this.form.remainingSampleCount =
+            this.form.sampleQuantity + this.form.remainingSampleCount;
         }
 
         this.visible = true;
@@ -638,7 +673,7 @@
             ]);
           });
         }
-        this.form.sampleQualifiedNumber = 0;
+        this.form.sampleQualifiedNumber = this.form.sampleQuantity;
         this.form.sampleNoQualifiedNumber = 0;
       },
       formSampleNoQualifiedNumberChange() {
@@ -653,8 +688,34 @@
         this.visible = false;
       },
       handleConfirm() {
-        this.$emit('success', { data: this.form, tableData: this.tableData });
-        this.visible = false;
+        let isHandleConfirm = false;
+        this.tableData.forEach((item, index) => {
+          if (!item.qualityResultContent) {
+            isHandleConfirm = true;
+          } else {
+            item.status = 1;
+          }
+        });
+        // if (isHandleConfirm) {
+        //   return this.$message.error('质检内容不能为空!');
+        // }
+        if (!this.pageName) {
+          this.$emit('success', { data: this.form, tableData: this.tableData });
+          this.visible = false;
+        } else {
+          let api =
+            this.pageName == 'inspectionProjectTask'
+              ? exeTaskReportWork
+              : exeEntrustReportWork;
+          api({
+            ...this.form,
+            templateList: this.tableData
+          }).then((res) => {
+            this.$message.success('操作成功');
+            this.$emit('reload');
+            this.visible = false;
+          });
+        }
       },
       inputValue(type, item, index) {
         //样品数

+ 217 - 6
src/views/inspectionWork/components/newQualityContentTabs.vue

@@ -420,15 +420,17 @@
           </el-table-column>
           <el-table-column
             label="质检状态"
-            prop="qualityStatus"
+            prop="status"
             align="center"
             :show-overflow-tooltip="true"
             v-if="form.recordingMethod == 1"
           >
             <template slot-scope="scope">
-              <span v-if="scope.row.qualityStatus == 0">未检</span>
-              <span v-if="scope.row.qualityStatus == 1">已检</span>
-              <span v-if="scope.row.qualityStatus == 2">待检</span>
+              {{
+                inspectionProjectStatus.find(
+                  (item) => item.value == scope.row.status
+                )?.label
+              }}
             </template>
           </el-table-column>
           <el-table-column
@@ -445,7 +447,9 @@
                 v-model="scope.row.qualityResults"
                 placeholder="请选择"
                 style="width: 100%"
-                :disabled="type == 'detail'"
+                :disabled="
+                  type == 'detail' || [2, 3, 4].includes(scope.row.status)
+                "
                 size="mini"
               >
                 <el-option
@@ -472,6 +476,7 @@
                 class="ele-action"
                 title="确定要删除当前方案吗?"
                 @confirm="handDel(scope.$index)"
+                v-if="![1, 2, 3, 4].includes(scope.row.status)"
               >
                 <template v-slot:reference>
                   <el-link
@@ -496,6 +501,28 @@
           :total="schemeList.length"
         /> -->
       </el-tab-pane>
+      <el-tab-pane
+        label="质检项任务单"
+        name="4"
+        v-if="form.recordingMethod == 1"
+      >
+        <ele-pro-table
+          ref="table"
+          :columns="taskColumns"
+          :datasource="form.taskMonadList"
+          :needPage="false"
+        >
+        </ele-pro-table>
+      </el-tab-pane>
+      <el-tab-pane label="质检项请托单" name="5" v-if="form.recordingMethod == 1">
+        <ele-pro-table
+          ref="table"
+          :columns="entrustColumns"
+          :datasource="form.requestEntrustList"
+          :needPage="false"
+        >
+        </ele-pro-table>
+      </el-tab-pane>
     </el-tabs>
   </el-row>
 </template>
@@ -517,8 +544,12 @@
   } from '@/api/inspectionWork';
   import { getQualityTemplateByIds } from '@/api/inspectionTemplate';
   import { getCodeList } from '@/api/login';
+  import { inspectionProjectStatus } from '@/enum/dict.js';
+  import dictMixins from '@/mixins/dictMixins';
 
   export default {
+    mixins: [dictMixins],
+
     components: {
       inspectionTemplateDialog
     },
@@ -555,6 +586,7 @@
     },
     data() {
       return {
+        inspectionProjectStatus,
         disposeTypeList: {
           1: '返工',
           2: '返修',
@@ -696,7 +728,183 @@
           { label: '生产日期', prop: 'productionDate', align: 'center' },
           { label: '采购日期', prop: 'purchaseDate', align: 'center' }
         ],
+        entrustColumns: [
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true,
+            fixed: 'left'
+          },
+          {
+            prop: 'code',
+            label: '请托单号',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 130
+          },
+          {
+            prop: 'name',
+            label: '任务名称',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
 
+          {
+            prop: 'sampleQuantity',
+            label: '样品数',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'sampleQualifiedNumber',
+            label: '样品合格数',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'sampleNoQualifiedNumber',
+            label: '样品不合格数',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'lossNumber',
+            label: '损耗数(合格品)',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'lossNumberUnqualified',
+            label: '损耗数(不合格品)',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'retainedSampleQuantity',
+            label: '留样数(合格品)',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'retainedSampleUnqualified',
+            label: '留样数(不合格品)',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'status',
+            minWidth: 110,
+            label: '状态',
+            align: 'center',
+            formatter: (row) => {
+              return row.status == 0
+                ? '待收样'
+                : row.status == 1
+                ? '未报工'
+                : '已报工';
+            },
+            showOverflowTooltip: true
+          }
+        ],
+        taskColumns: [
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true,
+            fixed: 'left'
+          },
+          {
+            prop: 'code',
+            label: '质检任务单号',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 130
+          },
+          {
+            prop: 'name',
+            label: '任务名称',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'sampleQuantity',
+            label: '样品数',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'sampleQualifiedNumber',
+            label: '样品合格数',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'sampleNoQualifiedNumber',
+            label: '样品不合格数',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'lossNumber',
+            label: '损耗数(合格品)',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'lossNumberUnqualified',
+            label: '损耗数(不合格品)',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'retainedSampleQuantity',
+            label: '留样数(合格品)',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'retainedSampleUnqualified',
+            label: '留样数(不合格品)',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'status',
+            minWidth: 110,
+            label: '状态',
+            align: 'center',
+            formatter: (row) => {
+              return row.status == 0
+                ? '待收样'
+                : row.status == 1
+                ? '未报工'
+                : '已报工';
+            },
+            showOverflowTooltip: true
+          }
+        ],
         conditionType: null,
         formData: {
           number: 1,
@@ -1244,10 +1452,13 @@
         // const removeDupList = [...new Set(strings)];
         // const result = removeDupList.map((item) => JSON.parse(item));
 
-        this.templateList = [];
+        if (this.form.recordingMethod != 1) {
+          this.templateList = [];
+        }
         this.templateList.push(...data);
         this.templateList.forEach((item) => {
           item['qualityResults'] = 1;
+          item['status'] = 0;
         });
 
         // this.templateList = result.map((item) => {

+ 149 - 53
src/views/inspectionWork/edit.vue

@@ -48,7 +48,7 @@
 
       <header-title title="样品信息"></header-title>
       <el-form label-width="130px">
-        <el-row>
+        <el-row v-if="form.recordingMethod != 1">
           <el-col :span="6">
             <el-form-item label="样品合格数:" prop="sampleQualifiedNumber">
               <el-input
@@ -85,6 +85,43 @@
             </el-form-item>
           </el-col>
         </el-row>
+        <el-row v-else>
+          <el-col :span="6">
+            <el-form-item label="样品合格数:" prop="sampleQualifiedNumber">
+              <el-input
+                type="number"
+                :min="0"
+                disabled
+                :value="getSampleQuantity('sampleQualifiedNumber')"
+                placeholder=""
+              ></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="样品不合格数:" prop="sampleNoQualifiedNumber">
+              <el-input
+                type="number"
+                :min="0"
+                disabled
+                :value="getSampleQuantity('sampleNoQualifiedNumber')"
+                placeholder=""
+              ></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="样品合格率:" prop="sampleQualificationRate">
+              <el-input v-model="form.sampleQualificationRate" disabled />
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item
+              label="样品不合格率:"
+              prop="sampleNoQualificationRate"
+            >
+              <el-input v-model="form.sampleNoQualificationRate" disabled />
+            </el-form-item>
+          </el-col>
+        </el-row>
         <el-row>
           <el-col :span="6">
             <el-form-item label="样品类型:" prop="samplesType">
@@ -113,7 +150,10 @@
         <el-row v-if="form.recordingMethod == 1">
           <el-col :span="6">
             <el-form-item label="留样数(合格品):" prop="retainedSampleQuantity">
-              <el-input disabled v-model="form.retainedSampleQuantity" />
+              <el-input
+                disabled
+                :value="getSampleQuantity('retainedSampleQuantity')"
+              />
             </el-form-item>
           </el-col>
           <el-col :span="6">
@@ -121,12 +161,15 @@
               label="留样数(不合格品):"
               prop="retainedSampleUnqualified"
             >
-              <el-input disabled v-model="form.retainedSampleUnqualified" />
+              <el-input
+                disabled
+                :value="getSampleQuantity('retainedSampleUnqualified')"
+              />
             </el-form-item>
           </el-col>
           <el-col :span="6">
-            <el-form-item label="损耗数(合格品):" prop="lossNumbe">
-              <el-input disabled v-model="form.lossNumbe" />
+            <el-form-item label="损耗数(合格品):" prop="lossNumber">
+              <el-input disabled :value="getSampleQuantity('lossNumber')" />
             </el-form-item>
           </el-col>
           <el-col :span="6">
@@ -134,7 +177,10 @@
               label="损耗数(不合格品):"
               prop="lossNumberUnqualified"
             >
-              <el-input disabled v-model="form.lossNumberUnqualified" />
+              <el-input
+                disabled
+                :value="getSampleQuantity('lossNumberUnqualified')"
+              />
             </el-form-item>
           </el-col>
         </el-row>
@@ -235,6 +281,34 @@
           }
           return '小样';
         };
+      },
+      getSampleQuantity() {
+        return (key) => {
+          let num = Number(this.form.taskMonadInfo?.[key]) || 0;
+          this.form.taskMonadList?.forEach((item) => {
+            num += Number(item[key]) || 0;
+          });
+          this.form.requestEntrustList?.forEach((item) => {
+            num += Number(item[key]) || 0;
+          });
+          this.form[key] = num;
+          if (key == 'sampleNoQualifiedNumber') {
+            let total = num + this.form.sampleQualifiedNumber;
+            if (total) {
+              this.form.sampleNoQualificationRate = (
+                (num / total) *
+                100
+              ).toFixed(2);
+              this.form.sampleQualificationRate = (
+                (this.form.sampleQualifiedNumber / total) *
+                100
+              ).toFixed(2);
+            }
+          }
+          this.quantityAssignment();
+
+          return num;
+        };
       }
     },
     // p:{
@@ -328,6 +402,7 @@
         statusType: false
       };
     },
+
     watch: {
       '$route.query.id': {
         handler(id) {
@@ -734,35 +809,45 @@
       //质检项报工
       inspectionProjectReport({ index, list }) {
         this.$nextTick(() => {
-          this.$refs.inspectionProjectReportRef.open({
-            workData: {
-              qualityWorkOrderCode: this.form.code,
-              qualityWorkOrderName: this.form.name,
-              qualityWorkOrderId: this.form.id,
-              sourceCode: this.form.sourceCode,
-              qualityType: this.form.qualityType,
-              qualityMode: this.form.qualityMode,
-              productCode: this.form.productCode,
-              productName: this.form.productName,
-              batchNo: this.form.batchNo,
-              specification: this.form.specification,
-              brandNo: this.form.brandNo,
-              produceTaskName: this.form.produceTaskName,
-              total: this.form.total,
-              hours: this.form.hours,
-              accessory: this.form.accessory,
-              qualityNames: this.form.qualityNames,
-              qualityTimeEnd: this.form.qualityTimeEnd,
-              remainingSampleCount: this.form.remainingSampleCount
+          if (this.form.taskMonadInfo) {
+            delete this.form.taskMonadInfo.remainingSampleCount;
+          }
+          this.$refs.inspectionProjectReportRef.open(
+            {
+              workData: {
+                qualityWorkOrderCode: this.form.code,
+                qualityWorkOrderName: this.form.name,
+                qualityWorkOrderId: this.form.id,
+                sourceCode: this.form.sourceCode,
+                qualityType: this.form.qualityType,
+                qualityMode: this.form.qualityMode,
+                productCode: this.form.productCode,
+                productName: this.form.productName,
+                batchNo: this.form.batchNo,
+                specification: this.form.specification,
+                brandNo: this.form.brandNo,
+                produceTaskName: this.form.produceTaskName,
+                total: this.form.total,
+                hours: this.form.hours,
+                accessory: this.form.accessory,
+                qualityNames: this.form.qualityNames,
+                qualityTimeEnd: this.form.qualityTimeEnd,
+                remainingSampleCount: this.form.remainingSampleCount
+              },
+              row: this.form.taskMonadInfo || {},
+              list
             },
-            row: this.form.taskMonadInfo || {},
-            list
-          },'report');
+            'report'
+          );
         });
       },
       //质检项报工回调
       inspectionProjectReportSuccess({ data, tableData }) {
-        this.schemeList = tableData;
+
+        this.schemeList = [
+          ...tableData,
+          ...this.schemeList.filter((item) =>item.correlationId)
+        ];
         data.type = 2;
         this.form.taskMonadInfo = data;
         this.form.hours = data.hours;
@@ -1441,43 +1526,49 @@
 
         this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
           if (!valid) return false;
-          this.loading = true;
+          //单样全部
+          if (this.form.recordingMethod == 2) {
+            if (this.qualityType == 2 && this.isReportProcessProduce) {
+              for (let i = 0; i < this.sampleList.length; i++) {
+                const disposalStatus = this.sampleList[i].disposalStatus;
+
+                if (disposalStatus == null) {
+                  this.loading = false;
+                  this.$refs.tabsRef.tabsChange('2');
+                  this.$message.error('请完成以下样品处置!');
+                  return;
+                }
+              }
+            }
 
-          if (this.qualityType == 2 && this.isReportProcessProduce) {
             for (let i = 0; i < this.sampleList.length; i++) {
-              const disposalStatus = this.sampleList[i].disposalStatus;
+              const qualityStatus = this.sampleList[i].qualityStatus;
 
-              if (disposalStatus == null) {
+              if (qualityStatus == '2') {
                 this.loading = false;
                 this.$refs.tabsRef.tabsChange('2');
-                this.$message.error('请完成以下样品处置!');
+                this.$message.error('请完成以下样品质检!');
                 return;
               }
             }
-          }
-
-          for (let i = 0; i < this.sampleList.length; i++) {
-            const qualityStatus = this.sampleList[i].qualityStatus;
-
-            if (qualityStatus == '2') {
-              this.loading = false;
-              this.$refs.tabsRef.tabsChange('2');
-              this.$message.error('请完成以下样品质检!');
-              return;
+          } else {
+            let is = false;
+            this.schemeList.forEach((item) => {
+              if (item.status != 1) {
+                is = true;
+              }
+            });
+            if (is) {
+              this.$message.error('有未完成质检项质检,请检查!');
+              return
             }
           }
-
-          // this.form.qualityTimeEnd = new Date(this.getNowTime());
-          // this.form.qualityTimeStart = new Date(this.qualityTimeStart);
+          this.loading = true;
 
           this.form.qualityTimeEnd = this.getNowTime();
           this.form.qualityTimeStart = this.qualityTimeStart;
           this.form.qualityId = this.form.qualityIdList.join(',');
 
-          // if (this.form.qualityMode == 1) {
-          //   this.form.qualityResults = '';
-          // }
-
           let params = {
             ...this.form,
             sampleList: this.sampleList,
@@ -1598,7 +1689,12 @@
           return;
         }
         if (this.form.recordingMethod == 1) {
-          this.inspectionProjectReport({ index: -1, list: this.schemeList });
+          this.inspectionProjectReport({
+            index: -1,
+            list: this.schemeList.filter(
+              (item) => !item.correlationId
+            )
+          });
           return;
         }
 

+ 1 - 1
src/views/inspectionWork/index.vue

@@ -184,7 +184,7 @@
 <script>
   import Certificate from './components/Certificate.vue';
   import search from './components/search.vue';
-  import addSample from '@/views/sample/sampleRecord/components/addSample.vue';
+  import addSample from '@/views/sample/sampleRecord/components/addSample1.vue';
   import jimureportBrowse from '@/components/jimureport/browseModal.vue';
   import Transfer from './components/transfer.vue';
   import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';

+ 91 - 94
src/views/sample/sampleRecord/components/addSample.vue

@@ -128,7 +128,7 @@
         :selection.sync="selection"
       >
         <template v-slot:toolbar>
-          累计取样数量:{{ workSampleQuantity }}{{ form.unit }}
+          累计取样数量:{{ workSampleQuantity }}{{form.conditionType == '1' ? form.measureUnit : form.unit}}
         </template>
       </ele-pro-table>
       <header-title title="请样信息"> </header-title>
@@ -147,7 +147,7 @@
           <el-form-item label="请样数量:" prop="pleaseQuantity">
             <el-input v-model="form.pleaseQuantity" placeholder="请输入">
               <template slot="append">
-                {{ form.pleaseUnit }}
+                {{ form.measureUnit }}
               </template>
             </el-input>
           </el-form-item>
@@ -319,7 +319,7 @@
         >确认</el-button
       >
 
-      <el-button @click="cancel">关闭 {{ form.processInstanceId }}</el-button>
+      <el-button @click="cancel">关闭</el-button>
     </template>
     <inspectionWorkDialog
       ref="inspectionWorkDialog"
@@ -657,8 +657,10 @@
           } else {
             this.$set(this.form, 'unit', data?.list[0].unit);
           }
-          this.datasource(data?.list[0]?.unit);
-          this.queryQualityTempleContent(!data?.list.length&&row.qualityMode==1);
+          await this.datasource(data?.list[0]?.unit);
+          await this.queryQualityTempleContent(
+            !data?.list.length && row.qualityMode == 1
+          );
         }
       },
       getById(id) {
@@ -682,16 +684,19 @@
           this.form = { ...res, ...res.qualityWorkOrderVO };
           this.datasource(this.form.unit);
           this.queryQualityTempleContent();
-          if (res.qualityWorkOrderVO.conditionType == 1) {
-            // if (this.form.unit == res.qualityWorkOrderVO.measureUnit) {
-            //   this.$set(this.form, 'packingUnit', '111');
-            // } else {
-            //   this.$set(this.form, 'packingUnit', '222');
-            // }
-            this.$set(this.form, 'portion', res.quantity);
-            this.$set(this.form, 'quantity', 0);
-          } else {
-            this.$set(this.form, 'portion', res.copies);
+          if (this.form.qualityMode == 2) {
+            if (res.qualityWorkOrderVO.conditionType == 1) {
+              // if (res.unit != res.qualitySampleList[0].measureUnit) {
+              //   this.$set(this.form, 'portion', res.qualitySampleList.length);
+              // } else {
+
+              // }
+              this.$set(this.form, 'portion', res.quantity);
+              this.$set(this.form, 'quantity', 0);
+            } else {
+              this.$set(this.form, 'portion', res.copies);
+              // this.$set(this.form, 'quantity', res.quantity / res.copies);
+            }
           }
 
           this.sampleList = res.qualitySampleList;
@@ -705,8 +710,8 @@
           size: 10000
         });
         this.schemeList = res.list;
-        if(is){
-             this.updatePackingList()
+        if (is) {
+          this.updatePackingList();
         }
       },
       cancel() {
@@ -791,21 +796,8 @@
         const unit = data.sampleUnit;
         const sampleCount = Number(data.portion);
         try {
-          if (
-            this.form.inspectionStandards === 1 ||
-            ([2, 3, 4, 5].includes(this.form.inspectionStandards) &&
-              this.form.conditionType == 2)
-          ) {
-            // 新增校验 数量  取整样 ***
-            if (this.form.conditionType == 1) {
-              let isFlag = this.validateSampleQuantity(
-                sampleCount,
-                specifications
-              );
-              if (!isFlag) return;
-            }
-            // ***
-            //抽检计量整样小样或者抽检计重小样
+          // 2 取小样
+          if (this.form.conditionType == 2) {
             if (!this.validateMeasureQuantity(quantity, unit, sampleCount))
               return; //取样数量验证
             if (unit === 'KG' && !this.validateWeight(quantity, sampleCount))
@@ -817,15 +809,22 @@
               unit,
               specifications
             );
-            // 这里是取整样 非数量
-          } else if (
-            [2, 3, 4, 5].includes(this.form.inspectionStandards) &&
-            this.form.conditionType == 1
-          ) {
-            console.log('这里是取整样 吗');
-            //抽检取计重取整样
-            if (!this.validateSampleCount(sampleCount, specifications)) return;
-            await this.handleWeightFullSample(sampleCount, specifications);
+          } else {
+            let isFlag = this.validateSampleQuantity(
+              sampleCount,
+              specifications
+            );
+            if (!isFlag) return;
+            if (this.form.inspectionStandards == 1) {
+              await this.getNewFullSampleList(
+                Math.ceil(sampleCount),
+                quantity,
+                unit,
+                specifications
+              );
+            } else {
+              await this.handleWeightFullSample(sampleCount, specifications);
+            }
           }
         } catch (error) {
           console.error('取样处理失败:', error);
@@ -839,7 +838,6 @@
         });
 
         if (totalMaxPossible < sampleCount) {
-          // this.form.portion = totalMaxPossible;
           this.$message.info(`最大取样条数为${totalMaxPossible}`);
           return false;
         }
@@ -871,7 +869,7 @@
       },
 
       validateMeasureQuantity(quantity, unit, sampleCount) {
-        if (this.form.conditionType == 2 && quantity <= 0) {
+        if (quantity <= 0) {
           this.$message.info('取样计量数量必须大于0');
           return false;
         }
@@ -881,8 +879,7 @@
           this.workSampleQuantity;
 
         if (
-          (this.selection[0].measureUnit === unit ||
-            this.form.conditionType == 1) &&
+          this.selection[0].measureUnit === unit &&
           quantity * sampleCount > totalQuantity
         ) {
           this.$message.info('取样计量数量不能大于总计量数量');
@@ -896,32 +893,6 @@
           this.$message.info('条目计量数量小于取样计量数量');
           return false;
         }
-
-        return true;
-      },
-
-      // 抽检取整样 校验
-      validateSampleCount(sampleCount, specifications) {
-        // 新增校验 ***
-        let isFlag = this.validateSampleQuantity(sampleCount, specifications);
-        if (!isFlag) {
-          return false;
-        }
-        // ***
-        const chooseNumber = this.selection.reduce((acc, pro) => {
-          return pro.measureQuantity ? acc + Number(pro.measureQuantity) : acc;
-        }, 0);
-        const invalidItem =
-          chooseNumber < sampleCount + this.workSampleQuantity;
-        // console.log(this.selection, 'this.selection');
-        // const invalidItem = this.selection.find(
-        //   (item) => item.measureQuantity < sampleCount
-        // );
-        if (invalidItem) {
-          this.$message.info('所选的条目计量数量小于取样计量数量');
-          return false;
-        }
-        // ***
         return true;
       },
 
@@ -1128,6 +1099,7 @@
       validateSampleQuantity(sampleCount, specifications) {
         let packingUnit = this.selection[0].packingUnit?.trim() || '';
         let totalS = 0;
+        let measureQuantityCount = 0;
         let labelKey =
           packingUnit == specifications.conversionUnit.trim()
             ? 'packingQuantity'
@@ -1135,7 +1107,7 @@
         let labelName = labelKey == 'packingQuantity' ? '包装数量' : '计量数量';
         totalS = this.selection.reduce((total, el) => total + el[labelKey], 0);
         let formTotalS = this.tableList.reduce(
-          (total, el) => total + el[labelKey],
+          (total, el) => total + el.measureQuantity,
           0
         );
         if (sampleCount > totalS) {
@@ -1144,9 +1116,17 @@
           );
           return false;
         }
-        if (sampleCount > formTotalS - this.workSampleQuantity) {
+        if (labelKey == 'packingQuantity') {
+          measureQuantityCount =
+            sampleCount * this.selection[0].measureQuantity;
+        } else {
+          measureQuantityCount = sampleCount;
+        }
+        if (measureQuantityCount > formTotalS - this.workSampleQuantity) {
           this.$message.info(
-            `取样数量不能大于${formTotalS - this.workSampleQuantity}`
+            `取样数量不能大于${formTotalS - this.workSampleQuantity} ${
+              this.selection[0].measureUnit
+            }`
           );
           return false;
         }
@@ -1184,28 +1164,27 @@
                 )
               );
 
-          if (sampleCount >= list.length) {
-            dataList.push({
-              ...item,
-              measureQuantity: item.measureQuantity, //作为计量数量
-              sampleCode: codeList[index],
-              qualitySampleTemplateList
-            });
-          }
+          // if (sampleCount >= list.length) {
+          dataList.push({
+            ...item,
+            measureQuantity: item.measureQuantity, //作为计量数量
+            sampleCode: codeList[index],
+            qualitySampleTemplateList
+          });
+          // }
         }
+        console.log(dataList, 'dataList');
 
         this.sampleList = dataList;
         this.getTotal();
       },
       getTotal() {
-        this.form.sampleQuantity = this.sampleList.reduce(
-          (total, el) => total + Number(el.measureQuantity),
-          0
-        );
-        this.form.sampleWeight = this.sampleList.reduce(
-          (total, el) => total + Number(el.weight),
-          0
-        );
+        this.form.sampleQuantity = this.sampleList
+          .reduce((total, el) => total + Number(el.measureQuantity), 0)
+          .toFixed(2);
+        this.form.sampleWeight = this.sampleList
+          .reduce((total, el) => total + Number(el.weight), 0)
+          .toFixed(2);
       },
       async batchCodes(count) {
         if (count <= 0) return;
@@ -1229,9 +1208,8 @@
             delete this.form[key];
           });
         }
-        if (this.form.conditionType == 1) {
-          this.form.quantity = this.form.portion;
-        }
+        let data = JSON.parse(JSON.stringify(this.form));
+
         let api =
           this.type == 'add' ? samplingrecordSave : samplingrecordUpdate;
         this.$refs.form.validate((valid) => {
@@ -1240,10 +1218,29 @@
               this.$message.error('样品清单不能为空!');
               return;
             }
+            //抽检
+            if (data.qualityMode == 2) {
+              //取整样
+              if (data.conditionType == 1) {
+                data.quantity = data.portion;
+                // if (data.unit != data.measureUnit) {
+                //   data.quantity = this.sampleList.reduce(
+                //     (total, el) => total + Number(el.measureQuantity),
+                //     0
+                //   );
+                // } else {
+                //   data.quantity = this.form.portion;
+                // }
+              } else {
+                data.measureUnit = data.unit;
+                data.copies = data.portion;
+                // data.quantity = data.quantity * data.copies;
+              }
+            }
             this.loading = true;
 
             api({
-              ...this.form,
+              ...data,
               sampleList: this.sampleList
             })
               .then((res) => {

+ 186 - 0
src/views/sample/sampleRecord/components/addSample1.vue

@@ -0,0 +1,186 @@
+<template>
+  <ele-modal
+    :visible.sync="visible"
+    :title="title"
+    width="80%"
+    append-to-body
+    :maxable="true"
+    @close="cancel"
+  >
+    <el-button type="primary" @click="insertInput">插入文本框</el-button>
+
+    <div
+      v-html="form"
+      contenteditable
+      class="contenteditable"
+      :ref="'valueChange'"
+      id="parentElement"
+    >
+    </div>
+    <template v-slot:footer>
+      <el-button type="primary" @click="save()">确认</el-button>
+
+      <el-button @click="cancel">关闭</el-button>
+    </template>
+    <!-- <ele-modal
+      :visible.sync="editShow"
+      title="配置"
+      width="800px"
+      append-to-body
+      :maxable="true"
+    >
+      <el-form label-width="130px">
+        <el-form-item label="字段标识:" prop="id">
+          <el-input v-model="domObj.id" placeholder=""></el-input>
+        </el-form-item>
+        <el-form-item label="宽度:" prop="width">
+          <el-input
+            v-model="domObj.width"
+            type="number"
+            placeholder=""
+          ></el-input>
+        </el-form-item>
+      </el-form>
+      <template v-slot:footer>
+        <el-button type="primary" @click="domSave()">确认</el-button>
+
+        <el-button @click="editShow = false">关闭</el-button>
+      </template>
+    </ele-modal> -->
+  </ele-modal>
+</template>
+
+<script>
+  export default {
+    data() {
+      return {
+        content: '',
+        visible: false,
+        showTrue: false,
+        form: null,
+        startIndex: -1,
+        valueObj: {},
+        domObj: { id: '', width: '' },
+        domId: '',
+        editShow: false
+      };
+    },
+    computed: {},
+    created() {},
+    methods: {
+      async open(type, row) {
+        this.visible = true;
+        this.$nextTick(() => {
+          document
+            .getElementById('parentElement')
+            .addEventListener('change', (event) => {
+              if (event.target && event.target.className == 'templateInput') {
+                this.valueObj[event.target.id] = event.target.value;
+              }
+            });
+
+          document
+            .getElementById('parentElement')
+            .addEventListener('click', (event) => {
+              if (event.target && event.target.className == 'templateInput') {
+                console.log(event, 'event.target');
+                this.domId = event.target.id;
+                this.editShow = true;
+                this.domObj.width = event.target.offsetWidth;
+                this.domObj.id = event.target.id;
+                // this.valueObj[event.target.id] = event.target.value;
+              }
+            });
+        });
+      },
+      generateRandomString() {
+        let result = '';
+        const characters =
+          'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; // 包含字母和数字
+        const charactersLength = characters.length;
+        for (let i = 0; i < 5; i++) {
+          result += characters.charAt(
+            Math.floor(Math.random() * charactersLength)
+          );
+        }
+        return result;
+      },
+
+      addHtml() {
+        this.insertInput();
+        this.form = this.$refs['valueChange'].innerHTML;
+        if (Object.keys(this.valueObj).length) {
+          for (let key in this.valueObj) {
+            this.$nextTick(() => {
+              let dom = document.getElementById(key);
+              dom.value = this.valueObj[key];
+            });
+          }
+        }
+      },
+      insertInput() {
+
+        const selection = window.getSelection();
+
+        if (selection.rangeCount > 0) {
+                const range = selection.getRangeAt(0)
+                console.log(range.commonAncestorContainer.id,'range')
+                return
+
+
+          // return
+          range.setStart(selection.anchorNode, selection.anchorOffset);
+          range.setEnd(selection.focusNode, selection.focusOffset);
+          range.deleteContents(); // 删除选中的内容(如果需要)
+          range.insertNode(this.getInput()); // 插入input元素
+          // 可以设置光标位置在input之后
+          range.selectNodeContents(this.getInput());
+          range.collapse(false); // 光标放在input之后
+          selection.removeAllRanges();
+          selection.addRange(range);
+        }
+      },
+      getInput() {
+        let id = this.generateRandomString();
+        const inputElement = document.createElement('input');
+        inputElement.setAttribute('type', 'text');
+        inputElement.setAttribute('class', 'templateInput');
+        inputElement.setAttribute('id', id);
+        return inputElement;
+      },
+
+      domSave() {
+        let dom = document.getElementById(this.domId);
+        dom.style.width = this.domObj.width + 'px';
+        delete this.valueObj[dom.id];
+        this.valueObj[this.domObj.id] = dom.value;
+        dom.id = this.domObj.id;
+        console.log(this.valueObj, 'this.valueObj');
+      },
+      save() {
+        let inpus = document.querySelectorAll('.templateInput');
+        inpus.forEach((element) => {
+          this.valueObj[element.id] = element.value;
+        });
+      },
+      cancel() {
+        this.visible = false;
+      }
+    }
+  };
+</script>
+<style lang="scss" scoped>
+  :deep(.templateInput) {
+    width: 80px;
+    border: solid 1px #bfbfbf;
+    padding: 1px;
+    margin: 1px;
+    margin-left: 3px;
+  }
+  .contenteditable {
+    padding: 5px;
+    width: 100%;
+    min-height: 20px;
+    border: solid 1px #b3b0b0;
+  }
+</style>

+ 4 - 15
src/views/sample/sampleRecord/index.vue

@@ -43,18 +43,7 @@
             @click="approvalSubmit(row)"
             >提交</el-link
           >
-          <!-- <el-popconfirm
-            class="ele-action"
-            title="确定要删除此条数据吗?"
-            @confirm="deleteRow(row)"
-            v-if="[0, 3].includes(row.approvalStatus)&&$hasPermission('qms:samplingrecord:update')"
-          >
-            <template v-slot:reference>
-              <el-link type="danger" :underline="false" icon="el-icon-delete">
-                删除
-              </el-link>
-            </template>
-          </el-popconfirm> -->
+       
         </template>
       </ele-pro-table>
     </el-card>
@@ -206,7 +195,7 @@
             showOverflowTooltip: true
           },
           {
-            prop: 'pleaseUnit',
+            prop: 'measureUnit',
             label: '单位',
             align: 'center',
             minWidth: 110,
@@ -233,14 +222,14 @@
             showOverflowTooltip: true
           },
           {
-            prop: 'quantity',
+            prop: 'sampleQuantity',
             label: '取样数量',
             align: 'center',
             minWidth: 110,
             showOverflowTooltip: true
           },
           {
-            prop: 'unit',
+            prop: 'measureUnit',
             label: '单位',
             align: 'center',
             minWidth: 110,

+ 1 - 1
vue.config.js

@@ -38,7 +38,7 @@ module.exports = {
         // target: 'http://192.168.1.30:18086',
         // target: 'http://192.168.1.251:18186',
         // target: 'http://124.71.68.31:50001',
-        target: 'http://192.168.1.251:18086',
+        target: 'http://192.168.1.3:18086',
         // target: 'http://192.168.1.3:18086', // 付丽
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {