list.vue 18 KB

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