list.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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. </a-card>
  125. </template>
  126. <script>
  127. import moment from 'moment'
  128. import getDate from '@/libs/getDate.js'
  129. import { STable, VSelect } from '@/components'
  130. import rangeDate from '@/views/common/rangeDate.vue'
  131. import custList from '@/views/common/custList.vue'
  132. import subarea from '@/views/common/subarea.js'
  133. import { getArea } from '@/api/data'
  134. import ProductBrand from '@/views/common/productBrand.js'
  135. import ProductType from '@/views/common/productType.js'
  136. import { headRebateDetailReportList, headRebateDetailReportCount, headRebateDetailReportExport } from '@/api/reportData'
  137. export default {
  138. components: { STable, VSelect, custList, subarea, rangeDate, ProductBrand, ProductType },
  139. data () {
  140. return {
  141. spinning: false,
  142. advanced: false, // 高级搜索 展开/关闭
  143. queryParam: { // 查询条件
  144. time: [
  145. getDate.getCurrMonthDays().starttime,
  146. getDate.getCurrMonthDays().endtime
  147. ],
  148. beginDate: getDate.getCurrMonthDays().starttime,
  149. endDate: getDate.getCurrMonthDays().endtime,
  150. exportLoading: false,
  151. bizNo: '',
  152. dealer: {
  153. dealerSn: undefined,
  154. dealerLevel: undefined,
  155. subareaSn: undefined, // 区域
  156. provinceSn: undefined
  157. },
  158. product: {
  159. brandType: undefined,
  160. productBrandSn: undefined, // 产品品牌
  161. productTypeSn1: '', // 产品一级分类
  162. productTypeSn2: '', // 产品二级分类
  163. productTypeSn3: '' // 产品三级分类
  164. },
  165. bizType: undefined
  166. },
  167. rules: {
  168. 'time': [{ required: true, message: '请选择日期', trigger: 'change' }]
  169. },
  170. disabled: false, // 查询、重置按钮是否可操作
  171. addrProvinceList: [], // 省下拉
  172. // 加载数据方法 必须为 Promise 对象
  173. loadData: parameter => {
  174. this.disabled = true
  175. const params = Object.assign(parameter, this.queryParam)
  176. if (!params.dealer.dealerSn && !params.dealer.dealerLevel && !params.dealer.subareaSn && !params.dealer.provinceSn) {
  177. delete params.dealer
  178. }
  179. delete params.time
  180. this.spinning = true
  181. return headRebateDetailReportList(params).then(res => {
  182. let data
  183. if (res.status == 200) {
  184. data = res.data
  185. // 总计
  186. this.getCount(params)
  187. const no = (data.pageNo - 1) * data.pageSize
  188. for (var i = 0; i < data.list.length; i++) {
  189. data.list[i].no = no + i + 1
  190. if (data.list[i].bizType) {
  191. data.list[i].bizTypeValue = data.list[i].bizType == 'SALES' ? '采购差价' : data.list[i].bizType == 'SALES_RETURN' ? '退货差价' : ''
  192. }
  193. }
  194. this.disabled = false
  195. }
  196. this.spinning = false
  197. return data
  198. })
  199. },
  200. productType: [],
  201. bizTypeList: [
  202. { value: 'SALES', name: '采购差价' },
  203. { value: 'SALES_RETURN', name: '退货差价' }
  204. ],
  205. totalData: null
  206. }
  207. },
  208. computed: {
  209. columns () {
  210. const arr = [
  211. { title: '区域', dataIndex: 'dealer.subareaNameSet', width: 120, align: 'center', customRender: function (text) { return (text && text.length > 0) ? text.join('/') : '--' } },
  212. { title: '订单号', dataIndex: 'bizNo', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  213. { title: '日期', dataIndex: 'bizCreateDate', width: 90, align: 'center', customRender: function (text) { return text || '--' } },
  214. { title: '省份', dataIndex: 'dealer.provinceName', width: 90, align: 'center', customRender: function (text) { return text || '--' } },
  215. { title: '直接绑定客户名称', dataIndex: 'directDealerName', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  216. { title: '间接绑定客户名称', dataIndex: 'indirectDealerName', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  217. { title: '客户名称', dataIndex: 'dealer.dealerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  218. { title: '客户级别', dataIndex: 'dealer.dealerLevelDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  219. { title: '品牌', dataIndex: 'productBrandName', width: 130, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  220. { title: '二级分类', dataIndex: 'productTypeName2', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
  221. { title: '数量', dataIndex: 'qty', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  222. // { title: '分公司金额', dataIndex: 'wholesalePrice1', width: 90, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  223. // { title: '加盟商金额', dataIndex: 'wholesalePrice2', width: 90, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  224. // { title: '特约加盟店金额', dataIndex: 'wholesalePrice3', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  225. // { title: '直接差价', dataIndex: 'directRebateAmount', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  226. // { title: '间接差价', dataIndex: 'indirectRebateAmount', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  227. { title: '类型', dataIndex: 'bizTypeValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } }
  228. ]
  229. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  230. arr.splice(11, 0, { title: '分公司金额', dataIndex: 'wholesalePrice1', width: 90, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  231. arr.splice(12, 0, { title: '加盟商金额', dataIndex: 'wholesalePrice2', width: 90, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  232. arr.splice(13, 0, { title: '特约加盟店金额', dataIndex: 'wholesalePrice3', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  233. arr.splice(14, 0, { title: '直接差价', dataIndex: 'directRebateAmount', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  234. arr.splice(15, 0, { title: '间接差价', dataIndex: 'indirectRebateAmount', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  235. }
  236. return arr
  237. }
  238. },
  239. methods: {
  240. // 导出
  241. handleExport () {
  242. const _this = this
  243. const params = this.queryParam
  244. this.exportLoading = true
  245. _this.spinning = true
  246. headRebateDetailReportExport(params).then(res => {
  247. this.exportLoading = false
  248. _this.spinning = false
  249. if (res.type == 'application/json') {
  250. var reader = new FileReader()
  251. reader.addEventListener('loadend', function () {
  252. const obj = JSON.parse(reader.result)
  253. _this.$notification.error({
  254. message: '提示',
  255. description: obj.message
  256. })
  257. })
  258. reader.readAsText(res)
  259. } else {
  260. this.download(res)
  261. }
  262. })
  263. },
  264. download (data) {
  265. if (!data) { return }
  266. const url = window.URL.createObjectURL(new Blob([data]))
  267. const link = document.createElement('a')
  268. link.style.display = 'none'
  269. link.href = url
  270. const a = moment().format('YYYYMMDDHHmmss')
  271. const fname = '总部差价明细报表' + a
  272. link.setAttribute('download', fname + '.xlsx')
  273. document.body.appendChild(link)
  274. link.click()
  275. },
  276. // 盘点库存日期
  277. handleStock () {
  278. this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
  279. },
  280. // 创建时间 change
  281. dateChange (date) {
  282. if (date[0] && date[1]) {
  283. this.queryParam.time = date
  284. } else {
  285. this.queryParam.time = []
  286. }
  287. this.queryParam.beginDate = date[0] || ''
  288. this.queryParam.endDate = date[1] || ''
  289. },
  290. // 合计
  291. getCount (params) {
  292. headRebateDetailReportCount(params).then(res => {
  293. if (res.status == 200) {
  294. this.totalData = res.data
  295. } else {
  296. this.totalData = null
  297. }
  298. })
  299. },
  300. // 查询
  301. handleSearch () {
  302. const _this = this
  303. this.$refs.ruleForm.validate(valid => {
  304. if (valid) {
  305. _this.$refs.table.refresh(true)
  306. } else {
  307. console.log('error submit!!')
  308. return false
  309. }
  310. })
  311. },
  312. custChange (val) {
  313. this.queryParam.dealer.dealerSn = val.key
  314. },
  315. // 产品分类 change
  316. changeProductType (val, opt) {
  317. this.queryParam.product.productTypeSn1 = val[0] ? val[0] : ''
  318. this.queryParam.product.productTypeSn2 = val[1] ? val[1] : ''
  319. this.queryParam.product.productTypeSn3 = val[2] ? val[2] : ''
  320. },
  321. // 省/市/区
  322. getArea (leve, sn) {
  323. let params
  324. if (leve == 'province') {
  325. params = { type: '2' }
  326. } else {
  327. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  328. }
  329. getArea(params).then(res => {
  330. if (res.status == 200) {
  331. if (leve == 'province') {
  332. this.addrProvinceList = res.data || []
  333. } else if (leve == 'city') {
  334. this.addrCityList = res.data || []
  335. } else if (leve == 'district') {
  336. this.addrDistrictList = res.data || []
  337. }
  338. } else {
  339. if (leve == 'province') {
  340. this.addrProvinceList = []
  341. } else if (leve == 'city') {
  342. this.addrCityList = []
  343. } else if (leve == 'district') {
  344. this.addrDistrictList = []
  345. }
  346. }
  347. })
  348. },
  349. // 重置
  350. resetSearchForm () {
  351. this.queryParam.time = [
  352. getDate.getCurrMonthDays().starttime,
  353. getDate.getCurrMonthDays().endtime
  354. ]
  355. this.$refs.rangeDate.resetDate(this.queryParam.time)
  356. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  357. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  358. this.queryParam.bizNo = ''
  359. this.queryParam.dealer.dealerSn = undefined
  360. this.queryParam.dealer.dealerLevel = undefined
  361. this.queryParam.dealer.subareaSn = undefined
  362. this.queryParam.dealer.provinceSn = undefined
  363. this.queryParam.product.brandType = ''
  364. this.queryParam.product.productBrandSn = ''
  365. this.queryParam.product.productTypeSn1 = ''
  366. this.queryParam.product.productTypeSn2 = ''
  367. this.queryParam.product.productTypeSn3 = ''
  368. this.queryParam.bizType = undefined
  369. this.productType = []
  370. this.totalData = null
  371. this.$refs.custList.resetForm()
  372. this.$refs.ruleForm.resetFields()
  373. this.$refs.table.clearTable()
  374. },
  375. pageInit () {
  376. this.getArea('province')
  377. }
  378. },
  379. mounted () {
  380. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  381. this.pageInit()
  382. this.resetSearchForm()
  383. }
  384. },
  385. activated () {
  386. // 如果是新页签打开,则重置当前页面
  387. if (this.$store.state.app.isNewTab) {
  388. this.pageInit()
  389. this.resetSearchForm()
  390. }
  391. },
  392. beforeRouteEnter (to, from, next) {
  393. next(vm => {})
  394. }
  395. }
  396. </script>