list.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <a-card size="small" :bordered="false" class="customerSalesDetailsReportList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form-model
  7. id="customerSalesDetailsReportList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="queryParam"
  12. :rules="rules"
  13. :labelCol="labelCol"
  14. :wrapperCol="wrapperCol"
  15. @keyup.enter.native="handleSearch" >
  16. <a-row :gutter="15">
  17. <a-col :md="6" :sm="24">
  18. <a-form-model-item label="审核日期" prop="time">
  19. <rangeDate ref="rangeDate" @change="dateChange" />
  20. </a-form-model-item>
  21. </a-col>
  22. <a-col :md="6" :sm="24">
  23. <a-form-model-item label="客户名称">
  24. <a-input id="customerSalesDetailsReportList-salesTargetName" v-model.trim="queryParam.salesTargetName" allowClear placeholder="请输入客户名称"/>
  25. </a-form-model-item>
  26. </a-col>
  27. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  28. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="customerSalesDetailsReportList-refresh">查询</a-button>
  29. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="customerSalesDetailsReportList-reset">重置</a-button>
  30. <a-button
  31. style="margin-left: 5px"
  32. type="primary"
  33. class="button-warning"
  34. @click="handleExport"
  35. :disabled="disabled"
  36. :loading="exportLoading"
  37. v-if="$hasPermissions('B_customerSalesDetailsReport_export')"
  38. id="customerSalesDetailsReportList-export">导出</a-button>
  39. </a-col>
  40. </a-row>
  41. </a-form-model>
  42. </div>
  43. <!-- 列表 -->
  44. <s-table
  45. class="sTable"
  46. ref="table"
  47. size="small"
  48. :rowKey="(record) => record.targetSn"
  49. :columns="columns"
  50. :data="loadData"
  51. :defaultLoadData="false"
  52. bordered>
  53. <template slot="footer">
  54. <a-row>
  55. <a-col span="2">合计:</a-col>
  56. <a-col span="22">
  57. <a-row>
  58. <a-col span="4">滤清器:{{ (totalData && (totalData.lqqAmount || totalData.lqqAmount==0)) ? toThousands(totalData.lqqAmount) : '--' }}</a-col>
  59. <a-col span="4">雨刮片:{{ (totalData && (totalData.ygpAmount || totalData.ygpAmount==0)) ? toThousands(totalData.ygpAmount) : '--' }}</a-col>
  60. <a-col span="4">刹车片:{{ (totalData && (totalData.scpAmount || totalData.scpAmount==0)) ? toThousands(totalData.scpAmount) : '--' }}</a-col>
  61. <a-col span="4">蓄电池:{{ (totalData && (totalData.xdcAmount || totalData.xdcAmount==0)) ? toThousands(totalData.xdcAmount) : '--' }}</a-col>
  62. <a-col span="4">润滑油:{{ (totalData && (totalData.rhyAmount || totalData.rhyAmount==0)) ? toThousands(totalData.rhyAmount) : '--' }}</a-col>
  63. <a-col span="4">火花塞:{{ (totalData && (totalData.hhsAmount || totalData.hhsAmount==0)) ? toThousands(totalData.hhsAmount) : '--' }}</a-col>
  64. <a-col span="4">点火线圈:{{ (totalData && (totalData.dhxqAmount || totalData.dhxqAmount==0)) ? toThousands(totalData.dhxqAmount) : '--' }}</a-col>
  65. <a-col span="4">LED灯:{{ (totalData && (totalData.ledAmount || totalData.ledAmount==0)) ? toThousands(totalData.ledAmount) : '--' }}</a-col>
  66. <a-col span="4">其他:{{ (totalData && (totalData.otherAmount || totalData.otherAmount==0)) ? toThousands(totalData.otherAmount) : '--' }}</a-col>
  67. <a-col span="4">合计:{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? toThousands(totalData.totalAmount) : '--' }}</a-col>
  68. </a-row>
  69. </a-col>
  70. </a-row>
  71. </template>
  72. </s-table>
  73. </a-spin>
  74. </a-card>
  75. </template>
  76. <script>
  77. import { commonMixin } from '@/utils/mixin'
  78. import { STable, VSelect } from '@/components'
  79. import rangeDate from '@/views/common/rangeDate.vue'
  80. import { downloadExcel } from '@/libs/JGPrint.js'
  81. import { reportCustomerSalesBillDetailList, reportCustomerSalesBillDetailCount, reportCustomerSalesBillDetailExport } from '@/api/reportData'
  82. export default {
  83. mixins: [commonMixin],
  84. components: { STable, VSelect, rangeDate },
  85. data () {
  86. const _this = this
  87. return {
  88. spinning: false,
  89. labelCol: { span: 8 },
  90. wrapperCol: { span: 16 },
  91. tableHeight: 0,
  92. queryParam: { // 查询条件
  93. salesTargetName: '',
  94. time: [],
  95. beginDate: '',
  96. endDate: ''
  97. },
  98. rules: {
  99. 'time': [{ required: true, message: '请选择审核日期', trigger: 'change' }]
  100. },
  101. disabled: false, // 查询、重置按钮是否可操作
  102. exportLoading: false,
  103. columns: [
  104. { title: '客户名称', dataIndex: 'salesTargetName', width: '16%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  105. { title: '滤清器', dataIndex: 'lqqAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  106. { title: '雨刮片', dataIndex: 'ygpAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  107. { title: '刹车片', dataIndex: 'scpAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  108. { title: '蓄电池', dataIndex: 'xdcAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  109. { title: '润滑油', dataIndex: 'rhyAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  110. { title: '火花塞', dataIndex: 'hhsAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  111. { title: '点火线圈', dataIndex: 'dhxqAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  112. { title: 'LED灯', dataIndex: 'ledAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  113. { title: '其他', dataIndex: 'otherAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  114. { title: '合计', dataIndex: 'totalAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  115. ],
  116. // 加载数据方法 必须为 Promise 对象
  117. loadData: parameter => {
  118. this.disabled = true
  119. const params = Object.assign(parameter, this.queryParam)
  120. this.spinning = true
  121. delete params.time
  122. return reportCustomerSalesBillDetailList(params).then(res => {
  123. let data
  124. if (res.status == 200) {
  125. data = res.data
  126. // 总计
  127. this.getCount(params)
  128. this.disabled = false
  129. }
  130. this.spinning = false
  131. return data
  132. })
  133. },
  134. linkageGroupData: [],
  135. totalData: null // 合计
  136. }
  137. },
  138. methods: {
  139. // 创建时间 change
  140. dateChange (date) {
  141. this.queryParam.time = date
  142. this.queryParam.beginDate = date[0] || ''
  143. this.queryParam.endDate = date[1] || ''
  144. },
  145. // 查询
  146. handleSearch () {
  147. this.$refs.ruleForm.validate(valid => {
  148. if (valid) {
  149. this.$refs.table.refresh(true)
  150. } else {
  151. console.log('error submit!!')
  152. return false
  153. }
  154. })
  155. },
  156. // 查询总计
  157. getCount (params) {
  158. reportCustomerSalesBillDetailCount(params).then(res => {
  159. if (res.status == 200 && res.data) {
  160. this.totalData = res.data
  161. } else {
  162. this.totalData = null
  163. }
  164. })
  165. },
  166. // 重置
  167. resetSearchForm () {
  168. this.queryParam.salesTargetName = ''
  169. this.$refs.rangeDate.resetDate()
  170. this.queryParam.time = []
  171. this.queryParam.beginDate = ''
  172. this.queryParam.endDate = ''
  173. this.totalData = null
  174. this.$refs.ruleForm.resetFields()
  175. this.$refs.table.clearTable()
  176. },
  177. // 导出
  178. handleExport () {
  179. const _this = this
  180. this.$refs.ruleForm.validate(valid => {
  181. if (valid) {
  182. const params = _this.queryParam
  183. _this.exportLoading = true
  184. _this.spinning = true
  185. reportCustomerSalesBillDetailExport(params).then(res => {
  186. downloadExcel(res, '客户销售明细报表')
  187. _this.exportLoading = false
  188. _this.spinning = false
  189. })
  190. } else {
  191. return false
  192. }
  193. })
  194. },
  195. pageInit () {}
  196. },
  197. mounted () {
  198. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  199. this.pageInit()
  200. this.resetSearchForm()
  201. }
  202. },
  203. activated () {
  204. // 如果是新页签打开,则重置当前页面
  205. if (this.$store.state.app.isNewTab) {
  206. this.pageInit()
  207. this.resetSearchForm()
  208. }
  209. },
  210. beforeRouteEnter (to, from, next) {
  211. next(vm => {})
  212. }
  213. }
  214. </script>