index.vue
5.01 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
<!-- 项目组管理 -->
<template>
<d2-container class="manage-project-group-manage">
<template #header>
<div class="header">
<d2-search ref="showSearch"
class="show-search"
:form-data="showFormData"
:search-form="searchForm" />
<div class="up-btns">
<el-button :id="tableParams.btnId"
size="small"
type="primary">
查询
</el-button>
<el-button size="small" @click="handleReset">
重置
</el-button>
</div>
</div>
</template>
<div class="d2-container-content">
<d2-table-header>
<auth-button category="Button" />
</d2-table-header>
<d2-table ref="serviceStoreTable"
:before-search-fn="beforeSearchFn"
:get-list-api="getListApi"
:search-form="searchForm"
:table-params="tableParams">
<template #auth-button="scope">
<el-button size="mini"
type="text"
@click="handleEdit(scope.scope)">
编辑
</el-button>
<el-button size="mini"
type="text"
@click="handleStoreManage(scope.scope)">
门店管理
</el-button>
<el-button v-if="scope.scope.canDelete !== false"
size="mini"
type="text"
:loading="!!scope.scope._deleteLoading"
@click="handleDelete(scope.scope)">
删除
</el-button>
</template>
</d2-table>
</div>
</d2-container>
</template>
<script>
import { deleteProjectGroup, getProjectGroupList } from "@api/projectGroup";
import { Util } from "@/common/util";
export default {
name: "ManageProjectGroupManage",
data() {
return {
searchForm: {
groupName: "",
},
showFormData: [{
label: "项目组名称",
name: "groupName",
type: "input",
placeholder: "请输入项目组名称",
maxlength: 10,
isClear: true,
keyFn: this.keyDowmGetList,
}],
tableParams: {
btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
listName: "list",
tableOption: true,
tableColumns: [{
label: "项目组名称",
minWidth: 200,
prop: "groupName",
showOverFlow: true,
}, {
label: "门店数量",
width: 100,
prop: "storeCount",
formatter: (row) => {
const val = row.storeCount;
return val === 0 || val ? val : "-";
},
}, {
label: "创建人",
width: 120,
prop: "createdBy",
formatter: (row) => {
return row.createdBy || "-";
},
}, {
label: "创建时间",
width: 180,
prop: "createdDate",
formatter: (row) => {
const time = row.createdDate;
return time ? Util.dateFormate(time, "YYYY-MM-DD HH:mm:ss") : "-";
},
}],
},
};
},
methods: {
getRowGroupId(row) {
return row && (row.groupId ?? row.id);
},
beforeSearchFn() {
return Promise.resolve();
},
getListApi(params) {
return getProjectGroupList({
groupName: (params.groupName || "").trim(),
pageNum: params.currentPage || 1,
pageSize: params.pageSize || 10,
});
},
keyDowmGetList() {
this.$refs.serviceStoreTable.refreshTable();
},
handleReset() {
this.searchForm = {
groupName: "",
};
this.$refs.serviceStoreTable.refreshTable(false, true);
},
handleAdd() {
this.$router.push({
name: "manageProjectGroupAdd",
});
},
handleStoreManage(row) {
const groupId = this.getRowGroupId(row);
this.$router.push({
name: "manageProjectGroupStore",
query: {
groupId: groupId != null && groupId !== "" ? String(groupId) : "",
groupName: row && row.groupName ? String(row.groupName) : "",
},
});
},
handleEdit(row) {
const groupId = this.getRowGroupId(row);
this.$router.push({
name: "manageProjectGroupAdd",
query: {
groupId: groupId != null && groupId !== "" ? String(groupId) : "",
},
});
},
handleDelete(row) {
const groupId = this.getRowGroupId(row);
if (groupId == null || groupId === "") {
this.$message.error("缺少项目组ID,无法删除");
return;
}
const groupName = row.groupName || "";
this.$confirm(
groupName ? `确定删除项目组「${groupName}」吗?` : "确定删除该项目组吗?",
"提示",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
closeOnClickModal: false,
},
).then(() => {
this.$set(row, "_deleteLoading", true);
return deleteProjectGroup({ groupId });
}).then(() => {
this.$message.success("删除成功");
this.$refs.serviceStoreTable.refreshTable();
}).catch(() => {}).finally(() => {
this.$set(row, "_deleteLoading", false);
});
},
},
};
</script>
<style lang="scss" scoped>
::v-deep .show-search .el-form-item__label {
white-space: nowrap;
word-break: keep-all;
}
</style>