@ajaxjs/ui 1.3.0 → 1.3.2

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.
Files changed (134) hide show
  1. package/.browserslistrc +3 -0
  2. package/.eslintrc.js +26 -0
  3. package/babel.config.js +5 -0
  4. package/deprecated/api-helper.zip +0 -0
  5. package/deprecated/api-helper2.zip +0 -0
  6. package/deprecated/api-selector.zip +0 -0
  7. package/deprecated/common-ui.zip +0 -0
  8. package/deprecated/data-source.zip +0 -0
  9. package/deprecated/table-selector.zip +0 -0
  10. package/deprecated/utils.js +220 -0
  11. package/dist/@ajaxjs/widgets.common.js +4084 -0
  12. package/dist/@ajaxjs/widgets.common.js.map +1 -0
  13. package/dist/@ajaxjs/widgets.css +1 -0
  14. package/dist/@ajaxjs/widgets.umd.js +4095 -0
  15. package/dist/@ajaxjs/widgets.umd.js.map +1 -0
  16. package/dist/@ajaxjs/widgets.umd.min.js +2 -0
  17. package/dist/@ajaxjs/widgets.umd.min.js.map +1 -0
  18. package/dist/demo.html +1 -0
  19. package/examples/App.vue +137 -0
  20. package/package.json +50 -41
  21. package/public/favicon.ico +0 -0
  22. package/public/index.html +17 -0
  23. package/{dist → src}/data-source/data-source.ts +16 -14
  24. package/{dist → src}/iam/iam.ts +2 -4
  25. package/{dist → src}/iam/user.vue +19 -16
  26. package/src/index.js +48 -0
  27. package/src/iview-ext/fast-iview-table.ts +131 -0
  28. package/src/iview-ext/fast-iview-table.vue +67 -0
  29. package/{dist/iView-ext/fast-iview-table → src/iview-ext}/list.ts +11 -12
  30. package/{dist/table-selector → src/iview-ext}/table-selector.vue +17 -12
  31. package/{dist/iView-ext → src/iview-ext}/tips.vue +5 -2
  32. package/src/main.ts +7 -0
  33. package/src/shims-tsx.d.ts +11 -0
  34. package/{dist → src}/shims-vue.d.ts +4 -4
  35. package/src/style/common-functions.less +286 -0
  36. package/src/style/reset.less +19 -0
  37. package/src/style/reset2.less +49 -0
  38. package/tsconfig.json +40 -0
  39. package/vue.config.js +14 -0
  40. package/LICENSE +0 -201
  41. package/dist/api-helper/common/arg.vue +0 -46
  42. package/dist/api-helper/common/http-method.vue +0 -53
  43. package/dist/api-helper/common/input-table.vue +0 -128
  44. package/dist/api-helper/document/document-render.d.ts +0 -10
  45. package/dist/api-helper/document/document-render.js +0 -38
  46. package/dist/api-helper/document/document-render.js.map +0 -1
  47. package/dist/api-helper/document/document-render.ts +0 -35
  48. package/dist/api-helper/document/document-render.vue +0 -155
  49. package/dist/api-helper/document/document.d.ts +0 -31
  50. package/dist/api-helper/document/document.js +0 -55
  51. package/dist/api-helper/document/document.js.map +0 -1
  52. package/dist/api-helper/document/document.ts +0 -55
  53. package/dist/api-helper/document/document.vue +0 -78
  54. package/dist/api-helper/document/perview.vue +0 -0
  55. package/dist/api-helper/index.js +0 -142
  56. package/dist/api-helper/index.vue +0 -108
  57. package/dist/api-helper/request-body.vue +0 -66
  58. package/dist/api-helper/table.d.ts +0 -7
  59. package/dist/api-helper/table.js +0 -13
  60. package/dist/api-helper/table.js.map +0 -1
  61. package/dist/api-helper/table.ts +0 -10
  62. package/dist/api-helper/table.vue +0 -103
  63. package/dist/api-helper/xhr.js +0 -100
  64. package/dist/api-helper2/api-helper.d.ts +0 -194
  65. package/dist/api-helper2/api-helper.vue +0 -144
  66. package/dist/api-helper2/bookmark.vue +0 -168
  67. package/dist/api-helper2/common/arg.vue +0 -46
  68. package/dist/api-helper2/common/http-method.vue +0 -53
  69. package/dist/api-helper2/document/document-render.vue +0 -189
  70. package/dist/api-helper2/document/document.vue +0 -130
  71. package/dist/api-helper2/document/perview.vue +0 -0
  72. package/dist/api-helper2/env.vue +0 -140
  73. package/dist/api-helper2/history.vue +0 -116
  74. package/dist/api-helper2/main.vue +0 -70
  75. package/dist/api-helper2/request-body.vue +0 -68
  76. package/dist/api-helper2/table.vue +0 -116
  77. package/dist/api-selector/api-list-dataservice.d.ts +0 -18
  78. package/dist/api-selector/api-list-dataservice.js +0 -209
  79. package/dist/api-selector/api-list-dataservice.js.map +0 -1
  80. package/dist/api-selector/api-list-dataservice.ts +0 -232
  81. package/dist/api-selector/api-list-swagger.d.ts +0 -28
  82. package/dist/api-selector/api-list-swagger.js +0 -179
  83. package/dist/api-selector/api-list-swagger.js.map +0 -1
  84. package/dist/api-selector/api-list-swagger.ts +0 -206
  85. package/dist/api-selector/api-list.d.ts +0 -80
  86. package/dist/api-selector/api-list.js +0 -129
  87. package/dist/api-selector/api-list.js.map +0 -1
  88. package/dist/api-selector/api-list.ts +0 -135
  89. package/dist/api-selector/index.vue +0 -125
  90. package/dist/api-selector/test-dataservice.d.ts +0 -23
  91. package/dist/api-selector/test-dataservice.js +0 -74
  92. package/dist/api-selector/test-dataservice.js.map +0 -1
  93. package/dist/api-selector/test-swagger.d.ts +0 -901
  94. package/dist/api-selector/test-swagger.js +0 -656
  95. package/dist/api-selector/test-swagger.js.map +0 -1
  96. package/dist/data-source/data-source.css +0 -44
  97. package/dist/data-source/data-source.d.ts +0 -14
  98. package/dist/data-source/data-source.html +0 -59
  99. package/dist/data-source/data-source.js +0 -97
  100. package/dist/data-source/data-source.js.map +0 -1
  101. package/dist/iView-ext/fast-iview-table/fast-iview-table.d.ts +0 -37
  102. package/dist/iView-ext/fast-iview-table/fast-iview-table.js +0 -72
  103. package/dist/iView-ext/fast-iview-table/fast-iview-table.js.map +0 -1
  104. package/dist/iView-ext/fast-iview-table/fast-iview-table.ts +0 -75
  105. package/dist/iView-ext/fast-iview-table/fast-iview-table.vue +0 -52
  106. package/dist/iView-ext/fast-iview-table/list.d.ts +0 -44
  107. package/dist/iView-ext/fast-iview-table/list.js +0 -97
  108. package/dist/iView-ext/fast-iview-table/list.js.map +0 -1
  109. package/dist/iam/iam.d.ts +0 -16
  110. package/dist/iam/iam.js +0 -54
  111. package/dist/iam/iam.js.map +0 -1
  112. package/dist/index.d.ts +0 -57
  113. package/dist/index.js +0 -22
  114. package/dist/index.js.map +0 -1
  115. package/dist/index.ts +0 -18
  116. package/dist/libs/entity.d.ts +0 -26
  117. package/dist/libs/entity.js +0 -1
  118. package/dist/libs/entity.js.map +0 -1
  119. package/dist/libs/iview-widgets.d.ts +0 -59
  120. package/dist/libs/iview-widgets.js +0 -2
  121. package/dist/libs/iview-widgets.js.map +0 -1
  122. package/dist/main.d.ts +0 -1
  123. package/dist/main.js +0 -24
  124. package/dist/main.js.map +0 -1
  125. package/dist/main.ts +0 -22
  126. package/dist/table-selector/table-selector.htm +0 -28
  127. package/dist/table-selector/table-selector.js +0 -149
  128. /package/{dist → src}/data-source/data-source.less +0 -0
  129. /package/{dist → src}/data-source/data-source.vue +0 -0
  130. /package/{dist → src}/libs/api-helper.d.ts +0 -0
  131. /package/{dist → src}/libs/api-list.d.ts +0 -0
  132. /package/{dist → src}/libs/common.d.ts +0 -0
  133. /package/{dist → src}/libs/entity.ts +0 -0
  134. /package/{dist → src}/libs/iview-widgets.ts +0 -0
package/package.json CHANGED
@@ -1,41 +1,50 @@
1
- {
2
- "name": "@ajaxjs/ui",
3
- "version": "1.3.0",
4
- "description": "Widgets based on iView.js",
5
- "repository": {
6
- "type": "git",
7
- "url": "git+https://github.com/lightweight-component/widgets.git"
8
- },
9
- "bugs": {
10
- "url": "https://github.com/lightweight-component/widgets/issues/issues"
11
- },
12
- "main": "dist/index.js",
13
- "types": "dist/libs/common.d.ts",
14
- "scripts": {
15
- "dev": "vue-cli-service serve",
16
- "build": "vue-cli-service build",
17
- "release": "tsc && xcopy src\\*.* dist\\ /s /y /d && npm publish"
18
- },
19
- "author": "sp42",
20
- "license": "Apache License 2.0",
21
- "files": [
22
- "dist/"
23
- ],
24
- "dependencies": {
25
- "vue-codemirror": "^4.0.6",
26
- "@ajaxjs/util": "1.1.1"
27
- },
28
- "devDependencies": {
29
- "@vue/cli-plugin-babel": "~4.5.0",
30
- "@vue/cli-plugin-typescript": "~4.5.0",
31
- "@vue/cli-service": "~4.5.0",
32
- "less": "^3.0.4",
33
- "less-loader": "^5.0.0",
34
- "style-resources-loader": "^1.4.1",
35
- "typescript": "^4.4.3",
36
- "view-design": "^4.7.0",
37
- "vue": "^2.6.14",
38
- "vue-cli-plugin-style-resources-loader": "~0.1.5",
39
- "vue-template-compiler": "^2.6.11"
40
- }
41
- }
1
+ {
2
+ "name": "@ajaxjs/ui",
3
+ "version": "1.3.2",
4
+ "private": false,
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "keywords": [
9
+ "ajaxjs"
10
+ ],
11
+ "author": "Frank Cheung <frank@ajaxjs.com>",
12
+ "license": "Apache License 2.0",
13
+ "description": "Widgets based on iView.js",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/lightweight-component/js/tree/main/ui"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/lightweight-component/js/issues"
20
+ },
21
+ "scripts": {
22
+ "serve": "vue-cli-service serve",
23
+ "build": "vue-cli-service build",
24
+ "lint": "vue-cli-service lint",
25
+ "lib": "vue-cli-service build --target lib --name @ajaxjs/widgets --dest dist src/index.js",
26
+ "deploy": "npm run lib && npm version patch && npm publish"
27
+ },
28
+ "main": "dist/@ajaxjs/widgets.umd.js",
29
+ "types": "dist/types.d.ts",
30
+ "dependencies": {
31
+ "@ajaxjs/util": "1.1.3"
32
+ },
33
+ "devDependencies": {
34
+ "@typescript-eslint/eslint-plugin": "^5.4.0",
35
+ "@typescript-eslint/parser": "^5.4.0",
36
+ "@vue/cli-plugin-babel": "~5.0.0",
37
+ "@vue/cli-plugin-eslint": "~5.0.0",
38
+ "@vue/cli-plugin-typescript": "~5.0.0",
39
+ "@vue/cli-service": "~5.0.0",
40
+ "@vue/eslint-config-typescript": "^9.1.0",
41
+ "eslint": "^7.32.0",
42
+ "eslint-plugin-vue": "^8.0.3",
43
+ "less": "^4.0.0",
44
+ "less-loader": "^8.0.0",
45
+ "typescript": "~4.5.5",
46
+ "view-design": "^4.7.0",
47
+ "vue": "^2.6.14",
48
+ "vue-template-compiler": "^2.6.14"
49
+ }
50
+ }
Binary file
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html lang="">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width,initial-scale=1.0">
7
+ <link rel="icon" href="<%= BASE_URL %>favicon.ico">
8
+ <title>Demo Page</title>
9
+ </head>
10
+ <body>
11
+ <noscript>
12
+ <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
13
+ </noscript>
14
+ <div id="app"></div>
15
+ <!-- built files will be auto injected -->
16
+ </body>
17
+ </html>
@@ -1,13 +1,15 @@
1
- import { xhr_get, xhr_post, xhr_put, xhr_del } from '@ajaxjs/util/dist/util/xhr';
1
+ import { Xhr } from "@ajaxjs/util";
2
+ import Vue from "vue";
2
3
 
3
4
  const DBType = { 'MY_SQL': 'MySQL', 'ORACLE': 'Oracle', 'SQL_SERVER': 'Sql Server', 'SPARK': 'Spark', 'SQLITE': 'SQLite', DB2: 'DB2' };
4
- // @ts-ignore
5
+ // @ts-ignore xxxxxxxx
5
6
  const DATASOURCE_API = window.API_ROOT ? API_ROOT + '/data_service/datasource' : '../../data_service/datasource';
6
- // @ts-ignore
7
+ // @ts-ignore xxxxxxxxxx
7
8
  const DATA_SERVICE_API = window.API_ROOT ? API_ROOT + '/data_service/admin' : '../../data_service/admin';
8
9
 
9
- export default {
10
- data(): {} {
10
+ export default Vue.extend({
11
+ name: 'DataSource',
12
+ data(): object {
11
13
  return {
12
14
  isCreate: true,
13
15
  datasources: [
@@ -38,8 +40,8 @@ export default {
38
40
  this.form.data = item;
39
41
  },
40
42
  getList(cb): void {
41
- // @ts-ignore
42
- xhr_get(`${window.config.dsApiRoot}/datasource`, (j: RepsonseResult) => {
43
+ // @ts-ignore xxxx
44
+ xhr_get(`${window.config.dsApiRoot}/datasource`, (j: RepsonseResult) => {
43
45
  this.datasources = j.data;
44
46
  }, { start: 0, limit: 99 });
45
47
  },
@@ -52,9 +54,9 @@ export default {
52
54
  create(): void {
53
55
  this.$refs.editForm.validate((valid) => {
54
56
  if (valid) {
55
- xhr_post(DATASOURCE_API, this.form.data, j => {
57
+ Xhr.xhr_post(DATASOURCE_API, this.form.data, j => {
56
58
  if (j.status === 1) {
57
- let newlyId = j.data;
59
+ const newlyId = j.data;
58
60
  this.getList(() => this.activedItem = newlyId);
59
61
  this.$Message.success('创建数据源成功');
60
62
  this.form.data.id = newlyId;
@@ -65,8 +67,8 @@ export default {
65
67
  });
66
68
  },
67
69
  update(): void {
68
- let entity = Object.assign({}, this.form.data);
69
- xhr_put(DATASOURCE_API, entity, j => {
70
+ const entity = Object.assign({}, this.form.data);
71
+ Xhr.xhr_put(DATASOURCE_API, entity, j => {
70
72
  if (j.status === 1) {
71
73
  this.$Message.success('修改数据源成功');
72
74
  }
@@ -77,7 +79,7 @@ export default {
77
79
  title: '删除数据源',
78
80
  content: `是否删除数据源 #${name}?`,
79
81
  onOk: () => {
80
- xhr_del(DATASOURCE_API + id, j => {
82
+ Xhr.xhr_del(DATASOURCE_API + id, j => {
81
83
  this.$Message.success('删除数据源成功');
82
84
  this.getList(() => this.add());
83
85
  });
@@ -85,11 +87,11 @@ export default {
85
87
  });
86
88
  },
87
89
  test(): void {
88
- // @ts-ignore
90
+ // @ts-ignore xxxxxx
89
91
  xhr_get(`${window.config.dsApiRoot}/datasource/test/` + this.activedItem, (j: RepsonseResult) => {
90
92
  if (j.status)
91
93
  this.$Modal.success({ title: '连接数据源成功' });
92
94
  });
93
95
  }
94
96
  }
95
- };
97
+ });
@@ -1,6 +1,4 @@
1
-
2
-
3
- import { setBaseHeadParams } from "@ajaxjs/util/dist/util/xhr";
1
+ import { Xhr } from "@ajaxjs/util";
4
2
 
5
3
  /**
6
4
  * 获取登录信息
@@ -42,7 +40,7 @@ export default {
42
40
  }
43
41
 
44
42
  // window.JWT_TOKEN = JSON.parse(accessToken);
45
- setBaseHeadParams({ Authorization: 'Bearer ' + accessToken });
43
+ Xhr.setBaseHeadParams({ Authorization: 'Bearer ' + accessToken });
46
44
 
47
45
  // 将 JWT Token 拆分为三个部分
48
46
  const tokenParts: string[] = accessToken.split('.')
@@ -1,21 +1,20 @@
1
1
  <template>
2
- <a @click="showUserInfo">{{ state }}
3
-
4
-
5
- </a>
2
+ <a @click="showUserInfo">{{ state }}</a>
6
3
  </template>
7
4
 
8
5
  <script lang="ts">
9
- import {dateFormat} from '@ajaxjs/util/dist/util/utils';
6
+ import { Utils } from "@ajaxjs/util";
7
+ import Vue from "vue";
10
8
 
11
- const logout:string = "localStorage.removeItem('accessToken');location.reload();";
9
+ const logout = "localStorage.removeItem('accessToken');location.reload();";
12
10
 
13
- export default {
11
+ export default Vue.extend({
12
+ name: 'IAM',
14
13
  data() {
15
14
  return {
16
15
  state: "未登录",
17
16
  isShowInfo: false,
18
- payload:null
17
+ payload: null,
19
18
  };
20
19
  },
21
20
 
@@ -28,23 +27,27 @@ export default {
28
27
  const tokenParts: string[] = accessToken.split(".");
29
28
  const payload = JSON.parse(atob(tokenParts[1])); // 解析载荷
30
29
 
31
- console.log(payload)
32
30
  this.payload = payload;
33
- this.state = payload.name;
31
+ this.state = payload.name + "已登录";
34
32
  }
35
33
  },
36
34
  methods: {
37
35
  showUserInfo(): void {
38
36
  if (this.state === "未登录") {
39
- // @ts:ignore
37
+ // @ts-ignore xxx
40
38
  location.assign(window.config.loginUrl);
41
39
  } else {
42
- this.$Modal.info({
43
- title: '当前用户信息',
44
- content: `<p>用户名: ${this.payload.name}</p><p>Token 过期时间:${dateFormat.call(new Date(this.payload.exp * 1000), 'yyyy-MM-dd hh:mm:ss')}</p><p><a href="#" onclick="${logout}">用户登出</a></p>`
45
- });
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
+ });
46
49
  }
47
50
  },
48
51
  },
49
- };
52
+ });
50
53
  </script>
package/src/index.js ADDED
@@ -0,0 +1,48 @@
1
+ // 动态引入组件
2
+ const requireComponent = require.context('./', true, /\.vue$/);
3
+ // import FooAbc from './FooAbc.vue';
4
+ const components = [];
5
+
6
+ requireComponent.keys().forEach(fileName => {
7
+ if (fileName != './App.vue') {
8
+ const cmp = requireComponent(fileName).default || requireComponent(fileName);
9
+ if (cmp.extendOptions)
10
+ components.push(cmp);
11
+ }
12
+ });
13
+
14
+ // 插件
15
+ const install = (Vue) => {
16
+ if (install.installed)
17
+ return install.installed;
18
+
19
+ requireComponent.keys().forEach(fileName => {
20
+ if (fileName != './App.vue') {
21
+ // 第i个组件
22
+ const cmp = requireComponent(fileName).default || requireComponent(fileName);
23
+
24
+ if (cmp.extendOptions && cmp.extendOptions.name) {
25
+ // console.log(fileName, cmp.extendOptions.name);
26
+
27
+ // 注册组件(组件名,组件)
28
+ Vue.component(cmp.extendOptions.name, cmp);
29
+ }
30
+ }
31
+ });
32
+
33
+ // 全局自定义指令
34
+ Vue.directive('focus', {
35
+ inserted: function (el) {
36
+ el.focus();
37
+ }
38
+ });
39
+ }
40
+
41
+ // 环境检测
42
+ if (typeof window !== 'undefined' && window.Vue)
43
+ install(window.Vue);
44
+
45
+ export default {
46
+ install,
47
+ ...components//组件也一样要暴露
48
+ }
@@ -0,0 +1,131 @@
1
+ import List from './list';
2
+ import { Xhr } from "@ajaxjs/util";
3
+
4
+ export default {
5
+ props: {
6
+ widgetName: { type: String, required: false },
7
+ apiUrl: { type: String, required: false }, // 接口地址
8
+ columnsDef: { type: Array, required: false }, // 列定义
9
+ listApiUrl: { type: String, required: true },
10
+ createRoute: { type: String, required: false }, // 新建事件触发时候,进入的路由地址
11
+ editRoute: { type: String, required: false }, // 编辑事件触发时候,进入的路由地址
12
+ pickup: { type: Boolean, required: false }, // 编辑事件触发时候,进入的路由地址
13
+ },
14
+ data() {
15
+ return {
16
+ widgetName_: this.widgetName,
17
+ listApiUrl_: this.listApiUrl,
18
+ colDefId: 0,
19
+ list: {
20
+ columns: this.columnsDef || [],
21
+ data: [],
22
+ total: 0,
23
+ start: 0,
24
+ limit: 9,
25
+ pageNo: 1,
26
+ pageSize: 9,
27
+ loading: false,
28
+ search: {
29
+ name: ''
30
+ },
31
+ } as TableListConfig
32
+ };
33
+ },
34
+ mounted() {
35
+ this.getData();
36
+ },
37
+ methods: {
38
+ getData(): void {
39
+ this.list.loading = true;
40
+ const params: any = { pageNo: this.list.pageNo, pageSize: this.list.pageSize };
41
+
42
+ // if (this.list.search.name)
43
+ // params.where = `name LIKE '%${this.list.search.name}%'`;
44
+
45
+ this.listApiUrl_ && Xhr.xhr_get(this.listApiUrl_, (j: RepsonseResult) => {
46
+ this.list.loading = false;
47
+
48
+ if (j.status) {
49
+ this.list.data = j.data.rows;
50
+ this.list.total = j.data.total;
51
+ } else
52
+ this.$Message.warning(j.message || '获取列表失败');
53
+ }, params);
54
+ },
55
+
56
+ /**
57
+ * 分页记录数
58
+ */
59
+ handleChangePageSize(pageSize: number): void {
60
+ this.list.limit = pageSize;
61
+ this.getData();
62
+ },
63
+ reset(): void {
64
+ for (const i in this.search)
65
+ this.search[i] = "";
66
+
67
+ this.getData();
68
+ },
69
+
70
+ /**
71
+ * 新建
72
+ */
73
+ onCreate(): void {
74
+ if (this.createRoute)
75
+ this.$router.push({ path: this.createRoute }); // 进入详情页,采用相对路径
76
+ else {
77
+ if (!this.$parent.onCreate)
78
+ throw '请设置父组件的 onCreate 事件处理器';
79
+
80
+ this.$parent.onCreate();
81
+ }
82
+ },
83
+
84
+ /**
85
+ * 编辑
86
+ */
87
+ onEdit(id: number): void {
88
+ if (this.editRoute)
89
+ this.$router.push({ path: this.editRoute, query: { id } }); // 进入详情页,采用相对路径
90
+ else {
91
+ if (!this.$parent.onEdit)
92
+ throw '请设置父组件的 onEdit 事件处理器';
93
+
94
+ this.$parent.onEdit(id);
95
+ }
96
+ },
97
+
98
+ doPickup(data: any): void {
99
+ this.$emit("on-select", data);
100
+ },
101
+ deleteInfo(id: number, index: number): void {
102
+ this.list.loading = true;
103
+ Xhr.xhr_del(`${this.apiUrl}/${id}`, List.afterDelete(() => {
104
+ this.list.data.splice(index, 1);
105
+ this.list.total--;
106
+ this.list.loading = false;
107
+ }).bind(this));
108
+ },
109
+ },
110
+ watch: {
111
+ listApiUrl(v: string): void {
112
+ // debugger
113
+ this.listApiUrl_ = v;
114
+ this.getData();
115
+ },
116
+
117
+ /**
118
+ * 分页
119
+ *
120
+ * @param v
121
+ */
122
+ current(v: number): void {
123
+ this.start = (v - 1) * this.list.limit;
124
+ this.getData();
125
+ },
126
+ 'list.pageNo'(v: number): void {
127
+ this.list.start = (v - 1) * this.list.limit;
128
+ this.getData();
129
+ }
130
+ },
131
+ };
@@ -0,0 +1,67 @@
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>
@@ -1,14 +1,13 @@
1
- import { dateFormat } from '@ajaxjs/util/dist/util/utils';
2
- import { xhr_del } from '@ajaxjs/util/dist/util/xhr';
1
+ import { Xhr, Utils } from "@ajaxjs/util";
3
2
 
4
3
  /**
5
4
  * 处理响应的回调函数
6
5
  */
7
- type XhrCallback = (json: {}, text: string) => void;
6
+ type XhrCallback = (json: object, text: string) => void;
8
7
 
9
8
  export default {
10
- afterDelete(cb?: Function): Function {
11
- return function (j: RepsonseResult) {
9
+ afterDelete(cb?: (a: RepsonseResult) => void): (j: RepsonseResult) => void {
10
+ return function (j: RepsonseResult): void {
12
11
  if (j.status) {
13
12
  cb && cb(j);
14
13
  this.$Message.success('删除成功');
@@ -19,7 +18,7 @@ export default {
19
18
  },
20
19
 
21
20
  delInfo(index: number) {
22
- xhr_del(`${this.API}/${this.list.data[index].id}`, (j: RepsonseResult) => {
21
+ Xhr.xhr_del(`${this.API}/${this.list.data[index].id}`, (j: RepsonseResult) => {
23
22
  if (j.status) {
24
23
  this.list.data.splice(index, 1);
25
24
  this.list.total--;
@@ -38,8 +37,8 @@ export default {
38
37
  * 创建日期
39
38
  */
40
39
  createDate: {
41
- title: '创建日期',/* key: 'createDate', */ width: 160, align: 'center', render(h: Function, params: any) {
42
- return h('div', dateFormat.call(new Date(params.row.createDate), 'yyyy-MM-dd hh:mm'));
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'));
43
42
  }
44
43
  },
45
44
 
@@ -50,8 +49,8 @@ export default {
50
49
 
51
50
  status: {
52
51
  title: '状态', width: 80,
53
- render(h: Function, params: any) {
54
- let str: string = '', color: string = '';
52
+ render(h: (a: string, b: object, c: string) => void, params: any) {
53
+ let str = '', color = '';
55
54
 
56
55
  switch (params.row.stat) {
57
56
  case -1:
@@ -80,7 +79,7 @@ export default {
80
79
  }, str);
81
80
  }
82
81
  },
83
- getPageList(self: any, listArray: any, callback?: Function): XhrCallback {
82
+ getPageList(self: any, listArray: any, callback?: () => void): XhrCallback {
84
83
  return (j: JsonResponse) => {
85
84
  if (j.status) {
86
85
  listArray.total = j.data.total;
@@ -92,7 +91,7 @@ export default {
92
91
  }
93
92
  },
94
93
 
95
- copyBeanClean(bean: {}): {} {
94
+ copyBeanClean(bean: object): object {
96
95
  const deepCopy: any = JSON.parse(JSON.stringify(bean));
97
96
 
98
97
  delete deepCopy.createDate;
@@ -28,10 +28,12 @@
28
28
  </template>
29
29
 
30
30
  <script>
31
- import { xhr_get, getPageList } from '@ajaxjs/util/dist/util/xhr';
31
+ import Vue from "vue";
32
+ import { Xhr, Utils } from "@ajaxjs/util";
32
33
 
33
34
  // 选择表
34
- export default {
35
+ export default Vue.extend({
36
+ name: "TableSelector",
35
37
  data() {
36
38
  return {
37
39
  // isCrossDb: false,
@@ -80,13 +82,13 @@ export default {
80
82
  methods: {
81
83
  getData() {
82
84
  this.loading = true;
83
- let url =`${window.config.dsApiRoot}/datasource/${this.dataSourceId}/get_all_tables?start=${this.start}&limit=${this.pageSize}`;
85
+ let url = `${window.config.dsApiRoot}/datasource/${this.dataSourceId}/get_all_tables?start=${this.start}&limit=${this.pageSize}`;
84
86
  // let url = `${DS_CONFIG.API_ROOT}/admin0/${this.dataSourceId}/getAllTables?start=${this.start}&limit=${this.pageSize}`;
85
87
 
86
88
  if (this.searchKeyword) url += `&tableName=${this.searchKeyword}`;
87
89
  if (this.databaseName) url += `&dbName=${this.databaseName}`;
88
90
 
89
- xhr_get(url, (j) => {
91
+ Xhr.xhr_get(url, (j) => {
90
92
  if (j.status) {
91
93
  this.data = j.data.rows;
92
94
  this.total = j.data.total;
@@ -102,9 +104,9 @@ export default {
102
104
  this.listData = this.data.slice(start, end);
103
105
  },
104
106
  onSelect(arr) {
105
- arr.forEach((item) => {
106
- this.data.forEach((_item) => {});
107
- });
107
+ // arr.forEach((item) => {
108
+ // this.data.forEach((_item) => {});
109
+ // });
108
110
  },
109
111
  resetData() {
110
112
  this.searchKeyword = "";
@@ -150,12 +152,15 @@ export default {
150
152
  dataSourceId(id) {
151
153
  if (id) {
152
154
  if (this.isCrossDb)
153
- aj.xhr.get(
154
- `${DS_CONFIG.API_ROOT}/admin/${this.dataSourceId}/get_databases`,
155
- (j) => {
155
+ Xhr.xhr_get(`/admin/${this.dataSourceId}/get_databases`, (j) => {
156
156
  if (j.status) {
157
157
  // 过滤 mysql 自带的库
158
- let not = ["information_schema", "performance_schema", "sys", "mysql"];
158
+ let not = [
159
+ "information_schema",
160
+ "performance_schema",
161
+ "sys",
162
+ "mysql",
163
+ ];
159
164
  let arr = j.data.filter((db) => !not.includes(db));
160
165
  this.databaseList = arr;
161
166
 
@@ -176,5 +181,5 @@ export default {
176
181
  this.getData(); // 会重复请求
177
182
  },
178
183
  },
179
- };
184
+ });
180
185
  </script>