<!-- 新增、修改固定计划 -->
<template>
  <div class="examination">
    <el-dialog
      @close="closeDialog"
      :visible.sync="dialogTableVisible"
      width="70%"
    >
      <div slot="title" class="titleBox">
        <i
          :class="tableType === 0 ? 'el-icon-document' : 'el-icon-edit-outline'"
          style="font-size: 20px"
        ></i>
        <!-- <img style="width: 25px; height: 25px" src='../../../../assets/img/imgScreen/more.png' /> -->
        <span style="margin-left: 10px; font-size: 18px">{{
          tableTypeDsc
        }}</span>
      </div>
      <el-form
        ref="baseData"
        label-width="90px"
        :rules="rules"
        :model="baseData"
      >
        <!-- 第一排 -->
        <el-row>
          <el-col :span="8">
            <el-form-item prop="planCompanyNo" label="委托单位">
              <el-select
                v-model="baseData.planCompanyNo"
                filterable
                style="width: 100%"
                collapse-tags
                @change="selectDepartment"
                size="small"
              >
                <el-option
                  v-for="item in companyNameType"
                  :key="item.orgCode"
                  :label="item.orgName"
                  :value="item.orgCode"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="companyNo" label="检验单位">
              <el-select
                v-model="baseData.companyNo"
                filterable
                style="width: 100%"
                collapse-tags
                @change="selectDepartment3"
                size="small"
              >
                <el-option
                  v-for="item in companyNameType3"
                  :key="item.orgCode"
                  :label="item.orgName"
                  :value="item.orgCode"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="取样单位">
              <el-select
                v-model="baseData.smpCompanyNo"
                filterable
                clearable
                style="width: 100%"
                collapse-tags
                @change="selectDepartment2"
                size="small"
              >
                <el-option
                  v-for="item in companyNameType2"
                  :key="item.orgCode"
                  :label="item.orgName"
                  :value="item.orgCode"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 第二排 -->
        <el-row>
          <el-col :span="8">
            <el-form-item prop="planDeptNo" label="联系人">
              <el-select
                v-model="baseData.planDeptNo"
                filterable
                style="width: 100%"
                collapse-tags
                @change="selectPlanMent"
                size="small"
              >
                <el-option
                  v-for="item in sectionNameType"
                  :key="item.orgCode"
                  :label="item.orgName"
                  :value="item.orgCode"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="deptNo" label="检验车间">
              <el-select
                v-model="baseData.deptNo"
                filterable
                clearable
                style="width: 100%"
                collapse-tags
                @change="selectClass3"
                size="small"
              >
                <el-option
                  v-for="item in sectionNameType3"
                  :key="item.orgCode"
                  :label="item.orgName"
                  :value="item.orgCode"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="取样车间">
              <el-select
                v-model="baseData.smpDeptNo"
                clearable
                filterable
                style="width: 100%"
                @change="selectClass2"
                collapse-tags
                size="small"
              >
                <el-option
                  v-for="item in sectionNameType2"
                  :key="item.orgCode"
                  :label="item.orgName"
                  :value="item.orgCode"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 第三排 -->
        <el-row>
          <el-col :span="8">
            <el-form-item label="联系电话">
              <el-select
                v-model="baseData.planSectionNo"
                clearable
                filterable
                style="width: 100%"
                collapse-tags
                size="small"
              >
                <el-option
                  v-for="item in planTeamList"
                  :key="item.orgCode"
                  :label="item.orgName"
                  :value="item.orgCode"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="sectionNo" label="检验班组">
              <el-select
                v-model="baseData.sectionNo"
                filterable
                clearable
                style="width: 100%"
                collapse-tags
                size="small"
              >
                <el-option
                  v-for="item in sectionClass3"
                  :key="item.orgCode"
                  :label="item.orgName"
                  :value="item.orgCode"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="smpSectionNo" label="取样班组">
              <el-select
                v-model="baseData.smpSectionNo"
                clearable
                style="width: 100%"
                @change="smpSection"
                collapse-tags
                size="small"
              >
                <el-option
                  v-for="item in sectionClass2"
                  :key="item.orgCode"
                  :label="item.orgName"
                  :value="item.orgCode"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 第四排 -->
        <el-row>
          <el-col :span="8">
            <el-form-item prop="matClassNo" label="物料类型">
              <el-select
                v-model="baseData.matClassNo"
                @change="selctMatName"
                clearable
                style="width: 100%"
                filterable
                collapse-tags
                size="small"
              >
                <el-option
                  v-for="(item, index) in matClassNameType"
                  :key="index"
                  :label="item.matClassName"
                  :value="item.matClassNo"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="gradeNo" label="牌号/等级">
              <el-select
                v-model="baseData.gradeNo"
                filterable
                collapse-tags
                size="small"
                style="width: 100%;"
              >
                <el-option
                  v-for="(item, index) in gradeType"
                  :key="index"
                  :label="item.gradeName"
                  :value="item.gradeNo"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="取样地点">
              <el-select
                v-model="baseData.pointNo"
                filterable
                clearable
                collapse-tags
                size="small"
                style="width: 100%"
              >
                <el-option
                  v-for="(item, index) in pointNameType"
                  :key="index"
                  :label="item.pointName"
                  :value="item.pointNo"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 第五排 -->
        <el-row>
          <el-col :span="8">
            <el-form-item prop="matNo" label="物料名称">
              <el-select
                v-model="baseData.matNo"
                clearable
                style="width: 100%"
                filterable
                collapse-tags
                size="small"
              >
                <el-option
                  v-for="(item, index) in matNameType"
                  :key="index"
                  :label="item.matName"
                  :value="item.matNo"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="isSmp">
              <span slot="label"
                >是否取样<el-tooltip
                  class="tooltip"
                  effect="dark"
                  content="是否检测中心取样"
                  placement="top"
                >
                  <i class="el-icon-question infoPrompt"></i> </el-tooltip
              ></span>
              <el-select
                v-model="baseData.isSmp"
                filterable
                clearable
                collapse-tags
                size="small"
                style="width: 100%"
              >
                <el-option
                  v-for="(item, index) in isSmpType"
                  :key="index"
                  :label="item.isSmp"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="matShapeName" label="试样形状">
              <el-select
                v-model="baseData.matShapeName"
                clearable
                filterable
                collapse-tags
                size="small"
                style="width: 100%;"
              >
                <el-option
                  v-for="(item, index) in matShapeNameType"
                  :key="index"
                  :label="item.baseName"
                  :value="item.baseName"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 第六排 -->
        <el-row>

          <el-col :span="8">
            <el-form-item prop="testTypeCode" label="检验类型">
              <el-select
                v-model="baseData.testTypeCode"
                readonly
                style="width: 100%"
                filterable
                collapse-tags
                size="small"
              >
                <el-option
                  v-for="(item, index) in testTypeNameType"
                  :key="index"
                  :label="item.baseName"
                  :value="item.baseCode"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
           <el-col :span="8">
            <el-form-item label="是否组合">
              <el-select
                v-model="baseData.isPrep"
                filterable
                collapse-tags
                size="small"
                style="width: 100%"
              >
                <el-option
                  v-for="(item, index) in isSmpType"
                  :key="index"
                  :label="item.isSmp"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="planYear" label="计划年份">
              <el-date-picker
                v-model="baseData.planYear"
                type="year"
                placeholder="选择年"
                size="small"
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 第七排 -->
        <el-row>
          <el-col :span="8">
            <el-form-item prop="smpDeliCode" label="送样频次">
              <el-select
                v-model="baseData.smpDeliCode"
                filterable
                style="width: 100%"
                collapse-tags
                size="small"
              >
                <el-option
                  v-for="item in deliver"
                  :key="item.baseCode"
                  :label="item.baseName"
                  :value="item.baseCode"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="是否组批">
              <el-select
                v-model="baseData.isBatch"
                filterable
                collapse-tags
                size="small"
                style="width: 100%"
              >
                <el-option
                  v-for="(item, index) in isSmpType"
                  :key="index"
                  :label="item.isSmp"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="planDate" label="计划日期">
              <el-date-picker
                v-model="baseData.planDate"
                type="date"
                placeholder="选择日期"
                size="small"
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 第九排 -->
        <el-row>
          <el-col :span="8">
            <el-form-item prop="sampleTypeCode" label="样品类型">
              <el-select
                v-model="baseData.sampleTypeCode"
                filterable
                collapse-tags
                size="small"
                style="width: 100%"
              >
                <el-option
                  v-for="(item, index) in sampleTypeNameType"
                  :key="index"
                  :label="item.baseName"
                  :value="item.baseCode"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="是否计量">
              <el-select
                v-model="baseData.isMater"
                filterable
                collapse-tags
                size="small"
                style="width: 100%"
              >
                <el-option
                  v-for="(item, index) in isSmpType"
                  :key="index"
                  :label="item.isSmp"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="测试起始时间">
              <el-time-picker
                v-model="baseData.testTime"
                placeholder="任意时间点"
                size="small"
                style="width: 100%"
              ></el-time-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 第十排 -->
        <el-row>
          <el-col :span="8">
            <el-form-item prop="suppNo" label="发货单位">
              <el-select
                v-model="baseData.suppNo"
                filterable
                style="width: 100%"
                collapse-tags
                size="small"
              >
                <el-option
                  v-for="item in loadPointNameType"
                  :key="item.loadPointNo"
                  :label="item.loadPointName"
                  :value="item.loadPointNo"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="是否顺延">
              <el-select
                v-model="baseData.isPostpone"
                filterable
                collapse-tags
                size="small"
                style="width: 100%"
              >
                <el-option
                  v-for="(item, index) in isSmpType"
                  :key="index"
                  :label="item.isSmp"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="testLimit" label="测试时限(h)">
              <el-input
                v-model="baseData.testLimit"
                size="small"
                style="width: 100%"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 第一排 -->
        <el-row>
          <el-col :span="8">
            <el-form-item prop="acceptNo" label="收货单位">
              <el-select
                v-model="baseData.acceptNo"
                filterable
                style="width: 100%"
                collapse-tags
                size="small"
              >
                <el-option
                  v-for="item in loadPointNameType"
                  :key="item.loadPointNo"
                  :label="item.loadPointName"
                  :value="item.loadPointNo"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="是否加权">
              <el-select
                v-model="baseData.isCheck"
                filterable
                collapse-tags
                size="small"
                style="width: 100%"
              >
                <el-option
                  v-for="(item, index) in isSmpType"
                  :key="index"
                  :label="item.isSmp"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="durTime" label="间隔时间(h)">
              <el-input
                v-model="baseData.durTime"
                size="small"
                style="width: 100%"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item prop="spec" label="规格/说明">
              <el-input
                v-model="baseData.spec"
                size="small"
                style="width: 100%"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="备注">
              <el-input
                v-model="baseData.memo"
                size="small"
                style="width: 100%"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button
          type="goon"
          size="mini"
          icon="el-icon-check"
          @click="tableType === 0 ? addData() : modifyData()"
          >确定</el-button
        >
        <el-button
          size="mini"
          type="goon"
          icon="el-icon-remove-outline"
          @click="cancel"
          >取消</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { getCookie, formatDate } from "@/utils/util.js";
import { cookieUserId, cookieUserName } from "@/config/config.js";
let userName = getCookie(cookieUserName);
let userId = getCookie(cookieUserId);
import { momentImmutableMethods } from "moment-immutable-methods";
import moment from "moment";
momentImmutableMethods(moment);
export default {
  props: ["showFlag", "Params"],
  data() {
    return {
      dialogTableVisible: false,
      tableTypeDsc: "新增固定计划信息表",
      tableType: 0,
      seen: true,
      seenNo: true,
      beInvalid: false,
      planYear: "",
      planDate: "",
      testTime: "",
      durTime: "",
      testLimit: "",
      memo: "",
      baseData: {
        isSmp: "",
        matNo: "",
        planDeptNo: "",
        smpDeptNo: "",
        smpSectionNo: "",
        deptNo: "",
        suppNo: "",
        unloadPlace: "",
        sectionNo: "",
        isPrep: "0",
        isCheck: "0", //是否加权
        planSectionNo: "", //计划班组  （编码）
        planSectionName: "", //计划班组  名称
        isPostpone: "0",
        isBatch: "0",
        isMater: "0",
        matClassNo: "", // 物料类型
        planDate: new Date(),
        planYear: new Date(),
        gradeNo: "",
        gradeName: "",
      },
      // pointNameTypeIndex: 0,//取样单位
      // sampleTypeNameTypeIndex: 0,//样品类型
      // companyNameTypeIndex: 0,//委托单位
      // matNameTypeIndex: 0,//物料名称
      // deptNameTypeIndex: 0,//委托人
      // smpDeptNameTypeIndex: 0,//采样单位
      isSmpTypeIndex: 1, //是否取样
      pointNameType: [],
      sampleTypeNameType: [],
      companyNameType: [],
      loadPointNameType: [], //发货单位
      sectionClass: [],
      matShapeNameType: [],
      companyNameType2: [],
      planTeamList: [], //联系电话数据列表
      sectionNameType2: [],
      sectionClass2: [],
      gradeType: [],
      companyNameType3: [],
      sectionNameType3: [],
      sectionClass3: [],
      deliver: [],
      testTypeNameType: [],
      matClassNameType: [],
      matNameType: [],
      rules: {
        planYear: [{ required: true, message: "不能为空", trigger: "blur" }],
        planDate: [{ required: true, message: "不能为空", trigger: "change" }],
        testLimit: [],
        durTime: [],
        planCompanyNo: [
          { required: true, message: "不能为空", trigger: "change" },
        ],
        matClassNo: [
          { required: true, message: "不能为空", trigger: "change" },
        ],
        planDeptNo: [
          { required: true, message: "不能为空", trigger: "change" },
        ],
        matNo: [{ required: true, message: "不能为空", trigger: "change" }],
        pointNo: [{ required: true, message: "不能为空", trigger: "change" }],
        smpCompanyNo: [
          { required: true, message: "不能为空", trigger: "change" },
        ],
        smpDeptNo: [{ required: true, message: "不能为空", trigger: "change" }],
        sampleTypeCode: [
          { required: true, message: "不能为空", trigger: "change" },
        ],
        smpDeliCode: [
          { required: true, message: "不能为空", trigger: "change" },
        ],
        testTypeCode: [
          { required: true, message: "不能为空", trigger: "change" },
        ],
        isSmp: [{ required: true, message: "不能为空", trigger: "change" }],
        deptNo: [{ required: true, message: "不能为空", trigger: "change" }],
        companyNo: [{ required: true, message: "不能为空", trigger: "change" }],
      },
      sectionNameType: [],
      isSmpType: [
        { id: "0", isSmp: "否" },
        { id: "1", isSmp: "是" },
      ],
    };
  },
  mounted() {
    this.getGradeType();
    //获取公司
    this.axios
      .post(
        "pass/baseManagement/v1/sysorgs/querySysOrgCompanyAll",
        {},
        { individualType: "json" }
      )
      .then((response) => {
        this.companyNameType = response.data;
        this.companyNameType2 = response.data;
        this.companyNameType3 = response.data;
      });
    //发货单位
    this.axios
      .post(
        "pass/testManagement/v1/meterbaseloadpoints/queryMeterBaseLoadPoint",
        {},
        { individualType: "json" }
      )
      .then((res) => {
        this.loadPointNameType = res.data;
      });
    //物料类型
    this.axios
      .get("pass/baseManagement/v1/limsbasematerialsclasss/" + "?validFlag=1")
      .then((res) => {
        this.matClassNameType = res.data.list;
      });
    this.axios
      .post(
        "pass/baseManagement/v1/limsbaseinfos/queryBaseInfoByBaseCode",
        { validFlag: 1, baseCode: 4819 },
        { individualType: "json" }
      )
      .then((res) => {
        this.matShapeNameType = res.data;
      });
    //样品类型
    this.axios
      .post(
        "pass/baseManagement/v1/limsbaseinfos/queryBaseInfoByBaseCode",
        { validFlag: 1, baseCode: 4801 },
        { individualType: "json" }
      )
      .then((res) => {
        this.sampleTypeNameType = res.data;
      });
    //检验类型
    this.axios
      .post(
        "pass/baseManagement/v1/limsbaseinfos/queryBaseInfoByBaseCode",
        { validFlag: 1, baseCode: 4803 },
        { individualType: "json" }
      )
      .then((res) => {
        this.testTypeNameType = res.data;
      });
    //送样频次
    this.axios
      .post(
        "pass/baseManagement/v1/limsbaseinfos/queryBaseInfoByBaseCode",
        { validFlag: 1, baseCode: 4818 },
        { individualType: "json" }
      )
      .then((res) => {
        this.deliver = res.data;
      });
    // this.axios.post("pass/baseManagement/v1/limsbasepoints/queryLimsBasePointPage",{object:{companyNo:'',pointTypeCode:'480401',validFlag:1},pageIndex:1,pageSize:9999}, {individualType: 'json'}).then(response => {
    //   this.pointNameType = response.data.list
    // });

  },
  methods: {
    getCode(code, arr, codeKey, nameKey) {
      if (!code) {
        return "";
      }
      let targetRow = arr.find((item) => {
        return item[codeKey] === code;
      });
      // console.log(targetRow, 'targetRow');
      return targetRow ? targetRow[nameKey] : "";
    },
    cancel() {
      this.baseData = {
        isSmp: "",
        deptNo: "",
        matNo: "",
        isPrep: "0",
        isPostpone: "0",
        isCheck: "0",
        isBatch: "0",
        isMater: "0",
      };
      this.dialogTableVisible = false;
    },
    //查询选中的公司的部门名称数据
    selectDepartment(val) {
      this.sectionNameType = [];
      this.companyNameType.find((item) => {
        if (val === item.orgCode) {
          this.sectionNameType = item.sysOrgList;
          this.baseData.clearFlag ? "" : (this.baseData.planDeptNo = "");
        }
      });
    },
    //根据联系人联动查询联系电话组数据
      selectPlanMent(val) {
      this.planTeamList = []
      this.sectionNameType.find((item) => {
        if (val === item.orgCode) {
          this.planTeamList = item.sysOrgList;
          this.baseData.clearFlag ? "" : (this.baseData.planSectionNo = "");
        }
      });
    },
    selectDepartment2(val) {
      this.sectionNameType2 = [];
      this.pointNameType = [];
      this.companyNameType2.find((item) => {
        if (val === item.orgCode) {
          this.sectionNameType2 = item.sysOrgList;
          this.baseData.clearFlag ? "" : (this.baseData.smpDeptNo = "");
        }
      });
      let obj = {
        object: { companyNo: val, pointTypeCode: "480401", validFlag: 1 },
        pageIndex: 1,
        pageSize: 9999,
      };
      this.axios
        .post(
          "pass/baseManagement/v1/limsbasepoints/queryLimsBasePointPage",
          obj,
          { individualType: "json" }
        )
        .then((response) => {
          this.pointNameType = response.data.list;
        });
    },
    //根据选中的部门名称，查询班组名称
    selectClass2(val) {
      this.sectionClass2 = [];
      this.sectionNameType2.find((item) => {
        if (val === item.orgCode) {
          this.sectionClass2 = item.sysOrgList;
          this.baseData.clearFlag ? "" : (this.baseData.smpSectionNo = "");
        }
      });
    },
    selectDepartment3(val) {
      this.sectionNameType3 = [];
      this.companyNameType3.find((item) => {
        if (val === item.orgCode) {
          this.sectionNameType3 = item.sysOrgList;
          this.baseData.clearFlag ? "" : (this.baseData.deptNo = "");
        }
      });
    },
    //根据选中的部门名称，查询班组名称
    selectClass3(val) {
      this.sectionClass3 = [];
      this.sectionNameType3.find((item) => {
        if (val === item.orgCode) {
          this.sectionClass3 = item.sysOrgList;
          this.baseData.clearFlag ? "" : (this.baseData.sectionNo = "");
        }
      });
    },
    smpSection() {
      this.$forceUpdate();
    },
    selctMatName(val) {
      this.matNameType = [];
      this.baseData.clearFlag ? "" : (this.baseData.matNo = "");
      if (!val) {
        return;
      }
      //物料名称
      this.axios
        .post(
          "pass/baseManagement/v1/limsbasematerialss/queryLimsBaseMaterialsPage/",
          {
            object: { validFlag: 1, matClassNo: val },
            pageIndex: 1,
            pageSize: 99999,
          },
          { individualType: "json" }
        )
        .then((res) => {
          this.matNameType = res.data.list;
        });
    },
    getGradeType() {
      let that = this;
      let obj = {
        object: {
          validFlag: "1",
        },
        pageIndex: 1,
        pageSize: 99999,
      };
      that.axios
        .post(
          "pass/baseManagement/v1/limsbasegrades/queryLimsBaseGradePage",
          obj,
          {
            individualType: "json",
          }
        )
        .then((res) => {
          if (res.succeed) {
            this.gradeType = res.data.list;
          }
        })
        .catch((e) => {});
    },
    addData() {
      this.$refs["baseData"].validate((valid) => {
        if (valid) {
          this.baseData.planYear = moment(this.baseData.planYear).get("year");
          this.baseData.planTypeCode = "481701";
          this.baseData.planTypeName = "固定计划";
          this.baseData.pointName = this.getCode(
            this.baseData.pointNo,
            this.pointNameType,
            "pointNo",
            "pointName"
          );
          this.baseData.sampleTypeName = this.getCode(
            this.baseData.sampleTypeCode,
            this.sampleTypeNameType,
            "baseCode",
            "baseName"
          );
          this.baseData.planCompanyName = this.getCode(
            this.baseData.planCompanyNo,
            this.companyNameType,
            "orgCode",
            "orgName"
          );
          console.log(this.baseData.planCompanyNo,'委托单位编号')
          console.log(this.baseData.planCompanyName,'委托单位名称')
          this.baseData.suppName = this.getCode(
            this.baseData.suppNo,
            this.loadPointNameType,
            "loadPointNo",
            "loadPointName"
          );
          this.baseData.acceptName = this.getCode(
            this.baseData.acceptNo,
            this.loadPointNameType,
            "loadPointNo",
            "loadPointName"
          );
          this.baseData.planDeptName = this.getCode(
            this.baseData.planDeptNo,
            this.sectionNameType,
            "orgCode",
            "orgName"
          );
          this.baseData.planSectionName = this.getCode(
            this.baseData.planSectionNo,
            this.planTeamList,
            "orgCode",
            "orgName"
          );
          // this.baseData.sectionName = this.getCode(this.baseData.sectionNo,this.sectionClass,'orgCode','orgName')
          this.baseData.smpCompanyName = this.getCode(
            this.baseData.smpCompanyNo,
            this.companyNameType2,
            "orgCode",
            "orgName"
          );
          this.baseData.smpDeptName = this.getCode(
            this.baseData.smpDeptNo,
            this.sectionNameType2,
            "orgCode",
            "orgName"
          );
          this.baseData.smpSectionName = this.getCode(
            this.baseData.smpSectionNo,
            this.sectionClass2,
            "orgCode",
            "orgName"
          );
          this.baseData.companyName = this.getCode(
            this.baseData.companyNo,
            this.companyNameType3,
            "orgCode",
            "orgName"
          );
          this.baseData.deptName = this.getCode(
            this.baseData.deptNo,
            this.sectionNameType3,
            "orgCode",
            "orgName"
          );
          this.baseData.sectionName = this.getCode(
            this.baseData.sectionNo,
            this.sectionClass3,
            "orgCode",
            "orgName"
          );
          this.baseData.matName = this.getCode(
            this.baseData.matNo,
            this.matNameType,
            "matNo",
            "matName"
          );
          this.baseData.matClassName = this.getCode(
            this.baseData.matClassNo,
            this.matClassNameType,
            "matClassNo",
            "matClassName"
          );
          this.baseData.matClassName = this.getCode(
            this.baseData.matClassNo,
            this.matClassNameType,
            "matClassNo",
            "matClassName"
          );
          this.baseData.smpDeliName = this.getCode(
            this.baseData.smpDeliCode,
            this.deliver,
            "baseCode",
            "baseName"
          );
          this.baseData.matShapeCode = this.getCode(
            this.baseData.matShapeName,
            this.matShapeNameType,
            "baseName",
            "baseCode"
          );
          // let obj = this.gradeType.find((item) => {
          //   return item.gradeNo === this.baseData.gradeNo;
          // });
          this.baseData.gradeName = this.getCode(
            this.baseData.gradeNo,
            this.gradeType,
            "gradeNo",
            "gradeName"
          );
          // this.baseData.entrOrgNo = this.baseData.smpDeptNo
          // this.baseData.entrOrgName = this.baseData.smpDeptName
          this.baseData.testTypeName = this.getCode(
            this.baseData.testTypeCode,
            this.testTypeNameType,
            "baseCode",
            "baseName"
          );
          this.axios
            .post(
              "pass/testManagement/v1/limstestplans/saveLimsTestPlan",
              this.baseData,
              { individualType: "json" }
            )
            .then((res) => {
              if (res.succeed) {
                this.dialogTableVisible = false;
                this.$message.success("添加成功");
                this.$emit("refresh");
              } else {
                this.$message.error(res.message);
              }
            })
            .catch((e) => {
              this.$message.error(e.message);
            });
        }
      });
    },
    modifyData() {
      this.$refs["baseData"].validate((valid) => {
        if (valid) {
          this.baseData.planYear = moment(this.baseData.planYear).get("year");
          console.log("修改计划-- 取样地点名称"+this.baseData.pointNo)
          console.log("修改计划-- 取样地点名称"+this.pointNameType)
          this.baseData.pointName = this.getCode(
            this.baseData.pointNo,
            this.pointNameType,
            "pointNo",
            "pointName"
          );
          console.log("修改计划-- 取样地点名称"+this.baseData.pointName)
          this.baseData.sampleTypeName = this.getCode(
            this.baseData.sampleTypeCode,
            this.sampleTypeNameType,
            "baseCode",
            "baseName"
          );
          this.baseData.suppName = this.getCode(
            this.baseData.suppNo,
            this.loadPointNameType,
            "loadPointNo",
            "loadPointName"
          );
          this.baseData.acceptName = this.getCode(
            this.baseData.acceptNo,
            this.loadPointNameType,
            "loadPointNo",
            "loadPointName"
          );
          this.baseData.planSectionName = this.getCode(
            this.baseData.planSectionNo,
            this.planTeamList,
            "orgCode",
            "orgName"
          );
          this.baseData.planCompanyName = this.getCode(
            this.baseData.planCompanyNo,
            this.companyNameType,
            "orgCode",
            "orgName"
          );
          this.baseData.planDeptName = this.getCode(
            this.baseData.planDeptNo,
            this.sectionNameType,
            "orgCode",
            "orgName"
          );
          this.baseData.gradeName = this.getCode(
            this.baseData.gradeNo,
            this.gradeType,
            "gradeNo",
            "gradeName"
          );
          // this.baseData.sectionName = this.getCode(this.baseData.sectionNo,this.sectionClass,'orgCode','orgName')
          this.baseData.smpCompanyName = this.getCode(
            this.baseData.smpCompanyNo,
            this.companyNameType2,
            "orgCode",
            "orgName"
          );
          this.baseData.smpDeptName = this.getCode(
            this.baseData.smpDeptNo,
            this.sectionNameType2,
            "orgCode",
            "orgName"
          );
          this.baseData.smpSectionName = this.getCode(
            this.baseData.smpSectionNo,
            this.sectionClass2,
            "orgCode",
            "orgName"
          );
          this.baseData.companyName = this.getCode(
            this.baseData.companyNo,
            this.companyNameType3,
            "orgCode",
            "orgName"
          );
          this.baseData.deptName = this.getCode(
            this.baseData.deptNo,
            this.sectionNameType3,
            "orgCode",
            "orgName"
          );
          this.baseData.sectionName = this.getCode(
            this.baseData.sectionNo,
            this.sectionClass3,
            "orgCode",
            "orgName"
          );
          this.baseData.matName = this.getCode(
            this.baseData.matNo,
            this.matNameType,
            "matNo",
            "matName"
          );
          this.baseData.matClassName = this.getCode(
            this.baseData.matClassNo,
            this.matClassNameType,
            "matClassNo",
            "matClassName"
          );
          this.baseData.smpDeliName = this.getCode(
            this.baseData.smpDeliCode,
            this.deliver,
            "baseCode",
            "baseName"
          );
          // this.baseData.entrOrgNo = this.baseData.smpDeptNo
          // this.baseData.entrOrgName = this.baseData.smpDeptName
          this.baseData.testTypeName = this.getCode(
            this.baseData.testTypeCode,
            this.testTypeNameType,
            "baseCode",
            "baseName"
          );
          this.axios
            .post(
              "pass/testManagement/v1/limstestplans/saveLimsTestPlan",
              this.baseData,
              { individualType: "json" }
            )
            .then((res) => {
              if (res.succeed) {
                this.dialogTableVisible = false;
                this.$message.success("修改成功");
                this.$emit("refresh");
              } else {
                this.$message.error(res.message);
              }
            })
            .catch((e) => {
              this.$message.error(e.message);
            });
        }
      });
    },
    closeDialog() {
      this.baseData = {
        isSmp: "",
        planDeptNo: "",
        smpDeptNo: "",
        smpSectionNo: "",
        matNo: "",
        deptNo: "",
        sectionNo: "",
        isPrep: "0",
        isCheck: "0",
        isPostpone: "0",
        isBatch: "0",
        isMater: "0",
      };
    },
  },
  watch: {
    showFlag(arg) {
      let _this = this;
      this.dialogTableVisible = true;
      // console.log('_this.Params', _this.Params);
      if (_this.Params !== null && _this.Params.addFlag == "0") {
        this.baseData = Object.assign({ clearFlag: true }, this.Params);
        this.selctMatName(this.baseData.matClassNo); // 物料名称选择
        this.selectDepartment(this.baseData.planCompanyNo);
        this.selectPlanMent(this.baseData.planDeptNo); //联系电话组选择
        this.selectDepartment2(this.baseData.smpCompanyNo);
        this.selectClass2(this.baseData.smpDeptNo);
        this.selectDepartment3(this.baseData.companyNo);
        this.selectClass3(this.baseData.deptNo);
        this.baseData.clearFlag = false;
        _this.tableType = 1;
        _this.tableTypeDsc = "修改固定计划信息表";
      } else {
        _this.tableType = 0;
        _this.matNameType = [];
        _this.tableTypeDsc = "新增固定计划信息表";
        _this.baseData = Object.assign({ clearFlag: true }, this.Params);
        if (this.baseData.id) {
          // 有模板数据传入
          this.selctMatName(this.baseData.matClassNo); // 物料名称选择
          this.selectDepartment(this.baseData.planCompanyNo);
          this.selectDepartment2(this.baseData.smpCompanyNo);
          this.selectClass2(this.baseData.smpDeptNo);
           this.selectPlanMent(this.baseData.planDeptNo);
          this.selectDepartment3(this.baseData.companyNo);
          this.selectClass3(this.baseData.deptNo);
        } else {
          _this.baseData = {
            // 初始化数据
            isSmp: "",
            matNo: "",
            planDeptNo: "",
            smpDeptNo: "",
            smpSectionNo: "",
            planSectionNo: "", //联系电话   编码
            planSectionName: "", //联系电话  名
            deptNo: "",
            sectionNo: "",
            isPrep: "0",
            isCheck: "0",
            isPostpone: "0",
            isBatch: "0",
            isMater: "0",
            matClassNo: "", // 物料类型
            planDate: new Date(),
            planYear: new Date(),
          };
          _this.$nextTick(() => {
            _this.$refs.baseData.clearValidate();
          });
        }
        _this.baseData.clearFlag = false;
        _this.baseData.id = "";
        _this.baseData.planId = "";
      }
    },
    baseData: {
      handler(val) {
        console.log("------------------", val);
      },
      deep: true,
    },
  },
};
</script>
<style lang="less">
.customWidth_certifi3 {
  width: 600px !important;
}
.infoPrompt {
  color: #409eff;
  font-size: 14px;
}
</style>
