list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <a-card size="small" :bordered="false" class="salesSlipReportList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form-model
  7. id="salesSlipReportList-form"
  8. layout="inline"
  9. ref="ruleForm"
  10. :model="queryParam"
  11. :rules="rules"
  12. @keyup.enter.native="$refs.table.refresh(true)">
  13. <a-row :gutter="15">
  14. <a-col :md="6" :sm="24">
  15. <a-form-model-item label="销售日期" prop="time">
  16. <rangeDate ref="rangeDate" :value="queryParam.time" @change="dateChange" />
  17. </a-form-model-item>
  18. </a-col>
  19. <a-col :md="6" :sm="24">
  20. <a-form-model-item label="客户名称">
  21. <custList id="salesSlipReportList-allocateTypeSn" ref="custList" @change="custChange"></custList>
  22. </a-form-model-item>
  23. </a-col>
  24. <a-col :md="6" :sm="24">
  25. <a-form-model-item label="客户类型">
  26. <v-select
  27. v-model="queryParam.dealer.dealerLevel"
  28. ref="dealerLevel"
  29. id="salesSlipReportList-allocateTypeSn"
  30. code="DEALER_LEVEL"
  31. placeholder="请选择客户类型"
  32. allowClear></v-select>
  33. </a-form-model-item>
  34. </a-col>
  35. <template v-if="advanced">
  36. <a-col :md="6" :sm="24">
  37. <a-form-model-item label="销售单号">
  38. <a-input id="salesSlipReportList-allocateTypeSn" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  39. </a-form-model-item>
  40. </a-col>
  41. <a-col :md="6" :sm="24">
  42. <a-form-model-item label="所在区域">
  43. <subarea id="salesSlipReportList-allocateTypeSn" v-model="queryParam.dealer.subareaSn"></subarea>
  44. </a-form-model-item>
  45. </a-col>
  46. <a-col :md="12" :sm="24">
  47. <a-row>
  48. <a-form-model-item label="地区">
  49. <a-col span="7">
  50. <a-form-model-item prop="dealerProvinceSn" style="margin: 0;">
  51. <a-select v-model="queryParam.dealer.provinceSn" allowClear @change="getCityList" placeholder="请选择省">
  52. <a-select-option v-for="item in addrProvinceList" :value="item.id" :key="item.id + 'a'">{{ item.name }}</a-select-option>
  53. </a-select>
  54. </a-form-model-item>
  55. </a-col>
  56. <a-col span="7" offset="1">
  57. <a-form-model-item prop="dealerCitySn" style="margin: 0;">
  58. <a-select v-model="queryParam.dealer.citySn" allowClear @change="getAreaList" placeholder="请选择市">
  59. <a-select-option v-for="item in addrCityList" :value="item.id" :key="item.id + 'b'">{{ item.name }}</a-select-option>
  60. </a-select>
  61. </a-form-model-item>
  62. </a-col>
  63. <a-col span="7" offset="1">
  64. <a-form-model-item prop="dealerCountySn" style="margin: 0;">
  65. <a-select v-model="queryParam.dealer.districtSn" allowClear placeholder="请选择区/县">
  66. <a-select-option v-for="item in addrDistrictList" :value="item.id" :key="item.id + 'c'">{{ item.name }}</a-select-option>
  67. </a-select>
  68. </a-form-model-item>
  69. </a-col>
  70. </a-form-model-item>
  71. </a-row>
  72. </a-col>
  73. </template>
  74. <a-col :md="6" :sm="24">
  75. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="salesSlipReportList-refresh">查询</a-button>
  76. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="salesSlipReportList-reset">重置</a-button>
  77. <a @click="advanced=!advanced" style="margin-left: 8px">
  78. {{ advanced ? '收起' : '展开' }}
  79. <a-icon :type="advanced ? 'up' : 'down'"/>
  80. </a>
  81. </a-col>
  82. </a-row>
  83. </a-form-model>
  84. </div>
  85. <!-- 列表 -->
  86. <s-table
  87. class="sTable"
  88. ref="table"
  89. size="small"
  90. :defaultLoadData="false"
  91. :rowKey="(record) => record.id"
  92. :columns="columns"
  93. :data="loadData"
  94. :scroll="{ x: 3220 }"
  95. bordered>
  96. </s-table>
  97. </a-spin>
  98. </a-card>
  99. </template>
  100. <script>
  101. import { STable, VSelect } from '@/components'
  102. import rangeDate from '@/views/common/rangeDate.vue'
  103. import custList from '@/views/common/custList.vue'
  104. import subarea from '@/views/common/subarea.js'
  105. import { getArea } from '@/api/data'
  106. import { salesBillReportList } from '@/api/salesBillReport'
  107. export default {
  108. components: { STable, VSelect, rangeDate, subarea, custList },
  109. data () {
  110. return {
  111. spinning: false,
  112. advanced: false, // 高级搜索 展开/关闭
  113. tableHeight: 0,
  114. queryParam: { // 查询条件
  115. time: [],
  116. beginDate: '',
  117. endDate: '',
  118. salesBillNo: '', // 销售单号
  119. dealer: {
  120. 'dealerSn': undefined,
  121. 'provinceSn': undefined,
  122. 'citySn': undefined,
  123. 'districtSn': undefined,
  124. 'subareaSn': undefined,
  125. 'dealerLevel': undefined
  126. }
  127. },
  128. rules: {
  129. 'time': [{ required: true, message: '请选择销售日期', trigger: 'change' }]
  130. },
  131. disabled: false, // 查询、重置按钮是否可操作
  132. exportLoading: false,
  133. columns: [
  134. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  135. { title: '区域', dataIndex: 'dealer.subareaNameSet', width: 220, align: 'center', customRender: function (text) { return text.join('/') || '--' } },
  136. { title: '销售单号', dataIndex: 'salesBillNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  137. { title: '省份', dataIndex: 'dealer.provinceName', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  138. { title: '客户名称', dataIndex: 'dealer.dealerName', align: 'center', customRender: function (text) { return text || '--' } },
  139. { title: '客户类型', dataIndex: 'dealer.dealerLevelDictValue', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  140. { title: '品牌',
  141. align: 'center',
  142. children: [
  143. {
  144. title: '箭牌',
  145. align: 'center',
  146. children: [
  147. {
  148. title: '滤清器',
  149. dataIndex: 'jpLqqAmount',
  150. align: 'center',
  151. width: 100,
  152. customRender: function (text) { return text ? ('¥' + text) : '0' }
  153. },
  154. {
  155. title: '雨刮片',
  156. dataIndex: 'jpYgpAmount',
  157. align: 'center',
  158. width: 100,
  159. customRender: function (text) { return text ? ('¥' + text) : '0' }
  160. },
  161. {
  162. title: '喇叭',
  163. dataIndex: 'jpLbAmount',
  164. align: 'center',
  165. width: 100,
  166. customRender: function (text) { return text ? ('¥' + text) : '0' }
  167. },
  168. {
  169. title: '刹车片',
  170. dataIndex: 'pp4',
  171. align: 'jpScpAmount',
  172. width: 100,
  173. customRender: function (text) { return text ? ('¥' + text) : '0' }
  174. },
  175. {
  176. title: '感应线',
  177. dataIndex: 'jpGyxAmount',
  178. align: 'center',
  179. width: 100,
  180. customRender: function (text) { return text ? ('¥' + text) : '0' }
  181. }
  182. ]
  183. },
  184. {
  185. title: '冠牌',
  186. align: 'center',
  187. children: [
  188. {
  189. title: '滤清器',
  190. dataIndex: 'gpLqqAmount',
  191. align: 'center',
  192. width: 100,
  193. customRender: function (text) { return text ? ('¥' + text) : '0' }
  194. },
  195. {
  196. title: '雨刮片',
  197. dataIndex: 'gpYgpAmount',
  198. align: 'center',
  199. width: 100,
  200. customRender: function (text) { return text ? ('¥' + text) : '0' }
  201. },
  202. {
  203. title: '刹车片',
  204. dataIndex: 'gpScpAmount',
  205. align: 'center',
  206. width: 100,
  207. customRender: function (text) { return text ? ('¥' + text) : '0' }
  208. }
  209. ]
  210. },
  211. {
  212. title: '汇箭',
  213. dataIndex: 'hjAmount',
  214. align: 'center',
  215. width: 100,
  216. customRender: function (text) { return text ? ('¥' + text) : '0' }
  217. },
  218. {
  219. title: '德路斯',
  220. dataIndex: 'dlsAmount',
  221. align: 'center',
  222. width: 100,
  223. customRender: function (text) { return text ? ('¥' + text) : '0' }
  224. },
  225. {
  226. title: '稳升',
  227. dataIndex: 'wsAmount',
  228. align: 'center',
  229. width: 100,
  230. customRender: function (text) { return text ? ('¥' + text) : '0' }
  231. },
  232. {
  233. title: 'TBU',
  234. dataIndex: 'tbuAmount',
  235. align: 'center',
  236. width: 100,
  237. customRender: function (text) { return text ? ('¥' + text) : '0' }
  238. }
  239. ] },
  240. { title: '代理品牌',
  241. align: 'center',
  242. children: [
  243. {
  244. title: 'NGK',
  245. dataIndex: 'ngkAmount',
  246. align: 'center',
  247. width: 100,
  248. customRender: function (text) { return text ? ('¥' + text) : '0' }
  249. },
  250. {
  251. title: '飞利浦',
  252. dataIndex: 'flpAmount',
  253. align: 'center',
  254. width: 100,
  255. customRender: function (text) { return text ? ('¥' + text) : '0' }
  256. },
  257. {
  258. title: '车仆',
  259. dataIndex: 'cpAmount',
  260. align: 'center',
  261. width: 100,
  262. customRender: function (text) { return text ? ('¥' + text) : '0' }
  263. },
  264. {
  265. title: '瓦尔塔',
  266. dataIndex: 'wetAmount',
  267. align: 'center',
  268. width: 100,
  269. customRender: function (text) { return text ? ('¥' + text) : '0' }
  270. },
  271. {
  272. title: '雷贝斯托',
  273. dataIndex: 'lbstAmount',
  274. align: 'center',
  275. width: 100,
  276. customRender: function (text) { return text ? ('¥' + text) : '0' }
  277. },
  278. {
  279. title: '德尔福',
  280. dataIndex: 'defAmount',
  281. align: 'center',
  282. width: 100,
  283. customRender: function (text) { return text ? ('¥' + text) : '0' }
  284. },
  285. {
  286. title: '巴诺德',
  287. dataIndex: 'bndAmount',
  288. align: 'center',
  289. width: 100,
  290. customRender: function (text) { return text ? ('¥' + text) : '0' }
  291. }
  292. ] },
  293. { title: '实际销售合计金额', width: 200, dataIndex: 'totalAmount', align: 'center', customRender: function (text) { return text ? ('¥' + text) : '0' } }
  294. ],
  295. // 加载数据方法 必须为 Promise 对象
  296. loadData: parameter => {
  297. this.disabled = true
  298. this.spinning = true
  299. if (this.tableHeight == 0) {
  300. this.tableHeight = window.innerHeight - 380
  301. }
  302. const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize }) // 有分页
  303. return salesBillReportList(paramsPage).then(res => {
  304. const data = res.data
  305. const no = (data.pageNo - 1) * data.pageSize
  306. for (var i = 0; i < data.list.length; i++) {
  307. const row = data.list[i]
  308. row.no = no + i + 1
  309. row.totalAmount = row.jpLqqAmount + row.jpYgpAmount + row.jpLbAmount + row.jpScpAmount
  310. row.totalAmount += row.jpGyxAmount + row.gpLqqAmount + row.gpYgpAmount + row.gpScpAmount + row.hjAmount
  311. row.totalAmount += row.dlsAmount + row.wsAmount + row.tbuAmount + row.ngkAmount + row.flpAmount + row.cpAmount
  312. row.totalAmount += row.wetAmount + row.lbstAmount + row.defAmount + row.bndAmount
  313. }
  314. this.disabled = false
  315. this.spinning = false
  316. return data
  317. })
  318. },
  319. addrProvinceList: [], // 省下拉
  320. addrCityList: [], // 市下拉
  321. addrDistrictList: [] // 区下拉
  322. }
  323. },
  324. methods: {
  325. handleSearch () {
  326. const _this = this
  327. this.$refs.ruleForm.validate(valid => {
  328. if (valid) {
  329. _this.$refs.table.refresh(true)
  330. } else {
  331. return false
  332. }
  333. })
  334. },
  335. // 创建时间 change
  336. dateChange (date) {
  337. this.queryParam.time = date
  338. this.queryParam.beginDate = date[0]
  339. this.queryParam.endDate = date[1]
  340. },
  341. custChange (val) {
  342. this.queryParam.dealer.dealerSn = val.key
  343. },
  344. // 重置
  345. resetSearchForm () {
  346. this.$refs.rangeDate.resetDate()
  347. this.queryParam.time = []
  348. this.queryParam.beginDate = ''
  349. this.queryParam.endDate = ''
  350. this.queryParam.salesBillNo = ''
  351. this.queryParam.dealer = {
  352. 'dealerSn': undefined,
  353. 'provinceSn': undefined,
  354. 'citySn': undefined,
  355. 'districtSn': undefined,
  356. 'subareaSn': undefined,
  357. 'dealerLevel': undefined
  358. }
  359. this.$refs.custList.resetForm()
  360. this.$refs.ruleForm.resetFields()
  361. this.$refs.table.clearTable()
  362. },
  363. // 获取城市列表
  364. getCityList (val) {
  365. this.addrCityList = []
  366. this.addrDistrictList = []
  367. this.queryParam.dealerCitySn = undefined
  368. this.queryParam.dealerCountySn = undefined
  369. this.getArea('city', val)
  370. },
  371. // 获取区县列表
  372. getAreaList (val) {
  373. this.addrDistrictList = []
  374. this.queryParam.dealerCountySn = undefined
  375. this.getArea('district', val)
  376. },
  377. // 省/市/区
  378. getArea (leve, sn) {
  379. let params
  380. if (leve == 'province') {
  381. params = { type: '2' }
  382. } else {
  383. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  384. }
  385. getArea(params).then(res => {
  386. if (res.status == 200) {
  387. if (leve == 'province') {
  388. this.addrProvinceList = res.data || []
  389. } else if (leve == 'city') {
  390. this.addrCityList = res.data || []
  391. } else if (leve == 'district') {
  392. this.addrDistrictList = res.data || []
  393. }
  394. } else {
  395. if (leve == 'province') {
  396. this.addrProvinceList = []
  397. } else if (leve == 'city') {
  398. this.addrCityList = []
  399. } else if (leve == 'district') {
  400. this.addrDistrictList = []
  401. }
  402. }
  403. })
  404. }
  405. },
  406. beforeRouteEnter (to, from, next) {
  407. next(vm => {
  408. vm.getArea('province')
  409. })
  410. }
  411. }
  412. </script>