@steedos-widgets/amis-lib 3.6.2-beta.13 → 3.6.2-beta.14
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 +87 -37
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +87 -37
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +23 -14
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/util.d.ts +5 -0
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -38,14 +38,18 @@ var value=sessionStorage.getItem(key);var defaultDisplay="grid";if(uiSchema.enab
|
|
|
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
|
|
41
|
-
* @LastEditors:
|
|
42
|
-
* @LastEditTime:
|
|
41
|
+
* @LastEditors: liaodaxue
|
|
42
|
+
* @LastEditTime: 2024-01-25 14:44:17
|
|
43
43
|
* @Description:
|
|
44
44
|
*/function getImageFieldUrl(url){if(window.Meteor&&window.Meteor.isCordova!=true){// '//'的位置
|
|
45
45
|
var doubleSlashIndex=url.indexOf('//');var urlIndex=url.indexOf('/',doubleSlashIndex+2);var rootUrl=url.substring(urlIndex);return rootUrl;}return url;}if(typeof window!='undefined'){window.getImageFieldUrl=getImageFieldUrl;}function getContrastColor(bgColor){var backgroundColor=bgColor.charAt(0)==='#'?bgColor.substring(1,7):bgColor;var r=parseInt(backgroundColor.substr(0,2),16);var g=parseInt(backgroundColor.substr(2,2),16);var b=parseInt(backgroundColor.substr(4,2),16);var brightness=(r*299+g*587+b*114)/1000;return brightness<128?"#ffffff":"#000000";}function getLookupListView(refObjectConfig){if(!refObjectConfig){return null;}var listNameAll="all";var listNameLookup="lookup";var listViewAll,listViewLookup;_.each(refObjectConfig.list_views,function(view,name){if(name===listNameAll){listViewAll=view;if(!listViewAll.name){listViewAll.name=name;}}else if(name===listNameLookup){listViewLookup=view;if(!listViewLookup.name){listViewLookup.name=name;}}});var listView=listViewLookup||listViewAll;return listView;}/**
|
|
46
46
|
* 获取可比较的amis版本号
|
|
47
47
|
* @returns 只返回前两位版本,第三位忽略,比如3.6.3返回3.6
|
|
48
|
-
*/function getComparableAmisVersion(){var amis=window.amisRequire&&window.amisRequire('amis')||window.Amis;var amisVersion=amis&&amis.version;if(amisVersion){var comparableVersions=amisVersion.split(".");var comparableVersion=parseFloat(comparableVersions[0].toString()+"."+comparableVersions[1].toString());return comparableVersion;}}
|
|
48
|
+
*/function getComparableAmisVersion(){var amis=window.amisRequire&&window.amisRequire('amis')||window.Amis;var amisVersion=amis&&amis.version;if(amisVersion){var comparableVersions=amisVersion.split(".");var comparableVersion=parseFloat(comparableVersions[0].toString()+"."+comparableVersions[1].toString());return comparableVersion;}}/**
|
|
49
|
+
* 判断浏览器类型
|
|
50
|
+
* @returns 按需返回浏览器类型;
|
|
51
|
+
*/function getBowserType(){var userAgent=navigator.userAgent;if(userAgent.indexOf("Chrome")!==-1&&userAgent.indexOf("Safari")!==-1&&userAgent.indexOf("Edg")===-1){return"Chrome";}else if(userAgent.indexOf("Firefox")!==-1){return"Firefox";}else if(userAgent.indexOf("Safari")!==-1&&userAgent.indexOf("Chrome")===-1&&userAgent.indexOf("Edge")===-1){return"Safari";}else if(userAgent.indexOf("Edg")!==-1){return"Edge";}else{return"Unknown browser";// 其他浏览器...(可根据自己需要确定是否新增其他浏览器的判断)
|
|
52
|
+
}}/*
|
|
49
53
|
* @Author: baozhoutao@steedos.com
|
|
50
54
|
* @Date: 2022-05-23 09:53:08
|
|
51
55
|
* @LastEditors: liaodaxue
|
|
@@ -92,7 +96,7 @@ TempDisplayField="";quickEditSchema.body[0].onEvent={};quickEditOnEvent=function
|
|
|
92
96
|
第一种是减少选项时(判断新的数据是否比老的数据短),按照index删除_display中对应选项,保证回显没问题;
|
|
93
97
|
第二种是增加选项时,按照value的值,找到对应选项,并按照_display的规则为其赋值
|
|
94
98
|
*/TempDisplayField="\n const preData = _.cloneDeep(event.data.__super.".concat(field.name,");\n if(preData && event.data.").concat(field.name,".length < preData.length){\n let deletedIndex;\n preData.forEach(function(item,index){\n if(_.indexOf(event.data.").concat(field.name,", item) == -1) _display[\"").concat(field.name,"\"].splice(index, 1);\n })\n }else{\n _display[\"").concat(field.name,"\"] = [];\n event.data.value.forEach(function(val,index){\n const item = _.find(event.data.selectedItems, { ").concat(valueField,": val });\n _display[\"").concat(field.name,"\"].push(\n {\n \"label\": item.").concat(labelField,",\n \"value\": item[event.data.uiSchema.idFieldName],\n \"objectName\": \"").concat(field.reference_to,"\"\n }\n )\n })\n }\n \n ");}else{TempDisplayField="\n if(event.data.value){\n _display[\"".concat(field.name,"\"] = {\n \"label\": event.data.selectedItems.").concat(labelField,",\n \"value\": event.data.selectedItems[event.data.uiSchema.idFieldName],\n \"objectName\": \"").concat(field.reference_to,"\"\n }\n }else{\n _display[\"").concat(field.name,"\"] = {}\n }\n ");}quickEditSchema.body[0].onEvent["change"]=quickEditOnEvent(TempDisplayField);return _context55.abrupt("break",53);case 25:TempDisplayField="\n _display[\"".concat(field.name,"\"] = event.data.selectedItems.label;\n ");quickEditSchema.body[0].onEvent["change"]=quickEditOnEvent(TempDisplayField);return _context55.abrupt("break",53);case 28:TempDisplayField="\n _display[\"".concat(field.name,"\"] = event.data.value.toFixed(").concat(field.scale,") + '%';\n ");quickEditSchema.body[0].onEvent["change"]=quickEditOnEvent(TempDisplayField);return _context55.abrupt("break",53);case 31:TempDisplayField="\n _display[\"".concat(field.name,"\"] = moment(event.data.value).utc().format('HH:mm');\n ");quickEditSchema.body[0].onEvent["change"]=quickEditOnEvent(TempDisplayField);return _context55.abrupt("break",53);case 34:TempDisplayField="\n _display[\"".concat(field.name,"\"] = moment(event.data.value).utc().format('YYYY-MM-DD');\n ");quickEditSchema.body[0].onEvent["change"]=quickEditOnEvent(TempDisplayField);return _context55.abrupt("break",53);case 37:TempDisplayField="\n _display[\"".concat(field.name,"\"] = moment(event.data.value).format('YYYY-MM-DD HH:mm');\n ");quickEditSchema.body[0].onEvent["change"]=quickEditOnEvent(TempDisplayField);return _context55.abrupt("break",53);case 40:TempDisplayField="\n _display[\"".concat(field.name,"\"] = event.data.value?\"\u221A\":\"\";\n ");quickEditSchema.body[0].onEvent["change"]=quickEditOnEvent(TempDisplayField);return _context55.abrupt("break",53);case 43:TempDisplayField="\n _display[\"".concat(field.name,"\"] = event.data.value && event.data.value.toFixed(").concat(field.scale,");\n ");quickEditSchema.body[0].onEvent["change"]=quickEditOnEvent(TempDisplayField);return _context55.abrupt("break",53);case 46:removeDisplayField="";if(field.multiple){TempDisplayField="\n _display[\"".concat(field.name,"\"].push({\n \"name\": event.data.result.name,\n \"url\": event.data.result.url,\n \"type\": event.data.item.type,\n \"size\": event.data.item.size\n });\n ");removeDisplayField="\n _.remove(_display[\"".concat(field.name,"\"], function(file){return file.url == event.data.item.url});\n ");}else{TempDisplayField=" \n _display[\"".concat(field.name,"\"] = {\n \"name\": event.data.result.name,\n \"url\": event.data.result.url,\n \"type\": event.data.item.type,\n \"size\": event.data.item.size\n };\n ");removeDisplayField="\n if(_display[\"".concat(field.name,"\"].url == event.data.item.url){\n _display[\"").concat(field.name,"\"] = {};\n }\n ");}quickEditSchema.body[0].onEvent["success"]=quickEditOnEvent(TempDisplayField);quickEditSchema.body[0].onEvent["remove"]=quickEditOnEvent(removeDisplayField);return _context55.abrupt("break",53);case 51:quickEditSchema.body[0].receiver.adaptor="\n const superData = (typeof context != 'undefined') ? context : api.body; \n const { context:pageContext } = superData; \n var rootUrl = pageContext.rootUrl + \"/api/files/".concat(field.type,"s/\";\n payload = {\n status: response.status == 200 ? 0 : response.status,\n msg: response.statusText,\n data: {\n value: rootUrl + payload._id,//\u4E3A\u4E86\u5B9E\u73B0\u56FE\u7247crud\u7684\u56DE\u663E\uFF0C\u9700\u8981\u5C06value\u4ECEid\u6539\u4E3Aurl\uFF0C\u5F53\u4FDD\u5B58\u6570\u636E\u6570\u636E\u65F6\uFF0C\u518D\u5728\u53D1\u9001\u9002\u914D\u5668\u5185\u91CD\u65B0\u5C06id\u63D0\u53D6\u51FA\u6765\n name: payload.original.name,\n url: rootUrl + payload._id,\n }\n }\n return payload;\n ");return _context55.abrupt("break",53);case 53:quickEditSchema.body[0].visibleOn="${quickedit_record_permissions.allowEdit && quickedit_record_permissions_loading == false}";quickEditSchema.body.push({"type":"service","body":[{"type":"tpl","tpl":i18next__default["default"].t('frontend_records_no_allowedit'),"visibleOn":"${!quickedit_record_permissions.allowEdit && quickedit_record_permissions_loading == false}"},{"type":"spinner","showOn":"${quickedit_record_permissions_loading}"}],"onEvent":{"init":{"actions":[//amis3.6无法从数据域中直接拿到正确的selectitems,需要通过crud组件的getSelected()函数获取
|
|
95
|
-
{"actionType":"custom","script":"\n crudScoped = event.context.scoped.getComponentById('".concat(options.crudId,"');\n const selectedItems = crudScoped && crudScoped.control.getSelected();\n doAction({\n \"componentId\": \"").concat(quickEditId,"\",\n \"actionType\": \"setValue\",\n \"args\": {\n \"value\": {\n selectedItems\n }\n }\n });\n ")},{"actionType":"setValue","componentId":quickEditId,"args":{"value":{"quickedit_record_permissions_loading":true}}},{"actionType":"ajax","args":{"api":{"url":"${context.rootUrl}/service/api/@\${objectName}/recordPermissions/${_id}","method":"get","headers":{"Authorization":"Bearer ${context.tenantId},${context.authToken}"},"cache":30000,"messages":{"failed":"失败了呢。。"}}}},{"actionType":"setValue","componentId":quickEditId,"args":{"value":{"quickedit_record_permissions_loading":false}}},{"actionType":"setValue","componentId":quickEditId,"args":{"value":{"quickedit_record_permissions":"${event.data}"}}}]}}});if(field.type!='avatar'&&field.type!='image'&&field.type!='file'&&isAmisVersionforBatchEdit){quickEditSchema.body.push({"name":"isBatchEdit","type":"checkbox","option":[{"type":"tpl","tpl":"更新${COUNT(selectedItems)}个选定记录"},{"type":"spinner","showOn":"${batchPermissionLoading}","size":"sm","className":"mr-4"}],"visibleOn":"${ARRAYSOME(selectedItems, item => item._id === _id) && COUNT(selectedItems)>1 && quickedit_record_permissions.allowEdit && quickedit_record_permissions_loading == false}","disabledOn":"${batchPermissionLoading}","onEvent":{"change":{"actions":[{"actionType":"setValue","componentId":quickEditId,"args":{"value":{"batchPermissionLoading":true}},"expression":"${event.data.value}"},{"actionType":"ajax","args":{"api":{"url":"${context.rootUrl}/graphql","method":"post","headers":{"Authorization":"Bearer ${context.tenantId},${context.authToken}"},"data":{"query":"{rows:${objectName}(filters:[\"_id\",\"in\",${selectedItems | pick:_id | split | json}]){_id,_permissions{allowEdit}}}"},"adaptor":"\n const noPermission = [];\n payload.data.rows.forEach(function (row) {\n if(!row._permissions.allowEdit){\n noPermission.push(row._id);\n }\n })\n payload.data.noPermission = noPermission;\n return payload;\n "}},"expression":"${event.data.value}"},{"actionType":"setValue","componentId":quickEditId,"args":{"value":{"batchPermissionLoading":false}},"expression":"${event.data.value}"},{"actionType":"dialog","dialog":{"title":"记录权限","showCloseButton":false,"body":[{"type":"tpl","tpl":"当前选中记录中,有${COUNT(noPermission)}条记录无编辑权限,是否需要批量编辑其他记录?"}],"onEvent":{"confirm":{"actions":[{"actionType":"custom","script":"\n const noPermission = event.data.noPermission;\n const crudComponent = event.context.scoped.getComponentById(\"".concat(options.crudId,"\");\n
|
|
99
|
+
{"actionType":"custom","script":"\n crudScoped = event.context.scoped.getComponentById('".concat(options.crudId,"');\n const selectedItems = crudScoped && crudScoped.control.getSelected();\n doAction({\n \"componentId\": \"").concat(quickEditId,"\",\n \"actionType\": \"setValue\",\n \"args\": {\n \"value\": {\n selectedItems\n }\n }\n });\n ")},{"actionType":"setValue","componentId":quickEditId,"args":{"value":{"quickedit_record_permissions_loading":true}}},{"actionType":"ajax","args":{"api":{"url":"${context.rootUrl}/service/api/@\${objectName}/recordPermissions/${_id}","method":"get","headers":{"Authorization":"Bearer ${context.tenantId},${context.authToken}"},"cache":30000,"messages":{"failed":"失败了呢。。"}}},"expression":"${!recordPermissions.modifyAllRecords}"},{"actionType":"setValue","componentId":quickEditId,"args":{"value":{"quickedit_record_permissions_loading":false}}},{"actionType":"setValue","componentId":quickEditId,"args":{"value":{"quickedit_record_permissions":"${recordPermissions.modifyAllRecords ? {'allowEdit': true} : event.data}"}}}]}}});if(field.type!='avatar'&&field.type!='image'&&field.type!='file'&&isAmisVersionforBatchEdit){quickEditSchema.body.push({"name":"isBatchEdit","type":"checkbox","option":[{"type":"tpl","tpl":"更新${COUNT(selectedItems)}个选定记录"},{"type":"spinner","showOn":"${batchPermissionLoading}","size":"sm","className":"mr-4"}],"visibleOn":"${ARRAYSOME(selectedItems, item => item._id === _id) && COUNT(selectedItems)>1 && quickedit_record_permissions.allowEdit && quickedit_record_permissions_loading == false}","disabledOn":"${batchPermissionLoading}","onEvent":{"change":{"actions":[{"actionType":"setValue","componentId":quickEditId,"args":{"value":{"batchPermissionLoading":true}},"expression":"${event.data.value}"},{"actionType":"ajax","args":{"api":{"url":"${context.rootUrl}/graphql","method":"post","headers":{"Authorization":"Bearer ${context.tenantId},${context.authToken}"},"data":{"query":"{rows:${objectName}(filters:[\"_id\",\"in\",${selectedItems | pick:_id | split | json}]){_id,_permissions{allowEdit}}}"},"adaptor":"\n const noPermission = [];\n payload.data.rows.forEach(function (row) {\n if(!row._permissions.allowEdit){\n noPermission.push(row._id);\n }\n })\n payload.data.noPermission = noPermission;\n return payload;\n "}},"expression":"${event.data.value && !recordPermissions.modifyAllRecords}"},{"actionType":"setValue","componentId":quickEditId,"args":{"value":{"batchPermissionLoading":false}},"expression":"${event.data.value}"},{"actionType":"dialog","dialog":{"title":"记录权限","showCloseButton":false,"body":[{"type":"tpl","tpl":"当前选中记录中,有${COUNT(noPermission)}条记录无编辑权限,是否需要批量编辑其他记录?"}],"onEvent":{"confirm":{"actions":[{"actionType":"custom","script":"\n const noPermission = event.data.noPermission;\n const crudComponent = event.context.scoped.getComponentById(\"".concat(options.crudId,"\");\n let selectedItems = crudComponent && crudComponent.props.store.selectedItems.concat();\n noPermission.forEach(function (item) {\n crudComponent && crudComponent.unSelectItem(_.find(selectedItems,{_id:item}));\n _.remove(selectedItems, (selected) => selected._id === item);\n })\n doAction({\n \"componentId\": \"").concat(quickEditId,"\",\n \"actionType\": \"setValue\",\n \"args\": {\n \"value\": {\n selectedItems\n }\n }\n });\n ")},{"actionType":"setValue","componentId":quickEditId,"args":{"value":{"isBatchEdit":true}}}]},"cancel":{"actions":[{"actionType":"setValue","componentId":quickEditId,"args":{"value":{"isBatchEdit":false}}}]}}},"expression":"${COUNT(event.data.noPermission)>0}"}]}}});}_context55.next=59;break;case 58:quickEditSchema=false;case 59://amis3.2以下禁用lookup的单元格编辑
|
|
96
100
|
if(field.type=="lookup"&&!isAmisVersionforBatchEdit){quickEditSchema=false;}//TODO:附件多选时会覆盖老数据,暂时禁用
|
|
97
101
|
if(field.type=="file"&&field.multiple){quickEditSchema=false;}//TODO:location字段在列表中快速编辑后存在bug,保存时可能会丢失部分数据,暂时禁用
|
|
98
102
|
if(field.type=="location"){quickEditSchema=false;}if(field.type=="color"){quickEditSchema={type:"input-color"};}case 63:return _context55.abrupt("return",quickEditSchema);case 64:case"end":return _context55.stop();}}},_callee55);}));return _getQuickEditSchema.apply(this,arguments);}function getFieldWidth(width){var defaultWidth=null;if(typeof width=='string'){if(isNaN(width)){return width||defaultWidth;}else{return Number(width)||defaultWidth;}}else if(typeof width=='number'){return width;}else{return defaultWidth;}}function getTableColumns(_x19,_x20){return _getTableColumns.apply(this,arguments);}/**
|
|
@@ -112,22 +116,22 @@ if(field.type=="location"){quickEditSchema=false;}if(field.type=="color"){quickE
|
|
|
112
116
|
"size": "none",
|
|
113
117
|
"className": "flex items-center justify-between"//每行样式类
|
|
114
118
|
}
|
|
115
|
-
*/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,
|
|
119
|
+
*/function _getTableColumns(){_getTableColumns=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee56(fields,options){var _options$permissions;var columns,allowEdit,_iterator6,_step7,_field$amis,_field$amis2,field,quickEditSchema,className,bowserType,fieldAmis,columnItem,previewFileScript,map,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=53;break;}field=_step7.value;if(!(field.hidden||field.extra)){_context56.next=10;break;}return _context56.abrupt("continue",51);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="";bowserType=getBowserType();if(bowserType==="Safari"){className+=" whitespace-nowrap ";}else{if(field.wrap!=true){className+=" whitespace-nowrap ";}else{className+=" break-words ";}}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," ");}fieldAmis=___namespace.clone(field.amis);fieldAmis===null||fieldAmis===void 0?true:delete fieldAmis.className;columnItem=void 0;if(!((field.is_name||field.name===options.labelFieldName)&&options.objectName==='cms_files')){_context56.next=30;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"//浏览器上直接下载
|
|
116
120
|
"expression":"!!!(window && window.nw && window.nw.require)"//浏览器上直接下载
|
|
117
121
|
},{"args":{},"actionType":"custom","script":previewFileScript,// "expression": "!!window?.nw?.require" //PC客户端预览附件
|
|
118
122
|
"expression":"!!!(window && window.nw && window.nw.require)"//PC客户端预览附件
|
|
119
|
-
}]}}};_context56.next=
|
|
123
|
+
}]}}};_context56.next=50;break;case 30:if(!(field.type==='toggle')){_context56.next=34;break;}columnItem=Object.assign({},{type:"switch",name:field.name,label:field.label,width:getFieldWidth(field.width),toggled:field.toggled,"static":true,className:className},fieldAmis,{name:field.name});_context56.next=50;break;case 34:if(!(field.type==='avatar'||field.type==='image'||field.type==='file')){_context56.next=38;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)),fieldAmis,{name:field.name});_context56.next=50;break;case 38:if(!(field.type==='select')){_context56.next=43;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},fieldAmis,{name:field.name});_context56.next=50;break;case 43:_context56.next=45;return getFieldTpl(field,options);case 45: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'){
|
|
120
124
|
// className += 'date-min-w';
|
|
121
125
|
// }
|
|
122
126
|
// if(field.type === 'datetime'){
|
|
123
127
|
// className += 'datetime-min-w';
|
|
124
128
|
// }
|
|
125
129
|
//field上的amis属性里的clssname需要单独判断类型合并
|
|
126
|
-
if(
|
|
130
|
+
if(!field.hidden&&!field.extra){columnItem=Object.assign({},{name:field.name,label:field.label,sortable:field.sortable,// searchable: field.searchable,
|
|
127
131
|
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
|
|
128
|
-
},
|
|
132
|
+
},fieldAmis,{name:field.name});if(field.type==='color'){columnItem.type='color';columnItem.defaultColor=null;}}case 50: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 51:_context56.next=6;break;case 53:_context56.next=58;break;case 55:_context56.prev=55;_context56.t1=_context56["catch"](4);_iterator6.e(_context56.t1);case 58:_context56.prev=58;_iterator6.f();return _context56.finish(58);case 61:// columns.push(getOperation(fields));
|
|
129
133
|
if(!options.isLookup&&!options.isInputTable&&!___namespace.some(columns,{name:options.labelFieldName})){// 没有名称字段时显示序号字段为链接,lookup弹出的picker不需要此功能
|
|
130
|
-
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
|
|
134
|
+
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 63:case"end":return _context56.stop();}}},_callee56,null,[[4,55,58,61]]);}));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){// 左侧半行
|
|
131
135
|
lineChildrenClassName="steedos-listview-item-left truncate h-5";if(item.field.is_wide){// 左侧全行样式可以单独写,如果需要配置两行省略号效果,可以加样式类 two-lines-truncate
|
|
132
136
|
lineChildrenClassName="steedos-listview-item-wide";}if(lines.length===0){// 第一个字段加粗黑色显示
|
|
133
137
|
lineChildrenClassName+=" font-bold text-gray-800";}}else{// 右侧半行,这里加样式类 flex flex-shrink-0,是为了省略号只显示在左半行,右半行文字一般比较短,如果也加省略号效果的话,左侧文字多的话,右侧没几个字就显示省略号了
|
|
@@ -528,12 +532,12 @@ recordPermissions:objectSchema.permissions,uiSchema:objectSchema// loaded: false
|
|
|
528
532
|
});body=null;id="listview_".concat(objectSchema.name);if(!(options.formFactor==='SMALL'&&false)){_context81.next=42;break;}delete bodyProps.bulkActions;delete bodyProps.headerToolbar;delete bodyProps.footerToolbar;_context81.next=27;return getCardSchema(fields,Object.assign({idFieldName:objectSchema.idFieldName,labelFieldName:objectSchema.NAME_FIELD_KEY||'name'},options,{actions:false}));case 27:card=_context81.sent;_context81.t3=Object;_context81.t4={};_context81.t5=card;_context81.t6=id;_context81.t7=id;_context81.next=35;return getTableApi(objectSchema,fields,options);case 35:_context81.t8=_context81.sent;_context81.t9=options.tableHiddenOn;_context81.t10={type:'crud',primaryField:'_id',id:_context81.t6,name:_context81.t7,keepItemSelectionOnPageChange:false,api:_context81.t8,hiddenOn:_context81.t9};_context81.t11=bodyProps;body=_context81.t3.assign.call(_context81.t3,_context81.t4,_context81.t5,_context81.t10,_context81.t11);_context81.next=71;break;case 42:labelFieldName=objectSchema.NAME_FIELD_KEY||'name';// organizations 对象的历史遗留问题, fullname 被标记为了 名称字段. 在此处特殊处理.
|
|
529
533
|
if(objectSchema.name==='organizations'){labelFieldName='name';}tableOptions=Object.assign({idFieldName:objectSchema.idFieldName,labelFieldName:labelFieldName,permissions:objectSchema.permissions,enable_inline_edit:objectSchema.enable_inline_edit,crudId:listSchema.id||id,enable_tree:objectSchema.enable_tree},options);tableOptions.amisData=createObject(options.amisData||{},{});_context81.next=48;return getTableSchema$1(fields,tableOptions);case 48:table=_context81.sent;// delete table.mode;
|
|
530
534
|
//image与avatar需要在提交修改时特别处理
|
|
531
|
-
imageNames=___default["default"].compact(___default["default"].map(___default["default"].filter(fields,function(field){return["image","avatar"].includes(field.type);}),'name'));quickSaveApiRequestAdaptor="\n var graphqlOrder = \"\";\n var imageNames = ".concat(JSON.stringify(imageNames),";\n const rowsDiff = _.cloneDeep(api.data.rowsDiff);\n rowsDiff.forEach(function (item, index) {\n for(key in item){\n // image\u3001select\u7B49\u5B57\u6BB5\u6E05\u7A7A\u503C\u540E\u4FDD\u5B58\u7684\u7A7A\u5B57\u7B26\u4E32\u8F6C\u6362\u4E3Anull\u3002\n if(item[key] === ''){\n item[key] = null;\n }\n if(_.includes(imageNames, key)){\n if(typeof item[key] == \"string\"){\n const match = item[key].match(/\\/([^\\/]+)$/);\n item[key] = match && match.length > 1?match[1]:\"\";\n }else{\n item[key] = _.map(item[key], function(ele){\n const match = ele.match(/\\/([^\\/]+)$/);\n return match && match.length > 1?match[1]:\"\";\n })\n }\n }\n }\n item = _.omit(item, '_display');\n const itemOrder = 'update' + index + ':' + api.data.objectName + '__update(id:\"' + item._id + '\", doc:' + JSON.stringify(JSON.stringify(_.omit(item, '_id'))) + ') {_id}';\n graphqlOrder += itemOrder;\n })\n graphqlOrder = 'mutation {' + graphqlOrder + '}';\n return {\n ...api,\n data: {\n query: graphqlOrder\n }\n }\n ");autoFillHeight=true;if(options.isRelated||window.innerWidth<768){autoFillHeight=false;}_context81.t12=Object;_context81.t13={};_context81.t14=table;_context81.t15=id;_context81.t16=id;_context81.next=60;return getTableApi(objectSchema,fields,options);case 60:_context81.t17=_context81.sent;_context81.t18=options.tableHiddenOn;_context81.t19=autoFillHeight;_context81.t20="flex-auto ".concat(crudClassName||"");_context81.t21={"mb-0":true,"is-steedos-crud-data-empty":"${!items || COUNT(items) == 0}"};_context81.t22=crudClassName;_context81.t23={url:"${context.rootUrl}/graphql",method:"post",dataType:"json",headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"},requestAdaptor:quickSaveApiRequestAdaptor
|
|
535
|
+
imageNames=___default["default"].compact(___default["default"].map(___default["default"].filter(fields,function(field){return["image","avatar"].includes(field.type);}),'name'));quickSaveApiRequestAdaptor="\n var graphqlOrder = \"\";\n var imageNames = ".concat(JSON.stringify(imageNames),";\n const rowsDiff = _.cloneDeep(api.data.rowsDiff);\n rowsDiff.forEach(function (item, index) {\n for(key in item){\n // image\u3001select\u7B49\u5B57\u6BB5\u6E05\u7A7A\u503C\u540E\u4FDD\u5B58\u7684\u7A7A\u5B57\u7B26\u4E32\u8F6C\u6362\u4E3Anull\u3002\n if(item[key] === ''){\n item[key] = null;\n }\n if(_.includes(imageNames, key)){\n if(typeof item[key] == \"string\"){\n const match = item[key].match(/\\/([^\\/]+)$/);\n item[key] = match && match.length > 1?match[1]:\"\";\n }else{\n item[key] = _.map(item[key], function(ele){\n const match = ele.match(/\\/([^\\/]+)$/);\n return match && match.length > 1?match[1]:\"\";\n })\n }\n }\n }\n item = _.omit(item, '_display');\n const itemOrder = 'update' + index + ':' + api.data.objectName + '__update(id:\"' + item._id + '\", doc:' + JSON.stringify(JSON.stringify(_.omit(item, '_id'))) + ') {_id}';\n graphqlOrder += itemOrder;\n })\n graphqlOrder = 'mutation {' + graphqlOrder + '}';\n return {\n ...api,\n data: {\n query: graphqlOrder\n }\n }\n ");autoFillHeight=true;if(options.isRelated||window.innerWidth<768){autoFillHeight=false;}_context81.t12=Object;_context81.t13={};_context81.t14=table;_context81.t15=id;_context81.t16=id;_context81.next=60;return getTableApi(objectSchema,fields,options);case 60:_context81.t17=_context81.sent;_context81.t18=options.tableHiddenOn;_context81.t19=autoFillHeight;_context81.t20="flex-auto ".concat(crudClassName||"");_context81.t21={"mb-0":true,"is-steedos-crud-data-empty":"${!items || COUNT(items) == 0}"};_context81.t22=crudClassName;_context81.t23={url:"${context.rootUrl}/graphql",method:"post",dataType:"json",headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"},requestAdaptor:quickSaveApiRequestAdaptor};_context81.t24=options.rowClassNameExpr||"<%= data._id === data.recordId ? 'steedos-record-tr steedos-record-tr-' + data._id + ' steedos-record-selected' : 'steedos-record-tr steedos-record-tr-' + data._id %>";_context81.t25={type:'crud',primaryField:'_id',affixHeader:false,id:_context81.t15,name:_context81.t16,keepItemSelectionOnPageChange:true,api:_context81.t17,hiddenOn:_context81.t18,autoFillHeight:_context81.t19,className:_context81.t20,bodyClassName:_context81.t21,crudClassName:_context81.t22,quickSaveApi:_context81.t23,rowClassNameExpr:_context81.t24};_context81.t26=bodyProps;body=_context81.t12.assign.call(_context81.t12,_context81.t13,_context81.t14,_context81.t25,_context81.t26);case 71:body=defaultsDeep({},listSchema,body);_context81.next=74;return getCrudSchemaWithDataFilter(body,{crudDataFilter:crudDataFilter,onCrudDataFilter:onCrudDataFilter,amisData:amisData,env:env});case 74:body=_context81.sent;crudModeClassName="";if(body.mode){crudModeClassName="steedos-crud-mode-".concat(body.mode);}body.quickSaveApi.adaptor="\n if(payload.errors){\n payload.status = 2;\n payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;\n }\n debugger;\n var scope = SteedosUI.getRef(context.scopeId);\n var scopeParent = scope && scope.parent;\n var crudScoped = scopeParent.getComponentById('".concat(body.id,"');\n setTimeout(()=>{\n crudScoped && crudScoped.control.updateAutoFillHeight();\n }, 500);\n return payload;\n ");if(body.columns&&options.formFactor!='SMALL'){//将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
532
536
|
body.columns.splice(body.columns.length-1,0,{name:'_display',type:'static',width:1,placeholder:"",id:objectSchema.name+"_display_${_index}",tpl:"${''}"});}if(defaults){headerSchema=defaults.headerSchema;footerSchema=defaults.footerSchema;if(headerSchema||footerSchema){wrappedBody=[body];if(headerSchema){if(___default["default"].isArray(headerSchema)){wrappedBody=___default["default"].union(headerSchema,wrappedBody);}else{wrappedBody.unshift(headerSchema);}}if(footerSchema){if(___default["default"].isArray(footerSchema)){wrappedBody=___default["default"].union(wrappedBody,footerSchema);}else{wrappedBody.push(footerSchema);}}body=wrappedBody;}}// console.timeEnd('getObjectCRUD');
|
|
533
537
|
// TODO: data应该只留loaded,其他属性都改为从上层传递下来
|
|
534
538
|
return _context81.abrupt("return",{type:'service',className:crudModeClassName,//目前crud的service层id不认用户自定义id,只支持默认规则id,许多地方的格式都写死了service_listview_${objectname}
|
|
535
539
|
id:"service_".concat(id),name:"page",data:options.amisData,body:body,//监听广播事件,重算crud高度
|
|
536
|
-
onEvent:_defineProperty({},"@height.changed.".concat(objectSchema.name),{"actions":[{"actionType":"custom","script":"\n var crudScoped = event.context.scoped.getComponentById('".concat(body.id,"');\n var timeOut = event.data.timeOut || 500;\n setTimeout(()=>{\n crudScoped && crudScoped.control.updateAutoFillHeight();\n }, timeOut);\n ")}]})});case
|
|
540
|
+
onEvent:_defineProperty({},"@height.changed.".concat(objectSchema.name),{"actions":[{"actionType":"custom","script":"\n var crudScoped = event.context.scoped.getComponentById('".concat(body.id,"');\n var timeOut = event.data.timeOut || 500;\n setTimeout(()=>{\n crudScoped && crudScoped.control.updateAutoFillHeight();\n }, timeOut);\n ")}]})});case 81:case"end":return _context81.stop();}}},_callee81);}));return _getObjectCRUD.apply(this,arguments);}var getFormFields$1=function getFormFields$1(objectSchema,formProps){/**
|
|
537
541
|
* fieldsExtend: 重写字段定义
|
|
538
542
|
* fields: 包含的字段
|
|
539
543
|
* excludedFields: 排除的字段
|
|
@@ -899,7 +903,7 @@ sectionFieldsVisibleOn=___namespace.map(___namespace.compact(___namespace.map(fi
|
|
|
899
903
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
900
904
|
* @Date: 2023-11-15 09:50:22
|
|
901
905
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
902
|
-
* @LastEditTime: 2024-01-
|
|
906
|
+
* @LastEditTime: 2024-01-25 14:11:50
|
|
903
907
|
*/function getTablePrimaryKey(props){return props.primaryKey||"_id";}/**
|
|
904
908
|
* 子表组件字段值中每行数据的补上唯一标识字段值,其值为随机uuid
|
|
905
909
|
* @param {*} value 子表组件字段值,数组
|
|
@@ -931,7 +935,8 @@ var newItemValue=_$1.clone(itemValue);if(newItemValue.children){newItemValue.chi
|
|
|
931
935
|
newItem.name=newItem.name.replace(new RegExp("^".concat(fieldPrefix)),"");return newItem;});}/**
|
|
932
936
|
* @param {*} props
|
|
933
937
|
* @param {*} mode edit/new/readonly
|
|
934
|
-
*/function getFormFields(props){var mode=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"edit";var fieldPrefix=props.fieldPrefix;var fields=props.fields||[];if(fieldPrefix){fields=getTableFieldsWithoutFieldPrefix(fields,fieldPrefix);}return(fields||[]).map(function(item){var formItem={"type":"steedos-field","name":item.name,"config":item};if(mode==="readonly"){formItem["static"]=true;}return formItem;})||[];}function getInputTableCell(field,showAsInlineEditMode){if(showAsInlineEditMode){return{label:field.label,name:field.name,quickEdit:{"type":"steedos-field","mode":"inline","config":Object.assign({},field,{label:false})}};}else{
|
|
938
|
+
*/function getFormFields(props){var mode=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"edit";var fieldPrefix=props.fieldPrefix;var fields=props.fields||[];if(fieldPrefix){fields=getTableFieldsWithoutFieldPrefix(fields,fieldPrefix);}return(fields||[]).map(function(item){var formItem={"type":"steedos-field","name":item.name,"config":item};if(mode==="readonly"){formItem["static"]=true;}return formItem;})||[];}function getInputTableCell(field,showAsInlineEditMode){if(showAsInlineEditMode){return{label:field.label,name:field.name,quickEdit:{"type":"steedos-field","mode":"inline","config":Object.assign({},field,{label:false})}};}else{// 这里加一层service是因为amis 3.6/6.0中有bug,不加的话,这里会显示为父作用域中中的同名变量值,见:https://github.com/baidu/amis/issues/9520
|
|
939
|
+
return{"type":"service",label:field.label,name:field.name,"body":[{"type":"steedos-field","config":Object.assign({},field,{label:false}),inInputTable:true,"static":true,"readonly":true}]};}}function getComponentId(name,tag){var id="";switch(name){case"table_service":id="service_wrapper__".concat(tag);break;case"form_pagination":id="service_popup_pagination_wrapper__".concat(tag);break;case"form":id="form_popup__".concat(tag);break;case"dialog":id="dialog_popup__".concat(tag);break;default:id="".concat(name,"__").concat(tag);break;}return id;}/**
|
|
935
940
|
* @param {*} props
|
|
936
941
|
* @param {*} mode edit/new/readonly
|
|
937
942
|
*/function getInputTableColumns(_x218){return _getInputTableColumns.apply(this,arguments);}/**
|
|
@@ -1156,7 +1161,11 @@ value=getTableValueWithPrimaryKeyValue(value,primaryKey);}else{// 默认情况
|
|
|
1156
1161
|
// 需要注意如果没有配置autoGeneratePrimaryKey时,因为每次弹出行编辑窗口保存后都会先后进入pipeOut和pipeIn,
|
|
1157
1162
|
// 这里删除掉了primaryKey值,所以primaryKey值每次弹出编辑窗口保存后都会给每行重新生成新的primaryKey值
|
|
1158
1163
|
// 只有autoGeneratePrimaryKey配置为true时,每行的primaryKey字段值才会始终保持不变
|
|
1159
|
-
value=getTableValueWithoutPrimaryKeyValue(value,primaryKey);}if(amis.pipeOut){if(typeof amis.pipeOut==='function'){return amis.pipeOut(value,data);}}return value;};inputTableSchema={"type":"input-table","mode":"normal","name":_context19.t0,"draggable":_context19.t1,"showIndex":_context19.t2,"perPage":_context19.t3,"id":_context19.t4,"columns":_context19.t5,"strictMode":_context19.t6,"showTableAddBtn":false,"showFooterAddBtn":false,"className":_context19.t7,"pipeIn":_context19.t8,"pipeOut":_context19.t9};if(buttonsForColumnOperations.length){inputTableSchema.columns.push({"name":"__op__","type":"operation","buttons":buttonsForColumnOperations,"width":buttonsForColumnOperations.length>1?"60px":"20px"});}if(
|
|
1164
|
+
value=getTableValueWithoutPrimaryKeyValue(value,primaryKey);}if(amis.pipeOut){if(typeof amis.pipeOut==='function'){return amis.pipeOut(value,data);}}return value;};inputTableSchema={"type":"input-table","mode":"normal","name":_context19.t0,"draggable":_context19.t1,"showIndex":_context19.t2,"perPage":_context19.t3,"id":_context19.t4,"columns":_context19.t5,"strictMode":_context19.t6,"showTableAddBtn":false,"showFooterAddBtn":false,"className":_context19.t7,"pipeIn":_context19.t8,"pipeOut":_context19.t9};if(buttonsForColumnOperations.length){inputTableSchema.columns.push({"name":"__op__","type":"operation","buttons":buttonsForColumnOperations,"width":buttonsForColumnOperations.length>1?"60px":"20px"});}// if (showAsInlineEditMode) {
|
|
1165
|
+
// // 因为要支持不同的列上配置inlineEditMode属性,所有不可以把整个子表组件都设置为inlineEditMode
|
|
1166
|
+
// inputTableSchema.needConfirm = false;
|
|
1167
|
+
// }
|
|
1168
|
+
if(amis){// 支持配置amis属性重写或添加最终生成的input-table中任何属性。
|
|
1160
1169
|
delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
|
|
1161
1170
|
delete amis.pipeIn;//该属性在上面合并过了
|
|
1162
1171
|
delete amis.pipeOut;//该属性在上面合并过了
|