tianheng-ui 0.1.33 → 0.1.35

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.33",
4
+ "version": "0.1.35",
5
5
  "author": "shu lang <403732931@qq.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -3,7 +3,7 @@
3
3
  <el-form
4
4
  class="generateForm"
5
5
  :class="{ isHideLabel: formJson.config.hideLabel }"
6
- :style="{ width: formWidth }"
6
+ :style="{ width: formJson.config.width }"
7
7
  :label-suffix="formJson.config.labelSuffix"
8
8
  :size="formJson.config.size"
9
9
  :model="models"
@@ -97,7 +97,6 @@ export default {
97
97
  return [];
98
98
  }
99
99
  },
100
- client: String
101
100
  },
102
101
  data() {
103
102
  return {
@@ -110,7 +109,6 @@ export default {
110
109
  computed: {
111
110
  formWidth() {
112
111
  if (this.formJson.config.width) return this.formJson.config.width;
113
- if (this.client === "mobile") return "375px";
114
112
 
115
113
  return "";
116
114
  }
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div class="widgetTools">
3
3
  <div class="left">
4
- <el-button
4
+ <!-- <el-button
5
5
  v-if="permissions.includes('monitor')"
6
6
  :class="{ active: client === 'monitor' }"
7
7
  type="text"
@@ -18,11 +18,10 @@
18
18
  icon="el-icon-mobile"
19
19
  @click="handleClick('mobile')"
20
20
  >
21
- </el-button>
21
+ </el-button> -->
22
+ <slot> </slot>
22
23
  </div>
23
24
  <div class="right">
24
- <slot> </slot>
25
-
26
25
  <el-button
27
26
  v-if="permissions.includes('clearable')"
28
27
  style="margin-left:10px;"
@@ -32,14 +31,34 @@
32
31
  @click="handleClick('clear')"
33
32
  >清空
34
33
  </el-button>
35
- <el-button
36
- v-if="permissions.includes('preview')"
37
- type="text"
38
- size="medium"
39
- icon="el-icon-view"
40
- @click="dialog.preview.visible = true"
41
- >预览
42
- </el-button>
34
+ <el-popover style="margin-left:10px;" placement="bottom" trigger="hover">
35
+ <el-button
36
+ v-if="permissions.includes('preview')"
37
+ type="text"
38
+ size="medium"
39
+ icon="el-icon-view"
40
+ slot="reference"
41
+ >预览
42
+ </el-button>
43
+ <div>
44
+ <el-button
45
+ type="text"
46
+ size="medium"
47
+ icon="el-icon-monitor"
48
+ @click="handleDialogOpen('previewPc')"
49
+ >电脑端
50
+ </el-button>
51
+ </div>
52
+ <div>
53
+ <el-button
54
+ type="text"
55
+ size="medium"
56
+ icon="el-icon-mobile"
57
+ @click="handleDialogOpen('previewH5')"
58
+ >移动端
59
+ </el-button>
60
+ </div>
61
+ </el-popover>
43
62
  <el-popover style="margin-left:10px;" placement="bottom" trigger="hover">
44
63
  <el-button
45
64
  v-if="permissions.includes('upload')"
@@ -54,7 +73,7 @@
54
73
  <el-button
55
74
  type="text"
56
75
  size="medium"
57
- @click="dialog.import.visible = true"
76
+ @click="handleDialogOpen('importJson')"
58
77
  >导入JSON
59
78
  </el-button>
60
79
  </div>
@@ -73,7 +92,8 @@
73
92
  <el-button
74
93
  type="text"
75
94
  size="medium"
76
- @click="dialog.template.visible = true"
95
+ disabled
96
+ @click="handleDialogOpen('importTemplate')"
77
97
  >导入模板
78
98
  </el-button>
79
99
  </div>
@@ -81,10 +101,7 @@
81
101
  </el-popover>
82
102
  <el-popover style="margin-left:10px;" placement="bottom" trigger="hover">
83
103
  <el-button
84
- v-if="
85
- permissions.includes('generateJson') ||
86
- permissions.includes('generateCode')
87
- "
104
+ v-if="permissions.includes('generate')"
88
105
  type="text"
89
106
  size="medium"
90
107
  icon="el-icon-document"
@@ -94,20 +111,19 @@
94
111
  <div>
95
112
  <div>
96
113
  <el-button
97
- v-if="permissions.includes('generateJson')"
98
114
  type="text"
99
115
  size="medium"
100
- @click="handleGenerateJson"
116
+ @click="handleDialogOpen('generateJson')"
101
117
  >
102
118
  生成JSON
103
119
  </el-button>
104
120
  </div>
105
121
  <div>
106
122
  <el-button
107
- v-if="permissions.includes('generateCode')"
108
123
  type="text"
109
124
  size="medium"
110
- @click="handleGenerateCode"
125
+ disabled
126
+ @click="handleDialogOpen('generateCode')"
111
127
  >
112
128
  生成代码
113
129
  </el-button>
@@ -116,145 +132,111 @@
116
132
  </el-popover>
117
133
  </div>
118
134
 
119
- <!-- 导入JSON -->
120
135
  <th-dialog
121
- title="导入JSON"
122
- :visible="dialog.import.visible"
136
+ v-model="dialog.show"
137
+ :title="dialogTitles[dialog.action]"
123
138
  :modal-append-to-body="false"
124
- @on-close="dialog.import.visible = false"
125
- @on-affirm="handleImportJson"
126
- @on-fullscreen="$refs.valueCodeEditor.resize()"
127
- >
128
- <el-alert
129
- type="info"
130
- title="JSON格式如下,直接复制生成的json覆盖此处代码点击确定即可"
131
- ></el-alert>
132
- <th-code-editor
133
- v-model="dialog.import.value"
134
- ref="valueCodeEditor"
135
- ></th-code-editor>
136
- </th-dialog>
137
-
138
- <!-- 导入模板 -->
139
- <th-dialog
140
- title="导入模板"
141
- :visible="dialog.template.visible"
142
- :modal-append-to-body="false"
143
- @on-close="dialog.template.visible = false"
144
- @on-affirm="handleImportTemplate"
145
- >
146
-
147
- </th-dialog>
148
-
149
- <!-- 预览 -->
150
- <th-dialog
151
- title="预览"
152
- v-model="dialog.preview.visible"
153
- :modal-append-to-body="false"
154
- @on-close="dialog.preview.visible = false"
139
+ :showFooter="
140
+ dialog.action === 'previewPc' ||
141
+ dialog.action === 'previewH5' ||
142
+ dialog.action === 'importJson'
143
+ "
144
+ @on-close="handleDialogClose"
145
+ @on-affirm="handleDialogAffirm"
146
+ @on-fullscreen="handleDialogFullscreen"
155
147
  >
156
- <generate-form
157
- v-if="dialog.preview.visible"
158
- :config="formData"
159
- :value="formValue"
160
- :oauthConfig="oauthConfig"
161
- :remote="remoteData"
162
- :slotKeys="slotKeys"
163
- :client="client"
164
- insite="true"
165
- @on-change="handleDataChange"
166
- @button-submit="handleButtonSubmit"
167
- ref="generateForm"
168
- >
169
- <template v-for="name in slotKeys" :slot="name">
170
- <slot :name="name" />
148
+ <template v-if="dialog.action === 'importJson'">
149
+ <el-alert
150
+ type="info"
151
+ title="JSON格式如下,直接复制生成的json覆盖此处代码点击确定即可"
152
+ ></el-alert>
153
+ <th-code-editor v-model="dialog.data" ref="codeEditor"></th-code-editor>
154
+ </template>
155
+ <template v-if="dialog.action === 'importTemplate'"> </template>
156
+ <template v-if="dialog.action === 'generateJson'">
157
+ <th-code-editor v-model="dialog.data" ref="codeEditor"></th-code-editor>
158
+ </template>
159
+ <template v-if="dialog.action === 'generateCode'">
160
+ <el-tabs value="vue" type="border-card" style="box-shadow: none;">
161
+ <el-tab-pane label="Vue Component" name="vue">
162
+ <th-code-editor
163
+ v-model="dialog.data.vue"
164
+ language="html"
165
+ readonly
166
+ ref="vueCodeEditor"
167
+ ></th-code-editor>
168
+ </el-tab-pane>
169
+ <el-tab-pane label="HTML" name="html">
170
+ <th-code-editor
171
+ v-model="dialog.data.html"
172
+ language="html"
173
+ readonly
174
+ ref="htmlCodeEditor"
175
+ ></th-code-editor>
176
+ </el-tab-pane>
177
+ </el-tabs>
178
+ </template>
179
+ <template v-if="dialog.action === 'previewPc'">
180
+ <generate-form
181
+ :config="formData"
182
+ :value="formValue"
183
+ :oauthConfig="oauthConfig"
184
+ :remote="remoteData"
185
+ :slotKeys="slotKeys"
186
+ insite="true"
187
+ @on-change="handleDataChange"
188
+ @button-submit="handleButtonSubmit"
189
+ ref="generateForm"
190
+ >
191
+ <template v-for="name in slotKeys" :slot="name">
192
+ <slot :name="name" />
193
+ </template>
194
+ </generate-form>
195
+ <template slot="footer">
196
+ <el-button type="primary" @click="handleGetData">获取数据</el-button>
197
+ <el-button @click="handleReset">重置</el-button>
198
+ </template>
199
+ </template>
200
+ <template v-if="dialog.action === 'previewH5'">
201
+ <div class="previewH5">
202
+ <div class="header"></div>
203
+ <generate-form
204
+ class="box"
205
+ :config="formData"
206
+ :value="formValue"
207
+ :oauthConfig="oauthConfig"
208
+ :remote="remoteData"
209
+ :slotKeys="slotKeys"
210
+ insite="true"
211
+ @on-change="handleDataChange"
212
+ @button-submit="handleButtonSubmit"
213
+ ref="generateForm"
214
+ >
215
+ <template v-for="name in slotKeys" :slot="name">
216
+ <slot :name="name" />
217
+ </template>
218
+ </generate-form>
219
+ </div>
220
+ <template slot="footer">
221
+ <el-button type="primary" @click="handleGetData">获取数据</el-button>
222
+ <el-button @click="handleReset">重置</el-button>
171
223
  </template>
172
- </generate-form>
173
-
174
- <template slot="footer">
175
- <el-button type="primary" @click="handleGetData">获取数据</el-button>
176
- <el-button @click="handleReset">重置</el-button>
177
224
  </template>
178
225
  </th-dialog>
179
226
 
180
227
  <!-- 获取数据 -->
181
228
  <th-dialog
229
+ v-model="dialogResultData.show"
182
230
  title="获取数据"
183
- :visible="dialog.data.visible"
184
231
  :modal-append-to-body="false"
185
- @on-close="dialog.data.visible = false"
232
+ :showFooter="false"
233
+ @on-close="dialogResultData.show = false"
186
234
  @on-fullscreen="$refs.dataCodeEditor.resize()"
187
235
  >
188
236
  <th-code-editor
189
- v-model="dialog.data.value"
237
+ v-model="dialogResultData.data"
190
238
  ref="dataCodeEditor"
191
239
  ></th-code-editor>
192
-
193
- <template slot="footer">
194
- <el-button
195
- type="primary"
196
- class="json-btn"
197
- :data-clipboard-text="dialog.data.valueCopy"
198
- >复制数据</el-button
199
- >
200
- </template>
201
- </th-dialog>
202
-
203
- <!-- 生成json -->
204
- <th-dialog
205
- title="生成JSON"
206
- :visible="dialog.config.visible"
207
- :modal-append-to-body="false"
208
- @on-close="dialog.config.visible = false"
209
- @on-fullscreen="$refs.jsonCodeEditor.resize()"
210
- >
211
- <th-code-editor
212
- v-model="dialog.config.value"
213
- ref="jsonCodeEditor"
214
- ></th-code-editor>
215
-
216
- <template slot="footer">
217
- <el-button
218
- type="primary"
219
- class="json-btn"
220
- :data-clipboard-text="dialog.config.valueCopy"
221
- >复制数据</el-button
222
- >
223
- </template>
224
- </th-dialog>
225
-
226
- <!-- 生成代码 -->
227
- <th-dialog
228
- class="codeDialog"
229
- title="生成代码"
230
- :visible="dialog.code.visible"
231
- :showFooter="false"
232
- :modal-append-to-body="false"
233
- @on-close="dialog.code.visible = false"
234
- @on-fullscreen="handleDialogFullscreen"
235
- >
236
- <el-tabs
237
- type="border-card"
238
- style="box-shadow: none;"
239
- v-model="dialog.code.type"
240
- >
241
- <el-tab-pane label="Vue Component" name="vue">
242
- <th-code-editor
243
- v-model="dialog.code.valueVue"
244
- language="html"
245
- readonly
246
- ref="vueCodeEditor"
247
- ></th-code-editor>
248
- </el-tab-pane>
249
- <el-tab-pane label="HTML" name="html">
250
- <th-code-editor
251
- v-model="dialog.code.valueHtml"
252
- language="html"
253
- readonly
254
- ref="htmlCodeEditor"
255
- ></th-code-editor>
256
- </el-tab-pane>
257
- </el-tabs>
258
240
  </th-dialog>
259
241
  </div>
260
242
  </template>
@@ -282,12 +264,19 @@ export default {
282
264
  data() {
283
265
  return {
284
266
  dialog: {
285
- import: { visible: false, value: "" },
286
- template: { visible: false, value: "" },
287
- preview: { visible: false, value: "" },
288
- data: { visible: false, value: "", valueCopy: "" },
289
- config: { visible: false, value: "", valueCopy: "" },
290
- code: { visible: false, valueHtml: "", valueVue: "", type: "vue" }
267
+ show: false,
268
+ action: "",
269
+ data: null
270
+ },
271
+ dialogResultData: { show: false, data: null },
272
+
273
+ dialogTitles: {
274
+ previewPc: "预览-电脑端",
275
+ previewH5: "预览-移动端",
276
+ importJson: "导入JSON",
277
+ importTemplate: "导入模板",
278
+ generateJson: "生成JSON",
279
+ generateCode: "生成代码"
291
280
  },
292
281
  remoteData: {
293
282
  func_test(resolve) {
@@ -449,13 +438,6 @@ export default {
449
438
  }
450
439
  return data;
451
440
  },
452
- handleImportJson() {
453
- this.dialog.import.visible = false;
454
- this.handleClick("import-json", JSON.parse(this.dialog.import.value));
455
- },
456
- handleImportTemplate() {
457
- this.dialog.template.visible = false;
458
- },
459
441
  handleDataChange(field, value, data) {
460
442
  // console.log('handleDataChange =>',field, value, data);
461
443
  },
@@ -464,29 +446,15 @@ export default {
464
446
  },
465
447
  handleGetData() {
466
448
  this.$refs.generateForm.getData().then(data => {
467
- this.dialog.data = {
468
- visible: true,
469
- value: JSON.stringify(data, null, 2),
470
- valueCopy: JSON.stringify(data, null, 2)
449
+ this.dialogResultData = {
450
+ show: true,
451
+ data: JSON.stringify(data, null, 2)
471
452
  };
472
- this.$nextTick(() => {
473
- this.initClipboard();
474
- });
475
453
  });
476
454
  },
477
455
  handleReset() {
478
456
  this.$refs.generateForm.reset();
479
457
  },
480
- handleGenerateJson() {
481
- this.dialog.config = {
482
- visible: true,
483
- value: JSON.stringify(this.formData, null, 2),
484
- valueCopy: JSON.stringify(this.formData, null, 2)
485
- };
486
- this.$nextTick(() => {
487
- this.initClipboard();
488
- });
489
- },
490
458
  initClipboard() {
491
459
  if (!this.jsonClipboard) {
492
460
  this.jsonClipboard = new Clipboard(".json-btn");
@@ -495,17 +463,47 @@ export default {
495
463
  });
496
464
  }
497
465
  },
498
- handleGenerateCode() {
499
- this.dialog.code = {
500
- visible: true,
501
- valueHtml: generateCode(JSON.stringify(this.formData), "html"),
502
- valueVue: generateCode(JSON.stringify(this.formData), "vue"),
503
- type: "vue"
504
- };
466
+ handleDialogOpen(action) {
467
+ let data = "";
468
+ switch (action) {
469
+ case "generateJson":
470
+ data = JSON.stringify(this.formData, null, 2);
471
+ break;
472
+ case "generateCode":
473
+ data = {
474
+ html: generateCode(JSON.stringify(this.formData), "html"),
475
+ vue: generateCode(JSON.stringify(this.formData), "vue")
476
+ };
477
+ break;
478
+
479
+ default:
480
+ break;
481
+ }
482
+ this.dialog = { show: true, action, data };
483
+ },
484
+ handleDialogClose() {
485
+ this.dialog.show = false;
486
+ },
487
+ handleDialogAffirm() {
488
+ if (this.dialog.action === "importJson") {
489
+ this.handleClick("import-json", JSON.parse(this.dialog.data));
490
+ }
491
+ this.handleDialogClose();
505
492
  },
506
493
  handleDialogFullscreen() {
507
- this.$refs.vueCodeEditor.resize();
508
- this.$refs.htmlCodeEditor.resize();
494
+ switch (this.dialog.action) {
495
+ case "importJson":
496
+ case "generateJson":
497
+ this.$refs.codeEditor.resize();
498
+ break;
499
+ case "generateCode":
500
+ this.$refs.vueCodeEditor.resize();
501
+ this.$refs.htmlCodeEditor.resize();
502
+ break;
503
+
504
+ default:
505
+ break;
506
+ }
509
507
  }
510
508
  }
511
509
  };
@@ -521,13 +519,6 @@ export default {
521
519
  border-bottom: solid 2px #e4e7ed;
522
520
 
523
521
  .left {
524
- min-width: 60px;
525
- .el-button {
526
- color: #333;
527
- }
528
- .active {
529
- color: #409eff;
530
- }
531
522
  }
532
523
  .right {
533
524
  flex: 1;
@@ -535,5 +526,23 @@ export default {
535
526
  align-items: center;
536
527
  justify-content: right;
537
528
  }
529
+
530
+ .previewH5 {
531
+ width: 300px;
532
+ height: 649px;
533
+ margin: auto;
534
+ padding: 0 10px;
535
+ border-radius: 10px;
536
+ background-image: url("../../lib/theme-chalk/images/iPhone13.png");
537
+ background-size: 100% 100%;
538
+ overflow: hidden;
539
+ .header {
540
+ height: 44px;
541
+ }
542
+ .box {
543
+ height: 570px;
544
+ overflow-y: scroll;
545
+ }
546
+ }
538
547
  }
539
548
  </style>
@@ -215,8 +215,7 @@ export default {
215
215
  "upload",
216
216
  "clearable",
217
217
  "preview",
218
- "generateCode",
219
- "generateJson"
218
+ "generate"
220
219
  ]
221
220
  },
222
221
  basicFields: {
@@ -354,11 +353,7 @@ export default {
354
353
  },
355
354
 
356
355
  handleClear() {
357
- this.formConfig = {
358
- list: [],
359
- config: this.baseConfig
360
- };
361
-
356
+ this.formConfig.list = []
362
357
  this.widgetFormSelect = {};
363
358
  },
364
359
  handleWidgetToolsChange(val, data) {
@@ -17,9 +17,9 @@
17
17
  @click="handleClick('mobile')"
18
18
  >
19
19
  </el-button> -->
20
+ <slot> </slot>
20
21
  </div>
21
22
  <div class="right">
22
- <slot> </slot>
23
23
  <el-button
24
24
  v-if="permissions.includes('clearable')"
25
25
  style="margin-left:10px;"
@@ -44,7 +44,7 @@
44
44
  type="text"
45
45
  size="medium"
46
46
  icon="el-icon-monitor"
47
- @click="handleDialogOpen('preview_pc')"
47
+ @click="handleDialogOpen('previewPc')"
48
48
  >电脑端
49
49
  </el-button>
50
50
  </div>
@@ -53,7 +53,7 @@
53
53
  type="text"
54
54
  size="medium"
55
55
  icon="el-icon-mobile"
56
- @click="handleDialogOpen('preview_h5')"
56
+ @click="handleDialogOpen('previewH5')"
57
57
  >移动端
58
58
  </el-button>
59
59
  </div>
@@ -145,11 +145,12 @@
145
145
  @on-close="handleDialogClose"
146
146
  @on-affirm="handleDialogAffirm"
147
147
  >
148
- <template v-if="dialog.action === 'preview_pc'">
148
+ <template v-if="dialog.action === 'previewPc'">
149
149
  <th-table-generate :config="deepClone(config)"> </th-table-generate>
150
150
  </template>
151
- <template v-if="dialog.action === 'preview_h5'">
152
- <th-list-generate :data="[]" :config="deepClone(config)"> </th-list-generate>
151
+ <template v-if="dialog.action === 'previewH5'">
152
+ <th-list-generate :data="[]" :config="deepClone(config)">
153
+ </th-list-generate>
153
154
  </template>
154
155
  <template v-else-if="dialog.action === 'importJson'">
155
156
  <el-alert
@@ -190,8 +191,8 @@ export default {
190
191
  data: {}
191
192
  },
192
193
  dialogTitles: {
193
- preview_pc: "预览-电脑端",
194
- preview_h5: "预览-移动端",
194
+ previewPc: "预览-电脑端",
195
+ previewH5: "预览-移动端",
195
196
  importJson: "导入JSON",
196
197
  importTemplate: "导入模板",
197
198
  generateJson: "生成JSON",
@@ -263,13 +264,6 @@ export default {
263
264
  border-bottom: solid 2px #e4e7ed;
264
265
 
265
266
  .left {
266
- min-width: 60px;
267
- .el-button {
268
- color: #333;
269
- }
270
- .active {
271
- color: #409eff;
272
- }
273
267
  }
274
268
  .right {
275
269
  flex: 1;
@@ -40,13 +40,11 @@ export const table = {
40
40
  table: {
41
41
  border: true,
42
42
  height: "",
43
- maxHeight: "",
44
- customStyle: ""
45
43
  },
46
44
  cell: {
47
45
  customStyle: "",
48
46
  margin: "",
49
- padding: "20rpx",
47
+ padding: "10px",
50
48
  "border-bottom": "1px solid #e5e5e5"
51
49
  },
52
50
  title: {
@@ -11,6 +11,7 @@
11
11
  v-model="data[item.prop]"
12
12
  :placeholder="item.label"
13
13
  :disabled="item.disabled"
14
+ size="small"
14
15
  clearable
15
16
  ></el-input>
16
17
  <el-date-picker
@@ -22,6 +23,7 @@
22
23
  range-separator="至"
23
24
  start-placeholder="开始日期"
24
25
  end-placeholder="结束日期"
26
+ size="small"
25
27
  clearable
26
28
  >
27
29
  </el-date-picker>
@@ -33,6 +35,7 @@
33
35
  :multiple-limit="item.multipleLimit"
34
36
  :filterable="item.filterable"
35
37
  :disabled="item.disabled"
38
+ size="small"
36
39
  clearable
37
40
  >
38
41
  <template v-if="item.remote">