tianheng-ui 0.1.68 → 0.1.69

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.68",
4
+ "version": "0.1.69",
5
5
  "author": "shu lang <403732931@qq.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -36,9 +36,10 @@
36
36
  </template>
37
37
 
38
38
  <script>
39
- import * as Axios from "lib/theme-chalk/js/axios";
40
- import { deepClone, getProperty, setProperty } from "./util/index";
41
39
  import GenetateFormItem from "./GenerateFormItem";
40
+ import * as Axios from "./network/axios";
41
+ import appConfig from "./config/index";
42
+ import { deepClone, getProperty, setProperty } from "./util/index";
42
43
 
43
44
  export default {
44
45
  name: "thFormGenerate",
@@ -95,11 +96,14 @@ export default {
95
96
  console.log("watch models =>", this.models);
96
97
  }
97
98
  },
98
- created() {
99
- localStorage.setItem("_TH_OauthConfig", JSON.stringify(this.oauthConfig));
100
- this.axios = Axios.init(this.oauthConfig);
101
- },
99
+ created() {},
102
100
  mounted() {
101
+ sessionStorage.setItem(
102
+ appConfig.storageKeys.oauthConfig,
103
+ JSON.stringify(this.oauthConfig)
104
+ );
105
+ this.axios = Axios.init(this.oauthConfig);
106
+
103
107
  this.generateModle(this.formConfig.list, this.models);
104
108
  console.log("mounted models =>", this.models);
105
109
  this.handleMountedRemotData();
@@ -298,7 +302,9 @@ export default {
298
302
  initParams(item.children);
299
303
  } else {
300
304
  const value =
301
- item.defaultValue || getProperty(this.models, item.pAlias) || null;
305
+ item.defaultValue ||
306
+ getProperty(this.models, item.pAlias) ||
307
+ null;
302
308
  setProperty(params, item.pAlias, value);
303
309
  }
304
310
  });
@@ -224,7 +224,6 @@
224
224
  <script>
225
225
  import { deepClone } from "./util/index";
226
226
  import * as XLSX from "xlsx/xlsx.mjs";
227
- import request from "./util/request";
228
227
  import generateCode from "./util/generateCode.js";
229
228
  import GenerateForm from "./GenerateForm";
230
229
  export default {
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ title: "FormMaking",
3
+ logo: '',
2
4
  version: "1.0.0",
3
5
  storageKeys: {
4
6
  oauthConfig: "_TH_OauthConfig"
@@ -254,7 +254,7 @@ export const basicComponents = [
254
254
  rules: []
255
255
  },
256
256
  {
257
- name: "下拉选择框",
257
+ name: "下拉选择器",
258
258
  type: "select",
259
259
  icon: "icon-select",
260
260
  options: {
@@ -597,7 +597,7 @@ export const basicComponents = [
597
597
 
598
598
  export const advanceComponents = [
599
599
  {
600
- name: "子表单",
600
+ name: "子表格",
601
601
  type: "table",
602
602
  icon: "th-icon-insertrowabove",
603
603
  options: {
@@ -629,7 +629,7 @@ export const advanceComponents = [
629
629
  rules: []
630
630
  },
631
631
  {
632
- name: "子表单H5",
632
+ name: "子表格H5",
633
633
  type: "tableH5",
634
634
  icon: "th-icon-insertrowleft",
635
635
  options: {
@@ -662,7 +662,7 @@ export const advanceComponents = [
662
662
  type: "list",
663
663
  icon: "th-icon-orderedlist",
664
664
  options: {
665
- defaultValue: "",
665
+ defaultValue: [],
666
666
  columns: [],
667
667
  customClass: "",
668
668
  labelWidth: 100,
@@ -825,7 +825,7 @@ export const businessComponents = [
825
825
  {
826
826
  name: "描述列表",
827
827
  type: "descriptions",
828
- icon: "th-icon-layout",
828
+ icon: "th-icon-detail",
829
829
  options: {
830
830
  border: false,
831
831
  column: 1,
@@ -925,7 +925,7 @@ export const businessComponents = [
925
925
  {
926
926
  name: "流程节点",
927
927
  type: "workflow",
928
- icon: "th-icon-layout",
928
+ icon: "th-icon-apartment",
929
929
  options: {
930
930
  reverse: false,
931
931
  placement: "right",
@@ -6,10 +6,12 @@
6
6
  </el-form-item>
7
7
 
8
8
  <el-form-item label="栅格间隔">
9
- <el-input
10
- type="number"
11
- v-model.number="widget.options.gutter"
12
- ></el-input>
9
+ <el-input-number
10
+ style="width:100%"
11
+ v-model="widget.options.gutter"
12
+ controls-position="right"
13
+ :min="0"
14
+ ></el-input-number>
13
15
  </el-form-item>
14
16
 
15
17
  <el-form-item label="列配置项">
@@ -28,7 +30,13 @@
28
30
  :key="index"
29
31
  >
30
32
  <i class="drag"><i class="iconfont icon-icon_bars"></i></i>
31
- <el-input v-model.number="item.span" type="number"> </el-input>
33
+ <el-input-number
34
+ style="width:100%"
35
+ v-model="item.span"
36
+ controls-position="right"
37
+ :min="0"
38
+ :max="24"
39
+ ></el-input-number>
32
40
  <el-button
33
41
  class="delete"
34
42
  circle
@@ -39,12 +47,12 @@
39
47
  ></el-button>
40
48
  </div>
41
49
  </draggable>
42
- <div style="margin-left: 22px;text-align: right;">
50
+ <div style="margin-left: 22px;">
43
51
  <el-button type="text" @click="handleAddOption">添加列</el-button>
44
52
  </div>
45
53
  </el-form-item>
46
54
 
47
- <el-form-item label="水平排列方式">
55
+ <el-form-item label="水平排列">
48
56
  <el-select v-model="widget.options.justify">
49
57
  <el-option value="start" label="左对齐"></el-option>
50
58
  <el-option value="end" label="右对齐"></el-option>
@@ -54,7 +62,7 @@
54
62
  </el-select>
55
63
  </el-form-item>
56
64
 
57
- <el-form-item label="垂直排列方式">
65
+ <el-form-item label="垂直排列">
58
66
  <el-select v-model="widget.options.align">
59
67
  <el-option value="top" label="顶部对齐"></el-option>
60
68
  <el-option value="middle" label="居中"></el-option>
@@ -107,7 +115,7 @@ export default {
107
115
  display: flex;
108
116
  align-items: center;
109
117
 
110
- .el-input {
118
+ .el-input-number {
111
119
  margin: 0 5px;
112
120
  }
113
121
 
@@ -1,18 +1,100 @@
1
1
  <template>
2
- <div>
3
-
2
+ <div class="component-config">
3
+ <el-collapse-item title="组件配置" name="group-element">
4
+ <el-form-item label="标题">
5
+ <el-input v-model="widget.name" clearable></el-input>
6
+ </el-form-item>
7
+
8
+ <el-form-item label="标签宽度">
9
+ <div style="display: flex;">
10
+ <el-checkbox v-model="widget.options.isLabelWidth"
11
+ >自定义</el-checkbox
12
+ >
13
+ <el-input-number
14
+ style="margin-left:5px;"
15
+ v-model="widget.options.labelWidth"
16
+ controls-position="right"
17
+ :min="0"
18
+ :max="200"
19
+ :disabled="!widget.options.isLabelWidth"
20
+ >
21
+ </el-input-number>
22
+ </div>
23
+ </el-form-item>
24
+
25
+ <el-form-item label-width="0">
26
+ <div class="config-header">
27
+ <span class="title">默认值</span>
28
+ <span class="value" @click="handleAddData">添加数据</span>
29
+ </div>
30
+ <code-editor
31
+ v-model="widget.options.defaultValue"
32
+ language="json"
33
+ ></code-editor>
34
+ </el-form-item>
35
+
36
+ <el-form-item label="新增按钮">
37
+ <el-input v-model.number="widget.options.addButtonText"></el-input>
38
+ </el-form-item>
39
+
40
+ <el-form-item label="删除按钮">
41
+ <el-input v-model.number="widget.options.deleteButtonText"></el-input>
42
+ </el-form-item>
43
+
44
+ <el-form-item label="可删除的最小索引">
45
+ <el-input-number v-model="widget.options.deleteIndex" :min="0">
46
+ </el-input-number>
47
+ </el-form-item>
48
+
49
+ <el-form-item label="操作属性">
50
+ <el-checkbox v-model="widget.options.disabled">禁用 </el-checkbox>
51
+ <el-checkbox v-model="widget.options.hidden">隐藏组件 </el-checkbox>
52
+ <el-checkbox v-model="widget.options.hideLabel">隐藏标签 </el-checkbox>
53
+ <el-checkbox v-model="widget.options.isAdd">可新增 </el-checkbox>
54
+ <el-checkbox v-model="widget.options.isDelete">可删除 </el-checkbox>
55
+ </el-form-item>
56
+
57
+ <el-form-item label="校验">
58
+ <el-checkbox v-model="widget.options.required">必填</el-checkbox>
59
+ </el-form-item>
60
+ </el-collapse-item>
4
61
  </div>
5
62
  </template>
6
63
 
7
64
  <script>
65
+ import Draggable from "vuedraggable";
66
+ import { configComponent } from "../mixins";
67
+ import CodeEditor from "ui/CodeEditor/index.vue";
8
68
  export default {
9
- data() {
10
- return {};
69
+ components: {
70
+ Draggable,
71
+ CodeEditor
11
72
  },
12
- created() {},
73
+ props: {},
74
+ mixins: [configComponent],
13
75
  mounted() {},
14
- methods: {},
76
+ methods: {
77
+ handleAddData() {
78
+ let defaultValue = JSON.parse(this.widget.options.defaultValue || "[]");
79
+ let dic = {};
80
+ this.widget.options.columns.forEach(item => {
81
+ if (item.type === "grid") {
82
+ for (let i = 0; i < item.options.columns.length; i++) {
83
+ const element = item.options.columns[i];
84
+ for (let j = 0; j < element.list.length; j++) {
85
+ const element2 = element.list[j];
86
+ dic[element2.model] = element2.options.defaultValue;
87
+ }
88
+ }
89
+ } else {
90
+ dic[item.model] = item.options.defaultValue;
91
+ }
92
+ });
93
+ defaultValue.push(dic);
94
+ this.widget.options.defaultValue = JSON.stringify(defaultValue, null, 2);
95
+ }
96
+ }
15
97
  };
16
98
  </script>
17
99
 
18
- <style lang="scss" scoped></style>
100
+ <style lang="scss" scoped></style>
@@ -1,18 +1,119 @@
1
1
  <template>
2
- <div>
3
-
2
+ <div class="component-list">
3
+ <div
4
+ v-for="(column, columnIndex) in dataModel"
5
+ class="tableH5-list"
6
+ :key="`tableH5_${columnIndex}`"
7
+ >
8
+ <div
9
+ v-for="(element, elementIndex) in widget.options.columns"
10
+ class="tableH5-list-item"
11
+ :key="`tableH5_${columnIndex}_${element.key}`"
12
+ >
13
+ <generate-form-item
14
+ style="flex:1;"
15
+ :widget="element"
16
+ :model.sync="
17
+ element.type === 'grid' && !element.options.isEntity
18
+ ? column
19
+ : column[element.model]
20
+ "
21
+ :models="models"
22
+ :pModel="
23
+ pModel
24
+ ? `${pModel}.${columnIndex}`
25
+ : `${widget.model}.${columnIndex}`
26
+ "
27
+ :config="config"
28
+ :slotKeys="slotKeys"
29
+ :componentsData="componentsData"
30
+ >
31
+ <template v-for="name in slotKeys" :slot="name">
32
+ <slot :name="name" />
33
+ </template>
34
+ </generate-form-item>
35
+ <div
36
+ v-if="
37
+ widget.options.isDelete &&
38
+ elementIndex === 0 &&
39
+ columnIndex >= widget.options.deleteIndex
40
+ "
41
+ class="actions"
42
+ >
43
+ <el-button
44
+ type="danger"
45
+ @click.native.prevent="dataModel.splice(columnIndex, 1)"
46
+ >{{ widget.options.deleteButtonText }}</el-button
47
+ >
48
+ </div>
49
+ </div>
50
+ </div>
51
+
52
+ <div v-if="widget.options.isAdd" style="text-align: center;">
53
+ <el-button
54
+ type="text"
55
+ :disabled="widget.options.disabled"
56
+ @click="handleTableAdd"
57
+ >{{ widget.options.addButtonText }}</el-button
58
+ >
59
+ </div>
4
60
  </div>
5
61
  </template>
6
62
 
7
63
  <script>
64
+ import { itemsComponent, eventMixin } from "../mixins/index";
65
+ import GenerateFormItem from "../../GenerateFormItem.vue";
8
66
  export default {
67
+ components: { GenerateFormItem },
68
+ mixins: [itemsComponent, eventMixin],
69
+ props: ["models", "prop", "slotKeys", "componentsData"],
9
70
  data() {
10
71
  return {};
11
72
  },
12
- created() {},
13
- mounted() {},
14
- methods: {},
73
+ methods: {
74
+ handleTableAdd() {
75
+ let dic = {};
76
+ const initData = (list, data) => {
77
+ for (const item of list) {
78
+ if (item.type === "grid") {
79
+ if (item.options.isEntity) data[item.model] = {};
80
+ for (const column of item.options.columns) {
81
+ initData(
82
+ column.list,
83
+ item.options.isEntity ? data[item.model] : data
84
+ );
85
+ }
86
+ } else {
87
+ data[item.model] = item.options.defaultValue;
88
+ }
89
+ }
90
+ };
91
+ initData(this.widget.options.columns, dic);
92
+ this.dataModel.push(dic);
93
+ }
94
+ }
15
95
  };
16
96
  </script>
17
97
 
18
- <style lang="scss" scoped></style>
98
+ <style lang="scss" scoped>
99
+ .component-list {
100
+ background: #fff;
101
+
102
+ .tableH5-list {
103
+ .tableH5-list-item {
104
+ width: 100%;
105
+ }
106
+ .tableH5-list-item:nth-child(1) {
107
+ display: flex;
108
+ > div:first-child {
109
+ flex: 1;
110
+ margin-right: 10px;
111
+ }
112
+ }
113
+ }
114
+
115
+ .footer {
116
+ text-align: center;
117
+ }
118
+ }
119
+ </style>
@@ -54,6 +54,8 @@
54
54
 
55
55
  <script>
56
56
  import { itemsComponent, eventMixin } from "../mixins/index";
57
+ import appConfig from "../../config/index";
58
+
57
59
  export default {
58
60
  mixins: [itemsComponent, eventMixin],
59
61
  data() {
@@ -65,7 +67,7 @@ export default {
65
67
  computed: {
66
68
  uploadUrl() {
67
69
  if (this.widget.options.remote.open) {
68
- const info = sessionStorage.getItem("th_oauth_info");
70
+ const info = sessionStorage.getItem(appConfig.storageKeys.oauthConfig);
69
71
  let baseUrl = "";
70
72
  if (info) baseUrl = JSON.parse(info).baseUrl;
71
73
  const func = this.config.network[this.widget.options.remote.api];
@@ -171,6 +171,7 @@ import {
171
171
  baseConfig
172
172
  } from "./custom/config";
173
173
  import generateCode from "./util/generateCode.js";
174
+ import appConfig from "./config/index";
174
175
  import { deepClone } from "./util/index";
175
176
 
176
177
  export default {
@@ -314,7 +315,10 @@ export default {
314
315
  token: this.oauthConfig.token,
315
316
  baseUrl: this.oauthConfig.baseUrl
316
317
  };
317
- sessionStorage.setItem("th_oauth_info", JSON.stringify(oauthInfo));
318
+ sessionStorage.setItem(
319
+ appConfig.storageKeys.oauthConfig,
320
+ JSON.stringify(oauthInfo)
321
+ );
318
322
  } else if (this.oauthConfig.oauth) {
319
323
  // 模拟授权认证流程
320
324
  this.axios({
@@ -327,7 +331,10 @@ export default {
327
331
  token: res.data,
328
332
  baseUrl: this.oauthConfig.baseUrl
329
333
  };
330
- sessionStorage.setItem("th_oauth_info", JSON.stringify(oauthInfo));
334
+ sessionStorage.setItem(
335
+ appConfig.storageKeys.oauthConfig,
336
+ JSON.stringify(oauthInfo)
337
+ );
331
338
  });
332
339
  }
333
340
  },
@@ -488,6 +495,7 @@ export default {
488
495
  align-items: center;
489
496
  height: 45px;
490
497
  padding: 0 15px;
498
+ z-index: 99;
491
499
  }
492
500
  ul {
493
501
  position: relative;
@@ -11,7 +11,7 @@ export default {
11
11
  date: '日期选择器',
12
12
  rate: '评分',
13
13
  color: '颜色选择器',
14
- select: '下拉选择框',
14
+ select: '下拉选择器',
15
15
  switch: '开关',
16
16
  slider: '滑块',
17
17
  text: '文字',
@@ -20,7 +20,7 @@ export default {
20
20
  upload: '图片',
21
21
  editor: '编辑器',
22
22
  cascader: '级联选择器',
23
- table: '子表单',
23
+ table: '子表格',
24
24
  grid: '栅格布局',
25
25
  tabs: '标签页',
26
26
  divider: '分割线'
@@ -0,0 +1,88 @@
1
+ import axios from "axios";
2
+ import Log from "../util/Log";
3
+ import appConfig from "../config/index";
4
+ import { Notification } from "element-ui";
5
+
6
+ export const init = baseConfig => {
7
+ // 创建axios实例
8
+ const Axios = axios.create({
9
+ baseURL: baseConfig.baseUrl,
10
+ timeout: 60000 // 请求超时时间
11
+ // withCredentials: true, //允许携带cookie
12
+ });
13
+
14
+ // 添加请求拦截器
15
+ Axios.interceptors.request.use(
16
+ config => {
17
+ const info = sessionStorage.getItem(appConfig.storageKeys.oauthConfig);
18
+ if (info) {
19
+ const oauthInfo = JSON.parse(info);
20
+ config.baseURL = oauthInfo.baseUrl;
21
+ config.headers["Authorization"] = oauthInfo.token;
22
+ }
23
+ if (baseConfig.headers) {
24
+ config.headers = Object.assign(config.headers, baseConfig.headers);
25
+ }
26
+ return config;
27
+ },
28
+ error => {
29
+ Promise.reject(error);
30
+ }
31
+ );
32
+
33
+ // 添加响应拦截器
34
+ Axios.interceptors.response.use(
35
+ response => {
36
+ const code = response.status;
37
+ if (code < 200 || code > 300) {
38
+ Notification.error({
39
+ title: response.message
40
+ });
41
+ return Promise.reject("error");
42
+ }
43
+
44
+ const dataCode = response.data.code;
45
+ if (dataCode && dataCode !== 200) {
46
+ Notification.error({
47
+ title: response.data.message
48
+ });
49
+ return Promise.reject("error");
50
+ }
51
+
52
+ if (baseConfig.debug) {
53
+ Log.prettyPrimary("Request Url:", response.request.responseURL);
54
+ Log.prettySuccess("Request Res:", response);
55
+ }
56
+
57
+ return response.data;
58
+ },
59
+ error => {
60
+ let code = 0;
61
+ try {
62
+ code = error.response.data.status;
63
+ } catch (e) {
64
+ if (error.toString().indexOf("Error: timeout") !== -1) {
65
+ Notification.error({
66
+ title: "网络请求超时",
67
+ duration: 5000
68
+ });
69
+ return Promise.reject(error);
70
+ }
71
+ }
72
+ if (code) {
73
+ const errorMsg = error.response.data.message;
74
+ Notification.error({
75
+ title: errorMsg || "未知错误",
76
+ duration: 5000
77
+ });
78
+ } else {
79
+ Notification.error({
80
+ title: "接口请求失败",
81
+ duration: 5000
82
+ });
83
+ }
84
+ return Promise.reject(error);
85
+ }
86
+ );
87
+ return Axios;
88
+ };
@@ -75,7 +75,7 @@
75
75
  .draggable-list {
76
76
  min-height: 52px;
77
77
  background-color: #fff;
78
- // border: 1px dashed rgba(170, 170, 170, 0.7);
78
+ border: 1px dashed rgba(170, 170, 170, 0.7);
79
79
  }
80
80
 
81
81
  .widgetForm {
@@ -150,7 +150,7 @@
150
150
  }
151
151
 
152
152
  .value {
153
- color: var(--th-blue);
153
+ color: $color-parimary;
154
154
  cursor: pointer;
155
155
  }
156
156
  }