vue2-client 1.4.5 → 1.4.6
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/.env +15 -15
- package/.eslintrc.js +82 -82
- package/CHANGELOG.md +347 -344
- package/package.json +78 -78
- package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +113 -113
- package/src/base-client/components/common/CitySelect/CitySelect.vue +244 -244
- package/src/base-client/components/common/CitySelect/index.js +3 -3
- package/src/base-client/components/common/CitySelect/index.md +109 -109
- package/src/base-client/components/common/CreateQuery/CreateQuery.vue +589 -589
- package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +310 -310
- package/src/base-client/components/common/PersonSetting/PersonSetting.vue +210 -210
- package/src/base-client/components/common/PersonSetting/index.js +3 -3
- package/src/base-client/components/common/Upload/index.js +3 -3
- package/src/base-client/components/common/XFormTable/XFormTable.vue +546 -546
- package/src/base-client/components/common/XTable/XTable.vue +262 -262
- package/src/config/CreateQueryConfig.js +307 -307
- package/src/pages/system/ticket/index.vue +1 -1
- package/src/router/async/router.map.js +56 -58
- package/src/services/api/restTools.js +24 -24
- package/vue.config.js +99 -99
|
@@ -1,310 +1,310 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<a-drawer
|
|
3
|
-
title="基础表单配置生成"
|
|
4
|
-
placement="right"
|
|
5
|
-
:width="isMobile ? screenWidth : screenWidth * 0.85"
|
|
6
|
-
:visible="visible"
|
|
7
|
-
@close="onClose"
|
|
8
|
-
>
|
|
9
|
-
<a-row :gutter="24">
|
|
10
|
-
<a-col :xl="14" :lg="12" :md="12" :sm="24" :xs="24">
|
|
11
|
-
<a-form-model
|
|
12
|
-
ref="businessCreateForm"
|
|
13
|
-
:rules="rules"
|
|
14
|
-
:model="form"
|
|
15
|
-
:label-col="labelCol"
|
|
16
|
-
:wrapper-col="wrapperCol"
|
|
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>
|
|
24
|
-
<a-form-model-item label="数据字段" prop="column">
|
|
25
|
-
<a-button type="primary" @click="addColumnItem()">增加</a-button>
|
|
26
|
-
<div v-for="(columnItem, index) in form.column" :key="index">
|
|
27
|
-
<a-row :gutter="16">
|
|
28
|
-
<a-col :span="16">
|
|
29
|
-
<span style="font-weight: bold">{{ columnItem.title }}({{ columnItem.key }})</span>
|
|
30
|
-
</a-col>
|
|
31
|
-
<a-col v-if="index > 0 && form.column.length > 1" :span="2">
|
|
32
|
-
<a-icon type="up-square" @click="upColumnItem(columnItem.key,index)"/>
|
|
33
|
-
</a-col>
|
|
34
|
-
<a-col v-if="(index !== form.column.length - 1) && form.column.length > 1" :span="2">
|
|
35
|
-
<a-icon type="down-square" @click="downColumnItem(columnItem.key,index)"/>
|
|
36
|
-
</a-col>
|
|
37
|
-
<a-col :span="2">
|
|
38
|
-
<a-icon type="edit" @click="editColumnItem(columnItem.key,index)"/>
|
|
39
|
-
</a-col>
|
|
40
|
-
<a-col :span="2">
|
|
41
|
-
<a-icon type="close" @click="removeColumnItem(columnItem.key,index)"/>
|
|
42
|
-
</a-col>
|
|
43
|
-
</a-row>
|
|
44
|
-
</div>
|
|
45
|
-
</a-form-model-item>
|
|
46
|
-
</a-form-model>
|
|
47
|
-
<create-simple-form-query-item ref="queryItem" @itemHandle="itemHandle" @getColumn="getColumn"/>
|
|
48
|
-
<a-button type="primary" @click="view">操作</a-button>
|
|
49
|
-
</a-col>
|
|
50
|
-
<a-col :xl="10" :lg="12" :md="12" :sm="24" :xs="24">
|
|
51
|
-
<a-card :bordered="false" title="预览" size="small" style="overflow: auto">
|
|
52
|
-
<json-viewer :copyable="{copyText: '复制', copiedText: '已复制'}" :value="result" :expand-depth="parseInt('100')" style="overflow: auto;max-height: 440px"></json-viewer>
|
|
53
|
-
</a-card>
|
|
54
|
-
</a-col>
|
|
55
|
-
</a-row>
|
|
56
|
-
<x-add-form
|
|
57
|
-
business-title="效果预览"
|
|
58
|
-
business-type="新增"
|
|
59
|
-
:visible.sync="modelVisible"
|
|
60
|
-
:json-data="formItems"
|
|
61
|
-
@onSubmit="submit"/>
|
|
62
|
-
</a-drawer>
|
|
63
|
-
</template>
|
|
64
|
-
|
|
65
|
-
<script>
|
|
66
|
-
import CreateSimpleFormQueryItem from './CreateSimpleFormQueryItem'
|
|
67
|
-
import XAddForm from '@vue2-client/base-client/components/common/XAddForm/XAddForm'
|
|
68
|
-
import JsonViewer from 'vue-json-viewer'
|
|
69
|
-
import FileSaver from 'file-saver'
|
|
70
|
-
import { mapState } from 'vuex'
|
|
71
|
-
import { commonApi, post } from '@vue2-client/services/api'
|
|
72
|
-
export default {
|
|
73
|
-
name: 'CreateSimpleFormQuery',
|
|
74
|
-
components: {
|
|
75
|
-
CreateSimpleFormQueryItem,
|
|
76
|
-
JsonViewer,
|
|
77
|
-
XAddForm
|
|
78
|
-
},
|
|
79
|
-
data () {
|
|
80
|
-
return {
|
|
81
|
-
// 页面宽度
|
|
82
|
-
screenWidth: document.documentElement.clientWidth,
|
|
83
|
-
// 效果预览模态框是否展示
|
|
84
|
-
modelVisible: false,
|
|
85
|
-
// 数据列操作类型:新增,修改
|
|
86
|
-
type: '新增',
|
|
87
|
-
labelCol: { span: 4 },
|
|
88
|
-
wrapperCol: { span: 14 },
|
|
89
|
-
form: {
|
|
90
|
-
group: '',
|
|
91
|
-
describe: '',
|
|
92
|
-
column: []
|
|
93
|
-
},
|
|
94
|
-
result: {},
|
|
95
|
-
itemMap: {},
|
|
96
|
-
selectIndex: null,
|
|
97
|
-
selectType: undefined,
|
|
98
|
-
joinArray: [],
|
|
99
|
-
rules: {
|
|
100
|
-
group: [{ required: true, message: '请输入参数组名称', trigger: 'blur' }],
|
|
101
|
-
describe: [{ required: true, message: '请输入参数组描述', trigger: 'blur' }]
|
|
102
|
-
},
|
|
103
|
-
formItems: [],
|
|
104
|
-
// 字典键集合
|
|
105
|
-
option: []
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
mounted () {
|
|
109
|
-
this.initView()
|
|
110
|
-
},
|
|
111
|
-
computed: {
|
|
112
|
-
...mapState('setting', ['isMobile'])
|
|
113
|
-
},
|
|
114
|
-
props: {
|
|
115
|
-
visible: {
|
|
116
|
-
type: Boolean,
|
|
117
|
-
default: false
|
|
118
|
-
},
|
|
119
|
-
toEditJson: {
|
|
120
|
-
type: Object,
|
|
121
|
-
default: () => {}
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
watch: {
|
|
125
|
-
visible (rel) {
|
|
126
|
-
if (rel) {
|
|
127
|
-
this.initView()
|
|
128
|
-
}
|
|
129
|
-
if (rel && this.toEditJson) {
|
|
130
|
-
this.form = Object.assign(
|
|
131
|
-
{
|
|
132
|
-
group: '',
|
|
133
|
-
describe: '',
|
|
134
|
-
column: []
|
|
135
|
-
}, this.toEditJson
|
|
136
|
-
)
|
|
137
|
-
for (const columnItem of this.form.column) {
|
|
138
|
-
// 必选项兼容处理
|
|
139
|
-
if (columnItem.rule && columnItem.rule.required && columnItem.rule.required !== 'false') {
|
|
140
|
-
columnItem.rule.required = columnItem.rule.required.toString()
|
|
141
|
-
} else {
|
|
142
|
-
if (!columnItem.rule) {
|
|
143
|
-
columnItem.rule = {}
|
|
144
|
-
}
|
|
145
|
-
columnItem.rule.required = 'false'
|
|
146
|
-
}
|
|
147
|
-
// 数据源加载方式兼容处理
|
|
148
|
-
if (columnItem.lazyLoad && columnItem.lazyLoad !== 'false') {
|
|
149
|
-
columnItem.lazyLoad = columnItem.lazyLoad.toString()
|
|
150
|
-
} else {
|
|
151
|
-
columnItem.lazyLoad = 'false'
|
|
152
|
-
}
|
|
153
|
-
// 下拉框数据源兼容处理
|
|
154
|
-
if ((columnItem.formType === 'select' || columnItem.formType === 'cascader') && columnItem.selectKey) {
|
|
155
|
-
// 数据源为logic
|
|
156
|
-
if (columnItem.selectKey.toString().startsWith('logic@')) {
|
|
157
|
-
columnItem.selectType = 'logic'
|
|
158
|
-
} else if (columnItem.selectKey instanceof Array || this.isJSON(columnItem.selectKey)) {
|
|
159
|
-
// 数据源为固定json集合
|
|
160
|
-
if (columnItem.selectKey instanceof Array) {
|
|
161
|
-
columnItem.selectKey = JSON.stringify(columnItem.selectKey)
|
|
162
|
-
}
|
|
163
|
-
columnItem.selectType = 'fixArray'
|
|
164
|
-
} else {
|
|
165
|
-
columnItem.selectType = 'key'
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
this.itemMap[columnItem.key] = Object.assign({
|
|
169
|
-
key: '',
|
|
170
|
-
title: '',
|
|
171
|
-
pathKey: '',
|
|
172
|
-
rule: {
|
|
173
|
-
required: 'false'
|
|
174
|
-
}
|
|
175
|
-
}, columnItem)
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
methods: {
|
|
181
|
-
// 初始化组件
|
|
182
|
-
initView () {
|
|
183
|
-
this.result = {}
|
|
184
|
-
post(commonApi.getDictionaryParam, {}).then(res => {
|
|
185
|
-
this.option = res
|
|
186
|
-
})
|
|
187
|
-
},
|
|
188
|
-
onClose () {
|
|
189
|
-
this.$emit('update:visible', false)
|
|
190
|
-
},
|
|
191
|
-
filterOption (input, option) {
|
|
192
|
-
return (
|
|
193
|
-
option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
194
|
-
)
|
|
195
|
-
},
|
|
196
|
-
onModelClose () {
|
|
197
|
-
this.modelVisible = false
|
|
198
|
-
},
|
|
199
|
-
removeColumnItem (key, index) {
|
|
200
|
-
const _this = this
|
|
201
|
-
this.$confirm({
|
|
202
|
-
title: '您确定要删除该数据项?',
|
|
203
|
-
content: '删除的数据项无法恢复',
|
|
204
|
-
okText: '确定',
|
|
205
|
-
okType: 'danger',
|
|
206
|
-
cancelText: '取消',
|
|
207
|
-
onOk () {
|
|
208
|
-
delete _this.itemMap[key]
|
|
209
|
-
_this.form.column.splice(index, 1)
|
|
210
|
-
}
|
|
211
|
-
})
|
|
212
|
-
},
|
|
213
|
-
upColumnItem (key, index) {
|
|
214
|
-
const newIndex = index - 1
|
|
215
|
-
const itemA = this.form.column[newIndex]
|
|
216
|
-
const itemB = this.form.column[index]
|
|
217
|
-
this.form.column.splice(index, 1, itemA)
|
|
218
|
-
this.form.column.splice(newIndex, 1, itemB)
|
|
219
|
-
},
|
|
220
|
-
downColumnItem (key, index) {
|
|
221
|
-
const newIndex = index + 1
|
|
222
|
-
const itemA = this.form.column[newIndex]
|
|
223
|
-
const itemB = this.form.column[index]
|
|
224
|
-
this.form.column.splice(index, 1, itemA)
|
|
225
|
-
this.form.column.splice(newIndex, 1, itemB)
|
|
226
|
-
},
|
|
227
|
-
itemHandle (item, type) {
|
|
228
|
-
console.log(JSON.stringify(item))
|
|
229
|
-
this.itemMap[item.key] = item
|
|
230
|
-
if (type === '新增') {
|
|
231
|
-
this.form.column.push(item)
|
|
232
|
-
} else {
|
|
233
|
-
this.$set(this.form.column, this.selectIndex, item)
|
|
234
|
-
}
|
|
235
|
-
this.$message.success(`${type}成功`)
|
|
236
|
-
this.$refs.queryItem.flashModal(false)
|
|
237
|
-
},
|
|
238
|
-
addColumnItem () {
|
|
239
|
-
this.type = '新增'
|
|
240
|
-
this.$refs.queryItem.addColumnItemExecute()
|
|
241
|
-
},
|
|
242
|
-
editColumnItem (key, index) {
|
|
243
|
-
if (this.itemMap[key]) {
|
|
244
|
-
this.$refs.queryItem.editColumnItemExecute(this.itemMap[key])
|
|
245
|
-
this.selectIndex = index
|
|
246
|
-
} else {
|
|
247
|
-
this.$message.warn('编辑失败')
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
getColumn (callback) {
|
|
251
|
-
callback(JSON.parse(JSON.stringify(this.form.column)))
|
|
252
|
-
},
|
|
253
|
-
// 判断是否为json字符串
|
|
254
|
-
isJSON (str) {
|
|
255
|
-
if (typeof str == 'string') {
|
|
256
|
-
try {
|
|
257
|
-
const obj = JSON.parse(str)
|
|
258
|
-
return !!(typeof obj == 'object' && obj)
|
|
259
|
-
} catch (e) {
|
|
260
|
-
return false
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
},
|
|
264
|
-
exportJson () {
|
|
265
|
-
const data = JSON.stringify(this.form, null, 2)
|
|
266
|
-
const blob = new Blob([data], { type: 'application/json' })
|
|
267
|
-
FileSaver.saveAs(blob, `SimpleFormQuery.json`)
|
|
268
|
-
this.$message.success('导出成功!')
|
|
269
|
-
},
|
|
270
|
-
viewHandle (then) {
|
|
271
|
-
if (this.form.column.length === 0) {
|
|
272
|
-
this.$message.error('你没有增加任何数据字段')
|
|
273
|
-
return
|
|
274
|
-
}
|
|
275
|
-
this.result = JSON.parse(JSON.stringify(this.form))
|
|
276
|
-
for (const item of this.result.column) {
|
|
277
|
-
if (item.selectType === 'fixArray') {
|
|
278
|
-
item.selectKey = JSON.parse(item.selectKey)
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
then()
|
|
282
|
-
},
|
|
283
|
-
view () {
|
|
284
|
-
this.$refs.businessCreateForm.validate(valid => {
|
|
285
|
-
if (valid) {
|
|
286
|
-
this.viewHandle(() => {
|
|
287
|
-
post(commonApi.getColumnsJson, { queryObject: this.result }).then(res => {
|
|
288
|
-
this.formItems = res.formJson
|
|
289
|
-
this.modelVisible = true
|
|
290
|
-
})
|
|
291
|
-
})
|
|
292
|
-
}
|
|
293
|
-
})
|
|
294
|
-
},
|
|
295
|
-
submit () {
|
|
296
|
-
this.onModelClose()
|
|
297
|
-
this.$refs.businessCreateForm.validate(valid => {
|
|
298
|
-
if (valid) {
|
|
299
|
-
this.viewHandle(() => {
|
|
300
|
-
// saveQueryParams
|
|
301
|
-
this.$emit('saveSimpleFormQueryParams', this.result)
|
|
302
|
-
})
|
|
303
|
-
}
|
|
304
|
-
})
|
|
305
|
-
},
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
</script>
|
|
309
|
-
<style lang="less" scoped>
|
|
310
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<a-drawer
|
|
3
|
+
title="基础表单配置生成"
|
|
4
|
+
placement="right"
|
|
5
|
+
:width="isMobile ? screenWidth : screenWidth * 0.85"
|
|
6
|
+
:visible="visible"
|
|
7
|
+
@close="onClose"
|
|
8
|
+
>
|
|
9
|
+
<a-row :gutter="24">
|
|
10
|
+
<a-col :xl="14" :lg="12" :md="12" :sm="24" :xs="24">
|
|
11
|
+
<a-form-model
|
|
12
|
+
ref="businessCreateForm"
|
|
13
|
+
:rules="rules"
|
|
14
|
+
:model="form"
|
|
15
|
+
:label-col="labelCol"
|
|
16
|
+
:wrapper-col="wrapperCol"
|
|
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>
|
|
24
|
+
<a-form-model-item label="数据字段" prop="column">
|
|
25
|
+
<a-button type="primary" @click="addColumnItem()">增加</a-button>
|
|
26
|
+
<div v-for="(columnItem, index) in form.column" :key="index">
|
|
27
|
+
<a-row :gutter="16">
|
|
28
|
+
<a-col :span="16">
|
|
29
|
+
<span style="font-weight: bold">{{ columnItem.title }}({{ columnItem.key }})</span>
|
|
30
|
+
</a-col>
|
|
31
|
+
<a-col v-if="index > 0 && form.column.length > 1" :span="2">
|
|
32
|
+
<a-icon type="up-square" @click="upColumnItem(columnItem.key,index)"/>
|
|
33
|
+
</a-col>
|
|
34
|
+
<a-col v-if="(index !== form.column.length - 1) && form.column.length > 1" :span="2">
|
|
35
|
+
<a-icon type="down-square" @click="downColumnItem(columnItem.key,index)"/>
|
|
36
|
+
</a-col>
|
|
37
|
+
<a-col :span="2">
|
|
38
|
+
<a-icon type="edit" @click="editColumnItem(columnItem.key,index)"/>
|
|
39
|
+
</a-col>
|
|
40
|
+
<a-col :span="2">
|
|
41
|
+
<a-icon type="close" @click="removeColumnItem(columnItem.key,index)"/>
|
|
42
|
+
</a-col>
|
|
43
|
+
</a-row>
|
|
44
|
+
</div>
|
|
45
|
+
</a-form-model-item>
|
|
46
|
+
</a-form-model>
|
|
47
|
+
<create-simple-form-query-item ref="queryItem" @itemHandle="itemHandle" @getColumn="getColumn"/>
|
|
48
|
+
<a-button type="primary" @click="view">操作</a-button>
|
|
49
|
+
</a-col>
|
|
50
|
+
<a-col :xl="10" :lg="12" :md="12" :sm="24" :xs="24">
|
|
51
|
+
<a-card :bordered="false" title="预览" size="small" style="overflow: auto">
|
|
52
|
+
<json-viewer :copyable="{copyText: '复制', copiedText: '已复制'}" :value="result" :expand-depth="parseInt('100')" style="overflow: auto;max-height: 440px"></json-viewer>
|
|
53
|
+
</a-card>
|
|
54
|
+
</a-col>
|
|
55
|
+
</a-row>
|
|
56
|
+
<x-add-form
|
|
57
|
+
business-title="效果预览"
|
|
58
|
+
business-type="新增"
|
|
59
|
+
:visible.sync="modelVisible"
|
|
60
|
+
:json-data="formItems"
|
|
61
|
+
@onSubmit="submit"/>
|
|
62
|
+
</a-drawer>
|
|
63
|
+
</template>
|
|
64
|
+
|
|
65
|
+
<script>
|
|
66
|
+
import CreateSimpleFormQueryItem from './CreateSimpleFormQueryItem'
|
|
67
|
+
import XAddForm from '@vue2-client/base-client/components/common/XAddForm/XAddForm'
|
|
68
|
+
import JsonViewer from 'vue-json-viewer'
|
|
69
|
+
import FileSaver from 'file-saver'
|
|
70
|
+
import { mapState } from 'vuex'
|
|
71
|
+
import { commonApi, post } from '@vue2-client/services/api'
|
|
72
|
+
export default {
|
|
73
|
+
name: 'CreateSimpleFormQuery',
|
|
74
|
+
components: {
|
|
75
|
+
CreateSimpleFormQueryItem,
|
|
76
|
+
JsonViewer,
|
|
77
|
+
XAddForm
|
|
78
|
+
},
|
|
79
|
+
data () {
|
|
80
|
+
return {
|
|
81
|
+
// 页面宽度
|
|
82
|
+
screenWidth: document.documentElement.clientWidth,
|
|
83
|
+
// 效果预览模态框是否展示
|
|
84
|
+
modelVisible: false,
|
|
85
|
+
// 数据列操作类型:新增,修改
|
|
86
|
+
type: '新增',
|
|
87
|
+
labelCol: { span: 4 },
|
|
88
|
+
wrapperCol: { span: 14 },
|
|
89
|
+
form: {
|
|
90
|
+
group: '',
|
|
91
|
+
describe: '',
|
|
92
|
+
column: []
|
|
93
|
+
},
|
|
94
|
+
result: {},
|
|
95
|
+
itemMap: {},
|
|
96
|
+
selectIndex: null,
|
|
97
|
+
selectType: undefined,
|
|
98
|
+
joinArray: [],
|
|
99
|
+
rules: {
|
|
100
|
+
group: [{ required: true, message: '请输入参数组名称', trigger: 'blur' }],
|
|
101
|
+
describe: [{ required: true, message: '请输入参数组描述', trigger: 'blur' }]
|
|
102
|
+
},
|
|
103
|
+
formItems: [],
|
|
104
|
+
// 字典键集合
|
|
105
|
+
option: []
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
mounted () {
|
|
109
|
+
this.initView()
|
|
110
|
+
},
|
|
111
|
+
computed: {
|
|
112
|
+
...mapState('setting', ['isMobile'])
|
|
113
|
+
},
|
|
114
|
+
props: {
|
|
115
|
+
visible: {
|
|
116
|
+
type: Boolean,
|
|
117
|
+
default: false
|
|
118
|
+
},
|
|
119
|
+
toEditJson: {
|
|
120
|
+
type: Object,
|
|
121
|
+
default: () => {}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
watch: {
|
|
125
|
+
visible (rel) {
|
|
126
|
+
if (rel) {
|
|
127
|
+
this.initView()
|
|
128
|
+
}
|
|
129
|
+
if (rel && this.toEditJson) {
|
|
130
|
+
this.form = Object.assign(
|
|
131
|
+
{
|
|
132
|
+
group: '',
|
|
133
|
+
describe: '',
|
|
134
|
+
column: []
|
|
135
|
+
}, this.toEditJson
|
|
136
|
+
)
|
|
137
|
+
for (const columnItem of this.form.column) {
|
|
138
|
+
// 必选项兼容处理
|
|
139
|
+
if (columnItem.rule && columnItem.rule.required && columnItem.rule.required !== 'false') {
|
|
140
|
+
columnItem.rule.required = columnItem.rule.required.toString()
|
|
141
|
+
} else {
|
|
142
|
+
if (!columnItem.rule) {
|
|
143
|
+
columnItem.rule = {}
|
|
144
|
+
}
|
|
145
|
+
columnItem.rule.required = 'false'
|
|
146
|
+
}
|
|
147
|
+
// 数据源加载方式兼容处理
|
|
148
|
+
if (columnItem.lazyLoad && columnItem.lazyLoad !== 'false') {
|
|
149
|
+
columnItem.lazyLoad = columnItem.lazyLoad.toString()
|
|
150
|
+
} else {
|
|
151
|
+
columnItem.lazyLoad = 'false'
|
|
152
|
+
}
|
|
153
|
+
// 下拉框数据源兼容处理
|
|
154
|
+
if ((columnItem.formType === 'select' || columnItem.formType === 'cascader') && columnItem.selectKey) {
|
|
155
|
+
// 数据源为logic
|
|
156
|
+
if (columnItem.selectKey.toString().startsWith('logic@')) {
|
|
157
|
+
columnItem.selectType = 'logic'
|
|
158
|
+
} else if (columnItem.selectKey instanceof Array || this.isJSON(columnItem.selectKey)) {
|
|
159
|
+
// 数据源为固定json集合
|
|
160
|
+
if (columnItem.selectKey instanceof Array) {
|
|
161
|
+
columnItem.selectKey = JSON.stringify(columnItem.selectKey)
|
|
162
|
+
}
|
|
163
|
+
columnItem.selectType = 'fixArray'
|
|
164
|
+
} else {
|
|
165
|
+
columnItem.selectType = 'key'
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
this.itemMap[columnItem.key] = Object.assign({
|
|
169
|
+
key: '',
|
|
170
|
+
title: '',
|
|
171
|
+
pathKey: '',
|
|
172
|
+
rule: {
|
|
173
|
+
required: 'false'
|
|
174
|
+
}
|
|
175
|
+
}, columnItem)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
methods: {
|
|
181
|
+
// 初始化组件
|
|
182
|
+
initView () {
|
|
183
|
+
this.result = {}
|
|
184
|
+
post(commonApi.getDictionaryParam, {}).then(res => {
|
|
185
|
+
this.option = res
|
|
186
|
+
})
|
|
187
|
+
},
|
|
188
|
+
onClose () {
|
|
189
|
+
this.$emit('update:visible', false)
|
|
190
|
+
},
|
|
191
|
+
filterOption (input, option) {
|
|
192
|
+
return (
|
|
193
|
+
option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
194
|
+
)
|
|
195
|
+
},
|
|
196
|
+
onModelClose () {
|
|
197
|
+
this.modelVisible = false
|
|
198
|
+
},
|
|
199
|
+
removeColumnItem (key, index) {
|
|
200
|
+
const _this = this
|
|
201
|
+
this.$confirm({
|
|
202
|
+
title: '您确定要删除该数据项?',
|
|
203
|
+
content: '删除的数据项无法恢复',
|
|
204
|
+
okText: '确定',
|
|
205
|
+
okType: 'danger',
|
|
206
|
+
cancelText: '取消',
|
|
207
|
+
onOk () {
|
|
208
|
+
delete _this.itemMap[key]
|
|
209
|
+
_this.form.column.splice(index, 1)
|
|
210
|
+
}
|
|
211
|
+
})
|
|
212
|
+
},
|
|
213
|
+
upColumnItem (key, index) {
|
|
214
|
+
const newIndex = index - 1
|
|
215
|
+
const itemA = this.form.column[newIndex]
|
|
216
|
+
const itemB = this.form.column[index]
|
|
217
|
+
this.form.column.splice(index, 1, itemA)
|
|
218
|
+
this.form.column.splice(newIndex, 1, itemB)
|
|
219
|
+
},
|
|
220
|
+
downColumnItem (key, index) {
|
|
221
|
+
const newIndex = index + 1
|
|
222
|
+
const itemA = this.form.column[newIndex]
|
|
223
|
+
const itemB = this.form.column[index]
|
|
224
|
+
this.form.column.splice(index, 1, itemA)
|
|
225
|
+
this.form.column.splice(newIndex, 1, itemB)
|
|
226
|
+
},
|
|
227
|
+
itemHandle (item, type) {
|
|
228
|
+
console.log(JSON.stringify(item))
|
|
229
|
+
this.itemMap[item.key] = item
|
|
230
|
+
if (type === '新增') {
|
|
231
|
+
this.form.column.push(item)
|
|
232
|
+
} else {
|
|
233
|
+
this.$set(this.form.column, this.selectIndex, item)
|
|
234
|
+
}
|
|
235
|
+
this.$message.success(`${type}成功`)
|
|
236
|
+
this.$refs.queryItem.flashModal(false)
|
|
237
|
+
},
|
|
238
|
+
addColumnItem () {
|
|
239
|
+
this.type = '新增'
|
|
240
|
+
this.$refs.queryItem.addColumnItemExecute()
|
|
241
|
+
},
|
|
242
|
+
editColumnItem (key, index) {
|
|
243
|
+
if (this.itemMap[key]) {
|
|
244
|
+
this.$refs.queryItem.editColumnItemExecute(this.itemMap[key])
|
|
245
|
+
this.selectIndex = index
|
|
246
|
+
} else {
|
|
247
|
+
this.$message.warn('编辑失败')
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
getColumn (callback) {
|
|
251
|
+
callback(JSON.parse(JSON.stringify(this.form.column)))
|
|
252
|
+
},
|
|
253
|
+
// 判断是否为json字符串
|
|
254
|
+
isJSON (str) {
|
|
255
|
+
if (typeof str == 'string') {
|
|
256
|
+
try {
|
|
257
|
+
const obj = JSON.parse(str)
|
|
258
|
+
return !!(typeof obj == 'object' && obj)
|
|
259
|
+
} catch (e) {
|
|
260
|
+
return false
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
exportJson () {
|
|
265
|
+
const data = JSON.stringify(this.form, null, 2)
|
|
266
|
+
const blob = new Blob([data], { type: 'application/json' })
|
|
267
|
+
FileSaver.saveAs(blob, `SimpleFormQuery.json`)
|
|
268
|
+
this.$message.success('导出成功!')
|
|
269
|
+
},
|
|
270
|
+
viewHandle (then) {
|
|
271
|
+
if (this.form.column.length === 0) {
|
|
272
|
+
this.$message.error('你没有增加任何数据字段')
|
|
273
|
+
return
|
|
274
|
+
}
|
|
275
|
+
this.result = JSON.parse(JSON.stringify(this.form))
|
|
276
|
+
for (const item of this.result.column) {
|
|
277
|
+
if (item.selectType === 'fixArray') {
|
|
278
|
+
item.selectKey = JSON.parse(item.selectKey)
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
then()
|
|
282
|
+
},
|
|
283
|
+
view () {
|
|
284
|
+
this.$refs.businessCreateForm.validate(valid => {
|
|
285
|
+
if (valid) {
|
|
286
|
+
this.viewHandle(() => {
|
|
287
|
+
post(commonApi.getColumnsJson, { queryObject: this.result }).then(res => {
|
|
288
|
+
this.formItems = res.formJson
|
|
289
|
+
this.modelVisible = true
|
|
290
|
+
})
|
|
291
|
+
})
|
|
292
|
+
}
|
|
293
|
+
})
|
|
294
|
+
},
|
|
295
|
+
submit () {
|
|
296
|
+
this.onModelClose()
|
|
297
|
+
this.$refs.businessCreateForm.validate(valid => {
|
|
298
|
+
if (valid) {
|
|
299
|
+
this.viewHandle(() => {
|
|
300
|
+
// saveQueryParams
|
|
301
|
+
this.$emit('saveSimpleFormQueryParams', this.result)
|
|
302
|
+
})
|
|
303
|
+
}
|
|
304
|
+
})
|
|
305
|
+
},
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
</script>
|
|
309
|
+
<style lang="less" scoped>
|
|
310
|
+
</style>
|