Commit 0454a6e3 by 李嘉林

自定义列表组件

parent 10dfbe6a
...@@ -84,6 +84,10 @@ console.log(process.env,'-----------------config------') ...@@ -84,6 +84,10 @@ console.log(process.env,'-----------------config------')
getVehicleNumber(number) { getVehicleNumber(number) {
return requestGET(`${process.env.OLSHOP_URL}/user/generatorUniqueCodeByCarDynamic?numberPlate=${encodeURIComponent(number)}`) return requestGET(`${process.env.OLSHOP_URL}/user/generatorUniqueCodeByCarDynamic?numberPlate=${encodeURIComponent(number)}`)
}, },
// 获取数据源
outDataSourceData(data) {
return requestPOST(`${process.env.OLSHOP_URL}/outDataSource/api`,data)
},
} }
\ No newline at end of file
<template> <template>
<!-- 自定义列表 --> <!-- 自定义列表 -->
<div class="customList" :style="{'padding':padding+'px','margin': margin+'px','border-radius': borderRadius + 'px','background':backgroundColor}"> <div class="customList" v-if="loaded && comDataList.length>0" :style="{'padding':padding+'px','margin': margin+'px','border-radius': borderRadius + 'px','background':backgroundColor}">
<div v-for="(item,index) in 4" :key="index" @click="itemClick(item,index)"> <div v-for="(item,index) in comDataList" :key="index" @click="itemClick(item,index)">
<rich-text :nodes="comStr"></rich-text> <rich-text :nodes="item.comStr"></rich-text>
</div> </div>
</div> </div>
</template> </template>
...@@ -20,6 +20,7 @@ function compiler(str, data) { ...@@ -20,6 +20,7 @@ function compiler(str, data) {
return str; return str;
} }
import Vue from "vue"; import Vue from "vue";
import index from "@/api/index";
export default { export default {
name: "custom-list", name: "custom-list",
props: { props: {
...@@ -35,7 +36,9 @@ export default { ...@@ -35,7 +36,9 @@ export default {
}, },
}, },
data() { data() {
return {}; return {
loaded: false,
};
}, },
computed:{ computed:{
comStr(){ comStr(){
...@@ -53,13 +56,50 @@ export default { ...@@ -53,13 +56,50 @@ export default {
backgroundColor() { backgroundColor() {
return this.datas.componentData.backgroundColor; return this.datas.componentData.backgroundColor;
}, },
showCont() {
return this.datas.componentData.showCont;
},
dataSourceObj() {
return this.datas.componentData.dataSourceObj;
},
comDataList: {
get() {
return this.datas.componentData.comDataList || [];
},
set(newValue) {
this.datas.componentData.comDataList = newValue;
},
},
},
created() {
this.getList();
}, },
created() {},
mounted() {}, mounted() {},
methods:{ methods:{
itemClick(item,index){ itemClick(item,index){
eval(this.datas.componentData.comMethods) eval(this.datas.componentData.comMethods)
} },
getList(){
let query = {
...this.dataSourceObj,
current: 1,
size: this.showCont,
}
index.outDataSourceData(query).then(res=>{
if(res.data.code == 200){
this.comDataList = res.data.data.records || [];
if(this.comDataList && this.comDataList.length>0){
this.comDataList.forEach((item,index)=>{
item.comStr = compiler(this.datas.componentData.comStr,item);
})
}
}
this.loaded = true;
})
},
getComStr(item){
compiler(this.datas.componentData.comStr,item);
},
}, },
components: {}, components: {},
}; };
......
...@@ -93,9 +93,9 @@ ...@@ -93,9 +93,9 @@
<div v-if="item.componentCode == 'wo-timeout' && item.componentInfo.visible == 1"> <div v-if="item.componentCode == 'wo-timeout' && item.componentInfo.visible == 1">
<wo-timeout :datas="item"></wo-timeout> <wo-timeout :datas="item"></wo-timeout>
</div> </div>
<!-- <div v-if="item.componentCode == 'custom-list' && item.componentInfo.visible == 1"> <div v-if="item.componentCode == 'custom-list' && item.componentInfo.visible == 1">
<custom-list :datas="item"></custom-list> <custom-list :datas="item"></custom-list>
</div> --> </div>
</div> </div>
<bottomCont></bottomCont> <bottomCont></bottomCont>
......
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 to comment