123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- <template>
- <a-card size="small" :bordered="false" class="accountManagementList-wrap jg-page-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="5" :sm="24">
- <a-form-item label="货架名称">
- <shelfList id="settle-shelfsn" style="max-width:300px;" v-model="queryParam.shelfSn"></shelfList>
- </a-form-item>
- </a-col>
- <a-col :md="5" :sm="24">
- <a-form-item label="关联客户">
- <custList id="settle-customerName" ref="custList" @change="custChange" v-model="queryParam.customerName"></custList>
- </a-form-item>
- </a-col>
- <a-col :md="4" :sm="24">
- <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="settle-refresh" >查询</a-button>
- <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="settle-reset">重置</a-button>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <div class="table-operator">
- <div class="alert-message">
- 账单总金额:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? toThousands(detailData.totalAmount) : '--' }}</strong>;
- 其中收款金额:<strong>{{ detailData&&(detailData.totalCost || detailData.totalCost==0) ? toThousands(detailData.totalCost) : '--' }}</strong>;
- 待退款金额:<strong>{{ detailData&&(detailData.grossProfit || detailData.grossProfit==0) ? toThousands(detailData.grossProfit) : '--' }}</strong>;
- 已退款金额:<strong>{{ detailData&&(detailData.totalGiveAmount || detailData.totalGiveAmount==0) ? toThousands(detailData.totalGiveAmount) : '--' }}</strong>;
- </div>
- </div>
- <s-table
- class="sTable fixPagination"
- ref="table"
- :style="{ height: tableHeight+77+'px' }"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :scroll="{ y:tableHeight }"
- :defaultLoadData="false"
- bordered>
- <template slot="action" slot-scope="text,record">
- <a-button
- size="small"
- type="link"
- class="button-primary"
- @click="handleUndetail(record)"
- :id="'settle-detail-btn-'+record.id">明细</a-button>
- </template>
- </s-table>
- </a-spin>
- </a-card>
- </template>
- <script>
- import moment from 'moment'
- import { commonMixin } from '@/utils/mixin'
- import { toThousands } from '@/libs/tools.js'
- import { STable, VSelect } from '@/components'
- import shelfList from '@/views/common/shelfList'
- import custList from '@/views/common/custList.vue'
- import { queryShelfSettleRulePage, queryShelfSettleRuleCount } from '@/api/merchant'
- export default {
- components: { STable, shelfList, custList, VSelect },
- mixins: [commonMixin],
- data () {
- return {
- toThousands,
- advanced: true, // 高级搜索 展开/关闭
- spinning: false,
- disabled: false,
- tableHeight: 0, // 表格高度
- total: 0, // 待结算金额合计
- count: 0, // 总记录
- time: [], // 时间
- queryParam: {
- shelfSn: undefined, // 货架sn
- settleType: undefined, // 结算方式
- customerName: undefined, // 客户名称
- beginAmount: '', // 开始金额
- endAmount: ''//
- },
- // 列
- columns: [
- { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
- { title: '货架名称', dataIndex: 'shelfName', width: '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '关联客户', dataIndex: 'customerName', width: '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '账单总金额', dataIndex: 'waitSettleAmount', width: '15%', align: 'right', customRender: function (text) { return toThousands(text, 2) || '--' } },
- { title: '收款金额', dataIndex: 'waitSettleAmount', width: '15%', align: 'right', customRender: function (text) { return toThousands(text, 2) || '--' } },
- { title: '待退款金额', dataIndex: 'waitSettleAmount', width: '15%', align: 'right', customRender: function (text) { return toThousands(text, 2) || '--' } },
- { title: '已退款金额', dataIndex: 'waitSettleAmount', width: '15%', align: 'right', customRender: function (text) { return toThousands(text, 2) || '--' } },
- { title: '操作', width: '15%', align: 'left', scopedSlots: { customRender: 'action' } }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- const _this = this
- _this.disabled = true
- _this.spinning = true
- const paramsPage = Object.assign(parameter, this.queryParam) // 有分页
- // 校验待结金额数值范围是否正确
- if (this.checkValueRange()) {
- return queryShelfSettleRulePage(paramsPage).then(res => {
- let data
- if (res.status == 200) {
- data = res.data
- this.getCount(paramsPage)
- 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
- this.disabled = true
- this.spinning = true
- return new Promise(function (resolve, reject) {
- const data = []
- _this.disabled = false
- _this.spinning = false
- resolve(data)
- })
- }
- }
- }
- },
- methods: {
- // 选择客户
- custChange (obj, row) {
- if (row) {
- this.queryParam.customerSn = row && row.customerSn || undefined
- this.queryParam.customerName = undefined
- } else {
- this.queryParam.customerName = obj || undefined
- this.queryParam.customerSn = undefined
- }
- },
- // 禁止选择今天之后的日期
- disabledDate (current) {
- return current && current > moment().endOf('day')
- },
- // 校验待结金额数值范围
- checkValueRange () {
- const isONull = this.queryParam.beginAmount === null || this.queryParam.beginAmount === undefined
- const isOEmpty = this.queryParam.beginAmount === ''
- const isOZero = this.queryParam.beginAmount === 0
- const isTNull = this.queryParam.endAmount === null || this.queryParam.endAmount === undefined
- const isTEmpty = this.queryParam.endAmount === ''
- const isTZero = this.queryParam.endAmount === 0
- // 第一个为空(可为null可为空字符)第二个不为空
- // 第一个不为空第二个为空(可为null可为空字符)
- // 第一个大于第二个
- if ((isONull || isOEmpty) && (this.queryParam.endAmount || isTZero)) {
- this.$message.info('请输入正确的待结金额查询范围!')
- return false
- }
- if ((this.queryParam.beginAmount || isOZero) && (isTNull || isTEmpty)) {
- this.$message.info('请输入正确的待结金额查询范围!')
- return false
- }
- if (this.queryParam.beginAmount > this.queryParam.endAmount) {
- this.$message.info('请输入正确的待结金额查询范围!')
- return false
- }
- this.queryParam.beginAmount = this.queryParam.beginAmount > 999999999 ? 999999999 : this.queryParam.beginAmount
- this.queryParam.endAmount = this.queryParam.endAmount > 999999999 ? 999999999 : this.queryParam.endAmount
- return true
- },
- // 重置
- resetSearchForm () {
- this.time = []
- this.queryParam = {
- shelfSn: undefined,
- settleType: undefined,
- customerName: undefined,
- customerSn: undefined,
- beginAmount: '',
- endAmount: ''
- }
- this.$refs.custList.resetForm()
- this.$refs.table.refresh(true)
- },
- // 合计
- getCount (val) {
- queryShelfSettleRuleCount(val).then(res => {
- if (res.status == 200) {
- this.count = res.data.size || 0
- this.total = res.data.waitSettleAmount || 0
- }
- })
- },
- // 待结明细
- handleUndetail (row) {
- this.$router.push({ name: 'onlinePayInvoiceDetail', params: { shelfSn: row.shelfSn, settleType: row.settleType, shelfName: row.shelfName } })
- },
- // 结算历史
- handleDetail (row) {
- sessionStorage.setItem('settlementDetail', JSON.stringify(row))
- this.$router.push({ name: 'settlementDetail', params: { shelfSn: row.shelfSn, shelfName: row.shelfName } })
- },
- // 计算表格高度
- setTableH () {
- const tableSearchH = this.$refs.tableSearch.offsetHeight
- this.tableHeight = window.innerHeight - tableSearchH - 245
- },
- // 初始化页面
- pageInit () {
- const _this = this
- this.$nextTick(() => { // 页面渲染完成后的回调
- _this.setTableH()
- })
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.pageInit()
- this.resetSearchForm()
- }
- },
- watch: {
- advanced (newValue, oldValue) {
- const _this = this
- setTimeout(() => {
- _this.setTableH()
- }, 400)
- },
- '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
- this.setTableH()
- }
- },
- activated () {
- // 如果是新页签打开,则重置当前页面
- if (this.$store.state.app.isNewTab) {
- this.pageInit()
- this.resetSearchForm()
- }
- // 仅刷新列表,不重置页面
- if (this.$store.state.app.updateList) {
- this.pageInit()
- this.$refs.table.refresh()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
|