htui-yllkbz 1.2.15 → 1.2.19

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.
@@ -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 16:33:39
8
+ * @LastEditTime: 2021-12-12 09:55:18
9
9
  -->
10
10
  <template>
11
11
  <div v-loading="state.loading">
@@ -57,16 +57,27 @@
57
57
  </el-table-column>
58
58
  <el-table-column :label="item.title"
59
59
  :key='item.key'
60
+ :fixed="item.fixed"
61
+ :align="item.align"
62
+ :header-align="item.headerAlign"
63
+ :column-key="item.columnKey"
64
+ :class-name="item.className"
60
65
  v-for="item in columns"
61
66
  :show-overflow-tooltip="true"
62
67
  :prop="item.key"
63
- :width="item.width||120">
68
+ :sortable="item.sortable"
69
+ :sort-method="item.sortMethod"
70
+ :sort-orders="item.sortOrders"
71
+ :formatter="item.formatter"
72
+ :sort-by="item.sortBy"
73
+ :min-width="item.minWidth"
74
+ :width="item.width">
64
75
  <template slot-scope="{row,column,rowIndex}">
65
76
  <slot :name="item.key"
66
77
  :row="row"
67
78
  :column="column"
68
- :rowIndex="rowIndex">{{row[item.key]}}</slot>
69
- {{item.headerSlot}}
79
+ :rowIndex="rowIndex">{{getPropByPath(row,item.key)}}</slot>
80
+
70
81
  </template>
71
82
  <template slot-scope="{column,$index}"
72
83
  slot="header">
@@ -102,11 +113,12 @@ interface State {
102
113
  loading: boolean;
103
114
  }
104
115
  @Component({
116
+ name: "HtTable",
105
117
  components: {
106
118
  PageInfo,
107
119
  },
108
120
  })
109
- export default class Index extends Vue {
121
+ export default class HtTable extends Vue {
110
122
  /** 默认的table头 */
111
123
  @Prop() columns!: Column[];
112
124
  @Prop() data!: any[];
@@ -142,7 +154,56 @@ export default class Index extends Vue {
142
154
  // console.log("this", this.$props);
143
155
  this.setPageInfo(this.pageInfo);
144
156
  }
157
+ getPropByPath(obj: any, path: string, strict: boolean) {
158
+ let tempObj = obj;
159
+ path = path.replace(/\[(\w+)\]/g, ".$1");
160
+ path = path.replace(/^\./, "");
145
161
 
162
+ const keyArr = path.split(".");
163
+ let i = 0;
164
+ for (let len = keyArr.length; i < len - 1; ++i) {
165
+ if (!tempObj && !strict) break;
166
+ const key = keyArr[i];
167
+ if (key in tempObj) {
168
+ tempObj = tempObj[key];
169
+ } else {
170
+ if (strict) {
171
+ throw new Error("please transfer a valid prop path to form item!");
172
+ }
173
+ break;
174
+ }
175
+ }
176
+ // return {
177
+ // o: tempObj,
178
+ // k: keyArr[i],
179
+ // v: tempObj ? tempObj[keyArr[i]] : null,
180
+ // };
181
+ return tempObj ? tempObj[keyArr[i]] : null;
182
+ }
183
+ /** 遍历循环展示row数据 */
184
+ showValue(row: any, key: string) {
185
+ if (key) {
186
+ if (key.includes(".")) {
187
+ //存在多级的情况
188
+ //console.log("eval", key, eval(row[key]));
189
+ // const arrKey = key.split(".");
190
+ // let data = row;
191
+ // arrKey.forEach((item) => {
192
+ // if (data[item]) {
193
+ // data = data[item];
194
+ // } else {
195
+ // data = "";
196
+ // }
197
+ // });
198
+ return "";
199
+ } else {
200
+ //如果不存在多级数据
201
+ return row[key];
202
+ }
203
+ } else {
204
+ return "";
205
+ }
206
+ }
146
207
  /** 监听 */
147
208
  @Watch("pageInfo")
148
209
  setPageInfo(val?: PageInfoType) {
@@ -4,7 +4,7 @@
4
4
  * @Author: hutao
5
5
  * @Date: 2021-12-08 11:30:56
6
6
  * @LastEditors: hutao
7
- * @LastEditTime: 2021-12-09 16:20:43
7
+ * @LastEditTime: 2021-12-09 18:04:54
8
8
  -->
9
9
 
10
10
  <!--
@@ -44,7 +44,9 @@ interface State {
44
44
  };
45
45
  }
46
46
 
47
- @Component
47
+ @Component({
48
+ name: "HtPagination",
49
+ })
48
50
  export default class HtPagination extends Vue {
49
51
  /** 通用样式 */
50
52
  @Prop() comStyle!: string;
@@ -4,7 +4,7 @@
4
4
  * @Author: hutao
5
5
  * @Date: 2021-11-15 14:41:40
6
6
  * @LastEditors: hutao
7
- * @LastEditTime: 2021-12-09 16:47:22
7
+ * @LastEditTime: 2021-12-12 09:03:38
8
8
  -->
9
9
  <template>
10
10
  <div>
@@ -45,17 +45,21 @@ export default class Index extends Vue {
45
45
  state: State = {
46
46
  loading: false,
47
47
  data: [
48
- { name: "胡涛", age: 12, sex: 0, id: 1 },
49
- { name: "胡涛", age: 12, sex: 1, id: 2 },
50
- { name: "胡涛", age: 12, sex: 1, id: 3 },
51
- { name: "胡涛", age: 12, sex: 0, id: 4 },
48
+ { name: "胡涛", age: 12, sex: 0, id: 1, test: { title: "测试" } },
49
+ { name: "胡涛", age: 12, sex: 1, id: 2, test: { title: "测试" } },
50
+ { name: "胡涛", age: 12, sex: 1, id: 3, test: { title: "测试" } },
51
+ { name: "胡涛", age: 12, sex: 0, id: 4, test: { title: "测试" } },
52
52
  ],
53
53
  columns: [
54
54
  {
55
55
  title: "姓名",
56
- key: "name",
56
+ key: "test.title",
57
57
  width: "300px",
58
58
  },
59
+ {
60
+ title: "姓额外名",
61
+ key: "name",
62
+ },
59
63
  {
60
64
  title: "age",
61
65
  key: "age",