addWorkersLogic.js
1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import {_getListUser} from "../service/AppService";
import {observable, computed} from 'mobx'
import {ownerUserId,ownerUserName} from "../service/rpc";
import {taskOwnerId,taskOwnerName} from "../pages/TaskList";
import {currentListId} from "../pages/TaskList";
import Toast from "react-native-simple-toast";
export default class addUserLogic {
@observable
users = []
@observable
text = ""
@observable
chooseWorkers = []
@computed
get data() {
if (!!this.text) {
return this.users.filter(v => (v.userName.includes(this.text)))
}
return this.users
}
async get() {
try{
const data = await _getListUser({
taskListId: currentListId,
pageSize:0
})
const {result,errors,firstErrorMessage,} = data
if(errors.length>0){
Toast.show(firstErrorMessage)
}else {
let array=[]
if(result.some(v=>v.userId===ownerUserId)){
result.map(v=>{
if(v.userId===ownerUserId){
const {userName,...others}=v
array.push({
userName:v.userName+"(我)",
...others,
})
}else{
array.push(v)
}
})
}else {
array=[...result]
}
// if(taskOwnerId!==ownerUserId){
// array1=[{userName:'未分配'},{userName:`${ownerUserName}`,userId:ownerUserId},...array]
// }else{
// array1=[{userName:'未分配'},...array]
//
// }
this.users.replace([{userName:'未分配'},...array])
}
}catch(e){
}
}
}