diff --git a/CHANGELOG.md b/CHANGELOG.md index b8f18fd..02162ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ --|--|-- - | 标题栏变化 | [c0fcd9d](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/c0fcd9d) - | 标题栏角色栏全局任务组件新建 | [0500cb4](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/0500cb4) + - | 存token | [b8a178d](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/b8a178d) - | 角色栏实现 | [94cd671](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/94cd671) - | 模拟接口测试 | [69e7931](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/69e7931) - | 时间基准线,默认插件 | [a33ba1e](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/a33ba1e) diff --git a/src/apis/project.js b/src/apis/project.js index 86794ca..5e95104 100644 --- a/src/apis/project.js +++ b/src/apis/project.js @@ -1,9 +1,17 @@ const apiUrl = process.env.VUE_APP_API_URL; const tall = `${apiUrl}/defaultwbs`; +const project = `${tall}/project`; +const role = `${tall}/role`; +const task = `${tall}/task`; const install = (Vue, vm) => { vm.$u.api = { ...vm.$u.api } || {}; - vm.$u.api.findProjectById = params => vm.$u.post(`${tall}/project/findProjectById`, params); + //根据id获取项目信息 + vm.$u.api.findProjectById = params => vm.$u.post(`${project}/findProjectById`, params); + //查询角色栏展示的角色 + vm.$u.api.findShowRoles = params => vm.$u.post(`${role}/show`, params); + //根据时间基准点和角色查找定期任务 + vm.$u.api.getRegularTask = params => vm.$u.post(`${task}/regular`, params); }; export default { install }; diff --git a/src/components/Globals/Globals.vue b/src/components/Globals/Globals.vue index f8547ef..07a010f 100644 --- a/src/components/Globals/Globals.vue +++ b/src/components/Globals/Globals.vue @@ -1,7 +1,6 @@ @@ -36,14 +32,15 @@ export default { name: 'Global', components: { Skeleton }, data() { - return { loading: true }; + return { loading: false }; }, computed: mapState('home', ['isShrink']), mounted() { + this.loading = true; setTimeout(() => { this.loading = false; console.log('this.loading: ', this.loading); - }, 5000); + }, 10000); }, }; diff --git a/src/components/Project/Project.vue b/src/components/Project/Project.vue deleted file mode 100644 index 6d9bdf1..0000000 --- a/src/components/Project/Project.vue +++ /dev/null @@ -1,22 +0,0 @@ - - - diff --git a/src/components/Project/component/TimeBar.vue b/src/components/Project/component/TimeBar.vue deleted file mode 100644 index 07e8824..0000000 --- a/src/components/Project/component/TimeBar.vue +++ /dev/null @@ -1,37 +0,0 @@ - - - - - diff --git a/src/components/Project/component/TimeLine.vue b/src/components/Project/component/TimeLine.vue deleted file mode 100644 index ea53320..0000000 --- a/src/components/Project/component/TimeLine.vue +++ /dev/null @@ -1,80 +0,0 @@ - - - - - diff --git a/src/components/Roles/component/RoleList.vue b/src/components/Roles/component/RoleList.vue index 2b9b27a..d4ad52f 100644 --- a/src/components/Roles/component/RoleList.vue +++ b/src/components/Roles/component/RoleList.vue @@ -3,8 +3,8 @@ - - {{ item.name }} + + {{ item.name }} @@ -14,6 +14,8 @@ diff --git a/src/mock/mock.js b/src/mock/mock.js index f8b784b..c0dcf1f 100644 --- a/src/mock/mock.js +++ b/src/mock/mock.js @@ -95,11 +95,39 @@ export default [ ], //展示的角色 visibleList: [ { - id: 12345678932165, + id: 1, + name: '项目经理', mine: 0, - name: 'string', + pm: 1, + sequence: 1, + }, + { + id: 2, + name: '运维', + mine: 0, + pm: 0, + sequence: 2, + }, + { + id: 3, + name: '导师一', + mine: 1, + pm: 0, + sequence: 3, + }, + { + id: 4, + name: '导师二', + mine: 1, + pm: 0, + sequence: 4, + }, + { + id: 5, + name: '导师三', + mine: 1, pm: 0, - sequence: 22, + sequence: 5, }, ], }, diff --git a/src/pages/project/project.vue b/src/pages/project/project.vue index fbff5fd..5457559 100644 --- a/src/pages/project/project.vue +++ b/src/pages/project/project.vue @@ -16,18 +16,27 @@ export default { return { title: 'Hello', height: '', scrollHeight: null }; }, - computed: { ...mapState('user', ['user', 'token']) }, + computed: { + ...mapState('user', ['user', 'token']), + ...mapState('home', ['visibleRoles', 'roleId', 'timeNode', 'timeUnit']), + }, - onLoad(options) { + async onLoad(options) { console.log('options: ', options); - console.log(this.$u.config.v); // this.openPage(); - // DEBUG: - - this.getUserId('1217651354919636992'); - - const params = { param: { projectId: '1235555' } }; - this.$u.api.findProjectById(params); + let TOKEN = uni.getStorageSync('anyringToken'); + if (!TOKEN) { + await this.getUserId('1217651354919636992'); + } + const params = { projectId: '1235555' }; + // 根据项目id获取项目信息 + await this.getProjectById(params); + // 根据项目id获取角色列表 + await this.getRoles(params); + console.log('this.visibleRoles: ', this.visibleRoles); + this.setInitialRoleId(this.visibleRoles); + // 根据时间基准点和角色查找定期任务 + await this.getTasks(); }, mounted() { @@ -36,12 +45,42 @@ export default { methods: { ...mapMutations('user', ['setToken', 'setUser']), + ...mapMutations('home', ['setProject', 'setInvisibleRoles', 'setVisibleRoles', 'setRoleId']), ...mapActions('user', ['getUserId']), + ...mapActions('home', ['getProjectById', 'getRoles', 'handleRegularTask']), openPage() { console.log('open'); this.$u.route('/pages/pinch/pinch'); }, + + // 设置 初始显示角色信息 + setInitialRoleId(visibleList) { + const index = visibleList.findIndex(item => item.mine); + const currentRole = index > 0 ? visibleList[index] : visibleList[0]; + const currentRoleId = currentRole ? currentRole.id : ''; + this.setRoleId(currentRoleId); + }, + + /** + * 根据时间基准点和角色查找定期任务 + * @param {string} roleId 角色id + * @param {string} timeNode 时间基准点 默认当前 + * @param {string} timeUnit 时间颗粒度 默认天 + */ + async getTasks() { + try { + const { roleId, timeNode, timeUnit } = this; + const params = { + roleId, + timeNode, + timeUnit, + }; + await this.handleRegularTask(params); + } catch (error) { + console.log('error: ', error); + } + }, }, }; diff --git a/src/store/home/actions.js b/src/store/home/actions.js index 5dfa3d4..b0269d3 100644 --- a/src/store/home/actions.js +++ b/src/store/home/actions.js @@ -1,3 +1,52 @@ -const actions = {}; +const actions = { + /** + * 通过项目id获取项目信息 + * @param {any} commit + * @param {object} params 提交的参数 + */ + async getProjectById({ commit }, params) { + try { + uni.$u.api.findProjectById(params).then(res => { + commit('setProject', res); + return res; + }); + } catch (error) { + throw error || '获取项目信息失败'; + } + }, + + /** + * 通过项目id获取角色信息 + * @param {any} commit + * @param {object} params 提交的参数 + */ + async getRoles({ commit }, params) { + try { + const res = await uni.$u.api.findShowRoles(params); + commit('setInvisibleRoles', res.invisibleList); + commit('setVisibleRoles', res.visibleList); + return res; + } catch (error) { + throw error || '获取角色信息失败'; + } + }, + + /** + * 根据时间基准点和角色查找定期任务 + * @param {string} roleId 角色id + * @param {string} timeNode 时间基准点 默认当前 + * @param {string} timeUnit 时间颗粒度 默认天 + */ + async handleRegularTask({ commit }, params) { + try { + uni.$u.api.getRegularTask(params).then(res => { + commit('setTasks', res); + return res; + }); + } catch (error) { + throw error || '获取定期任务失败'; + } + }, +}; export default actions; diff --git a/src/store/home/mutations.js b/src/store/home/mutations.js index ae53b1d..ac50bb7 100644 --- a/src/store/home/mutations.js +++ b/src/store/home/mutations.js @@ -47,6 +47,67 @@ const mutations = { setTipsContent(state, data) { state.tipsContent = data; }, + /** + * 设置当前项目信息 + * @param { object } state + * @param { object } data + */ + setProject(state, data) { + state.project = { ...data }; + }, + /** + * 设置不展示的角色信息 + * @param {Object} state + * @param {Array} data 服务端返回的模板数组 + */ + setInvisibleRoles(state, data) { + state.invisibleRoles = data || []; + }, + + /** + * 设置展示的角色信息 + * @param {Object} state + * @param {Array} data 服务端返回的模板数组 + */ + setVisibleRoles(state, data) { + state.visibleRoles = data || []; + }, + + /** + * 设置当前角色信息 + * @param {Object} state + * @param {string} roleId 当前正在展示的角色的id + */ + setRoleId(state, roleId) { + state.roleId = roleId; + }, + + /** + * 设置时间基准点 + * @param { object } state + * @param { number } data + */ + setTimeNode(state, data) { + state.timeNode = data; + }, + + /** + * 设置时间颗粒度 + * @param { object } state + * @param { number } data + */ + setTimeUnit(state, data) { + state.timeUnit = data; + }, + + /** + * 设置定期任务数据 + * @param {Object} state + * @param {Array} data 服务端返回的模板数组 + */ + setTasks(state, data) { + state.tasks = data || []; + }, }; export default mutations; diff --git a/src/store/home/state.js b/src/store/home/state.js index 33e99c3..232ad33 100644 --- a/src/store/home/state.js +++ b/src/store/home/state.js @@ -8,6 +8,28 @@ const state = { showTips: false, status: 0, // 点击了时间轴上的哪种样式,默认点击了开始 tipsContent: '', // 提示框内的内容,需要传入 + project: { name: '加载中...' }, // 当前项目信息 + invisibleRoles: [], // 不展示的角色信息 + visibleRoles: [], // 展示的角色信息 + roleId: '', // 当前展示查看的角色id + timeNode: new Date().getTime(), // 时间基准点 + timeUnit: 4, // // 时间颗粒度 + timeUnits: [ + // 时间颗粒度 + { id: 0, value: '毫秒' }, + { id: 1, value: '秒' }, + { id: 2, value: '分' }, + { id: 3, value: '时' }, + { id: 4, value: '天' }, + { id: 5, value: '周' }, + { id: 6, value: '月' }, + { id: 7, value: '季度' }, + { id: 8, value: '年' }, + { id: 9, value: '年代' }, + { id: 10, value: '世纪' }, + { id: 11, value: '千年' }, + ], + tasks: [], // 定期任务 }; export default state; diff --git a/src/utils/request.js b/src/utils/request.js index 81c47c7..9a0680d 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -41,6 +41,15 @@ const install = (Vue, vm) => { return false; } }; + + Vue.prototype.$u.post = (url, param = {}, header = {}) => { + return Vue.prototype.$u.http.request({ + url, + method: 'POST', + header, + data: { param }, + }); + }; }; export default { install };