<!-- 样品接收确认 -->
<template>
  <div class="sample-scan">
    <!-- 扫码接收的输入框-->
        <el-input
          v-model="facilityId"
          ref="redarInput"
          @change="facilityData(facilityId)"
          style="z-index: -999;"
          ></el-input>
         <!-- <el-button type="primary" @click="openRedar" >
            測試</el-button> -->
         <!-- 扫码操作组件-->
           <div class="popContainer" v-if="redar" @click="remRedar">
                <dv-decoration-12 style="width:150px;height:150px;margin:0 auto;top: 35%;">
                 <span style=" color: #66D9EF;">开启扫描设备连接-样品接收确认</span>
                </dv-decoration-12>
           </div>
              <el-dialog
               width="90%"
               :modal-append-to-body='false'
               title="样品扫码接收确认操作 - 扫码样品标签并确认样品数量、存放位置-位置根据是否留样二选一进行选择 (如果扫描无结果,请点击除标题外的空白处,恢复扫码功能)"
               @close="closeDialog"
               :before-close = "handleClose"
               :visible.sync="visible"> <!-- 表单是否显示 -->
                   <div style="min-height: 600px;"  @click.self="handleChange">
                     <el-button @click="submitData('确认')" type="primary" style="float: right;margin: 5px;">样品确认</el-button>
                     <!--<el-button @click="submitData('入库确认')" type="primary" style="float: right;margin: 5px;">入库确认</el-button>-->
                        <el-table
                           :data="listData"
                           stripe
                           style="width: 100%">

                         <el-table-column
                             prop="yang_pin_bian_hao"
                             label="样品编号"
                             width="150px">
                            </el-table-column>
                         
                           <el-table-column
                             prop="yang_pin_ming_che"
                             label="样品名称">
                           </el-table-column>
                         
                           <el-table-column
                             prop="yang_pin_zong_shu"
                             label="样品总数"
                             width="180px">
                           </el-table-column>
                         
                           <el-table-column
                             label="本次确认数量"
                             width="150px">
                                 <template slot-scope="scope">
                                     <el-input-number
                                      v-model="scope.row.jie_yang_shu_lian"
                                      controls-position="right"
                                      @change="handleChange"
                                      :min="1" :max="9999">
                                      </el-input-number>
                                  </template>
                           </el-table-column>
                         
                         
                         
                         
                          <el-table-column
                            prop="yang_pin_lei_xing"
                            label="样品类型(一)"
                            width="150px">
                           </el-table-column>
                         
                          <el-table-column
                            prop="yang_ben_yun_shu_"
                            label="样品运输条件(一)"
                            width="150px">
                           </el-table-column>
                         
                          <el-table-column
                            prop="shu_liang_"
                            label="样品数量(一)"
                            width="150px">
                           </el-table-column>
                         
                          <el-table-column
                            prop="yang_pin_gui_ge_"
                            label="样品规格(一)"
                            width="150px">
                           </el-table-column>
                         
                         
                           <el-table-column
                             prop="yang_pin_lei_er_"
                             label="样品类型(二)"
                             width="150px">
                            </el-table-column>
                         
                           <el-table-column
                             prop="yang_pin_yun_shu_"
                             label="样品运输条件(二)"
                             width="150px">
                            </el-table-column>
                         
                           <el-table-column
                             prop="shu_liang_er_"
                             label="样品数量(二)"
                             width="150px">
                            </el-table-column>
                         
                           <el-table-column
                             prop="yang_pin_gui_ge_e"
                             label="样品规格(二)"
                             width="150px">
                            </el-table-column>
                         
                         
                           <el-table-column
                             prop="yang_pin_lei_san_"
                             label="样品类型(三)"
                             width="150px">
                            </el-table-column>
                         
                           <el-table-column
                             prop="yang_pin_yun_san"
                             label="样品运输条件(三)"
                             width="150px">
                            </el-table-column>
                         
                           <el-table-column
                             prop="shu_liang_san_"
                             label="样品数量(三)"
                             width="150px">
                            </el-table-column>
                         
                           <el-table-column
                             prop="yang_pin_gui_ge_s"
                             label="样品规格(三)"
                             width="150px">
                            </el-table-column>
                         
                          <el-table-column
                            prop="yang_pin_lei_si_"
                            label="样品类型(四)"
                            width="150px">
                           </el-table-column>
                         
                          <el-table-column
                            prop="yang_pin_yun_si_"
                            label="样品运输条件(四)"
                            width="150px">
                           </el-table-column>
                         
                          <el-table-column
                            prop="shu_liang_si_"
                            label="样品数量(四)"
                            width="150px">
                           </el-table-column>
                         
                          <el-table-column
                            prop="yang_pin_gui_si_"
                            label="样品规格(四)"
                            width="150px">
                           </el-table-column>
                         
                           <el-table-column
                             label="是否留样"
                             width="120px">
                             <template slot-scope="scope">
                                 <el-select v-model="scope.row.shi_fou_liu_yang_" placeholder="请选择">
                                   <el-option
                                     v-for="item in ifLY"
                                     :key="item.value"
                                     :label="item.label"
                                     :value="item.value">
                                   </el-option>
                                 </el-select>
                              </template>
                           </el-table-column>
                         
                           <el-table-column
                             label="样品存放位置"
                             width="200px"
                             >
                              <template slot-scope="scope">
                                <!-- <ibps-link-data
                                  v-model="scope.row.shou_yang_wei_zhi"
                                  template-key = "lhypwzztzly"
                                /> -->
                                <weizhiData  v-model="scope.row.shou_yang_wei_zhi"/>
                               </template>
                           </el-table-column>
                         
                           <el-table-column
                             label="留样存放位置"
                             width="200px">
                              <template slot-scope="scope">
                               <!-- <ibps-link-data
                                  v-model="scope.row.liu_yang_wei_zhi_"
                                  template-key = "lhypwzztzly"
                                /> -->
                                <liuyangData v-model="scope.row.liu_yang_wei_zhi_"/>
                               </template>
                         
                           </el-table-column>
                         
                         
                          <el-table-column
                            label="验收结果"
                            width="120px">
                            <template slot-scope="scope">
                                <el-select v-model="scope.row.yan_shou_jie_guo_" placeholder="请选择">
                                  <el-option
                                    v-for="item in checkOptions"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                  </el-option>
                                </el-select>
                             </template>
                          </el-table-column>
                         
                          <el-table-column
                            label="留样日期"
                            width="230px">
                            <template slot-scope="scope">
                              <el-date-picker
                                v-model="scope.row.liu_yang_ri_qi_"
                                type="date"
                                value-format="yyyy-MM-dd"
                                format="yyyy-MM-dd"
                                placeholder="请选择"
                                :readonly="false"
                                :clearable="true"
                              />
                            </template>
                          </el-table-column>
                         
                          <el-table-column
                            label="留样数量"
                            width="150px">
                            <template slot-scope="scope">
                                <el-input-number
                                 v-model="scope.row.liu_yang_shu_lian"
                                  controls-position="right"
                                  @change="handleChange"
                                  :min="1" :max="9999">
                                 </el-input-number>
                             </template>
                         
                          </el-table-column>
                         
                         
                          <el-table-column
                            label="留样期限至"
                            width="230px">
                            <template slot-scope="scope">
                              <el-date-picker
                                v-model="scope.row.liu_yang_qi_xian"
                                type="date"
                                value-format="yyyy-MM-dd"
                                format="yyyy-MM-dd"
                                placeholder="请选择"
                                :readonly="false"
                                :clearable="true"
                              />
                            </template>
                          </el-table-column>
                         
                         
                          <el-table-column
                            label="销毁日期"
                            width="230">
                            <template slot-scope="scope">
                              <el-date-picker
                                v-model="scope.row.xiao_hui_ri_qi_"
                                type="date"
                                value-format="yyyy-MM-dd"
                                format="yyyy-MM-dd"
                                placeholder="请选择"
                                :readonly="false"
                                :clearable="true"
                              />
                            </template>
                          </el-table-column>
                         
                          <el-table-column
                            label="返样日期"
                            width="230px">
                            <template slot-scope="scope">
                              <el-date-picker
                                v-model="scope.row.fan_yang_ri_qi_"
                                type="date"
                                value-format="yyyy-MM-dd"
                                format="yyyy-MM-dd"
                                placeholder="请选择"
                                :readonly="false"
                                :clearable="true"
                              />
                            </template>
                          </el-table-column>
                         
                         
                          <el-table-column
                            label="返样接样人"
                            width="150px">
                            <template slot-scope="scope">
                              <el-input
                                    v-model="scope.row.fan_yang_jyr"
                                    placeholder="请输入"
                                    type="text"
                                    :readonly="false"
                                    clearable
                                  />
                            </template>
                          </el-table-column>
                         
                         
                          <el-table-column
                            label="姓名"
                            width="150px">
                            <template slot-scope="scope">
                              <el-input
                                    v-model="scope.row.xing_ming_"
                                    placeholder="请输入"
                                    type="text"
                                    :readonly="false"
                                    clearable
                                  />
                            </template>
                          </el-table-column>
                         
                          <el-table-column
                            label="性别"
                            width="150px">
                              <template slot-scope="scope">
                                  <el-select v-model="scope.row.xing_bie_" placeholder="请选择">
                                    <el-option
                                      v-for="item in sex"
                                      :key="item.value"
                                      :label="item.label"
                                      :value="item.value">
                                    </el-option>
                                  </el-select>
                               </template>
                          </el-table-column>
                         
                          <el-table-column
                            label="年龄"
                            width="130px">
                            <template slot-scope="scope">
                              <el-input
                                    v-model="scope.row.nian_ling_"
                                    placeholder="请输入"
                                    type="text"
                                    :readonly="false"
                                    clearable
                                  />
                            </template>
                          </el-table-column>
                         
                         
                         <!-- <el-table-column
                            label="报告编制员"
                            width="130px">
                             <template slot-scope="scope">
                                <ibps-user-selector
                                  v-model="scope.row.bao_gao_bian_zhi_"
                                  placeholder="请选择"
                                  type="user"
                                  store="id"
                                />
                             </template>
                          </el-table-column>
                         
                          <el-table-column
                            label="报告复核员"
                            width="130px">
                             <template slot-scope="scope">
                              <ibps-user-selector
                                v-model="scope.row.bao_gao_shen_he_y"
                                placeholder="请选择"
                                type="user"
                                store="id"
                              />
                              </template>
                          </el-table-column> -->
                         
                         
                          <el-table-column
                            label="备注"
                            width="180px">
                            <template slot-scope="scope">
                              <el-input
                                    v-model="scope.row.bei_zhu_"
                                    placeholder="请输入"
                                    type="text"
                                    :readonly="false"
                                    clearable
                                  />
                            </template>
                          </el-table-column>
                                              

                        
                          <el-table-column
                          label="送样要求"
                          width="180px">
                          <template slot-scope="scope">
                            <el-input
                                  v-model="scope.row.song_yang_yao_qiu"
                                  placeholder="请输入"
                                  type="text"
                                  :readonly="false"
                                  clearable
                                />
                          </template>
                        </el-table-column> 

                           
                           <el-table-column
                             label="接样确认状态"
                             width="130px">
                              <template slot-scope="scope">
                                  <el-select v-model="scope.row.jie_yang_zhuang_t" placeholder="请选择">
                                    <el-option
                                      v-for="item in options"
                                      :key="item.value"
                                      :label="item.label"
                                      :value="item.value">
                                    </el-option>
                                  </el-select>
                         
                               </template>
                         
                           </el-table-column>

                         <el-table-column label="功能">
                                 <template slot-scope="scope">
                                     <el-button
                                       size="small"
                                       type="danger"
                                       icon="el-icon-delete"
                                       @click="deleteData(scope.row.id_)"
                                     >删除</el-button>
                                 </template>
                               </el-table-column>


                       </el-table>
                       <!-- <el-pagination
                         layout="prev,pager,next"
                         background
                         @current-change="current_change"
                         :current-page="currentPage"
                         :pager-count="5"
                         :page-size="10"
                         :total="this.pageCount"
                       ></el-pagination> -->
                   </div>
             </el-dialog>

  </div>
</template>


<script>
import sampleConfirmationJS from '../js/sampleConfirmationJS.js'
import IbpsLinkData from '@/business/platform/data/templaterender/link-data'
import weizhiData from "./weizhiData.vue"
import liuyangData from "./liuyangData.vue"
// import IbpsUserSelector from '@/business/platform/org/selector'
 export default {
   components:{
     IbpsLinkData,
     weizhiData,
     liuyangData,
    //  IbpsUserSelector
   },
   mixins:[sampleConfirmationJS],
   props:{scanVisible:Boolean},
   watch:{
    listData: {
           handler(val, oldName) {
            if(val.length>0){
              this.visible = true
              this.redar = false    // 扫描后就让扫描组件隐藏
            }
         },
         deep: true,
         immediate: true
         },
     scanVisible:{
       handler(val, oldName) {
          if(val){
            this.redar = true       // 扫码的组件  一开始先展示
            this.visible = false    // 结果列表   一开始没扫描就不展示
            this.$nextTick(() => {
                this.$refs.redarInput.focus(); //聚焦input
              })
            this.listData = [] //清空列表
          }else{
            this.remRedar()
          }
       },
       deep: true,
       immediate: true
     }
   },
  data () {
    return {
     updateNum:1,
     visible:false,
     redar:false,
     facilityId:'',
     listData:[],
     options: [{
               value: '已确认',
               label: '已确认'
             }, {
               value: '未确认',
               label: '未确认'
             }],
      OriginalPosition:[],
      mjwtsqbAllResult:[],
      checkOptions:[{
            value:'完好',
            label:'完好'
          },{
            value:'残缺',
            label:'残缺'
          }],
      ifLY:[{
          value:'是',
          label:'是'
        },{
          value:'否',
          label:'否'
        }],
        sex:[{
          value:'男',
          label:'男'
        },{
          value:'女',
          label:'女'
        }],
      // OriginalPosition:[],
      pageCount:'',
      item:''
      // currentPage:1,
      // pageCount:''

    }
  },
  // methods:{
  //   current_change(currentPage){
  //     this.currentPage = currentPage
  //     this.facilityData(currentPage)
  //   }
  // }
  }
</script>

<style>
 .sample-scan .popContainer{
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 9999999;
      background: rgba(0,0,0,0.7);
  }
</style>
