@ajaxjs/ui 1.2.4 → 1.2.6
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/README.md +16 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/index.ts +3 -1
- package/dist/table-selector/table-selector.vue +180 -0
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
|
+
[](https://www.npmjs.com/package/@ajaxjs/ui)
|
|
2
|
+
[](https://vuejs.org)
|
|
3
|
+
[](https://www.typescriptlang.org/)
|
|
4
|
+
[](http://www.apache.org/licenses/LICENSE-2.0.txt)
|
|
5
|
+
[](mailto:frank@ajaxjs.com)
|
|
6
|
+
[](https://shang.qq.com/wpa/qunwpa?idkey=3877893a4ed3a5f0be01e809e7ac120e346102bd550deb6692239bb42de38e22)
|
|
7
|
+
|
|
1
8
|
# Widgets based on iView.js
|
|
2
9
|
|
|
3
10
|
for Vue2 & iView.js v2
|
|
4
11
|
|
|
12
|
+
NPM: https://www.npmjs.com/package/@ajaxjs/ui.
|
|
13
|
+
|
|
14
|
+
```shell
|
|
15
|
+
npm i @ajaxjs/ui # install
|
|
16
|
+
npm run dev # do coding
|
|
17
|
+
npm run build # output js
|
|
18
|
+
npm run release # deploy to NPM
|
|
19
|
+
```
|
|
20
|
+
|
|
5
21
|
## API Selector API 选择器
|
|
6
22
|
|
|
7
23
|
## API Helper 可视化 HTTP 请求工具
|
package/dist/index.d.ts
CHANGED
|
@@ -36,5 +36,19 @@ declare const _default: {
|
|
|
36
36
|
copyBeanClean(bean: {}): {};
|
|
37
37
|
};
|
|
38
38
|
iViewListCommon: import("vue").VueConstructor<iViewListCommon<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => iViewListCommon<Record<string, any>, Record<string, any>, never, never, any>>>;
|
|
39
|
+
DataSource: {
|
|
40
|
+
data(): {};
|
|
41
|
+
mounted(): void;
|
|
42
|
+
methods: {
|
|
43
|
+
active(item: any): void;
|
|
44
|
+
getList(cb: any): void;
|
|
45
|
+
add(): void;
|
|
46
|
+
create(): void;
|
|
47
|
+
update(): void;
|
|
48
|
+
del(id: any, name: any): void;
|
|
49
|
+
test(): void;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
TableSelector: import("vue").VueConstructor<iViewListCommon<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => iViewListCommon<Record<string, any>, Record<string, any>, never, never, any>>>;
|
|
39
53
|
};
|
|
40
54
|
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -10,10 +10,12 @@ const list_1 = __importDefault(require("./iView-ext/fast-iview-table/list"));
|
|
|
10
10
|
const fast_iview_table_vue_1 = __importDefault(require("./iView-ext/fast-iview-table/fast-iview-table.vue"));
|
|
11
11
|
const index_vue_1 = __importDefault(require("./api-selector/index.vue"));
|
|
12
12
|
const index_vue_2 = __importDefault(require("./api-helper/index.vue"));
|
|
13
|
+
const data_source_1 = __importDefault(require("./data-source/data-source"));
|
|
14
|
+
const table_selector_vue_1 = __importDefault(require("./table-selector/table-selector.vue"));
|
|
13
15
|
/**
|
|
14
16
|
* 暴露各个组件
|
|
15
17
|
*/
|
|
16
18
|
exports.default = {
|
|
17
|
-
ApiHelper: index_vue_2.default, ApiSelector: index_vue_1.default, Fast_iViewTable: list_1.default, iViewListCommon: fast_iview_table_vue_1.default
|
|
19
|
+
ApiHelper: index_vue_2.default, ApiSelector: index_vue_1.default, Fast_iViewTable: list_1.default, iViewListCommon: fast_iview_table_vue_1.default, DataSource: data_source_1.default, TableSelector: table_selector_vue_1.default
|
|
18
20
|
};
|
|
19
21
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wCAAwC;AACxC,kDAAkD;;;;;AAElD,6EAAgE;AAChE,6GAAgF;AAChF,yEAAmD;AACnD,uEAA+C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,wCAAwC;AACxC,kDAAkD;;;;;AAElD,6EAAgE;AAChE,6GAAgF;AAChF,yEAAmD;AACnD,uEAA+C;AAC/C,4EAAmD;AACnD,6FAAgE;AAEhE;;GAEG;AACH,kBAAe;IACX,SAAS,EAAT,mBAAS,EAAE,WAAW,EAAX,mBAAW,EAAE,eAAe,EAAf,cAAe,EAAE,eAAe,EAAf,8BAAe,EAAE,UAAU,EAAV,qBAAU,EAAC,aAAa,EAAb,4BAAa;CACrF,CAAC"}
|
package/dist/index.ts
CHANGED
|
@@ -6,10 +6,12 @@ import Fast_iViewTable from './iView-ext/fast-iview-table/list';
|
|
|
6
6
|
import iViewListCommon from './iView-ext/fast-iview-table/fast-iview-table.vue';
|
|
7
7
|
import ApiSelector from './api-selector/index.vue';
|
|
8
8
|
import ApiHelper from './api-helper/index.vue';
|
|
9
|
+
import DataSource from './data-source/data-source';
|
|
10
|
+
import TableSelector from './table-selector/table-selector.vue';
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* 暴露各个组件
|
|
12
14
|
*/
|
|
13
15
|
export default {
|
|
14
|
-
ApiHelper, ApiSelector, Fast_iViewTable, iViewListCommon
|
|
16
|
+
ApiHelper, ApiSelector, Fast_iViewTable, iViewListCommon, DataSource,TableSelector
|
|
15
17
|
};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="table-selector">
|
|
3
|
+
<Row style="margin:20px 0;" type="flex" justify="center" align="middle">
|
|
4
|
+
<i-Col v-if="isCrossDb" span="6" style="padding-right:10px;">
|
|
5
|
+
<i-Select placeholder="请选择数据库名" v-model="databaseName">
|
|
6
|
+
<i-Option v-for="d in databaseList" :key="d" :value="d">{{d}}</i-Option>
|
|
7
|
+
</i-Select>
|
|
8
|
+
</i-Col>
|
|
9
|
+
<i-Col :span="isCrossDb ? 6 : 12">
|
|
10
|
+
<i-Input search enter-button placeholder="按表名模糊搜索" @on-keyup="search" ref="inputEl"></i-Input>
|
|
11
|
+
</i-Col>
|
|
12
|
+
<i-Col span="12">
|
|
13
|
+
<a @click="resetData">重置</a>
|
|
14
|
+
</i-Col>
|
|
15
|
+
</Row>
|
|
16
|
+
|
|
17
|
+
<i-Table :columns="list_column" :data="data" width="100%" @on-selection-change="onSelect" max-height="300" :loading="loading" class="table-selector-table">
|
|
18
|
+
<template slot-scope="{row}" slot="select">
|
|
19
|
+
<a @click="$emit('on-select', row, databaseName)">选择</a>
|
|
20
|
+
</template>
|
|
21
|
+
</i-Table>
|
|
22
|
+
<br />
|
|
23
|
+
|
|
24
|
+
<div class="ivu-mt ivu-text-right" v-if="!isFilter">
|
|
25
|
+
<Page :total="total" :current.sync="current" show-total :page-size="pageSize" />
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script>
|
|
31
|
+
import { xhr_get, xhr_post, getPageList } from '@ajaxjs/util/dist/util/xhr';
|
|
32
|
+
|
|
33
|
+
// 选择表
|
|
34
|
+
export default {
|
|
35
|
+
data() {
|
|
36
|
+
return {
|
|
37
|
+
// isCrossDb: false,
|
|
38
|
+
list_column: [
|
|
39
|
+
{
|
|
40
|
+
title: "#",
|
|
41
|
+
// key: 'id',
|
|
42
|
+
width: 60,
|
|
43
|
+
type: "index",
|
|
44
|
+
// type: 'selection'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
title: "表名",
|
|
48
|
+
key: "tableName",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
title: "说明",
|
|
52
|
+
key: "comment",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
title: "操作",
|
|
56
|
+
slot: "select",
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
listData: [], // 显示数据
|
|
60
|
+
data: [], // 全部数据
|
|
61
|
+
total: 0,
|
|
62
|
+
current: 1,
|
|
63
|
+
pageSize: 5,
|
|
64
|
+
isFilter: false,
|
|
65
|
+
start: 0,
|
|
66
|
+
searchKeyword: "",
|
|
67
|
+
loading: false,
|
|
68
|
+
databaseList: [],
|
|
69
|
+
databaseName: "",
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
props: {
|
|
73
|
+
isCrossDb: { type: Boolean, required: true },
|
|
74
|
+
dataSourceId: { type: Number, required: true },
|
|
75
|
+
},
|
|
76
|
+
mounted() {
|
|
77
|
+
// this.isCrossDb = true;
|
|
78
|
+
this.getData();
|
|
79
|
+
},
|
|
80
|
+
methods: {
|
|
81
|
+
getData() {
|
|
82
|
+
this.loading = true;
|
|
83
|
+
let url =`${window.config.dsApiRoot}/datasource/${this.dataSourceId}/get_all_tables?start=${this.start}&limit=${this.pageSize}`;
|
|
84
|
+
// let url = `${DS_CONFIG.API_ROOT}/admin0/${this.dataSourceId}/getAllTables?start=${this.start}&limit=${this.pageSize}`;
|
|
85
|
+
|
|
86
|
+
if (this.searchKeyword) url += `&tableName=${this.searchKeyword}`;
|
|
87
|
+
if (this.databaseName) url += `&dbName=${this.databaseName}`;
|
|
88
|
+
|
|
89
|
+
xhr_get(url, (j) => {
|
|
90
|
+
if (j.status) {
|
|
91
|
+
this.data = j.data.rows;
|
|
92
|
+
this.total = j.data.total;
|
|
93
|
+
} else this.$Message.error(j.message);
|
|
94
|
+
|
|
95
|
+
this.loading = false;
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
handleChangePageSize() {
|
|
99
|
+
let start = (this.current - 1) * this.pageSize,
|
|
100
|
+
end = start + this.pageSize;
|
|
101
|
+
|
|
102
|
+
this.listData = this.data.slice(start, end);
|
|
103
|
+
},
|
|
104
|
+
onSelect(arr) {
|
|
105
|
+
arr.forEach((item) => {
|
|
106
|
+
this.data.forEach((_item) => {});
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
resetData() {
|
|
110
|
+
this.searchKeyword = "";
|
|
111
|
+
|
|
112
|
+
this.start = 0;
|
|
113
|
+
this.getData();
|
|
114
|
+
this.$refs.inputEl.$el.querySelector("input").value = "";
|
|
115
|
+
},
|
|
116
|
+
search(ev) {
|
|
117
|
+
let input = ev.target,
|
|
118
|
+
v = input.value;
|
|
119
|
+
|
|
120
|
+
if (v) {
|
|
121
|
+
this.searchKeyword = v;
|
|
122
|
+
this.start = 0;
|
|
123
|
+
this.current = 1;
|
|
124
|
+
this.getData();
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
onkeypress(ev) {
|
|
128
|
+
let input = ev.target,
|
|
129
|
+
v = input.value;
|
|
130
|
+
|
|
131
|
+
if (v) {
|
|
132
|
+
this.isFilter = true;
|
|
133
|
+
let arr = this.data.filter((item) => item.tableName.indexOf(v) != -1);
|
|
134
|
+
this.listData = arr;
|
|
135
|
+
} else {
|
|
136
|
+
this.resetData();
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
watch: {
|
|
141
|
+
/**
|
|
142
|
+
* 分页
|
|
143
|
+
*
|
|
144
|
+
* @param v
|
|
145
|
+
*/
|
|
146
|
+
current(v) {
|
|
147
|
+
this.start = (v - 1) * this.pageSize;
|
|
148
|
+
this.getData();
|
|
149
|
+
},
|
|
150
|
+
dataSourceId(id) {
|
|
151
|
+
if (id) {
|
|
152
|
+
if (this.isCrossDb)
|
|
153
|
+
aj.xhr.get(
|
|
154
|
+
`${DS_CONFIG.API_ROOT}/admin/${this.dataSourceId}/get_databases`,
|
|
155
|
+
(j) => {
|
|
156
|
+
if (j.status) {
|
|
157
|
+
// 过滤 mysql 自带的库
|
|
158
|
+
let not = ["information_schema", "performance_schema", "sys", "mysql"];
|
|
159
|
+
let arr = j.data.filter((db) => !not.includes(db));
|
|
160
|
+
this.databaseList = arr;
|
|
161
|
+
|
|
162
|
+
// 默认选中第一个
|
|
163
|
+
this.start = 0;
|
|
164
|
+
this.current = 1;
|
|
165
|
+
this.databaseName = arr[0];
|
|
166
|
+
} else this.$Message.error(j.message);
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
else {
|
|
170
|
+
this.databaseName = null;
|
|
171
|
+
this.getData();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
databaseName(v) {
|
|
176
|
+
this.getData(); // 会重复请求
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
</script>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ajaxjs/ui",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "Widgets based on iView.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"vue-codemirror": "^4.0.6",
|
|
26
|
-
"vuedraggable": "^2.24.3",
|
|
27
26
|
"@ajaxjs/util": "1.1.1"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|