Commit eea939d2 authored by 满振华's avatar 满振华

修改控件展示

parent 4924e20d
......@@ -26,7 +26,9 @@ export const HandleClass = {
},
'changeParams': {
name: '修改business,请求参数',
fun: ({ behavior = {}, formData, componentData, value }, resertValue) => {
fun: ({ behavior = {}, formData, componentData, value, handleType }, resertValue) => {
// handleType 为init时不处理值的问题
const newFormData = formData.slice();
const targets = (behavior.targets || '').split(',');
targets.forEach(ls => {
......@@ -40,7 +42,10 @@ export const HandleClass = {
paramsJson,
}
resertValue && resertValue({ key: ls });
obj.value = void 0; //将目标组件清空
if (handleType !== 'init') {
obj.value = void 0; //将目标组件清空
}
});
return newFormData
......
......@@ -12,7 +12,7 @@ class HandleBehavior {
this.formData.map(item => {
if (!item.behaviors || !Array.isArray(item.behaviors) || item.behaviors.length === 0) return;
const value = this.handleFormaterValue(item.value, item);
this.handleBehavior({ currentValue: value, componentData: item })
this.handleBehavior({ currentValue: value, componentData: item, handleType: 'init' })
})
return this;
}
......@@ -33,28 +33,28 @@ class HandleBehavior {
/*
* 处理行为方法
*/
handleBehavior = ({ currentValue, componentData = {}, eventType, formData }) => {
handleBehavior = ({ currentValue, componentData = {}, eventType, formData, handleType }) => {
this.formData = formData || this.formData;
const value = this.handleFormaterValue((currentValue || componentData.value), componentData);
const events = componentData.events || []
const behaviors = componentData.behaviors || [];
const changeEvents = eventType ? events.filter(ls => ls.eventValue === 'onChange') : events;
changeEvents.forEach(event => {
this.onChangeBehavior({ event, value, componentData, behaviors })
this.onChangeBehavior({ event, value, componentData, behaviors, handleType })
});
}
onChangeBehavior = ({ event, value, componentData, behaviors }) => {
onChangeBehavior = ({ event, value, componentData, behaviors, handleType }) => {
if (!event.behaviors || !Array.isArray(event.behaviors)) return;
event.behaviors.forEach(item => {
this.handleBehaviorType({ value, behavior: item, componentData, behaviors });
this.handleBehaviorType({ value, behavior: item, componentData, behaviors, handleType });
});
}
handleBehaviorType = ({ value, behavior, behaviors, componentData }) => {
handleBehaviorType = ({ value, behavior, behaviors, componentData, handleType }) => {
const behaviorInstance = HandleClass[behavior.behaviorValue];
if (!behaviorInstance || !behaviorInstance.fun) return;
let formData = this.formData;
this.formData = behaviorInstance.fun({ value, behavior, behaviors, formData, componentData }, this.resertValueCallback);
this.formData = behaviorInstance.fun({ value, behavior, behaviors, formData, componentData, handleType }, this.resertValueCallback);
}
resertValueCallback = ({ key, value }) => {
const componentData = this.formData.find(ls => ls.name === key) || {};
......
......@@ -6,11 +6,22 @@ sidebar: true
---
import HandleBehavior from './';
import {data} from './test/json.js'
# Button Component
## new HandleBehavior({formData})
## instance{initBehavior(formData)}
<html>
<body>
<div>ddd
<script>
console.log(1)
</script>
</div>
</body>
</html>
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script src="../../dist/index.js">
</script>
</body>
</html>
\ No newline at end of file
export const data = [
{
"id": 569,
"name": "KDLX",
"parentId": 0,
"type": "select",
"value": [
{
"name": "DHL国际快递",
"value": 1
}
],
"formId": 76,
"conditonField": 1,
"purposeType": 0,
"inspectRules": null,
"fieldEmpty": 0,
"fieldMessage": "请选择快递类型",
"fieldSort": 1,
"createBy": 533,
"createAt": "2019-10-10 00:36:48",
"updateBy": 533,
"updateAt": "2019-10-22 17:51:53",
"title": "快递类型",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": [
{
"id": 9,
"formId": 76,
"fieldId": 569,
"fieldName": "KDLX",
"eventName": "值变化",
"eventValue": "onChange",
"behaviors": [
{
"id": 9,
"formId": 76,
"fieldId": 569,
"eventId": 9,
"behaviorValue": "showComponent",
"targets": "talentName,customerName",
"params": "1"
}
]
}
],
"behaviors": [
{
"id": 9,
"formId": 76,
"fieldId": 569,
"fieldName": "KDLX",
"behaviorName": "显示控制",
"behaviorValue": "showComponent",
"targets": "talentName,customerName"
}
]
},
{
"id": 571,
"name": "goodsType",
"parentId": 0,
"type": "select",
"value": [
{
"name": "合同/协议",
"value": 1
}
],
"formId": 76,
"conditonField": 1,
"purposeType": 0,
"inspectRules": null,
"fieldEmpty": 0,
"fieldMessage": "请选择物品类型",
"fieldSort": 2,
"createBy": 298,
"createAt": "2019-10-26 11:28:39",
"updateBy": 298,
"updateAt": "2019-10-29 19:26:34",
"title": "物品类型",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 550,
"name": "SSGS",
"parentId": 0,
"type": "select",
"value": [
{
"name": "北京春雨听雷网络科技有限公司",
"value": 2
}
],
"formId": 76,
"conditonField": 0,
"purposeType": 0,
"inspectRules": null,
"fieldEmpty": 0,
"fieldMessage": "请选择所属公司",
"fieldSort": 3,
"createBy": 533,
"createAt": "2019-08-21 14:02:59",
"updateBy": 533,
"updateAt": "2019-10-26 11:28:43",
"title": "所属公司",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 555,
"name": "JJRBM",
"parentId": 0,
"type": "department",
"value": [
{
"name": "运营管理部",
"value": 14
}
],
"formId": 76,
"conditonField": 0,
"purposeType": 0,
"inspectRules": null,
"fieldEmpty": 0,
"fieldMessage": "请选择寄件人部门",
"fieldSort": 4,
"createBy": 533,
"createAt": "2019-08-21 14:30:29",
"updateBy": 533,
"updateAt": "2019-10-26 11:28:45",
"title": "寄件人部门",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 556,
"name": "projectType",
"parentId": 0,
"type": "select",
"value": [
{
"name": "立项项目",
"value": 1
}
],
"formId": 76,
"conditonField": 0,
"purposeType": 0,
"inspectRules": null,
"fieldEmpty": 0,
"fieldMessage": "请选择项目类型",
"fieldSort": 5,
"createBy": 533,
"createAt": "2019-08-21 14:31:40",
"updateBy": 533,
"updateAt": "2019-10-26 15:10:17",
"title": "项目类型",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": [
{
"id": 3,
"formId": 76,
"fieldId": 556,
"fieldName": "projectType",
"eventName": "值变化",
"eventValue": "onChange",
"behaviors": [
{
"id": 3,
"formId": 76,
"fieldId": 556,
"eventId": 3,
"behaviorValue": "changeParams",
"targets": "projectName",
"params": null
},
{
"id": 8,
"formId": 76,
"fieldId": 556,
"eventId": 3,
"behaviorValue": "showComponent",
"targets": "contractName",
"params": "1"
}
]
}
],
"behaviors": [
{
"id": 3,
"formId": 76,
"fieldId": 556,
"fieldName": "projectType",
"behaviorName": "显示控制",
"behaviorValue": "showComponent",
"targets": "contractName"
},
{
"id": 8,
"formId": 76,
"fieldId": 556,
"fieldName": "projectType",
"behaviorName": "更新请求参数",
"behaviorValue": "changeParams",
"targets": "projectName"
}
]
},
{
"id": 557,
"name": "projectName",
"parentId": 0,
"type": "business",
"value": [
{
"name": " 广发信用卡授权 *papi酱*1905",
"value": "1388"
}
],
"formId": 76,
"conditonField": 0,
"purposeType": 0,
"inspectRules": null,
"fieldEmpty": 0,
"fieldMessage": "请输入项目名称",
"fieldSort": 6,
"createBy": 533,
"createAt": "2019-08-21 14:36:48",
"updateBy": 533,
"updateAt": "2019-10-26 15:09:28",
"title": "项目名称",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": [
{
"id": 4,
"formId": 76,
"fieldId": 557,
"fieldName": "projectName",
"eventName": "值变化",
"eventValue": "onChange",
"behaviors": [
{
"id": 4,
"formId": 76,
"fieldId": 557,
"eventId": 4,
"behaviorValue": "changeParams",
"targets": "contractName",
"params": null
}
]
}
],
"behaviors": [
{
"id": 4,
"formId": 76,
"fieldId": 557,
"fieldName": "projectName",
"behaviorName": "更新请求参数",
"behaviorValue": "changeParams",
"targets": "contractName"
}
]
},
{
"id": 572,
"name": "contractName",
"parentId": 0,
"type": "business",
"value": "",
"formId": 76,
"conditonField": 0,
"purposeType": 0,
"inspectRules": null,
"fieldEmpty": 1,
"fieldMessage": "请选择合同",
"fieldSort": 7,
"createBy": 298,
"createAt": "2019-10-26 11:30:24",
"updateBy": 298,
"updateAt": "2019-10-30 17:29:57",
"title": "合同",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 558,
"name": "talentName",
"parentId": 0,
"type": "business",
"value": [
{
"name": "经理人1",
"value": "233_0"
}
],
"formId": 76,
"conditonField": 0,
"purposeType": 0,
"inspectRules": null,
"fieldEmpty": 0,
"fieldMessage": "请输入涉及艺人/博主",
"fieldSort": 8,
"createBy": 533,
"createAt": "2019-08-21 14:49:55",
"updateBy": 533,
"updateAt": "2019-10-26 15:09:38",
"title": "涉及艺人/博主",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 570,
"name": "customerName",
"parentId": 0,
"type": "business",
"value": [
{
"name": "青青河边草123",
"value": "972"
}
],
"formId": 76,
"conditonField": 0,
"purposeType": 0,
"inspectRules": null,
"fieldEmpty": 0,
"fieldMessage": "请输入客户名称",
"fieldSort": 9,
"createBy": 533,
"createAt": "2019-10-10 00:38:48",
"updateBy": 533,
"updateAt": "2019-10-26 15:09:44",
"title": "客户名称",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 559,
"name": "FYCDGS",
"parentId": 0,
"type": "select",
"value": [
{
"name": "个人承担",
"value": 3
}
],
"formId": 76,
"conditonField": 0,
"purposeType": 0,
"inspectRules": null,
"fieldEmpty": 0,
"fieldMessage": "请选择费用承担归属",
"fieldSort": 10,
"createBy": 533,
"createAt": "2019-08-21 14:50:58",
"updateBy": 533,
"updateAt": "2019-10-26 11:30:35",
"title": "费用承担归属",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 551,
"name": "JJR",
"parentId": 0,
"type": "input",
"value": "风格",
"formId": 76,
"conditonField": 0,
"purposeType": 0,
"inspectRules": null,
"fieldEmpty": 0,
"fieldMessage": "请输入寄件人姓名",
"fieldSort": 11,
"createBy": 533,
"createAt": "2019-08-21 14:03:36",
"updateBy": 533,
"updateAt": "2019-10-26 11:28:53",
"title": "寄件人",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 560,
"name": "JTCDBM",
"parentId": 0,
"type": "department",
"value": [
{
"name": "市场部",
"value": 60
}
],
"formId": 76,
"conditonField": 0,
"purposeType": 0,
"inspectRules": null,
"fieldEmpty": 0,
"fieldMessage": "请输入具体承担部门",
"fieldSort": 11,
"createBy": 533,
"createAt": "2019-08-21 14:51:40",
"updateBy": 533,
"updateAt": "2019-10-30 16:49:59",
"title": "具体承担部门",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 552,
"name": "JJRLXFS",
"parentId": 0,
"type": "hidden",
"value": null,
"formId": 76,
"conditonField": 0,
"purposeType": -1,
"inspectRules": null,
"fieldEmpty": 1,
"fieldMessage": "请输入寄件人联系方式",
"fieldSort": 12,
"createBy": 533,
"createAt": "2019-08-21 14:04:11",
"updateBy": 533,
"updateAt": "2019-10-26 11:28:54",
"title": "寄件人联系方式",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 553,
"name": "SJR",
"parentId": 0,
"type": "hidden",
"value": null,
"formId": 76,
"conditonField": 0,
"purposeType": -1,
"inspectRules": null,
"fieldEmpty": 1,
"fieldMessage": "请输入收件人",
"fieldSort": 13,
"createBy": 533,
"createAt": "2019-08-21 14:05:01",
"updateBy": 533,
"updateAt": "2019-10-26 11:27:37",
"title": "收件人",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 562,
"name": "FJDZ",
"parentId": 0,
"type": "hidden",
"value": null,
"formId": 76,
"conditonField": 0,
"purposeType": -1,
"inspectRules": null,
"fieldEmpty": 1,
"fieldMessage": "请选择发件地址",
"fieldSort": 14,
"createBy": 533,
"createAt": "2019-08-21 14:53:22",
"updateBy": 533,
"updateAt": "2019-10-26 11:29:05",
"title": "发件地址",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 554,
"name": "SJRLXFS",
"parentId": 0,
"type": "hidden",
"value": null,
"formId": 76,
"conditonField": 0,
"purposeType": -1,
"inspectRules": null,
"fieldEmpty": 1,
"fieldMessage": "请输入收件人联系方式",
"fieldSort": 15,
"createBy": 533,
"createAt": "2019-08-21 14:25:43",
"updateBy": 533,
"updateAt": "2019-10-26 11:29:06",
"title": "收件人联系方式",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 563,
"name": "SJDZ",
"parentId": 0,
"type": "hidden",
"value": null,
"formId": 76,
"conditonField": 0,
"purposeType": -1,
"inspectRules": null,
"fieldEmpty": 1,
"fieldMessage": "请输入收件地址",
"fieldSort": 16,
"createBy": 533,
"createAt": "2019-08-21 14:54:08",
"updateBy": 533,
"updateAt": "2019-10-26 11:29:08",
"title": "收件地址",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 561,
"name": "JJRQ",
"parentId": 0,
"type": "hidden",
"value": null,
"formId": 76,
"conditonField": 0,
"purposeType": -1,
"inspectRules": null,
"fieldEmpty": 1,
"fieldMessage": "请选择寄件日期",
"fieldSort": 17,
"createBy": 533,
"createAt": "2019-08-21 14:52:31",
"updateBy": 533,
"updateAt": "2019-10-26 11:29:09",
"title": "寄件日期",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 564,
"name": "WPMC",
"parentId": 0,
"type": "hidden",
"value": null,
"formId": 76,
"conditonField": 0,
"purposeType": -1,
"inspectRules": null,
"fieldEmpty": 1,
"fieldMessage": "请输入物品名称",
"fieldSort": 18,
"createBy": 533,
"createAt": "2019-08-21 14:54:37",
"updateBy": 533,
"updateAt": "2019-10-26 11:29:11",
"title": "物品名称",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 565,
"name": "WPSL",
"parentId": 0,
"type": "hidden",
"value": null,
"formId": 76,
"conditonField": 0,
"purposeType": -1,
"inspectRules": null,
"fieldEmpty": 1,
"fieldMessage": "请输入物品数量",
"fieldSort": 19,
"createBy": 533,
"createAt": "2019-08-21 14:55:26",
"updateBy": 533,
"updateAt": "2019-10-26 11:29:13",
"title": "物品数量",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 566,
"name": "WPJZ",
"parentId": 0,
"type": "hidden",
"value": null,
"formId": 76,
"conditonField": 0,
"purposeType": -1,
"inspectRules": null,
"fieldEmpty": 1,
"fieldMessage": "请输入物品价值(元)",
"fieldSort": 20,
"createBy": 533,
"createAt": "2019-08-21 14:56:23",
"updateBy": 533,
"updateAt": "2019-10-26 11:29:15",
"title": "物品价值",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 567,
"name": "SXMS",
"parentId": 0,
"type": "textarea",
"value": "时间啥代理费控件水电费为广东人复合弓",
"formId": 76,
"conditonField": 0,
"purposeType": 0,
"inspectRules": null,
"fieldEmpty": 1,
"fieldMessage": "",
"fieldSort": 21,
"createBy": 533,
"createAt": "2019-08-21 14:57:31",
"updateBy": 533,
"updateAt": "2019-10-31 14:12:25",
"title": "事项描述",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
},
{
"id": 568,
"name": "FJ",
"parentId": 0,
"type": "upload",
"value": [
{
"type": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
"percent": 100,
"url": "https://attachment-test.mttop.cn/20191031193956gFN55Q.pptx",
"originFileObj": {
"uid": "rc-upload-1572517878886-4"
},
"uid": "rc-upload-1572517878886-4",
"size": 57517255,
"response": {
"hash": "lgtajVcjFEzl7f6a60UOieQpMpKO",
"key": "20191031193956gFN55Q.pptx"
},
"domain": "attachment-test.mttop.cn",
"name": "演示文稿1.pptx",
"attachmentOrigin": 1,
"lastModified": 1572320913000,
"thumbUrl": "https://static.mttop.cn/admin/pptIcon.png",
"value": "20191031193956gFN55Q.pptx",
"status": "done"
}
],
"formId": 76,
"conditonField": 0,
"purposeType": 0,
"inspectRules": null,
"fieldEmpty": 1,
"fieldMessage": "",
"fieldSort": 22,
"createBy": 533,
"createAt": "2019-08-21 14:58:08",
"updateBy": 533,
"updateAt": "2019-10-28 20:16:56",
"title": "附件",
"approvalFormFields": null,
"approvalFormFieldValues": null,
"events": null,
"behaviors": null
}
]
\ No newline at end of file
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