list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <a-card size="small" :bordered="false" class="finacialPay-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 标签页 -->
  5. <a-tabs type="card" default-active-key="0" @change="handleTabChange" class="finacialPay-tabs">
  6. <a-tab-pane v-for="item in tabPaneData" :key="item.bizType">
  7. <span slot="tab">{{ item.bizName }}({{ item.countNum }})</span>
  8. </a-tab-pane>
  9. </a-tabs>
  10. <!-- 搜索条件 -->
  11. <div ref="tableSearch" class="table-page-search-wrapper">
  12. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  13. <a-row :gutter="15">
  14. <a-col :md="6" :sm="24">
  15. <a-form-item label="付款单号"><a-input id="finacialPay-settleNo" v-model.trim="queryParam.settleNo" allowClear placeholder="请输入付款单号" /></a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="关联单号"><a-input id="finacialPay-bizNo" v-model.trim="queryParam.bizNo" allowClear placeholder="请输入关联单号" /></a-form-item>
  19. </a-col>
  20. <a-col :md="6" :sm="24">
  21. <a-form-item label="商户名称">
  22. <a-input id="finacialPay-settleClientName" v-model.trim="queryParam.settleClientName" allowClear placeholder="请输入商户名称" />
  23. </a-form-item>
  24. </a-col>
  25. <template v-if="advanced">
  26. <a-col :md="6" :sm="24">
  27. <a-form-item label="单据状态">
  28. <v-select
  29. v-model="queryParam.billState"
  30. ref="settleState"
  31. id="finacialPay-settleState"
  32. code="SETTLE_PAY_STATUS"
  33. placeholder="请选择单据状态"
  34. allowClear></v-select>
  35. </a-form-item>
  36. </a-col>
  37. <a-col :md="6" :sm="24">
  38. <a-form-item label="审核时间">
  39. <rangeDate ref="rangeDate" @change="dateChange" />
  40. </a-form-item>
  41. </a-col>
  42. </template>
  43. <a-col :md="6" :sm="24">
  44. <span class="table-page-search-submitButtons">
  45. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="finacialPay-refresh">查询</a-button>
  46. <a-button style="margin-left: 8px" @click="resetSearchForm()" :disabled="disabled" id="finacialPay-reset">重置</a-button>
  47. <a @click="advanced = !advanced" style="margin-left: 8px">
  48. {{ advanced ? '收起' : '展开' }}
  49. <a-icon :type="advanced ? 'up' : 'down'" />
  50. </a>
  51. </span>
  52. </a-col>
  53. </a-row>
  54. </a-form>
  55. </div>
  56. <!-- alert -->
  57. <a-alert type="info" style="margin-bottom:10px">
  58. <div slot="message">
  59. <strong>{{ totalData&&(totalData.count || totalData.count==0) ? totalData.count : '--' }}</strong>
  60. 条记录,应付金额合计
  61. <strong>{{ totalData&&(totalData.totalAmount || totalData.totalAmount==0) ? '¥'+totalData.totalAmount : '--' }}</strong>
  62. ,其中已付金额
  63. <strong>{{ totalData&&(totalData.settledAmount || totalData.settledAmount==0) ? '¥'+totalData.settledAmount : '--' }}</strong>
  64. ,待付金额
  65. <strong>{{ totalData&&(totalData.unsettleAmount || totalData.unsettleAmount==0) ? '¥'+totalData.unsettleAmount : '--' }}</strong>
  66. </div>
  67. </a-alert>
  68. <div v-if="$hasPermissions('B_financialPaymentPl')" style="margin-bottom: 10px">
  69. <a-button type="primary" id="finacialPay-export" :loading="loading" @click="handlePayment">批量付款</a-button>
  70. <span style="margin-left: 8px" v-if="$hasPermissions('B_financialPaymentPl')">
  71. <template v-if="hasSelected">
  72. {{ `已选 ${selectedRowKeys.length} 项` }}
  73. </template>
  74. </span>
  75. </div>
  76. <!-- 列表 -->
  77. <s-table
  78. class="sTable fixPagination"
  79. ref="table"
  80. :style="{ height: tableHeight+84.5+'px' }"
  81. size="small"
  82. :row-selection="$hasPermissions('B_financialPaymentPl') ? rowSelection : null"
  83. :rowKey="record => record.id"
  84. :columns="columns"
  85. :data="loadData"
  86. :scroll="{ x: 1660, y: tableHeight }"
  87. bordered
  88. >
  89. <!-- 操作 -->
  90. <template slot="action" slot-scope="text, record">
  91. <a-button
  92. size="small"
  93. type="link"
  94. class="button-info"
  95. v-if="record.settleState == 'SETTLED' && $hasPermissions('B_financialPaymentDetail')"
  96. @click="handleVoucher(record)"
  97. id="finacialPay-voucher-btn">凭证</a-button>
  98. <a-button
  99. size="small"
  100. type="link"
  101. class="button-warning"
  102. :loading="loading"
  103. v-else-if="record.settleState != 'SETTLED' && $hasPermissions('B_financialPaymentSing')"
  104. @click="handlePay(record)"
  105. id="finacialPay-pay-btn">付款</a-button>
  106. <span v-else>--</span>
  107. </template>
  108. </s-table>
  109. </a-spin>
  110. <!-- 详情 -->
  111. <detail-modal :openModal="openModal" ref="detailModal" @close="openModal = false" />
  112. </a-card>
  113. </template>
  114. <script>
  115. import { STable, VSelect } from '@/components'
  116. import detailModal from './detailModal.vue'
  117. import { settlePayQuery, queryByTypeSum, settlePayMoney, settlePayQuerySum } from '@/api/settlePay.js'
  118. import rangeDate from '@/views/common/rangeDate.vue'
  119. export default {
  120. components: { STable, VSelect, detailModal, rangeDate },
  121. data () {
  122. return {
  123. spinning: false,
  124. advanced: true, // 高级搜索 展开/关闭
  125. disabled: false, // 查询、重置按钮是否可操作
  126. openModal: false, // 详情弹框
  127. tableHeight: 0,
  128. curBizType: '',
  129. // 查询参数
  130. queryParam: {
  131. bizType: 'ALL',
  132. settleNo: '',
  133. bizNo: '',
  134. settleClientName: '',
  135. billState: '',
  136. auditBeginDate: '',
  137. auditEndDate: ''
  138. },
  139. // 总计
  140. totalData: {
  141. settledAmount: 0,
  142. totalAmount: 0,
  143. unsettleAmount: 0,
  144. count: 0
  145. },
  146. // 表头
  147. columns: [
  148. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  149. { title: '付款单号', dataIndex: 'settleNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  150. { title: '关联单号', dataIndex: 'bizNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  151. { title: '商户名称', dataIndex: 'settleClientName', align: 'center', customRender: function (text) { return text || '--' } },
  152. { title: '应付金额', dataIndex: 'totalAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  153. { title: '已付金额', dataIndex: 'settledAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  154. { title: '待付金额', dataIndex: 'unsettleAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  155. { title: '付款类型', dataIndex: 'bizName', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  156. { title: '付款方式', dataIndex: 'settleStyleName', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  157. { title: '审核时间', dataIndex: 'auditTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  158. { title: '付款时间', dataIndex: 'settleTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  159. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  160. ],
  161. selectedRowKeys: [], // Check here to configure the default column
  162. loading: false,
  163. // 加载数据方法 必须为 Promise 对象
  164. loadData: parameter => {
  165. this.disabled = true
  166. this.spinning = true
  167. return settlePayQuery(Object.assign(parameter, this.queryParam)).then(res => {
  168. const data = res.data
  169. const no = (data.pageNo - 1) * data.pageSize
  170. for (var i = 0; i < data.list.length; i++) {
  171. data.list[i].no = no + i + 1
  172. }
  173. this.disabled = false
  174. this.spinning = false
  175. this.totalData.count = data.count || 0
  176. // 查询总计
  177. this.settlePayQuerySum(Object.assign(parameter, this.queryParam))
  178. return data
  179. })
  180. },
  181. tabPaneData: []
  182. }
  183. },
  184. computed: {
  185. hasSelected () {
  186. return this.selectedRowKeys.length > 0
  187. },
  188. rowSelection () {
  189. if (this.$hasPermissions('B_financialPaymentPl')) {
  190. return {
  191. selectedRowKeys: this.selectedRowKeys,
  192. onChange: (selectedRowKeys, selectedRows) => {
  193. this.selectedRowKeys = selectedRowKeys
  194. },
  195. onSelect: (record, selected, selectedRows, nativeEvent) => {
  196. this.onSelectChange(record, selected, selectedRows, nativeEvent)
  197. },
  198. onSelectAll: (selected, selectedRows, changeRows) => {
  199. this.onSelectAllChange(selected, selectedRows, changeRows)
  200. },
  201. getCheckboxProps: record => ({
  202. props: {
  203. disabled: record.settleState == 'SETTLED'
  204. }
  205. })
  206. }
  207. } else {
  208. return null
  209. }
  210. }
  211. },
  212. beforeRouteEnter (to, from, next) {
  213. next(vm => {
  214. vm.queryByTypeSum()
  215. })
  216. },
  217. methods: {
  218. // 时间 change
  219. dateChange (date) {
  220. this.queryParam.auditBeginDate = date[0]
  221. this.queryParam.auditEndDate = date[1]
  222. },
  223. // 总计
  224. settlePayQuerySum (params) {
  225. settlePayQuerySum(params).then(res => {
  226. if (res.status == 200) {
  227. this.totalData = Object.assign(this.totalData, res.data)
  228. }
  229. })
  230. },
  231. // 获取类型
  232. queryByTypeSum () {
  233. queryByTypeSum({}).then(res => {
  234. if (res.data && res.status == 200) {
  235. this.tabPaneData = res.data
  236. this.queryParam.bizType = res.data[0].bizType
  237. }
  238. })
  239. },
  240. // 凭证弹框
  241. handleVoucher (row) {
  242. this.$refs.detailModal.getDetail(row.id)
  243. this.openModal = true
  244. },
  245. // 付款
  246. handlePay (row) {
  247. this.loading = true
  248. this.spinning = true
  249. settlePayMoney([row.id]).then(res => {
  250. this.loading = false
  251. if (res.status == 200) {
  252. this.$message.success(res.message)
  253. this.selectedRowKeys = []
  254. this.$refs.table.refresh()
  255. this.spinning = false
  256. } else {
  257. this.spinning = false
  258. }
  259. })
  260. },
  261. // 选择类型
  262. handleTabChange (key) {
  263. this.queryParam.bizType = key
  264. this.$refs.table.refresh(true)
  265. this.curBizType = key
  266. },
  267. // 批量付款
  268. handlePayment () {
  269. if (this.selectedRowKeys.length < 1) {
  270. this.$message.warning('请在列表勾选后再进行批量操作!')
  271. return
  272. }
  273. this.loading = true
  274. this.spinning = true
  275. settlePayMoney(this.selectedRowKeys).then(res => {
  276. this.loading = false
  277. if (res.status == 200) {
  278. this.$message.success(res.message)
  279. this.selectedRowKeys = []
  280. this.$refs.table.refresh()
  281. this.spinning = false
  282. } else {
  283. this.spinning = false
  284. }
  285. })
  286. },
  287. // 重置
  288. resetSearchForm () {
  289. if (this.advanced) {
  290. this.$refs.rangeDate.resetDate()
  291. }
  292. this.queryParam = {
  293. bizType: this.curBizType,
  294. settleNo: '',
  295. bizNo: '',
  296. settleClientName: '',
  297. billState: '',
  298. auditBeginDate: '',
  299. auditEndDate: ''
  300. }
  301. this.$refs.table.refresh(true)
  302. },
  303. onSelectChange (record, selected, selectedRows, nativeEvent) {
  304. if (selected) { // 选择
  305. this.selectedRows.push(record)
  306. } else { // 取消
  307. this.selectedRows = selectedRows
  308. }
  309. },
  310. // 本页全选/取消全选
  311. onSelectAllChange (selected, selectedRows, changeRows) {
  312. const _this = this
  313. if (selected) { // 选择
  314. this.selectedRows = [...this.selectedRows, ...changeRows]
  315. } else { // 取消
  316. const arrId = []
  317. this.selectedRows.map((item, index) => {
  318. this.selectedRows.map((subItem, ind) => {
  319. if (item.id == subItem.id) {
  320. arrId.push(index)
  321. }
  322. })
  323. })
  324. arrId.map((item, index) => {
  325. _this.selectedRows = _this.selectedRows.slice(item, item + 1)
  326. })
  327. }
  328. },
  329. setTableH () {
  330. const tableSearchH = this.$refs.tableSearch.offsetHeight
  331. this.tableHeight = window.innerHeight - tableSearchH - 330
  332. }
  333. },
  334. mounted () {
  335. const _this = this
  336. this.$nextTick(() => { // 页面渲染完成后的回调
  337. _this.setTableH()
  338. _this.queryByTypeSum()
  339. })
  340. },
  341. watch: {
  342. advanced (newValue, oldValue) {
  343. const _this = this
  344. setTimeout(() => {
  345. _this.setTableH()
  346. }, 400)
  347. }
  348. }
  349. }
  350. </script>