123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- <template>
- <a-card size="small" :bordered="false" class="sendStorageReportList-wrap">
- <!-- 搜索条件 -->
- <a-spin :spinning="spinning" tip="Loading...">
- <div class="table-page-search-wrapper">
- <a-form-model
- id="sendStorageReportList-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="auditDate">
- <a-month-picker
- id="sendStorageReportList-auditDate"
- v-model="queryParam.auditDate"
- :allowClear="false"
- @change="onChange"
- :defaultValue="moment()"
- style="width: 100%;" />
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="连锁店" prop="tenantId">
- <a-select
- placeholder="请选择连锁店"
- id="sendStorageReportList-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="sendStorageReportList-code" v-model.trim="queryParam.productEntity.code" 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="sendStorageReportList-name" v-model.trim="queryParam.productEntity.name" allowClear placeholder="请输入产品名称"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="产品品牌">
- <ProductBrand id="sendStorageReportList-productBrandSn" placeholder="请选择产品品牌" v-model="queryParam.productEntity.productBrandSn"></ProductBrand>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="产品分类">
- <ProductType id="sendStorageReportList-productType" placeholder="请选择产品分类" :isDealer="true" @change="changeProductType" v-model="productType"></ProductType>
- </a-form-model-item>
- </a-col>
- </template>
- <a-col :md="6" :sm="24">
- <a-button type="primary" @click="handleSearch" :disabled="disabled" id="sendStorageReportList-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="sendStorageReportList-reset">重置</a-button>
- <a-button
- style="margin-left: 5px"
- type="primary"
- class="button-warning"
- @click="handleExport"
- v-if="$hasPermissions('B_chainReceivedSendStorageReportExport')"
- :disabled="disabled"
- :loading="exportLoading"
- id="sendStorageReportList-export">导出</a-button>
- <a @click="advanced=!advanced" style="margin-left: 5px" id="sendStorageReportList-advanced">
- {{ advanced ? '收起' : '展开' }}
- <a-icon :type="advanced ? 'up' : 'down'"/>
- </a>
- </a-col>
- </a-row>
- </a-form-model>
- </div>
- <!-- 列表 -->
- <s-table
- class="sTable"
- ref="table"
- size="small"
- :defaultLoadData="false"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :scroll="{ x: 1830 }"
- bordered>
- <template slot="footer" slot-scope="currentPageData">
- <span>
- 合计: 期初数量:{{ (totalData && (totalData.beginQty || totalData.beginQty==0)) ? totalData.beginQty : '--' }}
- 期初金额:{{ (totalData && (totalData.beginAmount || totalData.beginAmount==0)) ? toThousands(totalData.beginAmount) : '--' }}
- 收入数量:{{ (totalData && (totalData.putQty || totalData.putQty==0)) ? totalData.putQty : '--' }}
- 收入金额:{{ (totalData && (totalData.putAmount || totalData.putAmount==0)) ? toThousands(totalData.putAmount) : '--' }}
- 发出数量:{{ (totalData && (totalData.outQty || totalData.outQty==0)) ? totalData.outQty : '--' }}
- 发出金额:{{ (totalData && (totalData.outAmount || totalData.outAmount==0)) ? toThousands(totalData.outAmount) : '--' }}
- 结存数量:{{ (totalData && (totalData.endQty || totalData.endQty==0)) ? totalData.endQty : '--' }}
- 结存金额:{{ (totalData && (totalData.endAmount || totalData.endAmount==0)) ? toThousands(totalData.endAmount) : '--' }}
- </span>
- </template>
- </s-table>
- </a-spin>
- </a-card>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import moment from 'moment'
- import { STable, VSelect } from '@/components'
- import ProductType from '../../common/productType.js'
- import ProductBrand from '../../common/productBrand.js'
- import { downloadExcel } from '@/libs/JGPrint.js'
- import { linkageReportPageList, linkageReportPageTotal, linkageGroupList, reportChainStockPutOutExport } from '@/api/reportData'
- export default {
- components: { STable, VSelect, ProductType, ProductBrand },
- mixins: [commonMixin],
- data () {
- const _this = this
- return {
- moment,
- spinning: false,
- advanced: true, // 高级搜索 展开/关闭
- tableHeight: 0,
- queryParam: { // 查询条件
- auditDate: moment().format('YYYY-MM'), // 审核时间,默认当前日期
- tenantId: undefined, // 连锁店id
- productEntity: {
- code: '', // 产品编码
- name: '', // 产品名称
- productBrandSn: undefined, // 产品品牌
- productTypeSn1: '', // 产品一级分类
- productTypeSn2: '', // 产品二级分类
- productTypeSn3: '' // 产品三级分类
- }
- },
- labelCol: { span: 8 },
- wrapperCol: { span: 16 },
- rules: {
- 'tenantId': [{ required: true, message: '请选择连锁店', trigger: 'change' }],
- 'auditDate': [{ required: true, message: '请选择日期', trigger: 'change' }]
- },
- disabled: false, // 查询、重置按钮是否可操作
- exportLoading: false,
- columns: [
- { title: '序号', dataIndex: 'no', width: 50, align: 'center' },
- { title: '产品编码', dataIndex: 'productCode', width: 120, align: 'left', customRender: function (text) { return text || '--' }, sorter: true },
- { title: '产品名称', dataIndex: 'productEntity.name', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '品牌', dataIndex: 'productEntity.productBrandName', width: 130, align: 'left', customRender: function (text) { return text || '--' } },
- { title: '三级分类', dataIndex: 'productEntity.productTypeName3', width: 130, align: 'left', customRender: function (text) { return text || '--' } },
- { title: '原厂编码', dataIndex: 'productEntity.origCode', width: 130, align: 'left', customRender: function (text) { return text || '--' } },
- { title: '单位', dataIndex: 'productEntity.unit', width: 50, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '期初数量', dataIndex: 'beginQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '期初单价(¥)', dataIndex: 'beginPrice', width: 100, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
- { title: '期初金额(¥)', dataIndex: 'beginAmount', width: 100, align: 'right', sorter: true, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
- { title: '收入数量', dataIndex: 'putQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '收入单价(¥)', dataIndex: 'putPrice', width: 100, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
- { title: '收入金额(¥)', dataIndex: 'putAmount', width: 100, align: 'right', sorter: true, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
- { title: '发出数量', dataIndex: 'outQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '发出单价(¥)', dataIndex: 'outPrice', width: 100, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
- { title: '发出金额(¥)', dataIndex: 'outAmount', width: 100, align: 'right', sorter: true, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
- { title: '结存数量', dataIndex: 'endQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '结存单价(¥)', dataIndex: 'endPrice', width: 100, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
- { title: '结存金额(¥)', dataIndex: 'endAmount', width: 100, align: 'right', sorter: true, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- const params = Object.assign(parameter, this.queryParam)
- this.spinning = true
- if (this.queryParam.auditDate && this.queryParam.tenantId) {
- params.auditDate = this.queryParam.auditDate + '-01'
- // 总计
- this.getCount(params)
- return linkageReportPageList(params).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
- }
- this.disabled = false
- }
- this.spinning = false
- return 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: [], // 连锁店列表
- totalData: null // 合计
- }
- },
- methods: {
- // 月份 change
- onChange (date, dateString) {
- this.queryParam.auditDate = dateString || null
- },
- // 查询
- handleSearch () {
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- this.$refs.table.refresh(true)
- } else {
- console.log('error submit!!')
- return false
- }
- })
- },
- // 查询总计
- getCount (params) {
- linkageReportPageTotal(params).then(res => {
- if (res.status == 200 && res.data) {
- this.totalData = res.data
- } else {
- this.totalData = null
- }
- })
- },
- // 重置
- resetSearchForm () {
- this.queryParam.tenantId = undefined
- this.queryParam.auditDate = moment().format('YYYY-MM')
- this.queryParam.productEntity.code = ''
- this.queryParam.productEntity.name = ''
- this.queryParam.productEntity.productBrandSn = undefined
- this.queryParam.productEntity.productTypeSn1 = ''
- this.queryParam.productEntity.productTypeSn2 = ''
- this.queryParam.productEntity.productTypeSn3 = ''
- this.productType = []
- this.$refs.ruleForm.resetFields()
- this.totalData = null
- this.$refs.table.clearTable()
- },
- // 导出
- handleExport () {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- const params = _this.queryParam
- params.auditDate = params.auditDate + '-01'
- _this.exportLoading = true
- _this.spinning = true
- reportChainStockPutOutExport(params).then(res => {
- downloadExcel(res, '连锁收发存报表')
- _this.exportLoading = false
- _this.spinning = false
- })
- } else {
- return false
- }
- })
- },
- // 产品分类 change
- changeProductType (val, opt) {
- this.queryParam.productEntity.productTypeSn1 = val[0] ? val[0] : ''
- this.queryParam.productEntity.productTypeSn2 = val[1] ? val[1] : ''
- this.queryParam.productEntity.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>
|