gy-ui-plus 1.0.6 → 1.0.8
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/README.md +3 -3
- package/dist/gy-ui-plus.es.js +1764 -1839
- package/dist/gy-ui-plus.umd.js +2 -2
- package/package.json +12 -11
- package/packages/button/src/index.vue +41 -0
- package/packages/button/src/type.ts +11 -0
- package/packages/index.ts +5 -3
- package/packages/layout-page/index.ts +4 -0
- package/packages/layout-page/src/index.vue +75 -0
- package/packages/layout-page/style/index.ts +1 -0
- package/packages/layout-page/style/layout-page.scss +37 -0
- package/packages/table/index.ts +5 -0
- package/packages/table/src/GyTableColumn.vue +100 -0
- package/packages/table/src/index.vue +1073 -0
- package/packages/table/src/operator.vue +203 -0
- package/packages/table/src/renderCol.vue +20 -0
- package/packages/table/src/renderHeader.vue +18 -0
- package/packages/table/src/singleEdit.vue +352 -0
- package/packages/table/src/singleEditCell.vue +301 -0
- package/packages/table/src/tableProps.ts +146 -0
- package/packages/{gy-table → table}/src/useExpose.ts +15 -15
- package/packages/table/style/index.ts +1 -0
- package/packages/table/style/table.scss +348 -0
- package/dist/gy-ui-plus.css +0 -1
- package/packages/gy-button/src/index.vue +0 -29
- package/packages/gy-table/index.ts +0 -8
- package/packages/gy-table/src/TTableColumn.vue +0 -140
- package/packages/gy-table/src/index.vue +0 -1205
- package/packages/gy-table/src/operator.vue +0 -246
- package/packages/gy-table/src/renderCol.vue +0 -24
- package/packages/gy-table/src/renderHeader.vue +0 -18
- package/packages/gy-table/src/singleEdit.vue +0 -406
- package/packages/gy-table/src/singleEditCell.vue +0 -337
- package/packages/gy-table/src/tableProps.ts +0 -174
- package/packages/gy-table/style/table.scss +0 -368
- /package/packages/{gy-button → button}/index.ts +0 -0
- /package/packages/{gy-table → table}/src/ColumnSet.vue +0 -0
- /package/packages/{gy-table → table}/src/useVirtualized.ts +0 -0
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<!-- 操作按钮 -->
|
|
3
|
-
<el-table-column
|
|
4
|
-
v-if="table.operator"
|
|
5
|
-
v-bind="{
|
|
6
|
-
fixed: table.operatorConfig?.fixed,
|
|
7
|
-
label: table.operatorConfig?.label || '操作',
|
|
8
|
-
'min-width': table.operatorConfig?.minWidth,
|
|
9
|
-
width: table.operatorConfig?.width,
|
|
10
|
-
align: table.operatorConfig?.align || align,
|
|
11
|
-
...table.operatorConfig?.bind,
|
|
12
|
-
}"
|
|
13
|
-
class-name="operator"
|
|
14
|
-
>
|
|
15
|
-
<template #default="scope">
|
|
16
|
-
<div class="operator_btn" :style="table.operatorConfig?.style">
|
|
17
|
-
<template v-for="(item, index) in table.operator">
|
|
18
|
-
<template v-if="!item.isMore">
|
|
19
|
-
<el-button
|
|
20
|
-
:key="index"
|
|
21
|
-
@click="
|
|
22
|
-
item.fun &&
|
|
23
|
-
item.fun(scope.row, scope.$index, tableData)
|
|
24
|
-
"
|
|
25
|
-
v-bind="{
|
|
26
|
-
type: 'primary',
|
|
27
|
-
link: true,
|
|
28
|
-
text: true,
|
|
29
|
-
size: 'small',
|
|
30
|
-
...item.bind,
|
|
31
|
-
}"
|
|
32
|
-
:disabled="
|
|
33
|
-
item.isDisabled &&
|
|
34
|
-
item.isDisabled(scope.row, item)
|
|
35
|
-
"
|
|
36
|
-
v-if="checkIsShow(scope, item)"
|
|
37
|
-
>
|
|
38
|
-
<template v-if="item.render">
|
|
39
|
-
<render-col
|
|
40
|
-
:column="item"
|
|
41
|
-
:row="scope.row"
|
|
42
|
-
:render="item.render"
|
|
43
|
-
:index="scope.$index"
|
|
44
|
-
/>
|
|
45
|
-
</template>
|
|
46
|
-
<span v-if="!item.render">{{ item.text }}</span>
|
|
47
|
-
</el-button>
|
|
48
|
-
</template>
|
|
49
|
-
</template>
|
|
50
|
-
<template v-if="hasMoreOper()">
|
|
51
|
-
<el-dropdown
|
|
52
|
-
v-bind="hasMoreBind"
|
|
53
|
-
class="oper_more_dropdown"
|
|
54
|
-
>
|
|
55
|
-
<span class="more_dropdown-link">
|
|
56
|
-
<el-button
|
|
57
|
-
v-bind="{
|
|
58
|
-
type: 'primary',
|
|
59
|
-
link: true,
|
|
60
|
-
text: true,
|
|
61
|
-
size: 'small',
|
|
62
|
-
...hasMoreBind.btnBind,
|
|
63
|
-
}"
|
|
64
|
-
>
|
|
65
|
-
{{ hasMoreBind.btnTxt || "更多" }}
|
|
66
|
-
<el-icon v-if="hasMoreBind.isShowArrwIcon">
|
|
67
|
-
<ArrowDown />
|
|
68
|
-
</el-icon>
|
|
69
|
-
</el-button>
|
|
70
|
-
</span>
|
|
71
|
-
<template #dropdown>
|
|
72
|
-
<el-dropdown-menu
|
|
73
|
-
v-bind="hasMoreBind.menuBind"
|
|
74
|
-
class="oper_more_dropdown_menu"
|
|
75
|
-
>
|
|
76
|
-
<template
|
|
77
|
-
v-for="(item, index) in table.operator"
|
|
78
|
-
>
|
|
79
|
-
<el-dropdown-item
|
|
80
|
-
v-if="item.isMore"
|
|
81
|
-
@click="
|
|
82
|
-
item.fun &&
|
|
83
|
-
item.fun(
|
|
84
|
-
scope.row,
|
|
85
|
-
scope.$index,
|
|
86
|
-
tableData
|
|
87
|
-
)
|
|
88
|
-
"
|
|
89
|
-
:key="'more_' + index"
|
|
90
|
-
v-bind="{
|
|
91
|
-
disabled:
|
|
92
|
-
item.isDisabled &&
|
|
93
|
-
item.isDisabled(
|
|
94
|
-
scope.row,
|
|
95
|
-
item
|
|
96
|
-
),
|
|
97
|
-
...item.itemBind,
|
|
98
|
-
}"
|
|
99
|
-
>
|
|
100
|
-
<el-button
|
|
101
|
-
:key="index"
|
|
102
|
-
v-bind="{
|
|
103
|
-
link: true,
|
|
104
|
-
text: true,
|
|
105
|
-
size: 'small',
|
|
106
|
-
disabled:
|
|
107
|
-
item.isDisabled &&
|
|
108
|
-
item.isDisabled(
|
|
109
|
-
scope.row,
|
|
110
|
-
item
|
|
111
|
-
),
|
|
112
|
-
...item.bind,
|
|
113
|
-
}"
|
|
114
|
-
v-if="checkIsShow(scope, item)"
|
|
115
|
-
>
|
|
116
|
-
<template v-if="item.render">
|
|
117
|
-
<render-col
|
|
118
|
-
:column="item"
|
|
119
|
-
:row="scope.row"
|
|
120
|
-
:render="item.render"
|
|
121
|
-
:index="scope.$index"
|
|
122
|
-
/>
|
|
123
|
-
</template>
|
|
124
|
-
<span v-if="!item.render">{{
|
|
125
|
-
item.text
|
|
126
|
-
}}</span>
|
|
127
|
-
</el-button>
|
|
128
|
-
</el-dropdown-item>
|
|
129
|
-
</template>
|
|
130
|
-
</el-dropdown-menu>
|
|
131
|
-
</template>
|
|
132
|
-
</el-dropdown>
|
|
133
|
-
</template>
|
|
134
|
-
</div>
|
|
135
|
-
</template>
|
|
136
|
-
</el-table-column>
|
|
137
|
-
</template>
|
|
138
|
-
|
|
139
|
-
<script setup lang="ts">
|
|
140
|
-
import { computed, useAttrs } from "vue";
|
|
141
|
-
import { ArrowDown } from "@element-plus/icons-vue";
|
|
142
|
-
import RenderCol from "./renderCol.vue";
|
|
143
|
-
const props = defineProps({
|
|
144
|
-
tableData: {
|
|
145
|
-
type: Array,
|
|
146
|
-
default: () => [],
|
|
147
|
-
},
|
|
148
|
-
table: { type: Object, default: () => {} },
|
|
149
|
-
btnPermissions: {
|
|
150
|
-
type: Array,
|
|
151
|
-
default: () => [],
|
|
152
|
-
},
|
|
153
|
-
align: {
|
|
154
|
-
type: String,
|
|
155
|
-
default: "center",
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
defineOptions({
|
|
159
|
-
name: "Operator",
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
// 是否显示表格操作按钮
|
|
163
|
-
const checkIsShow = (
|
|
164
|
-
scope: { row: { [s: string]: unknown } | ArrayLike<unknown> | any },
|
|
165
|
-
item: {
|
|
166
|
-
noshow: any;
|
|
167
|
-
show: { val: string | any[]; key: string | number };
|
|
168
|
-
hasPermi: any;
|
|
169
|
-
field: string | number;
|
|
170
|
-
isField: string | number;
|
|
171
|
-
}
|
|
172
|
-
) => {
|
|
173
|
-
let isNoshow = false;
|
|
174
|
-
if (item.noshow) {
|
|
175
|
-
// 解决双重判断循环递归
|
|
176
|
-
let nushowFun = JSON.parse(JSON.stringify(item.noshow));
|
|
177
|
-
// 双重判断
|
|
178
|
-
nushowFun.map(
|
|
179
|
-
(rs: {
|
|
180
|
-
isShow: string;
|
|
181
|
-
val: string | any[];
|
|
182
|
-
key: string | number;
|
|
183
|
-
}) => {
|
|
184
|
-
rs.isShow =
|
|
185
|
-
typeof rs.val === "string"
|
|
186
|
-
? rs.val === "isHasVal"
|
|
187
|
-
? scope.row[rs.key]
|
|
188
|
-
? "true"
|
|
189
|
-
: "false"
|
|
190
|
-
: "true"
|
|
191
|
-
: rs.val.includes(scope.row[rs.key])
|
|
192
|
-
? "false"
|
|
193
|
-
: "true";
|
|
194
|
-
}
|
|
195
|
-
);
|
|
196
|
-
isNoshow = nushowFun.every((key: { isShow: string }) => {
|
|
197
|
-
return key.isShow === "true";
|
|
198
|
-
});
|
|
199
|
-
} else {
|
|
200
|
-
isNoshow = true;
|
|
201
|
-
}
|
|
202
|
-
// 单独判断
|
|
203
|
-
let isShow = !item.show || item.show.val.includes(scope.row[item.show.key]);
|
|
204
|
-
// 按钮权限
|
|
205
|
-
let isPermission = item.hasPermi
|
|
206
|
-
? props.btnPermissions?.includes(item.hasPermi)
|
|
207
|
-
: true;
|
|
208
|
-
// table页面合计
|
|
209
|
-
let totalTxt = Object.values(scope.row).every((key) => {
|
|
210
|
-
return key !== "当页合计";
|
|
211
|
-
});
|
|
212
|
-
// table页面合计
|
|
213
|
-
let totalTxt1 = Object.values(scope.row).every((key) => {
|
|
214
|
-
return key !== "全部合计";
|
|
215
|
-
});
|
|
216
|
-
return (
|
|
217
|
-
isShow &&
|
|
218
|
-
isNoshow &&
|
|
219
|
-
!scope.row[item.field] &&
|
|
220
|
-
(item.isField ? scope.row[item.isField] : true) &&
|
|
221
|
-
totalTxt &&
|
|
222
|
-
totalTxt1 &&
|
|
223
|
-
isPermission
|
|
224
|
-
);
|
|
225
|
-
};
|
|
226
|
-
// 更多下拉配置
|
|
227
|
-
const $attrs = useAttrs();
|
|
228
|
-
const hasMoreBind: any = computed(() => {
|
|
229
|
-
const btnBind = { type: "primary", link: true, text: true, size: "small" }; // 按钮属性
|
|
230
|
-
const menuBind = {}; // 下拉menu属性
|
|
231
|
-
const setBind = {
|
|
232
|
-
btnTxt: "更多",
|
|
233
|
-
isShowArrwIcon: true, // 是否显示下拉箭头
|
|
234
|
-
...menuBind, // 下拉menu属性
|
|
235
|
-
...btnBind, // 按钮属性
|
|
236
|
-
...props.table.operatorConfig.dropdownBind, // 下拉属性
|
|
237
|
-
};
|
|
238
|
-
return { ...$attrs, ...setBind };
|
|
239
|
-
});
|
|
240
|
-
// 判断操作是否显示最多
|
|
241
|
-
const hasMoreOper = () => {
|
|
242
|
-
return props.table.operator.some(
|
|
243
|
-
(item: { isMore: boolean }) => item.isMore === true
|
|
244
|
-
);
|
|
245
|
-
};
|
|
246
|
-
</script>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<component :is="renderComponent" />
|
|
3
|
-
</template>
|
|
4
|
-
<script lang="ts" setup>
|
|
5
|
-
defineOptions({
|
|
6
|
-
name: "RenderCol",
|
|
7
|
-
});
|
|
8
|
-
const props: any = defineProps({
|
|
9
|
-
row: Object,
|
|
10
|
-
render: Function,
|
|
11
|
-
index: Number,
|
|
12
|
-
column: {
|
|
13
|
-
type: Object,
|
|
14
|
-
default: null,
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
const renderComponent = () => {
|
|
18
|
-
return props.render(
|
|
19
|
-
props?.row[props?.column?.prop],
|
|
20
|
-
props.row,
|
|
21
|
-
props.index
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
</script>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<component :is="renderComponent" />
|
|
3
|
-
</template>
|
|
4
|
-
<script lang="ts" setup>
|
|
5
|
-
defineOptions({
|
|
6
|
-
name: "RenderHeader",
|
|
7
|
-
});
|
|
8
|
-
const props: any = defineProps({
|
|
9
|
-
render: Function,
|
|
10
|
-
column: {
|
|
11
|
-
type: Object,
|
|
12
|
-
default: null,
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
const renderComponent = () => {
|
|
16
|
-
return props.render(props?.column);
|
|
17
|
-
};
|
|
18
|
-
</script>
|
|
@@ -1,406 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div @click="onFieldClick" class="single_edit_cell">
|
|
3
|
-
<div class="cell-content" v-if="!editMode">
|
|
4
|
-
<el-tooltip
|
|
5
|
-
v-if="configEdit.isShowTips"
|
|
6
|
-
class="item"
|
|
7
|
-
v-bind="{
|
|
8
|
-
effect: 'light',
|
|
9
|
-
content: '单击可编辑',
|
|
10
|
-
placement: 'top',
|
|
11
|
-
...configEdit.tipbind,
|
|
12
|
-
}"
|
|
13
|
-
>
|
|
14
|
-
<div v-if="childCom.includes(configEdit.type)">
|
|
15
|
-
{{ childVal }}
|
|
16
|
-
</div>
|
|
17
|
-
<div v-else>{{ model }} </div>
|
|
18
|
-
<slot name="content"></slot>
|
|
19
|
-
</el-tooltip>
|
|
20
|
-
<template v-else>
|
|
21
|
-
<div v-if="childCom.includes(configEdit.type)">
|
|
22
|
-
{{ childVal }}
|
|
23
|
-
</div>
|
|
24
|
-
<div v-else>{{ model }} </div>
|
|
25
|
-
<slot name="content"></slot>
|
|
26
|
-
</template>
|
|
27
|
-
</div>
|
|
28
|
-
<template v-if="editMode">
|
|
29
|
-
<template v-if="configEdit.editSlotName">
|
|
30
|
-
<div :class="[prop, 'slot_edit_name']">
|
|
31
|
-
<slot :name="configEdit.editSlotName" :scope="scope" />
|
|
32
|
-
</div>
|
|
33
|
-
</template>
|
|
34
|
-
<template v-if="configEdit.isSelfCom">
|
|
35
|
-
<component
|
|
36
|
-
v-if="configEdit.editComponent === 't-select-table'"
|
|
37
|
-
:ref="(el:any) => handleRef(el)"
|
|
38
|
-
:is="configEdit.editComponent"
|
|
39
|
-
:placeholder="
|
|
40
|
-
configEdit.placeholder || getPlaceholder(configEdit)
|
|
41
|
-
"
|
|
42
|
-
v-bind="
|
|
43
|
-
typeof configEdit.bind == 'function'
|
|
44
|
-
? configEdit.bind(scope)
|
|
45
|
-
: {
|
|
46
|
-
clearable: true,
|
|
47
|
-
filterable: true,
|
|
48
|
-
...configEdit.bind,
|
|
49
|
-
}
|
|
50
|
-
"
|
|
51
|
-
:style="{ width: configEdit.width || '100%' }"
|
|
52
|
-
v-on="cEvent(configEdit, 't-select-table')"
|
|
53
|
-
/>
|
|
54
|
-
<component
|
|
55
|
-
v-else
|
|
56
|
-
:is="configEdit.editComponent"
|
|
57
|
-
v-model="model"
|
|
58
|
-
:type="configEdit.type"
|
|
59
|
-
:placeholder="
|
|
60
|
-
configEdit.placeholder || getPlaceholder(configEdit)
|
|
61
|
-
"
|
|
62
|
-
ref="parentCom"
|
|
63
|
-
v-bind="
|
|
64
|
-
typeof configEdit.bind == 'function'
|
|
65
|
-
? configEdit.bind(scope)
|
|
66
|
-
: {
|
|
67
|
-
clearable: true,
|
|
68
|
-
filterable: true,
|
|
69
|
-
...configEdit.bind,
|
|
70
|
-
}
|
|
71
|
-
"
|
|
72
|
-
@change="
|
|
73
|
-
handleEvent(configEdit.event, model, configEdit.type)
|
|
74
|
-
"
|
|
75
|
-
:style="{ width: configEdit.width || '100%' }"
|
|
76
|
-
v-on="cEvent(configEdit)"
|
|
77
|
-
/>
|
|
78
|
-
</template>
|
|
79
|
-
<component
|
|
80
|
-
v-if="!configEdit.editSlotName && !configEdit.isSelfCom"
|
|
81
|
-
:is="configEdit.editComponent || 'el-input'"
|
|
82
|
-
v-model="model"
|
|
83
|
-
:type="configEdit.type"
|
|
84
|
-
:placeholder="
|
|
85
|
-
configEdit.placeholder || getPlaceholder(configEdit)
|
|
86
|
-
"
|
|
87
|
-
:class="prop"
|
|
88
|
-
ref="parentCom"
|
|
89
|
-
@change="handleEvent(configEdit.event, model, configEdit.type)"
|
|
90
|
-
@keyup.enter.native="onInputExit"
|
|
91
|
-
@blur="onInputExit"
|
|
92
|
-
v-bind="
|
|
93
|
-
typeof configEdit.bind == 'function'
|
|
94
|
-
? configEdit.bind(scope)
|
|
95
|
-
: {
|
|
96
|
-
clearable: true,
|
|
97
|
-
filterable: true,
|
|
98
|
-
...configEdit.bind,
|
|
99
|
-
}
|
|
100
|
-
"
|
|
101
|
-
:style="{ width: configEdit.width || '100%' }"
|
|
102
|
-
v-on="cEvent(configEdit)"
|
|
103
|
-
>
|
|
104
|
-
<template v-for="(_index, name) in slots" v-slot:[name]="data">
|
|
105
|
-
<slot :name="name" v-bind="data"></slot>
|
|
106
|
-
</template>
|
|
107
|
-
<template #prepend v-if="configEdit.prepend">{{
|
|
108
|
-
configEdit.prepend
|
|
109
|
-
}}</template>
|
|
110
|
-
<template #append v-if="configEdit.append">{{
|
|
111
|
-
configEdit.append
|
|
112
|
-
}}</template>
|
|
113
|
-
<slot name="editChild" />
|
|
114
|
-
<div v-if="!$slots.editChild">
|
|
115
|
-
<component
|
|
116
|
-
:is="compChildName(configEdit)"
|
|
117
|
-
v-for="(value, key) in listTypeInfo[configEdit.list]"
|
|
118
|
-
:key="key"
|
|
119
|
-
:disabled="value.disabled"
|
|
120
|
-
:label="compChildLabel(configEdit, value)"
|
|
121
|
-
:value="compChildValue(configEdit, value, key)"
|
|
122
|
-
>{{ compChildShowLabel(configEdit, value) }}</component
|
|
123
|
-
>
|
|
124
|
-
</div>
|
|
125
|
-
</component>
|
|
126
|
-
</template>
|
|
127
|
-
</div>
|
|
128
|
-
</template>
|
|
129
|
-
|
|
130
|
-
<script setup lang="ts">
|
|
131
|
-
import { computed, nextTick, ref, watch, useSlots } from "vue";
|
|
132
|
-
defineOptions({
|
|
133
|
-
name: "SingleEdit",
|
|
134
|
-
});
|
|
135
|
-
const props = defineProps({
|
|
136
|
-
/** 编辑配置项说明
|
|
137
|
-
* label: '爱好', // placeholder显示
|
|
138
|
-
* editComponent: 'el-select', // 组件
|
|
139
|
-
* type: 'select-arr', // option显示
|
|
140
|
-
* list: 'hobbyList', // 下拉选择数据源
|
|
141
|
-
* arrLabel: 'label', // 下拉选择中文显示
|
|
142
|
-
* arrKey: 'value' // 下拉选择number显示(最终传后台)
|
|
143
|
-
* bind:{} // 组件衍生属性(即第三方组件属性)
|
|
144
|
-
*/
|
|
145
|
-
configEdit: {
|
|
146
|
-
type: Object as any,
|
|
147
|
-
default: () => ({}),
|
|
148
|
-
},
|
|
149
|
-
// 下拉选择数据源
|
|
150
|
-
listTypeInfo: {
|
|
151
|
-
type: Object,
|
|
152
|
-
default: () => ({}),
|
|
153
|
-
},
|
|
154
|
-
scope: {
|
|
155
|
-
type: Object,
|
|
156
|
-
default: () => ({}),
|
|
157
|
-
},
|
|
158
|
-
prop: {
|
|
159
|
-
type: String,
|
|
160
|
-
default: "prop",
|
|
161
|
-
},
|
|
162
|
-
// 是否开启单击编辑
|
|
163
|
-
isClickEdit: {
|
|
164
|
-
type: Boolean,
|
|
165
|
-
default: false,
|
|
166
|
-
},
|
|
167
|
-
modelValue: {
|
|
168
|
-
type: [String, Number, Object, Array, Date],
|
|
169
|
-
},
|
|
170
|
-
// 列for index
|
|
171
|
-
indexColumns: [String, Number],
|
|
172
|
-
});
|
|
173
|
-
// 抛出事件
|
|
174
|
-
const emits = defineEmits(["handleEvent", "update:modelValue"]);
|
|
175
|
-
const slots = useSlots();
|
|
176
|
-
const childCom = ref([
|
|
177
|
-
"select-arr",
|
|
178
|
-
"checkbox",
|
|
179
|
-
"radio",
|
|
180
|
-
"select-obj",
|
|
181
|
-
"el-select-multiple",
|
|
182
|
-
]);
|
|
183
|
-
const editMode = ref(false);
|
|
184
|
-
// 下拉选择表格组件 ref
|
|
185
|
-
const tselecttableref: any = ref({});
|
|
186
|
-
// 下拉选择表格组件 动态ref
|
|
187
|
-
const handleRef = (el: any) => {
|
|
188
|
-
if (el) {
|
|
189
|
-
tselecttableref.value[`tselecttableref-${props.indexColumns}`] = el;
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
// 重置下拉表格
|
|
193
|
-
const resetClickTselectTable = () => {
|
|
194
|
-
// 获取所有下拉选择表格组件
|
|
195
|
-
const refList = Object.keys(tselecttableref.value).filter((item) =>
|
|
196
|
-
item.includes("tselecttableref")
|
|
197
|
-
);
|
|
198
|
-
if (refList.length > 0 && tselecttableref.value) {
|
|
199
|
-
refList.map((val) => {
|
|
200
|
-
tselecttableref.value[val].clear();
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
let model: any = computed({
|
|
205
|
-
get() {
|
|
206
|
-
return props?.modelValue;
|
|
207
|
-
},
|
|
208
|
-
set(val) {
|
|
209
|
-
emits("update:modelValue", val);
|
|
210
|
-
},
|
|
211
|
-
});
|
|
212
|
-
watch(
|
|
213
|
-
() => props.modelValue,
|
|
214
|
-
(data) => {
|
|
215
|
-
model.value = data;
|
|
216
|
-
}
|
|
217
|
-
);
|
|
218
|
-
// 引用第三方事件
|
|
219
|
-
const cEvent: any = computed(() => {
|
|
220
|
-
return ({ eventHandle }: any, type = "") => {
|
|
221
|
-
let event = { ...eventHandle };
|
|
222
|
-
let changeEvent = {} as any;
|
|
223
|
-
Object.keys(event).forEach((v) => {
|
|
224
|
-
changeEvent[v] = (e: any, ids: any) => {
|
|
225
|
-
if (type === "t-select-table") {
|
|
226
|
-
const argument = {
|
|
227
|
-
row: e,
|
|
228
|
-
ids: ids,
|
|
229
|
-
prop: props.prop,
|
|
230
|
-
scope: props.scope,
|
|
231
|
-
};
|
|
232
|
-
event[v] && event[v](argument);
|
|
233
|
-
} else {
|
|
234
|
-
if ((typeof e === "number" && e === 0) || e) {
|
|
235
|
-
event[v] &&
|
|
236
|
-
event[v]({
|
|
237
|
-
val: e,
|
|
238
|
-
prop: props.prop,
|
|
239
|
-
scope: props.scope,
|
|
240
|
-
});
|
|
241
|
-
} else {
|
|
242
|
-
event[v] &&
|
|
243
|
-
event[v]({ prop: props.prop, scope: props.scope });
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
});
|
|
248
|
-
return { ...changeEvent };
|
|
249
|
-
};
|
|
250
|
-
});
|
|
251
|
-
const childVal = computed({
|
|
252
|
-
get() {
|
|
253
|
-
let valLabel;
|
|
254
|
-
let checkboxVal = [] as any;
|
|
255
|
-
let selcetMultiple = [] as any;
|
|
256
|
-
props.listTypeInfo[props.configEdit.list] &&
|
|
257
|
-
props.listTypeInfo[props.configEdit.list].map((val: any) => {
|
|
258
|
-
switch (props.configEdit.type) {
|
|
259
|
-
case "checkbox":
|
|
260
|
-
case "radio":
|
|
261
|
-
if (model.value.join(",").includes(val.value)) {
|
|
262
|
-
checkboxVal.push(val.label);
|
|
263
|
-
}
|
|
264
|
-
valLabel = checkboxVal.join(",");
|
|
265
|
-
break;
|
|
266
|
-
case "select-arr":
|
|
267
|
-
// eslint-disable-next-line eqeqeq
|
|
268
|
-
if (model.value == val[props.configEdit.arrKey]) {
|
|
269
|
-
valLabel = val[props.configEdit.arrLabel];
|
|
270
|
-
}
|
|
271
|
-
break;
|
|
272
|
-
case "el-select-multiple":
|
|
273
|
-
if (
|
|
274
|
-
model.value &&
|
|
275
|
-
model.value
|
|
276
|
-
.join(",")
|
|
277
|
-
.includes(val[props.configEdit.arrKey])
|
|
278
|
-
) {
|
|
279
|
-
selcetMultiple.push(val[props.configEdit.arrLabel]);
|
|
280
|
-
}
|
|
281
|
-
valLabel = selcetMultiple.join(",");
|
|
282
|
-
break;
|
|
283
|
-
case "select-obj":
|
|
284
|
-
valLabel = val;
|
|
285
|
-
break;
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
return valLabel;
|
|
289
|
-
},
|
|
290
|
-
set(val) {
|
|
291
|
-
return val;
|
|
292
|
-
},
|
|
293
|
-
});
|
|
294
|
-
// 子组件名称
|
|
295
|
-
const compChildName = computed(() => {
|
|
296
|
-
return (configEdit: { type: any }) => {
|
|
297
|
-
switch (configEdit.type) {
|
|
298
|
-
case "checkbox":
|
|
299
|
-
return "el-checkbox";
|
|
300
|
-
case "radio":
|
|
301
|
-
return "el-radio";
|
|
302
|
-
case "el-select-multiple":
|
|
303
|
-
case "select-arr":
|
|
304
|
-
case "select-obj":
|
|
305
|
-
return "el-option";
|
|
306
|
-
}
|
|
307
|
-
};
|
|
308
|
-
});
|
|
309
|
-
// 子子组件label
|
|
310
|
-
const compChildLabel = computed(() => {
|
|
311
|
-
return (
|
|
312
|
-
configEdit: { type: any; arrLabel: any },
|
|
313
|
-
value: { [x: string]: any; value: any }
|
|
314
|
-
) => {
|
|
315
|
-
switch (configEdit.type) {
|
|
316
|
-
case "radio":
|
|
317
|
-
case "checkbox":
|
|
318
|
-
return value[configEdit.arrLabel || "label"];
|
|
319
|
-
case "el-select-multiple":
|
|
320
|
-
case "select-arr":
|
|
321
|
-
return value[configEdit.arrLabel || "label"];
|
|
322
|
-
case "select-obj":
|
|
323
|
-
return value;
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
});
|
|
327
|
-
// 子子组件value
|
|
328
|
-
const compChildValue = computed(() => {
|
|
329
|
-
return (
|
|
330
|
-
configEdit: { type: any; arrKey: any },
|
|
331
|
-
value: { [x: string]: any; value: any },
|
|
332
|
-
key: any
|
|
333
|
-
) => {
|
|
334
|
-
switch (configEdit.type) {
|
|
335
|
-
case "radio":
|
|
336
|
-
case "checkbox":
|
|
337
|
-
return value[configEdit.arrKey || "key"];
|
|
338
|
-
case "el-select-multiple":
|
|
339
|
-
case "select-arr":
|
|
340
|
-
return value[configEdit.arrKey || "key"];
|
|
341
|
-
case "select-obj":
|
|
342
|
-
return key;
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
});
|
|
346
|
-
// 子子组件文字展示
|
|
347
|
-
const compChildShowLabel = computed(() => {
|
|
348
|
-
return (
|
|
349
|
-
configEdit: { type: any; arrLabel: any },
|
|
350
|
-
value: { [x: string]: any; label: any }
|
|
351
|
-
) => {
|
|
352
|
-
switch (configEdit.type) {
|
|
353
|
-
case "radio":
|
|
354
|
-
case "checkbox":
|
|
355
|
-
return value[configEdit.arrLabel || "label"];
|
|
356
|
-
case "el-select-multiple":
|
|
357
|
-
case "select-arr":
|
|
358
|
-
return value[configEdit.arrLabel || "label"];
|
|
359
|
-
case "select-obj":
|
|
360
|
-
return value;
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
});
|
|
364
|
-
const parentCom = ref<null | any>();
|
|
365
|
-
// 点击外层开启编辑focus
|
|
366
|
-
const onFieldClick = () => {
|
|
367
|
-
if (props.isClickEdit) {
|
|
368
|
-
editMode.value = true;
|
|
369
|
-
nextTick(() => {
|
|
370
|
-
let parentRef = parentCom.value;
|
|
371
|
-
if (parentRef && parentRef.focus) {
|
|
372
|
-
parentRef.focus();
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
|
-
const onInputExit = () => {
|
|
378
|
-
editMode.value = false;
|
|
379
|
-
};
|
|
380
|
-
// placeholder的显示
|
|
381
|
-
const getPlaceholder = (row: any) => {
|
|
382
|
-
if (!row.editComponent || typeof row.editComponent !== "string") {
|
|
383
|
-
return row.label;
|
|
384
|
-
}
|
|
385
|
-
const componentType = row.editComponent.toLowerCase();
|
|
386
|
-
if (componentType.includes("input")) {
|
|
387
|
-
return "请输入";
|
|
388
|
-
} else if (
|
|
389
|
-
componentType.includes("select") ||
|
|
390
|
-
componentType.includes("date")
|
|
391
|
-
) {
|
|
392
|
-
return "请选择";
|
|
393
|
-
}
|
|
394
|
-
return row.label;
|
|
395
|
-
};
|
|
396
|
-
// 绑定的相关事件
|
|
397
|
-
const handleEvent = (type, val, comType) => {
|
|
398
|
-
// console.log("type---comType", comType)
|
|
399
|
-
if (comType === "datetime") onInputExit();
|
|
400
|
-
setTimeout(() => {
|
|
401
|
-
// console.log("组件", type, childValue.value)
|
|
402
|
-
emits("handleEvent", { type, val });
|
|
403
|
-
}, 0);
|
|
404
|
-
};
|
|
405
|
-
defineExpose({ resetClickTselectTable });
|
|
406
|
-
</script>
|