Commit fa32a3a1 authored by wcmoon's avatar wcmoon

fix: 添加文本数组类型

parent 1e6738eb
...@@ -49,6 +49,14 @@ export default class JsonForm extends Vue { ...@@ -49,6 +49,14 @@ export default class JsonForm extends Vue {
key: '', key: '',
value: '' value: ''
}]; }];
@Watch('jsons')
jsonsChange() {
// this.property.value =
}
mounted() { mounted() {
console.log(this.property); console.log(this.property);
} }
......
<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" />
:showInput="false" <div class="label-text" :title="property.label">{{ property.label }}</div>
class="array-form" </div>
>
<div class="lists"> <div class="lists">
<div <div
class="list" class="list"
...@@ -12,6 +11,7 @@ ...@@ -12,6 +11,7 @@
:key="index" :key="index"
> >
<input <input
@change="change"
class="input" class="input"
type="text" type="text"
v-model="item.value" v-model="item.value"
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
<i class="iconfont icontianjia"></i> <i class="iconfont icontianjia"></i>
</div> </div>
</div> </div>
</base-form> </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 BaseForm from "./BaseForm.vue";
import {Property} from "@/plugins/types2"; import {Property} from "@/plugins/types2";
@Component({ @Component({
...@@ -40,10 +40,27 @@ import {Property} from "@/plugins/types2"; ...@@ -40,10 +40,27 @@ import {Property} from "@/plugins/types2";
}) })
export default class TextArray extends Vue { export default class TextArray extends Vue {
@Prop() property!: Property; @Prop() property!: Property;
public array = [{ public array = [{
value: '' 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};
})
}
change() {
this.property.value = this.array.map(item => String(item.value));
}
public add() { public add() {
this.array.push({ this.array.push({
value: '' value: ''
...@@ -58,8 +75,33 @@ export default class TextArray extends Vue { ...@@ -58,8 +75,33 @@ export default class TextArray extends Vue {
</script> </script>
<style scoped lang="less"> <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 { .array-form {
flex-shrink: 0;
padding-left: 18px;
line-height: 65px;
height: auto; height: auto;
font-size: 0;
display: flex;
justify-content: flex-start;
align-items: center;
} }
.list { .list {
display: flex; display: flex;
...@@ -73,6 +115,26 @@ export default class TextArray extends Vue { ...@@ -73,6 +115,26 @@ export default class TextArray extends Vue {
flex-shrink: 0; flex-shrink: 0;
height: 44px; height: 44px;
width: 770px; 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 { .del {
......
...@@ -56,7 +56,7 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr ...@@ -56,7 +56,7 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr
}, },
}; };
} else if (property.type === PropertyType.Image) { } else if (property.type === PropertyType.Image) {
let data = {} let data = [];
if (property.value && property.value !== '') { if (property.value && property.value !== '') {
let dd = Array.from(property.value); let dd = Array.from(property.value);
data = dd.map((value: any) => ({ data = dd.map((value: any) => ({
...@@ -66,7 +66,11 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr ...@@ -66,7 +66,11 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr
})) }))
} }
else { else {
data = {} data.push({
format: "hash(hash)",
type: "image",
value: ''
})
} }
return { return {
key: property.key, key: property.key,
...@@ -75,7 +79,7 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr ...@@ -75,7 +79,7 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr
label: property.label label: property.label
}; };
} else if (property.type === PropertyType.File) { } else if (property.type === PropertyType.File) {
let data = {} let data = []
if (property.value) { if (property.value) {
let dd = Array.from(property.value); let dd = Array.from(property.value);
data = (dd as any).map((value: any) => ({ data = (dd as any).map((value: any) => ({
...@@ -85,7 +89,11 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr ...@@ -85,7 +89,11 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr
})) }))
} }
else { else {
data = {} data.push({
format: "hash(hash)",
type: "file",
value: ''
})
} }
return { return {
key: property.key, key: property.key,
...@@ -118,7 +126,7 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr ...@@ -118,7 +126,7 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr
}; };
} else if (property.type === PropertyType.Video) { } else if (property.type === PropertyType.Video) {
let data = {} let data = []
if (property.value) { if (property.value) {
let dd = Array.from(property.value); let dd = Array.from(property.value);
data = (dd as any).map((value: any) => ({ data = (dd as any).map((value: any) => ({
...@@ -128,7 +136,11 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr ...@@ -128,7 +136,11 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr
})) }))
} }
else { else {
data = {} data.push({
format: "hash(hash)",
type: "media",
value: ''
})
} }
return { return {
key: property.key, key: property.key,
...@@ -138,7 +150,7 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr ...@@ -138,7 +150,7 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr
}; };
} }
else if (property.type === PropertyType.Audio) { else if (property.type === PropertyType.Audio) {
let data = {} let data = []
if (property.value) { if (property.value) {
let dd = Array.from(property.value); let dd = Array.from(property.value);
data = (dd as any).map((value: any) => ({ data = (dd as any).map((value: any) => ({
...@@ -148,7 +160,11 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr ...@@ -148,7 +160,11 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr
})) }))
} }
else { else {
data = {} data.push({
format: "hash(hash)",
type: "media",
value: ''
})
} }
return { return {
key: property.key, key: property.key,
...@@ -157,7 +173,26 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr ...@@ -157,7 +173,26 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr
label: property.label label: property.label
}; };
} }
//Video else if (property.type === PropertyType.TextArray) {
let data = (property.value as [string])?.map((item:string) => {
return {
format: "string",
type: "text",
value: item
}
}) || [{
format: "string",
type: "text",
value: ''
}]
return {
key: property.key,
type: (property.type as PropertyType.TextArray),
data: data,
label: property.label
};
}
//Video
else { else {
return { return {
data: { data: {
...@@ -197,6 +232,8 @@ function formatApiProperty2Local(property: any, parent: Unit): Property { ...@@ -197,6 +232,8 @@ 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) {
local.value = property.data.map((item: {value: string}) => item.value);
} }
return local; return local;
} }
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