el-plus-crud 0.0.115 → 0.0.116

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 CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.116](https://github.com/KDJack/el-plus-crud/compare/v0.0.115...v0.0.116) (2024-01-04)
6
+
5
7
  ### [0.0.115](https://github.com/KDJack/el-plus-crud/compare/v0.0.114...v0.0.115) (2024-01-03)
6
8
 
7
9
  ### [0.0.114](https://github.com/KDJack/el-plus-crud/compare/v0.0.113...v0.0.114) (2024-01-02)
@@ -7037,6 +7037,7 @@ const bm = ["innerHTML"], Lm = {
7037
7037
  }), E = Ye(() => {
7038
7038
  const M = [];
7039
7039
  if (u.formDesc) {
7040
+ K();
7040
7041
  const _ = Vt.cloneDeep(u.formDesc);
7041
7042
  let A = [];
7042
7043
  for (const le in _)
@@ -7067,19 +7068,23 @@ const bm = ["innerHTML"], Lm = {
7067
7068
  }
7068
7069
  }
7069
7070
  return M;
7070
- }), K = Vt.throttle(() => {
7071
- u.formDesc && Object.keys(u.formDesc).forEach((M) => {
7072
- if (u.formDesc) {
7073
- const _ = u.formDesc[M];
7074
- if (_ && _.type) {
7075
- _._type = T.includes(_.type.toLowerCase()) ? "el-plus-form-" + _.type : _.type, _._vif = P(_, "vif", M, !_.isBlank), _._disabled = P(_, "disabled", M, u.disabled ?? !1);
7076
- const A = {};
7077
- _._attrs = Object.assign({}, P(_, "attrs", M), A), _._label = P(_, "label", M), _._tip = P(_, "tip", M), !_._tip && !_.noTip && _.type === "upload" && (_._tip = `最多上传${_.multiple ? _.limit || 20 : 1}${_.upType === "file" ? "个文件" : "张图片"}`), _.default !== void 0 && _.default !== null && u.modelValue[M] === void 0 && (u.modelValue[M] = _.default), _.defaultItem !== void 0 && _.defaultItem !== null && u.modelValue[M] === void 0 && (u.modelValue[M] = _.defaultItem.value), _.auth && (j.auth ? _._vif = j.auth(_.auth) : console.warn("使用auth属性,请在crud注册时传入auth校验方法~"));
7078
- } else
7079
- _ && _.isBlank && (_._vif = P(_, "vif", "", !0));
7080
- }
7081
- });
7082
- }, 100), U = Ye(() => {
7071
+ }), K = Vt.debounce(
7072
+ () => {
7073
+ u.formDesc && Object.keys(u.formDesc).forEach((M) => {
7074
+ if (u.formDesc) {
7075
+ const _ = u.formDesc[M];
7076
+ if (_ && _.type) {
7077
+ _._type = T.includes(_.type.toLowerCase()) ? "el-plus-form-" + _.type : _.type, _._vif = P(_, "vif", M, !_.isBlank), _._disabled = P(_, "disabled", M, u.disabled ?? !1);
7078
+ const A = {};
7079
+ _._attrs = Object.assign({}, P(_, "attrs", M), A), _._label = P(_, "label", M), _._tip = P(_, "tip", M), !_._tip && !_.noTip && _.type === "upload" && (_._tip = `最多上传${_.multiple ? _.limit || 20 : 1}${_.upType === "file" ? "个文件" : "张图片"}`), _.default !== void 0 && _.default !== null && u.modelValue[M] === void 0 && (u.modelValue[M] = _.default), _.defaultItem !== void 0 && _.defaultItem !== null && u.modelValue[M] === void 0 && (u.modelValue[M] = _.defaultItem.value), _.auth && (j.auth ? _._vif = j.auth(_.auth) : console.warn("使用auth属性,请在crud注册时传入auth校验方法~"));
7080
+ } else
7081
+ _ && _.isBlank && (_._vif = P(_, "vif", "", !0));
7082
+ }
7083
+ });
7084
+ },
7085
+ 100,
7086
+ { leading: !0, trailing: !1 }
7087
+ ), U = Ye(() => {
7083
7088
  let M = [];
7084
7089
  return u.showBtns && (u.showCancel && M.push({
7085
7090
  field: "_reset_btn",
@@ -8306,9 +8311,13 @@ const t_ = /* @__PURE__ */ et(e_, [["__scopeId", "data-v-2c8bae46"]]), n_ = {
8306
8311
  }
8307
8312
  re.value = 2, Y.value = !1;
8308
8313
  }
8309
- const pt = Vt.throttle(() => {
8310
- l("inited", V.value);
8311
- }, 1e3);
8314
+ const pt = Vt.debounce(
8315
+ () => {
8316
+ l("inited", V.value);
8317
+ },
8318
+ 400,
8319
+ { leading: !0, trailing: !1 }
8320
+ );
8312
8321
  function Nt() {
8313
8322
  V.value && V.value.length > 0 && u.type === "selection" && V.value.map((x) => {
8314
8323
  d.value.toggleRowSelection(
@@ -47,7 +47,7 @@ export default {
47
47
  <script lang="ts" setup>
48
48
  import { ref, computed, useAttrs, nextTick, onMounted, watch, inject, Ref } from 'vue'
49
49
  import { castArray, isMobile, time, isPromiseLike } from './util'
50
- import { cloneDeep, throttle } from 'lodash'
50
+ import { cloneDeep, debounce } from 'lodash'
51
51
  import * as validates from './util/validate'
52
52
  import { typeList } from './components/index'
53
53
  import ElPlusFormBtn from './components/ElPlusFormBtn.vue'
@@ -281,6 +281,7 @@ const computedRules = computed(() => {
281
281
  const attrMapToTableList = computed(() => {
282
282
  const formLayoutRows = [] as Array<Array<IFormDescItem>>
283
283
  if (props.formDesc) {
284
+ initFormAttrs()
284
285
  const tempFormDesc = cloneDeep(props.formDesc)
285
286
  let tempData = [] as Array<IFormDescItem>
286
287
  for (const key in tempFormDesc) {
@@ -337,70 +338,74 @@ const attrMapToTableList = computed(() => {
337
338
  })
338
339
 
339
340
  // 整体初始化属性
340
- const initFormAttrs = throttle(() => {
341
- if (props.formDesc) {
342
- Object.keys(props.formDesc).forEach((field) => {
343
- if (props.formDesc) {
344
- const formItem = props.formDesc[field]
345
- if (formItem && formItem.type) {
346
- // 设置 _type
347
- formItem._type = compTypeList.includes(formItem.type.toLowerCase()) ? 'el-plus-form-' + formItem.type : formItem.type
348
- // 触发 v-if 显示 / 隐藏 设置_vif
349
- formItem._vif = handelKeyValue(formItem, 'vif', field, !formItem.isBlank ?? true)
350
- // 触发 disabled 禁用 / 启用 设置_disabled
351
- formItem._disabled = handelKeyValue(formItem, 'disabled', field, props.disabled ?? false)
352
- // 动态属性 attrs
353
- const tempAttr = {} as any
354
- // if ((typeof formItem.attrs === 'object' && formItem.attrs?.options) || formItem.options) {
355
- // tempAttr.options = (formItem.attrs as any)?.options || formItem.options
356
- // }
357
- formItem._attrs = Object.assign({}, handelKeyValue(formItem, 'attrs', field), tempAttr)
358
- // 动态options
359
- // formItem._options = handelKeyValue(formItem, 'options', field)
360
- // 动态 _label
361
- formItem._label = handelKeyValue(formItem, 'label', field)
362
- // 动态 prop
363
- // formItem._prop = handelKeyValue(formItem, 'prop', field);
364
- // 动态 _tip
365
- formItem._tip = handelKeyValue(formItem, 'tip', field)
366
- // 单独处理下上传
367
- if (!formItem._tip && !formItem.noTip && formItem.type === 'upload') {
368
- formItem._tip = `最多上传${formItem.multiple ? formItem.limit || 20 : 1}${formItem.upType === 'file' ? '个文件' : '张图片'}`
369
- }
370
- // 这里初始化一下默认值
371
- if (formItem.default !== undefined && formItem.default !== null && props.modelValue[field] === undefined) {
372
- props.modelValue[field] = formItem.default
373
- }
374
- // 这里初始化一下默认选中项
375
- if (formItem.defaultItem !== undefined && formItem.defaultItem !== null && props.modelValue[field] === undefined) {
376
- props.modelValue[field] = formItem.defaultItem.value
377
- }
378
- // 这里格式化一下数据
379
- // if (formItem.format) {
380
- // if (typeof formItem.format === 'string') {
381
- // props.modelValue[field] = elPlusFormFormat[formItem.format](props.modelValue[field], props.modelValue)
382
- // } else if (typeof formItem.format === 'function') {
383
- // props.modelValue[field] = (formItem as any).format(props.modelValue[field], props.modelValue)
384
- // } else {
385
- // // console.log('未知的格式化类型:', formItem.format)
386
- // }
387
- // }
388
- // 这里最终处理一下auth权限问题
389
- if (formItem.auth) {
390
- if (!defaultConf.auth) {
391
- console.warn('使用auth属性,请在crud注册时传入auth校验方法~')
392
- } else {
393
- formItem._vif = defaultConf.auth(formItem.auth)
341
+ const initFormAttrs = debounce(
342
+ () => {
343
+ if (props.formDesc) {
344
+ Object.keys(props.formDesc).forEach((field) => {
345
+ if (props.formDesc) {
346
+ const formItem = props.formDesc[field]
347
+ if (formItem && formItem.type) {
348
+ // 设置 _type
349
+ formItem._type = compTypeList.includes(formItem.type.toLowerCase()) ? 'el-plus-form-' + formItem.type : formItem.type
350
+ // 触发 v-if 显示 / 隐藏 设置_vif
351
+ formItem._vif = handelKeyValue(formItem, 'vif', field, !formItem.isBlank ?? true)
352
+ // 触发 disabled 禁用 / 启用 设置_disabled
353
+ formItem._disabled = handelKeyValue(formItem, 'disabled', field, props.disabled ?? false)
354
+ // 动态属性 attrs
355
+ const tempAttr = {} as any
356
+ // if ((typeof formItem.attrs === 'object' && formItem.attrs?.options) || formItem.options) {
357
+ // tempAttr.options = (formItem.attrs as any)?.options || formItem.options
358
+ // }
359
+ formItem._attrs = Object.assign({}, handelKeyValue(formItem, 'attrs', field), tempAttr)
360
+ // 动态options
361
+ // formItem._options = handelKeyValue(formItem, 'options', field)
362
+ // 动态 _label
363
+ formItem._label = handelKeyValue(formItem, 'label', field)
364
+ // 动态 prop
365
+ // formItem._prop = handelKeyValue(formItem, 'prop', field);
366
+ // 动态 _tip
367
+ formItem._tip = handelKeyValue(formItem, 'tip', field)
368
+ // 单独处理下上传
369
+ if (!formItem._tip && !formItem.noTip && formItem.type === 'upload') {
370
+ formItem._tip = `最多上传${formItem.multiple ? formItem.limit || 20 : 1}${formItem.upType === 'file' ? '个文件' : '张图片'}`
371
+ }
372
+ // 这里初始化一下默认值
373
+ if (formItem.default !== undefined && formItem.default !== null && props.modelValue[field] === undefined) {
374
+ props.modelValue[field] = formItem.default
375
+ }
376
+ // 这里初始化一下默认选中项
377
+ if (formItem.defaultItem !== undefined && formItem.defaultItem !== null && props.modelValue[field] === undefined) {
378
+ props.modelValue[field] = formItem.defaultItem.value
394
379
  }
380
+ // 这里格式化一下数据
381
+ // if (formItem.format) {
382
+ // if (typeof formItem.format === 'string') {
383
+ // props.modelValue[field] = elPlusFormFormat[formItem.format](props.modelValue[field], props.modelValue)
384
+ // } else if (typeof formItem.format === 'function') {
385
+ // props.modelValue[field] = (formItem as any).format(props.modelValue[field], props.modelValue)
386
+ // } else {
387
+ // // console.log('未知的格式化类型:', formItem.format)
388
+ // }
389
+ // }
390
+ // 这里最终处理一下auth权限问题
391
+ if (formItem.auth) {
392
+ if (!defaultConf.auth) {
393
+ console.warn('使用auth属性,请在crud注册时传入auth校验方法~')
394
+ } else {
395
+ formItem._vif = defaultConf.auth(formItem.auth)
396
+ }
397
+ }
398
+ } else if (formItem && formItem.isBlank) {
399
+ // 触发 v-if 显示 / 隐藏 设置_vif
400
+ formItem._vif = handelKeyValue(formItem, 'vif', '', true)
395
401
  }
396
- } else if (formItem && formItem.isBlank) {
397
- // 触发 v-if 显示 / 隐藏 设置_vif
398
- formItem._vif = handelKeyValue(formItem, 'vif', '', true)
399
402
  }
400
- }
401
- })
402
- }
403
- }, 100)
403
+ })
404
+ }
405
+ },
406
+ 100,
407
+ { leading: true, trailing: false }
408
+ )
404
409
 
405
410
  // 表单底部按钮
406
411
  const btnList = computed(() => {
@@ -99,7 +99,7 @@ import { ref, reactive, onMounted, computed, watch, nextTick, useSlots, inject,
99
99
  import EleTabletHeader from './components/header.vue'
100
100
  import ElPlusTableColumn from './ElPlusTableColumn.vue'
101
101
  import { handelListColumn } from './util'
102
- import { cloneDeep, throttle } from 'lodash'
102
+ import { cloneDeep, debounce } from 'lodash'
103
103
  import { Loading } from '@element-plus/icons-vue'
104
104
  import type { TableColumnCtx } from 'element-plus'
105
105
  import { ICRUDConfig, ITableConfig, ITableTabItem, ITreeProps } from 'types'
@@ -699,9 +699,13 @@ async function loadData(isInit: Boolean) {
699
699
  localLoading.value = false
700
700
  }
701
701
 
702
- const noticeInited = throttle(() => {
703
- emits('inited', tableData.value)
704
- }, 1000)
702
+ const noticeInited = debounce(
703
+ () => {
704
+ emits('inited', tableData.value)
705
+ },
706
+ 400,
707
+ { leading: true, trailing: false }
708
+ )
705
709
 
706
710
  /**
707
711
  * 渲染列表的选中项
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "el-plus-crud",
3
- "version": "0.0.115",
3
+ "version": "0.0.116",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "el-plus-crud",
9
- "version": "0.0.115",
9
+ "version": "0.0.116",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@element-plus/icons-vue": "^2.1.0",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "el-plus-crud",
3
3
  "description": "采用Vue3 + TS,封装的element-plus数据驱动表单、列表组件",
4
4
  "author": "K.D.Jack",
5
- "version": "0.0.115",
5
+ "version": "0.0.116",
6
6
  "license": "MIT",
7
7
  "private": false,
8
8
  "main": "dist/el-plus-crud.mjs",