@steedos-widgets/amis-lib 3.6.2-beta.1 → 3.6.2-beta.3
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 +185 -52
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +185 -52
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +62 -22
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/api.d.ts +1 -0
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -2165,6 +2165,18 @@ async function getTableColumns(fields, options){
|
|
|
2165
2165
|
if(field.type === 'datetime'){
|
|
2166
2166
|
className += 'datetime-min-w';
|
|
2167
2167
|
}
|
|
2168
|
+
|
|
2169
|
+
//field上的amis属性里的clssname需要单独判断类型合并
|
|
2170
|
+
if (typeof field.amis?.className == "object") {
|
|
2171
|
+
className = {
|
|
2172
|
+
[className]: "true",
|
|
2173
|
+
...field.amis.className
|
|
2174
|
+
};
|
|
2175
|
+
} else if (typeof field.amis?.className == "string") {
|
|
2176
|
+
className = `${className} ${field.amis.className} `;
|
|
2177
|
+
}
|
|
2178
|
+
delete field.amis?.className;
|
|
2179
|
+
|
|
2168
2180
|
if(!field.hidden && !field.extra){
|
|
2169
2181
|
columnItem = Object.assign({}, {
|
|
2170
2182
|
name: field.name,
|
|
@@ -2261,12 +2273,24 @@ function getMobileLines(tpls){
|
|
|
2261
2273
|
// 右侧半行,这里加样式类 flex flex-shrink-0,是为了省略号只显示在左半行,右半行文字一般比较短,如果也加省略号效果的话,左侧文字多的话,右侧没几个字就显示省略号了
|
|
2262
2274
|
lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0";
|
|
2263
2275
|
}
|
|
2276
|
+
//支持字段amis属性配置classname,识别classname的类型,与原样式合并
|
|
2277
|
+
var className;
|
|
2278
|
+
if (typeof item.field.amis?.className == "object") {
|
|
2279
|
+
className = {
|
|
2280
|
+
[lineChildrenClassName]: "true",
|
|
2281
|
+
...item.field.amis.className
|
|
2282
|
+
};
|
|
2283
|
+
} else if (typeof item.field.amis?.className == "string") {
|
|
2284
|
+
className = `${lineChildrenClassName} ${item.field.amis.className} `;
|
|
2285
|
+
} else {
|
|
2286
|
+
className = lineChildrenClassName;
|
|
2287
|
+
}
|
|
2264
2288
|
lineChildren.push({
|
|
2265
2289
|
"type": "tpl",
|
|
2266
2290
|
"tpl": item.tpl,
|
|
2267
|
-
|
|
2291
|
+
className
|
|
2268
2292
|
});
|
|
2269
|
-
|
|
2293
|
+
|
|
2270
2294
|
if(item.field.is_wide){
|
|
2271
2295
|
// 宽字段占整行
|
|
2272
2296
|
isLeft = true;
|
|
@@ -2316,8 +2340,7 @@ async function getMobileTableColumns(fields, options){
|
|
|
2316
2340
|
tpl = await getFieldTpl(field, options);
|
|
2317
2341
|
}
|
|
2318
2342
|
if(!tpl){
|
|
2319
|
-
|
|
2320
|
-
tpl = `\${${field.name} | raw}`;
|
|
2343
|
+
tpl = `\${${field.name}}`;
|
|
2321
2344
|
}
|
|
2322
2345
|
if(!field.hidden && !field.extra){
|
|
2323
2346
|
tpls.push({ field, tpl });
|
|
@@ -2330,7 +2353,7 @@ async function getMobileTableColumns(fields, options){
|
|
|
2330
2353
|
|
|
2331
2354
|
let column = {
|
|
2332
2355
|
name: nameField.name,
|
|
2333
|
-
label: nameField.label,
|
|
2356
|
+
label: options.displayAs == 'split' ? '' : nameField.label,
|
|
2334
2357
|
sortable: nameField.sortable,
|
|
2335
2358
|
type: "button",
|
|
2336
2359
|
level: "link",
|
|
@@ -2990,6 +3013,13 @@ async function getTableApi(mainObject, fields, options){
|
|
|
2990
3013
|
}
|
|
2991
3014
|
// SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
|
|
2992
3015
|
};
|
|
3016
|
+
const listviewComponent = $(".steedos-object-listview .antd-Table-table");
|
|
3017
|
+
const firstListviewComponent = listviewComponent && listviewComponent[0];
|
|
3018
|
+
if(firstListviewComponent){
|
|
3019
|
+
setTimeout(()=>{
|
|
3020
|
+
firstListviewComponent.scrollIntoView();
|
|
3021
|
+
}, 600);
|
|
3022
|
+
}
|
|
2993
3023
|
${options.adaptor || ''}
|
|
2994
3024
|
return payload;
|
|
2995
3025
|
`;
|
|
@@ -3369,6 +3399,18 @@ function getBatchDelete(objectName){
|
|
|
3369
3399
|
return {
|
|
3370
3400
|
method: 'post',
|
|
3371
3401
|
url: getApi$2(),
|
|
3402
|
+
adaptor: `
|
|
3403
|
+
if(payload.errors){
|
|
3404
|
+
payload.data.deleteErrorMessage = [];
|
|
3405
|
+
payload.errors.forEach(function(error){
|
|
3406
|
+
let errorRecord = error.path.map(function (item) {
|
|
3407
|
+
return item.split('delete__')[1].to_float() + 1;
|
|
3408
|
+
}).toString();
|
|
3409
|
+
payload.data.deleteErrorMessage.push("第" + errorRecord + "条记录删除出现异常,报错信息为(" + (window.t ? window.t(error.message) : error.message) + ")");
|
|
3410
|
+
})
|
|
3411
|
+
}
|
|
3412
|
+
return payload;
|
|
3413
|
+
`,
|
|
3372
3414
|
requestAdaptor: `
|
|
3373
3415
|
var ids = api.data.ids.split(",");
|
|
3374
3416
|
var deleteArray = [];
|
|
@@ -8087,7 +8129,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8087
8129
|
else {
|
|
8088
8130
|
if(options && options.isRelated){
|
|
8089
8131
|
return [
|
|
8090
|
-
"statistics",
|
|
8091
8132
|
{
|
|
8092
8133
|
"type": "pagination",
|
|
8093
8134
|
"maxButtons": 10,
|
|
@@ -8100,7 +8141,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8100
8141
|
const no_pagination = mainObject.paging && (mainObject.paging.enabled === false);
|
|
8101
8142
|
const is_lookup = options.isLookup;
|
|
8102
8143
|
const commonConfig = [
|
|
8103
|
-
"statistics",
|
|
8104
8144
|
{
|
|
8105
8145
|
"type": "pagination",
|
|
8106
8146
|
"maxButtons": 10,
|
|
@@ -8219,6 +8259,29 @@ function getBulkActions(objectSchema){
|
|
|
8219
8259
|
"className": "hidden",
|
|
8220
8260
|
"id": "batchDelete",
|
|
8221
8261
|
"api": getBatchDelete(objectSchema.name),
|
|
8262
|
+
"feedback": {
|
|
8263
|
+
"title": "删除警告",
|
|
8264
|
+
"visibleOn": "${deleteErrorMessage}",
|
|
8265
|
+
"body": [
|
|
8266
|
+
{
|
|
8267
|
+
"type": "each",
|
|
8268
|
+
"name": "deleteErrorMessage",
|
|
8269
|
+
"items": {
|
|
8270
|
+
"type": "alert",
|
|
8271
|
+
"body": "${item}",
|
|
8272
|
+
"level": "danger",
|
|
8273
|
+
"className": "mb-3"
|
|
8274
|
+
}
|
|
8275
|
+
}
|
|
8276
|
+
],
|
|
8277
|
+
"actions": [
|
|
8278
|
+
{
|
|
8279
|
+
"type": "button",
|
|
8280
|
+
"actionType": "close",
|
|
8281
|
+
"label": "关闭"
|
|
8282
|
+
}
|
|
8283
|
+
]
|
|
8284
|
+
}
|
|
8222
8285
|
}
|
|
8223
8286
|
// {
|
|
8224
8287
|
// "label": "批量修改",
|
|
@@ -8365,6 +8428,10 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8365
8428
|
const rowsDiff = _.cloneDeep(api.data.rowsDiff);
|
|
8366
8429
|
rowsDiff.forEach(function (item, index) {
|
|
8367
8430
|
for(key in item){
|
|
8431
|
+
// image、select等字段清空值后保存的空字符串转换为null。
|
|
8432
|
+
if(item[key] === ''){
|
|
8433
|
+
item[key] = null;
|
|
8434
|
+
}
|
|
8368
8435
|
if(_.includes(imageNames, key)){
|
|
8369
8436
|
if(typeof item[key] == "string"){
|
|
8370
8437
|
const match = item[key].match(/\\/([^\\/]+)$/);
|
|
@@ -10757,9 +10824,11 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10757
10824
|
*/
|
|
10758
10825
|
if(enable_tree){
|
|
10759
10826
|
const rows = _.map(payload.data.rows, (item)=>{
|
|
10760
|
-
|
|
10761
|
-
|
|
10762
|
-
|
|
10827
|
+
if (!item.children) {
|
|
10828
|
+
return { ...item, children: [] };
|
|
10829
|
+
} else {
|
|
10830
|
+
return item;
|
|
10831
|
+
}
|
|
10763
10832
|
})
|
|
10764
10833
|
payload.data.rows = rows;
|
|
10765
10834
|
}
|
|
@@ -12665,8 +12734,8 @@ async function getFormBody(permissionFields, formFields, ctx){
|
|
|
12665
12734
|
/*
|
|
12666
12735
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
12667
12736
|
* @Date: 2023-11-15 09:50:22
|
|
12668
|
-
* @LastEditors:
|
|
12669
|
-
* @LastEditTime: 2024-01-
|
|
12737
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
12738
|
+
* @LastEditTime: 2024-01-12 14:51:00
|
|
12670
12739
|
*/
|
|
12671
12740
|
|
|
12672
12741
|
/**
|
|
@@ -12815,7 +12884,12 @@ function getFormPagination(props, mode) {
|
|
|
12815
12884
|
let currentIndex = event.data.index;
|
|
12816
12885
|
// 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
|
|
12817
12886
|
let currentFormValues = scope.getComponentById(__formId).getValues();
|
|
12818
|
-
|
|
12887
|
+
if(event.data.parent){
|
|
12888
|
+
fieldValue[event.data.__parentIndex].children[currentIndex] = currentFormValues;
|
|
12889
|
+
}
|
|
12890
|
+
else{
|
|
12891
|
+
fieldValue[currentIndex] = currentFormValues;
|
|
12892
|
+
}
|
|
12819
12893
|
// 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
|
|
12820
12894
|
doAction({
|
|
12821
12895
|
"componentId": "${props.id}",
|
|
@@ -12882,7 +12956,8 @@ function getFormPagination(props, mode) {
|
|
|
12882
12956
|
},
|
|
12883
12957
|
{
|
|
12884
12958
|
"type": "tpl",
|
|
12885
|
-
|
|
12959
|
+
// 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
|
|
12960
|
+
"tpl": "${__page}/${__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length}"
|
|
12886
12961
|
},
|
|
12887
12962
|
{
|
|
12888
12963
|
"type": "button",
|
|
@@ -12890,7 +12965,9 @@ function getFormPagination(props, mode) {
|
|
|
12890
12965
|
"icon": `fa fa-angle-right`,
|
|
12891
12966
|
"level": "link",
|
|
12892
12967
|
"pageChangeDirection": "next",
|
|
12893
|
-
"disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
|
|
12968
|
+
// "disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
|
|
12969
|
+
// 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
|
|
12970
|
+
"disabledOn": showPagination ? "${__page >= (__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length)}" : "true",
|
|
12894
12971
|
"size": "sm",
|
|
12895
12972
|
"id": buttonNextId,
|
|
12896
12973
|
"onEvent": {
|
|
@@ -12923,7 +13000,7 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12923
13000
|
"data": {
|
|
12924
13001
|
// 这里加__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
12925
13002
|
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
12926
|
-
"&": "${__tableItems[__super.index]}"
|
|
13003
|
+
"&": "${__super.parent ? __tableItems[__parentIndex]['children'][__super.index] : __tableItems[__super.index]}"
|
|
12927
13004
|
}
|
|
12928
13005
|
});
|
|
12929
13006
|
let formBody = [
|
|
@@ -12946,6 +13023,10 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12946
13023
|
}
|
|
12947
13024
|
];
|
|
12948
13025
|
let onServiceInitedScript = `
|
|
13026
|
+
if(event.data.parent){
|
|
13027
|
+
// 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
|
|
13028
|
+
event.data.__parentIndex = _.findIndex(event.data.__tableItems, {_id: event.data.parent._id});
|
|
13029
|
+
}
|
|
12949
13030
|
// 以下脚本是为了解决有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
|
|
12950
13031
|
// 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
|
|
12951
13032
|
// 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
|
|
@@ -13001,6 +13082,7 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13001
13082
|
// "body": formBody,
|
|
13002
13083
|
"data": {
|
|
13003
13084
|
"__page": "${index + 1}",
|
|
13085
|
+
"__parentIndex": null,//兼容节点嵌套情况,即节点中有children属性时,这里记录当前节点所属上层节点index,只支持向上找一层,不支持多层
|
|
13004
13086
|
// "__total": `\${${props.name}.length}`,
|
|
13005
13087
|
// "__total": "${__tableItems.length}",
|
|
13006
13088
|
// "__paginationServiceId": serviceId,
|
|
@@ -13048,7 +13130,17 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
13048
13130
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13049
13131
|
//这里加__super.__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
13050
13132
|
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
13051
|
-
fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
|
|
13133
|
+
// fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
|
|
13134
|
+
var currentIndex = event.data.__super.__super.index;
|
|
13135
|
+
var currentFormValues = JSON.parse(JSON.stringify(event.data));
|
|
13136
|
+
var parent = event.data.__super.__super.parent;
|
|
13137
|
+
var __parentIndex = event.data.__super.__super.__parentIndex;
|
|
13138
|
+
if(parent){
|
|
13139
|
+
fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
|
|
13140
|
+
}
|
|
13141
|
+
else{
|
|
13142
|
+
fieldValue[currentIndex] = currentFormValues;
|
|
13143
|
+
}
|
|
13052
13144
|
doAction({
|
|
13053
13145
|
"componentId": "${props.id}",
|
|
13054
13146
|
"actionType": "setValue",
|
|
@@ -13188,7 +13280,14 @@ async function getButtonActions(props, mode) {
|
|
|
13188
13280
|
let scope = event.context.scoped;
|
|
13189
13281
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13190
13282
|
// 新建一条空白行并保存到子表组件
|
|
13191
|
-
|
|
13283
|
+
var parent = event.data.__super.parent;
|
|
13284
|
+
var __parentIndex = parent && _.findIndex(fieldValue, {_id: parent._id});
|
|
13285
|
+
if(parent){
|
|
13286
|
+
fieldValue[__parentIndex].children.push({});
|
|
13287
|
+
}
|
|
13288
|
+
else{
|
|
13289
|
+
fieldValue.push({});
|
|
13290
|
+
}
|
|
13192
13291
|
doAction({
|
|
13193
13292
|
"componentId": "${props.id}",
|
|
13194
13293
|
"actionType": "setValue",
|
|
@@ -13200,7 +13299,13 @@ async function getButtonActions(props, mode) {
|
|
|
13200
13299
|
let __paginationServiceId = "${formPaginationId}";
|
|
13201
13300
|
let __paginationData = scope.getComponentById(__paginationServiceId).getData();
|
|
13202
13301
|
event.data.index = __paginationData.index;
|
|
13203
|
-
|
|
13302
|
+
if(parent){
|
|
13303
|
+
event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13304
|
+
event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
|
|
13305
|
+
}
|
|
13306
|
+
else{
|
|
13307
|
+
event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13308
|
+
}
|
|
13204
13309
|
// 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
|
|
13205
13310
|
scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
|
|
13206
13311
|
`;
|
|
@@ -13211,7 +13316,15 @@ async function getButtonActions(props, mode) {
|
|
|
13211
13316
|
let newItem = scope.getComponentById(__formId).getValues();//这里不可以用event.data,因为其拿到的是弹出表单时的初始值,不是用户实时填写的数据
|
|
13212
13317
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13213
13318
|
// 复制当前页数据到新建行并保存到子表组件
|
|
13214
|
-
fieldValue.push(newItem);
|
|
13319
|
+
// fieldValue.push(newItem);
|
|
13320
|
+
var parent = event.data.__super.parent;
|
|
13321
|
+
var __parentIndex = parent && _.findIndex(fieldValue, {_id: parent._id});
|
|
13322
|
+
if(parent){
|
|
13323
|
+
fieldValue[__parentIndex].children.push(newItem);
|
|
13324
|
+
}
|
|
13325
|
+
else{
|
|
13326
|
+
fieldValue.push(newItem);
|
|
13327
|
+
}
|
|
13215
13328
|
doAction({
|
|
13216
13329
|
"componentId": "${props.id}",
|
|
13217
13330
|
"actionType": "setValue",
|
|
@@ -13223,7 +13336,14 @@ async function getButtonActions(props, mode) {
|
|
|
13223
13336
|
let __paginationServiceId = "${formPaginationId}";
|
|
13224
13337
|
let __paginationData = scope.getComponentById(__paginationServiceId).getData();
|
|
13225
13338
|
event.data.index = __paginationData.index;
|
|
13226
|
-
event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13339
|
+
// event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13340
|
+
if(parent){
|
|
13341
|
+
event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13342
|
+
event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
|
|
13343
|
+
}
|
|
13344
|
+
else{
|
|
13345
|
+
event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13346
|
+
}
|
|
13227
13347
|
// 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
|
|
13228
13348
|
scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
|
|
13229
13349
|
`;
|
|
@@ -13299,7 +13419,8 @@ async function getButtonActions(props, mode) {
|
|
|
13299
13419
|
"_master": "${_master}",
|
|
13300
13420
|
"global": "${global}",
|
|
13301
13421
|
"uiSchema": "${uiSchema}",
|
|
13302
|
-
"index": "${index}"
|
|
13422
|
+
"index": "${index}",//amis组件自带行索引,在节点嵌套情况下,当前节点如果是children属性下的子节点时,这里的index是当前节点在children中的索引,而不是外层父节点的index
|
|
13423
|
+
"parent": "${parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
|
|
13303
13424
|
// "__tableItems": `\${${props.name}}`
|
|
13304
13425
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13305
13426
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
@@ -13327,35 +13448,39 @@ async function getButtonActions(props, mode) {
|
|
|
13327
13448
|
Object.assign(actionShowEditDialog.dialog, props.dialog);
|
|
13328
13449
|
}
|
|
13329
13450
|
if (mode == "new") {
|
|
13330
|
-
`
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
|
|
13334
|
-
|
|
13335
|
-
|
|
13336
|
-
|
|
13337
|
-
|
|
13338
|
-
|
|
13339
|
-
|
|
13340
|
-
|
|
13341
|
-
|
|
13342
|
-
|
|
13343
|
-
|
|
13344
|
-
|
|
13345
|
-
|
|
13346
|
-
|
|
13347
|
-
|
|
13348
|
-
|
|
13349
|
-
|
|
13350
|
-
|
|
13351
|
-
|
|
13352
|
-
|
|
13353
|
-
|
|
13354
|
-
|
|
13355
|
-
|
|
13356
|
-
|
|
13357
|
-
|
|
13358
|
-
`;
|
|
13451
|
+
// let onNewLineScript = `
|
|
13452
|
+
// let newItem = {};
|
|
13453
|
+
// if(event.data["${props.name}"]){
|
|
13454
|
+
// // let fieldValue = event.data.__tableItems;
|
|
13455
|
+
// // 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
|
|
13456
|
+
// // let fieldValue = _.clone(event.data["${props.name}"]);
|
|
13457
|
+
// let fieldValue = event.data["${props.name}"];
|
|
13458
|
+
// fieldValue.push(newItem);
|
|
13459
|
+
// doAction({
|
|
13460
|
+
// "componentId": "${props.id}",
|
|
13461
|
+
// "actionType": "setValue",
|
|
13462
|
+
// "args": {
|
|
13463
|
+
// "value": fieldValue
|
|
13464
|
+
// }
|
|
13465
|
+
// });
|
|
13466
|
+
// event.data.index = fieldValue.length - 1;
|
|
13467
|
+
// }
|
|
13468
|
+
// else{
|
|
13469
|
+
// // 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
|
|
13470
|
+
// doAction({
|
|
13471
|
+
// "componentId": "${props.id}",
|
|
13472
|
+
// "actionType": "setValue",
|
|
13473
|
+
// "args": {
|
|
13474
|
+
// "value": [newItem]
|
|
13475
|
+
// }
|
|
13476
|
+
// });
|
|
13477
|
+
// event.data.index = 1;
|
|
13478
|
+
// }
|
|
13479
|
+
// `;
|
|
13480
|
+
// let actionNewLine = {
|
|
13481
|
+
// "actionType": "custom",
|
|
13482
|
+
// "script": onNewLineScript
|
|
13483
|
+
// };
|
|
13359
13484
|
// 新增行时不需要在弹出编辑表单前先加一行,因为会在编辑表单所在service初始化时判断到是新增就自动增加一行,因为这里拿不到event.data.__tableItems,也无法变更其值
|
|
13360
13485
|
// actions = [actionNewLine, actionShowEditDialog];
|
|
13361
13486
|
actions = [actionShowEditDialog];
|
|
@@ -13414,7 +13539,15 @@ async function getButtonActions(props, mode) {
|
|
|
13414
13539
|
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
13415
13540
|
// 这里_.clone是因为字段设计布局设置分组这种弹出窗口中的子表组件,直接删除后,点取消无法还原
|
|
13416
13541
|
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
|
|
13417
|
-
|
|
13542
|
+
var currentIndex = event.data.index;
|
|
13543
|
+
var parent = event.data.__super.parent;
|
|
13544
|
+
var __parentIndex = parent && _.findIndex(lastestFieldValue, {_id: parent._id});
|
|
13545
|
+
if(parent){
|
|
13546
|
+
lastestFieldValue[__parentIndex].children.splice(currentIndex, 1);
|
|
13547
|
+
}
|
|
13548
|
+
else{
|
|
13549
|
+
lastestFieldValue.splice(currentIndex, 1);
|
|
13550
|
+
}
|
|
13418
13551
|
doAction({
|
|
13419
13552
|
"componentId": "${props.id}",
|
|
13420
13553
|
"actionType": "setValue",
|