htui-yllkbz 1.1.10 → 1.1.14
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 +65847 -4875
- package/lib/htui.common.js.gz +0 -0
- package/lib/htui.umd.js +65841 -4869
- package/lib/htui.umd.js.gz +0 -0
- package/lib/htui.umd.min.js +19 -4
- package/lib/htui.umd.min.js.gz +0 -0
- package/package.json +3 -2
- package/src/App.vue +68 -0
- package/src/main.ts +63 -0
- package/src/packages/SelectTable/CommonTable.vue +241 -0
- package/src/packages/SelectTable/index.ts +15 -0
- package/src/packages/SelectTable/index.vue +190 -0
- package/src/packages/index.ts +35 -0
- package/src/packages/style.scss +13 -0
- package/src/packages/type.ts +55 -0
- package/src/plugins/api.ts +0 -0
- package/src/router/index.ts +41 -0
- package/src/shims-tsx.d.ts +13 -0
- package/src/shims-vue.d.ts +4 -0
- package/src/store/baseData.ts +44 -0
- package/src/store/index.ts +14 -0
- package/src/styles.scss +6 -0
- package/src/views/About.vue +3 -0
- package/src/views/Index.vue +230 -0
package/lib/htui.umd.min.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "htui-yllkbz",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.14",
|
|
4
4
|
"typings": "types/index.d.ts",
|
|
5
5
|
"main": "lib/htui.common.js",
|
|
6
6
|
"style": "lib/htui.css",
|
|
7
7
|
"private": false,
|
|
8
8
|
"files": [
|
|
9
9
|
"lib/**",
|
|
10
|
-
"types"
|
|
10
|
+
"types",
|
|
11
|
+
"src"
|
|
11
12
|
],
|
|
12
13
|
"scripts": {
|
|
13
14
|
"serve": "vue-cli-service serve",
|
package/src/App.vue
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Descripttion:
|
|
3
|
+
* @version:
|
|
4
|
+
* @Author: hutao
|
|
5
|
+
* @Date: 2021-11-15 14:41:40
|
|
6
|
+
* @LastEditors: hutao
|
|
7
|
+
* @LastEditTime: 2021-11-25 11:45:18
|
|
8
|
+
-->
|
|
9
|
+
<template>
|
|
10
|
+
<div id="app">
|
|
11
|
+
<SelectTable :width="200"
|
|
12
|
+
:columns="[]"
|
|
13
|
+
:config="JSON.stringify({
|
|
14
|
+
key: 'code',
|
|
15
|
+
disabled:false,
|
|
16
|
+
clearable:true,
|
|
17
|
+
value:undefined,
|
|
18
|
+
name:'id',
|
|
19
|
+
ajax:{
|
|
20
|
+
type:'get',
|
|
21
|
+
url: '/asset-model/api/app/asset-model-instance',
|
|
22
|
+
},
|
|
23
|
+
text:'name',
|
|
24
|
+
})"></SelectTable>
|
|
25
|
+
<router-view></router-view>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script lang="ts">
|
|
30
|
+
import { Component, Vue } from "vue-property-decorator";
|
|
31
|
+
import SelectTable from "@/packages/SelectTable/index.vue";
|
|
32
|
+
@Component({
|
|
33
|
+
components: { SelectTable },
|
|
34
|
+
})
|
|
35
|
+
export default class App extends Vue {
|
|
36
|
+
/** 生命周期 */
|
|
37
|
+
created() {
|
|
38
|
+
// 动态加载引用文件
|
|
39
|
+
const files = this.$store.getters.getBaseData("files");
|
|
40
|
+
const filesKeys = Object.keys(files);
|
|
41
|
+
let heatStr = document.getElementsByTagName("head")[0].innerHTML;
|
|
42
|
+
filesKeys.forEach((cur) => {
|
|
43
|
+
const src = files[cur];
|
|
44
|
+
if (src && /\.css$/.test(src.toString())) {
|
|
45
|
+
heatStr += `<link rel="stylesheet" href="${src}?v=${Date.now()}" />`;
|
|
46
|
+
}
|
|
47
|
+
if (src && /\.ico$/.test(src.toString())) {
|
|
48
|
+
heatStr += `<link rel="icon" href="${src}">`;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
document.getElementsByTagName("head")[0].innerHTML = heatStr;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<style lang="scss">
|
|
57
|
+
#app {
|
|
58
|
+
font-family: "SourceHanSansCN-Normal", "Avenir", Helvetica, Arial, sans-serif;
|
|
59
|
+
-webkit-font-smoothing: antialiased;
|
|
60
|
+
-moz-osx-font-smoothing: grayscale;
|
|
61
|
+
color: #505050;
|
|
62
|
+
font-size: 14px;
|
|
63
|
+
}
|
|
64
|
+
body {
|
|
65
|
+
font-family: "SourceHanSansCN-Normal";
|
|
66
|
+
font-size: 14px;
|
|
67
|
+
}
|
|
68
|
+
</style>
|
package/src/main.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import Vue from "vue";
|
|
2
|
+
import App from "./App.vue";
|
|
3
|
+
import VueRouter from "vue-router";
|
|
4
|
+
import routes from "./router";
|
|
5
|
+
import store from "./store";
|
|
6
|
+
import ElementUI from "element-ui";
|
|
7
|
+
import "./styles.scss";
|
|
8
|
+
import { _axios, baseConfig } from "vue-kst-auth";
|
|
9
|
+
// import axios from "axios";
|
|
10
|
+
Vue.use(ElementUI);
|
|
11
|
+
Vue.use(VueRouter);
|
|
12
|
+
|
|
13
|
+
/** 设置axios返回类型 */
|
|
14
|
+
Vue.config.productionTip = false;
|
|
15
|
+
/** 获取配置文件 */
|
|
16
|
+
_axios.get(`${process.env.BASE_URL}/baseConfig.json`).then((res: any) => {
|
|
17
|
+
/** 将配置文件转换赋值 */
|
|
18
|
+
store.commit("setBaseData", res.data);
|
|
19
|
+
|
|
20
|
+
const router = new VueRouter({
|
|
21
|
+
mode: "history",
|
|
22
|
+
base: res.data.baseUrl,
|
|
23
|
+
routes
|
|
24
|
+
});
|
|
25
|
+
router.beforeEach((to: any, from: any, next: any) => {
|
|
26
|
+
/* 路由发生变化修改页面meta */
|
|
27
|
+
if (to.meta.content) {
|
|
28
|
+
const head = document.getElementsByTagName("head");
|
|
29
|
+
const meta = document.createElement("meta");
|
|
30
|
+
meta.content = to.meta.content;
|
|
31
|
+
head[0].appendChild(meta);
|
|
32
|
+
}
|
|
33
|
+
/* 路由发生变化修改页面title */
|
|
34
|
+
if (to.meta.title) {
|
|
35
|
+
document.title = to.meta.title;
|
|
36
|
+
}
|
|
37
|
+
if (baseConfig.getLoginState() || /login/.test(to.path)) {
|
|
38
|
+
// 授权配置
|
|
39
|
+
baseConfig.setOAuthConfig(store.getters.getBaseData("oAuthConfig"));
|
|
40
|
+
baseConfig.setLoginTitle(store.getters.getBaseData("enterpriseName")); // 企业名称
|
|
41
|
+
// 设置验证租户有效性地址
|
|
42
|
+
baseConfig.setIsTenantAvailable(
|
|
43
|
+
store.getters.getBaseData("isTenantAvailable")
|
|
44
|
+
);
|
|
45
|
+
// 设置登录地址
|
|
46
|
+
baseConfig.setLoginUrl(store.getters.getBaseData("loginUrl"));
|
|
47
|
+
// 设置获取当前登录租户相关信息地址
|
|
48
|
+
baseConfig.setcurrentLoginInfoUrl(
|
|
49
|
+
store.getters.getBaseData("currentLoginInfoUrl")
|
|
50
|
+
);
|
|
51
|
+
next();
|
|
52
|
+
} else {
|
|
53
|
+
next(false);
|
|
54
|
+
next("/login");
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
new Vue({
|
|
59
|
+
router,
|
|
60
|
+
store,
|
|
61
|
+
render: h => h(App)
|
|
62
|
+
}).$mount("#app");
|
|
63
|
+
});
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Descripttion:
|
|
3
|
+
* @version:
|
|
4
|
+
* @Author: hutao
|
|
5
|
+
* @Date: 2021-11-15 14:50:56
|
|
6
|
+
* @LastEditors: hutao
|
|
7
|
+
* @LastEditTime: 2021-11-25 11:20:02
|
|
8
|
+
-->
|
|
9
|
+
<!--
|
|
10
|
+
* @Descripttion:
|
|
11
|
+
* @version:
|
|
12
|
+
* @Author: hutao
|
|
13
|
+
* @Date: 2021-11-11 11:23:24
|
|
14
|
+
* @LastEditors: hutao
|
|
15
|
+
* @LastEditTime: 2021-11-14 16:03:32
|
|
16
|
+
-->
|
|
17
|
+
<template>
|
|
18
|
+
<div v-loading="state.loading">
|
|
19
|
+
<header>
|
|
20
|
+
<el-input :placeholder="searchPlaceholder||请输入关键字查询"
|
|
21
|
+
class="htui-search"
|
|
22
|
+
v-model="state.filterData.Filter"></el-input>
|
|
23
|
+
</header>
|
|
24
|
+
<article>
|
|
25
|
+
<el-table ref="comTable"
|
|
26
|
+
:height="confige.table&&confige.table.height?confige.table.height:250"
|
|
27
|
+
:row-key="confige.table&&confige.table.rowkey?confige.table.rowkey:'id'"
|
|
28
|
+
:data="dataSource"
|
|
29
|
+
tooltip-effect="dark"
|
|
30
|
+
@row-click="rowClick"
|
|
31
|
+
style="width: 100%">
|
|
32
|
+
<el-table-column width="55">
|
|
33
|
+
<template slot-scope="{row}">
|
|
34
|
+
<el-checkbox @click.native.prevent
|
|
35
|
+
:value="state.checkObj&&state.checkObj.id===row.id"></el-checkbox>
|
|
36
|
+
</template>
|
|
37
|
+
</el-table-column>
|
|
38
|
+
<el-table-column label="序号"
|
|
39
|
+
width="55">
|
|
40
|
+
<template slot-scope="scope">
|
|
41
|
+
{{(state.filterData.currentPage-1)*state.filterData.MaxResultCount+(scope.$index+1)}}
|
|
42
|
+
</template>
|
|
43
|
+
</el-table-column>
|
|
44
|
+
<el-table-column :label="item.title"
|
|
45
|
+
:key='item.key'
|
|
46
|
+
v-for="item in columns"
|
|
47
|
+
:show-overflow-tooltip="true"
|
|
48
|
+
:prop="item.key"
|
|
49
|
+
:width="item.width||120">
|
|
50
|
+
</el-table-column>
|
|
51
|
+
|
|
52
|
+
</el-table>
|
|
53
|
+
</article>
|
|
54
|
+
<footer>
|
|
55
|
+
<el-row>
|
|
56
|
+
<el-col :span="24">
|
|
57
|
+
<p style="width:90px;float:left">共{{dataSource.length}}条</p>
|
|
58
|
+
|
|
59
|
+
<el-pagination v-if="false"
|
|
60
|
+
@current-change="handleCurrentChange"
|
|
61
|
+
@size-change="handelSizeChange"
|
|
62
|
+
:page-sizes="[10, 20, 50, 100]"
|
|
63
|
+
:current-page="state.filterData.currentPage"
|
|
64
|
+
:page-size="state.filterData.MaxResultCount"
|
|
65
|
+
layout="total, sizes, prev, pager, next, jumper"
|
|
66
|
+
:total="state.filterData.totalCount">
|
|
67
|
+
</el-pagination>
|
|
68
|
+
</el-col>
|
|
69
|
+
</el-row>
|
|
70
|
+
</footer>
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|
|
73
|
+
<script lang='ts'>
|
|
74
|
+
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
75
|
+
import { _axios } from "vue-kst-auth";
|
|
76
|
+
import { AxiosRequestConfig } from "axios";
|
|
77
|
+
import { Column, ConfigProp } from "@/packages/type";
|
|
78
|
+
interface State {
|
|
79
|
+
/** 数据状态 */
|
|
80
|
+
loading: boolean;
|
|
81
|
+
/** table数据 */
|
|
82
|
+
dataSource: any[];
|
|
83
|
+
/** 是否展示分页 */
|
|
84
|
+
showPage: boolean;
|
|
85
|
+
filterData: {
|
|
86
|
+
currentPage: number;
|
|
87
|
+
MaxResultCount: number;
|
|
88
|
+
SkipCount: number;
|
|
89
|
+
totalCount: number;
|
|
90
|
+
Filter: string;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
checkObj?: any;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@Component
|
|
97
|
+
export default class Index extends Vue {
|
|
98
|
+
/** 默认的table头 */
|
|
99
|
+
@Prop() columns!: Column[];
|
|
100
|
+
/** 同原生placeholder */
|
|
101
|
+
@Prop() searchPlaceholder!: string;
|
|
102
|
+
/** 相关配置信息 */
|
|
103
|
+
@Prop() confige!: ConfigProp;
|
|
104
|
+
/** 相关配置信息 */
|
|
105
|
+
@Prop() visible!: boolean;
|
|
106
|
+
/** 数据 */
|
|
107
|
+
state: State = {
|
|
108
|
+
loading: false,
|
|
109
|
+
dataSource: [],
|
|
110
|
+
showPage: true,
|
|
111
|
+
filterData: {
|
|
112
|
+
currentPage: 1,
|
|
113
|
+
Filter: "",
|
|
114
|
+
MaxResultCount: 1000,
|
|
115
|
+
SkipCount: 0,
|
|
116
|
+
totalCount: 0,
|
|
117
|
+
},
|
|
118
|
+
checkObj: undefined,
|
|
119
|
+
};
|
|
120
|
+
/** 生命周期 */
|
|
121
|
+
created() {
|
|
122
|
+
this.getDataSource();
|
|
123
|
+
}
|
|
124
|
+
/** 方法 */
|
|
125
|
+
/** 改变输入框 */
|
|
126
|
+
// handelChange() {
|
|
127
|
+
// this.state.filterData.SkipCount = 0;
|
|
128
|
+
// this.state.filterData.currentPage = 1;
|
|
129
|
+
// this.getDataSource();
|
|
130
|
+
// }
|
|
131
|
+
|
|
132
|
+
/** 用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中) */
|
|
133
|
+
rowClick(row: any) {
|
|
134
|
+
const { checkObj } = this.state;
|
|
135
|
+
if (checkObj && checkObj.id === row.id) {
|
|
136
|
+
this.state.checkObj = undefined;
|
|
137
|
+
} else {
|
|
138
|
+
this.state.checkObj = row;
|
|
139
|
+
}
|
|
140
|
+
this.$emit("callback", this.state.checkObj, "click");
|
|
141
|
+
}
|
|
142
|
+
/** 此处进行分页处理 */
|
|
143
|
+
|
|
144
|
+
topage(res: any) {
|
|
145
|
+
/** 此处不分页 */
|
|
146
|
+
if (Array.isArray(res)) {
|
|
147
|
+
this.state.dataSource = res;
|
|
148
|
+
} else if (res.items && res.items.length) {
|
|
149
|
+
this.state.dataSource = res.items;
|
|
150
|
+
this.state.filterData.totalCount = res.totalCount;
|
|
151
|
+
} else {
|
|
152
|
+
this.state.dataSource = [];
|
|
153
|
+
}
|
|
154
|
+
this.toFindData();
|
|
155
|
+
}
|
|
156
|
+
clearCheck() {
|
|
157
|
+
this.state.checkObj = undefined;
|
|
158
|
+
this.$emit("callback", this.state.checkObj);
|
|
159
|
+
}
|
|
160
|
+
/** 去查找默认值*/
|
|
161
|
+
toFindData() {
|
|
162
|
+
const { name, value } = this.confige;
|
|
163
|
+
const { dataSource } = this.state;
|
|
164
|
+
const findIndex = dataSource.findIndex(
|
|
165
|
+
(item) => item[name ?? "id"] === value
|
|
166
|
+
);
|
|
167
|
+
if (dataSource.length) {
|
|
168
|
+
this.state.checkObj = dataSource[findIndex];
|
|
169
|
+
}
|
|
170
|
+
this.$emit("callback", this.state.checkObj);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** 翻页 */
|
|
174
|
+
handleCurrentChange(val: number) {
|
|
175
|
+
this.state.filterData.currentPage = val || 1;
|
|
176
|
+
const { MaxResultCount = 0, currentPage } = this.state.filterData;
|
|
177
|
+
this.state.filterData.SkipCount = (currentPage - 1) * MaxResultCount;
|
|
178
|
+
this.getDataSource();
|
|
179
|
+
}
|
|
180
|
+
/** 更新每页条数 */
|
|
181
|
+
handelSizeChange(val: number) {
|
|
182
|
+
this.state.filterData.currentPage = 1;
|
|
183
|
+
this.state.filterData.MaxResultCount = val;
|
|
184
|
+
const { MaxResultCount = 0, currentPage } = this.state.filterData;
|
|
185
|
+
this.state.filterData.SkipCount = (currentPage - 1) * MaxResultCount;
|
|
186
|
+
this.getDataSource();
|
|
187
|
+
}
|
|
188
|
+
/** 监听 */
|
|
189
|
+
/** 计算属性 */
|
|
190
|
+
get dataSource() {
|
|
191
|
+
const { filterData, dataSource } = this.state;
|
|
192
|
+
const data = filterData.Filter;
|
|
193
|
+
return dataSource.filter((item) => JSON.stringify(item).includes(data));
|
|
194
|
+
}
|
|
195
|
+
@Watch("confige")
|
|
196
|
+
getDataSource() {
|
|
197
|
+
const { ajax } = this.confige;
|
|
198
|
+
const { type = "get", url, params, data } = ajax;
|
|
199
|
+
|
|
200
|
+
this.state.loading = true;
|
|
201
|
+
if (type === "get") {
|
|
202
|
+
const param: AxiosRequestConfig = {
|
|
203
|
+
params: { ...this.state.filterData, ...params },
|
|
204
|
+
};
|
|
205
|
+
_axios
|
|
206
|
+
.get(url, {
|
|
207
|
+
...param,
|
|
208
|
+
})
|
|
209
|
+
.then((res) => {
|
|
210
|
+
this.topage(res.data);
|
|
211
|
+
})
|
|
212
|
+
.catch(() => {
|
|
213
|
+
this.$notify.error("请求失败");
|
|
214
|
+
})
|
|
215
|
+
.finally(() => {
|
|
216
|
+
this.state.loading = false;
|
|
217
|
+
});
|
|
218
|
+
} else {
|
|
219
|
+
const param: AxiosRequestConfig = {
|
|
220
|
+
params: { ...this.state.filterData, ...params },
|
|
221
|
+
data: { ...this.state.filterData, ...data },
|
|
222
|
+
};
|
|
223
|
+
_axios
|
|
224
|
+
.post(url, {
|
|
225
|
+
...param,
|
|
226
|
+
})
|
|
227
|
+
.then((res) => {
|
|
228
|
+
this.topage(res.data);
|
|
229
|
+
})
|
|
230
|
+
.catch(() => {
|
|
231
|
+
this.$notify.error("请求失败");
|
|
232
|
+
})
|
|
233
|
+
.finally(() => {
|
|
234
|
+
this.state.loading = false;
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
//this._ax --asset-model/api/app/asset-model-instance
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
</script>
|
|
241
|
+
<style lang='scss' scoped></style>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Descripttion:
|
|
3
|
+
* @version:
|
|
4
|
+
* @Author: hutao
|
|
5
|
+
* @Date: 2021-11-15 15:00:57
|
|
6
|
+
* @LastEditors: hutao
|
|
7
|
+
* @LastEditTime: 2021-11-15 15:48:37
|
|
8
|
+
*/
|
|
9
|
+
import SelectTable from "./index.vue";
|
|
10
|
+
|
|
11
|
+
(SelectTable as any).install = function (Vue: any) {
|
|
12
|
+
|
|
13
|
+
Vue.component(SelectTable.name, SelectTable);
|
|
14
|
+
};
|
|
15
|
+
export default SelectTable;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Descripttion:
|
|
3
|
+
* @version:
|
|
4
|
+
* @Author: hutao
|
|
5
|
+
* @Date: 2021-11-11 11:06:51
|
|
6
|
+
* @LastEditors: hutao
|
|
7
|
+
* @LastEditTime: 2021-11-29 18:25:09
|
|
8
|
+
-->
|
|
9
|
+
<template>
|
|
10
|
+
<el-popover placement="bottom"
|
|
11
|
+
title=""
|
|
12
|
+
class="ht-popover"
|
|
13
|
+
v-model="state.visible"
|
|
14
|
+
:width="width||600"
|
|
15
|
+
@show="show"
|
|
16
|
+
@hide="hide"
|
|
17
|
+
trigger="click">
|
|
18
|
+
<div slot="reference"
|
|
19
|
+
@click="!state.config.disabled?state.visible = !state.visible:state.visible=false"
|
|
20
|
+
class="ht-contnet">
|
|
21
|
+
<el-input readonly
|
|
22
|
+
@blur="blurInput"
|
|
23
|
+
:placeholder="placeholder"
|
|
24
|
+
:disabled="state.config.disabled"
|
|
25
|
+
@focus="focusInput"
|
|
26
|
+
:suffix-icon="state.icon"
|
|
27
|
+
v-model="state.name"></el-input>
|
|
28
|
+
<el-button type="text"
|
|
29
|
+
class="ht-close"
|
|
30
|
+
v-if="state.name&&state.config.clearable"
|
|
31
|
+
@click.native.stop="clear">
|
|
32
|
+
<div><i class="el-icon-circle-close"></i></div>
|
|
33
|
+
</el-button>
|
|
34
|
+
</div>
|
|
35
|
+
<CommonTable @callback="callback"
|
|
36
|
+
:searchPlaceholder="searchPlaceholder"
|
|
37
|
+
:columns="state.columns"
|
|
38
|
+
:visible.sync="state.visible"
|
|
39
|
+
:ref="state.config.key||'ht-table'"
|
|
40
|
+
:confige="state.config"></CommonTable>
|
|
41
|
+
</el-popover>
|
|
42
|
+
</template>
|
|
43
|
+
<script lang='ts'>
|
|
44
|
+
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
45
|
+
import CommonTable from "@/packages/SelectTable/CommonTable.vue";
|
|
46
|
+
import { ConfigProp } from "@/packages/type";
|
|
47
|
+
import "@/packages/style.scss";
|
|
48
|
+
import ElementUI from "element-ui";
|
|
49
|
+
Vue.use(ElementUI);
|
|
50
|
+
interface State {
|
|
51
|
+
/** 数据状态 */
|
|
52
|
+
loading: boolean;
|
|
53
|
+
/** 输入框内容 */
|
|
54
|
+
name?: string;
|
|
55
|
+
/** icon图标 */
|
|
56
|
+
icon: string;
|
|
57
|
+
/** 是否展示弹窗 */
|
|
58
|
+
show: boolean;
|
|
59
|
+
columns?: Column[];
|
|
60
|
+
visible: boolean;
|
|
61
|
+
config: ConfigProp;
|
|
62
|
+
}
|
|
63
|
+
interface Confige {
|
|
64
|
+
url: string;
|
|
65
|
+
type: "get" | "post";
|
|
66
|
+
/* 展示的字段 */
|
|
67
|
+
text: string;
|
|
68
|
+
/** 默认值 */
|
|
69
|
+
value: string;
|
|
70
|
+
columns: Column[] | undefined;
|
|
71
|
+
}
|
|
72
|
+
interface Column {
|
|
73
|
+
key: string;
|
|
74
|
+
title: string;
|
|
75
|
+
width?: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@Component({
|
|
79
|
+
components: {
|
|
80
|
+
CommonTable,
|
|
81
|
+
},
|
|
82
|
+
})
|
|
83
|
+
export default class SelectTable extends Vue {
|
|
84
|
+
/** 通用样式 */
|
|
85
|
+
@Prop() comStyle!: string;
|
|
86
|
+
@Prop() config!: string;
|
|
87
|
+
@Prop() width!: number;
|
|
88
|
+
/** 同原生placeholder */
|
|
89
|
+
@Prop() placeholder!: string;
|
|
90
|
+
/**搜索框 同原生placeholder */
|
|
91
|
+
@Prop() searchPlaceholder!: string;
|
|
92
|
+
@Prop() columns!: Column[] | undefined;
|
|
93
|
+
|
|
94
|
+
/** 数据 */
|
|
95
|
+
state: State = {
|
|
96
|
+
config: {
|
|
97
|
+
key: "",
|
|
98
|
+
disabled: false,
|
|
99
|
+
clearable: false,
|
|
100
|
+
value: "",
|
|
101
|
+
name: "",
|
|
102
|
+
ajax: {
|
|
103
|
+
url: "",
|
|
104
|
+
params: {},
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
text: undefined,
|
|
108
|
+
},
|
|
109
|
+
visible: false,
|
|
110
|
+
loading: false,
|
|
111
|
+
name: "",
|
|
112
|
+
show: false,
|
|
113
|
+
icon: "el-icon-arrow-down",
|
|
114
|
+
columns: [
|
|
115
|
+
{
|
|
116
|
+
key: "code",
|
|
117
|
+
title: "编码",
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
key: "name",
|
|
121
|
+
title: "名称",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
key: "description",
|
|
125
|
+
title: "描述",
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
};
|
|
129
|
+
/** 生命周期 */
|
|
130
|
+
/** 方法 */
|
|
131
|
+
created() {
|
|
132
|
+
this.state.config = JSON.parse(this.config);
|
|
133
|
+
this.columns ? (this.state.columns = this.columns) : "";
|
|
134
|
+
//this.state.columns = this.columns??;
|
|
135
|
+
}
|
|
136
|
+
/** 显示弹层 */
|
|
137
|
+
show() {
|
|
138
|
+
this.state.icon = "el-icon-arrow-up";
|
|
139
|
+
this.state.show = true;
|
|
140
|
+
|
|
141
|
+
//
|
|
142
|
+
}
|
|
143
|
+
/** 回调 */
|
|
144
|
+
callback(row: any | undefined, type?: string) {
|
|
145
|
+
const { config } = this.state;
|
|
146
|
+
const text = config.text || "name";
|
|
147
|
+
if (row) {
|
|
148
|
+
this.state.name = row[text];
|
|
149
|
+
} else {
|
|
150
|
+
this.state.name = undefined;
|
|
151
|
+
}
|
|
152
|
+
// console.log("change", row, type);
|
|
153
|
+
this.$emit("change", row, type);
|
|
154
|
+
if (type) {
|
|
155
|
+
this.state.visible = false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/** 隐藏弹窗 */
|
|
159
|
+
hide() {
|
|
160
|
+
this.state.icon = "el-icon-arrow-down";
|
|
161
|
+
this.state.show = false;
|
|
162
|
+
}
|
|
163
|
+
/** 焦点移入移出 */
|
|
164
|
+
blurInput() {
|
|
165
|
+
const { show } = this.state;
|
|
166
|
+
this.state.icon = show ? "el-icon-arrow-up" : "el-icon-arrow-down";
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
focusInput() {
|
|
170
|
+
this.state.icon = "el-icon-circle-close";
|
|
171
|
+
this.state.visible = !this.state.config.disabled;
|
|
172
|
+
}
|
|
173
|
+
/** 清除内容 */
|
|
174
|
+
clear() {
|
|
175
|
+
//
|
|
176
|
+
if (!this.state.config.disabled) {
|
|
177
|
+
const ref: any = this.$refs[this.state.config.key || "ht-table"];
|
|
178
|
+
this.state.visible = false;
|
|
179
|
+
ref.clearCheck();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/** 监听 */
|
|
183
|
+
@Watch("config")
|
|
184
|
+
watchConfig(value: string) {
|
|
185
|
+
this.state.config = JSON.parse(value);
|
|
186
|
+
}
|
|
187
|
+
/** 计算属性 */
|
|
188
|
+
}
|
|
189
|
+
</script>
|
|
190
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Descripttion:
|
|
3
|
+
* @version:
|
|
4
|
+
* @Author: hutao
|
|
5
|
+
* @Date: 2021-10-21 10:08:41
|
|
6
|
+
* @LastEditors: hutao
|
|
7
|
+
* @LastEditTime: 2021-11-15 15:06:00
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// 导入开关选择组件
|
|
11
|
+
import selectTable from './SelectTable/index'
|
|
12
|
+
|
|
13
|
+
// 存储组件列表
|
|
14
|
+
const components = [
|
|
15
|
+
selectTable
|
|
16
|
+
]
|
|
17
|
+
// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
|
|
18
|
+
const install = function (Vue: any) {
|
|
19
|
+
// 判断是否安装
|
|
20
|
+
if ((install as any).installed) return
|
|
21
|
+
// 遍历注册全局组件
|
|
22
|
+
components.map(component => Vue.component(component.name, component))
|
|
23
|
+
}
|
|
24
|
+
// 判断是否是直接引入文件
|
|
25
|
+
if (typeof window !== 'undefined' && window.Vue) {
|
|
26
|
+
install(window.Vue)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
// 导出的对象必须具有 install,才能被 Vue.use() 方法安装
|
|
31
|
+
install,
|
|
32
|
+
// 以下是具体的组件列表
|
|
33
|
+
selectTable
|
|
34
|
+
}
|
|
35
|
+
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Descripttion:
|
|
3
|
+
* @version:
|
|
4
|
+
* @Author: hutao
|
|
5
|
+
* @Date: 2021-10-25 17:05:17
|
|
6
|
+
* @LastEditors: hutao
|
|
7
|
+
* @LastEditTime: 2021-11-14 17:30:49
|
|
8
|
+
*/
|
|
9
|
+
/** 初始的默认条数 */
|
|
10
|
+
export const defalutPageSize = 10
|
|
11
|
+
/** 分页显示传入的参数
|
|
12
|
+
* @param currentPage(当前页码)
|
|
13
|
+
* @param pageSize(每页条数)
|
|
14
|
+
* @param total(总条数)
|
|
15
|
+
*/
|
|
16
|
+
export interface CurrentType {
|
|
17
|
+
currentPage: number;
|
|
18
|
+
pageSize: number;
|
|
19
|
+
total: number;
|
|
20
|
+
}
|
|
21
|
+
export interface ConfigProp {
|
|
22
|
+
/** 展示的相关列表code */
|
|
23
|
+
key: string;
|
|
24
|
+
/** 是否可用 */
|
|
25
|
+
disabled: boolean;
|
|
26
|
+
/** 清除内容 */
|
|
27
|
+
clearable?: boolean;
|
|
28
|
+
/** 默认值 */
|
|
29
|
+
value?: string; //code:"344"
|
|
30
|
+
/** value对应的匹配值 */
|
|
31
|
+
name?: string;
|
|
32
|
+
ajax: {
|
|
33
|
+
/** 请求地址 */
|
|
34
|
+
url: string;
|
|
35
|
+
/** 请求类型 */
|
|
36
|
+
type?: "get" | "post";
|
|
37
|
+
/** 头部参数 */
|
|
38
|
+
params: any;
|
|
39
|
+
/** body参数 */
|
|
40
|
+
data?: any;
|
|
41
|
+
};
|
|
42
|
+
/** 展示的内容 */
|
|
43
|
+
text?: string | number;
|
|
44
|
+
table?: {
|
|
45
|
+
rowkey?: string;
|
|
46
|
+
height?: number;
|
|
47
|
+
columns: Column[] | undefined;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
export interface Column {
|
|
52
|
+
key: string;
|
|
53
|
+
title: string;
|
|
54
|
+
width?: number;
|
|
55
|
+
}
|
|
File without changes
|