
 <!-- 新增标准液配制弹窗 -->
<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="sfId">
            <el-input v-model="formData.sfId" :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="eqpTypeName" :rules="[{required: true, message: '不能为空', trigger: 'blur'}]">
                <el-select  @change="selectTrigger(formData.eqpTypeName)" v-model="formData.eqpTypeName" clearable placeholder="请选择">
                    <el-option
                    v-for="(item,index) in eqpTypeNameList"
                    :key="index"
                    :label="item.baseName"
                    :value="index">
                    </el-option>
                </el-select>
            </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="stuffSpec" style="white-space:nowrap">
            <el-input v-model="formData.stuffSpec"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
            <el-form-item label="制配时间" prop="fabrTime" style="white-space:nowrap">
              <el-date-picker v-model="formData.fabrTime" style="width:100%" type="datetime" placeholder="选择时间"></el-date-picker>
            </el-form-item>
        </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="制配浓度(%)" prop="fabrPpm" style="white-space:nowrap">
                <el-input v-model="formData.fabrPpm"></el-input>
            </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="制配数量(ml)" prop="fabrNum" style="white-space:nowrap">
            <el-input v-model="formData.fabrNum"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="制配方法" prop="fabrMethod" style="white-space:nowrap">
            <el-input v-model="formData.fabrMethod"></el-input>
          </el-form-item>
        </el-col>
        </el-row>
        <el-row>
        <el-col :span="8">
            <el-form-item label="到期提醒" prop="warnFlag">
                <!-- <el-input v-model="formData.warnFlag"></el-input> -->
                <el-select v-model="formData.warnFlag" clearable placeholder="请选择">
                    <el-option
                    v-for="(item, index) in warnFlaglList"
                    :key="index"
                    :label="item.warnFlag"
                    :value="item.no">
                    </el-option>
                </el-select>
            </el-form-item>
        </el-col>
        <el-col :span="16">
           <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: ['showFlag5', 'Params', 'Params5'],
  data () {
    return {
        dialogTableVisible: false,
        formTypeDsc: '修改标准液制配信息',
        formType: 0,
        seen: true,
        seenNo: true,
        beInvalid: false,
        formData : {
          sfId: '',
          stuffNo: '',
          stuffName: '',
          stuffSpec: '',
          fabrTime: '',
          fabrPpm: '',
          fabrNum: '',
          fabrMethod: '',
          warnFlag: '',
          memo: ''
        },
        warnFlaglList:[
          {warnFlag: '是',no: '1'},
          {warnFlag: '否',no: '0'},
        ]
     }
  },
     methods: {
       cancel () {
        this.formData = {
          sfId: '',
          stuffNo: '',
          stuffName: '',
          stuffSpec: '',
          fabrTime: '',
          fabrPpm: '',
          fabrNum: '',
          fabrMethod: '',
          warnFlag: '',
          memo: ''
        };
        this.dialogTableVisible = false;
      },
     addData () {
        this.$refs['formData'].validate((valid) => {
         if (valid) {
            this.formData.createMan = userName;
            this.formData.createNo = userId;
            //  this.formData.eqpTypeName = this.eqpTypeNameList[this.formData.eqpTypeName].baseName
            //  this.formData.empNo = this.Params.empNo;
            this.axios.post('pass/baseManagement/v1/limslrcstufffabrs/', 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/limslrcstufffabrs/', 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 = {
          sfId: '',
          stuffNo: '',
          stuffName: '',
          stuffSpec: '',
          fabrTime: '',
          fabrPpm: '',
          fabrNum: '',
          fabrMethod: '',
          warnFlag: '',
          memo: ''
        };
       this.$emit('refresh')
     },
    },
   watch: {
   showFlag5 (arg) {
        this.dialogTableVisible = true;
        if (this.Params5 !== null) {
          this.formData = Object.assign({},this.Params5)
          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.sfId = this.Params.sfId;
          this.formData.stuffName = this.Params.stuffName;
          this.formTypeDsc = '新增标准液制配信息';
        }
      }
   }
}
</script>
<style lang="less">
.tb-row {
    margin-bottom: 2px !important;
}
</style>
