请问 Master-Detail 窗体,明细(Detail)文件的部分用 crud 实作新增及编辑功能
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 18.9k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
实现场景:
请问 Master-Detail 窗体,明细(Detail)文件的部分用 crud 实作新增及编辑功能,目前的写法会直接写入数据库,但是画面 UI 无法 reload,请教该如何改才能于存档后,画面同步更新?
存在的问题:
存档后,画面未同步更新
当前方案:
{
"title": "測試MD表單",
"type": "page",
"body": {
"type": "crud",
"tableClassName": "myGridHeader_a",
"name": "dataList",
"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": "opoorder9_m",
"_$_pk": "billno",
"_$_action": "P",
"_$_query_filter": "1^10^billno^*^^crmm09^billno,custid,personid,corpmemo,deliveraddress"
},
"dataType": "form",
"//requestAdaptor": "return {\n ...api,\n data: {\n ...api.data,\n _$_tableName: \"opoorder9_m\",\n _$_pk: \"billno\",\n _$_action: \"P\",\n _$_query_filter: \"1^10^billno^*\"}\n}"
},
"syncLocation": false,
"autoGenerateFilter": 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": [
{
"type": "date",
"name": "billdate",
"label": "日 期"
},
{
"type": "text",
"name": "billno",
"label": "訂單編號"
},
{
"type": "text",
"name": "custid",
"label": "客戶編號"
},
{
"type": "text",
"name": "personid",
"label": "業務編號"
},
{
"type": "text",
"name": "corpmemo",
"label": "注意事項"
},
{
"type": "text",
"name": "deliveraddress",
"label": "送貨地址"
},
{
"type": "text",
"name": "totalamount",
"label": "未稅合計"
},
{
"type": "text",
"name": "taxamount",
"label": "稅金"
},
{
"type": "operation",
"label": "操作",
"width": 100,
"buttons": [
{
"type": "button",
"icon": "fa fa-pencil",
"actionType": "drawer",
"disabledOn": "${ls:crmm09@update == null}",
"drawer": {
"position": "left",
"resizable": true,
"size": "xl",
"actions": [
{
"label": "存檔",
"actionType": "submit",
"primary": true,
"type": "button"
},
{
"label": "取消",
"actionType": "cancel",
"type": "button"
}
],
"title": "編輯",
"body": {
"type": "form",
"//promptPageLeave": true,
"//debug": true,
"mode": "horizontal",
"horizontal": {
"leftFixed": true
},
"name": "md-edit-form",
"api": {
"method": "post",
"url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/2/",
"dataType": "form",
"requestAdaptor": "return {\n ...api,\n data: {\n ...api.data,\n token: local_get_token(),\n _$_tableName: \"opoorder9_m\",\n _$_pk: \"billno\",\n _$_action: \"U\"}\n}"
},
"body": [
{
"type": "group",
"body": [
{
"type": "input-date",
"name": "billdate",
"format": "YYYY-MM-DDTHH:mm:ss.SSSZ",
"required": true,
"label": "日 期"
},
{
"type": "input-text",
"name": "billno",
"disabled": true,
"required": true,
"label": "訂單編號"
}
]
},
{
"type": "input-text",
"name": "corpmemo",
"label": "注意事項"
},
{
"type": "textarea",
"name": "deliveraddress",
"showCounter": true,
"label": "送貨地址"
},
{
"type": "group",
"body": [
{
"type": "input-number",
"name": "totalamount",
"label": "未稅合計"
},
{
"type": "formula",
"name": "totalamount",
"value": 0,
"formula": "${details|pick:subamount|sum}"
},
{
"type": "input-number",
"name": "taxamount",
"label": "稅金"
},
{
"type": "formula",
"name": "taxamount",
"value": 0,
"formula": "${totalamount*0.05|round:0}"
}
]
},
{
"type": "form",
"//promptPageLeave": true,
"//debug": true,
"title": "表身明細",
"actions": [],
"name": "form_detail",
"body": {
"type": "crud",
"name": "crud_detail",
"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": "opoorder9_d",
"_$_pk": "billno,uniqueno",
"_id_": "${billno}",
"_field_": "billno",
"_$_action": "P",
"_$_query_filter": "1^10^billno,seqno^billno,seqno,productid,prodcname,quantity,unit,price,subamount,onhanddate,isgiftprod,uniqueno ^^^billno"
},
"dataType": "form"
},
"syncLocation": false,
"perPage": 10,
"headerToolbar": [
{
"type": "search-box",
"name": "keywords",
"align": "left",
"placeholder": "全文檢索"
},
{
"type": "button",
"label": "新增表身",
"level": "primary",
"actionType": "drawer",
"drawer": {
"title": "新增表身",
"position": "right",
"body": {
"type": "form",
"//reload": "dataList.md-edit-form.form_detail.crud_detail",
"//promptPageLeave": true,
"name": "sample-edit-form",
"api": {
"method": "post",
"url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/2/",
"dataType": "form",
"requestAdaptor": "return {\n ...api,\n data: {\n ...api.data,\n token: local_get_token(),\n _$_tableName: \"opoorder9_d\",\n _$_pk: \"billno,uniqueno\",\n _$_action: \"C\"}\n}"
},
"body": [
{
"type": "hidden",
"name": "billno",
"width": 60,
"value": "自動編碼",
"label": "訂單編號"
},
{
"type": "input-text",
"name": "seqno",
"width": 60,
"value": "1",
"align": "right",
"required": true,
"label": "欄號"
},
{
"type": "picker",
"name": "productid",
"joinValues": false,
"valueField": "productid",
"labelField": "productid",
"width": 200,
"label": "產品編號",
"source": {
"method": "post",
"url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/3/",
"data": {
"page": "${page}",
"perPage": "${perPage}",
"keywords": "${productid_keywords}",
"_$_tableName": "basproduct",
"_$_pk": "productid",
"_$_action": "P",
"_$_query_filter": "1^10^productid^*^^^productid,scancode,invoiceprodname,prodcname,prodstructure,saleprice,calcunit"
},
"dataType": "form"
},
"size": "lg",
"value": "",
"multiple": false,
"pickerSchema": {
"mode": "table",
"tableClassName": "myGridHeader_a",
"title": "產品資料維護",
"name": "basproduct_productid",
"headerToolbar": {
"wrapWithPanel": false,
"type": "form",
"promptPageLeave": true,
"className": "text-right",
"target": "basproduct_productid",
"mode": "inline",
"body": [
{
"type": "input-text",
"name": "productid_keywords",
"addOn": {
"type": "submit",
"label": "查詢",
"tooltip": "輸入 * 可以查詢全部資料",
"level": "primary",
"icon": "fa fa-search pull-left"
}
}
]
},
"columns": [
{
"type": "text",
"name": "productid",
"label": "產品編號",
"toggled": true
},
{
"type": "text",
"name": "scancode",
"label": "條碼編號",
"toggled": true
},
{
"type": "text",
"name": "invoiceprodname",
"label": "產品品牌",
"toggled": true
},
{
"type": "text",
"name": "prodcateid",
"label": "產品類別",
"toggled": true
},
{
"type": "text",
"name": "prodcname",
"label": "產品品名",
"toggled": true
},
{
"type": "text",
"name": "prodstructure",
"label": "產品規格",
"toggled": true
},
{
"type": "text",
"name": "saleprice",
"label": "建議售價",
"toggled": true
},
{
"type": "text",
"name": "calcunit",
"label": "計量單位",
"toggled": true
}
]
}
},
{
"type": "input-text",
"name": "prodcname",
"width": 200,
"value": "${productid.prodcname}",
"required": true,
"label": "品名"
},
{
"type": "input-number",
"name": "quantity",
"width": 80,
"value": "1",
"align": "right",
"label": "數量"
},
{
"type": "input-text",
"name": "unit",
"width": 80,
"value": "${productid.calcunit}",
"label": "單位"
},
{
"type": "input-number",
"name": "price",
"width": 80,
"value": "${productid.saleprice}",
"label": "單價"
},
{
"type": "input-number",
"name": "subamount",
"label": "金額"
},
{
"type": "formula",
"name": "subamount",
"value": 0,
"formula": "${quantity * price}"
},
{
"type": "input-date",
"name": "onhanddate",
"width": 120,
"value": "+15days",
"format": "YYYY-MM-DD",
"label": "預交貨日"
},
{
"type": "switch",
"name": "isgiftprod",
"width": 80,
"trueValue": "Y",
"falseValue": "N",
"label": "贈品"
},
{
"type": "hidden",
"name": "uniqueno",
"width": 80,
"label": "唯一序號"
}
]
}
}
},
{
"type": "columns-toggler",
"align": "right"
},
{
"type": "drag-toggler",
"align": "right"
},
{
"type": "pagination",
"align": "right"
}
],
"footerToolbar": [
"statistics",
"switch-per-page",
"pagination"
],
"columns": [
{
"type": "static",
"name": "seqno",
"label": "欄號"
},
{
"type": "static",
"name": "productid",
"label": "產品編號"
},
{
"type": "static",
"name": "prodcname",
"label": "品名"
},
{
"type": "static",
"name": "quantity",
"label": "數量"
},
{
"type": "static",
"name": "unit",
"label": "單位"
},
{
"type": "static",
"name": "price",
"label": "單價"
},
{
"type": "static",
"name": "subamount",
"label": "金額"
},
{
"type": "static-date",
"name": "onhanddate",
"label": "預交貨日"
},
{
"type": "static",
"name": "isgiftprod",
"label": "贈品"
},
{
"type": "operation",
"label": "操作",
"width": 100,
"buttons": [
{
"type": "button",
"icon": "fa fa-pencil",
"tooltip": "編輯",
"actionType": "drawer",
"drawer": {
"position": "left",
"resizable": true,
"size": "md",
"actions": [
{
"label": "存檔",
"actionType": "submit",
"primary": true,
"type": "button"
},
{
"label": "取消",
"actionType": "cancel",
"type": "button"
}
],
"title": "編輯",
"body": {
"type": "form",
"promptPageLeave": true,
"mode": "horizontal",
"horizontal": {
"leftFixed": true
},
"name": "sample-edit-form",
"api": {
"method": "post",
"url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/3/",
"dataType": "form",
"requestAdaptor": "return {\n ...api,\n data: {\n ...api.data,\n token: local_get_token(),\n _$_tableName: \"opoorder9_d\",\n _$_pk: \"billno,uniqueno\",\n _$_action: \"U\"}\n}"
},
"body": [
{
"type": "hidden",
"name": "billno",
"disabled": true,
"label": "訂單編號"
},
{
"type": "input-text",
"name": "seqno",
"required": true,
"label": "欄號"
},
{
"type": "picker",
"name": "productid",
"joinValues": false,
"valueField": "productid",
"labelField": "productid",
"width": 200,
"label": "產品編號",
"source": {
"method": "post",
"url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/3/",
"data": {
"page": "${page}",
"perPage": "${perPage}",
"keywords": "${productid_keywords}",
"_$_tableName": "basproduct",
"_$_pk": "productid",
"_$_action": "P",
"_$_query_filter": "1^10^productid^*^^^productid,scancode,invoiceprodname,prodcname,prodstructure,saleprice,calcunit"
},
"dataType": "form"
},
"size": "lg",
"value": "",
"multiple": false,
"pickerSchema": {
"mode": "table",
"tableClassName": "myGridHeader_a",
"title": "產品資料維護",
"name": "basproduct_productid",
"headerToolbar": {
"wrapWithPanel": false,
"type": "form",
"promptPageLeave": true,
"className": "text-right",
"target": "basproduct_productid",
"mode": "inline",
"body": [
{
"type": "input-text",
"name": "productid_keywords",
"addOn": {
"type": "submit",
"label": "查詢",
"tooltip": "輸入 * 可以查詢全部資料",
"level": "primary",
"icon": "fa fa-search pull-left"
}
}
]
},
"columns": [
{
"type": "text",
"name": "productid",
"label": "產品編號",
"toggled": true
},
{
"type": "text",
"name": "scancode",
"label": "條碼編號",
"toggled": true
},
{
"type": "text",
"name": "invoiceprodname",
"label": "產品品牌",
"toggled": true
},
{
"type": "text",
"name": "prodcateid",
"label": "產品類別",
"toggled": true
},
{
"type": "text",
"name": "prodcname",
"label": "產品品名",
"toggled": true
},
{
"type": "text",
"name": "prodstructure",
"label": "產品規格",
"toggled": true
},
{
"type": "text",
"name": "saleprice",
"label": "建議售價",
"toggled": true
},
{
"type": "text",
"name": "calcunit",
"label": "計量單位",
"toggled": true
}
]
}
},
{
"type": "input-text",
"name": "prodcname",
"value": "${productid.prodcname|isFalse:prodcname:productid.prodcname}",
"required": true,
"label": "品名"
},
{
"type": "input-number",
"name": "quantity",
"label": "數量"
},
{
"type": "input-text",
"name": "unit",
"value": "${productid.calcunit|isFalse:unit:productid.calcunit}",
"label": "單位"
},
{
"type": "input-number",
"name": "price",
"value": "${productid.saleprice|isFalse:price:productid.saleprice}",
"label": "單價"
},
{
"type": "input-number",
"name": "subamount",
"label": "金額"
},
{
"type": "formula",
"name": "subamount",
"value": 0,
"formula": "${quantity * price}"
},
{
"type": "input-date",
"name": "onhanddate",
"format": "YYYY-MM-DDTHH:mm:ss.SSSZ",
"label": "預交貨日"
},
{
"type": "switch",
"name": "isgiftprod",
"trueValue": "Y",
"falseValue": "N",
"label": "贈品"
},
{
"type": "hidden",
"name": "uniqueno",
"disabled": true,
"label": "唯一序號"
}
]
}
}
},
{
"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/",
"dataType": "form",
"requestAdaptor": "return {\n ...api,\n data: {\n ...api.data,\n token: local_get_token(),\n _$_tableName: \"opoorder9_d\",\n _$_pk: \"billno,uniqueno\",\n _$_action: \"D\"}\n}"
}
}
]
}
]
}
}
]
}
}
},
{
"type": "button",
"icon": "fa fa-times text-danger",
"actionType": "ajax",
"disabledOn": "${ls:crmm09@delete == null}",
"tooltip": "刪除",
"confirmText": "確定要刪除本筆資料?",
"api": {
"method": "post",
"url": "${ls:base_ip}/xapi/v2/${ls:base_db}/orm_api/2/",
"dataType": "form",
"requestAdaptor": "return {\n ...api,\n data: {\n ...api.data,\n token: local_get_token(),\n _$_tableName: \"opoorder9_m\",\n _$_pk: \"billno\",\n _$_action: \"D\"}\n}"
}
}
]
}
]
}
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported Master-Detail configuration with the nested crud_detail inside md-edit-form.form_detail, focusing on the commented //reload target in the detail creation form. Trace how the create request completes and whether the parent detail CRUD refreshes; done means the saved detail appears in the UI without manually reloading the page.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100