From 11923f301138125d3ce2b2fd6cc6edee8bbeb326 Mon Sep 17 00:00:00 2001
From: xuesinan <1404152492@qq.com>
Date: Sat, 26 Feb 2022 23:29:13 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B0=8F=E7=BA=A2=E7=82=B9=E6=98=BE?=
=?UTF-8?q?=E7=A4=BA=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CHANGELOG.md | 3 +-
apis/plugin.js | 2 +-
components/Plugin/Plugin.vue | 4 +-
components/PrettyExchange/PrettyExchange.vue | 29 +++--
components/Projects/ProjectItem.vue | 12 ++
components/Roles/Roles.vue | 117 +++++++++++++++---
components/TimeLine/component/TimeBox.vue | 7 +-
hooks/project/useGetTasks.js | 41 +++++-
hooks/project/useInit.js | 3 +-
pages/index/index.vue | 13 +-
pages/project/project.vue | 72 +++++++++--
plugins/p-deliver-check/check-form-modal.vue | 2 +
plugins/p-deliver-check/p-deliver-check.vue | 6 +-
plugins/p-deliver-upload/p-deliver-upload.vue | 7 +-
plugins/p-deliver/p-deliver.vue | 13 ++
store/socket/actions.js | 56 ++++++---
store/socket/mutations.js | 105 +++++++++++++++-
store/socket/state.js | 35 +++++-
store/task/actions.js | 2 +-
19 files changed, 455 insertions(+), 74 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bdc369f..2470abf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,4 @@
-# 1.0.0 (2022-02-23)
+# 1.0.0 (2022-02-26)
### 🌟 新功能
范围|描述|commitId
@@ -75,6 +75,7 @@
- | first commit | [8dc26de](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/8dc26de)
- | get请求 | [3a61439](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/3a61439)
project | 日常任务面板添加 | [b3f16ff](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/b3f16ff)
+ - | socket | [996a1ca](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/996a1ca)
theme | theme demo | [9175758](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/9175758)
- | token过期策略 | [8f16ae1](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/8f16ae1)
- | vue3 | [12ed2ad](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/12ed2ad)
diff --git a/apis/plugin.js b/apis/plugin.js
index 838d7a7..805c8a6 100644
--- a/apis/plugin.js
+++ b/apis/plugin.js
@@ -5,7 +5,7 @@ import store from '@/store/index.js';
const { apiUrl } = Config;
// const defaultwbs = `${apiUrl}/defaultwbs`;
const domain = computed(() => store.state.domain);
-console.log('domain: ', domain.value);
+// console.log('domain: ', domain.value);
export function setupPlugin(app) {
uni.$u.api = { ...uni.$u.api } || {};
diff --git a/components/Plugin/Plugin.vue b/components/Plugin/Plugin.vue
index dabb0e9..dcaa828 100644
--- a/components/Plugin/Plugin.vue
+++ b/components/Plugin/Plugin.vue
@@ -1,5 +1,7 @@
-
+
+
+
diff --git a/components/PrettyExchange/PrettyExchange.vue b/components/PrettyExchange/PrettyExchange.vue
index 293e984..2a55e75 100644
--- a/components/PrettyExchange/PrettyExchange.vue
+++ b/components/PrettyExchange/PrettyExchange.vue
@@ -128,7 +128,8 @@
import dayjs from 'dayjs';
const store = useStore();
- const projects = computed(() => store.state.project.projects);
+ const projects = computed(() => store.state.project.projects);
+ const remindData = computed(() => store.state.socket.remindData);
const data = reactive({
// itemTop: 0,
// itemLeft: 0,
@@ -159,13 +160,25 @@
const emit = defineEmits(['changeHeight', 'change']);
// 监听项目列表
- watch(projects, (val) => {
- data.itemList = val;
- data.itemList.forEach(item => {
- item.showBorder = false; // 一级项目底部边框是否显示
- item.showSubBorder = false; // 一级项目底部边框是否显示
- item.showTopBorder = false; // 一级项目顶部边框是否显示
- });
+ watch([projects, remindData], () => {
+ if (projects.value) {
+ data.itemList = projects.value;
+ data.itemList.forEach(item => {
+ item.showBorder = false; // 一级项目底部边框是否显示
+ item.showSubBorder = false; // 一级项目底部边框是否显示
+ item.showTopBorder = false; // 一级项目顶部边框是否显示
+ item.remindNum = 0;
+
+ if (remindData.value) {
+ remindData.value.forEach(remind => {
+ const remind_data = JSON.parse(remind.data);
+ if (remind_data.data.projectId === item.id) {
+ item.remindNum++;
+ }
+ })
+ }
+ });
+ }
})
onMounted(() => {
diff --git a/components/Projects/ProjectItem.vue b/components/Projects/ProjectItem.vue
index 5087332..9c7d71a 100644
--- a/components/Projects/ProjectItem.vue
+++ b/components/Projects/ProjectItem.vue
@@ -19,6 +19,8 @@
工作台
+
+ {{ item.remindNum > 99 ? '99+' : item.remindNum }}
@@ -156,4 +158,14 @@ function openMenu(project) {
color: #FFFFFF;
text-align: center;
}
+
+.remind-box {
+ padding: 0 3px;
+ min-width: 16px;
+ height: 16px;
+ text-align: center;
+ line-height: 16px;
+ border-radius: 8px;
+ font-weight: 100;
+}
diff --git a/components/Roles/Roles.vue b/components/Roles/Roles.vue
index cfbab83..6f42a9d 100644
--- a/components/Roles/Roles.vue
+++ b/components/Roles/Roles.vue
@@ -16,10 +16,13 @@
}"
:key="index"
@click="changeRole(item.id, index)"
- class="tab-item"
+ class="tab-item relative"
v-for="(item, index) in data.roles"
>
- {{ item.name }}
+
+ {{ item.name }}
+
+ {{ item.remindNum > 99 ? '99+' : item.remindNum }}
@@ -32,6 +35,7 @@
diff --git a/plugins/p-deliver-check/check-form-modal.vue b/plugins/p-deliver-check/check-form-modal.vue
index 5adc968..829fac3 100644
--- a/plugins/p-deliver-check/check-form-modal.vue
+++ b/plugins/p-deliver-check/check-form-modal.vue
@@ -38,6 +38,7 @@ import { quickWords } from '@/config/deliver';
const props = defineProps({
data: { type: Object, default: {} },
+ msgId: { default: '', type: String }
});
const emits = defineEmits(['hide', 'submit-end']);
const store = useStore();
@@ -62,6 +63,7 @@ async function handleSubmit(mode) {
type: mode === 'RESOLVE' ? 1 : 2,
remark: commit.value,
score: mode === 'RESOLVE' ? score.value : '',
+ msgId: props.msgId
};
await uni.$u.api.checkDeliver(param);
handleHide(); // 隐藏 + 重置
diff --git a/plugins/p-deliver-check/p-deliver-check.vue b/plugins/p-deliver-check/p-deliver-check.vue
index 240d77d..c9e0270 100644
--- a/plugins/p-deliver-check/p-deliver-check.vue
+++ b/plugins/p-deliver-check/p-deliver-check.vue
@@ -81,7 +81,7 @@
-
+
@@ -90,6 +90,10 @@ import { ref, reactive, inject, computed } from 'vue';
import dayjs from 'dayjs';
import checkFormModal from './check-form-modal.vue';
+const props = defineProps({
+ msgId: { default: '', type: String }
+});
+
const deliverData = inject('deliver');
defineEmits(['check-success']);
const collapsed = ref(false);
diff --git a/plugins/p-deliver-upload/p-deliver-upload.vue b/plugins/p-deliver-upload/p-deliver-upload.vue
index 629fb55..b624194 100644
--- a/plugins/p-deliver-upload/p-deliver-upload.vue
+++ b/plugins/p-deliver-upload/p-deliver-upload.vue
@@ -82,11 +82,14 @@ import { useStore } from 'vuex';
import { UPLOAD_URL } from '@/config/index';
import { UPLOAD_EXTENSION } from '@/config/deliver';
+const props = defineProps({
+ msgId: { default: '', type: String }
+});
+
const deliver = inject('deliver');
const task = inject('task');
const store = useStore();
const emits = defineEmits(['upload-success', 'edit-success']);
-
const reviewerRef = ref(null);
const submitBtnLoading = ref(false);
const linkValue = ref(''); // 链接的值
@@ -130,11 +133,13 @@ async function submit() {
checkedCheckers.forEach(item => {
checkerList.push(item.memberId);
});
+
const param = {
projectId: projectId.value,
deliverId: deliver.value.deliverId,
fileList: [linkValue.value],
checkerList,
+ msgId: props.msgId
};
await uni.$u.api.submitDeliverInfo(param);
uni.$ui.showToast('提交交付物信息成功');
diff --git a/plugins/p-deliver/p-deliver.vue b/plugins/p-deliver/p-deliver.vue
index 66d82da..f3a95fd 100644
--- a/plugins/p-deliver/p-deliver.vue
+++ b/plugins/p-deliver/p-deliver.vue
@@ -4,6 +4,7 @@
@@ -26,9 +28,20 @@ const task = inject('task');
const pluginInfo = inject('pluginInfo');
const deliver = ref(null); // 服务端返回的交付物信息
const isMine = computed(() => store.getters['role/isMine']); // 是不是我的任务
+const remindData = computed(() => store.state.socket.remindData); // 小红点
deliver.value = pluginInfo && pluginInfo.data ? JSON.parse(pluginInfo.data) : null;
provide('deliver', deliver);
+
+let msgId = ref(null);
+remindData.value.forEach(remind => {
+ const remind_data = JSON.parse(remind.data);
+
+ if (remind_data.data.taskId === task.id) {
+ msgId = remind.id;
+ }
+})
+
// 根据任务id获取交付物信息
async function getDeliverData() {
try {
diff --git a/store/socket/actions.js b/store/socket/actions.js
index 9c6a6b0..e22394b 100644
--- a/store/socket/actions.js
+++ b/store/socket/actions.js
@@ -9,7 +9,8 @@ const actions = {
initSocket({ commit, dispatch, state }) {
if (state.lockSocket) return;
// const { token } = rootState.user;
- // if (!token) return;
+ // if (!token) return;
+
commit('setLockSocket', true);
commit('setSocket', uni.connectSocket({ url: Config.msgUrl, complete: () => {} }));
// dispatch('auth');
@@ -41,7 +42,7 @@ const actions = {
},
// 监听收到的ws消息
- onSocketMessage({ dispatch, state }) {
+ onSocketMessage({ commit, dispatch, state }) {
state.socket.onMessage(res => {
if (!res || !res.data || !JSON.parse(res.data)) return;
const resData = JSON.parse(res.data);
@@ -56,21 +57,48 @@ const actions = {
* 处理收到的消息内容
* @param {object} item 单个消息体对象
*/
- handleMessagesData({ dispatch, commit }, item) {
+ handleMessagesData({ dispatch, commit, state }, item) {
const data = JSON.parse(item.data);
switch (data.type) {
- case 'Sync': // 开始某个节点
- commit('messages/messagesAdd', { message: data, type: 'syncMessages' }, { root: true });
- break;
- case 'taskStatus': // 任务状态修改相关消息
- commit('task/setTaskStatus', data.data, { root: true });
- break;
- // case 'Deliver': // 交付物相关消息
- // commit('messages/messagesAdd', { type: 'checkMessages', message: data }, { root: true });
- // break;
- case 'ChannelStatus':
+ case 'ChannelStatus': // 认证
dispatch('handleAuthMessage', data);
- break;
+ break;
+ case 'Notification': // 系统通知
+ commit('setNotificationData', item);
+ break;
+ case 'Ring': // ring
+ commit('setRingData', item);
+ break;
+ case 'Remind': // 小红点
+ commit('setRemindData', item);
+ break;
+ case 'Success': // 小红点
+ let arr = [];
+ if (data.event === 'Notification') {
+ arr = state.notificationData;
+ } else if (data.event === 'Ring') {
+ arr = state.ringData;
+ } else if (data.event === 'Remind') {
+ arr = state.remindData;
+ }
+
+ let del_index = -1;
+ arr.forEach((item, index) => {
+ if (item.id === data.data.msgId) {
+ del_index = index;
+ }
+ })
+
+ arr.splice(notification_index, 1);
+
+ if (data.event === 'Notification') {
+ commit('uploadNotificationData', arr);
+ } else if (data.event === 'Ring') {
+ commit('uploadRingData', arr);
+ } else if (data.event === 'Remind') {
+ commit('uploadRemindData', arr);
+ }
+ break;
default:
break;
}
diff --git a/store/socket/mutations.js b/store/socket/mutations.js
index c66eea7..7449f27 100644
--- a/store/socket/mutations.js
+++ b/store/socket/mutations.js
@@ -20,7 +20,110 @@ const mutations = {
*/
setLockSocket(state, lockSocket) {
state.lockSocket = lockSocket;
- },
+ },
+
+ /**
+ * 设置系统通知消息数据
+ * @param {Object} state
+ * @param {Object} data
+ */
+ setNotificationData(state, data) {
+ let flag = false;
+ state.notificationData.forEach(item => {
+ if (item.id === data.id) {
+ flag = true;
+ }
+
+ if (item.data === data.data) {
+ item.data = data.data;
+ }
+ })
+
+ if (!flag) {
+ state.notificationData.push(data);
+ }
+ },
+
+ /**
+ * 设置ring消息
+ * @param {Object} state
+ * @param {Object} data
+ */
+ setRingData(state, data) {
+ let flag = false;
+ state.ringData.forEach(item => {
+ if (item.id === data.id) {
+ flag = true;
+ }
+
+ if (item.data === data.data) {
+ item.data = data.data;
+ }
+ })
+
+ if (!flag) {
+ state.ringData.push(data);
+ }
+ },
+
+ /**
+ * 设置小红点
+ * @param {Object} state
+ * @param {Object} data
+ */
+ setRemindData(state, data) {
+ let flag = false;
+ state.remindData.forEach(item => {
+ if (item.id === data.id) {
+ flag = true;
+ }
+
+ if (item.data === data.data) {
+ flag = true;
+ item.data = data.data;
+ }
+ })
+
+ if (!flag) {
+ state.remindData.push(data);
+ }
+ },
+
+ /**
+ * 设置系统通知消息数据
+ * @param {Object} state
+ * @param {Object} data
+ */
+ uploadNotificationData(state, data) {
+ state.notificationData = data;
+ },
+
+ /**
+ * 设置ring消息
+ * @param {Object} state
+ * @param {Object} data
+ */
+ uploadRingData(state, data) {
+ state.ringData = data;
+ },
+
+ /**
+ * 设置小红点
+ * @param {Object} state
+ * @param {Object} data
+ */
+ uploadRemindData(state, data) {
+ state.remindData = data;
+ },
+
+ /**
+ * 当前需要定位到的任务id
+ * @param {Object} state
+ * @param {Object} data
+ */
+ setCurrLocationTaskId(state, data) {
+ state.currLocationTaskId = data;
+ }
};
export default mutations;
diff --git a/store/socket/state.js b/store/socket/state.js
index bc48c25..6553375 100644
--- a/store/socket/state.js
+++ b/store/socket/state.js
@@ -1,7 +1,40 @@
const state = {
socket: null, // websocket实例
connected: false, // 是否处于连接状态
- lockSocket: false, // 是否正在连接状态
+ lockSocket: false, // 是否正在连接状态
+ notificationData: [], // 系统通知消息
+ ringData: [],
+ remindData: [],
+ // remindData: [{
+ // "id": "62132e19370c1e05f9a6ac3c",
+ // "time": "1645424153",
+ // "fromDomain": "Queue",
+ // "from": "tall_message_1",
+ // "data": "{\"type\": \"Remind\", \"data\": {\"projectId\":\"1496414578836512768\", \"roleId\":\"1496414579394355200\", \"taskId\":\"1496414580841390080\", \"pluginId\":\"1496414581055299584\"}}",
+ // "authMessage": "null"
+ // }, {
+ // "id": "62132e19370c1e05f9a6ac3c",
+ // "time": "1645424153",
+ // "fromDomain": "Queue",
+ // "from": "tall_message_1",
+ // "data": "{\"type\": \"Remind\", \"data\": {\"projectId\":\"1496414578836512768\", \"roleId\":\"1496414579482435584\", \"taskId\":\"1496414581852217344\", \"taskType\":0, \"pluginId\":\"1496414582036766720\"}}",
+ // "authMessage": "null"
+ // }, {
+ // "id": "62132e19370c1e05f9a6ac3c",
+ // "time": "1645424153",
+ // "fromDomain": "Queue",
+ // "from": "tall_message_1",
+ // "data": "{\"type\": \"Remind\", \"data\": {\"projectId\":\"1496414578836512768\", \"roleId\":\"1496414579482435584\", \"taskId\":\"1496414582330368068\", \"taskType\":1, \"pluginId\":\"1496414582934347776\"}}",
+ // "authMessage": "null"
+ // }, {
+ // "id": "62132e19370c1e05f9a6ac3c",
+ // "time": "1645424153",
+ // "fromDomain": "Queue",
+ // "from": "tall_message_1",
+ // "data": "{\"type\": \"Remind\", \"data\": {\"projectId\":\"1496414578836512768\", \"roleId\":\"1496414579482435584\", \"taskId\":\"1496414583173423178\", \"taskType\":1, \"pluginId\":\"1496414586478534656\"}}",
+ // "authMessage": "null"
+ // }], // 小红点
+ currLocationTaskId: '', // 前需要定位到的任务id
};
export default state;
diff --git a/store/task/actions.js b/store/task/actions.js
index 1ce0652..ecd7714 100644
--- a/store/task/actions.js
+++ b/store/task/actions.js
@@ -21,7 +21,7 @@ const actions = {
* @param {*} commit
* @param {object} param 请求参数 roleId, timeNode, timeUnit
*/
- getGlobal({ commit }, param) {
+ getGlobal({ commit, state }, param) {
commit('setShowGlobalSkeleton', true);
uni.$catchReq.getGlobal(param, (err, data) => {
commit('setShowGlobalSkeleton', false);