app-form-view 0.0.8 → 0.1.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/dist/index.js +86 -103
- package/package.json +1 -1
- package/src/api/app-form.js +37 -60
- package/src/api/dict/app-data.js +2 -2
- package/src/app-index.js +3 -0
- package/src/components/appForm/Checkbox.vue +1 -1
- package/src/components/appForm/Form.vue +2 -3
- package/src/components/appForm/Radio.vue +1 -1
- package/src/components/appForm/apiPopup.vue +1 -1
- package/src/components/appForm/select.vue +2 -2
- package/src/views/build/viewAppForm.vue +6 -22
package/package.json
CHANGED
package/src/api/app-form.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
const BASE = 'sjyy/sjczgl/form/bdgl/config/'
|
|
3
2
|
const API = {
|
|
4
3
|
scene: BASE + 'getFromConfigScene',
|
|
@@ -19,91 +18,69 @@ export const APIOPTIONS = [
|
|
|
19
18
|
{ label: '数据查询应用数据表JSON', url: 'sjyy/zycx/getZycxDataList', fhType: 'json', method: 'post', paramsList: [{ label: '选择模式', name: 'xzms', value: '' }, { label: '数据表ID', name: 'id', value: '' }], xtgllx: 'sjcxyy-table' }
|
|
20
19
|
]
|
|
21
20
|
export const TYPEMAPPINGS = {
|
|
22
|
-
input: {
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
select: {
|
|
35
|
-
widget: 'select',
|
|
36
|
-
},
|
|
37
|
-
date: {
|
|
38
|
-
widget: 'datetime',
|
|
39
|
-
},
|
|
40
|
-
rqsjfw: {
|
|
41
|
-
widget: 'datetimeRange',
|
|
42
|
-
},
|
|
43
|
-
password: {
|
|
44
|
-
widget: 'password',
|
|
45
|
-
},
|
|
46
|
-
number: {
|
|
47
|
-
widget: 'inputNumber'
|
|
48
|
-
},
|
|
49
|
-
upload: {
|
|
50
|
-
widget: 'inputUpload'
|
|
51
|
-
},
|
|
52
|
-
tree_select: {
|
|
53
|
-
widget: 'inputTree'
|
|
54
|
-
}
|
|
21
|
+
input: { widget: 'input' },
|
|
22
|
+
radio: { widget: 'radio' },
|
|
23
|
+
checkbox: { widget: 'checkbox' },
|
|
24
|
+
textarea: { widget: 'textarea' },
|
|
25
|
+
select: { widget: 'select' },
|
|
26
|
+
date: { widget: 'datetime' },
|
|
27
|
+
rqsjfw: { widget: 'datetimeRange' },
|
|
28
|
+
password: { widget: 'password' },
|
|
29
|
+
number: { widget: 'inputNumber' },
|
|
30
|
+
upload: { widget: 'inputUpload' },
|
|
31
|
+
tree_select: { widget: 'inputTree' }
|
|
55
32
|
}
|
|
56
|
-
|
|
57
|
-
export function getFormConfig(data) {
|
|
33
|
+
|
|
34
|
+
export function getFormConfig(request, data) {
|
|
58
35
|
|
|
59
36
|
}
|
|
60
|
-
export function getFormConfigScene(data) {
|
|
61
|
-
return
|
|
37
|
+
export function getFormConfigScene(request, data) {
|
|
38
|
+
return request({
|
|
62
39
|
url: API.scene,
|
|
63
40
|
method: 'post',
|
|
64
41
|
data: data
|
|
65
42
|
})
|
|
66
43
|
}
|
|
67
44
|
|
|
68
|
-
export function saveFormData(data) {
|
|
69
|
-
return
|
|
45
|
+
export function saveFormData(request, data) {
|
|
46
|
+
return request({
|
|
70
47
|
url: data.id !== undefined ? API.editSave : API.addSave,
|
|
71
48
|
method: 'post',
|
|
72
49
|
data: data
|
|
73
50
|
})
|
|
74
51
|
}
|
|
75
|
-
export function getTableData(data) {
|
|
76
|
-
return
|
|
52
|
+
export function getTableData(request, data) {
|
|
53
|
+
return request({
|
|
77
54
|
url: API.getData,
|
|
78
55
|
method: 'post',
|
|
79
56
|
data: data
|
|
80
57
|
})
|
|
81
58
|
}
|
|
82
59
|
|
|
83
|
-
export function getUserInfo() {
|
|
84
|
-
return
|
|
60
|
+
export function getUserInfo(request) {
|
|
61
|
+
return request({
|
|
85
62
|
url: '/sjyy/sjczgl/form/bdgl/config/getDqyh',
|
|
86
63
|
method: 'get'
|
|
87
64
|
})
|
|
88
65
|
}
|
|
89
66
|
|
|
90
|
-
export function getFormData(data) {
|
|
91
|
-
return
|
|
67
|
+
export function getFormData(request, data) {
|
|
68
|
+
return request({
|
|
92
69
|
url: API.view,
|
|
93
70
|
method: 'post',
|
|
94
71
|
data: data
|
|
95
72
|
})
|
|
96
73
|
}
|
|
97
74
|
|
|
98
|
-
export function getSjyyFields(data) {
|
|
99
|
-
return
|
|
75
|
+
export function getSjyyFields(request, data) {
|
|
76
|
+
return request({
|
|
100
77
|
url: API.getSjyyFields,
|
|
101
78
|
method: 'post',
|
|
102
79
|
data: data
|
|
103
80
|
})
|
|
104
81
|
}
|
|
105
|
-
export function getDict(dictType, dictLylx) {
|
|
106
|
-
return
|
|
82
|
+
export function getDict(request, dictType, dictLylx) {
|
|
83
|
+
return request({
|
|
107
84
|
url: API.getDict,
|
|
108
85
|
method: 'post',
|
|
109
86
|
data: { dictType, dictLylx: dictLylx || 'sys' }
|
|
@@ -111,40 +88,40 @@ export function getDict(dictType, dictLylx) {
|
|
|
111
88
|
}
|
|
112
89
|
|
|
113
90
|
// 接口列表
|
|
114
|
-
export function apiList(query) {
|
|
115
|
-
return
|
|
91
|
+
export function apiList(request, query) {
|
|
92
|
+
return request({
|
|
116
93
|
url: '/gzt/jkgl/getGztJklist',
|
|
117
94
|
method: 'post',
|
|
118
95
|
data: query
|
|
119
96
|
})
|
|
120
97
|
}
|
|
121
98
|
// 接口详情
|
|
122
|
-
export function apiView(id) {
|
|
123
|
-
return
|
|
99
|
+
export function apiView(request, id) {
|
|
100
|
+
return request({
|
|
124
101
|
url: '/gzt/jkgl/jkglView',
|
|
125
102
|
method: 'post',
|
|
126
103
|
data: { id }
|
|
127
104
|
})
|
|
128
105
|
}
|
|
129
106
|
|
|
130
|
-
export function getViewData(data) {
|
|
131
|
-
return
|
|
107
|
+
export function getViewData(request, data) {
|
|
108
|
+
return request({
|
|
132
109
|
url: API.getViewData,
|
|
133
110
|
method: 'post',
|
|
134
111
|
data: data
|
|
135
112
|
})
|
|
136
113
|
}
|
|
137
114
|
|
|
138
|
-
export function getFormInitData(data) {
|
|
139
|
-
return
|
|
115
|
+
export function getFormInitData(request, data) {
|
|
116
|
+
return request({
|
|
140
117
|
url: API.getFormInitData,
|
|
141
118
|
method: 'post',
|
|
142
119
|
data: data
|
|
143
120
|
})
|
|
144
121
|
}
|
|
145
122
|
|
|
146
|
-
export function getData(url, data) {
|
|
147
|
-
return
|
|
123
|
+
export function getData(request, url, data) {
|
|
124
|
+
return request({
|
|
148
125
|
url: url,
|
|
149
126
|
method: 'post',
|
|
150
127
|
data: data
|
package/src/api/dict/app-data.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
// 根据字典类型查询字典数据信息
|
|
4
|
-
export function getDicts(dictType, dictLylx) {
|
|
4
|
+
export function getDicts(request, dictType, dictLylx) {
|
|
5
5
|
let type = dictType.split('/')[0]
|
|
6
|
-
return
|
|
6
|
+
return request({
|
|
7
7
|
url: '/sjyy/sjczgl/form/bdgl/config/getFormDictData',
|
|
8
8
|
data: { dictType: type, dictLylx: dictLylx || dictType.split('/')[1] || 'sys' },
|
|
9
9
|
method: 'post'
|
package/src/app-index.js
CHANGED
|
@@ -50,6 +50,9 @@ const install = function (Vue, options) {
|
|
|
50
50
|
if (options.request) {
|
|
51
51
|
Vue.prototype.$request = options.request
|
|
52
52
|
}
|
|
53
|
+
if (options.goBack) {
|
|
54
|
+
Vue.prototype.goBack = options.goBack
|
|
55
|
+
}
|
|
53
56
|
Object.values(components).forEach(comp => {
|
|
54
57
|
// 增加判断:comp存在 + name是有效字符串
|
|
55
58
|
if (comp && comp.name && typeof comp.name === 'string') {
|
|
@@ -56,7 +56,7 @@ export default {
|
|
|
56
56
|
// 加载字典数据
|
|
57
57
|
async loadDictData(dictType, dictLylx) {
|
|
58
58
|
try {
|
|
59
|
-
const response = await getDicts(dictType, dictLylx);
|
|
59
|
+
const response = await getDicts(this.$request, dictType, dictLylx);
|
|
60
60
|
this.selectOptions = (response.rows || response.data || []).map(item => ({
|
|
61
61
|
value: item.dictValue,
|
|
62
62
|
label: item.dictLabel,
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
11
|
<script>
|
|
12
|
-
import request from '@/utils/request'
|
|
13
12
|
import Vue from 'vue'
|
|
14
13
|
import { isString } from '@/utils/index'
|
|
15
14
|
import eventsMixin from '../form/form-event-mixin.js'
|
|
@@ -134,7 +133,7 @@ export default {
|
|
|
134
133
|
// 2. 转换 Vue 响应式 formData 为原生 FormData
|
|
135
134
|
//const nativeFormData = this.convertVueFormToNativeFormData(JSON.parse(JSON.stringify(this.formModel)));
|
|
136
135
|
if (this.ywid && !this.formModel[this.conf.primaryKeyName]) nativeFormData.append(this.conf.primaryKeyName || 'id', this.ywid)
|
|
137
|
-
request({
|
|
136
|
+
this.$request({
|
|
138
137
|
url: this.saveUrl,
|
|
139
138
|
// cache: false,
|
|
140
139
|
// contentType: false,
|
|
@@ -177,7 +176,7 @@ export default {
|
|
|
177
176
|
message: '保存中…',
|
|
178
177
|
});
|
|
179
178
|
if (this.ywid && !this.formModel[this.conf.primaryKeyName]) nativeFormData.append(this.conf.primaryKeyName || 'id', this.ywid)
|
|
180
|
-
request({
|
|
179
|
+
this.$request({
|
|
181
180
|
url: this.saveUrl,
|
|
182
181
|
method: 'POST',
|
|
183
182
|
data: nativeFormData
|
|
@@ -48,7 +48,7 @@ export default {
|
|
|
48
48
|
// 加载字典数据
|
|
49
49
|
async loadDictData(dictType, dictLylx) {
|
|
50
50
|
try {
|
|
51
|
-
const response = await getDicts(dictType, dictLylx);
|
|
51
|
+
const response = await getDicts(this.$request, dictType, dictLylx);
|
|
52
52
|
this.selectOptions = (response.rows || response.data || []).map(item => ({
|
|
53
53
|
value: item.dictValue,
|
|
54
54
|
label: item.dictLabel,
|
|
@@ -114,7 +114,7 @@ export default {
|
|
|
114
114
|
this.$emit('close')
|
|
115
115
|
},
|
|
116
116
|
getTableData() {
|
|
117
|
-
getData(this.tableApi.url, this.tableApi.params).then(res => {
|
|
117
|
+
getData(this.$request, this.tableApi.url, this.tableApi.params).then(res => {
|
|
118
118
|
if (res.code == 0) {
|
|
119
119
|
this.tableData = res.rows
|
|
120
120
|
// this.tableData = res.rows.map((item, index) => {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
</template>
|
|
35
35
|
|
|
36
36
|
<script>
|
|
37
|
-
import { getDicts } from '@/api/dict/data'
|
|
37
|
+
import { getDicts } from '@/api/dict/app-data'
|
|
38
38
|
import baseMixin from './baseMixin.js'
|
|
39
39
|
import eventsMixin from '../form/form-event-mixin.js'
|
|
40
40
|
|
|
@@ -116,7 +116,7 @@ export default {
|
|
|
116
116
|
// 加载字典数据
|
|
117
117
|
async loadDictData(dictType, dictLylx) {
|
|
118
118
|
try {
|
|
119
|
-
const response = await getDicts(dictType, dictLylx);
|
|
119
|
+
const response = await getDicts(this.$request, dictType, dictLylx);
|
|
120
120
|
this.selectOptions = (response.rows || response.data || []).map(item => ({
|
|
121
121
|
value: item.dictValue,
|
|
122
122
|
label: item.dictLabel,
|
|
@@ -21,12 +21,11 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
<script>
|
|
23
23
|
import { baseComponents } from '@/utils/generator/config'
|
|
24
|
-
import { mapActions, mapState } from 'vuex'
|
|
25
24
|
import AppFormItem from './AppFormItem.vue'
|
|
26
25
|
import { getFormData, getFormInitData, getViewData } from '@/api/app-form'
|
|
27
26
|
import { findFirstNodeByNameAndSjbName } from '@/utils/index'
|
|
28
27
|
export default {
|
|
29
|
-
name: '
|
|
28
|
+
name: 'AppFormView',
|
|
30
29
|
components: {
|
|
31
30
|
AppFormItem
|
|
32
31
|
},
|
|
@@ -56,7 +55,6 @@ export default {
|
|
|
56
55
|
}
|
|
57
56
|
},
|
|
58
57
|
computed: {
|
|
59
|
-
...mapState('user', ['userInfo']),
|
|
60
58
|
hiddenList() {
|
|
61
59
|
return this.drawingList.filter(item => item.noDrag)
|
|
62
60
|
},
|
|
@@ -123,9 +121,7 @@ export default {
|
|
|
123
121
|
}
|
|
124
122
|
},
|
|
125
123
|
created() {
|
|
126
|
-
|
|
127
|
-
this.fetchUserInfo()
|
|
128
|
-
}
|
|
124
|
+
|
|
129
125
|
if (this.formData) {
|
|
130
126
|
this.formConf = this.formData
|
|
131
127
|
this.drawingList = this.formData.fields
|
|
@@ -145,10 +141,9 @@ export default {
|
|
|
145
141
|
|
|
146
142
|
},
|
|
147
143
|
methods: {
|
|
148
|
-
...mapActions('user', ['fetchUserInfo']),
|
|
149
144
|
initData(formId, buttonCode, ywid) {
|
|
150
145
|
// 原有接口请求逻辑不变
|
|
151
|
-
getFormData({ id: formId }).then(res => {
|
|
146
|
+
getFormData(this.$request, { id: formId }).then(res => {
|
|
152
147
|
if (res.code == 0) {
|
|
153
148
|
const data = res.data;
|
|
154
149
|
const formCode = data.formCode
|
|
@@ -178,7 +173,7 @@ export default {
|
|
|
178
173
|
this.paddingBottom = '0px';
|
|
179
174
|
}
|
|
180
175
|
if (this.formConf.mode == 'add') {
|
|
181
|
-
if (formCode) getFormInitData({ formCode }).then(res => {
|
|
176
|
+
if (formCode) getFormInitData(this.$request, { formCode }).then(res => {
|
|
182
177
|
if (res.code == 0) {
|
|
183
178
|
this.formConf.model = res.data
|
|
184
179
|
}
|
|
@@ -187,21 +182,10 @@ export default {
|
|
|
187
182
|
else if (this.formConf.mode == 'edit' || this.formConf.mode == 'view') {
|
|
188
183
|
//编辑
|
|
189
184
|
if (!ywid) {
|
|
190
|
-
|
|
191
|
-
//关闭当前页面
|
|
192
|
-
//根据页面打开方式
|
|
193
|
-
if (this.openType == 'dialog') {
|
|
194
|
-
var index = parent.layer.getFrameIndex(window.name); // 获取当前层的索引
|
|
195
|
-
parent.layer.close(index);
|
|
196
|
-
} else if (this.openType == 'blank') {
|
|
197
|
-
window.close();
|
|
198
|
-
} else {
|
|
199
|
-
$.modal.closeTab();
|
|
200
|
-
}
|
|
201
|
-
})
|
|
185
|
+
this.goBack();
|
|
202
186
|
} else if (formCode && ywid) {
|
|
203
187
|
//获取表单数据
|
|
204
|
-
getViewData({ formCode, id: ywid }).then(res => {
|
|
188
|
+
getViewData(this.$request, { formCode, id: ywid }).then(res => {
|
|
205
189
|
if (res.code == 0) {
|
|
206
190
|
this.formConf.model = res.data
|
|
207
191
|
let uploadData = {}
|