name: verification_set
amis_schema: |-
  {
      "type": "service",
      "body": [
          {
              "type": "button",
              "label": "设置校验规则",
              "id": "u:verification_set",
              "onEvent": {
                  "click": {
                      "weight": 0,
                      "actions": [
                          {
                              "ignoreError": false,
                              "actionType": "dialog",
                              "dialog": {
                                  "type": "dialog",
                                  "title": "设置校验规则",
                                  "body": [
                                      {
                                          "type": "button-group",
                                          "id": "u:173771bbd1fc",
                                          "buttons": [
                                              {
                                                  "type": "button",
                                                  "label": "新建",
                                                  "onEvent": {
                                                      "click": {
                                                          "actions": [
                                                              {
                                                                  "ignoreError": false,
                                                                  "actionType": "dialog",
                                                                  "dialog": {
                                                                      "type": "dialog",
                                                                      "title": "新建",
                                                                      "body": [
                                                                          {
                                                                              "type": "service",
                                                                              "body": [
                                                                                  {
                                                                                      "type": "steedos-object-form",
                                                                                      "label": "对象表单",
                                                                                      "objectApiName": "b6_verification",
                                                                                      "mode": "edit",
                                                                                      "enableInitApi": false,
                                                                                      "className": "",
                                                                                      "id": "u:6b0ec7966e4e",
                                                                                      "submitSuccActions": [
                                                                                            {
                                                                                                "actionType": "reload",
                                                                                                "componentId": "u:d6234e18fa74",
                                                                                                "groupType": "component"
                                                                                            },
                                                                                            {
                                                                                                "actionType": "broadcast",
                                                                                                "args": {
                                                                                                    "eventName": "broadcast_service_listview_b6_data_rebuild"
                                                                                                }
                                                                                            }
                                                                                      ],
                                                                                      "defaultData": {
                                                                                          "table": "${_master.recordId}"
                                                                                      },
                                                                                      "fieldsExtend": "{\n    \"table\": {\n        \"visible_on\": \"${false}\"\n    }\n}",
                                                                                      "visibleOn": "${!!_formulaVariablesLoaded}"
                                                                                  }
                                                                              ],
                                                                              "dsType": "api",
                                                                              "api": {
                                                                                  "url": "${context.rootUrl}/api/v1/b6_fields",
                                                                                  "method": "get",
                                                                                  "requestAdaptor": "api.url += '?filters=[\"table_id\", \"=\", \"' + context._master.recordId + '\"]&fields=[\"label\",\"name\",\"type\"]';\nreturn api;",
                                                                                  "adaptor": "var formulaVariables = [];\nvar fTypeTags = {\n  \"text\": \"文本\",\n  \"textarea\": \"长文本\",\n  \"number\": \"数字\",\n  \"select\": \"单选\",\n  \"select-multiple\": \"多选\",\n  \"boolean\": \"勾选\",\n  \"date\": \"日期\",\n  \"datetime\": \"日期时间\",\n  \"formula\": \"公式\",\n};\nvar getFormulaVariableTag = function (type) { \n  var tag = fTypeTags[type] || type;\n  return tag;\n}\nif (payload.data.items && payload.data.items.length) { \n  formulaVariables = payload.data.items.map(function (n) {\n    return {\n      \"label\": n.label,\n      \"value\": n.name,\n      \"tag\": getFormulaVariableTag(n.type)\n    }\n  })\n}\npayload.data = {\n  _b6_fields__formula_variables: formulaVariables,\n  _formulaVariablesLoaded: true\n}\nreturn payload;",
                                                                                  "messages": {},
                                                                                  "data": {}
                                                                              },
                                                                              "data": {
                                                                                  "_formulaVariablesLoaded": false
                                                                              },
                                                                              "id": "u:6c02fbd691a2"
                                                                          }
                                                                      ],
                                                                      "id": "u:b7df4c75cba3",
                                                                      "actions": [
                                                                          {
                                                                              "type": "button",
                                                                              "actionType": "cancel",
                                                                              "label": "取消",
                                                                              "id": "u:d727f2a03df4"
                                                                          },
                                                                          {
                                                                              "type": "button",
                                                                              "actionType": "confirm",
                                                                              "label": "确定",
                                                                              "primary": true,
                                                                              "id": "u:1f4e248f851b"
                                                                          }
                                                                      ],
                                                                      "showCloseButton": true,
                                                                      "closeOnOutside": false,
                                                                      "closeOnEsc": false,
                                                                      "showErrorMsg": true,
                                                                      "showLoading": true,
                                                                      "draggable": false,
                                                                      "actionType": "dialog",
                                                                      "editorSetting": {
                                                                          "displayName": "新建"
                                                                      },
                                                                      "resizable": false,
                                                                      "onEvent": {
                                                                          "confirm": {
                                                                              "weight": 0,
                                                                              "actions": []
                                                                          }
                                                                      },
                                                                      "size": "lg"
                                                                  },
                                                                  "size": "lg"
                                                              }
                                                          ]
                                                      }
                                                  },
                                                  "id": "u:f4bb2603b8e2",
                                                  "level": "primary"
                                              },
                                              {
                                                  "type": "button",
                                                  "label": "过滤",
                                                  "hidden": true,
                                                  "onEvent": {
                                                      "click": {
                                                          "actions": [
                                                              {
                                                                  "ignoreError": false,
                                                                  "actionType": "dialog",
                                                                  "dialog": {
                                                                      "type": "dialog",
                                                                      "title": "过滤",
                                                                      "body": [
                                                                          {
                                                                              "type": "form",
                                                                              "title": "过滤",
                                                                              "size": "md",
                                                                              "mode": "normal",
                                                                              "dsType": "api",
                                                                              "body": [
                                                                                  {
                                                                                      "type": "condition-builder",
                                                                                      "name": "conditions",
                                                                                      "label": "",
                                                                                      "fields": [
                                                                                          {
                                                                                              "name": "rule",
                                                                                              "label": "校验规则",
                                                                                              "sortable": true,
                                                                                              "type": "text"
                                                                                          },
                                                                                          {
                                                                                              "name": "alert",
                                                                                              "label": "报错提示",
                                                                                              "type": "text",
                                                                                              "sortable": true
                                                                                          }
                                                                                      ],
                                                                                      "id": "u:e250068c0913",
                                                                                      "builderMode": "simple"
                                                                                  }
                                                                              ],
                                                                              "actions": [
                                                                                  {
                                                                                      "type": "button",
                                                                                      "label": "提交",
                                                                                      "onEvent": {
                                                                                          "click": {
                                                                                              "actions": [
                                                                                                  {
                                                                                                      "actionType": "submit",
                                                                                                      "componentId": "u:bfb9d516ba7d"
                                                                                                  }
                                                                                              ]
                                                                                          }
                                                                                      },
                                                                                      "level": "primary"
                                                                                  }
                                                                              ],
                                                                              "id": "u:4041caac0110",
                                                                              "feat": "Insert"
                                                                          }
                                                                      ],
                                                                      "actions": [
                                                                          {
                                                                              "type": "button",
                                                                              "actionType": "cancel",
                                                                              "label": "取消",
                                                                              "id": "u:3fab80fd3f87"
                                                                          },
                                                                          {
                                                                              "type": "button",
                                                                              "actionType": "confirm",
                                                                              "label": "确定",
                                                                              "primary": true,
                                                                              "id": "u:77efd22a8ac1"
                                                                          }
                                                                      ],
                                                                      "data": {
                                                                          "conditions": "${_crud_conditions}"
                                                                      },
                                                                      "showCloseButton": true,
                                                                      "closeOnOutside": false,
                                                                      "closeOnEsc": false,
                                                                      "showErrorMsg": true,
                                                                      "showLoading": true,
                                                                      "draggable": false,
                                                                      "actionType": "dialog",
                                                                      "resizable": false,
                                                                      "onEvent": {
                                                                          "confirm": {
                                                                              "weight": 0,
                                                                              "actions": [
                                                                                  {
                                                                                      "actionType": "custom",
                                                                                      "script": "event.data._crud_filters=window.amisConvert.conditionsToFilters(event.data.conditions);"
                                                                                  },
                                                                                  {
                                                                                      "componentId": "u:set_fields_dialog",
                                                                                      "groupType": "component",
                                                                                      "actionType": "setValue",
                                                                                      "args": {
                                                                                          "value": "${{\n_crud_conditions: conditions\n}}"
                                                                                      }
                                                                                  },
                                                                                  {
                                                                                      "componentId": "u:set_fields_dialog",
                                                                                      "groupType": "component",
                                                                                      "actionType": "setValue",
                                                                                      "args": {
                                                                                          "value": "${{\nfilters: _crud_filters\n}}"
                                                                                      }
                                                                                  },
                                                                                  {
                                                                                      "componentId": "u:d6234e18fa74",
                                                                                      "groupType": "component",
                                                                                      "actionType": "reload"
                                                                                  }
                                                                              ]
                                                                          }
                                                                      },
                                                                      "size": "md",
                                                                      "className": "steedos-overflow-visible-dialog",
                                                                      "id": "u:b38279dc9ee3"
                                                                  }
                                                              }
                                                          ]
                                                      }
                                                  },
                                                  "id": "u:1e34ae7788f4"
                                              }
                                          ]
                                      },
                                      {
                                          "type": "crud",
                                          "hideQuickSaveBtn": true,
                                          "syncLocation": false,
                                          "api": {
                                              "method": "get",
                                              "url": "/api/v1/b6_verification?sort=created",
                                              "messages": {},
                                              "requestAdaptor": "const masterRecordId = context._master.recordId;\nlet filters = [\"table\", \"=\", masterRecordId];\nconst contextFilters = context && context.filters;\nif (contextFilters?.length) {\n  filters = [filters, contextFilters]\n}\napi.url = api.url + \"&skip=\" + context.top * (context.page - 1);\napi.url = api.url + '&filters=' + JSON.stringify(filters);\nreturn api;",
                                              "adaptor": ""
                                          },
                                          "bulkActions": [],
                                          "columns": [
                                              {
                                                  "name": "_id",
                                                  "label": "ID",
                                                  "type": "text",
                                                  "hidden": true,
                                                  "id": "u:5963440c8296"
                                              },
                                              {
                                                  "name": "rule",
                                                  "label": "校验规则",
                                                  "sortable": true,
                                                  "type": "text",
                                                  "id": "u:ac13847067a1"
                                              },
                                              {
                                                  "type": "text",
                                                  "label": "报错提示",
                                                  "id": "u:ac13847067a1",
                                                  "name": "alert",
                                                  "sortable": true
                                              },
                                              {
                                                  "type": "operation",
                                                  "label": "操作",
                                                  "width": 100,
                                                  "fixed": "right",
                                                  "buttons": [
                                                      {
                                                          "type": "button",
                                                          "icon": "fa fa-eye",
                                                          "actionType": "dialog",
                                                          "dialog": {
                                                              "type": "dialog",
                                                              "title": "查看",
                                                              "size": "lg",
                                                              "body": [
                                                                  {
                                                                      "type": "service",
                                                                      "body": [
                                                                          {
                                                                              "type": "steedos-object-form",
                                                                              "id": "u:fe44bc0ba67a",
                                                                              "mode": "read",
                                                                              "label": "对象表单",
                                                                              "objectApiName": "b6_verification",
                                                                              "recordId": "${_id}",
                                                                              "enableInitApi": true,
                                                                              "className": "",
                                                                              "fieldsExtend": "{\n    \"table\": {\n        \"visible_on\": \"${false}\"\n    }\n}",
                                                                              "visibleOn": "${!!_formulaVariablesLoaded}"
                                                                          }
                                                                      ],
                                                                      "dsType": "api",
                                                                      "api": {
                                                                          "url": "${context.rootUrl}/api/v1/b6_fields",
                                                                          "method": "get",
                                                                          "requestAdaptor": "api.url += '?filters=[\"table_id\", \"=\", \"' + context._master.recordId + '\"]&fields=[\"label\",\"name\",\"type\"]';\nreturn api;",
                                                                          "adaptor": "var formulaVariables = [];\nvar fTypeTags = {\n  \"text\": \"文本\",\n  \"textarea\": \"长文本\",\n  \"number\": \"数字\",\n  \"select\": \"单选\",\n  \"select-multiple\": \"多选\",\n  \"boolean\": \"勾选\",\n  \"date\": \"日期\",\n  \"datetime\": \"日期时间\",\n  \"formula\": \"公式\",\n};\nvar getFormulaVariableTag = function (type) { \n  var tag = fTypeTags[type] || type;\n  return tag;\n}\nif (payload.data.items && payload.data.items.length) { \n  formulaVariables = payload.data.items.map(function (n) {\n    return {\n      \"label\": n.label,\n      \"value\": n.name,\n      \"tag\": getFormulaVariableTag(n.type)\n    }\n  })\n}\npayload.data = {\n  _b6_fields__formula_variables: formulaVariables,\n  _formulaVariablesLoaded: true\n}\nreturn payload;",
                                                                          "messages": {},
                                                                          "data": {}
                                                                      },
                                                                      "data": {
                                                                          "_formulaVariablesLoaded": false
                                                                      },
                                                                      "id": "u:6c02fbd691a2"
                                                                  }
                                                              ],
                                                              "actionType": "dialog",
                                                              "id": "u:e479029896d7",
                                                              "actions": [
                                                                  {
                                                                      "type": "button",
                                                                      "actionType": "cancel",
                                                                      "label": "取消",
                                                                      "id": "u:92b561e1b4c8"
                                                                  },
                                                                  {
                                                                      "type": "button",
                                                                      "actionType": "confirm",
                                                                      "label": "确定",
                                                                      "primary": true,
                                                                      "id": "u:2f4cfaf9c1dc"
                                                                  }
                                                              ],
                                                              "showCloseButton": true,
                                                              "closeOnOutside": false,
                                                              "closeOnEsc": false,
                                                              "showErrorMsg": true,
                                                              "showLoading": true,
                                                              "draggable": false
                                                          },
                                                          "id": "u:6953bff06696"
                                                      },
                                                      {
                                                          "type": "button",
                                                          "icon": "fa fa-pencil",
                                                          "actionType": "dialog",
                                                          "dialog": {
                                                              "type": "dialog",
                                                              "title": "编辑",
                                                              "size": "lg",
                                                              "body": [
                                                                  {
                                                                      "type": "service",
                                                                      "body": [
                                                                          {
                                                                              "type": "steedos-object-form",
                                                                              "id": "u:fe44bc0ba67a",
                                                                              "mode": "edit",
                                                                              "label": "对象表单",
                                                                              "objectApiName": "b6_verification",
                                                                              "recordId": "${_id}",
                                                                              "enableInitApi": true,
                                                                              "className": "",
                                                                              "submitSuccActions": [
                                                                                    {
                                                                                        "actionType": "reload",
                                                                                        "componentId": "u:d6234e18fa74",
                                                                                        "groupType": "component"
                                                                                    },
                                                                                    {
                                                                                        "actionType": "broadcast",
                                                                                        "args": {
                                                                                            "eventName": "broadcast_service_listview_b6_data_rebuild"
                                                                                        }
                                                                                    }
                                                                              ],
                                                                              "fieldsExtend": "{\n    \"table\": {\n        \"visible_on\": \"${false}\"\n    }\n}",
                                                                              "visibleOn": "${!!_formulaVariablesLoaded}"
                                                                          }
                                                                      ],
                                                                      "dsType": "api",
                                                                      "api": {
                                                                          "url": "${context.rootUrl}/api/v1/b6_fields",
                                                                          "method": "get",
                                                                          "requestAdaptor": "api.url += '?filters=[\"table_id\", \"=\", \"' + context._master.recordId + '\"]&fields=[\"label\",\"name\",\"type\"]';\nreturn api;",
                                                                          "adaptor": "var formulaVariables = [];\nvar fTypeTags = {\n  \"text\": \"文本\",\n  \"textarea\": \"长文本\",\n  \"number\": \"数字\",\n  \"select\": \"单选\",\n  \"select-multiple\": \"多选\",\n  \"boolean\": \"勾选\",\n  \"date\": \"日期\",\n  \"datetime\": \"日期时间\",\n  \"formula\": \"公式\",\n};\nvar getFormulaVariableTag = function (type) { \n  var tag = fTypeTags[type] || type;\n  return tag;\n}\nif (payload.data.items && payload.data.items.length) { \n  formulaVariables = payload.data.items.map(function (n) {\n    return {\n      \"label\": n.label,\n      \"value\": n.name,\n      \"tag\": getFormulaVariableTag(n.type)\n    }\n  })\n}\npayload.data = {\n  _b6_fields__formula_variables: formulaVariables,\n  _formulaVariablesLoaded: true\n}\nreturn payload;",
                                                                          "messages": {},
                                                                          "data": {}
                                                                      },
                                                                      "data": {
                                                                          "_formulaVariablesLoaded": false
                                                                      },
                                                                      "id": "u:6c02fbd691a2"
                                                                  }
                                                              ],
                                                              "actionType": "dialog",
                                                              "id": "u:290932dffbb4",
                                                              "actions": [
                                                                  {
                                                                      "type": "button",
                                                                      "actionType": "cancel",
                                                                      "label": "取消",
                                                                      "id": "u:c96589a01a1d"
                                                                  },
                                                                  {
                                                                      "type": "button",
                                                                      "actionType": "confirm",
                                                                      "label": "确定",
                                                                      "primary": true,
                                                                      "id": "u:628cdfe34460"
                                                                  }
                                                              ],
                                                              "showCloseButton": true,
                                                              "closeOnOutside": false,
                                                              "closeOnEsc": false,
                                                              "showErrorMsg": true,
                                                              "showLoading": true,
                                                              "draggable": false
                                                          },
                                                          "id": "u:c52f85b98640"
                                                      },
                                                      {
                                                          "type": "button",
                                                          "icon": "fa fa-times text-danger",
                                                          "confirmText": "确定要删除吗",
                                                          "onEvent": {
                                                              "click": {
                                                                  "weight": 0,
                                                                  "actions": [
                                                                      {
                                                                          "ignoreError": false,
                                                                          "actionType": "ajax",
                                                                          "outputVar": "responseResult",
                                                                          "options": {},
                                                                          "api": {
                                                                              "url": "/api/v1/b6_verification/${_id}",
                                                                              "method": "delete",
                                                                              "requestAdaptor": "",
                                                                              "adaptor": "",
                                                                              "messages": {}
                                                                          }
                                                                      },
                                                                      {
                                                                          "componentId": "u:d6234e18fa74",
                                                                          "groupType": "component",
                                                                          "actionType": "reload"
                                                                      }
                                                                  ]
                                                              }
                                                          },
                                                          "id": "u:0a119a9ef3bb"
                                                      }
                                                  ],
                                                  "id": "u:293c7e7b65ef",
                                                  "placeholder": "-"
                                              }
                                          ],
                                          "id": "u:d6234e18fa74",
                                          "perPageAvailable": [
                                              10
                                          ],
                                          "messages": {},
                                          "primaryField": "_id",
                                          "filter": null,
                                          "perPageField": "top"
                                      }
                                  ],
                                  "id": "u:set_fields_dialog",
                                  "data": {
                                      "_crud_conditions": {},
                                      "filters": [],
                                      "_crud_ordering": false,
                                      "_master": "${_master}"
                                  },
                                  "actions": [
                                      {
                                          "type": "button",
                                          "actionType": "cancel",
                                          "label": "取消",
                                          "id": "u:cd0da5df3e78"
                                      },
                                      {
                                          "type": "button",
                                          "actionType": "confirm",
                                          "label": "确定",
                                          "primary": true,
                                          "id": "u:3ca3a2bb15b0"
                                      }
                                  ],
                                  "showCloseButton": true,
                                  "closeOnOutside": false,
                                  "closeOnEsc": false,
                                  "showErrorMsg": true,
                                  "showLoading": true,
                                  "draggable": false,
                                  "actionType": "dialog",
                                  "size": "lg"
                              }
                          }
                      ]
                  }
              },
              "editorState": "default"
          }
      ],
      "regions": [
          "body"
      ],
      "data": {
          "context": {},
          "dataComponentId": "",
          "record_id": "",
          "record": {},
          "permissions": {}
      },
      "id": "u:d1ab787d7dac",
      "bodyClassName": "p-0",
      "dsType": "api"
  }
is_enable: true
label: 设置校验规则
locked: false
'on': record_only
type: amis_button
visible: true
sort: 20
