lixiangyu
昨天 bda833babf139081fcf70546cc6d914a4a33ab78
feat(刀具入库): 实现单据提交功能并优化操作权限控制

- 添加提交接口配置和handleSubmit方法实现单据提交
- 根据orderStatus禁用编辑和删除操作按钮
- 修改刀具编码显示字段为cuttingId_dictText
- 清理无用注释代码
已修改2个文件
250 ■■■■ 文件已修改
src/views/cms/CuttingInboundList.vue 246 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/cms/CuttingInventoryList.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/cms/CuttingInboundList.vue
@@ -117,8 +117,7 @@
        </template>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a @click="handleEdit(record)" :disabled="record.orderStatus == '2'">编辑</a>
          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
@@ -126,14 +125,17 @@
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
<!--              <a-menu-item v-if="record.orderStatus != '2'">-->
<!--                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">-->
<!--                  <a>删除</a>-->
<!--                </a-popconfirm>-->
<!--              </a-menu-item>-->
              <a-menu-item v-if="record.orderStatus != '2'">
                  <a @click="handleSubmit(record.id)" :disabled="record.orderStatus == '3'">提交</a>
              </a-menu-item>
              <a-menu-item v-if="record.orderStatus != '2'">
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定提交吗?" @confirm="() => handleSubmit(record.id)">
                  <a>提交</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
@@ -165,7 +167,7 @@
  import Vue from 'vue'
  import { ACCESS_TOKEN } from '@/store/mutation-types'
  import store from '@/store'
  import { Modal } from 'ant-design-vue';
  export default {
    name: 'CuttingInboundList',
@@ -245,6 +247,7 @@
          deleteBatch: "/cms/cuttingInbound/deleteBatch",
          exportXlsUrl: "/cms/cuttingInbound/exportXls",
          importExcelUrl: "cms/cuttingInbound/importExcel",
          submit: "/cms/cuttingInbound/submit",
        },
        dictOptions:{},
        superFieldList:[],
@@ -284,6 +287,7 @@
        this.$refs.modalForm.title="详情";
        this.$refs.modalForm.disableSubmit = true;
      },
      // 自定义行点击事件
      customRow(record) {
        return {
@@ -409,42 +413,208 @@
      /**
       *  单据提交
       */
      // handleSubmit: function() {
      handleSubmit: function(id) {
        if (!this.url.submit) {
          this.$message.error('请设置url.submit属性!')
          return
        }
        let targetId = id; // 从参数获取ID
        // 如果没有通过参数传递ID,则检查选中的记录
        if (!targetId) {
          if (this.selectedRowKeys.length != 1) {
            this.$message.warning('请选择一条记录!')
            return
          } else {
            targetId = this.selectedRowKeys[0]
          }
        }
        // 将参数作为查询参数附加到URL上
        let httpurl = this.url.submit + '?orderId=' + encodeURIComponent(targetId)
        let method = 'get'
        var params = {}  // 清空params,因为参数已经在URL中传递
        const that = this
        this.$confirm({
          title: '确认提交!',
          // content: '正在提交数据,请耐心等待...',
          okText: '确认',
          cancelText: '取消',
          onOk() {
            // 显示加载提示
            const hide = that.$message.loading('正在提交数据,请耐心等待...', 0);
            // 发送请求
            return httpAction(httpurl, params, method).then((res) => {
              hide(); // 隐藏加载提示
              if (res.success) {
                that.$message.success(res.message)
                that.loadData()
              } else {
                that.$message.warning(res.message)
              }
            }).catch(error => {
              hide(); // 隐藏加载提示
              that.$message.error('提交失败: ' + error.message)
            }).finally(() => {
              that.loading = false
            })
          }
        })
      },
      // /**
      //  *  单据提交(支持实时进度更新)
      //  */
      // handleSubmit: function(id) {
      //   if (!this.url.submit) {
      //     this.$message.error('请设置url.submit属性!')
      //     return
      //   }
      //   if (this.selectedRowKeys.length != 1) {
      //     this.$message.warning('请选择一条记录!')
      //     return
      //   } else {
      //     var id = this.selectedRowKeys[0]
      //     let httpurl = this.url.submit
      //     let method = 'post'
      //     var params = { id: id }
      //
      //     const that = this
      //
      //     this.$confirm({
      //       title: '确认提交!',
      //       okText: '确认',
      //       cancelText: '取消',
      //       onOk() {
      //         httpAction(httpurl, params, method).then((res) => {
      //           if (res.success) {
      //             that.$message.success(res.message)
      //             that.loadData()
      //           } else {
      //             that.$message.warning(res.message)
      //           }
      //         }).finally(() => {
      //           that.loading = false
      //
      //         })
      //       }
      //     })
      //   let targetId = id; // 从参数获取ID
      //   // 如果没有通过参数传递ID,则检查选中的记录
      //   if (!targetId) {
      //     if (this.selectedRowKeys.length != 1) {
      //       this.$message.warning('请选择一条记录!')
      //       return
      //     } else {
      //       targetId = this.selectedRowKeys[0]
      //     }
      //   }
      //
      //   const that = this
      //
      //   this.$confirm({
      //     title: '确认提交!',
      //     content: '提交过程中可能需要较长时间,请耐心等待...',
      //     okText: '确认',
      //     cancelText: '取消',
      //
      //     onOk() {
      //       // 创建进度条模态框
      //       let percent = 0;
      //       let totalTools = 0; // 刀具总数
      //       let processedTools = 0; // 已处理刀具数
      //
      //       // 使用 this.$info 创建模态框
      //       const modal = that.$info({
      //         title: '正在提交数据',
      //         content: that.$createElement('div', [
      //           that.$createElement('p', '正在处理刀具入库,请稍候...'),
      //           that.$createElement('a-progress', {
      //             props: {
      //               percent: percent,
      //               status: 'active'
      //             }
      //           }),
      //           // that.$createElement('p', {
      //           //   style: {
      //           //     marginTop: '10px'
      //           //   }
      //           // }, `进度: ${processedTools}/${totalTools} 把刀具`)
      //         ]),
      //         okButtonProps: { style: { display: 'none' } }, // 隐藏确认按钮
      //         cancelText: '取消',
      //         closable: false, // 禁止关闭模态框
      //       });
      //
      //       // 更新进度显示函数
      //       const updateProgress = () => {
      //         if (totalTools > 0) {
      //           percent = Math.round((processedTools / totalTools) * 100);
      //           // 确保进度不超过90%,保留最后10%给最终完成
      //           percent = percent > 90 ? 90 : percent;
      //         }
      //
      //         modal.update({
      //           content: that.$createElement('div', [
      //             that.$createElement('p', '正在处理刀具入库,请稍候...'),
      //             that.$createElement('a-progress', {
      //               props: {
      //                 percent: percent,
      //                 status: 'active'
      //               }
      //             }),
      //             // that.$createElement('p', {
      //             //   style: {
      //             //     marginTop: '10px'
      //             //   }
      //             // }, `进度: ${processedTools}/${totalTools} 把刀具`)
      //           ])
      //         });
      //       };
      //
      //       // 发送请求
      //       let httpurl = that.url.submit + '?orderId=' + encodeURIComponent(targetId)
      //
      //       return httpAction(httpurl, {}, 'get').then((res) => {
      //         // 根据后端返回的总刀具数设置进度
      //         if (res.success) {
      //           // 如果后端返回了总刀具数
      //           if (res.result && res.result.quantity !== undefined) {
      //             totalTools = res.result.quantity;
      //             processedTools = res.result.totalSubmitted || 0; //已处理刀具数
      //           }
      //           // 如果后端返回了明细列表,根据receive_number计算总数量
      //           else if (res.result && res.result.detailList) {
      //             // 根据每个明细的receive_number累加计算总刀具数
      //             totalTools = res.result.detailList.reduce((total, detail) => {
      //               return total + (detail.receiveNumber || 0);
      //             }, 0);
      //             processedTools = totalTools; // 已处理数量
      //           }
      //
      //           // 更新进度显示
      //           percent = 100; // 直接显示100%完成
      //           updateProgress();
      //
      //           // 显示完成状态
      //           setTimeout(() => {
      //             modal.update({
      //               content: that.$createElement('div', [
      //                 that.$createElement('p', '正在处理刀具入库,请稍候...'),
      //                 that.$createElement('a-progress', {
      //                   props: {
      //                     percent: percent,
      //                     status: 'success'
      //                   }
      //                 }),
      //                 that.$createElement('p', {
      //                   style: {
      //                     marginTop: '10px'
      //                   }
      //                 }, totalTools > 0 ?
      //                   `进度: ${processedTools}/${totalTools} 把刀具` :
      //                   '处理完成')
      //               ])
      //             });
      //
      //             // 延迟关闭模态框
      //             setTimeout(() => {
      //               modal.destroy();
      //               that.$message.success(res.message || '提交成功');
      //               that.loadData();
      //             }, 500);
      //           }, 300);
      //         } else {
      //           // 处理错误情况
      //           modal.destroy();
      //           that.$message.warning(res.message || '提交失败');
      //         }
      //       }).catch(error => {
      //         modal.destroy();
      //         that.$message.error('提交失败: ' + error.message)
      //       }).finally(() => {
      //         that.loading = false
      //       })
      //     }
      //   })
      // },
    }
  }
</script>
src/views/cms/CuttingInventoryList.vue
@@ -147,7 +147,7 @@
          {
            title:'刀具编码',
            align:"center",
            dataIndex: 'cuttingId'
            dataIndex: 'cuttingId_dictText'
          },
          {
            title:'刀具条码',
@@ -179,7 +179,7 @@
          deleteBatch: "/cms/cuttingInventory/deleteBatch",
          exportXlsUrl: "/cms/cuttingInventory/exportXls",
          importExcelUrl: "cms/cuttingInventory/importExcel",
        },
        dictOptions:{},
        superFieldList:[],