From 7945ea51724d51a6c55fe2ea824849260c8b307a Mon Sep 17 00:00:00 2001 From: "liujw155@outlook.com" Date: Mon, 21 Sep 2020 19:17:44 +0800 Subject: [PATCH] add api --- src/js/api.js | 3 +- src/pages.json | 14 +- src/pages/collection/detail/detail.vue | 108 ++++++- src/pages/collection/record/record.vue | 139 +++++++-- .../employee/authority_filter/authority_filter.vue | 326 ++++++++++++++++----- .../employee/authority_select/authority_select.vue | 103 ++++++- src/pages/employee/manage/manage.vue | 40 ++- src/pages/employee/review_list/review_list.vue | 116 ++++++-- 8 files changed, 689 insertions(+), 160 deletions(-) diff --git a/src/js/api.js b/src/js/api.js index 79079b0..ec96a06 100644 --- a/src/js/api.js +++ b/src/js/api.js @@ -14,6 +14,7 @@ export const API = { collectionRecord:`${ORIGIN}/admin/assistant/collection/record`, // 收款记录 + collectionDetails:`${ORIGIN}/admin/assistant/collection/details`, // 收款记录-收款明细 reservationOrder:`${ORIGIN}/admin/stadium/order/list`, // 预约订单 @@ -31,7 +32,7 @@ API['employee'] = { employeeAdd:`${ORIGIN}/assistant/employee/add`, // 添加员工-填写信息 employeeList:`${ORIGIN}/admin/assistant/employee/list`, // 员工列表 employeeDelete:`${ORIGIN}/admin/assistant/employee/delete`, // 移除员工 - employeeGrant:`${ORIGIN}/admin/assistant/employee/grant`, // 员工授权 + employeeGrant:`${ORIGIN}/admin/assistant/employee/grant`, // 员工授权/审核 adminReplace:`${ORIGIN}/admin/assistant/replace`, // 更换管理员 employeeUnreview:`${ORIGIN}/admin/assistant/employee/unreview`, // 未审核员工列表 diff --git a/src/pages.json b/src/pages.json index 03e3dbc..06d46c0 100644 --- a/src/pages.json +++ b/src/pages.json @@ -1,12 +1,17 @@ { "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages - { "path": "pages/index/index", "style": { } }, { + "path": "pages/employee/authority_filter/authority_filter", + "style": { + "navigationBarTitleText": "员工筛选" + } + }, + { "path": "pages/employee/perfect_info/perfect_info", "style": { "navigationBarTitleText": "员工信息" @@ -79,12 +84,7 @@ "navigationBarTitleText": "员工管理" } }, - { - "path": "pages/employee/authority_filter/authority_filter", - "style": { - "navigationBarTitleText": "员工筛选" - } - }, + { "path": "pages/employee/authority_select/authority_select", "style": { diff --git a/src/pages/collection/detail/detail.vue b/src/pages/collection/detail/detail.vue index f1949a5..e21bec1 100644 --- a/src/pages/collection/detail/detail.vue +++ b/src/pages/collection/detail/detail.vue @@ -1,17 +1,17 @@ diff --git a/src/pages/collection/record/record.vue b/src/pages/collection/record/record.vue index 1a0b418..71ab0d7 100644 --- a/src/pages/collection/record/record.vue +++ b/src/pages/collection/record/record.vue @@ -2,32 +2,32 @@ 当前所在门店 - + - + - + - 2020年8月 + {{curDate.year || 0}}年{{curDate.month || 0}}月 - 共139笔 - 收入 ¥ 10899.34 - 退款 ¥ 99.34 + 共{{ (recordTotalInfo.in_total || 0) + (recordTotalInfo.out_total || 0) }}笔 + 收入 ¥ {{recordTotalInfo.in_amount || 0}} + 退款 ¥ {{recordTotalInfo.out_amount || 0}} - - 8月15日 - ¥1242.00 + + {{e.date || '-'}} + ¥{{e.sum || 0}} - 收款100笔(¥1089.00),退款2笔(¥234.00) + 收款{{e.in_count || 0}}笔(¥{{e.in_sum || 0}}),退款{{e.out_count || 0}}笔(¥{{e.out_sum || 0}}) @@ -39,30 +39,131 @@ import { API } from '../../../js/api' import { servers } from '../../../js/server' import util from '../../../utils/util' +import { mapState } from 'vuex'; export default { + computed: { + ...mapState(['brandInfo']), + timerArr(){ + let _curDate = new Date(); + return [ + new Array(5).fill(1).map((e,i)=>_curDate.getFullYear()-i), + new Array(12).fill(1).map((e,i)=>util.formatNumber(i+1)) + ] + }, + }, data(){ return { + storeList: [], + curStore: {}, + curDate: {}, recordList: [], + recordTotalInfo: {}, + } + }, + async onLoad(){ + try{ + util.showLoad(); + let _curDate = this.getCurDate(); + this.curDate = _curDate; + let _storeList = await this.getStoreList(); + this.curStore = _storeList[0] || {}; + this.getRecordList({ + stadium_id: _storeList[0].id || '', + date: `${_curDate.year}-${_curDate.month}` + }); + + util.hideLoad(); + }catch(err){ + util.hideLoad(); } }, methods: { - getRecordList({ - date - }){ - servers.get({ + async dateChange(e){ + try{ + util.showLoad(); + let { timerArr, curStore } = this; + let { value } = e.detail + let _curDate = { + year: timerArr[0][value[0]], + month: timerArr[1][value[1]], + } + await this.getRecordList({ + stadium_id: curStore.id || '', + date: `${_curDate.year}-${_curDate.month}` + }); + + this.curDate = _curDate; + util.hideLoad(); + }catch(err){ + util.hideLoad(); + console.warn('dateChange err',err) + } + + }, + async storeChange(e){ + try{ + util.showLoad(); + let { curDate, storeList } = this; + await this.getRecordList({ + stadium_id: storeList[e.detail.value].id || '', + date: `${curDate.year}-${curDate.month}` + }); + this.curStore = storeList[e.detail.value]; + util.hideLoad(); + }catch(err){ + util.hideLoad(); + console.warn('dateChange err',err) + } + }, + getCurDate(){ + let _curDate = new Date(); + return { + year: _curDate.getFullYear(), + month: util.formatNumber(_curDate.getMonth()+1), + } + }, + getStoreList(){ + let { brandInfo } = this; + return servers.get({ + url: API.stadiumList, + data: { + brand_id: brandInfo.brand.id, + }, + failMsg: '加载店铺列表失败!', + + }) + .then(res=>{ + let _list = res.list || []; + return this.storeList = _list; + }) + }, + getRecordList({ date='', stadium_id='' }){ + return servers.get({ url: API.collectionRecord, data: { date, - date, + stadium_id, }, failMsg: '加载失败!' }) .then(res=>{ - this.recordList = res.list; + let { list, ...totalInfo} = res; + this.recordList = list || []; + this.recordTotalInfo = totalInfo || {}; + return res; }) }, - toDetail(){ - util.routeTo(`/pages/collection/detail/detail`,'nT'); + toDetail(e){ + let { curStore, curDate } = this; + let _query = { + detail: e, + store: { + id: curStore.id, + name: curStore.name + } + } + + util.routeTo(`/pages/collection/detail/detail?query=${util.jsonStr(_query)}`,'nT'); } } } diff --git a/src/pages/employee/authority_filter/authority_filter.vue b/src/pages/employee/authority_filter/authority_filter.vue index 556eb03..145bca4 100644 --- a/src/pages/employee/authority_filter/authority_filter.vue +++ b/src/pages/employee/authority_filter/authority_filter.vue @@ -1,58 +1,170 @@