Houjie
3 天以前 4dfdc774c2e742764848177e44e75b7de518f285
src/views/cms/CuttingReceiveList.vue
@@ -100,9 +100,27 @@
          </a-button>
        </template>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
        <!--        <span slot="action" slot-scope="text, record">-->
        <!--          <a @click="handleEdit(record)">编辑</a>-->
        <!--          <a-divider type="vertical" />-->
        <!--          <a-dropdown>-->
        <!--            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>-->
        <!--            <a-menu slot="overlay">-->
        <!--              <a-menu-item>-->
        <!--                <a @click="handleDetail(record)">详情</a>-->
        <!--              </a-menu-item>-->
        <!--              <a-menu-item>-->
        <!--                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">-->
        <!--                  <a>删除</a>-->
        <!--                </a-popconfirm>-->
        <!--              </a-menu-item>-->
        <!--            </a-menu>-->
        <!--          </a-dropdown>-->
        <!--        </span>-->
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)" :disabled="record.orderStatus === '2' || record.orderStatus === '3'">编辑</a>
          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
@@ -110,10 +128,16 @@
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
              <a-menu-item v-if="record.orderStatus === '1'">
                  <a @click="handleSubmit(record.id)" :disabled="record.orderStatus === '3'">提交</a>
              </a-menu-item>
              <a-menu-item v-if="record.orderStatus === '1'">
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
               <a-menu-item v-if="record.orderStatus === '2'">
                  <a @click="handleBack(record.id)">归还</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
@@ -137,6 +161,7 @@
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import CuttingReceiveModal from './modules/CuttingReceiveModal'
import CuttingReceiveDetailList from './CuttingReceiveDetailList'
import { httpAction } from '@api/manage'
export default {
  name: 'CuttingReceiveList',
@@ -235,7 +260,7 @@
        {
          title: '领用单状态',
          align: 'center',
          dataIndex: 'orderStatus'
          dataIndex: 'orderStatus_dictText'
        },
        {
          title: '操作',
@@ -251,8 +276,9 @@
        delete: '/cms/cuttingReceive/delete',
        deleteBatch: '/cms/cuttingReceive/deleteBatch',
        exportXlsUrl: '/cms/cuttingReceive/exportXls',
        importExcelUrl: 'cms/cuttingReceive/importExcel'
        importExcelUrl: 'cms/cuttingReceive/importExcel',
        submit: '/cms/cuttingReceive/submit',
        returnBack: '/cms/cuttingReceive/handleBack'
      },
      dictOptions: {},
      superFieldList: []
@@ -307,6 +333,117 @@
          }
        }
      }
    },
    /**
     *  单据提交
     */
    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
          })
        }
      })
    },
    /**
     *  单据领用
     */
    handleBack: function(id) {
      if (!this.url.returnBack) {
        this.$message.error('请设置url.return属性!')
        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.returnBack + '?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
          })
        }
      })
    }
  }
}