vue2-client 1.8.15 → 1.8.17

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/CHANGELOG.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Change Log
2
2
  > 所有关于本项目的变化都在该文档里。
3
3
 
4
+ **1.8.15 - 1.8.17 -2023-11-23 @张振宇**
5
+ - 调整配置化组件
6
+
4
7
  **1.8.14 - 1.8.15 -2023-11-23 @江超**
5
8
  - 完善导入功能的返回值
6
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-client",
3
- "version": "1.8.15",
3
+ "version": "1.8.17",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
@@ -0,0 +1,3 @@
1
+ import AMisRender from './index.vue'
2
+
3
+ export default AMisRender
@@ -1,4 +1,4 @@
1
- <template><div>Loading...</div></template>
1
+ <template><div ref="domRef">Loading...</div></template>
2
2
 
3
3
  <script>
4
4
  // import "amis/sdk/sdk.js";
@@ -11,8 +11,10 @@
11
11
  import qs from 'qs'
12
12
  import Vue from 'vue'
13
13
  import Index from '@vue2-client/base-client/components/index.js'
14
- import locale from 'ant-design-vue/es/locale-provider/zh_CN'
15
-
14
+ let React
15
+ let amisLib
16
+ let scoped
17
+ const apps = {}
16
18
  function loadScript (src, callback) {
17
19
  const script = document.createElement('script')
18
20
  script.setAttribute('type', 'text/javascript')
@@ -21,45 +23,50 @@ function loadScript (src, callback) {
21
23
  script.onerror = () => callback(new Error(`Failed to load ${src}`))
22
24
  document.body.appendChild(script)
23
25
  }
26
+ const vueList = {}
24
27
 
25
- function loadStyles (styles) {
26
- for (const path of styles) {
27
- const style = document.createElement('link')
28
- style.setAttribute('rel', 'stylesheet')
29
- style.setAttribute('type', 'text/css')
30
- style.setAttribute('href', path)
31
- document.head.appendChild(style)
32
- }
33
- }
34
-
35
- // 动态导入组件
36
- function CustomComponent (props) {
37
- const React = window.amisRequire('react')
38
- const dom = React.useRef(null)
28
+ // eslint-disable-next-line no-unused-vars
29
+ function CustomComponent (props, dom) {
39
30
  const store = Vue.$store
40
31
  const router = Vue.$router
41
32
  const i18n = Vue.$i18n
33
+ console.log('props', props)
42
34
  React.useEffect(function () {
43
- new Vue({
35
+ vueList[props.$schema.name] = new Vue({
44
36
  router,
45
37
  store,
46
38
  i18n,
47
- render: h => h('a-config-provider', {
48
- props: {
49
- locale: locale,
50
- popContainer: document.getElementById('popContainer')
51
- }
52
- }, [
53
- h(Index[props.$schema.type], {
54
- props: props.$schema
55
- })
56
- ])
39
+ render: h => h(Index[props.$schema.type], {
40
+ props: props.$schema
41
+ })
57
42
  }).$mount(dom.current)
58
- })
59
- return React.createElement('div', {
43
+ }, [])
44
+ const app = React.createElement('div', {
60
45
  ref: dom
61
46
  })
47
+ if (apps[props.name] !== undefined) {
48
+ const vue = vueList[props.$schema.name]
49
+ vue.$children[0].active(props.data)
50
+ } else {
51
+ apps[props.name] = app
52
+ }
53
+ return app
54
+ }
55
+
56
+ function loadStyles (styles) {
57
+ for (const path of styles) {
58
+ const style = document.createElement('link')
59
+ style.setAttribute('rel', 'stylesheet')
60
+ style.setAttribute('type', 'text/css')
61
+ style.setAttribute('href', path)
62
+ document.head.appendChild(style)
63
+ }
64
+ }
65
+ // eslint-disable-next-line no-unused-vars
66
+ function appstyle (data) {
67
+ console.log('111111111111')
62
68
  }
69
+ // 动态导入组件
63
70
 
64
71
  function loadSDK () {
65
72
  return new Promise((resolve, reject) => {
@@ -127,6 +134,7 @@ export default {
127
134
  loading: false,
128
135
  amisInstance: null,
129
136
  unmounted: false,
137
+ applist: {}
130
138
  }
131
139
  },
132
140
 
@@ -151,73 +159,76 @@ export default {
151
159
  if (this.unmounted) {
152
160
  return
153
161
  }
154
-
155
- const amisLib = window.amisRequire('amis')
156
- const scoped = window.amisRequire('amis/embed')
162
+ React = window.amisRequire('react')
163
+ amisLib = window.amisRequire('amis')
164
+ scoped = window.amisRequire('amis/embed')
157
165
  const { normalizeLink } = amisLib
158
166
  const router = this.$router
167
+ // eslint-disable-next-line no-prototype-builtins
168
+ // console.log('this.schema.type', this.schema.type)
169
+
159
170
  amisLib.Renderer({
160
171
  test: new RegExp(`(^|\/)${this.schema.type}`)
161
- })(CustomComponent)
172
+ })(props => CustomComponent(props, this.$el))
173
+
162
174
  const instance = scoped.embed(
163
- this.$el,
164
- this.schema,
165
- {
166
- data: {
167
- ...this.locals,
168
- },
169
- context: this.context,
170
- location: this.location,
171
-
172
- // todo 下发 location 对象
173
- ...this.props,
175
+ this.$el,
176
+ this.schema,
177
+ {
178
+ data: {
179
+ ...this.locals,
174
180
  },
175
- {
176
- // 覆盖 amis env
177
- // 参考 https://aisuda.bce.baidu.com/amis/zh-CN/docs/start/getting-started#sdk
178
- jumpTo: (to, action) => {
179
- if (to === 'goBack') {
180
- return router.go(-1)
181
- }
182
-
183
- to = normalizeLink(to, this.location)
184
-
185
- if (action?.actionType === 'url') {
186
- action.blank === false ? router.push(to) : window.open(to)
187
- return
188
- }
189
-
190
- // 主要是支持 nav 中的跳转
191
- if (action && to && action.target) {
192
- window.open(to, action.target)
193
- return
194
- }
195
-
196
- if (/^https?:\/\//.test(to)) {
197
- window.location.replace(to)
198
- } else {
199
- router.push(to)
200
- }
201
- },
202
-
203
- updateLocation: (location, replace) => {
204
- if (location === 'goBack') {
205
- return router.go(-1)
206
- }
207
-
208
- location = normalizeLink(location, this.location)
209
- replace ? router.replace(location) : router.replace(location)
210
- },
211
-
212
- ...this.env,
181
+ context: this.context,
182
+ location: this.location,
183
+
184
+ // todo 下发 location 对象
185
+ ...this.props,
186
+ },
187
+ {
188
+ // 覆盖 amis env
189
+ // 参考 https://aisuda.bce.baidu.com/amis/zh-CN/docs/start/getting-started#sdk
190
+ jumpTo: (to, action) => {
191
+ if (to === 'goBack') {
192
+ return router.go(-1)
193
+ }
194
+
195
+ to = normalizeLink(to, this.location)
196
+
197
+ if (action?.actionType === 'url') {
198
+ action.blank === false ? router.push(to) : window.open(to)
199
+ return
200
+ }
201
+
202
+ // 主要是支持 nav 中的跳转
203
+ if (action && to && action.target) {
204
+ window.open(to, action.target)
205
+ return
206
+ }
207
+
208
+ if (/^https?:\/\//.test(to)) {
209
+ window.location.replace(to)
210
+ } else {
211
+ router.push(to)
212
+ }
213
213
  },
214
- () => {
215
- this.$emit('ready', {
216
- instance,
217
- })
218
- }
219
- )
220
214
 
215
+ updateLocation: (location, replace) => {
216
+ if (location === 'goBack') {
217
+ return router.go(-1)
218
+ }
219
+
220
+ location = normalizeLink(location, this.location)
221
+ replace ? router.replace(location) : router.replace(location)
222
+ },
223
+
224
+ ...this.env,
225
+ },
226
+ () => {
227
+ this.$emit('ready', {
228
+ instance,
229
+ })
230
+ }
231
+ )
221
232
  this.amisInstance = instance
222
233
  },
223
234
 
@@ -232,6 +243,9 @@ export default {
232
243
  ...this.props,
233
244
  })
234
245
  },
246
+ initConfig () {
247
+ console.warn('initConfig')
248
+ }
235
249
  },
236
250
 
237
251
  destroyed () {
@@ -236,7 +236,6 @@
236
236
  </template>
237
237
 
238
238
  <script>
239
- import XFormItem from '@vue2-client/base-client/components/common/XForm/XFormItem'
240
239
  import XFormTable from '@vue2-client/base-client/components/common/XFormTable/XFormTable'
241
240
  import JsonViewer from 'vue-json-viewer'
242
241
  import FileSaver from 'file-saver'
@@ -248,8 +247,7 @@ export default {
248
247
  components: {
249
248
  CreateQueryItem,
250
249
  JsonViewer,
251
- XFormTable,
252
- XFormItem
250
+ XFormTable
253
251
  },
254
252
  data () {
255
253
  return {
@@ -15,14 +15,19 @@
15
15
  :rules="rules"
16
16
  :wrapper-col="wrapperCol"
17
17
  >
18
- <a-form-model-item label="参数组名称" prop="group">
19
- <a-input v-model="form.group" placeholder="设置表单项的组名,如:设置上报参数" />
20
- </a-form-model-item>
21
- <a-form-model-item label="参数组描述" prop="describe">
22
- <a-input v-model="form.describe" placeholder="简单描述参数组,如:用于配置物联网设备的上报参数" />
23
- </a-form-model-item>
18
+ <template v-if="asAParamsGroup">
19
+ <a-form-model-item label="参数组名称" prop="group">
20
+ <a-input v-model="form.group" placeholder="设置表单项的组名,如:设置上报参数" />
21
+ </a-form-model-item>
22
+ <a-form-model-item label="参数组描述" prop="describe">
23
+ <a-input v-model="form.describe" placeholder="简单描述参数组,如:用于配置物联网设备的上报参数" />
24
+ </a-form-model-item>
25
+ </template>
24
26
  <a-form-model-item label="数据字段" prop="column">
25
- <a-button type="primary" @click="addColumnItem()">增加</a-button>
27
+ <a-space>
28
+ <a-button type="primary" @click="addColumnItem()">增加</a-button>
29
+ <a-button icon="import" @click="$message.warn('从创意库中选择并引用高质量的通用表单项配置,敬请期待')">从创意库引入</a-button>
30
+ </a-space>
26
31
  <a-row :gutter="24">
27
32
  <a-col :span="11">
28
33
  <span style="font-weight: bold">
@@ -44,7 +49,6 @@
44
49
  <div
45
50
  v-for="(columnItem, index) in form.column"
46
51
  :key="index"
47
- class="column_item"
48
52
  draggable="true"
49
53
  @dragend="handleDragEnd($event, columnItem)"
50
54
  @dragenter="handleDragEnter($event, columnItem)"
@@ -53,7 +57,7 @@
53
57
  <a-row v-if="ending && dragging && columnItem.key === ending.key && dragging.key !== ending.key" class="dragTipsWarp">
54
58
  <span class="dragTips">拖到此处放置</span>
55
59
  </a-row>
56
- <a-row :gutter="24">
60
+ <a-row :gutter="24" class="column_item">
57
61
  <a-col :span="11">
58
62
  <span style="font-weight: bold">
59
63
  {{ columnItem.title }}
@@ -73,41 +77,9 @@
73
77
  </a-row>
74
78
  </div>
75
79
  </a-form-model-item>
76
- <!-- 暂时不需要 -->
77
- <!-- <a-form-model-item label="接口插槽" prop="apiSlot">
78
- <a-popover placement="right" title="说明">
79
- <template slot="content">
80
- <p>通过插槽,你可以轻松扩展查询配置的默认业务,配置的插槽会根据类型在默认业务的前后执行,类似于切面</p>
81
- <p><span style="color: #FF0000">注意:插槽不应改变默认的业务行为</span></p>
82
- <p>如果配置了业务执行前插槽,<br/>执行默认业务前会先执行设置的插槽logic,传给插槽的参数为data本身</p>
83
- <p>如果配置了业务执行后插槽,<br/>执行默认业务后会执行设置的插槽logic,传给插槽的参数为默认业务的返回值</p>
84
- <img src="@vue2-client/assets/img/querySlotDemo.svg" style="zoom:0.5">
85
- </template>
86
- <a-button type="primary" @click="addApiSlot()">增加</a-button>
87
- </a-popover>
88
- <div
89
- v-for="(columnItem, index) in form.apiSlotView"
90
- :key="index"
91
- >
92
- <a-input v-model="columnItem.slotName" placeholder="插槽logic名称">
93
- <a-select slot="addonBefore" v-model="columnItem.slotType" style="width: 10rem" placeholder="选择插槽类型">
94
- <a-select-option
95
- v-for="item in apiSlotData"
96
- :key="item.value"
97
- :value="item.value">
98
- {{ item.label }}
99
- </a-select-option>
100
- </a-select>
101
- <a-icon slot="addonAfter" type="close" @click="removeApiSlotItem(index)"/>
102
- </a-input>
103
- </div>
104
- </a-form-model-item> -->
105
80
  </a-form-model>
106
81
  <create-simple-form-query-item ref="queryItem" @getColumn="getColumn" @itemHandle="itemHandle"/>
107
- <a-space>
108
- <a-button type="default" @click="view">预览</a-button>
109
- <a-button type="primary" @click="submit">保存</a-button>
110
- </a-space>
82
+ <a-button type="primary" @click="view">操作</a-button>
111
83
  </a-col>
112
84
  <a-col :lg="12" :md="12" :sm="24" :xl="6" :xs="24">
113
85
  <a-card :bordered="false" size="small" style="overflow: auto" title="预览">
@@ -119,18 +91,18 @@
119
91
  </a-card>
120
92
  </a-col>
121
93
  </a-row>
122
- <x-add-form ref="xAddForm"/>
94
+ <x-add-form ref="xAddForm" @onSubmit="submit"/>
123
95
  </a-drawer>
124
96
  </template>
125
97
 
126
98
  <script>
127
- import CreateSimpleFormQueryItem from './CreateSimpleFormQueryItem'
128
- import XAddForm from '@vue2-client/base-client/components/common/XAddForm/XAddForm'
99
+ import XAddForm from '@vue2-client/base-client/components/common/XAddForm'
129
100
  import JsonViewer from 'vue-json-viewer'
130
101
  import FileSaver from 'file-saver'
131
102
  import { mapState } from 'vuex'
132
- import { post } from '@vue2-client/services/api'
103
+ import CreateSimpleFormQueryItem from './CreateSimpleFormQueryItem'
133
104
  import { parseConfigUrl } from '@vue2-client/services/api/common'
105
+ import { post } from '@vue2-client/services/api'
134
106
 
135
107
  export default {
136
108
  name: 'CreateSimpleFormQuery',
@@ -148,8 +120,8 @@ export default {
148
120
  labelCol: { span: 3 },
149
121
  wrapperCol: { span: 18 },
150
122
  form: {
151
- group: '',
152
- describe: '',
123
+ group: undefined,
124
+ describe: undefined,
153
125
  column: [],
154
126
  apiSlotView: [],
155
127
  apiSlot: {},
@@ -159,10 +131,6 @@ export default {
159
131
  selectIndex: null,
160
132
  selectType: undefined,
161
133
  joinArray: [],
162
- rules: {
163
- group: [{ required: true, message: '请输入参数组名称', trigger: 'blur' }],
164
- describe: [{ required: true, message: '请输入参数组描述', trigger: 'blur' }]
165
- },
166
134
  ending: null,
167
135
  dragging: null,
168
136
  // 操作按钮状态集合
@@ -182,20 +150,34 @@ export default {
182
150
  this.initView()
183
151
  },
184
152
  computed: {
185
- ...mapState('setting', ['isMobile'])
153
+ ...mapState('setting', ['isMobile']),
154
+ rules () {
155
+ return this.asAParamsGroup ? {
156
+ group: [{ required: true, message: '请输入参数组名称', trigger: 'blur' }],
157
+ describe: [{ required: true, message: '请输入参数组描述', trigger: 'blur' }]
158
+ } : {}
159
+ },
186
160
  },
187
161
  props: {
188
162
  visible: {
189
163
  type: Boolean,
190
164
  default: false
191
165
  },
192
- serviceName: {
193
- type: String,
194
- default: undefined
166
+ asAParamsGroup: {
167
+ type: Boolean,
168
+ default: false
195
169
  },
196
170
  toEditJson: {
197
171
  type: Object,
198
172
  default: () => {}
173
+ },
174
+ saveExportJson: {
175
+ type: Boolean,
176
+ default: false
177
+ },
178
+ serviceName: {
179
+ type: String,
180
+ default: undefined
199
181
  }
200
182
  },
201
183
  watch: {
@@ -214,8 +196,6 @@ export default {
214
196
  // 处理具体表单项
215
197
  this.form = Object.assign(
216
198
  {
217
- group: '',
218
- describe: '',
219
199
  apiSlotView: [],
220
200
  apiSlot: {},
221
201
  column: []
@@ -290,6 +270,7 @@ export default {
290
270
  this.result = {}
291
271
  },
292
272
  onClose () {
273
+ this.$emit('close')
293
274
  this.$emit('update:visible', false)
294
275
  },
295
276
  addJoinItem () {
@@ -298,7 +279,7 @@ export default {
298
279
  },
299
280
  itemHandle (item, type) {
300
281
  this.itemMap[item.key] = item
301
- if (type === '新增') {
282
+ if (this.type === '新增') {
302
283
  this.form.column.push(item)
303
284
  } else {
304
285
  this.$set(this.form.column, this.selectIndex, item)
@@ -314,6 +295,7 @@ export default {
314
295
  this.$refs.queryItem.addColumnItemExecute()
315
296
  },
316
297
  editColumnItem (key, index) {
298
+ this.type = '修改'
317
299
  if (this.itemMap[key]) {
318
300
  this.$refs.queryItem.editColumnItemExecute(this.itemMap[key])
319
301
  this.selectIndex = index
@@ -349,8 +331,6 @@ export default {
349
331
  this.form.column.splice(index, 1, itemA)
350
332
  this.form.column.splice(newIndex, 1, itemB)
351
333
  },
352
- changeJoinArray () {
353
- },
354
334
  exportJson () {
355
335
  const data = JSON.stringify(this.result, null, 2)
356
336
  const blob = new Blob([data], { type: 'application/json' })
@@ -391,22 +371,25 @@ export default {
391
371
  businessType: '新增',
392
372
  title: '效果预览',
393
373
  formItems: res.formJson,
394
- serviceName: this.serviceName,
395
- viewMode: true
374
+ serviceName: this.serviceName
396
375
  })
397
376
  })
398
377
  })
399
378
  }
400
379
  })
401
380
  },
402
- submit () {
381
+ submit (params, callback) {
403
382
  this.$refs.businessCreateForm.validate(valid => {
404
- if (valid) {
405
- this.viewHandle(() => {
406
- // saveQueryParams
383
+ this.viewHandle(() => {
384
+ if (this.saveExportJson) {
407
385
  this.exportJson()
408
- })
409
- }
386
+ } else {
387
+ this.$emit('saveQueryParams', this.result)
388
+ if (callback) {
389
+ callback()
390
+ }
391
+ }
392
+ })
410
393
  })
411
394
  },
412
395
  // 判断是否为json字符串
@@ -455,7 +438,7 @@ export default {
455
438
  }
456
439
  </script>
457
440
  <style lang="less" scoped>
458
- .column_item :hover {
441
+ .column_item:hover {
459
442
  background-color:rgba(64, 169, 255,0.25);
460
443
  }
461
444
  .dragTips{
@@ -11,7 +11,7 @@
11
11
  @onSubmit="onAddOrEditSubmit"/>
12
12
  <a-list
13
13
  :grid="{gutter: 24, lg: 4, md: 3, sm: 1, xs: 1}"
14
- :dataSource="columnJson.groups"
14
+ :dataSource="content.groups"
15
15
  >
16
16
  <a-list-item slot="renderItem" slot-scope="item">
17
17
  <a-card :hoverable="true" @click="toEdit(item)">
@@ -40,7 +40,6 @@ export default {
40
40
  return {
41
41
  // 页面宽度
42
42
  screenWidth: document.documentElement.clientWidth,
43
- columnJson: {},
44
43
  formObj: {
45
44
  groupName: '',
46
45
  formJson: []
@@ -67,6 +66,10 @@ export default {
67
66
  default: () => {
68
67
  return {}
69
68
  }
69
+ },
70
+ content: {
71
+ type: Object,
72
+ required: true
70
73
  }
71
74
  },
72
75
  watch: {
@@ -79,9 +82,6 @@ export default {
79
82
  methods: {
80
83
  // 初始化组件
81
84
  initView () {
82
- this.$emit('getColumnJson', val => {
83
- this.columnJson = val
84
- })
85
85
  },
86
86
  toEdit (item) {
87
87
  parseConfig(item, 'SIMPLE_FORM', this.serviceName).then(res => {
@@ -8,11 +8,12 @@
8
8
  >
9
9
  <create-simple-form-query
10
10
  :to-edit-json="editItem()"
11
+ :as-a-params-group="true"
11
12
  :visible.sync="createQueryVisible"
12
- @saveSimpleFormQueryParams="saveQueryParams"
13
+ @saveQueryParams="saveQueryParams"
13
14
  />
14
15
  <a-list
15
- :dataSource="columnJsonCopy()"
16
+ :dataSource="contentCopy()"
16
17
  :grid="{gutter: 24, lg: 4, md: 3, sm: 1, xs: 1}"
17
18
  >
18
19
  <a-list-item slot="renderItem" slot-scope="item, index">
@@ -39,7 +40,7 @@
39
40
 
40
41
  <script>
41
42
  import { mapState } from 'vuex'
42
- import CreateSimpleFormQuery from '@vue2-client/base-client/components/common/CreateSimpleFormQuery'
43
+ import CreateSimpleFormQuery from '../CreateSimpleFormQuery'
43
44
 
44
45
  export default {
45
46
  name: 'FormGroupQuery',
@@ -53,7 +54,6 @@ export default {
53
54
  // 是否显示生成查询配置抽屉
54
55
  createQueryVisible: false,
55
56
  targetIndex: 0,
56
- columnJson: {},
57
57
  editIndex: -1
58
58
  }
59
59
  },
@@ -67,6 +67,10 @@ export default {
67
67
  visible: {
68
68
  type: Boolean,
69
69
  default: false
70
+ },
71
+ content: {
72
+ type: Object,
73
+ required: true
70
74
  }
71
75
  },
72
76
  watch: {
@@ -80,9 +84,6 @@ export default {
80
84
  // 初始化组件
81
85
  initView () {
82
86
  this.editIndex = -1
83
- this.$emit('getColumnJson', val => {
84
- this.columnJson = val
85
- })
86
87
  },
87
88
  toCreateQuery () {
88
89
  this.editIndex = -1
@@ -101,8 +102,8 @@ export default {
101
102
  okType: 'danger',
102
103
  cancelText: '取消',
103
104
  onOk () {
104
- _this.columnJson.groups.splice(index, 1)
105
- _this.$emit('saveQueryParams', _this.columnJson)
105
+ _this.content.groups.splice(index, 1)
106
+ _this.$emit('saveQueryParams', _this.content)
106
107
  }
107
108
  })
108
109
  },
@@ -111,21 +112,21 @@ export default {
111
112
  },
112
113
  // 存储查询配置信息
113
114
  saveQueryParams (source) {
114
- if (!this.columnJson.groups) {
115
- this.columnJson.groups = []
115
+ if (!this.content.groups) {
116
+ this.content.groups = []
116
117
  }
117
118
  if (this.editIndex !== -1) {
118
- this.columnJson.groups[this.editIndex] = source
119
+ this.content.groups[this.editIndex] = source
119
120
  } else {
120
- this.columnJson.groups.push(source)
121
+ this.content.groups.push(source)
121
122
  }
122
- this.$emit('saveQueryParams', this.columnJson)
123
+ this.$emit('saveQueryParams', this.content)
123
124
  this.createQueryVisible = false
124
125
  },
125
- columnJsonCopy () {
126
+ contentCopy () {
126
127
  let groups
127
- if (this.columnJson.groups) {
128
- groups = JSON.parse(JSON.stringify(this.columnJson.groups))
128
+ if (this.content.groups) {
129
+ groups = JSON.parse(JSON.stringify(this.content.groups))
129
130
  } else {
130
131
  groups = []
131
132
  }
@@ -134,7 +135,7 @@ export default {
134
135
  },
135
136
  editItem () {
136
137
  if (this.editIndex !== -1) {
137
- return JSON.parse(JSON.stringify(this.columnJson.groups[this.editIndex]))
138
+ return JSON.parse(JSON.stringify(this.content.groups[this.editIndex]))
138
139
  } else {
139
140
  return {}
140
141
  }
@@ -46,7 +46,7 @@
46
46
  </template>
47
47
  <template v-else>
48
48
  <a-empty>
49
- <span slot="description"> 页面配置不存在,请联系系统管理员 </span>
49
+ <span slot="description"> 页面配置不存在请联系系统管理员, </span>
50
50
  </a-empty>
51
51
  </template>
52
52
  </div>
@@ -239,6 +239,26 @@ export default {
239
239
  return false
240
240
  }
241
241
  },
242
+ active (props) {
243
+ let num = false
244
+ for (const key in props) {
245
+ // eslint-disable-next-line no-prototype-builtins
246
+ if (this.$props.hasOwnProperty(key)) {
247
+ console.log('key', this.$props[key] instanceof Object)
248
+ if (this.$props[key] instanceof Object) {
249
+ this.$props[key] = JSON.parse(props[key])
250
+ } else {
251
+ this.$props[key] = props[key]
252
+ }
253
+ num = true
254
+ }
255
+ console.log(key, props[key])
256
+ }
257
+ console.warn('activeProps', this.$props)
258
+ if (num) {
259
+ this.initConfig()
260
+ }
261
+ },
242
262
  /**
243
263
  * 提交新增/修改表单后事件
244
264
  */
@@ -338,6 +358,22 @@ export default {
338
358
  */
339
359
  refreshTable (toFirstPage = true) {
340
360
  this.$refs.xTable.refresh(toFirstPage)
361
+ },
362
+ },
363
+ action: {
364
+ /**
365
+ * 实现doAction方法
366
+ */
367
+ doAction (actionType, args, data) {
368
+ switch (actionType) {
369
+ case 'refreshTable':
370
+ for (const item in args) {
371
+ console.log('item', item)
372
+ }
373
+ break
374
+ default:
375
+ break
376
+ }
341
377
  }
342
378
  }
343
379
  }
@@ -14,8 +14,8 @@ import FormGroupEdit from './common/FormGroupEdit'
14
14
  import FormGroupQuery from './common/FormGroupQuery'
15
15
  import AddressSearchCombobox from './common/AddressSearchCombobox'
16
16
  import AmapMarker from './common/AmapMarker'
17
- import CreateQuery from './common/CreateQuery'
18
- import CreateSimpleFormQuery from './common/CreateSimpleFormQuery'
17
+ // import CreateQuery from './common/CreateQuery'
18
+ // import CreateSimpleFormQuery from './common/CreateSimpleFormQuery'
19
19
  import PersonSetting from './common/PersonSetting'
20
20
  import XFormTable from './common/XFormTable'
21
21
  import XStepView from './common/XStepView'
@@ -38,8 +38,8 @@ export default {
38
38
  FormGroupQuery,
39
39
  AddressSearchCombobox,
40
40
  AmapMarker,
41
- CreateQuery,
42
- CreateSimpleFormQuery,
41
+ // CreateQuery,
42
+ // CreateSimpleFormQuery,
43
43
  XFormTable,
44
44
  PersonSetting,
45
45
  Tree,
@@ -3,54 +3,204 @@
3
3
  </template>
4
4
  <script>
5
5
  import AMISRenderer from '@vue2-client/base-client/components/common/AMisRender'
6
+ // import Vue from 'vue'
7
+ // import Index from '@vue2-client/base-client/components/index.js'
8
+ //
9
+ // const vms = {}
10
+ // const store = Vue.$store
11
+ // const router = Vue.$router
12
+ // const i18n = Vue.$i18n
6
13
 
7
14
  const schema = {
8
15
  // 原生与自定义组件混用
9
16
  type: 'page',
10
- title: '页面主题',
17
+ css: {
18
+ },
11
19
  body: [
12
20
  {
13
- // 自定义组件
14
- type: 'XFormTable',
15
- queryParamsName: 'crud_dictionary_manage'
16
- }
17
- ],
18
- // 原生边栏组件
19
- aside: [
21
+ type: 'grid',
22
+ columns: [
23
+ {
24
+ mode: 'horizontal',
25
+ body: {
26
+ name: 'queryParams',
27
+ type: 'input-text',
28
+ label: '查询值'
29
+ },
30
+ md: 4
31
+ }
32
+ ]
33
+ },
20
34
  {
21
- type: 'panel',
22
- title: '边栏',
23
- body: [
35
+ type: 'grid',
36
+ columns: [
24
37
  {
25
- type: 'input-tree',
26
- label: '树选择框',
27
- name: 'tree',
28
- options: [
38
+ body: [
39
+ {
40
+ type: 'input-tree',
41
+ name: 'test',
42
+ label: '树选择框',
43
+ source: {
44
+ method: 'post',
45
+ url: '/api/af-system/logic/get_root_nodes'
46
+ },
47
+ // api: {
48
+ // method: 'post',
49
+ // url: '/api/af-system/logic/get_root_nodes'
50
+ // }
51
+ }
52
+ ],
53
+ id: 'u:b1d2075dc231',
54
+ md: 1.5
55
+ },
56
+ {
57
+ body: [
58
+ {
59
+ type: 'table-view',
60
+ name: 'table-view1',
61
+ api: '',
62
+ trs: [
63
+ {
64
+ background: '#F7F7F7',
65
+ tds: [
66
+ {
67
+ align: 'center',
68
+ body: {
69
+ type: 'tpl',
70
+ tpl: '地区'
71
+ }
72
+ },
73
+ {
74
+ align: 'center',
75
+ body: {
76
+ type: 'tpl',
77
+ tpl: '城市'
78
+ }
79
+ },
80
+ {
81
+ align: 'center',
82
+ body: {
83
+ type: 'tpl',
84
+ tpl: '销量'
85
+ }
86
+ }
87
+ ]
88
+ },
89
+ {
90
+ tds: [
91
+ {
92
+ align: 'center',
93
+ colspan: 2,
94
+ rowspan: 2,
95
+ body: {
96
+ type: 'tpl',
97
+ tpl: '${queryParams}'
98
+ }
99
+ },
100
+ {
101
+ body: {
102
+ type: 'tpl',
103
+ tpl: '北京'
104
+ },
105
+ }
106
+ ]
107
+ },
108
+ {
109
+ tds: [
110
+ {
111
+ body: {
112
+ type: 'tpl',
113
+ tpl: '上京'
114
+ },
115
+ }
116
+ ]
117
+ }
118
+ ]
119
+ },
29
120
  {
30
- label: '选项A',
31
- value: 'A',
32
- children: [
121
+
122
+ },
123
+ {
124
+ type: 'table-view',
125
+ trs: [
33
126
  {
34
- label: '选项C',
35
- value: 'C'
127
+ background: '#F7F7F7',
128
+ tds: [
129
+ {
130
+ align: 'center',
131
+ body: {
132
+ type: 'tpl',
133
+ tpl: '地区'
134
+ }
135
+ },
136
+ {
137
+ align: 'center',
138
+ body: {
139
+ type: 'tpl',
140
+ tpl: '城市'
141
+ }
142
+ },
143
+ {
144
+ align: 'center',
145
+ body: {
146
+ type: 'tpl',
147
+ tpl: '销量'
148
+ }
149
+ }
150
+ ]
36
151
  },
37
152
  {
38
- label: '选项D',
39
- value: 'D'
153
+ tds: [
154
+ {
155
+ align: 'center',
156
+ colspan: 3,
157
+ body: {
158
+ type: 'tpl',
159
+ tpl: '北京'
160
+ }
161
+ },
162
+
163
+ ]
40
164
  }
41
165
  ]
42
166
  },
43
- {
44
- label: '选项B',
45
- value: 'B'
46
- }
47
- ]
167
+ // {
168
+ // name: 'username', // 如果要放在 form 中,需要设置 name,onChange 将会设置这个值
169
+ // type: 'custom',
170
+ // // onMount 将会在组件创建时执行,默认会创建一个空 div 标签,也可以设置 inline: true 来创建 span 标签
171
+ // // dom 是 dom 节点,value 是初始数据,比如表单 name 初始拿到的数据,onChange 只有在表单下才会有
172
+ // onMount: (dom, value, onChange) => {
173
+ // const vm = new Vue({
174
+ // router,
175
+ // store,
176
+ // i18n,
177
+ // render: h => h(Index.XFormTable, {
178
+ // props: {
179
+ // queryParamsName: `crud_dictionary_manage`
180
+ // }
181
+ // })
182
+ // })
183
+ // vms.XFormTable = vm
184
+ // dom.appendChild(vm.$mount().$el)
185
+ // },
186
+ // // onUpdate 将会在数据更新时被调用
187
+ // // dom 是 dom 节点、data 将包含表单所有数据,prevData 是之前表单的所有数据
188
+ // onUpdate: (dom, data, prevData) => {
189
+ // console.log('数据有变化', data)
190
+ // const vm = vms.XFormTable
191
+ // vm.$children[0].active(data)
192
+ // },
193
+ // // onUnmount 将会在组件被销毁的时候调用,用于清理资源
194
+ // onUnmount: () => {
195
+ // console.log('组件被销毁')
196
+ // },
197
+ // }
198
+ ],
199
+ id: 'u:e4e49c147c06'
48
200
  }
49
- ]
201
+ ],
50
202
  }
51
- ],
52
- asideResizor: true,
53
- asideSticky: false
203
+ ]
54
204
  }
55
205
 
56
206
  export default {
@@ -58,10 +208,16 @@ export default {
58
208
  components: {
59
209
  'amis-renderer': AMISRenderer,
60
210
  },
61
- computed: {},
211
+ computed: {
212
+ },
213
+ mounted () {
214
+
215
+ },
62
216
  data: () => ({
63
217
  schema: schema,
64
- locals: {},
218
+ locals: { fixedQueryForm: {} },
219
+ vms: {},
220
+ queryParamsName: 'crud_dictionary_manage'
65
221
  }),
66
222
  }
67
223
  </script>
@@ -0,0 +1,74 @@
1
+ <template>
2
+ <amis-renderer :schema="schemaJson" :locals="locals" />
3
+ </template>
4
+ <script>
5
+ import AMISRenderer from '@vue2-client/base-client/components/common/AMisRender'
6
+
7
+ const schema = {
8
+ // 原生与自定义组件混用
9
+ type: 'page',
10
+ data: {
11
+ queryParamsName: 'crud_dictionary_manage',
12
+ fixedQueryForm: '{}'
13
+ },
14
+ body: [
15
+ {
16
+ type: 'tabs',
17
+ tabsMode: 'chrome',
18
+ name: 'fixedQueryForm',
19
+ id: 'username',
20
+ tabs: [
21
+ {
22
+ title: '测试1',
23
+ value: '{"d_f_name":"设备异常处理方式"}',
24
+ body: {
25
+ name: 'username',
26
+ id: 'XFormTable1',
27
+ type: 'XFormTable',
28
+ }
29
+ },
30
+ {
31
+ title: '选项卡3',
32
+ value: '{"d_f_name":"二级用气性质"}',
33
+ body: {
34
+ name: 'username2',
35
+ id: 'XFormTable2',
36
+ type: 'XFormTable',
37
+ }
38
+ },
39
+ ],
40
+ },
41
+ ]
42
+ }
43
+
44
+ export default {
45
+ name: 'AMisDemo',
46
+ components: {
47
+ 'amis-renderer': AMISRenderer,
48
+ },
49
+ computed: {
50
+ },
51
+ props: {
52
+ queryParamsName: {
53
+ type: String,
54
+ default: () => {
55
+ return 'crud_dictionary_manage'
56
+ }
57
+ },
58
+ schemaJson: {
59
+ type: Object,
60
+ default: () => {
61
+ return schema
62
+ }
63
+ }
64
+ },
65
+ mounted () {
66
+ },
67
+ data: () => ({
68
+ locals: {},
69
+ vms: {},
70
+ }),
71
+ methods: {
72
+ }
73
+ }
74
+ </script>
package/src/router.js CHANGED
@@ -7,7 +7,9 @@ function loadView (view) {
7
7
  const routes = [
8
8
  // 对于每个路由,你都可以使用 'loadView' 方法动态加载对应的组件
9
9
  { path: '/Tree', component: loadView('Tree') },
10
+ { path: '/XStepView', component: loadView('XStepView') },
10
11
  { path: '/Amis', component: () => import('@vue2-client/pages/AMisDemo/AMisDemo') },
12
+ { path: '/Amis2', component: () => import('@vue2-client/pages/AMisDemo/AMisDemo2') },
11
13
  // ... 其他路由
12
14
  ]
13
15
  export default routes