@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.cjs.js
CHANGED
|
@@ -1789,21 +1789,21 @@ async function getQuickEditSchema(field, options){
|
|
|
1789
1789
|
break;
|
|
1790
1790
|
case "avatar":
|
|
1791
1791
|
case "image":
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1792
|
+
quickEditSchema.body[0].receiver.adaptor = `
|
|
1793
|
+
const { context } = api.body;
|
|
1794
|
+
var rootUrl = context.rootUrl + "/api/files/${field.type}s/";
|
|
1795
|
+
payload = {
|
|
1796
|
+
status: response.status == 200 ? 0 : response.status,
|
|
1797
|
+
msg: response.statusText,
|
|
1798
|
+
data: {
|
|
1799
|
+
value: rootUrl + payload._id,//为了实现图片crud的回显,需要将value从id改为url,当保存数据数据时,再在发送适配器内重新将id提取出来
|
|
1800
|
+
name: payload.original.name,
|
|
1801
|
+
url: rootUrl + payload._id,
|
|
1802
|
+
}
|
|
1802
1803
|
}
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
break;
|
|
1804
|
+
return payload;
|
|
1805
|
+
`;
|
|
1806
|
+
break;
|
|
1807
1807
|
}
|
|
1808
1808
|
quickEditSchema.body[0].visibleOn = "${quickedit_record_permissions.allowEdit && quickedit_record_permissions_loading == false}";
|
|
1809
1809
|
quickEditSchema.body.push({
|
|
@@ -2010,6 +2010,11 @@ async function getQuickEditSchema(field, options){
|
|
|
2010
2010
|
if(field.type == "location"){
|
|
2011
2011
|
quickEditSchema = false;
|
|
2012
2012
|
}
|
|
2013
|
+
if(field.type == "color"){
|
|
2014
|
+
quickEditSchema = {
|
|
2015
|
+
type: "input-color"
|
|
2016
|
+
};
|
|
2017
|
+
}
|
|
2013
2018
|
}
|
|
2014
2019
|
return quickEditSchema;
|
|
2015
2020
|
}
|
|
@@ -11561,6 +11566,13 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
11561
11566
|
};
|
|
11562
11567
|
if(readonly){
|
|
11563
11568
|
convertData.defaultColor = null;
|
|
11569
|
+
}else {
|
|
11570
|
+
convertData.pipeIn = (value, data) => {
|
|
11571
|
+
if(value && value.indexOf('#')<0){
|
|
11572
|
+
return '#'+value;
|
|
11573
|
+
}
|
|
11574
|
+
return value;
|
|
11575
|
+
};
|
|
11564
11576
|
}
|
|
11565
11577
|
break;
|
|
11566
11578
|
case 'boolean':
|
|
@@ -12416,7 +12428,7 @@ async function getFormBody(permissionFields, formFields, ctx){
|
|
|
12416
12428
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
12417
12429
|
* @Date: 2023-11-15 09:50:22
|
|
12418
12430
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
12419
|
-
* @LastEditTime: 2023-12-
|
|
12431
|
+
* @LastEditTime: 2023-12-19 15:53:32
|
|
12420
12432
|
*/
|
|
12421
12433
|
|
|
12422
12434
|
/**
|
|
@@ -12515,33 +12527,22 @@ function getFormPagination(props) {
|
|
|
12515
12527
|
let __paginationServiceId = event.data.__paginationServiceId;
|
|
12516
12528
|
let __wrapperServiceId = event.data.__wrapperServiceId;
|
|
12517
12529
|
let __formId = event.data.__formId;
|
|
12518
|
-
let fieldValue = event.data.
|
|
12530
|
+
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
12519
12531
|
let pageChangeDirection = context.props.pageChangeDirection;
|
|
12520
12532
|
let currentPage = event.data.__page;
|
|
12521
12533
|
let currentIndex = event.data.index;
|
|
12522
12534
|
|
|
12523
|
-
// 翻页到下一页之前需要先把当前页改动的内容保存到中间变量
|
|
12535
|
+
// 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
|
|
12524
12536
|
let currentFormValues = scope.getComponentById(__formId).getValues();
|
|
12525
12537
|
fieldValue[currentIndex] = currentFormValues;
|
|
12526
|
-
//
|
|
12527
|
-
|
|
12528
|
-
|
|
12529
|
-
|
|
12530
|
-
|
|
12531
|
-
|
|
12532
|
-
|
|
12533
|
-
|
|
12534
|
-
// }
|
|
12535
|
-
// });
|
|
12536
|
-
// 如果翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,需要额外给正式表单字段执行一次setValue
|
|
12537
|
-
// 但是同时保存到正式表单字段中会造成翻页后点击取消无法取消翻页之前的改动内容
|
|
12538
|
-
// doAction({
|
|
12539
|
-
// "componentId": "${props.id}",
|
|
12540
|
-
// "actionType": "setValue",
|
|
12541
|
-
// "args": {
|
|
12542
|
-
// "value": fieldValue
|
|
12543
|
-
// }
|
|
12544
|
-
// });
|
|
12538
|
+
// 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
|
|
12539
|
+
doAction({
|
|
12540
|
+
"componentId": "${props.id}",
|
|
12541
|
+
"actionType": "setValue",
|
|
12542
|
+
"args": {
|
|
12543
|
+
"value": fieldValue
|
|
12544
|
+
}
|
|
12545
|
+
});
|
|
12545
12546
|
|
|
12546
12547
|
// 以下是翻页逻辑,翻到下一页并把下一页内容显示到表单上
|
|
12547
12548
|
let targetPage;
|
|
@@ -12552,7 +12553,7 @@ function getFormPagination(props) {
|
|
|
12552
12553
|
targetPage = currentPage - 1;
|
|
12553
12554
|
}
|
|
12554
12555
|
let targetIndex = targetPage - 1;//input-table组件行索引,从0开始的索引
|
|
12555
|
-
// let targetFormData =
|
|
12556
|
+
// let targetFormData = __tableItems[targetIndex];
|
|
12556
12557
|
doAction({
|
|
12557
12558
|
"actionType": "setValue",
|
|
12558
12559
|
"componentId": __paginationServiceId,
|
|
@@ -12632,16 +12633,11 @@ function getFormPagination(props) {
|
|
|
12632
12633
|
*/
|
|
12633
12634
|
function getFormPaginationWrapper(props, form, mode) {
|
|
12634
12635
|
let serviceId = `service_popup_pagination_wrapper__${props.id}`;
|
|
12635
|
-
// 这里加__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
12636
|
-
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
12637
|
-
// 只读的时候不可以走中间变量__changedItems,比如工作流规则详细页面修改了子表字段”时间触发器“值后,在只读界面点击查看按钮弹出的表单中__changedItems值是修改前的值
|
|
12638
|
-
let formValues = mode === "readonly" ? `\${${props.name}[__super.index]}` : "${__changedItems[__super.index]}";
|
|
12639
|
-
// 这时用__readonlyItemsLength是因为`\${${props.name}.length}`拿不到值
|
|
12640
|
-
let totalValue = mode === "readonly" ? "${__readonlyItemsLength}" : "${__changedItems.length}";
|
|
12641
12636
|
let innerForm = Object.assign({}, form, {
|
|
12642
12637
|
"data": {
|
|
12643
|
-
//
|
|
12644
|
-
|
|
12638
|
+
// 这里加__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
12639
|
+
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
12640
|
+
"&": "${__tableItems[__super.index]}"
|
|
12645
12641
|
}
|
|
12646
12642
|
});
|
|
12647
12643
|
let formBody = [
|
|
@@ -12664,47 +12660,43 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12664
12660
|
}
|
|
12665
12661
|
];
|
|
12666
12662
|
let onServiceInitedScript = `
|
|
12667
|
-
//
|
|
12668
|
-
// inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
|
|
12669
|
-
//
|
|
12663
|
+
// 以下脚本是为了解决有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
|
|
12664
|
+
// 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
|
|
12665
|
+
// 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
|
|
12666
|
+
// 再比如工作流规则详细页面修改了子表字段”时间触发器“值后,在只读界面点击查看按钮弹出的表单中__tableItems值是修改前的值
|
|
12667
|
+
// 处理思路是每次弹出form之前先把其__tableItems同步更新为最新值,这样就能在弹出form中包含单元格中做的修改
|
|
12670
12668
|
// 注意:service init事件只会在每次弹出窗口时才执行,在触发翻页时并不会触发service init事件
|
|
12671
|
-
let inlineEditMode = ${props.inlineEditMode};
|
|
12672
|
-
if(!inlineEditMode){
|
|
12673
|
-
return;
|
|
12674
|
-
}
|
|
12675
12669
|
let scope = event.context.scoped;
|
|
12676
12670
|
let __wrapperServiceId = event.data.__wrapperServiceId;
|
|
12677
12671
|
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
12678
12672
|
let wrapperServiceData = wrapperService.getData();
|
|
12679
12673
|
let lastestFieldValue = wrapperServiceData["${props.name}"];//这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
12680
|
-
//不可以直接像event.data.
|
|
12681
|
-
event.data.
|
|
12682
|
-
event.data.
|
|
12674
|
+
//不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
|
|
12675
|
+
event.data.__tableItems.forEach(function(n,i){
|
|
12676
|
+
event.data.__tableItems[i] = lastestFieldValue[i];
|
|
12683
12677
|
});
|
|
12684
12678
|
`;
|
|
12685
12679
|
let schema = {
|
|
12686
12680
|
"type": "service",
|
|
12687
12681
|
"id": serviceId,
|
|
12688
12682
|
"schemaApi": {
|
|
12689
|
-
"url": "${context.rootUrl}/graphql?rebuildOn=${index}",
|
|
12690
|
-
|
|
12691
|
-
"
|
|
12692
|
-
"
|
|
12693
|
-
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
12694
|
-
},
|
|
12695
|
-
"requestAdaptor": "api.data={query: '{spaces__findOne(id: \"none\"){_id,name}}'};return api;",
|
|
12683
|
+
// "url": "${context.rootUrl}/graphql?rebuildOn=${index}",
|
|
12684
|
+
"url": "${context.rootUrl}/api/v1/spaces/none",
|
|
12685
|
+
"trackExpression": "${index}",
|
|
12686
|
+
"method": "get",
|
|
12696
12687
|
"adaptor": `
|
|
12697
12688
|
const formBody = ${JSON.stringify(formBody)};
|
|
12698
12689
|
return {
|
|
12699
12690
|
"body": formBody
|
|
12700
12691
|
}
|
|
12701
|
-
|
|
12692
|
+
`,
|
|
12693
|
+
"cache": 600000
|
|
12702
12694
|
},
|
|
12703
12695
|
// "body": formBody,
|
|
12704
12696
|
"data": {
|
|
12705
12697
|
"__page": "${index + 1}",
|
|
12706
12698
|
// "__total": `\${${props.name}.length}`,
|
|
12707
|
-
"__total":
|
|
12699
|
+
"__total": "${__tableItems.length}",
|
|
12708
12700
|
"__paginationServiceId": serviceId,
|
|
12709
12701
|
"__formId": form.id
|
|
12710
12702
|
},
|
|
@@ -12726,13 +12718,15 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12726
12718
|
* @param {*} props
|
|
12727
12719
|
* @param {*} mode edit/new/readonly
|
|
12728
12720
|
*/
|
|
12729
|
-
async function getForm(props, mode = "edit") {
|
|
12721
|
+
async function getForm(props, mode = "edit", formId) {
|
|
12730
12722
|
let formFields = getFormFields(props, mode);
|
|
12731
12723
|
let body = await getFormBody(null, formFields);
|
|
12732
|
-
|
|
12724
|
+
if(!formId){
|
|
12725
|
+
formId = `form_popup__${props.id}`;
|
|
12726
|
+
}
|
|
12733
12727
|
let schema = {
|
|
12734
12728
|
"type": "form",
|
|
12735
|
-
"id":
|
|
12729
|
+
"id": formId,
|
|
12736
12730
|
"title": "表单",
|
|
12737
12731
|
"debug": false,
|
|
12738
12732
|
"mode": "normal",
|
|
@@ -12744,8 +12738,7 @@ async function getForm(props, mode = "edit") {
|
|
|
12744
12738
|
if (mode === "edit") {
|
|
12745
12739
|
let onEditItemSubmitScript = `
|
|
12746
12740
|
// let fieldValue = _.cloneDeep(event.data["${props.name}"]);
|
|
12747
|
-
let fieldValue = event.data.
|
|
12748
|
-
|
|
12741
|
+
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
12749
12742
|
//这里加__super.__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
12750
12743
|
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
12751
12744
|
fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
|
|
@@ -12756,16 +12749,6 @@ async function getForm(props, mode = "edit") {
|
|
|
12756
12749
|
"value": fieldValue
|
|
12757
12750
|
}
|
|
12758
12751
|
});
|
|
12759
|
-
// // 因为翻页form中用的是event.data.changedItems中的数据,所以不需要像下面这样doAction setValue变更中间变量changedItems值
|
|
12760
|
-
// doAction({
|
|
12761
|
-
// "componentId": event.data.__wrapperServiceId,
|
|
12762
|
-
// "actionType": "setValue",
|
|
12763
|
-
// "args": {
|
|
12764
|
-
// "value": {
|
|
12765
|
-
// "__changedItems": fieldValue
|
|
12766
|
-
// }
|
|
12767
|
-
// }
|
|
12768
|
-
// });
|
|
12769
12752
|
`;
|
|
12770
12753
|
Object.assign(schema, {
|
|
12771
12754
|
"onEvent": {
|
|
@@ -12793,29 +12776,30 @@ async function getForm(props, mode = "edit") {
|
|
|
12793
12776
|
}
|
|
12794
12777
|
else if (mode === "new") {
|
|
12795
12778
|
let onNewItemSubmitScript = `
|
|
12796
|
-
|
|
12797
|
-
if(
|
|
12798
|
-
event.data.
|
|
12779
|
+
let newItem = JSON.parse(JSON.stringify(event.data));
|
|
12780
|
+
if(event.data["${props.name}"]){
|
|
12781
|
+
// let fieldValue = event.data.__tableItems;
|
|
12782
|
+
// 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
|
|
12783
|
+
let fieldValue = event.data["${props.name}"];
|
|
12784
|
+
fieldValue.push(newItem);
|
|
12785
|
+
doAction({
|
|
12786
|
+
"componentId": "${props.id}",
|
|
12787
|
+
"actionType": "setValue",
|
|
12788
|
+
"args": {
|
|
12789
|
+
"value": fieldValue
|
|
12790
|
+
}
|
|
12791
|
+
});
|
|
12792
|
+
}
|
|
12793
|
+
else{
|
|
12794
|
+
// 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
|
|
12795
|
+
doAction({
|
|
12796
|
+
"componentId": "${props.id}",
|
|
12797
|
+
"actionType": "setValue",
|
|
12798
|
+
"args": {
|
|
12799
|
+
"value": [newItem]
|
|
12800
|
+
}
|
|
12801
|
+
});
|
|
12799
12802
|
}
|
|
12800
|
-
let fieldValue = event.data.__changedItems;
|
|
12801
|
-
fieldValue.push(JSON.parse(JSON.stringify(event.data)));
|
|
12802
|
-
doAction({
|
|
12803
|
-
"componentId": "${props.id}",
|
|
12804
|
-
"actionType": "setValue",
|
|
12805
|
-
"args": {
|
|
12806
|
-
"value": fieldValue
|
|
12807
|
-
}
|
|
12808
|
-
});
|
|
12809
|
-
// // 因为翻页form中用的是event.data.changedItems中的数据,所以不需要像下面这样doAction setValue变更中间变量changedItems值
|
|
12810
|
-
// doAction({
|
|
12811
|
-
// "componentId": event.data.__wrapperServiceId,
|
|
12812
|
-
// "actionType": "setValue",
|
|
12813
|
-
// "args": {
|
|
12814
|
-
// "value": {
|
|
12815
|
-
// "__changedItems": fieldValue
|
|
12816
|
-
// }
|
|
12817
|
-
// }
|
|
12818
|
-
// });
|
|
12819
12803
|
`;
|
|
12820
12804
|
Object.assign(schema, {
|
|
12821
12805
|
"onEvent": {
|
|
@@ -12842,12 +12826,13 @@ async function getForm(props, mode = "edit") {
|
|
|
12842
12826
|
});
|
|
12843
12827
|
}
|
|
12844
12828
|
if (mode === "edit" || mode === "readonly") {
|
|
12845
|
-
schema = getFormPaginationWrapper(props, schema
|
|
12829
|
+
schema = getFormPaginationWrapper(props, schema);
|
|
12846
12830
|
}
|
|
12847
12831
|
return schema;
|
|
12848
12832
|
}
|
|
12849
12833
|
|
|
12850
12834
|
async function getButtonNew(props) {
|
|
12835
|
+
let formId = `form_popup__${props.id}`;
|
|
12851
12836
|
return {
|
|
12852
12837
|
"label": "新增",
|
|
12853
12838
|
"type": "button",
|
|
@@ -12861,14 +12846,28 @@ async function getButtonNew(props) {
|
|
|
12861
12846
|
"type": "dialog",
|
|
12862
12847
|
"title": "新增行",
|
|
12863
12848
|
"body": [
|
|
12864
|
-
await getForm(props, "new")
|
|
12849
|
+
await getForm(props, "new", formId)
|
|
12865
12850
|
],
|
|
12866
12851
|
"size": "lg",
|
|
12867
12852
|
"showCloseButton": true,
|
|
12868
12853
|
"showErrorMsg": true,
|
|
12869
12854
|
"showLoading": true,
|
|
12870
12855
|
"className": "app-popover",
|
|
12871
|
-
"closeOnEsc": false
|
|
12856
|
+
"closeOnEsc": false,
|
|
12857
|
+
"onEvent": {
|
|
12858
|
+
"confirm": {
|
|
12859
|
+
"actions": [
|
|
12860
|
+
{
|
|
12861
|
+
"actionType": "validate",
|
|
12862
|
+
"componentId": formId
|
|
12863
|
+
},
|
|
12864
|
+
{
|
|
12865
|
+
"preventDefault": true,
|
|
12866
|
+
"expression": "${event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
|
|
12867
|
+
}
|
|
12868
|
+
]
|
|
12869
|
+
}
|
|
12870
|
+
}
|
|
12872
12871
|
}
|
|
12873
12872
|
}
|
|
12874
12873
|
]
|
|
@@ -12879,27 +12878,7 @@ async function getButtonNew(props) {
|
|
|
12879
12878
|
}
|
|
12880
12879
|
|
|
12881
12880
|
async function getButtonEdit(props, showAsInlineEditMode) {
|
|
12882
|
-
let
|
|
12883
|
-
let scope = event.context.scoped;
|
|
12884
|
-
let __wrapperServiceId = event.data.__wrapperServiceId;
|
|
12885
|
-
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
12886
|
-
let wrapperServiceData = wrapperService.getData();
|
|
12887
|
-
let originalFieldValue = wrapperServiceData["${props.name}"];//这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
12888
|
-
//不可以直接像event.data.__changedItems = originalFieldValue; 这样整个赋值,否则作用域会断,造成无法还原
|
|
12889
|
-
event.data.__changedItems.forEach(function(n,i){
|
|
12890
|
-
event.data.__changedItems[i] = originalFieldValue[i];
|
|
12891
|
-
});
|
|
12892
|
-
// 因为翻页form中用的是event.data.changedItems中的数据,所以像下面这样doAction setValue无法实现还原
|
|
12893
|
-
// doAction({
|
|
12894
|
-
// "componentId": __wrapperServiceId,
|
|
12895
|
-
// "actionType": "setValue",
|
|
12896
|
-
// "args": {
|
|
12897
|
-
// "value": {
|
|
12898
|
-
// "__changedItems": originalFieldValue
|
|
12899
|
-
// }
|
|
12900
|
-
// }
|
|
12901
|
-
// });
|
|
12902
|
-
`;
|
|
12881
|
+
let formId = `form_popup__${props.id}`;
|
|
12903
12882
|
return {
|
|
12904
12883
|
"type": "button",
|
|
12905
12884
|
"label": "",
|
|
@@ -12914,7 +12893,7 @@ async function getButtonEdit(props, showAsInlineEditMode) {
|
|
|
12914
12893
|
"type": "dialog",
|
|
12915
12894
|
"title": "编辑行",
|
|
12916
12895
|
"body": [
|
|
12917
|
-
await getForm(props, "edit")
|
|
12896
|
+
await getForm(props, "edit", formId)
|
|
12918
12897
|
],
|
|
12919
12898
|
"size": "lg",
|
|
12920
12899
|
"showCloseButton": true,
|
|
@@ -12923,7 +12902,7 @@ async function getButtonEdit(props, showAsInlineEditMode) {
|
|
|
12923
12902
|
"className": "app-popover",
|
|
12924
12903
|
"closeOnEsc": false,
|
|
12925
12904
|
"data": {
|
|
12926
|
-
// 这里必须加data数据映射,否则翻页功能中取
|
|
12905
|
+
// 这里必须加data数据映射,否则翻页功能中取__tableItems值时会乱,比如翻页编辑后会把上一页中没改过的字段值带过去
|
|
12927
12906
|
// 额外把华炎魔方主表记录ObjectForm中的字段值从record变量中映射到子表form中,因为子表lookup字段filtersFunction中可能依赖了主表记录中的字段值,比如“工作流规则”对象“时间触发器”字段中的“日期字段”字段
|
|
12928
12907
|
// 额外把global、uiSchema也映射过去,有可能要用,后续需要用到其他变更可以这里加映射
|
|
12929
12908
|
// "&": "${record || {}}",
|
|
@@ -12933,17 +12912,21 @@ async function getButtonEdit(props, showAsInlineEditMode) {
|
|
|
12933
12912
|
"global": "${global}",
|
|
12934
12913
|
"uiSchema": "${uiSchema}",
|
|
12935
12914
|
"index": "${index}",
|
|
12936
|
-
"
|
|
12915
|
+
"__tableItems": `\${${props.name}}`,
|
|
12937
12916
|
"__wrapperServiceId": "${__wrapperServiceId}"
|
|
12938
12917
|
},
|
|
12939
12918
|
"onEvent": {
|
|
12940
|
-
"
|
|
12941
|
-
|
|
12942
|
-
|
|
12943
|
-
|
|
12944
|
-
|
|
12945
|
-
|
|
12946
|
-
|
|
12919
|
+
"confirm": {
|
|
12920
|
+
"actions": [
|
|
12921
|
+
{
|
|
12922
|
+
"actionType": "validate",
|
|
12923
|
+
"componentId": formId
|
|
12924
|
+
},
|
|
12925
|
+
{
|
|
12926
|
+
"preventDefault": true,
|
|
12927
|
+
"expression": "${event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
|
|
12928
|
+
}
|
|
12929
|
+
]
|
|
12947
12930
|
}
|
|
12948
12931
|
}
|
|
12949
12932
|
}
|
|
@@ -12979,7 +12962,7 @@ async function getButtonView(props) {
|
|
|
12979
12962
|
"closeOnEsc": false,
|
|
12980
12963
|
"actions": [],
|
|
12981
12964
|
"data": {
|
|
12982
|
-
// 这里必须加data数据映射,否则翻页功能中取
|
|
12965
|
+
// 这里必须加data数据映射,否则翻页功能中取__tableItems值时会乱,比如翻页编辑后会把上一页中没改过的字段值带过去
|
|
12983
12966
|
// 额外把华炎魔方主表记录ObjectForm中的字段值从formData变量中映射到子表form中,因为子表lookup字段filtersFunction中可能依赖了主表记录中的字段值,比如“工作流规则”对象“时间触发器”字段中的“日期字段”字段
|
|
12984
12967
|
// global、uiSchema等常用变量本来就在formData变量已经存在了,无需另外映射
|
|
12985
12968
|
// "&": "${formData || {}}",
|
|
@@ -12987,9 +12970,8 @@ async function getButtonView(props) {
|
|
|
12987
12970
|
// 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
|
|
12988
12971
|
"__parentForm": "${__super.__super || {}}",
|
|
12989
12972
|
"index": "${index}",
|
|
12990
|
-
"
|
|
12991
|
-
"__wrapperServiceId": "${__wrapperServiceId}"
|
|
12992
|
-
"__readonlyItemsLength": `\${${props.name}.length}`
|
|
12973
|
+
"__tableItems": `\${${props.name}}`,
|
|
12974
|
+
"__wrapperServiceId": "${__wrapperServiceId}"
|
|
12993
12975
|
}
|
|
12994
12976
|
}
|
|
12995
12977
|
}
|
|
@@ -13001,30 +12983,20 @@ async function getButtonView(props) {
|
|
|
13001
12983
|
|
|
13002
12984
|
function getButtonDelete(props) {
|
|
13003
12985
|
let onDeleteItemScript = `
|
|
13004
|
-
// let fieldValue =
|
|
13005
|
-
|
|
13006
|
-
|
|
13007
|
-
|
|
13008
|
-
let
|
|
13009
|
-
|
|
13010
|
-
|
|
12986
|
+
// let fieldValue = event.data["${props.name}"];
|
|
12987
|
+
let scope = event.context.scoped;
|
|
12988
|
+
let __wrapperServiceId = event.data.__wrapperServiceId;
|
|
12989
|
+
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
12990
|
+
let wrapperServiceData = wrapperService.getData();
|
|
12991
|
+
let lastestFieldValue = wrapperServiceData["${props.name}"];//这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
12992
|
+
lastestFieldValue.splice(event.data.index, 1);
|
|
13011
12993
|
doAction({
|
|
13012
12994
|
"componentId": "${props.id}",
|
|
13013
12995
|
"actionType": "setValue",
|
|
13014
12996
|
"args": {
|
|
13015
|
-
"value":
|
|
12997
|
+
"value": lastestFieldValue
|
|
13016
12998
|
}
|
|
13017
12999
|
});
|
|
13018
|
-
// // 因为翻页form中用的是event.data.changedItems中的数据,所以不需要像下面这样doAction setValue变更中间变量changedItems值
|
|
13019
|
-
// doAction({
|
|
13020
|
-
// "componentId": event.data.__wrapperServiceId,
|
|
13021
|
-
// "actionType": "setValue",
|
|
13022
|
-
// "args": {
|
|
13023
|
-
// "value": {
|
|
13024
|
-
// "__changedItems": fieldValue
|
|
13025
|
-
// }
|
|
13026
|
-
// }
|
|
13027
|
-
// });
|
|
13028
13000
|
`;
|
|
13029
13001
|
return {
|
|
13030
13002
|
"type": "button",
|
|
@@ -13062,13 +13034,15 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13062
13034
|
if (props.editable) {
|
|
13063
13035
|
let showEditButton = true;
|
|
13064
13036
|
if (showAsInlineEditMode) {
|
|
13065
|
-
//
|
|
13066
|
-
|
|
13067
|
-
|
|
13068
|
-
|
|
13069
|
-
|
|
13070
|
-
|
|
13071
|
-
|
|
13037
|
+
// 始终显示弹出子表表单按钮,如果需要判断只在有列被隐藏时才需要显示弹出表单按钮放开下面的if逻辑就好
|
|
13038
|
+
showEditButton = true;
|
|
13039
|
+
// // inline edit模式下只在有列被隐藏时才需要显示编辑按钮
|
|
13040
|
+
// if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length) {
|
|
13041
|
+
// showEditButton = true;
|
|
13042
|
+
// }
|
|
13043
|
+
// else {
|
|
13044
|
+
// showEditButton = false;
|
|
13045
|
+
// }
|
|
13072
13046
|
}
|
|
13073
13047
|
// 编辑时显示编辑按钮
|
|
13074
13048
|
if (showEditButton) {
|
|
@@ -13078,11 +13052,9 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13078
13052
|
}
|
|
13079
13053
|
else {
|
|
13080
13054
|
// 只读时显示查看按钮
|
|
13081
|
-
if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
|
|
13082
|
-
|
|
13083
|
-
|
|
13084
|
-
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13085
|
-
}
|
|
13055
|
+
// 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
|
|
13056
|
+
let buttonViewSchema = await getButtonView(props);
|
|
13057
|
+
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13086
13058
|
}
|
|
13087
13059
|
if (props.removable) {
|
|
13088
13060
|
let buttonDeleteSchema = getButtonDelete(props);
|
|
@@ -13118,85 +13090,53 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13118
13090
|
if (showAsInlineEditMode) {
|
|
13119
13091
|
inputTableSchema.needConfirm = false;
|
|
13120
13092
|
}
|
|
13121
|
-
let dataProviderInited = `
|
|
13122
|
-
// 单独维护一份中间变量changedItems,因为原变量在input-table组件有单独的作用域,翻页功能中无法维护此作用域中的行记录值
|
|
13123
|
-
setData({ __changedItems: _.cloneDeep(data["${props.name}"]) || []});
|
|
13124
|
-
`;
|
|
13125
|
-
let onInitScript = `
|
|
13126
|
-
// 上面dataProviderInited中setData有时不生效,没有成功给service组件设置__changedItems变量值
|
|
13127
|
-
// 比如设计字段布局界面中的设置分组功能就因为__changedItems变量值不存在而报错,应该是因为把steedos-input-table组件单独放到弹出窗口中会有这个问题
|
|
13128
|
-
// 所以额外在service init事件中手动设置一次__changedItems值
|
|
13129
|
-
let __wrapperServiceId = event.data.__wrapperServiceId;
|
|
13130
|
-
let fieldValue = _.cloneDeep(event.data["${props.name}"]) || [];
|
|
13131
|
-
doAction({
|
|
13132
|
-
"componentId": __wrapperServiceId,
|
|
13133
|
-
"actionType": "setValue",
|
|
13134
|
-
"args": {
|
|
13135
|
-
"value": {
|
|
13136
|
-
"__changedItems": fieldValue
|
|
13137
|
-
}
|
|
13138
|
-
}
|
|
13139
|
-
});
|
|
13140
|
-
// 下面的doAction好像不是必须的
|
|
13141
|
-
// doAction({
|
|
13142
|
-
// "componentId": "${props.id}",
|
|
13143
|
-
// "actionType": "setValue",
|
|
13144
|
-
// "args": {
|
|
13145
|
-
// "value": fieldValue
|
|
13146
|
-
// }
|
|
13147
|
-
// });
|
|
13148
|
-
`;
|
|
13149
|
-
let schema = {
|
|
13150
|
-
"type": "service",
|
|
13151
|
-
"body": [
|
|
13152
|
-
inputTableSchema
|
|
13153
|
-
],
|
|
13154
|
-
"className": props.className,
|
|
13155
|
-
"id": serviceId,
|
|
13156
|
-
"data": {
|
|
13157
|
-
"__wrapperServiceId": serviceId
|
|
13158
|
-
},
|
|
13159
|
-
"dataProvider": {
|
|
13160
|
-
"inited": dataProviderInited
|
|
13161
|
-
},
|
|
13162
|
-
"onEvent": {
|
|
13163
|
-
"init": {
|
|
13164
|
-
"actions": [
|
|
13165
|
-
{
|
|
13166
|
-
"actionType": "custom",
|
|
13167
|
-
"script": onInitScript
|
|
13168
|
-
}
|
|
13169
|
-
]
|
|
13170
|
-
}
|
|
13171
|
-
}
|
|
13172
|
-
};
|
|
13173
|
-
let footerToolbar = _$1.clone(props.footerToolbar || []); //这里不clone的话,会造成死循环,应该是因为props属性变更会让组件重新渲染
|
|
13174
|
-
if (props.addable) {
|
|
13175
|
-
let buttonNewSchema = await getButtonNew(props);
|
|
13176
|
-
footerToolbar.unshift(buttonNewSchema);
|
|
13177
|
-
}
|
|
13178
|
-
if (footerToolbar.length) {
|
|
13179
|
-
schema.body.push({
|
|
13180
|
-
"type": "wrapper",
|
|
13181
|
-
"size": "none",
|
|
13182
|
-
"body": footerToolbar
|
|
13183
|
-
});
|
|
13184
|
-
}
|
|
13185
13093
|
let amis = props["input-table"] || props.amis;//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
|
|
13186
13094
|
if (amis) {
|
|
13187
13095
|
// 支持配置amis属性重写或添加最终生成的input-table中任何属性。
|
|
13188
13096
|
delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
|
|
13189
|
-
Object.assign(
|
|
13097
|
+
Object.assign(inputTableSchema, amis);
|
|
13190
13098
|
}
|
|
13191
13099
|
const isAnyFieldHasDependOn = (props.fields || []).find(function (item) {
|
|
13192
13100
|
return item.depend_on;
|
|
13193
13101
|
});
|
|
13194
|
-
if(isAnyFieldHasDependOn){
|
|
13102
|
+
if (isAnyFieldHasDependOn) {
|
|
13195
13103
|
// 有任意一个子字段有depend_on属性时,强制设置禁用静态模式
|
|
13196
|
-
Object.assign(
|
|
13104
|
+
Object.assign(inputTableSchema, {
|
|
13197
13105
|
strictMode: false
|
|
13198
13106
|
});
|
|
13199
13107
|
}
|
|
13108
|
+
let schemaBody = [inputTableSchema];
|
|
13109
|
+
let footerToolbar = _$1.clone(props.footerToolbar || []); //这里不clone的话,会造成死循环,应该是因为props属性变更会让组件重新渲染
|
|
13110
|
+
if (props.addable) {
|
|
13111
|
+
let buttonNewSchema = await getButtonNew(props);
|
|
13112
|
+
footerToolbar.unshift(buttonNewSchema);
|
|
13113
|
+
}
|
|
13114
|
+
if (footerToolbar.length) {
|
|
13115
|
+
schemaBody.push({
|
|
13116
|
+
"type": "wrapper",
|
|
13117
|
+
"size": "none",
|
|
13118
|
+
"body": footerToolbar
|
|
13119
|
+
});
|
|
13120
|
+
}
|
|
13121
|
+
// 不可以直接把headerToolbar unshift进schemaBody,因为它没有显示在label下面,而是显示在上面了,这没有意义
|
|
13122
|
+
// 看起来amis官方后续会支持给input-table组件配置headerToolbar,见:https://github.com/baidu/amis/issues/7246
|
|
13123
|
+
// let headerToolbar = clone(props.headerToolbar || []); //这里不clone的话,会造成死循环,应该是因为props属性变更会让组件重新渲染
|
|
13124
|
+
// if (headerToolbar.length) {
|
|
13125
|
+
// schemaBody.unshift({
|
|
13126
|
+
// "type": "wrapper",
|
|
13127
|
+
// "size": "none",
|
|
13128
|
+
// "body": headerToolbar
|
|
13129
|
+
// });
|
|
13130
|
+
// }
|
|
13131
|
+
let schema = {
|
|
13132
|
+
"type": "service",
|
|
13133
|
+
"body": schemaBody,
|
|
13134
|
+
"className": props.className,
|
|
13135
|
+
"id": serviceId,
|
|
13136
|
+
"data": {
|
|
13137
|
+
"__wrapperServiceId": serviceId
|
|
13138
|
+
}
|
|
13139
|
+
};
|
|
13200
13140
|
// console.log("===schema===", schema);
|
|
13201
13141
|
return schema;
|
|
13202
13142
|
};
|