list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. <custList id="customerSalesDetailsReportList-salesTargetName" ref="custSatelliteList" @change="custSatelliteChange"></custList>
  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 custList from '@/views/common/custList.vue'
  82. import { reportCustomerSalesBillDetailList, reportCustomerSalesBillDetailCount, reportCustomerSalesBillDetailExport } from '@/api/reportData'
  83. export default {
  84. mixins: [commonMixin],
  85. components: { STable, VSelect, rangeDate, custList },
  86. data () {
  87. const _this = this
  88. return {
  89. spinning: false,
  90. labelCol: { span: 8 },
  91. wrapperCol: { span: 16 },
  92. tableHeight: 0,
  93. queryParam: { // 查询条件
  94. buyerNameCurrent: undefined, // 客户名称
  95. buyerSnCurrent: undefined, // 客户sn
  96. time: [],
  97. beginDate: '',
  98. endDate: ''
  99. },
  100. rules: {
  101. 'time': [{ required: true, message: '请选择审核日期', trigger: 'change' }]
  102. },
  103. disabled: false, // 查询、重置按钮是否可操作
  104. exportLoading: false,
  105. columns: [
  106. { title: '客户名称', dataIndex: 'salesTargetName', width: '16%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  107. { title: '滤清器', dataIndex: 'lqqAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  108. { title: '雨刮片', dataIndex: 'ygpAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  109. { title: '刹车片', dataIndex: 'scpAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  110. { title: '蓄电池', dataIndex: 'xdcAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  111. { title: '润滑油', dataIndex: 'rhyAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  112. { title: '火花塞', dataIndex: 'hhsAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  113. { title: '点火线圈', dataIndex: 'dhxqAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  114. { title: 'LED灯', dataIndex: 'ledAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  115. { title: '其他', dataIndex: 'otherAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  116. { title: '合计', dataIndex: 'totalAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  117. ],
  118. // 加载数据方法 必须为 Promise 对象
  119. loadData: parameter => {
  120. this.disabled = true
  121. const params = Object.assign(parameter, this.queryParam)
  122. this.spinning = true
  123. delete params.time
  124. return reportCustomerSalesBillDetailList(params).then(res => {
  125. let data
  126. if (res.status == 200) {
  127. data = res.data
  128. // 总计
  129. this.getCount(params)
  130. this.disabled = false
  131. }
  132. this.spinning = false
  133. return data
  134. })
  135. },
  136. linkageGroupData: [],
  137. totalData: null // 合计
  138. }
  139. },
  140. methods: {
  141. // 创建时间 change
  142. dateChange (date) {
  143. this.queryParam.time = date
  144. this.queryParam.beginDate = date[0] || ''
  145. this.queryParam.endDate = date[1] || ''
  146. },
  147. // 查询
  148. handleSearch () {
  149. this.$refs.ruleForm.validate(valid => {
  150. if (valid) {
  151. this.$refs.table.refresh(true)
  152. } else {
  153. console.log('error submit!!')
  154. return false
  155. }
  156. })
  157. },
  158. // 查询总计
  159. getCount (params) {
  160. reportCustomerSalesBillDetailCount(params).then(res => {
  161. if (res.status == 200 && res.data) {
  162. this.totalData = res.data
  163. } else {
  164. this.totalData = null
  165. }
  166. })
  167. },
  168. custSatelliteChange (v, row) {
  169. if (row && row.customerSn) {
  170. this.queryParam.buyerSnCurrent = row.customerSn
  171. this.queryParam.buyerNameCurrent = undefined
  172. } else {
  173. this.queryParam.buyerNameCurrent = v
  174. this.queryParam.buyerSnCurrent = undefined
  175. }
  176. },
  177. // 重置
  178. resetSearchForm () {
  179. this.queryParam.buyerNameCurrent = undefined
  180. this.queryParam.buyerSnCurrent = undefined
  181. this.$refs.rangeDate.resetDate()
  182. this.queryParam.time = []
  183. this.queryParam.beginDate = ''
  184. this.queryParam.endDate = ''
  185. this.totalData = null
  186. this.$refs.custSatelliteList.resetForm()
  187. this.$refs.ruleForm.resetFields()
  188. this.$refs.table.clearTable()
  189. },
  190. // 导出
  191. handleExport () {
  192. const _this = this
  193. this.$refs.ruleForm.validate(valid => {
  194. if (valid) {
  195. const params = _this.queryParam
  196. _this.exportLoading = true
  197. _this.spinning = true
  198. reportCustomerSalesBillDetailExport(params).then(res => {
  199. downloadExcel(res, '客户销售明细报表')
  200. _this.exportLoading = false
  201. _this.spinning = false
  202. })
  203. } else {
  204. return false
  205. }
  206. })
  207. },
  208. pageInit () {}
  209. },
  210. mounted () {
  211. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  212. this.pageInit()
  213. this.resetSearchForm()
  214. }
  215. },
  216. activated () {
  217. // 如果是新页签打开,则重置当前页面
  218. if (this.$store.state.app.isNewTab) {
  219. this.pageInit()
  220. this.resetSearchForm()
  221. }
  222. },
  223. beforeRouteEnter (to, from, next) {
  224. next(vm => {})
  225. }
  226. }
  227. </script>