list.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <div class="jg-page-wrap">
  3. <a-card size="small" :bordered="false" class="table-page-search-wrapper">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="客户名称">
  10. <a-input id="crpnList-settleClientName" v-model.trim="queryParam.settleClientNameCurrent" allowClear placeholder="请输入客户名称"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="单位类型">
  15. <v-select
  16. v-model="queryParam.settleClientType"
  17. ref="settleClientType"
  18. id="crpnList-settleClientType"
  19. code="SETTLE_CLIENT_TYPE"
  20. placeholder="请选择单位类型"
  21. allowClear></v-select>
  22. </a-form-item>
  23. </a-col>
  24. <a-col :md="6" :sm="24">
  25. <span class="table-page-search-submitButtons">
  26. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="crpnList-refresh">查询</a-button>
  27. <a-button style="margin-left: 8px" @click="resetSearchForm()" :disabled="disabled" id="crpnList-reset">重置</a-button>
  28. <a-button
  29. type="primary"
  30. v-if="$hasPermissions('B_collectionPaymentExoprt')"
  31. class="button-warning"
  32. @click="handleExport"
  33. :disabled="disabled"
  34. :loading="exportLoading"
  35. id="companyCollectionPaymentList-export">导出</a-button>
  36. </span>
  37. </a-col>
  38. </a-row>
  39. </a-form>
  40. </div>
  41. </a-card>
  42. <a-card size="small" :bordered="false" class="crpnList-wrap">
  43. <a-spin :spinning="spinning" tip="Loading...">
  44. <!-- 统计 -->
  45. <div class="table-operator">
  46. <div class="alert-message">
  47. 共 <strong>{{ total }}</strong> 条记录,
  48. 应收金额合计 <strong>{{ (productTotal&&(productTotal.receipt || productTotal.receipt==0)) ? toThousands(productTotal.receipt) : '--' }}</strong> ,
  49. 应付金额合计 <strong>{{ (productTotal&&productTotal.pay) ? toThousands(productTotal.pay) : 0 }}</strong>
  50. </div>
  51. </div>
  52. <!-- 列表 -->
  53. <s-table
  54. class="sTable fixPagination"
  55. ref="table"
  56. :style="{ height: tableHeight+84.5+'px' }"
  57. size="small"
  58. :rowKey="(record) => record.no"
  59. rowKeyName="no"
  60. :columns="columns"
  61. :data="loadData"
  62. :scroll="{ y: tableHeight }"
  63. :defaultLoadData="false"
  64. bordered>
  65. <!-- 客户名称 -->
  66. <template slot="customerName" slot-scope="text, record">
  67. <span v-if="record.settleClientType&&record.settleClientType=='CUSTOMER'">{{ record.settleClientNameCurrent||'--' }}</span>
  68. <span v-else>{{ record.settleClientName||'--' }}</span>
  69. </template>
  70. <!-- 操作 -->
  71. <template slot="action" slot-scope="text, record">
  72. <a-button
  73. v-if="$hasPermissions('M_collectionPayment')"
  74. size="small"
  75. type="link"
  76. class="button-primary"
  77. @click="handleCollectionPayment(record)"
  78. :id="'crpnList-collectionPayment-pay-'+record.id">收付款</a-button>
  79. <a-button
  80. size="small"
  81. type="link"
  82. class="button-success"
  83. @click="handleDetail(record)"
  84. :id="'crpnList-collectionPayment-detail-'+record.id"
  85. v-if="$hasPermissions('M_companyReceivablePayable_detail')">详情</a-button>
  86. <span v-if="!$hasPermissions('M_collectionPayment') && !$hasPermissions('M_companyReceivablePayable_detail')">--</span>
  87. </template>
  88. </s-table>
  89. </a-spin>
  90. </a-card>
  91. </div>
  92. </template>
  93. <script>
  94. import { commonMixin } from '@/utils/mixin'
  95. import { downloadExcel } from '@/libs/JGPrint.js'
  96. import { STable, VSelect } from '@/components'
  97. import { settleUnitClientList, settleInfoQuerySum, exportClientUnSettle } from '@/api/settle'
  98. export default {
  99. name: 'CollectionPaymentList',
  100. components: { STable, VSelect },
  101. mixins: [commonMixin],
  102. data () {
  103. const _this = this
  104. return {
  105. spinning: false,
  106. disabled: false, // 查询、重置按钮是否可操作
  107. tableHeight: 0, // 表格高度
  108. exportLoading: false,
  109. // 查询参数
  110. queryParam: {
  111. settleClientNameCurrent: '', // 客户名称
  112. settleClientType: undefined // 单位类型
  113. },
  114. // 表头
  115. columns: [
  116. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  117. { title: '客户名称', width: '20%', align: 'center', scopedSlots: { customRender: 'customerName' } },
  118. { title: '单位类型', dataIndex: 'settleClientTypeDictValue', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  119. { title: '应收金额', dataIndex: 'unSettleAmountReceipt', width: '20%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  120. { title: '应付金额', dataIndex: 'unSettleAmountPay', width: '20%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  121. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  122. ],
  123. // 加载数据方法 必须为 Promise 对象
  124. loadData: parameter => {
  125. this.disabled = true
  126. this.spinning = true
  127. return settleUnitClientList(Object.assign(parameter, this.queryParam)).then(res => {
  128. let data
  129. if (res.status == 200) {
  130. data = res.data
  131. this.getTotal(Object.assign(parameter, this.queryParam))
  132. const no = (data.pageNo - 1) * data.pageSize
  133. for (var i = 0; i < data.list.length; i++) {
  134. data.list[i].no = no + i + 1
  135. // 应付金额 值为负,应显示为正
  136. data.list[i].unSettleAmountPay = Math.abs(data.list[i].unSettleAmountPay) || 0
  137. }
  138. this.disabled = false
  139. this.total = data.count || 0
  140. }
  141. this.spinning = false
  142. return data
  143. })
  144. },
  145. total: 0, // 总条数
  146. productTotal: null // 金额统计
  147. }
  148. },
  149. methods: {
  150. // 导出
  151. handleExport () {
  152. const _this = this
  153. const params = this.queryParam
  154. this.exportLoading = true
  155. _this.spinning = true
  156. exportClientUnSettle(params).then(res => {
  157. this.exportLoading = false
  158. _this.spinning = false
  159. downloadExcel(res, '单位收付款客户')
  160. })
  161. },
  162. // 详情
  163. handleDetail (row) {
  164. const clientName = row.settleClientType == 'CUSTOMER' ? row.settleClientNameCurrent : row.settleClientName
  165. this.$router.push({ name: 'companyReceivablePayableNewDetail', params: { sn: row.settleClientSn, name: clientName, type: row.settleClientType } })
  166. },
  167. // 金额合计
  168. getTotal (param) {
  169. settleInfoQuerySum(param).then(res => {
  170. if (res.status == 200 && res.data) {
  171. this.productTotal = res.data
  172. } else {
  173. this.productTotal = null
  174. }
  175. })
  176. },
  177. // 去收付款
  178. handleCollectionPayment (row) {
  179. const clientName = row.settleClientType == 'CUSTOMER' ? row.settleClientNameCurrent : row.settleClientName
  180. this.$router.push({ name: 'companyReceivablePayableNewCollectionPayment', params: { sn: row.settleClientSn, name: clientName, type: row.settleClientType } })
  181. },
  182. // 重置
  183. resetSearchForm () {
  184. this.queryParam.settleClientNameCurrent = ''
  185. this.queryParam.settleClientType = undefined
  186. this.$refs.table.refresh(true)
  187. },
  188. // 初始化
  189. pageInit () {
  190. const _this = this
  191. this.$nextTick(() => { // 页面渲染完成后的回调
  192. _this.setTableH()
  193. })
  194. },
  195. // 计算表格高度
  196. setTableH () {
  197. const tableSearchH = this.$refs.tableSearch.offsetHeight
  198. this.tableHeight = window.innerHeight - tableSearchH - 265
  199. }
  200. },
  201. watch: {
  202. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  203. this.setTableH()
  204. }
  205. },
  206. mounted () {
  207. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  208. this.pageInit()
  209. this.resetSearchForm()
  210. }
  211. },
  212. activated () {
  213. // 如果是新页签打开,则重置当前页面
  214. if (this.$store.state.app.isNewTab) {
  215. this.pageInit()
  216. this.resetSearchForm()
  217. }
  218. // 仅刷新列表,不重置页面
  219. if (this.$store.state.app.updateList) {
  220. this.pageInit()
  221. this.$refs.table.refresh()
  222. }
  223. },
  224. beforeRouteEnter (to, from, next) {
  225. next(vm => {})
  226. }
  227. }
  228. </script>
  229. <style lang="less">
  230. .crpnList-wrap{
  231. .sTable{
  232. margin-top: 10px;
  233. }
  234. }
  235. </style>