list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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. rowKeyName="targetSn"
  50. :columns="columns"
  51. :data="loadData"
  52. :defaultLoadData="false"
  53. bordered>
  54. <template slot="footer">
  55. <a-row>
  56. <a-col span="2">合计:</a-col>
  57. <a-col span="22">
  58. <a-row>
  59. <a-col span="4">滤清器:{{ (totalData && (totalData.lqqAmount || totalData.lqqAmount==0)) ? toThousands(totalData.lqqAmount) : '--' }}</a-col>
  60. <a-col span="4">雨刮片:{{ (totalData && (totalData.ygpAmount || totalData.ygpAmount==0)) ? toThousands(totalData.ygpAmount) : '--' }}</a-col>
  61. <a-col span="4">刹车片:{{ (totalData && (totalData.scpAmount || totalData.scpAmount==0)) ? toThousands(totalData.scpAmount) : '--' }}</a-col>
  62. <a-col span="4">蓄电池:{{ (totalData && (totalData.xdcAmount || totalData.xdcAmount==0)) ? toThousands(totalData.xdcAmount) : '--' }}</a-col>
  63. <a-col span="4">火花塞:{{ (totalData && (totalData.hhsAmount || totalData.hhsAmount==0)) ? toThousands(totalData.hhsAmount) : '--' }}</a-col>
  64. <a-col span="4">LED灯:{{ (totalData && (totalData.ledAmount || totalData.ledAmount==0)) ? toThousands(totalData.ledAmount) : '--' }}</a-col>
  65. <a-col span="4">防冻液:{{ (totalData && (totalData.fdyAmount || totalData.fdyAmount==0)) ? toThousands(totalData.fdyAmount) : '--' }}</a-col>
  66. <a-col span="4">点火线圈:{{ (totalData && (totalData.dhxqAmount || totalData.dhxqAmount==0)) ? toThousands(totalData.dhxqAmount) : '--' }}</a-col>
  67. <a-col span="4">润滑油:{{ (totalData && (totalData.rhyAmount || totalData.rhyAmount==0)) ? toThousands(totalData.rhyAmount) : '--' }}</a-col>
  68. <a-col span="4">变速箱油:{{ (totalData && (totalData.bsxyAmount || totalData.bsxyAmount==0)) ? toThousands(totalData.bsxyAmount) : '--' }}</a-col>
  69. <a-col span="4">刹车油:{{ (totalData && (totalData.scyAmount || totalData.scyAmount==0)) ? toThousands(totalData.scyAmount) : '--' }}</a-col>
  70. <a-col span="4">皮带:{{ (totalData && (totalData.pdAmount || totalData.pdAmount==0)) ? toThousands(totalData.pdAmount) : '--' }}</a-col>
  71. <a-col span="4">轮子:{{ (totalData && (totalData.lzAmount || totalData.lzAmount==0)) ? toThousands(totalData.lzAmount) : '--' }}</a-col>
  72. <a-col span="4">轮胎:{{ (totalData && (totalData.ltAmount || totalData.ltAmount==0)) ? toThousands(totalData.ltAmount) : '--' }}</a-col>
  73. <a-col span="4">其他:{{ (totalData && (totalData.otherAmount || totalData.otherAmount==0)) ? toThousands(totalData.otherAmount) : '--' }}</a-col>
  74. <a-col span="4">合计:{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? toThousands(totalData.totalAmount) : '--' }}</a-col>
  75. </a-row>
  76. </a-col>
  77. </a-row>
  78. </template>
  79. </s-table>
  80. </a-spin>
  81. </a-card>
  82. </template>
  83. <script>
  84. import { commonMixin } from '@/utils/mixin'
  85. import { STable, VSelect } from '@/components'
  86. import rangeDate from '@/views/common/rangeDate.vue'
  87. import { downloadExcel } from '@/libs/JGPrint.js'
  88. import custList from '@/views/common/custList.vue'
  89. import { reportCustomerSalesBillDetailList, reportCustomerSalesBillDetailCount, reportCustomerSalesBillDetailExport } from '@/api/reportData'
  90. export default {
  91. mixins: [commonMixin],
  92. components: { STable, VSelect, rangeDate, custList },
  93. data () {
  94. const _this = this
  95. return {
  96. spinning: false,
  97. labelCol: { span: 8 },
  98. wrapperCol: { span: 16 },
  99. tableHeight: 0,
  100. queryParam: { // 查询条件
  101. buyerNameCurrent: undefined, // 客户名称
  102. buyerSnCurrent: undefined, // 客户sn
  103. time: [],
  104. beginDate: '',
  105. endDate: ''
  106. },
  107. rules: {
  108. 'time': [{ required: true, message: '请选择审核日期', trigger: 'change' }]
  109. },
  110. disabled: false, // 查询、重置按钮是否可操作
  111. exportLoading: false,
  112. columns: [
  113. { title: '客户名称', dataIndex: 'salesTargetName', width: '16%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  114. {
  115. title: '所有品牌',
  116. children: [
  117. { title: '滤清器', dataIndex: 'lqqAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  118. { title: '雨刮片', dataIndex: 'ygpAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  119. { title: '刹车制动系统', dataIndex: 'scpAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  120. { title: '蓄电池', dataIndex: 'xdcAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  121. // { title: '火花塞', dataIndex: 'hhsAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  122. { title: 'LED灯', dataIndex: 'ledAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  123. ]
  124. },
  125. {
  126. title: '稳升',
  127. children: [
  128. { title: '点火线圈', dataIndex: 'dhxqAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  129. ]
  130. },
  131. {
  132. title: '德路斯、TBU',
  133. children: [
  134. { title: '润滑油', dataIndex: 'rhyAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  135. { title: '变速箱油', dataIndex: 'bsxyAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  136. { title: '刹车油', dataIndex: 'scyAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  137. ]
  138. },
  139. {
  140. title: '火花塞',
  141. children: [
  142. { title: 'NGK', dataIndex: 'hhsNgkAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  143. { title: '中冠', dataIndex: 'hhsZgAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  144. ]
  145. },
  146. {
  147. title: '轮胎',
  148. children: [
  149. { title: '箭冠', dataIndex: 'ltAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  150. ]
  151. },
  152. {
  153. title: '防冻液',
  154. children: [
  155. { title: '酷兰德', dataIndex: 'fdyAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  156. ]
  157. },
  158. { title: '皮带', dataIndex: 'pdAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  159. { title: '轮子', dataIndex: 'lzAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  160. { title: '其他', dataIndex: 'otherAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  161. { title: '合计', dataIndex: 'totalAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  162. ],
  163. // 加载数据方法 必须为 Promise 对象
  164. loadData: parameter => {
  165. this.disabled = true
  166. const params = Object.assign(parameter, this.queryParam)
  167. this.spinning = true
  168. delete params.time
  169. return reportCustomerSalesBillDetailList(params).then(res => {
  170. let data
  171. if (res.status == 200) {
  172. data = res.data
  173. // 总计
  174. this.getCount(params)
  175. this.disabled = false
  176. }
  177. this.spinning = false
  178. return data
  179. })
  180. },
  181. linkageGroupData: [],
  182. totalData: null // 合计
  183. }
  184. },
  185. methods: {
  186. // 创建时间 change
  187. dateChange (date) {
  188. this.queryParam.time = date
  189. this.queryParam.beginDate = date[0] || ''
  190. this.queryParam.endDate = date[1] || ''
  191. },
  192. // 查询
  193. handleSearch () {
  194. this.$refs.ruleForm.validate(valid => {
  195. if (valid) {
  196. this.$refs.table.refresh(true)
  197. } else {
  198. console.log('error submit!!')
  199. return false
  200. }
  201. })
  202. },
  203. // 查询总计
  204. getCount (params) {
  205. reportCustomerSalesBillDetailCount(params).then(res => {
  206. if (res.status == 200 && res.data) {
  207. res.data.hhsAmount = res.data.hhsNgkAmount * 1 + res.data.hhsZgAmount * 1
  208. this.totalData = res.data
  209. } else {
  210. this.totalData = null
  211. }
  212. })
  213. },
  214. custSatelliteChange (v, row) {
  215. if (row && row.customerSn) {
  216. this.queryParam.buyerSnCurrent = row.customerSn
  217. this.queryParam.buyerNameCurrent = undefined
  218. } else {
  219. this.queryParam.buyerNameCurrent = v
  220. this.queryParam.buyerSnCurrent = undefined
  221. }
  222. },
  223. // 重置
  224. resetSearchForm () {
  225. this.queryParam.buyerNameCurrent = undefined
  226. this.queryParam.buyerSnCurrent = undefined
  227. this.$refs.rangeDate.resetDate()
  228. this.queryParam.time = []
  229. this.queryParam.beginDate = ''
  230. this.queryParam.endDate = ''
  231. this.totalData = null
  232. this.$refs.custSatelliteList.resetForm()
  233. this.$refs.ruleForm.resetFields()
  234. this.$refs.table.clearTable()
  235. },
  236. // 导出
  237. handleExport () {
  238. const _this = this
  239. this.$refs.ruleForm.validate(valid => {
  240. if (valid) {
  241. const params = _this.queryParam
  242. _this.exportLoading = true
  243. _this.spinning = true
  244. reportCustomerSalesBillDetailExport(params).then(res => {
  245. downloadExcel(res, '客户销售明细报表')
  246. _this.exportLoading = false
  247. _this.spinning = false
  248. })
  249. } else {
  250. return false
  251. }
  252. })
  253. },
  254. pageInit () {}
  255. },
  256. mounted () {
  257. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  258. this.pageInit()
  259. this.resetSearchForm()
  260. }
  261. },
  262. activated () {
  263. // 如果是新页签打开,则重置当前页面
  264. if (this.$store.state.app.isNewTab) {
  265. this.pageInit()
  266. this.resetSearchForm()
  267. }
  268. },
  269. beforeRouteEnter (to, from, next) {
  270. next(vm => {})
  271. }
  272. }
  273. </script>