@steedos-widgets/amis-lib 3.6.2-beta.8 → 3.6.2-beta.9
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 +100 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +100 -19
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +43 -15
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -33,8 +33,8 @@ return Object.assign({},_$1.cloneDeep(STEEDOS_AUTH)||{},getBuilderContext()||{})
|
|
|
33
33
|
* @LastEditors: baozhoutao@steedos.com
|
|
34
34
|
* @LastEditTime: 2023-06-20 13:50:15
|
|
35
35
|
* @Description:
|
|
36
|
-
*/var Router={getTabDisplayAs:function getTabDisplayAs(tab_id){var urlSearch=new URLSearchParams(document.location.search);if(urlSearch.has('display')){return urlSearch.get('display');}var key="tab_".concat(tab_id,"_display");// const key = `page_display`;
|
|
37
|
-
var value=
|
|
36
|
+
*/var Router={getTabDisplayAs:function getTabDisplayAs(tab_id){var uiSchema=getUISchemaSync$1(tab_id,false);var urlSearch=new URLSearchParams(document.location.search);if(urlSearch.has('display')){return urlSearch.get('display');}var key="tab_".concat(tab_id,"_display");// const key = `page_display`;
|
|
37
|
+
var value=sessionStorage.getItem(key);var defaultDisplay="grid";if(uiSchema.enable_split){defaultDisplay="split";}return value?value:defaultDisplay;},setTabDisplayAs:function setTabDisplayAs(tab_id,displayAs){var key="tab_".concat(tab_id,"_display");sessionStorage.setItem(key,displayAs);},getAppPath:function getAppPath(_ref2){var formFactor=_ref2.formFactor,appId=_ref2.appId;return"/app/".concat(appId);},getPagePath:function getPagePath(){//TODO
|
|
38
38
|
},getObjectListViewPath:function getObjectListViewPath(_ref3){var formFactor=_ref3.formFactor,appId=_ref3.appId,objectName=_ref3.objectName,listViewName=_ref3.listViewName;return"/app/".concat(appId,"/").concat(objectName,"/grid/").concat(listViewName);},getObjectDetailPath:function getObjectDetailPath(props){var formFactor=props.formFactor,appId=props.appId,objectName=props.objectName,recordId=props.recordId,listViewName=props.listViewName,_templateType=props._templateType;if(_templateType==='JavaScript'){return"/app/".concat(appId,"/").concat(objectName,"/view/").concat(recordId,"?side_object=<%=item.objectName%>&side_listview_id=<%=item.listName%>");}return"/app/".concat(appId,"/").concat(objectName,"/view/").concat(recordId,"?side_object=${objectName}&side_listview_id=${listName}");},getObjectRelatedViewPath:function getObjectRelatedViewPath(_ref4){var formFactor=_ref4.formFactor,appId=_ref4.appId,masterObjectName=_ref4.masterObjectName,masterRecordId=_ref4.masterRecordId,objectName=_ref4.objectName,foreignKey=_ref4.foreignKey;return"/app/".concat(appId,"/").concat(masterObjectName,"/").concat(masterRecordId,"/").concat(objectName,"/grid?related_field_name=").concat(foreignKey);}};/*
|
|
39
39
|
* @Author: baozhoutao@steedos.com
|
|
40
40
|
* @Date: 2022-07-20 16:29:22
|
|
@@ -113,16 +113,22 @@ if(typeof width=='string'){if(isNaN(width)){return width||defaultWidth;}else{ret
|
|
|
113
113
|
"size": "none",
|
|
114
114
|
"className": "flex items-center justify-between"//每行样式类
|
|
115
115
|
}
|
|
116
|
-
*/function _getTableColumns(){_getTableColumns=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee56(fields,options){var _options$permissions;var columns,allowEdit,_iterator6,_step7,field,quickEditSchema,className,columnItem,previewFileScript,map,_field$amis,_field$amis2,_field$amis3,tpl,type,href;return _regeneratorRuntime().wrap(function _callee56$(_context56){while(1){switch(_context56.prev=_context56.next){case 0:columns=[];if(!options.isLookup&&!options.isInputTable){if(!options.enable_tree){columns.push({name:'_index',type:'text',width:32,placeholder:""});}}allowEdit=((_options$permissions=options.permissions)===null||_options$permissions===void 0?void 0:_options$permissions.allowEdit)&&!options.isLookup&&options.enable_inline_edit!=false;_iterator6=_createForOfIteratorHelper(fields);_context56.prev=4;_iterator6.s();case 6:if((_step7=_iterator6.n()).done){_context56.next=
|
|
116
|
+
*/function _getTableColumns(){_getTableColumns=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee56(fields,options){var _options$permissions;var columns,allowEdit,_iterator6,_step7,field,quickEditSchema,className,columnItem,previewFileScript,map,_field$amis,_field$amis2,_field$amis3,tpl,type,href;return _regeneratorRuntime().wrap(function _callee56$(_context56){while(1){switch(_context56.prev=_context56.next){case 0:columns=[];if(!options.isLookup&&!options.isInputTable){if(!options.enable_tree){columns.push({name:'_index',type:'text',width:32,placeholder:""});}}allowEdit=((_options$permissions=options.permissions)===null||_options$permissions===void 0?void 0:_options$permissions.allowEdit)&&!options.isLookup&&options.enable_inline_edit!=false;_iterator6=_createForOfIteratorHelper(fields);_context56.prev=4;_iterator6.s();case 6:if((_step7=_iterator6.n()).done){_context56.next=51;break;}field=_step7.value;if(!(field.hidden||field.extra)){_context56.next=10;break;}return _context56.abrupt("continue",49);case 10:if(!allowEdit){_context56.next=16;break;}_context56.next=13;return getQuickEditSchema(field,options);case 13:_context56.t0=_context56.sent;_context56.next=17;break;case 16:_context56.t0=allowEdit;case 17:quickEditSchema=_context56.t0;className="";if(field.wrap!=true){if(field.wrap!=false&&field.is_wide){className+=" break-words ";}else{className+=" whitespace-nowrap ";}}else{className+=" break-words ";}columnItem=void 0;if(!((field.is_name||field.name===options.labelFieldName)&&options.objectName==='cms_files')){_context56.next=26;break;}previewFileScript="\n var data = event.data;\n var file_name = data.versions ? data.name : \"".concat(field.label,"\";\n var file_id = data._id;\n SteedosUI.previewFile && SteedosUI.previewFile({file_name, file_id});\n ");columnItem={"type":"button","label":"<%=data.versions ? data.name : \"".concat(field.label,"\"%>"),className:className,"level":"link","onEvent":{"click":{"actions":[{"args":{"api":{"url":"${(versions[0] && versions[0].url) ? versions[0].url+'?download=true' : context.rootUrl+'/api/files/files/'+versions[0]+'?download=true'}","method":"get","headers":{"Authorization":"Bearer ${context.tenantId},${context.authToken}"}}},"actionType":"download",// "expression": "!!!window?.nw?.require"//浏览器上直接下载
|
|
117
117
|
"expression":"!!!(window && window.nw && window.nw.require)"//浏览器上直接下载
|
|
118
118
|
},{"args":{},"actionType":"custom","script":previewFileScript,// "expression": "!!window?.nw?.require" //PC客户端预览附件
|
|
119
119
|
"expression":"!!!(window && window.nw && window.nw.require)"//PC客户端预览附件
|
|
120
|
-
}]}}};_context56.next=
|
|
120
|
+
}]}}};_context56.next=48;break;case 26:if(!(field.type==='toggle')){_context56.next=30;break;}columnItem=Object.assign({},{type:"switch",name:field.name,label:field.label,width:getFieldWidth(field.width),toggled:field.toggled,"static":true,className:className},field.amis,{name:field.name});_context56.next=48;break;case 30:if(!(field.type==='avatar'||field.type==='image'||field.type==='file')){_context56.next=34;break;}columnItem=Object.assign({},_objectSpread({type:"switch",name:field.name,label:field.label,width:getFieldWidth(field.width),toggled:field.toggled,"static":true,className:className},getAmisFileReadonlySchema(field)),field.amis,{name:field.name});_context56.next=48;break;case 34:if(!(field.type==='select')){_context56.next=39;break;}map=getSelectMap(field.options);columnItem=Object.assign({},{type:"static-mapping",name:field.name,label:field.label,map:map,sortable:field.sortable,width:getFieldWidth(field.width),toggled:field.toggled,className:className,inputClassName:"inline","static":true},field.amis,{name:field.name});_context56.next=48;break;case 39:_context56.next=41;return getFieldTpl(field,options);case 41:tpl=_context56.sent;type='static-text';if(tpl){type='static';}else if(field.type==='html'){type='static-markdown';}else if(field.type==='url'){if(field.show_as_qr){type='static-qr-code';}else{type='input-url';}}if(field.type==='textarea'){className+='min-w-56';}// if(field.type === 'date'){
|
|
121
|
+
// className += 'date-min-w';
|
|
122
|
+
// }
|
|
123
|
+
// if(field.type === 'datetime'){
|
|
124
|
+
// className += 'datetime-min-w';
|
|
125
|
+
// }
|
|
126
|
+
//field上的amis属性里的clssname需要单独判断类型合并
|
|
121
127
|
if(_typeof((_field$amis=field.amis)===null||_field$amis===void 0?void 0:_field$amis.className)=="object"){className=_objectSpread(_defineProperty({},className,"true"),field.amis.className);}else if(typeof((_field$amis2=field.amis)===null||_field$amis2===void 0?void 0:_field$amis2.className)=="string"){className="".concat(className," ").concat(field.amis.className," ");}(_field$amis3=field.amis)===null||_field$amis3===void 0?true:delete _field$amis3.className;if(!field.hidden&&!field.extra){columnItem=Object.assign({},{name:field.name,label:field.label,sortable:field.sortable,// searchable: field.searchable,
|
|
122
128
|
width:getFieldWidth(field.width),type:type,tpl:tpl,toggled:field.toggled,className:className,inputClassName:"inline","static":true,options:field.type==='html'?{html:true}:null// toggled: true
|
|
123
|
-
},field.amis,{name:field.name});if(field.type==='color'){columnItem.type='color';columnItem.defaultColor=null;}}case
|
|
129
|
+
},field.amis,{name:field.name});if(field.type==='color'){columnItem.type='color';columnItem.defaultColor=null;}}case 48:if(columnItem){if(quickEditSchema){columnItem.quickEdit=quickEditSchema;columnItem.quickEditEnabledOn="${is_system !== true}";}columnItem.id="".concat(options.objectName,"_").concat(field.name,"_${_index}");columns.push(columnItem);}case 49:_context56.next=6;break;case 51:_context56.next=56;break;case 53:_context56.prev=53;_context56.t1=_context56["catch"](4);_iterator6.e(_context56.t1);case 56:_context56.prev=56;_iterator6.f();return _context56.finish(56);case 59:// columns.push(getOperation(fields));
|
|
124
130
|
if(!options.isLookup&&!options.isInputTable&&!___namespace.some(columns,{name:options.labelFieldName})){// 没有名称字段时显示序号字段为链接,lookup弹出的picker不需要此功能
|
|
125
|
-
href=Router.getObjectDetailPath(_objectSpread(_objectSpread({},options),{},{formFactor:options.formFactor,appId:"${appId}",objectName:options.objectName||"${objectName}",recordId:"${".concat(options.idFieldName,"}")}));columns[0].type="tpl";columns[0].tpl="<a href=\"".concat(href,"\">${").concat(columns[0].name,"}</a>");}return _context56.abrupt("return",columns);case
|
|
131
|
+
href=Router.getObjectDetailPath(_objectSpread(_objectSpread({},options),{},{formFactor:options.formFactor,appId:"${appId}",objectName:options.objectName||"${objectName}",recordId:"${".concat(options.idFieldName,"}")}));columns[0].type="tpl";columns[0].tpl="<a href=\"".concat(href,"\">${").concat(columns[0].name,"}</a>");}return _context56.abrupt("return",columns);case 61:case"end":return _context56.stop();}}},_callee56,null,[[4,53,56,59]]);}));return _getTableColumns.apply(this,arguments);}function getMobileLines(tpls){var lines=[];var maxLineCount=3;var lineChildren=[];var isNewLine=false;var isLeft=true;var lineChildrenClassName="";var lineClassName="flex items-center justify-between";tpls.forEach(function(item){var _item$field$amis,_item$field$amis2;if(isNewLine&&lines.length<maxLineCount){lines.push({"type":"wrapper","body":lineChildren,"size":"none","className":lineClassName});lineChildren=[];}if(isLeft){// 左侧半行
|
|
126
132
|
lineChildrenClassName="steedos-listview-item-left truncate h-5";if(item.field.is_wide){// 左侧全行样式可以单独写,如果需要配置两行省略号效果,可以加样式类 two-lines-truncate
|
|
127
133
|
lineChildrenClassName="steedos-listview-item-wide";}if(lines.length===0){// 第一个字段加粗黑色显示
|
|
128
134
|
lineChildrenClassName+=" font-bold text-gray-800";}}else{// 右侧半行,这里加样式类 flex flex-shrink-0,是为了省略号只显示在左半行,右半行文字一般比较短,如果也加省略号效果的话,左侧文字多的话,右侧没几个字就显示省略号了
|
|
@@ -401,13 +407,28 @@ secordLineSchema={"type":"grid","columns":[{"body":[{"type":"tpl","tpl":"${$coun
|
|
|
401
407
|
* 记录详细界面中相关表顶部头amisSchema
|
|
402
408
|
* @param {*} relatedObjectSchema 相关对象UISchema
|
|
403
409
|
* @returns amisSchema
|
|
404
|
-
*/function _getObjectRecordDetailHeader(){_getObjectRecordDetailHeader=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee76(objectSchema,recordId,options){var _ref55,_ref55$showRecordTitl,showRecordTitle,name,label,icon,NAME_FIELD_KEY,amisButtonsSchema,backButtonsSchema,reg,standardIcon,gridBody,body,max,details;return _regeneratorRuntime().wrap(function _callee76$(_context76){while(1){switch(_context76.prev=_context76.next){case 0:// console.log(`getObjectRecordDetailHeader====>`, options)
|
|
410
|
+
*/function _getObjectRecordDetailHeader(){_getObjectRecordDetailHeader=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee76(objectSchema,recordId,options){var _ref55,_ref55$showRecordTitl,showRecordTitle,name,label,icon,NAME_FIELD_KEY,amisButtonsSchema,backButtonsSchema,reg,standardIcon,gridBody,body,max,divWidth,details;return _regeneratorRuntime().wrap(function _callee76$(_context76){while(1){switch(_context76.prev=_context76.next){case 0:// console.log(`getObjectRecordDetailHeader====>`, options)
|
|
405
411
|
_ref55=options||{},_ref55$showRecordTitl=_ref55.showRecordTitle,showRecordTitle=_ref55$showRecordTitl===void 0?true:_ref55$showRecordTitl;// console.log('getObjectRecordDetailHeader==>', objectSchema, recordId)
|
|
406
412
|
name=objectSchema.name,label=objectSchema.label,icon=objectSchema.icon,NAME_FIELD_KEY=objectSchema.NAME_FIELD_KEY;amisButtonsSchema=[];if(options.showButtons!=false){amisButtonsSchema=getObjectDetailButtonsSchemas(objectSchema,recordId,options);}backButtonsSchema=null;if(options.showBackButton!=false){backButtonsSchema=getBackButtonSchema();}// console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
|
|
407
413
|
reg=new RegExp('_','g');standardIcon=icon&&icon.replace(reg,'-');gridBody=[];if(showRecordTitle){gridBody.push({"body":[{"type":"grid","columns":[{"body":[backButtonsSchema,{"type":"tpl","className":"block",// "tpl": `<img class='slds-icon slds-icon_container slds-icon-standard-${standardIcon}' src='\${context.rootUrl}/unpkg.com/@salesforce-ux/design-system/assets/icons/standard/${icon}.svg'>`
|
|
408
414
|
"tpl":"<svg class=\"slds-icon slds-icon_container slds-icon-standard-".concat(standardIcon," slds-page-header__icon\" aria-hidden=\"true\"><use xlink:href=\"/assets/icons/standard-sprite/svg/symbols.svg#").concat(icon,"\"></use></svg>")}],"md":"auto","className":"","columnClassName":"flex justify-center items-center"},{"body":[{"type":"tpl","tpl":"".concat(label),"inline":false,"wrapperComponent":"","className":"leading-4 text-md"},{"type":"tpl","tpl":"${NAME_FIELD_VALUE}","inline":false,"wrapperComponent":"","className":"record-detail-header-name leading-5 text-xl font-bold"}],"columnClassName":"p-l-xs"}],"className":"flex justify-between"}],"columnClassName":"flex-initial","md":"auto"});}gridBody.push({"body":{"type":"flex","items":amisButtonsSchema},"md":"auto"// "hiddenOn": "${recordLoaded != true}"
|
|
409
|
-
});body=[{"type":"wrapper","className":"p-4 bg-gray-100 border-b","body":[{"type":"grid","columns":gridBody,"className":"flex justify-between flex-nowrap"}],"hiddenOn":"${recordLoaded != true}"}];if(showRecordTitle){body.push({"type":"wrapper","className":"p-4","body":[{"type":"grid","columns":[gridBody[0]],"className":"flex justify-between"}],"hiddenOn":"${recordLoaded == true}"});}max=10;if(options.formFactor==='SMALL'){max=4;}
|
|
410
|
-
|
|
415
|
+
});body=[{"type":"wrapper","className":"p-4 bg-gray-100 border-b","body":[{"type":"grid","columns":gridBody,"className":"flex justify-between flex-nowrap"}],"hiddenOn":"${recordLoaded != true}"}];if(showRecordTitle){body.push({"type":"wrapper","className":"p-4","body":[{"type":"grid","columns":[gridBody[0]],"className":"flex justify-between"}],"hiddenOn":"${recordLoaded == true}"});}max=10;if(options.formFactor==='SMALL'){max=4;}else{divWidth=window.innerWidth;if(options.display==='split'){divWidth=divWidth-388;}if(document.body.classList.contains('sidebar')){divWidth=divWidth-210;}// 根据屏幕宽度计算显示数量, 使高亮字段只占1行
|
|
416
|
+
max=Math.trunc(divWidth/200);if(max>10){max=10;}}// console.log('=======================max=========================', max)
|
|
417
|
+
if(objectSchema.compactLayouts){details=[];_.each(_.slice(_.difference(objectSchema.compactLayouts,[objectSchema.NAME_FIELD_KEY]),0,max),function(fieldName){var field=objectSchema.fields[fieldName];if(field){details.push({type:'steedos-field',"static":true,config:field});}});// 注意: 以下注释不能删除. tailwind css 动态编译时会识别以下注释, 生成对应的样式
|
|
418
|
+
// xl:grid-cols-1
|
|
419
|
+
// xl:grid-cols-2
|
|
420
|
+
// xl:grid-cols-3
|
|
421
|
+
// xl:grid-cols-4
|
|
422
|
+
// xl:grid-cols-5
|
|
423
|
+
// xl:grid-cols-6
|
|
424
|
+
// xl:grid-cols-7
|
|
425
|
+
// xl:grid-cols-8
|
|
426
|
+
// xl:grid-cols-9
|
|
427
|
+
// xl:grid-cols-10
|
|
428
|
+
// xl:grid-cols-11
|
|
429
|
+
// xl:grid-cols-12
|
|
430
|
+
body.push({"type":"wrapper","body":{"type":"form",// "className": "gap-2 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-5 3xl:grid-cols-8 4xl:grid-cols-8 5xl:grid-cols-10", //max-h-12 overflow-hidden
|
|
431
|
+
"className":"gap-2 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-5 xl:grid-cols-".concat(max),"wrapWithPanel":false,"actions":[],"body":details,"hiddenOn":"${recordLoaded != true}"},"className":"steedos-record-compact-layouts p-4 bg-white compact-layouts border-b"});}return _context76.abrupt("return",{type:'service',id:"page_readonly_".concat(name,"_header"),name:"page",body:body,className:''});case 17:case"end":return _context76.stop();}}},_callee76);}));return _getObjectRecordDetailHeader.apply(this,arguments);}function getObjectRecordDetailRelatedListHeader(_x94,_x95,_x96){return _getObjectRecordDetailRelatedListHeader.apply(this,arguments);}/**
|
|
411
432
|
* 点击记录详细界面相关表顶部标题进入的相关表页面的顶部amisSchema
|
|
412
433
|
* @param {*} objectSchema
|
|
413
434
|
* @param {*} recordId
|
|
@@ -421,7 +442,7 @@ reg=new RegExp('_','g');standardIcon=icon&&icon.replace(reg,'-');gridBody=[];if(
|
|
|
421
442
|
"targetObjectName":"${objectName}","recordId":"${uiSchema.list_views[listName]._id}","listName":"${listName}","appId":"${appId}","context":"${context}"},"body":[{"type":"steedos-object-form","label":"对象表单","objectApiName":"object_listviews","recordId":"${recordId}","mode":"edit","fieldsExtend":fieldsExtend$1(),"initApiAdaptor":initApiAdaptor$1(),"apiRequestAdaptor":apiRequestAdaptor$1(),"fields":["columns","mobile_columns"],"onEvent":{"submitSucc":{"weight":0,"actions":[{"args":{"url":"${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}","blank":false},"actionType":"url"}]}}}],"searchable":true,"showCloseButton":true,"showErrorMsg":true,"showLoading":true,"size":"lg"},"actionType":"dialog"}]}}};};function fieldsExtend$1(){return{"columns":{"amis":{"type":"transfer","sortable":true,"searchable":true,"source":{"method":"get","url":"${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/fields/options","headers":{"Authorization":"Bearer ${context.tenantId},${context.authToken}"}}}},"mobile_columns":{"amis":{"type":"transfer","sortable":true,"searchable":true,"source":{"method":"get","url":"${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/fields/options","headers":{"Authorization":"Bearer ${context.tenantId},${context.authToken}"}}}}};}function initApiAdaptor$1(){return"\n const recordId_tmp = api.body.recordId;\n let columns_tmp = {}, mobile_columns_tmp = {};\n if (recordId_tmp) {\n columns_tmp = payload.data.columns;\n mobile_columns_tmp = payload.data.mobile_columns;\n if (columns_tmp) {\n columns_tmp = lodash.map(columns_tmp, 'field');\n }\n if (mobile_columns_tmp) {\n mobile_columns_tmp = lodash.map(mobile_columns_tmp, 'field');\n }\n }\n payload.data.columns = columns_tmp;\n payload.data.mobile_columns = mobile_columns_tmp;\n \n delete payload.extensions;\n return payload;\n ";}function apiRequestAdaptor$1(){return"\n const formData_tmp = api.body.$;\n const objectName_tmp = api.body.objectName;\n const recordId_tmp = api.body.recordId;\n \n if (typeof formData_tmp.columns == 'string') {\n formData_tmp.columns = formData_tmp.columns && formData_tmp.columns.split(',');\n }\n if (typeof formData_tmp.mobile_columns == 'string') {\n formData_tmp.mobile_columns = formData_tmp.mobile_columns && formData_tmp.mobile_columns.split(',');\n }\n \n // \u6570\u636E\u683C\u5F0F\u8F6C\u6362\n formData_tmp.columns = lodash.map(formData_tmp.columns, (item) => {\n return { field: item };\n });\n formData.mobile_columns = lodash.map(formData.mobile_columns, (item) => {\n return { field: item };\n });\n \n let query_tmp = 'mutation{record: ' + objectName_tmp + '__insert(doc: {__saveData}){_id}}';\n if (api.body.recordId) {\n query_tmp = 'mutation{record: ' + objectName_tmp + '__update(id: \"' + recordId_tmp +'\", doc: {__saveData}){_id}}';\n };\n delete formData_tmp._id;\n let __saveData_tmp = JSON.stringify(JSON.stringify(formData_tmp));\n api.data = { query: query_tmp.replace('{__saveData}', __saveData_tmp) };\n \n return api;\n ";}var getSetListviewSortButtonSchema=function getSetListviewSortButtonSchema(){return{"type":"button","label":i18next__default["default"].t('frontend_listview_control_sort'),"disabledOn":"!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)","onEvent":{"click":{"weight":0,"actions":[{"dialog":{"type":"dialog","title":i18next__default["default"].t('frontend_listview_control_sort'),"data":{//"&":"$$",2.7、2.9、3.0在此处失效
|
|
422
443
|
"targetObjectName":"${objectName}","recordId":"${uiSchema.list_views[listName]._id}","listName":"${listName}","appId":"${appId}","context":"${context}"},"body":[{"type":"steedos-object-form","label":"对象表单","objectApiName":"object_listviews","recordId":"${recordId}","className":"","id":"u:061f158b4c5a","mode":"edit","fields":["sort","sort.$.field_name","sort.$.order"],"onEvent":{"submitSucc":{"weight":0,"actions":[{"args":{"url":"${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}","blank":false},"actionType":"url"}]}},"fieldsExtend":fieldsExtend(),"initApiAdaptor":initApiAdaptor(),"apiRequestAdaptor":apiRequestAdaptor()}],"showCloseButton":true,"showErrorMsg":true,"showLoading":true,"id":"u:d3f6947b6acf","size":"lg"},"actionType":"dialog"}]}}};};function fieldsExtend(){return{"sort":{"amis":{"type":"tabs-transfer","sortable":true,"searchable":true,"source":{"method":"get","url":"${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/sortFields/options","headers":{"Authorization":"Bearer ${context.tenantId},${context.authToken}"}}}}};}function initApiAdaptor(){return"\n let sort;\n if (recordId) {\n sort = payload.data.sort;\n //\u6570\u636E\u683C\u5F0F\u8F6C\u6362\n if (sort instanceof Array) {\n sort = lodash.map(sort, (item) => {\n return item.field_name + ':' + (item.order || 'asc')\n });\n }\n }\n payload.data.sort = sort;\n delete payload.extensions;\n return payload;\n ";}function apiRequestAdaptor(){return"\n const recordId = api.body.recordId;\n //\u6570\u636E\u683C\u5F0F\u8F6C\u6362\n if (typeof formData.sort == 'string') {\n formData.sort = formData.sort && formData.sort.split(',');\n }\n formData.sort = lodash.map(formData.sort, (item) => {\n const arr = item.split(':');\n return { field_name: arr[0], order: arr[1] };\n });\n if (recordId) {\n query = 'mutation{record: ' + objectName + '__update(id: \"' + recordId + '\", doc: {__saveData}){_id}}';\n }\n __saveData = JSON.stringify(JSON.stringify(formData));\n api.data = { query: query.replace('{__saveData}', __saveData) };\n return api;\n ";}var getDeleteListviewButtonSchema=function getDeleteListviewButtonSchema(){return{"type":"button","label":i18next__default["default"].t('frontend_listview_control_delete_label'),"disabledOn":"!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)","confirmText":i18next__default["default"].t('frontend_listview_control_delete_confirm_text'),"onEvent":{"click":{"actions":[{"actionType":"ajax","args":{"api":{"url":"${context.rootUrl}/graphql","method":"post","headers":{"Authorization":"Bearer ${context.tenantId},${context.authToken}"},"data":{"&":"$$","uiSchema":"${uiSchema}","recordId":"${uiSchema.list_views[listName]._id}"},"messages":{"success":i18next__default["default"].t('frontend_listview_control_delete_message_success')},"requestAdaptor":requestAdaptor(),"adaptor":adaptor()}}},{"actionType":"url","args":{"url":"${context.rootUrl}/app/${appId}/${objectName}/grid/all","blank":false},"expression":"data.delete == 1"}]}}};};function requestAdaptor(){return"\n const { recordId } = api.body;\n var deleteArray = [];\n if (recordId) { deleteArray.push(`delete:object_listviews__delete(id: \"${recordId}\")`); }\n api.data = { query: `mutation{${deleteArray.join(',')}}` };\n return api;\n ";}function adaptor(){return"\n if (payload.errors) {\n payload.status = 2;\n payload.msg = payload.errors[0].message;\n }\n return payload;\n ";}var getSettingListviewToolbarButtonSchema=function getSettingListviewToolbarButtonSchema(){return{"type":"dropdown-button","trigger":"click","icon":"fa fa-cog",//TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
|
|
423
444
|
// "tooltip": i18next.t('frontend_button_listview_control_tooltip'),
|
|
424
|
-
"btnClassName":"antd-Button--iconOnly bg-white !p-2 rounded border-gray-300 text-gray-500","align":"right","visibleOn":"${!isLookup}","buttons":[{"label":i18next__default["default"].t('frontend_button_listview_control_label'),"children":[getNewListviewButtonSchema(),getCopyListviewButtonSchema(),getRenameListviewButtonSchema(),getSetListviewShareButtonSchema(),getSetListviewFiltersButtonSchema(),getSetListviewColumnsButtonSchema(),getSetListviewSortButtonSchema(),getDeleteListviewButtonSchema()]}]};};var getDisplayAsButton=function getDisplayAsButton(objectName,showDisplayAs){var displayAs=amisLib.Router.getTabDisplayAs(objectName);var buttons=[{"type":"button","label":i18next__default["default"].t('frontend_display_type_is_table'),"onClick":"const key = 'tab_"+objectName+"_display';
|
|
445
|
+
"btnClassName":"antd-Button--iconOnly bg-white !p-2 rounded border-gray-300 text-gray-500","align":"right","visibleOn":"${!isLookup}","buttons":[{"label":i18next__default["default"].t('frontend_button_listview_control_label'),"children":[getNewListviewButtonSchema(),getCopyListviewButtonSchema(),getRenameListviewButtonSchema(),getSetListviewShareButtonSchema(),getSetListviewFiltersButtonSchema(),getSetListviewColumnsButtonSchema(),getSetListviewSortButtonSchema(),getDeleteListviewButtonSchema()]}]};};var getDisplayAsButton=function getDisplayAsButton(objectName,showDisplayAs){var displayAs=amisLib.Router.getTabDisplayAs(objectName);var buttons=[{"type":"button","label":i18next__default["default"].t('frontend_display_type_is_table'),"onClick":"const key = 'tab_"+objectName+"_display';sessionStorage.setItem(key, 'grid');let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');","rightIcon":displayAs!='split'?"fa fa-check":null,"rightIconClassName":"m-l-sm"},{"type":"button","label":i18next__default["default"].t('frontend_display_type_is_split'),"onClick":"const key = 'tab_"+objectName+"_display';sessionStorage.setItem(key, 'split');const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);","rightIcon":displayAs==='split'?"fa fa-check":null,"rightIconClassName":"m-l-sm"}];displayAs==='split'?i18next__default["default"].t('frontend_display_type_is_split'):i18next__default["default"].t('frontend_display_type_is_table');return{"type":"dropdown-button","icon":"fa fa-table-columns",//TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
|
|
425
446
|
// "tooltip": `${i18next.t('frontend_display_as')} ${displayAsLabel}`,
|
|
426
447
|
"btnClassName":"antd-Button--iconOnly bg-white !p-2 rounded border-gray-300 text-gray-500","align":"right","visibleOn":"${window:innerWidth > 768 && !!!isLookup}","buttons":[{"label":i18next__default["default"].t('frontend_display_as'),"children":buttons}]};};var onFieldsFilterToggleScript="\nconst scope = event.context.scoped;\nconst filterForm = scope.getComponents().find(function(n){\n return n.props.type === \"form\";\n});\nconst filterService = filterForm.context.getComponents().find(function(n){\n return n.props.type === \"service\";\n});\nlet toShowFieldsFilter = !!!filterService.props.data.showFieldsFilter;\nfilterService.setData({showFieldsFilter: toShowFieldsFilter});\n//\u89E6\u53D1amis crud \u9AD8\u5EA6\u91CD\u7B97\ndoAction({\n \"actionType\": \"broadcast\",\n \"args\": {\n \"eventName\": \"@height.changed.\" + event.data.objectName\n },\n \"data\": {\n \"timeOut\": 1000\n }\n});\n// \u624B\u673A\u7AEF\u5728\u663E\u793A\u641C\u7D22\u680F\u65F6\u9690\u85CFcrud\u4E0A\u7684\u5237\u65B0\u6309\u94AE\uFF0C\u56E0\u4E3A\u70B9\u51FB\u540Ecrud\u9AD8\u5EA6\u663E\u793A\u6709\u95EE\u9898\nlet crudService = scope.getComponentById(\"service_listview_\" + event.data.objectName);\ncrudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});\n// if(filterService.props.data.showFieldsFilter){\n// if(isMobile){\n// // \u624B\u673A\u4E0A\u53EA\u80FD\u901A\u8FC7\u53D6\u6D88\u6309\u94AE\u6765\u5173\u95ED\u641C\u7D22\u680F\n// return;\n// }\n// let buttonCancel = SteedosUI.getClosestAmisComponentByType(filterForm.context, \"button\", { \n// direction: \"down\", \n// name: \"btn_filter_form_cancel\" \n// });\n// buttonCancel.props.dispatchEvent('click', {}).then(function(){\n// resizeWindow();\n// });\n// }\n// else{\n// if(isMobile){\n// // \u624B\u673A\u7AEF\u5728\u663E\u793A\u641C\u7D22\u680F\u65F6\u9690\u85CFcrud\u4E0A\u7684\u5237\u65B0\u6309\u94AE\uFF0C\u56E0\u4E3A\u70B9\u51FB\u540Ecrud\u9AD8\u5EA6\u663E\u793A\u6709\u95EE\u9898\n// let crudService = scope.getComponentById(\"service_listview_\" + event.data.objectName);\n// crudService && crudService.setData({showFieldsFilter: true});\n// }\n// }\n";// function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLookup = false, keywordsSearchBoxName = "__keywords", crudId } = {}){
|
|
427
448
|
function getObjectHeaderQuickSearchBox(mainObject,fields,formFactor){var _ref11=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},_ref11$isLookup=_ref11.isLookup,isLookup=_ref11$isLookup===void 0?false:_ref11$isLookup,_ref11$keywordsSearch=_ref11.keywordsSearchBoxName,keywordsSearchBoxName=_ref11$keywordsSearch===void 0?"__keywords":_ref11$keywordsSearch;var searchableFieldsLabel=[];_.each(mainObject.fields,function(field){if(isFieldQuickSearchable(field,mainObject.NAME_FIELD_KEY)){searchableFieldsLabel.push(field.label);}});var listViewPropsStoreKey=location.pathname+"/crud";var localListViewProps=sessionStorage.getItem(listViewPropsStoreKey);var crudKeywords="";if(localListViewProps&&!isLookup){localListViewProps=JSON.parse(localListViewProps);crudKeywords=localListViewProps&&localListViewProps.__keywords||"";}var onChangeScript="\n const scope = event.context.scoped;\n let crud = SteedosUI.getClosestAmisComponentByType(scope, \"crud\");\n // let crudService = crud && SteedosUI.getClosestAmisComponentByType(crud.context, \"service\");\n let __changedSearchBoxValues = {};\n __changedSearchBoxValues[\"".concat(keywordsSearchBoxName,"\"] = event.data[\"").concat(keywordsSearchBoxName,"\"];\n // crudService && crudService.setData({__changedSearchBoxValues: __changedSearchBoxValues});\n // \u8FD9\u91CC\u4E0D\u7528crudService\u800C\u7528crud\u662F\u56E0\u4E3Alookup\u5B57\u6BB5\u5F39\u51FA\u7684\u5217\u8868\u4E2D\u7684crudService\u4E2D\u7684\u53D8\u91CF\u65E0\u6CD5\u4F20\u5165crud\u7684\u53D1\u9001\u9002\u914D\u5668\u4E2D\n // crud && crud.setData({__changedSearchBoxValues: __changedSearchBoxValues});\n if(crud){\n let crudData = crud.getData();\n crudData.__changedSearchBoxValues = __changedSearchBoxValues;\n crud.setData(crudData);\n }\n ");// onSearchScript中加上了onChangeScript中的脚本,是因为amis 3.2不能用change事件执行onChangeScript
|
|
@@ -869,13 +890,18 @@ sectionFieldsVisibleOn=___namespace.map(___namespace.compact(___namespace.map(fi
|
|
|
869
890
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
870
891
|
* @Date: 2023-11-15 09:50:22
|
|
871
892
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
872
|
-
* @LastEditTime: 2024-01-
|
|
893
|
+
* @LastEditTime: 2024-01-18 10:29:57
|
|
873
894
|
*/ /**
|
|
874
895
|
* 子表组件字段值中每行数据的键值key移除指定前缀
|
|
875
896
|
* @param {*} value 子表组件字段值,数组
|
|
876
897
|
* @param {*} fieldPrefix 字段前缀
|
|
877
898
|
* @returns 转换后的子表组件字段值
|
|
878
899
|
*/function _getFormBody(){_getFormBody=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee118(permissionFields,formFields,ctx){return _regeneratorRuntime().wrap(function _callee118$(_context118){while(1){switch(_context118.prev=_context118.next){case 0:_context118.next=2;return getSections(permissionFields,formFields,ctx);case 2:return _context118.abrupt("return",_context118.sent);case 3:case"end":return _context118.stop();}}},_callee118);}));return _getFormBody.apply(this,arguments);}function getTableValueWithoutFieldPrefix(value,fieldPrefix){var convertedValue=[];(value||[]).forEach(function(itemValue){var newItemValue={};for(var n in itemValue){newItemValue[n.replace(new RegExp("^".concat(fieldPrefix)),"")]=itemValue[n];}convertedValue.push(newItemValue);});return convertedValue;}/**
|
|
900
|
+
* 子表组件字段值中每行数据的键值key补上指定前缀
|
|
901
|
+
* @param {*} value 子表组件字段值,数组
|
|
902
|
+
* @param {*} fieldPrefix 字段前缀
|
|
903
|
+
* @returns 转换后的子表组件字段值
|
|
904
|
+
*/function getTableValuePrependFieldPrefix(value,fieldPrefix){var convertedValue=[];(value||[]).forEach(function(itemValue){var newItemValue={};for(var n in itemValue){if(_typeof(itemValue[n])!==undefined){newItemValue["".concat(fieldPrefix).concat(n)]=itemValue[n];}}convertedValue.push(newItemValue);});return convertedValue;}/**
|
|
879
905
|
* 子表组件字段集合属性中每个字段name移除指定前缀
|
|
880
906
|
* @param {*} fields 子表组件字段集合,数组
|
|
881
907
|
* @param {*} fieldPrefix 字段前缀
|
|
@@ -1087,8 +1113,8 @@ actions=[actionShowEditDialog];}else if(mode=="edit"){actions=[actionShowEditDia
|
|
|
1087
1113
|
// },
|
|
1088
1114
|
// "componentId": props.id
|
|
1089
1115
|
// },
|
|
1090
|
-
{"actionType":"custom","script":onDeleteItemScript}];}case 42:return _context121.abrupt("return",actions);case 43:case"end":return _context121.stop();}}},_callee121);}));return _getButtonActions.apply(this,arguments);}function getButtonNew(_x222){return _getButtonNew.apply(this,arguments);}function _getButtonNew(){_getButtonNew=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee122(props){return _regeneratorRuntime().wrap(function _callee122$(_context122){while(1){switch(_context122.prev=_context122.next){case 0:_context122.next=2;return getButtonActions(props,"new");case 2:_context122.t0=_context122.sent;_context122.t1={"actions":_context122.t0};_context122.t2={"click":_context122.t1};return _context122.abrupt("return",{"label":"新增","type":"button","icon":"fa fa-plus","onEvent":_context122.t2,"level":"primary"});case 6:case"end":return _context122.stop();}}},_callee122);}));return _getButtonNew.apply(this,arguments);}function getButtonEdit(_x223,_x224){return _getButtonEdit.apply(this,arguments);}function _getButtonEdit(){_getButtonEdit=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee123(props,showAsInlineEditMode){return _regeneratorRuntime().wrap(function _callee123$(_context123){while(1){switch(_context123.prev=_context123.next){case 0:_context123.t0="fa fa-".concat(showAsInlineEditMode?"expand-alt":"pencil");_context123.next=3;return getButtonActions(props,"edit");case 3:_context123.t1=_context123.sent;_context123.t2={"actions":_context123.t1};_context123.t3={"click":_context123.t2};return _context123.abrupt("return",{"type":"button","label":"","icon":_context123.t0,"level":"link","onEvent":_context123.t3});case 7:case"end":return _context123.stop();}}},_callee123);}));return _getButtonEdit.apply(this,arguments);}function getButtonView(_x225){return _getButtonView.apply(this,arguments);}function _getButtonView(){_getButtonView=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee124(props){return _regeneratorRuntime().wrap(function _callee124$(_context124){while(1){switch(_context124.prev=_context124.next){case 0:_context124.next=2;return getButtonActions(props,"readonly");case 2:_context124.t0=_context124.sent;_context124.t1={"actions":_context124.t0};_context124.t2={"click":_context124.t1};return _context124.abrupt("return",{"type":"button","label":"","icon":"fa fa-expand-alt","level":"link","onEvent":_context124.t2});case 6:case"end":return _context124.stop();}}},_callee124);}));return _getButtonView.apply(this,arguments);}function getButtonDelete(_x226){return _getButtonDelete.apply(this,arguments);}function _getButtonDelete(){_getButtonDelete=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee125(props){return _regeneratorRuntime().wrap(function _callee125$(_context125){while(1){switch(_context125.prev=_context125.next){case 0:_context125.next=2;return getButtonActions(props,"delete");case 2:_context125.t0=_context125.sent;_context125.t1={"actions":_context125.t0};_context125.t2={"click":_context125.t1};return _context125.abrupt("return",{"type":"button","label":"","icon":"fa fa-trash-alt","level":"link","onEvent":_context125.t2});case 6:case"end":return _context125.stop();}}},_callee125);}));return _getButtonDelete.apply(this,arguments);}var getAmisInputTableSchema=/*#__PURE__*/function(){var _ref20=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(props){var showOperation,serviceId,buttonsForColumnOperations,inlineEditMode,showAsInlineEditMode,showEditButton,buttonEditSchema,buttonViewSchema,buttonDeleteSchema,inputTableSchema,
|
|
1091
|
-
if(props.fieldPrefix){props.fields=getTableFieldsWithoutFieldPrefix(props.fields,props.fieldPrefix);}
|
|
1116
|
+
{"actionType":"custom","script":onDeleteItemScript}];}case 42:return _context121.abrupt("return",actions);case 43:case"end":return _context121.stop();}}},_callee121);}));return _getButtonActions.apply(this,arguments);}function getButtonNew(_x222){return _getButtonNew.apply(this,arguments);}function _getButtonNew(){_getButtonNew=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee122(props){return _regeneratorRuntime().wrap(function _callee122$(_context122){while(1){switch(_context122.prev=_context122.next){case 0:_context122.next=2;return getButtonActions(props,"new");case 2:_context122.t0=_context122.sent;_context122.t1={"actions":_context122.t0};_context122.t2={"click":_context122.t1};return _context122.abrupt("return",{"label":"新增","type":"button","icon":"fa fa-plus","onEvent":_context122.t2,"level":"primary"});case 6:case"end":return _context122.stop();}}},_callee122);}));return _getButtonNew.apply(this,arguments);}function getButtonEdit(_x223,_x224){return _getButtonEdit.apply(this,arguments);}function _getButtonEdit(){_getButtonEdit=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee123(props,showAsInlineEditMode){return _regeneratorRuntime().wrap(function _callee123$(_context123){while(1){switch(_context123.prev=_context123.next){case 0:_context123.t0="fa fa-".concat(showAsInlineEditMode?"expand-alt":"pencil");_context123.next=3;return getButtonActions(props,"edit");case 3:_context123.t1=_context123.sent;_context123.t2={"actions":_context123.t1};_context123.t3={"click":_context123.t2};return _context123.abrupt("return",{"type":"button","label":"","icon":_context123.t0,"level":"link","onEvent":_context123.t3});case 7:case"end":return _context123.stop();}}},_callee123);}));return _getButtonEdit.apply(this,arguments);}function getButtonView(_x225){return _getButtonView.apply(this,arguments);}function _getButtonView(){_getButtonView=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee124(props){return _regeneratorRuntime().wrap(function _callee124$(_context124){while(1){switch(_context124.prev=_context124.next){case 0:_context124.next=2;return getButtonActions(props,"readonly");case 2:_context124.t0=_context124.sent;_context124.t1={"actions":_context124.t0};_context124.t2={"click":_context124.t1};return _context124.abrupt("return",{"type":"button","label":"","icon":"fa fa-expand-alt","level":"link","onEvent":_context124.t2});case 6:case"end":return _context124.stop();}}},_callee124);}));return _getButtonView.apply(this,arguments);}function getButtonDelete(_x226){return _getButtonDelete.apply(this,arguments);}function _getButtonDelete(){_getButtonDelete=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee125(props){return _regeneratorRuntime().wrap(function _callee125$(_context125){while(1){switch(_context125.prev=_context125.next){case 0:_context125.next=2;return getButtonActions(props,"delete");case 2:_context125.t0=_context125.sent;_context125.t1={"actions":_context125.t0};_context125.t2={"click":_context125.t1};return _context125.abrupt("return",{"type":"button","label":"","icon":"fa fa-trash-alt","level":"link","onEvent":_context125.t2});case 6:case"end":return _context125.stop();}}},_callee125);}));return _getButtonDelete.apply(this,arguments);}var getAmisInputTableSchema=/*#__PURE__*/function(){var _ref20=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(props){var showOperation,serviceId,buttonsForColumnOperations,inlineEditMode,showAsInlineEditMode,showEditButton,buttonEditSchema,buttonViewSchema,buttonDeleteSchema,amis,inputTableSchema,isAnyFieldHasDependOn,schemaBody,footerToolbar,buttonNewSchema,headerToolbar,schema;return _regeneratorRuntime().wrap(function _callee19$(_context19){while(1){switch(_context19.prev=_context19.next){case 0:if(!props.id){props.id="steedos_input_table_"+props.name+"_"+Math.random().toString(36).substr(2,9);}if(!props.primaryKey){props.primaryKey="_id";}showOperation=props.showOperation;if(showOperation!==false){showOperation=true;}// props.fieldPrefix = "project_milestone_";
|
|
1117
|
+
if(props.fieldPrefix){props.fields=getTableFieldsWithoutFieldPrefix(props.fields,props.fieldPrefix);}serviceId=getComponentId("table_service",props.id);buttonsForColumnOperations=[];inlineEditMode=props.inlineEditMode;showAsInlineEditMode=inlineEditMode&&props.editable;if(!showOperation){_context19.next=29;break;}if(!props.editable){_context19.next=20;break;}showEditButton=true;if(showAsInlineEditMode){// 始终显示弹出子表表单按钮,如果需要判断只在有列被隐藏时才需要显示弹出表单按钮放开下面的if逻辑就好
|
|
1092
1118
|
showEditButton=true;// // inline edit模式下只在有列被隐藏时才需要显示编辑按钮
|
|
1093
1119
|
// if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length) {
|
|
1094
1120
|
// showEditButton = true;
|
|
@@ -1097,9 +1123,11 @@ showEditButton=true;// // inline edit模式下只在有列被隐藏时才需要
|
|
|
1097
1123
|
// showEditButton = false;
|
|
1098
1124
|
// }
|
|
1099
1125
|
}// 编辑时显示编辑按钮
|
|
1100
|
-
if(!showEditButton){_context19.next=
|
|
1101
|
-
if(amis){// 支持配置amis属性重写或添加最终生成的input-table中任何属性。
|
|
1126
|
+
if(!showEditButton){_context19.next=18;break;}_context19.next=16;return getButtonEdit(props,showAsInlineEditMode);case 16:buttonEditSchema=_context19.sent;buttonsForColumnOperations.push(buttonEditSchema);case 18:_context19.next=24;break;case 20:_context19.next=22;return getButtonView(props);case 22:buttonViewSchema=_context19.sent;buttonsForColumnOperations.push(buttonViewSchema);case 24:if(!props.removable){_context19.next=29;break;}_context19.next=27;return getButtonDelete(props);case 27:buttonDeleteSchema=_context19.sent;buttonsForColumnOperations.push(buttonDeleteSchema);case 29:amis=props["input-table"]||props.amis;//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
|
|
1127
|
+
_context19.t0=props.label;_context19.t1=props.name;_context19.t2=props.draggable;_context19.t3=props.showIndex;_context19.t4=props.perPage;_context19.t5=props.id;_context19.next=38;return getInputTableColumns(props);case 38:_context19.t6=_context19.sent;_context19.t7=props.strictMode;_context19.t8=props.tableClassName;_context19.t9=function pipeOut(value,data){value=(value||[]).map(function(item){delete item.__fix_rerender_after_children_modified_tag;return item;});if(props.fieldPrefix){value=getTableValuePrependFieldPrefix(value,props.fieldPrefix);}if(amis.pipeOut){if(typeof amis.pipeOut==='function'){return amis.pipeOut(value,data);}}return value;};inputTableSchema={"type":"input-table","label":_context19.t0,"name":_context19.t1,"draggable":_context19.t2,"showIndex":_context19.t3,"perPage":_context19.t4,"id":_context19.t5,"columns":_context19.t6,"strictMode":_context19.t7,"showTableAddBtn":false,"showFooterAddBtn":false,"className":_context19.t8,"pipeOut":_context19.t9};if(amis.pipeIn){inputTableSchema.pipeIn=amis.pipeIn;}if(props.fieldPrefix){inputTableSchema.pipeIn=function(value,data){value=getTableValueWithoutFieldPrefix(value,props.fieldPrefix);if(amis.pipeIn){if(typeof amis.pipeIn==='function'){return amis.pipeIn(value,data);}}return value;};}if(buttonsForColumnOperations.length){inputTableSchema.columns.push({"name":"__op__","type":"operation","buttons":buttonsForColumnOperations,"width":buttonsForColumnOperations.length>1?"60px":"20px"});}if(showAsInlineEditMode){inputTableSchema.needConfirm=false;}if(amis){// 支持配置amis属性重写或添加最终生成的input-table中任何属性。
|
|
1102
1128
|
delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
|
|
1129
|
+
delete amis.pipeIn;//该属性在上面合并过了
|
|
1130
|
+
delete amis.pipeOut;//该属性在上面合并过了
|
|
1103
1131
|
Object.assign(inputTableSchema,amis);}isAnyFieldHasDependOn=(props.fields||[]).find(function(item){return item.depend_on;});if(isAnyFieldHasDependOn){// 有任意一个子字段有depend_on属性时,强制设置禁用静态模式,因为strictMode模式下,dependOn的字段值变更后,不会rerender整个子表
|
|
1104
1132
|
Object.assign(inputTableSchema,{strictMode:false});}schemaBody=[inputTableSchema];footerToolbar=_$1.clone(props.footerToolbar||[]);//这里不clone的话,会造成死循环,应该是因为props属性变更会让组件重新渲染
|
|
1105
1133
|
if(!props.addable){_context19.next=57;break;}_context19.next=55;return getButtonNew(props);case 55:buttonNewSchema=_context19.sent;footerToolbar.unshift(buttonNewSchema);case 57:if(footerToolbar.length){schemaBody.push({"type":"wrapper","size":"none","body":footerToolbar});}// 直接把headerToolbar unshift进schemaBody,不会显示在label下面,而是显示在上面了,这个暂时没有解决办法,只能等amis 升级
|