app-form-view 0.0.1 → 0.0.2
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/README.md +1 -1
- package/dist/css/style.css +157 -206
- package/dist/index.js +567 -2
- package/package.json +7 -5
- package/scripts/rollup.config.base.js +100 -68
- package/scripts/rollup.config.build.js +32 -29
- package/scripts/rollup.config.dev.js +18 -21
- package/scripts/rollup.config.prod.js +12 -2
- package/src/assets/css/app-form.css +50 -14
- package/src/assets/css/global.css +12 -12
- package/src/assets/scss/_flex.scss +31 -34
- package/src/assets/scss/app-form.scss +184 -1
- package/src/assets/scss/global.scss +179 -1
- package/src/components/appForm/Checkbox.vue +5 -0
- package/src/components/appForm/Input.vue +2 -2
- package/src/components/appForm/SearchApi.vue +1 -1
- package/src/components/appForm/Table.vue +21 -3
- package/src/components/appForm/select.vue +5 -5
- package/src/components/form/SearchSelect.vue +3 -3
- package/src/components/form/Table.vue +1 -1
- package/src/index.js +1 -1
- package/src/views/build/FieldMappingDialog.vue +0 -7
- package/src/views/build/RightPanel.vue +0 -1
- package/src/views/build/index.vue +0 -15
- package/src/views/build/viewAppForm.vue +150 -111
- package/src/views/build/viewForm.vue +2 -2
- package/static/plugins/css/app-form.css +3 -1
- package/static/plugins/scss/app-form.scss +5 -0
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<script>
|
|
23
23
|
import { baseComponents } from '@/utils/generator/config'
|
|
24
24
|
import { mapActions, mapState } from 'vuex'
|
|
25
|
-
import AppFormItem from './AppFormItem'
|
|
25
|
+
import AppFormItem from './AppFormItem.vue'
|
|
26
26
|
import { getFormData, getFormInitData, getViewData } from '@/api/form'
|
|
27
27
|
import { findFirstNodeByNameAndSjbName } from '@/utils/index'
|
|
28
28
|
export default {
|
|
@@ -30,6 +30,15 @@ export default {
|
|
|
30
30
|
AppFormItem
|
|
31
31
|
},
|
|
32
32
|
props: {
|
|
33
|
+
formId: {
|
|
34
|
+
type: String,
|
|
35
|
+
},
|
|
36
|
+
buttonCode: {
|
|
37
|
+
type: String,
|
|
38
|
+
},
|
|
39
|
+
ywid: {
|
|
40
|
+
type: String,
|
|
41
|
+
},
|
|
33
42
|
formData: {
|
|
34
43
|
type: Object,
|
|
35
44
|
default: () => { }
|
|
@@ -101,6 +110,15 @@ export default {
|
|
|
101
110
|
}
|
|
102
111
|
},
|
|
103
112
|
deep: true
|
|
113
|
+
},
|
|
114
|
+
formId() {
|
|
115
|
+
this.initData(this.formId, this.buttonCode, this.ywid)
|
|
116
|
+
},
|
|
117
|
+
buttonCode() {
|
|
118
|
+
this.initData(this.formId, this.buttonCode, this.ywid)
|
|
119
|
+
},
|
|
120
|
+
ywid() {
|
|
121
|
+
this.initData(this.formId, this.buttonCode, this.ywid)
|
|
104
122
|
}
|
|
105
123
|
},
|
|
106
124
|
created() {
|
|
@@ -114,132 +132,153 @@ export default {
|
|
|
114
132
|
|
|
115
133
|
// 调用修改后的方法,获取formId
|
|
116
134
|
const { formId, buttonCode, ywid } = this.getFormParamsFromUrl();
|
|
117
|
-
if (
|
|
135
|
+
if (formId) this.initData(formId, buttonCode, ywid)
|
|
136
|
+
if (this.formId) this.initData(this.formId, this.buttonCode, this.ywid)
|
|
137
|
+
if (!formId || !this.formId) {
|
|
118
138
|
console.warn('未从URL中获取到表单ID');
|
|
119
139
|
return; // 无ID时终止请求,避免接口报错
|
|
120
140
|
}
|
|
121
|
-
// 原有接口请求逻辑不变
|
|
122
|
-
getFormData({ id: formId }).then(res => {
|
|
123
|
-
if (res.code == 0) {
|
|
124
|
-
const data = res.data;
|
|
125
|
-
const formCode = data.formCode
|
|
126
|
-
this.openType = data.openType
|
|
127
|
-
let formJson = JSON.parse(data.formJson);
|
|
128
141
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
currentType = formJson.sceneList.filter(item => item.sceneCode == buttonCode)[0].operationType
|
|
132
|
-
}
|
|
133
|
-
this.drawingList = JSON.parse(JSON.stringify(formJson.fields))
|
|
134
|
-
delete formJson.fields
|
|
135
|
-
this.formConf = formJson
|
|
136
|
-
this.formConf.mode = currentType == 'detail' ? 'view' : currentType
|
|
137
|
-
this.formConf.model = {}
|
|
138
|
-
if (this.formConf && this.formConf.buttons && this.formConf.buttons.length > 0) {
|
|
139
|
-
if (this.$refs.detailBtns) {
|
|
140
|
-
this.paddingBottom = this.$refs.detailBtns.offsetHeight + 'px';
|
|
141
|
-
} else {
|
|
142
|
-
this.paddingBottom = '60px'
|
|
143
|
-
this.$nextTick(() => {
|
|
144
|
-
if (this.$refs.detailBtns) this.paddingBottom = this.$refs.detailBtns.offsetHeight + 'px';
|
|
145
|
-
})
|
|
146
|
-
}
|
|
142
|
+
},
|
|
143
|
+
mounted() {
|
|
147
144
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
145
|
+
},
|
|
146
|
+
methods: {
|
|
147
|
+
...mapActions('user', ['fetchUserInfo']),
|
|
148
|
+
initData(formId, buttonCode, ywid) {
|
|
149
|
+
// 原有接口请求逻辑不变
|
|
150
|
+
getFormData({ id: formId }).then(res => {
|
|
151
|
+
if (res.code == 0) {
|
|
152
|
+
const data = res.data;
|
|
153
|
+
const formCode = data.formCode
|
|
154
|
+
this.openType = data.openType
|
|
155
|
+
let formJson = JSON.parse(data.formJson);
|
|
156
|
+
|
|
157
|
+
let currentType = 'add'
|
|
158
|
+
if (formJson.sceneList && formJson.sceneList.length > 0 && buttonCode && formJson.sceneList.filter(item => item.sceneCode == buttonCode).length > 0) {
|
|
159
|
+
currentType = formJson.sceneList.filter(item => item.sceneCode == buttonCode)[0].operationType
|
|
160
|
+
}
|
|
161
|
+
this.drawingList = JSON.parse(JSON.stringify(formJson.fields))
|
|
162
|
+
delete formJson.fields
|
|
163
|
+
this.formConf = formJson
|
|
164
|
+
this.formConf.mode = currentType == 'detail' ? 'view' : currentType
|
|
165
|
+
this.formConf.model = {}
|
|
166
|
+
if (this.formConf && this.formConf.buttons && this.formConf.buttons.length > 0) {
|
|
167
|
+
if (this.$refs.detailBtns) {
|
|
168
|
+
this.paddingBottom = this.$refs.detailBtns.offsetHeight + 'px';
|
|
169
|
+
} else {
|
|
170
|
+
this.paddingBottom = '60px'
|
|
171
|
+
this.$nextTick(() => {
|
|
172
|
+
if (this.$refs.detailBtns) this.paddingBottom = this.$refs.detailBtns.offsetHeight + 'px';
|
|
173
|
+
})
|
|
155
174
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
//关闭当前页面
|
|
163
|
-
//根据页面打开方式
|
|
164
|
-
if (this.openType == 'dialog') {
|
|
165
|
-
var index = parent.layer.getFrameIndex(window.name); // 获取当前层的索引
|
|
166
|
-
parent.layer.close(index);
|
|
167
|
-
} else if (this.openType == 'blank') {
|
|
168
|
-
window.close();
|
|
169
|
-
} else {
|
|
170
|
-
$.modal.closeTab();
|
|
171
|
-
}
|
|
172
|
-
})
|
|
173
|
-
} else if (formCode && ywid) {
|
|
174
|
-
//获取表单数据
|
|
175
|
-
getViewData({ formCode, id: ywid }).then(res => {
|
|
175
|
+
|
|
176
|
+
} else {
|
|
177
|
+
this.paddingBottom = '0px';
|
|
178
|
+
}
|
|
179
|
+
if (this.formConf.mode == 'add') {
|
|
180
|
+
if (formCode) getFormInitData({ formCode }).then(res => {
|
|
176
181
|
if (res.code == 0) {
|
|
177
182
|
this.formConf.model = res.data
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
183
|
+
}
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
else if (this.formConf.mode == 'edit' || this.formConf.mode == 'view') {
|
|
187
|
+
//编辑
|
|
188
|
+
if (!ywid) {
|
|
189
|
+
$.modal.confirm('编辑状态下未从URL中获取到表单ywid,是否返回?', () => {
|
|
190
|
+
//关闭当前页面
|
|
191
|
+
//根据页面打开方式
|
|
192
|
+
if (this.openType == 'dialog') {
|
|
193
|
+
var index = parent.layer.getFrameIndex(window.name); // 获取当前层的索引
|
|
194
|
+
parent.layer.close(index);
|
|
195
|
+
} else if (this.openType == 'blank') {
|
|
196
|
+
window.close();
|
|
197
|
+
} else {
|
|
198
|
+
$.modal.closeTab();
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
} else if (formCode && ywid) {
|
|
202
|
+
//获取表单数据
|
|
203
|
+
getViewData({ formCode, id: ywid }).then(res => {
|
|
204
|
+
if (res.code == 0) {
|
|
205
|
+
this.formConf.model = res.data
|
|
206
|
+
let uploadData = {}
|
|
207
|
+
for (let key in this.formConf.model) {
|
|
208
|
+
const keyMap = this.multiplyUploadList[key]
|
|
209
|
+
if (keyMap) {
|
|
210
|
+
const bizType = keyMap.bizType
|
|
211
|
+
this.formConf.model[key].forEach(item => {
|
|
212
|
+
if (!uploadData[key + '@' + item[bizType]]) {
|
|
213
|
+
uploadData[key + '@' + item[bizType]] = []
|
|
214
|
+
}
|
|
215
|
+
uploadData[key + '@' + item[bizType]].push({
|
|
216
|
+
[keyMap.path]: item.path.fileBase64,
|
|
217
|
+
[keyMap.name]: item.path.fileName,
|
|
218
|
+
[keyMap.type]: item.path.fileType,
|
|
219
|
+
[keyMap.size]: item.size,
|
|
220
|
+
[bizType]: item[bizType]
|
|
221
|
+
})
|
|
193
222
|
})
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
223
|
+
delete this.multiplyUploadList[key]
|
|
224
|
+
delete this.formConf.model[key]
|
|
225
|
+
}
|
|
226
|
+
const keyMap2 = this.multiplySingleUploadList[key]
|
|
227
|
+
if (keyMap2 && this.formConf.model[key]) {
|
|
228
|
+
this.formConf.model[key] = this.formConf.model[key].map(item => {
|
|
229
|
+
return {
|
|
230
|
+
[keyMap2.path]: item.path.fileBase64,
|
|
231
|
+
[keyMap2.name]: item.path.fileName,
|
|
232
|
+
[keyMap2.type]: item.path.fileType,
|
|
233
|
+
[keyMap2.size]: item.size,
|
|
234
|
+
[keyMap2.bizType]: item[keyMap2.bizType]
|
|
235
|
+
}
|
|
207
236
|
}
|
|
237
|
+
)
|
|
208
238
|
}
|
|
209
|
-
)
|
|
210
|
-
}
|
|
211
|
-
const tableMap = this.tableList.filter(item => item.name == key)
|
|
239
|
+
const tableMap = this.tableList.filter(item => item.name == key)
|
|
212
240
|
|
|
213
|
-
|
|
214
|
-
|
|
241
|
+
if (tableMap && tableMap.length > 0) {
|
|
242
|
+
this.formConf.model[key] = JSON.stringify(this.formConf.model[key])
|
|
243
|
+
}
|
|
215
244
|
}
|
|
245
|
+
for (let key in uploadData) {
|
|
246
|
+
this.formConf.model[key] = uploadData[key]
|
|
247
|
+
}
|
|
248
|
+
console.log(this.formConf.model, '回显数据')
|
|
216
249
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
console.log(this.formConf.model, '回显数据')
|
|
221
|
-
}
|
|
222
|
-
})
|
|
223
|
-
}
|
|
224
|
-
} else {
|
|
250
|
+
})
|
|
251
|
+
}
|
|
252
|
+
} else {
|
|
225
253
|
|
|
254
|
+
}
|
|
226
255
|
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
|
-
mounted() {
|
|
233
|
-
|
|
234
|
-
},
|
|
235
|
-
methods: {
|
|
236
|
-
...mapActions('user', ['fetchUserInfo']),
|
|
256
|
+
}).catch(err => {
|
|
257
|
+
console.error('获取表单数据失败:', err);
|
|
258
|
+
})
|
|
259
|
+
},
|
|
237
260
|
onClickLeft() { },
|
|
238
261
|
// 抽取方法:返回处理后的 fields 数组
|
|
239
262
|
getDrawingList(fields) {
|
|
240
263
|
const len = fields.length;
|
|
264
|
+
|
|
265
|
+
// 先深拷贝一份,避免修改原数组
|
|
266
|
+
const fieldList = [...fields];
|
|
267
|
+
|
|
268
|
+
// 第一步:遍历处理 subTitle 与 table 联动
|
|
269
|
+
for (let i = 0; i < len; i++) {
|
|
270
|
+
const current = fieldList[i];
|
|
271
|
+
const next = fieldList[i + 1];
|
|
272
|
+
// 当前是 subTitle 且下一个存在、并且是 table
|
|
273
|
+
if (current.widget === 'subTitle' && next && next.widget === 'table') {
|
|
274
|
+
// subTitle 设为显示
|
|
275
|
+
current.appVisible = false;
|
|
276
|
+
// table 的 label 赋值为 subTitle 的 label
|
|
277
|
+
next.label = current.label;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
241
280
|
// 直接 return map 结果
|
|
242
|
-
return
|
|
281
|
+
return fieldList.map((item, index) => {
|
|
243
282
|
const { class: cls, ...rest } = item;
|
|
244
283
|
const isFirst = index === 0;
|
|
245
284
|
const isLast = index === len - 1;
|
|
@@ -247,8 +286,9 @@ export default {
|
|
|
247
286
|
|
|
248
287
|
let KClass = '';
|
|
249
288
|
// 最后一个
|
|
250
|
-
if (isLast
|
|
251
|
-
|
|
289
|
+
if (isLast) {
|
|
290
|
+
if (isInBase)
|
|
291
|
+
KClass = 'last-cell-child';
|
|
252
292
|
}
|
|
253
293
|
// 第一个
|
|
254
294
|
else if (isFirst) {
|
|
@@ -256,11 +296,10 @@ export default {
|
|
|
256
296
|
KClass = 'first-cell-child';
|
|
257
297
|
}
|
|
258
298
|
}
|
|
259
|
-
|
|
260
299
|
// 中间元素
|
|
261
300
|
else {
|
|
262
|
-
const prev =
|
|
263
|
-
const next =
|
|
301
|
+
const prev = fieldList[index - 1];
|
|
302
|
+
const next = fieldList[index + 1];
|
|
264
303
|
const prevIn = this.baseWidget.indexOf(prev.widget) > -1;
|
|
265
304
|
const nextIn = this.baseWidget.indexOf(next.widget) > -1;
|
|
266
305
|
const isPrevSubTitle = prev.widget === 'subTitle';
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
<div class="gray-bg dialog-content" :style="{ 'padding-bottom': paddingBottom }">
|
|
4
4
|
<c-form :conf="formConf" ref="cform" :model="formConf.model || {}" :openType="openType"
|
|
5
5
|
:singleUploadList="singleUploadList" :multiplySingleUploadList="multiplySingleUploadList"
|
|
6
|
-
@updateItem="updateItem">
|
|
6
|
+
@updateItem="updateItem" class="h100">
|
|
7
7
|
<div class="container-div animated fadeInRight">
|
|
8
|
-
<div class="row">
|
|
8
|
+
<div class="row" style="overflow:auto">
|
|
9
9
|
<div class="col-xs-12 col-lg-12 col-md-12 search-collapse">
|
|
10
10
|
<div class="detail-title" v-if="formConf.showName && formConf.name">{{ sceneName }}{{
|
|
11
11
|
formConf.name }}</div>
|
|
@@ -90,13 +90,15 @@ button[disabled] { opacity: 0.6; }
|
|
|
90
90
|
|
|
91
91
|
.app-page { height: 100%; overflow: hidden; }
|
|
92
92
|
|
|
93
|
+
.app-page .bottom-btns { gap: 15px; padding-left: 10px; padding-right: 10px; }
|
|
94
|
+
|
|
93
95
|
.app-page .bottom-btns .widget-button { display: -webkit-box; display: -ms-flexbox; display: flex; margin: 0; -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column; -webkit-box-align: center; -ms-flex-align: center; align-items: center; color: #646566; }
|
|
94
96
|
|
|
95
97
|
.app-page .bottom-btns .widget-button .van-icon { display: none; }
|
|
96
98
|
|
|
97
99
|
.app-page .bottom-btns .widget-button .icon { margin: 0 auto 2px; font-size: 18px; }
|
|
98
100
|
|
|
99
|
-
.app-page .bottom-btns .widget-button:last-child { -webkit-box-orient: horizontal; -webkit-box-direction: normal; -ms-flex-direction: row; flex-direction: row; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; color: white; border-radius: 15px; height: 40px; font-size: 14px; margin-right: 5px; background: -webkit-gradient(linear, left top, right top, from(var(--primary-color-60)), to(var(--primary-color))); background: -o-linear-gradient(left, var(--primary-color-60), var(--primary-color)); background: linear-gradient(to right, var(--primary-color-60), var(--primary-color)); }
|
|
101
|
+
.app-page .bottom-btns .widget-button:last-child { -webkit-box-orient: horizontal; -webkit-box-direction: normal; -ms-flex-direction: row; flex-direction: row; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; color: white; border-radius: 15px; height: 40px; font-size: 14px; margin-right: 5px; -webkit-box-flex: 1; -ms-flex: 1; flex: 1; background: -webkit-gradient(linear, left top, right top, from(var(--primary-color-60)), to(var(--primary-color))); background: -o-linear-gradient(left, var(--primary-color-60), var(--primary-color)); background: linear-gradient(to right, var(--primary-color-60), var(--primary-color)); }
|
|
100
102
|
|
|
101
103
|
.app-page .bottom-btns .widget-button:last-child .icon { color: #fff; margin: 0 5px 0 0; }
|
|
102
104
|
|
|
@@ -81,9 +81,13 @@ button[disabled]{
|
|
|
81
81
|
height:100%;
|
|
82
82
|
overflow:hidden;
|
|
83
83
|
.bottom-btns{
|
|
84
|
+
gap:15px;
|
|
85
|
+
padding-left: 10px;
|
|
86
|
+
padding-right: 10px;
|
|
84
87
|
.widget-button{
|
|
85
88
|
display:flex;
|
|
86
89
|
margin:0;
|
|
90
|
+
|
|
87
91
|
flex-direction: column;
|
|
88
92
|
align-items: center;
|
|
89
93
|
color: #646566;
|
|
@@ -101,6 +105,7 @@ button[disabled]{
|
|
|
101
105
|
height: 40px;
|
|
102
106
|
font-size: 14px;
|
|
103
107
|
margin-right: 5px;
|
|
108
|
+
flex:1;
|
|
104
109
|
background: linear-gradient(to right, var(--primary-color-60), var(--primary-color));
|
|
105
110
|
.icon{color:#fff;margin:0 5px 0 0;}
|
|
106
111
|
}
|