@steedos-widgets/amis-lib 1.0.40 → 1.0.42
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 +70 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +95 -36
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +70 -11
- package/dist/index.umd.js.map +1 -1
- package/dist/types/workflow/approve.d.ts +1 -0
- package/dist/types/workflow/flow.d.ts +1 -0
- package/dist/types/workflow/instance.d.ts +2 -0
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import*as _$1 from"lodash";import ___default,{isEmpty,isArray,each,find,endsWith,cloneDeep,includes,get,map,keys,sortBy,compact,toArray,mergeWith,isBoolean,omitBy,isNil,isString,slice,defaultsDeep as defaultsDeep$1,isObject as isObject$1,has,filter,startsWith}from"lodash";import isPlainObject from"lodash/isPlainObject";import{Router as Router$1,getSteedosAuth as getSteedosAuth$1,lookupToAmis as lookupToAmis$1,fetchAPI as fetchAPI$1}from"@steedos-widgets/amis-lib";const RegisterRenders=[],normalizeLink=(e,t=window.location)=>{(e=e||"")&&"#"===e[0]?e=t.pathname+t.search+e:e&&"?"===e[0]&&(e=t.pathname+e);var a=e.indexOf("?"),i=e.indexOf("#");let r=~a?e.substring(0,a):~i?e.substring(0,i):e;a=~a?e.substring(a,~i?i:void 0):"",e=~i?e.substring(i):t.hash;if(r){if("/"!=r[0]&&!/^https?\:\/\//.test(r)){var s,
|
|
1
|
+
import*as _$1 from"lodash";import ___default,{isEmpty,isArray,each,find,endsWith,cloneDeep,includes,get,map,keys,sortBy,compact,toArray,mergeWith,isBoolean,omitBy,isNil,isString,slice,defaultsDeep as defaultsDeep$1,isObject as isObject$1,has,filter,startsWith}from"lodash";import isPlainObject from"lodash/isPlainObject";import{Router as Router$1,getSteedosAuth as getSteedosAuth$1,lookupToAmis as lookupToAmis$1,fetchAPI as fetchAPI$1}from"@steedos-widgets/amis-lib";const RegisterRenders=[],normalizeLink=(e,t=window.location)=>{(e=e||"")&&"#"===e[0]?e=t.pathname+t.search+e:e&&"?"===e[0]&&(e=t.pathname+e);var a=e.indexOf("?"),i=e.indexOf("#");let r=~a?e.substring(0,a):~i?e.substring(0,i):e;a=~a?e.substring(a,~i?i:void 0):"",e=~i?e.substring(i):t.hash;if(r){if("/"!=r[0]&&!/^https?\:\/\//.test(r)){var s,o=t.pathname.split("/");for(o.pop();s=/^\.\.?\//.exec(r);)"../"===s[0]&&o.pop(),r=r.substring(s[0].length);r=o.concat(r).join("/")}}else r=t.pathname;return r+a+e},amisRootClick=(e,t)=>{"a"===t.target.nodeName.toLocaleLowerCase()&&t.target.href&&(t.preventDefault(),e.push(t.target.href))},getEvn=a=>({theme:"antd",notify:(e,t)=>{t.props?.schema.tpl?SteedosUI.message[e](t.props?.schema.tpl):"string"==typeof t?SteedosUI.message[e](t):console.warn("notify",e,t)},confirm:a=>new Promise((e,t)=>SteedosUI.Modal.confirm({title:a,onOk:()=>{e(!0)},okText:"确认",cancelText:"取消"})),jumpTo:(e,t)=>{if("goBack"===e)return window.history.back();e=normalizeLink(e),t&&"url"===t.actionType?!0===t.blank?window.open(e):a.push(e):t&&e&&t.target?window.open(e,t.target):/^https?:\/\//.test(e)?window.location.replace(e):a.push(e)}}),registerRenders=e=>{if(!isEmpty(e)&&isArray(e)){var t=amisRequire("amis");const a={renderer:t.Renderer,formitem:t.FormItem,options:t.OptionsControl};let o=amisRequire("react");each(e,t=>{if(!find(RegisterRenders,e=>e===t.componentName)){let s=Builder.components.find(e=>e.name===t.componentName),e=s.class;"amisSchema"===t.componentType&&(e=t=>{var{body:e,render:a}=t;const[i,r]=o.useState(null);return o.useEffect(()=>{var e=s.class(t);e&&e.then&&"function"==typeof e.then?e.then(e=>{r(e)}):r(e)},[]),o.createElement(o.Fragment,null,o.createElement(o.Fragment,null,i&&a?a("body",i):""),o.createElement(o.Fragment,null,a?a("body",e):""))}),a[t.usage]?(a[t.usage]({test:new RegExp("(^|/)"+t.type),type:t.type,weight:t.weight,autoVar:!0})(e),console.info("注册了一个自定义amis组件:",{type:t.type,weight:t.weight,component:e,framework:t.framework,usage:t.usage})):console.error(`${consoleTag}自定义组件注册失败,不存在${t.usage}自定义组件类型。`),RegisterRenders.push(t.componentName)}})}},amisRender=(e,t,a={},i={},r)=>{var s=amisRequire("amis/embed"),{router:r,assets:o}=r;return registerRenders(o),s.embed(e,t,a,Object.assign(getEvn(r),i))},STEEDOS_AUTH={},getBuilderContext=()=>"undefined"==typeof window?{}:Builder.settings.context||Builder.settings,setSteedosAuth=e=>{Object.assign(STEEDOS_AUTH,e)};async function fetchAPI(e,t={credentials:"include"}){var a={"Content-Type":"application/json"},i=getAuthorization(),i=(i&&(a.Authorization=i),t.headers=Object.assign({},a,t.headers),t.credentials="include",await fetch(""+getRootUrl()+e,t));if(401===i.status)throw new Error(401);a=await i.json();if(a.errors)throw console.error(a.errors),new Error("Failed to fetch API");return a}function getFileSrc(e){return getRootUrl()+"/api/files/files/"+e}function getImageSrc(e){return getRootUrl()+"/api/files/images/"+e}function getTenantId(){try{let e=getBuilderContext().tenantId;var t;return(window.location.search&&!e&&(t=new URLSearchParams(window.location.search),e=t.get("X-Space-Id")),e)?e:null}catch(e){console.error(e)}}function getAuthToken(){try{var e=getBuilderContext().authToken;return e?e:null}catch(e){console.error(e)}}function getAuthorization(){try{var e=getBuilderContext(),t=e.tenantId,a=e.authToken;return t&&a?`Bearer ${t},`+a:null}catch(e){console.error(e)}}function getUserId(){try{var e=getBuilderContext().userId;return e?e:null}catch(e){console.error(e)}}function absoluteUrl(e){return""+getRootUrl()+e}function getRootUrl(e){var t=getBuilderContext();return t.rootUrl||("undefined"!=typeof window?window.localStorage.getItem("steedos:rootUrl"):"")||e}function setRootUrl(e){endsWith(e,"/")&&(e=e.substring(0,e.length-1)),localStorage.setItem("steedos:rootUrl",e)}const getSteedosAuth=()=>Object.assign({},cloneDeep(STEEDOS_AUTH)||{},getBuilderContext()||{}),Router={getTabDisplayAs(e){e=localStorage.getItem(`tab.${e}.display`);return e||"grid"},setTabDisplayAs(e,t){localStorage.setItem(`tab.${e}.display`,t)},getAppPath({appId:e}){return"/app/"+e},getPagePath(){},getObjectListViewPath({appId:e,objectName:t,listViewName:a}){return`/app/${e}/${t}/grid/`+a},getObjectDetailPath(e){var{appId:e,objectName:t,recordId:a,_templateType:i}=e,r=Router.getTabDisplayAs(t);return"JavaScript"===i?`/app/${e}/${t}/view/${a}?display=${r}&side_object=<%=item.objectName%>&side_listview_id=<%=item.listName%>`:`/app/${e}/${t}/view/${a}?display=${r}&side_object=\${objectName}&side_listview_id=\${listName}`},getObjectRelatedViewPath({appId:e,masterObjectName:t,masterRecordId:a,objectName:i,foreignKey:r}){return`/app/${e}/${t}/${a}/${i}/grid?related_field_name=`+r}};function getCreatedInfoTpl(e){return`<div><a href='${Router.getObjectDetailPath({formFactor:e,appId:"admin",objectName:"users",recordId:"${created_by._id}"})}'>\${_display.created_by.label}</a>\${_display.created}</div>`}function getModifiedInfoTpl(e){return`<div><a href='${Router.getObjectDetailPath({formFactor:e,appId:"admin",objectName:"users",recordId:"${modified_by._id}"})}'>\${_display.modified_by.label}</a>\${_display.modified}</div>`}function getNumberTpl(e){return`<div>\${_display.${e.name}}</div>`}function getTimeTpl(e){return`<div>\${_display.${e.name}}</div>`}function getDateTpl(e){return`<div>\${_display.${e.name}}</div>`}function getDateTimeTpl(e){return`<div>\${_display.${e.name}}</div>`}function getUiFieldTpl(e){return`<div>\${_display.${e.name}}</div>`}function getUiFileSizeTpl(e){return`<div>\${_display.${e.name}}</div>`}async function getRefObjectNameFieldName(e){return(await getUISchema(e.reference_to)).NAME_FIELD_KEY||"name"}function getSelectTpl(e){return`<div>\${_display.${e.name}}</div>`}function getNameTplUrl(e,t){return"cms_files"===t.objectName?"${context.rootUrl}/api/files/files/${versions[0]}?download=true":Router.getObjectDetailPath({...t,formFactor:t.formFactor,appId:"${appId}",objectName:t.objectName||"${objectName}",recordId:`\${${t.idFieldName}}`})}function getNameTpl(e,t){return`<a href="${getNameTplUrl(e,t)}">\${${e.name}}</a>`}function getRelatedFieldTpl(i,r){let s="";if(!i.reference_to&&(i.optionsFunction||i._optionsFunction))return i.isTableField?`\${${i.name}}`:`\${${i.name}__label}`;var o,l=r.onlyDisplayLabel;let t="data._display."+i.name;if(i.isTableField&&(t="data."+i.name),_.isString(i.reference_to)||!i.reference_to)if(i.multiple){let e="<%=item.label%>";l||(o=Router.getObjectDetailPath({formFactor:r.formFactor,appId:"<%=data.appId%>",objectName:"<%=item.objectName%>",recordId:"<%=item.value%>",_templateType:"JavaScript"}),e=`<a href="${o}"><%=item.label%></a>`),s=`
|
|
2
2
|
<% if (${t} && ${t}.length) { %><% ${t}.forEach(function(item,index) { %> <% if(index>0 && index<${t}.length){ %> , <% } %> ${e} <% }); %><% } %>
|
|
3
|
-
`}else{let e=`\${_display.${i.name}.label}`,t=`\${_display.${i.name}.objectName}`,a=`\${_display.${i.name}.value}`;i.isTableField&&(e=`\${${i.name}.label}`,t=`\${${i.name}.objectName}`,a=`\${${i.name}.value}`),
|
|
3
|
+
`}else{let e=`\${_display.${i.name}.label}`,t=`\${_display.${i.name}.objectName}`,a=`\${_display.${i.name}.value}`;i.isTableField&&(e=`\${${i.name}.label}`,t=`\${${i.name}.objectName}`,a=`\${${i.name}.value}`),l||(o=Router.getObjectDetailPath({formFactor:r.formFactor,appId:"${appId}",objectName:""+t,recordId:""+a}),e=`<a href="${o}">${e}</a>`),s=e}else{let e="<%=item.label%>";l||(i=Router.getObjectDetailPath({formFactor:r.formFactor,appId:"<%=data.appId%>",objectName:"<%=item.objectName%>",recordId:"<%=item.value%>",_templateType:"JavaScript"}),e=`<a href="${i}"><%=item.label%></a>`),s=`
|
|
4
4
|
<% if (${t} && ${t}.length) { %><% ${t}.forEach(function(item) { %> ${e} <% }); %><% } %>
|
|
5
5
|
`}return s}async function getLookupTpl(e,t){var a,i;return e.reference_to?(a=await getRefObjectNameFieldName(e),e.multiple?(i=Router.getObjectDetailPath({formFactor:t.formFactor,appId:t.appId,objectName:e.reference_to,recordId:"<%=item._id%>",_templateType:"JavaScript"}),`
|
|
6
6
|
<% if (data.${e.name} && data.${e.name}.length) { %><% data.${e.name}.forEach(function(item) { %> <a href="${i}"><%=item.${a}%></a> <% }); %><% } %>
|
|
@@ -108,7 +108,7 @@ import*as _$1 from"lodash";import ___default,{isEmpty,isArray,each,find,endsWith
|
|
|
108
108
|
${getSaveDataTpl(e)}
|
|
109
109
|
api.data = {query: query.replace('{__saveData}', __saveData)};
|
|
110
110
|
return api;
|
|
111
|
-
`}async function getFindQuery(e,t,a,i){var r=i.limit||10;let s=`(top: ${r})`,
|
|
111
|
+
`}async function getFindQuery(e,t,a,i){var r=i.limit||10;let s=`(top: ${r})`,o=(t&&(s=`(filters:["_id", "=", "${t}"], top: ${r})`),"data");i&&(i.alias&&(o=i.alias),i.filters&&(s=`(filters:${i.filters})`),i.queryOptions&&(s=`(${i.queryOptions})`));var t="",r=(e.enable_tree&&_$1.includes(_$1.keys(e.fields),"parent")&&_$1.includes(_$1.keys(e.fields),"children")&&(t=",parent,children"),""),l=("cms_files"===e.name&&(r=",versions"),!1===i.count?"":`,count:${e.name}__count(filters:{__filters})`),n=i.moreQueries?.length?","+i.moreQueries.map(function(e){return e.replace(/^{/,"").replace(/}$/,"")}).join(","):"";return{orderBy:"${orderBy}",orderDir:"${orderDir}",pageNo:"${page}",pageSize:"${perPage}",query:`{${o}:${e.name}${s}{${await getFieldsTemplate(a,i.expand)}${t}${r}}${l}${n}}`}}function getRecordPermissionsQuery(e,t,a){let i="",r=(t&&(i=`(filters:["${e.idFieldName}", "=", "${t}"])`),"data"),s=(a&&(a.alias&&(r=a.alias),a.filters&&(i=`(filters:${a.filters})`),a.queryOptions&&(i=`(${a.queryOptions})`)),getRecordPermissionsTemplate());return a?.fields&&a.fields.length&&(s=`
|
|
112
112
|
recordPermissions: _permissions{
|
|
113
113
|
${a.fields.join(",")}
|
|
114
114
|
}
|
|
@@ -204,8 +204,8 @@ import*as _$1 from"lodash";import ___default,{isEmpty,isArray,each,find,endsWith
|
|
|
204
204
|
}
|
|
205
205
|
api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__sort}', sort.trim());
|
|
206
206
|
return api;
|
|
207
|
-
`;return{method:"post",url:getApi$2()+"?term=${term}",requestAdaptor:e,data:a,headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}}function getRefListViewSort$1(e){e=_$1.find(e.list_views,(e,t)=>"all"===t);let t="";return t=e?getListViewSort(e):t}async function getSelectUserSchema(e,t,a){if(!e)return{};a=a||{};var i={type:getAmisStaticFieldType("select",t)};return t?i.tpl=await getLookupTpl(e,a):(t=await getUISchema(refUsersObjectName),a.usersSort=getRefListViewSort$1(t),t=await getUISchema(refOrgsObjectName),a.orgsSort=getRefListViewSort$1(t),Object.assign(i,{multiple:e.multiple,searchable:e.searchable,selectMode:"associated",leftMode:"tree",extractValue:!0,clearable:!0,source:await getSource$1(e,a),deferApi:await getDeferApi$1(e,a),searchApi:await getSearchApi(e,a)}),e.multiple&&Object.assign(i,{joinValues:!1}),"boolean"!=typeof i.searchable&&(i.searchable=!0),(t=e.onEvent)&&(i.onEvent=t)),i}const globalTag="__G_L_O_B_A_L__",getParentPath=function(e){return"string"!=typeof e||1===(e=e.split(".")).length?"#":(e.pop(),e.join("."))},getValueByPath=function(e,t){return"#"!==t&&t?"string"==typeof t?get(e,t):void console.error("path has to be a string"):e||{}},isExpression=function(e){var t,a;return"string"==typeof e&&(t=/^{{(function.+)}}$/,a=/^{{(.+=>.+)}}$/,!("string"!=typeof e||!e.match(/^{{(.+)}}$/)||e.match(t)||e.match(a)))},parseSingleExpression=function(t,e,a,i,r={}){var s,
|
|
208
|
-
var $user=${JSON.stringify(r)}; return `+s.replace(/\bformData\b/g,JSON.stringify(e).replace(/\bglobal\b/g,globalTag)).replace(/\bglobal\b/g,JSON.stringify(i)).replace(new RegExp("\\b"+globalTag+"\\b","g"),"global").replace(/rootValue/g,JSON.stringify(
|
|
207
|
+
`;return{method:"post",url:getApi$2()+"?term=${term}",requestAdaptor:e,data:a,headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}}function getRefListViewSort$1(e){e=_$1.find(e.list_views,(e,t)=>"all"===t);let t="";return t=e?getListViewSort(e):t}async function getSelectUserSchema(e,t,a){if(!e)return{};a=a||{};var i={type:getAmisStaticFieldType("select",t)};return t?i.tpl=await getLookupTpl(e,a):(t=await getUISchema(refUsersObjectName),a.usersSort=getRefListViewSort$1(t),t=await getUISchema(refOrgsObjectName),a.orgsSort=getRefListViewSort$1(t),Object.assign(i,{multiple:e.multiple,searchable:e.searchable,selectMode:"associated",leftMode:"tree",extractValue:!0,clearable:!0,source:await getSource$1(e,a),deferApi:await getDeferApi$1(e,a),searchApi:await getSearchApi(e,a)}),e.multiple&&Object.assign(i,{joinValues:!1}),"boolean"!=typeof i.searchable&&(i.searchable=!0),(t=e.onEvent)&&(i.onEvent=t)),i}const globalTag="__G_L_O_B_A_L__",getParentPath=function(e){return"string"!=typeof e||1===(e=e.split(".")).length?"#":(e.pop(),e.join("."))},getValueByPath=function(e,t){return"#"!==t&&t?"string"==typeof t?get(e,t):void console.error("path has to be a string"):e||{}},isExpression=function(e){var t,a;return"string"==typeof e&&(t=/^{{(function.+)}}$/,a=/^{{(.+=>.+)}}$/,!("string"!=typeof e||!e.match(/^{{(.+)}}$/)||e.match(t)||e.match(a)))},parseSingleExpression=function(t,e,a,i,r={}){var s,o;if(void 0===e&&(e={}),o=getParentPath(a),o=getValueByPath(e,o)||{},"string"!=typeof t)return t;s=t.substring(2,t.length-2),r=`
|
|
208
|
+
var $user=${JSON.stringify(r)}; return `+s.replace(/\bformData\b/g,JSON.stringify(e).replace(/\bglobal\b/g,globalTag)).replace(/\bglobal\b/g,JSON.stringify(i)).replace(new RegExp("\\b"+globalTag+"\\b","g"),"global").replace(/rootValue/g,JSON.stringify(o));try{return Function(r)()}catch(e){return console.log(e,t,a),t}};var config={listView:{newRecordMode:"modal",editRecordMode:"modal",perPage:20}};const getSchema$4=async(e,t)=>{return{type:"service",body:[{type:"button",label:"新建",id:"u:standard_new",level:"default",onEvent:{click:{weight:0,actions:[{actionType:"dialog",dialog:{type:"dialog",data:{$master:"$$",defaultData:"${defaultData}",appId:"${appId}",objectName:"${objectName}",context:"${context}",global:"${global}",listViewId:"${listViewId}",uiSchema:"${uiSchema}",isLookup:"${isLookup}",listName:"${listName}"},title:"新建 ${uiSchema.label}",body:[{type:"service",id:"u:1678e148c4d2",messages:{},schemaApi:{data:{isLookup:"${isLookup}"},url:"${context.rootUrl}/api/pageSchema/form?app=${appId}&objectApiName=${objectName}&formFactor=${formFactor}",method:"get",messages:{},headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"},requestAdaptor:"",adaptor:`
|
|
209
209
|
let formSchema = {
|
|
210
210
|
"type": "steedos-object-form",
|
|
211
211
|
"label": "对象表单",
|
|
@@ -394,7 +394,7 @@ import*as _$1 from"lodash";import ___default,{isEmpty,isArray,each,find,endsWith
|
|
|
394
394
|
sessionStorage.setItem(listViewPropsStoreKey, JSON.stringify(localListViewProps));
|
|
395
395
|
}
|
|
396
396
|
// ===END===
|
|
397
|
-
`},{componentId:"",args:{},actionType:"closeDrawer"}]}},id:"u:14e7388fecd3",level:"primary"}],closeOnEsc:!1,closeOnOutside:!1,showCloseButton:!0,data:{"&":"$$",objectName:"${objectName}",listName:"${listName}",listViewId:"${listViewId}",uiSchema:"${uiSchema}",isLookup:"${isLookup}",context:"${context}",fields:"${filterFormSearchableFields}"}}}]}},id:"u:b96d84868a5a",level:"link"}],size:"xs",className:"space-x-4"},size:"xs",className:"slds-filters__footer slds-grid slds-shrink-none flex justify-between p-0"}],size:"xs",className:"slds-filters"},size:"xs",className:"border-gray-300 border-y slds-grid slds-grid_vertical slds-nowrap "+(!a.isLookup&&"mt-2"),visibleOn:"this.showFieldsFilter"},className:"bg-white"}}function getObjectListHeaderFirstLine(a,e,t){var{icon:i,label:r}=a;const s=[];each(a.list_views,(e,t)=>{s.push({type:"button",label:e.label,actionType:"link",link:`/app/\${appId}/${a.name}/grid/`+t})});var
|
|
397
|
+
`},{componentId:"",args:{},actionType:"closeDrawer"}]}},id:"u:14e7388fecd3",level:"primary"}],closeOnEsc:!1,closeOnOutside:!1,showCloseButton:!0,data:{"&":"$$",objectName:"${objectName}",listName:"${listName}",listViewId:"${listViewId}",uiSchema:"${uiSchema}",isLookup:"${isLookup}",context:"${context}",fields:"${filterFormSearchableFields}"}}}]}},id:"u:b96d84868a5a",level:"link"}],size:"xs",className:"space-x-4"},size:"xs",className:"slds-filters__footer slds-grid slds-shrink-none flex justify-between p-0"}],size:"xs",className:"slds-filters"},size:"xs",className:"border-gray-300 border-y slds-grid slds-grid_vertical slds-nowrap "+(!a.isLookup&&"mt-2"),visibleOn:"this.showFieldsFilter"},className:"bg-white"}}function getObjectListHeaderFirstLine(a,e,t){var{icon:i,label:r}=a;const s=[];each(a.list_views,(e,t)=>{s.push({type:"button",label:e.label,actionType:"link",link:`/app/\${appId}/${a.name}/grid/`+t})});var o=getListViewButtons(a,{}),o=map(o,e=>({type:"steedos-object-button",name:e.name,objectName:e.objectName,visibleOn:getButtonVisibleOn$1(e),className:"button_"+e.name})),l=new RegExp("_","g");return{type:"grid",columns:[{body:[{type:"grid",columns:[{body:{type:"tpl",className:"block",tpl:`<svg class="slds-icon slds-icon_container slds-icon-standard-${i&&i.replace(l,"-")} slds-page-header__icon" aria-hidden="true"><use xlink:href="/assets/icons/standard-sprite/svg/symbols.svg#${i}"></use></svg>`},md:"auto",className:"",columnClassName:"flex justify-center items-center",valign:"middle"},{body:[{type:"tpl",tpl:""+r,inline:!1,wrapperComponent:"",className:"text-md leading-none text-black"},{type:"dropdown-button",className:"",label:"${uiSchema.list_views[listName].label}",rightIcon:"fa fa-caret-down",size:"sm",hideCaret:!0,btnClassName:"!bg-transparent !border-none !hover:border-none text-lg h-5 font-bold p-0 text-black leading-none",buttons:s}],md:"",columnClassName:"p-l-xs"}],className:"flex justify-between"}],md:"auto"},{body:{type:"flex",items:o},md:"auto",valign:"middle"}],className:"flex justify-between"}}async function getObjectListHeaderSecordLine(e,t,a){e="listview_"+e.name;return{type:"grid",columns:[{body:[{type:"tpl",tpl:"${$count} 个项目",visibleOn:"this.$count >= 0",inline:!1,wrapperComponent:"",className:"leading-none",style:{fontFamily:"",fontSize:14},id:"u:1661f8471235"}],md:"auto",columnClassName:"flex items-center"},{body:[await getObjectFieldsFilterButtonSchema(),{type:"button",label:"",icon:"fa fa-refresh",actionType:"reload",target:e,className:"bg-white p-2 rounded border-gray-300 text-gray-500"}],md:"auto"}],className:"flex justify-between"}}async function getObjectListHeaderFieldsFilterBar(t,e,a){var i=keys(t.fields),i=sortBy(compact(map(i,e=>t.fields[e])),"sort_no");return await getObjectFieldsFilterBarSchema(t,i,a)}async function getObjectListHeader$1(e,t,a){return[{type:"wrapper",body:[getObjectListHeaderFirstLine(e)],className:"bg-gray-100 sm:rounded-tl sm:rounded-tr p-4 -mb-4"}]}async function getObjectRecordDetailHeader(e,t,a){var{showRecordTitle:a=!0}=a||{},{name:i,label:r,icon:s}=e,o=getObjectDetailButtons(e,{}),l=getObjectDetailMoreButtons(e,{recordId:t,objectName:i}),o=map(o,e=>({type:"steedos-object-button",name:e.name,objectName:e.objectName,visibleOn:getButtonVisibleOn$1(e),className:"button_"+e.name})),l=map(l,e=>({type:"steedos-object-button",name:e.name,objectName:e.objectName,visibleOn:getButtonVisibleOn$1(e)})),l=(o.push({type:"steedos-dropdown-button",label:"",buttons:l,className:"slds-icon"}),new RegExp("_","g")),l=s&&s.replace(l,"-"),n=[],l=(a&&n.push({body:[{type:"grid",columns:[{body:{type:"tpl",className:"block",tpl:`<svg class="slds-icon slds-icon_container slds-icon-standard-${l} slds-page-header__icon" aria-hidden="true"><use xlink:href="/assets/icons/standard-sprite/svg/symbols.svg#${s}"></use></svg>`},md:"auto",className:"",columnClassName:"flex justify-center items-center"},{body:[{type:"tpl",tpl:""+r,inline:!1,wrapperComponent:"",className:"leading-4 text-md"},{type:"tpl",tpl:"${name}",inline:!1,wrapperComponent:"",className:"leading-5 text-xl font-bold"}],columnClassName:"p-l-xs"}],className:"flex justify-between"}],md:"auto"}),n.push({body:{type:"flex",items:o},md:"auto"}),[{type:"service",id:`page_readonly_${i}_header`,data:{"&":"$$",objectName:i,_id:t,recordPermissions:"${record.recordPermissions}",uiSchema:e},body:[{type:"grid",columns:n,className:"flex justify-between"}],messages:{},hiddenOn:"${recordLoaded != true}"}]);return a&&l.push({type:"service",body:[{type:"grid",columns:[n[0]],className:"flex justify-between"}],messages:{},hiddenOn:"${recordLoaded == true}"}),{type:"service",bodyClassName:"",name:"page",data:{"&":"$$",objectName:i,_id:t,recordPermissions:e.permissions,uiSchema:e,record:"${record}"},body:l,className:""}}async function getObjectRecordDetailRelatedListHeader(e,t){var a=e["icon"],e=await getObjectRelatedListButtons(e,{}),e=map(e,e=>({type:"steedos-object-button",name:e.name,objectName:e.objectName,visibleOn:getButtonVisibleOn$1(e),className:"button_"+e.name})),i=new RegExp("_","g");return{type:"wrapper",body:[{type:"grid",valign:"middle",columns:[{body:[{type:"grid",valign:"middle",className:"flex justify-between",columns:[{body:{type:"tpl",className:"block",tpl:`<svg class="w-6 h-6 slds-icon slds-icon_container slds-icon-standard-${a&&a.replace(i,"-")}" aria-hidden="true"><use xlink:href="/assets/icons/standard-sprite/svg/symbols.svg#${a}"></use></svg>`},md:"auto",className:"",columnClassName:"flex justify-center items-center"},{body:[{type:"tpl",tpl:`<a class="text-black text-base font-bold" href="/app/\${appId}/\${masterObjectName}/\${masterRecordId}/\${objectName}/grid?related_field_name=\${relatedKey}">${t}(\${$count})</a>`,inline:!1,wrapperComponent:"",className:""}],md:"",valign:"middle",columnClassName:"p-l-xs"}]}],md:"auto"},{body:{type:"flex",items:e},md:"auto"}],className:"flex justify-between"}],className:"p-3"}}async function getObjectRelatedListHeader(e,t,a){}const getDisplayAsButton=function(e){return{type:"dropdown-button",icon:"fa fa-table-columns",btnClassName:"antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",align:"right",buttons:[{label:"显示为",children:[{type:"button",label:"表格",onClick:"const url = document.location.pathname + '?display=grid'; props.env.jumpTo(url);"},{type:"button",label:"分栏视图",onClick:"const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);"}]}]}},onFieldsFilterToggleScript=`
|
|
398
398
|
const scope = event.context.scoped;
|
|
399
399
|
const filterForm = scope.getComponents().find(function(n){
|
|
400
400
|
return n.props.type === "form";
|
|
@@ -403,13 +403,65 @@ const filterService = filterForm.context.getComponents().find(function(n){
|
|
|
403
403
|
return n.props.type === "service";
|
|
404
404
|
});
|
|
405
405
|
filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
|
|
406
|
-
`;function
|
|
406
|
+
`;function getExportApiRequestAdaptorScript(){return`
|
|
407
|
+
console.log(api.url);
|
|
408
|
+
// 获取列表视图的属性
|
|
409
|
+
let uiSchema = api.body.uiSchema;
|
|
410
|
+
let list_views = uiSchema.list_views;
|
|
411
|
+
let list_views_name = api.body.listName;
|
|
412
|
+
let col = list_views[list_views_name].columns;
|
|
413
|
+
let sort_test = list_views[list_views_name].sort;
|
|
414
|
+
|
|
415
|
+
// 获取下载字段
|
|
416
|
+
let select = [];
|
|
417
|
+
_.each(col, (col) => {
|
|
418
|
+
if (col.field == undefined)
|
|
419
|
+
select.push(col);
|
|
420
|
+
else select.push(col.field);
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
// 获取排序字段
|
|
424
|
+
|
|
425
|
+
let sort = [];
|
|
426
|
+
_.forEach(sort_test, (sortField) => {
|
|
427
|
+
if (sortField.field_name == undefined)
|
|
428
|
+
sort.push(sortField);
|
|
429
|
+
else sort.push([sortField.field_name, sortField.order]);
|
|
430
|
+
})
|
|
431
|
+
|
|
432
|
+
let orders = [];
|
|
433
|
+
_.map(sort, (value) => {
|
|
434
|
+
let order_tmp = [];
|
|
435
|
+
if (value[1] == "desc")
|
|
436
|
+
order_tmp = value[0] + ' desc';
|
|
437
|
+
else
|
|
438
|
+
order_tmp = value[0];
|
|
439
|
+
orders.push(order_tmp);
|
|
440
|
+
});
|
|
441
|
+
let order = orders.join(',');
|
|
442
|
+
|
|
443
|
+
let filename = uiSchema.label + "-" + list_views[list_views_name].label;
|
|
444
|
+
|
|
445
|
+
url_tmp = api.url.split('?')[0];
|
|
446
|
+
api.url = url_tmp + "?$select=" + select.toString() + "&filename=" + filename;
|
|
447
|
+
|
|
448
|
+
// 判断sort 和 filters
|
|
449
|
+
if (sort.length > 0) {
|
|
450
|
+
api.url += "&$orderby=" + order;
|
|
451
|
+
}
|
|
452
|
+
let filters = list_views[list_views_name].filters;
|
|
453
|
+
if (filters && filters.length > 0) {
|
|
454
|
+
api.url = api.url + "&filters=" + JSON.stringify(filters);
|
|
455
|
+
}
|
|
456
|
+
console.log(api.url);
|
|
457
|
+
return api;
|
|
458
|
+
`}function getObjectHeaderToolbar(e,t,{showDisplayAs:a=!1,hiddenCount:i=!1}={}){return window.innerWidth<768&&(a=!1),"SMALL"===t?[i?{}:{type:"tpl",tpl:"${count} 个项目"},{type:"button",align:"right",className:"bg-white p-2 rounded border-gray-300 text-gray-500",label:"",icon:"fa fa-sync",onEvent:{click:{actions:[{actionType:"custom",script:`
|
|
407
459
|
const scope = event.context.scoped;
|
|
408
460
|
var listView = scope.parent.getComponents().find(function(n){
|
|
409
461
|
return n.props.type === "crud";
|
|
410
462
|
});
|
|
411
463
|
listView.handleChangePage(1);
|
|
412
|
-
`}]}}},{label:"",icon:"fa fa-search",type:"button",align:"right",className:"bg-white p-2 rounded border-gray-300 text-gray-500",onEvent:{click:{actions:[{actionType:"custom",script:onFieldsFilterToggleScript}]}}},a?getDisplayAsButton():{}]:["bulkActions",{type:"columns-toggler",className:"hidden"},i?{}:{type:"tpl",tpl:"${count} 个项目"},{type:"reload",align:"right",tooltipPlacement:"bottom",className:"bg-white p-2 rounded border-gray-300 text-gray-500"},{type:"button",label:"",icon:"fa fa-download",align:"right",className:"bg-white p-2 rounded border-gray-300 text-gray-500",tooltipPlacement:"bottom",visibleOn:"${!isLookup && global.user.is_space_admin}",tooltip:"导出Excel",onEvent:{click:{weight:0,actions:[{args:{api:{url:"${context.rootUrl}/api/record/export/${
|
|
464
|
+
`}]}}},{label:"",icon:"fa fa-search",type:"button",align:"right",className:"bg-white p-2 rounded border-gray-300 text-gray-500",onEvent:{click:{actions:[{actionType:"custom",script:onFieldsFilterToggleScript}]}}},a?getDisplayAsButton():{}]:["bulkActions",{type:"columns-toggler",className:"hidden"},i?{}:{type:"tpl",tpl:"${count} 个项目"},{type:"reload",align:"right",tooltipPlacement:"bottom",className:"bg-white p-2 rounded border-gray-300 text-gray-500"},{type:"button",label:"",icon:"fa fa-download",align:"right",className:"bg-white p-2 rounded border-gray-300 text-gray-500",tooltipPlacement:"bottom",visibleOn:"${!isLookup && global.user.is_space_admin}",tooltip:"导出Excel",onEvent:{click:{weight:0,actions:[{args:{api:{url:"${context.rootUrl}/api/record/export/${objectName}",method:"get",messages:{},requestAdaptor:""+getExportApiRequestAdaptorScript(),data:{uiSchema:"${uiSchema}",listName:"${listName}"},headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}},actionType:"download"}]}}},{label:"",icon:"fa fa-search",type:"button",align:"right",className:"bg-white p-2 rounded border-gray-300 text-gray-500",onEvent:{click:{actions:[{actionType:"custom",script:onFieldsFilterToggleScript}]}}},a?getDisplayAsButton():{}]}function getObjectFooterToolbar(e,t){return"SMALL"===t?["load-more"]:["statistics","pagination"]}async function getObjectFilter(e,t,a){return{title:"",submitText:"",className:"",mode:"normal",wrapWithPanel:!1,body:[await getObjectListHeaderFieldsFilterBar(e,null,a)]}}async function getSource(e,t){var a=t.objectName,i=await getFindQuery({name:a},null,[{name:t.valueField,alias:"value"},{name:t.labelField,alias:"label"},{name:"children"}],{alias:"options",filters:"{__filters}"}),a=(i.query=i.query.replace(/,count\:.+/,"}"),await getFindQuery({name:a},null,[{name:t.valueField,alias:"value"},{name:t.labelField,alias:"label"}],{alias:"defaultValueOptions",filters:"{__options_filters}"}));a.query=a.query.replace(/,count\:.+/,"}"),i.query=i.query.replace(/}$/,","+a.query.replace(/{(.+)}/,"$1}"));let r=""+e.name;e._prefix&&(r=""+e._prefix+e.name),t.fieldNamePrefix&&(r=""+t.fieldNamePrefix+r),i.$value="$"+r;a=`
|
|
413
465
|
var filters = [['parent', '=', null]];
|
|
414
466
|
api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters));
|
|
415
467
|
var defaultValue = api.data.$value;
|
|
@@ -462,7 +514,7 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
462
514
|
payload.data = data;
|
|
463
515
|
}
|
|
464
516
|
return payload;
|
|
465
|
-
`,data:i,headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}}function getRefListViewSort(e){e=_$1.find(e.list_views,(e,t)=>"all"===t);let t="";return t=e?getListViewSort(e):t}async function lookupToAmisTreeSelect(e,t,a){if(!e)return{};a=a||{};var i={type:getAmisStaticFieldType("tree-select",t)};return t?i.tpl=await getLookupTpl(e,a):(t=await getUISchema(a.objectName),a.sort=getRefListViewSort(t),Object.assign(i,{multiple:e.multiple,searchable:e.searchable,extractValue:!0,hideNodePathLabel:!0,clearable:!0,source:await getSource(e,a),deferApi:await getDeferApi(e,a)}),e.multiple&&Object.assign(i,{joinValues:!1}),"boolean"!=typeof i.searchable&&(i.searchable=!0),(t=e.onEvent)&&(i.onEvent=t)),i}const getReferenceTo=async a=>{let i=a.reference_to;if(i){"users"===i&&(i="space_users",a.reference_to_field="user");var r=await getUISchema(i);if(!r)return null;let e=null,t=a.reference_to_field;return t=t||r.idFieldName||"_id",e="_id"===t?{name:"_id",label:"ID",type:"text",toggled:!1}:r.fields[t]||{name:t},{objectName:i,valueField:e,labelField:r.fields[r.NAME_FIELD_KEY||"name"],NAME_FIELD_KEY:r.NAME_FIELD_KEY||"name"}}};async function lookupToAmisPicker(r,s,
|
|
517
|
+
`,data:i,headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}}function getRefListViewSort(e){e=_$1.find(e.list_views,(e,t)=>"all"===t);let t="";return t=e?getListViewSort(e):t}async function lookupToAmisTreeSelect(e,t,a){if(!e)return{};a=a||{};var i={type:getAmisStaticFieldType("tree-select",t)};return t?i.tpl=await getLookupTpl(e,a):(t=await getUISchema(a.objectName),a.sort=getRefListViewSort(t),Object.assign(i,{multiple:e.multiple,searchable:e.searchable,extractValue:!0,hideNodePathLabel:!0,clearable:!0,source:await getSource(e,a),deferApi:await getDeferApi(e,a)}),e.multiple&&Object.assign(i,{joinValues:!1}),"boolean"!=typeof i.searchable&&(i.searchable=!0),(t=e.onEvent)&&(i.onEvent=t)),i}const getReferenceTo=async a=>{let i=a.reference_to;if(i){"users"===i&&(i="space_users",a.reference_to_field="user");var r=await getUISchema(i);if(!r)return null;let e=null,t=a.reference_to_field;return t=t||r.idFieldName||"_id",e="_id"===t?{name:"_id",label:"ID",type:"text",toggled:!1}:r.fields[t]||{name:t},{objectName:i,valueField:e,labelField:r.fields[r.NAME_FIELD_KEY||"name"],NAME_FIELD_KEY:r.NAME_FIELD_KEY||"name"}}};async function lookupToAmisPicker(r,s,o){var l=await getReferenceTo(r);if(l){const c=await getUISchema(l.objectName),p=[];let e=0;const u=[],m=[];var n=_$1.find(c.list_views,(e,t)=>"all"===t);n&&n.columns?_$1.each(n.columns,function(e){_$1.isString(e)&&c.fields[e]?m.push(c.fields[e]):_$1.isObject(e)&&c.fields[e.field]&&m.push(Object.assign({},c.fields[e.field],{width:e.width,wrap:e.wrap}))}):_$1.each(c.fields,(e,t)=>{"_id"==t||e.hidden||(_$1.has(e,"name")||(e.name=t),m.push(e))}),_$1.each(_$1.sortBy(m,"sort_no"),function(t){e<5&&(_$1.find(p,function(e){return e.name===t.name})||(e++,p.push(t),t.searchable&&u.push(t.name)))});const f={[l.labelField.name]:l.labelField,[l.valueField.name]:l.valueField};_$1.each(p,e=>{e.hidden||(f[e.name]=e)});let t="";n&&(t=getListViewSort(n));n=await getApi$1(c,null,f,{expand:!0,alias:"rows",queryOptions:'filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"'});if(n.url){const g=[],y=[];_$1.each(r.depend_on,e=>{g.push(`depend_on_${e}=\${${e}}`),y.push("this."+e)}),0<g.length&&(n.url=n.url+"?"+g.join("&"),n.sendOn=""+y.join(" && "))}n.data.$term="$term",n.data.$self="$$",n.requestAdaptor=`
|
|
466
518
|
const selfData = JSON.parse(JSON.stringify(api.data.$self));
|
|
467
519
|
var filters = [];
|
|
468
520
|
var pageSize = api.data.pageSize || 10;
|
|
@@ -477,9 +529,9 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
477
529
|
filters = [["name", "contains", "'+ api.data.$term +'"]];
|
|
478
530
|
}else if(selfData.op === 'loadOptions' && selfData.value){
|
|
479
531
|
if(selfData.value?.indexOf(',') > 0){
|
|
480
|
-
filters = [["${
|
|
532
|
+
filters = [["${l.valueField.name}", "=", selfData.value.split(',')]];
|
|
481
533
|
}else{
|
|
482
|
-
filters = [["${
|
|
534
|
+
filters = [["${l.valueField.name}", "=", selfData.value]];
|
|
483
535
|
}
|
|
484
536
|
}
|
|
485
537
|
|
|
@@ -520,7 +572,7 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
520
572
|
filters.push(fieldFilters);
|
|
521
573
|
}
|
|
522
574
|
|
|
523
|
-
const filtersFunction = ${r._filtersFunction};
|
|
575
|
+
const filtersFunction = ${r.filtersFunction||r._filtersFunction};
|
|
524
576
|
|
|
525
577
|
if(filtersFunction){
|
|
526
578
|
const _filters = filtersFunction(filters, api.data.$self.__super.__super);
|
|
@@ -531,7 +583,7 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
531
583
|
|
|
532
584
|
api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim());
|
|
533
585
|
return api;
|
|
534
|
-
`,
|
|
586
|
+
`,n.adaptor=`
|
|
535
587
|
const enable_tree = ${c.enable_tree};
|
|
536
588
|
if(enable_tree){
|
|
537
589
|
const records = payload.data.rows;
|
|
@@ -559,7 +611,10 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
559
611
|
payload.data.rows = treeRecords;
|
|
560
612
|
}
|
|
561
613
|
return payload;
|
|
562
|
-
|
|
614
|
+
`,(r.optionsFunction||r._optionsFunction)&&(n.adaptor=`
|
|
615
|
+
payload.data.rows = eval(${r.optionsFunction||r._optionsFunction})(api.data.$self);
|
|
616
|
+
return payload;
|
|
617
|
+
`);let a=20,i=(c.paging&&!1===c.paging.enabled&&(a=1e3),null);"SMALL"===o.formFactor?i=await getListSchema$1(p,{top:a,...o,actions:!1}):((i=await getTableSchema$1(p,{labelFieldName:c.NAME_FIELD_KEY,top:a,...o})).headerToolbar=getObjectHeaderToolbar(c,o.formFactor),c.permissions.allowCreate&&((d=await getSchema$4(c,{appId:o.appId,objectName:c.name,formFactor:o.formFactor})).align="right",i.headerToolbar.push(d)),i.footerToolbar=getObjectFooterToolbar(),!1!==o.filterVisible&&(d=o.filterLoopCount||0,d++,i.filter=await getObjectFilter(c,f,{isLookup:!0,...o,filterLoopCount:d})),i.data=Object.assign({},i.data,{"&":"$$",objectName:c.name,uiSchema:c,listName:"all",isLookup:!0}),i.onEvent||(i.onEvent={}),i.onEvent["@data.changed."+c.name]={actions:[{actionType:"reload"}]});var d={type:getAmisStaticFieldType("picker",s),labelField:l.labelField.name,valueField:l.valueField.name,modalMode:"dialog",source:n,size:"lg",pickerSchema:i,joinValues:!1,extractValue:!0};return r.multiple&&(d.multiple=!0,d.extractValue=!0),s&&(d.tpl=await getLookupTpl(r,o)),d}}async function lookupToAmisSelect(e,t,a){var i=await getReferenceTo(e),r=i&&i.valueField?.name||"_id";let s;i?(o=await getFindQuery({name:i.objectName},null,{[i.labelField.name]:Object.assign({},i.labelField,{alias:"label"}),[i.valueField.name]:Object.assign({},i.valueField,{alias:"value"})},{alias:"defaultValueOptions",filters:"{__options_filters}",count:!1}),(s=await getApi$1({name:i.objectName},null,{[i.labelField.name]:Object.assign({},i.labelField,{alias:"label"}),[i.valueField.name]:Object.assign({},i.valueField,{alias:"value"})},{expand:!1,alias:"options",queryOptions:'filters: {__filters}, top: {__top}, sort: "{__sort}"',moreQueries:[o.query]})).adaptor=`
|
|
563
618
|
const data = payload.data;
|
|
564
619
|
var defaultValueOptions = data.defaultValueOptions;
|
|
565
620
|
// 字段值下拉选项合并到options中
|
|
@@ -569,7 +624,7 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
569
624
|
delete data.defaultValueOptions;
|
|
570
625
|
payload.data.options = data.options;
|
|
571
626
|
return payload;
|
|
572
|
-
`):s={method:"post",url:getApi$2(),data:{query:'{objects(filters: ["_id", "=", "-1"]){_id}}',$:"$$"}};var
|
|
627
|
+
`):s={method:"post",url:getApi$2(),data:{query:'{objects(filters: ["_id", "=", "-1"]){_id}}',$:"$$"}};var o=i&&await getUISchema(i.objectName),o=o&&_$1.find(o.list_views,(e,t)=>"all"===t);let l="";if(o&&(l=getListViewSort(o)),s.url){const n=[],d=[];_$1.each(e.depend_on,e=>{n.push(`depend_on_${e}=\${${e}}`),d.push("this."+e)}),0<n.length&&(s.url=s.url+"?"+n.join("&"),s.sendOn=""+d.join(" && "))}s.data.$term="$term",s.data.$value=a.isRefToMutiple?`$${e.name}.ids`:"$"+e.name,_$1.each(e.depend_on,function(e){s.data[e]="$"+e}),s.data.$="$$",s.data.rfield="${object_name}",s.requestAdaptor=`
|
|
573
628
|
var filters = [];
|
|
574
629
|
var top = 10;
|
|
575
630
|
if(api.data.$term){
|
|
@@ -592,7 +647,7 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
592
647
|
filters.push(_filters);
|
|
593
648
|
}
|
|
594
649
|
}
|
|
595
|
-
var sort = "${
|
|
650
|
+
var sort = "${l}";
|
|
596
651
|
api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', top).replace('{__sort}', sort.trim());
|
|
597
652
|
|
|
598
653
|
var defaultValue = api.data.$value;
|
|
@@ -610,7 +665,7 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
610
665
|
`,i&&i.labelField.name,i&&i.valueField.name,(e.optionsFunction||e._optionsFunction)&&(s.adaptor=`
|
|
611
666
|
payload.data.options = eval(${e.optionsFunction||e._optionsFunction})(api.data.$);
|
|
612
667
|
return payload;
|
|
613
|
-
`);
|
|
668
|
+
`);o={type:getAmisStaticFieldType("select",t),joinValues:!1,extractValue:!0,source:s,autoComplete:s,searchable:!0};return o.menuTpl="${icon ? `<span class='flex items-center mt-0.5'>\n <span role='img' aria-label='smile' class='anticon anticon-smile'>\n <span class='slds-icon_container slds-icon-standard-${REPLACE(icon,'_','-')}'>\n <svg class='slds-icon slds-icon_x-small' aria-hidden='true'>\n <use xlink:href='${context.rootUrl}/assets/icons/standard-sprite/svg/symbols.svg#${icon}'></use>\n </svg>\n </span> \n </span>\n <span class='pl-1.5'>${label}</span>\n </span>` : label}",e.multiple&&(o.multiple=!0,o.extractValue=!0),t&&(o.tpl=await getLookupTpl(e,a)),o}async function getApi$1(e,t,a,i){e=await getFindQuery(e,t,a,i);return{method:"post",url:getApi$2(),data:e,headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}}async function lookupToAmis(e,t,a){var i,r;return a=a||{},t?{type:getAmisStaticFieldType("picker",t),tpl:getRelatedFieldTpl(e,a)}:!e.reference_to||_$1.isString(e.reference_to)||t?a.ids||a.idsTrackOn?lookupToAmisIdsPicker(e,t,a):(i=await getReferenceTo(e))?(r=await getUISchema(i.objectName),"space_users"===i.objectName&&"user"===e.reference_to_field?lookupToAmisSelectUser(e,t,a):1==r.enable_enhanced_lookup&&_$1.isEmpty(e.depend_on)?lookupToAmisPicker(e,t,a):r.enable_tree?lookupToAmisTreeSelect(e,t,Object.assign({},a,{labelField:i.labelField?.name||"name",valueField:i.valueField?.name||"_id",objectName:i.objectName})):lookupToAmisSelect(e,t,a)):lookupToAmisSelect(e,t,a):{type:"steedos-field-lookup",field:e,readonly:t,ctx:{}}}async function lookupToAmisSelectUser(e,t,a){return getSelectUserSchema(e,t,a)}async function lookupToAmisIdsPicker(e,t,a){return getIdsPickerSchema(e,t,a)}async function getIdsPickerSchema(t,a,i){i=i||{};var r=await getReferenceTo(t);if(r){var s=await getUISchema(r.objectName),{ids:o,idsTrackOn:l}=i,n={[r.labelField.name]:r.labelField,[r.valueField.name]:r.valueField},d=[r.labelField],n=await getApi$1(s,null,n,{expand:!0,alias:"rows",queryOptions:"filters: {__filters}, top: {__top}, skip: {__skip}"});n.data.$term="$term",n.data.$self="$$",o&&o.length?n.sendOn=!0:n.sendOn=!1,l&&(n.sendOn=`\${${l} && ${l}.length}`),n.requestAdaptor=`
|
|
614
669
|
const selfData = JSON.parse(JSON.stringify(api.data.$self));
|
|
615
670
|
var filters = [];
|
|
616
671
|
var pageSize = api.data.pageSize || 1000;
|
|
@@ -623,15 +678,19 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
623
678
|
filters = [["${r.valueField.name}", "=", selfData.value]];
|
|
624
679
|
}
|
|
625
680
|
}
|
|
626
|
-
|
|
627
|
-
var ids = ${JSON.stringify(
|
|
681
|
+
|
|
682
|
+
var ids = ${JSON.stringify(o)};
|
|
683
|
+
var idsTrackOn = "${l}";
|
|
684
|
+
if(idsTrackOn){
|
|
685
|
+
ids = api.data.$self[idsTrackOn];
|
|
686
|
+
}
|
|
628
687
|
if(ids && ids.length){
|
|
629
688
|
filters.push(["${r.valueField.name}", "=", ids]);
|
|
630
689
|
}
|
|
631
690
|
|
|
632
691
|
api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip);
|
|
633
692
|
return api;
|
|
634
|
-
`;let e=null;e="SMALL"===i.formFactor?await getListSchema$1(
|
|
693
|
+
`;let e=null;e="SMALL"===i.formFactor?await getListSchema$1(d,{top:1e3,...i,actions:!1}):await getTableSchema$1(d,{labelFieldName:s.NAME_FIELD_KEY,top:1e3,...i});o={type:getAmisStaticFieldType("picker",a),labelField:r.labelField.name,valueField:r.valueField.name,modalMode:"dialog",source:n,size:"lg",pickerSchema:e,joinValues:!1,extractValue:!0};return t.multiple&&(o.multiple=!0,o.extractValue=!0),a&&(o.tpl=await getLookupTpl(t,i)),o}}const getMarkdownFieldSchema=(e,t,a)=>t?{type:"markdown",name:e.name,options:{linkify:!0,html:!0,breaks:!0}}:{type:"group",body:[{type:"editor",name:e.name,language:"markdown"},{type:"markdown",name:e.name,options:{linkify:!0,html:!0,breaks:!0}}]},getHtmlFieldSchema=(e,t,a)=>t?{type:"html",name:e.name}:{type:"input-rich-text",name:e.name},AmisFormInputs=["text","date","file","avatar","image","datetime","time","number","currency","percent","password","url","email"];function getAmisStaticFieldType(e,t,a){return t?_$1.includes(["text","image"],e)?"image"===e&&a&&a.multiple?"static-images":"static-"+e:"static":_$1.includes(AmisFormInputs,e)?"input-"+e:e}const getFileTableName=e=>{switch(e.type){case"avatar":return"avatars";case"image":return"images";case"file":return"files"}},getAmisFieldType$1=(e,t)=>getAmisStaticFieldType("avatar"===e.type?"image":e.type,t,{multiple:e.multiple}),getAmisFileReadonlySchema=e=>{var t=e.type,a=getAmisFieldType$1(e,!0);return _.includes(["avatar","image"],t)?{type:a,defaultImage:"",enlargeAble:!0,showToolbar:!0}:"file"===t?{type:a,tpl:`
|
|
635
694
|
<% let fileData = data.${e.name}; if (fileData) { %>
|
|
636
695
|
<% if(!Array.isArray(fileData)){ fileData = [fileData]} %>
|
|
637
696
|
<% fileData.forEach(function(item) { %>
|
|
@@ -649,7 +708,7 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
649
708
|
}
|
|
650
709
|
}
|
|
651
710
|
return payload;
|
|
652
|
-
`,headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}};return e.multiple&&(t.multiple=!0,t.joinValues=!1,t.extractValue=!0),t},getAmisFileSchema=(e,t)=>(t?getAmisFileReadonlySchema:getAmisFileEditSchema)(e),OMIT_FIELDS=["created","created_by","modified","modified_by"];function getBaseFields(e){let t="m-1";return[{name:"createdInfo",label:"创建人",type:"static",labelClassName:"text-left",className:t=e?""+t:t,tpl:getCreatedInfoTpl()},{name:"modifiedInfo",label:"修改人",type:"static",labelClassName:"text-left",className:t,tpl:getModifiedInfoTpl()}]}function getAmisFieldType(e){switch(e.type){case"text":return"text";case"textarea":return"textarea";case"html":return"html";case"markdown":return"markdown";case"select":return"select";case"boolean":return"checkbox";case"date":return"date";case"datetime":return"datetime";case"number":case"currency":case"percent":return"number";case"password":return"password";case"lookup":return"select";case"master_detail":return"picker";case"autonumber":return"text";case"url":return"url";case"email":return"email";case"image":return"image";case"formula":case"summary":break;case"grid":return"table";default:console.log("convertData default",e.type)}}function getObjectFieldSubFields(a,e){var t=Object.assign({subFields:[]},a),e=_$1.filter(e,function(e){var t=e.name.startsWith(a.name+".")&&_$1.split(e.name,".").length<3;return t&&(e._prefix=a.name+"."),t});return t.subFields=e,t}function getGridFieldSubFields(a,e){var t=Object.assign({subFields:[]},a),e=_$1.filter(e,function(e){var t=e.name.startsWith(a.name+".");return t&&(e._prefix=a.name+"."),t});return t.subFields=e,t}function getPermissionFields(e,t){const a=[],i=[];return _$1.each(e.fields,(e,t)=>{_$1.has(e,"name")||(e.name=t),i.push(e)}),_$1.each(_$1.sortBy(i,"sort_no"),function(e){e.hidden||a.push(Object.assign({},e,{permission:{allowEdit:!0}}))}),a}function getSelectFieldOptions(e){const t=e.data_type||"text",a=[];return _$1.each(e.options,e=>{switch(t){case"number":a.push({label:e.label,value:Number(e.value)});break;case"text":a.push({label:e.label,value:String(e.value)});break;case"boolean":a.push({label:e.label,value:"false"!==e.value})}}),a}async function convertSFieldToAmisField(a,i,r){if(!_$1.includes(OMIT_FIELDS,a.name)||1==r.showSystemFields){var e={name:r.fieldNamePrefix?""+r.fieldNamePrefix+a.name:a.name,label:a.label,labelRemark:a.inlineHelpText,required:(_$1.has(r,"required")?r:a).required};let t={};switch(a.type){case"text":t.type=getAmisStaticFieldType("text",i);break;case"textarea":t.type=getAmisStaticFieldType("textarea",i),t.tpl=`<%=(data.${a.name} || "").split("\\n").join('<br>')%>`;break;case"html":t=getHtmlFieldSchema(a,i);break;case"markdown":t=getMarkdownFieldSchema(a,i);break;case"select":t={type:getAmisStaticFieldType("select",i),joinValues:!1,options:getSelectFieldOptions(a),extractValue:!0,clearable:!0,labelField:"label",valueField:"value",tpl:i?getSelectTpl(a):null},a.multiple&&(t.multiple=!0,t.extractValue=!0);break;case"boolean":t={type:getAmisStaticFieldType("checkbox",i),tpl:i?getSwitchTpl(a):null};break;case"input-date-range":t={type:"input-date-range",inputFormat:"YYYY-MM-DD",format:"YYYY-MM-DDT00:00:00.000[Z]",tpl:i?getDateTpl(a):null,joinValues:!1};break;case"date":t={type:getAmisStaticFieldType("date",i),inputFormat:"YYYY-MM-DD",format:"YYYY-MM-DDT00:00:00.000[Z]",tpl:i?getDateTpl(a):null};break;case"input-datetime-range":t={type:"input-datetime-range",inputFormat:"YYYY-MM-DD HH:mm",format:"YYYY-MM-DDTHH:mm:ss.SSSZ",tpl:i?getDateTimeTpl(a):null,utc:!0,joinValues:!1};break;case"datetime":t={type:getAmisStaticFieldType("datetime",i),inputFormat:"YYYY-MM-DD HH:mm",format:"YYYY-MM-DDTHH:mm:ss.SSSZ",tpl:i?getDateTimeTpl(a):null,utc:!0};break;case"input-time-range":t={type:"input-time-range",inputFormat:"HH:mm",timeFormat:"HH:mm",format:"1970-01-01THH:mm:00.000[Z]",tpl:i?getDateTimeTpl(a):null,joinValues:!1};break;case"time":t={type:getAmisStaticFieldType("time",i),inputFormat:"HH:mm",timeFormat:"HH:mm",format:"1970-01-01THH:mm:00.000[Z]",tpl:i?getDateTimeTpl(a):null};break;case"currency":case"number":t=i?{type:"static-tpl",tpl:getNumberTpl(a)}:{type:getAmisStaticFieldType("number",i),min:a.min,max:a.max,precision:a.scale};break;case"input-array":t=Object.assign({},a,e);break;case"input-range":t={type:"input-range",min:a.min,max:a.max,value:[0,0],multiple:!0,showInput:!0};break;case"percent":t={type:getAmisStaticFieldType("number",i),min:a.min,max:a.max,precision:a.scale};break;case"password":t={type:getAmisStaticFieldType("password",i),tpl:i?getPasswordTpl(a):null};break;case"lookup":case"master_detail":t=await lookupToAmis(a,i,r);break;case"autonumber":i&&(t={type:"static-text"});break;case"url":t={type:getAmisStaticFieldType("url",i)};break;case"email":t={type:getAmisStaticFieldType("email",i)};break;case"avatar":case"image":case"file":t=getAmisFileSchema(a,i);break;case"formula":case"summary":i&&(t.type=getAmisStaticFieldType(a.data_type,i));break;case"code":t={type:"editor",language:a.language};break;case"toggle":t={type:"switch",name:a.name,label:a.label,width:a.width,toggled:a.toggled,disabled:i};break;case"grid":if(a.subFields){t={type:"input-table",showIndex:!0,columnsTogglable:!1,strictMode:!1,affixHeader:!1,editable:!i,addable:!i,removable:!i,draggable:!i,columns:[]};for(const c of a.subFields){var s,
|
|
711
|
+
`,headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}};return e.multiple&&(t.multiple=!0,t.joinValues=!1,t.extractValue=!0),t},getAmisFileSchema=(e,t)=>(t?getAmisFileReadonlySchema:getAmisFileEditSchema)(e),OMIT_FIELDS=["created","created_by","modified","modified_by"];function getBaseFields(e){let t="m-1";return[{name:"createdInfo",label:"创建人",type:"static",labelClassName:"text-left",className:t=e?""+t:t,tpl:getCreatedInfoTpl()},{name:"modifiedInfo",label:"修改人",type:"static",labelClassName:"text-left",className:t,tpl:getModifiedInfoTpl()}]}function getAmisFieldType(e){switch(e.type){case"text":return"text";case"textarea":return"textarea";case"html":return"html";case"markdown":return"markdown";case"select":return"select";case"boolean":return"checkbox";case"date":return"date";case"datetime":return"datetime";case"number":case"currency":case"percent":return"number";case"password":return"password";case"lookup":return"select";case"master_detail":return"picker";case"autonumber":return"text";case"url":return"url";case"email":return"email";case"image":return"image";case"formula":case"summary":break;case"grid":return"table";default:console.log("convertData default",e.type)}}function getObjectFieldSubFields(a,e){var t=Object.assign({subFields:[]},a),e=_$1.filter(e,function(e){var t=e.name.startsWith(a.name+".")&&_$1.split(e.name,".").length<3;return t&&(e._prefix=a.name+"."),t});return t.subFields=e,t}function getGridFieldSubFields(a,e){var t=Object.assign({subFields:[]},a),e=_$1.filter(e,function(e){var t=e.name.startsWith(a.name+".");return t&&(e._prefix=a.name+"."),t});return t.subFields=e,t}function getPermissionFields(e,t){const a=[],i=[];return _$1.each(e.fields,(e,t)=>{_$1.has(e,"name")||(e.name=t),i.push(e)}),_$1.each(_$1.sortBy(i,"sort_no"),function(e){e.hidden||a.push(Object.assign({},e,{permission:{allowEdit:!0}}))}),a}function getSelectFieldOptions(e){const t=e.data_type||"text",a=[];return _$1.each(e.options,e=>{switch(t){case"number":a.push({label:e.label,value:Number(e.value)});break;case"text":a.push({label:e.label,value:String(e.value)});break;case"boolean":a.push({label:e.label,value:"false"!==e.value})}}),a}async function convertSFieldToAmisField(a,i,r){if(!_$1.includes(OMIT_FIELDS,a.name)||1==r.showSystemFields){var e={name:r.fieldNamePrefix?""+r.fieldNamePrefix+a.name:a.name,label:a.label,labelRemark:a.inlineHelpText,required:(_$1.has(r,"required")?r:a).required};let t={};switch(a.type){case"text":t.type=getAmisStaticFieldType("text",i);break;case"textarea":t.type=getAmisStaticFieldType("textarea",i),t.tpl=`<%=(data.${a.name} || "").split("\\n").join('<br>')%>`;break;case"html":t=getHtmlFieldSchema(a,i);break;case"markdown":t=getMarkdownFieldSchema(a,i);break;case"select":t={type:getAmisStaticFieldType("select",i),joinValues:!1,options:getSelectFieldOptions(a),extractValue:!0,clearable:!0,labelField:"label",valueField:"value",tpl:i?getSelectTpl(a):null},a.multiple&&(t.multiple=!0,t.extractValue=!0);break;case"boolean":t={type:getAmisStaticFieldType("checkbox",i),tpl:i?getSwitchTpl(a):null};break;case"input-date-range":t={type:"input-date-range",inputFormat:"YYYY-MM-DD",format:"YYYY-MM-DDT00:00:00.000[Z]",tpl:i?getDateTpl(a):null,joinValues:!1};break;case"date":t={type:getAmisStaticFieldType("date",i),inputFormat:"YYYY-MM-DD",format:"YYYY-MM-DDT00:00:00.000[Z]",tpl:i?getDateTpl(a):null};break;case"input-datetime-range":t={type:"input-datetime-range",inputFormat:"YYYY-MM-DD HH:mm",format:"YYYY-MM-DDTHH:mm:ss.SSSZ",tpl:i?getDateTimeTpl(a):null,utc:!0,joinValues:!1};break;case"datetime":t={type:getAmisStaticFieldType("datetime",i),inputFormat:"YYYY-MM-DD HH:mm",format:"YYYY-MM-DDTHH:mm:ss.SSSZ",tpl:i?getDateTimeTpl(a):null,utc:!0};break;case"input-time-range":t={type:"input-time-range",inputFormat:"HH:mm",timeFormat:"HH:mm",format:"1970-01-01THH:mm:00.000[Z]",tpl:i?getDateTimeTpl(a):null,joinValues:!1};break;case"time":t={type:getAmisStaticFieldType("time",i),inputFormat:"HH:mm",timeFormat:"HH:mm",format:"1970-01-01THH:mm:00.000[Z]",tpl:i?getDateTimeTpl(a):null};break;case"currency":case"number":t=i?{type:"static-tpl",tpl:getNumberTpl(a)}:{type:getAmisStaticFieldType("number",i),min:a.min,max:a.max,precision:a.scale};break;case"input-array":t=Object.assign({},a,e);break;case"input-range":t={type:"input-range",min:a.min,max:a.max,value:[0,0],multiple:!0,showInput:!0};break;case"percent":t={type:getAmisStaticFieldType("number",i),min:a.min,max:a.max,precision:a.scale};break;case"password":t={type:getAmisStaticFieldType("password",i),tpl:i?getPasswordTpl(a):null};break;case"lookup":case"master_detail":t=await lookupToAmis(a,i,r);break;case"autonumber":i&&(t={type:"static-text"});break;case"url":t={type:getAmisStaticFieldType("url",i)};break;case"email":t={type:getAmisStaticFieldType("email",i)};break;case"avatar":case"image":case"file":t=getAmisFileSchema(a,i);break;case"formula":case"summary":i&&(t.type=getAmisStaticFieldType(a.data_type,i));break;case"code":t={type:"editor",language:a.language};break;case"toggle":t={type:"switch",name:a.name,label:a.label,width:a.width,toggled:a.toggled,disabled:i};break;case"grid":if(a.subFields){t={type:"input-table",showIndex:!0,columnsTogglable:!1,strictMode:!1,affixHeader:!1,editable:!i,addable:!i,removable:!i,draggable:!i,columns:[]};for(const c of a.subFields){var s,o=c.name.replace(`${a._prefix||""}${a.name}.$.`,"").replace(a.name+".",""),l=await convertSFieldToAmisField(Object.assign({},c,{name:o,isTableField:!0}),i,r);l&&(delete l.name,delete l.label,s={name:o,label:c.label,quickEdit:!i&&l},"lookup"===c.type&&(s.type=l.type,s.tpl=l.tpl),t.columns.push(Object.assign({},s,c.amis,{name:o})))}}break;case"object":if(a.subFields){t={type:"combo",items:[]};for(var n of a.subFields){let e=n.name.replace(a.name+".$.","").replace(a.name+".","");"grid"===n.type?n=await getGridFieldSubFields(n,r.__formFields):i&&(e=a.name+"."+e);var d=await convertSFieldToAmisField(Object.assign({},n,{name:e}),i,r);d&&(delete d.name,delete d.label,t.items.push(Object.assign({},d,{label:n.label},n.amis,{name:e})))}}}return _$1.isEmpty(t)?void 0:(a.is_wide||"group"===t.type?t.className="col-span-2 m-1":t.className="m-1",i&&(t.className=t.className+" md:border-b"),i&&(t.quickEdit=!1),a.visible_on&&(a.visible_on.startsWith("{{")?t.visibleOn=""+a.visible_on.substring(2,a.visible_on.length-2).replace(/formData./g,"data."):t.visibleOn=""+a.visible_on.replace(/formData./g,"data.")),"group"===t.type?(t.body[0]=Object.assign({},e,t.body[0],{labelClassName:"text-left",clearValueOnHidden:!0,fieldName:a.name}),t):Object.assign({},e,t,{labelClassName:"text-left",clearValueOnHidden:!0,fieldName:a.name},a.amis,{name:e.name}))}}async function getFieldSearchable(e,t,a){var i=a.filterLoopCount||0;let r=e,s=("grid"===r.type?r=await getGridFieldSubFields(e,t):"object"===e.type&&(r=await getObjectFieldSubFields(e,t)),"__searchable__");if(r.name.indexOf(".")<0){e=cloneDeep(r),t=(includes(["textarea","html","code","autonumber"],r.type)&&(e.type="text"),includes(["formula","summary"],r.type)?(e.type=r.data_type,e.precision=r.precision,e.scale=r.scale):"select"===r.type&&r.data_type&&"text"!=r.data_type&&(e.type=r.data_type),"number"!==e.type&&"currency"!==e.type||(e.type="input-array",e.inline=!0,e.addable=!1,e.removable=!1,e.value=[null,null],e.items={type:"input-number"},e.is_wide=!0,s+="between__"),"date"===e.type&&(e.type="input-date-range",e.is_wide=!0,s+="between__"),"datetime"===e.type&&(e.type="input-datetime-range",e.is_wide=!0,s+="between__"),"time"===e.type&&(e.type="input-time-range",e.is_wide=!0,s+="between__"),"users"===e.reference_to&&(e.reference_to="space_users",e.reference_to_field="user"),e.readonly=!1,e.disabled=!1,e.multiple=!0,e.is_wide=!1,e.defaultValue=void 0,await convertSFieldToAmisField(e,!1,Object.assign({},a,{fieldNamePrefix:s,required:!1,showSystemFields:!0,filterVisible:i<5})));if(t)return t}}var index=Object.freeze({__proto__:null,OMIT_FIELDS:OMIT_FIELDS,getBaseFields:getBaseFields,getAmisFieldType:getAmisFieldType,getObjectFieldSubFields:getObjectFieldSubFields,getGridFieldSubFields:getGridFieldSubFields,getPermissionFields:getPermissionFields,getSelectFieldOptions:getSelectFieldOptions,convertSFieldToAmisField:convertSFieldToAmisField,getFieldSearchable:getFieldSearchable,getAmisStaticFieldType:getAmisStaticFieldType});const API_CACHE=100;function getReadonlyFormAdaptor(e){let a="";var t=_$1.filter(e,function(e){return e.name.indexOf(".")<0&&("select"==e.type&&e.options||("lookup"==e.type||"master_detail"==e.type)&&!e.reference_to)}),i=_$1.map(_$1.filter(e,function(e){return e.name.indexOf(".")<0&&("object"===e.type||"grid"===e.type)}),"name");return _$1.each(t,function(e){var t;_$1.includes(OMIT_FIELDS,e.name)||(e.name,e.options?(t=JSON.stringify({options:e.options}),a+=`var ${e.name}Options= (${t}).options;`):e.optionsFunction?a+=`var ${e.name}Options = eval(${e.optionsFunction.toString()})(api.data);`:e._optionsFunction&&(a+=`var ${e.name}Options = eval(${e._optionsFunction})(api.data);`),e.multiple?a+=`data.${e.name}__label = _.map(_.filter(${e.name}Options, function(option){return _.includes(data.${e.name}, option.value)}), 'label');`:a=(a+=`var ${e.name}Selected = _.find(${e.name}Options, function(option){return data.${e.name} == option.value});`)+`data.${e.name}__label = ${e.name}Selected ? ${e.name}Selected.label:null;`)}),`
|
|
653
712
|
if(payload.data.data){
|
|
654
713
|
var data = payload.data.data[0];
|
|
655
714
|
var gridAndObjectFieldsName = ${JSON.stringify(i)};
|
|
@@ -795,15 +854,15 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
795
854
|
})
|
|
796
855
|
api.data = {query: \`mutation{\${deleteArray.join(',')}}\`};
|
|
797
856
|
return api;
|
|
798
|
-
`,data:{ids:"${ids}"},headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}}const getFieldSchemaArray=e=>{let i=[];return i.length=0,_$1.forEach(e,e=>{e.group&&"null"!=e.group&&"-"!=e.group||(e.group="通用");var t=e.name,a=/\w+\.\w+/.test(t);"grid"!=e.type&&"object"!=e.type||(e.is_wide=!0),a||e.hidden||i.push(Object.assign({name:t},e,{permission:{allowEdit:!0}}))}),i},getSection=async(t,e,a,i,r)=>{a=_$1.filter(a,{group:i});if(a.length!=_$1.filter(a,["hidden",!0]).length){var s,
|
|
857
|
+
`,data:{ids:"${ids}"},headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}}const getFieldSchemaArray=e=>{let i=[];return i.length=0,_$1.forEach(e,e=>{e.group&&"null"!=e.group&&"-"!=e.group||(e.group="通用");var t=e.name,a=/\w+\.\w+/.test(t);"grid"!=e.type&&"object"!=e.type||(e.is_wide=!0),a||e.hidden||i.push(Object.assign({name:t},e,{permission:{allowEdit:!0}}))}),i},getSection=async(t,e,a,i,r)=>{a=_$1.filter(a,{group:i});if(a.length!=_$1.filter(a,["hidden",!0]).length){var s,o=[];for(const l of a){let e=l;"grid"===l.type?e=await getGridFieldSubFields(l,t):"object"===l.type&&(e=await getObjectFieldSubFields(l,t)),e.name.indexOf(".")<0&&(r.__formFields=t,(s=await convertSFieldToAmisField(e,e.readonly,r))&&o.push(s))}a=_$1.map(_$1.compact(_$1.map(o,"visibleOn")),e=>e),i={type:"fieldSet",title:i,collapsable:!0,body:o};return 0<a.length&&o.length===a.length&&(i.visibleOn=""+a.join(" || ")),i}},getSections=async(e,t,a)=>{var i=getFieldSchemaArray(t),r=[];for(const o in _$1.groupBy(i,"group")){var s=await getSection(t,e,i,o,a);0<s.body.length&&r.push(s)}return r};async function getFormBody(e,t,a){return getSections(e,t,a)}const defaultsDeep=(...e)=>{let t={};return toArray(e).reverse().forEach(e=>{mergeWith(t,e,(e,t)=>isArray(t)?t:void 0)}),t};function getBulkActions(e){return[{type:"button",level:"danger",label:"批量删除",actionType:"ajax",confirmText:"确定要删除吗",className:"hidden",id:"batchDelete",api:getBatchDelete(e.name)}]}async function getObjectCRUD(t,a,i){var{top:e,showDisplayAs:r=!1,crudClassName:s=""}=i,o=t.paging&&!1===t.paging.enabled,l=t.enable_tree,n=getBulkActions(t),d={headerToolbarClassName:"px-4 py-2 border-gray-300 bg-gray-100 border-solid border-b",footerToolbar:getObjectFooterToolbar(t,i.formFactor,{disableStatistics:!1===i.queryCount}),filter:!!i.filterVisible&&await getObjectFilter(t,a,i)};"SMALL"!==i.formFactor&&Object.assign(d,{bulkActions:0!=i.bulkActions&&n}),i.queryCount=!0,o||l?(i.top=5e4,d.footerToolbar=[],i.queryCount=!0):e&&(d.footerToolbar=[],i.queryCount=!1),d.headerToolbar=getObjectHeaderToolbar(t,i.formFactor,{showDisplayAs:r,hiddenCount:!1===i.queryCount});let c=null;n="listview_"+t.name;i.formFactor;{let e=t.NAME_FIELD_KEY||"name";"organizations"===t.name&&(e="name");o=await getTableSchema$1(a,Object.assign({idFieldName:t.idFieldName,labelFieldName:e},i));delete o.mode,c=Object.assign({},o,{type:"crud",primaryField:"_id",affixHeader:!1,id:n,name:n,keepItemSelectionOnPageChange:!0,api:await getTableApi(t,a,i),hiddenOn:i.tableHiddenOn,autoFillHeight:!1,className:"flex-auto "+(s||""),crudClassName:s},d)}l=i.defaults;if(l){e=l.listSchema||{},r=(c=defaultsDeep({},e,c),l.headerSchema),o=l.footerSchema;if(r||o){let e=[c];r&&(___default.isArray(r)?e=___default.union(r,e):e.unshift(r)),o&&(___default.isArray(o)?e=___default.union(e,o):e.push(o)),c=e}}return{type:"service",className:"",id:"service_"+n,name:"page",data:{objectName:t.name,_id:null,recordPermissions:t.permissions,uiSchema:t,loaded:!1},body:c}}const getGlobalData=e=>{var t=getSteedosAuth();return{mode:e,user:t,spaceId:t.spaceId,userId:t.userId}},getFormFields=(e,t)=>{const{fieldsExtend:a,fields:i,excludedFields:r}=t;let s={};if(___default.forEach(e.fields,(e,t)=>{lodash.has(e,"name")||(e.name=t),a&&a[t]?s[e.name]=Object.assign({},e,a[t],{name:e.name}):s[e.name]=e}),!___default.isEmpty(i)&&___default.isArray(i)){const o={};___default.each(i,(e,t)=>{s[e]&&(o[e]=Object.assign({},s[e],{sort_no:t}))}),s=o}return!___default.isEmpty(r)&&___default.isArray(r)&&___default.each(r,e=>{delete s[e]}),lodash.sortBy(___default.values(s),"sort_no")};async function getObjectForm(e,t){var{recordId:a,layout:i="normal",labelAlign:r,defaults:s}=t,o=___default.values(e.fields),l=getFormFields(e,t),s=s&&s.formSchema||{},i=(___default.has(s,"className")&&(s.className="steedos-amis-form"),{type:"service",className:"p-0",name:"page_edit_"+a,api:await getEditFormInitApi(e,a,o),data:{editFormInited:!1},initApi:null,initFetch:null,body:[defaultsDeep({},s,{type:"form",mode:i,data:{"&":"${initialValues}"},labelAlign:r,persistData:!1,promptPageLeave:!0,canAccessSuperData:!1,name:"form_edit_"+a,debug:!1,title:"",submitText:"",api:await getSaveApi(e,a,o),initFetch:"new"!=a,body:await getFormBody(o,l,t),panelClassName:"m-0 sm:rounded-lg shadow-none border-none",bodyClassName:"p-0",className:"steedos-amis-form",hiddenOn:"${editFormInited != true}",onEvent:{submitSucc:{weight:0,actions:[{actionType:"broadcast",args:{eventName:"@data.changed."+e.name},data:{objectName:""+e.name}}]}}})]});return s.id&&(i.id="service-"+s.id),i}async function getObjectDetail(e,t,a){var{layout:i="normal",labelAlign:r,formInitProps:s}=a,o=___default.values(e.fields),l=getFormFields(e,a),n="detail_"+t;return{type:"service",name:"page_readonly_"+t,id:n,data:{global:getGlobalData("read"),context:{rootUrl:getRootUrl(),tenantId:getTenantId(),authToken:getAuthToken()}},api:await getReadonlyFormInitApi(e,t,o,s),body:[{type:"wrapper",hiddenOn:"${recordLoaded != true}",className:"p-0 m-0",body:{type:"form",mode:i,labelAlign:r,persistData:!1,promptPageLeave:!1,name:"form_readonly_"+t,debug:!1,title:"",data:{formData:"$$"},wrapWithPanel:!1,body:await getFormBody(map(o,e=>(e.readonly=!0,e)),map(l,e=>(e.readonly=!0,e)),Object.assign({},a,{showSystemFields:!0})),className:"steedos-amis-form bg-white",actions:[],onEvent:{["@data.changed."+e.name]:{actions:[{actionType:"reload",componentId:n,expression:"this.__deletedRecord != true"},{args:{url:"/app/${appId}/${objectName}/grid/${side_listview_id}",blank:!1},actionType:"link",expression:"this.__deletedRecord === true"}]}}}}],onEvent:{fetchInited:{weight:0,actions:[{actionType:"broadcast",eventName:"recordLoaded",args:{eventName:"recordLoaded"},data:{record:"${event.data.__record}"}},{actionType:"setValue",args:{value:{recordLoaded:!0}}}]}}}}async function getTableColumns(e,t){var a=[{name:"_index",type:"text",width:32,placeholder:""}];for(const r of e)if(!r.is_name&&r.name!==t.labelFieldName||"cms_files"!==t.objectName)if("toggle"===r.type)a.push(Object.assign({},{type:"switch",name:r.name,label:r.label,width:r.width,toggled:r.toggled,disabled:!0,className:"whitespace-nowrap"},r.amis,{name:r.name}));else if("avatar"===r.type||"image"===r.type||"file"===r.type)a.push(Object.assign({},{type:"switch",name:r.name,label:r.label,width:r.width,toggled:r.toggled,disabled:!0,className:"whitespace-nowrap",...getAmisFileReadonlySchema(r)},r.amis,{name:r.name}));else{var i=await getFieldTpl(r,t);let e="text";i?e="tpl":"html"===r.type&&(e="markdown"),r.hidden||r.extra||a.push(Object.assign({},{name:r.name,label:r.label,sortable:r.sortable,width:r.width,type:e,tpl:i,toggled:r.toggled,className:"textarea"===r.type?"min-w-56 whitespace-pre-wrap textarea":"whitespace-nowrap",html:"html"===r.type||null},r.amis,{name:r.name}))}else{i=`
|
|
799
858
|
var data = event.data;
|
|
800
859
|
var file_name = data.versions ? data.name : "${r.label}";
|
|
801
860
|
var file_id = data._id;
|
|
802
861
|
SteedosUI.previewFile && SteedosUI.previewFile({file_name, file_id});
|
|
803
|
-
`;a.push({type:"button",label:`<%=data.versions ? data.name : "${r.label}"%>`,className:"whitespace-nowrap",level:"link",onEvent:{click:{actions:[{args:{api:{url:"${context.rootUrl}/api/files/files/${versions[0]}?download=true",method:"get",headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}},actionType:"download",expression:"!!!window?.nw?.require"},{args:{},actionType:"custom",script:i,expression:"!!window?.nw?.require"}]}}})}return a}function getMobileLines(e){let t=[],a=[],i=!1,r=!0,s="",
|
|
862
|
+
`;a.push({type:"button",label:`<%=data.versions ? data.name : "${r.label}"%>`,className:"whitespace-nowrap",level:"link",onEvent:{click:{actions:[{args:{api:{url:"${context.rootUrl}/api/files/files/${versions[0]}?download=true",method:"get",headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}},actionType:"download",expression:"!!!window?.nw?.require"},{args:{},actionType:"custom",script:i,expression:"!!window?.nw?.require"}]}}})}return a}function getMobileLines(e){let t=[],a=[],i=!1,r=!0,s="",o="flex items-center justify-between h-[20px]";return e.forEach(function(e){i&&t.length<2&&(t.push({type:"wrapper",body:a,size:"none",className:o}),a=[]),r?(s="steedos-listview-item-left truncate",e.field.is_wide&&(s="steedos-listview-item-wide truncate"),0===t.length&&(s+=" font-bold text-gray-800")):s="steedos-listview-item-right truncate ml-2 flex flex-shrink-0",a.push({type:"tpl",tpl:e.tpl,className:s}),i=e.field.is_wide?r=!0:r=!r}),a.length&&t.length<2&&t.push({type:"wrapper",body:a,size:"none",className:o}),t}async function getMobileTableColumns(e,t){var a=[];let i={};var r=[];for(const o of e){let e="";e=(e=o.is_name||o.name===t.labelFieldName?(i=o,t.onlyDisplayLabel=!0,await getFieldTpl(o,t)):"avatar"===o.type||"image"===o.type||"file"===o.type?`\${_display.${o.name}.name}`:("lookup"!==o.type&&"master_detail"!==o.type||(t.onlyDisplayLabel=!0),await getFieldTpl(o,t)))||`\${${o.name}}`,o.hidden||o.extra||r.push({field:o,tpl:e})}var e=getNameTplUrl(i,t),s=getMobileLines(r);return a.push({name:i.name,label:i.label,sortable:i.sortable,type:"button",level:"link",actionType:"link",link:e,innerClassName:"steedos-listview-item block text-gray-500",body:{type:"wrapper",body:s,size:"none",className:"p-1"}}),a}function getDefaultParams(e){return{perPage:e.top||e.perPage||config.listView.perPage}}function getButtonVisibleOn(e){let t=e.visible;if(e._visible&&(t=e._visible),t=isBoolean(t)?t.toString():t)return t.trim().startsWith("function")?t+"(objectName, _id, recordPermissions, data)":t;if("amis_button"===e.type){e=e.amis_schema;if(e&&e.body&&0<e.body.length)return e.body[0].visibleOn}}async function getTableOperation(e){e=e.buttons;const t=[];if(each(e,e=>{isBoolean(e.visible)&&(e.visible=e.visible.toString()),t.push({type:"steedos-object-button",name:e.name,objectName:e.objectName,visibleOn:getButtonVisibleOn(e),className:"antd-Button--default"})}),!(t.length<1))return{type:"operation",label:"操作",fixed:"right",labelClassName:"text-center",className:"text-center steedos-listview-operation w-20",buttons:[{type:"steedos-dropdown-button",label:"xxx",buttons:t,placement:"bottomRight",overlayClassName:"shadow !min-w-[160px]",trigger:["click"],id:"u:c2140a365019",onOpenApi:{url:"${context.rootUrl}/service/api/@${objectName}/recordPermissions/${_id}",method:"get",data:{$:"$$",objectName:"${objectName}",listViewId:"${listViewId}",appId:"${appId}",formFactor:"${formFactor}",context:"${context}"},responseData:{recordPermissions:"$$"},headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"},adaptor:`
|
|
804
863
|
payload.recordPermissions = payload;
|
|
805
864
|
return payload;
|
|
806
|
-
`}}]}}async function getTableSchema$1(e,t){let a=[];return"SMALL"===(t=t||{}).formFactor?a=await getMobileTableColumns(e,t):(a=await getTableColumns(e,t)).push(await getTableOperation(t)),{mode:"table",name:"thelist",headerToolbarClassName:"py-2 px-2 border-gray-300 bg-gray-100 border-solid border-b",className:"",draggable:!1,defaultParams:getDefaultParams(t),columns:a,syncLocation:!1,keepItemSelectionOnPageChange:!0,checkOnItemClick:!1,labelTpl:`\${${t.labelFieldName}}`,autoFillHeight:!1,columnsTogglable:!1}}async function getTableApi(e,t,a){const i=[];let{filter:r,filtersFunction:s,sort:
|
|
865
|
+
`}}]}}async function getTableSchema$1(e,t){let a=[];return"SMALL"===(t=t||{}).formFactor?a=await getMobileTableColumns(e,t):(a=await getTableColumns(e,t)).push(await getTableOperation(t)),{mode:"table",name:"thelist",headerToolbarClassName:"py-2 px-2 border-gray-300 bg-gray-100 border-solid border-b",className:"",draggable:!1,defaultParams:getDefaultParams(t),columns:a,syncLocation:!1,keepItemSelectionOnPageChange:!0,checkOnItemClick:!1,labelTpl:`\${${t.labelFieldName}}`,autoFillHeight:!1,columnsTogglable:!1}}async function getTableApi(e,t,a){const i=[];let{filter:r,filtersFunction:s,sort:o,top:l,setDataToComponentId:n=""}=a,d=null;(r=(r=_$1.isArray(r)?_$1.map(r,function(e){return e.operation?[e.field,e.operation,e.value]:e}):r)||[])&&(d=r),_$1.each(t,function(e){e.searchable&&i.push(e.name)});const c={},p=[];t.forEach(e=>{_$1.includes(["image","avatar","file"],e.type)&&(p.push(e.name),c[e.name]={name:e.name,type:e.type,multiple:e.multiple})});var u=e.key_field||"_id",t=await getApi(e,null,t,{count:a.queryCount,alias:"rows",limit:l,queryOptions:'filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"'});return t.data.$term="$term",t.data.$self="$$",t.data.filter="$filter",t.data.loaded="${loaded}",t.data.listViewId="${listViewId}",t.requestAdaptor=`
|
|
807
866
|
// selfData 中的数据由 CRUD 控制. selfData中,只能获取到 CRUD 给定的data. 无法从数据链中获取数据.
|
|
808
867
|
let selfData = JSON.parse(JSON.stringify(api.data.$self));
|
|
809
868
|
try{
|
|
@@ -857,7 +916,7 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
857
916
|
var orderBy = api.data.orderBy || '';
|
|
858
917
|
var orderDir = api.data.orderDir || '';
|
|
859
918
|
var sort = orderBy + ' ' + orderDir;
|
|
860
|
-
sort = orderBy ? sort : "${
|
|
919
|
+
sort = orderBy ? sort : "${o||""}";
|
|
861
920
|
var allowSearchFields = ${JSON.stringify(i)};
|
|
862
921
|
if(api.data.$term){
|
|
863
922
|
userFilters = [["name", "contains", "'+ api.data.$term +'"]];
|
|
@@ -1025,13 +1084,13 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
1025
1084
|
// 标记加载过,后续优先从本地存储中加载相关参数
|
|
1026
1085
|
payload.data.loaded= true;
|
|
1027
1086
|
|
|
1028
|
-
const setDataToComponentId = "${
|
|
1087
|
+
const setDataToComponentId = "${n}";
|
|
1029
1088
|
if(setDataToComponentId){
|
|
1030
1089
|
SteedosUI.getRef(api.body.$self.$scopeId)?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
|
|
1031
1090
|
};
|
|
1032
1091
|
${a.adaptor||""}
|
|
1033
1092
|
return payload;
|
|
1034
|
-
`,t}async function getApi(e,t,a,i){e=await getFindQuery(e,t,a,i);return{method:"post",url:getApi$2(),data:e,headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}}function getRecordPermissionsApi(e,t,a){e=getRecordPermissionsQuery(e,t,a);return{method:"post",url:getApi$2(),data:e,headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}}const DEFAULT_CALENDAR_OPTIONS={startDateExpr:"start",endDateExpr:"end",allDayExpr:"is_all_day",textExpr:"name"};async function getCalendarApi(e,t,a){var i=(a=a||{}).calendarOptions;const r=[];let{filter:s,sort:
|
|
1093
|
+
`,t}async function getApi(e,t,a,i){e=await getFindQuery(e,t,a,i);return{method:"post",url:getApi$2(),data:e,headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}}function getRecordPermissionsApi(e,t,a){e=getRecordPermissionsQuery(e,t,a);return{method:"post",url:getApi$2(),data:e,headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}}const DEFAULT_CALENDAR_OPTIONS={startDateExpr:"start",endDateExpr:"end",allDayExpr:"is_all_day",textExpr:"name"};async function getCalendarApi(e,t,a){var i=(a=a||{}).calendarOptions;const r=[];let{filter:s,sort:o,top:l,setDataToComponentId:n=""}=a;l=l||200,s=(s=___default.isArray(s)?___default.map(s,function(e){return e.operation?[e.field,e.operation,e.value]:e}):s)||[],___default.each(t,function(e){e.searchable&&r.push(e.name)});var a=e.idFieldName||"_id",d=e.key_field||"_id",e=await getApi(e,null,t,{alias:"rows",limit:l,queryOptions:'filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"'});return e.data.$term="$term",e.data.$self="$$",e.data.filter="$filter",e.data.pageSize=l||10,e.requestAdaptor=`
|
|
1035
1094
|
let selfData = JSON.parse(JSON.stringify(api.data.$self));
|
|
1036
1095
|
var filters = api.data.filter || ${JSON.stringify(s)} || [];
|
|
1037
1096
|
const eventFetchInfo = selfData.fetchInfo;
|
|
@@ -1049,7 +1108,7 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
1049
1108
|
var orderBy = api.data.orderBy || '';
|
|
1050
1109
|
var orderDir = api.data.orderDir || '';
|
|
1051
1110
|
var sort = orderBy + ' ' + orderDir;
|
|
1052
|
-
sort = orderBy ? sort : "${
|
|
1111
|
+
sort = orderBy ? sort : "${o}";
|
|
1053
1112
|
var allowSearchFields = ${JSON.stringify(r)};
|
|
1054
1113
|
if(api.data.$term){
|
|
1055
1114
|
filters = [["name", "contains", "'+ api.data.$term +'"]];
|
|
@@ -1113,7 +1172,7 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
1113
1172
|
return api;
|
|
1114
1173
|
`,e.adaptor=`
|
|
1115
1174
|
window.postMessage(Object.assign({type: "listview.loaded"}), "*");
|
|
1116
|
-
const setDataToComponentId = "${
|
|
1175
|
+
const setDataToComponentId = "${n}";
|
|
1117
1176
|
if(setDataToComponentId){
|
|
1118
1177
|
SteedosUI.getRef(api.body.$self.scopeId)?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
|
|
1119
1178
|
}
|
|
@@ -1162,7 +1221,7 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
1162
1221
|
revert && revert();
|
|
1163
1222
|
}
|
|
1164
1223
|
return payload;
|
|
1165
|
-
`,headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}}async function getObjectCalendar(t,e,a){var i=t.permissions,r=(a=a||{},(e=Object.assign({},DEFAULT_CALENDAR_OPTIONS,omitBy(e,isNil))).title||[e.startDateExpr,e.endDateExpr,e.allDayExpr,e.textExpr]);let s=[],
|
|
1224
|
+
`,headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"}}}async function getObjectCalendar(t,e,a){var i=t.permissions,r=(a=a||{},(e=Object.assign({},DEFAULT_CALENDAR_OPTIONS,omitBy(e,isNil))).title||[e.startDateExpr,e.endDateExpr,e.allDayExpr,e.textExpr]);let s=[],o=(each(r,function(e){t.fields[e]&&s.push(t.fields[e])}),t.fields[e.allDayExpr]&&s.push(t.fields[e.allDayExpr]),a.sort||(r=a.sortField,a.sortOrder,r&&0),e.currentView);if(o)switch(o){case"day":o="timeGridDay";break;case"week":o="timeGridWeek";break;case"month":o="dayGridMonth";break;case"agenda":o="timeGridDay"}else o="timeGridWeek";a.calendarOptions=e;var r=await getCalendarApi(t,s,a),a=`
|
|
1166
1225
|
const api = ${JSON.stringify(r)};
|
|
1167
1226
|
event.data.calendarOptions = ${JSON.stringify(e)};
|
|
1168
1227
|
doAction({
|
|
@@ -1213,7 +1272,7 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
1213
1272
|
"size": "lg"
|
|
1214
1273
|
}
|
|
1215
1274
|
});
|
|
1216
|
-
`,
|
|
1275
|
+
`,l=getCalendarRecordPermissionsApi(t,"${event.id}"),n=getCalendarRecordSaveApi(t,e),d={daysOfWeek:[1,2,3,4,5],startTime:"08:00",endTime:"18:00"},e=(isEmpty(e.startDayHour)||(d.startTime=e.startDayHour+":00"),isEmpty(e.endDayHour)||(d.endTime=e.endDayHour+":00"),{type:"steedos-fullcalendar",label:"",name:"fullcalendar",editable:i.allowEdit,selectable:i.allowCreate,selectMirror:i.allowCreate,initialView:o,businessHours:d,onEvent:{getEvents:{weight:0,actions:[{componentId:"",args:{},actionType:"custom",script:a}]},select:{weight:0,actions:[{componentId:"",args:{},actionType:"custom",script:r}]},eventClick:{weight:0,actions:[{componentId:"",args:{},actionType:"custom",script:`
|
|
1217
1276
|
const data = event.data;
|
|
1218
1277
|
const eventData = data.event;
|
|
1219
1278
|
const appId = data.appId;
|
|
@@ -1238,11 +1297,11 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
1238
1297
|
"actions": []
|
|
1239
1298
|
}
|
|
1240
1299
|
});
|
|
1241
|
-
`}]},eventAdd:{weight:0,actions:[{componentId:"",args:{},actionType:"custom",script:"console.log('eventAdd'); console.log(event);"}]},eventChange:{weight:0,actions:[{actionType:"ajax",args:{api:
|
|
1300
|
+
`}]},eventAdd:{weight:0,actions:[{componentId:"",args:{},actionType:"custom",script:"console.log('eventAdd'); console.log(event);"}]},eventChange:{weight:0,actions:[{actionType:"ajax",args:{api:l}},{actionType:"toast",expression:"!event.data.editable",args:{msgType:"error",msg:"您没有编辑该记录的权限!",position:"top-center"}},{actionType:"ajax",expression:"event.data.editable",args:{api:n,messages:{success:t.label+"修改成功",failed:t.label+"修改失败!"}}}]},eventRemove:{weight:0,actions:[{componentId:"",args:{},actionType:"custom",script:"console.log('eventRemove'); console.log(event);"}]},eventsSet:{weight:0,actions:[{componentId:"",args:{},actionType:"custom",script:"console.log('eventsSet'); console.log(event);"}]}}});return e}const getGraphqlFieldsQuery=e=>{const t=["_id"];return e.push("record_permissions"),each(e,e=>{-1<e.indexOf(".")&&(e=e.split(".")[0]),t.push(""+e)}),""+t.join(" ")},getFindOneQuery=(e,t,a)=>{e=e.replace(/\./g,"_");a=getGraphqlFieldsQuery(a);let i="";t=[`id: "${t}"`];return`{record:${e}__findOne${i=0<t.length?`(${t.join(",")})`:i}{${a}}}`},getRecord=async(e,t,a)=>{return(await fetchAPI("/graphql",{method:"post",body:JSON.stringify({query:getFindOneQuery(e,t,a)})})).data.record},getRelatedsCount=async(t,e)=>{const a=[];each(e,e=>{a.push(`${e.object_name}: ${e.object_name}__count(filters: [["${e.foreign_key}","=","${t}"]])`)});e=`
|
|
1242
1301
|
{
|
|
1243
1302
|
${a.join(",")}
|
|
1244
1303
|
}
|
|
1245
|
-
`;return(await fetchAPI("/graphql",{method:"POST",body:JSON.stringify({query:e})})).data},getRecordPermissions=async(e,t)=>{return await fetchAPI(`/service/api/@${e}/recordPermissions/`+t,{method:"GET"})};function str2function(e,...t){try{return new Function(...t,e)}catch(e){return console.warn(e),null}}const getRelatedFieldValue=(e,t,a,i)=>{a=find(a.fields,e=>i===e?.name);return isString(a.reference_to)?a.multiple?[t]:t:{o:e,ids:[t]}};async function getObjectRelatedList(e,t,a){var i=await getUISchema(e),r=[],s=[].concat(i.related_lists||[]);if(isEmpty(s))for(const o of[].concat(i.details||[])){var l=o.split(".");r.push({masterObjectName:e,object_name:l[0],foreign_key:l[1]})}else for(const d of s){var n=d.related_field_fullname.split(".");r.push({masterObjectName:e,object_name:n[0],foreign_key:n[1],label:d.label,columns:d.field_names,sort:d.sort,filters:d.filters,visible_on:d.visible_on,page_size:d.page_size})}return r}async function getRecordDetailRelatedListSchema(e,t,a,i,r){let{top:s,perPage:l,hiddenEmptyTable:n,appId:o,relatedLabel:d,className:c}=r;var p=await getUISchema(a),u=p["label"];if(d=d||u,!i){var m={},u=await getUISchema(e);if(u){var f=u.related_lists||[];if(isEmpty(f))for(const h of u.details||[]){var g=h.split(".");m[g[0]]=g[1]}else for(const v of f){var y=v.related_field_fullname.split(".");m[y[0]]=y[1]}}i=m[a]}let _=null;u=await getField(a,i);if(!u)return{uiSchema:p,amisSchema:{type:"alert",body:`未找到与相关列表对象${a}关联的相关表字段`,level:"warning",showIcon:!0,className:"mb-3"}};let b=t;u.reference_to_field&&"_id"!=u.reference_to_field&&(f=await getRecord(e,t,[u.reference_to_field]),b=f[u.reference_to_field]),_=u._reference_to||u.reference_to&&!isString(u.reference_to)?[[i+"/o","=",e],[i+"/ids","=",b]]:[""+i,"=",b];t=await getObjectRecordDetailRelatedListHeader(p,d),f="steedos-record-related-list-"+a,u=(await getRelatedListSchema(a,"all",{globalFilter:_,defaults:{listSchema:{headerToolbar:[],columnsTogglable:!1,onEvent:{["@data.changed."+a]:{actions:[{actionType:"reload"}]}}},headerSchema:t},showHeader:!0,top:s,perPage:l,setDataToComponentId:f,tableHiddenOn:n?"this.$count === 0":null,appId:o,crudClassName:"border-t border-slate-300",...r})).amisSchema;return u?{uiSchema:p,amisSchema:{type:"service",id:f,className:"steedos-record-related-list rounded border border-slate-300 bg-gray-100 mb-4 "+c,data:{"&":"$$",appId:"${appId}",app_id:"${appId}",masterObjectName:e,masterRecordId:"${recordId}",relatedKey:i,objectName:a,listViewId:`amis-\${appId}-${a}-listview`,_isRelated:!0},body:[{...u,data:{"&":"$$",appId:"${appId}",app_id:"${appId}",relatedKey:i,objectName:"${objectName}",recordId:"${masterRecordId}",defaultData:{[i]:getRelatedFieldValue(e,b,p,i)}}}]}}:void 0}function getDefaultRelatedListProps(e,a,t){var i=find(e.list_views,(e,t)=>"calendar"!==e.type&&t===(a=a||t));let r=[],s="",l=null,n=null;return i?(r=getListViewColumns(i,t.formFactor),s=getListViewSort(i),l=getListViewFilter(i),isArray(t.globalFilter)&&t.globalFilter.length&&isArray(l)&&l.length?l=[t.globalFilter,"and",l]:!t.globalFilter||l&&l.length||(l=t.globalFilter),n=i&&i._filters):(i=find(e.fields,(e,t)=>e.is_name),r=i?[i.name]:["name"],t.globalFilter&&(l=t.globalFilter)),{columns:r,sort:s,filter:l,filtersFunction:n}}function getRelatedListProps(e,t,a){if(a.columns){var i=getListViewSort(a.sort);let{filters:e,filtersFunction:t}=a;return!t&&e&&(t=str2function(e,"filters","data")),{columns:a.columns,sort:i,filter:a.globalFilter,filtersFunction:t}}return getDefaultRelatedListProps(e,t,a)}async function getRelatedListSchema(e,t,a){var i=await getUISchema(e),r=i.list_views,{columns:s,sort:l,filter:n,filtersFunction:o}=getRelatedListProps(i,t,a),d=a.defaults||{},t=(!d.headerSchema&&a.showHeader&&(d.headerSchema=await getObjectListHeader(i,t)),a.showHeader||(d.headerSchema=null),a.defaults=d,delete a.filtersFunction,delete a.sort,delete a.extraColumns,delete a.filters,delete a.globalFilter,{type:"steedos-object-table",objectApiName:e,columns:s,extraColumns:r.extra_columns,filters:n,filtersFunction:o,sort:l,ctx:a});return{uiSchema:i,amisSchema:t}}let UI_SCHEMA_CACHE={},UISchemaFunction;const setUISchemaFunction=function(e){UISchemaFunction=e},setUISchemaCache=("undefined"!=typeof window&&(window.UI_SCHEMA_CACHE||(window.UI_SCHEMA_CACHE=UI_SCHEMA_CACHE),UI_SCHEMA_CACHE=window.UI_SCHEMA_CACHE),(e,t)=>{UI_SCHEMA_CACHE[e]=t}),getUISchemaCache=e=>cloneDeep(UI_SCHEMA_CACHE[e]),hasUISchemaCache=e=>has(UI_SCHEMA_CACHE,e);function getListViewColumns(e,t){let a=[];return a="SMALL"===t?isEmpty(e.mobile_columns)?slice(e.columns,0,4):e.mobile_columns:e.columns}function getListViewSort(e){let i="";return e&&e.sort&&e.sort.length&&each(e.sort,function(e,t){var a;isArray(e)?(a=e[0]+" "+(e[1]||""),a=0<t?","+a:a,i+=a):(a=e.field_name+" "+e.order,a=0<t?","+a:a,i+=a)}),i}function getListViewFilter(t){if(t)try{var a=getUserId();let e=t.filters;if("mine"===t.filter_scope)if(___default.isEmpty(e))e=[["owner","=",a]];else{if(___default.isString(e)&&___default.startsWith(___default.trim(e),"function")&&(e=(e=new Function("return "+e))()),!___default.isArray(e))throw console.debug("listView filters is not array",t),new Error("filters is not array");e.push(["owner","=",a])}return e}catch(e){console.error(e)}}function formatUISchemaCache(objectName,uiSchema){setUISchemaCache(objectName,uiSchema),each(uiSchema.fields,field=>{try{"lookup"===field.type&&field._reference_to&&___default.isString(field._reference_to)&&(field.reference_to=eval(`(${field._reference_to})`)())}catch(exception){field.reference_to=void 0,console.error(exception)}}),each(uiSchema.list_views,(e,t)=>{e.name=t,has(e,"columns")||(e.columns=uiSchema.list_views.all.columns)})}async function getUISchema(t,a){if(t){if(!hasUISchemaCache(t)||a){let e=null;try{if(!(e=UISchemaFunction?await UISchemaFunction(t,a):await fetchAPI(`/service/api/@${t.replace(/\./g,"_")}/uiSchema`,{method:"get"})))return;formatUISchemaCache(t,e)}catch(e){console.error("getUISchema",t,e),setUISchemaCache(t,null)}}return getUISchemaCache(t)}}function getUISchemaSync(t,e){if(t){if(!hasUISchemaCache(t)||e)try{var a,i=`/service/api/@${t.replace(/\./g,"_")}/uiSchema`;if(!(a=Steedos.authRequest(i,{type:"GET",async:!1})))return;formatUISchemaCache(t,a)}catch(e){console.error("getUISchema",t,e),setUISchemaCache(t,null)}return getUISchemaCache(t)}}async function getField(e,t){return(await getUISchema(e))?.fields[t]}async function getFormSchema(e,t){e=await getUISchema(e);return{uiSchema:e,amisSchema:await getObjectForm(e,t)}}async function getViewSchema(e,t,a){e=await getUISchema(e);return{uiSchema:e,amisSchema:await getObjectDetail(e,t,a)}}async function getListSchema(e,t,a,i={}){var r=await getUISchema(t),s=find(r.list_views,(e,t)=>t===(a=a||t)||e._id===a);if(!s)return{uiSchema:r};if(s.enable_amis_schema&&s.amis_schema){const f=isString(s.amis_schema)?JSON.parse(s.amis_schema):s.amis_schema;return{uiSchema:r,isCustomAmisSchema:!0,amisSchema:f}}var l=getListViewColumns(s,i.formFactor),n=getListViewSort(s),o=getListViewFilter(s),d=s&&s._filters;if("calendar"===s.type){const f={type:"steedos-object-calendar",objectApiName:t,filters:o,filtersFunction:d,sort:n,...s.options};return{uiSchema:r,isCalendar:!0,amisSchema:f}}var c=i.defaults||{};!c.headerSchema&&i.showHeader&&(c.headerSchema=await getObjectListHeader$1(r)),i.showHeader||(c.headerSchema=null);try{var p,u=location.pathname+"/crud/"+i.listViewId,m=sessionStorage.getItem(u);m&&(m=JSON.parse(m),p={},m.orderBy&&(p.orderBy=m.orderBy),m.orderDir&&(p.orderDir=m.orderDir),c.listSchema=defaultsDeep$1({},p,c.listSchema||{}))}catch(e){console.error("本地存储中crud参数解析异常:",e)}i.defaults=c;const f={type:"steedos-object-table",objectApiName:t,columns:l,extraColumns:s.extra_columns,filters:o,filtersFunction:d,sort:n,ctx:i,requestAdaptor:s.requestAdaptor,adaptor:s.adaptor};return{uiSchema:r,amisSchema:f}}async function getTableSchema(e,t,a,i={}){const r=await getUISchema(t);let s=i.sort;s||(n=i.sortField,o=i.sortOrder,n&&(s=n+" "+o||"asc"));let l=[];each(a,function(e){isString(e)&&r.fields[e]?l.push(r.fields[e]):isObject$1(e)&&r.fields[e.field]&&l.push(Object.assign({},r.fields[e.field],{width:e.width,wrap:e.wrap,amis:e.amis}))});var n=i.extraColumns,o=(n&&each(n,function(e){isString(e)?l.push({extra:!0,name:e}):isObject$1(e)&&l.push({extra:!0,name:e.field})}),await getObjectCRUD(r,l,{tabId:t,appId:e,objectName:t,...i,filter:i.filters,sort:s,buttons:await getListViewItemButtons(r,i)}));return{uiSchema:r,amisSchema:o}}async function getCalendarSchema(e,t,a,i={}){var r=await getUISchema(t);return{uiSchema:r,amisSchema:await getObjectCalendar(r,a,{tabId:t,appId:e,objectName:t,...i})}}async function getRecordDetailHeaderSchema(e,t,a){e=await getUISchema(e);return{uiSchema:e,amisSchema:await getObjectRecordDetailHeader(e,t,a)}}async function getRecordDetailSchema(e,t,a={}){var i=await getUISchema(e),r={type:"tabs",className:"sm:mt-3 bg-white sm:shadow sm:rounded sm:border border-slate-300 p-4",tabs:[{title:"详细",className:"px-0 py-4",body:[{type:"steedos-object-form",label:"对象表单",objectApiName:"${objectName}",recordId:"${recordId}",id:"u:d4a495811d57",appId:t}],id:"u:5d4e7e3f6ecc"}],id:"u:a649e4094a12"};return(await getObjectRelatedList(e)).length&&r.tabs.push({title:"相关",className:"px-0 pt-4",body:[{type:"steedos-object-related-lists",label:"相关列表",objectApiName:"${objectName}",recordId:"${recordId}",id:"u:3b85b7b7a7f6",appId:t}],id:"u:1a0326aeec2b"}),{uiSchema:i,amisSchema:{type:"service",body:[{type:"steedos-record-detail-header",label:"标题面板",objectApiName:"${objectName}",recordId:"${recordId}",id:"u:48d2c28eb755",onEvent:{recordLoaded:{actions:[{actionType:"reload",data:{name:`\${event.data.record.${i?.NAME_FIELD_KEY||"name"}}`,record:"${event.data.record}",recordLoaded:!0}},{actionType:"reload",componentId:`page_readonly_${e}_header`,data:{name:`\${event.data.record.${i?.NAME_FIELD_KEY||"name"}}`,record:"${event.data.record}",recordLoaded:!0}}]}}},r],data:{"_master.objectName":"${objectName}","_master.recordId":"${recordId}"},onEvent:{recordLoaded:{actions:[{actionType:"reload",data:{name:`\${record.${i.NAME_FIELD_KEY||"name"}}`,"_master.record":"${record}","_master.objectName":"${objectName}","_master.recordId":"${recordId}"}}]},...a.onEvent}}}}async function getObjectRelated({appName:e,masterObjectName:t,objectName:a,relatedFieldName:i,recordId:r,formFactor:s}){let l=null;var n=await getField(a,i),n=(l=n._reference_to||n.reference_to&&!isString(n.reference_to)?[[i+"/o","=",t],[i+"/ids","=",r]]:[""+i,"=",r],await getUISchema(t));return{masterObjectName:t,object_name:a,foreign_key:i,schema:await getListSchema(e,a,"all",{globalFilter:l,formFactor:s}),record:await getRecord(t,r,[n.NAME_FIELD_KEY]),masterObjectUISchema:n}}function getScopeId(e,t){return`page_${e}_`+t}async function getFormPageInitSchema(e){var t=await getFormSchema(e,{recordId:"${recordId}"});return{type:"page",name:getScopeId(e,"form"),bodyClassName:"",regions:["body"],body:[t.amisSchema]}}async function getListPageInitSchema(e,t,a){return{type:"page",name:getScopeId(e,"list"),bodyClassName:"",regions:["body"],body:[{type:"steedos-object-listview",objectApiName:e,columnsTogglable:!1,showHeader:!0,className:"sm:border bg-white sm:shadow sm:rounded border-slate-300 border-solid"}]}}async function getRecordPageInitSchema(e){var t=await getObjectRelatedList(e),a=[{type:"steedos-record-detail-header",label:"标题面板",objectApiName:"${objectName}",recordId:"${recordId}",onEvent:{recordLoaded:{actions:[{actionType:"setValue",args:{value:{recordLoaded:!0}}},{actionType:"reload",data:{name:`\${record.${(await getUISchema(e))?.NAME_FIELD_KEY||"name"}}`,record:"${record}",recordLoaded:!0}}]}}}],i={type:"tabs",tabs:[{title:"详情",body:[{type:"steedos-object-form",label:"对象表单",mode:"read",objectApiName:"${objectName}",recordId:"${recordId}",labelAlign:"left"}]}],className:"sm:mt-3 flex flex-col region-main bg-white sm:shadow sm:rounded sm:border border-slate-300",linksClassName:"pl-4 pt-2"};return t.length&&i.tabs.push({title:"相关",body:{type:"steedos-object-related-lists",label:"所有相关表",objectApiName:"${objectName}",recordId:"${recordId}"}}),a.push(i),{type:"page",id:`page_${e}_record_detail`,name:getScopeId(e,"record_detail"),bodyClassName:"",regions:["body"],body:a}}async function getListviewInitSchema(t,a,i){i=i||{};var r=await getUISchema(t),s=find(r.list_views,(e,t)=>t===a);let l={};if(s){var n=getListViewColumns(s,i.formFactor),s=getListViewSort(s),o=i.defaults||{};o.headerSchema||(r=await getObjectListHeader$1(r),o.headerSchema=r),i.defaults=o;let e=i.setDataToComponentId;e=e||"service_listview_"+t;r=await getTableSchema(null,t,n,{sort:s,...i,setDataToComponentId:e});delete(l=r.amisSchema).data.$master,delete l.data._id,delete l.data.recordPermissions,delete l.data.uiSchema}return l}async function getApps(){return await fetchAPI("/service/api/apps/menus")}async function getApp(e){return await fetchAPI(`/service/api/apps/${e}/menus`)}"undefined"!=typeof window&&(window.getUISchema=getUISchema,window.getUISchemaSync=getUISchemaSync);const getNotifications=async()=>{var e=getSteedosAuth(),e=`
|
|
1304
|
+
`;return(await fetchAPI("/graphql",{method:"POST",body:JSON.stringify({query:e})})).data},getRecordPermissions=async(e,t)=>{return await fetchAPI(`/service/api/@${e}/recordPermissions/`+t,{method:"GET"})};function str2function(e,...t){try{return new Function(...t,e)}catch(e){return console.warn(e),null}}const getRelatedFieldValue=(e,t,a,i)=>{a=find(a.fields,e=>i===e?.name);return isString(a.reference_to)?a.multiple?[t]:t:{o:e,ids:[t]}};async function getObjectRelatedList(e,t,a){var i=await getUISchema(e),r=[],s=[].concat(i.related_lists||[]);if(isEmpty(s))for(const n of[].concat(i.details||[])){var o=n.split(".");r.push({masterObjectName:e,object_name:o[0],foreign_key:o[1]})}else for(const d of s){var l=d.related_field_fullname.split(".");r.push({masterObjectName:e,object_name:l[0],foreign_key:l[1],label:d.label,columns:d.field_names,sort:d.sort,filters:d.filters,visible_on:d.visible_on,page_size:d.page_size})}return r}async function getRecordDetailRelatedListSchema(e,t,a,i,r){let{top:s,perPage:o,hiddenEmptyTable:l,appId:n,relatedLabel:d,className:c}=r;var p=await getUISchema(a),u=p["label"];if(d=d||u,!i){var m={},u=await getUISchema(e);if(u){var f=u.related_lists||[];if(isEmpty(f))for(const h of u.details||[]){var g=h.split(".");m[g[0]]=g[1]}else for(const v of f){var y=v.related_field_fullname.split(".");m[y[0]]=y[1]}}i=m[a]}let _=null;u=await getField(a,i);if(!u)return{uiSchema:p,amisSchema:{type:"alert",body:`未找到与相关列表对象${a}关联的相关表字段`,level:"warning",showIcon:!0,className:"mb-3"}};let b=t;u.reference_to_field&&"_id"!=u.reference_to_field&&(f=await getRecord(e,t,[u.reference_to_field]),b=f[u.reference_to_field]),_=u._reference_to||u.reference_to&&!isString(u.reference_to)?[[i+"/o","=",e],[i+"/ids","=",b]]:[""+i,"=",b];t=await getObjectRecordDetailRelatedListHeader(p,d),f="steedos-record-related-list-"+a,u=(await getRelatedListSchema(a,"all",{globalFilter:_,defaults:{listSchema:{headerToolbar:[],columnsTogglable:!1,onEvent:{["@data.changed."+a]:{actions:[{actionType:"reload"}]}}},headerSchema:t},showHeader:!0,top:s,perPage:o,setDataToComponentId:f,tableHiddenOn:l?"this.$count === 0":null,appId:n,crudClassName:"border-t border-slate-300",...r})).amisSchema;return u?{uiSchema:p,amisSchema:{type:"service",id:f,className:"steedos-record-related-list rounded border border-slate-300 bg-gray-100 mb-4 "+c,data:{"&":"$$",appId:"${appId}",app_id:"${appId}",masterObjectName:e,masterRecordId:"${recordId}",relatedKey:i,objectName:a,listViewId:`amis-\${appId}-${a}-listview`,_isRelated:!0},body:[{...u,data:{"&":"$$",appId:"${appId}",app_id:"${appId}",relatedKey:i,objectName:"${objectName}",recordId:"${masterRecordId}",defaultData:{[i]:getRelatedFieldValue(e,b,p,i)}}}]}}:void 0}function getDefaultRelatedListProps(e,a,t){var i=find(e.list_views,(e,t)=>"calendar"!==e.type&&t===(a=a||t));let r=[],s="",o=null,l=null;return i?(r=getListViewColumns(i,t.formFactor),s=getListViewSort(i),o=getListViewFilter(i),isArray(t.globalFilter)&&t.globalFilter.length&&isArray(o)&&o.length?o=[t.globalFilter,"and",o]:!t.globalFilter||o&&o.length||(o=t.globalFilter),l=i&&i._filters):(i=find(e.fields,(e,t)=>e.is_name),r=i?[i.name]:["name"],t.globalFilter&&(o=t.globalFilter)),{columns:r,sort:s,filter:o,filtersFunction:l}}function getRelatedListProps(e,t,a){if(a.columns){var i=getListViewSort(a.sort);let{filters:e,filtersFunction:t}=a;return!t&&e&&(t=str2function(e,"filters","data")),{columns:a.columns,sort:i,filter:a.globalFilter,filtersFunction:t}}return getDefaultRelatedListProps(e,t,a)}async function getRelatedListSchema(e,t,a){var i=await getUISchema(e),r=i.list_views,{columns:s,sort:o,filter:l,filtersFunction:n}=getRelatedListProps(i,t,a),d=a.defaults||{},t=(!d.headerSchema&&a.showHeader&&(d.headerSchema=await getObjectListHeader(i,t)),a.showHeader||(d.headerSchema=null),a.defaults=d,delete a.filtersFunction,delete a.sort,delete a.extraColumns,delete a.filters,delete a.globalFilter,{type:"steedos-object-table",objectApiName:e,columns:s,extraColumns:r.extra_columns,filters:l,filtersFunction:n,sort:o,ctx:a});return{uiSchema:i,amisSchema:t}}let UI_SCHEMA_CACHE={},UISchemaFunction;const setUISchemaFunction=function(e){UISchemaFunction=e},setUISchemaCache=("undefined"!=typeof window&&(window.UI_SCHEMA_CACHE||(window.UI_SCHEMA_CACHE=UI_SCHEMA_CACHE),UI_SCHEMA_CACHE=window.UI_SCHEMA_CACHE),(e,t)=>{UI_SCHEMA_CACHE[e]=t}),getUISchemaCache=e=>cloneDeep(UI_SCHEMA_CACHE[e]),hasUISchemaCache=e=>has(UI_SCHEMA_CACHE,e);function getListViewColumns(e,t){let a=[];return a="SMALL"===t?isEmpty(e.mobile_columns)?slice(e.columns,0,4):e.mobile_columns:e.columns}function getListViewSort(e){let i="";return e&&e.sort&&e.sort.length&&each(e.sort,function(e,t){var a;isArray(e)?(a=e[0]+" "+(e[1]||""),a=0<t?","+a:a,i+=a):(a=e.field_name+" "+e.order,a=0<t?","+a:a,i+=a)}),i}function getListViewFilter(t){if(t)try{var a=getUserId();let e=t.filters;if("mine"===t.filter_scope)if(___default.isEmpty(e))e=[["owner","=",a]];else{if(___default.isString(e)&&___default.startsWith(___default.trim(e),"function")&&(e=(e=new Function("return "+e))()),!___default.isArray(e))throw console.debug("listView filters is not array",t),new Error("filters is not array");e.push(["owner","=",a])}return e}catch(e){console.error(e)}}function formatUISchemaCache(objectName,uiSchema){setUISchemaCache(objectName,uiSchema),each(uiSchema.fields,field=>{try{"lookup"===field.type&&field._reference_to&&___default.isString(field._reference_to)&&(field.reference_to=eval(`(${field._reference_to})`)())}catch(exception){field.reference_to=void 0,console.error(exception)}}),each(uiSchema.list_views,(e,t)=>{e.name=t,has(e,"columns")||(e.columns=uiSchema.list_views.all.columns)})}async function getUISchema(t,a){if(t){if(!hasUISchemaCache(t)||a){let e=null;try{if(!(e=UISchemaFunction?await UISchemaFunction(t,a):await fetchAPI(`/service/api/@${t.replace(/\./g,"_")}/uiSchema`,{method:"get"})))return;formatUISchemaCache(t,e)}catch(e){console.error("getUISchema",t,e),setUISchemaCache(t,null)}}return getUISchemaCache(t)}}function getUISchemaSync(t,e){if(t){if(!hasUISchemaCache(t)||e)try{var a,i=`/service/api/@${t.replace(/\./g,"_")}/uiSchema`;if(!(a=Steedos.authRequest(i,{type:"GET",async:!1})))return;formatUISchemaCache(t,a)}catch(e){console.error("getUISchema",t,e),setUISchemaCache(t,null)}return getUISchemaCache(t)}}async function getField(e,t){return(await getUISchema(e))?.fields[t]}async function getFormSchema(e,t){e=await getUISchema(e);return{uiSchema:e,amisSchema:await getObjectForm(e,t)}}async function getViewSchema(e,t,a){e=await getUISchema(e);return{uiSchema:e,amisSchema:await getObjectDetail(e,t,a)}}async function getListSchema(e,t,a,i={}){var r=await getUISchema(t),s=find(r.list_views,(e,t)=>t===(a=a||t)||e._id===a);if(!s)return{uiSchema:r};if(s.enable_amis_schema&&s.amis_schema){const f=isString(s.amis_schema)?JSON.parse(s.amis_schema):s.amis_schema;return{uiSchema:r,isCustomAmisSchema:!0,amisSchema:f}}var o=getListViewColumns(s,i.formFactor),l=getListViewSort(s),n=getListViewFilter(s),d=s&&s._filters;if("calendar"===s.type){const f={type:"steedos-object-calendar",objectApiName:t,filters:n,filtersFunction:d,sort:l,...s.options};return{uiSchema:r,isCalendar:!0,amisSchema:f}}var c=i.defaults||{};!c.headerSchema&&i.showHeader&&(c.headerSchema=await getObjectListHeader$1(r)),i.showHeader||(c.headerSchema=null);try{var p,u=location.pathname+"/crud/"+i.listViewId,m=sessionStorage.getItem(u);m&&(m=JSON.parse(m),p={},m.orderBy&&(p.orderBy=m.orderBy),m.orderDir&&(p.orderDir=m.orderDir),c.listSchema=defaultsDeep$1({},p,c.listSchema||{}))}catch(e){console.error("本地存储中crud参数解析异常:",e)}i.defaults=c;const f={type:"steedos-object-table",objectApiName:t,columns:o,extraColumns:s.extra_columns,filters:n,filtersFunction:d,sort:l,ctx:i,requestAdaptor:s.requestAdaptor,adaptor:s.adaptor};return{uiSchema:r,amisSchema:f}}async function getTableSchema(e,t,a,i={}){const r=await getUISchema(t);let s=i.sort;s||(l=i.sortField,n=i.sortOrder,l&&(s=l+" "+n||"asc"));let o=[];each(a,function(e){isString(e)&&r.fields[e]?o.push(r.fields[e]):isObject$1(e)&&r.fields[e.field]&&o.push(Object.assign({},r.fields[e.field],{width:e.width,wrap:e.wrap,amis:e.amis}))});var l=i.extraColumns,n=(l&&each(l,function(e){isString(e)?o.push({extra:!0,name:e}):isObject$1(e)&&o.push({extra:!0,name:e.field})}),await getObjectCRUD(r,o,{tabId:t,appId:e,objectName:t,...i,filter:i.filters,sort:s,buttons:await getListViewItemButtons(r,i)}));return{uiSchema:r,amisSchema:n}}async function getCalendarSchema(e,t,a,i={}){var r=await getUISchema(t);return{uiSchema:r,amisSchema:await getObjectCalendar(r,a,{tabId:t,appId:e,objectName:t,...i})}}async function getRecordDetailHeaderSchema(e,t,a){e=await getUISchema(e);return{uiSchema:e,amisSchema:await getObjectRecordDetailHeader(e,t,a)}}async function getRecordDetailSchema(e,t,a={}){var i=await getUISchema(e),r={type:"tabs",className:"sm:mt-3 bg-white sm:shadow sm:rounded sm:border border-slate-300 p-4",tabs:[{title:"详细",className:"px-0 py-4",body:[{type:"steedos-object-form",label:"对象表单",objectApiName:"${objectName}",recordId:"${recordId}",id:"u:d4a495811d57",appId:t}],id:"u:5d4e7e3f6ecc"}],id:"u:a649e4094a12"};return(await getObjectRelatedList(e)).length&&r.tabs.push({title:"相关",className:"px-0 pt-4",body:[{type:"steedos-object-related-lists",label:"相关列表",objectApiName:"${objectName}",recordId:"${recordId}",id:"u:3b85b7b7a7f6",appId:t}],id:"u:1a0326aeec2b"}),{uiSchema:i,amisSchema:{type:"service",body:[{type:"steedos-record-detail-header",label:"标题面板",objectApiName:"${objectName}",recordId:"${recordId}",id:"u:48d2c28eb755",onEvent:{recordLoaded:{actions:[{actionType:"reload",data:{name:`\${event.data.record.${i?.NAME_FIELD_KEY||"name"}}`,record:"${event.data.record}",recordLoaded:!0}},{actionType:"reload",componentId:`page_readonly_${e}_header`,data:{name:`\${event.data.record.${i?.NAME_FIELD_KEY||"name"}}`,record:"${event.data.record}",recordLoaded:!0}}]}}},r],data:{"_master.objectName":"${objectName}","_master.recordId":"${recordId}"},onEvent:{recordLoaded:{actions:[{actionType:"reload",data:{name:`\${record.${i.NAME_FIELD_KEY||"name"}}`,"_master.record":"${record}","_master.objectName":"${objectName}","_master.recordId":"${recordId}"}}]},...a.onEvent}}}}async function getObjectRelated({appName:e,masterObjectName:t,objectName:a,relatedFieldName:i,recordId:r,formFactor:s}){let o=null;var l=await getField(a,i),l=(o=l._reference_to||l.reference_to&&!isString(l.reference_to)?[[i+"/o","=",t],[i+"/ids","=",r]]:[""+i,"=",r],await getUISchema(t));return{masterObjectName:t,object_name:a,foreign_key:i,schema:await getListSchema(e,a,"all",{globalFilter:o,formFactor:s}),record:await getRecord(t,r,[l.NAME_FIELD_KEY]),masterObjectUISchema:l}}function getScopeId(e,t){return`page_${e}_`+t}async function getFormPageInitSchema(e){var t=await getFormSchema(e,{recordId:"${recordId}"});return{type:"page",name:getScopeId(e,"form"),bodyClassName:"",regions:["body"],body:[t.amisSchema]}}async function getListPageInitSchema(e,t,a){return{type:"page",name:getScopeId(e,"list"),bodyClassName:"",regions:["body"],body:[{type:"steedos-object-listview",objectApiName:e,columnsTogglable:!1,showHeader:!0,className:"sm:border bg-white sm:shadow sm:rounded border-slate-300 border-solid"}]}}async function getRecordPageInitSchema(e){var t=await getObjectRelatedList(e),a=[{type:"steedos-record-detail-header",label:"标题面板",objectApiName:"${objectName}",recordId:"${recordId}",onEvent:{recordLoaded:{actions:[{actionType:"setValue",args:{value:{recordLoaded:!0}}},{actionType:"reload",data:{name:`\${record.${(await getUISchema(e))?.NAME_FIELD_KEY||"name"}}`,record:"${record}",recordLoaded:!0}}]}}}],i={type:"tabs",tabs:[{title:"详情",body:[{type:"steedos-object-form",label:"对象表单",mode:"read",objectApiName:"${objectName}",recordId:"${recordId}",labelAlign:"left"}]}],className:"sm:mt-3 flex flex-col region-main bg-white sm:shadow sm:rounded sm:border border-slate-300",linksClassName:"pl-4 pt-2"};return t.length&&i.tabs.push({title:"相关",body:{type:"steedos-object-related-lists",label:"所有相关表",objectApiName:"${objectName}",recordId:"${recordId}"}}),a.push(i),{type:"page",id:`page_${e}_record_detail`,name:getScopeId(e,"record_detail"),bodyClassName:"",regions:["body"],body:a}}async function getListviewInitSchema(t,a,i){i=i||{};var r=await getUISchema(t),s=find(r.list_views,(e,t)=>t===a);let o={};if(s){var l=getListViewColumns(s,i.formFactor),s=getListViewSort(s),n=i.defaults||{};n.headerSchema||(r=await getObjectListHeader$1(r),n.headerSchema=r),i.defaults=n;let e=i.setDataToComponentId;e=e||"service_listview_"+t;r=await getTableSchema(null,t,l,{sort:s,...i,setDataToComponentId:e});delete(o=r.amisSchema).data.$master,delete o.data._id,delete o.data.recordPermissions,delete o.data.uiSchema}return o}async function getApps(){return await fetchAPI("/service/api/apps/menus")}async function getApp(e){return await fetchAPI(`/service/api/apps/${e}/menus`)}"undefined"!=typeof window&&(window.getUISchema=getUISchema,window.getUISchemaSync=getUISchemaSync);const getNotifications=async()=>{var e=getSteedosAuth(),e=`
|
|
1246
1305
|
{
|
|
1247
1306
|
notifications(filters: ["owner","=","${e.userId}"], sort: "created desc,name", top : 10){
|
|
1248
1307
|
_id,name,body,related_to,related_name,url,owner,is_read,from,created
|
|
@@ -1329,7 +1388,7 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
1329
1388
|
return form.validate().then((approvalFormValidate)=>{
|
|
1330
1389
|
event.setData({...event.data, approvalFormValidate})
|
|
1331
1390
|
})
|
|
1332
|
-
`,expression:"${event.data.instanceFormValidate}"},{componentId:"",args:{api:{url:"${context.rootUrl}"+t,method:"post",dataType:"json",data:{"&":"$$",$scopeId:"${$scopeId}"},headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"},requestAdaptor:a},messages:{success:"提交成功!"}},actionType:"ajax",expression:"${event.data.instanceFormValidate && event.data.approvalFormValidate}"},{componentId:"",args:{blank:!1,url:Router$1.getObjectListViewPath({appId:"${appId}",objectName:"${objectName}",listViewName:"${side_listview_id}"})},actionType:"url",expression:"${event.data.instanceFormValidate && event.data.approvalFormValidate}"},{actionType:"closeDialog",expression:"${event.data.instanceFormValidate && event.data.approvalFormValidate}"}]},getApprovalDrawerSchema=async e=>({type:"drawer",overlay:!0,resizable:!1,closeOnEsc:!0,closeOnOutside:!0,size:"sm",title:""+e.step.name,className:"approval-drawer absolute",body:[{type:"form",debug:!1,id:"instance_approval",resetAfterSubmit:!0,clearPersistDataAfterSubmit:!0,persistData:"workflow_approve_form_"+e.approve._id,body:[await getJudgeInput(e),{type:"textarea",label:!1,name:"suggestion",id:"u:cd344f708ddc",minRows:3,maxRows:20,placeholder:"请填写意见",requiredOn:"${judge === 'rejected'}"},await getNextStepInput(e),await getNextStepUsersInput(e)],onEvent:{approve_judge_change:{actions:[{actionType:"reload",componentId:"u:next_step",args:{}}]},validateError:{weight:0,actions:[{componentId:"",args:{msgType:"info",position:"top-right",closeButton:!0,showIcon:!0,title:"提交失败",msg:"请填写必填字段"},actionType:"toast"}]}}}],id:"u:approve_8861156e0b23",position:"bottom",actions:[{type:"button",label:"提交",onEvent:{click:{actions:await getSubmitActions(e)}},id:"u:f6f8c3933f6c",level:"primary"},{type:"button",label:"取消",onEvent:{click:{actions:[{componentId:"",args:{},actionType:"closeDrawer"}]}},id:"u:127ff1da7283"}]}),getAttachments=async e=>({type:"panel",className:"border-none bg-none shadow-none",headerClassName:"p-0 border-none mb-1",bodyClassName:"p-0",title:[await getAttachmentUploadInput(e)],body:[{type:"service",id:"u:attachmentsService",api:{method:"post",url:"${context.rootUrl}/graphql",dataType:"json",headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"},requestAdaptor:`
|
|
1391
|
+
`,expression:"${event.data.instanceFormValidate}"},{componentId:"",args:{api:{url:"${context.rootUrl}"+t,method:"post",dataType:"json",data:{"&":"$$",$scopeId:"${$scopeId}"},headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"},requestAdaptor:a},messages:{success:"提交成功!"}},actionType:"ajax",expression:"${event.data.instanceFormValidate && event.data.approvalFormValidate}"},{componentId:"",args:{blank:!1,url:Router$1.getObjectListViewPath({appId:"${appId}",objectName:"${objectName}",listViewName:"${side_listview_id}"})},actionType:"url",expression:"${event.data.instanceFormValidate && event.data.approvalFormValidate}"},{actionType:"closeDialog",expression:"${event.data.instanceFormValidate && event.data.approvalFormValidate}"}]},getApprovalDrawerSchema=async e=>({type:"drawer",overlay:!0,resizable:!1,closeOnEsc:!0,closeOnOutside:!0,size:"sm",title:""+e.step.name,className:"approval-drawer absolute",drawerContainer:()=>window.$(".antd-Page-content",window.$(".steedos-instance-wrapper"))[0],body:[{type:"form",debug:!1,id:"instance_approval",resetAfterSubmit:!0,clearPersistDataAfterSubmit:!0,persistData:"workflow_approve_form_"+e.approve._id,body:[await getJudgeInput(e),{type:"textarea",label:!1,name:"suggestion",id:"u:cd344f708ddc",minRows:3,maxRows:20,placeholder:"请填写意见",requiredOn:"${judge === 'rejected'}"},await getNextStepInput(e),await getNextStepUsersInput(e)],onEvent:{approve_judge_change:{actions:[{actionType:"reload",componentId:"u:next_step",args:{}}]},validateError:{weight:0,actions:[{componentId:"",args:{msgType:"info",position:"top-right",closeButton:!0,showIcon:!0,title:"提交失败",msg:"请填写必填字段"},actionType:"toast"}]}}}],id:"u:approve_8861156e0b23",position:"bottom",actions:[{type:"button",label:"提交",onEvent:{click:{actions:await getSubmitActions(e)}},id:"u:f6f8c3933f6c",level:"primary"},{type:"button",label:"取消",onEvent:{click:{actions:[{componentId:"",args:{},actionType:"closeDrawer"}]}},id:"u:127ff1da7283"}]}),getAttachments=async e=>({type:"panel",className:"border-none bg-none shadow-none",headerClassName:"p-0 border-none mb-1",bodyClassName:"p-0",title:[await getAttachmentUploadInput(e)],body:[{type:"service",id:"u:attachmentsService",api:{method:"post",url:"${context.rootUrl}/graphql",dataType:"json",headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"},requestAdaptor:`
|
|
1333
1392
|
api.data.query = 'query{attachments:cfs_instances_filerecord(filters: [["metadata.instance", "=", "${e._id}"], "metadata.current", "=", true]){ _id,original,metadata}}';
|
|
1334
1393
|
return api;
|
|
1335
1394
|
`},body:[{type:"list",source:"${attachments}",title:!1,listItem:{body:[{type:"tpl",inline:!0,tpl:"<a href='${context.rootUrl}/api/files/instances/${_id}?download=true' target='_blank'>${original.name}</a>"}],actions:[{icon:"fa fa-eye",type:"button",id:"u:ef52fa8940a8"}],id:"u:550b3fdc8788"},id:"u:f538be693fad"}]}]}),getAttachmentUploadInput=async e=>{var t;return e.approve?(t=getSteedosAuth$1(),{type:"form",title:"表单",body:[{type:"input-file",labelClassName:"antd-List-heading",className:"flex items-center",label:"附件",mode:"inline",name:"file",id:"u:a58d02614e04",btnLabel:"上传",btnClassName:"m-0",multiple:!0,maxLength:10,submitType:"asUpload",uploadType:"fileReceptor",proxy:!1,drag:!1,autoUpload:!0,useChunk:!1,joinValues:!1,extractValue:!1,valueField:"version_id",receiver:{url:"${context.rootUrl}/api/v4/instances/s3",headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"},method:"post",messages:{},dataType:"form-data",requestAdaptor:`
|
|
@@ -1354,7 +1413,7 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
1354
1413
|
})
|
|
1355
1414
|
}
|
|
1356
1415
|
return payload;
|
|
1357
|
-
`};break;case"html":i.type=i.disabled?"html":"input-rich-text";break;case"table":i.type="input-table",i.addable="editable"===e.permission,i.editable=i.addable,i.copyable=i.addable,i.columns=[];for(const s of e.fields)"hidden"!=s.type&&(s.permission=e.permission,a=await getTdInputTpl(s,!0),i.columns.push(a));break;case"section":i.type="input-text"}return i},getFieldReadonlyTpl=async(e,t)=>{var a,i={label:!0===t&&e.name,name:e.code,mode:"horizontal",className:"m-none p-none form-control"};if(includes(["text"],e.type))i.type="static-"+e.type;else if("select"===e.type){t=getSelectOptions(e);const r={};each(t,e=>{r[e.value]=e.label}),i.type="static",i.tpl=`<% var options = ${JSON.stringify(r)}; return options?.[data.${e.code}] || ''%>`}else if("odata"===e.type)i.type="static",i.tpl=`<div>\${${e.code}['@label']}</div>`;else if("checkbox"===e.type)i.type="static",i.tpl=`\${${e.code} ? '是': '否'}`;else if("email"===e.type)i.type="static",i.tpl=`<a href="mailto:\${${e.code}}">\${${e.code}}</a>`;else if("url"===e.type)i.type="static",i.tpl=`<a href="\${${e.code}}" target="_blank">\${${e.code}}</a>`;else if("password"===e.type)i.type="static",i.tpl="******";else if("dateTime"===e.type)i.type="static",i.tpl=`<%=data.${e.code} ? date(new Date(data.${e.code}), 'YYYY-MM-DD HH:mm') : '' %>`;else if("user"===e.type)i.type="static",e.is_multiselect?i.tpl=`\${_.map(${e.code}, 'name')}`:i.tpl=`\${${e.code}?.name}`;else if("group"===e.type)i.type="static",i.tpl=`\${${e.code}.name}`;else if("table"===e.type){i.type="input-table",i.addable="editable"===e.permission,i.editable=i.addable,i.copyable=i.addable,i.columns=[];for(const s of e.fields)"hidden"!=s.type&&(a=await getTdInputTpl(s,!0),i.columns.push(a))}else"html"===e.type?i.type="tpl":i.type="static";return i},getTdInputTpl=async(e,t)=>{return("editable"===e.permission?getFieldEditTpl:getFieldReadonlyTpl)(e,t)},getTdField=async(e,t)=>({background:"editable"!==e.permission?"#FFFFFF":"rgba(255,255,0,.1)",colspan:"table"===e.type?4:3-2*(t-1),align:"left",className:"td-field",width:"32%",body:[await getTdInputTpl(e)],style:{marginTop:"0",paddingTop:"0",paddingRight:"0",paddingBottom:"0",paddingLeft:"0",marginRight:"0",marginBottom:"0",marginLeft:"0",borderLeftColor:"#000000",borderTopColor:"#000000",borderRightColor:"#000000",borderBottomColor:"#000000"}}),getTdTitle=e=>({className:"td-title",align:"section"!=e.type?"center":"left",width:"section"!=e.type?"16%":"",colspan:"section"==e.type?4:"",background:"#FFFFFF",body:[{type:"tpl",tpl:`<div>${e.name||e.code} ${e.is_required?'<span class="antd-Form-star">*</span>':""}</div>`}],style:{borderLeftColor:"#000000",borderTopColor:"#000000",borderRightColor:"#000000",borderBottomColor:"#000000"}}),getTds=async e=>{var t=[];for(const a of e)"table"!=a.type&&t.push(getTdTitle(a)),"section"!=a.type&&t.push(await getTdField(a,e.length));return t},getFormTrs=async e=>{var t=[];const a=[];let i=[],r=[];each(e.fields,e=>{r.push(e),"section"===e.type&&e.fields&&(r=r.concat(e.fields))}),each(r,(e,t)=>{e.is_wide?(0!=i.length&&a.push(i),"table"==e.type&&a.push([Object.assign({},e,{type:"section"})]),(i=[]).push(e),a.push(i),i=[]):(i.push(e),2!=i.length&&t!==r.length-1||(a.push(i),i=[]))});for(const i of a)t.push({background:"#F7F7F7",tds:await getTds(i)});return t},getFormTableView=async e=>
|
|
1416
|
+
`};break;case"html":i.type=i.disabled?"html":"input-rich-text";break;case"table":i.type="input-table",i.addable="editable"===e.permission,i.editable=i.addable,i.copyable=i.addable,i.removable=i.addable,i.columns=[];for(const s of e.fields)"hidden"!=s.type&&(s.permission=e.permission,a=await getTdInputTpl(s,!0),i.columns.push(a));break;case"section":i.type="input-text"}return i},getFieldReadonlyTpl=async(e,t)=>{var a,i={label:!0===t&&e.name,name:e.code,mode:"horizontal",className:"m-none p-none form-control"};if(includes(["text"],e.type))i.type="static-"+e.type;else if("select"===e.type){t=getSelectOptions(e);const r={};each(t,e=>{r[e.value]=e.label}),i.type="static",i.tpl=`<% var options = ${JSON.stringify(r)}; return options?.[data.${e.code}] || ''%>`}else if("odata"===e.type)i.type="static",i.tpl=`<div>\${${e.code}['@label']}</div>`;else if("checkbox"===e.type)i.type="static",i.tpl=`\${${e.code} ? '是': '否'}`;else if("email"===e.type)i.type="static",i.tpl=`<a href="mailto:\${${e.code}}">\${${e.code}}</a>`;else if("url"===e.type)i.type="static",i.tpl=`<a href="\${${e.code}}" target="_blank">\${${e.code}}</a>`;else if("password"===e.type)i.type="static",i.tpl="******";else if("date"===e.type)i.type="static",i.tpl=`<%=data.${e.code} ? date(new Date(data.${e.code}), 'YYYY-MM-DD') : '' %>`;else if("dateTime"===e.type)i.type="static",i.tpl=`<%=data.${e.code} ? date(new Date(data.${e.code}), 'YYYY-MM-DD HH:mm') : '' %>`;else if("user"===e.type)i.type="static",e.is_multiselect?i.tpl=`\${_.map(${e.code}, 'name')}`:i.tpl=`\${${e.code}?.name}`;else if("group"===e.type)i.type="static",i.tpl=`\${${e.code}.name}`;else if("table"===e.type){i.type="input-table",i.addable="editable"===e.permission,i.editable=i.addable,i.removable=i.addable,i.copyable=i.addable,i.columns=[];for(const s of e.fields)"hidden"!=s.type&&(a=await getTdInputTpl(s,!0),i.columns.push(a))}else"html"===e.type?i.type="tpl":i.type="static";return i},getTdInputTpl=async(e,t)=>{return("editable"===e.permission?getFieldEditTpl:getFieldReadonlyTpl)(e,t)},getTdField=async(e,t)=>({background:"editable"!==e.permission?"#FFFFFF":"rgba(255,255,0,.1)",colspan:"table"===e.type?4:3-2*(t-1),align:"left",className:"td-field",width:"32%",body:[await getTdInputTpl(e)],style:{marginTop:"0",paddingTop:"0",paddingRight:"0",paddingBottom:"0",paddingLeft:"0",marginRight:"0",marginBottom:"0",marginLeft:"0",borderLeftColor:"#000000",borderTopColor:"#000000",borderRightColor:"#000000",borderBottomColor:"#000000"}}),getTdTitle=e=>({className:"td-title",align:"section"!=e.type?"center":"left",width:"section"!=e.type?"16%":"",colspan:"section"==e.type?4:"",background:"#FFFFFF",body:[{type:"tpl",tpl:`<div>${e.name||e.code} ${e.is_required?'<span class="antd-Form-star">*</span>':""}</div>`}],style:{borderLeftColor:"#000000",borderTopColor:"#000000",borderRightColor:"#000000",borderBottomColor:"#000000"}}),getTds=async e=>{var t=[];for(const a of e)"table"!=a.type&&t.push(getTdTitle(a)),"section"!=a.type&&t.push(await getTdField(a,e.length));return t},getFormTrs=async e=>{var t=[];const a=[];let i=[],r=[];each(e.fields,e=>{r.push(e),"section"===e.type&&e.fields&&(r=r.concat(e.fields))}),each(r,(e,t)=>{e.is_wide?(0!=i.length&&a.push(i),"table"==e.type&&a.push([Object.assign({},e,{type:"section"})]),(i=[]).push(e),a.push(i),i=[]):(i.push(e),2!=i.length&&t!==r.length-1||(a.push(i),i=[]))});for(const i of a)t.push({background:"#F7F7F7",tds:await getTds(i)});return t},getFormTableView=async e=>{e={type:"table-view",className:"instance-form-view",trs:await getFormTrs(e),id:"u:047f3669468b"};return console.log("getFormTableView formSchema=====>",e),e},getApplicantTableView=async e=>{let t=null;return{type:"table-view",className:"instance-applicant-view",trs:[{background:"#FFFFFF",tds:[{className:"td-title",background:"#FFFFFF",align:"left",width:"16%",colspan:"",body:[{type:"tpl",tpl:"<div>提交人</div>",id:"u:ee62634201bf"}],id:"u:6c24c1bb99c9",style:{padding:"none"}},{background:"#FFFFFF",colspan:1,align:"left",className:"td-field",width:"32%",body:[t="draft"===e.state?Object.assign({name:"applicant",value:getSteedosAuth$1().userId,disabled:"draft"!==e.box},await lookupToAmis$1({name:"applicant",label:!1,reference_to:"space_users",reference_to_field:"user",multiple:!1},!1,{})):{label:!1,mode:"horizontal",className:"m-none p-none",disabled:!0,type:"tpl",tpl:"<div>${applicant_name}</div>",id:"u:2016b04355f4"}],id:"u:45d65d91905c"},{className:"td-title",background:"#FFFFFF",align:"left",width:"16%",colspan:"",body:[{type:"tpl",tpl:"<div>提交日期</div>",id:"u:6d0a7763d527"}],id:"u:c8b8214ac931",style:{padding:"none"}},{background:"#FFFFFF",colspan:1,align:"left",className:"td-field",width:"32%",body:[{label:!1,mode:"horizontal",className:"m-none p-none",disabled:!0,type:"tpl",inputFormat:"YYYY-MM-DD",valueFormat:"YYYY-MM-DDT00:00:00.000[Z]",tpl:"<div>${submit_date}</div>",id:"u:2016b04355f4"}],id:"u:81b07d82a5e4"}]}],id:"u:047f3669468b",style:{borderLeftStyle:"none",borderTopStyle:"none",borderRightStyle:"none",borderBottomStyle:"none"}}},getApproveButton=async e=>!e.approve||"inbox"!=e.box&&"draft"!=e.box?null:{type:"button",label:"签批",onEvent:{click:{actions:[{componentId:"",args:{},actionType:"drawer",drawer:await getApprovalDrawerSchema(e)}]}},id:"steedos-approve-button",level:"primary",className:"approve-button w-14 h-14 rounded-full fixed bottom-4 right-4 shadow-lg text-white text-base text-center font-semibold bg-blue-500 p-0"},getFlowFormSchema=async(e,t)=>({type:"page",name:"instancePage",className:"steedos-amis-instance-view",title:{type:"steedos-record-detail-header",label:"标题面板",objectApiName:"instances",recordId:e._id,id:"u:e6b2adbe0e21",showRecordTitle:!1,className:"p-0 m-0 p0 m0"},css:{".instance-approve-history .antd-Table-table thead":{display:"none"},".instance-approve-history .antd-Table-heading":{"font-size":"14px","font-weight":"500","padding-left":"0px"},".antd-List-heading":{"font-size":"14px","font-weight":"500"}},body:[await getAttachments(e),await getRelatedInstances(),await getRelatedRecords(e),{type:"form",debug:!1,wrapWithPanel:!1,resetAfterSubmit:!0,body:[{type:"tpl",id:"u:f5bb0ad602a6",tpl:`<div class="instance-name">${e.title}</div>`,inline:!0,wrapperComponent:"",style:{fontFamily:"",fontSize:12,textAlign:"center"}},await getFormTableView(e),await getApplicantTableView(e)],id:"instance_form",onEvent:{validateError:{weight:0,actions:[{componentId:"",args:{msgType:"info",position:"top-right",closeButton:!0,showIcon:!0,title:"提交失败",msg:"请填写必填字段"},actionType:"toast"}]}}},await getInstanceApprovalHistory(),await getApproveButton(e)],id:"u:63849ea39e12",messages:{},pullRefresh:{},regions:["body","header"],onEvent:{"@data.@instanceDetail.changed":{actions:[{actionType:"reload"}]}},initApi:{url:"${context.rootUrl}/graphql",method:"post",headers:{Authorization:"Bearer ${context.tenantId},${context.authToken}"},messages:{},requestAdaptor:`
|
|
1358
1417
|
const { context } = api.data;
|
|
1359
1418
|
api.data = {
|
|
1360
1419
|
query: \`
|
|
@@ -1410,5 +1469,5 @@ filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsF
|
|
|
1410
1469
|
}
|
|
1411
1470
|
}
|
|
1412
1471
|
}
|
|
1413
|
-
`})});let r=null,s=null,
|
|
1472
|
+
`})});let r=null,s=null,o=null;var l,n,d,c,p,i=i.data.instance;if(i)return"inbox"!==t&&"draft"!==t||(r=getUserApprove({instance:i,userId:a})),l=getFlowVersion(i),n=getFormVersion(i),r&&(s=getTrace({instance:i,traceId:r.trace}),o=getStep({flowVersion:l,stepId:s.step})),d=getStep({flowVersion:l,stepId:___default.last(i.traces).step}),a=getLastCCStep(i,a),c=getApproveValues({instance:i,trace:s,step:o,approve:r,box:t}),p=await fetchAPI$1("/api/workflow/v2/flow_permissions/"+i.flow._id,{method:"get"}),{box:t,_id:e,space:i.space,flow:i.flow,form:i.form,applicant:i.applicant,applicant_name:i.applicant_name,submitter:i.submitter,submit_date:i.submit_date?amisRequire("moment")(i.submit_date).format("YYYY-MM-DD"):"",state:i.state,approveValues:c,title:i.name||i.form.name,name:i.name||i.form.name,fields:___default.map(n.fields,e=>Object.assign({},e,{permission:"cc"!=r?.type&&(o?.permissions[e.code]||(isCurrentStepOpinionField(e,o)?"editable":""))})),flowVersion:l,formVersion:n,step:o,lastCCStep:a,trace:s,currentStep:d,flowPermissions:p?.permissions||[],approve:r,record_ids:i.record_ids,related_instances:i.related_instances,forward_from_instance:i.forward_from_instance,cc_users:i.cc_users,traces:i.traces,historyApproves:___default.map(i.traces,e=>Object.assign({children:___default.map(e.approves,e=>{let t=e.finish_date,a=e.judge,i=e.user_name,r=e.description;switch("cc"===e.type&&(i+=" (传阅)",r=e.cc_description),t?t=amisRequire("moment")(t).format("YYYY-MM-DD HH:mm"):(t=e.is_read?"已读":"未处理",a=null),a){case"submitted":a="";break;case"returned":a="已退回";break;case"terminated":a="被取回";break;case"pending":a="审核中";break;case"approved":a="已核准";break;case"rejected":a="已驳回";break;case"finished":a="已完成";break;case"reassigned":a="转签核";break;case"inhand":a="处理中";break;case"relocated":a="重定位";break;case"readed":a="已阅"}return{name:"",user_name:i,finish_date:t,judge:a,opinion:r}})},{name:e.name,judge:""}))}};export{index as Field,Router,absoluteUrl,amisRender,amisRootClick,cloneObject,conditionsToFilters,createObject,defaultsDeep,deleteVariable,execute,executeButton,extendObject,fetchAPI,filtersToConditions,getApp,getApps,getAuthToken,getAuthorization,getButton,getButtonVisible,getButtonVisibleOn$1 as getButtonVisibleOn,getButtons,getCalendarSchema,getDefaultRenderData,getEnv,getEnvs,getEvn,getField,getFileSrc,getFlowFormSchema,getFormPageInitSchema,getFormSchema,getIdsPickerSchema,getImageSrc,getInstanceInfo,getListPageInitSchema,getListSchema,getListViewButtons,getListViewColumns,getListViewFilter,getListViewItemButtons,getListViewSort,getListviewInitSchema,getNotifications,getObjectDetailButtons,getObjectDetailMoreButtons,getObjectFieldsFilterBarSchema,getObjectFieldsFilterButtonSchema,getObjectFieldsFilterFormSchema,getObjectListHeader$1 as getObjectListHeader,getObjectListHeaderFieldsFilterBar,getObjectListHeaderFirstLine,getObjectListHeaderSecordLine,getObjectRecordDetailHeader,getObjectRecordDetailRelatedListHeader,getObjectRelated,getObjectRelatedList,getObjectRelatedListButtons,getObjectRelatedListHeader,getPage,getRecord,getRecordDetailHeaderSchema,getRecordDetailRelatedListSchema,getRecordDetailSchema,getRecordPageInitSchema,getRecordPermissions,getRelatedFieldValue,getRelatedListSchema,getRelatedsCount,getRootUrl,getSelectUserSchema,getSpaceUsersPickerAmisSchema,getSpaceUsersPickerSchema,getSteedosAuth,getTableSchema,getTenantId,getUISchema,getUISchemaSync,getUserId,getViewSchema,isExpression,isObject,lookupToAmis,lookupToAmisIdsPicker,lookupToAmisPicker,lookupToAmisSelect,lookupToAmisSelectUser,markReadAll,parseSingleExpression,registerRemoteAssets,registerRenders,setEnv,setEnvs,setRootUrl,setSteedosAuth,setUISchemaFunction,setVariable,standardButtonsTodo};
|
|
1414
1473
|
//# sourceMappingURL=index.esm.js.map
|