formui-vue2-vistastory 0.1.53 → 0.2.0
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/FormUiForm.vue +36 -20
- package/FormUiSimpleFormDialog.vue +162 -0
- package/FormUiSimpleTable.vue +192 -0
- package/FormUiSimpleTableFormDialog.vue +156 -0
- package/FormUiTable.vue +236 -0
- package/formuiConfig.js +10 -0
- package/index.js +6 -1
- package/package.json +1 -1
- package/service/base/OssService.js +39 -0
- package/service/formui/FormuiService.js +31 -0
- package/widget/FormUiForeignByBean.vue +153 -0
- package/widget/FormUiForeignSelect.vue +4 -1
- package/widget/FormUiRichText.vue +6 -3
package/FormUiForm.vue
CHANGED
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
<!--:min="-99999" :max="99999"-->
|
|
89
89
|
<el-input-number v-model="ruleFormMoney[fieldItem.name]"
|
|
90
90
|
controls-position="right"
|
|
91
|
-
|
|
91
|
+
@blur="handleBlur"
|
|
92
92
|
:controls="false"
|
|
93
93
|
:disabled="fieldItem.disabled"></el-input-number>
|
|
94
94
|
</span>
|
|
@@ -289,37 +289,49 @@ export default {
|
|
|
289
289
|
// console.log('imagePath=' + imagePath)
|
|
290
290
|
// console.log('imageUrl=' + imageUrl)
|
|
291
291
|
},
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
let that = this
|
|
292
|
+
formatRuleForm(){
|
|
293
|
+
// 从money date等数据像form表更新
|
|
294
|
+
let that = this
|
|
296
295
|
|
|
297
296
|
// alert(that.formuiFields.length)
|
|
298
297
|
// console.log(that.formuiFields)
|
|
299
|
-
|
|
300
|
-
|
|
298
|
+
for(let i=0;i< that.formuiFields.length;i++){
|
|
299
|
+
let fieldItem=that.formuiFields[i]
|
|
301
300
|
// alert(fieldItem.name)
|
|
302
|
-
|
|
301
|
+
|
|
302
|
+
if(fieldItem.valueType=='MONEY'){
|
|
303
303
|
// alert(mathUtil.methods.mul)
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
304
|
+
if(that.ruleFormMoney[fieldItem.name]||that.ruleFormMoney[fieldItem.name]===0){
|
|
305
|
+
//
|
|
306
|
+
// console.log('try set money')
|
|
307
|
+
that.ruleForm[fieldItem.name]=mathUtil.mul(that.ruleFormMoney[fieldItem.name],100)
|
|
308
|
+
}
|
|
307
309
|
|
|
308
|
-
|
|
310
|
+
}else if(fieldItem.valueType=='DATETIME'){
|
|
309
311
|
// alert(1)
|
|
310
312
|
// alert(that.ruleFormTime[fieldItem.name])
|
|
311
313
|
// that.ruleForm[fieldItem.name]=that.ruleFormTime[fieldItem.name]
|
|
312
|
-
|
|
314
|
+
}
|
|
313
315
|
|
|
314
|
-
|
|
316
|
+
}
|
|
315
317
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
318
|
+
for(let i=0;i< that.formuiFields.length;i++){
|
|
319
|
+
let fieldItem=that.formuiFields[i]
|
|
320
|
+
if(fieldItem.bindColumn&&this.getIsHide(fieldItem,that.ruleForm)==false){
|
|
319
321
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
322
|
+
this.$set(that.ruleForm,fieldItem.bindColumn,that.ruleForm[fieldItem.name])
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
},
|
|
327
|
+
// 提交
|
|
328
|
+
submitForm (formName) {
|
|
329
|
+
// console.log(this.queryParams)
|
|
330
|
+
let that = this
|
|
331
|
+
|
|
332
|
+
// alert(that.formuiFields.length)
|
|
333
|
+
// console.log(that.formuiFields)
|
|
334
|
+
this.formatRuleForm()
|
|
323
335
|
// alert(4444)
|
|
324
336
|
// alert(this.$refs[formName].validate())
|
|
325
337
|
try{
|
|
@@ -408,6 +420,10 @@ export default {
|
|
|
408
420
|
// console.log(that.rules)
|
|
409
421
|
// return rules
|
|
410
422
|
},
|
|
423
|
+
handleBlur(){
|
|
424
|
+
// console.log('input_blur')
|
|
425
|
+
this.formatRuleForm()
|
|
426
|
+
},
|
|
411
427
|
getIsHide(fieldItem,ruleForm){
|
|
412
428
|
|
|
413
429
|
if(fieldItem.pre&&fieldItem.pre.length>0){
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="hf-form-ui-form">
|
|
3
|
+
<el-dialog
|
|
4
|
+
v-model="dialogVisible"
|
|
5
|
+
v-bind:title="title"
|
|
6
|
+
width="30%"
|
|
7
|
+
v-on:before-close="handleClose">
|
|
8
|
+
<FormUiForm v-if="loadSuccess"
|
|
9
|
+
ref="FormUiFormRef"
|
|
10
|
+
v-bind:removeFileds="removeFields"
|
|
11
|
+
v-bind:ruleFormSrc="ruleForm"
|
|
12
|
+
v-bind:autoSubmit="autoSubmit"
|
|
13
|
+
v-bind:beanName="simpleFormResp.beanName"
|
|
14
|
+
v-on:submitForm="submitFormObj">
|
|
15
|
+
</FormUiForm>
|
|
16
|
+
</el-dialog>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
<script>
|
|
20
|
+
import FormUiForm from './FormUiForm.vue'
|
|
21
|
+
import formuiService from './service/formui/FormuiService.js'
|
|
22
|
+
import httpUtil from './service/base/httpUtil.js'
|
|
23
|
+
import { ElMessage } from 'element-plus'
|
|
24
|
+
import {useRoute} from 'vue-router'
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
name: 'FormUiSimpleForm',
|
|
28
|
+
props: {
|
|
29
|
+
simpleFormName: String,
|
|
30
|
+
id: String,
|
|
31
|
+
formData: Object, //用于编辑的编辑格式
|
|
32
|
+
title: String,
|
|
33
|
+
autoSubmit: Boolean,
|
|
34
|
+
},
|
|
35
|
+
components: {FormUiForm},
|
|
36
|
+
data() {
|
|
37
|
+
return {
|
|
38
|
+
loadSuccess: false,
|
|
39
|
+
ruleForm: {},
|
|
40
|
+
simpleFormResp: {},
|
|
41
|
+
removeFields: '',
|
|
42
|
+
formDataCurrent: {},
|
|
43
|
+
queryParams: {},
|
|
44
|
+
dialogVisible: false,
|
|
45
|
+
simpleFormPath: ''
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
created () {
|
|
49
|
+
this.simpleFormPath = formuiConfig.simpleFormPath
|
|
50
|
+
Object.keys(this.$route.query).forEach(key => {
|
|
51
|
+
this.queryParams[key] = this.$route.query[key]
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
this.loadData()
|
|
55
|
+
},
|
|
56
|
+
mounted() {
|
|
57
|
+
let params = {}
|
|
58
|
+
params['methodName'] = this.simpleFormName;
|
|
59
|
+
|
|
60
|
+
if (this.formData && this.formData['id']) {
|
|
61
|
+
params['id'] = this.formData['id']
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
this.formDataCurrent = {}
|
|
65
|
+
for (var name in this.formData) {
|
|
66
|
+
this.formDataCurrent[name] = this.formData[name]
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
this.dialogVisible = true
|
|
70
|
+
},
|
|
71
|
+
methods: {
|
|
72
|
+
submitFormObj (formObj) {
|
|
73
|
+
formObj.fuTableName = this.tableName
|
|
74
|
+
if (this.simpleFormResp.method === 'POST') {
|
|
75
|
+
httpUtil.httpPost(ENV.VITE_API_PREFIX + '/table/process_simple_table_form', formObj, (res) => {
|
|
76
|
+
if (res.status.code !== 1) {
|
|
77
|
+
alert(res.status.msg) // 修改: ElMessage 改为 alert
|
|
78
|
+
} else {
|
|
79
|
+
this.$emit('submitCallback', res)
|
|
80
|
+
this.$emit('closeDialog')
|
|
81
|
+
alert('提交完成.') // 修改: ElMessage 改为 alert
|
|
82
|
+
}
|
|
83
|
+
}, (err) => {
|
|
84
|
+
console.error('err post' + err)
|
|
85
|
+
alert('提交错误,需要调试.') // 修改: ElMessage 改为 alert
|
|
86
|
+
})
|
|
87
|
+
} else if (this.simpleFormResp.method === 'GET') {
|
|
88
|
+
console.log('暂不支持get')
|
|
89
|
+
} else if (this.simpleFormResp.method === 'PUT') {
|
|
90
|
+
httpUtil.httpPut(ENV.VITE_API_PREFIX + '/table/process_simple_table_form', formObj, (res) => {
|
|
91
|
+
if (res.status.code !== 1) {
|
|
92
|
+
alert(res.status.msg) // 修改: ElMessage 改为 alert
|
|
93
|
+
} else {
|
|
94
|
+
this.$emit('submitCallback', res)
|
|
95
|
+
this.$emit('closeDialog')
|
|
96
|
+
alert('提交完成.') // 修改: ElMessage 改为 alert
|
|
97
|
+
}
|
|
98
|
+
}, (err) => {
|
|
99
|
+
console.error('err put' + err)
|
|
100
|
+
alert('提交错误,需要调试.') // 修改: ElMessage 改为 alert
|
|
101
|
+
})
|
|
102
|
+
} else if (this.simpleFormResp.method === 'DELETE') {
|
|
103
|
+
httpUtil.httpDelete(ENV.VITE_API_PREFIX + '/table/process_simple_table_form', formObj, (res) => {
|
|
104
|
+
this.$emit('submitCallback', res)
|
|
105
|
+
this.$emit('closeDialog')
|
|
106
|
+
alert('删除完成.') // 修改: ElMessage 改为 alert
|
|
107
|
+
}, (err) => {
|
|
108
|
+
console.error('err post' + err)
|
|
109
|
+
alert('删除错误,需要调试.') // 修改: ElMessage 改为 alert
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
handleClose (done) {
|
|
114
|
+
done()
|
|
115
|
+
this.$emit('closeDialog')
|
|
116
|
+
},
|
|
117
|
+
loadData() {
|
|
118
|
+
let param = { 'tableName': this.tableName, 'runType': this.runType }
|
|
119
|
+
if (this.runType === 'EDIT') {
|
|
120
|
+
param['id'] = this.formData['id']
|
|
121
|
+
}
|
|
122
|
+
if (this.runType === 'DELETE') {
|
|
123
|
+
param['id'] = this.formData['id']
|
|
124
|
+
}
|
|
125
|
+
formuiService.getTableSimpleForm(param, (resp) => {
|
|
126
|
+
this.simpleFormResp = resp
|
|
127
|
+
this.removeFields = resp.removeFields.split(',')
|
|
128
|
+
if (this.autoSubmit === true) {
|
|
129
|
+
this.ruleForm['id'] = resp.dataObj['id']
|
|
130
|
+
this.submitFormObj(this.ruleForm)
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
if (resp.dataObj) {
|
|
134
|
+
this.ruleForm = resp.dataObj
|
|
135
|
+
} else {
|
|
136
|
+
this.ruleForm = {}
|
|
137
|
+
let formDataCurrent = {}
|
|
138
|
+
for (var name in this.formData) {
|
|
139
|
+
formDataCurrent[name] = this.formData[name]
|
|
140
|
+
}
|
|
141
|
+
for (var name in formDataCurrent) {
|
|
142
|
+
if (formDataCurrent[name] || formDataCurrent[name] === '' || formDataCurrent[name] === 0) {
|
|
143
|
+
if (typeof formDataCurrent[name] === 'number') {
|
|
144
|
+
this.ruleForm[name] = formDataCurrent[name]
|
|
145
|
+
} else if (Date.parse(formDataCurrent[name]).toString() !== 'NaN') {
|
|
146
|
+
this.ruleForm[name] = formDataCurrent[name]
|
|
147
|
+
} else if (formDataCurrent[name].indexOf(',') === -1 && parseFloat(formDataCurrent[name]).toString() !== 'NaN') {
|
|
148
|
+
this.ruleForm[name] = parseFloat(formDataCurrent[name])
|
|
149
|
+
} else if (formDataCurrent[name].indexOf(',') !== -1) {
|
|
150
|
+
this.ruleForm[name] = formDataCurrent[name]
|
|
151
|
+
} else {
|
|
152
|
+
this.ruleForm[name] = formDataCurrent[name]
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
this.loadSuccess = true
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
</script>
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div v-if="addSimpleFormName">
|
|
4
|
+
<el-button v-on:click="showDialog(addSimpleFormName,'新增')" v-bind:text="true" size="small">新增</el-button>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<FormUiQueryParam
|
|
8
|
+
ref="formUiSimpleTableRef"
|
|
9
|
+
v-if="tableConfig&&tableConfig.isQuery==1"
|
|
10
|
+
v-bind:beanName="tableConfig.queryName"
|
|
11
|
+
v-bind:removeFileds="[]"
|
|
12
|
+
v-bind:queryParams="queryParams"
|
|
13
|
+
v-bind:fieldGroupType="1"
|
|
14
|
+
v-on:updateQueryParams="updateQueryParams"
|
|
15
|
+
v-on:search="queryData">
|
|
16
|
+
<template v-slot:btns="slotProps">
|
|
17
|
+
</template>
|
|
18
|
+
</FormUiQueryParam>
|
|
19
|
+
<FormUiTable
|
|
20
|
+
v-if="tableConfig"
|
|
21
|
+
ref="formUiTableRef"
|
|
22
|
+
v-bind:methodName="tableConfig.tableName"
|
|
23
|
+
v-bind:isMenu="true"
|
|
24
|
+
v-bind:isFilter="tableConfig.isFilter==1"
|
|
25
|
+
v-bind:pageSize="5"
|
|
26
|
+
v-bind:editSimpleFormName="tableConfig.isBtnEdit==1?'editForm':''"
|
|
27
|
+
v-bind:addSimpleFormName="tableConfig.isBtnAdd==1?tableConfig.addFormName:''"
|
|
28
|
+
v-bind:deleteSimpleFormName="tableConfig.isBtnDel==1?'removeForm':''">
|
|
29
|
+
</FormUiTable>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
<script>
|
|
33
|
+
|
|
34
|
+
import formuiService from './service/formui/FormuiService.js'
|
|
35
|
+
import FormUiTable from './FormUiTable.vue'
|
|
36
|
+
import formuiConfig from './formuiConfig.js'
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
export default {
|
|
40
|
+
props: {
|
|
41
|
+
tableName: String,
|
|
42
|
+
isMenu: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: false
|
|
45
|
+
},
|
|
46
|
+
isFilter: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: false
|
|
49
|
+
},
|
|
50
|
+
editSimpleFormName: String,
|
|
51
|
+
deleteSimpleFormName: String,
|
|
52
|
+
addSimpleFormName: String,
|
|
53
|
+
pageSize: {
|
|
54
|
+
type: Number,
|
|
55
|
+
default: 20
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
components: {
|
|
59
|
+
FormUiTable
|
|
60
|
+
},
|
|
61
|
+
data() {
|
|
62
|
+
return {
|
|
63
|
+
tableConfig: null,
|
|
64
|
+
simpleFormPath: '',
|
|
65
|
+
queryParams: {}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
created() {
|
|
69
|
+
this.simpleFormPath = formuiConfig.simpleFormPath
|
|
70
|
+
},
|
|
71
|
+
mounted() {
|
|
72
|
+
Object.keys(this.$route.query).forEach(key => {
|
|
73
|
+
this.queryParams[key] = this.$route.query[key]
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
this.loadData()
|
|
77
|
+
},
|
|
78
|
+
beforeRouteUpdate(to) {
|
|
79
|
+
this.queryParams.pageNo = to.query.pageNo
|
|
80
|
+
this.loadData()
|
|
81
|
+
},
|
|
82
|
+
methods: {
|
|
83
|
+
handleCurrentChange(data) {
|
|
84
|
+
this.queryParams.pageNo = data - 1
|
|
85
|
+
this.goByParam()
|
|
86
|
+
},
|
|
87
|
+
goByParam() {
|
|
88
|
+
delete this.queryParams.methodName
|
|
89
|
+
this.$router.push({
|
|
90
|
+
query: this.queryParams
|
|
91
|
+
})
|
|
92
|
+
},
|
|
93
|
+
queryData(queryParams) {
|
|
94
|
+
if (queryParams) {
|
|
95
|
+
this.queryParams = queryParams
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
this.$refs['formUiTableRef'].loadData(this.queryParams)
|
|
99
|
+
},
|
|
100
|
+
loadData(queryParamsUpdate) {
|
|
101
|
+
if (queryParamsUpdate) {
|
|
102
|
+
this.queryParams = queryParamsUpdate
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
this.queryParams['tableName'] = this.$route.query.tableName
|
|
106
|
+
|
|
107
|
+
if (this.tableName) {
|
|
108
|
+
this.queryParams['tableName'] = this.tableName
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
formuiService.getFormUiSimpleTable(this,this.queryParams, (resp) => {
|
|
112
|
+
console.log('resp', resp)
|
|
113
|
+
this.tableConfig = resp
|
|
114
|
+
}, (err) => {})
|
|
115
|
+
},
|
|
116
|
+
filterClear() {
|
|
117
|
+
for (let i = 0; i < this.formuiTableRowList.length; i++) {
|
|
118
|
+
if (typeof this.formuiTableRowList[i]['isShow'] === 'undefined') {
|
|
119
|
+
this.formuiTableRowList[i].isShow = true
|
|
120
|
+
}
|
|
121
|
+
if (!this.formuiTableRowList[i].isShow && this.formuiTableRowList[i].isShow === false) {
|
|
122
|
+
this.formuiTableRowList[i].isShow = true
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
this.formuiTableRowFilterList = this.formuiTableRowList
|
|
126
|
+
},
|
|
127
|
+
filterCellValue() {
|
|
128
|
+
if (!this.queryParams.filter) {
|
|
129
|
+
this.filterClear()
|
|
130
|
+
return
|
|
131
|
+
}
|
|
132
|
+
let filterArr = this.queryParams.filter.split(' ')
|
|
133
|
+
console.log('filter:', filterArr)
|
|
134
|
+
this.formuiTableRowFilterList = []
|
|
135
|
+
for (let i = 0; i < this.formuiTableRowList.length; i++) {
|
|
136
|
+
let showNum = 0
|
|
137
|
+
outj:
|
|
138
|
+
for (let k = 0; k < filterArr.length; k++) {
|
|
139
|
+
if (filterArr[k] === '') {
|
|
140
|
+
showNum++
|
|
141
|
+
continue outj
|
|
142
|
+
}
|
|
143
|
+
for (let j = 0; j < this.formuiFieldList.length; j++) {
|
|
144
|
+
if (this.formuiTableRowList[i].tableCellList[j].formatValue.indexOf(filterArr[k]) !== -1) {
|
|
145
|
+
showNum++
|
|
146
|
+
continue outj
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (showNum === filterArr.length) {
|
|
151
|
+
this.formuiTableRowFilterList.push(this.formuiTableRowList[i])
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
checkDel(rowId) {
|
|
156
|
+
if (confirm('确认删除?') === false) {
|
|
157
|
+
return false
|
|
158
|
+
}
|
|
159
|
+
this.simpleFormAutoSubmit = true
|
|
160
|
+
this.showSimpleForm = 1
|
|
161
|
+
this.simpleFormTitle = '删除'
|
|
162
|
+
if (!rowId) {
|
|
163
|
+
console.error('异常,无id')
|
|
164
|
+
return
|
|
165
|
+
} else {
|
|
166
|
+
this.simpleFormId = rowId
|
|
167
|
+
}
|
|
168
|
+
this.simpleFormName = this.deleteSimpleFormName
|
|
169
|
+
},
|
|
170
|
+
showDialog(formName, title, rowId) {
|
|
171
|
+
this.simpleFormAutoSubmit = false
|
|
172
|
+
this.showSimpleForm = 1
|
|
173
|
+
this.simpleFormName = formName
|
|
174
|
+
this.simpleFormTitle = title
|
|
175
|
+
if (!rowId) {
|
|
176
|
+
this.simpleFormId = null
|
|
177
|
+
} else {
|
|
178
|
+
this.simpleFormId = rowId
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
closeDialog() {
|
|
182
|
+
console.log('closeDialog2---------------------')
|
|
183
|
+
this.showSimpleForm = 0
|
|
184
|
+
this.tableConfig=null
|
|
185
|
+
},
|
|
186
|
+
submitCallback() {
|
|
187
|
+
console.log('submitCallback---------------------')
|
|
188
|
+
this.loadData()
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
</script>
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="hf-form-ui-form">
|
|
3
|
+
|
|
4
|
+
<el-dialog
|
|
5
|
+
:visible.sync="dialogVisible"
|
|
6
|
+
v-bind:title="title"
|
|
7
|
+
width="80%"
|
|
8
|
+
:before-close="handleClose">
|
|
9
|
+
|
|
10
|
+
<FormUiForm v-if="loadSuccess"
|
|
11
|
+
ref="FormUiFormRef"
|
|
12
|
+
v-bind:removeFileds="removeFields"
|
|
13
|
+
v-bind:ruleFormSrc="ruleForm"
|
|
14
|
+
v-bind:autoSubmit="autoSubmit"
|
|
15
|
+
v-bind:beanName="simpleFormResp.beanName"
|
|
16
|
+
v-on:submitForm="submitFormObj">
|
|
17
|
+
</FormUiForm>
|
|
18
|
+
</el-dialog>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
<script>
|
|
22
|
+
import FormUiForm from './FormUiForm.vue'
|
|
23
|
+
import formuiService from './service/formui/FormuiService'
|
|
24
|
+
import httpUtil from './service/base/httpUtil'
|
|
25
|
+
import formuiConfig from './formuiConfig.js'
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
components:{FormUiForm},
|
|
29
|
+
props: {
|
|
30
|
+
simpleFormName: String,
|
|
31
|
+
id: String,
|
|
32
|
+
formData: Object, //用于编辑的编辑格式
|
|
33
|
+
title: String,
|
|
34
|
+
autoSubmit: Boolean,
|
|
35
|
+
tableName: String,
|
|
36
|
+
runType: String
|
|
37
|
+
},
|
|
38
|
+
data() {
|
|
39
|
+
return {
|
|
40
|
+
dialogVisible:true,
|
|
41
|
+
loadSuccess: false,
|
|
42
|
+
ruleForm: {},
|
|
43
|
+
simpleFormResp: {},
|
|
44
|
+
removeFields: '',
|
|
45
|
+
queryParams:{}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
created() {
|
|
49
|
+
// alert(1)
|
|
50
|
+
this.simpleFormPath = formuiConfig.simpleFormPath
|
|
51
|
+
},
|
|
52
|
+
mounted() {
|
|
53
|
+
// alert(2)
|
|
54
|
+
Object.keys(this.$route.query).forEach(key => {
|
|
55
|
+
this.queryParams[key] = this.$route.query[key]
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
this.loadData()
|
|
59
|
+
},
|
|
60
|
+
beforeDestroy() {
|
|
61
|
+
console.log('----onBeforeUnmount-tableformDialog----')
|
|
62
|
+
this.loadSuccess = false
|
|
63
|
+
},
|
|
64
|
+
methods: {
|
|
65
|
+
submitFormObj(formObj) {
|
|
66
|
+
formObj.fuTableName = this.tableName
|
|
67
|
+
if (this.simpleFormResp.method === 'POST') {
|
|
68
|
+
httpUtil.httpPost(ENV.VITE_API_PREFIX + '/table/process_simple_table_form', formObj, (res) => {
|
|
69
|
+
if (res.status.code !== 1) {
|
|
70
|
+
alert(res.status.msg) // 修改: ElMessage 改为 alert
|
|
71
|
+
} else {
|
|
72
|
+
this.$emit('submitCallback', res)
|
|
73
|
+
this.$emit('closeDialog')
|
|
74
|
+
alert('提交完成.') // 修改: ElMessage 改为 alert
|
|
75
|
+
}
|
|
76
|
+
}, (err) => {
|
|
77
|
+
console.error('err post' + err)
|
|
78
|
+
alert('提交错误,需要调试.') // 修改: ElMessage 改为 alert
|
|
79
|
+
})
|
|
80
|
+
} else if (this.simpleFormResp.method === 'GET') {
|
|
81
|
+
console.log('暂不支持get')
|
|
82
|
+
} else if (this.simpleFormResp.method === 'PUT') {
|
|
83
|
+
httpUtil.httpPut(ENV.VITE_API_PREFIX + '/table/process_simple_table_form', formObj, (res) => {
|
|
84
|
+
if (res.status.code !== 1) {
|
|
85
|
+
alert(res.status.msg) // 修改: ElMessage 改为 alert
|
|
86
|
+
} else {
|
|
87
|
+
this.$emit('submitCallback', res)
|
|
88
|
+
this.$emit('closeDialog')
|
|
89
|
+
alert('提交完成.') // 修改: ElMessage 改为 alert
|
|
90
|
+
}
|
|
91
|
+
}, (err) => {
|
|
92
|
+
console.error('err put' + err)
|
|
93
|
+
alert('提交错误,需要调试.') // 修改: ElMessage 改为 alert
|
|
94
|
+
})
|
|
95
|
+
} else if (this.simpleFormResp.method === 'DELETE') {
|
|
96
|
+
httpUtil.httpDelete(ENV.VITE_API_PREFIX + '/table/process_simple_table_form', formObj, (res) => {
|
|
97
|
+
this.$emit('submitCallback', res)
|
|
98
|
+
this.$emit('closeDialog')
|
|
99
|
+
alert('删除完成.') // 修改: ElMessage 改为 alert
|
|
100
|
+
}, (err) => {
|
|
101
|
+
console.error('err post' + err)
|
|
102
|
+
alert('删除错误,需要调试.') // 修改: ElMessage 改为 alert
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
handleClose(done) {
|
|
107
|
+
done()
|
|
108
|
+
this.$emit('closeDialog')
|
|
109
|
+
console.log('closeDialog---from dialog')
|
|
110
|
+
},
|
|
111
|
+
loadData() {
|
|
112
|
+
let param = { 'tableName': this.tableName, 'runType': this.runType }
|
|
113
|
+
if (this.runType === 'EDIT') {
|
|
114
|
+
param['id'] = this.formData['id']
|
|
115
|
+
}
|
|
116
|
+
if (this.runType === 'DELETE') {
|
|
117
|
+
param['id'] = this.formData['id']
|
|
118
|
+
}
|
|
119
|
+
formuiService.getTableSimpleForm(this,param, (resp) => {
|
|
120
|
+
this.simpleFormResp = resp
|
|
121
|
+
this.removeFields = resp.removeFields.split(',')
|
|
122
|
+
if (this.autoSubmit === true) {
|
|
123
|
+
this.ruleForm['id'] = resp.dataObj['id']
|
|
124
|
+
this.submitFormObj(this.ruleForm)
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
if (resp.dataObj) {
|
|
128
|
+
this.ruleForm = resp.dataObj
|
|
129
|
+
} else {
|
|
130
|
+
this.ruleForm = {}
|
|
131
|
+
let formDataCurrent = {}
|
|
132
|
+
for (var name in this.formData) {
|
|
133
|
+
formDataCurrent[name] = this.formData[name]
|
|
134
|
+
}
|
|
135
|
+
for (var name in formDataCurrent) {
|
|
136
|
+
if (formDataCurrent[name] || formDataCurrent[name] === '' || formDataCurrent[name] === 0) {
|
|
137
|
+
if (typeof formDataCurrent[name] === 'number') {
|
|
138
|
+
this.ruleForm[name] = formDataCurrent[name]
|
|
139
|
+
} else if (Date.parse(formDataCurrent[name]).toString() !== 'NaN') {
|
|
140
|
+
this.ruleForm[name] = formDataCurrent[name]
|
|
141
|
+
} else if (formDataCurrent[name].indexOf(',') === -1 && parseFloat(formDataCurrent[name]).toString() !== 'NaN') {
|
|
142
|
+
this.ruleForm[name] = parseFloat(formDataCurrent[name])
|
|
143
|
+
} else if (formDataCurrent[name].indexOf(',') !== -1) {
|
|
144
|
+
this.ruleForm[name] = formDataCurrent[name]
|
|
145
|
+
} else {
|
|
146
|
+
this.ruleForm[name] = formDataCurrent[name]
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
this.loadSuccess = true
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
</script>
|
package/FormUiTable.vue
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
|
|
2
|
+
<template>
|
|
3
|
+
<!--格式化表格中的cell,因为有些数据比较难格式化,如枚举,和需子表查询,如通过id显示名字-->
|
|
4
|
+
<div>
|
|
5
|
+
<div v-if="addSimpleFormName">
|
|
6
|
+
<el-button v-on:click="showDialog(addSimpleFormName,'新增','ADD')" v-bind:text="true" size="small">新增</el-button>
|
|
7
|
+
</div>
|
|
8
|
+
<div style="padding: 10px 0;" v-if="isFilter">
|
|
9
|
+
过滤:<el-input v-model="queryParams.filter" placeholder="输入关键字进行过滤" size="small" clearable style="width: 200px;" v-on:keyup="filterCellValue()"></el-input>
|
|
10
|
+
</div>
|
|
11
|
+
<el-table
|
|
12
|
+
v-bind:border="true"
|
|
13
|
+
v-bind:data="formuiTableRowFilterList"
|
|
14
|
+
style="width: 100%">
|
|
15
|
+
<el-table-column v-for="(fieldItem,fieldIndex) in formuiFieldList"
|
|
16
|
+
v-bind:label="fieldItem.title" :key="fieldItem.id">
|
|
17
|
+
<template v-slot:default="scope">
|
|
18
|
+
<slot
|
|
19
|
+
v-bind:name="'cell_'+fieldItem.name"
|
|
20
|
+
v-bind:value="scope.row.tableCellList[fieldIndex].value"
|
|
21
|
+
v-bind:formatValue="scope.row.tableCellList[fieldIndex].formatValue">
|
|
22
|
+
{{scope.row.tableCellList[fieldIndex].formatValue}}
|
|
23
|
+
</slot>
|
|
24
|
+
</template>
|
|
25
|
+
</el-table-column>
|
|
26
|
+
<el-table-column
|
|
27
|
+
v-if="isMenu"
|
|
28
|
+
fixed="right"
|
|
29
|
+
label="操作">
|
|
30
|
+
<template v-slot:default="scope">
|
|
31
|
+
<slot name="menu" v-bind:scope="scope.row">
|
|
32
|
+
</slot>
|
|
33
|
+
<el-button v-if="editSimpleFormName" v-on:click="showDialog(editSimpleFormName,'编辑','EDIT',scope.row.id)" v-bind:text="true" size="small">编辑</el-button>
|
|
34
|
+
<el-button v-if="deleteSimpleFormName" v-on:click="checkDel(scope.row.id)" v-bind:text="true" size="small">删除</el-button>
|
|
35
|
+
</template>
|
|
36
|
+
</el-table-column>
|
|
37
|
+
</el-table>
|
|
38
|
+
<el-pagination
|
|
39
|
+
layout="prev, pager, next"
|
|
40
|
+
v-bind:total="page.rsCount"
|
|
41
|
+
v-bind:page-size="page.pageSize"
|
|
42
|
+
v-bind:current-page="parseInt(queryParams.pageNo)+1"
|
|
43
|
+
v-on:current-change="handleCurrentChange">
|
|
44
|
+
</el-pagination>
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
<div class="table-dialog" v-if="showSimpleForm==1">
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
<FormUiSimpleTableFormDialog
|
|
51
|
+
v-if="showSimpleForm==1"
|
|
52
|
+
v-bind:formData="{id:simpleFormId}"
|
|
53
|
+
v-bind:tableName="formTableName"
|
|
54
|
+
v-bind:runType="formRunType"
|
|
55
|
+
v-bind:title="simpleFormTitle"
|
|
56
|
+
v-bind:autoSubmit="simpleFormAutoSubmit"
|
|
57
|
+
v-on:closeDialog="closeDialog"
|
|
58
|
+
v-on:submitCallback="submitCallback">
|
|
59
|
+
</FormUiSimpleTableFormDialog>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</template>
|
|
63
|
+
<script>
|
|
64
|
+
|
|
65
|
+
import formuiService from './service/formui/FormuiService'
|
|
66
|
+
import ossService from './service/base/OssService'
|
|
67
|
+
import FormUiSimpleTableFormDialog from './FormUiSimpleTableFormDialog.vue'
|
|
68
|
+
|
|
69
|
+
import formuiConfig from './formuiConfig'
|
|
70
|
+
|
|
71
|
+
export default {
|
|
72
|
+
props: {
|
|
73
|
+
methodName: String,
|
|
74
|
+
isMenu: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: false
|
|
77
|
+
},
|
|
78
|
+
isFilter: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: false
|
|
81
|
+
},
|
|
82
|
+
editSimpleFormName: String,
|
|
83
|
+
deleteSimpleFormName: String,
|
|
84
|
+
addSimpleFormName: String,
|
|
85
|
+
pageSize: {
|
|
86
|
+
type: Number,
|
|
87
|
+
default: 20
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
components:{FormUiSimpleTableFormDialog},
|
|
91
|
+
data() {
|
|
92
|
+
return {
|
|
93
|
+
simpleFormPath: '',
|
|
94
|
+
formuiFieldList: [],
|
|
95
|
+
formuiTableRowList: [],
|
|
96
|
+
formuiTableRowFilterList: [],
|
|
97
|
+
routeQuery: this.$route.query,
|
|
98
|
+
page: { rsCount: 0, pageNo: 0, pageSize: 0 },
|
|
99
|
+
queryParams: {},
|
|
100
|
+
showSimpleForm: 0,
|
|
101
|
+
simpleFormName: '',
|
|
102
|
+
simpleFormTitle: '',
|
|
103
|
+
simpleFormAutoSubmit: false,
|
|
104
|
+
formTableName: '',
|
|
105
|
+
formRunType: ''
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
created() {
|
|
109
|
+
this.simpleFormPath = formuiConfig.simpleFormPath
|
|
110
|
+
},
|
|
111
|
+
mounted() {
|
|
112
|
+
this.queryParams['pageNo'] = 0
|
|
113
|
+
this.queryParams['pageSize'] = this.pageSize
|
|
114
|
+
|
|
115
|
+
Object.keys(this.$route.query).forEach(key => {
|
|
116
|
+
this.queryParams[key] = this.$route.query[key]
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
ossService.initOssUrl(this,this.loadData)
|
|
120
|
+
},
|
|
121
|
+
beforeRouteUpdate(to) {
|
|
122
|
+
this.queryParams.pageNo = to.query.pageNo
|
|
123
|
+
this.loadData()
|
|
124
|
+
},
|
|
125
|
+
methods: {
|
|
126
|
+
handleCurrentChange(data) {
|
|
127
|
+
this.queryParams.pageNo = data - 1
|
|
128
|
+
this.goByParam()
|
|
129
|
+
},
|
|
130
|
+
goByParam() {
|
|
131
|
+
delete this.queryParams.methodName
|
|
132
|
+
this.$router.push({
|
|
133
|
+
query: this.queryParams
|
|
134
|
+
})
|
|
135
|
+
},
|
|
136
|
+
loadData(queryParamsUpdate) {
|
|
137
|
+
if (this,this.$route.query['methodName'] && this.$route.query['methodName'] !== this.methodName) {
|
|
138
|
+
alert('你使用了受保护参数methodName:' + this.$route.query['methodName'])
|
|
139
|
+
return
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (queryParamsUpdate) {
|
|
143
|
+
this.queryParams = queryParamsUpdate
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
this.queryParams['methodName'] = this.methodName
|
|
147
|
+
|
|
148
|
+
formuiService.getFormUiTable(this,this.queryParams, (resp) => {
|
|
149
|
+
if (resp) {
|
|
150
|
+
this.formuiFieldList = resp.formuiFieldList
|
|
151
|
+
this.formuiTableRowList = resp.formuiTableRowList
|
|
152
|
+
this.page = resp.page
|
|
153
|
+
this.filterClear()
|
|
154
|
+
}
|
|
155
|
+
}, (err) => {})
|
|
156
|
+
},
|
|
157
|
+
filterClear() {
|
|
158
|
+
for (let i = 0; i < this.formuiTableRowList.length; i++) {
|
|
159
|
+
if (typeof this.formuiTableRowList[i]['isShow'] === 'undefined') {
|
|
160
|
+
this.formuiTableRowList[i].isShow = true
|
|
161
|
+
}
|
|
162
|
+
if (!this.formuiTableRowList[i].isShow && this.formuiTableRowList[i].isShow === false) {
|
|
163
|
+
this.formuiTableRowList[i].isShow = true
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
this.formuiTableRowFilterList = this.formuiTableRowList
|
|
167
|
+
},
|
|
168
|
+
filterCellValue() {
|
|
169
|
+
if (!this.queryParams.filter) {
|
|
170
|
+
this.filterClear()
|
|
171
|
+
return
|
|
172
|
+
}
|
|
173
|
+
let filterArr = this.queryParams.filter.split(' ')
|
|
174
|
+
console.log('filter:', filterArr)
|
|
175
|
+
this.formuiTableRowFilterList = []
|
|
176
|
+
for (let i = 0; i < this.formuiTableRowList.length; i++) {
|
|
177
|
+
let showNum = 0
|
|
178
|
+
outj:
|
|
179
|
+
for (let k = 0; k < filterArr.length; k++) {
|
|
180
|
+
if (filterArr[k] === '') {
|
|
181
|
+
showNum++
|
|
182
|
+
continue outj
|
|
183
|
+
}
|
|
184
|
+
for (let j = 0; j < this.formuiFieldList.length; j++) {
|
|
185
|
+
if (this.formuiTableRowList[i].tableCellList[j].formatValue.indexOf(filterArr[k]) !== -1) {
|
|
186
|
+
showNum++
|
|
187
|
+
continue outj
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (showNum === filterArr.length) {
|
|
192
|
+
this.formuiTableRowFilterList.push(this.formuiTableRowList[i])
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
checkDel(rowId) {
|
|
197
|
+
if (confirm('确认删除?') === false) {
|
|
198
|
+
return false
|
|
199
|
+
}
|
|
200
|
+
this.simpleFormAutoSubmit = true
|
|
201
|
+
this.showSimpleForm = 1
|
|
202
|
+
this.simpleFormTitle = '删除'
|
|
203
|
+
this.formRunType = 'DELETE'
|
|
204
|
+
this.formTableName = this.methodName
|
|
205
|
+
if (!rowId) {
|
|
206
|
+
console.error('异常,无id')
|
|
207
|
+
return
|
|
208
|
+
} else {
|
|
209
|
+
this.simpleFormId = rowId
|
|
210
|
+
}
|
|
211
|
+
this.simpleFormName = this.deleteSimpleFormName
|
|
212
|
+
},
|
|
213
|
+
showDialog(formName, title, formRunType, rowId) {
|
|
214
|
+
this.simpleFormAutoSubmit = false
|
|
215
|
+
this.showSimpleForm = 1
|
|
216
|
+
this.simpleFormName = formName
|
|
217
|
+
this.simpleFormTitle = title
|
|
218
|
+
this.formTableName = this.methodName
|
|
219
|
+
this.formRunType = formRunType
|
|
220
|
+
if (!rowId) {
|
|
221
|
+
this.simpleFormId = null
|
|
222
|
+
} else {
|
|
223
|
+
this.simpleFormId = rowId
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
closeDialog() {
|
|
227
|
+
console.log('closeDialog---------------------')
|
|
228
|
+
this.showSimpleForm = 0
|
|
229
|
+
},
|
|
230
|
+
submitCallback() {
|
|
231
|
+
console.log('submitCallback---------------------')
|
|
232
|
+
this.loadData()
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
</script>
|
package/formuiConfig.js
ADDED
package/index.js
CHANGED
|
@@ -3,6 +3,9 @@ import FormUiForm from './FormUiForm.vue'
|
|
|
3
3
|
import FormUiQueryParam from './FormUiQueryParam.vue'
|
|
4
4
|
import FormUiTableCell from './FormUiTableCell.vue'
|
|
5
5
|
import FormUiSimpleForm from './FormUiSimpleForm.vue'
|
|
6
|
+
import FormUiTable from './FormUiTable.vue'
|
|
7
|
+
import FormUiSimpleTable from './FormUiSimpleTable.vue'
|
|
8
|
+
import formuiConfig from './formuiConfig.vue'
|
|
6
9
|
|
|
7
10
|
|
|
8
11
|
export default {
|
|
@@ -12,6 +15,8 @@ export default {
|
|
|
12
15
|
Vue.component('FormUiQuery', FormUiQueryParam)
|
|
13
16
|
Vue.component('FormUiTableCell', FormUiTableCell)
|
|
14
17
|
Vue.component('FormUiSimpleForm', FormUiSimpleForm)
|
|
15
|
-
|
|
18
|
+
Vue.component('FormUiTable', FormUiTable)
|
|
19
|
+
Vue.component('FormUiSimpleTable', FormUiSimpleTable)
|
|
20
|
+
Vue.component('formuiConfig', formuiConfig)
|
|
16
21
|
}
|
|
17
22
|
}
|
package/package.json
CHANGED
|
@@ -11,5 +11,44 @@ export default {
|
|
|
11
11
|
error(err)
|
|
12
12
|
}
|
|
13
13
|
})
|
|
14
|
+
},
|
|
15
|
+
getFormuiConfig(that,params,callback,error){
|
|
16
|
+
// console.log('--------------------')
|
|
17
|
+
// console.log(ENV)
|
|
18
|
+
httpUtil.httpGet(that,'/formui/oss/get_formui_config', params,function (res) {
|
|
19
|
+
callback(res)
|
|
20
|
+
},function (err) {
|
|
21
|
+
console.log('err get' + err)
|
|
22
|
+
if(error){
|
|
23
|
+
error(err)
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
},
|
|
27
|
+
initOssUrl(that,callback){
|
|
28
|
+
|
|
29
|
+
// alert(callback)
|
|
30
|
+
let formuiOssUrl=localStorage.getItem('formuiOssUrl');
|
|
31
|
+
if(formuiOssUrl){
|
|
32
|
+
// callback(formuiOssUrl)
|
|
33
|
+
if(callback){
|
|
34
|
+
callback()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}else{
|
|
38
|
+
this.getFormuiConfig(that,{},function (resp) {
|
|
39
|
+
// callback(resp.configMap.ossUrl)
|
|
40
|
+
localStorage.setItem('formuiOssUrl',resp.configMap.ossUrl)
|
|
41
|
+
if(callback){
|
|
42
|
+
callback()
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
// localStorage
|
|
47
|
+
},
|
|
48
|
+
getOssUrl(){
|
|
49
|
+
|
|
50
|
+
// alert(callback)
|
|
51
|
+
let formuiOssUrl=localStorage.getItem('formuiOssUrl');
|
|
52
|
+
return formuiOssUrl;
|
|
14
53
|
}
|
|
15
54
|
}
|
|
@@ -52,5 +52,36 @@ export default {
|
|
|
52
52
|
}
|
|
53
53
|
})
|
|
54
54
|
},
|
|
55
|
+
getTableSimpleForm(that,params,callback,error){
|
|
56
|
+
httpUtil.httpGet(that,'/formui/table/get_formui_table_form', params,function (res) {
|
|
57
|
+
callback(res)
|
|
58
|
+
},function (err) {
|
|
59
|
+
console.log('err get' + err)
|
|
60
|
+
if(error){
|
|
61
|
+
error(err)
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
},
|
|
65
|
+
getFormUiTable(that,params,callback,error){
|
|
55
66
|
|
|
67
|
+
httpUtil.httpGet(that,'/formui/get_formui_table', params,function (res) {
|
|
68
|
+
callback(res)
|
|
69
|
+
},function (err) {
|
|
70
|
+
console.log('err get' + err)
|
|
71
|
+
if(error){
|
|
72
|
+
error(err)
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
},
|
|
76
|
+
getFormUiSimpleTable(that,params,callback,error){
|
|
77
|
+
|
|
78
|
+
httpUtil.httpGet(that,'/formui/get_formui_simple_table', params,function (res) {
|
|
79
|
+
callback(res)
|
|
80
|
+
},function (err) {
|
|
81
|
+
console.log('err get' + err)
|
|
82
|
+
if(error){
|
|
83
|
+
error(err)
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
},
|
|
56
87
|
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!--管理员列表-->
|
|
3
|
+
<div>
|
|
4
|
+
<!--[begin]-->
|
|
5
|
+
<!--{{fieldValue}}-->
|
|
6
|
+
<!--:multiple="multipleSrc"-->
|
|
7
|
+
<!--{{fieldItem.valueType}}-->
|
|
8
|
+
<!--[a1]-->
|
|
9
|
+
<!--{{state.selectItems}}-->
|
|
10
|
+
<el-select
|
|
11
|
+
:validate-event="validate"
|
|
12
|
+
@change="changeSelect"
|
|
13
|
+
v-model="fieldValueSrc"
|
|
14
|
+
filterable
|
|
15
|
+
reserve-keyword
|
|
16
|
+
placeholder="请选择"
|
|
17
|
+
|
|
18
|
+
:disabled="disabled"
|
|
19
|
+
:multiple="multipleSrc||fieldItem.valueType=='CHECKBOX'"
|
|
20
|
+
|
|
21
|
+
>
|
|
22
|
+
<el-option v-if="!selectItems||selectItems.length==0"
|
|
23
|
+
:label="defaultLabelStr"
|
|
24
|
+
value="" >
|
|
25
|
+
</el-option>
|
|
26
|
+
<el-option v-for="item in selectItems"
|
|
27
|
+
:label="item.title"
|
|
28
|
+
:value="item.id" :key="item.id">
|
|
29
|
+
</el-option>
|
|
30
|
+
<!--<el-option-->
|
|
31
|
+
<!--label="非主库"-->
|
|
32
|
+
<!--:value="0">-->
|
|
33
|
+
<!--</el-option>-->
|
|
34
|
+
</el-select>
|
|
35
|
+
<!--[a2]-->
|
|
36
|
+
<!--{{defaultLabelStr}}___-->
|
|
37
|
+
<!--{{selectItems}}-->
|
|
38
|
+
<!--[end]-->
|
|
39
|
+
<!--{{props.fieldItem}}-->
|
|
40
|
+
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
import formuiService from '../service/formui/FormuiService'
|
|
46
|
+
import moment from 'moment'
|
|
47
|
+
|
|
48
|
+
export default {
|
|
49
|
+
props: {
|
|
50
|
+
beanName: String,
|
|
51
|
+
fieldName: String,
|
|
52
|
+
fieldValue: [Object, String, Number],
|
|
53
|
+
defaultLabel: String,
|
|
54
|
+
multiple: Boolean,
|
|
55
|
+
fieldItem: Object,
|
|
56
|
+
formData: Object,
|
|
57
|
+
disabled: Boolean,
|
|
58
|
+
},
|
|
59
|
+
data() {
|
|
60
|
+
return {
|
|
61
|
+
validate: false,
|
|
62
|
+
defaultLabelStr: '请选择',
|
|
63
|
+
selectItems: [],
|
|
64
|
+
fieldValueSrc: '',
|
|
65
|
+
title: '',
|
|
66
|
+
multipleSrc: false,
|
|
67
|
+
jsonList: [],
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
mounted() {
|
|
71
|
+
// 值转换
|
|
72
|
+
if (Array.isArray(this.fieldValue)) {
|
|
73
|
+
// 数组直接赋值
|
|
74
|
+
this.fieldValueSrc = (this.fieldValue)
|
|
75
|
+
} else if ((this.fieldValue && Number.isInteger(this.fieldValue) == false
|
|
76
|
+
&& this.fieldValue.indexOf(',') != -1) || this.fieldItem.valueType == 'CHECKBOX') {
|
|
77
|
+
// 包含,的字符串
|
|
78
|
+
let arr = []
|
|
79
|
+
if (this.fieldValue) {
|
|
80
|
+
arr = (this.fieldValue + '').split(",");
|
|
81
|
+
}
|
|
82
|
+
this.fieldValueSrc = []
|
|
83
|
+
for (var i = 0; i < arr.length; i++) {
|
|
84
|
+
if (arr[i] === '') {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
this.fieldValueSrc.push(parseInt(arr[i]))
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
} else if ((this.fieldValue || this.fieldValue === 0) && isNaN(this.fieldValue) == false) {
|
|
91
|
+
// 非空数字
|
|
92
|
+
this.fieldValueSrc = parseInt(this.fieldValue)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (this.multiple) {
|
|
96
|
+
// 是否支多选,目前checkbox为多选
|
|
97
|
+
this.multipleSrc = this.multiple
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (this.defaultLabel) {
|
|
101
|
+
this.defaultLabelStr = this.defaultLabel
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (this.fieldItem.joinItems) {
|
|
105
|
+
let jsonObj = {}
|
|
106
|
+
for (var i = 0; i < this.fieldItem.joinItems.length; i++) {
|
|
107
|
+
jsonObj = {}
|
|
108
|
+
let parentFieldName = this.fieldItem.joinItems[i].parentFieldName
|
|
109
|
+
let joinFieldName = this.fieldItem.joinItems[i].joinFieldName
|
|
110
|
+
let value = this.fieldItem.joinItems[i].value
|
|
111
|
+
jsonObj['parentFieldName'] = parentFieldName
|
|
112
|
+
jsonObj['joinFieldName'] = joinFieldName
|
|
113
|
+
jsonObj['value'] = value
|
|
114
|
+
|
|
115
|
+
if (parentFieldName && this.formData) {
|
|
116
|
+
if (this.formData[parentFieldName] || this.formData[parentFieldName] === 0) {
|
|
117
|
+
jsonObj['value'] = parseInt(this.formData[parentFieldName])
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
this.jsonList.push(jsonObj)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
this.loadData()
|
|
126
|
+
},
|
|
127
|
+
methods: {
|
|
128
|
+
loadData() {
|
|
129
|
+
formuiService.getFormuiForeignByBean({ beanName: this.beanName, fieldName: this.fieldName, value: this.formData['id'] }, (resp) => {
|
|
130
|
+
this.selectItems = resp.selectItems
|
|
131
|
+
this.fieldValueSrc = resp.values
|
|
132
|
+
|
|
133
|
+
this.changeSelect()
|
|
134
|
+
this.validate = true
|
|
135
|
+
})
|
|
136
|
+
},
|
|
137
|
+
changeSelect() {
|
|
138
|
+
this.$emit('setFieldValue', this.fieldName, this.fieldValueSrc.toString())
|
|
139
|
+
},
|
|
140
|
+
updateJsonList(jsonList) {
|
|
141
|
+
this.jsonList = jsonList
|
|
142
|
+
this.loadData();
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
expose: {
|
|
146
|
+
updateJsonList
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
</script>
|
|
150
|
+
|
|
151
|
+
<style scoped>
|
|
152
|
+
|
|
153
|
+
</style>
|
|
@@ -104,7 +104,10 @@
|
|
|
104
104
|
if(Array.isArray(this.fieldValue)) {
|
|
105
105
|
this.fieldValueSrc = (this.fieldValue)
|
|
106
106
|
}else if((this.fieldValue&&Number.isInteger(this.fieldValue)==false&&this.fieldValue.indexOf(',')!=-1)||this.fieldItem.valueType=='CHECKBOX'){
|
|
107
|
-
|
|
107
|
+
var arr=[]
|
|
108
|
+
if(this.fieldValue){
|
|
109
|
+
arr=this.fieldValue.split(",");
|
|
110
|
+
}
|
|
108
111
|
this.fieldValueSrc=[]
|
|
109
112
|
for(var i=0;i<arr.length;i++){
|
|
110
113
|
if(arr[i]===''){
|