htui-yllkbz 1.2.16 → 1.2.20

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 17:29:45
8
+ * @LastEditTime: 2021-12-12 10:25:50
9
9
  -->
10
10
  <template>
11
11
  <div v-loading="state.loading">
@@ -43,10 +43,12 @@
43
43
  @cell-click="(row, column, cell, event)=>$emit('cell-click',row, column, cell, event)"
44
44
  @cell-dblclick="(row, column, cell, event)=>$emit('cell-dblclick',row, column, cell, event)">
45
45
  <el-table-column width="55"
46
+ v-if="checked"
46
47
  type='selection'>
47
48
  </el-table-column>
48
49
  <el-table-column v-if="!hideOrder"
49
50
  label="序号"
51
+ :align="'center'"
50
52
  width="55">
51
53
  <template slot="header">
52
54
  <slot :name="'header_order'"></slot>
@@ -57,16 +59,28 @@
57
59
  </el-table-column>
58
60
  <el-table-column :label="item.title"
59
61
  :key='item.key'
62
+ :fixed="item.fixed"
63
+ :align="item.align"
64
+ :header-align="item.headerAlign"
65
+ :column-key="item.columnKey"
66
+ :class-name="item.className"
60
67
  v-for="item in columns"
61
68
  :show-overflow-tooltip="true"
69
+ :selectable="item.selectable"
62
70
  :prop="item.key"
63
- :width="item.width||120">
71
+ :sortable="item.sortable"
72
+ :sort-method="item.sortMethod"
73
+ :sort-orders="item.sortOrders"
74
+ :formatter="item.formatter"
75
+ :sort-by="item.sortBy"
76
+ :min-width="item.minWidth"
77
+ :width="item.width">
64
78
  <template slot-scope="{row,column,rowIndex}">
65
79
  <slot :name="item.key"
66
80
  :row="row"
67
81
  :column="column"
68
- :rowIndex="rowIndex">{{row[item.key]}}</slot>
69
- {{item.headerSlot}}
82
+ :rowIndex="rowIndex">{{getPropByPath(row,item.key)}}</slot>
83
+
70
84
  </template>
71
85
  <template slot-scope="{column,$index}"
72
86
  slot="header">
@@ -102,6 +116,7 @@ interface State {
102
116
  loading: boolean;
103
117
  }
104
118
  @Component({
119
+ name: "HtTable",
105
120
  components: {
106
121
  PageInfo,
107
122
  },
@@ -112,6 +127,8 @@ export default class HtTable extends Vue {
112
127
  @Prop() data!: any[];
113
128
  /** 是否隐藏分页 */
114
129
  @Prop() hidePage!: boolean;
130
+ /** 是否启用复选框 */
131
+ @Prop() checked!: boolean;
115
132
  @Prop() height?: string | number;
116
133
  @Prop() maxHeight?: string | number;
117
134
  @Prop() rowKey?: string;
@@ -142,7 +159,56 @@ export default class HtTable extends Vue {
142
159
  // console.log("this", this.$props);
143
160
  this.setPageInfo(this.pageInfo);
144
161
  }
162
+ getPropByPath(obj: any, path: string, strict: boolean) {
163
+ let tempObj = obj;
164
+ path = path.replace(/\[(\w+)\]/g, ".$1");
165
+ path = path.replace(/^\./, "");
145
166
 
167
+ const keyArr = path.split(".");
168
+ let i = 0;
169
+ for (let len = keyArr.length; i < len - 1; ++i) {
170
+ if (!tempObj && !strict) break;
171
+ const key = keyArr[i];
172
+ if (key in tempObj) {
173
+ tempObj = tempObj[key];
174
+ } else {
175
+ if (strict) {
176
+ throw new Error("please transfer a valid prop path to form item!");
177
+ }
178
+ break;
179
+ }
180
+ }
181
+ // return {
182
+ // o: tempObj,
183
+ // k: keyArr[i],
184
+ // v: tempObj ? tempObj[keyArr[i]] : null,
185
+ // };
186
+ return tempObj ? tempObj[keyArr[i]] : null;
187
+ }
188
+ /** 遍历循环展示row数据 */
189
+ showValue(row: any, key: string) {
190
+ if (key) {
191
+ if (key.includes(".")) {
192
+ //存在多级的情况
193
+ //console.log("eval", key, eval(row[key]));
194
+ // const arrKey = key.split(".");
195
+ // let data = row;
196
+ // arrKey.forEach((item) => {
197
+ // if (data[item]) {
198
+ // data = data[item];
199
+ // } else {
200
+ // data = "";
201
+ // }
202
+ // });
203
+ return "";
204
+ } else {
205
+ //如果不存在多级数据
206
+ return row[key];
207
+ }
208
+ } else {
209
+ return "";
210
+ }
211
+ }
146
212
  /** 监听 */
147
213
  @Watch("pageInfo")
148
214
  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-11 11:06:51
6
6
  * @LastEditors: hutao
7
- * @LastEditTime: 2021-12-08 11:29:19
7
+ * @LastEditTime: 2021-12-12 10:07:34
8
8
  -->
9
9
  <template>
10
10
  <el-popover placement="bottom"
@@ -182,7 +182,7 @@ export default class HtSelectTable extends Vue {
182
182
  //
183
183
  if (!this.state.config.disabled) {
184
184
  const ref: any = this.$refs[this.state.config.key || "ht-table"];
185
- console.log("333");
185
+
186
186
  this.state.visible = false;
187
187
  ref.clearCheck();
188
188
  }
@@ -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",