Browse Source

feat: 添加项目列表小红点,查询工具箱使用者

tall
song 4 years ago
parent
commit
d620a54795
  1. 3
      CHANGELOG.md
  2. 1
      src/App.vue
  3. 2
      src/apis/yanyuan.js
  4. 11
      src/components/Projects/ProjectItem.vue
  5. 30
      src/pages/index/index.vue
  6. 55
      src/pagesYanyuan/hold-all/hold-all.vue
  7. 5
      src/store/socket/actions.js

3
CHANGELOG.md

@ -1,4 +1,4 @@
# 0.1.0 (2022-02-08)
# 0.1.0 (2022-02-09)
### 🌟 新功能
范围|描述|commitId
@ -78,6 +78,7 @@
- | 项目列表, 项目url | [32e005b](https://101.201.226.163:50022/DIGITAL_MEDICAL/yanyuan/commits/32e005b)
- | 项目列表排序 | [224c58b](https://101.201.226.163:50022/DIGITAL_MEDICAL/yanyuan/commits/224c58b)
- | 项目api url设置 | [6cd5245](https://101.201.226.163:50022/DIGITAL_MEDICAL/yanyuan/commits/6cd5245)
- | 修改连接WiFi逻辑 | [74248c7](https://101.201.226.163:50022/DIGITAL_MEDICAL/yanyuan/commits/74248c7)
- | 修改时间轴滚动 | [537df8c](https://101.201.226.163:50022/DIGITAL_MEDICAL/yanyuan/commits/537df8c)
- | 修改小程序id | [4206bf2](https://101.201.226.163:50022/DIGITAL_MEDICAL/yanyuan/commits/4206bf2)
- | 修改config | [eb5f9c5](https://101.201.226.163:50022/DIGITAL_MEDICAL/yanyuan/commits/eb5f9c5)

1
src/App.vue

@ -41,6 +41,7 @@ export default {
}
}
/* #endif */
this.initSocket();
},

2
src/apis/yanyuan.js

@ -56,6 +56,8 @@ const install = (Vue, vm) => {
vm.$u.api.queryFamilyList = param => vm.$u.post(`${yanyuan}/family/queryList`, param);
// 查询用户是否是项目成员
vm.$u.api.familyIsMember = param => vm.$u.post(`${yanyuan}/family/isMember`, param);
// 查询项目待审核家属成员数量
vm.$u.api.queryProjectAuditNum = param => vm.$u.post(`${yanyuan}/family/queryProjectAuditNum`, param);
// 试题答案保存
vm.$u.api.chooseTool = param => vm.$u.post(`${yanyuan}/trainPlan/chooseTool`, param);

11
src/components/Projects/ProjectItem.vue

@ -4,18 +4,25 @@
<view class="flex items-center justify-between p-3">
<u-icon @click="openMenu(item)" class="mover" name="https://www.tall.wiki/staticrec/drag.svg" size="48"></u-icon>
<view @click="openProject(item)" class="flex-1 px-3">
<view @click="openProject(item)" class="flex-1 px-3 relative">
<view class="flex items-center mb-1">
<view class="mr-2">{{ item.name }}</view>
<view class="mr-2">
{{ item.name }}
</view>
<!-- 状态 TODO:-->
<view class="px-2 text-xs text-green-400 bg-green-100 rounded-full flex-shrink-0">进行中</view>
</view>
<view class="flex items-center text-xs text-gray-400">
<!-- <view v-if="item.auditNum"> -->
<!-- </view> -->
<view class="pr-2">{{ $moment(+item.startTime).format('MM-DD HH:mm') }}</view>
<view class="pl-2">{{ $moment(+item.endTime).format('MM-DD HH:mm') }}</view>
</view>
<!-- 未读消息 -->
<u-badge v-if="item.auditNum" type="error" :count="item.auditNum" class="font-normal"></u-badge>
</view>
<!-- 箭头 -->

30
src/pages/index/index.vue

@ -121,10 +121,40 @@ export default {
item.show = false;
});
this.setProjects(data);
//
this.handleProjectAuditNum(data);
}
});
},
/**
* 查询项目待审核家属成员数量
*/
async handleProjectAuditNum(projects) {
try {
const params = [];
projects.forEach(item => {
let project = { projectId: '' };
project.projectId = item.id;
params.push(project);
});
const res = await this.$u.api.queryProjectAuditNum(params);
let data = projects;
data.forEach(project => {
if (res && res.length) {
res.forEach(item => {
if (project.id === item.traineeId) {
project.auditNum = item.auditNum;
}
});
}
});
this.setProjects(data);
} catch (error) {
console.log('error: ', error);
}
},
/**
* 查询小红点
* @param { string } endTime 结束时间

55
src/pagesYanyuan/hold-all/hold-all.vue

@ -1,9 +1,11 @@
<template>
<view class="bg-white flex flex-col px-2">
<view class="flex flex-nowrap mt-3">
<view class="flex-1"></view>
<u-button type="primary" text="添加WiFi" size="mini" :plain="true" @click="openBinding">添加WiFi</u-button>
<view class="flex flex-col">
<view class="flex flex-nowrap my-3 px-4" @click="openBinding">
<view class="flex-1">添加WiFi</view>
<u-icon name="arrow-right"></u-icon>
<!-- <u-button type="primary" text="添加WiFi" size="mini" :plain="true" @click="openBinding">添加WiFi</u-button> -->
</view>
<view class="w-full h-3" style="background: #f8f8f8"></view>
<!-- <view class="flex flex-nowrap text-xs text-gray-400 my-2">
提示:
<view v-for="(tip, tipIndex) in tips" :key="tipIndex" class="flex flex-nowrap items-center ml-3">
@ -11,51 +13,29 @@
{{ tip.value }}
</view>
</view> -->
<view v-if="lists && lists.length">
<view v-if="lists && lists.length" class="px-2">
<view v-for="item in lists" :key="item.toolId">
<view class="flex justify-between items-center py-3 border-b">
<view class="flex justify-between items-center py-3 px-2 border-b">
<view class="flex flex-row items-center">
<!-- :class="
item.equipmentStatus === 0
? 'text-gray-500'
: item.equipmentStatus === 1
? 'text-green-500'
: item.equipmentStatus === 2
? 'text-yellow-500'
: 'text-red-500'
" -->
<view class="mr-2">
{{ item.code }}
</view>
<view class="flex items-center text-gray-400" @click="getUserName(item.equipmentId)">
<!-- :class="
item.equipmentStatus === 0
? 'text-gray-500'
: item.equipmentStatus === 1
? 'text-green-500'
: item.equipmentStatus === 2
? 'text-yellow-500'
: 'text-red-500'
" -->
<u-icon name="error-circle" size="36"></u-icon>
</view>
</view>
<view class="flex flex-nowrap items-center">
<view class="flex items-center text-gray-400">
<u-icon v-if="item.wifiStatus === 1" name="wifi" color="#1890FF" size="36"></u-icon>
<u-icon v-else name="wifi" color="#999999" size="36"></u-icon>
<view class="flex items-center text-gray-400" v-show="show">
{{ content }}
</view>
<view class="battery-box ml-3">
<view class="battery-text u-font-10 font-light">{{ item.electricQuantity }}</view>
<view class="battery" :style="{ width: setWidth(item.electricQuantity) }"></view>
<view class="">
<u-button v-if="!show" type="primary" text="查询使用者" size="mini" :plain="true" @click="getUserName(item.equipmentId)">
查询使用者
</u-button>
<u-icon v-else bold name="reload" color="#1890FF" size="32" class="ml-2" @click="getUserName(item.equipmentId)"></u-icon>
</view>
</view>
</view>
</view>
</view>
<u-empty v-else text="列表为空" mode="list" class="mt-10"></u-empty>
<u-modal v-model="show" :content="content"></u-modal>
</view>
</template>
@ -127,8 +107,10 @@ export default {
*/
async getUserName(equipmentId) {
try {
this.$t.ui.showLoading();
const params = { equipmentId };
const data = await this.$u.api.getUserName(params);
this.$t.ui.hideLoading();
if (data.status === -2) {
this.show = true;
this.content = '使用前请先选择长者!';
@ -139,9 +121,10 @@ export default {
}
if (data.status === 0) {
this.show = true;
this.content = `绑定者为 ${data.userName},性别 ${data.sex === 1 ? '男' : '女'}`;
this.content = `使用者为 ${data.userName}(${data.sex === 1 ? '男' : '女'})`;
}
} catch (error) {
this.$t.ui.hideLoading();
console.error('error: ', error);
this.$t.ui.showToast(error.msg || '工具箱的使用者查询失败');
}

5
src/store/socket/actions.js

@ -23,7 +23,6 @@ const actions = {
onSocketOpen({ dispatch, commit, state }) {
// eslint-disable-next-line no-unused-vars
state.socket.onOpen(res => {
// console.log('ws open: ', res);
commit('setConnected', true);
prevTime = Date.now();
// this.auth();
@ -38,7 +37,6 @@ const actions = {
// 监听收到的ws消息
onSocketMessage({ dispatch, state }) {
state.socket.onMessage(res => {
// console.log('收到消息:', res);
prevTime = Date.now();
if (!res || !res.data || !JSON.parse(res.data)) return;
const resData = JSON.parse(res.data);
@ -63,7 +61,6 @@ const actions = {
commit('task/setTaskStatus', data.data, { root: true });
break;
// case 'Chrome': // !收到开始游戏的消息
// console.log('handleMessagesData', data);
// // @ts-ignore
// util.openGameApp({
// type: data.data.type,
@ -82,7 +79,6 @@ const actions = {
// dispatch('home/getProjectById', data.data.projectId, { root: true });
// break;
// case 'startDrill': // 康复开始训练相关消息
// console.log('setStartDrillInfo', data.data);
// commit('home/setStartDrillMessages', data.data, { root: true });
// break;
default:
@ -102,7 +98,6 @@ const actions = {
// 监听关闭事件
onSocketClose({ dispatch, commit, state }) {
// console.log('onSocketClose');
state.socket.onClose(() => {
commit('setConnected', false);
if (sendHeartTimer) clearInterval(sendHeartTimer);

Loading…
Cancel
Save