taskListLogic.js
3.48 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import {observable,computed} from 'mobx'
import {_getTaskList, _taskFind, _star, _unStar, _done, _todo, _taskCreate,_share,_myTask} from "../service/AppService";
import Toast from "react-native-simple-toast";
import moment from 'moment';
import {tenantId} from "../service/rpc";
export default class taskListLogic {
@observable
showFinish = false
@observable
showOrdersBar = false
@observable
text = ''
@observable
marked = false
@observable
doneList = []
@observable
undoneList = []
@observable
loading = true
params = null
@observable
title = ""
@observable
changeStatus=false
@observable
currentListOwner=""
@computed
get showButton(){
if(this.doneList.length>0){
return true
}
return false
}
async taskFind(type) {
const option = {
...this.params,
pageSize: 0,
}
if (type) {
option.sortColumn = type
option.sortType = "ASC"
}
try {
let data
if(this.params.myTask){
data=await _myTask(option)
}else{
data = await _taskFind(option)
}
const {errors, firstErrorMessage, result, totalCount} = data
if (errors.length > 0) {
Toast.show(firstErrorMessage)
} else {
this.doneList.clear()
this.undoneList.clear()
let resultArray=result
if(!type){
const sortArray = result.sort((a, b) => (b.lastUpdateTime || b.creationTime) - (a.lastUpdateTime || a.creationTime))
const starArray = sortArray.filter(v => v.isStar)
const notsSartArray = sortArray.filter(v => !v.isStar)
resultArray = [...starArray, ...notsSartArray];
}
this.doneList=resultArray.filter(v => v.isDone && v)
this.undoneList=resultArray.filter(v => !v.isDone && v)
}
} catch (e) {
}
this.changeStatus=!this.changeStatus
this.loading = false
}
async todoSetting(status, id, rowVersion) {
try {
if (status) {
await _todo({id, rowVersion})
} else {
await _done({id, rowVersion})
}
} catch (e) {
}
}
async starSetting(status, id, rowVersion) {
try {
if (status) {
await _unStar({id, rowVersion})
} else {
await _star({id, rowVersion})
}
} catch (e) {
}
}
async addTask(objectId) {
try {
const result = await _taskCreate({
listId: objectId,
objectType: "MANUAL",
isStar: this.marked,
objectName: this.text,
ObjectCategory: "NONE",
})
const {errors, firstErrorMessage,} = result
if (errors.length > 0) {
Toast.show(firstErrorMessage)
} else {
this.text = ""
}
} catch (e) {
}
}
async getTaskList(id) {
try{
const data = await _getTaskList({id})
const {errors, firstErrorMessage, taskList} = data
if (errors.length > 0) {
Toast.show(firstErrorMessage)
} else {
const {objectName,ownerUserId} = taskList
this.title = objectName
this.currentListOwner=ownerUserId
}
}catch(e){
}
}
async share(businessId,userIds){
const time=moment(new Date()).format("YYYY-MM-DD HH:mm:ss")
const receiptIds=userIds.map(v=>v.userId)
const url=`xntalk://rnapp.open/tasklistRN?jj=${businessId}&tenantId=${tenantId}&title=${this.title}&objectType=${this.params.objectType}`
const option={
businessId,
businessType:"TASKLIST_TASK",
receiptIds,
messageTitle:this.title,
messageContent:this.title,
messageTime:time,
messageMobileUrl:url
}
console.log(url)
console.log(option)
try{
const data=await _share(option)
const {errors, firstErrorMessage,} = data
if (errors.length > 0) {
Toast.show(firstErrorMessage)
} else {
Toast.show("分享成功")
}
}catch(e){
}
}
}