Преглед на файлове

对接库存查询、库存预警

chenrui преди 4 години
родител
ревизия
217eebd417

+ 27 - 9
src/api/stock.js

@@ -14,14 +14,14 @@ export const stockList = (params) => {
 //  库存 列表 合计
 export const stockCount = (params) => {
   return axios({
-    url: '/stock/queryCount',
+    url: '/stock/queryPageCount',
     data: params,
     method: 'post'
   })
 }
 //  库存 详情列表  分页
 export const stockDetailList = (params) => {
-  const url = `/stock/detail/queryPage/${params.pageNo}/${params.pageSize}`
+  const url = `/stock/queryDetailPage/${params.pageNo}/${params.pageSize}`
   delete params.pageNo
   delete params.pageSize
   return axios({
@@ -33,15 +33,14 @@ export const stockDetailList = (params) => {
 //  库存 详情列表 合计
 export const stockDetailCount = (params) => {
   return axios({
-    url: '/stock/detail/queryCount',
+    url: '/stock/queryDetailPageCount',
     data: params,
     method: 'post'
   })
 }
-
-//  库存 详情列表  分页
-export const querySumByProductLocation = (params) => {
-  const url = `/stock/detail/querySumByProductLocation/${params.pageNo}/${params.pageSize}`
+//  出入库明细 列表  有分页
+export const stockFlowList = (params) => {
+  const url = `/stock/queryFlowPage/${params.pageNo}/${params.pageSize}`
   delete params.pageNo
   delete params.pageSize
   return axios({
@@ -51,11 +50,30 @@ export const querySumByProductLocation = (params) => {
   })
 }
 //  出入库明细  列表  合计
-export const stockByProductSn = (params) => {
-  const url = `/stock/findByProductSn/${params.productSn}`
+export const stockFlowCount = (params) => {
+  return axios({
+    url: '/stock/queryFlowPageCount',
+    data: params,
+    method: 'post'
+  })
+}
+
+//  库存预警 列表  分页
+export const stockWarnList = (params) => {
+  const url = `/stock/queryWarnPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
   return axios({
     url: url,
     data: params,
     method: 'post'
   })
 }
+//  库存预警 保存
+export const stockWarnSaveBatch = (params) => {
+  return axios({
+    url: '/stock/updateStateBatch',
+    data: params,
+    method: 'post'
+  })
+}

+ 0 - 13
src/api/stockFlow.js

@@ -1,13 +0,0 @@
-import { axios } from '@/utils/request'
-
-//  库存流水(出入库明细) 列表  有分页
-export const stockFlowList = (params) => {
-  const url = `/stockFlow/queryPage/${params.pageNo}/${params.pageSize}`
-  delete params.pageNo
-  delete params.pageSize
-  return axios({
-    url: url,
-    data: params,
-    method: 'post'
-  })
-}

+ 0 - 21
src/api/stockWarn.js

@@ -1,21 +0,0 @@
-import { axios } from '@/utils/request'
-
-//  库存预警 列表  分页
-export const stockWarnList = (params) => {
-  const url = `/stockWarn/queryPage/${params.pageNo}/${params.pageSize}`
-  delete params.pageNo
-  delete params.pageSize
-  return axios({
-    url: url,
-    data: params,
-    method: 'post'
-  })
-}
-//  库存预警 保存
-export const stockWarnSaveBatch = (params) => {
-  return axios({
-    url: '/stockWarn/saveBatch',
-    data: params,
-    method: 'post'
-  })
-}

+ 14 - 8
src/views/inventoryManagement/inventoryQuery/detailModal.vue

@@ -4,13 +4,13 @@
     class="inventoryQueryDetail-modal"
     :footer="null"
     :maskClosable="false"
-    :title="modalTit"
+    title="库存详情"
     v-model="isShow"
     @cancle="isShow=false"
     width="80%">
     <!-- 合计 -->
     <a-alert type="info" showIcon style="margin-bottom:15px">
-      <div class="ftext" slot="message">现有库存总数量(个):<strong>{{ currentStock.currentQty || 0 }}</strong>;现有库存总成本(¥):<strong>{{ currentStock.putCost || 0 }}</strong>。</div>
+      <div class="ftext" slot="message">现有库存总数量(个):<strong>{{ stockQty }}</strong>;现有库存总成本(¥):<strong>{{ stockCost }}</strong>。</div>
     </a-alert>
     <!-- 库存详情 -->
     <s-table
@@ -51,11 +51,6 @@ export default {
       default: ''
     }
   },
-  computed: {
-    modalTit () {
-      return '库存详情'
-    }
-  },
   data () {
     return {
       isShow: this.openModal, //  是否打开弹框
@@ -84,7 +79,6 @@ export default {
           this.disabled = false
           // 总计
           this.getTotal(Object.assign(parameter, { stockSn: this.itemId }))
-          console.log(data)
           return data
         })
       },
@@ -94,6 +88,18 @@ export default {
       }
     }
   },
+  computed: {
+    stockQty () { //  库存总数量 合计
+      const currentStockQty = Number(this.currentStock.currentStockQty) || 0
+      const freezeStockQty = Number(this.currentStock.freezeStockQty) || 0
+      return currentStockQty + freezeStockQty
+    },
+    stockCost () { //  库存总成本 合计
+      const currentStockCost = Number(this.currentStock.currentStockCost) || 0
+      const freezeStockCost = Number(this.currentStock.freezeStockCost) || 0
+      return currentStockCost + freezeStockCost
+    }
+  },
   methods: {
     // 合计
     getTotal (param) {

+ 86 - 29
src/views/inventoryManagement/inventoryQuery/list.vue

@@ -22,12 +22,30 @@
           <template v-if="advanced">
             <a-col :md="6" :sm="24">
               <a-form-item label="产品品牌">
-                <ProductBrand id="inventoryQueryList-brandSn" v-model="queryParam.brandSn"></ProductBrand>
+                <a-select
+                  placeholder="请选择产品品牌"
+                  id="inventoryQueryList-productBrandSn"
+                  allowClear
+                  v-model="queryParam.productBrandSn"
+                  :showSearch="true"
+                  option-filter-prop="children"
+                  :filter-option="filterOption">
+                  <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
+                </a-select>
               </a-form-item>
             </a-col>
             <a-col :md="6" :sm="24">
               <a-form-item label="产品分类">
-                <ProductType v-model="productTypeSn" @change="changeType"></ProductType>
+                <a-cascader
+                  @change="changeProductType"
+                  expand-trigger="hover"
+                  change-on-select
+                  :options="productTypeList"
+                  :fieldNames="{ label: 'productTypeName', value: 'id', children: 'children' }"
+                  id="inventoryQueryList-productType"
+                  placeholder="请选择产品分类"
+                  allowClear
+                  v-model="productType" />
               </a-form-item>
             </a-col>
             <a-col :md="6" :sm="24">
@@ -58,7 +76,7 @@
     </div>
     <!-- 合计 -->
     <a-alert type="info" showIcon style="margin-bottom:15px">
-      <div class="ftext" slot="message">现有库存总数量(个):<strong>{{ currentStock.currentStockQty || 0 }}</strong>;现有库存总成本(¥):<strong>{{ currentStock.currentStockCost || 0 }}</strong>。</div>
+      <div class="ftext" slot="message">现有库存总数量(个):<strong>{{ stockQty }}</strong>;现有库存总成本(¥):<strong>{{ stockCost }}</strong>。</div>
     </a-alert>
     <!-- 列表 -->
     <s-table
@@ -70,11 +88,6 @@
       :data="loadData"
       :scroll="{ x: 1630, y: tableHeight }"
       bordered>
-      <!-- 产品分类 -->
-      <template slot="productTypeName" slot-scope="text, record">
-        <span v-if="record.productTypeName2">{{ record.productTypeName2 || '' }} ></span>
-        <span v-if="record.productTypeName3">{{ record.productTypeName3 || '' }}</span>
-      </template>
       <!-- 现有库存数量 -->
       <template slot="currentStockQty" slot-scope="text, record">
         {{ (record.currentStockQty + record.freezeQty) || 0 }}
@@ -93,13 +106,13 @@
 
 <script>
 import moment from 'moment'
-import { stockList, stockCount } from '@/api/stock'
 import { STable, VSelect } from '@/components'
 import inventoryQueryDetailModal from './detailModal.vue'
-import ProductBrand from '@/views/common/productBrand.js'
-import ProductType from '@/views/common/productType.js'
+import { productBrandQuery } from '@/api/productBrand'
+import { productTypeQuery } from '@/api/productType'
+import { stockList, stockCount } from '@/api/stock'
 export default {
-  components: { STable, VSelect, inventoryQueryDetailModal, ProductBrand, ProductType },
+  components: { STable, VSelect, inventoryQueryDetailModal },
   data () {
     return {
       advanced: false, // 高级搜索 展开/关闭
@@ -108,15 +121,17 @@ export default {
         productCode: '', //  产品编码
         productName: '', //  产品名称
         productOrigCode: '', //  原厂编码
-        brandSn: undefined, //  产品品牌
+        productBrandSn: undefined, //  产品品牌
         productTypeSn1: '', //  产品分类1
         productTypeSn2: '', //  产品分类2
         productTypeSn3: '', //  产品分类3
         zeroQtyFlag: undefined //  库存数量是否为0
       },
-      productTypeSn: [],
+      productType: [],
       exportLoading: false, // 导出loading
       disabled: false, //  查询、重置按钮是否可操作
+      productBrandList: [], //  品牌下拉数据
+      productTypeList: [], //  分类下拉数据
       zeroQtyData: [ //  库存情况
         { name: '库存数量为0', id: '1' },
         { name: '库存数量不为0', id: '0' }
@@ -125,11 +140,11 @@ export default {
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
         { title: '产品编码', dataIndex: 'productCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '产品名称', dataIndex: 'productName', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
-        { title: '原厂编码', dataIndex: 'productOrigCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品品牌', dataIndex: 'brandName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品分类', scopedSlots: { customRender: 'productTypeName' }, width: 240, align: 'center' },
-        { title: '现有库存数量(个)', dataIndex: 'currentStockQty', scopedSlots: { customRender: 'currentStockQty' }, width: 165, align: 'center', sorter: true },
-        { title: '现有库存成本(¥)', dataIndex: 'currentStockCost', width: 165, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '最后入库时间', dataIndex: 'lastStockTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '单位', dataIndex: 'productUnit', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品品牌', dataIndex: 'productBrandName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '库存数量(个)', dataIndex: 'currentStockQty', scopedSlots: { customRender: 'currentStockQty' }, width: 165, align: 'center', sorter: true },
+        { title: '库存成本(¥)', dataIndex: 'currentStockCost', width: 165, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
       ],
       // 加载数据方法 必须为 Promise 对象
@@ -156,6 +171,14 @@ export default {
           this.disabled = false
           // 总计
           this.getTotal(Object.assign(parameter, this.queryParam))
+          // 产品分类
+          if (this.productTypeList.length == 0) {
+            this.getProductType()
+          }
+          // 产品品牌
+          if (this.productBrandList.length == 0) {
+            this.getProductBrand()
+          }
           return data
         })
       },
@@ -167,20 +190,30 @@ export default {
       }
     }
   },
+  computed: {
+    stockQty () { //  库存总数量 合计
+      const currentStockQty = Number(this.currentStock.currentStockQty) || 0
+      const freezeStockQty = Number(this.currentStock.freezeStockQty) || 0
+      return currentStockQty + freezeStockQty
+    },
+    stockCost () { //  库存总成本 合计
+      const currentStockCost = Number(this.currentStock.currentStockCost) || 0
+      const freezeStockCost = Number(this.currentStock.freezeStockCost) || 0
+      return currentStockCost + freezeStockCost
+    }
+  },
   methods: {
     //  重置
     resetSearchForm () {
-      this.queryParam.brandSn = undefined
+      this.queryParam.productBrandSn = undefined
       this.queryParam.productTypeSn1 = ''
       this.queryParam.productTypeSn2 = ''
       this.queryParam.productTypeSn3 = ''
       this.queryParam.productCode = ''
       this.queryParam.productOrigCode = ''
       this.queryParam.productName = ''
-      this.queryParam.brandName = undefined
-      this.queryParam.productTypeName = undefined
       this.queryParam.zeroQtyFlag = undefined
-      this.productTypeSn = []
+      this.productType = []
       this.$refs.table.refresh(true)
     },
     // 合计
@@ -243,12 +276,36 @@ export default {
         })
       }
     },
-    // 分类  changeType
-    changeType (val) {
-      console.log(val)
-      for (let i = 0; i < val.length; i++) {
-        this.queryParam['productTypeSn' + (i + 1)] = val[i]
-      }
+    //  产品分类  change
+    changeProductType (val, opt) {
+      this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
+      this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
+      this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
+    },
+    //  产品品牌  列表
+    getProductBrand () {
+      productBrandQuery({}).then(res => {
+        if (res.status == 200) {
+          this.productBrandList = res.data
+        } else {
+          this.productBrandList = []
+        }
+      })
+    },
+    //  产品分类  列表
+    getProductType () {
+      productTypeQuery({}).then(res => {
+        if (res.status == 200) {
+          this.productTypeList = res.data
+        } else {
+          this.productTypeList = []
+        }
+      })
+    },
+    filterOption (input, option) {
+      return (
+        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
+      )
     }
   }
 }

+ 18 - 25
src/views/inventoryManagement/inventoryQuery/warehouseDetail.vue

@@ -16,7 +16,7 @@
                 <v-select
                   v-model="queryParam.flowType"
                   ref="flowType"
-                  id="warehousingAuditList-flowType"
+                  id="inventoryQueryWarehouseDetail-flowType"
                   code="STOCK_FLOW_TYPE"
                   placeholder="请选择变动类型"
                   allowClear></v-select>
@@ -72,7 +72,7 @@
       </div>
       <!-- 合计 -->
       <a-alert type="info" showIcon style="margin-bottom:15px">
-        <div class="ftext" slot="message">当前库存总数量(个):<strong>{{ productTotal.stockQty }}</strong>;当前库存总成本(¥):<strong>{{ productTotal.stockCost }}</strong>。</div>
+        <div class="ftext" slot="message">当前库存总数量(个):<strong>{{ (productTotal&&productTotal.totalQty) ? productTotal.totalQty : 0 }}</strong>;当前库存总成本(¥):<strong>{{ (productTotal&&productTotal.totalCost) ? productTotal.totalCost : 0 }}</strong>。</div>
       </a-alert>
       <!-- 列表 -->
       <s-table
@@ -86,7 +86,10 @@
         bordered>
         <!-- 数量 -->
         <template slot="qty" slot-scope="text, record">
-          <span :class="record.flowType=='PUT' ? 'green':'red'">{{ record.flowType=='PUT' ? '+':'-' }}{{ record.qty }}</span>
+          <p :class="record.flowType=='PUT' ? 'green':'red'" style="margin: 0;">
+            <span v-if="record.qty!=0">{{ record.flowType=='PUT' ? '+':'-' }}</span>
+            {{ record.qty }}
+          </p>
         </template>
       </s-table>
     </a-card>
@@ -96,8 +99,7 @@
 <script>
 import moment from 'moment'
 import { STable, VSelect } from '@/components'
-import { stockFlowList } from '@/api/stockFlow'
-import { stockByProductSn } from '@/api/stock'
+import { stockFlowCount, stockFlowList } from '@/api/stock'
 import { warehouseAllList } from '@/api/warehouse'
 export default {
   components: { STable, VSelect },
@@ -158,10 +160,7 @@ export default {
         })
       },
       warehouseList: [], //  仓库  下拉数据
-      productTotal: {
-        stockQty: 0,
-        stockCost: 0
-      } //  合计
+      productTotal: null //  合计
     }
   },
   methods: {
@@ -171,17 +170,11 @@ export default {
     },
     // 合计
     getTotal (param) {
-      stockByProductSn(param).then(res => {
+      stockFlowCount(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
-          }
+          this.productTotal = res.data
         } else {
-          this.productTotal = {
-            stockQty: 0,
-            stockCost: 0
-          }
+          this.productTotal = null
         }
       })
     },
@@ -200,13 +193,13 @@ export default {
     },
     // 仓库下拉数据
     getWarehouseList (type) {
-      warehouseAllList({}).then(res => {
-        if (res.status == 200) {
-          this.warehouseList = res.data
-        } else {
-          this.warehouseList = []
-        }
-      })
+      // warehouseAllList({}).then(res => {
+      //   if (res.status == 200) {
+      //     this.warehouseList = res.data
+      //   } else {
+      //     this.warehouseList = []
+      //   }
+      // })
     }
   },
   beforeRouteEnter (to, from, next) {

+ 54 - 7
src/views/inventoryManagement/inventoryWarning/list.vue

@@ -22,12 +22,30 @@
           <template v-if="advanced">
             <a-col :md="6" :sm="24">
               <a-form-item label="产品品牌">
-                <ProductBrand id="inventoryWarningList-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
+                <a-select
+                  placeholder="请选择产品品牌"
+                  id="inventoryWarningList-productBrandSn"
+                  allowClear
+                  v-model="queryParam.productBrandSn"
+                  :showSearch="true"
+                  option-filter-prop="children"
+                  :filter-option="filterOption">
+                  <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
+                </a-select>
               </a-form-item>
             </a-col>
             <a-col :md="6" :sm="24">
               <a-form-item label="产品分类">
-                <ProductType id="inventoryWarningList-productType" v-model="productType" @change="changeProductType"></ProductType>
+                <a-cascader
+                  @change="changeProductType"
+                  change-on-select
+                  v-model="productType"
+                  expand-trigger="hover"
+                  :options="productTypeList"
+                  :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
+                  id="inventoryWarningList-productType"
+                  placeholder="请选择产品分类"
+                  allowClear />
               </a-form-item>
             </a-col>
             <a-col :md="6" :sm="24">
@@ -142,11 +160,11 @@
 <script>
 import moment from 'moment'
 import { STable, VSelect } from '@/components'
-import { stockWarnList, stockWarnSaveBatch } from '@/api/stockWarn'
-import ProductBrand from '@/views/common/productBrand.js'
-import ProductType from '@/views/common/productType.js'
+import { productBrandQuery } from '@/api/productBrand'
+import { productTypeQuery } from '@/api/productType'
+import { stockWarnList, stockWarnSaveBatch } from '@/api/stock'
 export default {
-  components: { STable, VSelect, ProductBrand, ProductType },
+  components: { STable, VSelect },
   data () {
     return {
       advanced: false, // 高级搜索 展开/关闭
@@ -163,13 +181,15 @@ export default {
       },
       exportLoading: false, // 导出loading
       disabled: false, //  查询、重置按钮是否可操作
+      productBrandList: [], //  产品品牌下拉数据
+      productTypeList: [], //  产品类别下拉数据
       productType: [],
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
         { title: '产品编码', dataIndex: 'productCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '产品名称', dataIndex: 'productName', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
         { title: '原厂编码', dataIndex: 'productOrigCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品品牌', dataIndex: 'brandName', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品品牌', dataIndex: 'productBrandName', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 200, align: 'center' },
         { title: '实时库存数(个)', scopedSlots: { customRender: 'stockQty' }, width: 180, align: 'center' },
         { title: '在途数(个)', scopedSlots: { customRender: 'inTransit' }, width: 130, align: 'center' },
@@ -332,6 +352,31 @@ export default {
       this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
       this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
     },
+    //  产品品牌  列表
+    getProductBrand () {
+      productBrandQuery({}).then(res => {
+        if (res.status == 200) {
+          this.productBrandList = res.data
+        } else {
+          this.productBrandList = []
+        }
+      })
+    },
+    //  产品分类  列表
+    getProductType () {
+      productTypeQuery({}).then(res => {
+        if (res.status == 200) {
+          this.productTypeList = res.data
+        } else {
+          this.productTypeList = []
+        }
+      })
+    },
+    filterOption (input, option) {
+      return (
+        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
+      )
+    },
     //  导出
     handleExport () {
       const params = this.queryParam
@@ -358,6 +403,8 @@ export default {
   beforeRouteEnter (to, from, next) {
     next(vm => {
       vm.pageInit(1)
+      vm.getProductType()
+      vm.getProductBrand()
     })
   }
 }