licp
2024-04-19 e04fbe73f7785155bffe3db30a7ead37f9200f06
src/components/do/b1-ins-order/add.vue
@@ -2,6 +2,12 @@
   .ins_order_add {
      width: 100%;
      height: 100%;
      overflow-y: auto;
      overflow-x: hidden;
   }
   .ins_order_add::-webkit-scrollbar {
      width: 0;
   }
   .title {
@@ -12,7 +18,7 @@
   .search {
      width: calc(100% - 40px);
      background-color: #fff;
      padding: 10px 40px 10px 0;
      padding: 5px 40px 5px 0;
   }
   .search_thing {
@@ -34,6 +40,12 @@
   .node_i {
      color: orange;
      font-size: 18px;
   }
   .el-select-dropdown__item {
      display: flex;
      align-items: center;
      justify-content: space-between;
   }
</style>
<style>
@@ -64,6 +76,17 @@
   .ins_order_add .el-table__row .cell {
      font-size: 12px;
   }
   .ins_order_add .el-table .warning-row .cell {
      color: #bababa;
   }
  .el-select .is-disabled{
    background: transparent !important;
  }
  .el-select .is-disabled .el-input__inner{
    background: transparent !important;
  }
</style>
<template>
@@ -72,13 +95,22 @@
         <el-row class="title">
            <el-col :span="6" style="padding-left: 20px;">委托单信息</el-col>
            <el-col :span="18" style="text-align: right;">
               <el-select v-model="template" size="medium" placeholder="下单模板" style="margin-right: 10px;">
                  <el-option v-for="(a, ai) in templates" :key="ai" :value="a.value" :label="a.label"></el-option>
               <el-select v-model="template" size="medium" placeholder="下单模板" style="margin-right: 10px;" v-show="active==1"
                  @change="selectInsOrderTemplateById">
                  <el-option v-for="(a, ai) in templates" :key="ai" :value="a.id" :label="a.name">
                     <span style="float: left">{{ a.name }}</span>
                     <i class="el-icon-delete" style="float: right; color: #66b1ff; font-size: 16px"
                        @click.stop="handleDelete(a)"></i>
                  </el-option>
               </el-select>
               <el-button size="medium" @click="">
               <el-button size="medium" @click="templateDia=true" v-show="active==1">
                  <span style="color: #3A7BFA;">保存模板</span>
               </el-button>
               <el-button size="medium" type="primary" @click="save">提交</el-button>
               <el-button size="medium" type="primary" @click="save" :loading="saveLoad" v-show="active==1">提交</el-button>
          <!-- 审核 -->
               <el-button size="medium" @click="upInsOrderOfState(2)" :loading="saveLoad" v-show="active==3">不通过</el-button>
               <el-button size="medium" type="primary" @click="upInsOrderOfState(1)" :loading="saveLoad"
                  v-show="active==3">通过</el-button>
               <el-button size="medium" @click="$parent.playOrder(0)">
                  <span style="color: #3A7BFA;">返回</span>
               </el-button>
@@ -94,17 +126,11 @@
               </div>
            </el-col>
            <el-col class="search_thing" :span="6">
               <div class="search_label"><span class="required-span">* </span>样品编号:</div>
               <div class="search_input">
                  <el-input v-model="addObj.sampleCode" size="small" placeholder="请输入" clearable></el-input>
               </div>
            </el-col>
            <el-col class="search_thing" :span="6">
               <div class="search_label"><span class="required-span">* </span>下单客户:</div>
               <div class="search_input">
                  <el-input readonly size="small" v-model="addObj.custom">
                     <template slot="append"><el-button slot="append" icon="el-icon-search"
                           @click="selectUserDia = true"></el-button></template>
                           @click="selectUserDia = true" :disabled="active>1"></el-button></template>
                  </el-input>
               </div>
            </el-col>
@@ -115,16 +141,24 @@
               </div>
            </el-col>
            <el-col class="search_thing" :span="6">
               <div class="search_label"><span class="required-span">* </span>紧急程度:</div>
               <div class="search_input">
                  <el-select size="small" style="width: 100%;" clearable v-model="addObj.type" :disabled="active>1">
                     <el-option v-for="(a, ai) in type" :key="ai" :value="a.value" :label="a.label"></el-option>
                  </el-select>
               </div>
            </el-col>
            <el-col class="search_thing" :span="6">
               <div class="search_label"><span class="required-span">* </span>样品名称:</div>
               <div class="search_input">
                  <el-input readonly size="small" v-model="addObj.sample">
                     <template slot="append"><el-button slot="append" icon="el-icon-search"
                           @click="selectStandardTree = true"></el-button></template>
                           @click="selectStandardTree = true" :disabled="active>1"></el-button></template>
                  </el-input>
               </div>
            </el-col>
            <el-col class="search_thing" :span="6">
               <div class="search_label"><span class="required-span">* </span>实验室名称:</div>
               <div class="search_label"><span class="required-span">* </span>实验室:</div>
               <div class="search_input">
                  <el-input size="small" clearable disabled v-model="addObj.laboratory"></el-input>
               </div>
@@ -136,80 +170,104 @@
               </div>
            </el-col>
            <el-col class="search_thing" :span="6">
               <div class="search_label"><span class="required-span">* </span>规格型号:</div>
               <div class="search_input">
                  <el-input size="small" placeholder="请输入" clearable v-model="addObj.model"></el-input>
               </div>
            </el-col>
            <el-col class="search_thing" :span="6">
               <div class="search_label">约定时间:</div>
               <div class="search_input">
                  <el-date-picker type="date" placeholder="选择日期" size="small" value-format="yyyy-MM-dd" style="width: 100%;"
                     v-model="addObj.appointedTime"></el-date-picker>
               </div>
            </el-col>
            <el-col class="search_thing" :span="6">
               <div class="search_label"><span class="required-span">* </span>紧急程度:</div>
               <div class="search_input">
                  <el-select size="small" style="width: 100%;" clearable v-model="addObj.type">
                     <el-option v-for="(a, ai) in type" :key="ai" :value="a.value" :label="a.label"></el-option>
                  </el-select>
               </div>
            </el-col>
            <el-col class="search_thing" :span="6">
               <div class="search_label"><span class="required-span">* </span>样品数量:</div>
               <div class="search_input">
                  <el-input-number size="small" v-model="addObj.sampleNum" :controls="false" :min="0" :max="1000"
                     :precision="0" style="width: 50%;" @change="onSample"></el-input-number>
                  <el-input-number size="small" v-model="addObj.sampleNum" :min="1" :max="100" :precision="0"
                     style="width: 65%;" @change="addStandardTree" :readonly="active>1"></el-input-number>
               </div>
            </el-col>
            <el-col class="search_thing" :span="6">
               <div class="search_label">样品单位:</div>
               <div class="search_input">
                  <el-select v-model="addObj.unit" clearable size="small" style="width: 100%;" :disabled="active>1">
                     <el-option v-for="(a, i) in units" :key="i" :label="a.label" :value="a.value"></el-option>
                  </el-select>
               </div>
            </el-col>
            <el-col class="search_thing" :span="6">
               <div class="search_label">OTC订单号:</div>
               <div class="search_input">
                  <el-input size="small" placeholder="请输入" clearable v-model="addObj.otcCode"></el-input>
                  <el-input size="small" placeholder="请输入" clearable v-model="addObj.otcCode" :readonly="active>1"></el-input>
               </div>
            </el-col>
            <el-col class="search_thing" :span="6">
               <div class="search_label">样品留样:</div>
               <div class="search_input">
                  <el-radio-group v-model="addObj.isLeave" @change="addObj.leaveNum = null">
                     <el-radio :label="1">留样</el-radio>
                     <el-radio :label="0">不留样</el-radio>
               <div class="search_label" style="width: 175px;">是否涉及配套样品:</div>
               <div class="search_input" style="width: calc(100% - 175px);">
                  <el-radio-group v-model="addObj.mating" @change="$refs.sampleTable.doLayout()" :disabled="active>1">
                     <el-radio :label="1">是</el-radio>
                     <el-radio :label="0">否</el-radio>
                  </el-radio-group>
               </div>
            </el-col>
            <el-col class="search_thing" :span="6">
               <div class="search_label">留样数量:</div>
               <div class="search_input">
                  <el-input-number size="small" v-model="addObj.leaveNum" :controls="false" :min="0"
                     :disabled="addObj.isLeave == 0" style="width: 50%;"></el-input-number>
               </div>
            </el-col>
            <el-col class="search_thing" :span="6" style="align-items: flex-start;margin: 8px 0;">
               <div class="search_label">备注:</div>
               <div class="search_input">
                  <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 2}" size="small" clearable
                     v-model="addObj.remark"></el-input>
               </div>
            </el-col>
            <el-col class="search_thing" :span="6">
               <div class="search_label" style="width: 160px;">是否涉及配套样品:</div>
               <div class="search_input" style="width: calc(100% - 160px);">
                  <el-radio-group v-model="addObj.mating" @change="$refs.sampleTable.doLayout()">
                     <el-radio :label="1">是</el-radio>
                     <el-radio :label="0">否</el-radio>
                  </el-radio-group>
                     v-model="addObj.remark" :readonly="active>1"></el-input>
               </div>
            </el-col>
         </el-row>
      </div>
      <div style="display: flex;">
         <el-table class="el-table" ref="sampleTable" :data="sampleList" height="300px" tooltip-effect="dark" border
            @selection-change="selectSample">
            <el-table-column type="selection" width="60"></el-table-column>
      <div>
         <!-- <div style="text-align: right;line-height: 45px;" v-if="active<2">
            <el-button type="primary" size="small" @click="addSampleDia = true">添加样品</el-button>
            <el-button size="small" @click="delSample">
               <span style="color: #3A7BFA;">删除样品</span>
            </el-button>
         </div> -->
         <el-table class="el-table sampleTable" ref="sampleTable" :data="sampleList" height="250px" tooltip-effect="dark"
            border @selection-change="selectSample" highlight-current-row @row-click="rowClick" style="margin-top: 10px;" >
            <el-table-column type="selection" width="60" :selectable="selectable" v-if="active==1"></el-table-column>
            <el-table-column type="index" label="序号" width="65" align="center"></el-table-column>
            <el-table-column prop="sample" label="样品名称" align="center" show-overflow-tooltip
               min-width="100"></el-table-column>
            <el-table-column prop="sample" label="样品名称" align="center" min-width="100">
               <template slot-scope="scope">
                  <el-input size="small" v-model="scope.row.sample" clearable :readonly="active>1"></el-input>
               </template>
            </el-table-column>
            <el-table-column prop="sampleCode" label="样品编号" min-width="140" align="center">
               <template slot-scope="scope">
                  <el-input size="small" v-model="scope.row.sampleCode" clearable placeholder="不填写则系统自动生成" :readonly="active>1"></el-input>
               </template>
            </el-table-column>
            <!-- <el-table-column prop="factory" label="工厂" align="center" min-width="100">
            </el-table-column>
            <el-table-column prop="laboratory" label="实验室" align="center" min-width="100">
            </el-table-column>
            <el-table-column prop="sampleType" label="样品类型" align="center" min-width="100">
            </el-table-column> -->
            <el-table-column prop="model" label="样品型号" align="center" min-width="100">
               <template slot-scope="scope">
                  <el-select v-model="scope.row.model" filterable allow-create default-first-option placeholder="样品型号"
                     size="small" @change="handleChangeModel" :disabled="active>1">
                     <el-option v-for="item in models" :key="item.value" :label="item.label" :value="item.value">
                     </el-option>
                  </el-select>
               </template>
            </el-table-column>
            <el-table-column prop="standardMethodListId" label="检验标准" align="center" min-width="100">
               <template slot-scope="scope">
                  <el-select v-model="scope.row.standardMethodListId" :disabled="scope.row.model==null||active>1" placeholder="检验标准" size="small"
                     :loading="methodLoad" @change="(value)=>methodChange(value, scope.row)" @focus="methodFocus" :readonly="active>1">
                     <el-option v-for="item in methods" :key="item.id" :label="item.code" :value="item.id">
                     </el-option>
                  </el-select>
               </template>
            </el-table-column>
            <el-table-column prop="unit" label="单位" align="center" min-width="100">
               <template slot-scope="scope">
                  <el-select v-model="scope.row.unit" clearable size="small" style="width: 100%;" :disabled="active>1">
                     <el-option v-for="(a, i) in units" :key="i" :label="a.label" :value="a.value"></el-option>
                  </el-select>
               </template>
            </el-table-column>
            <el-table-column prop="isLeave" label="是否留样" align="center" min-width="100">
               <template slot-scope="scope">
                  <el-select v-model="scope.row.isLeave" size="small" :disabled="active>1">
                     <el-option label="留样" :value="1"></el-option>
                     <el-option label="不留样" :value="0"></el-option>
                  </el-select>
               </template>
            </el-table-column>
            <el-table-column prop="joinName" label="配套样品名称" width="140" align="center" v-if="addObj.mating==1">
               <template slot-scope="scope">
                  <el-input size="small" type="textarea" :autosize="{ minRows: 1, maxRows: 1}"
@@ -222,9 +280,42 @@
                     v-model="scope.row.joinModel"></el-input>
               </template>
            </el-table-column>
            <el-table-column label="操作" width="65" align="center">
            <el-table-column prop="joinNum" label="配套样品数量" width="140" align="center" v-if="addObj.mating==1">
               <template slot-scope="scope">
                  <el-button type="text" size="small" @click="">删除</el-button>
                  <el-input-number size="small" v-model="scope.row.joinNum" :min="1" :max="100" :precision="0"
                     :controls="false" style="width: 80%;"></el-input-number>
               </template>
            </el-table-column>
            <!-- <el-table-column label="操作" width="65" align="center">
               <template slot-scope="scope">
                  {{scope.index}}
                  <el-button type="text" size="small" @click="delSampleAndProduct" :disabled="active!=1">删除</el-button>
               </template>
            </el-table-column> -->
         </el-table>
         <el-table class="el-table" ref="productTable" :data="productList" height="380px" tooltip-effect="dark" border
            @selection-change="selectProduct" style="margin-bottom: 10px;" @select="upProductSelect"
            :row-class-name="tableRowClassName" v-loading="getProductLoad" @select-all="handleAll">
            <el-table-column type="selection" width="65" :selectable="selectable" v-if="active==1"></el-table-column>
            <el-table-column prop="inspectionItem" label="检验项" min-width="140" show-overflow-tooltip></el-table-column>
            <el-table-column prop="inspectionItemSubclass" label="检验项子项" min-width="140"
               show-overflow-tooltip></el-table-column>
            <el-table-column prop="sonLaboratory" label="子实验室" width="130" show-overflow-tooltip></el-table-column>
            <el-table-column prop="method" label="试验方法" min-width="120" show-overflow-tooltip>
          <template slot-scope="scope">
            <span>{{scope.row.method.replace('[','').replace(']','').replaceAll('"','')}}</span>
          </template>
        </el-table-column>
            <el-table-column prop="unit" label="计量单位" width="100" show-overflow-tooltip></el-table-column>
            <el-table-column prop="price" label="单价" width="100" show-overflow-tooltip></el-table-column>
            <el-table-column prop="manDay" label="预计时间(天)" width="120" show-overflow-tooltip></el-table-column>
            <el-table-column prop="manHourGroup" label="工时分组" width="100" show-overflow-tooltip></el-table-column>
            <!-- <el-table-column prop="deviceGroup" label="设备组" width="120" show-overflow-tooltip></el-table-column> -->
            <el-table-column prop="section" label="区间" width="120" show-overflow-tooltip></el-table-column>
            <el-table-column prop="ask" label="要求值" min-width="220px">
               <template slot-scope="scope">
                  <el-input size="small" placeholder="要求值" v-model="scope.row.ask" clearable type="textarea"
                     :autosize="{ minRows: 1, maxRows: 3}" @change="e=>requestChange(e,scope.row)"></el-input>
               </template>
            </el-table-column>
         </el-table>
@@ -266,6 +357,130 @@
            <el-button type="primary" @click="activeStandardTree">确 定</el-button>
         </span>
      </el-dialog>
      <el-dialog title="添加样品" :visible.sync="addSampleDia" width="400px">
         <div class="body" style="max-height: 60vh;">
            <el-row>
               <el-col class="search_thing" :span="22">
                  <div class="search_label"><span class="required-span">* </span>样品名称:</div>
                  <div class="search_input">
                     <el-input readonly size="small" v-model="sample.sample">
                        <template slot="append"><el-button slot="append" icon="el-icon-search"
                              @click="selectStandardTree = true"></el-button></template>
                     </el-input>
                  </div>
               </el-col>
               <el-col class="search_thing" :span="22">
                  <div class="search_label"><span class="required-span">* </span>工厂名称:</div>
                  <div class="search_input">
                     <el-input size="small" clearable disabled v-model="sample.factory"></el-input>
                  </div>
               </el-col>
               <el-col class="search_thing" :span="22">
                  <div class="search_label"><span class="required-span">* </span>实验室名称:</div>
                  <div class="search_input">
                     <el-input size="small" clearable disabled v-model="sample.laboratory"></el-input>
                  </div>
               </el-col>
               <el-col class="search_thing" :span="22">
                  <div class="search_label"><span class="required-span">* </span>样品类型:</div>
                  <div class="search_input">
                     <el-input size="small" clearable disabled v-model="sample.sampleType"></el-input>
                  </div>
               </el-col>
               <el-col class="search_thing" :span="22">
                  <div class="search_label"><span class="required-span">* </span>规格型号:</div>
                  <div class="search_input">
                     <el-input size="small" placeholder="请输入" clearable v-model="sample.model"></el-input>
                  </div>
               </el-col>
               <el-col class="search_thing" :span="22">
                  <div class="search_label">样品编号:</div>
                  <div class="search_input">
                     <el-input v-model="sample.sampleCode" size="small" placeholder="请输入" clearable></el-input>
                  </div>
               </el-col>
               <el-col class="search_thing" :span="24">
                  <div class="search_label">样品数量:</div>
                  <div class="search_input">
                     <el-input-number size="small" v-model="sample.sampleNum" :min="1" :max="100" :precision="0"
                        style="width: 50%;"></el-input-number>
                  </div>
               </el-col>
               <el-col class="search_thing" :span="22">
                  <div class="search_label">样品留样:</div>
                  <div class="search_input">
                     <el-radio-group v-model="sample.isLeave">
                        <el-radio :label="1">留样</el-radio>
                        <el-radio :label="0">不留样</el-radio>
                     </el-radio-group>
                  </div>
               </el-col>
            </el-row>
         </div>
         <span slot="footer" class="dialog-footer">
            <el-button @click="addSampleDia = false">取 消</el-button>
            <el-button type="primary" @click="onSample()" :loading="getProductLoad">确 定</el-button>
         </span>
      </el-dialog>
      <el-dialog title="保存模板" :visible.sync="templateDia" width="400px">
         <div class="body" style="display: flex;align-items: center;" v-if="templateDia">
            <div class="search_label" style="width: 90px;"><span class="required-span">* </span>模板名称:</div>
            <div class="search_input">
               <el-input size="small" clearable v-model="templateName"></el-input>
            </div>
         </div>
         <span slot="footer" class="dialog-footer">
            <el-button @click="templateDia = false">取 消</el-button>
            <el-button type="primary" @click="addTemplateDia" :loading="templateLoading">确 定</el-button>
         </span>
      </el-dialog>
      <el-dialog title="检验下发" :visible.sync="issuedDialogVisible" width="400px">
         <div class="body" style="max-height: 60vh;">
            <el-row>
               <el-col class="search_thing" :span="22">
                  <div class="search_label"><span class="required-span">* </span>约定时间:</div>
                  <div class="search_input">
                     <el-date-picker size="small" v-model="distributeData.appointed" type="date" placeholder="选择日期"
                        value-format="yyyy-MM-dd" style="width: 100%;" format="yyyy-MM-dd">
                     </el-date-picker>
                  </div>
               </el-col>
               <el-col class="search_thing" :span="22">
                  <div class="search_label"><span class="required-span" v-if="addObj.type == 2">* </span>指派人员:</div>
                  <div class="search_input">
                     <el-select v-model="distributeData.userId" placeholder="请选择" size="small" style="width: 100%;">
                        <el-option v-for="item in personList" :key="item.value" :label="item.label" :value="item.value">
                        </el-option>
                     </el-select>
                  </div>
               </el-col>
            </el-row>
         </div>
         <span slot="footer" class="dialog-footer">
            <el-row>
               <el-button @click="issuedDialogVisible=false">取 消</el-button>
               <el-button type="primary" @click="submitForm2" :loading="upLoad">确 定</el-button>
            </el-row>
         </span>
      </el-dialog>
    <el-dialog title="不通过原因" :visible.sync="noDialogVisible" width="400px">
         <div class="body" style="max-height: 60vh;">
            <el-row>
               <el-col class="search_thing" :span="22">
                  <div class="search_label"><span class="required-span">* </span>不通过原因:</div>
                  <div class="search_input">
                     <el-input v-model="tell" size="small" placeholder="请输入不通过原因"></el-input>
                  </div>
               </el-col>
            </el-row>
         </div>
         <span slot="footer" class="dialog-footer">
            <el-row>
               <el-button @click="noDialogVisible=false,tell=''">取 消</el-button>
               <el-button type="primary" @click="submitTell" :loading="noLoading">确 定</el-button>
            </el-row>
         </span>
      </el-dialog>
   </div>
</template>
@@ -275,30 +490,50 @@
      components: {
         ValueTable
      },
      props: {
         active: {
            type: Number,
            default: () => 0
         },
         currentId: {
            type: Number,
            default: () => 0
         }
      },
      data() {
         return {
            template: null,
            templates: [],
            addObj: {
               entrustCode: null,
               sampleCode: null,
               custom: null,
               company: null,
               userId: null,
               type: '0',
               code: null,
               laboratory: null,
               appointedTime: null,
               factory: null,
               sample: null,
               sampleType: null,
               sampleNum: null,
               model: null,
               isLeave: 0,
               leaveNum: null,
               appointed: null,
               remark: null,
               otcCode: null,
               mating: 0
               mating: 0,
               sample: null,
               factory: null,
               laboratory: null,
               sampleType: null,
               sampleNum: 1,
               unit: null,
               model: null,
               method: null
            },
            sample: {
               sampleCode: null,
               laboratory: null,
               factory: null,
               sampleType: null,
               sample: null,
               model: null,
               sampleNum: 1,
               isLeave: 0,
               unit: null
            },
            type: [],
            selectUserDia: false,
@@ -335,15 +570,77 @@
            expandedKeys: [],
            sampleList: [],
            sampleIds: [],
            methodList: []
            methodList: [],
            addSampleDia: false,
            count: 1,
            productList: [],
            productIds: [],
            getProductLoad: false,
            saveLoad: false,
            templateDia: false,
            templateLoading: false,
            templateName: '',
            issuedDialogVisible: false,
            distributeData: {
               appointed: '',
               userId: ''
            },
            personList: [],
            upLoad: false,
            units: [],
            models: [],
            methods: [],
            methodLoad: false,
        noDialogVisible:false,
        tell:'',
        noLoading:false
         }
      },
      watch: {
         sampleList() {
            this.addObj.method = null
            this.productList = []
         }
      },
      mounted() {
         this.selectEnumByCategoryForType()
         this.getUserNow()
         this.selectStandardTreeList()
         this.selectInsOrderTemplate()
         this.getAuthorizedPerson();
         this.selectEnumByCategoryForUnit()
         this.selectStandardMethods()
         if (this.active != 1) {
            // 查看/审核流程
            // 请求接口,回显数据
            this.$axios.post(this.$api.insOrder.getInsOrder, {
               orderId: this.currentId
            }).then(res => {
               this.addObj = {
                  ...res.data.insOrder
               };
               this.addObj.type = String(this.addObj.type)
               this.sampleList = this.HaveJson(res.data.sampleProduct);
               this.addObj.sampleNum = this.sampleList.length
               this.$nextTick(() => {
                  this.$refs.sampleTable.doLayout()
               })
            })
         }
      },
      methods: {
         getAuthorizedPerson() {
            this.$axios.get(this.$api.user.getUserMenu).then(res => {
               let data = []
               res.data.forEach(a => {
                  data.push({
                     label: a.name,
                     value: a.id
                  })
               })
               this.personList = data
            })
         },
         selectEnumByCategoryForType() {
            this.$axios.post(this.$api.enums.selectEnumByCategory, {
               category: "紧急程度"
@@ -367,7 +664,106 @@
            this.selectUserDia = false
         },
         save() {
            console.log(this.addObj);
            if (!this.addObj.custom) {
               this.$message.error('未选择下单客户')
          return
            }
        if (!this.addObj.type) {
               this.$message.error('未选择紧急程度')
            } else if (this.sampleList.length < 1) {
               this.$message.error('请添加一个样品')
            } else if (!this.sampleList.every(m => m.sample)) {
               this.$message.error('请输入样品名称')
            } else if (!this.sampleList.every(m => m.model)) {
               this.$message.error('请输入样品型号')
            } else if (!this.sampleList.every(m => m.standardMethodListId)) {
               this.$message.error('请选择检验标准')
            } else if (!this.sampleList.every(m => m.unit)) {
               this.$message.error('请输入样品的单位')
            } else {
               this.saveLoad = true
               this.$axios.post(this.$api.insOrder.addInsOrder, {
                  insOrder: this.addObj,
                  list: this.sampleList
               }, {
                  headers: {
                     'Content-Type': 'application/json'
                  }
               }).then(res => {
                  this.saveLoad = false
                  if (res.code == 201) return
                  this.$message.success('已提交')
                  this.$parent.playOrder(0)
               })
            }
         },
         upInsOrderOfState(state) {
        if(state == 1){
          this.saveLoad = true
          this.$axios.post(this.$api.insOrder.upInsOrderOfState, {
            state,
            id: this.currentId
          }, {
            headers: {
              'Content-Type': 'application/json'
            }
          }).then(res => {
            this.saveLoad = false
            if (res.code == 201) return
            this.$message.success('提交成功')
            // 如果紧急程度为紧急,需要直接下发人员
            // if (this.addObj.type == 2) {
            //    this.issuedDialogVisible = true;
            //    this.$axios.post(this.$api.insOrder.selectOrderManDay, {
            //       id: this.currentId
            //    }).then(ress => {
            //       this.distributeData.orderId = this.currentId
            //       this.distributeData.appointed = ress.data
            //    })
            // } else {
            //    this.$parent.playOrder(0)
            // }
            this.issuedDialogVisible = true;
            this.$axios.post(this.$api.insOrder.selectOrderManDay, {
              id: this.currentId
            }).then(ress => {
              this.distributeData.orderId = this.currentId
              this.distributeData.appointed = ress.data
            })
          })
        }else{
          // 不通过
          this.noDialogVisible = true
        }
         },
         // 下发
         submitForm2() {
            if (this.distributeData.appointed == null || this.distributeData.appointed == '') {
               this.$message.error('约定时间未填写')
               return
            }
            if (this.addObj.type == 2&&(this.distributeData.userId == null || this.distributeData.userId == '')) {
               this.$message.error('指派人员未填写')
               return
            }
            this.upLoad = true;
            this.$axios.post(this.$api.insOrder.upInsOrder, {
               orderId: this.distributeData.orderId,
               appointed: this.distributeData.appointed,
               userId: this.distributeData.userId
            }).then(res => {
               if (res.code === 201) {
                  this.upLoad = false
                  return
               }
               this.$message.success('提交成功')
               this.upLoad = false
               this.issuedDialogVisible = false
               this.$parent.playOrder(0)
            }).catch(e => {
               this.$message.error('提交失败')
               this.upLoad = false
            })
         },
         getUserNow() {
            this.$axios.get(this.$api.user.getUserNow).then(res => {
@@ -390,6 +786,7 @@
         },
         handleNodeClick(val, node, el) { //树的值
            this.selectTree = ''
            this.models = val.children
            this.getNodeParent(node)
            this.selectTree = this.selectTree.replace(' - ', '')
            let data = this.selectTree.split(' - ')
@@ -429,27 +826,365 @@
            this.addObj.laboratory = trees[1]
            this.addObj.sampleType = trees[2]
            this.addObj.sample = trees[3]
            this.addObj.model = trees[4]
            this.addObj.model = (trees[4] == undefined ? null : trees[4])
            this.selectStandardTree = false
            this.onSample()
            this.sampleList = []
            for (var i = 0; i < this.addObj.sampleNum; i++) {
               this.sample.joinName = null
               this.sample.joinModel = null
               this.sample.joinNum = 1
               this.sample.sample = this.addObj.sample
               this.sample.model = this.addObj.model
               this.sample.unit = this.addObj.unit
               this.sample.standardMethodListId = null
               this.sample.insProduct = []
               this.sample.id = this.count
               this.sampleList.push(this.HaveJson(this.sample))
               this.count++
            }
            this.$refs.sampleTable.doLayout()
            // this.selectsStandardMethodByFLSSM()
         },
         selectsStandardMethodByFLSSM() {
            this.methodLoad = true
            this.$axios.post(this.$api.standardTree.selectsStandardMethodByFLSSM, {
               tree: this.selectTree
            }).then(res => {
               this.methodLoad = false
               try {
                  if (res.data.standardMethodList.length == 0 && this.selectTree.split('-').length == 5) {
                     let arr = this.selectTree.split('-')
                     let arr0 = arr.slice(0, arr.length - 1)
                     let selectTree = arr0.join('-').substring(0, arr0.join('-').length - 1)
                     this.$axios.post(this.$api.standardTree.selectsStandardMethodByFLSSM, {
                        tree: selectTree
                     }).then(ress => {
                        this.methods = ress.data.standardMethodList
                     })
                  } else {
                     this.methods = res.data.standardMethodList
                  }
               } catch (e) {}
            })
         },
         addStandardTree() {
            if (this.selectTree == null) return
            this.sampleList = []
            for (var i = 0; i < this.addObj.sampleNum; i++) {
               this.sample.joinName = null
               this.sample.joinModel = null
               this.sample.joinNum = 1
               this.sample.sample = this.addObj.sample
               this.sample.model = this.addObj.model
               this.sample.unit = this.addObj.unit
               this.sample.standardMethodListId = null
               this.sample.insProduct = []
               this.sample.id = this.count
               this.sampleList.push(this.HaveJson(this.sample))
               this.count++
            }
         },
         selectSample(val) {
            this.sampleIds = []
            val.forEach(a => {
               this.sampleIds = a.id
               this.sampleIds.push(a.id)
            })
         },
         onSample() {
            this.sampleList = []
            if (this.addObj.sampleNum == 0 || this.addObj.sample == null || this.addObj.sample == '') return
            for (var i = 0; i < this.addObj.sampleNum; i++) {
               this.sampleList.push({
                  sample: this.addObj.sample,
                  joinName: null,
                  joinModel: null
               })
            if (this.sample.sample == null || this.sample.sample == '') {
               this.$message.error('请选择样品')
               return
            }
            if (this.sample.model == null || this.sample.model == '') {
               this.$message.error('请输入样品型号')
               return
            }
            // this.getProductLoad = true
            /* this.$axios.post(this.$api.standardTree.selectStandardProductList, {
               factory: this.sample.factory,
               laboratory: this.sample.laboratory,
               sampleType: this.sample.sampleType,
               sample: this.sample.sample,
               model: this.sample.model
            }, {
               headers: {
                  'Content-Type': 'application/json'
               }
            }).then(res => {
               res.data.forEach(a => {
                  a.state = 1
               })
               for (var i = 0; i < this.sample.sampleNum; i++) {
                  this.sample.joinName = null
                  this.sample.joinModel = null
                  this.sample.joinNum = 1
                  this.sample.insProduct = res.data
                  this.sample.id = this.count
                  this.sampleList.push(this.HaveJson(this.sample))
                  this.count++
               }
               this.$refs.sampleTable.doLayout()
               this.getProductLoad = false
               this.addSampleDia = false
               this.sample = {
                  sampleCode: null,
                  laboratory: null,
                  factory: null,
                  sampleType: null,
                  sample: null,
                  model: null,
                  sampleNum: 1,
                  isLeave: 0,
               }
            }) */
         },
         delSample() {
            this.sampleIds.forEach(a => {
               for (var i = 0; i < this.sampleList.length; i++) {
                  if (this.sampleList[i].id == a) {
                     this.sampleList.splice(i, 1)
                     i -= 1
                     break
                  }
               }
            })
            this.$refs.sampleTable.doLayout()
         }
         },
         selectProduct(val) {
            this.productIds = []
            val.forEach(a => {
               this.productIds.push(a.id)
            })
         },
         rowClick(row, column, event) {
            this.productList = row.insProduct
            setTimeout(() => {
               this.productList.forEach(a => {
                  if (a.state == 1) this.toggleSelection(a)
               })
            }, 200)
         },
         toggleSelection(row) {
            this.$refs.productTable.toggleRowSelection(row, true);
         },
         upProductSelect(selection, row) {
            row.state = row.state == 1 ? 0 : 1
            this.sampleList.map(item => {
               if (this.sampleIds.indexOf(item.id) > -1) {
                  item.insProduct.map(m => {
                     if (m.id == row.id) {
                        m.state = row.state;
                     }
                     return m;
                  })
               }
               return item
            })
         },
         tableRowClassName({
            row,
            rowIndex
         }) {
            if (row.state === 0) {
               return 'warning-row';
            }
            return '';
         },
         selectInsOrderTemplate() {
            this.$axios.get(this.$api.insOrder.selectInsOrderTemplate).then(res => {
               if (res.code == 201) return
               this.templates = res.data
            })
         },
         // 删除模板--调用接口
         handleDelete(row) {
            this.$confirm('是否删除当前数据?', "警告", {
               confirmButtonText: "确定",
               cancelButtonText: "取消",
               type: "warning"
            }).then(() => {
               this.$axios.post(this.$api.insOrder.delInsOrderTemplate, {
                  id: row.id
               }).then(res => {
                  if (res.code === 201) {
                     return
                  }
                  this.$message.success('删除成功')
                  this.selectInsOrderTemplate()
               }).catch(e => {
                  this.$message.error('删除失败')
               })
            }).catch(() => {})
         },
         // 保存模板
         addTemplateDia() {
            if (this.templateName) {
               this.templateLoading = true;
               this.$axios.post(this.$api.insOrder.addInsOrderTemplate, {
                  name: this.templateName,
                  thing: JSON.stringify({
                     addObj: this.addObj,
                     sampleList: this.sampleList
                  })
               }, {
                  headers: {
                     'Content-Type': 'application/json'
                  }
               }).then(res => {
                  if (res.code == 201) return
                  this.templateLoading = false;
                  this.templateDia = false;
                  this.$message.success('保存成功')
                  this.selectInsOrderTemplate()
                  this.templateName = ''
               })
            } else {
               this.$message.error('请填写模板名称')
            }
         },
         // 查询模板
         selectInsOrderTemplateById(e) {
            this.$axios.post(this.$api.insOrder.selectInsOrderTemplateById + '?id=' + e).then(res => {
               if (res.code == 201) return
               let obj = JSON.parse(res.data)
               this.addObj = obj.addObj;
               this.sampleList = obj.sampleList;
            })
         },
         delSampleAndProduct() {
            this.sampleList.splice(scope.$index, 1)
            this.productList = []
         },
         selectEnumByCategoryForUnit() {
            this.$axios.post(this.$api.enums.selectEnumByCategory, {
               category: "单位"
            }).then(res => {
               this.units = res.data
            })
         },
         methodChange(val, row) {
            this.getProductLoad = true
            this.$axios.post(this.$api.standardTree.selectStandardProductList, {
               model: this.addObj.model,
               standardMethodListId: val
            }, {
               headers: {
                  'Content-Type': 'application/json'
               }
            }).then(res => {
               res.data.forEach(a => {
                  a.state = 1
               })
               row.insProduct = this.HaveJson(res.data)
               this.getProductLoad = false
               this.productList = row.insProduct
               this.$refs.sampleTable.setCurrentRow(row)
               setTimeout(() => {
                  this.productList.forEach(a => {
                     if (a.state == 1) this.toggleSelection(a)
                  })
               }, 200)
            })
         },
         methodFocus() {
            this.selectsStandardMethodByFLSSM()
         },
         handleChangeModel(e) {
            let num = this.selectTree.split('-').length;
            if (num == 4) {
               this.selectTree = this.selectTree + ' - ' + e
            } else {
               let arr = this.selectTree.split('-')
               let arr0 = arr.slice(0, arr.length - 1)
               this.selectTree = arr0.join('-') + '- ' + e
            }
         },
         // 要求值变化时
         requestChange(e, row) {
            this.sampleList.map(item => {
               if (this.sampleIds.indexOf(item.id) > -1) {
                  item.insProduct.map(m => {
                     if (m.id == row.id) {
                        m.ask = e;
                     }
                     return m;
                  })
               }
               return item
            })
         },
         selectStandardMethods() {
            this.$axios.get(this.$api.standardTree.selectStandardMethodEnum).then(res => {
               this.methods = res.data
            })
         },
      selectable(){
        if(this.active>1){
          return false
        }else{
          return true
        }
      },
      handleAll(e){
        if(e.length>0){
          this.productList.map(m=>{
            m.state = 1
            return m
          })
        }else{
          this.productList.map(m=>{
            m.state = 0
            return m
          })
        }
        if(e.length>0){
          this.sampleList.map(item => {
            if (this.sampleIds.indexOf(item.id) > -1) {
              item.insProduct.map(m => {
                m.state = 1
                return m;
              })
            }
            return item
          })
        }else{
          this.sampleList.map(item => {
            if (this.sampleIds.indexOf(item.id) > -1) {
              item.insProduct.map(m => {
                m.state = 0
                return m;
              })
            }
            return item
          })
        }
        this.$nextTick(()=>{
          this.$refs.productTable.doLayout()
        })
      },
      submitTell(){
        if (!this.tell) {
               this.$message.error('请输入不通过原因')
          return
            }
        this.noLoading = true;
        this.$axios.post(this.$api.insOrder.upInsOrderOfState, {
            state:2,
            id: this.currentId,
            tell:this.tell
          }, {
            headers: {
              'Content-Type': 'application/json'
            }
          }).then(res => {
            this.noLoading = false;
            this.tell = '';
            if (res.code == 201) return
            this.$message.success('提交成功')
            this.issuedDialogVisible = false;
            this.$parent.playOrder(0)
          })
      }
      }
   }
</script>