value
2023-08-31 cd6e23073fcda76f9852e883aacf1315ee4b9a67
src/views/inspectionManagement/reportForInspection/index.vue
@@ -30,7 +30,7 @@
         </div>
         <el-dialog title="新增原材料报检" :visible.sync="addReportVisible" width="40%">
            <el-form ref="addMaterialForm" :rules="insertRule" :model="insertData" :inline="true" label-position="right"
               label-width="80px">
               label-width="100px">
               <el-form-item label="来料日期:" prop="fromDate">
                  <el-date-picker v-model="insertData.fromDate" type="date" value-format="yyyy-MM-dd"></el-date-picker>
               </el-form-item>
@@ -115,19 +115,30 @@
            </div>
         </div>
      </div>
      <el-dialog title="选择日期" :visible.sync="addReportDialog" width="30%">
      <el-dialog title="选择日期" :visible.sync="addReportDialog" width="60%">
         <el-form :model="addInspectionForm" :rules="addInspectionFormRules" rule="addInspectionForm">
            <el-form-item label="检验日期" label-width="100px" prop="inspectionDate">
               <el-date-picker v-model="addInspectionForm.inspectionDate" type="daterange" value-format="yyyy-MM-dd"
                  range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
               </el-date-picker>
            </el-form-item>
            <el-form-item label="版本" label-width="100px" prop="version">
               <el-select v-model="addInspectionForm.version" placeholder="请选择版本">
                  <el-option v-for="(item,index) in 5" :key="index" :value="item" :label="item"></el-option>
            <el-form-item label="当前版本" label-width="100px" prop="version">
               <el-select @change="changeVersionFun" v-model="addInspectionForm.version" placeholder="请选择版本">
                  <el-option v-for="item in chooseVersion" :key="item.value" :label="item.label" :value="item.value" ></el-option>
               </el-select>
            </el-form-item>
         </el-form>
      <el-table
        style="width:90%;margin-left:5%"
        :data="standardLibraryData" row-key="id" border
        default-expand-all ref="multipleTable"
        :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
        <el-table-column type="index" width="50px" label="序号"></el-table-column>
        <el-table-column label="项目名称" prop="name" sortable></el-table-column>
        <el-table-column prop="unit" label="单位" sortable></el-table-column>
        <el-table-column label="标准值" prop="required" sortable></el-table-column>
        <el-table-column prop="internal" label="内控值" sortable></el-table-column>
      </el-table>
         <div slot="footer" class="dialog-footer">
            <el-button @click="resetForm('addInspectionForm')">取 消</el-button>
            <el-button type="primary" @click="confirmBtn('addInspectionForm')">确 定</el-button>
@@ -245,16 +256,20 @@
      deleteMaterial,
      addMaterial,
      getMaterielName,
      getSpecification
      getSpecification,
    getChooseVersion,
    lookProByVer
   } from '@/api/inspection/rawmaterial'
   export default {
      data() {
         return {
        standardLibraryData:[],
        chooseVersion: [],
            userName: "",
            devices: "",
            addInspectionForm: {
               inspectionDate: ['2023-08-01', '2023-08-31'],
               version: 5
               inspectionDate: [],
               version: null
            },
            addInspectionFormRules: {
               inspectionDate: [{
@@ -405,7 +420,7 @@
         this.getRawMaterialList()
      },
      mounted() {
         this.getMaterielName()
         this.getMaterielName();
      },
      methods: {
         handleChange() {
@@ -454,6 +469,7 @@
         },
         handleSelectionChange(val) {
            this.checkData = val;
        console.log(val);
         },
         //生成报检单按钮
         addReportBtn() {
@@ -463,10 +479,55 @@
               if (this.checkData.length > 1) {
                  this.$message.error("最多选择一条数据!");
               } else {
            let mcode = this.checkData[0].materialCoding;
            let name = this.checkData[0].materialName;
            let specifications = this.checkData[0].specificationsModels;
            this.getChooseVersionFun(mcode,name,specifications);
            console.log(this.standardLibraryData);
                  this.addReportDialog = true;
               }
            }
         },
      changeVersionFun(){
        let mCode = this.checkData[0].materialCoding;
        let name = this.checkData[0].materialName;
        let specifications = this.checkData[0].specificationsModels;
        let version = this.addInspectionForm.version;
        this.getProByVersion(mCode,name,specifications,version);
      },
      //获取版本下的标准库数据
      async getProByVersion(mCode,name,specifications,version){
          var vm = this;
          await lookProByVer({
              mcode : mCode,
              name : name,
              specifications : specifications,
              version: version
          }).then((res)=>{
            console.log(res);
            vm.standardLibraryData = res.data;
          })
      },
      //获取版本列表
      async getChooseVersionFun(mCode,name,specifications){
        var vm = this;
        this.chooseVersion = [];
        await getChooseVersion({
          mcode : mCode,
          name : name,
          specifications : specifications
        }).then((res)=>{
              vm.getProByVersion(mCode,name,specifications,res.data[0])
              for(let i=0;i<res.data.length;i++){
                vm.chooseVersion.push({
                  value: res.data[i],
                  label: "V"+res.data[i]
                });
              }
              vm.addInspectionForm.version = res.data[0];
        });
      },
         //生成报检单确认按钮
         confirmBtn(formName) {
            let dateArr = this.addInspectionForm.inspectionDate;
@@ -485,14 +546,14 @@
               "supplier": val.supplierName,
               "type": val.type,
               "unit": val.unit,
               "version": val.version
               "version": this.addInspectionForm.version
            }
            // this.createReport(obj);
            this.addReportDialog = false;
            this.initNewSelection();
            this.showNewPage = true;
         },
         //生成报价单
         //生成报检单
         async createReport(param) {
            let res = await addInspect(param);
            const res2 = await selectInspectsListById({
@@ -501,7 +562,6 @@
            this.resultData = res2.data;
            this.inspectionForm = res2.data;
            this.inspectionItems = res2.data.insProducts;
         },
         // 获取分页列表数据
         async getRawMaterialList() {