zouyu
2023-09-07 275d9a3c158173842449782201b9be2c243dd58b
src/views/inspectionManagement/commissionInspection/addCommision.vue
@@ -2,6 +2,79 @@
   <div class="add_commision">
      <div class="content-main">
         <div class="firstBox">
            <div class="printCommision" >
            <table height="30px" id="printCommision">
               <tr>
                  <td colspan="8">
                     <img :src="imgSrc" style="position: absolute;left: 50px;top:26px">
                     <h1 style="display: inline;">委托检验申请单</h1>
                  </td>
               </tr>
               <tr>
                  <td colspan="2">委托编号</td>
                  <td colspan="2">{{infoForm.commisioncode}}</td>
                  <td colspan="2">委托单位</td>
                  <td colspan="2">{{infoForm.department}}</td>
               </tr>
               <tr>
                  <td colspan="2">联系人</td>
                  <td colspan="2">{{infoForm.contacter}}</td>
                  <td colspan="2">联系电话</td>
                  <td colspan="2">{{infoForm.tel}}</td>
               </tr>
               <tr>
                  <td colspan="2">联系地址</td>
                  <td colspan="2">{{infoForm.address}}</td>
                  <td colspan="2">完成期限</td>
                  <td colspan="2">{{infoForm.deadline}}</td>
               </tr>
               <tr>
                  <td colspan="2">送样时间</td>
                  <td colspan="2">{{infoForm.time}}</td>
                  <td colspan="2">送样人</td>
                  <td colspan="2">{{infoForm.sender}}</td>
               </tr>
               <tr>
                  <td colspan="2">送样人电话</td>
                  <td colspan="2">{{infoForm.sendertel}}</td>
                  <td colspan="2">报告数量</td>
                  <td colspan="2">{{infoForm.num}}</td>
               </tr>
               <tr>
                  <td colspan="2">送样方式</td>
                  <td colspan="6">
                     <ul>
                        <li>
                           <i :class="`${infoForm.way == 1 ? 'el-icon-success' : 'el-icon-circle-check'}`"></i> 送样
                        </li>
                        <li>
                           <i :class="`${infoForm.way == 2 ? 'el-icon-success' : 'el-icon-circle-check'}`"></i> 上门
                        </li>
                     </ul>
                  </td>
               </tr>
               <tbody colspan="8"  v-for="(item,index) in sampleNameList" :key="index">
                  <tr>
                     <td colspan="2">样品</td>
                     <td colspan="2">{{item}}</td>
                     <td colspan="2">评定标准</td>
                     <td colspan="2">{{standardList[index]}}</td>
                  </tr>
                  <tr>
                     <td colspan="2">试验项目</td>
                     <td colspan="6">
                        <p style="text-align:left;margin-left:20px" v-for="(data,index) in testProjectList[index]" :key="index">
                        {{index+1 + "、" + data}}
                        </p>
                     </td>
                  </tr>
               </tbody>
               <tr>
                  <td colspan="2">备注</td>
                  <td colspan="6">{{infoForm.other}}</td>
               </tr>
            </table>
         </div>
            <div class="title">委托信息</div>
            <div class="tableBox">
               <div class="tableBox-header">
@@ -21,13 +94,12 @@
                  :data="detectionInfo" style="width: 100%;margin-bottom: 20px;">
                  <el-table-column type="index" label="序号" min-width="10%" />
                  <el-table-column prop="sampleNumber" label="样品编号" min-width="8%" />
                  <el-table-column prop="sampleName" label="样品名称" min-width="10%" />
                  <el-table-column prop="specificationsModels" label="规格型号" min-width="10%" />
                  <el-table-column prop="speName" label="规格型号" min-width="10%">
                  </el-table-column>
                  <el-table-column prop="unit" label="单位" min-width="8%" />
                  <el-table-column prop="samplesNumber" label="数量" min-width="8%" />
                  <el-table-column prop="addway" label="添加方式" min-width="8%">
                  <!-- <el-table-column prop="addway" label="添加方式" min-width="8%">
                     <template slot-scope="scope">
                        <div v-if="scope.row.addway === 0">
                           <el-tag type="success" disable-transitions>扫描</el-tag>
@@ -37,11 +109,12 @@
                        </div>
                        <div v-else></div>
                     </template>
                  </el-table-column>
                  </el-table-column> -->
                  <el-table-column prop="remarks" label="备注" min-width="8%" />
                  <el-table-column label="操作" min-width="8%">
                     <template slot-scope="scope">
                        <el-button type="text" size="small" @click="deleteRow(scope.row)">删除</el-button>
                        <el-button type="text" size="small"
                           @click.native.prevent="deleteRow(scope.$index, detectionInfo)">删除</el-button>
                     </template>
                  </el-table-column>
               </el-table>
@@ -87,22 +160,22 @@
                        </el-col>
                        <el-col :span="5">
                           <el-form-item label="完成期限:">
                              <el-date-picker v-model="infoForm.deadline" type="date" placeholder="选择日期" style="width: 200px;"
                              <el-date-picker value-format="yyyy-MM-dd" v-model="infoForm.deadline" type="date" placeholder="选择日期" style="width: 200px;"
                                 size="small">
                              </el-date-picker>
                           </el-form-item>
                        </el-col>
                        <el-col :span="5">
                           <el-form-item label="送样时间:">
                              <el-date-picker v-model="infoForm.time" type="date" placeholder="选择日期" style="width: 200px;">
                              <el-date-picker value-format="yyyy-MM-dd" v-model="infoForm.time" type="date" placeholder="选择日期" style="width: 200px;">
                              </el-date-picker>
                           </el-form-item>
                        </el-col>
                        <el-col :span="5">
                           <el-form-item label="送样方式:">
                              <el-select style="width: 200px;" v-model="infoForm.way" size="small" placeholder="送样">
                                 <el-option v-for="options in sampleDeliveryMode" :key="options.key"
                                    :value="options.value">{{ options.value }}</el-option>
                                 <el-option v-for="options in sampleDeliveryMode" :key="options.key" :value="options.key"
                                    :label="options.value">{{ options.value }}</el-option>
                              </el-select>
                           </el-form-item>
                        </el-col>
@@ -122,7 +195,7 @@
                        </el-col>
                        <el-col :span="5">
                           <el-form-item label="报告数:">
                              <el-input style="width: 200px;" v-model="infoForm.num" placeholder="请输入报告数" autocomplete="off"
                              <el-input type="number" min="0" style="width: 200px;" v-model="infoForm.num" placeholder="请输入报告数" autocomplete="off"
                                 size="small" />
                           </el-form-item>
                        </el-col>
@@ -138,7 +211,7 @@
                     <el-button type="primary" size="small" @click="submitInspection"
                        style="background-color: rgb(1, 102, 226);">提交</el-button>
                     <!-- 点击返回,当前页面值为false -->
                     <el-button type="primary" size="mini" style="background-color: rgb(1, 102, 226); ">打印委托单</el-button>
                     <el-button type="primary" size="mini" style="background-color: rgb(1, 102, 226); " @click="printCommision">打印委托单</el-button>
                  </div>
               </el-form>
            </div>
@@ -158,7 +231,7 @@
                        <el-form-item label="样品名称:">
                           <el-select v-model="addPointerForm.sampleName" size="small" placeholder="请选择样品名称"
                              @change="upMaterialName">
                              <el-option v-for="options in sampleoptions" :value="options.key" :label="options.value"></el-option>
                              <el-option v-for="(options,index) in sampleoptions" :key="index" :value="options.key" :label="options.value"></el-option>
                           </el-select>
                        </el-form-item>
                     </el-col>
@@ -174,7 +247,8 @@
                     </el-col>
                     <el-col :span="11">
                        <el-form-item label="规格型号:">
                           <el-select v-model="addPointerForm.specificationsModels" size="small" placeholder="请先选择样品名称" @change="getProductList">
                           <el-select v-model="addPointerForm.specificationsModels" size="small" placeholder="请先选择样品名称"
                              @change="getProductList">
                              <el-option v-for="options in model_sta_options" :value="options.key" :label="options.value"
                                 :key="options.key">{{ options.value }}</el-option>
                           </el-select>
@@ -194,7 +268,7 @@
                     </el-col>
                  </el-row>
                  <el-row :gutter="50">
                     <el-col :span="9">
                     <el-col :span="11">
                        <el-form-item label="添加项目:">
                           <el-checkbox-group v-model="addPointerForm.experiment" style="display: flex; flex-direction: column;">
                              <el-checkbox v-for="(expers, ai) in productList" :label="expers"
@@ -202,7 +276,7 @@
                           </el-checkbox-group>
                        </el-form-item>
                     </el-col>
                     <el-col :span="41">
                     <el-col :span="11">
                        <el-form-item label="备注:">
                           <el-input type="textarea" :autosize="{ minRows: 4, maxRows: 20}" style="width: 200px;"
                              v-model="addPointerForm.remarks" placeholder="请输入备注" autocomplete="off" />
@@ -221,17 +295,24 @@
</template>
<script>
   import PrintJS from 'print-js'
   import {
      getSampleName,
      getModelSpecification,
      getlink,
      addInspection,
      isIfViewUUID,
      getProductList
      getProductList,
      getContractsSampleInfo,
      getSpecificationsName
   } from '@/api/inspection/commisioninspection'
   export default {
      data() {
         return {
            sampleNameList:[],
            standardList:[],
            testProjectList:[],
            imgSrc: require("@/assets/404_images/logo.png"),
            currentPage: 0,
            searchData: '',
            infoForm: {
@@ -259,30 +340,9 @@
               experiment: [],
               addway: ''
            },
            experList: [{
               key: '1',
               label: '外观检查'
            }, {
               key: '2',
               label: '动作电压试验'
            }, {
               key: '3',
               label: '电阻管泄漏电流试验'
            }, {
               key: '4',
               label: '绝缘部分交流耐压试验'
            }],
            sampleoptions: [{
               key: '1',
               value: '选项1'
            }, {
               key: '2',
               value: '选项2'
            }],
            samplecodeoptions: [{
               key: '1',
               value: ''
            }],
            experList: [],
            sampleoptions: [],
            samplecodeoptions: [],
            model_spe_options: [],
            model_sta_options: [],
            model_options: [],
@@ -302,12 +362,12 @@
      watch: {
         addPointerForm: {
            handler: function(val) {
               if(val.addway!=""){
               if (val.addway != "") {
                  this.model_sta_options = []
                  this.model_options.forEach(a=>{
                     if(a.specificationsName==val.addway){
                        this.model_sta_options = a.children.map(item=>{
                           return{
                  this.model_options.forEach(a => {
                     if (a.specificationsName == val.addway) {
                        this.model_sta_options = a.children.map(item => {
                           return {
                              key: item.modelId,
                              value: item.modelName
                           }
@@ -323,11 +383,26 @@
         this.viewId = this.$route.params.viewId
         this.$store.commit('settings/SAVE_LINK', this.viewId)
         this.getlink(this.$route.params.viewId)
         this.getContractsSampleInfo(this.$route.params.viewId)
      },
      mounted() {
         this.getSampleName()
      },
      methods: {
         printCommision(){
            console.log(this.infoForm);
            PrintJS({
               printable: "printCommision",
               type: "html",
               css: [
                  "https://unpkg.com/element-ui/lib/theme-chalk/fonts/element-icons.ttf",
                  "https://unpkg.com/element-ui/lib/theme-chalk/fonts/element-icons.woff",
                  "https://unpkg.com/element-ui/lib/theme-chalk/icon.css"
               ],
               targetStyles: ["*"],
               ignoreElements: ["no-ignore"],
            });
         },
         getlink(viewId) {
            if (viewId == null) {
               this.$message.error('当前链接不在有效期内,系统自动关闭')
@@ -340,7 +415,14 @@
               if (!res.data) {
                  this.$message.error('当前链接不在有效期内,系统自动关闭')
                  this.$router.push('/404')
               } else {
                  this.getContractsSampleInfo()
               }
            })
         },
         async getContractsSampleInfo(viewId) {
            let res = await getContractsSampleInfo({
               viewId
            })
         },
         async getSampleName() {
@@ -366,15 +448,23 @@
            })
         },
         addInspection() {
            let sName = this.addPointerForm.sampleName;
            this.sampleoptions.forEach(a=>{
               if(a.key == sName) this.sampleNameList.push(a.value);
            })
            this.standardList.push(this.addPointerForm.addway);
            this.testProjectList.push(this.addPointerForm.experiment);
            let exper = this.addPointerForm.experiment[0]
            this.addPointerForm.addway = 1
            for (let i = 1; i < this.addPointerForm.experiment.length; i++) {
               exper += ',' + this.addPointerForm.experiment[i]
            }
            // console.log(exper)
            this.addPointerForm.experiment = exper
            let tmp = this.addPointerForm
            this.sampleoptions.forEach(a => {
               if (a.key == tmp.sampleName) tmp.sampleName = a.value
            })
            tmp.speName = tmp.addway + '-' + tmp.speName
            tmp.addway = 1
            this.detectionInfo.push(tmp)
            this.dialogueFormVisible = false
            this.addPointerForm = {
@@ -385,8 +475,10 @@
               samplesNumber: '',
               remarks: '',
               experiment: [],
               addway: ''
               addway: '',
               speName: ''
            }
            console.log(this.sampleNameList);
         },
         async submitInspection() {
            let sampledeliveryway
@@ -407,12 +499,13 @@
               reportNumber: parseInt(this.infoForm.num),
               sampleDeliveryMode: sampledeliveryway,
               sampleDeliveryPhone: this.infoForm.sendertel,
               sampleSender: this.infoForm.sender
               sampleSender: this.infoForm.sender,
               speName: this.infoForm.speName
            })
            this.infoForm.commisioncode = res.data
            if (res.data) {
               this.$message({
                  message: '恭喜你!',
                  message: '添加成功!',
                  type: 'success'
               })
               this.showDetail = true
@@ -426,8 +519,8 @@
         handleCurrentChange(pageNo) {
            this.pageParams.pageNo = pageNo
         },
         deleteRow(row) {
         deleteRow(index, rows) {
            rows.splice(index, 1);
         },
         upMaterialName(val) {
            this.sampleoptions.forEach(a => {
@@ -437,18 +530,82 @@
            })
            this.getModelSpecification(val)
         },
         getProductList(val){
            getProductList({modelId: val}).then(res=>{
               this.productList = res.data.map(item=>{
         getProductList(val) {
            getProductList({
               modelId: val
            }).then(res => {
               this.productList = res.data.map(item => {
                  return item.name
               })
            })
         }
            this.model_sta_options.forEach(a => {
               if (a.key == val) {
                  this.addPointerForm.speName = a.value
               }
            })
         },
         getContractsSampleInfo() {
            getContractsSampleInfo({
               viewId: this.viewId
            }).then(res => {
               if (res.data == null) return
               this.infoForm = {
                  commisioncode: res.data.entrustCoding,
                  deadline: res.data.completionDeadline,
                  address: res.data.contactAddress,
                  tel: res.data.contactNumber,
                  contacter: res.data.contacts,
                  other: res.data.entrustRemarks,
                  department: res.data.entrusted,
                  time: res.data.inspectionTime,
                  detectionInfo: res.data.linkDetectionList,
                  num: res.data.reportNumber,
                  way: '' + res.data.sampleDeliveryMode,
                  sendertel: res.data.sampleDeliveryPhone,
                  sender: res.data.sampleSender
               }
               this.detectionInfo = res.data.linkDetectionList
            })
         },
      }
   }
</script>
<style lang="scss" scoped>
   .printCommision{
      display: none;
      width: 90%;
      height:100px;
      table {
         width: 100%;
         border-collapse: collapse;
         font-size: 18px;
      }
      table,
      tr,
      th,
      td {
         border: 2px solid black;
         text-align: center;
         font-family: '微软雅黑';
         ul{
            list-style: none;
            width: 500px;
         }
         ul li{
            display: inline;
            width:100px;
            margin: 0 25px;
         }
      }
      tr,
      td,
      th {
         padding: 20px 10px;
      }
   }
   .content-main {
      padding: 20px 40px;
      background-color: #f0f2f5;