activeUser.vue 14 KB

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