
 <!-- 出库弹窗 -->
<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="qtyOutstk" style="white-space:nowrap">
              <el-input v-model="formData.qtyOutstk" type="number"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="出库类型" prop="outstkType">
              <el-input v-model="formData.outstkType"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="出库备注" prop="memo" style="white-space:nowrap">
              <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="outLoading" @click="outbound">确定</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: ['showFlag8', 'Params', 'Params8'],
  data () {
    return {
        dialogTableVisible: false,
        formTypeDsc: '出库',
        formType: 0,
        seen: true,
        outLoading: false,
        seenNo: true,
        beInvalid: false,
        formRules: {
          qtyOutstk: [{required: true, message: '该项不能为空', trigger: 'input'}]
        },
        formData : {
          strNo: '',
          stuffNo: '',
          stuffName: '',
          stuffItem: '',
          stuffTypeCode: '',
          stuffTypeName: '',
          stuffUnit: '',
          outstkType: '',
          qtyOutstk: '',
          outstkApp: '',
          outstkHnd: '',
          outstkTime: '',
          stkId: '',
          startDate: '',
          endDate: '',
          merchNo: '',
          merchName: '',
          certNum: '',
          memo: ''
         }
     }
  },

     methods: {
      cancel () {
        this.formData = {
          strNo: '',
          stuffNo: '',
          stuffName: '',
          stuffItem: '',
          stuffTypeCode: '',
          stuffTypeName: '',
          stuffUnit: '',
          outstkType: '',
          qtyOutstk: '',
          outstkApp: '',
          outstkHnd: '',
          outstkTime: '',
          stkId: '',
          startDate: '',
          endDate: '',
          merchNo: '',
          merchName: '',
          certNum: '',
          memo: ''
        };
        this.dialogTableVisible = false;
      },
       outbound () {
        this.$refs['formData'].validate((valid) => {
        if (valid) {
            this.formData.createMan = userName;
            this.formData.createNo = userId;
            this.formData.outstkApp = userName;
            this.outLoading = true
            this.axios.post('pass/baseManagement/v1/limslrcstuffos/',this.formData, {individualType: 'json'}).then(res => {
              if (res.succeed) {
                this.dialogTableVisible = false;
                this.$message.success(res.message)
                this.$emit('refresh')
                this.outLoading = false
              } else {
                this.$message.warning(res.message)
                this.outLoading = false
              }
            }).catch(e => {
              this.$message.error(e.message)
              this.outLoading = false
            })
          }
        })
     },
     closeDialog () {
        this.formData = {
          strNo: '',
          stuffNo: '',
          stuffName: '',
          stuffItem: '',
          stuffTypeCode: '',
          stuffTypeName: '',
          stuffUnit: '',
          outstkType: '',
          qtyOutstk: '',
          outstkApp: '',
          outstkHnd: '',
          outstkTime: '',
          stkId: '',
          startDate: '',
          endDate: '',
          merchNo: '',
          merchName: '',
          certNum: '',
          memo: ''
        }
     },
     },
   watch: {
   showFlag8 (arg) {
        this.dialogTableVisible = true;
         this.formType = 0;
         this.seenNo = false;
         this.formData = JSON.parse(JSON.stringify(this.Params))
         this.formData.memo = ''
         this.formData.outstkType = '消耗出库'
         this.formTypeDsc = '出库';
      }
   }
}
</script>
<style lang="less">
.tb-row {
    margin-bottom: 2px !important;
}
</style>
