@steedos-widgets/amis-lib 1.3.22-beta.2 → 1.3.22-beta.4
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 +225 -115
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +225 -115
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +110 -63
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1626,6 +1626,7 @@ async function getQuickEditSchema(field, options){
|
|
|
1626
1626
|
{
|
|
1627
1627
|
"actionType": "custom",
|
|
1628
1628
|
"script": `
|
|
1629
|
+
|
|
1629
1630
|
var _display = _.cloneDeep(event.data._display);
|
|
1630
1631
|
${displayField}
|
|
1631
1632
|
doAction({actionType: 'setValue', "args": {"value": {_display}},componentId: "${quickEditId}"});
|
|
@@ -2012,7 +2013,9 @@ async function getTableColumns(fields, options){
|
|
|
2012
2013
|
if(!options.isLookup && !options.isInputTable){
|
|
2013
2014
|
//将_display放入crud的columns中,可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
2014
2015
|
columns.push({name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
|
|
2015
|
-
|
|
2016
|
+
if(!options.enable_tree){
|
|
2017
|
+
columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
|
|
2018
|
+
}
|
|
2016
2019
|
}
|
|
2017
2020
|
const allowEdit = options.permissions?.allowEdit && !options.isLookup && options.enable_inline_edit != false;
|
|
2018
2021
|
|
|
@@ -2863,7 +2866,21 @@ async function getTableApi(mainObject, fields, options){
|
|
|
2863
2866
|
|
|
2864
2867
|
if(enable_tree){
|
|
2865
2868
|
const records = payload.data.rows || [];
|
|
2866
|
-
const getTreeOptions = SteedosUI.getTreeOptions
|
|
2869
|
+
const getTreeOptions = SteedosUI.getTreeOptions;
|
|
2870
|
+
const assignIndexToTreeRecords = function(tree, parentIndex) {
|
|
2871
|
+
tree.forEach(function (node, index) {
|
|
2872
|
+
// 构建当前节点的 _index
|
|
2873
|
+
var currentIndex = parentIndex ? parentIndex + '-' + (index + 1) : '' + (index + 1);
|
|
2874
|
+
|
|
2875
|
+
// 赋值给节点
|
|
2876
|
+
node._index = currentIndex;
|
|
2877
|
+
|
|
2878
|
+
// 如果有子节点,递归调用函数
|
|
2879
|
+
if (node.children && node.children.length > 0) {
|
|
2880
|
+
assignIndexToTreeRecords(node.children, currentIndex);
|
|
2881
|
+
}
|
|
2882
|
+
});
|
|
2883
|
+
};
|
|
2867
2884
|
let isTreeOptionsComputed = false;
|
|
2868
2885
|
if(records.length === 1 && records[0].children){
|
|
2869
2886
|
isTreeOptionsComputed = true;
|
|
@@ -2871,6 +2888,7 @@ async function getTableApi(mainObject, fields, options){
|
|
|
2871
2888
|
if(!isTreeOptionsComputed){
|
|
2872
2889
|
// 如果api接口设置在缓存,缓存期间并不会重新请求接口,payload.data.rows是上次计算后的结果
|
|
2873
2890
|
payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
|
|
2891
|
+
assignIndexToTreeRecords(payload.data.rows, '');
|
|
2874
2892
|
}
|
|
2875
2893
|
try{
|
|
2876
2894
|
setTimeout(() => {
|
|
@@ -5747,6 +5765,8 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
5747
5765
|
`;
|
|
5748
5766
|
const onCancelScript = `
|
|
5749
5767
|
// console.log("===onCancelScript=form==");
|
|
5768
|
+
let isLookup = event.data.isLookup;
|
|
5769
|
+
let __lookupField = event.data.__lookupField;
|
|
5750
5770
|
const scope = event.context.scoped;
|
|
5751
5771
|
var filterForm = scope.parent.parent.getComponents().find(function(n){
|
|
5752
5772
|
return n.props.type === "form";
|
|
@@ -5794,7 +5814,20 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
5794
5814
|
// });
|
|
5795
5815
|
|
|
5796
5816
|
// 清除__changedFilterFormValues中的值
|
|
5797
|
-
crud && crud.setData({__changedFilterFormValues: {}});
|
|
5817
|
+
// crud && crud.setData({__changedFilterFormValues: {}});
|
|
5818
|
+
let __changedFilterFormValuesKey = "__changedFilterFormValues";
|
|
5819
|
+
if(isLookup && __lookupField){
|
|
5820
|
+
let lookupTag = "__" + __lookupField.name + "__" + __lookupField.reference_to;
|
|
5821
|
+
if(__lookupField.reference_to_field){
|
|
5822
|
+
lookupTag += "__" + __lookupField.reference_to_field;
|
|
5823
|
+
}
|
|
5824
|
+
__changedFilterFormValuesKey += lookupTag;
|
|
5825
|
+
}
|
|
5826
|
+
if(crud){
|
|
5827
|
+
let crudData = crud.getData();
|
|
5828
|
+
crudData[__changedFilterFormValuesKey] = {};
|
|
5829
|
+
crud.setData(crudData);
|
|
5830
|
+
}
|
|
5798
5831
|
filterForm.handleFormSubmit(event);
|
|
5799
5832
|
// crud.handleFilterSubmit(removedValues);
|
|
5800
5833
|
|
|
@@ -7722,7 +7755,12 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
|
|
|
7722
7755
|
__changedSearchBoxValues["${keywordsSearchBoxName}"] = event.data["${keywordsSearchBoxName}"];
|
|
7723
7756
|
// crudService && crudService.setData({__changedSearchBoxValues: __changedSearchBoxValues});
|
|
7724
7757
|
// 这里不用crudService而用crud是因为lookup字段弹出的列表中的crudService中的变量无法传入crud的发送适配器中
|
|
7725
|
-
crud && crud.setData({__changedSearchBoxValues: __changedSearchBoxValues});
|
|
7758
|
+
// crud && crud.setData({__changedSearchBoxValues: __changedSearchBoxValues});
|
|
7759
|
+
if(crud){
|
|
7760
|
+
let crudData = crud.getData();
|
|
7761
|
+
crudData.__changedSearchBoxValues = __changedSearchBoxValues;
|
|
7762
|
+
crud.setData(crudData);
|
|
7763
|
+
}
|
|
7726
7764
|
`;
|
|
7727
7765
|
|
|
7728
7766
|
// onSearchScript中加上了onChangeScript中的脚本,是因为amis 3.2不能用change事件执行onChangeScript
|
|
@@ -7735,9 +7773,19 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
|
|
|
7735
7773
|
// const scope = event.context.scoped;
|
|
7736
7774
|
// 如果点击过顶部搜索栏表单的取消按钮,会把此处event.data.__super.__super.__super中的搜索表单项的所有字段设置为null
|
|
7737
7775
|
// 点击取消按钮后继续在表单项中输入过滤条件且最后没有点击回车按键或点击表单项搜索按钮的话,在快速搜索中点击回车按钮提交搜索会所顶部搜索表单中的字段值清空
|
|
7776
|
+
let isLookup = event.data.isLookup;
|
|
7777
|
+
let __lookupField = event.data.__lookupField;
|
|
7778
|
+
let __changedFilterFormValuesKey = "__changedFilterFormValues";
|
|
7779
|
+
if(isLookup && __lookupField){
|
|
7780
|
+
let lookupTag = "__" + __lookupField.name + "__" + __lookupField.reference_to;
|
|
7781
|
+
if(__lookupField.reference_to_field){
|
|
7782
|
+
lookupTag += "__" + __lookupField.reference_to_field;
|
|
7783
|
+
}
|
|
7784
|
+
__changedFilterFormValuesKey += lookupTag;
|
|
7785
|
+
}
|
|
7738
7786
|
let filterForm = SteedosUI.getClosestAmisComponentByType(scope, "form");
|
|
7739
7787
|
setTimeout(function(){
|
|
7740
|
-
filterForm.setValues(event.data
|
|
7788
|
+
filterForm.setValues(event.data[__changedFilterFormValuesKey]);
|
|
7741
7789
|
}, 500);
|
|
7742
7790
|
`;
|
|
7743
7791
|
|
|
@@ -7758,8 +7806,8 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
|
|
|
7758
7806
|
"name": keywordsSearchBoxName,
|
|
7759
7807
|
"placeholder": "搜索此列表",
|
|
7760
7808
|
"value": crudKeywords,
|
|
7761
|
-
"clearable": true
|
|
7762
|
-
|
|
7809
|
+
// "clearable": true,//因为清除并不会触发失去焦点事件,只有禁用,但是它会触发change事件,所以等升级到amis 3.4+后可以重新放开
|
|
7810
|
+
"clearAndSubmit": true,
|
|
7763
7811
|
"searchImediately": false,
|
|
7764
7812
|
"onEvent": {
|
|
7765
7813
|
"search": {
|
|
@@ -8039,6 +8087,9 @@ async function getObjectFilter(objectSchema, fields, options) {
|
|
|
8039
8087
|
crudService && crudService.setData({isFieldsFilterEmpty});
|
|
8040
8088
|
`;
|
|
8041
8089
|
let onChangeScript = `
|
|
8090
|
+
let isLookup = event.data.isLookup;
|
|
8091
|
+
let __lookupField = event.data.__lookupField;
|
|
8092
|
+
console.log("==onChangeScript=isLookup===", isLookup);
|
|
8042
8093
|
const scope = event.context.scoped;
|
|
8043
8094
|
// let filterFormValues = event.data;
|
|
8044
8095
|
let filterForm = SteedosUI.getClosestAmisComponentByType(scope, "form");
|
|
@@ -8050,7 +8101,20 @@ async function getObjectFilter(objectSchema, fields, options) {
|
|
|
8050
8101
|
// let crudService = crud && SteedosUI.getClosestAmisComponentByType(crud.context, "service");
|
|
8051
8102
|
// crudService && crudService.setData({__changedFilterFormValues: changedFilterFormValues});
|
|
8052
8103
|
// 这里不用crudService而用crud是因为lookup字段弹出的列表中的crudService中的变量无法传入crud的发送适配器中
|
|
8053
|
-
crud && crud.setData({__changedFilterFormValues: changedFilterFormValues});
|
|
8104
|
+
// crud && crud.setData({__changedFilterFormValues: changedFilterFormValues});
|
|
8105
|
+
let __changedFilterFormValuesKey = "__changedFilterFormValues";
|
|
8106
|
+
if(isLookup && __lookupField){
|
|
8107
|
+
let lookupTag = "__" + __lookupField.name + "__" + __lookupField.reference_to;
|
|
8108
|
+
if(__lookupField.reference_to_field){
|
|
8109
|
+
lookupTag += "__" + __lookupField.reference_to_field;
|
|
8110
|
+
}
|
|
8111
|
+
__changedFilterFormValuesKey += lookupTag;
|
|
8112
|
+
}
|
|
8113
|
+
if(crud){
|
|
8114
|
+
let crudData = crud.getData();
|
|
8115
|
+
crudData[__changedFilterFormValuesKey] = changedFilterFormValues;
|
|
8116
|
+
crud.setData(crudData);
|
|
8117
|
+
}
|
|
8054
8118
|
`;
|
|
8055
8119
|
return {
|
|
8056
8120
|
"title": "",
|
|
@@ -8227,7 +8291,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8227
8291
|
let tableOptions = Object.assign({
|
|
8228
8292
|
idFieldName: objectSchema.idFieldName, labelFieldName: labelFieldName,
|
|
8229
8293
|
permissions:objectSchema.permissions,enable_inline_edit:objectSchema.enable_inline_edit,
|
|
8230
|
-
crudId: listSchema.id || id
|
|
8294
|
+
crudId: listSchema.id || id, enable_tree: objectSchema.enable_tree
|
|
8231
8295
|
}, options);
|
|
8232
8296
|
tableOptions.amisData = createObject(options.amisData || {}, {});
|
|
8233
8297
|
const table = await getTableSchema$1(fields, tableOptions);
|
|
@@ -10442,13 +10506,24 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10442
10506
|
let keywordsSearchBoxName = `__keywords_lookup__${field.name.replace(/\./g, "_")}__to__${refObjectConfig.name}`;
|
|
10443
10507
|
|
|
10444
10508
|
source.requestAdaptor = `
|
|
10445
|
-
let
|
|
10509
|
+
let __changedFilterFormValuesKey = "__changedFilterFormValues";
|
|
10510
|
+
let __lookupField = api.data.$self.__lookupField;
|
|
10511
|
+
if(__lookupField){
|
|
10512
|
+
let lookupTag = "__" + __lookupField.name + "__" + __lookupField.reference_to;
|
|
10513
|
+
if(__lookupField.reference_to_field){
|
|
10514
|
+
lookupTag += "__" + __lookupField.reference_to_field;
|
|
10515
|
+
}
|
|
10516
|
+
__changedFilterFormValuesKey += lookupTag;
|
|
10517
|
+
}
|
|
10518
|
+
let __changedFilterFormValues = api.data.$self[__changedFilterFormValuesKey] || {};
|
|
10446
10519
|
let __changedSearchBoxValues = api.data.$self.__changedSearchBoxValues || {};
|
|
10447
10520
|
// 把表单搜索和快速搜索中的change事件中记录的过滤条件也拼到$self中,是为解决触发搜索请求时,两边输入的过滤条件都带上,即:
|
|
10448
10521
|
// 有时在搜索表单中输入过滤条件事,忘记点击回车键或搜索按钮,而是进一步修改快速搜索框中的关键字点击其中回车键触发搜索
|
|
10449
10522
|
// 这种情况下,触发的搜索请求中没有带上搜索表单中输入的过滤条件。
|
|
10450
10523
|
// 反过来先在快速搜索框中输入过滤条件却不点击其中回车键触发搜索,而是到搜索表单中触发搜索请求也是一样的。
|
|
10451
|
-
|
|
10524
|
+
if(api.data.$self.op !== 'loadOptions'){
|
|
10525
|
+
Object.assign(api.data.$self, __changedSearchBoxValues, __changedFilterFormValues);
|
|
10526
|
+
}
|
|
10452
10527
|
const selfData = JSON.parse(JSON.stringify(api.data.$self));
|
|
10453
10528
|
var filters = [];
|
|
10454
10529
|
var pageSize = api.data.pageSize || 10;
|
|
@@ -10652,7 +10727,12 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10652
10727
|
"objectName": refObjectConfig.name,
|
|
10653
10728
|
"uiSchema": refObjectConfig,
|
|
10654
10729
|
"listName": listName,// 需要按视图取可搜索项
|
|
10655
|
-
"isLookup": true
|
|
10730
|
+
"isLookup": true,
|
|
10731
|
+
"__lookupField": {
|
|
10732
|
+
"name": field.name,
|
|
10733
|
+
"reference_to": refObjectConfig.name,
|
|
10734
|
+
"reference_to_field": field.reference_to_field
|
|
10735
|
+
}
|
|
10656
10736
|
});
|
|
10657
10737
|
|
|
10658
10738
|
if(!pickerSchema.onEvent){
|
|
@@ -12414,7 +12494,7 @@ async function getFormBody(permissionFields, formFields, ctx){
|
|
|
12414
12494
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
12415
12495
|
* @Date: 2023-11-15 09:50:22
|
|
12416
12496
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
12417
|
-
* @LastEditTime: 2023-12-
|
|
12497
|
+
* @LastEditTime: 2023-12-26 11:15:04
|
|
12418
12498
|
*/
|
|
12419
12499
|
|
|
12420
12500
|
/**
|
|
@@ -12442,20 +12522,22 @@ function getInputTableCell(field, showAsInlineEditMode) {
|
|
|
12442
12522
|
name: field.name,
|
|
12443
12523
|
quickEdit: {
|
|
12444
12524
|
"type": "steedos-field",
|
|
12445
|
-
"config": field,
|
|
12446
|
-
|
|
12525
|
+
"config": Object.assign({}, field, {
|
|
12526
|
+
label: false
|
|
12527
|
+
})
|
|
12447
12528
|
}
|
|
12448
12529
|
}
|
|
12449
12530
|
}
|
|
12450
12531
|
else {
|
|
12451
12532
|
return {
|
|
12452
12533
|
"type": "steedos-field",
|
|
12453
|
-
"config": field,
|
|
12534
|
+
"config": Object.assign({}, field, {
|
|
12535
|
+
label: false
|
|
12536
|
+
}),
|
|
12454
12537
|
"static": true,
|
|
12455
12538
|
"readonly": true,
|
|
12456
12539
|
label: field.label,
|
|
12457
|
-
name: field.name
|
|
12458
|
-
hideLabel: true
|
|
12540
|
+
name: field.name
|
|
12459
12541
|
}
|
|
12460
12542
|
}
|
|
12461
12543
|
}
|
|
@@ -12661,7 +12743,7 @@ function getFormPagination(props, mode) {
|
|
|
12661
12743
|
* @returns 带翻页容器的wrapper
|
|
12662
12744
|
*/
|
|
12663
12745
|
function getFormPaginationWrapper(props, form, mode) {
|
|
12664
|
-
console.log("==getFormPaginationWrapper===", props, mode);
|
|
12746
|
+
// console.log("==getFormPaginationWrapper===", props, mode);
|
|
12665
12747
|
let serviceId = getComponentId("form_pagination", props.id);
|
|
12666
12748
|
let tableServiceId = getComponentId("table_service", props.id);
|
|
12667
12749
|
let innerForm = Object.assign({}, form, {
|
|
@@ -12701,8 +12783,28 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12701
12783
|
let __wrapperServiceId = "${tableServiceId}";
|
|
12702
12784
|
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
12703
12785
|
let wrapperServiceData = wrapperService.getData();
|
|
12704
|
-
|
|
12786
|
+
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
12787
|
+
// 这里如果不.clone的话,在弹出窗口中显示的子表组件,添加行后点窗口的取消按钮关闭窗口后无法把之前的操作还原,即把之前添加的行自动移除
|
|
12788
|
+
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"] || []);
|
|
12705
12789
|
//不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
|
|
12790
|
+
let mode = "${mode}";
|
|
12791
|
+
if(mode === "new"){
|
|
12792
|
+
// 点击子表组件底部新增按钮时新增一条空白行并自动翻页到新增行
|
|
12793
|
+
// 注意点击弹出的子表行详细表单中的新增按钮不会进此service init事件函数中
|
|
12794
|
+
let newItem = {};
|
|
12795
|
+
event.data.__tableItems.push(newItem);
|
|
12796
|
+
lastestFieldValue.push(newItem);
|
|
12797
|
+
event.data.index = lastestFieldValue.length - 1;
|
|
12798
|
+
event.data.__page = lastestFieldValue.length;
|
|
12799
|
+
// 这里新增空白行时要把值同步保存到子表组件中,如果不同步保存的话,用户点击弹出表单右上角的关闭窗口时不会自动删除这里自动增加的空白行,同步后可以让用户手动删除此行
|
|
12800
|
+
doAction({
|
|
12801
|
+
"componentId": "${props.id}",
|
|
12802
|
+
"actionType": "setValue",
|
|
12803
|
+
"args": {
|
|
12804
|
+
"value": lastestFieldValue
|
|
12805
|
+
}
|
|
12806
|
+
});
|
|
12807
|
+
}
|
|
12706
12808
|
event.data.__tableItems.forEach(function(n,i){
|
|
12707
12809
|
event.data.__tableItems[i] = lastestFieldValue[i];
|
|
12708
12810
|
});
|
|
@@ -12766,7 +12868,8 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
12766
12868
|
"canAccessSuperData": false,
|
|
12767
12869
|
"className": "steedos-object-form steedos-amis-form"
|
|
12768
12870
|
};
|
|
12769
|
-
if (mode === "edit") {
|
|
12871
|
+
if (mode === "edit" || mode === "new") {
|
|
12872
|
+
// 新增行弹出编辑行表单,在弹出之前已经不用先增加一行,因为在翻页service初始化的时候会判断mode为new时自动新增一行
|
|
12770
12873
|
let onEditItemSubmitScript = `
|
|
12771
12874
|
// let fieldValue = _.cloneDeep(event.data["${props.name}"]);
|
|
12772
12875
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
@@ -12805,66 +12908,66 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
12805
12908
|
}
|
|
12806
12909
|
});
|
|
12807
12910
|
}
|
|
12808
|
-
else if (mode === "new") {
|
|
12809
|
-
|
|
12810
|
-
|
|
12811
|
-
|
|
12812
|
-
|
|
12813
|
-
|
|
12814
|
-
|
|
12815
|
-
|
|
12816
|
-
|
|
12817
|
-
|
|
12818
|
-
|
|
12819
|
-
|
|
12820
|
-
|
|
12821
|
-
|
|
12822
|
-
|
|
12823
|
-
|
|
12824
|
-
|
|
12825
|
-
|
|
12826
|
-
|
|
12827
|
-
|
|
12828
|
-
|
|
12829
|
-
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
|
|
12834
|
-
|
|
12835
|
-
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
|
|
12840
|
-
|
|
12841
|
-
|
|
12842
|
-
|
|
12843
|
-
|
|
12844
|
-
|
|
12845
|
-
|
|
12846
|
-
|
|
12847
|
-
|
|
12848
|
-
|
|
12849
|
-
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
|
|
12853
|
-
|
|
12854
|
-
|
|
12855
|
-
|
|
12856
|
-
|
|
12857
|
-
|
|
12858
|
-
}
|
|
12911
|
+
// else if (mode === "new") {
|
|
12912
|
+
// let onNewItemSubmitScript = `
|
|
12913
|
+
// let newItem = JSON.parse(JSON.stringify(event.data));
|
|
12914
|
+
// if(event.data["${props.name}"]){
|
|
12915
|
+
// // let fieldValue = event.data.__tableItems;
|
|
12916
|
+
// // 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
|
|
12917
|
+
// let fieldValue = event.data["${props.name}"];
|
|
12918
|
+
// fieldValue.push(newItem);
|
|
12919
|
+
// doAction({
|
|
12920
|
+
// "componentId": "${props.id}",
|
|
12921
|
+
// "actionType": "setValue",
|
|
12922
|
+
// "args": {
|
|
12923
|
+
// "value": fieldValue
|
|
12924
|
+
// }
|
|
12925
|
+
// });
|
|
12926
|
+
// }
|
|
12927
|
+
// else{
|
|
12928
|
+
// // 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
|
|
12929
|
+
// doAction({
|
|
12930
|
+
// "componentId": "${props.id}",
|
|
12931
|
+
// "actionType": "setValue",
|
|
12932
|
+
// "args": {
|
|
12933
|
+
// "value": [newItem]
|
|
12934
|
+
// }
|
|
12935
|
+
// });
|
|
12936
|
+
// }
|
|
12937
|
+
// `;
|
|
12938
|
+
// Object.assign(schema, {
|
|
12939
|
+
// "onEvent": {
|
|
12940
|
+
// "submit": {
|
|
12941
|
+
// "weight": 0,
|
|
12942
|
+
// "actions": [
|
|
12943
|
+
// {
|
|
12944
|
+
// "actionType": "custom",
|
|
12945
|
+
// "script": onNewItemSubmitScript
|
|
12946
|
+
// },
|
|
12947
|
+
// // {
|
|
12948
|
+
// // "componentId": props.id,
|
|
12949
|
+
// // "actionType": "addItem",//input-table组件的needConfirm属性为true时,addItem动作会把新加的行显示为编辑状态,所以只能使用上面的custom script来setValue实现添加行
|
|
12950
|
+
// // "args": {
|
|
12951
|
+
// // "index": `\${${props.name}.length || 9000}`,//这里加9000是因为字段如果没放在form组件内,props.name.length拿不到值
|
|
12952
|
+
// // "item": {
|
|
12953
|
+
// // "&": "$$"
|
|
12954
|
+
// // }
|
|
12955
|
+
// // }
|
|
12956
|
+
// // }
|
|
12957
|
+
// ]
|
|
12958
|
+
// }
|
|
12959
|
+
// }
|
|
12960
|
+
// });
|
|
12961
|
+
// }
|
|
12859
12962
|
schema = getFormPaginationWrapper(props, schema, mode);
|
|
12860
12963
|
return schema;
|
|
12861
12964
|
}
|
|
12862
12965
|
|
|
12863
12966
|
|
|
12864
12967
|
/**
|
|
12865
|
-
*
|
|
12968
|
+
* 编辑、新增、删除、查看按钮actions
|
|
12866
12969
|
* @param {*} props
|
|
12867
|
-
* @param {*} mode edit/new/readonly
|
|
12970
|
+
* @param {*} mode edit/new/readonly/delete
|
|
12868
12971
|
*/
|
|
12869
12972
|
async function getButtonActions(props, mode) {
|
|
12870
12973
|
let actions = [];
|
|
@@ -12955,6 +13058,7 @@ async function getButtonActions(props, mode) {
|
|
|
12955
13058
|
}
|
|
12956
13059
|
];
|
|
12957
13060
|
if(props.addable){
|
|
13061
|
+
// 有新增行权限时额外添加新增和复制按钮
|
|
12958
13062
|
dialogButtons = [
|
|
12959
13063
|
{
|
|
12960
13064
|
"type": "button",
|
|
@@ -13019,7 +13123,8 @@ async function getButtonActions(props, mode) {
|
|
|
13019
13123
|
// "__tableItems": `\${${props.name}}`
|
|
13020
13124
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13021
13125
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13022
|
-
"__tableItems": `\${${props.name}|json|toJson}`
|
|
13126
|
+
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13127
|
+
"__tableItems": `\${(${props.name} || [])|json|toJson}`
|
|
13023
13128
|
},
|
|
13024
13129
|
"actions": dialogButtons,
|
|
13025
13130
|
"onEvent": {
|
|
@@ -13042,11 +13147,12 @@ async function getButtonActions(props, mode) {
|
|
|
13042
13147
|
Object.assign(actionShowEditDialog.dialog, props.dialog);
|
|
13043
13148
|
}
|
|
13044
13149
|
if (mode == "new") {
|
|
13045
|
-
|
|
13150
|
+
`
|
|
13046
13151
|
let newItem = {};
|
|
13047
13152
|
if(event.data["${props.name}"]){
|
|
13048
13153
|
// let fieldValue = event.data.__tableItems;
|
|
13049
13154
|
// 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
|
|
13155
|
+
// let fieldValue = _.clone(event.data["${props.name}"]);
|
|
13050
13156
|
let fieldValue = event.data["${props.name}"];
|
|
13051
13157
|
fieldValue.push(newItem);
|
|
13052
13158
|
doAction({
|
|
@@ -13070,11 +13176,9 @@ async function getButtonActions(props, mode) {
|
|
|
13070
13176
|
event.data.index = 1;
|
|
13071
13177
|
}
|
|
13072
13178
|
`;
|
|
13073
|
-
|
|
13074
|
-
|
|
13075
|
-
|
|
13076
|
-
};
|
|
13077
|
-
actions = [actionNewLine, actionShowEditDialog];
|
|
13179
|
+
// 新增行时不需要在弹出编辑表单前先加一行,因为会在编辑表单所在service初始化时判断到是新增就自动增加一行,因为这里拿不到event.data.__tableItems,也无法变更其值
|
|
13180
|
+
// actions = [actionNewLine, actionShowEditDialog];
|
|
13181
|
+
actions = [actionShowEditDialog];
|
|
13078
13182
|
}
|
|
13079
13183
|
else if (mode == "edit") {
|
|
13080
13184
|
actions = [actionShowEditDialog];
|
|
@@ -13112,9 +13216,44 @@ async function getButtonActions(props, mode) {
|
|
|
13112
13216
|
// "__tableItems": `\${${props.name}}`
|
|
13113
13217
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13114
13218
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13115
|
-
"__tableItems": `\${${props.name}|json|toJson}`
|
|
13116
|
-
|
|
13219
|
+
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13220
|
+
"__tableItems": `\${(${props.name} || [])|json|toJson}`
|
|
13221
|
+
},
|
|
13222
|
+
}
|
|
13223
|
+
}
|
|
13224
|
+
];
|
|
13225
|
+
}
|
|
13226
|
+
else if (mode == "delete") {
|
|
13227
|
+
let tableServiceId = getComponentId("table_service", props.id);
|
|
13228
|
+
let onDeleteItemScript = `
|
|
13229
|
+
// let fieldValue = event.data["${props.name}"];
|
|
13230
|
+
let scope = event.context.scoped;
|
|
13231
|
+
let __wrapperServiceId = "${tableServiceId}";
|
|
13232
|
+
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
13233
|
+
let wrapperServiceData = wrapperService.getData();
|
|
13234
|
+
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
13235
|
+
// 这里_.clone是因为字段设计布局设置分组这种弹出窗口中的子表组件,直接删除后,点取消无法还原
|
|
13236
|
+
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
|
|
13237
|
+
lastestFieldValue.splice(event.data.index, 1);
|
|
13238
|
+
doAction({
|
|
13239
|
+
"componentId": "${props.id}",
|
|
13240
|
+
"actionType": "setValue",
|
|
13241
|
+
"args": {
|
|
13242
|
+
"value": lastestFieldValue
|
|
13117
13243
|
}
|
|
13244
|
+
});
|
|
13245
|
+
`;
|
|
13246
|
+
actions = [
|
|
13247
|
+
// {
|
|
13248
|
+
// "actionType": "deleteItem",
|
|
13249
|
+
// "args": {
|
|
13250
|
+
// "index": "${index+','}" //这里不加逗号后续会报错,语法是逗号分隔可以删除多行
|
|
13251
|
+
// },
|
|
13252
|
+
// "componentId": props.id
|
|
13253
|
+
// },
|
|
13254
|
+
{
|
|
13255
|
+
"actionType": "custom",
|
|
13256
|
+
"script": onDeleteItemScript
|
|
13118
13257
|
}
|
|
13119
13258
|
];
|
|
13120
13259
|
}
|
|
@@ -13163,24 +13302,7 @@ async function getButtonView(props) {
|
|
|
13163
13302
|
};
|
|
13164
13303
|
}
|
|
13165
13304
|
|
|
13166
|
-
function getButtonDelete(props) {
|
|
13167
|
-
let tableServiceId = getComponentId("table_service", props.id);
|
|
13168
|
-
let onDeleteItemScript = `
|
|
13169
|
-
// let fieldValue = event.data["${props.name}"];
|
|
13170
|
-
let scope = event.context.scoped;
|
|
13171
|
-
let __wrapperServiceId = "${tableServiceId}";
|
|
13172
|
-
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
13173
|
-
let wrapperServiceData = wrapperService.getData();
|
|
13174
|
-
let lastestFieldValue = wrapperServiceData["${props.name}"];//这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
13175
|
-
lastestFieldValue.splice(event.data.index, 1);
|
|
13176
|
-
doAction({
|
|
13177
|
-
"componentId": "${props.id}",
|
|
13178
|
-
"actionType": "setValue",
|
|
13179
|
-
"args": {
|
|
13180
|
-
"value": lastestFieldValue
|
|
13181
|
-
}
|
|
13182
|
-
});
|
|
13183
|
-
`;
|
|
13305
|
+
async function getButtonDelete(props) {
|
|
13184
13306
|
return {
|
|
13185
13307
|
"type": "button",
|
|
13186
13308
|
"label": "",
|
|
@@ -13188,19 +13310,7 @@ function getButtonDelete(props) {
|
|
|
13188
13310
|
"level": "link",
|
|
13189
13311
|
"onEvent": {
|
|
13190
13312
|
"click": {
|
|
13191
|
-
"actions":
|
|
13192
|
-
// {
|
|
13193
|
-
// "actionType": "deleteItem",
|
|
13194
|
-
// "args": {
|
|
13195
|
-
// "index": "${index+','}" //这里不加逗号后续会报错,语法是逗号分隔可以删除多行
|
|
13196
|
-
// },
|
|
13197
|
-
// "componentId": props.id
|
|
13198
|
-
// },
|
|
13199
|
-
{
|
|
13200
|
-
"actionType": "custom",
|
|
13201
|
-
"script": onDeleteItemScript
|
|
13202
|
-
}
|
|
13203
|
-
]
|
|
13313
|
+
"actions": await getButtonActions(props, "delete")
|
|
13204
13314
|
}
|
|
13205
13315
|
}
|
|
13206
13316
|
};
|
|
@@ -13240,7 +13350,7 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13240
13350
|
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13241
13351
|
}
|
|
13242
13352
|
if (props.removable) {
|
|
13243
|
-
let buttonDeleteSchema = getButtonDelete(props);
|
|
13353
|
+
let buttonDeleteSchema = await getButtonDelete(props);
|
|
13244
13354
|
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13245
13355
|
}
|
|
13246
13356
|
let inputTableSchema = {
|