<template>
  <div>
    <el-card>
      <el-row type="flex">
        <el-col style="flex: 1" v-show="Dictionary">
          <el-col v-if="showSearch" style="min-width: 300px; max-width: 100%">
            <el-tree
              :data="treeList"
              class="tree"
              :default-expand-all="true"
              @node-click="handleNodeClick"
              :expand-on-click-node="false"
              highlight-current
            >
              <span class="custom-tree-node" slot-scope="{ node, data }">
                <span style="font-size: 14px; font-weight: 500">{{
                    node.label
                  }}</span>
                  <el-button
                    type="text"
                    size="mini"
                    style="margin-left: 10px"
                    @click="() => append(data,'add')">
                  新增
                </el-button>
                <el-button
                  type="text"
                  size="mini"
                  :disabled="data.parentCode == null"
                  @click="() => append(data, 'edit')">
            编辑
          </el-button>
          <el-button
            type="text"
            size="mini"
            :disabled="data.parentCode == null"
            @click="() => remove(node, data)">
            删除
          </el-button>

              </span
              >
            </el-tree>
          </el-col>
        </el-col>
        <el-button
          type="success"
          @click="Dictionary = !Dictionary"
          icon="el-icon-arrow-left"
          v-show="Dictionary"
          class="iconButton"
        >
        </el-button>
        <el-button
          type="success"
          @click="Dictionary = !Dictionary"
          icon="el-icon-arrow-right"
          v-show="!Dictionary"
          class="iconButton"
        >
        </el-button>
        <el-col style="border-left: 3px solid #dddddd; overflow-y: hidden">
          <el-form
            :model="filterQuery"
            v-if="queryList && queryList.length > 0 && showSearch"
            size="mini"
            label-width="100px"
          >
            <el-row style=" display:flex;  flex-wrap: wrap; ">
              <template v-for="(item, index) in queryList" >
                <el-form-item v-if="item.columnType == 'input' && executeEval(row,item.expression,true)" :label="item.columnDesc+`:`" :key="item.id">
                  <el-input
                    v-model="filterQuery[item.columnName]"
                    :placeholder="item.columnDesc"
                    :disabled="executeEval(null,item.disabledFuc,false)"
                    @keyup.enter.native="executeFuc($event,'5',item.clickFuc)"
                    clearable
                  ></el-input>
                </el-form-item>
                <el-form-item v-if="item.columnType == 'select' && executeEval(row,item.expression,true)" :label="item.columnDesc+`:`">
                  <el-select v-model="filterQuery[item.columnName]"
                             :placeholder="item.columnDesc"
                             :disabled="executeEval(null,item.disabledFuc,false)"
                             clearable>
                    <el-option
                      v-for="dict in item.lableRuleObj"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    />
                  </el-select>
                </el-form-item>
                <el-form-item v-if="item.columnType == 'selectServer' && executeEval(row,item.expression,true)" :label="item.columnDesc+`:`">
                  <el-select
                    v-model="filterQuery[item.columnName]"
                    :placeholder="item.columnDesc"
                    :disabled="executeEval(null,item.disabledFuc,false)"
                    filterable
                    remote
                    :remote-method="(query) => executeFuc(query,'5',item.clickFuc)"
                    clearable>
                    <el-option
                      v-for="item in options[item.clickFuc]"
                      :key="item.code"
                      :label="item.label"
                      :value="item.code"
                    />
                  </el-select>
                </el-form-item>
                <el-form-item v-if="item.columnType == 'datePicker' && executeEval(row,item.expression,true)" :label="item.columnDesc+`:`">
                  <el-date-picker
                    v-model="dateRange"
                    :style="`width:${item.width+'px'}`"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    :disabled="executeEval(null,item.disabledFuc,false)"
                    type="daterange"
                    range-separator="-"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    :default-time="['00:00:00', '23:59:59']"
                  ></el-date-picker>
                </el-form-item>
                <el-form-item v-if="item.columnType == 'date' && executeEval(row,item.expression,true)" :label="item.columnDesc+`:`">
                  <el-date-picker
                    v-model="filterQuery[item.columnName]"
                    :style="`width:${item.width+'px'}`"
                    value-format="yyyy-MM-dd"
                    :disabled="executeEval(null,item.disabledFuc,false)"
                    type="date"
                    :placeholder="item.columnDesc"
                  ></el-date-picker>
                </el-form-item>
              </template>
            </el-row>
<!--            <el-row>-->
<!--              <el-col :span="18">-->
<!--                <el-form-item class="query-form-item" label="UDI码:">-->
<!--                  <el-input-->
<!--                    v-model="filterQuery.udiCode"-->
<!--                    style="width: 97%"-->
<!--                    placeholder="请扫描或输入UDI码"-->
<!--                    clearable="true"-->
<!--                    @keyup.enter.native="keyup_submit($event)"-->
<!--                  ></el-input>-->
<!--                </el-form-item>-->
<!--              </el-col>-->
<!--            </el-row>-->
<!--            <el-row>-->
<!--              <el-col :span="6">-->
<!--                <el-form-item class="query-form-item" label="最小销售标识:">-->
<!--                  <el-input-->
<!--                    v-model="filterQuery.unionCode"-->
<!--                    placeholder="请输入最小销售标识"-->
<!--                    style="width: 90%"-->
<!--                    clearable="true"-->
<!--                  ></el-input>-->
<!--                </el-form-item>-->
<!--              </el-col>-->
<!--              <el-col :span="6">-->
<!--                <el-form-item class="query-form-item" label="物资名称:">-->
<!--                  <el-input-->
<!--                    v-model="filterQuery.cpmctymc"-->
<!--                    placeholder="请输入物资名称"-->
<!--                    clearable="true"-->
<!--                    style="width: 90%"-->
<!--                  ></el-input>-->
<!--                </el-form-item>-->
<!--              </el-col>-->
<!--              <el-col :span="6">-->
<!--                <el-form-item class="query-form-item" label="规格型号:">-->
<!--                  <el-input-->
<!--                    v-model="filterQuery.ggxh"-->
<!--                    placeholder="请输入规格型号"-->
<!--                    clearable="true"-->
<!--                    style="width: 90%"-->
<!--                  ></el-input>-->
<!--                </el-form-item>-->
<!--              </el-col>-->
<!--              &lt;!&ndash;<el-col :span="6">&ndash;&gt;-->
<!--              &lt;!&ndash;  <el-form-item class="query-form-item" label="对照条件:">&ndash;&gt;-->
<!--              &lt;!&ndash;    <el-select&ndash;&gt;-->
<!--              &lt;!&ndash;      v-model="filterQuery.filterType"&ndash;&gt;-->
<!--              &lt;!&ndash;      placeholder="请选择过滤对照条件"&ndash;&gt;-->
<!--              &lt;!&ndash;      style="width: 90%"&ndash;&gt;-->
<!--              &lt;!&ndash;    >&ndash;&gt;-->
<!--              &lt;!&ndash;      <el-option&ndash;&gt;-->
<!--              &lt;!&ndash;        v-for="item in filterList"&ndash;&gt;-->
<!--              &lt;!&ndash;        :key="item.filterType"&ndash;&gt;-->
<!--              &lt;!&ndash;        :label="item.sysName"&ndash;&gt;-->
<!--              &lt;!&ndash;        :value="item.filterType"&ndash;&gt;-->
<!--              &lt;!&ndash;      >&ndash;&gt;-->
<!--              &lt;!&ndash;        <span style="float: left">{{ item.sysName }}</span>&ndash;&gt;-->
<!--              &lt;!&ndash;      </el-option>&ndash;&gt;-->
<!--              &lt;!&ndash;    </el-select>&ndash;&gt;-->
<!--              &lt;!&ndash;  </el-form-item>&ndash;&gt;-->
<!--              &lt;!&ndash;</el-col>&ndash;&gt;-->
<!--            </el-row>-->
<!--            <el-row>-->

<!--              &lt;!&ndash;<el-col :span="6">&ndash;&gt;-->
<!--              &lt;!&ndash;  <el-form-item class="query-form-item" label="第三方编码:">&ndash;&gt;-->
<!--              &lt;!&ndash;    <el-input&ndash;&gt;-->
<!--              &lt;!&ndash;      v-model="filterQuery.thrPiId"&ndash;&gt;-->
<!--              &lt;!&ndash;      placeholder="请输入第三方主系统编码"&ndash;&gt;-->
<!--              &lt;!&ndash;      style="width: 90%"&ndash;&gt;-->
<!--              &lt;!&ndash;      clearable="true"&ndash;&gt;-->
<!--              &lt;!&ndash;    ></el-input>&ndash;&gt;-->
<!--              &lt;!&ndash;  </el-form-item>&ndash;&gt;-->
<!--              &lt;!&ndash;</el-col>&ndash;&gt;-->
<!--              &lt;!&ndash;<el-col :span="6">&ndash;&gt;-->
<!--              &lt;!&ndash;  <el-form-item class="query-form-item" label="集采状态:">&ndash;&gt;-->
<!--              &lt;!&ndash;    <el-select&ndash;&gt;-->
<!--              &lt;!&ndash;      v-model="filterQuery.groupBuy"&ndash;&gt;-->
<!--              &lt;!&ndash;      placeholder="请选择集采状态"&ndash;&gt;-->
<!--              &lt;!&ndash;      clearable&ndash;&gt;-->
<!--              &lt;!&ndash;      style="width: 90%"&ndash;&gt;-->
<!--              &lt;!&ndash;    >&ndash;&gt;-->
<!--              &lt;!&ndash;      <el-option label="全部" value=""></el-option>&ndash;&gt;-->
<!--              &lt;!&ndash;      <el-option label="集采" value="true"></el-option>&ndash;&gt;-->
<!--              &lt;!&ndash;      <el-option label="非集采" value="false"></el-option>&ndash;&gt;-->
<!--              &lt;!&ndash;    </el-select>&ndash;&gt;-->
<!--              &lt;!&ndash;  </el-form-item>&ndash;&gt;-->
<!--              &lt;!&ndash;</el-col>&ndash;&gt;-->
<!--              &lt;!&ndash;<el-col :span="6">&ndash;&gt;-->
<!--              &lt;!&ndash;  <el-form-item class="query-form-item" label="可配送状态:">&ndash;&gt;-->
<!--              &lt;!&ndash;    <el-select&ndash;&gt;-->
<!--              &lt;!&ndash;      v-model="filterQuery.dispatch"&ndash;&gt;-->
<!--              &lt;!&ndash;      placeholder="请选择可配送状态"&ndash;&gt;-->
<!--              &lt;!&ndash;      clearable&ndash;&gt;-->
<!--              &lt;!&ndash;      style="width: 90%"&ndash;&gt;-->
<!--              &lt;!&ndash;    >&ndash;&gt;-->
<!--              &lt;!&ndash;      <el-option label="全部" value=""></el-option>&ndash;&gt;-->
<!--              &lt;!&ndash;      <el-option label="可配送" value="true"></el-option>&ndash;&gt;-->
<!--              &lt;!&ndash;      <el-option label="不可配送" value="false"></el-option>&ndash;&gt;-->
<!--              &lt;!&ndash;    </el-select>&ndash;&gt;-->
<!--              &lt;!&ndash;  </el-form-item>&ndash;&gt;-->
<!--              &lt;!&ndash;</el-col>&ndash;&gt;-->
<!--            </el-row>-->

<!--            <el-row>-->
<!--              <el-col :span="6">-->
<!--                <el-form-item class="query-form-item" label="注册备案人:">-->
<!--                  <el-input-->
<!--                    v-model="filterQuery.ylqxzcrbarmc"-->
<!--                    placeholder="请输入注册备案人"-->
<!--                    style="width: 90%"-->
<!--                    clearable="true"-->
<!--                  ></el-input>-->
<!--                </el-form-item>-->
<!--              </el-col>-->
<!--              <el-col :span="6">-->
<!--                <el-form-item class="query-form-item" label="注册/备案号:">-->
<!--                  <el-input-->
<!--                    v-model="filterQuery.zczbhhzbapzbh"-->
<!--                    placeholder="请输入注册/备案号"-->
<!--                    style="width: 90%"-->
<!--                    clearable="true"-->
<!--                  ></el-input>-->
<!--                </el-form-item>-->
<!--              </el-col>-->
<!--              <el-col :span="6">-->
<!--                <el-form-item class="query-form-item" label="生产企业:">-->
<!--                  <el-input-->
<!--                    v-model="filterQuery.manufactory"-->
<!--                    placeholder="请输入生产企业"-->
<!--                    style="width: 90%"-->
<!--                    clearable="true"-->
<!--                  ></el-input>-->
<!--                </el-form-item>-->
<!--              </el-col>-->
<!--              &lt;!&ndash;<el-col :span="6">&ndash;&gt;-->
<!--              &lt;!&ndash;  <el-form-item class="query-form-item" label="是否在用:">&ndash;&gt;-->
<!--              &lt;!&ndash;    <el-select&ndash;&gt;-->
<!--              &lt;!&ndash;        v-model="filterQuery.isDisable"&ndash;&gt;-->
<!--              &lt;!&ndash;        placeholder="请选择是否在用"&ndash;&gt;-->
<!--              &lt;!&ndash;        clearable&ndash;&gt;-->
<!--              &lt;!&ndash;        style="width: 90%"&ndash;&gt;-->
<!--              &lt;!&ndash;    >&ndash;&gt;-->
<!--              &lt;!&ndash;      <el-option label="在用" value="false"></el-option>&ndash;&gt;-->
<!--              &lt;!&ndash;      <el-option label="停用" value="true"></el-option>&ndash;&gt;-->
<!--              &lt;!&ndash;    </el-select>&ndash;&gt;-->
<!--              &lt;!&ndash;  </el-form-item>&ndash;&gt;-->
<!--              &lt;!&ndash;</el-col>&ndash;&gt;-->
<!--            </el-row>-->
          </el-form>
          <div class="top-right-btn">
            <el-button-group>
              <el-button icon="el-icon-view" type="primary" @click="hideSearch">显示/隐藏搜索栏</el-button>
              <el-button type="primary" icon="el-icon-refresh" @click="onReset">重置</el-button>
              <el-button type="primary" icon="el-icon-search" @click="submit">查询</el-button>
              <el-button type="primary" icon="el-icon-plus" @click.native="handleForm()">新增
              </el-button>
            </el-button-group>
          </div>
          <el-divider style="margin: 15px"></el-divider>
          <el-table
            v-loading="loading"
            :data="list"
            style="width: 100%"
            border
            key="1"
          >
            <template v-for="(item, index) in tableHeader">
              <el-table-column
                v-if="item.columnType == 'id' && executeEval(row,item.expression,true)"
                type="index" :label="item.columnDesc"></el-table-column>
              <el-table-column
                v-if="item.columnType == 'selection'"
                type="selection"
                :width="item.width"
                :selectable="(row,number) => executeFuc(row,'3',item.clickFuc)"></el-table-column>

              <el-table-column
                v-if="item.columnType == 'radio' && executeEval(row,item.expression,true)"
                :prop="item.columnName"
                :label="item.columnDesc"
                :sortable="item.sort"
                :width="item.width"
                :show-overflow-tooltip="item.tooltip"
                :key="item.columnName"
              >
                <template  slot-scope="scope">
                  <el-radio :label="scope.row.id" v-model="radioCheck"><span></span></el-radio>
                </template>
              </el-table-column>
              <el-table-column
                v-if="item.columnType == 'laber' && executeEval(row,item.expression,true)"
                :prop="item.columnName"
                :label="item.columnDesc"
                :sortable="item.sort"
                :width="item.width"
                :show-overflow-tooltip="item.tooltip"
                :key="item.columnName"
              >
                <template   slot-scope="scope">
                  <span :style="{color: executeFuc(scope.row,'4',item.lableRuleObj[scope.row[item.columnName]])}">{{ item.lableRuleObj[scope.row[item.columnName]] }}</span>
                </template>
              </el-table-column>
              <el-table-column
                v-if="item.columnType == 'eltag' && executeEval(row,item.expression,true)"
                :prop="item.columnName"
                :label="item.columnDesc"
                :sortable="item.sort"
                :width="item.width"
                :show-overflow-tooltip="item.tooltip"
                :key="item.columnName"
              >
                <template   slot-scope="scope">
                  <el-tag :type="executeFuc(scope.row,'4',item,item.lableRuleObj?item.lableRuleObj[scope.row[item.columnName]]:scope.row[item.columnName])">
                    <span>{{ item.lableRuleObj?item.lableRuleObj[scope.row[item.columnName]]:scope.row[item.columnName] }}</span>
                  </el-tag>
                </template>
              </el-table-column>
              <el-table-column
                v-if="item.columnType == 'button' && executeEval(row,item.expression,true)"
                :prop="item.columnName"
                :label="item.columnDesc"
                :width="item.width"
                :key="item.columnName"
                fixed="right"
              >
                <template slot-scope="scope">
                  <el-button v-for="(buttonItem, buttonIndex) in item.buttonRulObj"
                             :type="buttonItem.type"
                             :size="buttonItem.size"
                             :style="buttonItem.style"
                             :key="buttonItem"
                             v-if="executeEval(scope.row,buttonItem.hasPermi,true)"
                             :disabled="executeEval(scope.row,buttonItem.disabledFuc,false)"
                             @click.native.stop="executeFuc(scope.row,'1',buttonItem.clickFuc)"
                  >{{ buttonItem.name }}
                  </el-button>
                </template>
              </el-table-column>
              <el-table-column
                v-if="item.columnType == 'text' && executeEval(row,item.expression,true)"
                :prop="item.columnName"
                :label="item.columnDesc"
                :sortable="item.sort"
                :width="item.width"
                :show-overflow-tooltip="item.tooltip"
                :key="item.columnName"
              >
                <template slot-scope="scope">
                  <span :style="{color: executeFuc(scope.row,'4',item,scope.row[item.columnName])}">{{ scope.row[item.columnName] }}</span>
                </template>
              </el-table-column>

            </template>
<!--            <el-table-column label="序号" type="index"></el-table-column>-->
<!--            <el-table-column-->
<!--              label="最小销售产品标识"-->
<!--              prop="nameCode"-->
<!--              width="140"-->
<!--              show-overflow-tooltip-->
<!--            ></el-table-column>-->
<!--            <el-table-column-->
<!--              label="物资名称"-->
<!--              prop="cpmctymc"-->
<!--              width="160"-->
<!--              show-overflow-tooltip-->
<!--            ></el-table-column>-->
<!--            <el-table-column-->
<!--              label="规格型号"-->
<!--              prop="ggxh"-->
<!--              width="160"-->
<!--              show-overflow-tooltip-->
<!--            ></el-table-column>-->
<!--            <el-table-column-->
<!--              label="注册/备案号"-->
<!--              prop="zczbhhzbapzbh"-->
<!--              width="160"-->
<!--              show-overflow-tooltip-->
<!--            ></el-table-column>-->
<!--            <el-table-column-->
<!--              label="注册/备案人"-->
<!--              prop="ylqxzcrbarmc"-->
<!--              width="180"-->
<!--              show-overflow-tooltip-->
<!--            ></el-table-column>-->
<!--            <el-table-column-->
<!--              label="生产厂家"-->
<!--              prop="manufactory"-->
<!--              width="180"-->
<!--              show-overflow-tooltip-->
<!--            ></el-table-column>-->

<!--            <el-table-column width="180" label="操作" fixed="right">-->
<!--              <template slot-scope="scope">-->
<!--                &lt;!&ndash;<el-button&ndash;&gt;-->
<!--                &lt;!&ndash;  type="text"&ndash;&gt;-->
<!--                &lt;!&ndash;  size="small"&ndash;&gt;-->
<!--                &lt;!&ndash;  :disabled="scope.row.originUuid != null"&ndash;&gt;-->
<!--                &lt;!&ndash;  @click.native.stop="intentSelectUdi(scope.row)"&ndash;&gt;-->
<!--                &lt;!&ndash;&gt;关联DI&ndash;&gt;-->
<!--                &lt;!&ndash;</el-button>&ndash;&gt;-->
<!--                &lt;!&ndash;<el-button&ndash;&gt;-->
<!--                &lt;!&ndash;  type="text"&ndash;&gt;-->
<!--                &lt;!&ndash;  size="small"&ndash;&gt;-->
<!--                &lt;!&ndash;  @click.native.stop="handleModifyClick(scope.row)"&ndash;&gt;-->
<!--                &lt;!&ndash;&gt;详情&ndash;&gt;-->
<!--                &lt;!&ndash;</el-button>&ndash;&gt;-->

<!--                <el-button-->
<!--                  type="text"-->
<!--                  size="small"-->
<!--                  @click.native.stop="diEdit(scope.row)"-->
<!--                >详情-->
<!--                </el-button>-->

<!--                <el-button-->
<!--                  type="text"-->
<!--                  size="small"-->
<!--                  @click.native.stop="deleteDialog(scope.row)"-->
<!--                >删除-->
<!--                </el-button>-->
<!--              </template>-->
<!--            </el-table-column>-->
          </el-table>
        </el-col>
      </el-row>
      <pagination
        :total="total"
        :limit.sync="filterQuery.limit"
        :page.sync="filterQuery.page"
        @pagination="handleCurrentChange"
      >
      </pagination>

      <el-dialog
        :title="formMap[formName]"
        append-to-body
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        :visible.sync="subFormVisible"
        width="60%"
        top="5vh"
      >
        <el-form :model="subData" ref="dataForm" :rules="formRules" label-width="80px">
          <el-row :gutter="20" class="el-row" type="flex">
            <el-col :span="12" class="el-col">
              <el-form-item label="上级菜单" prop="parentCode">
                <treeselect
                  disabled
                  v-model="subData.parentCode"
                  :options="fromDeptOptions"
                  :normalizer="normalizer"
                  :clearable="false"
                  :show-count="true"
                  placeholder="选择上级菜单"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12" class="el-col">
              <el-form-item label="名称" prop="name" class="query-form-item">
                <el-input
                  v-model="subData.name" style="width: 80%"
                  placeholder="请输入名称"
                  auto-complete="off"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row class="el-row" type="flex">
            <el-col class="el-col">
              <el-form-item label="备注:" prop="remark" class="query-form-item">
                <el-input
                  v-model="subData.remark"
                  type="textarea"
                  style="width: 90%"
                  auto-complete="off"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click.native="hideForm">取消</el-button>
          <el-button
            type="primary"
            @click.native="forInvSubmit()"
            :loading="subLoading"
          >提交
          </el-button
          >
        </div>
      </el-dialog>


      <el-dialog
        title="选入-耗材产品"
        :visible.sync="selectHospProductVisible"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        :before-close="closeCategory"
        width="80%"
        append-to-body
        v-if="selectHospProductVisible"
      >
        <selectProduct
          :closeDialog="closeCategory"
          :rId="rId"
        ></selectProduct>
      </el-dialog>


      <el-dialog
        title="物资字典-详情"
        :visible.sync="editDialogVisible"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        width="70%"
        v-if="editDialogVisible"
      >
        <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>
        </el-card>
        <el-card>
          <div
            style="
                  float: left;
                  text-align: left;
                  font-weight: bold;
                  margin-bottom: 8px;
                "
          >
            <span>产品标识:</span>
          </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="packUnit"
              show-overflow-tooltip
            ></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.allowNoSerial"
                        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.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-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.zdcfsycs"
                      ></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">国家DI标识数据库版本信息</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-card>
      </el-dialog>
      <el-dialog
        title="耗材字典-选择DI版本"
        :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 {filterByUuid} from "@/api/basic/product/udiInfo";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";


import selectProduct from "@/views/basic/product/bindProduct";
import Treeselect from "@riophae/vue-treeselect";
import {
  getListTree,
  getOneName,
  getListMenu,
  uodateBasicHospType,
  saveBasicHospType,
  deleteBasicHospType,
  getbindList, deleterel
} from "@/api/basic/basicProductType";
import {thirdSysDetail} from "@/api/basic/product/udiRelevance";
import {finProductSet} from "@/api/param/systemParamConfig";
import selectUdiVersion from './UdiinfoSelectVersion'
import {
  getHead,executeFuc
} from "@/utils/customConfig";

export default {
  data() {
    return {
      originUuid: null,
      uuid: "111",
      relId: "",
      selectVersionVisible: false,
      useNumEnable: true,
      checked: false,
      sysList: [],
      productRemarkSet: {},
      inputQuery: {},
      editDialogVisible: false,
      loading: false,
      total: 0,
      list: [],
      selectHospProductVisible: false,
      rId: null,
      subFormVisible: false,
      formMap: {
        add: "新增",
        edit: "编辑"
      },
      fromDeptOptions: [],
      subData: {},
      formName: null,
      showSearch: true,
      tableHeader:[],
      queryList:[],
      fromList:[],
      options:[],
      treeList: [],
      Dictionary: true, //物资字典分类显示、隐藏
      filterQuery: {
        code: "",
        parentCode: "",
        unionCode: null,
        udiCode: null,
        ylqxzcrbarmc: "",
        cpmctymc: "",
        nameCode: "",
        ggxh: null,
        page: 1,
        limit: 20,
        zczbhhzbapzbh: null,
      },
      subLoading: false,
    };
  },
  filters: {},
  methods: {
    closeUdi(val) {
      this.selectUdiDialogVisible = false;
      this.selectErpDialogVisible = false;
      this.selectLocalVisible = false;
      this.selectVersionVisible = false;
      this.selectHospProductVisible = false;
      this.getThirdSysDetail();
      let ttquery = {
        id: this.relId,
      };
      this.getDetailList(ttquery)
      if (val) {
        this.getList();
        this.cancelDialog();
      }
    },
    closeDialog() {
      this.selectErpDialogVisible = false;
      this.selectLocalVisible = false;
      this.selectVersionVisible = false;
      this.selectHospProductVisible = false;
      this.selectUnBindHospProductVisible = false;
    },
    selectVersion() {
      this.selectVersionVisible = true;
      this.uuid = this.editQuery.uuid;
      this.originUuid = this.editQuery.originUuid;
      this.relId = this.editQuery.id;
    },
    onReset() {
      this.$router.push({
        path: "",
      });
      this.filterQuery = {
        lockStatus: null,
        unionCode: null,
        udiCode: null,
        ylqxzcrbarmc: "",
        cpmctymc: "",
        thrPiId: null,
        nameCode: "",
        ggxh: null,
        page: 1,
        limit: 20,
        addType: 1,
      };
      this.getList();
    },
    submit() {
      this.loading = true;
      this.filterQuery.page = 1;
      this.getList();
    },
    getList() {
      getbindList(this.filterQuery)
        .then((response) => {
          this.loading = false;
          this.list = response.data.list || [];
          this.total = response.data.total || 0;
        })
        .catch(() => {
          this.loading = false;
          this.list = [];
          this.total = 0;
        });
    },
    findBasicProductSet() {
      finProductSet().then((response) => {
        if (response.code == 20000) {
          this.productRemarkSet = response.data;
        } else {
          //出错了
        }
      });
    },


    diEdit(_this,row) {
      _this.uuid = row.uuid;
      _this.relId = row.id;
      _this.isImport = false;
      _this.thisData = row;
      _this.editDialogVisible = true;
      console.log("row.uuid="+_this.uuid)

      _this.pId = row.id;
      _this.relevanceEdit = {
        id: row.id,
        isUseDy: row.isUseDy,
        isDisable: row.isDisable,
        isLock: row.isLock,
        isAdavence: row.isAdavence,
      };
      _this.checked = row.isUseDy == 1;
      _this.editQuery = row;
      //获取产品标识列表
      let ttquery = {
        id: row.id,
      };
      _this.getDetailList(ttquery);
      //获取关联第三方系统产品信息列表
      _this.getThirdSysDetail();

    },

    getThirdSysDetail() {
      let query = {
        id: this.relevanceEdit.id,
      };
      thirdSysDetail(query)
        .then((response) => {
          this.loading = false;
          this.sysList = response.data.list || [];
        })
        .catch(() => {
          this.loading = false;
          this.sysList = [];
        });
    },
    deleteDialog(_this,row) {
      _this.$confirm('确认删除吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          let param = {
            id: row.bpcrid
          }
          deleterel(param)
            .then((res) => {
              if (res.code == 20000) {
                _this.$message.success("删除成功!");
              } else {
                _this.$message.error(res.message);
              }
              _thisgetList();
            })
        })
        .catch(() => {

        })


    },


    closeCategory() {
      this.selectHospProductVisible = false;
      this.getList();
    },
    handleCurrentChange(val) {
      this.filterQuery.page = val.page;
      this.getList();

    },

    handleForm() {
      if (this.rId == null || this.rId == 10000) {
        this.$message("请选择分类!");
        this.selectHospProductVisible = false;
      } else {
        this.selectHospProductVisible = true;
      }

    },


    handleNodeClick(data) {
      this.rId = data.code;
      if (data.code != 10000) {
        this.filterQuery.code = data.code;
      } else {
        this.filterQuery.code = null;
      }
      this.filterQuery.page = 1;
      this.getList();
    },


    remove(node, data) {
      if (data.id) {
        this.$confirm("确认删除该节点吗?", "提示", {
          type: "warning",
        })
          .then(() => {
            this.deleteLoading = true;
            let param = {id: data.id, code: data.code};
            deleteBasicHospType(param)
              .then((response) => {
                this.deleteLoading = false;
                if (response.code !== 20000) {
                  this.$message.error(response.message);
                  return false;
                }
                this.getTerrList();
                this.$message.success("删除成功");
              })
              .catch(() => {
                this.deleteLoading = false;
              })

          })
          .catch(() => {
            this.$message.info("取消删除");
          })
      }
    },


    forInvSubmit() { // 新增 编辑 提交
      if (this.subData.code != 10000 && this.subData.parentCode == null) {
        this.$message.error("上级菜单不能为空");
        return
      }
      if (this.subData.name == null) {
        this.$message.error("名称不能为空！");
        return
      }
      this.subLoading = true
      if (this.subData.id != null) {
        uodateBasicHospType(this.subData).then((response) => {
          this.subLoading = false
          if (response.code == 20000) {
            this.subFormVisible = false;
            this.getTerrList();
          } else {
            this.$message.error(response.message);
          }
        }).catch(() => {
          this.subLoading = false
          this.subFormVisible = false;
        });
      } else {
        saveBasicHospType(this.subData).then((response) => {
          this.subLoading = false
          if (response.code == 20000) {
            this.subFormVisible = false;
            this.getTerrList();
          } else {
            this.$message.error(response.message);
          }
        }).catch(() => {
          this.subLoading = false
          this.subFormVisible = false;
        });
      }


    },


    hideForm() {
      this.formVisible = false;
      this.subFormVisible = false;
      this.resetForm();
      return true;
    },
    // 刷新表单
    resetForm() {
      if (this.$refs["dataForm"]) {
        // 清空验证信息表单
        this.$refs["dataForm"].clearValidate();
        // 刷新表单
        this.$refs["dataForm"].resetFields();
        this.getList();
      }
    },

    append(data, formName) {//新增 编辑
      this.formName = formName;
      if (formName === "edit") {
        this.subData = JSON.parse(JSON.stringify(data));
        this.subData.name = JSON.parse(JSON.stringify(data.label));
      } else if (formName === "add") {
        this.subData = {
          parentCode: JSON.parse(JSON.stringify(data)).code
        };
      }
      this.getTreeselect(data);
      this.subFormVisible = true;
    },

    /** 查询菜单下拉树结构 */
    getTreeselect(row) {
      if (row != null) {
        var data = {
          code: row.code,
          type: 1
        }
      }
      getOneName().then(res => {
        const menu = {id: res.data.id, code: res.data.code, name: res.data.name, children: []};
        getListMenu(data).then(response => {
          this.fromDeptOptions = [];
          menu.children = this.handleTree(response.data, "code", "parentCode");
          console.log(menu)
          this.fromDeptOptions.push(menu);
          console.log(this.fromDeptOptions)
        });
      })
    },

    /** 转换菜单数据结构 */
    normalizer(node) {
      if (node.children && !node.children.length) {
        delete node.children;
      }
      return {
        id: node.code,
        label: node.name,
        children: node.children
      };
    },


    getTerrList() {
      getListTree(this.query)
        .then((response) => {
          var invlist = response.data || [];
          this.treeList = this.handleTree(invlist, "code", "parentCode");
        })
        .catch(() => {
        });
    },

    hideSearch() {
      this.showSearch = !this.showSearch;
    },
    keyup_submit(_this,event) {
      _this.filterQuery.page = 1;
      _this.getList();
      event.target.select();
    },
    getDetailList(detailQuery) {
      this.loading = true;
      filterByUuid(detailQuery)
        .then((response) => {
          this.isUseDyCheck = false;
          this.loading = false;
          this.detailList = response.data || [];
          this.detailList.forEach((item, index, array) => {
            // this.detailList[index].isAdavence = item.adavence
            // this.detailList[index].isDisable = item.disable
            // this.detailList[index].useMuti = item.useMuti
            if (item.zxxsbzbhsydysl > 1) {
              this.isUseDyCheck = true;
            }
          });
          this.productType = this.detailList[0].productType;
          this.editQuery.versionNumber = this.detailList[0].versionNumber
          this.editQuery.originUuid = this.detailList[0].originUuid
        })
        .catch(() => {
          this.loading = false;
          this.detailList = [];
        });
    },
    executeFuc(row,type,clickFuc,value){
      return executeFuc(this,row,type,clickFuc,value);
    },
    executeEval(row,expression,defaultRet){
      if(expression){
        return eval(expression);
      }
      return defaultRet;
    }
  },
  mounted() {
  },
  components: {
    Treeselect, selectProduct,selectUdiVersion,
  },
  created() {
    getHead("productCategory","1").then((re) => {
      // 处理返回的数据
      this.tableObj = re.data;
      this.tableHeader = re.data.tableList;
      this.queryList = re.data.queryList;
      this.fromList = re.data.fromList;
      this.getList();
    });
    this.getTerrList();
  },
};
</script>
<style scoped lang="scss">
.iconButton {
  margin-left: 0px;
  height: 30px;
}

.tree {
  ::v-deep .el-tree-node {
    white-space: normal;

    .el-tree-node__content {
      height: 100%;
      align-items: start;
    }

    .el-tree-node:focus > .el-tree-node__content {
      background-color: rgb(158, 213, 250) !important;
    }
  }
}

.itemTag {
  float: left;
  text-align: right;
  margin-top: 5px;
  padding-right: 10px;
  width: 35%;
}

.text {
  font-size: 13px;
  font-family: "Microsoft YaHei";
}


.edit-row {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 0px;
}

.el-row {
  display: flex;
  flex-wrap: nowrap;
}

/* .el-col {
  border-radius: 4px;
  flex-wrap: wrap;
} */

.el-table .cell.el-tooltip {
  white-space: pre-wrap;
}

.form-title {
  font-size: 16px;
  font-family: Noto Sans SC;
  font-weight: bold;
  color: #303133;
  padding-bottom: 17px;
  padding-top: 17px;
}
</style>
