bug
liuying
2024-04-25 087b06eb3550e65603a9fbfef9e24dbf4168a09e
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsContainerPackaging/editForm.vue
@@ -1,19 +1,14 @@
<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-item label="容器类型名称" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <!-- <a-input placeholder="请输入容器类型ID" v-decorator="['containerTypeId', {rules: [{required: true, message: '请输入容器类型ID!'}]}]" /> -->
          <a-select style="width: 100%" placeholder="请选择容器类型名称" v-decorator="['containerTypeId']">
            <a-select-option v-for="(item, index) in selectTypeData" :key="index"
              :value="item.typeCode">{{ item.typeName }}</a-select-option>
          <a-select style="width: 100%" placeholder="请选择容器类型名称"  v-decorator="['containerTypeId', {rules: [{required: true, message: '请输入容器类型名称!'}]}]">
            <a-select-option v-for="(item, index) in selectTypeData" :key="index" :value="item.typeCode">{{ item.typeName
            }}</a-select-option>
          </a-select>
        </a-form-item>
@@ -21,11 +16,9 @@
          <a-input placeholder="请输入容器类型名称" v-decorator="['containerTypeName', {rules: [{required: true, message: '请输入容器类型名称!'}]}]" />
        </a-form-item> -->
        <a-form-item label="物料类型名称" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <!-- <a-input placeholder="请输入物料类型ID" v-decorator="['materialTypeId', {rules: [{required: true, message: '请输入物料类型ID!'}]}]" /> -->
          <a-select style="width: 100%" placeholder="请选择物料类型名称" v-decorator="['materialTypeId']">
            <a-select-option v-for="(item, index) in selectTypeData2" :key="index"
              :value="item.materialTypeCode">{{ item.materialTypeName }}</a-select-option>
          <a-select style="width: 100%" placeholder="请选择物料类型名称" v-decorator="['materialTypeId', {rules: [{required: true, message: '请输入物料类型名称!'}]}]">
            <a-select-option v-for="(item, index) in selectTypeData2" :key="index" :value="item.materialTypeCode">{{
              item.materialTypeName }}</a-select-option>
          </a-select>
        </a-form-item>
@@ -36,7 +29,7 @@
          <a-input placeholder="请输入物料类型名称" v-decorator="['materialTypeName', {rules: [{required: true, message: '请输入物料类型名称!'}]}]" />
        </a-form-item> -->
        <a-form-item label="物料容器容量" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入物料容器容量" v-decorator="['boxQty', {rules: [{required: true, message: '请输入物料容器容量!'}]}]" />
          <a-input placeholder="请输入物料容器容量" v-decorator="['boxQty', { rules: [{ required: true, message: '请输入物料容器容量!' }] }]" />
        </a-form-item>
      </a-form>
    </a-spin>
@@ -45,98 +38,99 @@
<script>
import moment from 'moment'
  import {
import {
  WmsContainerPackagingEdit
  } from '@/api/modular/main/WmsBase/WmsContainerPackagingManage'
} from '@/api/modular/main/WmsBase/WmsContainerPackagingManage'
  import { WmsContainerTypePage, WmsContainerTypeDelete, WmsContainerTypeToExcel } from '@/api/modular/main/WmsBase/WmsContainerTypeManage'
   import { WmsMaterialTypePage,} from '@/api/modular/main/WmsBase/WmsMaterialTypeManage'
import { WmsContainerTypePage, WmsContainerTypeDelete, WmsContainerTypeToExcel } from '@/api/modular/main/WmsBase/WmsContainerTypeManage'
import { WmsMaterialTypePage, } from '@/api/modular/main/WmsBase/WmsMaterialTypeManage'
  export default {
  data () {
  return {
  Id: 0,
  labelCol: {
  xs: { span: 24 },
  sm: { span: 5 }
export default {
  data() {
    return {
      Id: 0,
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 15 }
      },
      record: {},
      visible: false,
      confirmLoading: false,
      form: this.$form.createForm(this),
      selectTypeData2:[]
    }
  },
  wrapperCol: {
  xs: { span: 24 },
  sm: { span: 15 }
  created() {
    WmsContainerTypePage().then((d) => {
      this.selectTypeData = d.data.rows || []
    }).catch(() => {
    })
    WmsMaterialTypePage().then((d) => {
      this.selectTypeData2 = d.data.rows || []
    }).catch(() => {
    })
  },
  record: {},
        visible: false,
        confirmLoading: false,
        form: this.$form.createForm(this)
      }
  methods: {
    moment,
    // 初始化方法
    edit(record) {
      this.visible = true;
      this.Id = record.id;
      this.$nextTick(() => {
      });
      //深度拷贝 移除VUE的监听,防止INDEX页面值变动
      this.record = JSON.parse(JSON.stringify(record))
      this.$nextTick(() => {
        this.form.setFieldsValue(
          {
            ...record
          }
        )
      })
    },
    created() {
      WmsContainerTypePage().then((d) => {
        this.selectTypeData = d.data.rows || []
      }).catch(() => {
      })
      WmsMaterialTypePage().then((d) => {
        this.selectTypeData2 = d.data.rows || []
      }).catch(() => {
      })
  },
    methods: {
   moment,
      // 初始化方法
      edit (record) {
        this.visible = true;
      this.Id = record.id;
        this.$nextTick(() => {
        });
        //深度拷贝 移除VUE的监听,防止INDEX页面值变动
        this.record = JSON.parse(JSON.stringify(record))
        this.$nextTick(() => {
          this.form.setFieldsValue(
            {
              ...record
    handleSubmit() {
      const { form: { validateFields } } = this
      this.confirmLoading = true
      validateFields((errors, values) => {
        if (!errors) {
          for (const key in values) {
            if (values[key] == null) continue
            if (typeof (values[key]) === 'object') {
              values[key] = JSON.stringify(values[key])
              this.record[key] = values[key]
            } else {
              this.record[key] = values[key]
            }
          )
        })
      },
      handleSubmit () {
        const { form: { validateFields } } = this
        this.confirmLoading = true
        validateFields((errors, values) => {
          if (!errors) {
            for (const key in values) {
              if (values[key] == null) continue
              if (typeof (values[key]) === 'object') {
                values[key] = JSON.stringify(values[key])
                 this.record[key] = values[key]
              } else {
                 this.record[key] = values[key]
              }
            }
            WmsContainerPackagingEdit(this.record).then((res) => {
              if (res.success) {
                this.$message.success('编辑成功')
                this.confirmLoading = false
                this.$emit('ok', this.record)
                this.handleCancel()
              } else {
                this.$message.error('编辑失败:' + JSON.stringify(res.message))
              }
            }).finally((res) => {
          }
          WmsContainerPackagingEdit(this.record).then((res) => {
            if (res.success) {
              this.$message.success('编辑成功')
              this.confirmLoading = false
            })
          }else{
              this.$emit('ok', this.record)
              this.handleCancel()
            } else {
              this.$message.error('编辑失败:' + JSON.stringify(res.message))
            }
          }).finally((res) => {
            this.confirmLoading = false
          }
        });
      },
      handleCancel () {
        this.form.resetFields()
        this.visible = false
      }
          })
        } else {
          this.confirmLoading = false
        }
      });
    },
    handleCancel() {
      this.form.resetFields()
      this.visible = false
    }
  }
}
</script>