activeUser.vue 13 KB

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