
 <!-- 出库弹窗 -->
<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" :rules="formRules">
        <el-row>
          <el-col :span="8">
            <el-form-item label="物品名称" prop="stuffName">
              <el-input v-model="formData.stuffName" readOnly :disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="分析项目" prop="anlyItemName" >
              <el-input v-model="formData.anlyItemName" readOnly :disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="显示顺序" prop="dspOrder" >
              <el-input v-model="formData.dspOrder"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="拼音助记码" prop="mnemonicCode">
              <el-input v-model="formData.mnemonicCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="默认值" prop="stdValue">
              <el-input v-model="formData.stdValue"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="单位" prop="unitNo">
              <el-select v-model="formData.unitNo" clearable filterable collapse-tags size="small" style="width: 100%;">
                <el-option v-for="(item,index) in unitList" :key="index" :label="item.unitName"
                           :value="item.unitNo" placeholder="请选择单位">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="memo">
              <el-input 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" :loading="modifyLoading" @click="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: ['showFlag9', 'Params', 'Params9'],
  data () {
    return {
        dialogTableVisible: false,
        formTypeDsc: '修改标样信息',
        formType: 0,
        seen: true,
        seenNo: true,
        beInvalid: false,
        formRules: {
        },
        unitList: [],
        modifyLoading: false,
        formData : {
          iId: '',
          stuffNo: '',
          stuffName: '',
          anlyItemNo: '',
          anlyItemName: '',
          itemTypeCode: '',
          itemTypeName: '',
          dspOrder: '',
          dataTypeCode: '',
          dataTypeName: '',
          stdValue: '',
          unitNo: '',
          unitName: '',
          mnemonicCode: '',
          memo: ''
         }
     }
  },

     methods: {
      cancel () {
        this.formData = {
          iId: '',
          stuffNo: '',
          stuffName: '',
          anlyItemNo: '',
          anlyItemName: '',
          itemTypeCode: '',
          itemTypeName: '',
          dspOrder: '',
          dataTypeCode: '',
          dataTypeName: '',
          stdValue: '',
          unitNo: '',
          unitName: '',
          mnemonicCode: '',
          memo: ''
        };
        this.dialogTableVisible = false;
      },
       modifyData () {
         this.$refs['formData'].validate((valid) => {
           if (valid) {
             this.formData.updateMan = userName;
             this.formData.updateNo = userId;
             this.formData.updateTime = new Date();
             let id = this.formData.iId
             this.unitList.forEach(item => {
               if (item.unitNo === this.formData.unitNo) {
                 this.formData.unitName = item.unitName
               }
             })
             console.log(this.formData, 'form');
             this.modifyLoading = true
             this.axios.put(`pass/baseManagement/v1/limslrcstuffinfos/${id}`, this.formData, {individualType: 'json'}).then(res => {
               if (res.succeed) {
                 this.dialogTableVisible = false;
                 this.$message.success('修改成功')
                 this.$emit('refresh')
                 this.modifyLoading = false
               } else {
                 this.$message.error(res.message)
                 this.modifyLoading = false
               }
             }).catch(e => {
               this.$message.error(e.message)
               this.modifyLoading = false
             })
           }
         })
       },
       closeDialog () {
          this.formData = {
            iId: '',
            stuffNo: '',
            stuffName: '',
            anlyItemNo: '',
            anlyItemName: '',
            itemTypeCode: '',
            itemTypeName: '',
            dspOrder: '',
            dataTypeCode: '',
            dataTypeName: '',
            stdValue: '',
            unitNo: '',
            unitName: '',
            mnemonicCode: '',
            memo: ''
          }
       }
     },
   mounted () {
     //度量单位
     this.axios.post("pass/baseManagement/v1/limsbaseunits/queryLimsBaseUnitPage",{object:{validFlag:1},pageIndex:1,pageSize:9999}, {individualType: 'json'}).then(res => {
       this.unitList = res.data.list;
     })
   },
  watch: {
   showFlag9 (arg) {
        this.dialogTableVisible = true;
         this.formType = 0;
         this.seenNo = false;
         this.formData = JSON.parse(JSON.stringify(this.Params9))
         this.formTypeDsc = '修改标样信息';
      }
   }
}
</script>
<style lang="less">
.tb-row {
    margin-bottom: 2px !important;
}
</style>
