chenrui 3 年之前
父节点
当前提交
66999fb334
共有 1 个文件被更改,包括 41 次插入79 次删除
  1. 41 79
      src/views/allocationManagement/transferOut/edit.vue

+ 41 - 79
src/views/allocationManagement/transferOut/edit.vue

@@ -9,8 +9,8 @@
         </template>
         <!-- 操作区,位于 title 行的行尾 -->
         <template v-if="$hasPermissions('B_transferOut_print')" slot="extra">
-          <a-button key="2" id="allocateBillEdit-preview-btn" :disabled="chooseLoadData.length==0" @click="handlePrint('preview')">打印预览</a-button>
-          <a-button key="1" type="primary" id="allocateBillEdit-print-btn" :disabled="chooseLoadData.length==0" @click="handlePrint('print')">快捷打印</a-button>
+          <a-button key="2" id="allocateBillEdit-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
+          <a-button key="1" type="primary" id="allocateBillEdit-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
         </template>
       </a-page-header>
       <!-- 选择产品 -->
@@ -78,7 +78,7 @@
             <a-row :gutter="15">
               <a-col :span="17">
                 <div class="table-page-search-wrapper">
-                  <a-form layout="inline" @keyup.enter.native="getChooseProductList(1)">
+                  <a-form layout="inline" @keyup.enter.native="$refs.chooseTable.refresh(true)">
                     <a-row :gutter="15">
                       <a-col :md="9" :sm="24">
                         <a-form-item label="产品编码" prop="productCode">
@@ -91,7 +91,7 @@
                         </a-form-item>
                       </a-col>
                       <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
-                        <a-button type="primary" @click="getChooseProductList(1)" :disabled="chooseDisabled" id="storeTransferOutList-refresh">查询</a-button>
+                        <a-button type="primary" @click="$refs.chooseTable.refresh(true)" :disabled="chooseDisabled" id="storeTransferOutList-refresh">查询</a-button>
                         <a-button style="margin-left: 8px" @click="chooseResetSearchForm" :disabled="chooseDisabled" id="storeTransferOutList-reset">重置</a-button>
                       </a-col>
                     </a-row>
@@ -104,16 +104,14 @@
               </a-col>
             </a-row>
             <!-- 列表 -->
-            <a-table
+            <s-table
               class="sTable"
               ref="chooseTable"
               size="small"
               :rowKey="(record) => record.id"
               :columns="chooseColumns"
-              :dataSource="chooseLoadData"
+              :data="chooseLoadData"
               :scroll="{ x: 1090, y: 300 }"
-              :loading="loading"
-              :pagination="false"
               bordered>
               <!-- 调出数量 -->
               <template slot="qty" slot-scope="text, record">
@@ -127,20 +125,21 @@
                   placeholder="请输入"
                   @blur="e => qtyBlur(e.target.value, record)"
                   style="width: 100%;" />
+                <!-- <a-select
+                  id="allocateBillEdit-qty"
+                  option-label-prop="label"
+                  v-model="record.qty"
+                  placeholder="请选择"
+                  style="width: 100%;">
+                  <a-select-option v-if="record.price" :value="record.price" :label="record.price">成本价{{ record.price }}</a-select-option>
+                  <a-select-option v-if="record.totalCost" :value="record.totalCost" :label="record.totalCost">A价{{ record.totalCost }}</a-select-option>
+                </a-select> -->
               </template>
               <!-- 操作 -->
               <template slot="action" slot-scope="text, record">
                 <a-button size="small" type="primary" class="button-error" @click="handleDel(record)" id="allocateBillEdit-del-btn">删除</a-button>
               </template>
-            </a-table>
-            <!-- 分页 -->
-            <tablePagination
-              ref="chooseTablePagination"
-              :total="choosePaginationProps.total"
-              :current="choosePaginationProps.current"
-              :pageSize="choosePaginationProps.pageSize"
-              @changePageSize="changeChoosePageSize"
-              @changePage="changeChoosePage" />
+            </s-table>
           </a-collapse-panel>
         </a-collapse>
       </a-card>
@@ -164,12 +163,11 @@
 
 <script>
 import { STable, VSelect } from '@/components'
-import tablePagination from '@/views/common/tablePagination.vue'
 import ImportGuideModal from './importGuideModal.vue'
 import { queryStockProductPage } from '@/api/stock'
 import { allocateBillDetailList, allocateBillDetailCount, allocateBillDetailSave, allocateBillSubmit, allocateBillDetailDel, allocateBillDetailDelAll, allocateBillDetailPrint, allocateBillBatchInsert } from '@/api/allocateBill'
 export default {
-  components: { STable, VSelect, tablePagination, ImportGuideModal },
+  components: { STable, VSelect, ImportGuideModal },
   data () {
     return {
       spinning: false,
@@ -228,11 +226,24 @@ export default {
         { title: '单位', dataIndex: 'productEntity.unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: 80, align: 'center', fixed: 'right' }
       ],
-      chooseLoadData: [],
-      choosePaginationProps: {
-        total: 0, //  分页总条数
-        current: 1,
-        pageSize: 20
+      localDataSource: [],
+      // 加载数据方法 必须为 Promise 对象
+      chooseLoadData: parameter => {
+        this.chooseDisabled = true
+        const params = Object.assign(parameter, this.chooseQueryParam, { allocateSn: this.$route.params.sn })
+        return allocateBillDetailList(params).then(res => {
+          //  合计
+          this.getDetailCount(params)
+          const data = res.data
+          const no = (data.pageNo - 1) * data.pageSize
+          for (var i = 0; i < data.list.length; i++) {
+            data.list[i].no = no + i + 1
+            data.list[i].qtyBackups = data.list[i].qty
+          }
+          this.localDataSource = data.list
+          this.chooseDisabled = false
+          return data
+        })
       },
       productTotal: null, //  合计
       openGuideModal: false //  导入产品引导
@@ -260,7 +271,7 @@ export default {
     hanldeOk (obj) {
       allocateBillBatchInsert(obj).then(res => {
         if (res.status == 200) {
-          this.getChooseProductList(1)
+          this.$refs.chooseTable.refresh(true)
         }
       })
     },
@@ -268,10 +279,7 @@ export default {
     chooseResetSearchForm () {
       this.chooseQueryParam.productCode = ''
       this.chooseQueryParam.productName = ''
-      this.choosePaginationProps.total = 0
-      this.choosePaginationProps.current = 1
-      this.choosePaginationProps.pageSize = 20
-      this.getChooseProductList(1)
+      this.$refs.chooseTable.refresh(true)
     },
     //  添加/编辑
     handleAdd (row, isEdit) {
@@ -295,7 +303,7 @@ export default {
         if (res.status == 200) {
           this.$message.success(res.message)
           this.$refs.table.refresh()
-          this.getChooseProductList()
+          this.$refs.chooseTable.refresh()
           this.spinning = false
         } else {
           row.qty = row.qtyBackups
@@ -318,7 +326,7 @@ export default {
               if (res.status == 200) {
                 _this.$message.success(res.message)
                 _this.$refs.table.refresh()
-                _this.getChooseProductList()
+                _this.$refs.chooseTable.refresh()
                 _this.spinning = false
               } else {
                 _this.spinning = false
@@ -330,7 +338,7 @@ export default {
               if (res.status == 200) {
                 _this.$message.success(res.message)
                 _this.$refs.table.refresh()
-                _this.getChooseProductList()
+                _this.$refs.chooseTable.refresh()
                 _this.spinning = false
               } else {
                 _this.spinning = false
@@ -370,50 +378,6 @@ export default {
     handleBack () {
       this.$router.push({ path: '/allocationManagement/transferOut/list', query: { closeLastOldTab: true } })
     },
-    //  已选产品 分页  一页多少条change
-    changeChoosePageSize (current, pageSize) {
-      this.choosePaginationProps.current = current
-      this.choosePaginationProps.pageSize = pageSize
-      this.getChooseProductList()
-    },
-    //  已选产品 分页 页码change
-    changeChoosePage (current) {
-      this.choosePaginationProps.current = current
-      this.getChooseProductList()
-    },
-    // 已选产品列表数据
-    getChooseProductList (pageNo) {
-      this.choosePaginationProps.current = this.choosePaginationProps.current || pageNo
-      this.chooseDisabled = true
-      this.loading = true
-      const params = {
-        pageNo: this.choosePaginationProps.current,
-        pageSize: this.choosePaginationProps.pageSize,
-        allocateSn: this.$route.params.sn
-      }
-      allocateBillDetailList(Object.assign(params, this.chooseQueryParam)).then(res => {
-        this.loading = false
-        if (res.status == 200) {
-          //  合计
-          this.getDetailCount(Object.assign(params, this.chooseQueryParam))
-          const data = res.data
-          this.choosePaginationProps.total = Number(res.data.count) || 0
-          this.choosePaginationProps.current = data.pageNo
-          const no = (data.pageNo - 1) * data.pageSize
-          for (var i = 0; i < data.list.length; i++) {
-            data.list[i].no = no + i + 1
-            data.list[i].qtyBackups = data.list[i].qty
-          }
-          this.chooseLoadData = data.list
-          this.chooseDisabled = false
-        } else {
-          this.choosePaginationProps.total = 0
-          this.choosePaginationProps.current = 1
-          this.choosePaginationProps.pageSize = 20
-          this.chooseLoadData = []
-        }
-      })
-    },
     // 已选产品 调出数量  blur
     qtyBlur (val, record) {
       //  光标移出,值发生改变再调用编辑接口
@@ -457,9 +421,7 @@ export default {
     }
   },
   beforeRouteEnter (to, from, next) {
-    next(vm => {
-      vm.getChooseProductList(1)
-    })
+    next(vm => {})
   }
 }
 </script>