11<template >
2- <div v-if =" this.selectItem && Object.keys(this.selectItem ).length > 0" >
2+ <div v-if =" this.selectWg && Object.keys(this.selectWg ).length > 0" >
33 <el-form label-position =" top" >
4- <el-form-item label =" 提示内容" v-if =" Object.keys(selectItem .config).indexOf('placeholder')>=0" >
5- <el-input v-model =" selectItem .config.placeholder" ></el-input >
4+ <el-form-item label =" 提示内容" v-if =" Object.keys(selectWg .config).indexOf('placeholder')>=0" >
5+ <el-input v-model =" selectWg .config.placeholder" ></el-input >
66 </el-form-item >
7- <el-form-item label =" 选择控件" v-if =" selectItem .type=='input'" >
8- <el-select v-model =" selectItem .config.apiKey" filterable placeholder =" 请选择" @change =" selectInput" >
9- <el-option v-for =" item in selectItem .config.inputTypes" :key =" item.value" :label =" item.label" :value =" item.value" ></el-option >
7+ <el-form-item label =" 选择控件" v-if =" selectWg .type=='input'" >
8+ <el-select v-model =" selectWg .config.apiKey" filterable placeholder =" 请选择" @change =" selectInput" >
9+ <el-option v-for =" item in selectWg .config.inputTypes" :key =" item.value" :label =" item.label" :value =" item.value" ></el-option >
1010 </el-select >
1111 </el-form-item >
12- <el-form-item label =" 选项" v-if =" Object.keys(selectItem .config).indexOf('options')>=0" >
13- <template v-if =" selectItem .type == ' radio' || (selectItem .type == ' select' &&! selectItem .config .multiple )" >
14- <draggable element =" ul" :list =" selectItem .config.options" :options =" {group:{ name: 'options'} , ghostClass: 'ghost',handle: '.move-icon'}" >
15- <li v-for =" (item, index) in selectItem .config.options" :key =" index" >
12+ <el-form-item label =" 选项" v-if =" Object.keys(selectWg .config).indexOf('options')>=0" >
13+ <template v-if =" selectWg .type == ' radio' || (selectWg .type == ' select' &&! selectWg .config .multiple )" >
14+ <draggable element =" ul" :list =" selectWg .config.options" :options =" {group:'options', ghostClass: 'ghost',handle: '.move-icon'}" >
15+ <li v-for =" (item, index) in selectWg .config.options" :key =" index" >
1616 <div class =" flex align-middle" >
17- <el-input :style =" {'width': selectItem .config.showLabel? '90px': '190px' }" size =" mini" v-model =" item.value" ></el-input >
17+ <el-input :style =" {'width': selectWg .config.showLabel? '90px': '190px' }" size =" mini" v-model =" item.value" ></el-input >
1818 <i class =" el-icon-menu move-icon" ></i >
1919 <i class =" el-icon-delete delect-icon" @click =" handleOptionsRemove(index)" ></i >
2020 </div >
2121 </li >
2222 </draggable >
2323 </template >
2424
25- <template v-if =" selectItem .type == ' checkbox' || (selectItem .type == ' select' && selectItem .config .multiple )" >
26- <draggable element =" ul" :list =" selectItem .config.options" :options =" {group:{ name: 'options'} , ghostClass: 'ghost',handle: '.move-icon'}" >
27- <li v-for =" (item, index) in selectItem .config.options" :key =" index" >
25+ <template v-if =" selectWg .type == ' checkbox' || (selectWg .type == ' select' && selectWg .config .multiple )" >
26+ <draggable element =" ul" :list =" selectWg .config.options" :options =" {group:'options', ghostClass: 'ghost',handle: '.move-icon'}" >
27+ <li v-for =" (item, index) in selectWg .config.options" :key =" index" >
2828 <div class =" flex align-middle" >
29- <el-input :style =" {'width': selectItem .config.showLabel? '90px': '190px' }" size =" mini" v-model =" item.value" ></el-input >
29+ <el-input :style =" {'width': selectWg .config.showLabel? '90px': '190px' }" size =" mini" v-model =" item.value" ></el-input >
3030 <i class =" el-icon-menu move-icon" ></i >
3131 <i class =" el-icon-delete delect-icon" @click =" handleOptionsRemove(index)" ></i >
3232 </div >
3838 </div >
3939 </el-form-item >
4040
41- <template v-if = " selectItem . type === ' imgshow ' " >
42- <el-form-item label = " 图片上传 " >
41+ <el-form-item label = " 图片上传 " >
42+ <template v-if = " selectWg . type === ' imgshow ' " >
4343 <el-upload
4444 class =" avatar-uploader"
4545 action =" https://jsonplaceholder.typicode.com/posts/"
4646 :show-file-list =" false"
4747 :on-success =" handleAvatarSuccess"
4848 :before-upload =" beforeAvatarUpload"
4949 >
50- <img v-if =" selectItem .config.defaultValue" :src =" selectItem .config.defaultValue" class =" avatar" >
50+ <img v-if =" selectWg .config.defaultValue" :src =" selectWg .config.defaultValue" class =" avatar" >
5151 <i v-else class =" el-icon-plus avatar-uploader-icon" ></i >
5252 </el-upload >
53- </el-form-item >
54- </template >
53+ </template >
54+ </el-form-item >
5555 </el-form >
5656 </div >
5757</template >
@@ -63,17 +63,19 @@ export default {
6363 components: {
6464 Draggable
6565 },
66- props: [' selectItem' ],
66+ props: {
67+ selectWg: Object
68+ },
6769 data () {
6870 return {}
6971 },
7072 methods: {
7173 selectInput (val ) {
72- let selectItem = this .selectItem .config .inputTypes .find (item => val === item .value );
73- this .selectItem .config .placeholder = ` 请输入${ selectItem .label } `
74+ let selectWg = this .selectWg .config .inputTypes .find (item => val === item .value );
75+ this .selectWg .config .placeholder = ` 请输入${ selectWg .label } `
7476 },
7577 handleAvatarSuccess (res , file ) {
76- this .selectItem .config .defaultValue = URL .createObjectURL (file .raw );
78+ this .selectWg .config .defaultValue = URL .createObjectURL (file .raw );
7779 },
7880 beforeAvatarUpload (file ) {
7981 const isLt2M = file .size / 1024 / 1024 < 2 ;
@@ -83,21 +85,21 @@ export default {
8385 return isLt2M;
8486 },
8587 handleOptionsRemove (index ) {
86- if (this .selectItem .type === ' grid' ) {
87- this .selectItem .columns .splice (index, 1 )
88+ if (this .selectWg .type === ' grid' ) {
89+ this .selectWg .columns .splice (index, 1 )
8890 } else {
89- this .selectItem .config .options .splice (index, 1 )
91+ this .selectWg .config .options .splice (index, 1 )
9092 }
9193
9294 },
9395 handleAddOption () {
94- if (this .selectItem .config .showLabel ) {
95- this .selectItem .config .options .push ({
96+ if (this .selectWg .config .showLabel ) {
97+ this .selectWg .config .options .push ({
9698 value: ' 新选项' ,
9799 label: ' 新选项'
98100 })
99101 } else {
100- this .selectItem .config .options .push ({
102+ this .selectWg .config .options .push ({
101103 value: ' 新选项'
102104 })
103105 }
0 commit comments