htui-yllkbz 1.2.11 → 1.2.15

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.
@@ -0,0 +1,161 @@
1
+
2
+ <!--
3
+ * @Descripttion: ht-table
4
+ * @version:
5
+ * @Author: hutao
6
+ * @Date: 2021-11-11 11:23:24
7
+ * @LastEditors: hutao
8
+ * @LastEditTime: 2021-12-09 16:33:39
9
+ -->
10
+ <template>
11
+ <div v-loading="state.loading">
12
+ <article>
13
+
14
+ <el-table ref="comTable"
15
+ :height="height"
16
+ :max-height="maxHeight"
17
+ :border="border"
18
+ :stripe="stripe"
19
+ :size="size"
20
+ :fit="fit"
21
+ :show-header="showHeader"
22
+ :empty-text="emptyText||'暂无数据'"
23
+ :row-style="rowStyle"
24
+ :row-class-name="rowClassName"
25
+ :current-row-key="currentRowKey"
26
+ :highlight-current-row="highlightCurrentRow"
27
+ :row-key="rowKey||'id'"
28
+ :data="data"
29
+ tooltip-effect="dark"
30
+ @row-click="(row, column, event)=>$emit('row-click',row, column, event)"
31
+ @row-contextmenu="(row, column, event)=>$emit('row-contextmenu',row, column, event)"
32
+ @row-dblclick="(row, column, event)=>$emit('row-dblclick',row, column, event)"
33
+ @header-click="( column, event)=>$emit('header-click', column, event)"
34
+ @header-contextmenu="( column, event)=>$emit('header-contextmenu', column, event)"
35
+ @sort-change="({ column, prop, order})=>$emit('sort-change', { column, prop, order})"
36
+ @filter-change="(filter)=>$emit('filter-change', filter)"
37
+ @current-change="(currentRow, oldCurrentRow)=>$emit('current-change', currentRow, oldCurrentRow)"
38
+ @select="(selection, row)=>$emit('select',selection, row)"
39
+ @select-all="(selection)=>$emit('select-all',selection)"
40
+ @selection-change="(selection)=>$emit('selection-change',selection)"
41
+ @cell-mouse-enter="(row, column, cell, event)=>$emit('cell-mouse-enter',row, column, cell, event)"
42
+ @cell-mouse-leave="(row, column, cell, event)=>$emit('cell-mouse-leave',row, column, cell, event)"
43
+ @cell-click="(row, column, cell, event)=>$emit('cell-click',row, column, cell, event)"
44
+ @cell-dblclick="(row, column, cell, event)=>$emit('cell-dblclick',row, column, cell, event)">
45
+ <el-table-column width="55"
46
+ type='selection'>
47
+ </el-table-column>
48
+ <el-table-column v-if="!hideOrder"
49
+ label="序号"
50
+ width="55">
51
+ <template slot="header">
52
+ <slot :name="'header_order'"></slot>
53
+ </template>
54
+ <template slot-scope="scope">
55
+ {{(state.pageInfo.currentPage-1)*state.pageInfo.pageSize+(scope.$index+1)}}
56
+ </template>
57
+ </el-table-column>
58
+ <el-table-column :label="item.title"
59
+ :key='item.key'
60
+ v-for="item in columns"
61
+ :show-overflow-tooltip="true"
62
+ :prop="item.key"
63
+ :width="item.width||120">
64
+ <template slot-scope="{row,column,rowIndex}">
65
+ <slot :name="item.key"
66
+ :row="row"
67
+ :column="column"
68
+ :rowIndex="rowIndex">{{row[item.key]}}</slot>
69
+ {{item.headerSlot}}
70
+ </template>
71
+ <template slot-scope="{column,$index}"
72
+ slot="header">
73
+ <slot :name="'header_'+item.key"
74
+ :column="column"
75
+ :$index="$index">{{item.title}}</slot>
76
+ </template>
77
+ </el-table-column>
78
+
79
+ </el-table>
80
+ </article>
81
+ <footer v-if="!hidePage">
82
+ <el-row>
83
+ <el-col :span="24">
84
+ <!-- <p style="width:90px;float:left">共{{data.length}}条</p> -->
85
+ <PageInfo :hide-on-single-page="pagination&&pagination.hideOnSinglePage"
86
+ :small="pagination&&pagination.small"
87
+ @onchange="(e)=>$emit('onchange',e)"
88
+ :page-sizes="pagination&&pagination.pageSizes"
89
+ :page-info="state.pageInfo"></PageInfo>
90
+ </el-col>
91
+ </el-row>
92
+ </footer>
93
+ </div>
94
+ </template>
95
+ <script lang='ts'>
96
+ import { Component, Prop, Vue, Watch } from "vue-property-decorator";
97
+ import { _axios } from "vue-kst-auth";
98
+ import { Column, PageInfoType } from "@/packages/type";
99
+ import PageInfo from "@/packages/PageInfo/index.vue";
100
+ interface State {
101
+ pageInfo: PageInfoType;
102
+ loading: boolean;
103
+ }
104
+ @Component({
105
+ components: {
106
+ PageInfo,
107
+ },
108
+ })
109
+ export default class Index extends Vue {
110
+ /** 默认的table头 */
111
+ @Prop() columns!: Column[];
112
+ @Prop() data!: any[];
113
+ /** 是否隐藏分页 */
114
+ @Prop() hidePage!: boolean;
115
+ @Prop() height?: string | number;
116
+ @Prop() maxHeight?: string | number;
117
+ @Prop() rowKey?: string;
118
+ @Prop() stripe?: boolean;
119
+ @Prop() border?: boolean;
120
+ @Prop() size?: "medium" | "small" | "mini";
121
+ @Prop() fit?: boolean;
122
+ @Prop() showHeader?: boolean;
123
+ @Prop() rowClassName?: any;
124
+ @Prop() currentRowKey?: string | number;
125
+ @Prop() highlightCurrentRow?: boolean;
126
+ @Prop() rowStyle?: any;
127
+ @Prop() hideOrder?: boolean;
128
+ @Prop() pageInfo?: PageInfoType;
129
+ @Prop() emptyText?: string | number;
130
+ /** 分页的所有额外信息通过此参数传递 */
131
+ @Prop() pagination?: any;
132
+ state: State = {
133
+ loading: false,
134
+ pageInfo: {
135
+ currentPage: 1,
136
+ pageSize: 10,
137
+ skipCount: 0,
138
+ totalCount: 0,
139
+ },
140
+ };
141
+ created() {
142
+ // console.log("this", this.$props);
143
+ this.setPageInfo(this.pageInfo);
144
+ }
145
+
146
+ /** 监听 */
147
+ @Watch("pageInfo")
148
+ setPageInfo(val?: PageInfoType) {
149
+ if (val) {
150
+ const pageInfo: PageInfoType = val;
151
+ this.state.pageInfo = {
152
+ currentPage: Number(pageInfo.currentPage),
153
+ pageSize: Number(pageInfo.pageSize),
154
+ skipCount: Number(pageInfo.skipCount),
155
+ totalCount: Number(pageInfo.totalCount),
156
+ };
157
+ }
158
+ }
159
+ }
160
+ </script>
161
+ <style lang='scss' scoped></style>
@@ -0,0 +1,16 @@
1
+ /*
2
+ * @Descripttion:
3
+ * @version:
4
+ * @Author: hutao
5
+ * @Date: 2021-11-15 15:00:57
6
+ * @LastEditors: hutao
7
+ * @LastEditTime: 2021-12-08 11:39:52
8
+ */
9
+ import HtPagination from "./index.vue";
10
+
11
+ (HtPagination as any).install = function (Vue: any) {
12
+
13
+ Vue.component("HtPagination", HtPagination);
14
+ };
15
+
16
+ export default HtPagination;
@@ -0,0 +1,113 @@
1
+ <!--
2
+ * @Descripttion: 处理分页封装
3
+ * @version:
4
+ * @Author: hutao
5
+ * @Date: 2021-12-08 11:30:56
6
+ * @LastEditors: hutao
7
+ * @LastEditTime: 2021-12-09 16:20:43
8
+ -->
9
+
10
+ <!--
11
+ * @Descripttion:
12
+ * @version:
13
+ * @Author: hutao
14
+ * @Date: 2021-11-22 10:00:05
15
+ * @LastEditors: hutao
16
+ * @LastEditTime: 2021-11-22 18:07:40
17
+ -->
18
+ <template>
19
+ <el-pagination @current-change="handleCurrentChange"
20
+ :background="background"
21
+ @size-change="handelSizeChange"
22
+ :hide-on-single-page="hideOnSinglePage"
23
+ :disabled="!!disabled"
24
+ :small="!!small"
25
+ :current-page="state.pageInfo.currentPage"
26
+ :page-size="state.pageInfo.maxResultCount"
27
+ :page-sizes="pageSizes||[10, 20, 30, 40, 50, 100]"
28
+ :layout="layout||'total, sizes, prev, pager, next, jumper'"
29
+ :total="state.pageInfo.totalCount">
30
+ </el-pagination>
31
+ </template>
32
+ <script lang='ts'>
33
+ import { Component, Prop, Vue, Watch } from "vue-property-decorator";
34
+ import { PageInfoType } from "../type";
35
+ interface State {
36
+ /** 数据状态 */
37
+ loading: boolean;
38
+ /** 分页信息 */
39
+ pageInfo: {
40
+ currentPage: number;
41
+ maxResultCount: number;
42
+ skipCount: number;
43
+ totalCount: number;
44
+ };
45
+ }
46
+
47
+ @Component
48
+ export default class HtPagination extends Vue {
49
+ /** 通用样式 */
50
+ @Prop() comStyle!: string;
51
+ /** 是否使用小型分页样式 */
52
+ @Prop() small!: string;
53
+ /** 当前页 */
54
+ @Prop() pageInfo!: PageInfoType;
55
+ /** 每页条数 */
56
+ @Prop() pageSize!: string;
57
+ /** 跳过多少条 */
58
+ @Prop() skipCount!: string;
59
+ /** 是否禁用 */
60
+ @Prop() disabled!: boolean;
61
+ /** 是否未分页按钮添加背景色 */
62
+ @Prop() background!: string;
63
+ /** 只有一页时是否隐藏 */
64
+ @Prop() hideOnSinglePage!: boolean;
65
+ /** 每页显示个数选择器的选项设置 */
66
+ @Prop() pageSizes!: number[];
67
+ /** 组件布局 */
68
+ @Prop() layout!: string; //组件布局,子组件名用逗号分隔
69
+ /** 数据 */
70
+ state: State = {
71
+ loading: false,
72
+ pageInfo: {
73
+ currentPage: 1,
74
+ maxResultCount: 10,
75
+ skipCount: 0,
76
+ totalCount: 0,
77
+ },
78
+ };
79
+
80
+ /** 生命周期 */
81
+ created() {
82
+ if (this.pageInfo) {
83
+ this.setpageInfo(this.pageInfo);
84
+ }
85
+ }
86
+ /** 方法 */
87
+ /** 翻页 */
88
+ handleCurrentChange(val: number) {
89
+ this.state.pageInfo.currentPage = val || 1;
90
+ const { maxResultCount = 0, currentPage } = this.state.pageInfo;
91
+ this.state.pageInfo.skipCount = (currentPage - 1) * maxResultCount;
92
+ this.$emit("onchange", this.state.pageInfo);
93
+ }
94
+ /** 更新每页条数 */
95
+ handelSizeChange(val: number) {
96
+ this.state.pageInfo.currentPage = 1;
97
+ this.state.pageInfo.maxResultCount = val;
98
+ this.handleCurrentChange(1);
99
+ }
100
+ /** 监听 */
101
+ @Watch("pageInfo")
102
+ setpageInfo(val: PageInfoType) {
103
+ const pageInfo: PageInfoType = val;
104
+ this.state.pageInfo = {
105
+ currentPage: Number(pageInfo.currentPage),
106
+ maxResultCount: Number(pageInfo.pageSize),
107
+ skipCount: Number(pageInfo.skipCount),
108
+ totalCount: Number(pageInfo.totalCount),
109
+ };
110
+ }
111
+ /** 计算属性 */
112
+ }
113
+ </script>
@@ -4,7 +4,7 @@
4
4
  * @Author: hutao
5
5
  * @Date: 2021-11-15 14:50:56
6
6
  * @LastEditors: hutao
7
- * @LastEditTime: 2021-11-30 10:26:25
7
+ * @LastEditTime: 2021-12-08 11:42:36
8
8
  -->
9
9
  <!--
10
10
  * @Descripttion:
@@ -47,6 +47,7 @@
47
47
  :show-overflow-tooltip="true"
48
48
  :prop="item.key"
49
49
  :width="item.width||120">
50
+ <slot :name="item.key">{{item.key}}</slot>
50
51
  </el-table-column>
51
52
 
52
53
  </el-table>
@@ -4,22 +4,24 @@
4
4
  * @Author: hutao
5
5
  * @Date: 2021-11-11 11:06:51
6
6
  * @LastEditors: hutao
7
- * @LastEditTime: 2021-11-30 14:15:32
7
+ * @LastEditTime: 2021-12-08 11:29:19
8
8
  -->
9
9
  <template>
10
10
  <el-popover placement="bottom"
11
11
  title=""
12
+ ref="elPopver"
12
13
  class="ht-popover"
13
- v-model="state.visible"
14
14
  :width="width||600"
15
15
  @show="show"
16
16
  @hide="hide"
17
17
  trigger="click">
18
18
  <div slot="reference"
19
- @click="!state.config.disabled?state.visible = !state.visible:state.visible=false"
19
+ :style="`width:${inputWidth}px`"
20
+ @click="!state.config.disabled?state.visible = true:state.visible=false"
20
21
  class="ht-contnet">
21
22
  <el-input readonly
22
23
  @blur="blurInput"
24
+ :style="`width:${inputWidth}px`"
23
25
  :placeholder="placeholder"
24
26
  :disabled="state.config.disabled"
25
27
  @focus="focusInput"
@@ -85,6 +87,8 @@ export default class HtSelectTable extends Vue {
85
87
  @Prop() comStyle!: string;
86
88
  @Prop() config!: string;
87
89
  @Prop() width!: number;
90
+ /** 输入框宽度 */
91
+ @Prop() inputWidth!: number;
88
92
  /** 同原生placeholder */
89
93
  @Prop() placeholder!: string;
90
94
  /**搜索框 同原生placeholder */
@@ -152,17 +156,20 @@ export default class HtSelectTable extends Vue {
152
156
 
153
157
  this.$emit("change", row, type);
154
158
  if (type) {
159
+ (this.$refs["elPopver"] as any).doToggle();
155
160
  this.state.visible = false;
156
161
  }
157
162
  }
158
163
  /** 隐藏弹窗 */
159
164
  hide() {
160
165
  this.state.icon = "el-icon-arrow-down";
166
+ this.state.visible = true;
161
167
  this.state.show = false;
162
168
  }
163
169
  /** 焦点移入移出 */
164
170
  blurInput() {
165
171
  const { show } = this.state;
172
+ this.state.visible = true;
166
173
  this.state.icon = show ? "el-icon-arrow-up" : "el-icon-arrow-down";
167
174
  }
168
175
 
@@ -175,6 +182,7 @@ export default class HtSelectTable extends Vue {
175
182
  //
176
183
  if (!this.state.config.disabled) {
177
184
  const ref: any = this.$refs[this.state.config.key || "ht-table"];
185
+ console.log("333");
178
186
  this.state.visible = false;
179
187
  ref.clearCheck();
180
188
  }
@@ -4,16 +4,21 @@
4
4
  * @Author: hutao
5
5
  * @Date: 2021-10-21 10:08:41
6
6
  * @LastEditors: hutao
7
- * @LastEditTime: 2021-12-01 11:22:56
7
+ * @LastEditTime: 2021-12-09 17:27:01
8
8
  */
9
9
 
10
10
  // 导入组件
11
11
  import { VueConstructor } from 'vue'
12
+ /** 下拉table选择控件 */
12
13
  import HtSelectTable from './SelectTable/index'
14
+ /** 分页组装配件 */
15
+ import HtPagination from './PageInfo/index'
16
+ import HtTable from './HtTable/index'
13
17
 
14
18
  // 存储组件列表
15
19
  const components = [
16
- HtSelectTable
20
+ HtSelectTable,
21
+ HtPagination, HtTable
17
22
  ]
18
23
  // 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
19
24
  const install = function (Vue: any) {
@@ -31,6 +36,6 @@ export default {
31
36
  // 导出的对象必须具有 install,才能被 Vue.use() 方法安装
32
37
  install,
33
38
  // 以下是具体的组件列表
34
- HtSelectTable
39
+ HtSelectTable, HtPagination, HtTable
35
40
  }
36
41
 
@@ -4,7 +4,7 @@
4
4
  * @Author: hutao
5
5
  * @Date: 2021-10-25 17:05:17
6
6
  * @LastEditors: hutao
7
- * @LastEditTime: 2021-11-14 17:30:49
7
+ * @LastEditTime: 2021-12-09 16:07:41
8
8
  */
9
9
  /** 初始的默认条数 */
10
10
  export const defalutPageSize = 10
@@ -48,8 +48,26 @@ export interface ConfigProp {
48
48
  };
49
49
 
50
50
  }
51
+ /** 参考element Table https://element.eleme.cn/#/zh-CN/component/table */
51
52
  export interface Column {
53
+
52
54
  key: string;
53
55
  title: string;
54
- width?: number;
56
+ width?: number | string;
57
+ minWidth?: number | string;
58
+ fixed?: 'left' | 'rigth' | boolean;
59
+ sortable?: 'custom' | boolean;
60
+ resizable?: boolean;
61
+ align?: 'left' | 'right' | 'center';
62
+ headerAlign?: 'left' | 'right' | 'center';
63
+ className?: string;
64
+ labelClassName?: string;
65
+ /** table头是否使用slot */
66
+ headerSlot?: boolean;
67
+ }
68
+ export interface PageInfoType {
69
+ currentPage: number;
70
+ pageSize: number;
71
+ skipCount: number;
72
+ totalCount: number;
55
73
  }
@@ -1,3 +1,78 @@
1
+ <!--
2
+ * @Descripttion:
3
+ * @version:
4
+ * @Author: hutao
5
+ * @Date: 2021-11-15 14:41:40
6
+ * @LastEditors: hutao
7
+ * @LastEditTime: 2021-12-09 16:47:22
8
+ -->
1
9
  <template>
2
- <div>模板框架</div>
10
+ <div>
11
+ <HtTable :data="state.data"
12
+ @onchange="test"
13
+ :height="200"
14
+ :columns="state.columns">
15
+ <div slot="sex"
16
+ slot-scope="{row}">{{row.sex?'男':'女'}}</div>
17
+ <div slot="age"
18
+ slot-scope="{row}">
19
+ <el-tag>{{row.age}}</el-tag>
20
+ </div>
21
+ <div slot="header_name">测试名字</div>
22
+ <!-- <div slot="header_age"
23
+ slot-scope="{column,$index}">
24
+ <el-tag>年龄{{$index}}</el-tag>
25
+ </div> -->
26
+ </HtTable>
27
+ </div>
3
28
  </template>
29
+ <script lang='ts'>
30
+ import { Component, Vue } from "vue-property-decorator";
31
+ import HtTable from "@/packages/HtTable/index.vue";
32
+ interface State {
33
+ /** 数据状态 */
34
+ loading: boolean;
35
+ columns: any;
36
+ data: any;
37
+ }
38
+ @Component({
39
+ components: {
40
+ HtTable,
41
+ },
42
+ })
43
+ export default class Index extends Vue {
44
+ /** 数据 */
45
+ state: State = {
46
+ loading: false,
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 },
52
+ ],
53
+ columns: [
54
+ {
55
+ title: "姓名",
56
+ key: "name",
57
+ width: "300px",
58
+ },
59
+ {
60
+ title: "age",
61
+ key: "age",
62
+ },
63
+ {
64
+ title: "性别",
65
+ key: "sex",
66
+ },
67
+ ],
68
+ };
69
+ /** 生命周期 */
70
+ /** 方法 */
71
+ test() {
72
+ //console.log("ee", e);
73
+ }
74
+ /** 监听 */
75
+ /** 计算属性 */
76
+ }
77
+ </script>
78
+ <style lang='scss' scoped></style>