kz-ui-base 1.0.13 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/src/components/base/dialog/Dialog.js +113 -2
- package/common/src/components/base/dialog/dialogType.js +32 -10
- package/common/src/components/base/dialog/editDialog.vue +192 -0
- package/common/src/components/base/dialog/lookupDialog.vue +224 -0
- package/common/src/components/base/dialog/printDialog.vue +1 -1
- package/common/src/components/base/dialog/tableDialog.vue +5 -1
- package/common/src/components/base/dialog/uploadDialog.vue +13 -0
- package/common/src/components/customForm/editTable.vue +324 -0
- package/common/src/components/customForm/lookup.vue +162 -0
- package/common/src/components/customForm/searchTable.vue +677 -0
- package/common/src/views/login.vue +8 -26
- package/common/src/views/tenantLogin.vue +12 -20
- package/package.json +1 -1
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-form :model="form" ref="form" size="small" :rules="rules">
|
|
3
|
+
<el-table :data="form.list" border>
|
|
4
|
+
<el-table-column
|
|
5
|
+
v-for="x in columns"
|
|
6
|
+
:key="x.prop"
|
|
7
|
+
:label="x.text"
|
|
8
|
+
:prop="x.prop"
|
|
9
|
+
v-bind="x.attr"
|
|
10
|
+
:show-overflow-tooltip="true"
|
|
11
|
+
>
|
|
12
|
+
<template slot-scope="{ row, $index }">
|
|
13
|
+
<t-text v-if="!x.edit" :row="{ x, row }" />
|
|
14
|
+
<template v-else>
|
|
15
|
+
<t-text v-if="isDetail" :row="{ x, row }" />
|
|
16
|
+
<template v-else>
|
|
17
|
+
<t-input
|
|
18
|
+
v-if="x.prop !== 'opt'"
|
|
19
|
+
v-model="row[`${x.prop}`]"
|
|
20
|
+
v-bind="componentAttrs(x, row, $index)"
|
|
21
|
+
class="width100"
|
|
22
|
+
@change="iptchange(row)"
|
|
23
|
+
/>
|
|
24
|
+
<template v-else>
|
|
25
|
+
<!-- <el-link
|
|
26
|
+
type="primary"
|
|
27
|
+
:underline="false"
|
|
28
|
+
@click="save(row, $index)"
|
|
29
|
+
>保存</el-link
|
|
30
|
+
> -->
|
|
31
|
+
<el-link
|
|
32
|
+
type="primary"
|
|
33
|
+
:underline="false"
|
|
34
|
+
v-if="row.isAdd"
|
|
35
|
+
@click="del($index)"
|
|
36
|
+
>删除</el-link
|
|
37
|
+
>
|
|
38
|
+
<el-link
|
|
39
|
+
type="primary"
|
|
40
|
+
:underline="false"
|
|
41
|
+
@click="resetField($index)"
|
|
42
|
+
>重置</el-link
|
|
43
|
+
>
|
|
44
|
+
</template>
|
|
45
|
+
</template>
|
|
46
|
+
</template>
|
|
47
|
+
</template>
|
|
48
|
+
</el-table-column>
|
|
49
|
+
</el-table>
|
|
50
|
+
|
|
51
|
+
<el-form-item v-if="buttomShow">
|
|
52
|
+
<template v-if="isSubmit">
|
|
53
|
+
<el-button type="primary" @click="add">新增</el-button>
|
|
54
|
+
<!-- <el-button type="primary" @click="submit">提交</el-button> -->
|
|
55
|
+
<el-button @click="reset">重置</el-button>
|
|
56
|
+
</template>
|
|
57
|
+
</el-form-item>
|
|
58
|
+
</el-form>
|
|
59
|
+
</template>
|
|
60
|
+
|
|
61
|
+
<script>
|
|
62
|
+
export default {
|
|
63
|
+
props: { config: Object },
|
|
64
|
+
components: {
|
|
65
|
+
TInput: {
|
|
66
|
+
functional: true,
|
|
67
|
+
props: ["prop", "rules", "type", "options", "row", "cb"],
|
|
68
|
+
render: (
|
|
69
|
+
h,
|
|
70
|
+
{
|
|
71
|
+
props: {
|
|
72
|
+
prop,
|
|
73
|
+
rules,
|
|
74
|
+
type = "default",
|
|
75
|
+
options = [],
|
|
76
|
+
row,
|
|
77
|
+
cb = () => {},
|
|
78
|
+
},
|
|
79
|
+
data,
|
|
80
|
+
listeners: { input = () => {} },
|
|
81
|
+
}
|
|
82
|
+
) => {
|
|
83
|
+
const children = {
|
|
84
|
+
checkbox: (h) =>
|
|
85
|
+
h(
|
|
86
|
+
"el-checkbox-group",
|
|
87
|
+
{
|
|
88
|
+
props: { ...data.attrs },
|
|
89
|
+
on: {
|
|
90
|
+
input(v) {
|
|
91
|
+
input(v);
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
options.map((o) =>
|
|
96
|
+
h(
|
|
97
|
+
"el-checkbox",
|
|
98
|
+
{ props: { ...o, label: o.value, key: o.value } },
|
|
99
|
+
[o.label]
|
|
100
|
+
)
|
|
101
|
+
)
|
|
102
|
+
),
|
|
103
|
+
select: (h) =>
|
|
104
|
+
h(
|
|
105
|
+
"el-select",
|
|
106
|
+
{
|
|
107
|
+
class: "width100",
|
|
108
|
+
props: { ...data.attrs },
|
|
109
|
+
on: {
|
|
110
|
+
change(v) {
|
|
111
|
+
input(v);
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
options.map((o) =>
|
|
116
|
+
h("el-option", { props: { ...o, key: o.value } })
|
|
117
|
+
)
|
|
118
|
+
),
|
|
119
|
+
date: (h) =>
|
|
120
|
+
h("el-date-picker", {
|
|
121
|
+
props: { type: "date", valueFormat: "yyyy-MM-dd" },
|
|
122
|
+
...data,
|
|
123
|
+
}),
|
|
124
|
+
|
|
125
|
+
switch: (h) =>
|
|
126
|
+
h("el-switch", { props: { activeColor: "#13ce66" }, ...data }),
|
|
127
|
+
mixInput: (h) =>
|
|
128
|
+
h("el-input", data, [
|
|
129
|
+
h("el-button", {
|
|
130
|
+
slot: "append",
|
|
131
|
+
props: { icon: "el-icon-search" },
|
|
132
|
+
on: {
|
|
133
|
+
click() {
|
|
134
|
+
cb(row);
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
}),
|
|
138
|
+
]),
|
|
139
|
+
opt: () => "-",
|
|
140
|
+
default: (h) => h("el-input", data),
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
return h("el-form-item", { props: { prop, rules } }, [
|
|
144
|
+
children[type](h),
|
|
145
|
+
]);
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
TText: {
|
|
149
|
+
functional: true,
|
|
150
|
+
props: ["row"],
|
|
151
|
+
render: (
|
|
152
|
+
h,
|
|
153
|
+
{
|
|
154
|
+
props: {
|
|
155
|
+
row: { x, row },
|
|
156
|
+
},
|
|
157
|
+
}
|
|
158
|
+
) => {
|
|
159
|
+
if (!row[`${x.prop}`]) return h("span", "-");
|
|
160
|
+
else if (x.format && typeof x.format == "function")
|
|
161
|
+
return h("span", x.format(row));
|
|
162
|
+
else return h("span", row[`${x.prop}`]);
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
data() {
|
|
167
|
+
const {
|
|
168
|
+
columns = [],
|
|
169
|
+
data = [],
|
|
170
|
+
isDetail = false,
|
|
171
|
+
isSubmit = true,
|
|
172
|
+
buttomShow = false,
|
|
173
|
+
} = this.config || {};
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
form: {
|
|
177
|
+
list: data,
|
|
178
|
+
// && data.length > 0
|
|
179
|
+
// ? data.map((n) =>
|
|
180
|
+
// columns.reduce(
|
|
181
|
+
// (r, c) => ({
|
|
182
|
+
// ...r,
|
|
183
|
+
// [c.prop]:
|
|
184
|
+
// n[c.prop] == false
|
|
185
|
+
// ? n[c.prop]
|
|
186
|
+
// : n[c.prop] || (c.type == "checkbox" ? [] : ""),
|
|
187
|
+
// }),
|
|
188
|
+
// {}
|
|
189
|
+
// )
|
|
190
|
+
// )
|
|
191
|
+
// : [
|
|
192
|
+
// columns.reduce(
|
|
193
|
+
// (r, c) => ({
|
|
194
|
+
// ...r,
|
|
195
|
+
// [c.prop]:
|
|
196
|
+
// c.type == "checkbox"
|
|
197
|
+
// ? []
|
|
198
|
+
// : c.type == "switch"
|
|
199
|
+
// ? false
|
|
200
|
+
// : "",
|
|
201
|
+
// }),
|
|
202
|
+
// { isAdd: true }
|
|
203
|
+
// ),
|
|
204
|
+
// ],
|
|
205
|
+
},
|
|
206
|
+
columns,
|
|
207
|
+
rules: columns.reduce(
|
|
208
|
+
(r, c) => ({
|
|
209
|
+
...r,
|
|
210
|
+
//input校验
|
|
211
|
+
// [c.prop]: {
|
|
212
|
+
// required: c.required == false ? false : true,
|
|
213
|
+
// message: c.label + "必填",
|
|
214
|
+
// trigger: "blur",
|
|
215
|
+
// },
|
|
216
|
+
}),
|
|
217
|
+
{}
|
|
218
|
+
),
|
|
219
|
+
isDetail,
|
|
220
|
+
isSubmit,
|
|
221
|
+
buttomShow,
|
|
222
|
+
};
|
|
223
|
+
},
|
|
224
|
+
created() {},
|
|
225
|
+
methods: {
|
|
226
|
+
iptchange(row) {
|
|
227
|
+
this.$emit("iptchange", row);
|
|
228
|
+
},
|
|
229
|
+
componentAttrs(item, row, idx) {
|
|
230
|
+
const { type, text } = item,
|
|
231
|
+
attrs = Object.fromEntries(
|
|
232
|
+
Object.entries(item).filter(
|
|
233
|
+
(n) => !/^(prop|edit|text|attr|format)/.test(n[0])
|
|
234
|
+
)
|
|
235
|
+
),
|
|
236
|
+
placeholder =
|
|
237
|
+
(/^(select|el-date-picker)/.test(type) ? "请选择" : "请输入") + text;
|
|
238
|
+
Object.assign(attrs, {
|
|
239
|
+
prop: `list.${idx}.${item.prop}`,
|
|
240
|
+
rules: this.rules[item.prop],
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
return { ...attrs, row, placeholder };
|
|
244
|
+
},
|
|
245
|
+
add() {
|
|
246
|
+
const { columns = [] } = this.config || {},
|
|
247
|
+
obj = columns.reduce(
|
|
248
|
+
(r, c) => ({
|
|
249
|
+
...r,
|
|
250
|
+
[c.prop]:
|
|
251
|
+
c.type == "checkbox" ? [] : c.type == "switch" ? false : "",
|
|
252
|
+
}),
|
|
253
|
+
{ isAdd: true }
|
|
254
|
+
);
|
|
255
|
+
this.form.list.push(obj);
|
|
256
|
+
},
|
|
257
|
+
save(row, idx) {
|
|
258
|
+
let ret = Object.keys(row)
|
|
259
|
+
.map((r) => `list.${idx}.${r}`)
|
|
260
|
+
.filter((r) => !/isAdd|opt/g.test(r)),
|
|
261
|
+
{
|
|
262
|
+
$refs: { form },
|
|
263
|
+
} = this,
|
|
264
|
+
num = 0;
|
|
265
|
+
|
|
266
|
+
form.validateField(ret, (valid) => {
|
|
267
|
+
if (valid) {
|
|
268
|
+
num++;
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
if (num == 0)
|
|
273
|
+
this.$emit(
|
|
274
|
+
"submit",
|
|
275
|
+
Object.fromEntries(
|
|
276
|
+
Object.entries(row).filter((n) => !/^(isAdd|opt)/.test(n[0]))
|
|
277
|
+
)
|
|
278
|
+
);
|
|
279
|
+
},
|
|
280
|
+
del(idx) {
|
|
281
|
+
this.form.list.splice(idx, 1);
|
|
282
|
+
this.$refs.form.fields.forEach((n) => {
|
|
283
|
+
if (n.prop.split(".")[1] == idx) {
|
|
284
|
+
n.clearValidate();
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
},
|
|
288
|
+
submit() {
|
|
289
|
+
this.$refs.form.validate((valid) => {
|
|
290
|
+
if (valid) {
|
|
291
|
+
this.$emit(
|
|
292
|
+
"submit",
|
|
293
|
+
this.form.list
|
|
294
|
+
// this.form.list.map((m) =>
|
|
295
|
+
// Object.fromEntries(
|
|
296
|
+
// Object.entries(m).filter((n) => !/^(isAdd|opt)/.test(n[0]))
|
|
297
|
+
// )
|
|
298
|
+
// )
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
resetField(idx) {
|
|
304
|
+
console.log(this.$refs.form);
|
|
305
|
+
this.$refs.form.fields.forEach((n) => {
|
|
306
|
+
if (n.prop.split(".")[1] == idx) {
|
|
307
|
+
n.resetField();
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
},
|
|
311
|
+
reset() {
|
|
312
|
+
this.$refs.form.resetFields();
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
};
|
|
316
|
+
</script>
|
|
317
|
+
<style scoped>
|
|
318
|
+
.width100 {
|
|
319
|
+
width: 100%;
|
|
320
|
+
}
|
|
321
|
+
.el-form-item--small.el-form-item {
|
|
322
|
+
margin-bottom: 0px;
|
|
323
|
+
}
|
|
324
|
+
</style>
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-form-item :label="column.text" :prop="column.property">
|
|
3
|
+
<el-input v-model="displayText" :placeholder="column.text" :disabled="true">
|
|
4
|
+
<input type="text" v-model="entity[column.property]" hidden />
|
|
5
|
+
<el-button
|
|
6
|
+
type="primary"
|
|
7
|
+
icon="el-icon-search"
|
|
8
|
+
slot="append"
|
|
9
|
+
@click="handleQuery"
|
|
10
|
+
></el-button>
|
|
11
|
+
</el-input>
|
|
12
|
+
</el-form-item>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
import formMixins from "./formMixins";
|
|
17
|
+
import LookupDialog from "../base/dialog/lookupDialog";
|
|
18
|
+
import eventHub from "@utils/eventHub";
|
|
19
|
+
import * as Utils from "@utils/utils";
|
|
20
|
+
export default {
|
|
21
|
+
name: "Lookup",
|
|
22
|
+
props: {
|
|
23
|
+
setting: {
|
|
24
|
+
type: Object,
|
|
25
|
+
default: function () {
|
|
26
|
+
return undefined;
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
mixins: [formMixins],
|
|
31
|
+
component: [LookupDialog],
|
|
32
|
+
data() {
|
|
33
|
+
return {
|
|
34
|
+
currentValue: this.value,
|
|
35
|
+
displayValue: undefined,
|
|
36
|
+
clickNum: true, //是否为第一次点击
|
|
37
|
+
//url,若Url中有变量,则使用此Url保存原始Url
|
|
38
|
+
url: undefined,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
created() {},
|
|
42
|
+
computed: {
|
|
43
|
+
displayText(val) {
|
|
44
|
+
return (
|
|
45
|
+
this.displayValue ||
|
|
46
|
+
this.entity[this.setting.displayProperty] ||
|
|
47
|
+
this.entity[this.column.property]
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
methods: {
|
|
52
|
+
|
|
53
|
+
replaceUrl(url, entity) {
|
|
54
|
+
for (var k in entity) {
|
|
55
|
+
//替换文本属性值
|
|
56
|
+
if (url.indexOf("{" + k + "}") > 0) {
|
|
57
|
+
url = url.replaceAll(
|
|
58
|
+
"{" + k + "}",
|
|
59
|
+
entity[k]
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return url;
|
|
64
|
+
},
|
|
65
|
+
handleQuery() {
|
|
66
|
+
//第二次点击还原数据
|
|
67
|
+
if (this.clickNum) {
|
|
68
|
+
this.newSetting = JSON.stringify(this.setting);
|
|
69
|
+
this.clickNum = false;
|
|
70
|
+
} else {
|
|
71
|
+
this.setting = JSON.parse(this.newSetting);
|
|
72
|
+
}
|
|
73
|
+
var self = this;
|
|
74
|
+
if (this.setting.url && this.setting.url.indexOf("{") > -1 && !this.url) {
|
|
75
|
+
if (this.setting.url.indexOf("{") > -1) {
|
|
76
|
+
this.url = this.setting.url;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (this.url) {
|
|
80
|
+
this.setting.url = this.replaceUrl(this.url, this.entity);
|
|
81
|
+
}
|
|
82
|
+
this.Dialog.open({
|
|
83
|
+
component: LookupDialog,
|
|
84
|
+
setting: this.setting,
|
|
85
|
+
data: { entity: this.entity },
|
|
86
|
+
//beforeClose: (done) => {
|
|
87
|
+
// //点右上角关闭按钮后触发
|
|
88
|
+
// console.log("1");
|
|
89
|
+
// done();
|
|
90
|
+
//},
|
|
91
|
+
//close: () => {
|
|
92
|
+
// //关闭后触发
|
|
93
|
+
// console.log("2");
|
|
94
|
+
//},
|
|
95
|
+
confirm: (result) => {
|
|
96
|
+
//显式$emit('confirm')时触发
|
|
97
|
+
console.log("3 ", result);
|
|
98
|
+
var newValue = result.data[self.setting.valueField];
|
|
99
|
+
this.$set(self.entity, self.column.property, newValue);
|
|
100
|
+
// self.entity[self.column.property] = newValue;
|
|
101
|
+
self.displayValue = result.data[self.setting.displayField];
|
|
102
|
+
if (self.setting.displayProperty)
|
|
103
|
+
this.$set(
|
|
104
|
+
self.entity,
|
|
105
|
+
self.setting.displayProperty,
|
|
106
|
+
self.displayValue
|
|
107
|
+
);
|
|
108
|
+
// self.entity[self.setting.displayProperty] = self.displayValue;
|
|
109
|
+
if (self.setting && self.setting.relationFields) {
|
|
110
|
+
var data = result.data;
|
|
111
|
+
if (self.setting.relationFieldsIgnoreNull) {
|
|
112
|
+
for (var key in self.setting.relationFields) {
|
|
113
|
+
var keyField = Utils.firstSpellToLower(key);
|
|
114
|
+
var valueField = Utils.firstSpellToLower(
|
|
115
|
+
self.setting.relationFields[key]
|
|
116
|
+
);
|
|
117
|
+
var Ignorekey = self.setting.relationFieldsIgnoreNull.find(
|
|
118
|
+
(x) => x == key
|
|
119
|
+
);
|
|
120
|
+
if (Ignorekey == undefined) {
|
|
121
|
+
var value = Utils.GetPropertyValue(data, valueField);
|
|
122
|
+
if (data && value != undefined) self.entity[keyField] = value;
|
|
123
|
+
// else self.entity[keyField] = undefined;
|
|
124
|
+
else this.$set(self.entity, keyField, undefined);
|
|
125
|
+
} else {
|
|
126
|
+
var value = Utils.GetPropertyValue(data, valueField);
|
|
127
|
+
// if (data && value != undefined) self.entity[keyField] = value;
|
|
128
|
+
if (data && value != undefined)
|
|
129
|
+
this.$set(self.entity, keyField, value);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
for (var key in self.setting.relationFields) {
|
|
134
|
+
var keyField = Utils.firstSpellToLower(key);
|
|
135
|
+
var valueField = Utils.firstSpellToLower(
|
|
136
|
+
self.setting.relationFields[key]
|
|
137
|
+
);
|
|
138
|
+
var value = Utils.GetPropertyValue(data, valueField);
|
|
139
|
+
if (data && value != undefined) this.$set(self.entity, keyField, value);
|
|
140
|
+
// else self.entity[keyField] = undefined;
|
|
141
|
+
else this.$set(self.entity, keyField, undefined);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
eventHub.$emit("entityValueChange", {
|
|
146
|
+
property: self.column.property,
|
|
147
|
+
value: newValue,
|
|
148
|
+
data: result.data,
|
|
149
|
+
column: self.column,
|
|
150
|
+
});
|
|
151
|
+
self.$emit("change", {
|
|
152
|
+
property: self.column.property,
|
|
153
|
+
value: newValue,
|
|
154
|
+
data: result.data,
|
|
155
|
+
column: self.column,
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
</script>
|