list.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <a-card size="small" :bordered="false" class="accountManagementList-wrap jg-page-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="5" :sm="24">
  9. <a-form-item label="货架名称">
  10. <shelfList id="settle-shelfsn" style="max-width:300px;" v-model="queryParam.shelfSn"></shelfList>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="5" :sm="24">
  14. <a-form-item label="关联客户">
  15. <custList id="settle-customerName" ref="custList" @change="custChange" v-model="queryParam.customerName"></custList>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="4" :sm="24">
  19. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="settle-refresh" >查询</a-button>
  20. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="settle-reset">重置</a-button>
  21. </a-col>
  22. </a-row>
  23. </a-form>
  24. </div>
  25. <div class="table-operator">
  26. <div class="alert-message">
  27. 账单总金额:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? toThousands(detailData.totalAmount) : '--' }}</strong>;
  28. 其中收款金额:<strong>{{ detailData&&(detailData.totalCost || detailData.totalCost==0) ? toThousands(detailData.totalCost) : '--' }}</strong>;
  29. 待退款金额:<strong>{{ detailData&&(detailData.grossProfit || detailData.grossProfit==0) ? toThousands(detailData.grossProfit) : '--' }}</strong>;
  30. 已退款金额:<strong>{{ detailData&&(detailData.totalGiveAmount || detailData.totalGiveAmount==0) ? toThousands(detailData.totalGiveAmount) : '--' }}</strong>;
  31. </div>
  32. </div>
  33. <s-table
  34. class="sTable fixPagination"
  35. ref="table"
  36. :style="{ height: tableHeight+77+'px' }"
  37. size="small"
  38. :rowKey="(record) => record.id"
  39. :columns="columns"
  40. :data="loadData"
  41. :scroll="{ y:tableHeight }"
  42. :defaultLoadData="false"
  43. bordered>
  44. <template slot="action" slot-scope="text,record">
  45. <a-button
  46. size="small"
  47. type="link"
  48. class="button-primary"
  49. @click="handleUndetail(record)"
  50. :id="'settle-detail-btn-'+record.id">明细</a-button>
  51. </template>
  52. </s-table>
  53. </a-spin>
  54. </a-card>
  55. </template>
  56. <script>
  57. import moment from 'moment'
  58. import { commonMixin } from '@/utils/mixin'
  59. import { toThousands } from '@/libs/tools.js'
  60. import { STable, VSelect } from '@/components'
  61. import shelfList from '@/views/common/shelfList'
  62. import custList from '@/views/common/custList.vue'
  63. import { queryShelfSettleRulePage, queryShelfSettleRuleCount } from '@/api/merchant'
  64. export default {
  65. components: { STable, shelfList, custList, VSelect },
  66. mixins: [commonMixin],
  67. data () {
  68. return {
  69. toThousands,
  70. advanced: true, // 高级搜索 展开/关闭
  71. spinning: false,
  72. disabled: false,
  73. tableHeight: 0, // 表格高度
  74. total: 0, // 待结算金额合计
  75. count: 0, // 总记录
  76. time: [], // 时间
  77. queryParam: {
  78. shelfSn: undefined, // 货架sn
  79. settleType: undefined, // 结算方式
  80. customerName: undefined, // 客户名称
  81. beginAmount: '', // 开始金额
  82. endAmount: ''//
  83. },
  84. // 列
  85. columns: [
  86. { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
  87. { title: '货架名称', dataIndex: 'shelfName', width: '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  88. { title: '关联客户', dataIndex: 'customerName', width: '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  89. { title: '账单总金额', dataIndex: 'waitSettleAmount', width: '15%', align: 'right', customRender: function (text) { return toThousands(text, 2) || '--' } },
  90. { title: '收款金额', dataIndex: 'waitSettleAmount', width: '15%', align: 'right', customRender: function (text) { return toThousands(text, 2) || '--' } },
  91. { title: '待退款金额', dataIndex: 'waitSettleAmount', width: '15%', align: 'right', customRender: function (text) { return toThousands(text, 2) || '--' } },
  92. { title: '已退款金额', dataIndex: 'waitSettleAmount', width: '15%', align: 'right', customRender: function (text) { return toThousands(text, 2) || '--' } },
  93. { title: '操作', width: '15%', align: 'left', scopedSlots: { customRender: 'action' } }
  94. ],
  95. // 加载数据方法 必须为 Promise 对象
  96. loadData: parameter => {
  97. const _this = this
  98. _this.disabled = true
  99. _this.spinning = true
  100. const paramsPage = Object.assign(parameter, this.queryParam) // 有分页
  101. // 校验待结金额数值范围是否正确
  102. if (this.checkValueRange()) {
  103. return queryShelfSettleRulePage(paramsPage).then(res => {
  104. let data
  105. if (res.status == 200) {
  106. data = res.data
  107. this.getCount(paramsPage)
  108. const no = (data.pageNo - 1) * data.pageSize
  109. for (var i = 0; i < data.list.length; i++) {
  110. data.list[i].no = no + i + 1
  111. }
  112. this.disabled = false
  113. }
  114. this.spinning = false
  115. return data
  116. })
  117. } else {
  118. const _this = this
  119. this.disabled = true
  120. this.spinning = true
  121. return new Promise(function (resolve, reject) {
  122. const data = []
  123. _this.disabled = false
  124. _this.spinning = false
  125. resolve(data)
  126. })
  127. }
  128. }
  129. }
  130. },
  131. methods: {
  132. // 选择客户
  133. custChange (obj, row) {
  134. if (row) {
  135. this.queryParam.customerSn = row && row.customerSn || undefined
  136. this.queryParam.customerName = undefined
  137. } else {
  138. this.queryParam.customerName = obj || undefined
  139. this.queryParam.customerSn = undefined
  140. }
  141. },
  142. // 禁止选择今天之后的日期
  143. disabledDate (current) {
  144. return current && current > moment().endOf('day')
  145. },
  146. // 校验待结金额数值范围
  147. checkValueRange () {
  148. const isONull = this.queryParam.beginAmount === null || this.queryParam.beginAmount === undefined
  149. const isOEmpty = this.queryParam.beginAmount === ''
  150. const isOZero = this.queryParam.beginAmount === 0
  151. const isTNull = this.queryParam.endAmount === null || this.queryParam.endAmount === undefined
  152. const isTEmpty = this.queryParam.endAmount === ''
  153. const isTZero = this.queryParam.endAmount === 0
  154. // 第一个为空(可为null可为空字符)第二个不为空
  155. // 第一个不为空第二个为空(可为null可为空字符)
  156. // 第一个大于第二个
  157. if ((isONull || isOEmpty) && (this.queryParam.endAmount || isTZero)) {
  158. this.$message.info('请输入正确的待结金额查询范围!')
  159. return false
  160. }
  161. if ((this.queryParam.beginAmount || isOZero) && (isTNull || isTEmpty)) {
  162. this.$message.info('请输入正确的待结金额查询范围!')
  163. return false
  164. }
  165. if (this.queryParam.beginAmount > this.queryParam.endAmount) {
  166. this.$message.info('请输入正确的待结金额查询范围!')
  167. return false
  168. }
  169. this.queryParam.beginAmount = this.queryParam.beginAmount > 999999999 ? 999999999 : this.queryParam.beginAmount
  170. this.queryParam.endAmount = this.queryParam.endAmount > 999999999 ? 999999999 : this.queryParam.endAmount
  171. return true
  172. },
  173. // 重置
  174. resetSearchForm () {
  175. this.time = []
  176. this.queryParam = {
  177. shelfSn: undefined,
  178. settleType: undefined,
  179. customerName: undefined,
  180. customerSn: undefined,
  181. beginAmount: '',
  182. endAmount: ''
  183. }
  184. this.$refs.custList.resetForm()
  185. this.$refs.table.refresh(true)
  186. },
  187. // 合计
  188. getCount (val) {
  189. queryShelfSettleRuleCount(val).then(res => {
  190. if (res.status == 200) {
  191. this.count = res.data.size || 0
  192. this.total = res.data.waitSettleAmount || 0
  193. }
  194. })
  195. },
  196. // 待结明细
  197. handleUndetail (row) {
  198. this.$router.push({ name: 'onlinePayInvoiceDetail', params: { shelfSn: row.shelfSn, settleType: row.settleType, shelfName: row.shelfName } })
  199. },
  200. // 结算历史
  201. handleDetail (row) {
  202. sessionStorage.setItem('settlementDetail', JSON.stringify(row))
  203. this.$router.push({ name: 'settlementDetail', params: { shelfSn: row.shelfSn, shelfName: row.shelfName } })
  204. },
  205. // 计算表格高度
  206. setTableH () {
  207. const tableSearchH = this.$refs.tableSearch.offsetHeight
  208. this.tableHeight = window.innerHeight - tableSearchH - 245
  209. },
  210. // 初始化页面
  211. pageInit () {
  212. const _this = this
  213. this.$nextTick(() => { // 页面渲染完成后的回调
  214. _this.setTableH()
  215. })
  216. }
  217. },
  218. mounted () {
  219. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  220. this.pageInit()
  221. this.resetSearchForm()
  222. }
  223. },
  224. watch: {
  225. advanced (newValue, oldValue) {
  226. const _this = this
  227. setTimeout(() => {
  228. _this.setTableH()
  229. }, 400)
  230. },
  231. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  232. this.setTableH()
  233. }
  234. },
  235. activated () {
  236. // 如果是新页签打开,则重置当前页面
  237. if (this.$store.state.app.isNewTab) {
  238. this.pageInit()
  239. this.resetSearchForm()
  240. }
  241. // 仅刷新列表,不重置页面
  242. if (this.$store.state.app.updateList) {
  243. this.pageInit()
  244. this.$refs.table.refresh()
  245. }
  246. },
  247. beforeRouteEnter (to, from, next) {
  248. next(vm => {})
  249. }
  250. }
  251. </script>