@steedos-widgets/amis-lib 1.3.20 → 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 +245 -217
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +245 -217
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +74 -44
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/input_table.d.ts +2 -5
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1065,7 +1065,7 @@ var config = {
|
|
|
1065
1065
|
* @Author: baozhoutao@steedos.com
|
|
1066
1066
|
* @Date: 2022-10-28 14:52:55
|
|
1067
1067
|
* @LastEditors: liaodaxue
|
|
1068
|
-
* @LastEditTime: 2023-
|
|
1068
|
+
* @LastEditTime: 2023-12-14 12:01:22
|
|
1069
1069
|
* @Description:
|
|
1070
1070
|
*/
|
|
1071
1071
|
|
|
@@ -1082,6 +1082,7 @@ const AmisFormInputs = [
|
|
|
1082
1082
|
'percent',
|
|
1083
1083
|
'password',
|
|
1084
1084
|
'url',
|
|
1085
|
+
"color",
|
|
1085
1086
|
'email'
|
|
1086
1087
|
];
|
|
1087
1088
|
|
|
@@ -1094,7 +1095,7 @@ function getAmisStaticFieldType(type, readonly, options){
|
|
|
1094
1095
|
}
|
|
1095
1096
|
return type;
|
|
1096
1097
|
}
|
|
1097
|
-
if(___namespace.includes(['text','image'], type)){
|
|
1098
|
+
if(___namespace.includes(['text','image','color'], type)){
|
|
1098
1099
|
if('text' === type && options && options.amis && options.amis.tpl){
|
|
1099
1100
|
return 'static';
|
|
1100
1101
|
}
|
|
@@ -1228,6 +1229,7 @@ var frontend_form_please_select$1 = "Please select";
|
|
|
1228
1229
|
var frontend_form_confirm$1 = "Confirm";
|
|
1229
1230
|
var frontend_form_delete$1 = "Delete";
|
|
1230
1231
|
var frontend_form_view$1 = "view";
|
|
1232
|
+
var frontend_form_details$1 = "details";
|
|
1231
1233
|
var frontend_delete_confirm_text$1 = "Are you sure you want to delete this item?";
|
|
1232
1234
|
var frontend_delete_many_selected_required$1 = "Please select the item to be deleted";
|
|
1233
1235
|
var frontend_delete_many_confirm_text$1 = "Are you sure you want to delete?";
|
|
@@ -1314,6 +1316,7 @@ var en_us = {
|
|
|
1314
1316
|
frontend_form_confirm: frontend_form_confirm$1,
|
|
1315
1317
|
frontend_form_delete: frontend_form_delete$1,
|
|
1316
1318
|
frontend_form_view: frontend_form_view$1,
|
|
1319
|
+
frontend_form_details: frontend_form_details$1,
|
|
1317
1320
|
frontend_delete_confirm_text: frontend_delete_confirm_text$1,
|
|
1318
1321
|
frontend_delete_many_selected_required: frontend_delete_many_selected_required$1,
|
|
1319
1322
|
frontend_delete_many_confirm_text: frontend_delete_many_confirm_text$1,
|
|
@@ -1401,6 +1404,7 @@ var frontend_form_please_select = "请选择";
|
|
|
1401
1404
|
var frontend_form_confirm = "确认";
|
|
1402
1405
|
var frontend_form_delete = "删除";
|
|
1403
1406
|
var frontend_form_view = "查看";
|
|
1407
|
+
var frontend_form_details = "详情";
|
|
1404
1408
|
var frontend_delete_confirm_text = "确定要删除此项目?";
|
|
1405
1409
|
var frontend_delete_many_selected_required = "请选择要删除的项";
|
|
1406
1410
|
var frontend_delete_many_confirm_text = "确定要删除吗?";
|
|
@@ -1488,6 +1492,7 @@ var zh_cn = {
|
|
|
1488
1492
|
frontend_form_confirm: frontend_form_confirm,
|
|
1489
1493
|
frontend_form_delete: frontend_form_delete,
|
|
1490
1494
|
frontend_form_view: frontend_form_view,
|
|
1495
|
+
frontend_form_details: frontend_form_details,
|
|
1491
1496
|
frontend_delete_confirm_text: frontend_delete_confirm_text,
|
|
1492
1497
|
frontend_delete_many_selected_required: frontend_delete_many_selected_required,
|
|
1493
1498
|
frontend_delete_many_confirm_text: frontend_delete_many_confirm_text,
|
|
@@ -1784,21 +1789,21 @@ async function getQuickEditSchema(field, options){
|
|
|
1784
1789
|
break;
|
|
1785
1790
|
case "avatar":
|
|
1786
1791
|
case "image":
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
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
|
+
}
|
|
1797
1803
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
break;
|
|
1804
|
+
return payload;
|
|
1805
|
+
`;
|
|
1806
|
+
break;
|
|
1802
1807
|
}
|
|
1803
1808
|
quickEditSchema.body[0].visibleOn = "${quickedit_record_permissions.allowEdit && quickedit_record_permissions_loading == false}";
|
|
1804
1809
|
quickEditSchema.body.push({
|
|
@@ -2005,6 +2010,11 @@ async function getQuickEditSchema(field, options){
|
|
|
2005
2010
|
if(field.type == "location"){
|
|
2006
2011
|
quickEditSchema = false;
|
|
2007
2012
|
}
|
|
2013
|
+
if(field.type == "color"){
|
|
2014
|
+
quickEditSchema = {
|
|
2015
|
+
type: "input-color"
|
|
2016
|
+
};
|
|
2017
|
+
}
|
|
2008
2018
|
}
|
|
2009
2019
|
return quickEditSchema;
|
|
2010
2020
|
}
|
|
@@ -2162,6 +2172,11 @@ async function getTableColumns(fields, options){
|
|
|
2162
2172
|
options: field.type === 'html' ? {html: true} : null
|
|
2163
2173
|
// toggled: true
|
|
2164
2174
|
}, field.amis, {name: field.name});
|
|
2175
|
+
|
|
2176
|
+
if(field.type === 'color'){
|
|
2177
|
+
columnItem.type = 'color';
|
|
2178
|
+
columnItem.defaultColor = null;
|
|
2179
|
+
}
|
|
2165
2180
|
}
|
|
2166
2181
|
}
|
|
2167
2182
|
if(columnItem){
|
|
@@ -4849,8 +4864,8 @@ const getSchema$2 = (uiSchema) => {
|
|
|
4849
4864
|
/*
|
|
4850
4865
|
* @Author: baozhoutao@steedos.com
|
|
4851
4866
|
* @Date: 2022-11-07 17:00:38
|
|
4852
|
-
* @LastEditors:
|
|
4853
|
-
* @LastEditTime: 2023-
|
|
4867
|
+
* @LastEditors: liaodaxue
|
|
4868
|
+
* @LastEditTime: 2023-12-13 10:09:05
|
|
4854
4869
|
* @Description:
|
|
4855
4870
|
*/
|
|
4856
4871
|
|
|
@@ -4861,7 +4876,7 @@ const getSchema$1 = (uiSchema)=>{
|
|
|
4861
4876
|
"body": [
|
|
4862
4877
|
{
|
|
4863
4878
|
"type": "button",
|
|
4864
|
-
"label": i18next__default["default"].t('
|
|
4879
|
+
"label": i18next__default["default"].t('frontend_form_details'),
|
|
4865
4880
|
"className": "border-none",
|
|
4866
4881
|
"onEvent": {
|
|
4867
4882
|
"click": {
|
|
@@ -11542,6 +11557,23 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
11542
11557
|
}
|
|
11543
11558
|
}
|
|
11544
11559
|
|
|
11560
|
+
break;
|
|
11561
|
+
case 'color':
|
|
11562
|
+
convertData = {
|
|
11563
|
+
type: getAmisStaticFieldType('color', readonly),
|
|
11564
|
+
name: field.name,
|
|
11565
|
+
label: field.label
|
|
11566
|
+
};
|
|
11567
|
+
if(readonly){
|
|
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
|
+
};
|
|
11576
|
+
}
|
|
11545
11577
|
break;
|
|
11546
11578
|
case 'boolean':
|
|
11547
11579
|
convertData = {
|
|
@@ -12396,7 +12428,7 @@ async function getFormBody(permissionFields, formFields, ctx){
|
|
|
12396
12428
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
12397
12429
|
* @Date: 2023-11-15 09:50:22
|
|
12398
12430
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
12399
|
-
* @LastEditTime: 2023-12-
|
|
12431
|
+
* @LastEditTime: 2023-12-19 15:53:32
|
|
12400
12432
|
*/
|
|
12401
12433
|
|
|
12402
12434
|
/**
|
|
@@ -12492,36 +12524,25 @@ async function getInputTableColumns(props) {
|
|
|
12492
12524
|
function getFormPagination(props) {
|
|
12493
12525
|
let onPageChangeScript = `
|
|
12494
12526
|
let scope = event.context.scoped;
|
|
12495
|
-
let
|
|
12496
|
-
let
|
|
12497
|
-
let
|
|
12498
|
-
let fieldValue = event.data.
|
|
12527
|
+
let __paginationServiceId = event.data.__paginationServiceId;
|
|
12528
|
+
let __wrapperServiceId = event.data.__wrapperServiceId;
|
|
12529
|
+
let __formId = event.data.__formId;
|
|
12530
|
+
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
12499
12531
|
let pageChangeDirection = context.props.pageChangeDirection;
|
|
12500
|
-
let currentPage = event.data.
|
|
12532
|
+
let currentPage = event.data.__page;
|
|
12501
12533
|
let currentIndex = event.data.index;
|
|
12502
12534
|
|
|
12503
|
-
// 翻页到下一页之前需要先把当前页改动的内容保存到中间变量
|
|
12504
|
-
let currentFormValues = scope.getComponentById(
|
|
12535
|
+
// 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
|
|
12536
|
+
let currentFormValues = scope.getComponentById(__formId).getValues();
|
|
12505
12537
|
fieldValue[currentIndex] = currentFormValues;
|
|
12506
|
-
//
|
|
12507
|
-
|
|
12508
|
-
|
|
12509
|
-
|
|
12510
|
-
|
|
12511
|
-
|
|
12512
|
-
|
|
12513
|
-
|
|
12514
|
-
// }
|
|
12515
|
-
// });
|
|
12516
|
-
// 如果翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,需要额外给正式表单字段执行一次setValue
|
|
12517
|
-
// 但是同时保存到正式表单字段中会造成翻页后点击取消无法取消翻页之前的改动内容
|
|
12518
|
-
// doAction({
|
|
12519
|
-
// "componentId": "${props.id}",
|
|
12520
|
-
// "actionType": "setValue",
|
|
12521
|
-
// "args": {
|
|
12522
|
-
// "value": fieldValue
|
|
12523
|
-
// }
|
|
12524
|
-
// });
|
|
12538
|
+
// 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
|
|
12539
|
+
doAction({
|
|
12540
|
+
"componentId": "${props.id}",
|
|
12541
|
+
"actionType": "setValue",
|
|
12542
|
+
"args": {
|
|
12543
|
+
"value": fieldValue
|
|
12544
|
+
}
|
|
12545
|
+
});
|
|
12525
12546
|
|
|
12526
12547
|
// 以下是翻页逻辑,翻到下一页并把下一页内容显示到表单上
|
|
12527
12548
|
let targetPage;
|
|
@@ -12532,13 +12553,13 @@ function getFormPagination(props) {
|
|
|
12532
12553
|
targetPage = currentPage - 1;
|
|
12533
12554
|
}
|
|
12534
12555
|
let targetIndex = targetPage - 1;//input-table组件行索引,从0开始的索引
|
|
12535
|
-
// let targetFormData =
|
|
12556
|
+
// let targetFormData = __tableItems[targetIndex];
|
|
12536
12557
|
doAction({
|
|
12537
12558
|
"actionType": "setValue",
|
|
12538
|
-
"componentId":
|
|
12559
|
+
"componentId": __paginationServiceId,
|
|
12539
12560
|
"args": {
|
|
12540
12561
|
"value": {
|
|
12541
|
-
"
|
|
12562
|
+
"__page": targetPage,
|
|
12542
12563
|
"index": targetIndex
|
|
12543
12564
|
}
|
|
12544
12565
|
}
|
|
@@ -12546,7 +12567,7 @@ function getFormPagination(props) {
|
|
|
12546
12567
|
// 这里不用进一步把表单内容setValue到form中,是因为编辑表单中schemaApi监听了行索引index的变化,其值变化时会重新build整个form
|
|
12547
12568
|
// doAction({
|
|
12548
12569
|
// "actionType": "setValue",
|
|
12549
|
-
// "componentId":
|
|
12570
|
+
// "componentId": __formId,
|
|
12550
12571
|
// "args": {
|
|
12551
12572
|
// "value": targetFormData
|
|
12552
12573
|
// },
|
|
@@ -12563,7 +12584,7 @@ function getFormPagination(props) {
|
|
|
12563
12584
|
"icon": `fa fa-angle-left`,
|
|
12564
12585
|
"level": "link",
|
|
12565
12586
|
"pageChangeDirection": "prev",
|
|
12566
|
-
"disabledOn": "${
|
|
12587
|
+
"disabledOn": "${__page <= 1}",
|
|
12567
12588
|
"size": "sm",
|
|
12568
12589
|
"onEvent": {
|
|
12569
12590
|
"click": {
|
|
@@ -12578,7 +12599,7 @@ function getFormPagination(props) {
|
|
|
12578
12599
|
},
|
|
12579
12600
|
{
|
|
12580
12601
|
"type": "tpl",
|
|
12581
|
-
"tpl": "${
|
|
12602
|
+
"tpl": "${__page}/${__total}"
|
|
12582
12603
|
},
|
|
12583
12604
|
{
|
|
12584
12605
|
"type": "button",
|
|
@@ -12586,7 +12607,7 @@ function getFormPagination(props) {
|
|
|
12586
12607
|
"icon": `fa fa-angle-right`,
|
|
12587
12608
|
"level": "link",
|
|
12588
12609
|
"pageChangeDirection": "next",
|
|
12589
|
-
"disabledOn": "${
|
|
12610
|
+
"disabledOn": "${__page >= __total}",
|
|
12590
12611
|
"size": "sm",
|
|
12591
12612
|
"onEvent": {
|
|
12592
12613
|
"click": {
|
|
@@ -12607,10 +12628,18 @@ function getFormPagination(props) {
|
|
|
12607
12628
|
* 传入formSchema输出带翻页容器的wrapper
|
|
12608
12629
|
* @param {*} props input-table组件props
|
|
12609
12630
|
* @param {*} form formSchema
|
|
12631
|
+
* @param {*} mode edit/readonly
|
|
12610
12632
|
* @returns 带翻页容器的wrapper
|
|
12611
12633
|
*/
|
|
12612
|
-
function getFormPaginationWrapper(props, form) {
|
|
12634
|
+
function getFormPaginationWrapper(props, form, mode) {
|
|
12613
12635
|
let serviceId = `service_popup_pagination_wrapper__${props.id}`;
|
|
12636
|
+
let innerForm = Object.assign({}, form, {
|
|
12637
|
+
"data": {
|
|
12638
|
+
// 这里加__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
12639
|
+
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
12640
|
+
"&": "${__tableItems[__super.index]}"
|
|
12641
|
+
}
|
|
12642
|
+
});
|
|
12614
12643
|
let formBody = [
|
|
12615
12644
|
{
|
|
12616
12645
|
"type": "wrapper",
|
|
@@ -12620,59 +12649,56 @@ function getFormPaginationWrapper(props, form) {
|
|
|
12620
12649
|
getFormPagination(props)
|
|
12621
12650
|
]
|
|
12622
12651
|
},
|
|
12623
|
-
|
|
12624
|
-
|
|
12625
|
-
"
|
|
12652
|
+
{
|
|
12653
|
+
"type": "service",
|
|
12654
|
+
"body": [
|
|
12655
|
+
innerForm
|
|
12656
|
+
],
|
|
12626
12657
|
"data": {
|
|
12627
|
-
|
|
12628
|
-
"&": "${changedItems[index]}"
|
|
12658
|
+
"&": "${__parentForm}"
|
|
12629
12659
|
}
|
|
12630
|
-
}
|
|
12660
|
+
}
|
|
12631
12661
|
];
|
|
12632
12662
|
let onServiceInitedScript = `
|
|
12633
|
-
//
|
|
12634
|
-
// inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
|
|
12635
|
-
//
|
|
12663
|
+
// 以下脚本是为了解决有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
|
|
12664
|
+
// 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
|
|
12665
|
+
// 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
|
|
12666
|
+
// 再比如工作流规则详细页面修改了子表字段”时间触发器“值后,在只读界面点击查看按钮弹出的表单中__tableItems值是修改前的值
|
|
12667
|
+
// 处理思路是每次弹出form之前先把其__tableItems同步更新为最新值,这样就能在弹出form中包含单元格中做的修改
|
|
12636
12668
|
// 注意:service init事件只会在每次弹出窗口时才执行,在触发翻页时并不会触发service init事件
|
|
12637
|
-
let inlineEditMode = ${props.inlineEditMode};
|
|
12638
|
-
if(!inlineEditMode){
|
|
12639
|
-
return;
|
|
12640
|
-
}
|
|
12641
12669
|
let scope = event.context.scoped;
|
|
12642
|
-
let
|
|
12643
|
-
let wrapperService = scope.getComponentById(
|
|
12670
|
+
let __wrapperServiceId = event.data.__wrapperServiceId;
|
|
12671
|
+
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
12644
12672
|
let wrapperServiceData = wrapperService.getData();
|
|
12645
12673
|
let lastestFieldValue = wrapperServiceData["${props.name}"];//这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
12646
|
-
//不可以直接像event.data.
|
|
12647
|
-
event.data.
|
|
12648
|
-
event.data.
|
|
12674
|
+
//不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
|
|
12675
|
+
event.data.__tableItems.forEach(function(n,i){
|
|
12676
|
+
event.data.__tableItems[i] = lastestFieldValue[i];
|
|
12649
12677
|
});
|
|
12650
12678
|
`;
|
|
12651
12679
|
let schema = {
|
|
12652
12680
|
"type": "service",
|
|
12653
12681
|
"id": serviceId,
|
|
12654
12682
|
"schemaApi": {
|
|
12655
|
-
"url": "${context.rootUrl}/graphql?rebuildOn=${index}",
|
|
12656
|
-
|
|
12657
|
-
"
|
|
12658
|
-
"
|
|
12659
|
-
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
12660
|
-
},
|
|
12661
|
-
"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",
|
|
12662
12687
|
"adaptor": `
|
|
12663
12688
|
const formBody = ${JSON.stringify(formBody)};
|
|
12664
12689
|
return {
|
|
12665
12690
|
"body": formBody
|
|
12666
12691
|
}
|
|
12667
|
-
|
|
12692
|
+
`,
|
|
12693
|
+
"cache": 600000
|
|
12668
12694
|
},
|
|
12669
12695
|
// "body": formBody,
|
|
12670
12696
|
"data": {
|
|
12671
|
-
"
|
|
12672
|
-
// "
|
|
12673
|
-
"
|
|
12674
|
-
"
|
|
12675
|
-
"
|
|
12697
|
+
"__page": "${index + 1}",
|
|
12698
|
+
// "__total": `\${${props.name}.length}`,
|
|
12699
|
+
"__total": "${__tableItems.length}",
|
|
12700
|
+
"__paginationServiceId": serviceId,
|
|
12701
|
+
"__formId": form.id
|
|
12676
12702
|
},
|
|
12677
12703
|
"onEvent": {
|
|
12678
12704
|
"init": {
|
|
@@ -12692,25 +12718,30 @@ function getFormPaginationWrapper(props, form) {
|
|
|
12692
12718
|
* @param {*} props
|
|
12693
12719
|
* @param {*} mode edit/new/readonly
|
|
12694
12720
|
*/
|
|
12695
|
-
async function getForm(props, mode = "edit") {
|
|
12721
|
+
async function getForm(props, mode = "edit", formId) {
|
|
12696
12722
|
let formFields = getFormFields(props, mode);
|
|
12697
12723
|
let body = await getFormBody(null, formFields);
|
|
12698
|
-
|
|
12724
|
+
if(!formId){
|
|
12725
|
+
formId = `form_popup__${props.id}`;
|
|
12726
|
+
}
|
|
12699
12727
|
let schema = {
|
|
12700
12728
|
"type": "form",
|
|
12701
|
-
"id":
|
|
12729
|
+
"id": formId,
|
|
12702
12730
|
"title": "表单",
|
|
12703
12731
|
"debug": false,
|
|
12704
12732
|
"mode": "normal",
|
|
12705
12733
|
"body": body,
|
|
12706
12734
|
"wrapWithPanel": false,
|
|
12735
|
+
"canAccessSuperData": false,
|
|
12707
12736
|
"className": "steedos-object-form steedos-amis-form"
|
|
12708
12737
|
};
|
|
12709
12738
|
if (mode === "edit") {
|
|
12710
12739
|
let onEditItemSubmitScript = `
|
|
12711
12740
|
// let fieldValue = _.cloneDeep(event.data["${props.name}"]);
|
|
12712
|
-
let fieldValue = event.data.
|
|
12713
|
-
|
|
12741
|
+
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
12742
|
+
//这里加__super.__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
12743
|
+
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
12744
|
+
fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
|
|
12714
12745
|
doAction({
|
|
12715
12746
|
"componentId": "${props.id}",
|
|
12716
12747
|
"actionType": "setValue",
|
|
@@ -12718,16 +12749,6 @@ async function getForm(props, mode = "edit") {
|
|
|
12718
12749
|
"value": fieldValue
|
|
12719
12750
|
}
|
|
12720
12751
|
});
|
|
12721
|
-
// // 因为翻页form中用的是event.data.changedItems中的数据,所以不需要像下面这样doAction setValue变更中间变量changedItems值
|
|
12722
|
-
// doAction({
|
|
12723
|
-
// "componentId": event.data.wrapperServiceId,
|
|
12724
|
-
// "actionType": "setValue",
|
|
12725
|
-
// "args": {
|
|
12726
|
-
// "value": {
|
|
12727
|
-
// "changedItems": fieldValue
|
|
12728
|
-
// }
|
|
12729
|
-
// }
|
|
12730
|
-
// });
|
|
12731
12752
|
`;
|
|
12732
12753
|
Object.assign(schema, {
|
|
12733
12754
|
"onEvent": {
|
|
@@ -12755,29 +12776,30 @@ async function getForm(props, mode = "edit") {
|
|
|
12755
12776
|
}
|
|
12756
12777
|
else if (mode === "new") {
|
|
12757
12778
|
let onNewItemSubmitScript = `
|
|
12758
|
-
|
|
12759
|
-
if(
|
|
12760
|
-
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
|
+
});
|
|
12761
12802
|
}
|
|
12762
|
-
let fieldValue = event.data.changedItems;
|
|
12763
|
-
fieldValue.push(JSON.parse(JSON.stringify(event.data)));
|
|
12764
|
-
doAction({
|
|
12765
|
-
"componentId": "${props.id}",
|
|
12766
|
-
"actionType": "setValue",
|
|
12767
|
-
"args": {
|
|
12768
|
-
"value": fieldValue
|
|
12769
|
-
}
|
|
12770
|
-
});
|
|
12771
|
-
// // 因为翻页form中用的是event.data.changedItems中的数据,所以不需要像下面这样doAction setValue变更中间变量changedItems值
|
|
12772
|
-
// doAction({
|
|
12773
|
-
// "componentId": event.data.wrapperServiceId,
|
|
12774
|
-
// "actionType": "setValue",
|
|
12775
|
-
// "args": {
|
|
12776
|
-
// "value": {
|
|
12777
|
-
// "changedItems": fieldValue
|
|
12778
|
-
// }
|
|
12779
|
-
// }
|
|
12780
|
-
// });
|
|
12781
12803
|
`;
|
|
12782
12804
|
Object.assign(schema, {
|
|
12783
12805
|
"onEvent": {
|
|
@@ -12810,6 +12832,7 @@ async function getForm(props, mode = "edit") {
|
|
|
12810
12832
|
}
|
|
12811
12833
|
|
|
12812
12834
|
async function getButtonNew(props) {
|
|
12835
|
+
let formId = `form_popup__${props.id}`;
|
|
12813
12836
|
return {
|
|
12814
12837
|
"label": "新增",
|
|
12815
12838
|
"type": "button",
|
|
@@ -12823,14 +12846,28 @@ async function getButtonNew(props) {
|
|
|
12823
12846
|
"type": "dialog",
|
|
12824
12847
|
"title": "新增行",
|
|
12825
12848
|
"body": [
|
|
12826
|
-
await getForm(props, "new")
|
|
12849
|
+
await getForm(props, "new", formId)
|
|
12827
12850
|
],
|
|
12828
12851
|
"size": "lg",
|
|
12829
12852
|
"showCloseButton": true,
|
|
12830
12853
|
"showErrorMsg": true,
|
|
12831
12854
|
"showLoading": true,
|
|
12832
12855
|
"className": "app-popover",
|
|
12833
|
-
"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
|
+
}
|
|
12834
12871
|
}
|
|
12835
12872
|
}
|
|
12836
12873
|
]
|
|
@@ -12841,27 +12878,7 @@ async function getButtonNew(props) {
|
|
|
12841
12878
|
}
|
|
12842
12879
|
|
|
12843
12880
|
async function getButtonEdit(props, showAsInlineEditMode) {
|
|
12844
|
-
let
|
|
12845
|
-
let scope = event.context.scoped;
|
|
12846
|
-
let wrapperServiceId = event.data.wrapperServiceId;
|
|
12847
|
-
let wrapperService = scope.getComponentById(wrapperServiceId);
|
|
12848
|
-
let wrapperServiceData = wrapperService.getData();
|
|
12849
|
-
let originalFieldValue = wrapperServiceData["${props.name}"];//这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
12850
|
-
//不可以直接像event.data.changedItems = originalFieldValue; 这样整个赋值,否则作用域会断,造成无法还原
|
|
12851
|
-
event.data.changedItems.forEach(function(n,i){
|
|
12852
|
-
event.data.changedItems[i] = originalFieldValue[i];
|
|
12853
|
-
});
|
|
12854
|
-
// 因为翻页form中用的是event.data.changedItems中的数据,所以像下面这样doAction setValue无法实现还原
|
|
12855
|
-
// doAction({
|
|
12856
|
-
// "componentId": wrapperServiceId,
|
|
12857
|
-
// "actionType": "setValue",
|
|
12858
|
-
// "args": {
|
|
12859
|
-
// "value": {
|
|
12860
|
-
// "changedItems": originalFieldValue
|
|
12861
|
-
// }
|
|
12862
|
-
// }
|
|
12863
|
-
// });
|
|
12864
|
-
`;
|
|
12881
|
+
let formId = `form_popup__${props.id}`;
|
|
12865
12882
|
return {
|
|
12866
12883
|
"type": "button",
|
|
12867
12884
|
"label": "",
|
|
@@ -12876,7 +12893,7 @@ async function getButtonEdit(props, showAsInlineEditMode) {
|
|
|
12876
12893
|
"type": "dialog",
|
|
12877
12894
|
"title": "编辑行",
|
|
12878
12895
|
"body": [
|
|
12879
|
-
await getForm(props, "edit")
|
|
12896
|
+
await getForm(props, "edit", formId)
|
|
12880
12897
|
],
|
|
12881
12898
|
"size": "lg",
|
|
12882
12899
|
"showCloseButton": true,
|
|
@@ -12885,25 +12902,31 @@ async function getButtonEdit(props, showAsInlineEditMode) {
|
|
|
12885
12902
|
"className": "app-popover",
|
|
12886
12903
|
"closeOnEsc": false,
|
|
12887
12904
|
"data": {
|
|
12888
|
-
// 这里必须加data数据映射,否则翻页功能中取
|
|
12905
|
+
// 这里必须加data数据映射,否则翻页功能中取__tableItems值时会乱,比如翻页编辑后会把上一页中没改过的字段值带过去
|
|
12889
12906
|
// 额外把华炎魔方主表记录ObjectForm中的字段值从record变量中映射到子表form中,因为子表lookup字段filtersFunction中可能依赖了主表记录中的字段值,比如“工作流规则”对象“时间触发器”字段中的“日期字段”字段
|
|
12890
12907
|
// 额外把global、uiSchema也映射过去,有可能要用,后续需要用到其他变更可以这里加映射
|
|
12891
|
-
"&": "${record || {}}",
|
|
12908
|
+
// "&": "${record || {}}",
|
|
12909
|
+
// 换成从__super来映射上级表单数据是因为对象列表视图界面中每行下拉菜单中的编辑按钮弹出的表单中的子表所在作用域中没有record变量
|
|
12910
|
+
// 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
|
|
12911
|
+
"__parentForm": "${__super.__super || {}}",
|
|
12892
12912
|
"global": "${global}",
|
|
12893
12913
|
"uiSchema": "${uiSchema}",
|
|
12894
|
-
"grid": "${grid}",
|
|
12895
12914
|
"index": "${index}",
|
|
12896
|
-
"
|
|
12897
|
-
"
|
|
12915
|
+
"__tableItems": `\${${props.name}}`,
|
|
12916
|
+
"__wrapperServiceId": "${__wrapperServiceId}"
|
|
12898
12917
|
},
|
|
12899
12918
|
"onEvent": {
|
|
12900
|
-
"
|
|
12901
|
-
|
|
12902
|
-
|
|
12903
|
-
|
|
12904
|
-
|
|
12905
|
-
|
|
12906
|
-
|
|
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
|
+
]
|
|
12907
12930
|
}
|
|
12908
12931
|
}
|
|
12909
12932
|
}
|
|
@@ -12939,14 +12962,16 @@ async function getButtonView(props) {
|
|
|
12939
12962
|
"closeOnEsc": false,
|
|
12940
12963
|
"actions": [],
|
|
12941
12964
|
"data": {
|
|
12942
|
-
// 这里必须加data数据映射,否则翻页功能中取
|
|
12965
|
+
// 这里必须加data数据映射,否则翻页功能中取__tableItems值时会乱,比如翻页编辑后会把上一页中没改过的字段值带过去
|
|
12943
12966
|
// 额外把华炎魔方主表记录ObjectForm中的字段值从formData变量中映射到子表form中,因为子表lookup字段filtersFunction中可能依赖了主表记录中的字段值,比如“工作流规则”对象“时间触发器”字段中的“日期字段”字段
|
|
12944
12967
|
// global、uiSchema等常用变量本来就在formData变量已经存在了,无需另外映射
|
|
12945
|
-
"&": "${formData || {}}",
|
|
12946
|
-
|
|
12968
|
+
// "&": "${formData || {}}",
|
|
12969
|
+
// 换成从__super来映射上级表单数据是因为对象列表视图界面中每行下拉菜单中的编辑按钮弹出的表单中的子表所在作用域中没有formData变量
|
|
12970
|
+
// 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
|
|
12971
|
+
"__parentForm": "${__super.__super || {}}",
|
|
12947
12972
|
"index": "${index}",
|
|
12948
|
-
"
|
|
12949
|
-
"
|
|
12973
|
+
"__tableItems": `\${${props.name}}`,
|
|
12974
|
+
"__wrapperServiceId": "${__wrapperServiceId}"
|
|
12950
12975
|
}
|
|
12951
12976
|
}
|
|
12952
12977
|
}
|
|
@@ -12958,30 +12983,20 @@ async function getButtonView(props) {
|
|
|
12958
12983
|
|
|
12959
12984
|
function getButtonDelete(props) {
|
|
12960
12985
|
let onDeleteItemScript = `
|
|
12961
|
-
// let fieldValue =
|
|
12962
|
-
|
|
12963
|
-
|
|
12964
|
-
|
|
12965
|
-
let
|
|
12966
|
-
|
|
12967
|
-
|
|
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);
|
|
12968
12993
|
doAction({
|
|
12969
12994
|
"componentId": "${props.id}",
|
|
12970
12995
|
"actionType": "setValue",
|
|
12971
12996
|
"args": {
|
|
12972
|
-
"value":
|
|
12997
|
+
"value": lastestFieldValue
|
|
12973
12998
|
}
|
|
12974
12999
|
});
|
|
12975
|
-
// // 因为翻页form中用的是event.data.changedItems中的数据,所以不需要像下面这样doAction setValue变更中间变量changedItems值
|
|
12976
|
-
// doAction({
|
|
12977
|
-
// "componentId": event.data.wrapperServiceId,
|
|
12978
|
-
// "actionType": "setValue",
|
|
12979
|
-
// "args": {
|
|
12980
|
-
// "value": {
|
|
12981
|
-
// "changedItems": fieldValue
|
|
12982
|
-
// }
|
|
12983
|
-
// }
|
|
12984
|
-
// });
|
|
12985
13000
|
`;
|
|
12986
13001
|
return {
|
|
12987
13002
|
"type": "button",
|
|
@@ -13019,13 +13034,15 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13019
13034
|
if (props.editable) {
|
|
13020
13035
|
let showEditButton = true;
|
|
13021
13036
|
if (showAsInlineEditMode) {
|
|
13022
|
-
//
|
|
13023
|
-
|
|
13024
|
-
|
|
13025
|
-
|
|
13026
|
-
|
|
13027
|
-
|
|
13028
|
-
|
|
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
|
+
// }
|
|
13029
13046
|
}
|
|
13030
13047
|
// 编辑时显示编辑按钮
|
|
13031
13048
|
if (showEditButton) {
|
|
@@ -13035,11 +13052,9 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13035
13052
|
}
|
|
13036
13053
|
else {
|
|
13037
13054
|
// 只读时显示查看按钮
|
|
13038
|
-
if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
|
|
13039
|
-
|
|
13040
|
-
|
|
13041
|
-
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13042
|
-
}
|
|
13055
|
+
// 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
|
|
13056
|
+
let buttonViewSchema = await getButtonView(props);
|
|
13057
|
+
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13043
13058
|
}
|
|
13044
13059
|
if (props.removable) {
|
|
13045
13060
|
let buttonDeleteSchema = getButtonDelete(props);
|
|
@@ -13059,7 +13074,7 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13059
13074
|
"id": props.id,
|
|
13060
13075
|
"columns": await getInputTableColumns(props),
|
|
13061
13076
|
// "needConfirm": false, //不可以配置为false,否则,单元格都是可编辑状态,且很多static类型无法正常显示,比如static-mapping
|
|
13062
|
-
"strictMode":
|
|
13077
|
+
"strictMode": props.strictMode,
|
|
13063
13078
|
"showTableAddBtn": false,
|
|
13064
13079
|
"showFooterAddBtn": false,
|
|
13065
13080
|
"className": props.tableClassName
|
|
@@ -13075,40 +13090,53 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13075
13090
|
if (showAsInlineEditMode) {
|
|
13076
13091
|
inputTableSchema.needConfirm = false;
|
|
13077
13092
|
}
|
|
13078
|
-
let
|
|
13079
|
-
|
|
13080
|
-
|
|
13081
|
-
|
|
13082
|
-
|
|
13083
|
-
|
|
13084
|
-
|
|
13085
|
-
|
|
13086
|
-
|
|
13087
|
-
|
|
13088
|
-
|
|
13089
|
-
|
|
13090
|
-
|
|
13091
|
-
}
|
|
13092
|
-
|
|
13093
|
-
|
|
13094
|
-
}
|
|
13095
|
-
};
|
|
13093
|
+
let amis = props["input-table"] || props.amis;//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
|
|
13094
|
+
if (amis) {
|
|
13095
|
+
// 支持配置amis属性重写或添加最终生成的input-table中任何属性。
|
|
13096
|
+
delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
|
|
13097
|
+
Object.assign(inputTableSchema, amis);
|
|
13098
|
+
}
|
|
13099
|
+
const isAnyFieldHasDependOn = (props.fields || []).find(function (item) {
|
|
13100
|
+
return item.depend_on;
|
|
13101
|
+
});
|
|
13102
|
+
if (isAnyFieldHasDependOn) {
|
|
13103
|
+
// 有任意一个子字段有depend_on属性时,强制设置禁用静态模式
|
|
13104
|
+
Object.assign(inputTableSchema, {
|
|
13105
|
+
strictMode: false
|
|
13106
|
+
});
|
|
13107
|
+
}
|
|
13108
|
+
let schemaBody = [inputTableSchema];
|
|
13096
13109
|
let footerToolbar = _$1.clone(props.footerToolbar || []); //这里不clone的话,会造成死循环,应该是因为props属性变更会让组件重新渲染
|
|
13097
13110
|
if (props.addable) {
|
|
13098
13111
|
let buttonNewSchema = await getButtonNew(props);
|
|
13099
13112
|
footerToolbar.unshift(buttonNewSchema);
|
|
13100
13113
|
}
|
|
13101
13114
|
if (footerToolbar.length) {
|
|
13102
|
-
|
|
13115
|
+
schemaBody.push({
|
|
13103
13116
|
"type": "wrapper",
|
|
13104
13117
|
"size": "none",
|
|
13105
13118
|
"body": footerToolbar
|
|
13106
13119
|
});
|
|
13107
13120
|
}
|
|
13108
|
-
|
|
13109
|
-
|
|
13110
|
-
|
|
13111
|
-
|
|
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
|
+
};
|
|
13112
13140
|
// console.log("===schema===", schema);
|
|
13113
13141
|
return schema;
|
|
13114
13142
|
};
|