{
  "title": "@functionName@",
  "type": "page",
  "toolbar": [
    {
      "type": "button",
      "label": "新增",
      "icon": "fa fa-plus pull-left",
      "primary": true,
      "actionType": "drawer",
	  "disabledOn": "${ls:@menuid@@insert == null}",
      "drawer": {
        "position": "right",
        "resizable": true,
        "size": "xl",
		"actions": [
			{
			  "label": "存檔",
			  "actionType": "submit",
			  "close": false,
			  "primary": true,
			  "type": "button"
			}
        ],
		@insert_default@
		"title": "新增",
        "body": {
          "type": "form",
          "mode": "horizontal",
          "horizontal": {
            "leftFixed": true
          },
          "name": "sample-edit-form",
		  @init_api_org@
          "api": {
            "method": "post",
            "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/2/",
			"data": {
				"&": "$$",
				"token": "${ls:token}",
				"_$_tableName": "@TableName@",
				"_$_pk": "@pk@",
				"_$_action": "C"
			},
            "dataType": "form"
          },
          "body": [
            @Fields_by_add@,
            {
				"type": "panel",
				"//title": "表身明細",
				"body": [{
					"type": "input-table",
					"name": "details",
					"label": false,
					"addable": true,
					"removable": true,
					"needConfirm": false,
					"canAccessSuperData": true,
					"strictMode": false,
					"columns": [
						@Detail_By_add@
					]
				}]
			}
          ]
        }
      }
    }
  ],
  "body": {
    "type": "crud",
	"tableClassName": "myGridHeader_a",
    "api": {
      "method": "post",
      "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/3/",
      "data": {
        "token": "${ls:token}",
        "page": "${page}",
        "perPage": "${perPage}",
        "keywords": "${keywords}",
		@aside_filter@
		@query_type_data@
        "_$_tableName": "@TableName@",
        "_$_pk": "@pk@",
        "_$_action": "P",
        "_$_query_filter": "1^10^@pk@^*^^@menuid@^@Filters@"
      },
      "dataType": "form"
    },
    "syncLocation": false,
	"autoGenerateFilter": @is_query_header@,
    "perPage": 10,
    "headerToolbar": [
      @keyword_search@
      {
		"type": "export-excel",
		"label": "匯出 Excel",
		"api": {
		  "method": "post",
		  "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/2/",
		  "data": {
	        "token": "${ls:token}",
			"page": "${page}",
			"perPage": "10000",
			"keywords": "${keywords}",
			@aside_filter@
			@query_type_data@
			"_$_tableName": "@TableName@",
			"_$_pk": "@pk@",
			"_$_action": "P",
			"_$_query_filter": "1^10^@pk@^*^^@menuid@^@Filters@"
		  },
		  "dataType": "form"
		}
	  },
	  {
		"type": "button",
		"level": "info",
		"tooltip": "查看 Source",
		"icon": "fas fa-bullseye",
		"actionType": "drawer",
		"drawer": {
			"size": "lg",
			"resizable": true,
			"body": {
				"type": "service",
				"schemaApi": "get:/pages/zen_codeviewer.json"
			},
			"actions": []
		}
	  },
	  @ext_button_U@
      {
        "type": "columns-toggler",
        "align": "right"
      },
      {
        "type": "drag-toggler",
        "align": "right"
      },
      {
        "type": "pagination",
        "align": "right"
      }
    ],
    "footerToolbar": [
      "statistics",
      "switch-per-page",
      "pagination"
    ],
    "columns": [
      @Fields_By_GridView@
      {
        "type": "operation",
        "label": "操作",
        "width": @op-width@,
        "buttons": [
		  {
            "type": "button",
            "icon": "fa fa-eye",
            "actionType": "dialog",
            "dialog": {
              "title": "查看",
              "size": "lg",
              "body": {
                "type": "form",
                "mode": "horizontal",
                "horizontal": {
                  "leftFixed": true
                },
				@init_api_org@
                "body": [
                  @Fields_By_View@,
                  {
                    "type": "panel",
                    "title": "表身明細",
                    "body": {
                      "type": "crud",
					  "tableClassName": "myGridHeader_a",
                      "api": {
                        "method": "post",
                        "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/3/",
                        "data": {
                          "token": "${ls:token}",
                          "page": "${page}",
                          "perPage": "${perPage}",
                          "keywords": "${keywords}",
                          "_$_tableName": "@Sub_TableName@",
                          "_$_pk": "@sub_pk@",
						  "_id_": "${@pk@}",
                          "_field_": "@pk@",
                          "_$_action": "P",
                          "_$_query_filter": "1^10^@pk@,@seqno@^@detail_fields@^^^@pk@"
                        },
                        "dataType": "form"                        
                      },
                      "syncLocation": false,
                      "perPage": 10,
                      "headerToolbar": [
                        {
                          "type": "search-box",
                          "name": "keywords",
                          "align": "left",
                          "placeholder": "全文檢索"
                        },
                        {
                          "type": "columns-toggler",
                          "align": "right"
                        },
                        {
                          "type": "drag-toggler",
                          "align": "right"
                        },
                        {
                          "type": "pagination",
                          "align": "right"
                        }
                      ],
                      "footerToolbar": [
                        "statistics",
                        "switch-per-page",
                        "pagination"
                      ],
                      "columns": [
						  @Detail_By_View@
                      ]
                    }
                  }
                ]
              }
            }
          },
          {
            "type": "button",
            "icon": "fa fa-pencil",
            "actionType": "drawer",
			"disabledOn": "${ls:@menuid@@update == null@bpm_edit@",
            "drawer": {
              "position": "left",
              "resizable": true,
              "size": "xl",
              "title": "編輯",			  
              "body": {
                "type": "form",
                "mode": "horizontal",
                "horizontal": {
                  "leftFixed": true
                },
                "name": "sample-edit-form",
				@init_api_org@
                "api": {
                  "method": "post",
                  "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/2/",
				  "data": {
						"&": "$$",
						"token": "${ls:token}",
						"_$_tableName": "@TableName@",
						"_$_pk": "@pk@",
						"_$_action": "U"
				  },
                  "dataType": "form"
                },
                "body": [
                  @Fields_By_Edit@,
                  {
                    "type": "panel",
                    "title": "表身明細",
                    "body": {
                      "type": "crud",
					  "tableClassName": "myGridHeader_a",
                      "api": {
                        "method": "post",
                        "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/3/",
                        "data": {
                          "token": "${ls:token}",
                          "page": "${page}",
                          "perPage": "${perPage}",
                          "keywords": "${keywords}",
                          "_$_tableName": "@Sub_TableName@",
                          "_$_pk": "@sub_pk@",
						  "_id_": "${@pk@}",
                          "_field_": "@pk@",
                          "_$_action": "P",
                          "_$_query_filter": "1^10^@pk@,@seqno@^@detail_fields@^^^@pk@"
                        },
                        "dataType": "form"                        
                      },
                      "quickSaveApi": {
                        "method": "post",
                        "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/3/",
						"data": {
							"&": "$$",
							"token": "${ls:token}",
							"_$_tableName": "@Sub_TableName@",
							"_$_pk": "@sub_pk@",
							"_$_action": "U"
						},
                        "dataType": "form"                       
                      },
                      "syncLocation": false,
                      "perPage": 10,
                      "headerToolbar": [
                        {
                          "type": "search-box",
                          "name": "keywords",
                          "align": "left",
                          "placeholder": "全文檢索"
                        },
						{
							"type": "button",
							"label": "新增表身",
							"actionType": "dialog",
							"level": "primary",
							"dialog": {
								"title": "新增表身",								
								"body": {
									"type": "form",
									"name": "sample-edit-form",
									"api": {
										"method": "post",
										"url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/2/",
										"data": {
											"&": "$$",
											"token": "${ls:token}",
											"_$_tableName": "@Sub_TableName@",
											"_$_pk": "@sub_pk@",
											"_$_action": "C"
										},
										"dataType": "form"
									},
									"body": [
										@Detail_By_add@									
									]
								}
							}
						},
                        {
                          "type": "columns-toggler",
                          "align": "right"
                        },
                        {
                          "type": "drag-toggler",
                          "align": "right"
                        },
                        {
                          "type": "pagination",
                          "align": "right"
                        }
                      ],
                      "footerToolbar": [
                        "statistics",
                        "switch-per-page",
                        "pagination"
                      ],
                      "columns": [
						  @Detail_By_Edit@,
                        {
                          "type": "operation",
                          "label": "操作",
                          "width": 100,
                          "buttons": [
                            {
                              "type": "button",
                              "icon": "fa fa-times text-danger",
                              "actionType": "ajax",
                              "tooltip": "刪除",
                              "confirmText": "確定要刪除本筆資料?",
                              "api": {
                                "method": "post",
                                "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/2/",
								"data": {
									"&": "$$",
									"token": "${ls:token}",
									"_$_tableName": "@Sub_TableName@",
									"_$_pk": "@sub_pk@",
									"_$_action": "D"
								},
                                "dataType": "form"                                                       
                              }
                            }
                          ]
                        }
                      ]
                    }
                  }
                ]
              }
            }
          },
		  @ext_button_I@
          {
            "type": "button",
            "icon": "fa fa-times text-danger",
            "actionType": "ajax",
			"disabledOn": "${ls:@menuid@@delete == null@bpm_edit@",
            "tooltip": "刪除",
            "confirmText": "確定要刪除本筆資料?",
            "api": {
              "method": "post",
              "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/2/",
			  "data": {
				"&": "$$",
				"token": "${ls:token}",
				"_$_tableName": "@TableName@",
				"_$_pk": "@pk@",
				"_$_action": "D"
			  },
              "dataType": "form"
            }
          }
        ]
      }
    ]
  }
}{
  "title": "@functionName@",
  "type": "page",
  "toolbar": [
    {
      "type": "button",
      "label": "新增",
      "icon": "fa fa-plus pull-left",
      "primary": true,
      "actionType": "drawer",
	  "disabledOn": "${ls:@menuid@@insert == null}",
      "drawer": {
        "position": "right",
        "resizable": true,
        "size": "xl",
		"actions": [
			{
			  "label": "存檔",
			  "actionType": "submit",
			  "close": false,
			  "primary": true,
			  "type": "button"
			}
        ],
		@insert_default@
		"title": "新增",
        "body": {
          "type": "form",
          "mode": "horizontal",
          "horizontal": {
            "leftFixed": true
          },
          "name": "sample-edit-form",
		  @init_api_org@
          "api": {
            "method": "post",
            "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/2/",
			"data": {
				"&": "$$",
				"token": "${ls:token}",
				"_$_tableName": "@TableName@",
				"_$_pk": "@pk@",
				"_$_action": "C"
			},
            "dataType": "form"
          },
          "body": [
            @Fields_by_add@,
            {
				"type": "panel",
				"//title": "表身明細",
				"body": [{
					"type": "input-table",
					"name": "details",
					"label": false,
					"addable": true,
					"removable": true,
					"needConfirm": false,
					"canAccessSuperData": true,
					"strictMode": false,
					"columns": [
						@Detail_By_add@
					]
				}]
			}
          ]
        }
      }
    }
  ],
  "body": {
    "type": "crud",
	"tableClassName": "myGridHeader_a",
    "api": {
      "method": "post",
      "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/3/",
      "data": {
        "token": "${ls:token}",
        "page": "${page}",
        "perPage": "${perPage}",
        "keywords": "${keywords}",
		@aside_filter@
		@query_type_data@
        "_$_tableName": "@TableName@",
        "_$_pk": "@pk@",
        "_$_action": "P",
        "_$_query_filter": "1^10^@pk@^*^^@menuid@^@Filters@"
      },
      "dataType": "form"
    },
    "syncLocation": false,
	"autoGenerateFilter": @is_query_header@,
    "perPage": 10,
    "headerToolbar": [
      @keyword_search@
      {
		"type": "export-excel",
		"label": "匯出 Excel",
		"api": {
		  "method": "post",
		  "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/2/",
		  "data": {
	        "token": "${ls:token}",
			"page": "${page}",
			"perPage": "10000",
			"keywords": "${keywords}",
			@aside_filter@
			@query_type_data@
			"_$_tableName": "@TableName@",
			"_$_pk": "@pk@",
			"_$_action": "P",
			"_$_query_filter": "1^10^@pk@^*^^@menuid@^@Filters@"
		  },
		  "dataType": "form"
		}
	  },
	  {
		"type": "button",
		"level": "info",
		"tooltip": "查看 Source",
		"icon": "fas fa-bullseye",
		"actionType": "drawer",
		"drawer": {
			"size": "lg",
			"resizable": true,
			"body": {
				"type": "service",
				"schemaApi": "get:/pages/zen_codeviewer.json"
			},
			"actions": []
		}
	  },
	  @ext_button_U@
      {
        "type": "columns-toggler",
        "align": "right"
      },
      {
        "type": "drag-toggler",
        "align": "right"
      },
      {
        "type": "pagination",
        "align": "right"
      }
    ],
    "footerToolbar": [
      "statistics",
      "switch-per-page",
      "pagination"
    ],
    "columns": [
      @Fields_By_GridView@
      {
        "type": "operation",
        "label": "操作",
        "width": @op-width@,
        "buttons": [
		  {
            "type": "button",
            "icon": "fa fa-eye",
            "actionType": "dialog",
            "dialog": {
              "title": "查看",
              "size": "lg",
              "body": {
                "type": "form",
                "mode": "horizontal",
                "horizontal": {
                  "leftFixed": true
                },
				@init_api_org@
                "body": [
                  @Fields_By_View@,
                  {
                    "type": "panel",
                    "title": "表身明細",
                    "body": {
                      "type": "crud",
					  "tableClassName": "myGridHeader_a",
                      "api": {
                        "method": "post",
                        "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/3/",
                        "data": {
                          "token": "${ls:token}",
                          "page": "${page}",
                          "perPage": "${perPage}",
                          "keywords": "${keywords}",
                          "_$_tableName": "@Sub_TableName@",
                          "_$_pk": "@sub_pk@",
						  "_id_": "${@pk@}",
                          "_field_": "@pk@",
                          "_$_action": "P",
                          "_$_query_filter": "1^10^@pk@,@seqno@^@detail_fields@^^^@pk@"
                        },
                        "dataType": "form"                        
                      },
                      "syncLocation": false,
                      "perPage": 10,
                      "headerToolbar": [
                        {
                          "type": "search-box",
                          "name": "keywords",
                          "align": "left",
                          "placeholder": "全文檢索"
                        },
                        {
                          "type": "columns-toggler",
                          "align": "right"
                        },
                        {
                          "type": "drag-toggler",
                          "align": "right"
                        },
                        {
                          "type": "pagination",
                          "align": "right"
                        }
                      ],
                      "footerToolbar": [
                        "statistics",
                        "switch-per-page",
                        "pagination"
                      ],
                      "columns": [
						  @Detail_By_View@
                      ]
                    }
                  }
                ]
              }
            }
          },
          {
            "type": "button",
            "icon": "fa fa-pencil",
            "actionType": "drawer",
			"disabledOn": "${ls:@menuid@@update == null@bpm_edit@",
            "drawer": {
              "position": "left",
              "resizable": true,
              "size": "xl",
              "title": "編輯",			  
              "body": {
                "type": "form",
                "mode": "horizontal",
                "horizontal": {
                  "leftFixed": true
                },
                "name": "sample-edit-form",
				@init_api_org@
                "api": {
                  "method": "post",
                  "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/2/",
				  "data": {
					"&": "$$",
					"token": "${ls:token}",
					"_$_tableName": "@TableName@",
					"_$_pk": "@pk@",
					"_$_action": "U"
				  },
                  "dataType": "form"
                },
                "body": [
                  @Fields_By_Edit@,
                  {
                    "type": "panel",
                    "title": "表身明細",
                    "body": {
                      "type": "crud",
					  "tableClassName": "myGridHeader_a",
                      "api": {
                        "method": "post",
                        "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/3/",
                        "data": {
                          "token": "${ls:token}",
                          "page": "${page}",
                          "perPage": "${perPage}",
                          "keywords": "${keywords}",
                          "_$_tableName": "@Sub_TableName@",
                          "_$_pk": "@sub_pk@",
						  "_id_": "${@pk@}",
                          "_field_": "@pk@",
                          "_$_action": "P",
                          "_$_query_filter": "1^10^@pk@,@seqno@^@detail_fields@^^^@pk@"
                        },
                        "dataType": "form"                        
                      },
                      "quickSaveApi": {
                        "method": "post",
                        "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/3/",
						"data": {
							"&": "$$",
							"token": "${ls:token}",
							"_$_tableName": "@Sub_TableName@",
							"_$_pk": "@sub_pk@",
							"_$_action": "U"
						},
                        "dataType": "form"                      
                      },
                      "syncLocation": false,
                      "perPage": 10,
                      "headerToolbar": [
                        {
                          "type": "search-box",
                          "name": "keywords",
                          "align": "left",
                          "placeholder": "全文檢索"
                        },
						{
							"type": "button",
							"label": "新增表身",
							"actionType": "dialog",
							"level": "primary",
							"dialog": {
								"title": "新增表身",								
								"body": {
									"type": "form",
									"name": "sample-edit-form",
									"api": {
										"method": "post",
										"url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/2/",
										"data": {
											"&": "$$",
											"token": "${ls:token}",
											"_$_tableName": "@Sub_TableName@",
											"_$_pk": "@sub_pk@",
											"_$_action": "C"
										},
										"dataType": "form"
									},
									"body": [
										@Detail_By_add@									
									]
								}
							}
						},
                        {
                          "type": "columns-toggler",
                          "align": "right"
                        },
                        {
                          "type": "drag-toggler",
                          "align": "right"
                        },
                        {
                          "type": "pagination",
                          "align": "right"
                        }
                      ],
                      "footerToolbar": [
                        "statistics",
                        "switch-per-page",
                        "pagination"
                      ],
                      "columns": [
						  @Detail_By_Edit@,
                        {
                          "type": "operation",
                          "label": "操作",
                          "width": 100,
                          "buttons": [
                            {
                              "type": "button",
                              "icon": "fa fa-times text-danger",
                              "actionType": "ajax",
                              "tooltip": "刪除",
                              "confirmText": "確定要刪除本筆資料?",
                              "api": {
                                "method": "post",
                                "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/2/",
								"data": {
									"&": "$$",
									"token": "${ls:token}",
									"_$_tableName": "@Sub_TableName@",
									"_$_pk": "@sub_pk@",
									"_$_action": "D"
								},
                                "dataType": "form"                                                    
                              }
                            }
                          ]
                        }
                      ]
                    }
                  }
                ]
              }
            }
          },
		  @ext_button_I@
          {
            "type": "button",
            "icon": "fa fa-times text-danger",
            "actionType": "ajax",
			"disabledOn": "${ls:@menuid@@delete == null@bpm_edit@",
            "tooltip": "刪除",
            "confirmText": "確定要刪除本筆資料?",
            "api": {
              "method": "post",
              "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/2/",
			  "data": {
				"&": "$$",
				"token": "${ls:token}",
				"_$_tableName": "@TableName@",
				"_$_pk": "@pk@",
				"_$_action": "D"
			  },
              "dataType": "form"
            }
          }
        ]
      }
    ]
  }
}