allocationNumDialog.vue 1.92 KB
<!-- 盘点 -->
<template>
  <GLDialog title="调拨" :visible.sync="allocationNumVisible" :before-close="e => handleClose(undefined, true)" class="allocationNumDailog" okText="确定" @onCancel="e => handleClose(e, true)" @onOk="handleAddConfirm">
    <div class="gl-form-page gl-form-min">
      <el-form ref="allocationNumForm" size="small" :model="infoForm" :rules="formRules" label-width="154px">
        <el-form-item label="调拨数量:" prop="allocationNum">
          <el-input placeholder="请输入调拨数量" v-model="infoForm.allocationNum" clearable @input="handleUpgradeNum"></el-input>
        </el-form-item>
      </el-form>
    </div>
  </GLDialog>
</template>

<script>
import { limitPrice } from '@/common/format'
export default {
  name: 'AllocationNumDialog',
  data() {
    return {
      infoForm: {
        allocationNum: ''
      },
      oldVal: {
        allocationNum: ''
      },

      formRules: {
        allocationNum: [{ required: true, message: '请输入调拨数量', trigger: 'change' }]
      },
      selectLoading: false
    }
  },

  props: {
    allocationNumVisible: {
      type: Boolean,
      default: false
    },
    allocationInfo: {
      type: Object,
      default: () => { }
    }
  },

  watch: {},

  created() { },
  components: {},

  computed: {},

  mounted() { },

  methods: {
    handleUpgradeNum(newVal) {
      this.infoForm.allocationNum = limitPrice(newVal, this.oldVal.allocationNum, 8, 2, 0, this.allocationInfo.stock)
      this.oldVal.allocationNum = this.infoForm.allocationNum
    },

    handleAddConfirm() {
      this.$refs.allocationNumForm.validate(valid => {
        if (valid) {
          this.allocationInfo.allocateNumber = parseFloat(this.infoForm.allocationNum)
          this.handleClose(this.allocationInfo)
        }
      })
    },

    handleClose(info, isClose = false) {
      this.$emit('dialogClose', isClose ? undefined : info)
    }
  }
}
</script>
<style >
</style>