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
<template>
<el-row class="page-container dict">
<el-container class="page-main" :gutter="20">
<el-aside width="300px" class="left-content">
<el-col :span="24" class="left-title">
<span>协作组列表</span>
</el-col>
<el-col :span="24" class="left-search">
<el-input
v-model.trim="searchVal"
clearable
:placeholder="placeholder"
>
</el-input>
</el-col>
<el-col class="dict-list">
<el-tree
@node-click="handClick"
class="filter-tree"
:data="dictList"
highlight-current
:props="{
children: 'children',
label: 'name',
}"
default-expand-all
:filter-node-method="filterNode"
ref="tree"
>
</el-tree>
</el-col>
</el-aside>
<el-main>
<el-tabs v-model="activeName" type="card">
<el-tab-pane label="用户管理" name="first">
<GroupUser :group-id="groupId"></GroupUser>
</el-tab-pane>
<el-tab-pane label="表单管理" name="second">
<GroupForm :group-id="groupId"></GroupForm>
</el-tab-pane>
<el-tab-pane label="参数配置" name="fifth">
<ParameterConfig :group-id="groupId"></ParameterConfig>
</el-tab-pane>
</el-tabs>
</el-main>
</el-container>
<dialog-form
ref="edit"
:width="'450px'"
:title="dictTitle"
:form-data="formData"
:form-edit="formEdit"
@handleConfirm="handleConfirm"
/>
</el-row>
</template>
<script>
import GroupUser from "./GroupUser"
import GroupForm from "./GroupForm"
import ParameterConfig from "./ParameterConfig.vue"
import { translateListToTree } from "@/utils/handleRoutes"
import { getCoopGroupList, addCoopGroup } from "@/api/coop-group.js"
export default {
name: "CollaGroup",
components: {
GroupUser,
GroupForm,
ParameterConfig,
},
data() {
return {
groupId: "",
groupName: "",
activeName: "first",
total: 0,
searchList: [
{
type: "input",
label: "",
prop: "name",
placeholder: "名称",
labelWidth: "0",
slot: {
slot: "append",
type: "button",
icon: "el-icon-search",
},
},
],
dictTitle: "",
isActive: -1,
dictList: [],
typeCode: "",
searchVal: "",
placeholder: "请输入关键字",
listLoading: false,
tabData: [],
name: "",
formEdit: {},
formData: [
{
type: "input",
label: "名称",
prop: "groupName",
rules: [{ required: true, message: "名称必填" }],
},
{
type: "input",
label: "代码",
rules: [{ required: true, message: "分类必填" }],
prop: "groupCode",
},
{
type: "select",
label: "专病库",
rules: [{ required: true, message: "分类必填" }],
prop: "diseaseCode",
optsFormatter: () => {
return this.dictMap && this.dictMap["disease_code"]
},
},
{
type: "select",
label: "协作组等级",
rules: [{ required: true, message: "协作组等级必填" }],
prop: "level",
optsFormatter: () => {
return this.dictMap && this.dictMap["group_level"]
},
},
],
}
},
watch: {
searchVal(val) {
this.$refs.tree.filter(val)
},
},
methods: {
filterNode(value, data) {
if (!value) return true
return data.name.indexOf(value) !== -1
},
getListIdx(list, id) {
let listIdx = -1
for (var i = 0; i < list.length; i++) {
if (list[i].id === id) {
listIdx = i
break
}
}
return listIdx
},
// 获得列表
getDictList() {
getCoopGroupList().then((res) => {
if (res.code === 1) {
const d = res.data
this.dictList = translateListToTree(
d.map((item) => {
return {
...item,
name: item.groupName,
}
})
)
}
})
},
// 点击左侧列表
handClick({ id, groupName }) {
this.groupId = id
this.groupName = groupName
},
// 新增
handleAdd(row) {
this.dictTitle = row ? "编辑" : "新增"
this.formEdit = Object.assign({}, row)
this.$refs.edit.open()
},
// 保存
handleConfirm(d) {
const form = Object.assign({}, d)
let msg = form.id ? "修改成功" : "保存成功"
form.diseaseName = this.$handle.formatDicList(
this.dictMap["disease_code"],
form.diseaseCode
)
// 分类新增编辑
addCoopGroup(form)
.then((res) => {
if (res.code === 1) {
this.$message.success(msg)
this.$refs.edit.close()
}
})
.catch(() => {
this.$refs.edit.loading = false
})
},
},
mounted() {
this.getDictList()
},
}
</script>
<style lang="scss" scoped>
.el-main {
padding: 0 20px;
}
</style>