Commit 1cf354ba authored by wcmoon's avatar wcmoon

fix: 图片链接支持多个链接

parent b80f6587
<template> <template>
<base-form <div class="array-form">
:label="property.label" <div class="label">
:watchValue="property.value" <img class="pre-tag" src="../../../assets/images/template/pre-tag.png" />
@changeValue="change" <div class="label-text" :title="property.label">{{ property.label }}</div>
></base-form> </div>
<div class="lists">
<div
class="list"
v-for="(item, index) in array"
:key="index"
>
<input
@change="change"
class="input"
type="text"
v-model="item.value"
:placeholder="'请输入' + property.label"
>
<div class="del" @click="del(index)">
<i class="iconfont iconshanchu-"></i>
</div>
</div>
<div class="add" @click="add">
<i class="iconfont icontianjia"></i>
</div>
</div>
</div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Prop, Vue} from "vue-property-decorator"; import {Component, Prop, Vue, Watch} from "vue-property-decorator";
import BaseForm from "./BaseForm.vue";
import {Property} from "@/plugins/types2"; import {Property} from "@/plugins/types2";
@Component({ @Component
components: {
BaseForm
}
})
export default class ImageUrlForm extends Vue { export default class ImageUrlForm extends Vue {
@Prop() property!: Property; @Prop() property!: Property;
public array = [{
value: ''
}];
@Watch('array')
public arrayChange() {
this.property.value = this.array.map(item => String(item.value));
}
mounted() {
if (!Array.isArray(this.property.value)) return;
this.array = this.property.value.map((value: string) => {
return {value};
})
}
public change(inputValue: string) { public change(inputValue: string) {
this.property.value = inputValue; this.property.value = this.array.map(item => String(item.value));
}
public add() {
this.array.push({
value: ''
})
}
public del(index:number) {
if (this.array.length <= 1) return;
this.array.splice(index, 1);
} }
} }
</script> </script>
<style scoped> <style scoped lang="less">
.label {
display: inline-block;
width: 150px; /* 104 - 18 */
flex-shrink: 0;
height: 44px;
cursor: pointer;
line-height: 44px;
color: #797d84; /* todo ui图颜色不一致 */
font-size: 14px;
font-weight: 300;
position: relative;
}
.pre-tag {
position: absolute;
left: -30px;
top: 14px;
display: none;
}
.array-form {
flex-shrink: 0;
padding-left: 18px;
line-height: 65px;
height: auto;
font-size: 0;
display: flex;
justify-content: flex-start;
align-items: center;
}
.list {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10px;
}
.input {
margin-right: 10px;
margin-top: 0;
flex-shrink: 0;
height: 44px;
width: 770px;
box-sizing: border-box;
min-height: 44px;
border-radius: 4px;
border: 1px solid #DCDFE6; /* todo 边框、背景色ui图颜色不一致 */
outline: none;
padding-left: 24px;
font-size: 14px;
font-weight: 300;
&::-webkit-input-placeholder {
color: #bababa;
}
&::-moz-placeholder {
/* Mozilla Firefox 19+ */
color: #bababa;
}
&:-ms-input-placeholder {
/* Internet Explorer 10+ */
color: #bababa;
}
}
.del {
height: 34px;
display: flex;
color: #eaeaea;
justify-content: center;
align-items: center;
cursor: pointer;
.iconfont {
font-size: 20px;
}
}
.add {
width: 34px;
height: 34px;
border-radius: 50%;
color: white;
display: flex;
background-color: #3f79fe;
justify-content: center;
align-items: center;
cursor: pointer;
margin: 10px 0;
}
</style> </style>
const configModules = { const configModules = {
// 溯源>测试环境 // 溯源>测试环境
"sy_test": { "sy_test": {
CHAIN_BROWSER_URL_PREFIX: '/llq', CHAIN_BROWSER_URL_PREFIX: '/llq/',
INERFACE_URL_PREFIX: '/api', INERFACE_URL_PREFIX: '/api',
/** /**
* 网站入口配置 * 网站入口配置
...@@ -17,7 +17,7 @@ const configModules = { ...@@ -17,7 +17,7 @@ const configModules = {
}, },
// 溯源>正式环境 // 溯源>正式环境
"sy_prod": { "sy_prod": {
CHAIN_BROWSER_URL_PREFIX: '/llq', CHAIN_BROWSER_URL_PREFIX: '/llq/',
INERFACE_URL_PREFIX: '/api', INERFACE_URL_PREFIX: '/api',
// CHAIN_BROWSER_URL_PREFIX: 'http://121.40.18.70:8995/', // CHAIN_BROWSER_URL_PREFIX: 'http://121.40.18.70:8995/',
// INERFACE_URL_PREFIX: 'http://172.16.101.87:46789', // INERFACE_URL_PREFIX: 'http://172.16.101.87:46789',
......
...@@ -125,7 +125,7 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr ...@@ -125,7 +125,7 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr
key: property.parent.title === 'ext' ? property.label : property.key, key: property.parent.title === 'ext' ? property.label : property.key,
label: property.label label: property.label
}; };
} else if (property.type === PropertyType.JSON || property.type === PropertyType.ImageUrl) { } else if (property.type === PropertyType.JSON ) {
return { return {
data: { data: {
format: 'string', format: 'string',
...@@ -196,7 +196,7 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr ...@@ -196,7 +196,7 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr
label: property.label label: property.label
}; };
} }
else if (property.type === PropertyType.TextArray) { else if (property.type === PropertyType.TextArray || property.type === PropertyType.ImageUrl) {
let data = property.value === '' ? [{ let data = property.value === '' ? [{
format: "string", format: "string",
type: "text", type: "text",
...@@ -210,7 +210,7 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr ...@@ -210,7 +210,7 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr
}); });
return { return {
key: property.key, key: property.key,
type: (property.type as PropertyType.TextArray), type: (property.type as (PropertyType.TextArray | PropertyType.ImageUrl)),
data: data, data: data,
label: property.label label: property.label
}; };
...@@ -278,7 +278,7 @@ function formatApiProperty2Local(property: any, parent: Unit): Property { ...@@ -278,7 +278,7 @@ function formatApiProperty2Local(property: any, parent: Unit): Property {
local.value = property.data local.value = property.data
} else if (property.type === PropertyType.Audio) { } else if (property.type === PropertyType.Audio) {
local.value = property.data local.value = property.data
} else if (property.type === PropertyType.TextArray) { } else if (property.type === PropertyType.TextArray || property.type === PropertyType.ImageUrl) {
local.value = property.data.map((item: {value: string}) => item.value); local.value = property.data.map((item: {value: string}) => item.value);
} }
return local; return local;
......
...@@ -3,6 +3,7 @@ import { Message } from 'element-ui'; ...@@ -3,6 +3,7 @@ import { Message } from 'element-ui';
import { CHAIN_BROWSER_URL } from "@/config/URLS"; import { CHAIN_BROWSER_URL } from "@/config/URLS";
function getChainBrowserUrl(hash: string): string { function getChainBrowserUrl(hash: string): string {
console.log(`${CHAIN_BROWSER_URL}${hash}`);
return `${CHAIN_BROWSER_URL}${hash}`; return `${CHAIN_BROWSER_URL}${hash}`;
} }
......
...@@ -90,12 +90,9 @@ ...@@ -90,12 +90,9 @@
</div> </div>
<!-- 图片链接 --> <!-- 图片链接 -->
<div class="info-content" v-if="item2.type === 13"> <div class="info-content" v-if="item2.type === 13">
<div <div class="imgbox" v-for="(item3, index) in item2.data" :key="index">
v-if="item2.data.value" <img :src="item3.value" />
class="imgbox" <div class="ibox" @click="displayPicture(item3.value)">
>
<img :src="item2.data.value" />
<div class="ibox" @click="displayPicture(item2.data.value)">
<i class="iconfont iconfangda"></i> <i class="iconfont iconfangda"></i>
</div> </div>
</div> </div>
...@@ -254,6 +251,10 @@ export default { ...@@ -254,6 +251,10 @@ export default {
element.data = list; element.data = list;
// this.$forceUpdate(); // this.$forceUpdate();
} else if (element.type === 13) {
if (Array.isArray(element.data)) {
element.data = element.data.filter(item => item.value !== '');
}
} }
} }
}, },
......
...@@ -10,7 +10,7 @@ module.exports = { ...@@ -10,7 +10,7 @@ module.exports = {
open: true, open: true,
proxy: { proxy: {
'^/api': { '^/api': {
target: 'http://172.16.101.87:46789', target: 'http://172.16.101.87:46789/',
pathRewrite: { pathRewrite: {
'^/api': '', '^/api': '',
}, },
......
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