Browse Source

对接出入库明细

chenrui 4 years ago
parent
commit
26af943553
2 changed files with 109 additions and 46 deletions
  1. 10 1
      src/api/stock.js
  2. 99 45
      src/views/inventoryManagement/inventoryQuery/warehouseDetail.vue

+ 10 - 1
src/api/stock.js

@@ -49,4 +49,13 @@ export const querySumByProductLocation = (params) => {
     data: params,
     method: 'post'
   })
-}
+}
+//  出入库明细  列表  合计
+export const stockByProductSn = (params) => {
+  const url = `/stock/findByProductSn/${params.productSn}`
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}

+ 99 - 45
src/views/inventoryManagement/inventoryQuery/warehouseDetail.vue

@@ -13,22 +13,30 @@
           <a-row :gutter="15">
             <a-col :md="6" :sm="24">
               <a-form-item label="变动类型">
-                <a-select id="inventoryQueryWarehouseDetail-bundleNames" placeholder="请选择产品品牌" allowClear v-model="queryParam.brand">
-                  <a-select-option v-for="item in brandData" :key="item.stationNo" :value="item.stationNo">{{ item.name }}</a-select-option>
-                </a-select>
+                <v-select
+                  v-model="queryParam.flowType"
+                  ref="flowType"
+                  id="warehousingAuditList-flowType"
+                  code="STOCK_FLOW_TYPE"
+                  placeholder="请选择变动类型"
+                  allowClear></v-select>
               </a-form-item>
             </a-col>
             <a-col :md="6" :sm="24">
               <a-form-item label="单据类型">
-                <a-select id="inventoryQueryWarehouseDetail-bundleNames" placeholder="请选择产品品牌" allowClear v-model="queryParam.brand">
-                  <a-select-option v-for="item in brandData" :key="item.stationNo" :value="item.stationNo">{{ item.name }}</a-select-option>
-                </a-select>
+                <v-select
+                  v-model="queryParam.bizType"
+                  ref="bizType"
+                  id="inventoryQueryWarehouseDetail-bizType"
+                  code="STOCK_FLOW_BIZ_TYPE"
+                  placeholder="请选择单据类型"
+                  allowClear></v-select>
               </a-form-item>
             </a-col>
             <a-col :md="6" :sm="24">
               <a-form-item label="仓库">
-                <a-select id="inventoryQueryWarehouseDetail-bundleNames" placeholder="请选择产品品牌" allowClear v-model="queryParam.brand">
-                  <a-select-option v-for="item in brandData" :key="item.stationNo" :value="item.stationNo">{{ item.name }}</a-select-option>
+                <a-select id="inventoryQueryWarehouseDetail-warehouseSn" placeholder="请选择仓库" v-model="queryParam.warehouseSn" >
+                  <a-select-option v-for="item in warehouseList" :key="item.warehouseSn" :value="item.warehouseSn">{{ item.name }}</a-select-option>
                 </a-select>
               </a-form-item>
             </a-col>
@@ -37,9 +45,9 @@
                 <a-form-item label="单据审核时间">
                   <a-range-picker
                     style="width:100%"
-                    id="inventoryQueryWarehouseDetail-bundleNamesss"
+                    id="inventoryQueryWarehouseDetail-createDate"
                     :disabledDate="disabledDate"
-                    v-model="queryParam.brand"
+                    v-model="createDate"
                     :format="dateFormat"
                     :placeholder="['开始时间', '结束时间']" />
                 </a-form-item>
@@ -47,7 +55,7 @@
               </a-col>
               <a-col :md="6" :sm="24">
                 <a-form-item label="单位名称">
-                  <a-input id="inventoryQueryWarehouseDetail-orderBundleNo" v-model.trim="queryParam.orderBundleNo" allowClear placeholder="请输入单位名称"/>
+                  <a-input id="inventoryQueryWarehouseDetail-unitName" v-model.trim="queryParam.unitName" allowClear placeholder="请输入单位名称"/>
                 </a-form-item>
               </a-col>
             </template>
@@ -64,7 +72,7 @@
       </div>
       <!-- 合计 -->
       <a-alert type="info" showIcon style="margin-bottom:15px">
-        <div class="ftext" slot="message">当前库存总数量(个):<strong>998</strong>;当前库存总成本(¥):<strong>2009.00</strong>。</div>
+        <div class="ftext" slot="message">当前库存总数量(个):<strong>{{ productTotal.stockQty }}</strong>;当前库存总成本(¥):<strong>{{ productTotal.stockCost }}</strong>。</div>
       </a-alert>
       <!-- 列表 -->
       <s-table
@@ -74,66 +82,82 @@
         :rowKey="(record) => record.id"
         :columns="columns"
         :data="loadData"
-        :showPagination="false"
-        :scroll="{ x: 1760, y: 300 }"
+        :scroll="{ x: 1760 }"
         bordered>
-        <!-- 数量 -->
-        <template slot="number" slot-scope="text, record">
-          <span :class="[record.type == 1 ? 'green' : 'red']">{{ record.type == 1 ? '+' : '-' }}{{ record.number }}</span>
-        </template>
       </s-table>
     </a-card>
   </div>
 </template>
 
 <script>
+import moment from 'moment'
+import { STable, VSelect } from '@/components'
 import { stockFlowList } from '@/api/stockFlow'
-import { STable } from '@/components'
+import { stockByProductSn } from '@/api/stock'
+import { warehouseAllList } from '@/api/warehouse'
 export default {
-  components: { STable },
+  components: { STable, VSelect },
   data () {
     return {
       advanced: false, // 高级搜索 展开/关闭
       queryParam: { //  查询条件
-        orderBundleNo: '', //  订单编号
-        bundleName: '', //  套餐名称
-        itemName: '', //  服务名称
-        brand: undefined, //  产品品牌
-        inventoryNum: false //  库存数量是否为0
+        bizType: undefined,
+        flowType: undefined,
+        unitName: '',
+        warehouseSn: undefined
       },
       exportLoading: false, // 导出loading
       disabled: false, //  查询、重置按钮是否可操作
-      brandData: [], //  产品品牌下拉数据
-      typeData: [], //  产品类别下拉数据
+      createDate: [],
       dateFormat: 'YYYY-MM-DD',
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
-        { title: '产品编码', dataIndex: 'productNum', width: 140, align: 'center', fixed: 'left', customRender: function (text) { return text || '--' } },
-        { title: '产品名称', dataIndex: 'productName', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
-        { title: '原厂编码', dataIndex: 'productOldNum', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '入库批次时间', dataIndex: 'prodsuctBrand', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '单据类型', dataIndex: 'productBdrand', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '单据审核时间', dataIndex: 'prodfuctBrand', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '单位名称', dataIndex: 'produhctBrand', width: 200, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
+        { title: '产品编码', dataIndex: 'product.code', width: 140, align: 'center', fixed: 'left', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'product.name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
+        { title: '原厂编码', dataIndex: 'product.origCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '入库批次时间', dataIndex: 'stockBatchNo', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '单据类型', dataIndex: 'bizTypeDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '单据审核时间', dataIndex: 'auditTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '单位名称', dataIndex: 'unitName', width: 200, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
         { title: '仓库', dataIndex: 'warehouseName', width: 140, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
         { title: '仓位', dataIndex: 'warehouseLocationName', width: 140, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
-        { title: '数量', scopedSlots: { customRender: 'number' }, width: 100, align: 'center' },
-        { title: '总成本', dataIndex: 'inventoryMoney', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '总售价', dataIndex: 'inventoryMoneys', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
+        { title: '数量', dataIndex: 'qty', width: 100, align: 'center' },
+        { title: '总成本', dataIndex: 'totalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '总售价', dataIndex: 'totalPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         this.disabled = true
-        return stockFlowList(Object.assign(parameter, this.queryParam)).then(res => {
+        // 入库时间
+        if (this.createDate && this.createDate.length > 0) {
+          this.queryParam.beginDate = moment(this.createDate[0]).format(this.dateFormat)
+          this.queryParam.endDate = moment(this.createDate[1]).format(this.dateFormat)
+        } else {
+          this.queryParam.beginDate = undefined
+          this.queryParam.endDate = undefined
+        }
+        const params = Object.assign(parameter, this.queryParam, { productSn: this.$route.params.sn })
+        return stockFlowList(params).then(res => {
           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
+            if (data.list[i].flowType == 'PUT') {
+              data.list[i].qty = data.list[i].putQty
+            } else if (data.list[i].flowType == 'OUT') {
+              data.list[i].qty = data.list[i].outQty
+            }
           }
           this.disabled = false
+          this.getTotal(params)
           return data
         })
-      }
+      },
+      warehouseList: [], //  仓库  下拉数据
+      productTotal: {
+        stockQty: 0,
+        stockCost: 0
+      } //  合计
     }
   },
   methods: {
@@ -141,20 +165,50 @@ export default {
     disabledDate (date, dateStrings) {
       return date && date.valueOf() > Date.now()
     },
+    // 合计
+    getTotal (param) {
+      stockByProductSn(param).then(res => {
+        if (res.status == 200 && res.data) {
+          this.productTotal = {
+            stockQty: (Number(res.data.currentStockQty) + Number(res.data.freezeQty)) || 0,
+            stockCost: (Number(res.data.currentStockCost) + Number(res.data.freezeCost)) || 0
+          }
+        } else {
+          this.productTotal = {
+            stockQty: 0,
+            stockCost: 0
+          }
+        }
+      })
+    },
     //  重置
     resetSearchForm () {
-      this.queryParam.orderBundleNo = ''
-      this.queryParam.orderBundle.custMobile = ''
-      this.queryParam.bundleName = ''
-      this.queryParam.itemName = ''
-      this.oldTime = undefined
-      this.newTime = undefined
+      this.queryParam.bizType = undefined
+      this.queryParam.flowType = undefined
+      this.queryParam.unitName = ''
+      this.queryParam.warehouseSn = undefined
+      this.createDate = []
       this.$refs.table.refresh(true)
     },
     //  返回列表
     handleBack () {
       this.$router.push({ path: '/inventoryManagement/inventoryQuery/list' })
+    },
+    // 仓库下拉数据
+    getWarehouseList (type) {
+      warehouseAllList({}).then(res => {
+        if (res.status == 200) {
+          this.warehouseList = res.data
+        } else {
+          this.warehouseList = []
+        }
+      })
     }
+  },
+  beforeRouteEnter (to, from, next) {
+    next(vm => {
+      vm.getWarehouseList()
+    })
   }
 }
 </script>