<template>
  <!-- 配送目录管理 -->
  <div style="display: flex">
    <!--  <el-card style="width:18%;margin-right:18px;border-radius:6px;">
     <el-tabs v-model="activeName" type="card" @tab-click="tabClick" stretch>
          <el-tab-pane label="按分类" name="grp"></el-tab-pane>
          <el-tab-pane label="按机构" name="org"></el-tab-pane>
      </el-tabs>
      <el-tree
        :data="data"
        :props="defaultProps"
        node-key="hospId"
        @node-click="handleNodeClick"
        style="margin-top:10px;"
      ></el-tree> 
    </el-card>-->
    <div class="right-common-box">
      <el-form :model="listQuery" ref="listQuery" :inline="true" label-width="100px">
        <el-form-item label="耗材编码" prop="materialId" class="long">
          <el-input
            v-model="listQuery.materialId"
            placeholder="请输入耗材编码"
          ></el-input>
        </el-form-item>
        <el-form-item label="医保编码" prop="ybbm" class="long">
          <el-input v-model="listQuery.ybbm" placeholder="请输入医保编码"></el-input>
        </el-form-item>
        <el-form-item label="耗材名称" prop="materialName" class="long">
          <el-input
            v-model="listQuery.materialName"
            placeholder="请输入耗材名称"
          ></el-input>
        </el-form-item>
        <el-form-item label="是否集采" prop="ifJc" class="long">
          <el-select v-model="listQuery.ifJc" placeholder="请选择是否集采" clearable>
            <el-option
              v-for="item in isFasData"
              :key="item.value"
              :label="item.name"
              :value="item.name"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="集采批次" prop="batch" class="long">
          <el-input v-model="listQuery.batch" placeholder="请输入集采批次"></el-input>
          <!-- <el-select v-model="listQuery.batch" placeholder="请选择集采批次" clearable>
            <el-option
              v-for="item in isFasData"
              :key="item.value"
              :label="item.name"
              :value="item.value"
            ></el-option>
          </el-select> -->
        </el-form-item>
        <el-form-item label="商品类别" prop="prodType" class="long">
          <el-select v-model="listQuery.prodType" placeholder="请选择商品类别" clearable>
            <el-option
              v-for="item in isFasData"
              :key="item.value"
              :label="item.name"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="规格" prop="spec" class="long">
          <el-input v-model="listQuery.spec" placeholder="请输入规格"></el-input>
        </el-form-item>
        <el-form-item label="型号" prop="model" class="long">
          <el-input v-model="listQuery.model" placeholder="请输入型号"></el-input>
        </el-form-item>
        <el-form-item label="材质" prop="matl" class="long">
          <el-input v-model="listQuery.matl" placeholder="请输入材质"></el-input>
        </el-form-item>

        <el-form-item label="生产来源" prop="source" class="long">
          <el-select v-model="listQuery.source" placeholder="请选择生产来源" clearable>
            <el-option
              v-for="item in isFasData"
              :key="item.value"
              :label="item.name"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="生产企业" prop="prodentpName" class="long">
          <el-select
            v-model="listQuery.prodentpName"
            placeholder="请选择生产企业"
            clearable
          >
            <el-option
              v-for="item in isFasData"
              :key="item.value"
              :label="item.name"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="当前状态" prop="status" class="long">
          <el-select v-model="listQuery.status" placeholder="请选择当前状态" clearable>
            <el-option
              v-for="item in statusData"
              :key="item.value"
              :label="item.name"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="对码状态" prop="stas">
          <el-select
            v-model="listQuery.stas"
            placeholder="请选择对码状态"
            clearable
          >
            <el-option
              v-for="item in crspFlgOption"
              :key="item.value"
              :label="item.name"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item>
          <el-button type="primary" @click="getHospConsum('search')">查询</el-button>
          <el-button @click="reset('consumableData')">重置</el-button>
        </el-form-item>
      </el-form>
      <div class="right-button">
        <el-button type="primary" icon="el-icon-plus" @click="handleUpdate('search')"
          >新增目录
        </el-button>
      </div>
      <el-table
        v-loading="listLoading"
        element-loading-text="加载中"
        :data="list"
        fit
        stripe
        border
      >
        <template slot="empty">
          <img src="@/assets/nopage.png" alt />
          <p>暂无数据</p>
        </template>
        <el-table-column fixed type="index" label="序号" width="60" />
        <el-table-column label="耗材编码" prop="materialId" width="80" />
        <el-table-column label="医保编码" prop="ybbm" width="80" />
        <el-table-column label="耗材名称" prop="materialName" width="80" />
        <el-table-column label="是否集采" prop="ifJc" width="80" />
        <el-table-column label="集采批次" prop="batch" width="80" />
        <el-table-column label="商品类别" prop="prodType" width="80" />
        <el-table-column label="规格" prop="spec" width="80" />
        <el-table-column label="型号" prop="model" width="80" />
        <el-table-column label="材质" prop="matl" width="80" />
        <el-table-column label="生产来源" prop="source" width="80" />
        <el-table-column label="注册证号" prop="approve" width="80" />
        <el-table-column label="生产企业" prop="prodentpName" width="80" />
        <el-table-column label="采购价" prop="pric" width="80" />
        <el-table-column label="当前状态" prop="status" width="80">
          <template #default="{ row }">
              <span v-if="row.status == 'A'">待审核</span>
              <span v-if="row.status == 'B'">审核中</span>
              <span v-if="row.status == 'C'">审核通过</span>
            </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="160">
          <template slot-scope="scope">
            <div>
              <el-button type="text" @click="handleDui(scope.row)">编辑</el-button>
              <!-- <el-button type="text" v-if="scope.row.stas == '1'"  @click="handleCanc(scope.row)">取消对码</el-button> -->
              <!-- <el-button type="text"   @click="handlePrice(scope.row)">申请调价</el-button> -->
            </div>
          </template>
        </el-table-column>
      </el-table>
      <!--分页-->
      <yl-pagination
        v-show="total > 0"
        :total="total"
        :page.sync="listQuery.current"
        :limit.sync="listQuery.size"
        @pagination="getHospConsum"
      />
    </div>

    <el-dialog title="调价申请" :visible.sync="dialogPrice" width="55%">
      <el-form
        ref="dataForm"
        :rules="rules"
        :model="temp"
        label-position="right"
        label-width="80px"
      >
        <el-row>
          <el-col :span="8">
            <el-form-item label="药品编码" prop="drugListId">
              <el-input v-model.trim="temp.drugListId" readonly placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="药品名称" prop="drugName">
              <el-input v-model.trim="temp.drugName" readonly placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="剂型" prop="dosformName">
              <el-input v-model.trim="temp.dosformName" readonly placeholder="请输入" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="规格" prop="specName">
              <el-input v-model.trim="temp.specName" readonly placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="包装单位" prop="pacUnt">
              <el-input v-model.trim="temp.pacUnt" readonly placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="生产企业" prop="prodentpName">
              <el-input v-model.trim="temp.prodentpName" readonly placeholder="请输入" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="当前价格" prop="pricInit">
              <el-input v-model.trim="temp.pricInit" readonly placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="调整价格" prop="pricCurr">
              <el-input v-model.trim="temp.pricCurr" placeholder="请输入调整后价格" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-form-item label="申请原因" prop="appyRea">
            <el-input
              type="textarea"
              v-model.trim="temp.appyRea"
              placeholder="请输入调价原因"
            />
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item label="上传文件" prop="fileId" :rules="rules.uploadRequired">
            <yl-upload :fileId="temp.fileId" @getUpload="getUpload" urlName="acco">
              <template v-slot:dec>只能上传pdf文件</template>
            </yl-upload>
          </el-form-item>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogPrice = false">取消</el-button>
        <el-button type="primary" @click="commitData()" :loading="ccLoad">确认</el-button>
      </div>
    </el-dialog>
    <el-dialog title="选择耗材" :visible.sync="dialogAdd" width="75%">
      <template>
        <el-form :model="listQueryadd" ref="listQueryadd" :inline="true">
          <el-form-item label="耗材名称" prop="materialName" class="long">
            <el-input
              v-model="listQueryadd.materialName"
              placeholder="请输入耗材名称"
            ></el-input>
          </el-form-item>
          <el-form-item label="耗材规格" prop="spec" class="long">
            <el-input v-model="listQueryadd.spec" placeholder="请输入耗材规格"></el-input>
          </el-form-item>
          <el-form-item label="耗材编码" prop="materialId" class="long">
            <el-input
              v-model="listQueryadd.materialId"
              placeholder="请输入耗材编码"
            ></el-input>
          </el-form-item>
          <el-form-item label="医保编码" prop="ybbm" class="long">
            <el-input v-model="listQueryadd.ybbm" placeholder="请输入医保编码"></el-input>
          </el-form-item>
          <el-form-item label="是否集采" prop="ifJc" class="long">
            <el-select v-model="listQueryadd.ifJc" placeholder="请选择是否集采" clearable>
              <el-option
                v-for="item in isFasData"
                :key="item.value"
                :label="item.name"
                :value="item.name"
              ></el-option>
            </el-select>
          </el-form-item>
          <!-- <el-form-item label="对码状态" prop="stas">
          <el-select
            v-model="listQuery.stas"
            placeholder="请选择对码状态"
            clearable
          >
            <el-option
              v-for="item in crspFlgOption"
              :key="item.value"
              :label="item.name"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item> -->
          <el-form-item>
            <el-button type="primary" @click="getdialog('search')">查询</el-button>
            <el-button @click="resetdialog('consumableData')">重置</el-button>
          </el-form-item>
        </el-form>
        <el-table
          ref="multipleTable"
          v-loading="listdialogLoading"
          element-loading-text="加载中"
          fit
          stripe
          border
          :data="consumableData"
          border
          style="width: 100%"
          row-key="id"

          @selection-change="handleSelectionChange"
          highlight-current-row
        >
          <el-table-column
            type="selection"
            :selectable="selected"
            :reserve-selection="true"
            width="55"
          ></el-table-column>
          <el-table-column prop="ybbm" label="医保编码" width="150"> </el-table-column>
          <el-table-column prop="materialName" label="耗材名称" width="180">
          </el-table-column>
          <el-table-column prop="ifJc" label="是否集采" width="120"> </el-table-column>
          <el-table-column prop="batch" label="集采批次"> </el-table-column>
          <el-table-column prop="prodType" label="商品类别" width="120">
          </el-table-column>
          <el-table-column prop="prodType" label="商品分类" width="120">
          </el-table-column>
          <el-table-column prop="spec" label="规格"> </el-table-column>
          <el-table-column prop="model" label="型号"> </el-table-column>
          <el-table-column prop="matl" label="材质"> </el-table-column>
          <el-table-column prop="pacMatl" label="包装材质"> </el-table-column>
          <el-table-column prop="source" label="生产来源"> </el-table-column>
          <el-table-column prop="approve" label="注册证号"> </el-table-column>
          <el-table-column prop="prodentpName" label="生产企业" width="120">
          </el-table-column>
        </el-table>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="handleConfirm" :loading="addLoading"
            >确认</el-button
          >
        </div>
        <!-- <el-form :model="form" ref="form" :rules="rules">
          <el-table
            :data="form.splerData"
            border
            style="width: 100%"
            v-loading="supLoading"
          >
            <el-table-column
              fixed
              prop="splerDrugName"
              label="药品名称"
              width="150"
            >
            </el-table-column>
            <el-table-column
              prop="splerDosformName"
              label="剂型名称"
              width="120"
            >
            </el-table-column>
            <el-table-column prop="splerProdentpName" label="生产企业">
            </el-table-column>
            <el-table-column
              prop="splerDrugListId"
              label="药品编码"
              width="120"
            >
            </el-table-column>
            <el-table-column prop="address" label="规格" width="250">
              <template slot-scope="scope">
                <div class="drug-name">
                  {{"供应商规格 【" +scope.row.splerSpecName +"*" +scope.row.splerPrepunt +"/" +scope.row.splerPacUnt +"】"}}
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="address" label="转换比" width="150">
              <template slot-scope="scope">
                <el-form-item :prop="'splerData.' + scope.$index + '.convrat'" :rules="{required: true,message: '输入转换比',trigger: 'change'}" >
                  <el-input v-model="scope.row.convrat" placeholder="请输入转换比"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作" width="60">
              <template slot-scope="scope">
                <el-button
                  @click="handleClick(scope.row, scope.$index)"
                  type="text"
                  size="small"
                  >对码</el-button
                >
              </template>
            </el-table-column>
          </el-table>
        </el-form> -->

        <!--分页-->
        <yl-pagination
          v-show="totalC > 0"
          :total="totalC"
          :page.sync="listQueryadd.current"
          :limit.sync="listQueryadd.size"
          @pagination="getdialog"
        />
      </template>
    </el-dialog>
  </div>
</template>

<script>
import ylPagination from "@/components/yl-pagination";
import {
  selectSplerMcsList,
  selectMcsList,
  saveSplerMcs,
  PricChg,
  QueryHospList,
  QueryHospDrugList,
  QuerySplerDrugList,
  DrugMatch,
  CancMatch,
} from "@/api/consumCataManage-sup/index";
import rulesR from "@/utils/rules";
import ylUpload from "@/components/yl-upload";
export default {
  components: {
    ylPagination,
    ylUpload,
  },
  data() {
    return {
      activeName: "grp",
      rulesR,
      hospId: null,
      data: [],
      defaultProps: {
        children: "children",
        label: "hospName",
      },
      listQuery: {
        current: 1,
        size: 10,
        materialName: "",
        materialId: "",
        spec: "",
        ybbm: "",
        ifJc: "",
        batch: "",
        model: "",
        source: "",
        prodType: "",
        matl: "",
        prodentpName: "",
        status: "",
      },
      supQuery: {
        current: 1,
        size: 10,
        materialName: "",
        materialId: "",
        spec: "",
        ybbm: "",
        ifJc: "",
        batch: "",
        model: "",
        source: "",
        prodType: "",
        matl: "",
        prodentpName: "",
        status: "",
      },
      listLoading: false,
      list: [],
      total: 0,
      tableLoading: false,
      supLoading: false,
      tableData: [],
      crspFlgOption: [
        { value: "0", name: "未对码" },
        { value: "1", name: "已对码" },
      ],
      isFasData: [
        { value: "0", name: "否" },
        { value: "1", name: "是" },
      ],
      statusData:[
        {value:"A",name:"待审核"},
        {value:"B",name:"审核中"},
        {value:"C",name:"审核通过"},
      ],
      dialogPrice: false,
      dialogDui: false,
      ccLoad: false,
      temp: {
        drugListId: "",
        drugName: "",
        dosformName: "",
        specName: "",
        pacUnt: "",
        prodentpName: "",
        pricInit: "",
        pricCurr: "",
        appyRea: "",
        fileId: "",
      },
      rules: {
        pricCurr: [
          {
            required: true,
            message: "调整价格不能为空",
            trigger: "blur",
          },
          {
            pattern: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
            message: "请输入数字，最多两位小数",
            trigger: "blur",
          },
        ],
        appyRea: [
          {
            required: true,
            message: "申请原因不能为空",
            trigger: "blur",
          },
        ],
        num: [
          {
            required: true,
            message: "请输入转换比",
            trigger: "change",
          },
        ],
        uploadRequired: [{ required: true, message: "请上传文件", trigger: "change" }],
      },
      tableData: [
        {
          date: "2016-05-02",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1517 弄",
          zip: 200333,
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1519 弄",
          zip: 200333,
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1516 弄",
          zip: 200333,
        },
      ],
      consumableData: [],
      form: {
        splerData: [],
      },
      // 省平台目录
      listdialogLoading: false,
      dialogAdd: false,
      listQueryadd: {
        materialName: "",
        materialId: "",
        spec: "",
        ybbm: "",
        ifJc: "",
        batch: "",
        model: "",
        current: 1,
        size: 10,
      },
      totalC: false,
      addLoading: false,
      insertMcsList: [],
    };
  },
  methods: {
    // tabClick(tab){
    //     if(tab.label == "按机构"){
    //         this.getData();
    //         this.defaultProps.label = 'hospName'
    //     }else if(tab.label == "按分类"){
    //         // this.getData4();
    //         // this.defaultProps.label = 'orgGrpName'
    //         // this.listQuery.type = 'grp';
    //     }
    // },
    // 上传文件
    getUpload(id) {
      this.temp.fileId = id;
      if (id) {
        this.$refs.dataForm.clearValidate("fileId");
      } else {
        this.$refs.dataForm.validateField("fileId");
      }
    },
    validateField(form, index) {
      let result = true;
      for (let item of this.$refs[form].fields) {
        if (item.prop.split(".")[1] == index) {
          this.$refs[form].validateField(item.prop, (error) => {
            if (error != "") {
              result = false;
            }
          });
        }
        if (!result) break;
      }
      return result;
    },
    // 搜索获取医院药品列表
    getHospConsum(type) {
      if (type == "search") {
        this.listQuery.current = 1;
      }
      this.listLoading = true;
      // this.listQuery.hospId = this.hospId;
      selectSplerMcsList(this.listQuery)
        .then((res) => {
          this.list = res.data.records;
          this.total = res.data.total;
          this.listLoading = false;
        })
        .catch((err) => {
          this.listLoading = false;
        });
    },
    // 获取新增目录弹框数据
    getdialog(type) {
      if (type == "search") {
        this.listQueryadd.current = 1;
      }
      this.listdialogLoading = true;
      // this.listQuery.hospId = this.hospId;
      selectMcsList(this.listQueryadd)
        .then((res) => {
          this.consumableData = res.data.records;
          this.totalC = res.data.total;
          this.listdialogLoading = false;
        })
        .catch((err) => {
          this.listdialogLoading = false;
        });
    },
    // 点击获取医院药品列表
    handleNodeClick(data) {
      this.listLoading = true;
      this.hospId = data.hospId;
      selectSplerMcsList({ hospId: data.hospId })
        .then((res) => {
          this.list = res.data.records;
          this.total = res.data.total;
          this.listLoading = false;
          console.log(res, "医院目录");
        })
        .catch((err) => {
          this.listLoading = false;
        });
    },
    // 获取医院列表
    // getData(type) {
    //   this.data = [];
    //   this.listLoading = true;
    //   QueryHospList()
    //     .then(res => {
    //       this.listQuery.hospId = res.data[0].hospId;
    //       this.data = res.data
    //       this.listLoading = false;
    //     })
    //     .catch(err => {
    //       this.listLoading = false;
    //     });
    // },

    reset(type) {
      if (type === "consumableData") {
        this.$refs.listQuery.resetFields();
        this.getHospConsum();
      } else {
        this.$refs.supQuery.resetFields();
        this.searchSup();
      }
    },
    resetdialog(type) {
      if (type === "consumableData") {
        this.$refs.listQueryadd.resetFields();
        this.getdialog();
      } else {
        this.$refs.supQuery.resetFields();
        this.searchSup();
      }
    },
    // 多选
    handleSelectionChange(e) {
      this.insertMcsList = e;
      // e.forEach((v) => {
      //   if (v.readFlag == "0") {
      //     this.marked.push(v.id);
      //   }
      // });
      // console.log(e, "ee");
    },
    // 多选后选过的禁用
    selected(row, index) {
      if (
        this.list.some((el) => {
          return el.ybbm === row.ybbm;
        })
      ) {
        return false;
      } else {
        return true;
      }
    },

    // 新增目录
    handleUpdate(type) {
      if (type == "search") {
        this.listQueryadd.current = 1;
      }
      this.dialogAdd = true;
      this.getdialog();
    },
    // 新增目录确认
    handleConfirm() {
      if (this.insertMcsList.length == 0) {
        this.$message({
          message: "请选择要添加的数据",
          type: "warning",
        });
      } else {
        this.$confirm("确认提交", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          this.addLoading = true;
          saveSplerMcs({ insertMcsList: this.insertMcsList })
            .then((res) => {
              if (res.success === true) {
                this.addLoading = false;
                this.getHospConsum();
                this.insertMcsList = [];
                this.dialogAdd = false;
                this.$refs.multipleTable.clearSelection()
              } else {
                this.addLoading = false;
                this.$refs.multipleTable.clearSelection()
                // this.$message({
                //   message: res.message || "操作失败",
                //   type: "error",
                // });
              }
            })
            .catch(() => {
              this.addLoading = false;
              this.dialogAdd = false;
              this.$refs.multipleTable.clearSelection()
            });
        });
      }

      // saveSplerMcs
      // this.addLoading = false;
      // this.dialogAdd = false;
    },
    // 申请调价

    handlePrice(row) {
      this.dialogPrice = true;
      this.temp.drugListId = row.drugListId;
      this.temp.drugName = row.drugName;
      this.temp.dosformName = row.dosformName;
      this.temp.specName = row.specName;
      this.temp.pacUnt = row.pacUnt;
      this.temp.prodentpName = row.prodentpName;
      this.temp.pricInit = row.pricCurr ? row.pricCurr : 0;
      this.$nextTick(() => {
        this.$refs.dataForm.resetFields();
      });
    },
    // 调价申请 确认
    commitData() {
      this.$refs["dataForm"].validate((valid) => {
        if (valid) {
          this.ccLoad = true;
          let data = {
            drugListId: this.temp.drugListId,
            pricInit: this.temp.pricInit,
            pricCurr: this.temp.pricCurr,
            appyRea: this.temp.appyRea,
            hospId: this.hospId,
            fileId: this.temp.fileId,
          };
          PricChg(data)
            .then((res) => {
              if (res.success === true) {
                this.$message("调价已申请");
                this.ccLoad = false;
                this.dialogPrice = false;
                this.getHospConsum();
              }
            })
            .catch((err) => {
              this.ccLoad = false;
            });
        }
      });
    },
    // 对码弹窗获取供应商列表
    handleDui(row) {
      // console.log(row, "编辑");
      this.$router.push({
        name: "catalogdetails",
        query: { id: row.id },
      });
      // this.dialogDui = true;
      // this.consumableData = [];
      // this.consumableData.push(row);
      // this.supLoading = true;
      // QuerySplerDrugList({ hospId: row.hospId })
      //   .then((res) => {
      //     this.form.splerData = res.data.records;
      //     this.total = res.data.total;
      //     this.supLoading = false;
      //   })
      //   .catch((err) => {
      //     this.supLoading = false;
      //   });
    },
    // 对码操作
    handleClick(item, index) {
      let DrugMatchObj = {
        hospId: this.hospId,
        drugListId: this.consumableData[0].drugListId,
        splerDrugListId: item.splerDrugListId,
        convrat: item.convrat,
      };

      if (!this.validateField("form", index)) {
        return;
      } else {
        DrugMatch(DrugMatchObj).then((res) => {
          if (res.success === true) {
            this.dialogDui = false;
            this.getHospConsum();
            this.$message({
              message: "对码成功",
              type: "success",
            });
          } else {
            this.$message.error("对码失败");
          }
        });
      }
    },
    // 取消对码
    handleCanc(row) {
      this.$confirm("此操作会取消该药品对码, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          CancMatch({ hospId: this.hospId, drugListId: row.drugListId }).then((res) => {
            if (res.success) {
              this.getHospConsum();
              this.$message({
                type: "success",
                message: "取消对码成功",
              });
            }
          });
        })
        .catch(() => {});
    },
    //搜索供应商列表
    searchSup() {
      this.supLoading = true;
      this.supQuery.hospId = this.hospId;
      QuerySplerDrugList(this.supQuery)
        .then((res) => {
          this.form.splerData = res.data.records;
          this.total = res.data.total;
          this.supLoading = false;
        })
        .catch((err) => {
          this.supLoading = false;
        });
    },
  },
  mounted() {
    this.getHospConsum();
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-card__body {
  padding: 12px;
}
::v-deep .el-tree-node__content {
  height: 35px;
}
::v-deep .el-input__suffix {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 15px;
}
::v-deep .long .el-form-item__content {
  width: 220px;
}
::v-deep .long .el-input__inner {
  width: 199px;
}
</style>
