123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446 |
- <template>
- <a-card size="small" :bordered="false" class="inventoryWarningList-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <!-- 搜索条件 -->
- <div ref="tableSearch" 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-form-item label="产品编码">
- <a-input id="inventoryWarningList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="原厂编码">
- <a-input id="inventoryWarningList-productOrigCode" v-model.trim="queryParam.productOrigCode" allowClear placeholder="请输入原厂编码"/>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="产品名称">
- <a-input id="inventoryWarningList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
- </a-form-item>
- </a-col>
- <template v-if="advanced">
- <a-col :md="6" :sm="24">
- <a-form-model-item label="产品品牌">
- <ProductBrand id="inventoryWarningList-productBrandSn" placeholder="请选择产品品牌" v-model="queryParam.productBrandSn"></ProductBrand>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="产品分类">
- <ProductType id="inventoryWarningList-productType" placeholder="请选择产品分类" :isDealer="true" @change="changeProductType" v-model="productType"></ProductType>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="预警提示">
- <v-select
- v-model="queryParam.stockState"
- ref="stockState"
- id="inventoryWarningList-stockState"
- code="STOCK_WARN_TIP"
- placeholder="请选择预警提示"
- allowClear
- ></v-select>
- </a-form-item>
- </a-col>
- </template>
- <a-col :md="6" :sm="24">
- <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="inventoryWarningList-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="inventoryWarningList-reset">重置</a-button>
- <a-button
- type="primary"
- style="margin-left: 5px"
- @click="handleExport"
- :disabled="disabled"
- :loading="exportLoading"
- class="button-warning"
- id="inventoryWarningList-export-btn">导出</a-button>
- <a @click="advanced=!advanced" style="margin-left: 5px">
- {{ advanced ? '收起' : '展开' }}
- <a-icon :type="advanced ? 'up' : 'down'"/>
- </a>
- </a-col>
- </a-row>
- </a-form>
- <!-- 操作按钮 -->
- <div class="table-operator">
- <a-button type="primary" v-if="$hasPermissions('B_inventoryWarningBatchSave')" id="inventoryWarningList-update" @click="handleupdate">批量更新</a-button>
- <a-button
- type="primary"
- style="margin-left: 5px"
- class="button-warning"
- @click="openGuideModal=true"
- v-if="$hasPermissions('B_inventoryWarningProductImport')"
- id="inventoryWarningList-import-btn">导入产品</a-button>
- <span style="margin-left: 5px" v-if="$hasPermissions('B_inventoryWarningBatchSave')">
- <template v-if="rowSelectionInfo&&rowSelectionInfo.selectedRowKeys.length>0">{{ `已选 ${rowSelectionInfo.selectedRowKeys.length} 项` }}</template>
- </span>
- </div>
- </div>
- <!-- 列表 -->
- <s-table
- class="sTable fixPagination"
- ref="table"
- :style="{ height: tableHeight+68.5+'px' }"
- size="small"
- :rowKey="(record) => record.id"
- :row-selection="$hasPermissions('B_inventoryWarningBatchSave') ? { columnWidth: 40 } : null"
- @rowSelection="rowSelectionFun"
- :columns="columns"
- :data="loadData"
- :scroll="{ x: 1330, y: tableHeight }"
- :defaultLoadData="false"
- bordered>
- <!-- 产品分类 -->
- <template slot="productType" slot-scope="text, record">
- <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
- <span v-else>--</span>
- </template>
- <!-- 实时库存数 -->
- <template slot="stockQty" slot-scope="text, record">
- {{ record.currentStockQty + record.freezeQty }}
- <span v-if="record.freezeQty">(冻结{{ record.freezeQty }})</span>
- </template>
- <!-- 预警提示 -->
- <template slot="stockState" slot-scope="text, record">
- <span v-if="record.stockStateDictValue" :class="[record.stockState=='OVERFLOW'?'yellow':record.stockState=='NOT_ENOUGH'?'red':record.stockState=='LACK'?'blue':record.stockState=='NORMAL'?'green':'']">{{ record.stockStateDictValue }}</span>
- <span v-else>--</span>
- </template>
- <!-- 在途数 -->
- <!-- <template slot="inTransit" slot-scope="text, record" >
- <div>
- <a-input-number
- id="inventoryWarningList-inTransit"
- size="small"
- v-model="record.inTransit"
- :precision="0"
- :min="0"
- :max="999999"
- style="width: 100%;"
- @change="numChange(record)"
- placeholder="请输入在途数" />
- </div>
- </template> -->
- <!-- 最大库存数 -->
- <template slot="upperLimit" slot-scope="text, record" >
- <div>
- <a-input-number
- id="inventoryWarningList-upperLimit"
- size="small"
- v-model="record.upperLimit"
- :precision="0"
- :min="0"
- :max="999999"
- style="width: 100%;"
- @change="numChange(record)"
- placeholder="请输入最大库存数" />
- </div>
- </template>
- <!-- 最小库存数 -->
- <template slot="lowerLimit" slot-scope="text, record" >
- <div>
- <a-input-number
- id="inventoryWarningList-lowerLimit"
- size="small"
- v-model="record.lowerLimit"
- :precision="0"
- :min="0"
- :max="record.upperLimit"
- style="width: 100%;"
- @change="numChange(record)"
- placeholder="请输入最小库存数" />
- </div>
- </template>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button
- type="link"
- v-if="$hasPermissions('B_inventoryWarningSave')"
- size="small"
- class="button-primary"
- @click="handleSave(record)"
- id="inventoryWarningList-add-btn">保存</a-button>
- <a-button type="link" v-if="record.dealerProduct.sysFlag==1&&record.dealerProduct.onlineFalg==1&&$hasPermissions('M_shoppingCart')" @click="addShopCar(record)">加入购物车</a-button>
- <span v-if="!$hasPermissions('B_inventoryWarningSave')">--</span>
- </template>
- </s-table>
- </a-spin>
- <!-- 导入产品 -->
- <importGuideModal :openModal="openGuideModal" @close="openGuideModal=false" @ok="resetSearchForm" />
- <!-- 设置采购数量 -->
- <set-purchase-qty ref="setPurchaseQty" :openModal="openPurchaseModal" @close="openPurchaseModal=false" v-drag></set-purchase-qty>
- </a-card>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { STable, VSelect } from '@/components'
- import { stockWarnList, stockWarnSaveBatch, stockWarnExport } from '@/api/stockWarn'
- import { purchaseCartExistProduct } from '@/api/purchaseCart'
- import { downloadExcel } from '@/libs/JGPrint.js'
- import ProductType from '../../common/productType.js'
- import ProductBrand from '../../common/productBrand.js'
- import importGuideModal from './importGuideModal.vue'
- import setPurchaseQty from '@/views/inventoryManagement/inventoryQuery/setPurchaseQty.vue'
- export default {
- name: 'InventoryWarningList',
- components: { STable, VSelect, ProductType, ProductBrand, importGuideModal, setPurchaseQty },
- mixins: [commonMixin],
- data () {
- return {
- spinning: false,
- openGuideModal: false,
- openPurchaseModal: false,
- advanced: true, // 高级搜索 展开/关闭
- tableHeight: 0,
- queryParam: { // 查询条件
- productCode: '',
- productName: '',
- productOrigCode: '', // 原厂编码
- productBrandSn: undefined,
- productTypeSn1: undefined,
- productTypeSn2: undefined,
- productTypeSn3: undefined,
- stockState: undefined
- },
- exportLoading: false, // 导出loading
- disabled: false, // 查询、重置按钮是否可操作
- productBrandList: [], // 产品品牌下拉数据
- productTypeList: [], // 产品类别下拉数据
- productType: [],
- columns: [
- { title: '序号', dataIndex: 'no', width: 50, align: 'center', fixed: 'left' },
- { title: '产品编码', dataIndex: 'productCode', width: 120, align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
- { title: '产品名称', dataIndex: 'productName', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '原厂编码', dataIndex: 'productOrigCode', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品品牌', dataIndex: 'brandName', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 120, align: 'center' },
- { title: '在途数(个)', dataIndex: 'inTransit', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '总库存数(个)', dataIndex: 'currentStockQty', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '最大库存数(个)', scopedSlots: { customRender: 'upperLimit' }, width: 100, align: 'center' },
- { title: '最小库存数(个)', scopedSlots: { customRender: 'lowerLimit' }, width: 100, align: 'center' },
- { title: '差异数量', dataIndex: 'differenceNum', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '预警提示', scopedSlots: { customRender: 'stockState' }, width: 100, align: 'center' },
- { title: <div><a-tooltip placement='top' title='注意:购物车仅限添加箭冠已上线产品。'><a-icon type="question-circle" /></a-tooltip> 操作</div>, scopedSlots: { customRender: 'action' }, width: 160, align: 'center', fixed: 'right' }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- this.spinning = true
- return stockWarnList(Object.assign(parameter, this.queryParam)).then(res => {
- let data
- if (res.status == 200) {
- 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 (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys) { // 处理切换页码后 上页已选已输数据保留
- const ind = this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.indexOf(data.list[i].id)
- if (ind >= 0) {
- data.list[i].inTransit = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows[ind].inTransit
- data.list[i].upperLimit = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows[ind].upperLimit
- data.list[i].lowerLimit = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows[ind].lowerLimit
- }
- }
- }
- this.disabled = false
- }
- this.spinning = false
- return data
- })
- },
- loading: false,
- rowSelectionInfo: null
- }
- },
- methods: {
- // 加入购物车
- addShopCar (row) {
- this.spinning = true
- purchaseCartExistProduct({
- productSn: row.productSn
- }).then(res => {
- if (res.status == 200) {
- if (res.data) {
- this.$message.info('此产品已添加到购物车!')
- } else {
- this.$refs.setPurchaseQty.setData(row)
- this.openPurchaseModal = true
- }
- }
- this.spinning = false
- })
- },
- // 表格选中项
- rowSelectionFun (obj) {
- this.rowSelectionInfo = obj || null
- },
- numChange (row) {
- if (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys) { // 处理切换页码后 上页已选已输数据保留
- const ind = this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.indexOf(row.id)
- if (ind >= 0) {
- this.rowSelectionInfo.selectedRows[ind].inTransit = row.inTransit
- this.rowSelectionInfo.selectedRows[ind].upperLimit = row.upperLimit
- this.rowSelectionInfo.selectedRows[ind].lowerLimit = row.lowerLimit
- }
- }
- },
- // 导出
- handleExport () {
- const _this = this
- _this.exportLoading = true
- stockWarnExport(_this.queryParam).then(res => {
- downloadExcel(res, '库存预警')
- _this.exportLoading = false
- })
- },
- // 保存
- handleSave (row, isBatch) {
- const params = []
- if (isBatch) { // 批量更新
- const dataInd = []
- this.rowSelectionInfo && this.rowSelectionInfo.selectedRows.map((item, index) => {
- if ((!item.inTransit && item.inTransit != 0) || (!item.upperLimit && item.upperLimit != 0) || (!item.lowerLimit && item.lowerLimit != 0)) {
- dataInd.push(item.no)
- }
- params.push({
- id: item.id,
- inTransit: item.inTransit,
- upperLimit: item.upperLimit,
- lowerLimit: item.lowerLimit
- })
- })
- if (dataInd.length > 0) {
- let str = ''
- dataInd.map(item => {
- str += item + '、'
- })
- str = str.substr(0, str.length - 1)
- this.$message.warning('请完善第' + str + '行数据后再提交')
- return
- }
- } else { // 单个保存
- if (!row.inTransit && row.inTransit != 0) {
- this.$message.warning('请输入在途数')
- return
- }
- if (!row.upperLimit && row.upperLimit != 0) {
- this.$message.warning('请输入最大库存数')
- return
- }
- if (!row.lowerLimit && row.lowerLimit != 0) {
- this.$message.warning('请输入最小库存数')
- return
- }
- params.push({
- id: row.id,
- inTransit: row.inTransit,
- upperLimit: row.upperLimit,
- lowerLimit: row.lowerLimit
- })
- }
- this.spinning = true
- stockWarnSaveBatch(params).then(res => {
- if (res.status == 200) {
- this.$message.success(res.message)
- this.$refs.table.refresh()
- this.$refs.table.clearSelected() // 清空表格选中项
- this.spinning = false
- } else {
- this.spinning = false
- }
- })
- },
- // 重置
- resetSearchForm () {
- this.queryParam.productCode = ''
- this.queryParam.productName = ''
- this.queryParam.productOrigCode = ''
- this.queryParam.productBrandSn = undefined
- this.queryParam.productTypeSn1 = undefined
- this.queryParam.productTypeSn2 = undefined
- this.queryParam.productTypeSn3 = undefined
- this.queryParam.stockState = undefined
- this.productType = []
- this.$refs.table.refresh(true)
- },
- // 批量更新
- handleupdate () {
- if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 1)) {
- this.$message.warning('请在列表勾选后再进行批量操作!')
- return
- }
- const _this = this
- this.$confirm({
- title: '提示',
- content: '确定提交批量更新的内容吗?',
- centered: true,
- onOk () {
- _this.handleSave('', 'batch')
- }
- })
- },
- // 产品分类 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] : ''
- },
- pageInit () {
- const _this = this
- this.$nextTick(() => { // 页面渲染完成后的回调
- _this.setTableH()
- })
- },
- setTableH () {
- const tableSearchH = this.$refs.tableSearch.offsetHeight
- this.tableHeight = window.innerHeight - tableSearchH - 180
- }
- },
- watch: {
- advanced (newValue, oldValue) {
- const _this = this
- this.$nextTick(() => { // 页面渲染完成后的回调
- _this.setTableH()
- })
- },
- '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
- this.setTableH()
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.pageInit()
- this.resetSearchForm()
- }
- },
- activated () {
- // 如果是新页签打开,则重置当前页面
- if (this.$store.state.app.isNewTab) {
- this.pageInit()
- this.resetSearchForm()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
- <style lang="less">
- .inventoryWarningList-wrap{
- .green{
- color: #19be6b;
- }
- .red{
- color: #ed1c24;
- }
- .yellow{
- color: #ff9900;
- }
- .blue{
- color: #2db7f5;
- }
- }
- </style>
|