list.vue 18 KB

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