list.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="hPriceDifferenceDetailList-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper" ref="tableSearch">
  6. <a-form-model
  7. id="hPriceDifferenceDetailList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="queryParam"
  12. :rules="rules"
  13. @keyup.enter.native="handleSearch">
  14. <a-row :gutter="15">
  15. <a-col :md="6" :sm="24">
  16. <a-form-model-item label="日期" prop="time">
  17. <rangeDate ref="rangeDate" :value="queryParam.time" @change="dateChange" />
  18. </a-form-model-item>
  19. </a-col>
  20. <a-col :md="5" :sm="24">
  21. <a-form-model-item label="单号">
  22. <a-input id="hPriceDifferenceDetailList-bizNo" v-model.trim="queryParam.bizNo" allowClear placeholder="请输入单号"/>
  23. </a-form-model-item>
  24. </a-col>
  25. <a-col :md="6" :sm="24">
  26. <a-form-model-item label="客户名称">
  27. <dealerSubareaScopeList id="hPriceDifferenceDetailList-custList" ref="custList" @change="custChange"></dealerSubareaScopeList>
  28. </a-form-model-item>
  29. </a-col>
  30. <a-col :md="7" :sm="24" v-if="isShowCustomerSearch">
  31. <a-form-model-item label="客户级别">
  32. <v-select
  33. v-model="queryParam.dealer.dealerLevel"
  34. ref="dealerLevel"
  35. id="hPriceDifferenceDetailList-dealerLevel"
  36. code="DEALER_LEVEL"
  37. placeholder="请选择客户级别"
  38. allowClear></v-select>
  39. </a-form-model-item>
  40. </a-col>
  41. <template v-if="advanced">
  42. <a-col :md="7" :sm="24" v-if="!isShowCustomerSearch">
  43. <a-form-model-item label="客户级别">
  44. <v-select
  45. v-model="queryParam.dealer.dealerLevel"
  46. ref="dealerLevel"
  47. id="hPriceDifferenceDetailList-dealerLevel"
  48. code="DEALER_LEVEL"
  49. placeholder="请选择客户级别"
  50. allowClear></v-select>
  51. </a-form-model-item>
  52. </a-col>
  53. <a-col :md="6" :sm="24">
  54. <a-form-model-item label="品牌分类">
  55. <v-select code="BRAND_TYPE" id="hPriceDifferenceDetailList-brandType" v-model="queryParam.product.brandType" allowClear placeholder="请选择品牌分类"></v-select>
  56. </a-form-model-item>
  57. </a-col>
  58. <a-col :md="5" :sm="24">
  59. <a-form-model-item label="产品品牌">
  60. <ProductBrand id="hPriceDifferenceDetailList-productBrandSn" v-model="queryParam.product.productBrandSn"></ProductBrand>
  61. </a-form-model-item>
  62. </a-col>
  63. <a-col :md="6" :sm="24">
  64. <a-form-model-item label="产品分类">
  65. <ProductType id="hPriceDifferenceDetailList-productType" v-model="productType" @change="changeProductType"></ProductType>
  66. </a-form-model-item>
  67. </a-col>
  68. <a-col :md="7" :sm="24">
  69. <a-form-model-item label="所在区域">
  70. <subarea id="hPriceDifferenceDetailList-subareaSn" ref="subarea" @change="subareaChange"></subarea>
  71. </a-form-model-item>
  72. </a-col>
  73. <a-col :md="6" :sm="24">
  74. <a-form-model-item label="区域负责人">
  75. <BizUser v-model="queryParam.subareaArea.bizUserSn"></BizUser>
  76. </a-form-model-item>
  77. </a-col>
  78. <a-col :md="5" :sm="24">
  79. <a-form-model-item label="省级区域">
  80. <Area id="hPriceDifferenceDetailList-provinceSn" v-model="queryParam.dealer.provinceSn" placeholder="请选择省"></Area>
  81. </a-form-model-item>
  82. </a-col>
  83. <a-col :md="6" :sm="24">
  84. <a-form-model-item label="类型" prop="bizType">
  85. <a-select id="hPriceDifferenceDetailList-bizType" allowClear v-model="queryParam.bizType" placeholder="请选择类型">
  86. <a-select-option v-for="item in bizTypeList" :value="item.value" :key="item.value">{{ item.name }}</a-select-option>
  87. </a-select>
  88. </a-form-model-item>
  89. </a-col>
  90. <a-col :md="6" :sm="24" v-show="isShowCustomerSearch">
  91. <a-form-item label="客服">
  92. <customerService ref="customerName" v-model="queryParam.bizUserSn"></customerService>
  93. </a-form-item>
  94. </a-col>
  95. </template>
  96. <a-col :md="isShowCustomerSearch?24:6" :sm="24" style="margin-bottom: 10px;" :style="{textAlign: isShowCustomerSearch?'center':''}">
  97. <!-- <a-button
  98. type="primary"
  99. class="button-info"
  100. size="small"
  101. @click="handleStock"
  102. id="hPriceDifferenceDetailList-stockDate">盘点区间日期</a-button> -->
  103. <a-button style="margin-left: 5px" type="primary" @click="handleSearch" :disabled="disabled" id="hPriceDifferenceDetailList-refresh">查询</a-button>
  104. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="hPriceDifferenceDetailList-reset">重置</a-button>
  105. <a-button
  106. style="margin-left: 5px"
  107. type="primary"
  108. class="button-warning"
  109. @click="handleExport"
  110. :disabled="disabled"
  111. id="shortageStatisticsCList-export">导出</a-button>
  112. <a @click="advanced=!advanced" style="margin-left: 5px">
  113. {{ advanced ? '收起' : '展开' }}
  114. <a-icon :type="advanced ? 'up' : 'down'"/>
  115. </a>
  116. </a-col>
  117. </a-row>
  118. </a-form-model>
  119. </div>
  120. </a-card>
  121. <!-- 列表 -->
  122. <a-card size="small" :bordered="false">
  123. <a-spin :spinning="spinning" tip="Loading...">
  124. <s-table
  125. class="sTable fixPagination"
  126. ref="table"
  127. size="small"
  128. :rowKey="(record) => record.no"
  129. rowKeyName="no"
  130. :columns="columns"
  131. :data="loadData"
  132. :defaultLoadData="false"
  133. :pageSize="30"
  134. :style="{ height: tableHeight+70+'px' }"
  135. :scroll="{ x: 1850 ,y: tableHeight-50 }"
  136. bordered>
  137. <template slot="footer">
  138. <a-row :gutter="15">
  139. <a-col :md="6" :sm="24" >分公司金额:{{ (totalData && (totalData.wholesalePrice1 || totalData.wholesalePrice1==0)) ? toThousands(totalData.wholesalePrice1) : '--' }}</a-col>
  140. <a-col :md="6" :sm="24" >加盟商金额:{{ (totalData && (totalData.wholesalePrice2 || totalData.wholesalePrice2==0)) ? toThousands(totalData.wholesalePrice2) : '--' }}</a-col>
  141. <a-col :md="6" :sm="24" >特约加盟店金额:{{ (totalData && (totalData.wholesalePrice3 || totalData.wholesalePrice3==0)) ? toThousands(totalData.wholesalePrice3) : '--' }}</a-col>
  142. <a-col :md="6" :sm="24" >直接差价金额:{{ (totalData && (totalData.directRebateAmount || totalData.directRebateAmount==0)) ? toThousands(totalData.directRebateAmount) : '--' }}</a-col>
  143. <a-col :md="6" :sm="24" >间接差价金额:{{ (totalData && (totalData.indirectRebateAmount || totalData.indirectRebateAmount==0)) ? toThousands(totalData.indirectRebateAmount) : '--' }}</a-col>
  144. </a-row>
  145. </template>
  146. </s-table>
  147. </a-spin>
  148. <!-- 导出提示框 -->
  149. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  150. </a-card>
  151. </div>
  152. </template>
  153. <script>
  154. import { commonMixin } from '@/utils/mixin'
  155. import getDate from '@/libs/getDate.js'
  156. import { STable, VSelect } from '@/components'
  157. import rangeDate from '@/views/common/rangeDate.vue'
  158. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  159. import subarea from '@/views/common/subarea.js'
  160. import reportModal from '@/views/common/reportModal.vue'
  161. import Area from '@/views/common/area.js'
  162. import ProductBrand from '@/views/common/productBrand.js'
  163. import ProductType from '@/views/common/productType.js'
  164. import BizUser from '@/views/common/bizUser.js'
  165. import customerService from '@/views/common/customerService'
  166. import { hdExportExcel } from '@/libs/exportExcel'
  167. import { headRebateDetailReportList, headRebateDetailReportCount, headRebateDetailReportExport } from '@/api/reportData'
  168. export default {
  169. name: 'HPriceDifferenceDetailReportList',
  170. mixins: [commonMixin],
  171. components: { STable, VSelect, dealerSubareaScopeList, subarea, Area, rangeDate, ProductBrand, ProductType, reportModal, BizUser, customerService },
  172. data () {
  173. return {
  174. spinning: false,
  175. advanced: false, // 高级搜索 展开/关闭
  176. showExport: false,
  177. queryParam: { // 查询条件
  178. time: [
  179. getDate.getCurrMonthDays().starttime,
  180. getDate.getCurrMonthDays().endtime
  181. ],
  182. beginDate: getDate.getCurrMonthDays().starttime,
  183. endDate: getDate.getCurrMonthDays().endtime,
  184. bizNo: '',
  185. dealer: {
  186. dealerSn: undefined,
  187. dealerLevel: undefined,
  188. provinceSn: undefined
  189. },
  190. subareaArea: {
  191. subareaSn: undefined,
  192. subareaAreaSn: undefined,
  193. bizUserSn: undefined
  194. },
  195. product: {
  196. brandType: undefined,
  197. productBrandSn: undefined, // 产品品牌
  198. productTypeSn1: '', // 产品一级分类
  199. productTypeSn2: '', // 产品二级分类
  200. productTypeSn3: '' // 产品三级分类
  201. },
  202. bizType: undefined,
  203. bizUserSn: undefined
  204. },
  205. rules: {
  206. 'time': [{ required: true, message: '请选择日期', trigger: 'change' }]
  207. },
  208. disabled: false, // 查询、重置按钮是否可操作
  209. // 加载数据方法 必须为 Promise 对象
  210. loadData: parameter => {
  211. this.disabled = true
  212. const params = Object.assign(parameter, this.queryParam)
  213. if (!params.dealer.dealerSn && !params.dealer.dealerLevel && !params.dealer.subareaSn && !params.dealer.provinceSn) {
  214. delete params.dealer
  215. }
  216. delete params.time
  217. this.spinning = true
  218. return headRebateDetailReportList(params).then(res => {
  219. let data
  220. if (res.status == 200) {
  221. data = res.data
  222. // 总计
  223. this.getCount(params)
  224. const no = (data.pageNo - 1) * data.pageSize
  225. for (var i = 0; i < data.list.length; i++) {
  226. data.list[i].no = no + i + 1
  227. if (data.list[i].bizType) {
  228. data.list[i].bizTypeValue = data.list[i].bizType == 'SALES' ? '采购差价' : data.list[i].bizType == 'SALES_RETURN' ? '退货差价' : ''
  229. }
  230. }
  231. this.disabled = false
  232. }
  233. this.spinning = false
  234. return data
  235. })
  236. },
  237. productType: [],
  238. bizTypeList: [
  239. { value: 'SALES', name: '采购差价' },
  240. { value: 'SALES_RETURN', name: '退货差价' }
  241. ],
  242. totalData: null,
  243. tableHeight: 0
  244. }
  245. },
  246. computed: {
  247. columns () {
  248. const _this = this
  249. const arr = [
  250. { title: '区域', dataIndex: 'subareaArea.subareaName', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  251. { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  252. { title: '区域负责人', dataIndex: 'subareaArea.bizUserName', width: 100, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  253. { title: '订单号', dataIndex: 'bizNo', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  254. { title: '日期', dataIndex: 'bizCreateDate', width: 90, align: 'center', customRender: function (text) { return text || '--' } },
  255. { title: '省份', dataIndex: 'provinceName', width: 90, align: 'center', customRender: function (text) { return text || '--' } },
  256. { title: '直接绑定客户名称', dataIndex: 'directDealerName', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  257. { title: '间接绑定客户名称', dataIndex: 'indirectDealerName', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  258. { title: '客户名称', dataIndex: 'buyerName', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  259. { title: '客户级别', dataIndex: 'buyerLevelDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  260. { title: '品牌', dataIndex: 'productBrandName', width: 130, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  261. { title: '二级分类', dataIndex: 'productTypeName2', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
  262. { title: '数量', dataIndex: 'qty', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  263. // { title: '分公司金额', dataIndex: 'wholesalePrice1', width: 90, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  264. // { title: '加盟商金额', dataIndex: 'wholesalePrice2', width: 90, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  265. // { title: '特约加盟店金额', dataIndex: 'wholesalePrice3', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  266. // { title: '直接差价', dataIndex: 'directRebateAmount', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  267. // { title: '间接差价', dataIndex: 'indirectRebateAmount', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  268. { title: '类型', dataIndex: 'bizTypeValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } }
  269. ]
  270. arr.splice(11, 0, { title: '分公司金额', dataIndex: 'wholesalePrice1', width: 90, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  271. arr.splice(12, 0, { title: '加盟商金额', dataIndex: 'wholesalePrice2', width: 90, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  272. arr.splice(13, 0, { title: '特约加盟店金额', dataIndex: 'wholesalePrice3', width: 100, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  273. arr.splice(14, 0, { title: '直接差价', dataIndex: 'directRebateAmount', width: 80, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  274. arr.splice(15, 0, { title: '间接差价', dataIndex: 'indirectRebateAmount', width: 80, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  275. return arr
  276. }
  277. },
  278. watch: {
  279. advanced (newValue, oldValue) {
  280. const _this = this
  281. this.$nextTick(() => { // 页面渲染完成后的回调
  282. _this.setTableH()
  283. })
  284. },
  285. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  286. this.setTableH()
  287. }
  288. },
  289. methods: {
  290. // 导出
  291. handleExport () {
  292. const _this = this
  293. this.$refs.ruleForm.validate(valid => {
  294. if (valid) {
  295. const params = _this.queryParam
  296. _this.$store.state.app.curActionPermission = 'M_hPriceDifferenceDetailReportList'
  297. _this.showExport = true
  298. _this.spinning = true
  299. hdExportExcel(headRebateDetailReportExport, params, '总部差价明细报表', function () {
  300. _this.spinning = false
  301. _this.$store.state.app.curActionPermission = ''
  302. })
  303. } else {
  304. return false
  305. }
  306. })
  307. },
  308. // 盘点库存日期
  309. handleStock () {
  310. this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
  311. },
  312. // 创建时间 change
  313. dateChange (date) {
  314. if (date[0] && date[1]) {
  315. this.queryParam.time = date
  316. } else {
  317. this.queryParam.time = []
  318. }
  319. this.queryParam.beginDate = date[0] || ''
  320. this.queryParam.endDate = date[1] || ''
  321. },
  322. // 合计
  323. getCount (params) {
  324. headRebateDetailReportCount(params).then(res => {
  325. if (res.status == 200) {
  326. this.totalData = res.data
  327. } else {
  328. this.totalData = null
  329. }
  330. })
  331. },
  332. // 查询
  333. handleSearch () {
  334. const _this = this
  335. this.$refs.ruleForm.validate(valid => {
  336. if (valid) {
  337. _this.$refs.table.refresh(true)
  338. } else {
  339. _this.$message.error('请选择日期')
  340. return false
  341. }
  342. })
  343. },
  344. custChange (val) {
  345. this.queryParam.dealer.dealerSn = val.key
  346. },
  347. // 产品分类 change
  348. changeProductType (val, opt) {
  349. this.queryParam.product.productTypeSn1 = val[0] ? val[0] : ''
  350. this.queryParam.product.productTypeSn2 = val[1] ? val[1] : ''
  351. this.queryParam.product.productTypeSn3 = val[2] ? val[2] : ''
  352. },
  353. subareaChange (val) {
  354. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  355. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  356. },
  357. // 重置
  358. resetSearchForm () {
  359. this.queryParam.time = [
  360. getDate.getCurrMonthDays().starttime,
  361. getDate.getCurrMonthDays().endtime
  362. ]
  363. this.$refs.rangeDate.resetDate(this.queryParam.time)
  364. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  365. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  366. this.queryParam.bizNo = ''
  367. this.queryParam.dealer.dealerSn = undefined
  368. this.queryParam.dealer.dealerLevel = undefined
  369. this.queryParam.subareaArea.subareaSn = undefined
  370. this.queryParam.subareaArea.subareaAreaSn = undefined
  371. this.queryParam.subareaArea.bizUserSn = undefined
  372. this.queryParam.dealer.provinceSn = undefined
  373. this.queryParam.product.brandType = ''
  374. this.queryParam.product.productBrandSn = ''
  375. this.queryParam.product.productTypeSn1 = ''
  376. this.queryParam.product.productTypeSn2 = ''
  377. this.queryParam.product.productTypeSn3 = ''
  378. this.queryParam.bizType = undefined
  379. this.queryParam.bizUserSn = undefined
  380. this.productType = []
  381. this.totalData = null
  382. if (this.advanced) {
  383. this.$refs.subarea.clearData()
  384. }
  385. this.$refs.custList.resetForm()
  386. this.$refs.ruleForm.resetFields()
  387. this.$refs.table.clearTable()
  388. },
  389. setTableH () {
  390. const tableSearchH = this.$refs.tableSearch.offsetHeight
  391. this.tableHeight = window.innerHeight - tableSearchH - 200
  392. }
  393. },
  394. mounted () {
  395. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  396. this.resetSearchForm()
  397. this.setTableH()
  398. }
  399. },
  400. activated () {
  401. // 如果是新页签打开,则重置当前页面
  402. if (this.$store.state.app.isNewTab) {
  403. this.resetSearchForm()
  404. this.setTableH()
  405. }
  406. },
  407. beforeRouteEnter (to, from, next) {
  408. next(vm => {})
  409. }
  410. }
  411. </script>