Commit 72e2aa5b authored by zL's avatar zL

保留data数据格式

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