lilei 3 years ago
parent
commit
b9367226c3

+ 8 - 0
src/api/allocateReturn.js

@@ -118,6 +118,14 @@ export const allocReturnDetailInsert = params => {
     method: 'post'
   })
 }
+// 批量添加退货明细
+export const allocReturnDetailInsertBatch = params => {
+  return axios({
+    url: '/allocReturnDetail/insertBatch',
+    data: params,
+    method: 'post'
+  })
+}
 // 分页查询调拨退货明细列表
 export const allocReturnDetailQueryPage = (params) => {
   const url = `/allocReturnDetail/queryPage/${params.pageNo}/${params.pageSize}`

+ 9 - 0
src/api/salesDetail.js

@@ -9,6 +9,15 @@ export const salesDetailDel = (params) => {
   })
 }
 
+// 批量删除
+export const salesDetailBatchDel = (params) => {
+  return axios({
+    url: `/sales/detail/delete/batch`,
+    data: params,
+    method: 'post'
+  })
+}
+
 // 一键发货
 export const salesDetailDispatchByOneKey = (params) => {
   return axios({

+ 81 - 7
src/views/allocationManagement/transferReturn/editGrp.vue

@@ -40,25 +40,35 @@
             <div class="table-page-search-wrapper">
               <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
                 <a-row :gutter="15">
-                  <a-col :md="6" :sm="24">
+                  <a-col :md="5" :sm="24">
                     <a-form-item label="调拨单号" prop="allocateNo">
                       <a-input id="editGrap-allocateNo" v-model.trim="queryParam.allocateNo" placeholder="请输入调拨单号" allowClear />
                     </a-form-item>
                   </a-col>
-                  <a-col :md="6" :sm="24">
+                  <a-col :md="5" :sm="24">
                     <a-form-item label="产品编码" prop="productCode">
                       <a-input id="editGrap-productCode" v-model.trim="queryParam.productCode" placeholder="请输入产品编码" allowClear />
                     </a-form-item>
                   </a-col>
-                  <a-col :md="6" :sm="24">
+                  <a-col :md="5" :sm="24">
                     <a-form-item label="产品名称" prop="productName">
                       <a-input id="editGrap-productName" v-model.trim="queryParam.productName" placeholder="请输入产品名称" allowClear />
                     </a-form-item>
                   </a-col>
-                  <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
+                  <a-col :md="4" :sm="24" style="margin-bottom: 10px;">
                     <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="storeTransferOutList-refresh">查询</a-button>
                     <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="storeTransferOutList-reset">重置</a-button>
                   </a-col>
+                  <a-col :md="5" :sm="24" style="margin-bottom: 10px;text-align: right;">
+                    <span>已选{{ selectTotal }}项</span>
+                    <a-button
+                      style="margin:0 15px;"
+                      size="small"
+                      type="primary"
+                      class="button-info"
+                      id="salesEdit-plDel-btn"
+                      @click="handleBatchAdd">批量添加</a-button>
+                  </a-col>
                 </a-row>
               </a-form>
             </div>
@@ -73,6 +83,8 @@
               :columns="columns"
               :customRow="handleClickRow"
               :data="loadData"
+              :row-selection="{ columnWidth: 40, getCheckboxProps: record => ({ props: { disabled: !record.refundableQty } }) }"
+              @rowSelection="rowSelectionFun"
               :scroll="{ y: 300 }"
               :defaultLoadData="false"
               bordered>
@@ -230,8 +242,8 @@ import {
   allocReturnDetailInsert,
   allocReturnDetailUpdate,
   allocateReturnSubmit,
-  allocReturnDetailDelete
-  // allocateBillBatchInsert
+  allocReturnDetailDelete,
+  allocReturnDetailInsertBatch
 } from '@/api/allocateReturn'
 
 export default {
@@ -295,10 +307,14 @@ export default {
         })
       },
       basicInfoData: null, // 基本信息
-      openGuideModal: false //  导入产品引导
+      openGuideModal: false, //  导入产品引导
+      rowSelectionInfo: null
     }
   },
   computed: {
+    selectTotal () {
+      return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length || 0
+    },
     columns () {
       const arr = [
         { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
@@ -331,6 +347,63 @@ export default {
     }
   },
   methods: {
+    // 表格选中项
+    rowSelectionFun (obj) {
+      this.rowSelectionInfo = obj || null
+    },
+    // 批量添加
+    handleBatchAdd () {
+      const _this = this
+      if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
+        _this.$message.warning('请在选择要添加的产品后再进行批量操作!')
+        return
+      }
+      const obj = []
+      _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
+        obj.push({
+          'allocateNo': item.allocateNo,
+          'allocateSn': item.allocateSn,
+          'oldPrice': item.oldPrice,
+          'price': item.returnPrice,
+          'productSn': item.productSn,
+          'productCode': item.productCode
+        })
+      })
+      this.$confirm({
+        title: '提示',
+        content: '已选产品' + obj.length + '项,确认要批量添加吗?',
+        centered: true,
+        onOk () {
+          _this.spinning = true
+          allocReturnDetailInsertBatch({
+            allocateReturnSn: _this.$route.params.sn,
+            detailDtoList: obj
+          }).then(res => {
+            if (res.status == 200) {
+              _this.$refs.table.clearSelected() // 清空表格选中项
+              _this.getDetail(true)
+              _this.$refs.chooseTable.refresh()
+              if (res.data.failMessage.length) {
+                _this.showFailMessage(res.data)
+              }
+            }
+            _this.spinning = false
+          })
+        }
+      })
+    },
+    showFailMessage (data) {
+      const h = this.$createElement
+      const htmlStr = [h('p', data.message)]
+      for (let i = 0; i < data.failMessage.length; i++) {
+        htmlStr.push(h('p', data.failMessage[i]))
+      }
+      this.$info({
+        title: '操作提示',
+        content: h('div', {}, htmlStr),
+        centered: true
+      })
+    },
     // 修改备注
     handleEditRemark () {
       const _this = this
@@ -366,6 +439,7 @@ export default {
       this.queryParam.productName = ''
       this.queryParam.allocateNo = ''
       this.$refs.table.refresh(true)
+      this.$refs.table.clearSelected() // 清空表格选中项
     },
     // 双击快速添加
     handleClickRow (record) {

+ 58 - 3
src/views/salesManagement/salesQuery/edit.vue

@@ -65,7 +65,20 @@
                 </a-row>
               </a-form>
               <div style="position: absolute;right: 0;top: 3px;">
-                <a-button size="small" type="primary" class="button-info" id="salesEdit-import-btn" @click="openGuideModal=true">导入产品</a-button>
+                <span>已选{{ selectTotal }}项</span>
+                <a-button
+                  style="margin:0 15px;"
+                  size="small"
+                  type="danger"
+                  class="button-info"
+                  id="salesEdit-plDel-btn"
+                  @click="handleBatchDel">批量删除</a-button>
+                <a-button
+                  size="small"
+                  type="primary"
+                  class="button-info"
+                  id="salesEdit-import-btn"
+                  @click="openGuideModal=true">导入产品</a-button>
               </div>
             </div>
           </a-col>
@@ -78,6 +91,8 @@
           :rowKey="(record) => record.id"
           :columns="columns"
           :data="loadData"
+          :row-selection="{ columnWidth: 40 }"
+          @rowSelection="rowSelectionFun"
           :defaultLoadData="false"
           :scroll="{ y: 300 }"
           bordered>
@@ -193,7 +208,7 @@ import queryPromotable from './queryPromotable.vue'
 import ChooseActive from './chooseActive.vue'
 import ImportGuideModal from './importGuideModal.vue'
 import { salesDetailBySn, salesWriteSubmit, getPromoacActiveList } from '@/api/sales'
-import { salesDetailStockList, salesDetailInsert, salesDetailUpdateQty, salesDetailDel, salesDetailDelAll, addPromoGoods, salesBatchInsert } from '@/api/salesDetail'
+import { salesDetailStockList, salesDetailInsert, salesDetailUpdateQty, salesDetailDel, salesDetailBatchDel, salesDetailDelAll, addPromoGoods, salesBatchInsert } from '@/api/salesDetail'
 export default {
   name: 'SalesEdit',
   mixins: [commonMixin],
@@ -239,10 +254,14 @@ export default {
       queryParam: {
         productCode: '',
         productName: ''
-      }
+      },
+      rowSelectionInfo: null
     }
   },
   computed: {
+    selectTotal () {
+      return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length || 0
+    },
     columns () {
       const arr = [
         { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
@@ -263,6 +282,41 @@ export default {
     }
   },
   methods: {
+    // 表格选中项
+    rowSelectionFun (obj) {
+      this.rowSelectionInfo = obj || null
+    },
+    // 批量删除已选产品
+    handleBatchDel () {
+      const _this = this
+      if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
+        _this.$message.warning('请在选择要删除的产品后再进行批量操作!')
+        return
+      }
+      const obj = []
+      _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
+        obj.push(item.salesBillDetailSn)
+      })
+      this.$confirm({
+        title: '提示',
+        content: '已选产品' + obj.length + '项,确认要批量删除吗?',
+        centered: true,
+        onOk () {
+          _this.spinning = true
+          salesDetailBatchDel({
+            salesBillSn: _this.salesBillSn,
+            salesBillDetailSnList: obj
+          }).then(res => {
+            if (res.status == 200) {
+              _this.resetSearchForm(true)
+              _this.$refs.promotable.resetCurForm()
+              _this.$message.success(res.message)
+            }
+            _this.spinning = false
+          })
+        }
+      })
+    },
     // 已选产品  blur
     onCellBlur (val, record) {
       const _this = this
@@ -297,6 +351,7 @@ export default {
       this.$refs.table.refresh(!!flag)
       this.getPromoacActiveList()
       this.getOrderDetail(false)
+      this.$refs.table.clearSelected() // 清空表格选中项
     },
     //  返回
     handleBack () {