xianniu-ui 0.8.38 → 0.8.40

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xianniu-ui",
3
- "version": "0.8.38",
3
+ "version": "0.8.40",
4
4
  "private": false,
5
5
  "main": "lib/xianniu-ui.umd.min.js",
6
6
  "scripts": {
@@ -46,7 +46,7 @@
46
46
  :key="idxBtn"
47
47
  :confirm-button-text="itemBtn.options.confirmButtonText"
48
48
  class="ml-10"
49
- @confirm="handleClick(itemBtn.method, row, $index)"
49
+ @confirm="handleClick(itemBtn.method, row, $index, $event)"
50
50
  >
51
51
  <el-button
52
52
  :type="itemBtn.type || 'text'"
@@ -66,7 +66,9 @@
66
66
  :size="itemBtn.size || 'mini'"
67
67
  :icon="itemBtn.icon"
68
68
  :plain="itemBtn.plain"
69
- @click.native.stop="handleClick(itemBtn.method, row, $index)"
69
+ @click.native.stop="
70
+ handleClick(itemBtn.method, row, $index, $event)
71
+ "
70
72
  >{{ label(itemBtn, row) }}</el-button
71
73
  >
72
74
  </template>
@@ -102,11 +104,15 @@ export default {
102
104
  },
103
105
  },
104
106
  computed: {
105
- showOverflowTooltip(){
106
- return (attrs)=>{
107
- const showTip = (attrs['showOverflowTooltip'] != undefined && attrs['showOverflowTooltip'] !== true) || (attrs['show-overflow-tooltip'] != undefined && attrs['show-overflow-tooltip'] !== true)
108
- return attrs.more ? false : showTip ? !showTip : true
109
- }
107
+ showOverflowTooltip() {
108
+ return (attrs) => {
109
+ const showTip =
110
+ (attrs["showOverflowTooltip"] != undefined &&
111
+ attrs["showOverflowTooltip"] !== true) ||
112
+ (attrs["show-overflow-tooltip"] != undefined &&
113
+ attrs["show-overflow-tooltip"] !== true);
114
+ return attrs.more ? false : showTip ? !showTip : true;
115
+ };
110
116
  },
111
117
  label() {
112
118
  return (itemBtn, row) => {
@@ -127,12 +133,13 @@ export default {
127
133
 
128
134
  watch: {},
129
135
  methods: {
130
- handleClick(method, row, index) {
136
+ handleClick(method, row, index, ev) {
131
137
  if (this.$parent) {
132
138
  this.$parent.$emit("handle-buttons", {
133
139
  method,
134
140
  row,
135
141
  index,
142
+ ev,
136
143
  });
137
144
  }
138
145
  },
@@ -198,7 +198,32 @@ export const toCamelCase = (string)=> {
198
198
  return camelCaseString;
199
199
  }
200
200
 
201
+ export function assignValues(form, apiResponse) {
202
+ function isEmpty(value) {
203
+ return (
204
+ (Array.isArray(value) && value.length === 0) ||
205
+ (typeof value === 'object' && Object.keys(value).length === 0)
206
+ )
207
+ }
208
+
209
+ const updatedForm = Array.isArray(form) ? [...form] : { ...form }
210
+
211
+ for (const key in form) {
212
+ if (Object.hasOwnProperty.call(form, key)) {
213
+ const apiValue = apiResponse[key]
214
+
215
+ // 检查 apiValue 是否是一个对象,如果是,则递归
216
+ if (typeof apiValue === 'object' && apiValue !== null && !Array.isArray(apiValue)) {
217
+ updatedForm[key] = assignValues(form[key], apiValue)
218
+ } else if (apiValue !== null && apiValue !== undefined && apiValue !== '' && !isEmpty(apiValue)) {
219
+ // 如果 apiValue 不是空值及不是空的对象或数组,更新 updatedForm
220
+ updatedForm[key] = apiValue
221
+ }
222
+ }
223
+ }
201
224
 
225
+ return updatedForm
226
+ }
202
227
  export default {
203
228
  isEmpty,
204
229
  isImg,
@@ -209,5 +234,6 @@ export default {
209
234
  isBlank,
210
235
  toCamelCase,
211
236
  checkFile,
212
- isAV
237
+ isAV,
238
+ assignValues
213
239
  }