2个ElFormItem直接怎么传数据,还有emit event

2个ElFormItem直接怎么传数据,还有emit event。比如怎么根据报备开始日期、报备类型,自动填充报备结束日期? 我看到表单都是 getField 通过后台接口返回表单字段属性数组,循环生成的。   {"code":200,"data":[{"field":"initiator","name":"报备人","form_type":"XhUserCell","width":"","is_null":0,"value":[{"disabled":false,"id":null,"realname":null,"s_name":"","show":true,"thumb_img":"","username":null}]},{"field":"unit","name":"报备人单位","form_type":"text","width":"","is_null":0,"value":null},{"field":"type_name","name":"报备类型","form_type":"select","setting":["普通报备","参会报备","核心学校","成单报备"],"width":"","value":"-"},{"field":"started_date","name":"报备日期","form_type":"date","width":"","value":null},{"field":"expire_date","name":"有效期至","form_type":"date","width":"","value":null},{"field":"area","name":"省、市、县","form_type":"area","width":"140","value":{"address":[null,null,null]}},{"field":"school","name":"报备机构","form_type":"text","width":"","value":null},{"field":"principal_name","name":"负责人姓名","form_type":"text","width":"","value":null},{"field":"principal_status","name":"负责人职位","form_type":"text","width":"","value":null},{"field":"principal_mobile","name":"负责人联系方式","form_type":"mobile","width":"","value":null},{"field":"deposit_required","name":"是否需要保证金","form_type":"select","setting":["否","是"],"width":"","value":null},{"field":"deposit_amount","name":"保证金数额","form_type":"number","width":"","value":null},{"field":"approver","name":"审核人","form_type":"XhUserCell","width":"","value":[{"disabled":false,"id":null,"realname":null,"s_name":"","show":true,"thumb_img":"","username":null}]},{"field":"state","name":"报备状态","form_type":"select","setting":["未审核","审核中","保护中","已成单","取消审核","取消保护","已过期"],"width":"","value":null}],"error":""}
已邀请:

mingzhanghui - PHP是世界上最好的语言,拍黄片是世界上最好的工作。

ux/src/views/customermanagement/components/CRMCreateView.vue 反正应该在这个文件里改
 
在方法 fieldValueChange 中打印 data和item如下:

{"index":3,"value":"2019-07-16"}

{"value":"2019-07-16","key":"started_date","data":{"field":"started_date","name":"报备日期","form_type":"date","width":"","value":null},"disabled":false,"styleIndex":3}

mingzhanghui - PHP是世界上最好的语言,拍黄片是世界上最好的工作。

 // 对于报备日期 ElFormItem  ElDatePicker
else if (this.crmType === 'report') {
console.log(JSON.stringify(this.crmForm.crmFields));

let getExpireDate = function(startedDate, typeName) {
let days = 0;
switch (typeName) {
case "普通报备": days = 180; break;
case "参会报备": days = 60; break;
case "核心学校": days = 80*360; break;
case "成单报备": days = 365; break;
default:
days = 180;
}
let start = new Date(startedDate);
let end = new Date(start.getTime() + days * 86400 * 1000);

return end.getFullYear() + "-" + (end.getMonth()+1) + "-" + end.getDate();
};

let startedDate = "", expireDate = "", typeName = 0; // 报备类型

if (item.key === 'started_date') {
for (let i = 0; i < this.crmForm.crmFields.length; i++) {
const element = this.crmForm.crmFields[i];
if (element.key === "expire_date") {
element.value = getExpireDate(startedDate, typeName);
} else if (element.key === "started_date") {
startedDate = element.value;
} else if (element.key === "type_name") {
typeName = element.value
}
}
console.log("startedDate="+startedDate + ", expireDate=" + expireDate + ", typeName=" +typeName);
} else if (item.key === 'type_name') {
for (let i = 0; i < this.crmForm.crmFields.length; i++) {
const element = this.crmForm.crmFields[i];
if (element.key === "expire_date") {
element.value = getExpireDate(startedDate, typeName);
} else if (element.key === "started_date") {
startedDate = element.value;
} else if (element.key === "type_name") {
typeName = element.value
}
}
console.log("startedDate="+startedDate + ", expireDate=" + expireDate + ", typeName=" +typeName);
}
}

要回复问题请先登录注册