<template>
<div>
  <el-card>
    <el-table :data="sysList" style="width: 100%;   margin-bottom: 8px" key="2" border>
      <el-table-column label="序号" type="index"></el-table-column>
      <el-table-column label="系统名称" prop="sysName" show-overflow-tooltip></el-table-column>
      <el-table-column label="产品编码" prop="thirdId" show-overflow-tooltip></el-table-column>
      <el-table-column label="产品名称" prop="thirdName" show-overflow-tooltip></el-table-column>
      <el-table-column label="规格型号" prop="spec" show-overflow-tooltip></el-table-column>
      <el-table-column label="注册/备案凭证号" prop="registerNo" show-overflow-tooltip></el-table-column>
      <el-table-column label="生产厂家" prop="manufactory" show-overflow-tooltip></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="text" @click="addSelectErp(scope.row)" :disabled="scope.row.thirdId==editQuery.nameCode">关联</el-button>
          <el-button type="text" @click.native.stop="removeErp(scope.row)" :disabled="editQuery.flbm==null || scope.row.thirdId==null || scope.row.thirdId==''">解绑
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-card>
  <el-card>
    <div style=" float: left;
                        text-align: left;
                        font-weight: bold;
                        margin-bottom: 8px">
      <span>产品标识:</span>
    </div>
    <div style=" float: right;
                        text-align: right;
                        margin-bottom: 8px;">
      <el-button type="primary" size="mini" icon="search" @click="removeDi" v-if="productType!=1" style="text-align:right">解绑DI器械信息
      </el-button>
    </div>
    <el-table v-loading="loading" :data="detailList" style="width: 100%; " border key="3" highlight-current-row @current-change="handleDetail">
      <el-table-column label="产品标识" prop="nameCode" show-overflow-tooltip></el-table-column>
      <el-table-column label="产品通用名" prop="cpmctymc" show-overflow-tooltip></el-table-column>
      <el-table-column label="包装级别" prop="packLevel" show-overflow-tooltip></el-table-column>
      <el-table-column label="包装层级" prop="bzcj" show-overflow-tooltip></el-table-column>
<!--      <el-table-column label="操作" width="180px">-->
<!--        <template slot-scope="scope">-->
<!--          <el-button type="text" @click.native.stop="singleDiEdit">编辑</el-button>-->
<!--        </template>-->
<!--      </el-table-column>-->
    </el-table>
  </el-card>
  <el-card>
    <el-form :model="editQuery" :rules="rules" ref="editQuery" border label-width="140px" style="margin-top: 20px;  ">
      <el-collapse v-model="activeNames">
        <el-collapse-item name="1">
          <template slot="title">
            <p class="form-title">产品属性</p>
          </template>

          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>产品是否禁用:&nbsp;</span>
                </div>
                <el-select v-model="editQuery.isDisable" disabled style="width: 65%" size="small">
                  <el-option label="是" :value="true"></el-option>
                  <el-option label="否" :value="false"></el-option>
                  <el-option label="否" :value="null"></el-option>
                </el-select>
              </div>
            </el-col>
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>是否寄售:&nbsp;</span>
                </div>
                <el-select v-model="editQuery.isAdavence" disabled style="width: 65%" size="small">
                  <el-option label="是" :value="true"></el-option>
                  <el-option label="否" :value="false"></el-option>
                  <el-option label="否" :value="null"></el-option>
                </el-select>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>允许无批次号:&nbsp;</span>
                </div>
                <el-select v-model="editQuery.allowNoBatch" disabled style="width: 65%" size="small">
                  <el-option label="是" :value="true"></el-option>
                  <el-option label="否" :value="false"></el-option>
                  <el-option label="否" :value="null"></el-option>
                </el-select>
              </div>
            </el-col>
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>允许无失效日期:&nbsp;</span>
                </div>
                <el-select v-model="editQuery.allowNoExpire" disabled style="width: 65%" size="small">
                  <el-option label="是" :value="true"></el-option>
                  <el-option label="否" :value="false"></el-option>
                  <el-option label="否" :value="null"></el-option>
                </el-select>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>允许无生产日期:&nbsp;</span>
                </div>
                <el-select v-model="editQuery.allowNoProduct" disabled style="width: 65%" size="small">
                  <el-option label="是" :value="true"></el-option>
                  <el-option label="否" :value="false"></el-option>
                  <el-option label="否" :value="null"></el-option>
                </el-select>
              </div>
            </el-col>
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>启用使用单元:&nbsp;</span>
                </div>
                <el-select v-model="editQuery.isUseDy" disabled style="width: 65%" size="small">
                  <el-option label="是" :value="true"></el-option>
                  <el-option label="否" :value="false"></el-option>
                  <el-option label="否" :value="null"></el-option>
                </el-select>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>允许科室多次使用出库:&nbsp;</span>
                </div>
                <el-select v-model="editQuery.useMuti" disabled style="width: 65%" size="small">
                  <el-option label="是" :value="true"></el-option>
                  <el-option label="否" :value="false"></el-option>
                  <el-option label="否" :value="null"></el-option>
                </el-select>
              </div>
            </el-col>
          </el-row>
        </el-collapse-item>


        <el-collapse-item name="2">
          <template slot="title">
            <p class="form-title">产品标识基本信息</p>
          </template>
          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>产品名称:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  size="small"
                  splaceholder="请输入内容"
                  :disabled="true"
                  v-model="editQuery.cpmctymc"
                ></el-input>
              </div>
            </el-col>

            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>最小包装内包含使用单元数量:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="!checked"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.zxxsbzbhsydysl"
                ></el-input>
              </div>
            </el-col>

          </el-row>

          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>包含下级产品编码:&nbsp;</span>
                </div>

                <el-input
                  style="width: 65%"
                  size="small"
                  :disabled="true"
                  splaceholder="请输入内容"
                  v-model="editQuery.bhxjcpbm"

                ></el-input>
              </div>
            </el-col>

            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>包含最小销售包装数量:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  size="small"
                  :disabled="true"
                  splaceholder="请输入内容"
                  v-model="editQuery.bhzxxsbzsl"
                ></el-input>
              </div>
            </el-col>
          </el-row>

          <el-row :gutter="20" class="el-row" type="flex">

            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>包装单位:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  size="small"
                  splaceholder="请输入内容"
                  :disabled="true"
                  v-model="editQuery.packUnit"
                ></el-input>
              </div>
            </el-col>

            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>最小包装可使用次数:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  size="small"
                  splaceholder="请输入内容"
                  :disabled="useNumEnable"
                  type="number"
                  v-model="editQuery.useNum"
                ></el-input>
              </div>
            </el-col>
          </el-row>
        </el-collapse-item>

        <el-collapse-item name="3">
          <template slot="title">
            <p class="form-title">产品基本信息</p>
          </template>
          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>产品标识:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.nameCode"
                ></el-input>
              </div>
            </el-col>
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>规格型号:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.ggxh"
                ></el-input>
              </div>
            </el-col>

          </el-row>

          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>产品类别:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.cplb"
                ></el-input>
              </div>
            </el-col>

            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>分类编码:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.flbm"
                ></el-input>
              </div>
            </el-col>
          </el-row>

          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>器械类别:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.qxlb"
                ></el-input>
              </div>
            </el-col>

            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>注册证/备案号:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.zczbhhzbapzbh"
                ></el-input>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>医疗器械注册人:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  size="small"
                  splaceholder="ylqxzcrbarmc"
                  v-model="editQuery.ylqxzcrbarmc"
                ></el-input>
              </div>
            </el-col>

            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>注册人英文名称:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.ylqxzcrbarywmc"
                ></el-input>
              </div>
            </el-col>

          </el-row>
          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>医保编码:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  size="small" :disabled="true"
                  splaceholder="请输入内容"
                  v-model="editQuery.ybbm"
                ></el-input>
              </div>
            </el-col>
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>统一社会信用号:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.tyshxydm"
                ></el-input>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>商品名称:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.spmc"
                ></el-input>
              </div>
            </el-col>

            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>商品条码:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  size="small" :disabled="true"
                  splaceholder="请输入内容"
                  v-model="editQuery.sptm"
                ></el-input>
              </div>
            </el-col>

          </el-row>

          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>计量单位:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  size="small"
                  splaceholder="请输入内容" :disabled="true"
                  v-model="editQuery.measname"
                ></el-input>
              </div>
            </el-col>
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>生产厂家:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  size="small"
                  :disabled="true"
                  v-model="editQuery.manufactory"
                  splaceholder="请输入内容"
                ></el-input>
              </div>
            </el-col>
          </el-row>

          <el-row :gutter="20" class="el-row" type="flex">


            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>产品描述:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  size="small"
                  :disabled="true"
                  splaceholder="请输入内容"
                  v-model="editQuery.cpms"
                ></el-input>
              </div>
            </el-col>
          </el-row>

          <el-row :gutter="20" class="el-row" type="flex">

            <el-col :span="12" class="el-col" v-if="productRemarkSet.remarkEnable1">
              <div class="text item">
                <div class="itemTag">
                  <span>{{ productRemarkSet.remarkTitle1 }}:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  size="small"
                  :disabled="true"
                  splaceholder="请输入内容"
                  v-model="editQuery.basicPrductRemak1"
                ></el-input>
              </div>
            </el-col>

            <el-col :span="12" class="el-col" v-if="productRemarkSet.remarkEnable2">
              <div class="text item">
                <div class="itemTag">
                  <span>{{ productRemarkSet.remarkTitle2 }}:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  size="small"
                  :disabled="true"
                  splaceholder="请输入内容"
                  v-model="editQuery.basicPrductRemak2"
                ></el-input>
              </div>
            </el-col>
          </el-row>

          <el-row :gutter="20" class="el-row" type="flex">

            <el-col :span="12" class="el-col" v-if="productRemarkSet.remarkEnable3">
              <div class="text item">
                <div class="itemTag">
                  <span>{{ productRemarkSet.remarkTitle3 }}:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.basicPrductRemak3"
                ></el-input>
              </div>
            </el-col>

            <el-col :span="12" class="el-col" v-if="productRemarkSet.remarkEnable4">
              <div class="text item">
                <div class="itemTag">
                  <span>{{ productRemarkSet.remarkTitle4 }}:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.basicPrductRemak4"
                ></el-input>
              </div>
            </el-col>
          </el-row>

          <el-row :gutter="20" class="el-row" type="flex">

            <el-col :span="12" class="el-col" v-if="productRemarkSet.remarkEnable5">
              <div class="text item">
                <div class="itemTag">
                  <span>{{ productRemarkSet.remarkTitle5 }}:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.basicPrductRemak5"
                ></el-input>
              </div>
            </el-col>

            <el-col :span="12" class="el-col" v-if="productRemarkSet.remarkEnable6">
              <div class="text item">
                <div class="itemTag">
                  <span>{{ productRemarkSet.remarkTitle6 }}:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  size="small"
                  :disabled="true"
                  splaceholder="请输入内容"
                  v-model="editQuery.basicPrductRemak6"
                ></el-input>
              </div>
            </el-col>
          </el-row>

          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col" v-if="productRemarkSet.remarkEnable7">
              <div class="text item">
                <div class="itemTag">
                  <span>{{ productRemarkSet.remarkTitle7 }}:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  size="small"
                  :disabled="true"
                  splaceholder="请输入内容"
                  v-model="editQuery.basicPrductRemak7"
                ></el-input>
              </div>
            </el-col>

            <el-col :span="12" class="el-col" v-if="productRemarkSet.remarkEnable8">
              <div class="text item">
                <div class="itemTag">
                  <span>{{ productRemarkSet.remarkTitle8 }}:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  size="small"
                  :disabled="true"
                  splaceholder="请输入内容"
                  v-model="editQuery.basicPrductRemak8"
                ></el-input>
              </div>
            </el-col>
          </el-row>

        </el-collapse-item>


        <el-collapse-item name="4">
          <template slot="title">
            <p class="form-title">生产标识基本信息</p>
          </template>
          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>是否包含批号:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.scbssfbhph"
                ></el-input>
              </div>
            </el-col>
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>是否包含序列号:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  size="small"
                  v-model="editQuery.scbssfbhxlh"
                  splaceholder="请输入内容"
                ></el-input>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>是否包含生产日期:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.scbssfbhscrq"
                ></el-input>
              </div>
            </el-col>
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>是否包含失效日期:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  v-model="editQuery.scbssfbhsxrq"
                  size="small"
                  splaceholder="请输入内容"
                ></el-input>
              </div>
            </el-col>
          </el-row>
        </el-collapse-item>

        <el-collapse-item name="5">
          <template slot="title">
            <p class="form-title">包装标识信息</p>
          </template>
          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>上级产品编码:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  :disabled="true"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.sjcpbm"
                ></el-input>
              </div>
            </el-col>

            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>包装级别:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  size="small"
                  splaceholder="请输入内容"
                  :disabled="true"
                  v-model="editQuery.packLevel"
                ></el-input>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>包装单位/包装级别:&nbsp;</span>
                </div>

                <el-input
                  style="width: 65%"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.bzcj"
                  :disabled="true"

                ></el-input>
              </div>
            </el-col>

            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>包含下级包装数量:&nbsp;</span>
                </div>
                <el-input
                  style="width: 65%"
                  size="small"
                  splaceholder="请输入内容"
                  :disabled="true"
                  v-model="editQuery.bhxjsl"
                ></el-input>
              </div>
            </el-col>
          </el-row>
        </el-collapse-item>

        <el-collapse-item name="6">
          <template slot="title">
            <p class="form-title">版本信息</p>
          </template>

          <el-row :gutter="20" class="el-row" type="flex">

            <el-col :span="12" class="el-col">
              <div class="text item">
                <div class="itemTag">
                  <span>当前版本号:&nbsp;</span>
                </div>
                <el-input
                  style="width: 35%"
                  :disabled="true"
                  size="small"
                  splaceholder="请输入内容"
                  v-model="editQuery.versionNumber"
                ></el-input>
                <el-button type="text" size="small" @click.native.stop="selectVersion()"
                           style="margin-left: 5%"
                >切换版本
                </el-button>
              </div>
            </el-col>
          </el-row>

        </el-collapse-item>
      </el-collapse>
    </el-form>

    <el-dialog
       title="耗材字典-编辑"
      :visible.sync="editSingleDiDialogVisible"
      :close-on-click-modal="false"
       append-to-body
      :close-on-press-escape="false"
      width="45%"
      v-if="editSingleDiDialogVisible"
    >
      <el-form :model="editSingleFormat" :rules="rules" ref="editSingleFormat" border label-width="120px">
        <el-row>
          <el-form-item label="商品条码:">
            <el-input style="width: 80%" size="small" splaceholder="请输入内容" v-model="editSingleFormat.sptm"></el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item label="包装单位:">
            <el-input style="width: 80%" size="small" splaceholder="请输入内容" v-model="editSingleFormat.packUnit"></el-input>
          </el-form-item>
        </el-row>
      </el-form>
      <div style="text-align: center;margin-top: 12px">
        <el-button type="primary" size="small" icon="search" @click="onAddSingleSubmit(false)">提交</el-button>
        <el-button type="primary" size="small" icon="search" @click="cancelDialog">取消</el-button>
      </div>
    </el-dialog>
    <el-dialog
      title="耗材字典-从指定系统添加器械信息"
      :visible.sync="selectErpDialogVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      width="85%"
      append-to-body
      v-if="selectErpDialogVisible"
    >
      <selectErp
        :closeDialog="closeDialog"
        :uuid="uuid"
        :relId="relId"
        :isImport="isImport"
        :data="thisData"
        :defaultSys="defaultSys"
        @closeUdi="closeUdi2"
        :supEnable="false"
      ></selectErp>
    </el-dialog>
    <el-dialog
      title="选择DI版本"
      append-to-body
      :visible.sync="selectVersionVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      width="85%"
      v-if="selectVersionVisible"
    >
      <selectUdiVersion
        :closeDialog="closeDialog"
        :relId="relId"
        :uuid="uuid"
        :originUuid="originUuid"
        @closeUdi="closeUdi"
      ></selectUdiVersion>
    </el-dialog>
  </el-card>
</div>
</template>

<script>
import { updateById } from '@/api/basic/udiRelevance'
import { removeDiRl, removeRl, thirdSysDetail, updatetSingleUdiInfo } from '@/api/basic/product/udiRelevance'
import { filterByUuid } from '@/api/basic/udiInfo'

import selectErp from "./udiInfoselectErpUdi";
import ProductSingleEdit from '@/views/basic/product/productSingleEdit'
import ProductEdit from '@/views/basic/product/productEdit'
import selectUdi from '@/views/basic/product/UdiInfoSelectRel'
import selectLocalUdi from '@/views/basic/product/UdiInfoSelectLocalUdi'
import selectUdiVersion from '@/views/basic/product/UdiinfoSelectVersion'

export default {
  name: 'basicCompanyproductDetail',
  props: {
    editQuery: {
      type: Object,
      required: true
    },
    productRemarkSet: {
      type: Object,
      required: true
    },
    closeDialog: {
      type: Function,
      required: true
    },
  },

  data() {
    return {
      isUseDyCheck: false,
      selectVersionVisible:false,
      originUuid: null,
      relId:null,
      sysList:{},
      detailList:{},
      isImport:null,
      thisData: {
        nameCode: null,
        cpmctymc: null,
        ggxh: null
      },
      defaultSys:null,
      uuid:null,
      useNumEnable: true,
      editDialogVisible:false,
      editSingleFormat: {
        uuid: null,
        relId: null,
        sptm: null,
        packUnit: null,
        measname: null,
        nameCode:null
      },

      editSingleDiDialogVisible: false,
      selectErpDialogVisible: false,  //选入ERP产品
    }
  },

  methods: {

    getDetailList(detailQuery) {
      this.loading = true;
      filterByUuid(detailQuery)
        .then((response) => {
          this.loading = false;
          this.detailList = response.data || [];
        })
        .catch(() => {
          this.loading = false;
          this.detailList = [];
        });
    },
    selectVersion() {
      this.selectVersionVisible = true;
      this.uuid = this.editQuery.uuid;
      this.originUuid = this.editQuery.originUuid;
      this.relId = this.editQuery.rlId;
    },
    closeUdi2() {
      this.selectUdiDialogVisible = false;
      this.selectErpDialogVisible = false;
      this.selectLocalVisible = false;
      this.selectVersionVisible = false;
      this.getThirdSysDetail();
    },
    getThirdSysDetail() {
      let query = {
        id: this.editQuery.rlId,
      };
      thirdSysDetail(query)
        .then((response) => {
          this.loading = false;
          this.sysList = response.data.list || [];
        })
        .catch(() => {
          this.loading = false;
          this.sysList = [];
        });
    },
    singleDiEdit() {
      let temp = JSON.parse(JSON.stringify(this.editQuery));
      this.editSingleFormat.uuid = temp.uuid;
      this.editSingleFormat.id = temp.id;
      this.editSingleFormat.sptm = temp.sptm;
      this.editSingleFormat.packUnit = temp.packUnit;
      this.editSingleFormat.measname = temp.measname;
      this.editSingleFormat.nameCode=temp.nameCode;
      this.editSingleDiDialogVisible = true;
    },
    onAddSingleSubmit() {
      updatetSingleUdiInfo(this.editSingleFormat)
        .then((response) => {
          if (response.code == 20000) {
            var ttquery = {
              id: this.editQuery.rlId,
              page: 1,
              limit: 10,
            };
            this.getDetailList(ttquery);
            this.editSingleDiDialogVisible = false;
          } else {
            this.$message.error(response.message);
          }
        })
        .catch(() => {
        });
    },
    cancelDialog(){
      this.editSingleDiDialogVisible = false;
    },
    addSelectErp(row) {
      this.defaultSys = row.sysId;
      this.isImport = false;
      this.relId=this.editQuery.rlId;
      this.thisData = this.editQuery;
      this.selectErpDialogVisible = true;
    },
    removeDi() {
      this.$confirm("此操作将解除该绑定DI器械信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          let query = {
            relId: this.editQuery.rlId,
          };
          removeDiRl(query)
            .then((response) => {
              if (response.code == 20000) {
                this.$message({
                  type: "success",
                  message: "删除成功！",
                });
                this.editDialogVisible=false;
                this.closeDialog();
              } else {
                this.$message.error(response.message);
              }
            })
            .catch(() => {
            });
        })
        .catch(() => {
        });
    },
    closeUdi() {
      this.closeDialog();
    },
    removeErp(row) {
      this.$confirm("此操作将解除该绑定产品信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          let query = {
            relId: this.editQuery.rlId,
            thirdSys: row.sysId
          };
          removeRl(query)
            .then((response) => {
              if (response.code == 20000) {
                this.$message({
                  type: "success",
                  message: "删除成功！",
                });
                this.getThirdSysDetail();
              } else {
                this.$message.error(response.message);
              }
            })
            .catch(() => {
            });
        })
        .catch(() => {
        });
    },
  },

  components: {
    selectErp,
    selectUdiVersion
  },
  created() {
    this.getThirdSysDetail();
    var ttquery = {
      id: this.editQuery.rlId,
      page: 1,
      limit: 10,
    };
    this.getDetailList(ttquery);
  },
}
</script>

<style scoped>

</style>
