123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429 |
- <template>
- <a-card size="small" :bordered="false" class="chainStockReportList-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <!-- 搜索条件 -->
- <div class="table-page-search-wrapper">
- <a-form-model
- id="chainStockReportList-form"
- ref="ruleForm"
- class="form-model-con"
- layout="inline"
- :model="queryParam"
- :rules="rules"
- :labelCol="labelCol"
- :wrapperCol="wrapperCol"
- @keyup.enter.native="handleSearch" >
- <a-row :gutter="15">
- <a-col :md="6" :sm="24">
- <a-form-model-item label="连锁店" prop="tenantId">
- <a-select
- placeholder="请选择连锁店"
- id="chainStockReportList-tenantId"
- allowClear
- v-model="queryParam.tenantId"
- :showSearch="true"
- option-filter-prop="children"
- :filter-option="filterOption">
- <a-select-option v-for="item in linkageGroupData" :key="item.dealerSn" :value="item.dealerSn">{{ item.dealerName }}</a-select-option>
- </a-select>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="产品编码">
- <a-input id="chainStockReportList-code" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="产品名称">
- <a-input id="chainStockReportList-name" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
- </a-form-model-item>
- </a-col>
- <template v-if="advanced">
- <a-col :md="6" :sm="24">
- <a-form-model-item label="原厂编码">
- <a-input id="chainStockReportList-origCode" v-model.trim="queryParam.productOrigCode" allowClear placeholder="请输入原厂编码"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="产品品牌">
- <ProductBrand id="chainStockReportList-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="chainStockReportList-productType" placeholder="请选择产品分类" :isDealer="true" @change="changeProductType" v-model="productType"></ProductType>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="滞销天数">
- <a-input-group>
- <a-row>
- <a-col :span="11">
- <a-input-number
- id="shelfMonitoringList-minUnsalableDays"
- v-model="queryParam.minUnsalableDays"
- :precision="0"
- :min="0"
- :max="999999"
- placeholder="起始天数"
- style="width: 100%;display: inline-block;" />
- </a-col>
- <a-col :span="2"><span style="display: block;text-align: center;line-height: 32px;">至</span></a-col>
- <a-col :span="11">
- <a-input-number
- id="shelfMonitoringList-maxUnsalableDays"
- v-model="queryParam.maxUnsalableDays"
- :precision="0"
- :min="0"
- :max="999999"
- placeholder="截止天数"
- style="width: 100%;display: inline-block;" />
- </a-col>
- </a-row>
- </a-input-group>
- </a-form-model-item>
- </a-col>
- </template>
- <a-col :md="6" :sm="24">
- <a-button type="primary" @click="handleSearch" :disabled="disabled" id="chainStockReportList-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chainStockReportList-reset">重置</a-button>
- <a-button
- type="primary"
- class="button-warning"
- @click="handleExport"
- :disabled="disabled"
- :loading="exportLoading"
- id="inventoryQueryList-export">导出</a-button>
- <a @click="advanced=!advanced" style="margin-left: 8px">
- {{ advanced ? '收起' : '展开' }}
- <a-icon :type="advanced ? 'up' : 'down'"/>
- </a>
- </a-col>
- </a-row>
- </a-form-model>
- </div>
- <!-- 合计 -->
- <a-alert type="info" style="margin-bottom:10px">
- <div class="ftext" slot="message">
- 可用库存总数量:<strong> {{ (totalData && (totalData.currentStockQty || totalData.currentStockQty==0)) ? totalData.currentStockQty : '--' }} </strong>;
- 可用库存总成本:<strong> {{ (totalData && (totalData.currentStockCost || totalData.currentStockCost==0)) ? toThousands(totalData.currentStockCost) : '--' }} </strong>。
- </div>
- </a-alert>
- <!-- 列表 -->
- <s-table
- class="sTable"
- ref="table"
- size="small"
- :rowKey="(record) => record.productSn + record.stockSn"
- rowKeyName="productSn"
- :columns="columns"
- :data="loadData"
- :defaultLoadData="false"
- bordered>
- <!-- 直销天数 -->
- <template slot="unsalableDays" slot-scope="text, record" >
- <span v-if="record.unsalableDays>=180&&record.unsalableDays<=360" style="color:#FF9900">{{ num(record.unsalableDays) }}</span>
- <span v-else-if="record.unsalableDays>360" style="color:#FF0000">{{ num(record.unsalableDays) }}</span>
- <span v-else >{{ num(record.unsalableDays) }}</span>
- </template>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button size="small" type="link" class="button-success" @click="goDetail(record)" id="chainStockReportList-detail-btn">详情</a-button>
- </template>
- </s-table>
- </a-spin>
- <!-- 详情 -->
- <chain-stock-report-detail-modal :openModal="openModal" :productSn="productSn" :stockSn="stockSn" @close="closeModal" />
- </a-card>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { STable, VSelect } from '@/components'
- import chainStockReportDetailModal from './detailModal.vue'
- import { linkageGroupList } from '@/api/reportData'
- import ProductType from '../../common/productType.js'
- import ProductBrand from '../../common/productBrand.js'
- import { reportStockList, reportStockCount } from '@/api/reportStock'
- import { downloadExcel } from '@/libs/JGPrint.js'
- import { stockExport } from '@/api/stock'
- export default {
- components: { STable, VSelect, chainStockReportDetailModal, ProductType, ProductBrand },
- mixins: [commonMixin],
- data () {
- const _this = this
- return {
- spinning: false,
- advanced: true, // 高级搜索 展开/关闭
- tableHeight: 0,
- queryParam: { // 查询条件
- tenantId: undefined,
- productCode: '', // 产品编码
- productName: '', // 产品名称
- productOrigCode: '', // 原厂编码
- productBrandSn: undefined, // 产品品牌
- productTypeSn1: '', // 产品分类1
- productTypeSn2: '', // 产品分类2
- productTypeSn3: '', // 产品分类3
- minUnsalableDays: undefined, // 滞销天数最小值
- maxUnsalableDays: undefined // 滞销天数最大值
- },
- labelCol: { span: 8 },
- wrapperCol: { span: 16 },
- rules: {
- 'tenantId': [{ required: true, message: '请选择连锁店', trigger: 'change' }]
- },
- disabled: false, // 查询、重置按钮是否可操作
- exportLoading: false,
- columns: [
- { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
- { title: '产品编码', dataIndex: 'productCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
- { title: '产品名称', dataIndex: 'productName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '原厂编码', dataIndex: 'productOrigCode', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '可用库存数量(个)', dataIndex: 'currentStockQty', width: '14%', align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '可用库存成本(¥)', dataIndex: 'currentStockCost', width: '14%', align: 'right', sorter: true, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
- { title: <div><a-tooltip placement='top' title='1:产品距离最近一次销售的时间,30天算一个月 2:采购退货,调拨等不算销售,不用来计算滞销天数'><a-icon type="question-circle" /></a-tooltip> 滞销天数</div>, width: '10%', align: 'center', scopedSlots: { customRender: 'unsalableDays' }, sorter: true },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: '5%', align: 'center' }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- const params = Object.assign(parameter, this.queryParam)
- this.spinning = true
- if (params.tenantId) {
- if (this.checkValueRange()) {
- return reportStockList(params).then(res => {
- let data
- if (res.status == 200) {
- data = res.data
- // 总计
- this.getCount(params)
- const no = (data.pageNo - 1) * data.pageSize
- for (var i = 0; i < data.list.length; i++) {
- data.list[i].no = no + i + 1
- }
- this.disabled = false
- }
- this.spinning = false
- return data
- })
- } else {
- console.log('=======未登录')
- const _this = this
- return new Promise(function (resolve, reject) {
- const data = {
- pageNo: 1,
- pageSize: 10,
- list: [],
- count: 0
- }
- _this.disabled = false
- _this.spinning = false
- resolve(data)
- })
- }
- } else {
- const _this = this
- return new Promise(function (resolve, reject) {
- const data = {
- pageNo: 1,
- pageSize: 10,
- list: [],
- count: 0
- }
- _this.disabled = false
- _this.spinning = false
- _this.$message.info('请选择连锁店')
- resolve(data)
- })
- }
- },
- productType: [],
- linkageGroupData: [],
- productBrandList: [], // 品牌下拉数据
- productTypeList: [], // 分类下拉数据
- allocateTypeList: [], // 调拨类型
- totalData: null, // 合计
- productSn: '',
- stockSn: '',
- openModal: false // 弹框
- }
- },
- methods: {
- // 校验滞销天数数值范围
- checkValueRange () {
- const isONull = this.queryParam.minUnsalableDays === null || this.queryParam.minUnsalableDays === undefined
- const isOEmpty = this.queryParam.minUnsalableDays === ''
- const isOZero = this.queryParam.minUnsalableDays === 0
- const isTNull = this.queryParam.maxUnsalableDays === null || this.queryParam.maxUnsalableDays === undefined
- const isTEmpty = this.queryParam.maxUnsalableDays === ''
- const isTZero = this.queryParam.maxUnsalableDays === 0
- // 第一个为空(可为null可为空字符)第二个不为空
- // 第一个不为空第二个为空(可为null可为空字符)
- // 第一个大于第二个
- if ((isONull || isOEmpty) && (this.queryParam.maxUnsalableDays || isTZero)) {
- this.$message.info('请输入正确的滞销天数查询范围!')
- return false
- }
- if ((this.queryParam.minUnsalableDays || isOZero) && (isTNull || isTEmpty)) {
- this.$message.info('请输入正确的滞销天数查询范围!')
- return false
- }
- if (this.queryParam.minUnsalableDays > this.queryParam.maxUnsalableDays) {
- this.$message.info('请输入正确的滞销天数查询范围!')
- return false
- }
- this.queryParam.minUnsalableDays = this.queryParam.minUnsalableDays > 999999999 ? 999999999 : this.queryParam.minUnsalableDays
- this.queryParam.maxUnsalableDays = this.queryParam.maxUnsalableDays > 999999999 ? 999999999 : this.queryParam.maxUnsalableDays
- return true
- },
- num (val) {
- let days
- if (val) {
- if (val >= 30) {
- const a = Math.floor(val / 30)
- const b = val - a * 30
- if (b > 0) {
- days = a + '个月' + b + '天'
- } else {
- days = a + '个月'
- }
- } else {
- days = val + '天'
- }
- } else {
- days = '--'
- }
- return days
- },
- // 合计
- getCount (params) {
- reportStockCount(params).then(res => {
- if (res.status == 200) {
- this.totalData = res.data
- } else {
- this.totalData = null
- }
- })
- },
- // 查询
- handleSearch () {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- _this.$refs.table.refresh(true)
- } else {
- console.log('error submit!!')
- return false
- }
- })
- },
- // 重置
- resetSearchForm () {
- this.queryParam.tenantId = undefined
- this.queryParam.productCode = ''
- this.queryParam.productName = ''
- this.queryParam.productOrigCode = ''
- this.queryParam.productBrandSn = undefined
- this.queryParam.productTypeSn1 = ''
- this.queryParam.productTypeSn2 = ''
- this.queryParam.productTypeSn3 = ''
- this.queryParam.minUnsalableDays = undefined // 滞销天数最小值
- this.queryParam.maxUnsalableDays = undefined // 滞销天数最大值
- this.productType = []
- this.$refs.ruleForm.resetFields()
- this.totalData = null
- this.$refs.table.clearTable()
- },
- // 导出
- handleExport () {
- const _this = this
- const params = JSON.parse(JSON.stringify(this.queryParam))
- params.showCost = this.$hasPermissions('M_ShowAllCost') ? '1' : '0'
- if (params.tenantId) {
- this.exportLoading = true
- _this.spinning = true
- stockExport(params).then(res => {
- this.exportLoading = false
- _this.spinning = false
- if (res.type == 'application/json') {
- var reader = new FileReader()
- reader.addEventListener('loadend', function () {
- const obj = JSON.parse(reader.result)
- _this.$notification.error({
- message: '提示',
- description: obj.message
- })
- })
- reader.readAsText(res)
- } else {
- downloadExcel(res, '连锁库存总表')
- }
- })
- } else {
- this.exportLoading = false
- _this.spinning = false
- this.$message.info('请选择连锁店')
- return false
- }
- },
- // 详情
- goDetail (row) {
- this.productSn = row.productSn
- this.stockSn = row.stockSn
- this.openModal = true
- },
- // 关闭弹框
- closeModal () {
- this.productSn = ''
- this.stockSn = ''
- this.openModal = false
- },
- // 产品分类 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] : ''
- },
- filterOption (input, option) {
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
- )
- },
- // 连锁店
- getLinkageGroup () {
- linkageGroupList({}).then(res => {
- if (res.status == 200) {
- const data = res.data || []
- if (data.length > 0) {
- this.linkageGroupData = data
- } else {
- this.linkageGroupData = []
- }
- } else {
- this.linkageGroupData = []
- }
- })
- },
- pageInit () {
- this.getLinkageGroup()
- }
- },
- 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>
|