wsx 1 tahun lalu
induk
melakukan
1cee559203

+ 19 - 0
src/api/inspectionPlan/index.js

@@ -184,3 +184,22 @@ export async function getProductSteup(id) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// 关闭
+export async function closePlan(data) {
+  const res = await request.post(`/qms/quality_plan/close`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 撤回
+export async function retractPlan(data) {
+  const res = await request.post(`/qms/quality_plan/retract`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+

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

@@ -84,3 +84,12 @@ export async function getQualityTemplateByIds(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// 方案启用
+export async function updateStatus(data) {
+  const res = await request.put(`/qms/qualitytemplate/updateStatus`, data);
+  if (res.data.code == 0) {
+    return res.data.message;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 10 - 0
src/api/inspectionWork/index.js

@@ -122,4 +122,14 @@ export async function qualityWorkOrderCertificate(params) {
   if (res.data.code == 0) {
     return res.data.data;
   }
+}
+
+
+// 关闭
+export async function closeWork(data) {
+  const res = await request.post(`/qms/quality_work_order/close`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
 }

+ 31 - 8
src/api/unacceptedProduct/index.js

@@ -28,21 +28,25 @@ export async function getDetail(data) {
 }
 //不合格品新建/修改
 export async function unqualifiedProductsAdd(data) {
-  const res = await request.post(
-    '/qms/unqualifiedproducts/save' + (data.id ? 'update' : 'add'),
-    data
-  );
+  const res = await request.post(`/qms/unqualifiedproducts/save`, data);
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+//修改
+export async function updateData(data) {
+  const res = await request.put('/qms/unqualifiedproducts/update', data);
+  if (res.data.code == 0) {
+    return res.data.message;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
 //不合格品处置
 export async function dispose(data) {
-  const res = await request.post(
-    '/qms/unqualifiedproducts/dispose',
-    data
-  );
+  const res = await request.post('/qms/unqualifiedproducts/dispose', data);
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -140,3 +144,22 @@ export async function deleteScrapProducts(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// 详情页面
+
+export async function getById(id) {
+  const res = await request.get(`/qms/unqualifiedproducts/getById/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 不良品处置
+export async function disposeApi(data) {
+  const res = await request.post('/qms/unqualifiedproducts/dispose', data);
+  if (res.data.code == 0) {
+    return res.data.message;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 2 - 2
src/components/common/seekPage.vue

@@ -20,7 +20,7 @@
             <div v-if="item.type == 'select'">
               <el-select
                 clearable
-                :v-model="defaultWhere[item.value]"
+                v-model="defaultWhere[item.value]"
                 :placeholder="item.placeholder || '请输入内容'"
                 :multiple="item.multiple ? item.multiple : false"
                 :filterable="item.filterable ? item.filterable : true"
@@ -51,7 +51,7 @@
         </el-form-item>
       </el-form-item>
 
-      <el-form-item v-if="seekList.length > 3">
+      <el-form-item v-show="seekList.length > 3">
         <el-dropdown
           ref="dropdownref"
           trigger="click"

+ 6 - 2
src/enum/dict.js

@@ -14,7 +14,9 @@ export default {
   质检计划类型: 'inspection_plan_type',
   工艺参数单位: 'parameter_code',
   计量单位: 'measuring_uint',
-  检验方案: 'inspection_scheme'
+  检验方案: 'inspection_scheme',
+  处置状态:'dispose_status',
+  质检计划状态:'inspection_plan_status',
 };
 
 export const numberList = [
@@ -25,5 +27,7 @@ export const numberList = [
   'quality_testing_code',
   'quality_method_code',
   'inspection_type',
-  'inspection_plan_type'
+  'inspection_plan_type',
+  'dispose_status',
+  'inspection_plan_status'
 ];

+ 1 - 1
src/mixins/dictMixins.js

@@ -8,7 +8,7 @@ export default {
     };
   },
   computed: {
-    ...mapGetters(['getDictValue', 'dict', 'getDict'])
+    ...mapGetters(['getDictValue', 'dict', 'getDict','getDictName','getDictList'])
   },
   methods: {
     ...mapActions('dict', ['requestDict'])

+ 14 - 1
src/store/getters.js

@@ -18,5 +18,18 @@ export default {
     });
 
     return obj && obj.dictValue;
-  }
+  },
+  getDictName: (state) => (enumName, dictCode) => {
+    const arr = state.dict[dictEnum[enumName]] || [];
+    return arr.find((item) => item.dictCode === dictCode)?.dictValue || '';
+  },
+  // getDictList: (state) => (enumName) => {
+  //   if (!state.dict[dictEnum[enumName]].length) return [];
+  //   return state.dict[dictEnum[enumName]].map((item) => {
+  //     return {
+  //       value: item.dictCode,
+  //       label: item.dictValue
+  //     };
+  //   });
+  // }
 };

+ 43 - 5
src/views/inspectionPlan/index.vue

@@ -55,23 +55,46 @@
             type="primary"
             :underline="false"
             @click="openEdit('edit', row)"
-            v-if="row.status == 0"
+            v-if="row.status == 0 || row.status == 2"
           >
             修改
           </el-link>
           <el-link
             type="primary"
             :underline="false"
-            v-if="row.status == 0"
+            v-if="row.status == 0 || row.status == 2"
             @click="openEdit('issued', row)"
           >
             下发
           </el-link>
+
+          <el-popconfirm
+            class="ele-action"
+            title="确定要撤回吗?"
+            @confirm="retract(row)"
+            v-if="row.status == 1"
+          >
+            <template v-slot:reference>
+              <el-link type="warning" :underline="false"> 撤回 </el-link>
+            </template>
+          </el-popconfirm>
+
+          <el-popconfirm
+            class="ele-action"
+            title="确定要关闭吗?"
+            @confirm="close(row)"
+            v-if="row.status != 3 "
+          >
+            <template v-slot:reference>
+              <el-link type="warning" :underline="false"> 关闭 </el-link>
+            </template>
+          </el-popconfirm>
+
           <el-popconfirm
             class="ele-action"
             title="确定要删除吗?"
             @confirm="remove(row)"
-            v-if="row.status == 0"
+            v-if="row.status == 0 || row.status == 2 "
           >
             <template v-slot:reference>
               <el-link type="danger" :underline="false" icon="el-icon-delete">
@@ -90,7 +113,12 @@
   import search from './components/search.vue';
   // import edit from './components/edit.vue';
   import edit from './components/new-edit.vue';
-  import { getList, removeItem } from '@/api/inspectionPlan';
+  import {
+    getList,
+    removeItem,
+    closePlan,
+    retractPlan
+  } from '@/api/inspectionPlan';
   import dictMixins from '@/mixins/dictMixins';
   import { getFile } from '@/api/system/file';
   import { getByCode } from '@/api/system/dictionary-data';
@@ -256,7 +284,7 @@
             align: 'center',
             showOverflowTooltip: true,
             formatter: (row, column, cellValue) => {
-              return cellValue == 1 ? '已下发' : '未下发';
+              return this.getDictName('质检计划状态', cellValue);
             }
           },
 
@@ -335,6 +363,7 @@
     created() {
       this.requestDict('质检计划类型');
       this.requestDict('取样类型');
+      this.requestDict('质检计划状态');
       this.getTnspectionPlanType();
       this.getQualityMethodCode();
     },
@@ -375,6 +404,15 @@
           })
           .catch((e) => {});
       },
+      async retract(row) {
+        await retractPlan(row);
+        this.reload();
+      },
+      async close(row) {
+        console.log(row);
+        await closePlan(row);
+        this.reload();
+      },
       reload(where) {
         this.$refs.tableRef.reload({ page: 1, where });
       },

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

@@ -1,12 +1,18 @@
 <template>
   <div class="ele-body">
     <el-card shadow="never">
-      <search ref="search" @search="search"></search>
+      <seek-page
+        :seekList="seekList"
+        v-if="typeList.length"
+        @search="search"
+        ref="search"
+      ></seek-page>
+      <!-- <search ref="search" @search="search"></search> -->
       <ele-pro-table
         ref="table"
         :columns="columns"
         :datasource="datasource"
-        height="calc(100vh - 605px)"
+        height="calc(100vh - 400px)"
         tool-class="ele-toolbar-form"
         cache-key="inspectionClassify"
         row-key="qualityLevelId"
@@ -97,17 +103,57 @@
 
 <script>
   import AddOrUpdate from './AddorUpdate';
-  import search from './components/search.vue';
+  // import search from './components/search.vue';
+  import dictMixins from '@/mixins/dictMixins';
   import {
     getList,
     removeItem,
     update,
-    copyData
+    copyData,
+    updateStatus
   } from '@/api/inspectionTemplate';
   export default {
+    mixins: [dictMixins],
     components: {
-      AddOrUpdate,
-      search
+      AddOrUpdate
+      // search
+    },
+    computed: {
+      seekList() {
+        console.log(this.typeList);
+        
+        return [
+          {
+            label: '名称:',
+            value: 'qualitySchemeTemplateName',
+            type: 'input',
+            placeholder: ''
+          },
+          {
+            label: '编码:',
+            value: 'qualitySchemeTemplateCode',
+            type: 'input',
+            placeholder: ''
+          },
+          {
+            label: '类型:',
+            value: 'type',
+            type: 'select',
+            placeholder: '',
+            planList: this.typeList
+          },
+          {
+            label: '状态:',
+            value: 'status',
+            type: 'select',
+            planList: [
+              { value: 0, label: '停用' },
+              { value: 1, label: '启用' }
+            ],
+            placeholder: ''
+          }
+        ];
+      }
     },
     data() {
       return {
@@ -132,6 +178,16 @@
             showOverflowTooltip: true,
             fixed: 'left'
           },
+          {
+            prop: 'type',
+            label: '类型',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110,
+            formatter: (row, column, cellValue) => {
+              return this.getDictName('质检类型', cellValue);
+            }
+          },
           {
             prop: 'qualitySchemeTemplateCode',
             label: '质检方案编码',
@@ -167,9 +223,20 @@
             slot: 'action',
             fixed: 'right'
           }
-        ]
+        ],
+        typeList: []
       };
     },
+    created() {
+      this.requestDict('质检类型').then((res) => {
+        this.typeList = res.map((item) => {
+          return {
+            value: item.dictCode,
+            label: item.dictValue
+          };
+        });
+      });
+    },
     methods: {
       // 获取数据列表
       datasource({ page, where, limit }) {
@@ -226,7 +293,7 @@
         let status = row.status === 1 ? 0 : 1;
         dataForm['status'] = status;
         dataForm['id'] = row.id;
-        update(dataForm)
+        updateStatus(dataForm)
           .then((res) => {
             this.loading = false;
             this.$message.success('操作成功!');

+ 20 - 3
src/views/inspectionWork/index.vue

@@ -2,7 +2,7 @@
   <div class="ele-body">
     <el-card shadow="never">
       <!-- <search ref="search" @search="search"></search> -->
-      <seek-page :seekList="seekList" @search="search"></seek-page>
+      <seek-page :seekList="seekList" @search="search" ref="search"></seek-page>
 
       <ele-pro-table
         ref="table"
@@ -82,6 +82,17 @@
             :businessId="row.id"
             businessCode="qmsqualityinspectionprint"
           ></jimureportBrowse>
+
+          <el-popconfirm
+            class="ele-action"
+            title="确定要关闭吗?"
+            @confirm="close(row)"
+            v-if="row.status == 0 && row.qualityType == 2"
+          >
+            <template v-slot:reference>
+              <el-link type="warning" :underline="false"> 关闭 </el-link>
+            </template>
+          </el-popconfirm>
           <!-- <el-link type="primary" :underline="false">
             质检报告
           </el-link>-->
@@ -124,7 +135,8 @@
   import {
     getList,
     removeItem,
-    updateCertificateNumber
+    updateCertificateNumber,
+    closeWork
   } from '@/api/inspectionWork';
   import dictMixins from '@/mixins/dictMixins';
   import { getFile } from '@/api/system/file';
@@ -302,7 +314,7 @@
             align: 'center',
             width: 80,
             formatter: (row, column, cellValue) => {
-              return cellValue == 0 ? '未报工' : cellValue == 1 ? '已报工' : '';
+              return cellValue == 0 ? '未报工' : cellValue == 1 ? '已报工' : '已关闭';
             },
             fixed: 'right'
           },
@@ -468,6 +480,11 @@
       closeModel() {
         this.addOpen = false;
       },
+      async close(row) {
+        console.log(row);
+        await closeWork(row);
+        this.done();
+      },
       // handleClose() {
       //   this.certificateVisible = false;
       // },

+ 102 - 29
src/views/sample/samplemanagement/detailList.vue

@@ -11,9 +11,12 @@
         :pageSizes="[20, 30, 40, 50, 100]"
         :height="500"
         :key="key"
+        @selection-change="handleSelectionChange"
+        @update:current="kk"
+        @current-change="kk"
       >
         <!-- 操作列 -->
-        <template v-slot:toolbar>
+        <template v-slot:toolbar v-if="showBtn">
           <el-button
             type="primary"
             slot="reference"
@@ -35,6 +38,7 @@
             </template>
           </el-popconfirm>
         </template>
+
         <template v-slot:action="{ row }">
           <el-popconfirm
             class="ele-action"
@@ -226,6 +230,7 @@
     mixins: [dictMixins],
     data() {
       return {
+        dataList: [],
         key: '',
         response: {
           dataName: 'sampleVOList'
@@ -245,6 +250,7 @@
         sampleType: '',
         loading: false,
         selection: [],
+        allSelectedData: [],
         disposeType: '',
         dialogVisible: false,
         current: {},
@@ -260,88 +266,121 @@
         ],
         rules: {
           disposeWarehouseId: [
-            { required: true, message: '请选择仓库', trigger: 'blur' }
+            { required: true, message: '请选择仓库', trigger: 'change' }
           ]
         }
       };
     },
     computed: {
+      showBtn() {
+        return !this.$route.query.type;
+      },
       // 表格列配置
       columns() {
-        return [
+        const arr = [
+          {
+            width: 45,
+            type: 'selection',
+            columnKey: 'selection',
+            selectable: (row, index) => {
+              return row.disposalStatus !== 2;
+            },
+            align: 'center'
+          },
+          {
+            type: 'index',
+            columnKey: 'index',
+            align: 'center',
+            label: '序号',
+            width: 55,
+            showOverflowTooltip: true
+          },
           {
             label: '样品编码',
             prop: 'sampleCode',
             width: '150',
-            align: 'center'
+            align: 'center',
+            showOverflowTooltip: true
           },
           {
             label: '物品编码',
             prop: 'categoryCode',
             width: '150',
-            align: 'center'
+            align: 'center',
+            showOverflowTooltip: true
           },
           {
             label: '物品名称',
             prop: 'categoryName',
-            width: '150',
-            align: 'center'
+            width: '180',
+            align: 'center',
+            showOverflowTooltip: true
           },
           {
             label: '规格',
             prop: 'specification',
-            width: '150',
-            align: 'center'
+            width: '120',
+            align: 'center',
+            showOverflowTooltip: true
           },
           {
             label: '牌号',
             prop: 'brandNum',
-            width: '150',
-            align: 'center'
+            width: '120',
+            align: 'center',
+            showOverflowTooltip: true
           },
           {
             prop: 'modelType',
             label: '型号',
             align: 'center',
-            width: '150'
+            width: '120',
+            showOverflowTooltip: true
           },
           {
             prop: 'batchNo',
             label: '批次号',
             align: 'center',
-            width: '150'
+            width: '120',
+            showOverflowTooltip: true
           },
           {
             prop: 'weight',
             label: '重量',
             align: 'center',
-            width: '150'
+            width: '120',
+            showOverflowTooltip: true
           },
           {
             prop: 'weightUnit',
             label: '重量单位',
             align: 'center',
-            width: '150'
+            width: '120',
+            showOverflowTooltip: true
           },
           {
             prop: 'disposeTime',
             label: '处置时间',
             align: 'center',
-            width: '180'
+            width: '180',
+            showOverflowTooltip: true
           },
           {
             prop: 'disposalStatus',
             label: '处置结果',
             align: 'center',
-
+            width: '120',
+            showOverflowTooltip: true,
             formatter: (row, column, cellValue) => {
-              return this.disposalStatustList[cellValue];
+              return this.disposalStatustList[cellValue ? cellValue : 0];
             }
           },
           {
             prop: 'disposeType',
             label: '处置类型',
             align: 'center',
+            width: '120',
+            showOverflowTooltip: true,
             formatter: (row, column, cellValue) => {
               return this.disposeTypeList[0][cellValue];
             }
@@ -350,7 +389,8 @@
             prop: 'qualityResults',
             label: '质检结果',
             align: 'center',
-            width: '180',
+            width: '120',
+            showOverflowTooltip: true,
             formatter: (row, column, cellValue) => {
               return this.qualityResultList[cellValue];
             }
@@ -366,6 +406,8 @@
             fixed: 'right'
           }
         ];
+
+        return this.$route.query.type ? arr.slice(0, -1) : arr;
       },
       seekList() {
         return [
@@ -427,23 +469,48 @@
       }
     },
     async created() {
-      // this.getList();
+      this.getList();
       this.warehouseList = await getWarehouseList();
       this.qualityType = this.$route.query.qualityType;
     },
 
     methods: {
+      kk() {
+        console.log('fany');
+      },
+      handleSelectionChange(selection) {
+        console.log('choose');
+        
+        this.selection = selection;
+        // 更新所有选中的数据
+        this.allSelectedData = [
+          ...new Set([...this.allSelectedData, ...selection])
+        ];
+      },
+      handlePageChange() {
+        console.log('fan');
+
+        // 翻页时同步选中状态
+        const currentPageData = this.dataList;
+        const selectedOnCurrentPage = currentPageData.filter((item) =>
+          this.allSelectedData.some(
+            (selectedItem) => selectedItem.id === item.id
+          )
+        );
+        this.$refs.table.setSelectedRows(selectedOnCurrentPage);
+      },
       chooseWarehouse(item) {
         console.log(item);
         this.type6Form.disposeWarehouseId = item.id;
         this.type6Form.disposeWarehouseName = item.name;
       },
-      // getList() {
-      //   getDetail({unqualifiedProductsId:this.$route.query.id}).then((res) => {
-      //     this.datasource = res;
-      //   });
-      // },
+      async getList() {
+        let id = this.$route.query.id;
+        const arr = await getById(id);
+        this.dataList = arr.sampleVOList;
+      },
       // /* 表格数据源 */
+
       async datasource({ page, where, limit }) {
         let id = this.$route.query.id;
         // where.id = this.$route.query.id;
@@ -457,7 +524,8 @@
         this.$nextTick(() => {
           // this.datasource();
           // this.$refs.table.reRenderTable();
-          this.$refs.table.reload({ page: 1, where: where });
+          // this.getList()
+          // this.$refs.table.reload({ page: 1, where: where });
         });
       },
       remove(row) {
@@ -465,6 +533,10 @@
         removeSample(ids).then((res) => {
           this.$message.success('删除' + res);
           this.reload();
+          // 删除后更新 allSelectedData
+          this.allSelectedData = this.allSelectedData.filter(
+            (item) => !ids.includes(item.id)
+          );
         });
       },
       close() {
@@ -473,10 +545,11 @@
       },
       // // 处置
       disposeList(type, row) {
-        this.id = row.id;
         if (type == 1) {
           this.all = true;
+          console.log(this.selection);
         } else {
+          this.id = row.id;
           this.current = row;
           console.log(this.current, 'row');
         }
@@ -508,14 +581,14 @@
         })
           .then((res) => {
             console.log(res);
+            this.$message.success('处置成功!');
+            this.reload();
           })
           .catch((err) => {
             console.log(err);
           });
         this.dialogVisible = false;
         this.current = null;
-        this.$message.success('处置成功!');
-        this.reload();
       },
       async consfirm() {
         if (this.disposeType == 6) {

+ 36 - 75
src/views/sample/samplemanagement/index.vue

@@ -17,10 +17,9 @@
         :columns="columns"
         :datasource="datasource"
         :pageSize="20"
-        :pageSizes="[20, 30, 40, 50, 100]"
       >
         <!-- 表头工具栏 -->
-        <!-- <template v-slot:toolbar> </template> -->
+
         <template v-slot:toolbar>
           <el-button
             size="small"
@@ -33,10 +32,13 @@
           </el-button>
         </template>
 
-        <template v-slot:code="{ row }">
-          <el-link type="primary" :underline="false">
-            {{ row.code }}
-          </el-link>
+        <template v-slot:sampleCode="{ row }">
+          <el-link
+            type="primary"
+            :underline="false"
+            @click="goDetail(row.id, 'detail')"
+            >{{ row.sampleCode }}</el-link
+          >
         </template>
 
         <!-- 操作列 -->
@@ -52,7 +54,8 @@
           <el-link
             type="primary"
             :underline="false"
-            @click="processingMethod('process', row)"
+            @click="goDetail(row.id)"
+            v-if="row.status !== 2"
           >
             处置
           </el-link>
@@ -69,55 +72,23 @@
           </el-popconfirm>
         </template>
       </ele-pro-table>
-      <!-- <processingInfo ref="processingRefs"></processing> -->
     </el-card>
-
-    <el-dialog :visible.sync="dialogVisible" width="30%" @close="close">
-      <!-- <DictSelection
-        dictName="样品处理类型"
-        :filterArr="all ? ['返工返修'] : []"
-        v-model="sampleType"
-      /> -->
-
-      <el-select
-        v-model="sampleType"
-        :key="sampleType"
-        placeholder="请选择"
-        style="width: 100%"
-      >
-        <el-option
-          v-for="item in sampleTypeList"
-          :key="item.value"
-          :label="item.label"
-          :value="item.value"
-        >
-        </el-option>
-      </el-select>
-      <span slot="footer" class="dialog-footer">
-        <el-button @click="dialogVisible = false">取 消 </el-button>
-        <el-button type="primary" @click="consfirm">确 定</el-button>
-      </span>
-    </el-dialog>
-    <!--      <edit ref="edit" ></edit>-->
     <!-- 新增的dialog -->
     <sample ref="sampleRef" @done="reload"></sample>
   </div>
 </template>
 <script>
-  import edit from './components/edit.vue';
   import sample from './components/addOrEditSample.vue';
-  import { getList, removeItem, disposeApi } from '@/api/samplemanagement';
+  import { getList, removeItem } from '@/api/samplemanagement';
   import dictMixins from '@/mixins/dictMixins';
 
   export default {
     mixins: [dictMixins],
     components: {
-      edit,
       sample
     },
     data() {
       return {
-        dialogVisible: false,
         columns: [
           {
             type: 'index',
@@ -224,9 +195,8 @@
             label: '状态',
             align: 'center',
             width: 80,
-            fixed: 'right',
             formatter: (row, column, cellValue) => {
-              return this.statusList[cellValue];
+              return this.getDictName('处置状态', cellValue);
             }
           },
           {
@@ -239,20 +209,11 @@
             fixed: 'right'
           }
         ],
-        activeName: '1',
-        sampleTypeList: [
-          { value: 1, label: '留样' },
-          { value: 2, label: '归批/回用' },
-          { value: 3, label: '报废' },
-          { value: 4, label: '退货' },
-          { value: 5, label: '消耗' }
-        ],
-        id: '',
-        sampleType: ''
+        activeName: '1'
       };
     },
     created() {
-      // this.requestDict('取样类型');
+      this.requestDict('处置状态');
     },
 
     computed: {
@@ -265,21 +226,35 @@
             placeholder: ''
           },
           {
-            label: '样品编码:',
+            label: '来源编码:',
+            value: 'sourceCode',
+            type: 'input',
+            placeholder: ''
+          },
+          {
+            label: '物品编码:',
             value: 'categoryCode',
             type: 'input',
             placeholder: ''
           },
           {
-            label: '样品名称:',
+            label: '物品名称:',
             value: 'categoryName',
             type: 'input',
             placeholder: ''
+          },
+          {
+            label: '状态:',
+            value: 'status',
+            type: 'select',
+            placeholder: '',
+            planList: [
+              { value: 0, label: '待处置' },
+              { value: 1, label: '部分处置' },
+              { value: 2, label: '处置完成' }
+            ]
           }
         ];
-      },
-      statusList() {
-        return { 0: '待处置', 1: '处置中', 2: '处置完成' };
       }
     },
 
@@ -309,16 +284,14 @@
 
         // this.$refs.table.reload({ page: 1, where });
       },
-      processingMethod(type, row) {
+      goDetail(id, type) {
         this.$router.push({
           path: '/sample/samplemanagement/detailList',
           query: {
-            id: row.id
+            id,
+            type
           }
         });
-        // this.dialogVisible = true;
-        // this.id = row.id;
-        // this.$refs.edit.open(type, row)
       },
       handleClick(tab) {
         this.activeName = tab.name;
@@ -335,18 +308,6 @@
             this.reload();
           })
           .catch((e) => {});
-      },
-      close() {
-        this.dialogVisible = false;
-        this.sampleType = '';
-      },
-      async consfirm() {
-        const params = {
-          disposeType: this.sampleType,
-          id: this.id
-        };
-        await disposeApi(params);
-        this.reload();
       }
     }
   };

+ 1 - 1
src/views/unqualifiedProduct/unqualifiedList/components/EquipmentDialog.vue

@@ -75,7 +75,7 @@
     props: {
       selectList: Array,
       type: {
-        default: 1 //1多选 2单选
+        default: 2 //1多选 2单选
       },
       treeIds: {
         default: () => {

+ 442 - 288
src/views/unqualifiedProduct/unqualifiedList/components/create.vue

@@ -1,33 +1,68 @@
 <template>
-  <ele-modal :visible.sync="visible" :title="title" width="80vw" append-to-body @close="cancel" :maxable="true">
-    <el-form ref="form" :model="form" :rules="rules" label-width="90px" class="create-form">
+  <ele-modal
+    :visible.sync="visible"
+    :title="title"
+    width="80vw"
+    append-to-body
+    @close="cancel"
+    :maxable="true"
+  >
+    <el-form
+      ref="form"
+      :model="form"
+      :rules="rules"
+      label-width="90px"
+      class="create-form"
+    >
       <el-row :gutter="15">
         <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
           <el-form-item label="编码:">
-            <el-input :maxlength="20" v-model="form.code" disabled />
+            <el-input
+              :maxlength="20"
+              v-model="form.unqualifiedProductsCode"
+              disabled
+            />
           </el-form-item>
         </el-col>
         <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
           <el-form-item label="来源编码:">
-            <el-input :maxlength="20" v-model="form.unqualifiedSourceCode" disabled />
+            <el-input :maxlength="20" v-model="form.sourceCode" disabled />
           </el-form-item>
         </el-col>
         <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
           <el-form-item label="数量:">
-            <el-input :maxlength="20" v-model="form.unqualifiedQuantity" disabled />
+            <el-input
+              :maxlength="20"
+              v-model="form.unqualifiedQuantity"
+              disabled
+            />
           </el-form-item>
         </el-col>
 
         <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
           <el-form-item label="工艺路线:">
-            <el-input @click.native="openVersion" clearable v-model="form.produceRoutingName" />
+            <el-input
+              @click.native="openVersion"
+              clearable
+              v-model="form.produceRoutingName"
+            />
           </el-form-item>
         </el-col>
         <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
           <el-form-item label="工序:">
-            <el-select style="width: 100%" v-model="form.produceTaskId" placeholder="请选择" clearable
-              @change="produceTaskChange">
-              <el-option v-for="item in produceTaskList" :key="item.id" :label="item.name" :value="item.id">
+            <el-select
+              style="width: 100%"
+              v-model="form.taskId"
+              placeholder="请选择"
+              clearable
+              @change="produceTaskChange"
+            >
+              <el-option
+                v-for="item in produceTaskList"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              >
               </el-option>
             </el-select>
           </el-form-item>
@@ -38,6 +73,7 @@
           </el-form-item>
         </el-col>
       </el-row>
+      <!--  -->
       <el-table :data="form.poList" border height="40vh">
         <el-table-column label="序号" align="center" width="60">
           <template slot-scope="scope">
@@ -49,12 +85,20 @@
         </el-table-column>
         <el-table-column label="产品编码" align="center" prop="categoryCode">
         </el-table-column>
-        <el-table-column label="牌号" align="center" prop="brandNo">
+        <el-table-column label="牌号" align="center" prop="brandNum">
         </el-table-column>
         <el-table-column label="刻码" align="center" prop="engrave">
           <template slot-scope="scope">
-            <el-form-item label-width="0px" :prop="'poList.' + scope.$index + '.engrave'">
-              <el-input v-model="scope.row.engrave" size="small" style="width: 100%" placeholder="输入刻码"></el-input>
+            <el-form-item
+              label-width="0px"
+              :prop="'poList.' + scope.$index + '.engrave'"
+            >
+              <el-input
+                v-model="scope.row.engrave"
+                size="small"
+                style="width: 100%"
+                placeholder="输入刻码"
+              ></el-input>
             </el-form-item>
           </template>
         </el-table-column>
@@ -65,41 +109,67 @@
 
         <el-table-column label="数量" align="center" prop="unqualifiedQuantity">
           <template slot-scope="scope">
-            <el-form-item label-width="0px" :prop="'poList.' + scope.$index + '.unqualifiedQuantity'" :rules="[
-              {
-                required: true,
-                message: '请输入数量',
-                trigger: 'blur'
-              },
-              { validator: validatePass, trigger: 'change' }
-            ]">
-              <el-input :disabled="!!scope.row.id" v-model.number="scope.row.unqualifiedQuantity" size="small"
-                oninput="value=value.replace(/[^\d]/g,'')" style="width: 100%" placeholder="输入数量" @input="
+            <el-form-item
+              label-width="0px"
+              :prop="'poList.' + scope.$index + '.unqualifiedQuantity'"
+              :rules="[
+                {
+                  required: true,
+                  message: '请输入数量',
+                  trigger: 'blur'
+                },
+                { validator: validatePass, trigger: 'change' }
+              ]"
+            >
+              <el-input
+                v-model.number="scope.row.unqualifiedQuantity"
+                size="small"
+                oninput="value=value.replace(/[^\d]/g,'')"
+                style="width: 100%"
+                placeholder="输入数量"
+              ></el-input>
+              <!--   @input="
                   inputNumber(scope.$index, scope.row.unqualifiedQuantity)
-                  "></el-input>
+                " -->
             </el-form-item>
           </template>
         </el-table-column>
-        <el-table-column label="工艺路线" align="center" prop="produceRoutingName">
+        <el-table-column
+          label="工艺路线"
+          align="center"
+          prop="produceRoutingName"
+        >
         </el-table-column>
         <el-table-column label="工序" align="center" prop="produceTaskName">
         </el-table-column>
 
         <el-table-column label="原因" align="center" prop="unqualifiedReason">
           <template slot-scope="scope">
-            <el-form-item label-width="0px" :prop="'poList.' + scope.$index + '.unqualifiedReason'" :rules="{
-              required: true,
-              message: '请输入原因',
-              trigger: 'blur'
-            }">
-              <el-input v-model="scope.row.unqualifiedReason" size="small" style="width: 100%"
-                placeholder="输入原因"></el-input>
+            <el-form-item
+              label-width="0px"
+              :prop="'poList.' + scope.$index + '.unqualifiedReason'"
+              :rules="{
+                required: true,
+                message: '请输入原因',
+                trigger: 'blur'
+              }"
+            >
+              <el-input
+                v-model="scope.row.unqualifiedReason"
+                size="small"
+                style="width: 100%"
+                placeholder="输入原因"
+              ></el-input>
             </el-form-item>
           </template>
         </el-table-column>
         <el-table-column label="操作" align="center" width="70">
           <template slot-scope="scope">
-            <el-link type="danger" :underline="false" @click="handleDeleteItem(scope.$index, scope.row.id)">
+            <el-link
+              type="danger"
+              :underline="false"
+              @click="handleDeleteItem(scope.$index, scope.row.id)"
+            >
               删除
             </el-link>
           </template>
@@ -119,289 +189,373 @@
     <!-- 选择产品 -->
     <EquipmentDialog ref="equipmentRefs" @choose="confirmChoose">
     </EquipmentDialog>
-    <ProductionVersion ref="versionRefs" @changeProduct="changeProduct"></ProductionVersion>
+    <ProductionVersion
+      ref="versionRefs"
+      @changeProduct="changeProduct"
+    ></ProductionVersion>
   </ele-modal>
 </template>
 
 <script>
-import EquipmentDialog from '../components/EquipmentDialog.vue';
-import ProductionVersion from '@/components/ProductionVersion/ProductionVersion.vue';
-import { getProduceTaskList } from '@/api/aps';
-import {
-  unqualifiedProductsAdd,
-  getDetail,
-  deleteUnacceptedProductDetail
-} from '@/api/unacceptedProduct/index';
-export default {
-  components: {
-    EquipmentDialog,
-    ProductionVersion
-  },
-  data() {
-    return {
-      validatePass: (rule, value, callback) => {
-        if (!value) {
-          callback(new Error('数量不能为0'));
+  import EquipmentDialog from '../components/EquipmentDialog.vue';
+  import ProductionVersion from '@/components/ProductionVersion/ProductionVersion.vue';
+  import { getProduceTaskList } from '@/api/aps';
+  import {
+    unqualifiedProductsAdd,
+    updateData,
+    getDetail,
+    deleteUnacceptedProductDetail,
+    getById
+  } from '@/api/unacceptedProduct/index';
+  export default {
+    components: {
+      EquipmentDialog,
+      ProductionVersion
+    },
+    data() {
+      return {
+        validatePass: (rule, value, callback) => {
+          if (!value) {
+            callback(new Error('数量不能为0'));
+          } else {
+            callback();
+          }
+        },
+        id:'',
+        visible: false,
+        loading: false,
+        produceTaskList: [],
+        form: {
+          poList: [],
+          unqualifiedProductsCode: '',
+          sourceCode: '',
+          batchNo: '',
+          brandNum: '',
+          categoryCode: '',
+          categoryId: '',
+          categoryName: '',
+          specification: '',
+          modelType: '',
+          produceRoutingId: '',
+          produceRoutingName: '',
+          taskId: '',
+          taskName: '',
+          unqualifiedQuantity: '',
+          measureQuantity: '',
+          measureUnit: '',
+          weight: '',
+          weightUnit: ''
+        },
+        // 表单验证规则
+        rules: {
+          deliveryTime: [
+            { required: true, message: '请选择交付日期', trigger: 'change' }
+          ]
+        },
+
+        title: '创建'
+      };
+    },
+
+    computed: {
+      // 是否开启响应式布局
+      styleResponsive() {
+        return this.$store.state.theme.styleResponsive;
+      }
+    },
+    created() {},
+    methods: {
+      open(row, type) {
+        this.visible = true;
+        if (type == 'add') {
+          this.title = '创建';
+          this.form = row;
+          this.getProduceTaskList();
+          return;
+        }
+        console.log(row, 'row');
+        if (row) {
+          this.title = '修改';
+          this.getDetail(row);
         } else {
-          callback();
+          this.title = '创建';
         }
       },
-      visible: false,
-      loading: false,
-      produceTaskList: [],
-      form: {
-        poList: [],
-        code: '',
-        unqualifiedSourceCode: '',
-        unqualifiedSourceId: '',
+      //选择工艺路线
+      openVersion() {
+        this.$refs.versionRefs.open();
+      },
+      //工艺路线回调
+      changeProduct(data) {
+        this.form.produceRoutingId = data.id;
+        this.form.produceRoutingName = data.name;
+        this.form.taskId = '';
+        this.form.taskName = '';
+        if (this.title == '修改') {
+          this.form.poList.forEach((item) => {
+            item.produceRoutingId = data.id;
+            item.produceRoutingName = data.name;
+            item.produceTaskId = '';
+            item.produceTaskName = '';
+          });
+        }
 
-        unqualifiedQuantity: '',
-        type: '',
-        status: null,
-        reviewerId: null,
-        reviewerName: '',
-        createUserName: '',
-        brandNo: '',
-        produceRoutingId: '',
-        produceRoutingName: '',
-        produceTaskId: '',
-        produceTaskName: '',
-        batchNo: ''
+        this.getProduceTaskList();
+      },
+      async getProduceTaskList() {
+        const res = await getProduceTaskList({
+          isDetail: true,
+          pageNum: 1,
+          routingId: this.form.produceRoutingId,
+          size: -1
+        });
+        this.produceTaskList = res.list;
       },
-      // 表单验证规则
-      rules: {
-        deliveryTime: [
-          { required: true, message: '请选择交付日期', trigger: 'change' }
-        ]
+      produceTaskChange() {
+        if (!this.form.taskId) {
+          return;
+        }
+        this.form.taskName = this.produceTaskList.find(
+          (item) => item.id == this.form.taskId
+        ).name;
+        this.form.poList.forEach((item, index) => {
+          this.$set(
+            this.form.poList[index],
+            'produceRoutingId',
+            this.form.produceRoutingId
+          );
+          this.$set(
+            this.form.poList[index],
+            'produceRoutingName',
+            this.form.produceRoutingName
+          );
+          this.$set(this.form.poList[index], 'produceTaskId', this.form.taskId);
+          this.$set(
+            this.form.poList[index],
+            'produceTaskName',
+            this.form.taskName
+          );
+        });
       },
 
-      title: '创建'
-    };
-  },
+      async getDetail(row) {
+        console.log(row.id, 'row.id');
+        // this.form = row;
 
-  computed: {
-    // 是否开启响应式布局
-    styleResponsive() {
-      return this.$store.state.theme.styleResponsive;
-    }
-  },
-  created() { },
-  methods: {
-    open(row, type) {
-      this.visible = true;
-      if (type == 'add') {
-        this.title = '创建';
-        this.form = row;
-        this.getProduceTaskList();
-        return;
-      }
-      console.log(row, 'row');
-      if (row) {
-        this.title = '修改';
-        this.getDetail(row);
-      } else {
-        this.title = '创建';
-      }
-    },
-    //选择工艺路线
-    openVersion() {
-      this.$refs.versionRefs.open();
-    },
-    //工艺路线回调
-    changeProduct(data) {
-      this.form.produceRoutingId = data.id;
-      this.form.produceRoutingName = data.name;
-      this.form.produceTaskId = '';
-      this.form.produceTaskName = '';
-      this.getProduceTaskList();
-    },
-    async getProduceTaskList() {
-      const res = await getProduceTaskList({
-        isDetail: true,
-        pageNum: 1,
-        routingId: this.form.produceRoutingId,
-        size: -1
-      });
-      this.produceTaskList = res.list;
-    },
-    produceTaskChange() {
-      if (!this.form.produceTaskId) {
-        return;
-      }
-      this.form.produceTaskName = this.produceTaskList.find(
-        (item) => item.id == this.form.produceTaskId
-      ).name;
-      this.form.poList.forEach((item, index) => {
-        this.$set(
-          this.form.poList[index],
-          'produceRoutingId',
-          this.form.produceRoutingId
-        );
-        this.$set(
-          this.form.poList[index],
-          'produceRoutingName',
-          this.form.produceRoutingName
-        );
-        this.$set(
-          this.form.poList[index],
-          'produceTaskId',
-          this.form.produceTaskId
-        );
-        this.$set(
-          this.form.poList[index],
-          'produceTaskName',
-          this.form.produceTaskName
-        );
-      });
-    },
+        const data = await getById(row.id);
+        this.form.id=row.id
+        this.form.unqualifiedProductsCode = data.unqualifiedProductsCode;
+        this.form.sourceCode = data.sourceCode;
+        this.form.batchNo = data.batchNo;
+        this.form.brandNum = data.brandNum;
+        this.form.categoryCode = data.categoryCode;
+        this.form.categoryId = data.categoryId;
+        this.form.categoryName = data.categoryName;
+        this.form.specification = data.specification;
+        this.form.modelType = data.modelType;
+        this.form.produceRoutingId = data.produceRoutingId;
+        this.form.produceRoutingName = data.produceRoutingName;
+        this.form.taskId = data.taskId;
+        this.form.taskName = data.taskName;
+        this.form.unqualifiedQuantity = data.unqualifiedQuantity;
 
-    getDetail(row) {
-      console.log(row.id, 'row.id')
-      this.form = row;
-      getDetail(row.id).then((res) => {
-        this.getProduceTaskList();
-        this.form.poList = res;
-      });
-    },
-    cancel() {
-      this.form = {
-        poList: [],
-        code: '',
-        workOrderId: '',
-        productCode: '',
-        productName: '',
-        specifications: '',
-        unqualifiedQuantity: '',
-        type: '',
-        status: null,
-        reviewerId: null,
-        reviewerName: '',
-        createUserName: '',
-        brandNo: '',
-        produceRoutingId: '',
-        produceRoutingName: '',
-        produceTaskId: '',
-        produceTaskName: '',
-        batchNo: ''
-      };
-      this.$refs.form.clearValidate();
-      this.visible = false;
-    },
-    // 删除产品
-    handleDeleteItem(index, id) {
-      this.$confirm('确认删除吗?', '提示', {
-        confirmButtonText: '确定',
-        cancleButtonText: '取消',
-        type: 'warning'
-      })
-        .then((res) => {
-          if (id) {
-            deleteUnacceptedProductDetail([id]).then((res) => {
-              this.form.poList.splice(index, 1);
-            });
-          } else {
-            this.form.poList.splice(index, 1);
-          }
+        this.form.measureQuantity = data.measureQuantity;
+        this.form.measureUnit = data.measureUnit;
+        this.form.weight = data.weight;
+        this.form.weightUnit = data.weightUnit;
+
+        this.form.poList = data.poList;
+
+        // getDetail(row.id).then((res) => {
+        //   // this.getProduceTaskList();
+        //   // this.form.poList = res;
+        // });
+      },
+      cancel() {
+        this.form = {
+          poList: [],
+          unqualifiedProductsCode: '',
+          sourceCode: '',
+          batchNo: '',
+          brandNum: '',
+          categoryCode: '',
+          categoryId: '',
+          categoryName: '',
+          weight: '',
+          specification: '',
+          modelType: '',
+          produceRoutingId: '',
+          produceRoutingName: '',
+          taskId: '',
+          taskName: '',
+          measureQuantity: '',
+          measureUnit: '',
+          weight: '',
+          weightUnit: ''
+        };
+        this.$refs.form.clearValidate();
+        this.visible = false;
+      },
+      // 删除产品
+      handleDeleteItem(index, id) {
+        this.$confirm('确认删除吗?', '提示', {
+          confirmButtonText: '确定',
+          cancleButtonText: '取消',
+          type: 'warning'
         })
-        .catch(() => { });
+          .then((res) => {
+            if (id) {
+              deleteUnacceptedProductDetail([id]).then((res) => {
+                this.form.poList.splice(index, 1);
+              });
+            } else {
+              this.form.poList.splice(index, 1);
+            }
+          })
+          .catch(() => {});
 
-      this.inputNumber();
-    },
-    addEquipment() {
-      this.$refs.equipmentRefs.open();
-    },
-    /* 保存编辑 */
-    save() {
-      console.log(this.form.poList);
-      this.$refs.form.validate((valid) => {
-        if (!valid) {
-          return false;
-        }
-        if (!this.form.poList.length) {
-          return this.$message.warning('产品列表不能为空!');
-        }
-        for (let key in this.form) {
-          if (key.includes('create')) {
-            this.form[key] = '';
+        // this.inputNumber();
+      },
+      addEquipment() {
+        this.$refs.equipmentRefs.open();
+      },
+      /* 保存编辑 */
+      save() {
+        console.log(this.form.poList);
+        this.$refs.form.validate((valid) => {
+          if (!valid) {
+            return false;
           }
-        }
-        this.form.poList.forEach((item) => {
-          for (let key in item) {
+          if (!this.form.poList.length) {
+            return this.$message.warning('产品列表不能为空!');
+          }
+          for (let key in this.form) {
             if (key.includes('create')) {
-              item[key] = '';
+              this.form[key] = '';
             }
           }
-        });
-        this.loading = true;
-        unqualifiedProductsAdd(this.form)
-          .then((res) => {
-            this.loading = false;
-            this.$message.success('成功');
-            this.cancel();
-            this.$emit('refresh');
-          })
-          .catch((e) => {
-            this.loading = false;
+          this.form.poList.forEach((item) => {
+            for (let key in item) {
+              if (key.includes('create')) {
+                item[key] = '';
+              }
+            }
           });
-      });
-    },
+          this.loading = true;
 
-    // 确定选择
-    confirmChoose(data) {
-      let list = [];
-      list = data.map((item, index) => {
-        if (item.productCode) {
-          return item;
-        } else {
-          return {
-            productCode: item.code,
-            productName: item.name,
-            // productUnitWeight: item.netWeight,
-            // weightUnit: item.weightUnit,
-            specification: item.specification,
-            brandNo: item.brandNum,
-            unqualifiedQuantity: '',
-            unqualifiedReason: '',
-            produceRoutingId: '',
-            produceRoutingName: '',
-            produceTaskId: '',
-            produceTaskName: ''
-          };
-        }
-      });
+          if (this.title == '创建') {
+            unqualifiedProductsAdd(this.form)
+              .then((res) => {
+                this.loading = false;
+                this.$message.success('成功');
+                this.cancel();
+                this.$emit('refresh');
+              })
+              .catch((e) => {
+                this.loading = false;
+              });
+          }
 
-      this.form.poList = this.form.poList.concat(list);
+          if (this.title == '修改') {
+            updateData({...this.form,id:this.id})
+              .then((res) => {
+                this.loading = false;
+                this.$message.success('成功');
+                this.cancel();
+                this.$emit('refresh');
+              })
+              .catch((e) => {
+                this.loading = false;
+              });
+          }
+        });
+      },
 
-      this.produceTaskChange();
-      this.inputNumber();
-    },
+      // 确定选择
+      confirmChoose(data) {
+        console.log(data);
+        this.form.poList = [];
+
+        let list = [];
+        list = data.map((item, index) => {
+          if (item.productCode) {
+            return item;
+          } else {
+            return {
+              categoryCode: item.code,
+              categoryName: item.name,
+              categoryId: item.id,
+              brandNum: item.brandNum,
+              brandNo: item.batchNo,
+              specification: item.specification,
+              modelType: item.modelType,
+              engrave: '',
+              unqualifiedQuantity: '',
+              unqualifiedReason: '',
+              produceRoutingId: '',
+              produceRoutingName: '',
+              produceTaskId: '',
+              produceTaskName: '',
+              measureQuantity: '',
+              measureUnit: item.measuringUnit,
+              weight: '',
+              weightUnit: item.weightUnit
+            };
+          }
+        });
+        this.form.categoryCode = data[0].code;
+        this.form.categoryName = data[0].name;
+        this.form.categoryId = data[0].id;
+        this.form.brandNum = data[0].brandNum;
+        this.form.brandNo = data[0].batchNo;
+        this.form.specification = data[0].specification;
+        this.form.modelType = data[0].modelType;
+        this.form.measureQuantity = '';
+        this.form.measureUnit = data[0].measuringUnit;
+        this.form.weight = '';
+        this.form.weightUnit = data[0].weightUnit;
+        this.form.unqualifiedQuantity = data.length;
+
+        this.form.poList = this.form.poList.concat(list);
+
+        this.produceTaskChange();
+        // this.inputNumber();
+      },
 
-    inputNumber() {
-      this.form.unqualifiedQuantity = 0;
-      this.form.poList.forEach((item) => {
-        this.form.unqualifiedQuantity += Number(item.unqualifiedQuantity) || 0;
-      });
+      inputNumber() {
+        this.form.unqualifiedQuantity = 0;
+        this.form.poList.forEach((item) => {
+          this.form.unqualifiedQuantity +=
+            Number(item.unqualifiedQuantity) || 0;
+        });
+      }
+    },
+    watch: {
+      'form.produceRoutingId': {
+        handler(val) {
+          this.getProduceTaskList();
+        }
+      }
     }
-  }
-};
+  };
 </script>
 <style lang="scss" scoped>
-.basic-details-title {
-  margin: 10px 0;
-}
+  .basic-details-title {
+    margin: 10px 0;
+  }
 
-.add-product {
-  width: 100%;
-  display: flex;
-  align-items: center;
-  justify-content: flex-end;
-  font-size: 30px;
-  color: #1890ff;
-  margin: 10px 0;
-  cursor: pointer;
-}
+  .add-product {
+    width: 100%;
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    font-size: 30px;
+    color: #1890ff;
+    margin: 10px 0;
+    cursor: pointer;
+  }
 
-.create-form .el-form-item {
-  margin-bottom: 15px !important;
-}
+  .create-form .el-form-item {
+    margin-bottom: 15px !important;
+  }
 </style>

+ 2 - 2
src/views/unqualifiedProduct/unqualifiedList/components/order-search.vue

@@ -13,11 +13,11 @@
           <el-input clearable v-model="where.unqualifiedProductsCode" placeholder="请输入" />
         </el-form-item>
       </el-col>
-      <el-col v-bind="styleResponsive ? { lg: 6, md: 8 } : { span: 4 }">
+      <!-- <el-col v-bind="styleResponsive ? { lg: 6, md: 8 } : { span: 4 }">
         <el-form-item label="创建人:">
           <el-input clearable v-model="where.reviewerName" placeholder="请输入" />
         </el-form-item>
-      </el-col>
+      </el-col> -->
       <el-col v-bind="styleResponsive ? { lg: 6, md: 8 } : { span: 4 }">
         <el-form-item label="创建时间:">
           <el-date-picker class="w100" style="width: 100%" v-model="where.createTime" type="daterange"

+ 332 - 139
src/views/unqualifiedProduct/unqualifiedList/detailList.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="ele-body">
     <el-card shadow="never" v-loading="loading">
-      <order-search @search="reload" ref="searchRef"> </order-search>
+      <!-- <order-search @search="reload" ref="searchRef"> </order-search> -->
       <ele-pro-table
         ref="table"
         :columns="columns"
@@ -9,14 +9,15 @@
         :selection.sync="selection"
         :pageSize="20"
         :pageSizes="[20, 30, 40, 50, 100]"
+        :key="key"
       >
         <!-- 操作列 -->
-        <template v-slot:toolbar>
+        <template v-slot:toolbar v-if="showBtn">
           <el-button
             type="primary"
             slot="reference"
             :disabled="selection.length == 0"
-            @click="disposeList(1)"
+            @click="disposeFn(1)"
             >批量处置</el-button
           >
 
@@ -52,7 +53,7 @@
             :underline="false"
             icon="el-icon-edit"
             v-if="row.disposalStatus == null"
-            @click="disposeList(2, row)"
+            @click="disposeFn(2, row)"
           >
             处置
           </el-link>
@@ -66,81 +67,142 @@
       @close="close"
       title="处置"
     >
-      <!-- <el-form ref="form1" :model="formData" label-width="80px"> -->
-      <!-- <el-row :gutter="24">
-          <el-col :span="12">
-            <el-form-item label="产品编码">
-              <el-input v-model="formData.categoryCode" disabled></el-input>
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="产品名称">
-              <el-input v-model="formData.categoryName" disabled></el-input>
-            </el-form-item>
-          </el-col>
-        </el-row> -->
-      <!-- <el-row :gutter="24">
-          <el-col :span="12">
-            <el-form-item label="批次号">
-              <el-input v-model="formData.batchNo" disabled></el-input>
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="刻码">
-              <el-input v-model="formData.engrave" disabled></el-input>
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row :gutter="24">
-          <el-col :span="12">
-            <el-form-item label="类型">
-              <template>
-                <template v-if="this.qualityType == 1">
-                  <el-select
-                    v-model="formData.disposalStatus"
-                    placeholder="请选择"
-                    style="width: 100%"
-                    clearable
-                  >
-                    <el-option
-                      v-for="item in disposalStatusListType"
-                      :key="item.value"
-                      :label="item.label"
-                      :value="item.value"
-                    >
-                    </el-option>
-                  </el-select>
-                </template>
-                <template v-if="this.qualityType == 2">
-                  <el-select
-                    v-model="formData.disposalStatus"
-                    placeholder="请选择"
-                    style="width: 100%"
-                    clearable
-                  >
-                    <el-option
-                      v-for="item in disposalStatusList"
-                      :key="item.value"
-                      :label="item.label"
-                      :value="item.value"
-                    >
-                    </el-option>
-                  </el-select>
-                </template>
-              </template> -->
-      <DictSelection
+      <el-form
+        ref="type6Form"
+        :model="type6Form"
+        label-width="150px"
+        :rules="rules"
+      >
+        <el-form-item label="处置方式:" prop="disposeType">
+          <el-select
+            v-model="type6Form.disposeType"
+            placeholder="请选择"
+            style="width: 100%"
+          >
+            <el-option
+              v-for="item in disposeList"
+              :key="item.value"
+              :label="item.label"
+              :value="item.value"
+            >
+            </el-option>
+          </el-select>
+        </el-form-item>
+
+        <template v-if="type6Form.disposeType == 6">
+          <el-row>
+            <el-col :span="24">
+              <el-form-item label="留样日期:" prop="sampleDate" align="center">
+                <el-date-picker
+                  class="w100"
+                  v-model="type6Form.sampleDate"
+                  type="date"
+                  value-format="yyyy-MM-dd"
+                  placeholder="请输入"
+                ></el-date-picker>
+              </el-form-item>
+            </el-col>
+            <el-col :span="6"> </el-col>
+          </el-row>
+          <el-row style="margin-top: 12px">
+            <el-col :span="24">
+              <el-form-item
+                label="留样条件:"
+                prop="sampleCondition"
+                align="center"
+              >
+                <el-input
+                  v-model="type6Form.sampleCondition"
+                  placeholder="请输入"
+                  style="width: 100%"
+                ></el-input>
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row style="margin-top: 12px">
+            <el-col :span="24">
+              <el-form-item
+                label="生产商/受托生产:"
+                prop="producerManufacturer"
+                align="center"
+              >
+                <el-input
+                  v-model="type6Form.producerManufacturer"
+                  placeholder="请输入"
+                  style="width: 100%"
+                ></el-input>
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row style="margin-top: 12px">
+            <el-col :span="24">
+              <el-form-item
+                label="留样地点:"
+                prop="samplePlace"
+                align="center"
+              >
+                <el-input
+                  type="textarea"
+                  v-model="type6Form.samplePlace"
+                  placeholder="请输入"
+                  style="width: 100%"
+                ></el-input>
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row style="margin-top: 12px">
+            <el-col :span="24">
+              <el-form-item
+                label="留样备注:"
+                prop="sampleRemark"
+                align="center"
+              >
+                <el-input
+                  type="textarea"
+                  v-model="type6Form.sampleRemark"
+                  placeholder="请输入"
+                  style="width: 100%"
+                ></el-input>
+              </el-form-item>
+            </el-col>
+          </el-row>
+
+          <el-row style="margin-top: 12px">
+            <el-col :span="24"> </el-col>
+          </el-row>
+        </template>
+
+        <template v-if="this.type6Form.disposeType !== 8">
+          <el-form-item
+            label="入库仓库:"
+            prop="disposeWarehouseId"
+            align="center"
+          >
+            <el-select
+              style="width: 100%"
+              v-model="type6Form.disposeWarehouseId"
+            >
+              <el-option
+                v-for="item in warehouseList"
+                :key="item.id"
+                :value="item.id"
+                :label="item.name"
+                @click.native="chooseWarehouse(item)"
+              ></el-option>
+            </el-select>
+          </el-form-item>
+        </template>
+      </el-form>
+
+      <!-- <DictSelection
         dictName="不良品处理类型"
         :filterArr="all ? ['返工返修'] : []"
         v-model="current.disposalStatus"
-      />
-      <!-- </el-form-item>
-          </el-col>
-        </el-row> -->
-      <!-- </el-form> -->
+      /> -->
 
       <div slot="footer" class="dialog-footer">
         <el-button @click="dialogVisible = false">取 消 </el-button>
-        <el-button type="primary" @click="handleDispose()">确 定</el-button>
+        <el-button type="primary" @click="handleDispose">确 定</el-button>
       </div>
     </el-dialog>
     <Edit ref="edit" @success="save" />
@@ -150,14 +212,18 @@
 <script>
   import OrderSearch from './components/detail-search.vue';
   import Edit from './components/edit.vue';
+  import { getWarehouseList } from '@/api/samplemanagement';
 
   import dictMixins from '@/mixins/dictMixins';
   import { unacceptedProductStatus } from '@/utils/util';
+  import { deepClone } from '@/utils';
+  import { disposeApi } from '@/api/unacceptedProduct';
 
   import {
     getDetail,
     deleteUnacceptedProductDetail,
-    dispose
+    dispose,
+    getById
   } from '@/api/unacceptedProduct/index';
   export default {
     components: {
@@ -167,15 +233,46 @@
     mixins: [dictMixins],
     data() {
       return {
+        key: '',
+        warehouseList: [],
+        rules: {
+          disposeType: [
+            { required: true, message: '请选择处置方式', trigger: 'change' }
+          ],
+          disposeWarehouseId: [
+            { required: true, message: '请选择仓库', trigger: 'change' }
+          ]
+        },
+        disposeType: '',
+        type6Form: {
+          disposeType: '',
+          sampleCondition: '',
+          sampleDate: '',
+          samplePlace: '',
+          sampleRemark: '',
+          producerManufacturer: '',
+          disposeWarehouseId: '',
+          disposeWarehouseName: ''
+        },
         loading: false,
         selection: [],
-        // datasource: [],
-        disposeType: '',
         dialogVisible: false,
         current: {},
         formData: {},
         all: false,
         qualityType: null,
+        allList: [
+          { value: 1, label: '返工' },
+          { value: 2, label: '返修' },
+          { value: 3, label: '报废' },
+          { value: 4, label: '降级使用' },
+          { value: 5, label: '让步接收' },
+          { value: 6, label: '留样' },
+          { value: 7, label: '消耗' },
+          { value: 8, label: '回用/归批' },
+          { value: 9, label: '转试销' },
+          { value: 10, label: '退货' }
+        ],
         //来料
         disposalStatusListType: [
           {
@@ -225,16 +322,34 @@
       };
     },
     computed: {
+      showBtn() {
+        return !this.$route.query.type;
+      },
+      disposeList() {
+        if (this.$route.query.qualityType == 1) {
+          return this.allList.filter((item) => [5, 10].includes(item.value));
+        }
+        if (
+          this.$route.query.qualityType == 2 ||
+          this.$route.query.qualityType == 3
+        ) {
+          return this.allList.filter(
+            (item) => item.value !== 8 && item.value !== 10
+          );
+        } else {
+          return this.allList;
+        }
+      },
       // 表格列配置
       columns() {
-        return [
+        const arr = [
           {
             width: 45,
             type: 'selection',
             columnKey: 'selection',
             align: 'center',
             selectable: (row, index) => {
-              return row.status == 0; //
+              return row.disposalStatus !== 2; //
             }
           },
           {
@@ -247,46 +362,71 @@
             fixed: 'left'
           },
           {
-            prop: 'code',
-            label: '编码',
-            align: 'center'
+            label: '样品编码',
+            prop: 'sampleCode',
+            width: '150',
+            align: 'center',
+            showOverflowTooltip: true
           },
           {
-            prop: 'workOrderId',
-            label: '工单号',
-            align: 'center'
+            prop: 'categoryCode',
+            label: '物品编码',
+            width: '150',
+            align: 'center',
+            showOverflowTooltip: true
           },
           {
-            prop: 'batchNo',
-            label: '批次号',
-            align: 'center'
+            prop: 'categoryName',
+            label: '物品名称',
+            width: '150',
+            align: 'center',
+            showOverflowTooltip: true
           },
           {
-            prop: 'engravingCode',
-            label: '刻码',
-            align: 'center'
+            label: '规格',
+            prop: 'specification',
+            width: '120',
+            align: 'center',
+            showOverflowTooltip: true
           },
           {
-            prop: 'productName',
-            label: '产品名称',
+            prop: 'brandNum',
+            label: '牌号',
             align: 'center'
           },
           {
-            prop: 'productCode',
-            label: '产品编码',
-            align: 'center'
+            prop: 'modelType',
+            label: '型号',
+            align: 'center',
+            width: '120',
+            showOverflowTooltip: true
           },
           {
-            prop: 'specification',
-            label: '规格',
-            align: 'center'
+            prop: 'batchNo',
+            label: '批次号',
+            align: 'center',
+            width: '120',
+            showOverflowTooltip: true
           },
           {
-            prop: 'brandNo',
-            label: '牌号',
+            prop: 'weight',
+            label: '重量',
+            align: 'center',
+            width: '120',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'weightUnit',
+            label: '重量单位',
+            align: 'center',
+            width: '120',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'engrave',
+            label: '刻码',
             align: 'center'
           },
-
           {
             prop: 'unqualifiedQuantity',
             label: '数量',
@@ -308,27 +448,43 @@
             label: '原因',
             align: 'center'
           },
-
           {
-            prop: 'createTime',
-            label: '创建时间',
+            prop: 'disposeTime',
+            label: '处置时间',
             align: 'center',
-            width: 160
+            width: '180',
+            showOverflowTooltip: true
           },
           {
-            prop: 'reviewerName',
-            label: '创建人',
-            align: 'center'
+            prop: 'disposalStatus',
+            label: '处置结果',
+            align: 'center',
+            width: '120',
+            showOverflowTooltip: true,
+            formatter: (row, column, cellValue) => {
+              return this.disposalStatustList[cellValue ? cellValue : 0];
+            }
           },
           {
-            prop: 'type',
+            prop: 'disposeType',
             label: '处置类型',
             align: 'center',
-            // slot: 'SlottingType'
+            width: '120',
+            showOverflowTooltip: true,
             formatter: (row, column, cellValue) => {
-              return this.getDictValue('不良品处理类型', cellValue + '');
+              return this.allList.filter((item) => item.val == cellValue).value;
             }
           },
+
+          // {
+          //   prop: 'type',
+          //   label: '处置类型',
+          //   align: 'center',
+          //   // slot: 'SlottingType'
+          //   formatter: (row, column, cellValue) => {
+          //     return this.getDictValue('不良品处理类型', cellValue + '');
+          //   }
+          // },
           {
             prop: 'status',
             label: '状态',
@@ -349,36 +505,31 @@
             showOverflowTooltip: true
           }
         ];
+        return this.$route.query.type ? arr.slice(0, -1) : arr;
+      },
+      disposalStatustList() {
+        return { 0: '待处置', 1: '处置中', 2: '处置完成' };
       }
     },
-    created() {
-      // this.getList();
+    async created() {
       this.qualityType = this.$route.query.qualityType;
+      this.warehouseList = await getWarehouseList();
     },
 
     methods: {
-      // getList() {
-      //   getDetail({unqualifiedProductsId:this.$route.query.id}).then((res) => {
-      //     this.datasource = res;
-      //   });
-      // },
       // /* 表格数据源 */
       async datasource({ page, where, limit }) {
-        where.unqualifiedProductsId = this.$route.query.id;
-        const arr = await getDetail({
-          ...where,
-          pageNum: page,
-          size: limit
-        });
-        this.tableData = arr.list;
-        console.log(arr, 'arr');
-        return arr.list;
+        let id = this.$route.query.id;
+        const arr = await getById(id);
+        // where.unqualifiedProductsId = this.$route.query.id;
+        return arr.poList;
       },
       reload(where) {
-        this.$nextTick(() => {
-          if (this.$refs.searchRef && this.$refs.searchRef.reload)
-            this.$refs.searchRef.reload({ page: 1, where: where });
-        });
+        this.key = Math.random();
+        // this.$nextTick(() => {
+        //   if (this.$refs.searchRef && this.$refs.searchRef.reload)
+        //     this.$refs.searchRef.reload({ page: 1, where: where });
+        // });
       },
       remove(row) {
         let ids = row ? [row.id] : this.selection.map((item) => item.id);
@@ -392,7 +543,7 @@
         this.formData.disposalStatus = '';
       },
       // // 处置
-      disposeList(type, row) {
+      disposeFn(type, row) {
         if (type == 1) {
           this.all = true;
         } else {
@@ -404,15 +555,39 @@
         // let ids = this.current ? [this.current.id] : this.selection.map((item) => item.id);
       },
       async handleDispose() {
-        if (!this.formData.disposalStatus) {
+        this.$refs['type6Form'].validate(async (valid) => {
+          if (valid) {
+            let params = {
+              disposeType: this.type6Form.disposeType,
+              poList: []
+            };
+            if (this.all) {
+              params.poList = this.selection.map((item) => {
+                return { ...item, ...this.type6Form };
+              });
+            } else {
+              params.poList = [
+                { ...deepClone(this.current), ...this.type6Form }
+              ];
+            }
+            console.log(params);
+            await disposeApi(params);
+            this.dialogVisible = false;
+            this.current = null;
+            this.$message.success('处置成功!');
+            this.reload();
+            return;
+          } else {
+            return false;
+          }
           return;
-        }
-        this.$refs.edit.open(
-          this.all ? this.selection : [this.current],
-          this.formData.disposalStatus
-        );
-        this.dialogVisible = false;
+        });
+
+        return;
+
+
       },
+      validate() {},
       async save(data) {
         if (data.data && data.data.length > 0) {
           data.data.forEach((item) => {
@@ -430,6 +605,24 @@
         this.current = null;
         this.$message.success('处置成功!');
         this.reload();
+      },
+      chooseWarehouse(item) {
+        console.log(item);
+        this.type6Form.disposeWarehouseId = item.id;
+        this.type6Form.disposeWarehouseName = item.name;
+      }
+    },
+    watch: {
+      'type6Form.disposeType': {
+        handler(newVal, oldVal) {
+          this.type6Form.sampleCondition = '';
+          this.type6Form.sampleDate = '';
+          this.type6Form.samplePlace = '';
+          this.type6Form.sampleRemark = '';
+          this.type6Form.producerManufacturer = '';
+          this.type6Form.disposeWarehouseId = '';
+          this.type6Form.disposeWarehouseName = '';
+        }
       }
     }
   };

+ 97 - 27
src/views/unqualifiedProduct/unqualifiedList/index.vue

@@ -8,6 +8,16 @@
         <template v-slot:toolbar>
           <el-button type="primary" @click="open()">新建</el-button>
         </template>
+
+        <template v-slot:unqualifiedProductsCode="{ row }">
+          <el-link
+            type="primary"
+            :underline="false"
+            @click="goDetail(row, 'detail')"
+            >{{ row.unqualifiedProductsCode }}</el-link
+          >
+        </template>
+
         <template v-slot:qualityType="{ row }">
           {{ getDictValue('质检计划类型', row.qualityType) }}
         </template>
@@ -34,10 +44,11 @@
             </template>
           </el-popconfirm>
           <el-link
+            v-if="row.status == 0||row.status == 1"
             type="primary"
             :underline="false"
             icon="el-icon-edit"
-            @click="detail(row)"
+            @click="goDetail(row)"
           >
             处置
           </el-link>
@@ -89,78 +100,136 @@
           {
             prop: 'unqualifiedProductsCode',
             label: '编码',
+            slot: 'unqualifiedProductsCode',
             align: 'center',
-            width: 170
+            width: 150,
+            showOverflowTooltip: true
           },
           {
             prop: 'sourceCode',
             label: '来源编码',
             align: 'center',
-            width: 170
+            width: 150,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'categoryCode',
+            label: '物品编码',
+            align: 'center',
+            width: 160,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'categoryName',
+            label: '物品名称',
+            align: 'center',
+            width: 160,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'specification',
+            label: '规格',
+            align: 'center',
+            width: 100,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'brandNum',
+            label: '牌号',
+            align: 'center',
+            width: 100,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'modelType',
+            label: '型号',
+            align: 'center',
+            width: 160,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'unit',
+            label: '计量单位',
+            align: 'center',
+            width: 100,
+            showOverflowTooltip: true
           },
           {
             prop: 'batchNo',
             label: '批次号',
             align: 'center',
-            width: 150
+            width: 100,
+            showOverflowTooltip: true
           },
           {
             prop: 'unqualifiedQuantity',
             label: '数量',
             align: 'center',
-            width: 80
+            width: 80,
+            showOverflowTooltip: true
           },
           {
-            prop: 'produceRoutingName',
-            label: '工艺路线',
+            prop: 'weight',
+            label: '重量',
             align: 'center',
-            width: 120
+            width: 100,
+            showOverflowTooltip: true
           },
           {
-            prop: 'produceTaskName',
-            label: '工序',
+            prop: 'weightUnit',
+            label: '重量单位',
+            align: 'center',
+            width: 100,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'produceRoutingName',
+            label: '工艺路线',
             align: 'center',
-            width: 120
+            width: 120,
+            showOverflowTooltip: true
           },
-
           {
-            prop: 'createTime',
-            label: '创建时间',
+            prop: 'taskName',
+            label: '工序',
             align: 'center',
-            width: 160
+            width: 120,
+            showOverflowTooltip: true
           },
           {
-            prop: 'reviewerName',
-            label: '创建人',
+            prop: 'disposeTime',
+            label: '处置时间',
             align: 'center',
-            width: 120
+            width: 180,
+            showOverflowTooltip: true
           },
           {
             prop: 'qualityType',
             slot: 'qualityType',
             label: '质检类型',
             align: 'center',
-            width: 120
+            width: 120,
+            showOverflowTooltip: true
           },
           {
             prop: 'status',
             label: '状态',
             align: 'center',
+            width: 100,
+            showOverflowTooltip: true,
             formatter: (row, column, cellValue) => {
               return unacceptedProductStatus(cellValue);
-            },
-            width: 100
+            }
           },
 
           {
             columnKey: 'action',
             label: '操作',
-            width: 240,
+            width: 200,
             align: 'center',
             resizable: false,
             fixed: 'right',
-            slot: 'action',
-            showOverflowTooltip: true
+            slot: 'action'
           }
         ];
       }
@@ -169,12 +238,13 @@
     filters: {},
     methods: {
       //处置
-      detail(row) {
+      goDetail(row, type) {
         this.$router.push({
           path: '/unqualifiedProduct/unqualifiedList/detailList',
           query: {
-            id: row.id
-            // qualityType: row.qualityType
+            id: row.id,
+            qualityType: row.qualityType,
+            type
           }
         });
       },