list.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <a-card size="small" :bordered="false" class="ledgerRecordList-wrap">
  3. <!-- 搜索条件 -->
  4. <div ref="tableSearch" class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="分账时间">
  9. <rangeDate ref="rangeDate" :value="createDate" @change="dateChange" />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="客户名称">
  14. <custSatelliteList ref="custSatelliteList" @change="custSatelliteChange"></custSatelliteList>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="产品名称">
  19. <a-input id="ledgerRecordList-name" v-model.trim="queryParam.dealerProduct.name" allowClear placeholder="请输入产品名称"/>
  20. </a-form-item>
  21. </a-col>
  22. <template v-if="advanced">
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="产品编码">
  25. <a-input id="ledgerRecordList-code" v-model.trim="queryParam.dealerProduct.code" allowClear placeholder="请输入产品编码"/>
  26. </a-form-item>
  27. </a-col>
  28. </template>
  29. <a-col :md="6" :sm="24">
  30. <span class="table-page-search-submitButtons">
  31. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="ledgerRecordList-refresh">查询</a-button>
  32. <a-button style="margin-left: 8px" @click="resetSearchForm()" :disabled="disabled" id="ledgerRecordList-reset">重置</a-button>
  33. <a @click="advanced=!advanced" style="margin-left: 8px">
  34. {{ advanced ? '收起' : '展开' }}
  35. <a-icon :type="advanced ? 'up' : 'down'"/>
  36. </a>
  37. </span>
  38. </a-col>
  39. </a-row>
  40. </a-form>
  41. </div>
  42. <!-- alert -->
  43. <a-alert type="info" style="margin-bottom:10px">
  44. <div slot="message">
  45. 总计:<strong>{{ total }}</strong>条 ,
  46. 分账金额:<strong>{{ (totalAmount || totalAmount == 0) ? totalAmount+'元' : '--' }}</strong>
  47. </div>
  48. </a-alert>
  49. <!-- 列表 -->
  50. <s-table
  51. class="sTable fixPagination"
  52. ref="table"
  53. :style="{ height: tableHeight+84.5+'px' }"
  54. size="small"
  55. :rowKey="(record) => record.id"
  56. :columns="columns"
  57. :data="loadData"
  58. :scroll="{ x: 1690 }"
  59. :defaultLoadData="false"
  60. bordered>
  61. </s-table>
  62. </a-card>
  63. </template>
  64. <script>
  65. import getDate from '@/libs/getDate.js'
  66. import { STable, VSelect } from '@/components'
  67. import rangeDate from '@/views/common/rangeDate.vue'
  68. import custSatelliteList from '@/views/common/custSatelliteList.vue'
  69. import { satelliteWHSeparateList, satelliteWHSeparateTotal } from '@/api/satelliteWH'
  70. export default {
  71. components: { STable, VSelect, rangeDate, custSatelliteList },
  72. data () {
  73. return {
  74. advanced: true, // 高级搜索 展开/关闭
  75. disabled: false, // 查询、重置按钮是否可操作
  76. tableHeight: 0,
  77. createDate: [
  78. getDate.getRecentday().starttime,
  79. getDate.getRecentday().endtime
  80. ],
  81. // 查询参数
  82. queryParam: {
  83. customer: {
  84. customerSn: undefined
  85. },
  86. dealerProduct: {
  87. name: '',
  88. code: ''
  89. },
  90. beginDate: getDate.getRecentday().starttime + ' 00:00:00',
  91. endDate: getDate.getRecentday().endtime + ' 23:59:59'
  92. },
  93. // 表头
  94. columns: [
  95. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  96. { title: '分账时间', dataIndex: 'separateTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  97. { title: '客户名称', dataIndex: 'customer.customerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  98. { title: '关联工单号', dataIndex: 'separateBizNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  99. { title: '产品名称', dataIndex: 'dealerProduct.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  100. { title: '产品编码', dataIndex: 'dealerProduct.code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  101. { title: '数量', dataIndex: 'productQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  102. { title: '分账金额(¥)', dataIndex: 'separateAmount', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  103. { title: '分账状态', dataIndex: 'stateDictValue', width: 150, align: 'center', customRender: function (text) { return text || '--' } },
  104. { title: '备注', dataIndex: 'remark', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
  105. ],
  106. // 加载数据方法 必须为 Promise 对象
  107. loadData: parameter => {
  108. this.disabled = true
  109. this.spinning = true
  110. return satelliteWHSeparateList(Object.assign(parameter, this.queryParam)).then(res => {
  111. let data
  112. if (res.status == 200) {
  113. data = res.data
  114. const no = (data.pageNo - 1) * data.pageSize
  115. for (var i = 0; i < data.list.length; i++) {
  116. data.list[i].no = no + i + 1
  117. }
  118. this.disabled = false
  119. this.total = data.count || 0
  120. this.getTotal(Object.assign(parameter, this.queryParam))
  121. }
  122. this.spinning = false
  123. return data
  124. })
  125. },
  126. total: 0, // 总条数
  127. totalAmount: ''
  128. }
  129. },
  130. methods: {
  131. // 时间 change
  132. dateChange (date) {
  133. this.queryParam.beginDate = date[0] ? date[0] + ' 00:00:00' : ''
  134. this.queryParam.endDate = date[1] ? date[1] + ' 23:59:59' : ''
  135. },
  136. // 合计
  137. getTotal (params) {
  138. satelliteWHSeparateTotal(params).then(res => {
  139. if (res.status == 200) {
  140. this.totalAmount = res.data
  141. } else {
  142. this.totalAmount = ''
  143. }
  144. })
  145. },
  146. custSatelliteChange (val) {
  147. this.queryParam.customer.customerSn = val.key
  148. },
  149. // 重置
  150. resetSearchForm () {
  151. this.$refs.rangeDate.resetDate(this.createDate)
  152. this.queryParam.beginDate = getDate.getRecentday().starttime + ' 00:00:00'
  153. this.queryParam.endDate = getDate.getRecentday().endtime + ' 23:59:59'
  154. this.queryParam.customer.customerSn = undefined
  155. this.queryParam.dealerProduct.name = ''
  156. this.queryParam.dealerProduct.code = ''
  157. this.$refs.custSatelliteList.resetForm()
  158. this.$refs.table.refresh(true)
  159. },
  160. pageInit () {
  161. const _this = this
  162. this.$nextTick(() => { // 页面渲染完成后的回调
  163. _this.setTableH()
  164. })
  165. },
  166. setTableH () {
  167. const tableSearchH = this.$refs.tableSearch.offsetHeight
  168. this.tableHeight = window.innerHeight - tableSearchH - 230
  169. }
  170. },
  171. watch: {
  172. advanced (newValue, oldValue) {
  173. const _this = this
  174. this.$nextTick(() => { // 页面渲染完成后的回调
  175. _this.setTableH()
  176. })
  177. },
  178. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  179. this.setTableH()
  180. }
  181. },
  182. mounted () {
  183. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  184. this.pageInit()
  185. this.resetSearchForm()
  186. }
  187. },
  188. activated () {
  189. // 如果是新页签打开,则重置当前页面
  190. if (this.$store.state.app.isNewTab) {
  191. this.pageInit()
  192. this.resetSearchForm()
  193. }
  194. },
  195. beforeRouteEnter (to, from, next) {
  196. next(vm => {})
  197. }
  198. }
  199. </script>