Browse Source

feat: 默认选择上次退出项目时的角色

carbasic
aBin 4 years ago
parent
commit
a695868484
  1. 6
      .env.development
  2. 6
      .env.production
  3. 3
      CHANGELOG.md
  4. 27
      src/apis/role.js
  5. 75
      src/components/Globals/Globals.vue
  6. 3
      src/components/Guide/Guide.vue
  7. 8
      src/components/Roles/Roles.vue
  8. 53
      src/pages/project/project.vue
  9. 1
      src/store/role/mutations.js

6
.env.development

@ -1,4 +1,4 @@
VUE_APP_NODE_ENV=development
VUE_APP_BASE_URL=https://www.tall.wiki/
VUE_APP_API_URL=https://www.tall.wiki/gateway
VUE_APP_MSG_URL=wss://www.tall.wiki/websocket/message/v4.0/ws
VUE_APP_BASE_URL=https://test.tall.wiki/
VUE_APP_API_URL=https://test.tall.wiki/gateway
VUE_APP_MSG_URL=wss://test.tall.wiki/websocket/message/v4.0/ws

6
.env.production

@ -1,4 +1,4 @@
VUE_APP_NODE_ENV=production
VUE_APP_BASE_URL=https://www.tall.wiki/
VUE_APP_API_URL=https://www.tall.wiki/gateway
VUE_APP_MSG_URL=wss://www.tall.wiki/websocket/message/v4.0/ws
VUE_APP_BASE_URL=https://test.tall.wiki/
VUE_APP_API_URL=https://test.tall.wiki/gateway
VUE_APP_MSG_URL=wss://test.tall.wiki/websocket/message/v4.0/ws

3
CHANGELOG.md

@ -1,4 +1,4 @@
# 0.1.0 (2021-11-08)
# 0.1.0 (2021-11-19)
### 🌟 新功能
范围|描述|commitId
@ -25,6 +25,7 @@
- | 面变化首页变化 | [5e860f1](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/5e860f1)
- | 模拟接口测试 | [69e7931](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/69e7931)
- | 配置默认插件接口 | [f0c177d](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/f0c177d)
- | 切换角色时,取消显示多角色下拉框 | [4a57c0c](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/4a57c0c)
- | 全局插件及默认插件位置修改 | [6c80d08](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/6c80d08)
- | 任务进行中状态数字 | [27b7326](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/27b7326)
- | 任务状态时间显示 | [56f5183](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/56f5183)

27
src/apis/role.js

@ -12,10 +12,37 @@ export const queryMustShow = {
},
};
export const queryLastRoleChoose = {
async index(params) {
try {
/* #endif */
const data = await uni.$u.http.post(`${url}/carbasics/v4.0/role/queryLastRoleChoose`, params);
return data;
} catch (error) {
throw new Error(error);
}
},
};
export const saveRoleRecord = {
async index(params) {
try {
/* #endif */
await uni.$u.http.post(`${url}/carbasics/v4.0/role/saveRoleRecord`, params);
} catch (error) {
throw new Error(error);
}
},
};
const install = (Vue, vm) => {
vm.$u.api = { ...vm.$u.api } || {};
// 根据项目id查找所有体验角色
vm.$u.api.queryMustShow = params => queryMustShow.index(params);
// 根据项目id查找上次退出项目时所选择的角色
vm.$u.api.queryLastRoleChoose = params => queryLastRoleChoose.index(params);
// 保存当前用户在当前项目最后一次选择的角色
vm.$u.api.saveRoleRecord = params => saveRoleRecord.index(params);
// 根据项目id查找角色
vm.$u.api.findShowRole = param => vm.$u.post(`${uni.$t.domain}/role/show`, param);
// 根据项目id查找所有成员

75
src/components/Globals/Globals.vue

@ -1,12 +1,17 @@
<template>
<view :class="organData && organData.organizationType === 0 ? 'organ-box' : 'm-2'" v-if="globals && globals.length">
<view :class="organData && organData.organizationType === 0 ? 'organ-box' : ''" v-if="globals && globals.length">
<!-- <u-card @click="openCard" :show-foot="false" :show-head="false" style="max-height: 218rpx" border-radius="25" margin="0"> -->
<!-- :style="{ 'max-height': isShrink ? '106rpx' : '340rpx' }" -->
<!-- <div> -->
<!-- <u-tabs v-if="globals.length > 1" :list="globals" :is-scroll="false" :current="current" @change="change"></u-tabs> -->
<u-subsection :list="globalTabs" :current="current" @change="change"></u-subsection>
<!-- </div> -->
<u-card
v-if="!showLine"
@click="openCard"
:show-foot="false"
:show-head="false"
:style="{ 'min-height': '42px', 'max-height': organData && organData.organizationType === 0 ? '100vh' : globalsHeight + 'px' }"
:style="{ height: organData && organData.organizationType === 0 ? '100vh' : globalsHeight + 'px' }"
:border-radius="organData && organData.organizationType === 0 ? 0 : 25"
margin="0"
:padding="organData && organData.organizationType === 0 ? 0 : 15"
@ -15,32 +20,33 @@
<scroll-view
:scrollY="true"
:style="{
'min-height': '24rpx',
'max-height': organData && organData.organizationType === 0 ? '100vh' : globalsHeight - 30 + 'px',
height: organData && organData.organizationType === 0 ? '100vh' : globalsHeight - 30 + 'px',
}"
>
<!-- <scroll-view :scrollY="true" style="max-height: 280rpx"> -->
<!-- <scroll-view :scrollY="true" :style="{ 'max-height': isShrink ? '50rpx' : '280rpx' }"> -->
<skeleton :banner="false" :loading="!globals.length" :row="4" animate class="u-line-2 skeleton"></skeleton>
<view class="grid gap-2">
<block v-for="item in globals" :key="item.id">
<template v-if="item.plugins">
<block v-for="(pluginArr, i) in item.plugins" :key="i">
<template class="p-0 u-col-between" v-if="pluginArr.length">
<Plugin
:class="[`row-span-${plugin.row}`, `col-span-${plugin.col}`]"
:task="item"
:key="plugin.pluginTaskId"
:plugin-task-id="plugin.pluginTaskId"
:plugin-id="plugin.pluginId"
:param="plugin.param"
:style-type="plugin.styleType || 0"
v-for="plugin in pluginArr"
/>
</template>
</block>
</template>
</block>
<template v-if="global.length">
<block v-for="item in global" :key="item.id">
<template v-if="item.plugins">
<block v-for="(pluginArr, i) in item.plugins" :key="i">
<template class="p-0 u-col-between" v-if="pluginArr.length">
<Plugin
:class="[`row-span-${plugin.row}`, `col-span-${plugin.col}`]"
:task="item"
:key="plugin.pluginTaskId"
:plugin-task-id="plugin.pluginTaskId"
:plugin-id="plugin.pluginId"
:param="plugin.param"
:style-type="plugin.styleType || 0"
v-for="plugin in pluginArr"
/>
</template>
</block>
</template>
</block>
</template>
</view>
</scroll-view>
</view>
@ -63,6 +69,10 @@ export default {
// loading: true,
task: null,
sysHeight: sysHeight,
current: 0,
global: [],
globalTabs: [],
showLine: false,
};
},
@ -72,11 +82,16 @@ export default {
...mapGetters('task', ['globals']),
globalsHeight: function () {
let h = ((this.sysHeight - 44 - 30 - 10) / 5) * 3;
let h = this.sysHeight;
return h;
},
},
created() {
console.log('this.globals: ', this.globals);
this.global[0] = this.globals[0];
const list = [{ name: '时间轴' }];
this.globalTabs = [...this.globals, ...list];
},
methods: {
...mapMutations('task', ['setShrink']),
@ -86,6 +101,18 @@ export default {
this.setShrink(false);
}
},
change(e) {
console.log('e: ', e);
this.current = e;
if (e !== this.globals.length) {
this.global[0] = this.globals[e];
this.$emit('changeShowLine', false);
this.showLine = false;
} else {
this.$emit('changeShowLine', true);
this.showLine = true;
}
},
},
};
</script>

3
src/components/Guide/Guide.vue

@ -25,7 +25,8 @@ export default {
.guide-img {
width: 730rpx;
position: absolute;
top: calc(72px + 60rpx);
top: calc(28px + 60rpx);
/* top: calc(72px + 60rpx); */
margin-left: 10rpx;
}
.guide-button {

8
src/components/Roles/Roles.vue

@ -58,7 +58,7 @@
</template>
<script>
import { mapState, mapMutations, mapActions } from 'vuex';
import { mapState, mapMutations, mapActions, mapGetters } from 'vuex';
export default {
name: 'Roles',
@ -81,6 +81,7 @@ export default {
computed: {
...mapState('role', ['visibleRoles', 'invisibleRoles', 'roleId']),
...mapState('task', ['tasks']),
...mapGetters('project', ['projectId']),
},
watch: {
@ -177,10 +178,13 @@ export default {
changeRole(id, index) {
try {
this.isActive = false;
const { projectId } = this;
// script
this.clearPluginScript();
this.$nextTick(() => {
this.$nextTick(async () => {
this.setRoleId(id);
const saveParams = { param: { roleId: id, projectId } };
await uni.$u.api.saveRoleRecord(saveParams);
// index
this.setCurrentRole(index);
});

53
src/pages/project/project.vue

@ -1,21 +1,21 @@
<template>
<view :style="{ height: height }" class="flex flex-col overflow-hidden u-font-14">
<!-- 引导页 -->
<Guide v-if="showGuide" @changGuide="showGuide = false" />
<!-- <Guide v-if="showGuide" @changGuide="showGuide = false" /> -->
<!-- 标题栏 -->
<Title />
<!-- <Title /> -->
<view class="container flex flex-col flex-1 mx-auto overflow-hidden bg-gray-100">
<!-- 角色栏 -->
<Roles />
<!-- 体验项目切换角色 -->
<Experience v-if="showEXP" />
<!-- <Experience v-if="showEXP" /> -->
<Greenway v-if="greenMsgs.length" />
<!-- 日常任务面板 -->
<Globals />
<Globals v-if="globals.length" @changeShowLine="changeShowLine" />
<!-- 定期任务面板 -->
<TimeLine @getTasks="getTasks" class="flex-1 overflow-hidden" ref="timeLine" />
<TimeLine v-if="!globals.length || showLine" @getTasks="getTasks" class="flex-1 overflow-hidden" ref="timeLine" />
<!-- 医院项目的问卷悬浮按钮 -->
<view style="z-index: 99" class="absolute bottom-10 right-5" v-if="name">
@ -24,26 +24,7 @@
class="relative text-white bg-blue-400 flex justify-center items-center w-12 h-12 rounded-full shadow-2xl"
>
{{ name }}
<!-- <u-badge type="error" :count="count" :offset="[-8, -8]"></u-badge> -->
</view>
<!-- <u-popup v-model="showQuestionList" mode="bottom" border-radius="14">
<view class="h-64">
<view class="text-center font-bold fixed bg-white py-3 top-0 w-full">请选择</view>
<view class="flex flex-col mx-3 pt-10 pb-6 h-full overflow-y-auto" :class="questionnaires.length < 5 ? 'justify-center' : ''">
<view
v-for="(item, index) in questionnaires"
:key="item.id"
class="p-2 text-center"
@click="openQuestionnaire(true, item.type)"
:class="index === questionnaires.length - 1 ? '' : 'border-b'"
>
<view class="text-gray-500">{{ item.questionnaireName }}</view>
</view>
</view>
<view class="fixed bottom-0 bg-white h-6 w-full"></view>
</view>
</u-popup> -->
</view>
</view>
</view>
@ -70,6 +51,7 @@ export default {
url: '',
showStatus: 0,
detailId: '',
showLine: false,
};
},
@ -79,7 +61,7 @@ export default {
...mapState('task', ['timeNode', 'timeUnit', 'tasks', 'regularTask', 'newProjectInfo', 'showSkeleton', 'showScrollTo']),
...mapState('messages', ['greenMsgs']),
...mapState('project', ['project']),
...mapGetters('task', ['timeGranularity']),
...mapGetters('task', ['timeGranularity', 'globals']),
...mapGetters('project', ['projectId']),
...mapGetters('user', ['userId']),
},
@ -187,6 +169,11 @@ export default {
'setShowScrollTo',
]),
//
changeShowLine(status) {
this.showLine = status;
},
//
async initPlanTasks() {
this.setPrevPlaceholderTasks(); //
@ -387,6 +374,7 @@ export default {
if (!options || !options.p) {
this.$t.ui.showToast('缺少项目信息参数'); // id
} else {
uni.setNavigationBarTitle({ title: options.pname });
if (options.p !== this.$t.storage.getStorageSync('projectId')) {
console.log('切项目了');
this.$t.storage.setStorageSync('roleId', '');
@ -467,13 +455,22 @@ export default {
},
//
setInitialRoleId(visibleList) {
async setInitialRoleId(visibleList) {
if (!visibleList || !visibleList.length) return;
const index = visibleList.findIndex(item => +item.mine === 1);
const currentRole = index > 0 ? visibleList[index] : visibleList[0];
const storageRoleId = this.$t.storage.getStorageSync('roleId');
const currentRoleId = storageRoleId ? storageRoleId : currentRole ? currentRole.id : '';
this.setRoleId(currentRoleId);
const params = { param: { projectId: this.projectId } };
const data = await uni.$u.api.queryLastRoleChoose(params);
console.log('data: ', data);
if (data && data.roleId) {
this.setRoleId(data.roleId);
} else {
const saveParams = { param: { roleId: currentRoleId, projectId: this.projectId } };
await uni.$u.api.saveRoleRecord(saveParams);
const currentRoleId = storageRoleId ? storageRoleId : currentRole ? currentRole.id : '';
this.setRoleId(currentRoleId);
}
// storage
this.$t.storage.setStorageSync('roleId', '');
},

1
src/store/role/mutations.js

@ -41,7 +41,6 @@ const mutations = {
* @param {Array} data 服务端返回的模板数组
*/
setExperienceRole(state, data) {
console.log('data11111111111111: ', data);
state.experienceRole = data || [];
},
};

Loading…
Cancel
Save