activeUser.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <div class="activeuser-baseInfo">
  3. <a-page-header :ghost="false" title="活跃用户" :backIcon="false" class="activeuser-back">
  4. <template slot="subTitle">
  5. <a href="javascript:;" @click="handleBack" id="activeuser-handleBack">
  6. <a-icon type="left"></a-icon> 返回上页
  7. </a>
  8. </template>
  9. </a-page-header>
  10. <a-card size="small" :bordered="false" style="margin-bottom: 6px;">
  11. <div style="padding:0 10px;color: #00aaff;cursor: pointer;" slot="extra" @click="showSetModal=true"><a-icon type="setting" /> 参数设置</div>
  12. <div class="gard-box">
  13. <div v-for="(card,i) in getShelfLeveData" :key="i" @click="chooseCard(i)" :class="cardIndex == i? 'chooseCard':''">
  14. <a-card size="small">
  15. <h4>{{ card.levelName }}</h4>
  16. <p v-if="card.levelName == 'LV1'">近{{ card.dayLimit }}天销售金额 ≤ {{ card.amountMax }}元</p>
  17. <p v-if="card.levelName == 'LV2'">{{ card.amountMin }}元 < 近{{ card.dayLimit }}天销售金额 ≤ {{ card.amountMax }}元</p>
  18. <p v-if="card.levelName == 'LV3'">{{ card.amountMin }}元 < 近{{ card.dayLimit }}天销售金额 ≤ {{ card.amountMax }}元</p>
  19. <p v-if="card.levelName == 'LV4'">{{ card.amountMin }}元 < 近{{ card.dayLimit }}天销售金额 ≤ {{ card.amountMax }}元</p>
  20. <p v-if="card.levelName == 'LV5'">{{ card.amountMin }}元 < 近{{ card.dayLimit }}天销售金额</p>
  21. <div>
  22. <div>
  23. <span>门店数量</span>
  24. <span>{{ card.shelfCount }}个</span>
  25. </div>
  26. <div>
  27. <span>累计销售金额</span>
  28. <span>{{ card.amountSum }}元</span>
  29. </div>
  30. <div>
  31. <span>门店数量占比</span>
  32. <span>{{ card.shelfRate? card.shelfRate : 0 }}</span>
  33. </div>
  34. <div>
  35. <span>累计销售金额占比</span>
  36. <span>{{ card.amountRate? card.amountRate : 0 }}</span>
  37. </div>
  38. </div>
  39. </a-card>
  40. </div>
  41. <!-- <div>
  42. <a-card size="small">
  43. <h4>LV2</h4>
  44. <p> 1000元 < 近30天销售金额 ≤ 2000元</p>
  45. <div>
  46. <div><span>门店数量</span><span>21个</span></div>
  47. <div><span>累计销售金额</span><span>21元</span></div>
  48. <div><span>门店数量占比</span><span>21%</span></div>
  49. <div><span>累计销售金额占比</span><span>21%</span></div>
  50. </div>
  51. </a-card>
  52. </div>
  53. <div>
  54. <a-card size="small">
  55. <h4>LV3</h4>
  56. <p> 2000元 < 近30天销售金额 ≤ 3000元</p>
  57. <div>
  58. <div><span>门店数量</span><span>21个</span></div>
  59. <div><span>累计销售金额</span><span>21元</span></div>
  60. <div><span>门店数量占比</span><span>21%</span></div>
  61. <div><span>累计销售金额占比</span><span>21%</span></div>
  62. </div>
  63. </a-card>
  64. </div>
  65. <div>
  66. <a-card size="small">
  67. <h4>LV4</h4>
  68. <p> 3000元 < 近30天销售金额 ≤ 5000元</p>
  69. <div>
  70. <div><span>门店数量</span><span>21个</span></div>
  71. <div><span>累计销售金额</span><span>21元</span></div>
  72. <div><span>门店数量占比</span><span>21%</span></div>
  73. <div><span>累计销售金额占比</span><span>21%</span></div>
  74. </div>
  75. </a-card>
  76. </div>
  77. <div>
  78. <a-card size="small">
  79. <h4>LV5</h4>
  80. <p> 5000元 < 近30天销售金额</p>
  81. <div>
  82. <div><span>门店数量</span><span>21个</span></div>
  83. <div><span>累计销售金额</span><span>21元</span></div>
  84. <div><span>门店数量占比</span><span>21%</span></div>
  85. <div><span>累计销售金额占比</span><span>21%</span></div>
  86. </div>
  87. </a-card>
  88. </div> -->
  89. </div>
  90. </a-card>
  91. <a-card size="small" :bordered="false">
  92. <a-spin :spinning="spinning" tip="Loading...">
  93. <div ref="tableSearch" class="table-page-search-wrapper">
  94. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  95. <a-row :gutter="15">
  96. <a-col :md="5" :sm="24">
  97. <a-form-item label="货架创建时间">
  98. <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
  99. </a-form-item>
  100. </a-col>
  101. <a-col :md="5" :sm="24">
  102. <a-form-item label="汽车修理厂">
  103. <storeList ref="storeList" @change="storeChange" id="activeuser-storeChange"></storeList>
  104. </a-form-item>
  105. </a-col>
  106. <a-col :md="5" :sm="24">
  107. <a-form-item label="配件经销商">
  108. <dealerList ref="dealerList" @change="dealerChange" id="activeuser-dealerChange"></dealerList>
  109. </a-form-item>
  110. </a-col>
  111. <a-col :md="4" :sm="24">
  112. <a-form-item label="所在地">
  113. <areaList level="2" placeholder="请选择所在地" v-model="areaArr" @change="areaChange"></areaList>
  114. </a-form-item>
  115. </a-col>
  116. <template v-if="advanced">
  117. <a-col :md="4" :sm="24">
  118. <a-form-item label="货架状态">
  119. <v-select id="activeuser-state" code="SHELF_STATE" v-model="queryParam.state" allowClear placeholder="请选择状态"></v-select>
  120. </a-form-item>
  121. </a-col>
  122. </template>
  123. <a-col :md="4" :sm="24" style="margin-bottom: 10px;">
  124. <a-button type="primary" @click="$refs.table.refresh(true)" id="activeuser-refresh">查询</a-button>
  125. <a-button type="" @click="reset" style="margin-left: 10px;" id="activeuser-reset">重置</a-button>
  126. <a-button type="primary" @click="exportFile" class="button-warning" style="margin-left: 10px;" id="activeuser-reset">导出</a-button>
  127. <a @click="advanced=!advanced" style="margin-left: 8px">
  128. {{ advanced ? '收起' : '展开' }}
  129. <a-icon :type="advanced ? 'up' : 'down'"/>
  130. </a>
  131. </a-col>
  132. </a-row>
  133. </a-form>
  134. </div>
  135. <div class="table-operator" v-if="statisticsObj">
  136. <a-alert type="info">
  137. <div slot="message" class="total-bar">
  138. <div>
  139. 门店数量:<strong>{{ statisticsObj.shelfCount || 0 }}</strong>;
  140. 近30天货架取货数量合计:<strong>{{ statisticsObj.totalShelfMaxQty || 0 }}</strong>;
  141. 近30天货架取货金额合计:<strong>{{ statisticsObj.totalShelfMaxCost || 0 }}</strong>;
  142. 近30天销售数量合计:<strong>{{ statisticsObj.saleOrderQty || 0 }}</strong>;
  143. 近30天销售金额合计:<strong>{{ statisticsObj.saleOrderAmount || 0 }}</strong>;
  144. </div>
  145. </div>
  146. </a-alert>
  147. </div>
  148. <s-table
  149. class="sTable fixPagination"
  150. ref="table"
  151. :style="{ height: tableHeight+84.5+'px', wordBreak: 'break-all' }"
  152. size="small"
  153. :rowKey="(record,index)=>{return index}"
  154. :columns="columns"
  155. :data="loadData"
  156. :scroll="{ y: tableHeight }"
  157. :defaultLoadData="false"
  158. bordered>
  159. <div slot="area" slot-scope="text, record">
  160. {{ record.dealerProvinceName }} {{ record.dealerCityName }}
  161. </div>
  162. </s-table>
  163. </a-spin>
  164. </a-card>
  165. <!-- 参数设置 -->
  166. <setModal :openModal="showSetModal" :nowData="itemData" @close="showSetModal=false"></setModal>
  167. </div>
  168. </template>
  169. <script>
  170. import { STable, VSelect } from '@/components'
  171. import rangeDate from '@/views/common/rangeDate.vue'
  172. import { queryShelfActiveUserPage, queryShelfLevelReport, exportShelfActiveUser, statistics } from '@/api/report.js'
  173. import areaList from '@/views/common/areaList.js'
  174. import dealerList from '@/views/common/dealerList.vue'
  175. import storeList from '@/views/common/storeList.vue'
  176. import { toThousands } from '@/libs/tools.js'
  177. import { hdExportExcel } from '@/libs/exportExcel'
  178. import setModal from './setModal.vue'
  179. export default {
  180. name: 'UserList',
  181. components: { STable, VSelect, rangeDate, dealerList, storeList, areaList, setModal },
  182. data () {
  183. return {
  184. spinning: false,
  185. advanced: false,
  186. showSetModal: false,
  187. tableHeight: 0,
  188. activeKey: ['1'],
  189. time: [],
  190. orderTime: [],
  191. // 查询参数
  192. queryParam: {
  193. endDate: '',
  194. beginDate: '',
  195. storeSn: undefined,
  196. dealerSn: undefined,
  197. state: undefined,
  198. dealerProvinceSn: undefined,
  199. dealerCitySn: undefined
  200. },
  201. showModal: false,
  202. itemData: null, // 编辑行数据
  203. openStatusModal: false, // 货架状态弹窗初始状态
  204. getShelfLeveData: [], // 货架等级数据
  205. statisticsObj: null,
  206. cardIndex: null,
  207. areaArr: [],
  208. // 表头
  209. columns: [
  210. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  211. { title: '货架创建时间', dataIndex: 'shelfCreateDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  212. { title: '汽车修理厂', dataIndex: 'storeName', width: '15%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  213. { title: '配件经销商', dataIndex: 'dealerName', width: '15%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  214. { title: '所在地', scopedSlots: { customRender: 'area' }, width: '11%', align: 'center' },
  215. { title: '货架状态', dataIndex: 'shelfStateDictValue', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  216. { title: '近30天货架取货数量', dataIndex: 'totalOrderQty', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') }, sorter: true },
  217. { title: '近30天货架取货金额', dataIndex: 'totalOrderAmount', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? toThousands(text, 2) : '--') }, sorter: true },
  218. { title: '近30天销售数量', dataIndex: 'saleOrderQty', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') }, sorter: true },
  219. { title: '近30天销售金额', dataIndex: 'saleOrderAmount', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? toThousands(text, 2) : '--') }, sorter: true }
  220. ],
  221. // 加载数据方法 必须为 Promise 对象
  222. loadData: parameter => {
  223. this.spinning = true
  224. return queryShelfActiveUserPage(Object.assign(parameter, this.queryParam)).then(res => {
  225. let data
  226. if (res.status == 200) {// eslint-disable-line
  227. data = res.data
  228. const no = (data.pageNo - 1) * data.pageSize
  229. for (let i = 0; i < data.list.length; i++) {
  230. const _item = data.list[i]
  231. _item.no = no + i + 1
  232. }
  233. }
  234. this.spinning = false
  235. this.getShelfLeve()
  236. this.getStatistics(this.queryParam)
  237. return data
  238. })
  239. }
  240. }
  241. },
  242. methods: {
  243. handleBack () {
  244. this.$router.go(-1)
  245. },
  246. // 时间 change
  247. dateChange (date) {
  248. this.queryParam.beginDate = date[0]
  249. this.queryParam.endDate = date[1]
  250. },
  251. // 经销商 change
  252. dealerChange (obj) {
  253. this.queryParam.dealerSn = obj.key || undefined
  254. },
  255. // 汽车修理厂 change
  256. storeChange (obj) {
  257. this.queryParam.storeSn = obj.key || undefined
  258. },
  259. // 地区
  260. areaChange (val, opts) {
  261. this.queryParam.dealerProvinceSn = val && val[0] ? val[0] : ''
  262. this.queryParam.dealerCitySn = val && val[1] ? val[1] : ''
  263. },
  264. // 导出
  265. exportFile () {
  266. const _this = this
  267. this.spinning = true
  268. hdExportExcel(exportShelfActiveUser, this.queryParam, '用户分析(活跃用户)详情', function () {
  269. _this.spinning = false
  270. })
  271. },
  272. // 重置
  273. reset () {
  274. this.cardIndex = null
  275. this.queryParam = {
  276. endDate: '',
  277. beginDate: '',
  278. storeSn: undefined,
  279. dealerSn: undefined,
  280. state: undefined,
  281. dealerProvinceSn: undefined,
  282. dealerCitySn: undefined
  283. }
  284. this.areaArr = []
  285. this.$refs.rangeDate.resetDate()
  286. this.$refs.dealerList.resetForm()
  287. this.$refs.storeList.resetForm()
  288. this.$refs.table.refresh(true)
  289. },
  290. pageInit () {
  291. const _this = this
  292. this.$nextTick(() => { // 页面渲染完成后的回调
  293. _this.setTableH()
  294. })
  295. },
  296. setTableH () {
  297. const tableSearchH = this.$refs.tableSearch.offsetHeight
  298. this.tableHeight = window.innerHeight - tableSearchH - 255
  299. },
  300. // 获取货架等级
  301. getShelfLeve () {
  302. const _this = this
  303. queryShelfLevelReport().then(res => {
  304. if (res.status == 200) { // eslint-disable-line
  305. _this.getShelfLeveData = res.data
  306. } else {
  307. _this.$message.error(res.message)
  308. }
  309. })
  310. },
  311. // 获取活跃用户统计数据
  312. getStatistics (ajaxData) {
  313. statistics(ajaxData).then(res => {
  314. if (res.status == 200) { // eslint-disable-line
  315. this.statisticsObj = res.data
  316. } else {
  317. this.$message.error(res.message)
  318. }
  319. })
  320. },
  321. // 选中盒子
  322. chooseCard (num) {
  323. if (this.cardIndex == num) { // eslint-disable-line
  324. this.cardIndex = null
  325. var { lvCode, dealerSnList, customerSnList, ...newObj } = this.queryParam
  326. this.queryParam = newObj
  327. } else {
  328. this.cardIndex = num
  329. const obj = {
  330. lvCode: this.getShelfLeveData[num].levelName,
  331. dealerSnList: this.getShelfLeveData[num].dealerSnList || [],
  332. customerSnList: this.getShelfLeveData[num].customerSnList || []
  333. }
  334. Object.assign(this.queryParam, obj)
  335. }
  336. this.$refs.table.refresh(true)
  337. }
  338. },
  339. watch: {
  340. advanced (newValue, oldValue) {
  341. const _this = this
  342. this.$nextTick(() => { // 页面渲染完成后的回调
  343. _this.setTableH()
  344. })
  345. },
  346. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  347. this.setTableH()
  348. }
  349. },
  350. mounted () {
  351. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  352. this.pageInit()
  353. this.reset()
  354. }
  355. },
  356. activated () {
  357. // 如果是新页签打开,则重置当前页面
  358. if (this.$store.state.app.isNewTab) {
  359. this.pageInit()
  360. this.reset()
  361. }
  362. }
  363. }
  364. </script>
  365. <style lang="less">
  366. .activeuser-baseInfo{
  367. .activeuser-back{
  368. margin-bottom: 6px;
  369. }
  370. .gard-box{
  371. display: flex;
  372. > div{
  373. width: 20%;
  374. padding:0 10px;
  375. .ant-card-body{
  376. > h4,p{
  377. text-align: center;
  378. }
  379. > h4{
  380. font-size: 18px;
  381. margin: 0 0 5px;
  382. }
  383. > div{
  384. > div{
  385. display: flex;
  386. align-items: center;
  387. justify-content: space-between;
  388. padding: 2px 0;
  389. > span{
  390. &:first-child{
  391. color:#999;
  392. }
  393. }
  394. }
  395. }
  396. }
  397. }
  398. }
  399. }
  400. .chooseCard .ant-card-bordered{
  401. border:1px solid #91d5ff !important;
  402. background:#e6f7ff !important;
  403. }
  404. </style>