
 <!-- 新增标定弹窗 -->
<template>
  <div class="resource">
      <el-dialog @close="closeDialog" :visible.sync="dialogTableVisible">
     <div slot="title" class="titleBox">
       <i :class="formType === 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">{{formTypeDsc}}</span>
        </div>
        <!-- 表单 -->
      <el-form ref="formData" label-width="69px" size="mini" :model="formData">
        <el-row>
        <!-- <el-col :span="8">
          <el-form-item label="标定编号" prop="scId">
            <el-input v-model="formData.scId" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="物品编码" prop="stuffNo">
            <el-input v-model="formData.stuffNo" :disabled="true"></el-input>
          </el-form-item>
        </el-col> -->
        <el-col :span="8">
          <el-form-item label="物品名称" prop="stuffName">
            <el-input v-model="formData.stuffName" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
            <!-- <el-col :span="8">
          <el-form-item label="物品编号" prop="stuffNoUser" :rules="[{required: true, message: '不能为空', trigger: 'blur'}]">
            <el-input v-model="formData.stuffNoUser"></el-input>
          </el-form-item>
        </el-col> -->
        <el-col :span="8">
          <el-form-item label="标定值" prop="calibrValue" style="white-space:nowrap">
            <el-input v-model="formData.calibrValue"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
            <el-form-item label="标定方法" prop="calibrMethod">
                <el-input v-model="formData.calibrMethod"></el-input>
            </el-form-item>
        </el-col>
        </el-row>
        <el-row>
        <el-col :span="8">
          <el-form-item label="标定日期" prop="calibrTime">
            <el-date-picker v-model="formData.calibrTime" style="width:100%" type="date" placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"></el-date-picker>
          </el-form-item>
        </el-col>
        <!-- <el-col :span="8">
          <el-form-item label="处置人" prop="">
            <el-input v-model="formData.zhigName"></el-input>
          </el-form-item>
        </el-col> -->
            <el-col :span="8">
          <el-form-item label="标定人" prop="calibrMan">
            <el-input v-model="formData.calibrMan"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="失效日期" prop="failureDate" style="white-space:nowrap">
            <el-date-picker v-model="formData.failureDate" style="width:100%" type="date" placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"></el-date-picker>
          </el-form-item>
        </el-col>
         </el-row>
        <el-row>
        <el-col :span="24">
           <el-form-item label="备注" prop="memo" style="width: 100%;">
                <el-input size="mini" v-model="formData.memo"></el-input>
            </el-form-item>
        </el-col>
        </el-row>
      </el-form>
          <span slot="footer" class="dialog-footer">
        <el-button type="primary" icon="el-icon-check" size="mini" @click="formType === 0 ? addData():modifyData()">确定</el-button>
        <el-button size="mini" type="primary" icon="el-icon-remove-outline" @click="cancel">取消</el-button>
      </span>
 </el-dialog>
  </div>
</template>
<script>
import {
  getCookie
} from '@/utils/util.js';
import {
  cookieUserId,
  cookieUserName
} from '@/config/config.js';
let userName = getCookie(cookieUserName);
let userId = getCookie(cookieUserId);
export default {
   props: ['showFlag6', 'Params', 'Params6'],
  data () {
    return {
        dialogTableVisible: false,
        formTypeDsc: '修改标准液标定信息',
        formType: 0,
        seen: true,
        seenNo: true,
        beInvalid: false,
        formData : {
          scId: '',
          stuffNo: '',
          stuffName: '',
          calibrValue: '',
          calibrMethod: '',
          calibrTime: '',
          calibrMan: '',
          failureDate: '',
          memo: ''
         },
     }
  },

     methods: {
      cancel () {
        this.formData = {
          scId: '',
          stuffNo: '',
          stuffName: '',
          // stuffNoUser: '',
          calibrValue: '',
          calibrMethod: '',
          calibrTime: '',
          calibrMan: '',
          failureDate: '',
          memo: ''
        };
        this.dialogTableVisible = false;
      },
     addData () {
        this.$refs['formData'].validate((valid) => {
        if (valid) {
            this.axios.post('pass/baseManagement/v1/limslrcstuffcalibrs/', this.formData, {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['formData'].validate((valid) => {
        if (valid) {
           this.formData.updateMan = userName;
           this.formData.updateNo = userId;
           this.axios.put('pass/baseManagement/v1/limslrcstuffcalibrs/', this.formData, {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.formData = {
          scId: '',
          stuffNo: '',
          stuffName: '',
          calibrValue: '',
          calibrMethod: '',
          calibrTime: '',
          calibrMan: '',
          failureDate: '',
          memo: ''
        }
     },
     },
   watch: {
   showFlag6 (arg) {
        this.dialogTableVisible = true;
        if (this.Params6 !== null) {
          this.formData = Object.assign({},this.Params6)
          this.formType = 1;
          this.formTypeDsc = '修改标准液标定信息';
          this.beInvalid = true;
          this.seen = false;
        } else {
          this.formType = 0;
          this.seenNo = false;
          this.formData.stuffNo = this.Params.stuffNo;
          this.formData.scId = this.Params.scId;
          this.formData.stuffName = this.Params.stuffName;
          this.formTypeDsc = '新增标准液标定信息';
        }
      }
        }
}
</script>
<style lang="less">
.tb-row {
    margin-bottom: 2px !important;
}
</style>
