src/views/cms/modules/CuttingScrapModal.vue
@@ -26,7 +26,8 @@
        <a-row style="width: 100%">
          <a-col :span="24">
            <a-form-item label="申请说明" :labelCol="{span:3}" :wrapperCol="{span:21}">
              <a-textarea :disabled="disableSubmit" placeholder="请输入申请说明" v-decorator="['applicationComment', validatorRules.applicationComment]" />
              <a-textarea :disabled="disableSubmit" placeholder="请输入申请说明"
                          v-decorator="['applicationComment', validatorRules.applicationComment]" />
            </a-form-item>
          </a-col>
        </a-row>
@@ -54,14 +55,16 @@
        <a-row style="width: 100%">
          <a-col :span="24">
            <a-form-item label="确认意见" :labelCol="{span:3}" :wrapperCol="{span:21}">
              <a-textarea :disabled="disableSubmit" placeholder="请输入确认意见" v-decorator="['confirmComment', validatorRules.confirmComment]" />
              <a-textarea :disabled="disableSubmit" placeholder="请输入确认意见"
                          v-decorator="['confirmComment', validatorRules.confirmComment]" />
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </a-spin>
    <a-button type="primary" :style="{ marginBottom: '8px' }" @click="selectTooling()"
      >选择刀具</a-button
    >选择报废刀具
    </a-button
    >
    <a-table
      ref="table"
@@ -98,7 +101,7 @@
    <template slot="footer" v-if="disableSubmit == true">
      <a-button :style="{ marginRight: '8px' }" @click="handleCancel">关闭</a-button>
    </template>
    <j-select-tooling-modal ref="toolingModalForm" @ok="modalFormOk"></j-select-tooling-modal>
    <j-select-scrap-modal ref="scrapModalForm" @ok="modalFormOk"></j-select-scrap-modal>
  </a-modal>
</template>
@@ -113,14 +116,16 @@
  import JMultiSelectTag from '@/components/dict/JMultiSelectTag'
  import { filterObj } from '@/utils/util'
  import store from '@/store/'
import JSelectScrapModal from '@views/cms/modules/JSelectScrapModal.vue'
  export default {
    name: 'CuttingInboundModal',
    components: {
    JSelectToolingModal,
    JSelectScrapModal,
    JMultiSelectTag,
    JDictSelectTag,
    store,
    moment,
    moment
  },
    data () {
      return {
@@ -134,7 +139,7 @@
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0,
        total: 0
      },
      title:'新增',
         visible: false,
@@ -142,19 +147,18 @@
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 },
        sm: { span: 6 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 18 },
        sm: { span: 18 }
      },
      confirmLoading: false,
      loading: false,
      form: this.$form.createForm(this),
      dataSource: [],
      param: {},
      validatorRules: {
      },
      validatorRules: {},
      columns: [
        {
          title: '#',
@@ -164,30 +168,30 @@
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
          }
        },
        {
          title: '刀具编码',
          align: 'center',
          dataIndex: 'cuttingCode',
          width: 150,
          width: 150
        },
        {
          title: '刀具名称',
          align: 'center',
          dataIndex: 'cuttingName',
          dataIndex: 'cuttingName'
        },
        
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' },
        },
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        add: '/cms/cuttingScrap/add',
        detailList: '/cms/cuttingScrap/detailList',
        detailList: '/cms/cuttingScrap/detailList'
      },
      orderId:'',
      disableSubmit:false
@@ -240,10 +244,11 @@
      let ids = []
      for (let i = 0; i < this.dataSource.length; i++) {
        ids.push(this.dataSource[i].cuttingId)
        ids.push(this.dataSource[i].inventoryId)
      }
      this.$refs.toolingModalForm.showModal(ids)
      this.$refs.toolingModalForm.title = '选择刀具'
      this.$refs.toolingModalForm.disableSubmit = false
      this.$refs.scrapModalForm.showModal(ids)
      this.$refs.scrapModalForm.title = '选择报废刀具'
      this.$refs.scrapModalForm.disableSubmit = false
    },
    detailList(orderId) {
      this.param.orderId = orderId
@@ -262,17 +267,32 @@
        return
      }
      const that = this
      // 触发表单验证
      this.form.validateFields((err, values) => {
        if (!err) {
          that.confirmLoading = true
          let formData = Object.assign(this.model, values)
          formData.detailData = this.dataSource
          // 确保传递给后端的数据包含所有必要字段
          formData.detailData = this.dataSource.map(item => {
            return {
              // 明确指定每个字段,确保 inventoryId 被正确传递
              inventoryId: item.inventoryId,
              cuttingId: item.cuttingId,
              cuttingCode: item.cuttingCode,
              cuttingName: item.cuttingName,
              // 如果还有其他字段也需要包含
              ...item // 包含其他可能存在的字段
            }
          })
          postAction(that.url.add, formData)
            .then((res) => {
              if (res.success) {
                that.$message.success('报废成功')
                that.$emit('ok', new Date())
                that.$message.success('报废成功')
              } else {
                that.$message.warning(res.message)
              }
@@ -292,19 +312,24 @@
      this.dataSource = []
      this.visible = false
      this.disableSubmit = false
    },
    }
    },
    mounted() {
    this.$bus.$on('selectionRows', (data) => {
      //getCurrSelected 事件 接收组件传递的参数
      for (let i = 0; i < data.length; i++) {
        this.dataSource.push({
          cuttingId: data[i].id,
          // cuttingId: data[i].id,
          // cuttingCode: data[i].cuttingCode,
          // cuttingName: data[i].cuttingName
          inventoryId: data[i].id,
          cuttingCode: data[i].cuttingCode,
          cuttingName: data[i].cuttingName
          cuttingName: data[i].cuttingName,
          cuttingId: data[i].cuttingId,
        })
      }
    })
  },
    console.log('更新后的数据源:', this.dataSource)
  }
  }
</script>