Commit 1f68bc9c by hank

bug

parent 2518cd19
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
</edit-menu>--> </edit-menu>-->
<div> <div>
<!-- <div>{{schemaData[item.dataKey]}} {{item.dataKey}}</div> -->
<img <img
v-if="item.type === 'image'" v-if="item.type === 'image'"
class="image" class="image"
...@@ -36,7 +37,6 @@ ...@@ -36,7 +37,6 @@
<span class="del-btn" @click="deleteItem(index2, schemaData[item.dataKey])">删除</span> <span class="del-btn" @click="deleteItem(index2, schemaData[item.dataKey])">删除</span>
</div> </div>
<div class="list-item-list" v-for="(item3, index3) in item2" :key="index3"> <div class="list-item-list" v-for="(item3, index3) in item2" :key="index3">
<div v-if="(index3 != 'schemaIndex' && index3 != 'index')"> <div v-if="(index3 != 'schemaIndex' && index3 != 'index')">
<input <input
v-if="item.modelSchema[isSchemaIndex(item2)][index3].type === 'text'" v-if="item.modelSchema[isSchemaIndex(item2)][index3].type === 'text'"
...@@ -46,8 +46,21 @@ ...@@ -46,8 +46,21 @@
v-model="item2[index3]" v-model="item2[index3]"
@keyup="valueChange2()" @keyup="valueChange2()"
/> />
<div>
<img
v-if="item.modelSchema[isSchemaIndex(item2)][index3].type === 'image'"
:src="item2[index3]"
class="edit-input"
/>
<van-uploader
result-type="dataUrl"
@click.native="uploadListItem(item.dataKey,index2, index3)"
:after-read="uploadAfter"
>
<van-button icon="photo" type="info">上传图片</van-button>
</van-uploader>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="create-btn-container"> <div class="create-btn-container">
...@@ -83,11 +96,15 @@ export default { ...@@ -83,11 +96,15 @@ export default {
default: () => {} default: () => {}
} }
}, },
created() {}, created() {
console.log(this.schemaData);
},
data() { data() {
return { return {
activeName: "", activeName: "",
dataKey: "" dataKey: "",
listIndex: "",
itemKey: ""
}; };
}, },
methods: { methods: {
...@@ -97,13 +114,20 @@ export default { ...@@ -97,13 +114,20 @@ export default {
}, },
uploadItem(key) { uploadItem(key) {
// alert(key); // alert(key);
this.itemKey = '',
this.dataKey = key; this.dataKey = key;
}, },
uploadListItem(key, index, itemKey) {
this.dataKey = key;
this.listIndex = index;
this.itemKey = itemKey;
console.log(key, index, itemKey, "dsadadsa");
},
isSchemaIndex(item) { isSchemaIndex(item) {
return item["schemaIndex"] ? item["schemaIndex"] : 0; return item["schemaIndex"] ? item["schemaIndex"] : 0;
}, },
toObj(obj) { toObj(obj) {
console.log(obj) console.log(obj);
return JSON.parse(JSON.stringify(obj)); return JSON.parse(JSON.stringify(obj));
}, },
addItem(item) { addItem(item) {
...@@ -115,22 +139,34 @@ export default { ...@@ -115,22 +139,34 @@ export default {
}); });
this.schemaData[item.dataKey].push(obj); this.schemaData[item.dataKey].push(obj);
} else { } else {
alert('选择类型添加,敬请期待!') alert("选择类型添加,敬请期待!");
} }
console.log(item); console.log(item);
}, },
uploadAfter(file) { uploadAfter(file) {
upload(file.file) upload(file.file)
.then(res => { .then(res => {
this.schemaData[this.dataKey].value = res.data.data; // this.schemaData[this.dataKey].value = res.data.data;
this.valueChange2(); if (this.itemKey) {
this.setSchemaListData(res.data.data);
} else {
this.setSchemaData(res.data.data);
}
}) })
.catch(e => { .catch(e => {
console.log(e); console.log(e);
alert(JSON.stringify(e))
this.$toast("上传失败"); this.$toast("上传失败");
}); });
}, },
setSchemaData(value) {
this.schemaData[this.dataKey].value = value;
this.valueChange2();
},
setSchemaListData(value) {
this.schemaData[this.dataKey][this.listIndex][this.itemKey] = value;
this.valueChange2();
this.itemKey = ''
},
deleteItem(index, arr) { deleteItem(index, arr) {
arr.splice(index, 1); arr.splice(index, 1);
this.$emit("setList", this.schemaData); this.$emit("setList", this.schemaData);
......
...@@ -64,15 +64,6 @@ ...@@ -64,15 +64,6 @@
<div class="content-right"> <div class="content-right">
<div class="title">编辑栏</div> <div class="title">编辑栏</div>
<div class="edit-area"> <div class="edit-area">
<!-- <div class="btn-container " v-if="!templateData.listData.length">
<span
class="editbtn"
v-for="(item, index) in templateData.listData[currentPage]['itemList']"
:key="index"
@dblclick="goEdit(index, item)"
@click="goEdit(index, item)"
>{{item.name}}</span>
</div>-->
<div v-if="false"> <div v-if="false">
<van-collapse v-model="activeName" accordion> <van-collapse v-model="activeName" accordion>
<van-collapse-item <van-collapse-item
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</template> </template>
<script> <script>
// import "swiper/dist/css/swiper.css"; import "swiper/dist/css/swiper.css";
import { swiper, swiperSlide } from "vue-awesome-swiper"; import { swiper, swiperSlide } from "vue-awesome-swiper";
export default { export default {
name: 'mySlider', name: 'mySlider',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment