Showing
8 changed files
with
557 additions
and
11 deletions
| ... | @@ -16,7 +16,7 @@ VITE_PIN = | ... | @@ -16,7 +16,7 @@ VITE_PIN = |
| 16 | 16 | ||
| 17 | # 反向代理服务器地址 | 17 | # 反向代理服务器地址 |
| 18 | # VITE_PROXY_TARGET = https://oa.anxinchashi.com/ | 18 | # VITE_PROXY_TARGET = https://oa.anxinchashi.com/ |
| 19 | -VITE_PROXY_TARGET = http://oa.onwall.cn | 19 | +VITE_PROXY_TARGET = http://oa-dev.onwall.cn |
| 20 | # VITE_PROXY_TARGET = https://www.wxgzjs.cn/ | 20 | # VITE_PROXY_TARGET = https://www.wxgzjs.cn/ |
| 21 | 21 | ||
| 22 | # PC端地址 | 22 | # PC端地址 | ... | ... |
| ... | @@ -21,6 +21,7 @@ declare module '@vue/runtime-core' { | ... | @@ -21,6 +21,7 @@ declare module '@vue/runtime-core' { |
| 21 | EmailField: typeof import('./src/components/EmailField/index.vue')['default'] | 21 | EmailField: typeof import('./src/components/EmailField/index.vue')['default'] |
| 22 | FileUploaderField: typeof import('./src/components/FileUploaderField/index.vue')['default'] | 22 | FileUploaderField: typeof import('./src/components/FileUploaderField/index.vue')['default'] |
| 23 | GenderField: typeof import('./src/components/GenderField/index.vue')['default'] | 23 | GenderField: typeof import('./src/components/GenderField/index.vue')['default'] |
| 24 | + GroupField: typeof import('./src/components/GroupField/index.vue')['default'] | ||
| 24 | IdentityField: typeof import('./src/components/IdentityField/index.vue')['default'] | 25 | IdentityField: typeof import('./src/components/IdentityField/index.vue')['default'] |
| 25 | ImageUploaderField: typeof import('./src/components/ImageUploaderField/index.vue')['default'] | 26 | ImageUploaderField: typeof import('./src/components/ImageUploaderField/index.vue')['default'] |
| 26 | MarqueeField: typeof import('./src/components/MarqueeField/index.vue')['default'] | 27 | MarqueeField: typeof import('./src/components/MarqueeField/index.vue')['default'] | ... | ... |
src/components/GroupField/index.vue
0 → 100644
| 1 | +<!-- | ||
| 2 | + * @Date: 2024-05-27 14:28:57 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2024-05-28 10:28:26 | ||
| 5 | + * @FilePath: /data-table/src/components/GroupField/index.vue | ||
| 6 | + * @Description: 组集合输入控件 | ||
| 7 | +--> | ||
| 8 | +<template> | ||
| 9 | + <div v-if="HideShow" class="group-field-page"> | ||
| 10 | + <div class="label"> | ||
| 11 | + <span v-if="item.component_props.required"> *</span> | ||
| 12 | + {{ item.component_props.label }} | ||
| 13 | + </div> | ||
| 14 | + <div v-if="item.component_props.note" class="note" v-html="item.component_props.note" /> | ||
| 15 | + <div> | ||
| 16 | + <div v-for="(data, idx) in listData" :key="idx" style="border: 1px solid #eee; border-top: 0; margin: 1rem; position: relative;"> | ||
| 17 | + <van-icon @click="onRemove(idx)" v-if="listData.length > 1" size="1.5rem" color="#ee0a24" name="clear" style="position: absolute; right: -0.5rem; top: -0.5rem;" /> | ||
| 18 | + <van-cell-group :border="false"> | ||
| 19 | + <component v-for="(item, index) in data" :id="item.key" :key="index" | ||
| 20 | + :is="item.component" :item="item" @active="onActive" /> | ||
| 21 | + </van-cell-group> | ||
| 22 | + </div> | ||
| 23 | + <div style="margin: 1rem;"> | ||
| 24 | + <van-button icon="plus" type="primary" block @click="addData">追加一条记录</van-button> | ||
| 25 | + </div> | ||
| 26 | + </div> | ||
| 27 | + </div> | ||
| 28 | +</template> | ||
| 29 | + | ||
| 30 | +<script setup> | ||
| 31 | +import { styleColor } from "@/constant.js"; | ||
| 32 | +import { queryFormAPI } from "@/api/form.js"; | ||
| 33 | +import { useRoute } from "vue-router"; | ||
| 34 | +import { createComponentType } from "@/hooks/useComponentType"; | ||
| 35 | + | ||
| 36 | +const props = defineProps({ | ||
| 37 | + item: Object, | ||
| 38 | +}); | ||
| 39 | + | ||
| 40 | +// TAG: 自定义主题颜色 | ||
| 41 | +const themeVars = { | ||
| 42 | + radioColor: styleColor.baseColor, | ||
| 43 | +}; | ||
| 44 | +// 隐藏显示 | ||
| 45 | +const HideShow = computed(() => { | ||
| 46 | + return !props.item.component_props.disabled | ||
| 47 | +}); | ||
| 48 | + | ||
| 49 | +// TODO:模拟集合组数据源 | ||
| 50 | +const testData = props.item.component_props.field_groups; | ||
| 51 | + | ||
| 52 | +// TAG: 测试调整了input和name两个组件头部显示 | ||
| 53 | + | ||
| 54 | +/*const testData = [ | ||
| 55 | + // { | ||
| 56 | + // "tag": "radio", | ||
| 57 | + // "name": "radio_8", | ||
| 58 | + // "note": "", | ||
| 59 | + // "index": 8, | ||
| 60 | + // "label": "组别", | ||
| 61 | + // "options": [ | ||
| 62 | + // { | ||
| 63 | + // "title": "少年组", | ||
| 64 | + // "value": "少年组", | ||
| 65 | + // "checked": false, | ||
| 66 | + // "desc_url": "", | ||
| 67 | + // "is_input": false, | ||
| 68 | + // "desc_text": "", | ||
| 69 | + // "desc_type": "", | ||
| 70 | + // "desc_btn_name": "", | ||
| 71 | + // "input_required": false, | ||
| 72 | + // "input_placeholder": "请输入补充信息" | ||
| 73 | + // }, | ||
| 74 | + // { | ||
| 75 | + // "title": "成人组", | ||
| 76 | + // "value": "成人组", | ||
| 77 | + // "checked": false, | ||
| 78 | + // "desc_url": "", | ||
| 79 | + // "is_input": false, | ||
| 80 | + // "desc_text": "", | ||
| 81 | + // "desc_type": "", | ||
| 82 | + // "desc_btn_name": "", | ||
| 83 | + // "input_required": false, | ||
| 84 | + // "input_placeholder": "请输入补充信息" | ||
| 85 | + // }, | ||
| 86 | + // { | ||
| 87 | + // "title": "老年组", | ||
| 88 | + // "value": "老年组", | ||
| 89 | + // "checked": false, | ||
| 90 | + // "desc_url": "", | ||
| 91 | + // "is_input": false, | ||
| 92 | + // "desc_text": "", | ||
| 93 | + // "desc_type": "", | ||
| 94 | + // "desc_btn_name": "", | ||
| 95 | + // "input_required": false, | ||
| 96 | + // "input_placeholder": "请输入补充信息" | ||
| 97 | + // } | ||
| 98 | + // ], | ||
| 99 | + // "disabled": false, | ||
| 100 | + // "field_id": 799497, | ||
| 101 | + // "required": true, | ||
| 102 | + // "data_type": "text", | ||
| 103 | + // "direction": "vertical", | ||
| 104 | + // "field_name": "field_6", | ||
| 105 | + // "option_map": { | ||
| 106 | + // "少年组": { | ||
| 107 | + // "title": "少年组", | ||
| 108 | + // "value": "少年组", | ||
| 109 | + // "checked": false, | ||
| 110 | + // "desc_url": "", | ||
| 111 | + // "is_input": false, | ||
| 112 | + // "desc_text": "", | ||
| 113 | + // "desc_type": "", | ||
| 114 | + // "desc_btn_name": "", | ||
| 115 | + // "input_required": false, | ||
| 116 | + // "input_placeholder": "请输入补充信息" | ||
| 117 | + // }, | ||
| 118 | + // "成人组": { | ||
| 119 | + // "title": "成人组", | ||
| 120 | + // "value": "成人组", | ||
| 121 | + // "checked": false, | ||
| 122 | + // "desc_url": "", | ||
| 123 | + // "is_input": false, | ||
| 124 | + // "desc_text": "", | ||
| 125 | + // "desc_type": "", | ||
| 126 | + // "desc_btn_name": "", | ||
| 127 | + // "input_required": false, | ||
| 128 | + // "input_placeholder": "请输入补充信息" | ||
| 129 | + // }, | ||
| 130 | + // "老年组": { | ||
| 131 | + // "title": "老年组", | ||
| 132 | + // "value": "老年组", | ||
| 133 | + // "checked": false, | ||
| 134 | + // "desc_url": "", | ||
| 135 | + // "is_input": false, | ||
| 136 | + // "desc_text": "", | ||
| 137 | + // "desc_type": "", | ||
| 138 | + // "desc_btn_name": "", | ||
| 139 | + // "input_required": false, | ||
| 140 | + // "input_placeholder": "请输入补充信息" | ||
| 141 | + // } | ||
| 142 | + // }, | ||
| 143 | + // "interaction_type": "h5edit", | ||
| 144 | + // "default": "" | ||
| 145 | + // }, | ||
| 146 | + { | ||
| 147 | + "tag": "input", | ||
| 148 | + "name": "input_21", | ||
| 149 | + "index": 2, | ||
| 150 | + "label": "物品描述", | ||
| 151 | + "unique": false, | ||
| 152 | + "default": "", | ||
| 153 | + "disabled": false, | ||
| 154 | + "field_id": 7985071, | ||
| 155 | + "readonly": false, | ||
| 156 | + "required": false, | ||
| 157 | + "data_type": "text", | ||
| 158 | + "field_name": "field_21", | ||
| 159 | + "placeholder": "请输入", | ||
| 160 | + "is_camera_scan": false, | ||
| 161 | + "camera_scan_type": "", | ||
| 162 | + "interaction_type": "h5edit", | ||
| 163 | + "is_edit_camera_scan_result": false | ||
| 164 | + }, | ||
| 165 | + // { | ||
| 166 | + // "tag": "radio", | ||
| 167 | + // "name": "radio_3", | ||
| 168 | + // "note": "", | ||
| 169 | + // "index": 3, | ||
| 170 | + // "label": "单选框", | ||
| 171 | + // "options": [ | ||
| 172 | + // { | ||
| 173 | + // "title": "选项标题1", | ||
| 174 | + // "value": "选项标题1", | ||
| 175 | + // "checked": true, | ||
| 176 | + // "desc_url": "", | ||
| 177 | + // "is_input": false, | ||
| 178 | + // "desc_text": "", | ||
| 179 | + // "desc_type": "", | ||
| 180 | + // "desc_btn_name": "", | ||
| 181 | + // "input_required": false, | ||
| 182 | + // "input_placeholder": "请输入补充信息" | ||
| 183 | + // }, | ||
| 184 | + // { | ||
| 185 | + // "title": "选项标题2", | ||
| 186 | + // "value": "选项标题2", | ||
| 187 | + // "checked": false, | ||
| 188 | + // "desc_url": "", | ||
| 189 | + // "is_input": false, | ||
| 190 | + // "desc_text": "", | ||
| 191 | + // "desc_type": "", | ||
| 192 | + // "desc_btn_name": "", | ||
| 193 | + // "input_required": false, | ||
| 194 | + // "input_placeholder": "请输入补充信息" | ||
| 195 | + // } | ||
| 196 | + // ], | ||
| 197 | + // "disabled": false, | ||
| 198 | + // "field_id": 798510, | ||
| 199 | + // "required": false, | ||
| 200 | + // "data_type": "text", | ||
| 201 | + // "direction": "vertical", | ||
| 202 | + // "field_name": "field_4", | ||
| 203 | + // "option_map": { | ||
| 204 | + // "选项标题1": { | ||
| 205 | + // "title": "选项标题1", | ||
| 206 | + // "value": "选项标题1", | ||
| 207 | + // "checked": true, | ||
| 208 | + // "desc_url": "", | ||
| 209 | + // "is_input": false, | ||
| 210 | + // "desc_text": "", | ||
| 211 | + // "desc_type": "", | ||
| 212 | + // "desc_btn_name": "", | ||
| 213 | + // "input_required": false, | ||
| 214 | + // "input_placeholder": "请输入补充信息" | ||
| 215 | + // }, | ||
| 216 | + // "选项标题2": { | ||
| 217 | + // "title": "选项标题2", | ||
| 218 | + // "value": "选项标题2", | ||
| 219 | + // "checked": false, | ||
| 220 | + // "desc_url": "", | ||
| 221 | + // "is_input": false, | ||
| 222 | + // "desc_text": "", | ||
| 223 | + // "desc_type": "", | ||
| 224 | + // "desc_btn_name": "", | ||
| 225 | + // "input_required": false, | ||
| 226 | + // "input_placeholder": "请输入补充信息" | ||
| 227 | + // } | ||
| 228 | + // }, | ||
| 229 | + // "interaction_type": "h5edit", | ||
| 230 | + // "default": "选项标题1" | ||
| 231 | + // }, | ||
| 232 | + // { | ||
| 233 | + // "tag": "datetime", | ||
| 234 | + // "name": "datetime_4", | ||
| 235 | + // "index": 4, | ||
| 236 | + // "label": "日期时间", | ||
| 237 | + // "default": "", | ||
| 238 | + // "disabled": false, | ||
| 239 | + // "field_id": 798512, | ||
| 240 | + // "readonly": false, | ||
| 241 | + // "required": false, | ||
| 242 | + // "data_type": "text", | ||
| 243 | + // "field_name": "field_5", | ||
| 244 | + // "placeholder": "请选择", | ||
| 245 | + // "data_maxvalue": "", | ||
| 246 | + // "data_minvalue": "", | ||
| 247 | + // "data_dateformat": "YYYY-MM-DD HH:mm:ss", | ||
| 248 | + // "interaction_type": "h5edit" | ||
| 249 | + // }, | ||
| 250 | + // { | ||
| 251 | + // "tag": "email", | ||
| 252 | + // "name": "email_5", | ||
| 253 | + // "index": 5, | ||
| 254 | + // "label": "邮箱", | ||
| 255 | + // "unique": false, | ||
| 256 | + // "default": "", | ||
| 257 | + // "disabled": false, | ||
| 258 | + // "field_id": 799499, | ||
| 259 | + // "readonly": false, | ||
| 260 | + // "required": true, | ||
| 261 | + // "data_type": "text", | ||
| 262 | + // "field_name": "field_7", | ||
| 263 | + // "placeholder": "请输入", | ||
| 264 | + // "interaction_type": "h5edit" | ||
| 265 | + // }, | ||
| 266 | + // { | ||
| 267 | + // "tag": "gender", | ||
| 268 | + // "name": "gender_6", | ||
| 269 | + // "note": "", | ||
| 270 | + // "index": 6, | ||
| 271 | + // "label": "性别", | ||
| 272 | + // "options": [ | ||
| 273 | + // { | ||
| 274 | + // "title": "男", | ||
| 275 | + // "value": "男", | ||
| 276 | + // "checked": false, | ||
| 277 | + // "desc_url": "", | ||
| 278 | + // "is_input": false, | ||
| 279 | + // "desc_text": "", | ||
| 280 | + // "desc_type": "", | ||
| 281 | + // "desc_btn_name": "", | ||
| 282 | + // "input_required": false, | ||
| 283 | + // "input_placeholder": "请输入补充信息" | ||
| 284 | + // }, | ||
| 285 | + // { | ||
| 286 | + // "title": "女", | ||
| 287 | + // "value": "女", | ||
| 288 | + // "checked": false, | ||
| 289 | + // "desc_url": "", | ||
| 290 | + // "is_input": false, | ||
| 291 | + // "desc_text": "", | ||
| 292 | + // "desc_type": "", | ||
| 293 | + // "desc_btn_name": "", | ||
| 294 | + // "input_required": false, | ||
| 295 | + // "input_placeholder": "请输入补充信息" | ||
| 296 | + // } | ||
| 297 | + // ], | ||
| 298 | + // "disabled": false, | ||
| 299 | + // "field_id": 799501, | ||
| 300 | + // "required": true, | ||
| 301 | + // "data_type": "text", | ||
| 302 | + // "direction": "vertical", | ||
| 303 | + // "field_name": "field_8", | ||
| 304 | + // "option_map": { | ||
| 305 | + // "女": { | ||
| 306 | + // "title": "女", | ||
| 307 | + // "value": "女", | ||
| 308 | + // "checked": false, | ||
| 309 | + // "desc_url": "", | ||
| 310 | + // "is_input": false, | ||
| 311 | + // "desc_text": "", | ||
| 312 | + // "desc_type": "", | ||
| 313 | + // "desc_btn_name": "", | ||
| 314 | + // "input_required": false, | ||
| 315 | + // "input_placeholder": "请输入补充信息" | ||
| 316 | + // }, | ||
| 317 | + // "男": { | ||
| 318 | + // "title": "男", | ||
| 319 | + // "value": "男", | ||
| 320 | + // "checked": false, | ||
| 321 | + // "desc_url": "", | ||
| 322 | + // "is_input": false, | ||
| 323 | + // "desc_text": "", | ||
| 324 | + // "desc_type": "", | ||
| 325 | + // "desc_btn_name": "", | ||
| 326 | + // "input_required": false, | ||
| 327 | + // "input_placeholder": "请输入补充信息" | ||
| 328 | + // } | ||
| 329 | + // }, | ||
| 330 | + // "interaction_type": "h5edit" | ||
| 331 | + // }, | ||
| 332 | + { | ||
| 333 | + "tag": "name", | ||
| 334 | + "name": "name_71", | ||
| 335 | + "index": 7, | ||
| 336 | + "label": "序列号", | ||
| 337 | + "unique": false, | ||
| 338 | + "default": "", | ||
| 339 | + "disabled": false, | ||
| 340 | + "field_id": 7995031, | ||
| 341 | + "readonly": false, | ||
| 342 | + "required": true, | ||
| 343 | + "data_type": "text", | ||
| 344 | + "field_name": "field_91", | ||
| 345 | + "placeholder": "请输入", | ||
| 346 | + "interaction_type": "h5edit" | ||
| 347 | + }, | ||
| 348 | +]*/ | ||
| 349 | + | ||
| 350 | +const listData = ref([]); | ||
| 351 | +const formData = ref([]); | ||
| 352 | + | ||
| 353 | +// 格式化表单数据结构 | ||
| 354 | +const formatData = (data) => { | ||
| 355 | + const arr = []; | ||
| 356 | + data.forEach((field) => { | ||
| 357 | + const { interaction_type, data_type, field_id, field_name, ...component_props } = field; | ||
| 358 | + component_props.is_field_group = true; // 集合标识 | ||
| 359 | + // 生成组件属性 | ||
| 360 | + const temp = { | ||
| 361 | + key: field_name, | ||
| 362 | + value: component_props.default ? component_props.default : "", | ||
| 363 | + component_props, | ||
| 364 | + }; | ||
| 365 | + arr.push(temp); | ||
| 366 | + }); | ||
| 367 | + return arr; | ||
| 368 | +}; | ||
| 369 | + | ||
| 370 | +const onRemove = (idx) => { // 移除列表item | ||
| 371 | + listData.value.splice(idx, 1) | ||
| 372 | +} | ||
| 373 | + | ||
| 374 | +// const gender_value = ref(props.item.component_props.default); | ||
| 375 | +const $route = useRoute(); | ||
| 376 | + | ||
| 377 | +onMounted(async () => { | ||
| 378 | + const form_data = testData; | ||
| 379 | + let page_form = []; | ||
| 380 | + form_data.forEach((element) => { | ||
| 381 | + page_form.push(element); | ||
| 382 | + }); | ||
| 383 | + formData.value = formatData(page_form); | ||
| 384 | + // 生成自定义组件 | ||
| 385 | + createComponentType(formData.value); | ||
| 386 | + | ||
| 387 | + listData.value.push(formData.value) | ||
| 388 | + // gender_value.value = props.item.component_props.default ? props.item.component_props.default : ''; | ||
| 389 | + // // 发送自定义数据结构 | ||
| 390 | + // props.item.value = { key: props.item.key, value: gender_value.value, type: "gender" }; | ||
| 391 | + // emit("active", props.item.value); | ||
| 392 | +}); | ||
| 393 | + | ||
| 394 | +const emit = defineEmits(["active"]); | ||
| 395 | + | ||
| 396 | +const onChange = (item) => { | ||
| 397 | + // // 发送自定义数据结构 | ||
| 398 | + // props.item.value = { key: props.item.key, value: gender_value.value, type: "gender" }; | ||
| 399 | + // emit("active", props.item.value); | ||
| 400 | +} | ||
| 401 | + | ||
| 402 | +// 操作绑定自定义字段回调 | ||
| 403 | +const onActive = (item) => { | ||
| 404 | + emit("active", item); | ||
| 405 | +}; | ||
| 406 | + | ||
| 407 | +const addData = async () => { | ||
| 408 | + const form_data = testData; | ||
| 409 | + let page_form = []; | ||
| 410 | + form_data.forEach((element) => { | ||
| 411 | + page_form.push(element); | ||
| 412 | + }); | ||
| 413 | + formData.value = formatData(page_form); | ||
| 414 | + // 生成自定义组件 | ||
| 415 | + createComponentType(formData.value); | ||
| 416 | + | ||
| 417 | + listData.value.push(formData.value) | ||
| 418 | +} | ||
| 419 | +</script> | ||
| 420 | + | ||
| 421 | +<style lang="less" scoped> | ||
| 422 | +.group-field-page { | ||
| 423 | + .label { | ||
| 424 | + padding: 1rem 1rem 0 1rem; | ||
| 425 | + font-size: 0.9rem; | ||
| 426 | + font-weight: bold; | ||
| 427 | + span { | ||
| 428 | + color: red; | ||
| 429 | + } | ||
| 430 | + } | ||
| 431 | + .note { | ||
| 432 | + font-size: 0.9rem; | ||
| 433 | + margin-left: 1rem; | ||
| 434 | + color: gray; | ||
| 435 | + padding-bottom: 0.5rem; | ||
| 436 | + white-space: pre-wrap; | ||
| 437 | + } | ||
| 438 | + .radio-wrapper { | ||
| 439 | + border: 1px solid #eaeaea; | ||
| 440 | + border-radius: 0.25rem; | ||
| 441 | + padding: 0.25rem 0.5rem; | ||
| 442 | + margin-bottom: 0.25rem; | ||
| 443 | + } | ||
| 444 | +} | ||
| 445 | +</style> |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-08-29 14:31:20 | 2 | * @Date: 2022-08-29 14:31:20 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-02-01 11:21:00 | 4 | + * @LastEditTime: 2024-05-27 17:47:52 |
| 5 | * @FilePath: /data-table/src/components/NameField/index.vue | 5 | * @FilePath: /data-table/src/components/NameField/index.vue |
| 6 | * @Description: 姓名输入框 | 6 | * @Description: 姓名输入框 |
| 7 | --> | 7 | --> |
| 8 | <template> | 8 | <template> |
| 9 | <div v-if="HideShow" class="name-field-page"> | 9 | <div v-if="HideShow" class="name-field-page"> |
| 10 | - <div class="label"> | 10 | + <div :class="[isGroup ? 'group-label' : 'label']"> |
| 11 | <span v-if="item.component_props.required"> *</span> | 11 | <span v-if="item.component_props.required"> *</span> |
| 12 | {{ item.component_props.label }} | 12 | {{ item.component_props.label }} |
| 13 | </div> | 13 | </div> |
| ... | @@ -29,10 +29,17 @@ | ... | @@ -29,10 +29,17 @@ |
| 29 | const props = defineProps({ | 29 | const props = defineProps({ |
| 30 | item: Object, | 30 | item: Object, |
| 31 | }); | 31 | }); |
| 32 | + | ||
| 32 | // 隐藏显示 | 33 | // 隐藏显示 |
| 33 | const HideShow = computed(() => { | 34 | const HideShow = computed(() => { |
| 34 | return !props.item.component_props.disabled | 35 | return !props.item.component_props.disabled |
| 35 | -}) | 36 | +}); |
| 37 | + | ||
| 38 | +// 集合组标识 | ||
| 39 | +const isGroup = computed(() => { | ||
| 40 | + return props.item.component_props.is_field_group | ||
| 41 | +}); | ||
| 42 | + | ||
| 36 | onMounted(() => { | 43 | onMounted(() => { |
| 37 | props.item.value = props.item.component_props.default; | 44 | props.item.value = props.item.component_props.default; |
| 38 | }) | 45 | }) |
| ... | @@ -48,6 +55,20 @@ onMounted(() => { | ... | @@ -48,6 +55,20 @@ onMounted(() => { |
| 48 | color: red; | 55 | color: red; |
| 49 | } | 56 | } |
| 50 | } | 57 | } |
| 58 | + | ||
| 59 | + .group-label { | ||
| 60 | + padding: 0.75rem 0 0.75rem 1rem; | ||
| 61 | + font-size: 0.9rem; | ||
| 62 | + font-weight: bold; | ||
| 63 | + background-color: #f9f9f9; | ||
| 64 | + color: #666; | ||
| 65 | + border-top: 1px solid #eee; | ||
| 66 | + border-bottom: 1px solid #eee; | ||
| 67 | + | ||
| 68 | + span { | ||
| 69 | + color: red; | ||
| 70 | + } | ||
| 71 | + } | ||
| 51 | } | 72 | } |
| 52 | 73 | ||
| 53 | :deep(.van-field__body) { | 74 | :deep(.van-field__body) { | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-08-30 11:34:19 | 2 | * @Date: 2022-08-30 11:34:19 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-03-28 16:19:08 | 4 | + * @LastEditTime: 2024-05-27 14:27:25 |
| 5 | * @FilePath: /data-table/src/components/RadioField/index.vue | 5 | * @FilePath: /data-table/src/components/RadioField/index.vue |
| 6 | * @Description: 单项选择控件 | 6 | * @Description: 单项选择控件 |
| 7 | --> | 7 | --> | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-08-29 14:31:20 | 2 | * @Date: 2022-08-29 14:31:20 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-05-25 18:29:39 | 4 | + * @LastEditTime: 2024-05-28 10:05:08 |
| 5 | * @FilePath: /data-table/src/components/TextField/index.vue | 5 | * @FilePath: /data-table/src/components/TextField/index.vue |
| 6 | * @Description: 单行文本输入框(微信扫描功能) | 6 | * @Description: 单行文本输入框(微信扫描功能) |
| 7 | --> | 7 | --> |
| 8 | <template> | 8 | <template> |
| 9 | <div v-if="HideShow" class="text-field-page"> | 9 | <div v-if="HideShow" class="text-field-page"> |
| 10 | - <div class="label"> | 10 | + <div :class="[isGroup ? 'group-label' : 'label']"> |
| 11 | <span v-if="item.component_props.required"> *</span> | 11 | <span v-if="item.component_props.required"> *</span> |
| 12 | {{ item.component_props.label }} | 12 | {{ item.component_props.label }} |
| 13 | </div> | 13 | </div> |
| ... | @@ -30,10 +30,16 @@ import wx from 'weixin-js-sdk' | ... | @@ -30,10 +30,16 @@ import wx from 'weixin-js-sdk' |
| 30 | const props = defineProps({ | 30 | const props = defineProps({ |
| 31 | item: Object, | 31 | item: Object, |
| 32 | }); | 32 | }); |
| 33 | + | ||
| 33 | // 隐藏显示 | 34 | // 隐藏显示 |
| 34 | const HideShow = computed(() => { | 35 | const HideShow = computed(() => { |
| 35 | return !props.item.component_props.disabled | 36 | return !props.item.component_props.disabled |
| 36 | -}) | 37 | +}); |
| 38 | + | ||
| 39 | +// 集合组标识 | ||
| 40 | +const isGroup = computed(() => { | ||
| 41 | + return props.item.component_props.is_field_group | ||
| 42 | +}); | ||
| 37 | 43 | ||
| 38 | const $route = useRoute(); | 44 | const $route = useRoute(); |
| 39 | // 默认识别类型 | 45 | // 默认识别类型 |
| ... | @@ -92,6 +98,21 @@ const clickRightIcon = async () => { | ... | @@ -92,6 +98,21 @@ const clickRightIcon = async () => { |
| 92 | span { | 98 | span { |
| 93 | color: red; | 99 | color: red; |
| 94 | } | 100 | } |
| 101 | + } | ||
| 102 | + | ||
| 103 | + .group-label { | ||
| 104 | + padding: 0.75rem 0 0.75rem 1rem; | ||
| 105 | + font-size: 0.9rem; | ||
| 106 | + font-weight: bold; | ||
| 107 | + background-color: #f9f9f9; | ||
| 108 | + color: #666; | ||
| 109 | + border-top: 1px solid #eee; | ||
| 110 | + border-bottom: 1px solid #eee; | ||
| 111 | + | ||
| 112 | + span { | ||
| 113 | + color: red; | ||
| 114 | + } | ||
| 115 | + } | ||
| 95 | 116 | ||
| 96 | .note-wrapper { | 117 | .note-wrapper { |
| 97 | font-size: 0.9rem; | 118 | font-size: 0.9rem; |
| ... | @@ -101,7 +122,6 @@ const clickRightIcon = async () => { | ... | @@ -101,7 +122,6 @@ const clickRightIcon = async () => { |
| 101 | padding-top: 0.25rem; | 122 | padding-top: 0.25rem; |
| 102 | white-space: pre-wrap; | 123 | white-space: pre-wrap; |
| 103 | } | 124 | } |
| 104 | - } | ||
| 105 | } | 125 | } |
| 106 | 126 | ||
| 107 | :deep(.van-field__body) { | 127 | :deep(.van-field__body) { | ... | ... |
| ... | @@ -31,6 +31,7 @@ import NameField from '@/components/NameField/index.vue'; | ... | @@ -31,6 +31,7 @@ import NameField from '@/components/NameField/index.vue'; |
| 31 | import GenderField from '@/components/GenderField/index.vue'; | 31 | import GenderField from '@/components/GenderField/index.vue'; |
| 32 | import AppointmentField from '@/components/AppointmentField/index.vue'; | 32 | import AppointmentField from '@/components/AppointmentField/index.vue'; |
| 33 | import CustomField from '@/components/CustomField/index.vue'; | 33 | import CustomField from '@/components/CustomField/index.vue'; |
| 34 | +import GroupField from '@/components/GroupField/index.vue'; | ||
| 34 | 35 | ||
| 35 | /** | 36 | /** |
| 36 | * 生成自定义组件类型 | 37 | * 生成自定义组件类型 |
| ... | @@ -61,6 +62,7 @@ import CustomField from '@/components/CustomField/index.vue'; | ... | @@ -61,6 +62,7 @@ import CustomField from '@/components/CustomField/index.vue'; |
| 61 | * @type name 姓名控件 NameField | 62 | * @type name 姓名控件 NameField |
| 62 | * @type gender 性别控件 GenderField | 63 | * @type gender 性别控件 GenderField |
| 63 | * @type appointment 预约控件 AppointmentField | 64 | * @type appointment 预约控件 AppointmentField |
| 65 | + * @type group 组集合输入控件 GroupField | ||
| 64 | */ | 66 | */ |
| 65 | export function createComponentType(data) { | 67 | export function createComponentType(data) { |
| 66 | // 判断类型和使用组件 | 68 | // 判断类型和使用组件 |
| ... | @@ -189,5 +191,9 @@ export function createComponentType(data) { | ... | @@ -189,5 +191,9 @@ export function createComponentType(data) { |
| 189 | item.name = item.key; | 191 | item.name = item.key; |
| 190 | item.component = CustomField; | 192 | item.component = CustomField; |
| 191 | } | 193 | } |
| 194 | + if (item.component_props.tag === 'group') { | ||
| 195 | + item.name = item.key; | ||
| 196 | + item.component = GroupField; | ||
| 197 | + } | ||
| 192 | }) | 198 | }) |
| 193 | } | 199 | } | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-07-18 10:22:22 | 2 | * @Date: 2022-07-18 10:22:22 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-05-13 14:24:11 | 4 | + * @LastEditTime: 2024-05-28 10:39:05 |
| 5 | * @FilePath: /data-table/src/views/index.vue | 5 | * @FilePath: /data-table/src/views/index.vue |
| 6 | * @Description: 首页 | 6 | * @Description: 首页 |
| 7 | --> | 7 | --> |
| ... | @@ -240,6 +240,59 @@ onMounted(async () => { | ... | @@ -240,6 +240,59 @@ onMounted(async () => { |
| 240 | visible: !page_commit.invisible, | 240 | visible: !page_commit.invisible, |
| 241 | }; | 241 | }; |
| 242 | } | 242 | } |
| 243 | + // TODO:待完善,集合组保存的字段和值怎么处理,都是单条数据都要合并到相应的 group_field_name 下面? | ||
| 244 | + // page_form.unshift({ | ||
| 245 | + // data_type : "text", | ||
| 246 | + // default : "", | ||
| 247 | + // disabled : false, | ||
| 248 | + // field_id : 1414832, | ||
| 249 | + // field_name : "field_4", | ||
| 250 | + // index : 41, | ||
| 251 | + // interaction_type : "h5edit", | ||
| 252 | + // label : "物品详情", | ||
| 253 | + // name : "name_41", | ||
| 254 | + // placeholder : "请输入", | ||
| 255 | + // readonly : false, | ||
| 256 | + // required : false, | ||
| 257 | + // tag : "group", | ||
| 258 | + // unique : false, | ||
| 259 | + // field_groups: [{ | ||
| 260 | + // "tag": "input", | ||
| 261 | + // "name": "input_21", | ||
| 262 | + // "index": 2, | ||
| 263 | + // "label": "物品描述", | ||
| 264 | + // "unique": false, | ||
| 265 | + // "default": "", | ||
| 266 | + // "disabled": false, | ||
| 267 | + // "field_id": 7985071, | ||
| 268 | + // "readonly": false, | ||
| 269 | + // "required": false, | ||
| 270 | + // "data_type": "text", | ||
| 271 | + // "field_name": "field_21", | ||
| 272 | + // "placeholder": "请输入", | ||
| 273 | + // "is_camera_scan": false, | ||
| 274 | + // "camera_scan_type": "", | ||
| 275 | + // "interaction_type": "h5edit", | ||
| 276 | + // "is_edit_camera_scan_result": false, | ||
| 277 | + // "group_field_name" : "field_4", | ||
| 278 | + // },{ | ||
| 279 | + // "tag": "name", | ||
| 280 | + // "name": "name_71", | ||
| 281 | + // "index": 7, | ||
| 282 | + // "label": "序列号", | ||
| 283 | + // "unique": false, | ||
| 284 | + // "default": "", | ||
| 285 | + // "disabled": false, | ||
| 286 | + // "field_id": 7995031, | ||
| 287 | + // "readonly": false, | ||
| 288 | + // "required": true, | ||
| 289 | + // "data_type": "text", | ||
| 290 | + // "field_name": "field_91", | ||
| 291 | + // "placeholder": "请输入", | ||
| 292 | + // "interaction_type": "h5edit", | ||
| 293 | + // "group_field_name" : "field_4", | ||
| 294 | + // },] | ||
| 295 | + // }); | ||
| 243 | formData.value = formatData(page_form); | 296 | formData.value = formatData(page_form); |
| 244 | // TODO:再次提交测试, 需要获取原来表单数据 | 297 | // TODO:再次提交测试, 需要获取原来表单数据 |
| 245 | // formData.value.forEach((item) => { | 298 | // formData.value.forEach((item) => { |
| ... | @@ -315,7 +368,7 @@ onMounted(async () => { | ... | @@ -315,7 +368,7 @@ onMounted(async () => { |
| 315 | }, | 368 | }, |
| 316 | ]; | 369 | ]; |
| 317 | // 生成自定义组件 | 370 | // 生成自定义组件 |
| 318 | - createComponentType(mockData.value); | 371 | + // createComponentType(mockData.value); |
| 319 | createComponentType(formData.value); | 372 | createComponentType(formData.value); |
| 320 | // 过期时间显示 | 373 | // 过期时间显示 |
| 321 | notice_text.value = `表单报名将在 ${formSetting.value.sjsj_end_time} 后结束`; | 374 | notice_text.value = `表单报名将在 ${formSetting.value.sjsj_end_time} 后结束`; | ... | ... |
-
Please register or login to post a comment