todoCommon.js
7.92 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
import LeaderDialog from '@/views/matter/components/LeaderDialog'
import Circulate from '@/views/matter/components/Circulate'
import CardTodo from '@/views/matter/myTask/CardTodo'
import ApprovalDialog from '@/views/matter/myTask/ApprovalDialog.vue'
import matter from '@/mixins/matter'
import tableHeight from '@/mixins/tableHeight'
import { uniqueArrayObject, filterQueryList } from '@/utils/array'
import {
getTodoList,
getTodoCard,
getLeaderTodoList,
getLeaderTodoCard,
} from '@/api/process'
import { mapState } from 'vuex'
export default {
components: {
LeaderDialog,
Circulate,
CardTodo,
ApprovalDialog,
},
mixins: [matter, tableHeight],
data() {
return {
tableData: [],
selectedIds: '',
selectedList: [],
isDisabled: true,
isCardView: false,
cardLoading: false,
isShowPagination: false,
isShowMore: false,
currentDefKey: '',
currentDefName: '',
currentTaskId: '',
currentInstId: '',
currentLearderId: '',
isValChange: false,
isFrom: 'todo',
isFocus: false,
specialFocusTaskList: [],
currentQuery: {},
}
},
computed: {
...mapState('user', ['account']),
specialFocusTaskIds() {
return this.specialFocusTaskList.map((item) => item.id)
},
noSpecialFocusTasks() {
return this.tableData.filter(
(item) => !this.specialFocusTaskIds.includes(item.id)
)
},
getCurrentTableData() {
const currentTableData = [
...this.specialFocusTaskList,
...this.noSpecialFocusTasks,
]
const listData = currentTableData.slice(0, this.pageResult.pageSize)
return this.isCardView ? this.tableData : listData
},
},
watch: {
selectedList(val) {
this.isDisabled = val.length < 1 ? true : false
},
},
mounted() {
if (localStorage.getItem(this.account)) {
this.specialFocusTaskList =
JSON.parse(localStorage.getItem(this.account)) || []
}
},
methods: {
getTodoList(data, type, cb) {
const querys =
this.isShowMore && this.isCardView
? this.getCardMoreQuerys(data)
: data.querys
const params = {
...data,
querys: filterQueryList(querys),
}
this.currentQuery = params
const currentApi = type === 'todo' ? getTodoList : getLeaderTodoList
currentApi(params)
.then((res) => {
if (!res) return
const { rows, page, pageSize, total } = res
this.tableData = rows || []
this.filterNotFoundSpecialFocusTask(querys)
if (this.isShowMore) {
this.tableData = [
{
key: this.currentDefKey,
list: rows || [],
procDefName: this.currentDefName,
},
]
}
this.pageResult = {
page,
pageSize,
total,
}
})
.finally(() => {
cb?.()
})
},
filterNotFoundSpecialFocusTask(queryList) {
const taskIds = this.tableData.map((it) => it.taskId)
const specialFocusTaskList =
JSON.parse(localStorage.getItem(this.account)) || []
if (
queryList.length > 0 &&
specialFocusTaskList &&
specialFocusTaskList.length > 0
) {
this.specialFocusTaskList = this.specialFocusTaskList.filter((item) =>
taskIds.includes(item.taskId)
)
} else {
this.specialFocusTaskList = specialFocusTaskList
}
},
handleSpecialFocus(row) {
this.$set(row, 'isFocus', row.isFocus ? false : true)
this.$message.success(
row.isFocus ? '特别关注置顶成功' : '取消特别关注成功'
)
if (row.isFocus) {
this.specialFocusTaskList.unshift(row)
} else {
this.specialFocusTaskList = this.specialFocusTaskList.filter(
(item) => item.id !== row.id
)
}
localStorage.setItem(
this.account,
JSON.stringify(this.specialFocusTaskList)
)
},
getTodoCardList(param, type, cb) {
this.isFrom = type
this.cardLoading = true
const cardPageBean = {
page: 1,
pageSize: 10e6,
total: 0,
}
const data = {
...param,
pageBean: cardPageBean,
}
const currentApi = type === 'todo' ? getTodoCard : getLeaderTodoCard
currentApi(data)
.then((res) => {
if (res.state) {
const cardObj = res.value
let cardList = []
for (const key in cardObj) {
if (Object.hasOwnProperty.call(cardObj, key)) {
cardList.push({
key,
count: type === 'todo' ? '' : cardObj[key].num,
list: type === 'todo' ? cardObj[key] : cardObj[key].taskList,
procDefName:
type === 'todo'
? cardObj[key][0]?.procDefName
: cardObj[key].taskList[0]?.procDefName,
})
}
}
this.tableData = cardList
}
})
.finally(() => {
this.cardLoading = false
cb?.()
})
},
handleViewChange(val) {
this.isCardView = val
this.isShowPagination = false
this.pageResult = {
page: 1,
pageSize: 20,
total: 0,
}
this.$nextTick(() => {
this.$refs.htTable.load(false)
})
if (val) {
this.getTodoCardList(this.currentQuery, this.isFrom)
this.isShowPagination = true
} else {
this.isShowMore = false
}
},
handleClickMore(item, type) {
this.isShowMore = true
this.currentDefKey = item.procDefKey
this.currentDefName = item.procDefName
this.isShowPagination = false
this.getTodoListByDefKey(type)
},
getTodoListByDefKey(type) {
const params = {
pageBean: this.pageResult,
querys: this.getCardMoreQuerys({}),
}
const currentApi = type === 'todo' ? getTodoList : getLeaderTodoList
currentApi(params).then((res) => {
const { rows, page, pageSize, total } = res
this.tableData = [
{
key: this.currentDefKey,
list: rows || [],
procDefName: this.currentDefName,
},
]
this.pageResult = {
page,
pageSize,
total,
}
})
},
getCardMoreQuerys(params) {
let query = params?.querys || []
query.push({
property: 'bt.proc_def_key_',
value: this.currentDefKey,
group: 'main',
operation: 'LIKE',
relation: 'AND',
})
return query
},
handleCardBack(cb) {
this.loadData({ isBack: true }, cb)
this.isShowPagination = true
},
handleCheckboxChange(data) {
const checkedList = data.filter((it) => it.checked)
this.selectedList = uniqueArrayObject(checkedList, 'id')
this.selectedIds = this.selectedList?.map((item) => item.id)?.join(',')
},
handleSelectionChange(selection) {
this.selectedIds = selection?.map((item) => item.id).join(',')
this.selectedList = selection
},
handleCardClick(row, key) {
this.jumpApproval(row, key)
},
handleClick(row, key) {
this.jumpApproval(row, key)
},
jumpApproval(row, key) {
const isDialogModel = localStorage.getItem('isDialog')
if (isDialogModel && JSON.parse(isDialogModel) === true) {
this.currentTaskId = row.id
this.currentInstId = row.procInstId
this.currentLearderId = row.leaderIds
this.$refs.approvalDialogForm.openApprovalFormDialog()
} else {
//根据状态跳转
this.$refs.leaderDialog.handleJumpsTodoPage(row, {
isGetApprovalBtn: true,
key,
type: 'fromTodoList',
})
}
},
//传阅
handleCirculate() {
this.$refs.circulate.handleOpen()
},
},
}