@elementplus-kit/uikit 1.1.0 → 1.3.0
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.
|
@@ -50,6 +50,7 @@ const propsAttrs = {
|
|
|
50
50
|
options: { type: Array, default: () => [] },
|
|
51
51
|
// 字典选项
|
|
52
52
|
optionsRef: { type: Object, default: () => {} },
|
|
53
|
+
params: { type: Object, default: () => {} },
|
|
53
54
|
};
|
|
54
55
|
|
|
55
56
|
export default defineComponent({
|
|
@@ -107,7 +108,7 @@ export default defineComponent({
|
|
|
107
108
|
const getDisabled = () => {
|
|
108
109
|
let disabled = false;
|
|
109
110
|
if (isFunction(attrs.value?.disabled)) {
|
|
110
|
-
disabled = attrs.value.disabled(model.value);
|
|
111
|
+
disabled = attrs.value.disabled({formData: model.value, params: props.params});
|
|
111
112
|
}
|
|
112
113
|
if (isBoolean(attrs.value?.disabled)) { // 在 attrs 后面结构, 也要处理直接赋值的情况,不然会覆盖
|
|
113
114
|
disabled = attrs.value.disabled;
|
|
@@ -186,7 +187,6 @@ export default defineComponent({
|
|
|
186
187
|
return options?.value?.map((item) => {
|
|
187
188
|
return h(ElOption, {
|
|
188
189
|
...item,
|
|
189
|
-
// disabled: isFunction(item.disabled) ? item.disabled(model.value) : item.disabled,
|
|
190
190
|
label: item.label,
|
|
191
191
|
value: item.value,
|
|
192
192
|
key: item.value,
|
|
@@ -108,8 +108,8 @@ export default defineComponent({
|
|
|
108
108
|
const list = [];
|
|
109
109
|
formOptions.value.map((item) => {
|
|
110
110
|
// 处理 vIf true 显示 false 隐藏
|
|
111
|
-
if (isFunction(item?.vIf) && item.vIf(
|
|
112
|
-
if (item.vIf(
|
|
111
|
+
if (isFunction(item?.vIf) && item.vIf({formData: model.value, params: props.params}) !== undefined) {
|
|
112
|
+
if (item.vIf({formData: model.value, params: props.params})) {
|
|
113
113
|
list.push(item);
|
|
114
114
|
}
|
|
115
115
|
} else {
|
|
@@ -124,6 +124,7 @@ export default defineComponent({
|
|
|
124
124
|
class: "c-form-itme",
|
|
125
125
|
model: model.value,
|
|
126
126
|
allReadonly,
|
|
127
|
+
params: props.params,
|
|
127
128
|
...item,
|
|
128
129
|
optionsRef: optionsRef.value,
|
|
129
130
|
});
|
|
@@ -94,9 +94,11 @@ export default defineComponent({
|
|
|
94
94
|
}, 0);
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
-
|
|
97
|
+
|
|
98
98
|
const showCount = ref(6); // 显示个数
|
|
99
|
-
const
|
|
99
|
+
const simpleRef = ref<HTMLDivElement>(null);
|
|
100
|
+
const simpleFormRef = ref<HTMLDivElement>(null);
|
|
101
|
+
const simpleBtnRef = ref<HTMLDivElement>(null);
|
|
100
102
|
const cFormRef = ref<HTMLDivElement>(null);
|
|
101
103
|
const calcFlg = ref(false); // 计算宽度后再显示表单
|
|
102
104
|
const childW = ref([]);
|
|
@@ -114,9 +116,9 @@ export default defineComponent({
|
|
|
114
116
|
|
|
115
117
|
// 初次计算显示个数
|
|
116
118
|
const calcSunInit = () => {
|
|
117
|
-
if (
|
|
119
|
+
if (simpleFormRef.value) {
|
|
118
120
|
// 寻找cForm 先写死 后期做成动态寻找
|
|
119
|
-
const cFormDom =
|
|
121
|
+
const cFormDom = simpleFormRef.value.children[0];
|
|
120
122
|
const cFormW = cFormDom.offsetWidth;
|
|
121
123
|
// 收集子元素宽度并保存到数组中
|
|
122
124
|
const cW = [];
|
|
@@ -128,7 +130,7 @@ export default defineComponent({
|
|
|
128
130
|
// marginR.push(mgValue);
|
|
129
131
|
cW.push(child.offsetWidth + mgValue); // 把mg加上 mg 一般不会变 为了避免多次计算
|
|
130
132
|
});
|
|
131
|
-
childW.value = cW;
|
|
133
|
+
childW.value = cW; // 储存子元素宽度
|
|
132
134
|
childW.value.reduce((pre, cur, index) => {
|
|
133
135
|
if (pre > cFormW) {
|
|
134
136
|
return 10000; // 终止累加
|
|
@@ -139,19 +141,13 @@ export default defineComponent({
|
|
|
139
141
|
}
|
|
140
142
|
return pre + cur;
|
|
141
143
|
}, 0);
|
|
142
|
-
|
|
143
|
-
// 得到结果后 显示表单
|
|
144
|
-
calcFlg.value = true;
|
|
145
|
-
// offsetWidth
|
|
146
|
-
// clientWidth
|
|
147
|
-
// classList
|
|
148
144
|
}
|
|
149
145
|
};
|
|
150
146
|
// 变化时计算显示个数
|
|
151
147
|
const calcSunResize = () => {
|
|
152
|
-
if (
|
|
148
|
+
if (simpleFormRef.value) {
|
|
153
149
|
// 寻找cForm 先写死 后期做成动态寻找
|
|
154
|
-
const cFormDom =
|
|
150
|
+
const cFormDom = simpleFormRef.value.children[0];
|
|
155
151
|
const cFormW = cFormDom.offsetWidth;
|
|
156
152
|
childW.value.reduce((pre, cur, index) => {
|
|
157
153
|
if (pre > cFormW) {
|
|
@@ -182,9 +178,9 @@ export default defineComponent({
|
|
|
182
178
|
<div className="c-search">
|
|
183
179
|
<div
|
|
184
180
|
className="c-search-simple"
|
|
185
|
-
|
|
181
|
+
ref={simpleRef}
|
|
186
182
|
>
|
|
187
|
-
<div className="c-search-simple-form" ref={
|
|
183
|
+
<div className="c-search-simple-form" ref={simpleFormRef}>
|
|
188
184
|
<CForm
|
|
189
185
|
ref={(el) => (cFormRef.value = el)}
|
|
190
186
|
{...getEvent()}
|
|
@@ -197,13 +193,12 @@ export default defineComponent({
|
|
|
197
193
|
{getSlot()}
|
|
198
194
|
</CForm>
|
|
199
195
|
</div>
|
|
200
|
-
<div className="c-search-simple-btn">
|
|
196
|
+
<div className="c-search-simple-btn" ref={simpleBtnRef}>
|
|
201
197
|
{slots["btn-left"]?.()}
|
|
202
198
|
{showCount.value < props.formOptions?.length && (
|
|
203
199
|
<div
|
|
204
|
-
className={`c-search-simple-icon ${
|
|
205
|
-
|
|
206
|
-
}`}
|
|
200
|
+
className={`c-search-simple-icon ${showSearchForm.value ? "icon-rotate" : ""
|
|
201
|
+
}`}
|
|
207
202
|
onClick={handleShow}
|
|
208
203
|
>
|
|
209
204
|
<el-icon className="el-icon c-search-icon">
|
|
@@ -12,7 +12,13 @@
|
|
|
12
12
|
justify-content: space-between;
|
|
13
13
|
}
|
|
14
14
|
.c-search-simple-form {
|
|
15
|
-
flex: 1;
|
|
15
|
+
flex: 1; // 占满剩余空间
|
|
16
|
+
overflow: auto; // 开启滚动条
|
|
17
|
+
// 滚动条宽度
|
|
18
|
+
scrollbar-width: none; // 隐藏滚动条
|
|
19
|
+
> .c-form {
|
|
20
|
+
white-space: nowrap; // 防止表单内容换行
|
|
21
|
+
}
|
|
16
22
|
}
|
|
17
23
|
.c-search-simple-btn {
|
|
18
24
|
display: flex;
|