tianheng-ui 0.1.14 → 0.1.16

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tianheng-ui",
3
3
  "description": "A Vue.js project",
4
- "version": "0.1.14",
4
+ "version": "0.1.16",
5
5
  "author": "shu lang <403732931@qq.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -6,6 +6,33 @@ export const search = {
6
6
 
7
7
  // 列表配置
8
8
  export const table = {
9
+ mounted: {
10
+ api: ""
11
+ },
12
+ style: {
13
+ cell: {
14
+ customStyle: "",
15
+ margin: "",
16
+ padding: "20rpx",
17
+ "border-bottom": "1px solid #e5e5e5"
18
+ },
19
+ title: {
20
+ customStyle: "",
21
+ margin: "",
22
+ padding: "",
23
+ width: "",
24
+ "text-align": "",
25
+ color: "#999"
26
+ },
27
+ value: {
28
+ customStyle: "",
29
+ margin: "",
30
+ padding: "",
31
+ width: "",
32
+ "text-align": "",
33
+ color: "#333"
34
+ }
35
+ },
9
36
  options: [],
10
37
  pageInfo: {
11
38
  show: true,
@@ -35,72 +62,91 @@ export const table = {
35
62
  };
36
63
 
37
64
  // 按钮配置
65
+ const buttonStyle = {
66
+ type: "",
67
+ size: "small",
68
+ plain: false,
69
+ round: false,
70
+ circle: false,
71
+ disabled: false,
72
+ icon: ""
73
+ };
74
+
38
75
  export const tools = {
39
76
  add: {
40
77
  show: true,
78
+ type: "add",
41
79
  name: "新增",
42
80
  text: "新增",
43
81
  position: "header",
44
82
  form: "",
45
- api: ""
83
+ api: "",
84
+ style: buttonStyle
46
85
  },
47
86
  edit: {
48
87
  show: true,
88
+ type: "edit",
49
89
  name: "编辑",
50
90
  text: "编辑",
51
91
  position: "row",
52
92
  form: "",
53
- api: ""
93
+ api: "",
94
+ style: buttonStyle
54
95
  },
55
- detail: {
96
+ look: {
56
97
  show: false,
98
+ type: "look",
57
99
  name: "查看",
58
100
  text: "查看",
59
101
  position: "row",
60
102
  form: "",
61
- api: ""
103
+ api: "",
104
+ style: buttonStyle
62
105
  },
63
106
  delete: {
64
107
  show: true,
108
+ type: "delete",
65
109
  name: "删除",
66
110
  text: "删除",
67
111
  position: "row",
68
112
  form: "",
69
- api: ""
113
+ api: "",
114
+ style: buttonStyle
70
115
  },
71
116
  batchDelete: {
72
117
  show: false,
118
+ type: "batchDelete",
73
119
  name: "批量删除",
74
120
  text: "批量删除",
75
121
  position: "header",
76
122
  form: "",
77
- api: ""
123
+ api: "",
124
+ style: buttonStyle
78
125
  },
79
126
  export: {
80
127
  show: false,
128
+ type: "export",
81
129
  name: "导出",
82
130
  text: "导出",
83
131
  position: "header",
84
132
  form: "",
85
- api: ""
133
+ api: "",
134
+ style: buttonStyle
86
135
  },
87
136
  import: {
88
137
  show: false,
138
+ type: "import",
89
139
  name: "导入",
90
140
  text: "导入",
91
141
  position: "header",
92
142
  form: "",
93
- api: ""
143
+ api: "",
144
+ style: buttonStyle
94
145
  }
95
146
  };
96
147
 
97
148
  // 接口配置
98
- export const network = {
99
- mounted: {
100
- method: "get",
101
- api: "/list"
102
- }
103
- };
149
+ export const network = {};
104
150
 
105
151
  export const tableConfig = {
106
152
  search,
@@ -43,8 +43,36 @@ export default {
43
43
  }
44
44
  },
45
45
  fields: Array,
46
+
47
+ /**
48
+ * 表单配置列表。
49
+ * 只关联表单id,渲染器通过接口查询表单配置信息
50
+ * [
51
+ * {
52
+ * id:'', 表单id
53
+ * label:'', 表单名称
54
+ * }
55
+ * ]
56
+ */
46
57
  formOptions: Array,
58
+
59
+ /**
60
+ * 接口配置列表,会包装到 config.network 对象中。
61
+ * 只关联接口id,渲染器会通过关联接口id在 config.network 中过滤查询对应的接口
62
+ * [
63
+ * {
64
+ * id:'', 接口id
65
+ * label:'', 接口名称
66
+ * url:'', 接口地址
67
+ * method:'', 请求方式
68
+ * params:{}, 请求参数
69
+ * header:{}, 请求头
70
+ * }
71
+ * ]
72
+ *
73
+ */
47
74
  apiOptions: Array,
75
+
48
76
  permissions: {
49
77
  type: Array,
50
78
  default: () => [
@@ -73,10 +101,21 @@ export default {
73
101
  },
74
102
  data(val) {
75
103
  this.config = val;
104
+ this.handleNetwork();
105
+ },
106
+ apiOptions(val) {
107
+ this.handleNetwork();
76
108
  }
77
109
  },
78
110
  mounted() {},
79
111
  methods: {
112
+ handleNetwork() {
113
+ const network = {};
114
+ this.apiOptions.map(item => {
115
+ network[item.id] = item;
116
+ });
117
+ this.config.network = network;
118
+ },
80
119
  handleToolsClick(action, data) {
81
120
  switch (action) {
82
121
  case "import-json":
@@ -88,7 +127,27 @@ export default {
88
127
  }
89
128
  },
90
129
  getJson() {
91
- return this.config;
130
+ return new Promise((resolve, reject) =>
131
+ this.$refs.configRef
132
+ .handleFormValidate()
133
+ .then(res => {
134
+ if (res) {
135
+ const data = deepClone(this.config);
136
+ resolve(data);
137
+ } else {
138
+ reject();
139
+ }
140
+ })
141
+ .catch(err => {
142
+ if (!this.config.table.mounted.api) {
143
+ this.$message.warning("请选择列表接口");
144
+ reject();
145
+ } else {
146
+ const data = deepClone(this.config);
147
+ resolve(data);
148
+ }
149
+ })
150
+ );
92
151
  }
93
152
  }
94
153
  };