Commit 72e2aa5b authored by zL's avatar zL

保留data数据格式

parent 175a7ce0
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
:readonly="!operation" :readonly="!operation"
:value="value" :value="value"
@input="emitChange" @input="emitChange"
maxlength="10"
@keyup.enter="$event.target.blur()" @keyup.enter="$event.target.blur()"
:class="{ noMsg: value.trim().length === 0 }" :class="{ noMsg: value.trim().length === 0 }"
:style="getWidth" :style="getWidth"
......
...@@ -42,6 +42,7 @@ function formatL2Local2Api(localL2: Property | Unit): TemplateProperty | TmplSel ...@@ -42,6 +42,7 @@ function formatL2Local2Api(localL2: Property | Unit): TemplateProperty | TmplSel
function formatProperty2Api(property: Property): TemplateProperty | TmplSelectProperty | any { function formatProperty2Api(property: Property): TemplateProperty | TmplSelectProperty | any {
if (property.type === PropertyType.Select) { if (property.type === PropertyType.Select) {
return { return {
key: property.key, key: property.key,
...@@ -93,11 +94,12 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr ...@@ -93,11 +94,12 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr
label: property.label label: property.label
}; };
} else if (property.type === PropertyType.Input) { } else if (property.type === PropertyType.Input) {
// 针对扩展数据ext做保留key的处理 // 保留key,保留data
console.log(property.data);
return { return {
data: { data: {
format: "string", format: property.data ? property.data.format : 'string',
type: "text", type: property.data ? property.data.type : 'text',
value: property.value value: property.value
}, },
type: PropertyType.Input, type: PropertyType.Input,
...@@ -153,10 +155,7 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr ...@@ -153,10 +155,7 @@ function formatProperty2Api(property: Property): TemplateProperty | TmplSelectPr
// 接口json数据转换为本地 // 接口json数据转换为本地
export function formatTemplateApi2Local(apiList: RootUnitType[]): Unit[] { export function formatTemplateApi2Local(apiList: RootUnitType[]): Unit[] {
return apiList.map((rootUnit) => { return apiList.map((rootUnit) => {
console.log(rootUnit);
const unit = new Unit(rootUnit.label); const unit = new Unit(rootUnit.label);
if (rootUnit.data) { if (rootUnit.data) {
unit.children = rootUnit.data.map((l2) => { unit.children = rootUnit.data.map((l2) => {
......
...@@ -9,7 +9,8 @@ import { ...@@ -9,7 +9,8 @@ import {
Breadcrumb, Breadcrumb,
Form, Form,
Button, Button,
Loading Loading,
DatePicker
} from 'element-ui'; } from 'element-ui';
Vue.use(Checkbox); Vue.use(Checkbox);
...@@ -20,5 +21,6 @@ Vue.use(Progress); ...@@ -20,5 +21,6 @@ Vue.use(Progress);
Vue.use(Breadcrumb); Vue.use(Breadcrumb);
Vue.use(Button); Vue.use(Button);
Vue.use(Form); Vue.use(Form);
Vue.use(DatePicker)
Vue.prototype.$loading = Loading; Vue.prototype.$loading = Loading;
Vue.prototype.$message = Message; Vue.prototype.$message = Message;
\ No newline at end of file
...@@ -50,6 +50,5 @@ export interface TmplSelectProperty extends Property { ...@@ -50,6 +50,5 @@ export interface TmplSelectProperty extends Property {
*/ */
export interface UnitProperty extends Property { export interface UnitProperty extends Property {
type: PropertyType.Unit; type: PropertyType.Unit;
// label:any;
value: Array<TemplateProperty | TmplSelectProperty>; // 包含的子字段数组 value: Array<TemplateProperty | TmplSelectProperty>; // 包含的子字段数组
} }
...@@ -6,12 +6,14 @@ export class Unit { ...@@ -6,12 +6,14 @@ export class Unit {
public children: Array<Property | Unit>; public children: Array<Property | Unit>;
public parent: Unit | null; public parent: Unit | null;
public type: PropertyType = PropertyType.Unit; public type: PropertyType = PropertyType.Unit;
// public data: object = declaration
constructor(title: string, parent?: Unit) { constructor(title: string, data?: object, parent?: Unit) {
this.id = getUuid(); this.id = getUuid();
this.title = title; this.title = title;
this.children = []; this.children = [];
this.parent = parent || null; this.parent = parent || null;
// this.data = data || {}
} }
/** /**
...@@ -33,6 +35,16 @@ export class Unit { ...@@ -33,6 +35,16 @@ export class Unit {
} }
export class declaration {
public value: string;
public format: string;
public type: string;
constructor(value: string, format: string, type: string) {
this.value = value;
this.format = format;
this.type = type;
}
}
/** /**
* 属性 * 属性
*/ */
...@@ -45,10 +57,14 @@ export class Property { ...@@ -45,10 +57,14 @@ export class Property {
public value: string | Array<string>; public value: string | Array<string>;
public parent: Unit; public parent: Unit;
public data?: { public data?: {
value: string value: string,
format: string,
type: string
}; };
// public data: any constructor(label: string, key: string, parent: Unit, type: PropertyType = PropertyType.Input, value: string | Array<string> = ``, data?: {
constructor(label: string, key: string, parent: Unit, type: PropertyType = PropertyType.Input, value: string | Array<string> = ``, data?: { value: string }) { value: string, format: string,
type: string
}) {
this.id = getUuid(); this.id = getUuid();
this.label = label; this.label = label;
this.key = key; this.key = key;
...@@ -56,7 +72,7 @@ export class Property { ...@@ -56,7 +72,7 @@ export class Property {
this.options = []; this.options = [];
this.parent = parent; this.parent = parent;
this.value = ``; this.value = ``;
this.data = data
if (Object.prototype.toString.call(value) === `[object Array]`) { if (Object.prototype.toString.call(value) === `[object Array]`) {
if (!(value.length !== 0 && Object.prototype.toString.call(value[0]) === `[object Object]`)) { if (!(value.length !== 0 && Object.prototype.toString.call(value[0]) === `[object Object]`)) {
......
...@@ -567,6 +567,9 @@ export default class editTemplate extends Vue { ...@@ -567,6 +567,9 @@ export default class editTemplate extends Vue {
await this.fileHandler(); await this.fileHandler();
var newDetail = new Array(); var newDetail = new Array();
newDetail = formatApiJson(this.rootUnitList); newDetail = formatApiJson(this.rootUnitList);
console.log(newDetail);
return;
// 更新ext数据 // 更新ext数据
for (let index = 0; index < newDetail.length; index++) { for (let index = 0; index < newDetail.length; index++) {
const element = newDetail[index]; const element = newDetail[index];
...@@ -664,7 +667,9 @@ export default class editTemplate extends Vue { ...@@ -664,7 +667,9 @@ export default class editTemplate extends Vue {
}; };
var newDetail = new Array(); var newDetail = new Array();
newDetail = formatApiJson(this.rootUnitList); newDetail = formatApiJson(this.rootUnitList);
newDetail.push(newext); newDetail.push(newext);
const res = await this.$ajax({ const res = await this.$ajax({
type: "post", type: "post",
url: GO_URLS.add, url: GO_URLS.add,
......
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