tianheng-ui 0.1.67 → 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.67",
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();
@@ -259,6 +263,7 @@ export default {
259
263
  const params = {};
260
264
  for (let e of api.inParams) {
261
265
  const value =
266
+ e.defaultValue ||
262
267
  getProperty(this.models, e.pAlias) ||
263
268
  getProperty(this.query, e.pAlias) ||
264
269
  null;
@@ -296,7 +301,10 @@ export default {
296
301
  if (item.children) {
297
302
  initParams(item.children);
298
303
  } else {
299
- const value = getProperty(this.models, item.pAlias) || null;
304
+ const value =
305
+ item.defaultValue ||
306
+ getProperty(this.models, item.pAlias) ||
307
+ null;
300
308
  setProperty(params, item.pAlias, value);
301
309
  }
302
310
  });
@@ -102,6 +102,7 @@
102
102
  :config="config"
103
103
  :apiOptions="apiOptions"
104
104
  :is="compsData[data.type].content"
105
+ @remote-params="handleFieldsApiChange"
105
106
  ></component>
106
107
 
107
108
  <el-collapse-item
@@ -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 {
@@ -480,8 +479,10 @@ export default {
480
479
  });
481
480
  } else if (item.type === "table" || item.type === "tableH5") {
482
481
  initList(item.options.columns);
483
- } else if (item.options.remote?.open || item.options.remote?.api) {
484
- fieldsApi[item.model] = item.options.remote.api;
482
+ } else if (item.type === "workflow") {
483
+ initList(item.options.buttons);
484
+ } else if (item.options.remote?.open || item.options.remote?.api) {
485
+ fieldsApi[item.model || item.name] = item.options.remote.api;
485
486
  }
486
487
  }
487
488
  };
@@ -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",
@@ -998,43 +998,44 @@ export const businessComponents = [
998
998
  timestamp: "2023-05-05 14:30"
999
999
  }
1000
1000
  ],
1001
- processInstButtons: [
1002
- {
1003
- name: "通过",
1004
- options: {
1005
- remote: {
1006
- api: ""
1007
- },
1008
- type: "primary",
1009
- icon: "",
1010
- size: "small",
1011
- plain: false,
1012
- round: false,
1013
- circle: false,
1014
- disabled: false,
1015
- loading: false,
1016
- customStyle: ""
1017
- }
1018
- },
1019
- {
1020
- name: "驳回",
1021
- options: {
1022
- remote: {
1023
- api: ""
1024
- },
1025
- type: "primary",
1026
- icon: "",
1027
- size: "small",
1028
- plain: false,
1029
- round: false,
1030
- circle: false,
1031
- disabled: false,
1032
- loading: false,
1033
- customStyle: ""
1034
- }
1035
- }
1036
- ]
1001
+ processInstButtons: null
1037
1002
  },
1003
+ buttons: [
1004
+ {
1005
+ name: "通过",
1006
+ options: {
1007
+ remote: {
1008
+ api: ""
1009
+ },
1010
+ type: "primary",
1011
+ icon: "",
1012
+ size: "small",
1013
+ plain: false,
1014
+ round: false,
1015
+ circle: false,
1016
+ disabled: false,
1017
+ loading: false,
1018
+ customStyle: ""
1019
+ }
1020
+ },
1021
+ {
1022
+ name: "驳回",
1023
+ options: {
1024
+ remote: {
1025
+ api: ""
1026
+ },
1027
+ type: "primary",
1028
+ icon: "",
1029
+ size: "small",
1030
+ plain: false,
1031
+ round: false,
1032
+ circle: false,
1033
+ disabled: false,
1034
+ loading: false,
1035
+ customStyle: ""
1036
+ }
1037
+ }
1038
+ ],
1038
1039
  hideLabel: true
1039
1040
  },
1040
1041
  events: {},
@@ -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>
@@ -52,7 +52,7 @@
52
52
  </el-option>
53
53
  </el-select>
54
54
  </el-form-item>
55
- <el-form-item v-if="!widget.options.remote.open" label-width="0">
55
+ <el-form-item v-else label-width="0">
56
56
  <draggable
57
57
  :list="widget.options.defaultValue.processInstTaskRsps"
58
58
  v-bind="{
@@ -101,9 +101,20 @@
101
101
  >
102
102
  </div>
103
103
  </el-form-item>
104
- <el-form-item v-if="!widget.options.remote.open" label-width="0">
104
+
105
+ <el-form-item>
106
+ <el-tooltip
107
+ slot="label"
108
+ effect="light"
109
+ content="流程节点的默认操作,可被远端节点数据的 processInstButtons 配置属性覆盖"
110
+ placement="top"
111
+ >
112
+ <span style="color: #409EFF;">操作按钮</span>
113
+ </el-tooltip>
114
+ </el-form-item>
115
+ <el-form-item label-width="0">
105
116
  <draggable
106
- :list="widget.options.defaultValue.processInstButtons"
117
+ :list="widget.options.buttons"
107
118
  v-bind="{
108
119
  group: { name: 'options' },
109
120
  ghostClass: 'ghost',
@@ -112,8 +123,7 @@
112
123
  handle=".drag"
113
124
  >
114
125
  <div
115
- v-for="(item, index) in widget.options.defaultValue
116
- .processInstButtons"
126
+ v-for="(item, index) in widget.options.buttons"
117
127
  class="draggable-item"
118
128
  :key="index"
119
129
  >
@@ -242,8 +252,7 @@
242
252
  >
243
253
  </div>
244
254
  <div
245
- v-for="(item, index) in widget.options.defaultValue
246
- .processInstButtons"
255
+ v-for="(item, index) in widget.options.buttons"
247
256
  class="list-item th-is_hover"
248
257
  :class="{
249
258
  'th-is_active': dialog.data && dialog.data.name === item.name
@@ -328,17 +337,17 @@
328
337
  <el-select
329
338
  v-model="dialog.data.options.remote.api"
330
339
  style="width:100%"
331
- value-key="id"
332
340
  clearable
333
341
  placeholder=""
334
342
  filterable
335
343
  no-data-text="暂无接口,请前往【接口模块】创建"
344
+ @change="handleRemoteApiChange"
336
345
  >
337
346
  <el-option
338
347
  v-for="item in apiOptions"
339
348
  :key="item.id"
340
349
  :label="item.name"
341
- :value="item"
350
+ :value="item.id"
342
351
  >
343
352
  </el-option>
344
353
  </el-select>
@@ -400,9 +409,8 @@ export default {
400
409
  timestamp: "节点时间"
401
410
  });
402
411
  } else {
403
- this.widget.options.defaultValue.processInstButtons.push({
404
- name: `操作${this.widget.options.defaultValue.processInstButtons
405
- .length + 1}`,
412
+ this.widget.options.buttons.push({
413
+ name: `操作${this.widget.options.buttons.length + 1}`,
406
414
  options: {
407
415
  remote: {
408
416
  api: ""
@@ -423,7 +431,7 @@ export default {
423
431
  handleRemoveOption(index, type) {
424
432
  if (type === "processInstTaskRsps")
425
433
  this.widget.options.defaultValue.processInstTaskRsps.splice(index, 1);
426
- else this.widget.options.defaultValue.processInstButtons.splice(index, 1);
434
+ else this.widget.options.buttons.splice(index, 1);
427
435
  },
428
436
  handleRemoteChange(val) {
429
437
  if (val) return;
@@ -433,13 +441,16 @@ export default {
433
441
  const data =
434
442
  action === "processInstTaskRsps"
435
443
  ? this.widget.options.defaultValue.processInstTaskRsps[index]
436
- : this.widget.options.defaultValue.processInstButtons[index];
444
+ : this.widget.options.buttons[index];
437
445
  this.dialog = {
438
446
  show: true,
439
447
  action,
440
448
  data,
441
449
  index
442
450
  };
451
+ },
452
+ handleRemoteApiChange(val) {
453
+ this.$emit("remote-params", val);
443
454
  }
444
455
  }
445
456
  };
@@ -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];
@@ -58,12 +58,14 @@
58
58
  </el-timeline-item>
59
59
  </el-timeline>
60
60
  <div
61
- v-if="dataModel.processInstButtons.length"
61
+ v-if="dataModel.processInstButtons || widget.options.buttons.length"
62
62
  class="footer"
63
63
  :class="{ sticky: widget.options.buttonsSticky }"
64
64
  >
65
65
  <el-button
66
- v-for="(item, index) in dataModel.processInstButtons"
66
+ v-for="(item, index) in dataModel.processInstButtons
67
+ ? dataModel.processInstButtons
68
+ : widget.options.buttons"
67
69
  :key="index"
68
70
  :style="item.options.customStyle"
69
71
  :type="item.options.type"