@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.cjs.js
CHANGED
|
@@ -1653,6 +1653,7 @@ async function getQuickEditSchema(field, options){
|
|
|
1653
1653
|
{
|
|
1654
1654
|
"actionType": "custom",
|
|
1655
1655
|
"script": `
|
|
1656
|
+
|
|
1656
1657
|
var _display = _.cloneDeep(event.data._display);
|
|
1657
1658
|
${displayField}
|
|
1658
1659
|
doAction({actionType: 'setValue', "args": {"value": {_display}},componentId: "${quickEditId}"});
|
|
@@ -2039,7 +2040,9 @@ async function getTableColumns(fields, options){
|
|
|
2039
2040
|
if(!options.isLookup && !options.isInputTable){
|
|
2040
2041
|
//将_display放入crud的columns中,可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
2041
2042
|
columns.push({name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
|
|
2042
|
-
|
|
2043
|
+
if(!options.enable_tree){
|
|
2044
|
+
columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
|
|
2045
|
+
}
|
|
2043
2046
|
}
|
|
2044
2047
|
const allowEdit = options.permissions?.allowEdit && !options.isLookup && options.enable_inline_edit != false;
|
|
2045
2048
|
|
|
@@ -2890,7 +2893,21 @@ async function getTableApi(mainObject, fields, options){
|
|
|
2890
2893
|
|
|
2891
2894
|
if(enable_tree){
|
|
2892
2895
|
const records = payload.data.rows || [];
|
|
2893
|
-
const getTreeOptions = SteedosUI.getTreeOptions
|
|
2896
|
+
const getTreeOptions = SteedosUI.getTreeOptions;
|
|
2897
|
+
const assignIndexToTreeRecords = function(tree, parentIndex) {
|
|
2898
|
+
tree.forEach(function (node, index) {
|
|
2899
|
+
// 构建当前节点的 _index
|
|
2900
|
+
var currentIndex = parentIndex ? parentIndex + '-' + (index + 1) : '' + (index + 1);
|
|
2901
|
+
|
|
2902
|
+
// 赋值给节点
|
|
2903
|
+
node._index = currentIndex;
|
|
2904
|
+
|
|
2905
|
+
// 如果有子节点,递归调用函数
|
|
2906
|
+
if (node.children && node.children.length > 0) {
|
|
2907
|
+
assignIndexToTreeRecords(node.children, currentIndex);
|
|
2908
|
+
}
|
|
2909
|
+
});
|
|
2910
|
+
};
|
|
2894
2911
|
let isTreeOptionsComputed = false;
|
|
2895
2912
|
if(records.length === 1 && records[0].children){
|
|
2896
2913
|
isTreeOptionsComputed = true;
|
|
@@ -2898,6 +2915,7 @@ async function getTableApi(mainObject, fields, options){
|
|
|
2898
2915
|
if(!isTreeOptionsComputed){
|
|
2899
2916
|
// 如果api接口设置在缓存,缓存期间并不会重新请求接口,payload.data.rows是上次计算后的结果
|
|
2900
2917
|
payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
|
|
2918
|
+
assignIndexToTreeRecords(payload.data.rows, '');
|
|
2901
2919
|
}
|
|
2902
2920
|
try{
|
|
2903
2921
|
setTimeout(() => {
|
|
@@ -5774,6 +5792,8 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
5774
5792
|
`;
|
|
5775
5793
|
const onCancelScript = `
|
|
5776
5794
|
// console.log("===onCancelScript=form==");
|
|
5795
|
+
let isLookup = event.data.isLookup;
|
|
5796
|
+
let __lookupField = event.data.__lookupField;
|
|
5777
5797
|
const scope = event.context.scoped;
|
|
5778
5798
|
var filterForm = scope.parent.parent.getComponents().find(function(n){
|
|
5779
5799
|
return n.props.type === "form";
|
|
@@ -5821,7 +5841,20 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
5821
5841
|
// });
|
|
5822
5842
|
|
|
5823
5843
|
// 清除__changedFilterFormValues中的值
|
|
5824
|
-
crud && crud.setData({__changedFilterFormValues: {}});
|
|
5844
|
+
// crud && crud.setData({__changedFilterFormValues: {}});
|
|
5845
|
+
let __changedFilterFormValuesKey = "__changedFilterFormValues";
|
|
5846
|
+
if(isLookup && __lookupField){
|
|
5847
|
+
let lookupTag = "__" + __lookupField.name + "__" + __lookupField.reference_to;
|
|
5848
|
+
if(__lookupField.reference_to_field){
|
|
5849
|
+
lookupTag += "__" + __lookupField.reference_to_field;
|
|
5850
|
+
}
|
|
5851
|
+
__changedFilterFormValuesKey += lookupTag;
|
|
5852
|
+
}
|
|
5853
|
+
if(crud){
|
|
5854
|
+
let crudData = crud.getData();
|
|
5855
|
+
crudData[__changedFilterFormValuesKey] = {};
|
|
5856
|
+
crud.setData(crudData);
|
|
5857
|
+
}
|
|
5825
5858
|
filterForm.handleFormSubmit(event);
|
|
5826
5859
|
// crud.handleFilterSubmit(removedValues);
|
|
5827
5860
|
|
|
@@ -7749,7 +7782,12 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
|
|
|
7749
7782
|
__changedSearchBoxValues["${keywordsSearchBoxName}"] = event.data["${keywordsSearchBoxName}"];
|
|
7750
7783
|
// crudService && crudService.setData({__changedSearchBoxValues: __changedSearchBoxValues});
|
|
7751
7784
|
// 这里不用crudService而用crud是因为lookup字段弹出的列表中的crudService中的变量无法传入crud的发送适配器中
|
|
7752
|
-
crud && crud.setData({__changedSearchBoxValues: __changedSearchBoxValues});
|
|
7785
|
+
// crud && crud.setData({__changedSearchBoxValues: __changedSearchBoxValues});
|
|
7786
|
+
if(crud){
|
|
7787
|
+
let crudData = crud.getData();
|
|
7788
|
+
crudData.__changedSearchBoxValues = __changedSearchBoxValues;
|
|
7789
|
+
crud.setData(crudData);
|
|
7790
|
+
}
|
|
7753
7791
|
`;
|
|
7754
7792
|
|
|
7755
7793
|
// onSearchScript中加上了onChangeScript中的脚本,是因为amis 3.2不能用change事件执行onChangeScript
|
|
@@ -7762,9 +7800,19 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
|
|
|
7762
7800
|
// const scope = event.context.scoped;
|
|
7763
7801
|
// 如果点击过顶部搜索栏表单的取消按钮,会把此处event.data.__super.__super.__super中的搜索表单项的所有字段设置为null
|
|
7764
7802
|
// 点击取消按钮后继续在表单项中输入过滤条件且最后没有点击回车按键或点击表单项搜索按钮的话,在快速搜索中点击回车按钮提交搜索会所顶部搜索表单中的字段值清空
|
|
7803
|
+
let isLookup = event.data.isLookup;
|
|
7804
|
+
let __lookupField = event.data.__lookupField;
|
|
7805
|
+
let __changedFilterFormValuesKey = "__changedFilterFormValues";
|
|
7806
|
+
if(isLookup && __lookupField){
|
|
7807
|
+
let lookupTag = "__" + __lookupField.name + "__" + __lookupField.reference_to;
|
|
7808
|
+
if(__lookupField.reference_to_field){
|
|
7809
|
+
lookupTag += "__" + __lookupField.reference_to_field;
|
|
7810
|
+
}
|
|
7811
|
+
__changedFilterFormValuesKey += lookupTag;
|
|
7812
|
+
}
|
|
7765
7813
|
let filterForm = SteedosUI.getClosestAmisComponentByType(scope, "form");
|
|
7766
7814
|
setTimeout(function(){
|
|
7767
|
-
filterForm.setValues(event.data
|
|
7815
|
+
filterForm.setValues(event.data[__changedFilterFormValuesKey]);
|
|
7768
7816
|
}, 500);
|
|
7769
7817
|
`;
|
|
7770
7818
|
|
|
@@ -7785,8 +7833,8 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
|
|
|
7785
7833
|
"name": keywordsSearchBoxName,
|
|
7786
7834
|
"placeholder": "搜索此列表",
|
|
7787
7835
|
"value": crudKeywords,
|
|
7788
|
-
"clearable": true
|
|
7789
|
-
|
|
7836
|
+
// "clearable": true,//因为清除并不会触发失去焦点事件,只有禁用,但是它会触发change事件,所以等升级到amis 3.4+后可以重新放开
|
|
7837
|
+
"clearAndSubmit": true,
|
|
7790
7838
|
"searchImediately": false,
|
|
7791
7839
|
"onEvent": {
|
|
7792
7840
|
"search": {
|
|
@@ -8066,6 +8114,9 @@ async function getObjectFilter(objectSchema, fields, options) {
|
|
|
8066
8114
|
crudService && crudService.setData({isFieldsFilterEmpty});
|
|
8067
8115
|
`;
|
|
8068
8116
|
let onChangeScript = `
|
|
8117
|
+
let isLookup = event.data.isLookup;
|
|
8118
|
+
let __lookupField = event.data.__lookupField;
|
|
8119
|
+
console.log("==onChangeScript=isLookup===", isLookup);
|
|
8069
8120
|
const scope = event.context.scoped;
|
|
8070
8121
|
// let filterFormValues = event.data;
|
|
8071
8122
|
let filterForm = SteedosUI.getClosestAmisComponentByType(scope, "form");
|
|
@@ -8077,7 +8128,20 @@ async function getObjectFilter(objectSchema, fields, options) {
|
|
|
8077
8128
|
// let crudService = crud && SteedosUI.getClosestAmisComponentByType(crud.context, "service");
|
|
8078
8129
|
// crudService && crudService.setData({__changedFilterFormValues: changedFilterFormValues});
|
|
8079
8130
|
// 这里不用crudService而用crud是因为lookup字段弹出的列表中的crudService中的变量无法传入crud的发送适配器中
|
|
8080
|
-
crud && crud.setData({__changedFilterFormValues: changedFilterFormValues});
|
|
8131
|
+
// crud && crud.setData({__changedFilterFormValues: changedFilterFormValues});
|
|
8132
|
+
let __changedFilterFormValuesKey = "__changedFilterFormValues";
|
|
8133
|
+
if(isLookup && __lookupField){
|
|
8134
|
+
let lookupTag = "__" + __lookupField.name + "__" + __lookupField.reference_to;
|
|
8135
|
+
if(__lookupField.reference_to_field){
|
|
8136
|
+
lookupTag += "__" + __lookupField.reference_to_field;
|
|
8137
|
+
}
|
|
8138
|
+
__changedFilterFormValuesKey += lookupTag;
|
|
8139
|
+
}
|
|
8140
|
+
if(crud){
|
|
8141
|
+
let crudData = crud.getData();
|
|
8142
|
+
crudData[__changedFilterFormValuesKey] = changedFilterFormValues;
|
|
8143
|
+
crud.setData(crudData);
|
|
8144
|
+
}
|
|
8081
8145
|
`;
|
|
8082
8146
|
return {
|
|
8083
8147
|
"title": "",
|
|
@@ -8254,7 +8318,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8254
8318
|
let tableOptions = Object.assign({
|
|
8255
8319
|
idFieldName: objectSchema.idFieldName, labelFieldName: labelFieldName,
|
|
8256
8320
|
permissions:objectSchema.permissions,enable_inline_edit:objectSchema.enable_inline_edit,
|
|
8257
|
-
crudId: listSchema.id || id
|
|
8321
|
+
crudId: listSchema.id || id, enable_tree: objectSchema.enable_tree
|
|
8258
8322
|
}, options);
|
|
8259
8323
|
tableOptions.amisData = createObject(options.amisData || {}, {});
|
|
8260
8324
|
const table = await getTableSchema$1(fields, tableOptions);
|
|
@@ -10469,13 +10533,24 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10469
10533
|
let keywordsSearchBoxName = `__keywords_lookup__${field.name.replace(/\./g, "_")}__to__${refObjectConfig.name}`;
|
|
10470
10534
|
|
|
10471
10535
|
source.requestAdaptor = `
|
|
10472
|
-
let
|
|
10536
|
+
let __changedFilterFormValuesKey = "__changedFilterFormValues";
|
|
10537
|
+
let __lookupField = api.data.$self.__lookupField;
|
|
10538
|
+
if(__lookupField){
|
|
10539
|
+
let lookupTag = "__" + __lookupField.name + "__" + __lookupField.reference_to;
|
|
10540
|
+
if(__lookupField.reference_to_field){
|
|
10541
|
+
lookupTag += "__" + __lookupField.reference_to_field;
|
|
10542
|
+
}
|
|
10543
|
+
__changedFilterFormValuesKey += lookupTag;
|
|
10544
|
+
}
|
|
10545
|
+
let __changedFilterFormValues = api.data.$self[__changedFilterFormValuesKey] || {};
|
|
10473
10546
|
let __changedSearchBoxValues = api.data.$self.__changedSearchBoxValues || {};
|
|
10474
10547
|
// 把表单搜索和快速搜索中的change事件中记录的过滤条件也拼到$self中,是为解决触发搜索请求时,两边输入的过滤条件都带上,即:
|
|
10475
10548
|
// 有时在搜索表单中输入过滤条件事,忘记点击回车键或搜索按钮,而是进一步修改快速搜索框中的关键字点击其中回车键触发搜索
|
|
10476
10549
|
// 这种情况下,触发的搜索请求中没有带上搜索表单中输入的过滤条件。
|
|
10477
10550
|
// 反过来先在快速搜索框中输入过滤条件却不点击其中回车键触发搜索,而是到搜索表单中触发搜索请求也是一样的。
|
|
10478
|
-
|
|
10551
|
+
if(api.data.$self.op !== 'loadOptions'){
|
|
10552
|
+
Object.assign(api.data.$self, __changedSearchBoxValues, __changedFilterFormValues);
|
|
10553
|
+
}
|
|
10479
10554
|
const selfData = JSON.parse(JSON.stringify(api.data.$self));
|
|
10480
10555
|
var filters = [];
|
|
10481
10556
|
var pageSize = api.data.pageSize || 10;
|
|
@@ -10679,7 +10754,12 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10679
10754
|
"objectName": refObjectConfig.name,
|
|
10680
10755
|
"uiSchema": refObjectConfig,
|
|
10681
10756
|
"listName": listName,// 需要按视图取可搜索项
|
|
10682
|
-
"isLookup": true
|
|
10757
|
+
"isLookup": true,
|
|
10758
|
+
"__lookupField": {
|
|
10759
|
+
"name": field.name,
|
|
10760
|
+
"reference_to": refObjectConfig.name,
|
|
10761
|
+
"reference_to_field": field.reference_to_field
|
|
10762
|
+
}
|
|
10683
10763
|
});
|
|
10684
10764
|
|
|
10685
10765
|
if(!pickerSchema.onEvent){
|
|
@@ -12441,7 +12521,7 @@ async function getFormBody(permissionFields, formFields, ctx){
|
|
|
12441
12521
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
12442
12522
|
* @Date: 2023-11-15 09:50:22
|
|
12443
12523
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
12444
|
-
* @LastEditTime: 2023-12-
|
|
12524
|
+
* @LastEditTime: 2023-12-26 11:15:04
|
|
12445
12525
|
*/
|
|
12446
12526
|
|
|
12447
12527
|
/**
|
|
@@ -12469,20 +12549,22 @@ function getInputTableCell(field, showAsInlineEditMode) {
|
|
|
12469
12549
|
name: field.name,
|
|
12470
12550
|
quickEdit: {
|
|
12471
12551
|
"type": "steedos-field",
|
|
12472
|
-
"config": field,
|
|
12473
|
-
|
|
12552
|
+
"config": Object.assign({}, field, {
|
|
12553
|
+
label: false
|
|
12554
|
+
})
|
|
12474
12555
|
}
|
|
12475
12556
|
}
|
|
12476
12557
|
}
|
|
12477
12558
|
else {
|
|
12478
12559
|
return {
|
|
12479
12560
|
"type": "steedos-field",
|
|
12480
|
-
"config": field,
|
|
12561
|
+
"config": Object.assign({}, field, {
|
|
12562
|
+
label: false
|
|
12563
|
+
}),
|
|
12481
12564
|
"static": true,
|
|
12482
12565
|
"readonly": true,
|
|
12483
12566
|
label: field.label,
|
|
12484
|
-
name: field.name
|
|
12485
|
-
hideLabel: true
|
|
12567
|
+
name: field.name
|
|
12486
12568
|
}
|
|
12487
12569
|
}
|
|
12488
12570
|
}
|
|
@@ -12688,7 +12770,7 @@ function getFormPagination(props, mode) {
|
|
|
12688
12770
|
* @returns 带翻页容器的wrapper
|
|
12689
12771
|
*/
|
|
12690
12772
|
function getFormPaginationWrapper(props, form, mode) {
|
|
12691
|
-
console.log("==getFormPaginationWrapper===", props, mode);
|
|
12773
|
+
// console.log("==getFormPaginationWrapper===", props, mode);
|
|
12692
12774
|
let serviceId = getComponentId("form_pagination", props.id);
|
|
12693
12775
|
let tableServiceId = getComponentId("table_service", props.id);
|
|
12694
12776
|
let innerForm = Object.assign({}, form, {
|
|
@@ -12728,8 +12810,28 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12728
12810
|
let __wrapperServiceId = "${tableServiceId}";
|
|
12729
12811
|
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
12730
12812
|
let wrapperServiceData = wrapperService.getData();
|
|
12731
|
-
|
|
12813
|
+
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
12814
|
+
// 这里如果不.clone的话,在弹出窗口中显示的子表组件,添加行后点窗口的取消按钮关闭窗口后无法把之前的操作还原,即把之前添加的行自动移除
|
|
12815
|
+
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"] || []);
|
|
12732
12816
|
//不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
|
|
12817
|
+
let mode = "${mode}";
|
|
12818
|
+
if(mode === "new"){
|
|
12819
|
+
// 点击子表组件底部新增按钮时新增一条空白行并自动翻页到新增行
|
|
12820
|
+
// 注意点击弹出的子表行详细表单中的新增按钮不会进此service init事件函数中
|
|
12821
|
+
let newItem = {};
|
|
12822
|
+
event.data.__tableItems.push(newItem);
|
|
12823
|
+
lastestFieldValue.push(newItem);
|
|
12824
|
+
event.data.index = lastestFieldValue.length - 1;
|
|
12825
|
+
event.data.__page = lastestFieldValue.length;
|
|
12826
|
+
// 这里新增空白行时要把值同步保存到子表组件中,如果不同步保存的话,用户点击弹出表单右上角的关闭窗口时不会自动删除这里自动增加的空白行,同步后可以让用户手动删除此行
|
|
12827
|
+
doAction({
|
|
12828
|
+
"componentId": "${props.id}",
|
|
12829
|
+
"actionType": "setValue",
|
|
12830
|
+
"args": {
|
|
12831
|
+
"value": lastestFieldValue
|
|
12832
|
+
}
|
|
12833
|
+
});
|
|
12834
|
+
}
|
|
12733
12835
|
event.data.__tableItems.forEach(function(n,i){
|
|
12734
12836
|
event.data.__tableItems[i] = lastestFieldValue[i];
|
|
12735
12837
|
});
|
|
@@ -12793,7 +12895,8 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
12793
12895
|
"canAccessSuperData": false,
|
|
12794
12896
|
"className": "steedos-object-form steedos-amis-form"
|
|
12795
12897
|
};
|
|
12796
|
-
if (mode === "edit") {
|
|
12898
|
+
if (mode === "edit" || mode === "new") {
|
|
12899
|
+
// 新增行弹出编辑行表单,在弹出之前已经不用先增加一行,因为在翻页service初始化的时候会判断mode为new时自动新增一行
|
|
12797
12900
|
let onEditItemSubmitScript = `
|
|
12798
12901
|
// let fieldValue = _.cloneDeep(event.data["${props.name}"]);
|
|
12799
12902
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
@@ -12832,66 +12935,66 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
12832
12935
|
}
|
|
12833
12936
|
});
|
|
12834
12937
|
}
|
|
12835
|
-
else if (mode === "new") {
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
|
|
12840
|
-
|
|
12841
|
-
|
|
12842
|
-
|
|
12843
|
-
|
|
12844
|
-
|
|
12845
|
-
|
|
12846
|
-
|
|
12847
|
-
|
|
12848
|
-
|
|
12849
|
-
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
|
|
12853
|
-
|
|
12854
|
-
|
|
12855
|
-
|
|
12856
|
-
|
|
12857
|
-
|
|
12858
|
-
|
|
12859
|
-
|
|
12860
|
-
|
|
12861
|
-
|
|
12862
|
-
|
|
12863
|
-
|
|
12864
|
-
|
|
12865
|
-
|
|
12866
|
-
|
|
12867
|
-
|
|
12868
|
-
|
|
12869
|
-
|
|
12870
|
-
|
|
12871
|
-
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
12883
|
-
|
|
12884
|
-
|
|
12885
|
-
}
|
|
12938
|
+
// else if (mode === "new") {
|
|
12939
|
+
// let onNewItemSubmitScript = `
|
|
12940
|
+
// let newItem = JSON.parse(JSON.stringify(event.data));
|
|
12941
|
+
// if(event.data["${props.name}"]){
|
|
12942
|
+
// // let fieldValue = event.data.__tableItems;
|
|
12943
|
+
// // 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
|
|
12944
|
+
// let fieldValue = event.data["${props.name}"];
|
|
12945
|
+
// fieldValue.push(newItem);
|
|
12946
|
+
// doAction({
|
|
12947
|
+
// "componentId": "${props.id}",
|
|
12948
|
+
// "actionType": "setValue",
|
|
12949
|
+
// "args": {
|
|
12950
|
+
// "value": fieldValue
|
|
12951
|
+
// }
|
|
12952
|
+
// });
|
|
12953
|
+
// }
|
|
12954
|
+
// else{
|
|
12955
|
+
// // 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
|
|
12956
|
+
// doAction({
|
|
12957
|
+
// "componentId": "${props.id}",
|
|
12958
|
+
// "actionType": "setValue",
|
|
12959
|
+
// "args": {
|
|
12960
|
+
// "value": [newItem]
|
|
12961
|
+
// }
|
|
12962
|
+
// });
|
|
12963
|
+
// }
|
|
12964
|
+
// `;
|
|
12965
|
+
// Object.assign(schema, {
|
|
12966
|
+
// "onEvent": {
|
|
12967
|
+
// "submit": {
|
|
12968
|
+
// "weight": 0,
|
|
12969
|
+
// "actions": [
|
|
12970
|
+
// {
|
|
12971
|
+
// "actionType": "custom",
|
|
12972
|
+
// "script": onNewItemSubmitScript
|
|
12973
|
+
// },
|
|
12974
|
+
// // {
|
|
12975
|
+
// // "componentId": props.id,
|
|
12976
|
+
// // "actionType": "addItem",//input-table组件的needConfirm属性为true时,addItem动作会把新加的行显示为编辑状态,所以只能使用上面的custom script来setValue实现添加行
|
|
12977
|
+
// // "args": {
|
|
12978
|
+
// // "index": `\${${props.name}.length || 9000}`,//这里加9000是因为字段如果没放在form组件内,props.name.length拿不到值
|
|
12979
|
+
// // "item": {
|
|
12980
|
+
// // "&": "$$"
|
|
12981
|
+
// // }
|
|
12982
|
+
// // }
|
|
12983
|
+
// // }
|
|
12984
|
+
// ]
|
|
12985
|
+
// }
|
|
12986
|
+
// }
|
|
12987
|
+
// });
|
|
12988
|
+
// }
|
|
12886
12989
|
schema = getFormPaginationWrapper(props, schema, mode);
|
|
12887
12990
|
return schema;
|
|
12888
12991
|
}
|
|
12889
12992
|
|
|
12890
12993
|
|
|
12891
12994
|
/**
|
|
12892
|
-
*
|
|
12995
|
+
* 编辑、新增、删除、查看按钮actions
|
|
12893
12996
|
* @param {*} props
|
|
12894
|
-
* @param {*} mode edit/new/readonly
|
|
12997
|
+
* @param {*} mode edit/new/readonly/delete
|
|
12895
12998
|
*/
|
|
12896
12999
|
async function getButtonActions(props, mode) {
|
|
12897
13000
|
let actions = [];
|
|
@@ -12982,6 +13085,7 @@ async function getButtonActions(props, mode) {
|
|
|
12982
13085
|
}
|
|
12983
13086
|
];
|
|
12984
13087
|
if(props.addable){
|
|
13088
|
+
// 有新增行权限时额外添加新增和复制按钮
|
|
12985
13089
|
dialogButtons = [
|
|
12986
13090
|
{
|
|
12987
13091
|
"type": "button",
|
|
@@ -13046,7 +13150,8 @@ async function getButtonActions(props, mode) {
|
|
|
13046
13150
|
// "__tableItems": `\${${props.name}}`
|
|
13047
13151
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13048
13152
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13049
|
-
"__tableItems": `\${${props.name}|json|toJson}`
|
|
13153
|
+
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13154
|
+
"__tableItems": `\${(${props.name} || [])|json|toJson}`
|
|
13050
13155
|
},
|
|
13051
13156
|
"actions": dialogButtons,
|
|
13052
13157
|
"onEvent": {
|
|
@@ -13069,11 +13174,12 @@ async function getButtonActions(props, mode) {
|
|
|
13069
13174
|
Object.assign(actionShowEditDialog.dialog, props.dialog);
|
|
13070
13175
|
}
|
|
13071
13176
|
if (mode == "new") {
|
|
13072
|
-
|
|
13177
|
+
`
|
|
13073
13178
|
let newItem = {};
|
|
13074
13179
|
if(event.data["${props.name}"]){
|
|
13075
13180
|
// let fieldValue = event.data.__tableItems;
|
|
13076
13181
|
// 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
|
|
13182
|
+
// let fieldValue = _.clone(event.data["${props.name}"]);
|
|
13077
13183
|
let fieldValue = event.data["${props.name}"];
|
|
13078
13184
|
fieldValue.push(newItem);
|
|
13079
13185
|
doAction({
|
|
@@ -13097,11 +13203,9 @@ async function getButtonActions(props, mode) {
|
|
|
13097
13203
|
event.data.index = 1;
|
|
13098
13204
|
}
|
|
13099
13205
|
`;
|
|
13100
|
-
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
};
|
|
13104
|
-
actions = [actionNewLine, actionShowEditDialog];
|
|
13206
|
+
// 新增行时不需要在弹出编辑表单前先加一行,因为会在编辑表单所在service初始化时判断到是新增就自动增加一行,因为这里拿不到event.data.__tableItems,也无法变更其值
|
|
13207
|
+
// actions = [actionNewLine, actionShowEditDialog];
|
|
13208
|
+
actions = [actionShowEditDialog];
|
|
13105
13209
|
}
|
|
13106
13210
|
else if (mode == "edit") {
|
|
13107
13211
|
actions = [actionShowEditDialog];
|
|
@@ -13139,9 +13243,44 @@ async function getButtonActions(props, mode) {
|
|
|
13139
13243
|
// "__tableItems": `\${${props.name}}`
|
|
13140
13244
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13141
13245
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13142
|
-
"__tableItems": `\${${props.name}|json|toJson}`
|
|
13143
|
-
|
|
13246
|
+
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13247
|
+
"__tableItems": `\${(${props.name} || [])|json|toJson}`
|
|
13248
|
+
},
|
|
13249
|
+
}
|
|
13250
|
+
}
|
|
13251
|
+
];
|
|
13252
|
+
}
|
|
13253
|
+
else if (mode == "delete") {
|
|
13254
|
+
let tableServiceId = getComponentId("table_service", props.id);
|
|
13255
|
+
let onDeleteItemScript = `
|
|
13256
|
+
// let fieldValue = event.data["${props.name}"];
|
|
13257
|
+
let scope = event.context.scoped;
|
|
13258
|
+
let __wrapperServiceId = "${tableServiceId}";
|
|
13259
|
+
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
13260
|
+
let wrapperServiceData = wrapperService.getData();
|
|
13261
|
+
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
13262
|
+
// 这里_.clone是因为字段设计布局设置分组这种弹出窗口中的子表组件,直接删除后,点取消无法还原
|
|
13263
|
+
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
|
|
13264
|
+
lastestFieldValue.splice(event.data.index, 1);
|
|
13265
|
+
doAction({
|
|
13266
|
+
"componentId": "${props.id}",
|
|
13267
|
+
"actionType": "setValue",
|
|
13268
|
+
"args": {
|
|
13269
|
+
"value": lastestFieldValue
|
|
13144
13270
|
}
|
|
13271
|
+
});
|
|
13272
|
+
`;
|
|
13273
|
+
actions = [
|
|
13274
|
+
// {
|
|
13275
|
+
// "actionType": "deleteItem",
|
|
13276
|
+
// "args": {
|
|
13277
|
+
// "index": "${index+','}" //这里不加逗号后续会报错,语法是逗号分隔可以删除多行
|
|
13278
|
+
// },
|
|
13279
|
+
// "componentId": props.id
|
|
13280
|
+
// },
|
|
13281
|
+
{
|
|
13282
|
+
"actionType": "custom",
|
|
13283
|
+
"script": onDeleteItemScript
|
|
13145
13284
|
}
|
|
13146
13285
|
];
|
|
13147
13286
|
}
|
|
@@ -13190,24 +13329,7 @@ async function getButtonView(props) {
|
|
|
13190
13329
|
};
|
|
13191
13330
|
}
|
|
13192
13331
|
|
|
13193
|
-
function getButtonDelete(props) {
|
|
13194
|
-
let tableServiceId = getComponentId("table_service", props.id);
|
|
13195
|
-
let onDeleteItemScript = `
|
|
13196
|
-
// let fieldValue = event.data["${props.name}"];
|
|
13197
|
-
let scope = event.context.scoped;
|
|
13198
|
-
let __wrapperServiceId = "${tableServiceId}";
|
|
13199
|
-
let wrapperService = scope.getComponentById(__wrapperServiceId);
|
|
13200
|
-
let wrapperServiceData = wrapperService.getData();
|
|
13201
|
-
let lastestFieldValue = wrapperServiceData["${props.name}"];//这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
13202
|
-
lastestFieldValue.splice(event.data.index, 1);
|
|
13203
|
-
doAction({
|
|
13204
|
-
"componentId": "${props.id}",
|
|
13205
|
-
"actionType": "setValue",
|
|
13206
|
-
"args": {
|
|
13207
|
-
"value": lastestFieldValue
|
|
13208
|
-
}
|
|
13209
|
-
});
|
|
13210
|
-
`;
|
|
13332
|
+
async function getButtonDelete(props) {
|
|
13211
13333
|
return {
|
|
13212
13334
|
"type": "button",
|
|
13213
13335
|
"label": "",
|
|
@@ -13215,19 +13337,7 @@ function getButtonDelete(props) {
|
|
|
13215
13337
|
"level": "link",
|
|
13216
13338
|
"onEvent": {
|
|
13217
13339
|
"click": {
|
|
13218
|
-
"actions":
|
|
13219
|
-
// {
|
|
13220
|
-
// "actionType": "deleteItem",
|
|
13221
|
-
// "args": {
|
|
13222
|
-
// "index": "${index+','}" //这里不加逗号后续会报错,语法是逗号分隔可以删除多行
|
|
13223
|
-
// },
|
|
13224
|
-
// "componentId": props.id
|
|
13225
|
-
// },
|
|
13226
|
-
{
|
|
13227
|
-
"actionType": "custom",
|
|
13228
|
-
"script": onDeleteItemScript
|
|
13229
|
-
}
|
|
13230
|
-
]
|
|
13340
|
+
"actions": await getButtonActions(props, "delete")
|
|
13231
13341
|
}
|
|
13232
13342
|
}
|
|
13233
13343
|
};
|
|
@@ -13267,7 +13377,7 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13267
13377
|
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13268
13378
|
}
|
|
13269
13379
|
if (props.removable) {
|
|
13270
|
-
let buttonDeleteSchema = getButtonDelete(props);
|
|
13380
|
+
let buttonDeleteSchema = await getButtonDelete(props);
|
|
13271
13381
|
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13272
13382
|
}
|
|
13273
13383
|
let inputTableSchema = {
|