htui-yllkbz 1.2.17 → 1.2.18
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/lib/htui.common.js +6341 -5991
- package/lib/htui.common.js.gz +0 -0
- package/lib/htui.umd.js +6341 -5991
- package/lib/htui.umd.js.gz +0 -0
- package/lib/htui.umd.min.js +8 -22
- package/lib/htui.umd.min.js.gz +0 -0
- package/package.json +1 -1
- package/src/packages/HtTable/index.vue +39 -9
- package/src/views/About.vue +1 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @Author: hutao
|
|
6
6
|
* @Date: 2021-11-11 11:23:24
|
|
7
7
|
* @LastEditors: hutao
|
|
8
|
-
* @LastEditTime: 2021-12-09
|
|
8
|
+
* @LastEditTime: 2021-12-12 09:07:39
|
|
9
9
|
-->
|
|
10
10
|
<template>
|
|
11
11
|
<div v-loading="state.loading">
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
<slot :name="item.key"
|
|
66
66
|
:row="row"
|
|
67
67
|
:column="column"
|
|
68
|
-
:rowIndex="rowIndex">{{
|
|
68
|
+
:rowIndex="rowIndex">{{getPropByPath(row,item.key)}}</slot>
|
|
69
69
|
|
|
70
70
|
</template>
|
|
71
71
|
<template slot-scope="{column,$index}"
|
|
@@ -143,18 +143,48 @@ export default class HtTable extends Vue {
|
|
|
143
143
|
// console.log("this", this.$props);
|
|
144
144
|
this.setPageInfo(this.pageInfo);
|
|
145
145
|
}
|
|
146
|
+
getPropByPath(obj: any, path: string, strict: boolean) {
|
|
147
|
+
let tempObj = obj;
|
|
148
|
+
path = path.replace(/\[(\w+)\]/g, ".$1");
|
|
149
|
+
path = path.replace(/^\./, "");
|
|
150
|
+
|
|
151
|
+
const keyArr = path.split(".");
|
|
152
|
+
let i = 0;
|
|
153
|
+
for (let len = keyArr.length; i < len - 1; ++i) {
|
|
154
|
+
if (!tempObj && !strict) break;
|
|
155
|
+
const key = keyArr[i];
|
|
156
|
+
if (key in tempObj) {
|
|
157
|
+
tempObj = tempObj[key];
|
|
158
|
+
} else {
|
|
159
|
+
if (strict) {
|
|
160
|
+
throw new Error("please transfer a valid prop path to form item!");
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// return {
|
|
166
|
+
// o: tempObj,
|
|
167
|
+
// k: keyArr[i],
|
|
168
|
+
// v: tempObj ? tempObj[keyArr[i]] : null,
|
|
169
|
+
// };
|
|
170
|
+
return tempObj ? tempObj[keyArr[i]] : null;
|
|
171
|
+
}
|
|
146
172
|
/** 遍历循环展示row数据 */
|
|
147
173
|
showValue(row: any, key: string) {
|
|
148
174
|
if (key) {
|
|
149
175
|
if (key.includes(".")) {
|
|
150
176
|
//存在多级的情况
|
|
151
|
-
|
|
152
|
-
const arrKey = key.split(".");
|
|
153
|
-
let data = row;
|
|
154
|
-
arrKey.forEach((item) => {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
177
|
+
//console.log("eval", key, eval(row[key]));
|
|
178
|
+
// const arrKey = key.split(".");
|
|
179
|
+
// let data = row;
|
|
180
|
+
// arrKey.forEach((item) => {
|
|
181
|
+
// if (data[item]) {
|
|
182
|
+
// data = data[item];
|
|
183
|
+
// } else {
|
|
184
|
+
// data = "";
|
|
185
|
+
// }
|
|
186
|
+
// });
|
|
187
|
+
return "";
|
|
158
188
|
} else {
|
|
159
189
|
//如果不存在多级数据
|
|
160
190
|
return row[key];
|