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