@ajaxjs/ui 1.3.12 → 1.4.1
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 +2 -29
- package/dist/ajaxjs-ui.cjs.js +1 -0
- package/dist/ajaxjs-ui.es.js +33 -0
- package/dist/ajaxjs-ui.umd.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/utils.d.ts +36 -0
- package/package.json +55 -49
- package/.browserslistrc +0 -3
- package/.eslintrc.js +0 -26
- package/babel.config.js +0 -5
- package/deprecated/api-helper.zip +0 -0
- package/deprecated/api-helper2.zip +0 -0
- package/deprecated/api-selector.zip +0 -0
- package/deprecated/common-ui.zip +0 -0
- package/deprecated/data-source.zip +0 -0
- package/deprecated/table-selector.zip +0 -0
- package/deprecated/utils.js +0 -220
- package/dist/@ajaxjs/ui.common.js +0 -3818
- package/dist/@ajaxjs/ui.common.js.map +0 -1
- package/dist/@ajaxjs/ui.css +0 -1
- package/dist/@ajaxjs/ui.umd.js +0 -3829
- package/dist/@ajaxjs/ui.umd.js.map +0 -1
- package/dist/@ajaxjs/ui.umd.min.js +0 -2
- package/dist/@ajaxjs/ui.umd.min.js.map +0 -1
- package/dist/demo.html +0 -1
- package/examples/App.vue +0 -137
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -17
- package/src/data-source/data-source.less +0 -46
- package/src/data-source/data-source.ts +0 -97
- package/src/data-source/data-source.vue +0 -59
- package/src/iam/iam.ts +0 -65
- package/src/iam/user.vue +0 -53
- package/src/index.js +0 -52
- package/src/iview-ext/fast-iview-table.ts +0 -133
- package/src/iview-ext/fast-iview-table.vue +0 -67
- package/src/iview-ext/list.ts +0 -108
- package/src/iview-ext/table-selector.vue +0 -185
- package/src/iview-ext/tips.vue +0 -17
- package/src/libs/api-helper.d.ts +0 -194
- package/src/libs/api-list.d.ts +0 -15
- package/src/libs/common.d.ts +0 -201
- package/src/libs/entity.ts +0 -31
- package/src/libs/iview-widgets.ts +0 -73
- package/src/main.ts +0 -7
- package/src/shims-tsx.d.ts +0 -11
- package/src/shims-vue.d.ts +0 -4
- package/src/style/common-functions.less +0 -286
- package/src/style/reset.less +0 -19
- package/src/style/reset2.less +0 -49
- package/tsconfig.json +0 -40
- package/vue.config.js +0 -19
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
.datasource {
|
|
2
|
-
.left {
|
|
3
|
-
float: left;
|
|
4
|
-
width: 28%;
|
|
5
|
-
height: 300px;
|
|
6
|
-
border-right: 1px solid #f5f5f5;
|
|
7
|
-
|
|
8
|
-
ul {
|
|
9
|
-
margin: 0 2%;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
li {
|
|
13
|
-
border-bottom: 1px solid #eaeaea;
|
|
14
|
-
padding: 5px 8px;
|
|
15
|
-
cursor: pointer;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
li:hover {
|
|
19
|
-
border-bottom-color: lightgray;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
li.actived {
|
|
23
|
-
font-weight: bold;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.right {
|
|
28
|
-
float: right;
|
|
29
|
-
width: 70%;
|
|
30
|
-
padding-left: 10px;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.add {
|
|
34
|
-
display: block;
|
|
35
|
-
padding: 5px 10px;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.del-icon {
|
|
39
|
-
float: right;
|
|
40
|
-
margin-top: 3px
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.del-icon:hover {
|
|
44
|
-
color: brown;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { Xhr } from "@ajaxjs/util";
|
|
2
|
-
import Vue from "vue";
|
|
3
|
-
|
|
4
|
-
const DBType = { 'MY_SQL': 'MySQL', 'ORACLE': 'Oracle', 'SQL_SERVER': 'Sql Server', 'SPARK': 'Spark', 'SQLITE': 'SQLite', DB2: 'DB2' };
|
|
5
|
-
// @ts-ignore xxxxxxxx
|
|
6
|
-
const DATASOURCE_API = window.API_ROOT ? API_ROOT + '/data_service/datasource' : '../../data_service/datasource';
|
|
7
|
-
// @ts-ignore xxxxxxxxxx
|
|
8
|
-
const DATA_SERVICE_API = window.API_ROOT ? API_ROOT + '/data_service/admin' : '../../data_service/admin';
|
|
9
|
-
|
|
10
|
-
export default Vue.extend({
|
|
11
|
-
name: 'DataSource',
|
|
12
|
-
data(): object {
|
|
13
|
-
return {
|
|
14
|
-
isCreate: true,
|
|
15
|
-
datasources: [
|
|
16
|
-
{
|
|
17
|
-
id: 1,
|
|
18
|
-
name: '加载中……'
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
activedItem: null,
|
|
22
|
-
editing: {},
|
|
23
|
-
form: {
|
|
24
|
-
data: {},
|
|
25
|
-
rules: {
|
|
26
|
-
name: [
|
|
27
|
-
{ required: true, message: '数据源名称不能为空', trigger: 'blur' }
|
|
28
|
-
],
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
DBType: DBType
|
|
32
|
-
};
|
|
33
|
-
},
|
|
34
|
-
mounted(): void {
|
|
35
|
-
this.getList();
|
|
36
|
-
},
|
|
37
|
-
methods: {
|
|
38
|
-
active(item): void {
|
|
39
|
-
this.activedItem = item.id;
|
|
40
|
-
this.form.data = item;
|
|
41
|
-
},
|
|
42
|
-
getList(cb): void {
|
|
43
|
-
// @ts-ignore xxxx
|
|
44
|
-
xhr_get(`${window.config.dsApiRoot}/datasource`, (j: RepsonseResult) => {
|
|
45
|
-
this.datasources = j.data;
|
|
46
|
-
}, { start: 0, limit: 99 });
|
|
47
|
-
},
|
|
48
|
-
add(): void {
|
|
49
|
-
this.activedItem = null;
|
|
50
|
-
this.form.data = {
|
|
51
|
-
name: ''
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
create(): void {
|
|
55
|
-
this.$refs.editForm.validate((valid) => {
|
|
56
|
-
if (valid) {
|
|
57
|
-
Xhr.xhr_post(DATASOURCE_API, this.form.data, j => {
|
|
58
|
-
if (j.status === 1) {
|
|
59
|
-
const newlyId = j.data;
|
|
60
|
-
this.getList(() => this.activedItem = newlyId);
|
|
61
|
-
this.$Message.success('创建数据源成功');
|
|
62
|
-
this.form.data.id = newlyId;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
} else
|
|
66
|
-
this.$Message.error('表单验证不通过');
|
|
67
|
-
});
|
|
68
|
-
},
|
|
69
|
-
update(): void {
|
|
70
|
-
const entity = Object.assign({}, this.form.data);
|
|
71
|
-
Xhr.xhr_put(DATASOURCE_API, entity, j => {
|
|
72
|
-
if (j.status === 1) {
|
|
73
|
-
this.$Message.success('修改数据源成功');
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
},
|
|
77
|
-
del(id, name): void {
|
|
78
|
-
this.$Modal.confirm({
|
|
79
|
-
title: '删除数据源',
|
|
80
|
-
content: `是否删除数据源 #${name}?`,
|
|
81
|
-
onOk: () => {
|
|
82
|
-
Xhr.xhr_del(DATASOURCE_API + id, j => {
|
|
83
|
-
this.$Message.success('删除数据源成功');
|
|
84
|
-
this.getList(() => this.add());
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
},
|
|
89
|
-
test(): void {
|
|
90
|
-
// @ts-ignore xxxxxx
|
|
91
|
-
xhr_get(`${window.config.dsApiRoot}/datasource/test/` + this.activedItem, (j: RepsonseResult) => {
|
|
92
|
-
if (j.status)
|
|
93
|
-
this.$Modal.success({ title: '连接数据源成功' });
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
});
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="datasource" style="overflow: hidden">
|
|
3
|
-
<div class="left">
|
|
4
|
-
<ul>
|
|
5
|
-
<li v-for="datasource in datasources" :key="datasource.id" @click="active(datasource)" :class="{ actived: activedItem == datasource.id }">
|
|
6
|
-
<span>
|
|
7
|
-
<Icon type="md-trash" class="del-icon" title="删除此数据源" @click="del(datasource.id, datasource.name)" />
|
|
8
|
-
</span>
|
|
9
|
-
{{datasource.name}}
|
|
10
|
-
</li>
|
|
11
|
-
</ul>
|
|
12
|
-
<a class="add" @click="add">+ 新建……</a>
|
|
13
|
-
</div>
|
|
14
|
-
<div class="right">
|
|
15
|
-
<i-Form ref="editForm" :model="form.data" :rules="form.rules" :label-width="120" style="margin-right:100px">
|
|
16
|
-
<form-item label="数据源名称" prop="name">
|
|
17
|
-
<i-Input v-model="form.data.name" placeholder="数据源名称" />
|
|
18
|
-
</form-item>
|
|
19
|
-
<form-item label="数据源编码" prop="urlDir">
|
|
20
|
-
<i-Input v-model="form.data.urlDir" placeholder="数据源编码全局唯一不重复" />
|
|
21
|
-
</form-item>
|
|
22
|
-
<form-item label="数据库类型" prop="type">
|
|
23
|
-
<i-Select v-model="form.data.type">
|
|
24
|
-
<i-Option v-for="(value, key) in DBType" :value="key" :key="key">{{ value }}</i-Option>
|
|
25
|
-
</i-Select>
|
|
26
|
-
</form-item>
|
|
27
|
-
<form-item label="连接地址" prop="url">
|
|
28
|
-
<i-Input v-model="form.data.url" maxlength="200" show-word-limit type="textarea" :rows="4" placeholder="数据库连接 URL,注意无须携带用户名和密码,且不需要 URL 转义" />
|
|
29
|
-
</form-item>
|
|
30
|
-
<form-item label="登录用户" prop="username">
|
|
31
|
-
<i-Input v-model="form.data.username" placeholder="请输入数据库用户账号" />
|
|
32
|
-
</form-item>
|
|
33
|
-
<form-item label="登录密码" prop="password">
|
|
34
|
-
<i-Input v-model="form.data.password" type="password" password placeholder="请输入账号密码" />
|
|
35
|
-
</form-item>
|
|
36
|
-
<form-item label="是否跨库" prop="crossDb">
|
|
37
|
-
<i-switch v-model="form.data.crossDb" />
|
|
38
|
-
</form-item>
|
|
39
|
-
</i-Form>
|
|
40
|
-
|
|
41
|
-
<div align="center">
|
|
42
|
-
<i-Button v-if="!activedItem" icon="md-checkmark" @click="create">保存新建</i-Button>
|
|
43
|
-
<i-Button v-if="activedItem" @click="update">保存</i-Button>
|
|
44
|
-
<i-Button v-if="activedItem" @click="test">测试连接</i-Button>
|
|
45
|
-
<i-Button v-if="activedItem" @click="$emit('change_datasource', form.data)">切换</i-Button>
|
|
46
|
-
</div>
|
|
47
|
-
<!-- <i-Input v-model="editing.name" ref="inputName">
|
|
48
|
-
<span slot="prepend">环境名称</span>
|
|
49
|
-
</i-Input>
|
|
50
|
-
<br />
|
|
51
|
-
<i-Input v-model="editing.urlPrefix">
|
|
52
|
-
<span slot="prepend">URL前缀</span>
|
|
53
|
-
</i-Input> -->
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
</template>
|
|
57
|
-
|
|
58
|
-
<script lang="ts" src="./data-source.ts"></script>
|
|
59
|
-
<style lang="less" scoped src="./data-source.less"></style>
|
package/src/iam/iam.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { Xhr } from "@ajaxjs/util";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 获取登录信息
|
|
5
|
-
*
|
|
6
|
-
* @returns 用户 JWT
|
|
7
|
-
*/
|
|
8
|
-
export default {
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @param loginUrl 登录页面地址
|
|
13
|
-
* @param thisPageUrl 前端页面的地址,最后返回这里
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
getLoginInfo(loginUrl: string, thisPageUrl: string): any {
|
|
17
|
-
const token = getQueryParam("token", false);
|
|
18
|
-
let accessToken: string = localStorage.getItem("accessToken");
|
|
19
|
-
|
|
20
|
-
if (!accessToken && !token) {
|
|
21
|
-
console.log('你未登录!');
|
|
22
|
-
const target = `${loginUrl}?web_url=${encodeURIComponent(thisPageUrl)}`;
|
|
23
|
-
|
|
24
|
-
confirm('你未登录。是否跳转到登录页面?') && location.assign(target);
|
|
25
|
-
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (token) {
|
|
30
|
-
accessToken = decodeURIComponent(token);
|
|
31
|
-
localStorage.setItem("accessToken", accessToken);
|
|
32
|
-
|
|
33
|
-
// 只需要第一次的参数,之后不需要,现在清除
|
|
34
|
-
const url: URL = new URL(location.href); // 创建一个包含查询参数的URL
|
|
35
|
-
const params: URLSearchParams = new URLSearchParams(url.search);// 获取URL中的查询参数
|
|
36
|
-
params.delete('token');// 删除名为'b'的参数
|
|
37
|
-
url.search = params.toString();// 更新URL的查询参数
|
|
38
|
-
|
|
39
|
-
location.assign(url.href);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// window.JWT_TOKEN = JSON.parse(accessToken);
|
|
43
|
-
Xhr.setBaseHeadParams({ Authorization: 'Bearer ' + accessToken });
|
|
44
|
-
|
|
45
|
-
// 将 JWT Token 拆分为三个部分
|
|
46
|
-
const tokenParts: string[] = accessToken.split('.')
|
|
47
|
-
const payload = JSON.parse(atob(tokenParts[1])); // 解析载荷
|
|
48
|
-
|
|
49
|
-
return payload;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
function getQueryParam(variable: string, isParent: boolean): string | null {
|
|
54
|
-
const query: string = (isParent ? parent.location : window.location).search.substring(1);
|
|
55
|
-
const vars: string[] = query.split("&");
|
|
56
|
-
|
|
57
|
-
for (let i = 0; i < vars.length; i++) {
|
|
58
|
-
const pair: string[] = vars[i].split("=");
|
|
59
|
-
|
|
60
|
-
if (pair[0] == variable)
|
|
61
|
-
return pair[1];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return null;
|
|
65
|
-
}
|
package/src/iam/user.vue
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<a @click="showUserInfo">{{ state }}</a>
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script lang="ts">
|
|
6
|
-
import { Utils } from "@ajaxjs/util";
|
|
7
|
-
import Vue from "vue";
|
|
8
|
-
|
|
9
|
-
const logout = "localStorage.removeItem('accessToken');location.reload();";
|
|
10
|
-
|
|
11
|
-
export default Vue.extend({
|
|
12
|
-
name: 'IamUser',
|
|
13
|
-
data() {
|
|
14
|
-
return {
|
|
15
|
-
state: "未登录",
|
|
16
|
-
isShowInfo: false,
|
|
17
|
-
payload: null,
|
|
18
|
-
};
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
mounted(): void {
|
|
22
|
-
// localStorage.setItem("accessToken", 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwibmFtZSI6ImFkbWluIiwiYXVkIjoiREVGQVVMVF9TQ09QRTt0ZW5hbnRJZD0wIiwiZXhwIjoxNzIxMjMzMTE0LCJpc3MiOiJmb29AYmFyLm5ldCIsImlhdCI6MTcyMTE0NjcxNH0.mykPFQv2fkqmEk1UJs6vErtwATIdUmmbNvJDCMP4pMI');
|
|
23
|
-
let accessToken: string = localStorage.getItem("accessToken");
|
|
24
|
-
|
|
25
|
-
if (accessToken) {
|
|
26
|
-
// 将 JWT Token 拆分为三个部分
|
|
27
|
-
const tokenParts: string[] = accessToken.split(".");
|
|
28
|
-
const payload = JSON.parse(atob(tokenParts[1])); // 解析载荷
|
|
29
|
-
|
|
30
|
-
this.payload = payload;
|
|
31
|
-
this.state = payload.name + "已登录";
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
methods: {
|
|
35
|
-
showUserInfo(): void {
|
|
36
|
-
if (this.state === "未登录") {
|
|
37
|
-
// @ts-ignore xxx
|
|
38
|
-
location.assign(window.config.loginUrl);
|
|
39
|
-
} else {
|
|
40
|
-
this.$Modal.info({
|
|
41
|
-
title: "当前用户信息",
|
|
42
|
-
content: `<p>用户名: ${
|
|
43
|
-
this.payload.name
|
|
44
|
-
}</p><p>Token 过期时间:${Utils.dateFormat.call(
|
|
45
|
-
new Date(this.payload.exp * 1000),
|
|
46
|
-
"yyyy-MM-dd hh:mm:ss"
|
|
47
|
-
)}</p><p><a href="#" onclick="${logout}">用户登出</a></p>`,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
</script>
|
package/src/index.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// 动态引入组件
|
|
2
|
-
const requireComponent = require.context('./', true, /\.vue$/);
|
|
3
|
-
import List from './iview-ext/list';
|
|
4
|
-
import IAM from './iam/iam';
|
|
5
|
-
|
|
6
|
-
const components = {};
|
|
7
|
-
|
|
8
|
-
requireComponent.keys().forEach(fileName => {
|
|
9
|
-
if (fileName != './App.vue') {
|
|
10
|
-
const cmp = requireComponent(fileName).default || requireComponent(fileName);
|
|
11
|
-
if (cmp.extendOptions)
|
|
12
|
-
components[cmp.extendOptions.name] = cmp;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// 插件
|
|
17
|
-
const install = (Vue) => {
|
|
18
|
-
if (install.installed)
|
|
19
|
-
return install.installed;
|
|
20
|
-
|
|
21
|
-
requireComponent.keys().forEach(fileName => {
|
|
22
|
-
if (fileName != './App.vue') {
|
|
23
|
-
// 第i个组件
|
|
24
|
-
const cmp = requireComponent(fileName).default || requireComponent(fileName);
|
|
25
|
-
|
|
26
|
-
if (cmp.extendOptions && cmp.extendOptions.name) {
|
|
27
|
-
// console.log(fileName, cmp.extendOptions.name);
|
|
28
|
-
|
|
29
|
-
// 注册组件(组件名,组件)
|
|
30
|
-
Vue.component(cmp.extendOptions.name, cmp);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// 全局自定义指令
|
|
36
|
-
Vue.directive('focus', {
|
|
37
|
-
inserted: function (el) {
|
|
38
|
-
el.focus();
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// 环境检测
|
|
44
|
-
if (typeof window !== 'undefined' && window.Vue)
|
|
45
|
-
install(window.Vue);
|
|
46
|
-
|
|
47
|
-
export default {
|
|
48
|
-
install,
|
|
49
|
-
List,
|
|
50
|
-
IAM,
|
|
51
|
-
...components//组件也一样要暴露
|
|
52
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import Vue from "vue";
|
|
2
|
-
import List from "./list";
|
|
3
|
-
import { Xhr } from '@ajaxjs/util';
|
|
4
|
-
|
|
5
|
-
export default Vue.extend({
|
|
6
|
-
name: "FastViewTable",
|
|
7
|
-
props: {
|
|
8
|
-
widgetName: { type: String, required: false },
|
|
9
|
-
apiUrl: { type: String, required: false }, // 接口地址
|
|
10
|
-
columnsDef: { type: Array, required: false }, // 列定义
|
|
11
|
-
listApiUrl: { type: String, required: true },
|
|
12
|
-
createRoute: { type: String, required: false }, // 新建事件触发时候,进入的路由地址
|
|
13
|
-
editRoute: { type: String, required: false }, // 编辑事件触发时候,进入的路由地址
|
|
14
|
-
pickup: { type: Boolean, required: false }, // 编辑事件触发时候,进入的路由地址
|
|
15
|
-
},
|
|
16
|
-
data() {
|
|
17
|
-
return {
|
|
18
|
-
widgetName_: this.widgetName,
|
|
19
|
-
listApiUrl_: this.listApiUrl,
|
|
20
|
-
colDefId: 0,
|
|
21
|
-
list: {
|
|
22
|
-
columns: this.columnsDef || [],
|
|
23
|
-
data: [],
|
|
24
|
-
total: 0,
|
|
25
|
-
start: 0,
|
|
26
|
-
limit: 9,
|
|
27
|
-
pageNo: 1,
|
|
28
|
-
pageSize: 9,
|
|
29
|
-
loading: false,
|
|
30
|
-
search: {
|
|
31
|
-
name: ''
|
|
32
|
-
},
|
|
33
|
-
} as TableListConfig
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
mounted() {
|
|
37
|
-
this.getData();
|
|
38
|
-
},
|
|
39
|
-
methods: {
|
|
40
|
-
getData(): void {
|
|
41
|
-
this.list.loading = true;
|
|
42
|
-
const params: any = { pageNo: this.list.pageNo, pageSize: this.list.pageSize };
|
|
43
|
-
|
|
44
|
-
// if (this.list.search.name)
|
|
45
|
-
// params.where = `name LIKE '%${this.list.search.name}%'`;
|
|
46
|
-
|
|
47
|
-
this.listApiUrl_ && Xhr.xhr_get(this.listApiUrl_, (j: RepsonseResult) => {
|
|
48
|
-
this.list.loading = false;
|
|
49
|
-
|
|
50
|
-
if (j.status) {
|
|
51
|
-
this.list.data = j.data.rows;
|
|
52
|
-
this.list.total = j.data.total;
|
|
53
|
-
} else
|
|
54
|
-
this.$Message.warning(j.message || '获取列表失败');
|
|
55
|
-
}, params);
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* 分页记录数
|
|
60
|
-
*/
|
|
61
|
-
handleChangePageSize(pageSize: number): void {
|
|
62
|
-
this.list.limit = pageSize;
|
|
63
|
-
this.getData();
|
|
64
|
-
},
|
|
65
|
-
reset(): void {
|
|
66
|
-
for (const i in this.search)
|
|
67
|
-
this.search[i] = "";
|
|
68
|
-
|
|
69
|
-
this.getData();
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* 新建
|
|
74
|
-
*/
|
|
75
|
-
onCreate(): void {
|
|
76
|
-
if (this.createRoute)
|
|
77
|
-
this.$router.push({ path: this.createRoute }); // 进入详情页,采用相对路径
|
|
78
|
-
else {
|
|
79
|
-
if (!this.$parent.onCreate)
|
|
80
|
-
throw '请设置父组件的 onCreate 事件处理器';
|
|
81
|
-
|
|
82
|
-
this.$parent.onCreate();
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* 编辑
|
|
88
|
-
*/
|
|
89
|
-
onEdit(id: number): void {
|
|
90
|
-
if (this.editRoute)
|
|
91
|
-
this.$router.push({ path: this.editRoute, query: { id } }); // 进入详情页,采用相对路径
|
|
92
|
-
else {
|
|
93
|
-
if (!this.$parent.onEdit)
|
|
94
|
-
throw '请设置父组件的 onEdit 事件处理器';
|
|
95
|
-
|
|
96
|
-
this.$parent.onEdit(id);
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
doPickup(data: any): void {
|
|
101
|
-
this.$emit("on-select", data);
|
|
102
|
-
},
|
|
103
|
-
deleteInfo(id: number, index: number): void {
|
|
104
|
-
this.list.loading = true;
|
|
105
|
-
Xhr.xhr_del(`${this.apiUrl}/${id}`, List.afterDelete(() => {
|
|
106
|
-
this.list.data.splice(index, 1);
|
|
107
|
-
this.list.total--;
|
|
108
|
-
this.list.loading = false;
|
|
109
|
-
}).bind(this));
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
watch: {
|
|
113
|
-
listApiUrl(v: string): void {
|
|
114
|
-
// debugger
|
|
115
|
-
this.listApiUrl_ = v;
|
|
116
|
-
this.getData();
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* 分页
|
|
121
|
-
*
|
|
122
|
-
* @param v
|
|
123
|
-
*/
|
|
124
|
-
current(v: number): void {
|
|
125
|
-
this.start = (v - 1) * this.list.limit;
|
|
126
|
-
this.getData();
|
|
127
|
-
},
|
|
128
|
-
'list.pageNo'(v: number): void {
|
|
129
|
-
this.list.start = (v - 1) * this.list.limit;
|
|
130
|
-
this.getData();
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<!-- 搜索表单 -->
|
|
4
|
-
<Card :bordered="false" dis-hover class="common-search-panel" style="text-align:left">
|
|
5
|
-
<span style="float:right;">
|
|
6
|
-
<Button type="primary" icon="ios-search" @click="$parent.getData()">查询</Button>
|
|
7
|
-
<Button style="margin-left:10px" @click="reset">重置</Button>
|
|
8
|
-
</span>
|
|
9
|
-
<Input suffix="ios-search" v-model="list.search.name" @on-enter="getData" clearable :placeholder="'请输入' + widgetName_ + '名称'" />
|
|
10
|
-
</Card>
|
|
11
|
-
|
|
12
|
-
<div>
|
|
13
|
-
<Card :bordered="false" dis-hover>
|
|
14
|
-
<div class="toolbar">
|
|
15
|
-
<Tooltip class="ivu-ml" content="刷新" placement="top">
|
|
16
|
-
<Icon size="20" type="ios-refresh" @click="getData" style="cursor: pointer;" />
|
|
17
|
-
</Tooltip>
|
|
18
|
-
|
|
19
|
-
<slot name="toolbar"></slot>
|
|
20
|
-
<Button v-if="!!createRoute || !! $parent.onCreate" type="primary" icon="md-add" @click="onCreate">新建{{widgetName_}}</Button>
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
<Table :columns="list.columns" :data="list.data" :loading="list.loading" height="500">
|
|
24
|
-
<template slot-scope="{ row, index }" slot="action">
|
|
25
|
-
<slot name="list_action" :item="row"></slot>
|
|
26
|
-
<a v-if="pickup" style="color:green;" @click="doPickup(row)">选择</a>
|
|
27
|
-
|
|
28
|
-
<span v-if="!pickup">
|
|
29
|
-
<a style="color:green;" @click="onEdit(row.id)">编辑</a>
|
|
30
|
-
<Divider type="vertical" />
|
|
31
|
-
<Poptip confirm transfer title="是否要删除此行?" @on-ok="deleteInfo(row.id, index)">
|
|
32
|
-
<a style="color:red;">删除</a>
|
|
33
|
-
</Poptip>
|
|
34
|
-
</span>
|
|
35
|
-
</template>
|
|
36
|
-
</Table>
|
|
37
|
-
|
|
38
|
-
<Page class="ivu-mt ivu-text-right" :total="list.total" :current.sync="list.pageNo" show-total show-sizer :page-size="list.limit" @on-page-size-change="handleChangePageSize" />
|
|
39
|
-
</Card>
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
42
|
-
</template>
|
|
43
|
-
|
|
44
|
-
<style scoped>
|
|
45
|
-
.toolbar {
|
|
46
|
-
margin-bottom: 20px;
|
|
47
|
-
overflow: hidden;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.toolbar .ivu-ml {
|
|
51
|
-
float: right;
|
|
52
|
-
padding-top: 10px;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/* 分页控件有点问题,修改下 */
|
|
56
|
-
.ivu-mt.ivu-text-right {
|
|
57
|
-
text-align: right;
|
|
58
|
-
margin-top: 20px;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.common-search-panel .ivu-input-type-text {
|
|
62
|
-
width: 280px;
|
|
63
|
-
margin: 0 10px 16px 0;
|
|
64
|
-
}
|
|
65
|
-
</style>
|
|
66
|
-
|
|
67
|
-
<script lang="ts" src="./fast-iview-table.ts"></script>
|
package/src/iview-ext/list.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { Xhr, Utils } from "@ajaxjs/util";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 处理响应的回调函数
|
|
5
|
-
*/
|
|
6
|
-
type XhrCallback = (json: object, text: string) => void;
|
|
7
|
-
|
|
8
|
-
export default {
|
|
9
|
-
afterDelete(cb?: (a: RepsonseResult) => void): (j: RepsonseResult) => void {
|
|
10
|
-
return function (j: RepsonseResult): void {
|
|
11
|
-
if (j.status) {
|
|
12
|
-
cb && cb(j);
|
|
13
|
-
this.$Message.success('删除成功');
|
|
14
|
-
}
|
|
15
|
-
else
|
|
16
|
-
this.$Message.info('删除失败。' + j.message);
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
delInfo(index: number) {
|
|
21
|
-
Xhr.xhr_del(`${this.API}/${this.list.data[index].id}`, (j: RepsonseResult) => {
|
|
22
|
-
if (j.status) {
|
|
23
|
-
this.list.data.splice(index, 1);
|
|
24
|
-
this.list.total--;
|
|
25
|
-
this.$Message.success('删除成功');
|
|
26
|
-
} else
|
|
27
|
-
this.$Message.info('删除失败。' + j.message);
|
|
28
|
-
});
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* id 列
|
|
33
|
-
*/
|
|
34
|
-
id: { title: '#', width: 60, key: 'id', align: 'center' },
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 创建日期
|
|
38
|
-
*/
|
|
39
|
-
createDate: {
|
|
40
|
-
title: '创建日期',/* key: 'createDate', */ width: 160, align: 'center', render(h: (a: string, b: string) => object, params: any) {
|
|
41
|
-
return h('div', Utils.dateFormat.call(new Date(params.row.createDate), 'yyyy-MM-dd hh:mm'));
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* 分类标签
|
|
47
|
-
*/
|
|
48
|
-
tags: { title: '分类标签', minWidth: 100, key: 'tagsNames', align: 'center', ellipsis: true },
|
|
49
|
-
|
|
50
|
-
status: {
|
|
51
|
-
title: '状态', width: 80,
|
|
52
|
-
render(h: (a: string, b: object, c: string) => void, params: any) {
|
|
53
|
-
let str = '', color = '';
|
|
54
|
-
|
|
55
|
-
switch (params.row.stat) {
|
|
56
|
-
case -1:
|
|
57
|
-
str = '草稿';
|
|
58
|
-
color = 'gray';
|
|
59
|
-
break;
|
|
60
|
-
case 2:
|
|
61
|
-
color = 'red';
|
|
62
|
-
str = '禁用';
|
|
63
|
-
break;
|
|
64
|
-
case 1:
|
|
65
|
-
color = 'red';
|
|
66
|
-
str = '已删除';
|
|
67
|
-
break
|
|
68
|
-
case null:
|
|
69
|
-
case 0:
|
|
70
|
-
default:
|
|
71
|
-
color = 'green';
|
|
72
|
-
str = "启用";
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return h('div', {
|
|
76
|
-
style: {
|
|
77
|
-
color: color
|
|
78
|
-
}
|
|
79
|
-
}, str);
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
getPageList(self: any, listArray: any, callback?: () => void): XhrCallback {
|
|
83
|
-
return (j: JsonResponse) => {
|
|
84
|
-
if (j.status) {
|
|
85
|
-
listArray.total = j.data.total;
|
|
86
|
-
listArray.data = j.data.rows;
|
|
87
|
-
|
|
88
|
-
callback && callback();
|
|
89
|
-
} else
|
|
90
|
-
self.$Message.warning(j.message || '获取数据失败');
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
copyBeanClean(bean: object): object {
|
|
95
|
-
const deepCopy: any = JSON.parse(JSON.stringify(bean));
|
|
96
|
-
|
|
97
|
-
delete deepCopy.createDate;
|
|
98
|
-
delete deepCopy.updateDate;
|
|
99
|
-
delete deepCopy.updateDate;
|
|
100
|
-
delete deepCopy.creatorId;
|
|
101
|
-
delete deepCopy.updaterId;
|
|
102
|
-
delete deepCopy.creator;
|
|
103
|
-
delete deepCopy.updater;
|
|
104
|
-
delete deepCopy.extend;
|
|
105
|
-
|
|
106
|
-
return deepCopy;
|
|
107
|
-
}
|
|
108
|
-
};
|