Open shayulei opened 1 month ago
👍 Thanks for this! 🏷 I have applied any labels matching special text in your issue.
Please review the labels and make any necessary changes.
问题已经解决,解决过程比较曲折,使用reload可以使用api读到被清空的变量,然后在创建API发送条件,当变量不为空时才发送
这样也可以,不用那么绕,在提交到时候用reload事件去reload crud,并传递要传的参数,把另一个值置空就行
{
"ignoreError": false,
"actionType": "reload",
"dataMergeMode": "override",
"data": {
"employeeName": "",
"employeeNO": "${employeeNO}"
},
"componentId": "ad"
},
完整schema如下
{
"type": "page",
"body": [
{
"type": "form",
"id": "u:75adf2062959",
"body": [
{
"type": "input-text",
"name": "employeeNO",
"label": "",
"id": "u:07522193bb5d",
"clearable": true
}
],
"title": "通过工号查询",
"actions": [
{
"type": "submit",
"label": "搜索",
"primary": true,
"id": "u:e170d5fbd80c"
}
],
"name": "soushuoNO",
"labelAlign": "left",
"onEvent": {
"submitSucc": {
"weight": 0,
"actions": [
{
"ignoreError": false,
"actionType": "reload",
"dataMergeMode": "override",
"data": {
"employeeName": "",
"employeeNO": "${employeeNO}"
},
"componentId": "ad"
},
{
"ignoreError": false,
"actionType": "reload",
"dataMergeMode": "override",
"data": {
"employeeName": "",
"employeeNO": "${employeeNO}"
},
"componentId": "exmail"
}
]
}
},
"feat": "Insert",
"dsType": "api"
},
{
"type": "form",
"body": [
{
"type": "input-text",
"name": "employeeName",
"label": "",
"id": "u:11d28bb6fe01",
"clearable": true
}
],
"title": "通过姓名查询",
"submitText": "搜索",
"id": "u:8c1f6f0ff7f2",
"feat": "Insert",
"dsType": "api",
"labelAlign": "left",
"onEvent": {
"submitSucc": {
"weight": 0,
"actions": [
{
"componentId": "ad",
"ignoreError": false,
"actionType": "reload",
"dataMergeMode": "override",
"data": {
"employeeName": "${employeeName}",
"employeeNO": ""
}
},
{
"componentId": "exmail",
"ignoreError": false,
"actionType": "reload",
"dataMergeMode": "override",
"data": {
"employeeName": "${employeeName}",
"employeeNO": ""
}
}
]
}
},
"actions": [
{
"type": "submit",
"label": "搜索",
"primary": true,
"id": "u:b9f5ae82791d"
}
]
},
{
"type": "crud",
"api": {
"url": "/api/user/search",
"mothod": "post",
"data": {
"employeeNO": "${employeeNO|default:undefined}",
"employeeName": "${employeeName|default:undefined}"
},
"method": "post",
"messages": {},
"requestAdaptor": "",
"adaptor": "",
"dataType": "json"
},
"name": "ad",
"title": "域账户 ",
"columns": [
{
"name": "sAMAccountName",
"label": "工号",
"id": "u:c8a964aa1f37",
"placeholder": "-"
},
{
"name": "cn",
"label": "姓名",
"id": "u:0e463a52297d"
},
{
"label": "状态",
"type": "status",
"value": "${userStatus}",
"visible": true,
"source": {
"禁用": {
"label": "禁用",
"color": "#f00"
},
"启用": {
"label": "启用",
"color": "b-dark"
}
},
"id": "u:b45afe152a84"
},
{
"name": "distinguishedName",
"label": "AD显示名",
"id": "u:ad8a693fe0d9"
},
{
"type": "operation",
"label": "操作",
"width": 100,
"buttons": [
{
"type": "button",
"label": "禁用",
"actionType": "ajax",
"tooltip": "禁用",
"confirmText": "您确认要禁用${cn}?",
"api": {
"mothod": "post",
"url": "/api/user/setStatus",
"datatype": "json",
"data": {
"distinguishedName": "${distinguishedName}"
}
},
"id": "u:924ba504a5e6"
}
],
"id": "u:8d0c1c293c92"
}
],
"id": "ad",
"perPageAvailable": [
10
],
"messages": {},
"initFetch": "",
"initFetchOn": "employeeNO !== \"\" || employeeName !== \"\""
},
{
"type": "crud",
"name": "exmail",
"api": {
"method": "post",
"url": "/api/exmail/listUser",
"messages": {},
"requestAdaptor": "",
"adaptor": "",
"dataType": "json",
"data": {
"extid": "${employeeNO|default:undefined}",
"name": "${employeeName|default:undefined}"
}
},
"title": "邮箱账户",
"columns": [
{
"name": "extid",
"label": "工号",
"id": "u:a81773915c77",
"placeholder": "-"
},
{
"name": "name",
"label": "姓名",
"id": "u:b8934135b4ed",
"placeholder": "-"
},
{
"name": "userid",
"label": "邮箱地址",
"id": "u:44278b4b8e22",
"placeholder": "-"
},
{
"label": "状态",
"id": "u:d27bbafd4d1c",
"type": "status",
"value": "${enable}",
"visible": true,
"source": {
"0": {
"label": "禁用",
"color": "#f00"
},
"1": {
"label": "启用",
"color": "b-dark"
}
}
},
{
"label": "操作",
"id": "u:8d0c1c293c92",
"type": "operation",
"width": 100,
"buttons": [
{
"type": "button",
"label": "禁用",
"actionType": "ajax",
"tooltip": "禁用",
"confirmText": "您确认要禁用${name}?",
"api": {
"mothod": "post",
"url": "/api/exmail/update",
"datatype": "json",
"data": {
"userid": "{$userid}"
}
},
"id": "u:924ba504a5e6"
}
]
}
],
"id": "exmail",
"perPageAvailable": [
10
],
"messages": {},
"initFetchOn": "employeeNO !== \"\" || employeeName !== \"\"",
"primaryField": ""
}
],
"id": "u:ebea1273df8e",
"asideResizor": false,
"pullRefresh": {
"disabled": true
}
}
实现场景:
通过员工工号或姓名同时搜索AD和邮箱的账户,员工工号和姓名二选一
存在的问题:
选用员工工号搜索后,再使用姓名搜索时,API参数中还是带有之前的工号;反之先使用姓名搜索,再使用工号搜索,API中也会有之前的姓名参数(这块的代码没有实现,只是猜测);使用了各种清除变量内容的方案,只实现了输入框内容的清空,API参数没有被清空
当前方案: