el-plus-crud 0.1.1 → 0.1.2
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/CHANGELOG.md +2 -0
- package/dist/el-plus-crud.mjs +1445 -1440
- package/lib/components/el-plus-form/components/ElPlusFormBtns.vue +18 -5
- package/lib/util/index.ts +20 -28
- package/package.json +1 -1
|
@@ -31,11 +31,13 @@ export default {
|
|
|
31
31
|
}
|
|
32
32
|
</script>
|
|
33
33
|
<script lang="ts" setup>
|
|
34
|
-
import { ref, computed, watch, onMounted } from 'vue'
|
|
34
|
+
import { ref, computed, watch, onMounted, inject } from 'vue'
|
|
35
35
|
import ElPlusFormBtn from './ElPlusFormBtn.vue'
|
|
36
36
|
import ElPlusFormUpbtn from './ElPlusFormUpbtn.vue'
|
|
37
37
|
import { ElMessageBox } from 'element-plus'
|
|
38
|
-
import { IBtnBack } from 'types'
|
|
38
|
+
import { IBtnBack, ICRUDConfig } from 'types'
|
|
39
|
+
|
|
40
|
+
const defaultConf = inject('defaultConf') as ICRUDConfig
|
|
39
41
|
|
|
40
42
|
const props = defineProps<{
|
|
41
43
|
field?: string
|
|
@@ -106,12 +108,23 @@ const initBtnList = () => {
|
|
|
106
108
|
}
|
|
107
109
|
// 执行一次vif的处理
|
|
108
110
|
const handelItemVIf = (formItem: any): Boolean => {
|
|
111
|
+
let _vif = true
|
|
109
112
|
if (typeof formItem.vif === 'function') {
|
|
110
|
-
|
|
113
|
+
_vif = Boolean(runFnGetData(formItem.vif))
|
|
111
114
|
} else if (typeof formItem.vif === 'boolean') {
|
|
112
|
-
|
|
115
|
+
_vif = formItem.vif
|
|
116
|
+
}
|
|
117
|
+
if (_vif) {
|
|
118
|
+
// 这里最终处理一下auth权限问题
|
|
119
|
+
if (formItem?.auth) {
|
|
120
|
+
if (!defaultConf.auth) {
|
|
121
|
+
console.warn('使用auth属性,请在crud注册时传入auth校验方法~')
|
|
122
|
+
} else {
|
|
123
|
+
_vif = defaultConf.auth(formItem.auth)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
113
126
|
}
|
|
114
|
-
return
|
|
127
|
+
return _vif
|
|
115
128
|
}
|
|
116
129
|
// 执行函数,获取相关数据
|
|
117
130
|
const runFnGetData = (fn: Function) => {
|
package/lib/util/index.ts
CHANGED
|
@@ -234,7 +234,14 @@ export function handelListColumn(columnList: Array<IColumnItem> | undefined, def
|
|
|
234
234
|
case 'btns':
|
|
235
235
|
if (!item.minWidth && item.btns && item.btns.length >= 2) {
|
|
236
236
|
let labelLength = 0
|
|
237
|
-
|
|
237
|
+
// 这里判断最多按钮数量
|
|
238
|
+
for (let i = 0; i < item.btns.length && i < (item.limit || 3); i++) {
|
|
239
|
+
if (item.btns[i] && typeof item.btns[i].label === 'string') {
|
|
240
|
+
labelLength += (item.btns[i].label as string).length
|
|
241
|
+
} else {
|
|
242
|
+
labelLength += 4
|
|
243
|
+
}
|
|
244
|
+
}
|
|
238
245
|
item.width = item.width || labelLength * 24 + 'px'
|
|
239
246
|
}
|
|
240
247
|
item.align = item.align || 'left'
|
|
@@ -264,39 +271,24 @@ export function handelListColumn(columnList: Array<IColumnItem> | undefined, def
|
|
|
264
271
|
* @param tbName
|
|
265
272
|
*/
|
|
266
273
|
export function handelVIf(item: IColumnItem, defaultConf: ICRUDConfig, tbName: string) {
|
|
267
|
-
if (
|
|
268
|
-
if (
|
|
269
|
-
|
|
270
|
-
item._vif = item.vif(item)
|
|
271
|
-
} else {
|
|
272
|
-
item._vif = !!item.vif
|
|
273
|
-
}
|
|
274
|
+
if (item.vif !== undefined && item.vif !== null) {
|
|
275
|
+
if (typeof item.vif === 'function') {
|
|
276
|
+
item._vif = item.vif(item)
|
|
274
277
|
} else {
|
|
275
|
-
item._vif =
|
|
278
|
+
item._vif = !!item.vif
|
|
276
279
|
}
|
|
277
|
-
item.__vif = item.scShow && item._vif
|
|
278
280
|
} else {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
281
|
+
item._vif = true
|
|
282
|
+
}
|
|
283
|
+
// 这里最终处理一下auth权限问题
|
|
284
|
+
if (item.auth) {
|
|
285
|
+
if (!defaultConf.auth) {
|
|
286
|
+
console.warn('使用auth属性,请在crud注册时传入auth校验方法~')
|
|
286
287
|
} else {
|
|
287
|
-
item._vif =
|
|
288
|
+
item._vif = defaultConf.auth(item.auth)
|
|
288
289
|
}
|
|
289
|
-
// 这里最终处理一下auth权限问题
|
|
290
|
-
if (item.auth) {
|
|
291
|
-
if (!defaultConf.auth) {
|
|
292
|
-
console.warn('使用auth属性,请在crud注册时传入auth校验方法~')
|
|
293
|
-
} else {
|
|
294
|
-
item._vif = defaultConf.auth(item.auth)
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
item.__vif = item._vif
|
|
298
290
|
}
|
|
299
|
-
|
|
291
|
+
item.__vif = tbName ? item.scShow && item._vif : item._vif
|
|
300
292
|
// 这里要判断下下级显示状态, 如果下级全部隐藏了,那么本级也应该隐藏
|
|
301
293
|
if (item.children && item.children.every((info) => !info.__vif)) {
|
|
302
294
|
item.__vif = false
|