liuying
2024-04-25 acc8fe777aa6348abed17cb30767a66deda74253
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsMaterial/addForm.vue
@@ -1,18 +1,15 @@
<template>
  <a-modal
    title="新增物料信息表"
    :width="900"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
  <a-modal title="新增物料信息表" :width="900" :visible="visible" :confirmLoading="confirmLoading" @ok="handleSubmit"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
      <a-form :form="form">
        <a-form-item label="物料名称" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入物料名称" v-decorator="['materialName', {rules: [{required: true, message: '请输入物料名称!'}]}]" />
          <a-input placeholder="请输入物料名称"
            v-decorator="['materialName', { rules: [{ required: true, message: '请输入物料名称!' }] }]" />
        </a-form-item>
        <a-form-item label="物料编号" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入物料编号" v-decorator="['materialCode', {rules: [{required: true, message: '请输入物料编号!'}]}]" />
          <a-input placeholder="请输入物料编号"
            v-decorator="['materialCode', { rules: [{ required: true, message: '请输入物料编号!' }] }]" />
        </a-form-item>
        <a-form-item label="ERP编号" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入ERP编号" v-decorator="['erpCode']" />
@@ -77,69 +74,69 @@
</template>
<script>
  import moment from 'moment'
  import {
import moment from 'moment'
import {
  WmsMaterialAdd
  } from '@/api/modular/main/WmsBase/WmsMaterialManage'
  export default {
  data () {
  return {
  labelCol: {
  xs: { span: 24 },
  sm: { span: 5 }
} from '@/api/modular/main/WmsBase/WmsMaterialManage'
export default {
  data() {
    return {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 15 }
      },
      visible: false,
      confirmLoading: false,
      form: this.$form.createForm(this)
    }
  },
  wrapperCol: {
  xs: { span: 24 },
  sm: { span: 15 }
  },
        visible: false,
        confirmLoading: false,
        form: this.$form.createForm(this)
      }
    },
    methods: {
   moment,
      // 初始化方法
      add (record) {
        this.visible = true
        this.$nextTick(() => {
  methods: {
    moment,
    // 初始化方法
    add(record) {
      this.visible = true
      this.$nextTick(() => {
        });
      },
      /**
       * 提交表单
       */
      handleSubmit () {
        const { form: { validateFields } } = this
        this.confirmLoading = true
        validateFields((errors, values) => {
          if (!errors) {
            for (const key in values) {
              if (typeof (values[key]) === 'object') {
                values[key] = JSON.stringify(values[key])
              }
      });
    },
    /**
     * 提交表单
     */
    handleSubmit() {
      const { form: { validateFields } } = this
      this.confirmLoading = true
      validateFields((errors, values) => {
        if (!errors) {
          for (const key in values) {
            if (typeof (values[key]) === 'object') {
              values[key] = JSON.stringify(values[key])
            }
            WmsMaterialAdd(values).then((res) => {
              if (res.success) {
                this.$message.success('新增成功')
                this.confirmLoading = false
                this.$emit('ok', values)
                this.handleCancel()
              } else {
                this.$message.error('新增失败:' + JSON.stringify(res.message))
              }
            }).finally((res) => {
              this.confirmLoading = false
            })
          } else {
            this.confirmLoading = false
          }
        })
      },
      handleCancel () {
        this.form.resetFields()
        this.visible = false
      }
          WmsMaterialAdd(values).then((res) => {
            if (res.success) {
              this.$message.success('新增成功')
              this.confirmLoading = false
              this.$emit('ok', values)
              this.handleCancel()
            } else {
              this.$message.error('新增失败:' + JSON.stringify(res.message))
            }
          }).finally((res) => {
            this.confirmLoading = false
          })
        } else {
          this.confirmLoading = false
        }
      })
    },
    handleCancel() {
      this.form.resetFields()
      this.visible = false
    }
  }
}
</script>