@steedos-widgets/amis-lib 1.3.21 → 1.3.22-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/index.cjs.js +176 -236
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +176 -236
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +41 -25
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/input_table.d.ts +0 -11
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1762,21 +1762,21 @@ async function getQuickEditSchema(field, options){
|
|
|
1762
1762
|
break;
|
|
1763
1763
|
case "avatar":
|
|
1764
1764
|
case "image":
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1765
|
+
quickEditSchema.body[0].receiver.adaptor = `
|
|
1766
|
+
const { context } = api.body;
|
|
1767
|
+
var rootUrl = context.rootUrl + "/api/files/${field.type}s/";
|
|
1768
|
+
payload = {
|
|
1769
|
+
status: response.status == 200 ? 0 : response.status,
|
|
1770
|
+
msg: response.statusText,
|
|
1771
|
+
data: {
|
|
1772
|
+
value: rootUrl + payload._id,//为了实现图片crud的回显,需要将value从id改为url,当保存数据数据时,再在发送适配器内重新将id提取出来
|
|
1773
|
+
name: payload.original.name,
|
|
1774
|
+
url: rootUrl + payload._id,
|
|
1775
|
+
}
|
|
1775
1776
|
}
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
break;
|
|
1777
|
+
return payload;
|
|
1778
|
+
`;
|
|
1779
|
+
break;
|
|
1780
1780
|
}
|
|
1781
1781
|
quickEditSchema.body[0].visibleOn = "${quickedit_record_permissions.allowEdit && quickedit_record_permissions_loading == false}";
|
|
1782
1782
|
quickEditSchema.body.push({
|
|
@@ -1983,6 +1983,11 @@ async function getQuickEditSchema(field, options){
|
|
|
1983
1983
|
if(field.type == "location"){
|
|
1984
1984
|
quickEditSchema = false;
|
|
1985
1985
|
}
|
|
1986
|
+
if(field.type == "color"){
|
|
1987
|
+
quickEditSchema = {
|
|
1988
|
+
type: "input-color"
|
|
1989
|
+
};
|
|
1990
|
+
}
|
|
1986
1991
|
}
|
|
1987
1992
|
return quickEditSchema;
|
|
1988
1993
|
}
|
|
@@ -11534,6 +11539,13 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
11534
11539
|
};
|
|
11535
11540
|
if(readonly){
|
|
11536
11541
|
convertData.defaultColor = null;
|
|
11542
|
+
}else {
|
|
11543
|
+
convertData.pipeIn = (value, data) => {
|
|
11544
|
+
if(value && value.indexOf('#')<0){
|
|
11545
|
+
return '#'+value;
|
|
11546
|
+
}
|
|
11547
|
+
return value;
|
|
11548
|
+
};
|
|
11537
11549
|
}
|
|
11538
11550
|
break;
|
|
11539
11551
|
case 'boolean':
|
|
@@ -12389,7 +12401,7 @@ async function getFormBody(permissionFields, formFields, ctx){
|
|
|
12389
12401
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
12390
12402
|
* @Date: 2023-11-15 09:50:22
|
|
12391
12403
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
12392
|
-
* @LastEditTime: 2023-12-
|
|
12404
|
+
* @LastEditTime: 2023-12-19 15:53:32
|
|
12393
12405
|
*/
|
|
12394
12406
|
|
|
12395
12407
|
/**
|
|
@@ -12488,33 +12500,22 @@ function getFormPagination(props) {
|
|
|
12488
12500
|
let __paginationServiceId = event.data.__paginationServiceId;
|
|
12489
12501
|
let __wrapperServiceId = event.data.__wrapperServiceId;
|
|
12490
12502
|
let __formId = event.data.__formId;
|
|
12491
|
-
let fieldValue = event.data.
|
|
12503
|
+
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
12492
12504
|
let pageChangeDirection = context.props.pageChangeDirection;
|
|
12493
12505
|
let currentPage = event.data.__page;
|
|
12494
12506
|
let currentIndex = event.data.index;
|
|
12495
12507
|
|
|
12496
|
-
// 翻页到下一页之前需要先把当前页改动的内容保存到中间变量
|
|
12508
|
+
// 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
|
|
12497
12509
|
let currentFormValues = scope.getComponentById(__formId).getValues();
|
|
12498
12510
|
fieldValue[currentIndex] = currentFormValues;
|
|
12499
|
-
//
|
|
12500
|
-
|
|
12501
|
-
|
|
12502
|
-
|
|
12503
|
-
|
|
12504
|
-
|
|
12505
|
-
|
|
12506
|
-
|
|
12507
|
-
// }
|
|
12508
|
-
// });
|
|
12509
|
-
// 如果翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,需要额外给正式表单字段执行一次setValue
|
|
12510
|
-
// 但是同时保存到正式表单字段中会造成翻页后点击取消无法取消翻页之前的改动内容
|
|
12511
|
-
// doAction({
|
|
12512
|
-
// "componentId": "${props.id}",
|
|
12513
|
-
// "actionType": "setValue",
|
|
12514
|
-
// "args": {
|
|
12515
|
-
// "value": fieldValue
|
|
12516
|
-
// }
|
|
12517
|
-
// });
|
|
12511
|
+
// 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
|
|
12512
|
+
doAction({
|
|
12513
|
+
"componentId": "${props.id}",
|
|
12514
|
+
"actionType": "setValue",
|
|
12515
|
+
"args": {
|
|
12516
|
+
"value": fieldValue
|
|
12517
|
+
}
|
|
12518
|
+
});
|
|
12518
12519
|
|
|
12519
12520
|
// 以下是翻页逻辑,翻到下一页并把下一页内容显示到表单上
|
|
12520
12521
|
let targetPage;
|
|
@@ -12525,7 +12526,7 @@ function getFormPagination(props) {
|
|
|
12525
12526
|
targetPage = currentPage - 1;
|
|
12526
12527
|
}
|
|
12527
12528
|
let targetIndex = targetPage - 1;//input-table组件行索引,从0开始的索引
|
|
12528
|
-
// let targetFormData =
|
|
12529
|
+
// let targetFormData = __tableItems[targetIndex];
|
|
12529
12530
|
doAction({
|
|
12530
12531
|
"actionType": "setValue",
|
|
12531
12532
|
"componentId": __paginationServiceId,
|
|
@@ -12605,16 +12606,11 @@ function getFormPagination(props) {
|
|
|
12605
12606
|
*/
|
|
12606
12607
|
function getFormPaginationWrapper(props, form, mode) {
|
|
12607
12608
|
let serviceId = `service_popup_pagination_wrapper__${props.id}`;
|
|
12608
|
-
// 这里加__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
12609
|
-
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
12610
|
-
// 只读的时候不可以走中间变量__changedItems,比如工作流规则详细页面修改了子表字段”时间触发器“值后,在只读界面点击查看按钮弹出的表单中__changedItems值是修改前的值
|
|
12611
|
-
let formValues = mode === "readonly" ? `\${${props.name}[__super.index]}` : "${__changedItems[__super.index]}";
|
|
12612
|
-
// 这时用__readonlyItemsLength是因为`\${${props.name}.length}`拿不到值
|
|
12613
|
-
let totalValue = mode === "readonly" ? "${__readonlyItemsLength}" : "${__changedItems.length}";
|
|
12614
12609
|
let innerForm = Object.assign({}, form, {
|
|
12615
12610
|
"data": {
|
|
12616
|
-
//
|
|
12617
|
-
|
|
12611
|
+
// 这里加__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
12612
|
+
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
12613
|
+
"&": "${__tableItems[__super.index]}"
|
|
12618
12614
|
}
|
|
12619
12615
|
});
|
|
12620
12616
|
let formBody = [
|
|
@@ -12637,47 +12633,43 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12637
12633
|
}
|
|
12638
12634
|
];
|
|
12639
12635
|
let onServiceInitedScript = `
|
|
12640
|
-
//
|
|
12641
|
-
// inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
|
|
12642
|
-
//
|
|
12636
|
+
// 以下脚本是为了解决有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
|
|
12637
|
+
// 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
|
|
12638
|
+
// 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
|
|
12639
|
+
// 再比如工作流规则详细页面修改了子表字段”时间触发器“值后,在只读界面点击查看按钮弹出的表单中__tableItems值是修改前的值
|
|
12640
|
+
// 处理思路是每次弹出form之前先把其__tableItems同步更新为最新值,这样就能在弹出form中包含单元格中做的修改
|
|
12643
12641
|
// 注意:service init事件只会在每次弹出窗口时才执行,在触发翻页时并不会触发service init事件
|
|
12644
|
-
let inlineEditMode = ${props.inlineEditMode};
|
|
12645
|
-
if(!inlineEditMode){
|
|
12646
|
-
return;
|
|
12647
|
-
}
|
|
12648
12642
|
let scope = event.context.scoped;
|
|
12649
12643
|
let __wrapperServiceId = event.data.__wrapperServiceId;
|
|
12650
12644
|
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
12651
12645
|
let wrapperServiceData = wrapperService.getData();
|
|
12652
12646
|
let lastestFieldValue = wrapperServiceData["${props.name}"];//这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
12653
|
-
//不可以直接像event.data.
|
|
12654
|
-
event.data.
|
|
12655
|
-
event.data.
|
|
12647
|
+
//不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
|
|
12648
|
+
event.data.__tableItems.forEach(function(n,i){
|
|
12649
|
+
event.data.__tableItems[i] = lastestFieldValue[i];
|
|
12656
12650
|
});
|
|
12657
12651
|
`;
|
|
12658
12652
|
let schema = {
|
|
12659
12653
|
"type": "service",
|
|
12660
12654
|
"id": serviceId,
|
|
12661
12655
|
"schemaApi": {
|
|
12662
|
-
"url": "${context.rootUrl}/graphql?rebuildOn=${index}",
|
|
12663
|
-
|
|
12664
|
-
"
|
|
12665
|
-
"
|
|
12666
|
-
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
12667
|
-
},
|
|
12668
|
-
"requestAdaptor": "api.data={query: '{spaces__findOne(id: \"none\"){_id,name}}'};return api;",
|
|
12656
|
+
// "url": "${context.rootUrl}/graphql?rebuildOn=${index}",
|
|
12657
|
+
"url": "${context.rootUrl}/api/v1/spaces/none",
|
|
12658
|
+
"trackExpression": "${index}",
|
|
12659
|
+
"method": "get",
|
|
12669
12660
|
"adaptor": `
|
|
12670
12661
|
const formBody = ${JSON.stringify(formBody)};
|
|
12671
12662
|
return {
|
|
12672
12663
|
"body": formBody
|
|
12673
12664
|
}
|
|
12674
|
-
|
|
12665
|
+
`,
|
|
12666
|
+
"cache": 600000
|
|
12675
12667
|
},
|
|
12676
12668
|
// "body": formBody,
|
|
12677
12669
|
"data": {
|
|
12678
12670
|
"__page": "${index + 1}",
|
|
12679
12671
|
// "__total": `\${${props.name}.length}`,
|
|
12680
|
-
"__total":
|
|
12672
|
+
"__total": "${__tableItems.length}",
|
|
12681
12673
|
"__paginationServiceId": serviceId,
|
|
12682
12674
|
"__formId": form.id
|
|
12683
12675
|
},
|
|
@@ -12699,13 +12691,15 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12699
12691
|
* @param {*} props
|
|
12700
12692
|
* @param {*} mode edit/new/readonly
|
|
12701
12693
|
*/
|
|
12702
|
-
async function getForm(props, mode = "edit") {
|
|
12694
|
+
async function getForm(props, mode = "edit", formId) {
|
|
12703
12695
|
let formFields = getFormFields(props, mode);
|
|
12704
12696
|
let body = await getFormBody(null, formFields);
|
|
12705
|
-
|
|
12697
|
+
if(!formId){
|
|
12698
|
+
formId = `form_popup__${props.id}`;
|
|
12699
|
+
}
|
|
12706
12700
|
let schema = {
|
|
12707
12701
|
"type": "form",
|
|
12708
|
-
"id":
|
|
12702
|
+
"id": formId,
|
|
12709
12703
|
"title": "表单",
|
|
12710
12704
|
"debug": false,
|
|
12711
12705
|
"mode": "normal",
|
|
@@ -12717,8 +12711,7 @@ async function getForm(props, mode = "edit") {
|
|
|
12717
12711
|
if (mode === "edit") {
|
|
12718
12712
|
let onEditItemSubmitScript = `
|
|
12719
12713
|
// let fieldValue = _.cloneDeep(event.data["${props.name}"]);
|
|
12720
|
-
let fieldValue = event.data.
|
|
12721
|
-
|
|
12714
|
+
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
12722
12715
|
//这里加__super.__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
12723
12716
|
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
12724
12717
|
fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
|
|
@@ -12729,16 +12722,6 @@ async function getForm(props, mode = "edit") {
|
|
|
12729
12722
|
"value": fieldValue
|
|
12730
12723
|
}
|
|
12731
12724
|
});
|
|
12732
|
-
// // 因为翻页form中用的是event.data.changedItems中的数据,所以不需要像下面这样doAction setValue变更中间变量changedItems值
|
|
12733
|
-
// doAction({
|
|
12734
|
-
// "componentId": event.data.__wrapperServiceId,
|
|
12735
|
-
// "actionType": "setValue",
|
|
12736
|
-
// "args": {
|
|
12737
|
-
// "value": {
|
|
12738
|
-
// "__changedItems": fieldValue
|
|
12739
|
-
// }
|
|
12740
|
-
// }
|
|
12741
|
-
// });
|
|
12742
12725
|
`;
|
|
12743
12726
|
Object.assign(schema, {
|
|
12744
12727
|
"onEvent": {
|
|
@@ -12766,29 +12749,30 @@ async function getForm(props, mode = "edit") {
|
|
|
12766
12749
|
}
|
|
12767
12750
|
else if (mode === "new") {
|
|
12768
12751
|
let onNewItemSubmitScript = `
|
|
12769
|
-
|
|
12770
|
-
if(
|
|
12771
|
-
event.data.
|
|
12752
|
+
let newItem = JSON.parse(JSON.stringify(event.data));
|
|
12753
|
+
if(event.data["${props.name}"]){
|
|
12754
|
+
// let fieldValue = event.data.__tableItems;
|
|
12755
|
+
// 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
|
|
12756
|
+
let fieldValue = event.data["${props.name}"];
|
|
12757
|
+
fieldValue.push(newItem);
|
|
12758
|
+
doAction({
|
|
12759
|
+
"componentId": "${props.id}",
|
|
12760
|
+
"actionType": "setValue",
|
|
12761
|
+
"args": {
|
|
12762
|
+
"value": fieldValue
|
|
12763
|
+
}
|
|
12764
|
+
});
|
|
12765
|
+
}
|
|
12766
|
+
else{
|
|
12767
|
+
// 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
|
|
12768
|
+
doAction({
|
|
12769
|
+
"componentId": "${props.id}",
|
|
12770
|
+
"actionType": "setValue",
|
|
12771
|
+
"args": {
|
|
12772
|
+
"value": [newItem]
|
|
12773
|
+
}
|
|
12774
|
+
});
|
|
12772
12775
|
}
|
|
12773
|
-
let fieldValue = event.data.__changedItems;
|
|
12774
|
-
fieldValue.push(JSON.parse(JSON.stringify(event.data)));
|
|
12775
|
-
doAction({
|
|
12776
|
-
"componentId": "${props.id}",
|
|
12777
|
-
"actionType": "setValue",
|
|
12778
|
-
"args": {
|
|
12779
|
-
"value": fieldValue
|
|
12780
|
-
}
|
|
12781
|
-
});
|
|
12782
|
-
// // 因为翻页form中用的是event.data.changedItems中的数据,所以不需要像下面这样doAction setValue变更中间变量changedItems值
|
|
12783
|
-
// doAction({
|
|
12784
|
-
// "componentId": event.data.__wrapperServiceId,
|
|
12785
|
-
// "actionType": "setValue",
|
|
12786
|
-
// "args": {
|
|
12787
|
-
// "value": {
|
|
12788
|
-
// "__changedItems": fieldValue
|
|
12789
|
-
// }
|
|
12790
|
-
// }
|
|
12791
|
-
// });
|
|
12792
12776
|
`;
|
|
12793
12777
|
Object.assign(schema, {
|
|
12794
12778
|
"onEvent": {
|
|
@@ -12815,12 +12799,13 @@ async function getForm(props, mode = "edit") {
|
|
|
12815
12799
|
});
|
|
12816
12800
|
}
|
|
12817
12801
|
if (mode === "edit" || mode === "readonly") {
|
|
12818
|
-
schema = getFormPaginationWrapper(props, schema
|
|
12802
|
+
schema = getFormPaginationWrapper(props, schema);
|
|
12819
12803
|
}
|
|
12820
12804
|
return schema;
|
|
12821
12805
|
}
|
|
12822
12806
|
|
|
12823
12807
|
async function getButtonNew(props) {
|
|
12808
|
+
let formId = `form_popup__${props.id}`;
|
|
12824
12809
|
return {
|
|
12825
12810
|
"label": "新增",
|
|
12826
12811
|
"type": "button",
|
|
@@ -12834,14 +12819,28 @@ async function getButtonNew(props) {
|
|
|
12834
12819
|
"type": "dialog",
|
|
12835
12820
|
"title": "新增行",
|
|
12836
12821
|
"body": [
|
|
12837
|
-
await getForm(props, "new")
|
|
12822
|
+
await getForm(props, "new", formId)
|
|
12838
12823
|
],
|
|
12839
12824
|
"size": "lg",
|
|
12840
12825
|
"showCloseButton": true,
|
|
12841
12826
|
"showErrorMsg": true,
|
|
12842
12827
|
"showLoading": true,
|
|
12843
12828
|
"className": "app-popover",
|
|
12844
|
-
"closeOnEsc": false
|
|
12829
|
+
"closeOnEsc": false,
|
|
12830
|
+
"onEvent": {
|
|
12831
|
+
"confirm": {
|
|
12832
|
+
"actions": [
|
|
12833
|
+
{
|
|
12834
|
+
"actionType": "validate",
|
|
12835
|
+
"componentId": formId
|
|
12836
|
+
},
|
|
12837
|
+
{
|
|
12838
|
+
"preventDefault": true,
|
|
12839
|
+
"expression": "${event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
|
|
12840
|
+
}
|
|
12841
|
+
]
|
|
12842
|
+
}
|
|
12843
|
+
}
|
|
12845
12844
|
}
|
|
12846
12845
|
}
|
|
12847
12846
|
]
|
|
@@ -12852,27 +12851,7 @@ async function getButtonNew(props) {
|
|
|
12852
12851
|
}
|
|
12853
12852
|
|
|
12854
12853
|
async function getButtonEdit(props, showAsInlineEditMode) {
|
|
12855
|
-
let
|
|
12856
|
-
let scope = event.context.scoped;
|
|
12857
|
-
let __wrapperServiceId = event.data.__wrapperServiceId;
|
|
12858
|
-
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
12859
|
-
let wrapperServiceData = wrapperService.getData();
|
|
12860
|
-
let originalFieldValue = wrapperServiceData["${props.name}"];//这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
12861
|
-
//不可以直接像event.data.__changedItems = originalFieldValue; 这样整个赋值,否则作用域会断,造成无法还原
|
|
12862
|
-
event.data.__changedItems.forEach(function(n,i){
|
|
12863
|
-
event.data.__changedItems[i] = originalFieldValue[i];
|
|
12864
|
-
});
|
|
12865
|
-
// 因为翻页form中用的是event.data.changedItems中的数据,所以像下面这样doAction setValue无法实现还原
|
|
12866
|
-
// doAction({
|
|
12867
|
-
// "componentId": __wrapperServiceId,
|
|
12868
|
-
// "actionType": "setValue",
|
|
12869
|
-
// "args": {
|
|
12870
|
-
// "value": {
|
|
12871
|
-
// "__changedItems": originalFieldValue
|
|
12872
|
-
// }
|
|
12873
|
-
// }
|
|
12874
|
-
// });
|
|
12875
|
-
`;
|
|
12854
|
+
let formId = `form_popup__${props.id}`;
|
|
12876
12855
|
return {
|
|
12877
12856
|
"type": "button",
|
|
12878
12857
|
"label": "",
|
|
@@ -12887,7 +12866,7 @@ async function getButtonEdit(props, showAsInlineEditMode) {
|
|
|
12887
12866
|
"type": "dialog",
|
|
12888
12867
|
"title": "编辑行",
|
|
12889
12868
|
"body": [
|
|
12890
|
-
await getForm(props, "edit")
|
|
12869
|
+
await getForm(props, "edit", formId)
|
|
12891
12870
|
],
|
|
12892
12871
|
"size": "lg",
|
|
12893
12872
|
"showCloseButton": true,
|
|
@@ -12896,7 +12875,7 @@ async function getButtonEdit(props, showAsInlineEditMode) {
|
|
|
12896
12875
|
"className": "app-popover",
|
|
12897
12876
|
"closeOnEsc": false,
|
|
12898
12877
|
"data": {
|
|
12899
|
-
// 这里必须加data数据映射,否则翻页功能中取
|
|
12878
|
+
// 这里必须加data数据映射,否则翻页功能中取__tableItems值时会乱,比如翻页编辑后会把上一页中没改过的字段值带过去
|
|
12900
12879
|
// 额外把华炎魔方主表记录ObjectForm中的字段值从record变量中映射到子表form中,因为子表lookup字段filtersFunction中可能依赖了主表记录中的字段值,比如“工作流规则”对象“时间触发器”字段中的“日期字段”字段
|
|
12901
12880
|
// 额外把global、uiSchema也映射过去,有可能要用,后续需要用到其他变更可以这里加映射
|
|
12902
12881
|
// "&": "${record || {}}",
|
|
@@ -12906,17 +12885,21 @@ async function getButtonEdit(props, showAsInlineEditMode) {
|
|
|
12906
12885
|
"global": "${global}",
|
|
12907
12886
|
"uiSchema": "${uiSchema}",
|
|
12908
12887
|
"index": "${index}",
|
|
12909
|
-
"
|
|
12888
|
+
"__tableItems": `\${${props.name}}`,
|
|
12910
12889
|
"__wrapperServiceId": "${__wrapperServiceId}"
|
|
12911
12890
|
},
|
|
12912
12891
|
"onEvent": {
|
|
12913
|
-
"
|
|
12914
|
-
|
|
12915
|
-
|
|
12916
|
-
|
|
12917
|
-
|
|
12918
|
-
|
|
12919
|
-
|
|
12892
|
+
"confirm": {
|
|
12893
|
+
"actions": [
|
|
12894
|
+
{
|
|
12895
|
+
"actionType": "validate",
|
|
12896
|
+
"componentId": formId
|
|
12897
|
+
},
|
|
12898
|
+
{
|
|
12899
|
+
"preventDefault": true,
|
|
12900
|
+
"expression": "${event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
|
|
12901
|
+
}
|
|
12902
|
+
]
|
|
12920
12903
|
}
|
|
12921
12904
|
}
|
|
12922
12905
|
}
|
|
@@ -12952,7 +12935,7 @@ async function getButtonView(props) {
|
|
|
12952
12935
|
"closeOnEsc": false,
|
|
12953
12936
|
"actions": [],
|
|
12954
12937
|
"data": {
|
|
12955
|
-
// 这里必须加data数据映射,否则翻页功能中取
|
|
12938
|
+
// 这里必须加data数据映射,否则翻页功能中取__tableItems值时会乱,比如翻页编辑后会把上一页中没改过的字段值带过去
|
|
12956
12939
|
// 额外把华炎魔方主表记录ObjectForm中的字段值从formData变量中映射到子表form中,因为子表lookup字段filtersFunction中可能依赖了主表记录中的字段值,比如“工作流规则”对象“时间触发器”字段中的“日期字段”字段
|
|
12957
12940
|
// global、uiSchema等常用变量本来就在formData变量已经存在了,无需另外映射
|
|
12958
12941
|
// "&": "${formData || {}}",
|
|
@@ -12960,9 +12943,8 @@ async function getButtonView(props) {
|
|
|
12960
12943
|
// 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
|
|
12961
12944
|
"__parentForm": "${__super.__super || {}}",
|
|
12962
12945
|
"index": "${index}",
|
|
12963
|
-
"
|
|
12964
|
-
"__wrapperServiceId": "${__wrapperServiceId}"
|
|
12965
|
-
"__readonlyItemsLength": `\${${props.name}.length}`
|
|
12946
|
+
"__tableItems": `\${${props.name}}`,
|
|
12947
|
+
"__wrapperServiceId": "${__wrapperServiceId}"
|
|
12966
12948
|
}
|
|
12967
12949
|
}
|
|
12968
12950
|
}
|
|
@@ -12974,30 +12956,20 @@ async function getButtonView(props) {
|
|
|
12974
12956
|
|
|
12975
12957
|
function getButtonDelete(props) {
|
|
12976
12958
|
let onDeleteItemScript = `
|
|
12977
|
-
// let fieldValue =
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
12981
|
-
let
|
|
12982
|
-
|
|
12983
|
-
|
|
12959
|
+
// let fieldValue = event.data["${props.name}"];
|
|
12960
|
+
let scope = event.context.scoped;
|
|
12961
|
+
let __wrapperServiceId = event.data.__wrapperServiceId;
|
|
12962
|
+
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
12963
|
+
let wrapperServiceData = wrapperService.getData();
|
|
12964
|
+
let lastestFieldValue = wrapperServiceData["${props.name}"];//这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
12965
|
+
lastestFieldValue.splice(event.data.index, 1);
|
|
12984
12966
|
doAction({
|
|
12985
12967
|
"componentId": "${props.id}",
|
|
12986
12968
|
"actionType": "setValue",
|
|
12987
12969
|
"args": {
|
|
12988
|
-
"value":
|
|
12970
|
+
"value": lastestFieldValue
|
|
12989
12971
|
}
|
|
12990
12972
|
});
|
|
12991
|
-
// // 因为翻页form中用的是event.data.changedItems中的数据,所以不需要像下面这样doAction setValue变更中间变量changedItems值
|
|
12992
|
-
// doAction({
|
|
12993
|
-
// "componentId": event.data.__wrapperServiceId,
|
|
12994
|
-
// "actionType": "setValue",
|
|
12995
|
-
// "args": {
|
|
12996
|
-
// "value": {
|
|
12997
|
-
// "__changedItems": fieldValue
|
|
12998
|
-
// }
|
|
12999
|
-
// }
|
|
13000
|
-
// });
|
|
13001
12973
|
`;
|
|
13002
12974
|
return {
|
|
13003
12975
|
"type": "button",
|
|
@@ -13035,13 +13007,15 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13035
13007
|
if (props.editable) {
|
|
13036
13008
|
let showEditButton = true;
|
|
13037
13009
|
if (showAsInlineEditMode) {
|
|
13038
|
-
//
|
|
13039
|
-
|
|
13040
|
-
|
|
13041
|
-
|
|
13042
|
-
|
|
13043
|
-
|
|
13044
|
-
|
|
13010
|
+
// 始终显示弹出子表表单按钮,如果需要判断只在有列被隐藏时才需要显示弹出表单按钮放开下面的if逻辑就好
|
|
13011
|
+
showEditButton = true;
|
|
13012
|
+
// // inline edit模式下只在有列被隐藏时才需要显示编辑按钮
|
|
13013
|
+
// if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length) {
|
|
13014
|
+
// showEditButton = true;
|
|
13015
|
+
// }
|
|
13016
|
+
// else {
|
|
13017
|
+
// showEditButton = false;
|
|
13018
|
+
// }
|
|
13045
13019
|
}
|
|
13046
13020
|
// 编辑时显示编辑按钮
|
|
13047
13021
|
if (showEditButton) {
|
|
@@ -13051,11 +13025,9 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13051
13025
|
}
|
|
13052
13026
|
else {
|
|
13053
13027
|
// 只读时显示查看按钮
|
|
13054
|
-
if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13058
|
-
}
|
|
13028
|
+
// 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
|
|
13029
|
+
let buttonViewSchema = await getButtonView(props);
|
|
13030
|
+
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13059
13031
|
}
|
|
13060
13032
|
if (props.removable) {
|
|
13061
13033
|
let buttonDeleteSchema = getButtonDelete(props);
|
|
@@ -13091,85 +13063,53 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13091
13063
|
if (showAsInlineEditMode) {
|
|
13092
13064
|
inputTableSchema.needConfirm = false;
|
|
13093
13065
|
}
|
|
13094
|
-
let dataProviderInited = `
|
|
13095
|
-
// 单独维护一份中间变量changedItems,因为原变量在input-table组件有单独的作用域,翻页功能中无法维护此作用域中的行记录值
|
|
13096
|
-
setData({ __changedItems: _.cloneDeep(data["${props.name}"]) || []});
|
|
13097
|
-
`;
|
|
13098
|
-
let onInitScript = `
|
|
13099
|
-
// 上面dataProviderInited中setData有时不生效,没有成功给service组件设置__changedItems变量值
|
|
13100
|
-
// 比如设计字段布局界面中的设置分组功能就因为__changedItems变量值不存在而报错,应该是因为把steedos-input-table组件单独放到弹出窗口中会有这个问题
|
|
13101
|
-
// 所以额外在service init事件中手动设置一次__changedItems值
|
|
13102
|
-
let __wrapperServiceId = event.data.__wrapperServiceId;
|
|
13103
|
-
let fieldValue = _.cloneDeep(event.data["${props.name}"]) || [];
|
|
13104
|
-
doAction({
|
|
13105
|
-
"componentId": __wrapperServiceId,
|
|
13106
|
-
"actionType": "setValue",
|
|
13107
|
-
"args": {
|
|
13108
|
-
"value": {
|
|
13109
|
-
"__changedItems": fieldValue
|
|
13110
|
-
}
|
|
13111
|
-
}
|
|
13112
|
-
});
|
|
13113
|
-
// 下面的doAction好像不是必须的
|
|
13114
|
-
// doAction({
|
|
13115
|
-
// "componentId": "${props.id}",
|
|
13116
|
-
// "actionType": "setValue",
|
|
13117
|
-
// "args": {
|
|
13118
|
-
// "value": fieldValue
|
|
13119
|
-
// }
|
|
13120
|
-
// });
|
|
13121
|
-
`;
|
|
13122
|
-
let schema = {
|
|
13123
|
-
"type": "service",
|
|
13124
|
-
"body": [
|
|
13125
|
-
inputTableSchema
|
|
13126
|
-
],
|
|
13127
|
-
"className": props.className,
|
|
13128
|
-
"id": serviceId,
|
|
13129
|
-
"data": {
|
|
13130
|
-
"__wrapperServiceId": serviceId
|
|
13131
|
-
},
|
|
13132
|
-
"dataProvider": {
|
|
13133
|
-
"inited": dataProviderInited
|
|
13134
|
-
},
|
|
13135
|
-
"onEvent": {
|
|
13136
|
-
"init": {
|
|
13137
|
-
"actions": [
|
|
13138
|
-
{
|
|
13139
|
-
"actionType": "custom",
|
|
13140
|
-
"script": onInitScript
|
|
13141
|
-
}
|
|
13142
|
-
]
|
|
13143
|
-
}
|
|
13144
|
-
}
|
|
13145
|
-
};
|
|
13146
|
-
let footerToolbar = clone(props.footerToolbar || []); //这里不clone的话,会造成死循环,应该是因为props属性变更会让组件重新渲染
|
|
13147
|
-
if (props.addable) {
|
|
13148
|
-
let buttonNewSchema = await getButtonNew(props);
|
|
13149
|
-
footerToolbar.unshift(buttonNewSchema);
|
|
13150
|
-
}
|
|
13151
|
-
if (footerToolbar.length) {
|
|
13152
|
-
schema.body.push({
|
|
13153
|
-
"type": "wrapper",
|
|
13154
|
-
"size": "none",
|
|
13155
|
-
"body": footerToolbar
|
|
13156
|
-
});
|
|
13157
|
-
}
|
|
13158
13066
|
let amis = props["input-table"] || props.amis;//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
|
|
13159
13067
|
if (amis) {
|
|
13160
13068
|
// 支持配置amis属性重写或添加最终生成的input-table中任何属性。
|
|
13161
13069
|
delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
|
|
13162
|
-
Object.assign(
|
|
13070
|
+
Object.assign(inputTableSchema, amis);
|
|
13163
13071
|
}
|
|
13164
13072
|
const isAnyFieldHasDependOn = (props.fields || []).find(function (item) {
|
|
13165
13073
|
return item.depend_on;
|
|
13166
13074
|
});
|
|
13167
|
-
if(isAnyFieldHasDependOn){
|
|
13075
|
+
if (isAnyFieldHasDependOn) {
|
|
13168
13076
|
// 有任意一个子字段有depend_on属性时,强制设置禁用静态模式
|
|
13169
|
-
Object.assign(
|
|
13077
|
+
Object.assign(inputTableSchema, {
|
|
13170
13078
|
strictMode: false
|
|
13171
13079
|
});
|
|
13172
13080
|
}
|
|
13081
|
+
let schemaBody = [inputTableSchema];
|
|
13082
|
+
let footerToolbar = clone(props.footerToolbar || []); //这里不clone的话,会造成死循环,应该是因为props属性变更会让组件重新渲染
|
|
13083
|
+
if (props.addable) {
|
|
13084
|
+
let buttonNewSchema = await getButtonNew(props);
|
|
13085
|
+
footerToolbar.unshift(buttonNewSchema);
|
|
13086
|
+
}
|
|
13087
|
+
if (footerToolbar.length) {
|
|
13088
|
+
schemaBody.push({
|
|
13089
|
+
"type": "wrapper",
|
|
13090
|
+
"size": "none",
|
|
13091
|
+
"body": footerToolbar
|
|
13092
|
+
});
|
|
13093
|
+
}
|
|
13094
|
+
// 不可以直接把headerToolbar unshift进schemaBody,因为它没有显示在label下面,而是显示在上面了,这没有意义
|
|
13095
|
+
// 看起来amis官方后续会支持给input-table组件配置headerToolbar,见:https://github.com/baidu/amis/issues/7246
|
|
13096
|
+
// let headerToolbar = clone(props.headerToolbar || []); //这里不clone的话,会造成死循环,应该是因为props属性变更会让组件重新渲染
|
|
13097
|
+
// if (headerToolbar.length) {
|
|
13098
|
+
// schemaBody.unshift({
|
|
13099
|
+
// "type": "wrapper",
|
|
13100
|
+
// "size": "none",
|
|
13101
|
+
// "body": headerToolbar
|
|
13102
|
+
// });
|
|
13103
|
+
// }
|
|
13104
|
+
let schema = {
|
|
13105
|
+
"type": "service",
|
|
13106
|
+
"body": schemaBody,
|
|
13107
|
+
"className": props.className,
|
|
13108
|
+
"id": serviceId,
|
|
13109
|
+
"data": {
|
|
13110
|
+
"__wrapperServiceId": serviceId
|
|
13111
|
+
}
|
|
13112
|
+
};
|
|
13173
13113
|
// console.log("===schema===", schema);
|
|
13174
13114
|
return schema;
|
|
13175
13115
|
};
|