<template>
  <div class="requisition_add">
    <el-tabs type="border-card" v-model="tabValue" @tab-click="handleClick">
      <el-tab-pane label="基本信息" name="first">
        <div style="width: 100%;height: 680px;overflow-y: auto; overflow-x: hidden;">
        <el-form :model="basicForm" :rules="basicRules" ref="basic" label-width="160px">
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="单据编码" prop="billCode">
                <el-input disabled v-model="basicForm.billCode"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="申请组织" prop="orgId">
                <el-input disabled v-model="basicForm.orgId"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="四级分类" prop="classifyId">
                <el-input :disabled="disable" v-model="basicForm.classifyId">
                  <el-button :disabled="disable" slot="append" icon="el-icon-more" @click="test01"></el-button>
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="医药物料" prop="isMedicine">
                <el-select
                    v-model="basicForm.isMedicine"
                    placeholder="医药物料"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                  </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="DI" prop="diCode">
                <el-input :disabled="disable" v-model="basicForm.diCode"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="物料名称" prop="name">
                <el-input :disabled="disable" v-model="basicForm.name"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="英文名称" prop="enName">
                <el-input :disabled="disable" v-model="basicForm.enName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="简称" prop="commonName">
                <el-input :disabled="disable" v-model="basicForm.commonName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="规格" prop="specification">
                <el-input :disabled="disable" v-model="basicForm.specification"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="型号" prop="model">
                <el-input :disabled="disable" v-model="basicForm.model"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="计量单位" prop="unitId">
                <el-input :disabled="disable" v-model="basicForm.unitId">
                  <el-button :disabled="disable" slot="append" icon="el-icon-more" @click="test02"></el-button>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="生产厂家/代理人" prop="manufacturerId">
                <el-input :disabled="disable" v-model="basicForm.manufacturerId">
                  <el-button :disabled="disable" slot="append" icon="el-icon-more" @click="test02"></el-button>
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="注册人/上市许可持有人" prop="registrant">
                <el-input :disabled="disable" v-model="basicForm.registrant"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="产地" prop="originPlace">
                <el-input :disabled="disable" v-model="basicForm.originPlace"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="厂家物料名称" prop="manufacturersMaterialName">
                <el-input :disabled="disable" v-model="basicForm.manufacturersMaterialName"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="B2C物料" prop="isB2c">
                <el-select
                    v-model="basicForm.medicineMaterial"
                    placeholder="B2C物料"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="成套件" prop="assembly">
                <el-select
                    v-model="basicForm.assembly"
                    placeholder="成套件"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="批号及库存状态管理" prop="isInventoryStatus">
                <el-select
                    v-model="basicForm.isInventoryStatus"
                    placeholder="批号及库存状态管理"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="效期管理" prop="expiryDateManagerment">
                <el-select
                    v-model="basicForm.expiryDateManagerment"
                    placeholder="效期管理"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="近效期管理" prop="nearOnsetManagerment">
                <el-select
                    v-model="basicForm.nearOnsetManagerment"
                    placeholder="近效期管理"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="有效期" prop="usefulLife">
                <el-select
                    v-model="basicForm.usefulLife"
                    placeholder="有效期"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="有效期单位" prop="expiryUnitId">
                <el-select
                    v-model="basicForm.expiryUnitId"
                    placeholder="有效期单位"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="有效期至单位" prop="usefulLifeUnitId">
                <el-select
                    v-model="basicForm.usefulLifeUnitId"
                    placeholder="有效期至单位"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="近效期预警天数" prop="recentWarningPeriod">
                <el-select
                    v-model="basicForm.recentWarningPeriod"
                    placeholder="近效期预警天数"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="有效期单位" prop="expiryUnitId">
                <el-select
                    v-model="basicForm.expiryUnitId"
                    placeholder="有效期单位"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="有效期至单位" prop="usefulLifeUnitId">
                <el-select
                    v-model="basicForm.usefulLifeUnitId"
                    placeholder="有效期至单位"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="近效期预警天数" prop="recentWarningPeriod">
                <el-select
                    v-model="basicForm.recentWarningPeriod"
                    placeholder="近效期预警天数"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="存储条件" prop="storageCondition">
                <el-select
                    v-model="basicForm.storageCondition"
                    placeholder="存储条件"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="运输条件" prop="transportationCondition">
                <el-select
                    v-model="basicForm.transportationCondition"
                    placeholder="运输条件"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="物料税类" prop="materialRate">
                <el-input :disabled="disable" v-model="basicForm.materialRate"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="交货周期" prop="deliveryPeriod">
                <el-select
                    v-model="basicForm.deliveryPeriod"
                    placeholder="交货周期"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="最小起定量" prop="minOrderQty">
                <el-input :disabled="disable" v-model="basicForm.minOrderQty"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="最小包装量" prop="minPackQty">
                <el-input :disabled="disable" v-model="basicForm.minPackQty"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="采购员" prop="puPersonnelId">
                <el-input :disabled="disable" v-model="basicForm.puPersonnelId"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="最小批量" prop="minBatchQty">
                <el-input :disabled="disable" v-model="basicForm.minBatchQty"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="长度(MM)" prop="length">
                <el-input :disabled="disable" v-model="basicForm.length"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="高度(MM)" prop="height">
                <el-input :disabled="disable" v-model="basicForm.height"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="宽度(MM)" prop="width">
                <el-input :disabled="disable" v-model="basicForm.width"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="箱包装数" prop="boxPackaingQty">
                <el-input :disabled="disable" v-model="basicForm.boxPackaingQty"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="中包装数" prop="mediumPackageQty">
                <el-input :disabled="disable" v-model="basicForm.mediumPackageQty"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="包装说明" prop="packExplain">
                <el-input :disabled="disable" v-model="basicForm.packExplain"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="业务线" prop="businessLine">
                <el-input :disabled="disable" v-model="basicForm.businessLine"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="物料申请人" prop="proposerId">
                <el-input :disabled="disable" v-model="basicForm.proposerId"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="条形码" prop="barCode">
                <el-input :disabled="disable" v-model="basicForm.barCode"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="使用期限/次数" prop="serviceLife">
                <el-input :disabled="disable" v-model="basicForm.serviceLife"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="医保代码" prop="healthCode">
                <el-input :disabled="disable" v-model="basicForm.healthCode"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="原型系统物料编码" prop="oriMaterialCode">
                <el-input :disabled="disable" v-model="basicForm.oriMaterialCode"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="生产许可证/经营许可证/备案号" prop="productionPermit">
                <el-input :disabled="disable" v-model="basicForm.productionPermit"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="一级分类" prop="oneClass">
                <el-input :disabled="disable" v-model="basicForm.oneClass"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="二级分类" prop="twoClass">
                <el-input :disabled="disable" v-model="basicForm.twoClass"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="三级分类" prop="threeClass">
                <el-input :disabled="disable" v-model="basicForm.threeClass"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="启用状态" prop="isEnable">
                <el-input :disabled="disable" v-model="basicForm.isEnable"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="备注" prop="remark">
                <el-input :disabled="disable" v-model="basicForm.remark"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        </div>
      </el-tab-pane>

      <el-tab-pane label="医药属性" name="second">
        <el-form :model="basicForm2" ref="basic2" label-width="160px">
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="药品" prop="isDrug">
                <el-select
                    v-model="basicForm2.isDrug"
                    placeholder="药品"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="dict in dict.type.sys_medicine"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    />
                  </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="注册证号/备案凭证编号" prop="registrationNo">
                <el-input :disabled="disable" v-model="basicForm2.registrationNo"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="医疗器械" prop="medicalInstruments">
                <el-select
                    v-model="basicForm2.medicalInstruments"
                    placeholder="医疗器械"
                    clearable
                    :disabled="disable"
                  >
                    <el-option
                      v-for="dict in dict.type.medical_instruments"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    />
                  </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="通用名称" prop="commonName">
                <el-input :disabled="disable" v-model="basicForm2.commonName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="批准文号" prop="ratifyBatchNo">
                <el-input :disabled="disable" v-model="basicForm2.ratifyBatchNo"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="剂型" prop="dosageFrom">
                <el-input :disabled="disable" v-model="basicForm2.dosageFrom"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="旧注册证号" prop="oriRegistrationNo">
                <el-input :disabled="disable" v-model="basicForm2.oriRegistrationNo"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="养护类型" prop="curingType">
                <el-input :disabled="disable" v-model="basicForm2.curingType"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <!-- <el-row style="margin-bottom: 12px;">
          <span>物料类别</span>
        </el-row>
        <el-row style="margin-bottom: 12px;">
          <el-button type="primary" size="small" plain @click="addLine">新增</el-button>
          <el-button type="primary" size="small" plain @click="handleDelete">删除</el-button>
          <el-button type="primary" size="small" plain @click="testsave">暂存</el-button>
        </el-row> -->
        <!-- <el-row>
          <el-col :span="12">
            <el-table 
            :data="basicForm2.medicineTypeChanges"
            class="request-table"
            @selection-change="handleSelectionChange"
            >
              <el-table-column type="selection" width="55" />
              <el-table-column label="序号" align="center" prop="sort">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.sort"></el-input>
                </template>
              </el-table-column>
              <el-table-column label="物料类别" align="center" prop="medicineCode">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.medicineCode"></el-input>
                </template>
              </el-table-column>
              <el-table-column label="类别名称" align="center" prop="medicineName">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.medicineName"></el-input>
                </template>
              </el-table-column>
            </el-table>
          </el-col>
        </el-row> -->
      </el-tab-pane>

      <!-- <el-tab-pane label="修改记录" name="third">
        <el-table 
          :data="basicForm.changeRecords"
          class="request-table"
          >
          <el-table-column label="字段名称" align="center" prop="pageCondtion" />
          <el-table-column label="变更前" align="center" prop="beforeChangeValue" />
          <el-table-column label="变更后" align="center" prop="afterChangeValue" />
        </el-table>
      </el-tab-pane> -->

      <el-tab-pane label="单据信息" name="fourth">
        <el-form :model="basicForm" ref="info" label-width="160px">
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="申请人" prop="createBy">
                <el-input disabled v-model="basicForm.createBy"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="申请时间" prop="applicationTime">
                <el-input disabled v-model="basicForm.applicationTime"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="创建人" prop="createByName">
                <el-input disabled v-model="basicForm.createByName"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="创建时间" prop="createTime">
                <el-input disabled v-model="basicForm.createTime"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="最后修改人" prop="updateByName">
                <el-input disabled v-model="basicForm.updateByName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="最后修改时间" prop="updateTime">
                <el-input disabled v-model="basicForm.updateTime"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="最后审核人" prop="reviewedByName">
                <el-input disabled v-model="basicForm.reviewedByName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="最后审核时间" prop="approvalTime">
                <el-input disabled v-model="basicForm.approvalTime"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="单据状态" prop="status">
                <el-input disabled v-model="basicForm.status"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-tab-pane>
    </el-tabs>

    <div class="btn_group">
      <el-col :span="1.5">
        <el-button type="primary" size="small" plain @click="save" v-if="pageStu == 'add' || pageStu == 'edit'">保存</el-button>
      </el-col>
      <el-col :span="1.5" style="margin: 0 10px;">
        <el-button type="primary" size="small" plain @click="submit" v-if="pageStu == 'add' || pageStu == 'edit'">提交</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" size="small" plain @click="back">返回</el-button>
      </el-col>
    </div>

    <popDialog
      ref="contractSelect"
      @doSubmit="selectionsToInput"
      :selectData="selectData"
      :single="true"
    />

    <factory
      ref="contractSelect2"
      @doSubmit="selectionsToInput2"
      :selectData="selectData2"
      :single="true"
    />
  </div>
</template>

<script>
import popDialog from '@/components/PopDialog/index.vue'
import factory from '@/components/PopDialog/productFactory.vue'
import { addReq, getReqDetail, editReq } from '@/api/requisition/basic'
export default {
  name: 'requisition_add',
  dicts: ['sys_storage_condition', 'sys_conditions_carriage', 'sys_medicine', 'medical_instruments', 'curing_type'],
  components: {
    popDialog,
    factory
  },
  props: ['pageStu', 'row', 'disable'],
  model: {
    prop: 'isList',
    event: 'jugislist'
  },
  data() {
    return{
      tabValue: 'first',
      basicForm: {
        billCode: '',
        orgId: '',
        // 四级分类/物料分类
        classifyId: '',
        // 是否医药物料
        isMedicine: '',
        // DI
        diCode: '',
        // 物料名称
        name: '',
        // 英文名称
        enName: '',
        commonName: '',
        specification: '',
        model: '',
        unitId: '',
        manufacturerId: '',
        registrant: '',
        originPlace: '',
        manufacturersMaterialName: '',
        isB2c: '',
        assembly: '',
        isInventoryStatus: '',
        expiryDateManagerment: '',
        nearOnsetManagerment: '',
        usefulLife: '',
        expiryUnitId: '',
        usefulLifeUnitId: '',
        recentWarningPeriod: '',
        storageCondition: '',
        transportationCondition: '',
        materialRate: '',
        deliveryPeriod: '',
        minOrderQty: '',
        minPackQty: '',
        puPersonnelId: '',
        minBatchQty: '',
        length: '',
        height: '',
        width: '',
        boxPackaingQty: '',
        mediumPackageQty: '',
        packExplain: '',
        businessLine: '',
        proposerId: '',
        barCode: '',
        serviceLife: '',
        healthCode: '',
        oriMaterialCode: '',
        productionPermit: '',
        oneClass: '',
        twoClass: '',
        threeClass: '',
        isEnable: '',
        remark: '',
        // 物料申请单-单据信息
        applyBillInfo: {
          createByName: '',
          createTime:'',
          updateByName: '',
          updateTime: '',
          reviewedByName: '',
          auditTime: ''
        },
        // 单据信息字段
        status: ''
      },
      options: [{
        value: '0',
        label: '是'
      },{
        value: '2',
        label: '否'
      }],
      basicRules: {},
      basicForm2: {
        // 是否药品
        isDrug: '',
        registrationNo: '',
        medicalInstruments: '',
        commonName: '',
        ratifyBatchNo: '',
        dosageFrom: '',
        oriRegistrationNo: '',
        curingType: '',
        // 医药属性子表
        // medicineTypeChanges:[
        // ],
      },
      // tableList: [],
      // 子表选中
      ids: [],
      // 弹窗
      name: '',
      selectData: [],
      selectData2: []
    }
  },
  // watch: {
  //   value: {
  //     handler (newVal) {
  //       this.selectData = []
  //       if (newVal) {
  //         newVal.split(',').forEach((id) => { // 回显拿数据
  //           this.contractService.queryById(id).then(({data}) => {
  //             if (data && data.id !== '') {
  //               this.selectData.push(data)
  //             }
  //           })
  //         })
  //       }
  //     },
  //     immediate: true,
  //     deep: false
  //   },
  //   selectData: {
  //     handler (newVal) {
  //       this.name = newVal.map(contract => contract.contractName).join(',')
  //     },
  //     immediate: false,
  //     deep: false
  //   }
  // },
  mounted() {
    this.$nextTick(() => {
      // console.log('页面状态',this.pageStu)
      if(this.pageStu == 'check') {
        // alert('详情页面:')
        console.log('页面状态',this.pageStu)
        console.log('数据', this.row)
        this.getDetails(this.row)
      } else if (this.pageStu == 'edit') {
        // alert('修改页面')
        console.log('页面状态',this.pageStu)
        console.log('数据', this.row)
        this.getDetails(this.row)
      } else if(this.pageStu == 'add') {
        // alert('新增页面')
        console.log('页面状态',this.pageStu)
      }
    })
  },
  methods: {
    handleClick(tab, event) {
      console.log(tab, event);
      console.log('页面状态',this.pageStu)
    },
    // 如果是详情进入，则调用详情接口
    getDetails(row) {
      getReqDetail(row.id).then(res => {
        console.log('res',res)
        if(res.code === 200) {
          this.basicForm = res.data
          if(res.data.sysMaterialMedcineApply) {
            this.basicForm2 = res.data.sysMaterialMedcineApply
          }
        }
      })
    },
    save() {
      if(this.pageStu == 'edit') {
        alert(111)
        let sparams = {...this.basicForm, ...{status: 0}}
        sparams.sysMaterialMedcineApply = this.basicForm2
        console.log('提交参数', sparams)
        editReq(sparams).then(res => {
          if(res.code === 200) {
            this.$message({
              message: res.msg,
              type: 'success'
            });
            this.back()
          }
        })
      } else {
        alert(222)
        // alert('保存传status：0')
        let sparams = {...this.basicForm, ...{status: 0}}
        sparams.sysMaterialMedcineApply = this.basicForm2
        console.log('保存参数', sparams)
        addReq(sparams).then(res => {
          if(res.code === 200) {
            this.$message({
              message: res.msg,
              type: 'success'
            });
            this.back()
          }
        })
      }
    },
    submit() {
      // alert('提交传status：1')
      let sparams = {...this.basicForm, ...{status: 1}}
      sparams.sysMaterialMedcineApply = this.basicForm2
      console.log('提交参数', sparams)
      editReq(sparams).then(res => {
        if(res.code === 200) {
          this.$message({
            message: res.msg,
            type: 'success'
          });
          this.back()
        }
      })
    },
    back() {
      this.$emit('jugislist', true)
      let queryParams = {
        pageNum: 1,
        pageSize: 10
      }
      this.$emit('refresh', queryParams)
    },
    // 子表增删行
    // handleSelectionChange(val) {
    //   this.ids = val
    //   console.log('this.ids',this.ids)
    // },
    // addLine() {
    //   //添加行数
    //   let newValue = {
    //     sort:'',
    //     medicineCode: '',
    //     medicineName: '',
    //   };
    //   this.basicForm2.medicineTypeChanges.push(newValue);
    // },
    // handleDelete(index) {
    //   if(this.ids.length == 0) {
    //     this.$message({
    //       message: '请选择删除条目',
    //       type: 'warning'
    //     });
    //   } else {
    //     // console.log('index',index)
    //     // this.basicForm2.medicineTypeChanges.splice(index, 1);
    //     this.basicForm2.medicineTypeChanges = this.basicForm2.medicineTypeChanges.filter(item =>
    //      !this.ids.some(ele =>
    //      ele.sort == item.sort))
    //   }
    // },
    // testsave() {
    //   console.log('暂存表格：', this.basicForm2.medicineTypeChanges)
    //   console.log('暂存表单1', this.basicForm)
    //   let params = {...this.basicForm, ...this.basicForm2}
    //   console.log('暂存总表单', params)
    // },
    // 设置选中
    selectionsToInput (selections) {
      console.log('父组件拿到的：', selections)
      this.selectData = selections
      this.$emit('getInfo', this.selectData)
      getMaterialDetails(selections[0].id).then(res => {
        console.log('res',res)
        if (res.code === 200) {
          let data = res.data.data
          // 物料id
          this.basicForm.materialId = data.id
          // 物料分类Id
          this.basicForm.materialClassifyId = data.classifyId
          this.basicForm.materialCode = data.code
          this.basicForm.materialName = data.name
          this.basicForm.medicineMaterial = data.isMedicine
          this.basicForm.oneClass = data.oneClass
          this.basicForm.twoClass = data.twoClass
          this.basicForm.threeClass = data.threeClass
          this.basicForm.fourClass = data.fourClass
          this.basicForm.specification = data.specification
          this.basicForm.model = data.model
          this.basicForm.registrant = data.registrant
          this.basicForm.storageConditions = data.storageCondition
          this.basicForm.transportCondition = data.transportationCondition
          this.basicForm.remark = data.deliveryPeriod
          if(data.medcines.length !== 0) {
            this.basicForm2.drug = data.medcines[0].isDrug
            this.basicForm2.registrationNo = data.medcines[0].registrationNo
            this.basicForm2.medicalDevices = data.medcines[0].medicalInstruments
            this.basicForm2.maintenanceType = data.medcines[0].curingType
          }
        }
      })
    },
    selectionsToInput2 (selections) {
      console.log('选择的数据',selections)
      this.basicForm.factory = selections[0].manufactureName
    },
    // 显示列表
    test01() {
      console.log('测试点击')
      this.$refs.contractSelect.init()
    },
    test02() {
      console.log('测试弹窗2');
      this.$refs.contractSelect2.init()
    }
  }
}
</script>

<style lang="scss" scoped>
  .requisition_add {
  height: calc(100vh - 84px);
  padding: 12px;
  box-sizing: border-box;
}
.btn_group {
  width: 100%;
  margin: 20px 0;
  display: flex;
  justify-content: center;
}
</style>