123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- <template>
- <a-card size="small">
- <a-spin :spinning="spinning" tip="Loading...">
- <div class="table-page-search-wrapper newTableSearchName">
- <a-form-model
- id="billingBackReportList-form"
- ref="ruleForm"
- class="form-model-con"
- layout="inline"
- :rules="rules"
- :model="queryParam"
- @keyup.enter.native="handleSearch">
- <a-row :gutter="15">
- <a-col :md="6" :sm="24">
- <a-form-model-item label="退货完成时间" prop="time">
- <rangeDate ref="rangeDate" :value="queryParam.time" @change="dateChange"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="供应商名称">
- <supplier id="billingBackReport-supplierName" v-model="queryParam.supplier.supplierSn" @change="getSupplierName" placeholder="请输入供应商名称"></supplier>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="所在区域/分区">
- <subarea id="billingBackReportList-subareaSn" v-model="queryParam.subareaSn"></subarea>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="地区">
- <AreaList id="billingBackReportList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
- </a-form-model-item>
- </a-col>
- <a-col :md="24" :sm="24" style="margin-bottom: 10px;display:flex;algin-item:center;justify-content: center;">
- <a-button type="primary" @click="handleSearch" :disabled="disabled" id="billingBackReportList-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="billingBackReportList-reset">重置</a-button>
- <a-button
- style="margin-left: 5px"
- type="primary"
- class="button-warning"
- @click="handleExport"
- :disabled="disabled"
- :loading="exportLoading"
- v-if="$hasPermissions('B_regionTypeSalesReportExport')"
- id="billingBackReportList-export">导出</a-button>
- </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"
- :showPagination="false"
- :scroll="{ x: 1550 }"
- bordered>
- <template slot="footer">
- <a-row>
- <a-col span="2">合计:</a-col>
- <a-col span="22">
- <a-row>
- <a-col span="4" v-for="item in countLabel" :key="item.key">
- {{ item.title }}:{{ totalData?(totalData[item.dataIndex] ||totalData[item.dataIndex]==0)?toThousands(totalData[item.dataIndex]):'--':'--' }}
- </a-col>
- </a-row>
- </a-col>
- </a-row>
- </template>
- </s-table>
- </a-spin>
- <!-- 导出提示框 -->
- <reportModal :visible="showExport" @close="showExport=false"></reportModal>
- </a-card>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { STable, VSelect } from '@/components'
- import rangeDate from '@/views/common/rangeDate.vue'
- import AreaList from '@/views/common/areaList.js'
- import subarea from '@/views/common/subarea.js'
- import { hdExportExcel } from '@/libs/exportExcel'
- import reportModal from '@/views/common/reportModal.vue'
- import supplier from '@/views/common/supplier.js'
- import { querySupplierPage, querySupplierCount, querySupplierTitle, supplierExport } from '@/api/reportData.js'
- export default {
- name: 'RegionTypeSalesReportList',
- mixins: [commonMixin],
- components: { STable, VSelect, rangeDate, subarea, reportModal, AreaList, supplier },
- data () {
- return {
- spinning: false,
- showExport: false,
- queryParam: {
- time: [],
- beginDate: '',
- endDate: '',
- subareaSn: undefined,
- supplier: {
- supplierSn: undefined,
- supplierName: undefined,
- provinceSn: undefined,
- citySn: undefined,
- districtSn: undefined
- }
- },
- countLabel: [],
- columns: [],
- disabled: false, // 查询、重置按钮是否可操作
- exportLoading: false,
- totalData: null,
- rules: {
- 'time': [{ required: true, message: '请选择退货完成时间', trigger: 'change' }]
- },
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- this.spinning = true
- const params = Object.assign(parameter, this.queryParam) // 无分页
- delete params.time
- return querySupplierPage(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
- })
- }
- }
- },
- methods: {
- // 总计
- getCount (params) {
- querySupplierCount(params).then(res => {
- if (res.status == 200 && res.data) {
- this.totalData = res.data
- } else {
- this.totalData = null
- }
- })
- },
- // 选择供应商
- getSupplierName (val, item) {
- this.queryParam.supplier.supplierName = item.supplierName
- this.queryParam.supplier.supplierSn = val
- },
- // 创建时间 change
- dateChange (date) {
- if (date[0] && date[1]) {
- this.queryParam.time = date
- } else {
- this.queryParam.time = []
- }
- this.queryParam.beginDate = date[0] || ''
- this.queryParam.endDate = date[1] || ''
- },
- // 查询
- handleSearch () {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- _this.$refs.table.refresh(true)
- } else {
- _this.$message.error('请选择退货完成时间')
- return false
- }
- })
- },
- // 重置
- resetSearchForm () {
- this.$refs.ruleForm.resetFields()
- this.queryParam.time = []
- this.$refs.rangeDate.resetDate(this.queryParam.time)
- this.queryParam.beginDate = ''
- this.queryParam.endDate = ''
- this.queryParam.supplier.supplierName = undefined
- this.queryParam.supplier.supplierSn = undefined
- this.queryParam.supplier.provinceSn = undefined
- this.queryParam.supplier.citySn = undefined
- this.queryParam.supplier.districtSn = undefined
- this.queryParam.subareaSn = undefined
- this.$refs.areaList.clearData()
- this.$refs.table.clearTable()
- },
- areaChange (val) {
- this.queryParam.provinceSn = val[0] ? val[0] : ''
- this.queryParam.citySn = val[1] ? val[1] : ''
- this.queryParam.districtSn = val[2] ? val[2] : ''
- },
- // 导出
- handleExport () {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- const params = _this.queryParam
- _this.$store.state.app.curActionPermission = 'B_billingReturn_Report'
- _this.showExport = true
- _this.exportLoading = true
- _this.spinning = true
- hdExportExcel(supplierExport, params, '开单采退', function () {
- _this.exportLoading = false
- _this.spinning = false
- _this.$store.state.app.curActionPermission = ''
- })
- } else {
- _this.$message.error('请选择退货完成时间')
- return false
- }
- })
- },
- // 获取表头
- async getTableTitle () {
- const _this = this
- const tableTitle = await querySupplierTitle().then(res => res.data)
- this.columns = tableTitle.list
- this.countLabel = tableTitle.count
- this.columns.map(item => {
- let mw = 40
- if (item.customRender == 'amount') {
- mw = 15
- item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
- }
- const w = item.title.length * mw
- const tw = w <= 80 && item.customRender != 'amount' ? w * 2 : (w >= 360 ? 200 : w)
- item.width = tw + 'px'
- this.tableWidth = this.tableWidth + tw
- })
- this.resetSearchForm()
- },
- pageInit () {
- this.getTableTitle()
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.pageInit()
- }
- },
- activated () {
- // 如果是新页签打开,则重置当前页面
- if (this.$store.state.app.isNewTab) {
- this.pageInit()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
|