list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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: 'no', width: '5%', align: 'center' },
  114. { title: '客户名称', dataIndex: 'salesTargetName', width: '16%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  115. {
  116. title: '所有品牌',
  117. children: [
  118. { title: '滤清器', dataIndex: 'lqqAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  119. { title: '雨刮片', dataIndex: 'ygpAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  120. { title: '刹车制动系统', dataIndex: 'scpAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  121. { title: '蓄电池', dataIndex: 'xdcAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  122. // { title: '火花塞', dataIndex: 'hhsAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  123. { title: 'LED灯', dataIndex: 'ledAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  124. ]
  125. },
  126. {
  127. title: '稳升',
  128. children: [
  129. { title: '点火线圈', dataIndex: 'dhxqAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  130. ]
  131. },
  132. {
  133. title: '德路斯、TBU',
  134. children: [
  135. { title: '润滑油', dataIndex: 'rhyAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  136. { title: '变速箱油', dataIndex: 'bsxyAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  137. { title: '刹车油', dataIndex: 'scyAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  138. ]
  139. },
  140. {
  141. title: '火花塞',
  142. children: [
  143. { title: 'NGK', dataIndex: 'hhsNgkAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  144. { title: '中冠', dataIndex: 'hhsZgAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  145. ]
  146. },
  147. {
  148. title: '轮胎',
  149. children: [
  150. { title: '箭冠', dataIndex: 'ltAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  151. ]
  152. },
  153. {
  154. title: '防冻液',
  155. children: [
  156. { title: '酷兰德', dataIndex: 'fdyAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  157. ]
  158. },
  159. { title: '皮带', dataIndex: 'pdAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  160. { title: '轮子', dataIndex: 'lzAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  161. { title: '其他', dataIndex: 'otherAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  162. { title: '合计', dataIndex: 'totalAmount', width: '8.4%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  163. ],
  164. // 加载数据方法 必须为 Promise 对象
  165. loadData: parameter => {
  166. this.disabled = true
  167. const params = Object.assign(parameter, this.queryParam)
  168. this.spinning = true
  169. delete params.time
  170. return reportCustomerSalesBillDetailList(params).then(res => {
  171. let data
  172. if (res.status == 200) {
  173. data = res.data
  174. // 总计
  175. this.getCount(params)
  176. const no = (data.pageNo - 1) * data.pageSize
  177. for (var i = 0; i < data.list.length; i++) {
  178. data.list[i].no = no + i + 1
  179. }
  180. this.disabled = false
  181. }
  182. this.spinning = false
  183. return data
  184. })
  185. },
  186. linkageGroupData: [],
  187. totalData: null // 合计
  188. }
  189. },
  190. methods: {
  191. // 创建时间 change
  192. dateChange (date) {
  193. this.queryParam.time = date
  194. this.queryParam.beginDate = date[0] || ''
  195. this.queryParam.endDate = date[1] || ''
  196. },
  197. // 查询
  198. handleSearch () {
  199. this.$refs.ruleForm.validate(valid => {
  200. if (valid) {
  201. this.$refs.table.refresh(true)
  202. } else {
  203. console.log('error submit!!')
  204. return false
  205. }
  206. })
  207. },
  208. // 查询总计
  209. getCount (params) {
  210. reportCustomerSalesBillDetailCount(params).then(res => {
  211. if (res.status == 200 && res.data) {
  212. res.data.hhsAmount = res.data.hhsNgkAmount * 1 + res.data.hhsZgAmount * 1
  213. this.totalData = res.data
  214. } else {
  215. this.totalData = null
  216. }
  217. })
  218. },
  219. custSatelliteChange (v, row) {
  220. if (row && row.customerSn) {
  221. this.queryParam.buyerSnCurrent = row.customerSn
  222. this.queryParam.buyerNameCurrent = undefined
  223. } else {
  224. this.queryParam.buyerNameCurrent = v
  225. this.queryParam.buyerSnCurrent = undefined
  226. }
  227. },
  228. // 重置
  229. resetSearchForm () {
  230. this.queryParam.buyerNameCurrent = undefined
  231. this.queryParam.buyerSnCurrent = undefined
  232. this.$refs.rangeDate.resetDate()
  233. this.queryParam.time = []
  234. this.queryParam.beginDate = ''
  235. this.queryParam.endDate = ''
  236. this.totalData = null
  237. this.$refs.custSatelliteList.resetForm()
  238. this.$refs.ruleForm.resetFields()
  239. this.$refs.table.clearTable()
  240. },
  241. // 导出
  242. handleExport () {
  243. const _this = this
  244. this.$refs.ruleForm.validate(valid => {
  245. if (valid) {
  246. const params = _this.queryParam
  247. _this.exportLoading = true
  248. _this.spinning = true
  249. reportCustomerSalesBillDetailExport(params).then(res => {
  250. downloadExcel(res, '客户销售明细报表')
  251. _this.exportLoading = false
  252. _this.spinning = false
  253. })
  254. } else {
  255. return false
  256. }
  257. })
  258. },
  259. pageInit () {}
  260. },
  261. mounted () {
  262. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  263. this.pageInit()
  264. this.resetSearchForm()
  265. }
  266. },
  267. activated () {
  268. // 如果是新页签打开,则重置当前页面
  269. if (this.$store.state.app.isNewTab) {
  270. this.pageInit()
  271. this.resetSearchForm()
  272. }
  273. },
  274. beforeRouteEnter (to, from, next) {
  275. next(vm => {})
  276. }
  277. }
  278. </script>