index.vue
9.31 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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<!-- 商品上架 -->
<template>
<d2-container v-loading="loading.page" class="shelf-product-wrapper">
<template #header>
<div v-if="table.formSchema.length" class="header">
<d2-search class="show-search"
label-width="100px"
:form-data="table.formSchema"
:search-form="table.searchForm">
</d2-search>
<div class="up-btns">
<el-button size="small"
type="primary"
@click="handleSearch()">
查询
</el-button>
<el-button size="small" @click="handleReset">
重置
</el-button>
</div>
</div>
</template>
<div v-if="table.tableParams.tableColumns.length" class="d2-container-content">
<d2-table-header :left-span="24">
<template #left>
<div class="table-title-wrapper">
<div class="title">
任务列表
</div>
<div class="table-sum-wrapper">
<el-tag type="info">
<span>
总任务数
</span>
<span style="margin-left:4px">
{{ table.headerSummary.totalCount }}
</span>
</el-tag>
<el-tag type="info">
<span>
未完成
</span>
<span style="margin-left:4px">
{{ table.headerSummary.unfinishedCount }}
</span>
</el-tag>
<el-tag type="info">
<span>
已完成
</span>
<span style="margin-left:4px">
{{ table.headerSummary.finishedCount }}
</span>
</el-tag>
<el-tag type="info">
<span>
已逾期
</span>
<span style="margin-left:4px">
{{ table. headerSummary.overdueCount }}
</span>
</el-tag>
</div>
<div class="sort-wrapper">
<el-dropdown @command="handleChangeSort">
<span class="el-dropdown-link" style="cursor:pointer">
{{ table.searchForm.orderBy === "createdDate desc" ? "按创建时间" : "按截止时间" }}
<i class="el-icon-sort" />
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="createdDate desc" :class="table.searchForm.orderBy === 'createdDate desc' ? 'is-active' : '' ">
按创建时间
</el-dropdown-item>
<el-dropdown-item command="dueTime asc" :class="table.searchForm.orderBy === 'dueTime asc' ? 'is-active' : '' ">
按截止时间
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</div>
</template>
</d2-table-header>
<d2-table ref="tableRef" v-bind="table">
<template #auth-button="{ scope }">
<div style="padding:21px 0">
<span style="margin-right: 10px">
<auth-button :data="scope" :show-btn-ids="['9123001']" />
</span>
</div>
</template>
</d2-table>
<!-- <RejectDialog v-model="dialog.reject.show"
:business-code="dialog.reject.businessCode"
@confirmSuccess="handleRefreshTable" /> -->
</div>
</d2-container>
</template>
<script>
import { get, isEmpty } from "lodash-es";
import { mapActions } from "vuex";
import { setAllOptions } from "@/libs/select.js";
import reportTrackFunMixin from "@/mixins/reportTrackFunMixin";
import { getTaskCenterCountApi, getTaskCenterListApi } from "@/views/residentManage/taskCenter/api/index.js";
import { getTableColumns, getTableFormSchema } from "@/views/residentManage/taskCenter/view/table/table.data";
export default {
name: "TaskCenterTable",
components: {
},
mixins: [reportTrackFunMixin],
data() {
return {
loading: {
page: false,
},
table: {
pageSizes: [10, 50, 100],
hasNum: false,
formSchema: [],
headerSummary: {
finishedCount: 0,
overdueCount: 0,
totalCount: 0,
unfinishedCount: 0,
},
getListApi: async (query) => {
const res = await getTaskCenterListApi(query);
const headerSummary = await getTaskCenterCountApi(query);
Object.assign(this.table.headerSummary, headerSummary);
return res;
},
searchForm: {
orderBy: "createdDate desc",
// 排序字段:创建时间升序:createdDate asc
// 降序:createdDate desc
// 更新时间升序:updatedDate asc
// 降序:updatedDate desc
// 截止时间升序:dueTime asc
// 降序:dueTime desc
},
// 表格参数
tableParams: {
listName: "list",
tableOption: { width: "140", fixed: false },
tableColumns: [],
},
},
dialog: {
reject: {
businessCode: "",
show: false,
},
},
};
},
async mounted() {
this.loading.page = true;
try {
this.trackMenu();
await this.getBaseData();
await this.getHeaderSummary();
this.table.formSchema = await getTableFormSchema();
this.table.tableParams.tableColumns = await getTableColumns();
} finally {
this.loading.page = false;
}
},
methods: {
...mapActions({
close: "d2admin/page/close",
}),
checkQuery() {
const { searchForm, formSchema } = this.table;
const hasFormValue = formSchema.some(({ name }) => {
const value = get(searchForm, name);
if (Array.isArray(value)) {
return value.length > 0;
}
if (typeof value === "string") {
return value.trim() !== "";
}
return !isEmpty(value);
});
if (hasFormValue) {
return true;
}
return searchForm.orderBy !== "createdDate desc";
},
trackMenu() {
this.setReportTrackData(0, "task_web_menu_entry", {});
},
handleSearch(clearQuery = true, resetPage = true) {
const query = this.table.searchForm;
if (this.checkQuery()) {
console.log("埋点");
this.setReportTrackData(0, "task_web_search_request", query);
}
this.$refs.tableRef.refreshTable(clearQuery, resetPage);
},
async getBaseData() {
setAllOptions(this.table.formSchema);
},
async getHeaderSummary() {
const headerSummary = await getTaskCenterCountApi();
Object.assign(this.table.headerSummary, headerSummary);
},
handleReset() {
this.table.searchForm = this.$options.data().table.searchForm;
this.$refs.tableRef.refreshTable(false, true);
},
// 审核
async handleApprove(row) {
// this.$confirm("审核通过后,系统将自动完成上架商品及规则更新,且无法撤回。是否确认审核?", "提示", {
// confirmButtonText: "确定",
// cancelButtonText: "取消",
// type: "warning",
// beforeClose: async (action, instance, done) => {
// if (action === "confirm") {
// instance.confirmButtonLoading = true;
// try {
// await postShelfProductReviewApi({ businessCode: row.businessCode });
// await this.handleRefreshTable();
// this.$message.success("操作成功");
// } finally {
// instance.confirmButtonLoading = false;
// done();
// }
// } else {
// done();
// }
// },
// });
},
handleRefreshTable() {
// this.$refs.tableRef.refreshTable();
},
// 驳回
handleReject(row) {
// this.dialog.reject.businessCode = row.businessCode;
// this.dialog.reject.show = true;
},
// 查看
async handleDetail({ taskId, bizTypeName, bizType }) {
try {
this.setReportTrackData(0, "task_web_view_detail", { taskId, bizTypeName, bizType });
} finally {
this.$router.push({
name: "residentManageTaskCenterDetail",
query: {
taskId,
},
});
}
},
handleChangeSort(command) {
if (this.table.searchForm.orderBy === command) {
return;
}
this.table.searchForm.orderBy = command;
this.handleSearch(false, true);
},
// 新增 或 修改
handleModify({ operate, record }) {
// console.log("record", record);
// if (operate === "create") {
// this.$router.push({
// name: "goodsShelfCreate",
// });
// }
// if (operate === "edit") {
// this.$router.push({
// name: "goodsShelfModify",
// query: {
// baseSceneCode: record.baseSceneCode,
// businessCode: record.businessCode,
// shelfType: record.shelfType,
// },
// });
// }
},
},
};
</script>
<style lang="scss" scoped>
::v-deep .is-active {
background-color: #eaeef7;
color: #5579bd;
}
.d2-container-content {
.table-title-wrapper {
display: flex;
align-items: center;
margin-bottom: 8px;
> .title {
font-size: 16px;
font-weight: bold;
color: rgba(0, 0, 0, 0.88);
flex-shrink: 0;
}
> .table-sum-wrapper {
flex-shrink: 0;
flex: 1;
margin-left: 20px;
.el-tag {
margin-left: 16px;
&:first-child {
margin-left: 0;
}
color: #000;
font-size: 13px;
font-weight: bold;
border: 0;
background-color: #f5f5f5;
}
}
> .sort-wrapper {
}
}
::v-deep .d2-table {
.el-table__body-wrapper {
.cell {
padding: 0 6px;
.el-tag {
width: auto !important;
}
}
}
}
}
</style>