gyyg-components 0.4.7 → 0.4.9
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/lib/gyyg-components.common.js +216 -110
- package/lib/gyyg-components.umd.js +216 -110
- package/lib/gyyg-components.umd.min.js +216 -110
- package/package.json +1 -1
- package/src/components/MecButtonGroup/MecButtonGroup.vue +1 -0
- package/src/components/MecInputDropdown/MecInputDropdown.js +5 -0
- package/src/components/MecInputDropdown/MecInputDropdown.vue +280 -0
- package/src/components/MecTable/MecTable.vue +40 -1
- package/src/otherComponents/styleText.vue +2 -2
package/package.json
CHANGED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-input
|
|
3
|
+
v-model="inputValue"
|
|
4
|
+
:placeholder="placeholder"
|
|
5
|
+
:type="inputTypeValue"
|
|
6
|
+
:disabled="disabled"
|
|
7
|
+
:readonly="readonly"
|
|
8
|
+
:size="size"
|
|
9
|
+
:maxlength="maxlength"
|
|
10
|
+
:show-word-limit="showWordLimit"
|
|
11
|
+
:clearable="clearable"
|
|
12
|
+
:prefix-icon="prefixIcon"
|
|
13
|
+
:suffix-icon="suffixIcon"
|
|
14
|
+
:rows="rows"
|
|
15
|
+
:autosize="autosize"
|
|
16
|
+
v-bind="$attrs"
|
|
17
|
+
v-feeInput="isFeeInput"
|
|
18
|
+
@input="handleInput"
|
|
19
|
+
@clear="clear"
|
|
20
|
+
@keyup.enter.native="handleEnter"
|
|
21
|
+
@blur="handleBlur"
|
|
22
|
+
>
|
|
23
|
+
<el-dropdown
|
|
24
|
+
slot="append"
|
|
25
|
+
trigger="click"
|
|
26
|
+
:disabled="disabled || optionList.length === 0"
|
|
27
|
+
@command="handleDropdownCommand"
|
|
28
|
+
>
|
|
29
|
+
<span
|
|
30
|
+
class="mec-input-dropdown__text"
|
|
31
|
+
:class="{ 'is-disabled': disabled }"
|
|
32
|
+
>
|
|
33
|
+
{{ selectedLabel }}
|
|
34
|
+
<i class="el-icon-arrow-down el-icon--right"></i>
|
|
35
|
+
</span>
|
|
36
|
+
<el-dropdown-menu slot="dropdown">
|
|
37
|
+
<el-dropdown-item
|
|
38
|
+
v-for="item in optionList"
|
|
39
|
+
:key="getItemKey(item)"
|
|
40
|
+
:command="item[props.value]"
|
|
41
|
+
:disabled="item.disabled"
|
|
42
|
+
>
|
|
43
|
+
{{ item[props.label] }}
|
|
44
|
+
</el-dropdown-item>
|
|
45
|
+
</el-dropdown-menu>
|
|
46
|
+
</el-dropdown>
|
|
47
|
+
</el-input>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<script>
|
|
51
|
+
import feeInput from "@/directive/mec-feeInput/index";
|
|
52
|
+
|
|
53
|
+
export default {
|
|
54
|
+
name: "MecInputDropdown",
|
|
55
|
+
directives: {
|
|
56
|
+
feeInput,
|
|
57
|
+
},
|
|
58
|
+
props: {
|
|
59
|
+
value: {
|
|
60
|
+
default: "",
|
|
61
|
+
},
|
|
62
|
+
dropdownValue: {
|
|
63
|
+
default: null,
|
|
64
|
+
},
|
|
65
|
+
options: {
|
|
66
|
+
required: true,
|
|
67
|
+
},
|
|
68
|
+
props: {
|
|
69
|
+
type: Object,
|
|
70
|
+
default() {
|
|
71
|
+
return {
|
|
72
|
+
label: "name",
|
|
73
|
+
value: "id",
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
placeholder: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: "",
|
|
80
|
+
},
|
|
81
|
+
dropdownPlaceholder: {
|
|
82
|
+
type: String,
|
|
83
|
+
default: "请选择",
|
|
84
|
+
},
|
|
85
|
+
inputType: {
|
|
86
|
+
type: String,
|
|
87
|
+
default: "text",
|
|
88
|
+
},
|
|
89
|
+
type: {
|
|
90
|
+
type: String,
|
|
91
|
+
default: "text",
|
|
92
|
+
},
|
|
93
|
+
disabled: {
|
|
94
|
+
type: Boolean,
|
|
95
|
+
default: false,
|
|
96
|
+
},
|
|
97
|
+
readonly: {
|
|
98
|
+
type: Boolean,
|
|
99
|
+
default: false,
|
|
100
|
+
},
|
|
101
|
+
size: {
|
|
102
|
+
type: String,
|
|
103
|
+
default: "medium",
|
|
104
|
+
},
|
|
105
|
+
maxlength: {
|
|
106
|
+
type: [Number, String],
|
|
107
|
+
default: -1,
|
|
108
|
+
},
|
|
109
|
+
showWordLimit: {
|
|
110
|
+
type: Boolean,
|
|
111
|
+
default: false,
|
|
112
|
+
},
|
|
113
|
+
clearable: {
|
|
114
|
+
type: Boolean,
|
|
115
|
+
default: false,
|
|
116
|
+
},
|
|
117
|
+
prefixIcon: {
|
|
118
|
+
type: String,
|
|
119
|
+
default: "",
|
|
120
|
+
},
|
|
121
|
+
suffixIcon: {
|
|
122
|
+
type: String,
|
|
123
|
+
default: "",
|
|
124
|
+
},
|
|
125
|
+
rows: {
|
|
126
|
+
default: 2,
|
|
127
|
+
},
|
|
128
|
+
autosize: {
|
|
129
|
+
type: [Boolean, Object],
|
|
130
|
+
default: () => {
|
|
131
|
+
return { minRows: 2 };
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
isFeeInput: {
|
|
135
|
+
type: Boolean,
|
|
136
|
+
default: false,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
data() {
|
|
140
|
+
return {
|
|
141
|
+
inputValue: "",
|
|
142
|
+
selectedDropdown: null,
|
|
143
|
+
optionList: [],
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
computed: {
|
|
147
|
+
inputTypeValue() {
|
|
148
|
+
return this.inputType === "textarea" ? "textarea" : this.type;
|
|
149
|
+
},
|
|
150
|
+
optionMap() {
|
|
151
|
+
const map = new Map();
|
|
152
|
+
this.optionList.forEach((item) => {
|
|
153
|
+
map.set(item[this.props.value], item);
|
|
154
|
+
});
|
|
155
|
+
return map;
|
|
156
|
+
},
|
|
157
|
+
selectedInfo() {
|
|
158
|
+
return this.optionMap.get(this.selectedDropdown) || {};
|
|
159
|
+
},
|
|
160
|
+
selectedLabel() {
|
|
161
|
+
return this.selectedInfo[this.props.label] || this.dropdownPlaceholder;
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
watch: {
|
|
165
|
+
value: {
|
|
166
|
+
handler(newValue) {
|
|
167
|
+
this.inputValue = newValue;
|
|
168
|
+
},
|
|
169
|
+
immediate: true,
|
|
170
|
+
},
|
|
171
|
+
dropdownValue: {
|
|
172
|
+
handler(newValue) {
|
|
173
|
+
this.selectedDropdown = newValue;
|
|
174
|
+
this.selectFirstIfNeeded();
|
|
175
|
+
},
|
|
176
|
+
immediate: true,
|
|
177
|
+
},
|
|
178
|
+
options: {
|
|
179
|
+
handler(newOptions) {
|
|
180
|
+
this.processOptions(newOptions);
|
|
181
|
+
},
|
|
182
|
+
deep: true,
|
|
183
|
+
immediate: true,
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
methods: {
|
|
187
|
+
async processOptions(options) {
|
|
188
|
+
try {
|
|
189
|
+
let result = options;
|
|
190
|
+
|
|
191
|
+
if (options instanceof Promise) {
|
|
192
|
+
result = await options;
|
|
193
|
+
} else if (typeof options === "function") {
|
|
194
|
+
result = await options();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
this.optionList = Array.isArray(result) ? result : (result && result.data) || [];
|
|
198
|
+
this.selectFirstIfNeeded();
|
|
199
|
+
} catch (error) {
|
|
200
|
+
console.error("Failed to process options:", error);
|
|
201
|
+
this.optionList = [];
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
isEmptyValue(value) {
|
|
205
|
+
return value === undefined || value === null || value === "";
|
|
206
|
+
},
|
|
207
|
+
selectFirstIfNeeded() {
|
|
208
|
+
if (!this.optionList.length || !this.isEmptyValue(this.selectedDropdown)) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const firstOption = this.optionList[0];
|
|
213
|
+
this.setDropdownValue(firstOption[this.props.value]);
|
|
214
|
+
},
|
|
215
|
+
getItemKey(item) {
|
|
216
|
+
return item[this.props.value];
|
|
217
|
+
},
|
|
218
|
+
getOptionInfo(value) {
|
|
219
|
+
return this.optionMap.get(value) || {};
|
|
220
|
+
},
|
|
221
|
+
handleInput(val) {
|
|
222
|
+
let value = val;
|
|
223
|
+
if (this.inputType === "number") {
|
|
224
|
+
value = value.replace(/[^0-9]/g, "");
|
|
225
|
+
} else if (this.inputType === "chinese") {
|
|
226
|
+
value = value.replace(/[^\u4e00-\u9fa5]/g, "");
|
|
227
|
+
} else if (this.inputType === "english") {
|
|
228
|
+
value = value.replace(/[^a-zA-Z\s]/g, "");
|
|
229
|
+
} else if (this.inputType === "amount") {
|
|
230
|
+
value = value.replace(/[^0-9.]/g, "");
|
|
231
|
+
if (value.split(".").length > 2) {
|
|
232
|
+
value = value.replace(/\.+$/, "");
|
|
233
|
+
}
|
|
234
|
+
} else if (this.inputType === "englishAndNumber") {
|
|
235
|
+
value = value.replace(/[^a-zA-Z0-9\s]/g, "");
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
this.inputValue = value;
|
|
239
|
+
this.$emit("input", value);
|
|
240
|
+
this.$emit("update:value", value);
|
|
241
|
+
},
|
|
242
|
+
handleDropdownCommand(val) {
|
|
243
|
+
if (this.disabled) return;
|
|
244
|
+
|
|
245
|
+
this.setDropdownValue(val);
|
|
246
|
+
},
|
|
247
|
+
setDropdownValue(val) {
|
|
248
|
+
this.selectedDropdown = val;
|
|
249
|
+
console.log(val);
|
|
250
|
+
const info = this.getOptionInfo(val);
|
|
251
|
+
|
|
252
|
+
this.$emit("dropdown-change", val, info);
|
|
253
|
+
this.$emit("change", val, info);
|
|
254
|
+
this.$emit("update:dropdownValue", val);
|
|
255
|
+
},
|
|
256
|
+
clear() {
|
|
257
|
+
this.$emit("clear");
|
|
258
|
+
},
|
|
259
|
+
handleEnter() {
|
|
260
|
+
this.$emit("enter");
|
|
261
|
+
},
|
|
262
|
+
handleBlur() {
|
|
263
|
+
this.$emit("blur", this.inputValue);
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
</script>
|
|
268
|
+
|
|
269
|
+
<style lang="less" scoped>
|
|
270
|
+
.mec-input-dropdown__text {
|
|
271
|
+
cursor: pointer;
|
|
272
|
+
color: #606266;
|
|
273
|
+
white-space: nowrap;
|
|
274
|
+
|
|
275
|
+
&.is-disabled {
|
|
276
|
+
cursor: not-allowed;
|
|
277
|
+
color: #c0c4cc;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
</style>
|
|
@@ -92,6 +92,38 @@
|
|
|
92
92
|
</el-table-column>
|
|
93
93
|
|
|
94
94
|
<!-- 有type的列 -->
|
|
95
|
+
<el-table-column
|
|
96
|
+
v-else-if="col.type === 'expand'"
|
|
97
|
+
type="expand"
|
|
98
|
+
:label="col.label"
|
|
99
|
+
:align="col.align"
|
|
100
|
+
:min-width="col.minWidth"
|
|
101
|
+
:max-width="col.maxWidth"
|
|
102
|
+
:width="col.width"
|
|
103
|
+
:key="index + col.type"
|
|
104
|
+
:fixed="col.fixed"
|
|
105
|
+
>
|
|
106
|
+
<template slot-scope="scope">
|
|
107
|
+
<component
|
|
108
|
+
v-if="getExpandComponentType(col, scope.row)"
|
|
109
|
+
:is="getExpandComponentType(col, scope.row)"
|
|
110
|
+
:row="scope.row"
|
|
111
|
+
:scope="scope"
|
|
112
|
+
:tableData="col"
|
|
113
|
+
v-bind="
|
|
114
|
+
typeof col.componentProps === 'function'
|
|
115
|
+
? col.componentProps(scope.row)
|
|
116
|
+
: col.componentProps
|
|
117
|
+
"
|
|
118
|
+
v-on="
|
|
119
|
+
typeof col.componentListeners === 'function'
|
|
120
|
+
? col.componentListeners(scope.row)
|
|
121
|
+
: col.componentListeners || {}
|
|
122
|
+
"
|
|
123
|
+
></component>
|
|
124
|
+
</template>
|
|
125
|
+
</el-table-column>
|
|
126
|
+
|
|
95
127
|
<el-table-column
|
|
96
128
|
v-else
|
|
97
129
|
:label="col.label"
|
|
@@ -303,6 +335,13 @@ export default {
|
|
|
303
335
|
}
|
|
304
336
|
return col.type || "";
|
|
305
337
|
},
|
|
338
|
+
getExpandComponentType(col, row) {
|
|
339
|
+
const component = col.component ;
|
|
340
|
+
if (typeof component === "function") {
|
|
341
|
+
return component(row);
|
|
342
|
+
}
|
|
343
|
+
return component || "";
|
|
344
|
+
},
|
|
306
345
|
// 列表选中当前行字体加粗
|
|
307
346
|
selectedRowStyle({ row }) {
|
|
308
347
|
const idArr = this.multipleSelection.map((row) => row[this.rowKey]);
|
|
@@ -411,4 +450,4 @@ export default {
|
|
|
411
450
|
font-size: 15px;
|
|
412
451
|
color: #f56c6c;
|
|
413
452
|
}
|
|
414
|
-
</style>
|
|
453
|
+
</style>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<span>
|
|
3
3
|
<span class="default-text" :style="[statusStyle]" v-if="tableData.columnType == 'text'"
|
|
4
4
|
:class="tableData.getClass ? tableData.getClass(scope.row) : ''">{{ getText(tableData.bind) }}</span>
|
|
5
5
|
<el-button v-if="tableData.columnType == 'button' && getText(tableData.bind)" size="mini" plain round :type="tableData.setType(this.scope.row)">{{ getText(tableData.bind) }}</el-button>
|
|
6
|
-
</
|
|
6
|
+
</span>
|
|
7
7
|
</template>
|
|
8
8
|
<script>
|
|
9
9
|
|