usedUser.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <div class="userd-baseInfo">
  3. <a-page-header :ghost="false" title="使用用户" :backIcon="false" class="userd-back">
  4. <template slot="subTitle">
  5. <a href="javascript:;" @click="handleBack" id="userd-handleBack">
  6. <a-icon type="left"></a-icon> 返回上页
  7. </a>
  8. </template>
  9. </a-page-header>
  10. <a-card size="small" :bordered="false">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <div ref="tableSearch" class="table-page-search-wrapper">
  13. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  14. <a-row :gutter="15">
  15. <a-col :md="5" :sm="24">
  16. <a-form-item label="货架创建时间">
  17. <rangeDate ref="rangeDate" v-model="time" @change="dateChange" />
  18. </a-form-item>
  19. </a-col>
  20. <a-col :md="5" :sm="24">
  21. <a-form-item label="汽车修理厂">
  22. <storeList ref="storeList" @change="storeChange" id="userd-storeChange"></storeList>
  23. </a-form-item>
  24. </a-col>
  25. <a-col :md="5" :sm="24">
  26. <a-form-item label="配件经销商">
  27. <dealerList ref="dealerList" @change="dealerChange" id="userd-dealerChange"></dealerList>
  28. </a-form-item>
  29. </a-col>
  30. <a-col :md="4" :sm="24">
  31. <a-form-item label="所在地">
  32. <areaList level="2" placeholder="请选择所在地" v-model="areaArr" @change="areaChange"></areaList>
  33. </a-form-item>
  34. </a-col>
  35. <template v-if="advanced">
  36. <a-col :md="4" :sm="24">
  37. <a-form-item label="货架状态">
  38. <v-select
  39. id="userd-state"
  40. code="SHELF_STATE"
  41. v-model="queryParam.shelfState"
  42. allowClear
  43. placeholder="请选择状态"
  44. :notIn="['NOT_ENABLE']"></v-select>
  45. </a-form-item>
  46. </a-col>
  47. <a-col :md="5" :sm="24">
  48. <a-form-item label="最近下单时间">
  49. <rangeDate ref="orderDate" :value="orderTime" @change="orderDateChange" />
  50. </a-form-item>
  51. </a-col>
  52. </template>
  53. <a-col :md="4" :sm="24" style="margin-bottom: 10px;">
  54. <a-button type="primary" @click="$refs.table.refresh(true)" id="userd-refresh">查询</a-button>
  55. <a-button type="" @click="reset" style="margin-left: 10px;" id="userd-reset">重置</a-button>
  56. <a-button type="primary" @click="exportFile" class="button-warning" style="margin-left: 10px;" id="userd-reset">导出</a-button>
  57. <a @click="advanced=!advanced" style="margin-left: 8px">
  58. {{ advanced ? '收起' : '展开' }}
  59. <a-icon :type="advanced ? 'up' : 'down'"/>
  60. </a>
  61. </a-col>
  62. </a-row>
  63. </a-form>
  64. </div>
  65. <div class="table-operator" v-if="countData">
  66. <a-alert type="info">
  67. <div slot="message" class="total-bar">
  68. <div>
  69. 门店数量:<strong>{{ countData.shelfCount||0 }}</strong>;
  70. 铺货数量合计:<strong>{{ countData.totalShelfMaxQty||0 }}</strong>;
  71. 铺货金额合计:<strong>{{ countData.totalShelfMaxCost||0 }}</strong>;
  72. </div>
  73. </div>
  74. </a-alert>
  75. </div>
  76. <s-table
  77. class="sTable fixPagination"
  78. ref="table"
  79. :style="{ height: tableHeight+84.5+'px', wordBreak: 'break-all' }"
  80. size="small"
  81. :columns="columns"
  82. :data="loadData"
  83. :scroll="{ y: tableHeight }"
  84. :defaultLoadData="false"
  85. bordered>
  86. <div slot="area" slot-scope="text, record">
  87. {{ record.dealerProvinceName }} {{ record.dealerCityName }}
  88. </div>
  89. <span slot="customTitle">
  90. <a-popover>
  91. <template slot="content">
  92. 表示此修理厂最近一次从货架上取货的时间
  93. </template>
  94. <a-icon type="question-circle" theme="twoTone" />
  95. </a-popover>
  96. 最近下单时间
  97. </span>
  98. </s-table>
  99. </a-spin>
  100. </a-card>
  101. </div>
  102. </template>
  103. <script>
  104. import { STable, VSelect } from '@/components'
  105. import rangeDate from '@/views/common/rangeDate.vue'
  106. import { useUserQueryPage, useUserStatistics, exportShelfUseUser } from '@/api/report.js'
  107. import areaList from '@/views/common/areaList.js'
  108. import dealerList from '@/views/common/dealerList.vue'
  109. import storeList from '@/views/common/storeList.vue'
  110. import { hdExportExcel } from '@/libs/exportExcel'
  111. import { toThousands } from '@/libs/tools.js'
  112. export default {
  113. name: 'UserList',
  114. components: { STable, VSelect, rangeDate, dealerList, storeList, areaList },
  115. data () {
  116. return {
  117. spinning: false,
  118. advanced: false,
  119. tableHeight: 0,
  120. areaArr: [],
  121. time: [],
  122. orderTime: [],
  123. // 查询参数
  124. queryParam: {
  125. shelfCreateBeginDate: '',
  126. shelfCreateEndDate: '',
  127. lastOrderBeginDate: '',
  128. lastOrderEndDate: '',
  129. storeSn: undefined,
  130. dealerSn: undefined,
  131. shelfState: undefined,
  132. dealerProvinceSn: undefined,
  133. dealerCitySn: undefined
  134. },
  135. showModal: false,
  136. itemData: null, // 编辑行数据
  137. countData: null,
  138. openStatusModal: false, // 货架状态弹窗初始状态
  139. // 表头
  140. columns: [
  141. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  142. { title: '货架创建时间', dataIndex: 'shelfCreateDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  143. { title: '汽车修理厂', dataIndex: 'storeName', width: '15%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  144. { title: '配件经销商', dataIndex: 'dealerName', width: '15%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  145. { title: '所在地', scopedSlots: { customRender: 'area' }, width: '11%', align: 'center' },
  146. { title: '货架状态', dataIndex: 'shelfStateDictValue', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  147. { title: '铺货数量', dataIndex: 'totalShelfMaxQty', width: '11%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
  148. { title: '铺货金额', dataIndex: 'totalShelfMaxCost', width: '11%', align: 'center', customRender: function (text) { return (text || text == 0) ? toThousands(text, 2) : '--' } },
  149. { slots: { title: 'customTitle' }, dataIndex: 'lastOrderDate', width: '11%', align: 'center', customRender: function (text) { return text || '--' } }
  150. ],
  151. // 加载数据方法 必须为 Promise 对象
  152. loadData: parameter => {
  153. this.spinning = true
  154. const params = Object.assign(parameter, this.queryParam)
  155. return useUserQueryPage(params).then(res => {
  156. let data
  157. if (res.status == 200) {
  158. data = res.data
  159. const no = (data.pageNo - 1) * data.pageSize
  160. for (let i = 0; i < data.list.length; i++) {
  161. const _item = data.list[i]
  162. _item.no = no + i + 1
  163. }
  164. }
  165. this.getCount(params)
  166. this.spinning = false
  167. return data
  168. })
  169. }
  170. }
  171. },
  172. methods: {
  173. handleBack () {
  174. this.$router.go(-1)
  175. },
  176. getCount (params) {
  177. useUserStatistics(params).then(res => {
  178. this.countData = res.data || null
  179. })
  180. },
  181. // 地区
  182. areaChange (val, opts) {
  183. this.queryParam.dealerProvinceSn = val && val[0] ? val[0] : ''
  184. this.queryParam.dealerCitySn = val && val[1] ? val[1] : ''
  185. },
  186. // 时间 change
  187. dateChange (date) {
  188. this.queryParam.shelfCreateBeginDate = date[0]
  189. this.queryParam.shelfCreateEndDate = date[1]
  190. },
  191. // 时间 change
  192. orderDateChange (date) {
  193. this.queryParam.lastOrderBeginDate = date[0]
  194. this.queryParam.lastOrderEndDate = date[1]
  195. },
  196. // 经销商 change
  197. dealerChange (obj) {
  198. this.queryParam.dealerSn = obj.key || undefined
  199. },
  200. // 汽车修理厂 change
  201. storeChange (obj) {
  202. this.queryParam.storeSn = obj.key || undefined
  203. },
  204. // 导出
  205. exportFile () {
  206. const _this = this
  207. this.spinning = true
  208. hdExportExcel(exportShelfUseUser, this.queryParam, '用户分析(使用用户)详情', function () {
  209. _this.spinning = false
  210. })
  211. },
  212. // 重置
  213. reset () {
  214. this.queryParam = {
  215. shelfCreateBeginDate: '',
  216. shelfCreateEndDate: '',
  217. lastOrderBeginDate: '',
  218. lastOrderEndDate: '',
  219. storeSn: undefined,
  220. dealerSn: undefined,
  221. shelfState: undefined,
  222. dealerProvinceSn: undefined,
  223. dealerCitySn: undefined
  224. }
  225. this.areaArr = []
  226. this.$refs.rangeDate.resetDate()
  227. if (this.advanced) {
  228. this.$refs.orderDate.resetDate()
  229. }
  230. this.$refs.dealerList.resetForm()
  231. this.$refs.storeList.resetForm()
  232. this.$refs.table.refresh(true)
  233. },
  234. pageInit () {
  235. const _this = this
  236. this.$nextTick(() => { // 页面渲染完成后的回调
  237. _this.setTableH()
  238. })
  239. },
  240. setTableH () {
  241. const tableSearchH = this.$refs.tableSearch.offsetHeight
  242. this.tableHeight = window.innerHeight - tableSearchH - 255
  243. }
  244. },
  245. watch: {
  246. advanced (newValue, oldValue) {
  247. const _this = this
  248. this.$nextTick(() => { // 页面渲染完成后的回调
  249. _this.setTableH()
  250. })
  251. },
  252. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  253. this.setTableH()
  254. }
  255. },
  256. mounted () {
  257. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  258. this.pageInit()
  259. this.reset()
  260. }
  261. },
  262. activated () {
  263. // 如果是新页签打开,则重置当前页面
  264. if (this.$store.state.app.isNewTab) {
  265. this.pageInit()
  266. this.reset()
  267. }
  268. }
  269. }
  270. </script>
  271. <style lang="less">
  272. .userd-baseInfo{
  273. .userd-back{
  274. margin-bottom: 6px;
  275. }
  276. }
  277. </style>