index.vue
4.72 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
<!-- 通用表单弹窗组件 -->
<template>
<div class="glsk-form-dialog">
<d2-dialog :append-to-body="appendToBody"
:btn-ok-label="dialogConfig.okText"
:is-visible="selectVisible"
:no-cancel="dialogConfig.hideClose"
:title="dialogConfig.title"
:width="dialogWidth"
@closeDialog="handleClose"
@confirmDialog="handleConfirm">
<glsx-combi-form ref="editFormRef"
class="edit-form-container"
:default-width="defaultWidth"
:form-data="editFormData"
:form-obj="editData"
:form-ref="editChildRef"
:form-rules="formRules"
:form-select-obj="formSelectObj"
:is-block="isBlock"
:label-width="labelWidth"
:nested-modal-append-to-body="nestedModalAppendToBody"
@handleAddSelectTypeConfirm="handleAddSelectTypeConfirm"
@handleEditSelectTypeConfirm="handleEditSelectTypeConfirm">
<template v-for="name in slotArr" #[name]>
<slot :name="name"></slot>
</template>
</glsx-combi-form>
</d2-dialog>
</div>
</template>
<script>
import { deepClone } from "@/common/util";
export default {
name: "GlskFormDialog",
props: {
slotArr: {
type: Array,
default: () => ["resumeUrlHtml"],
},
dialogWidth: {
type: String,
default: "700px",
},
labelWidth: {
type: String,
default: "100px",
},
defaultWidth: {
type: String,
default: "314px",
},
dialogConfig: {
type: Object,
default: () => {
return {
title: "提示",
okText: "确定",
hideClose: false,
};
},
},
selectVisible: {
type: Boolean,
default: false,
},
formRules: {
type: Object,
default: () => ({}),
},
editData: {
type: Object,
default: () => ({}),
},
editFormData: {
type: Array,
default: () => [],
},
baseData: {
type: Object,
default: () => ({}),
},
appendToBody: {
type: Boolean,
default: false,
},
/** 表单内含地图/上传预览等内层弹窗时,外层已是 d2-dialog 则建议开启 */
nestedModalAppendToBody: {
type: Boolean,
default: false,
},
// 搜索+输入框/搜索组合组件,搜索栏绑值
formSelectObj: {
type: Object,
default: () => {},
},
},
data() {
return {
isBlock: true,
editChildRef: "editChildRef",
};
},
mounted() {
this.getOptionsList("editFormData", false);
},
methods: {
getOptionsList(formName, hasAll = true, refreshSigle) {
if (refreshSigle) {
let item = this[formName].find(k => k.name == refreshSigle);
let index = this[formName].findIndex(k => k.name == refreshSigle);
this.$set(
this[formName][index],
"optionList",
deepClone(this.baseData[item.optionsName]),
);
if (
hasAll
&& this.baseData[item.optionsName].length
&& this.baseData[item.optionsName][0][
this[formName][index].optionLabel
] !== "全部"
) {
const temp = {};
temp[this[formName][index].optionId] = "";
temp[this[formName][index].optionLabel] = "全部";
this[formName][index].optionList.unshift(temp);
}
} else {
this[formName].forEach((item, index) => {
if (
["select", "radio"].includes(item.type)
&& this.baseData[item.optionsName].length
) {
this.$set(
this[formName][index],
"optionList",
deepClone(this.baseData[item.optionsName]),
);
if (
hasAll
&& this.baseData[item.optionsName].length
&& this.baseData[item.optionsName][0][
this[formName][index].optionLabel
] !== "全部"
) {
const temp = {};
temp[this[formName][index].optionId] = "";
temp[this[formName][index].optionLabel] = "全部";
this[formName][index].optionList.unshift(temp);
}
}
});
}
},
handleConfirm() {
console.log(this.editFormData, this.editData);
this.$refs.editFormRef.$refs[this.editChildRef].validate((valid) => {
if (valid) {
this.$emit("handleConfirm", this.editData);
}
});
},
handleAddSelectTypeConfirm(data) {
this.$emit("handleAddSelectTypeConfirm", data);
},
handleEditSelectTypeConfirm(data) {
this.$emit("handleEditSelectTypeConfirm", data);
},
handleClose() {
this.$emit("handleClose");
},
},
};
</script>
<style lang="scss" scoped>
.glsk-form-dialog {
::v-deep {
.el-dialog__header {
border-bottom: 1px solid #e5e5e5 !important;
}
}
::v-deep {
.el-dialog__footer {
border-top: 1px solid #e5e5e5 !important;
.el-button {
width: 80px;
}
}
}
}
</style>