@steedos-widgets/sortable 1.3.9 → 1.3.11
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/assets.json +5 -5
- package/dist/sortable.cjs.js +1252 -1249
- package/dist/sortable.cjs.js.map +1 -1
- package/dist/sortable.esm.js +1252 -1249
- package/dist/sortable.esm.js.map +1 -1
- package/dist/sortable.umd.js +1252 -1249
- package/package.json +3 -3
package/dist/sortable.esm.js
CHANGED
|
@@ -53851,6 +53851,53 @@ var funcToString = funcProto.toString;
|
|
|
53851
53851
|
/** Used to infer the `Object` constructor. */
|
|
53852
53852
|
funcToString.call(Object);
|
|
53853
53853
|
|
|
53854
|
+
/*
|
|
53855
|
+
* @Author: baozhoutao@steedos.com
|
|
53856
|
+
* @Date: 2022-08-16 17:02:08
|
|
53857
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
53858
|
+
* @LastEditTime: 2023-06-20 13:50:15
|
|
53859
|
+
* @Description:
|
|
53860
|
+
*/
|
|
53861
|
+
|
|
53862
|
+
|
|
53863
|
+
const Router = {
|
|
53864
|
+
getTabDisplayAs(tab_id){
|
|
53865
|
+
var urlSearch = new URLSearchParams(document.location.search);
|
|
53866
|
+
if(urlSearch.has('display')){
|
|
53867
|
+
return urlSearch.get('display')
|
|
53868
|
+
}
|
|
53869
|
+
const key = `tab_${tab_id}_display`;
|
|
53870
|
+
// const key = `page_display`;
|
|
53871
|
+
const value = localStorage.getItem(key);
|
|
53872
|
+
return value ? value : 'grid'
|
|
53873
|
+
},
|
|
53874
|
+
|
|
53875
|
+
setTabDisplayAs(tab_id, displayAs){
|
|
53876
|
+
const key = `tab_${tab_id}_display`;
|
|
53877
|
+
localStorage.setItem(key, displayAs);
|
|
53878
|
+
},
|
|
53879
|
+
getAppPath({formFactor, appId}){
|
|
53880
|
+
return `/app/${appId}`;
|
|
53881
|
+
},
|
|
53882
|
+
getPagePath(){
|
|
53883
|
+
//TODO
|
|
53884
|
+
},
|
|
53885
|
+
getObjectListViewPath({formFactor, appId, objectName, listViewName}){
|
|
53886
|
+
return `/app/${appId}/${objectName}/grid/${listViewName}`;
|
|
53887
|
+
},
|
|
53888
|
+
getObjectDetailPath(props){
|
|
53889
|
+
const {formFactor, appId, objectName, recordId, listViewName, _templateType} = props;
|
|
53890
|
+
if(_templateType === 'JavaScript'){
|
|
53891
|
+
return `/app/${appId}/${objectName}/view/${recordId}?side_object=<%=item.objectName%>&side_listview_id=<%=item.listName%>`;
|
|
53892
|
+
}
|
|
53893
|
+
return `/app/${appId}/${objectName}/view/${recordId}?side_object=\${objectName}&side_listview_id=\${listName}`;
|
|
53894
|
+
},
|
|
53895
|
+
getObjectRelatedViewPath({formFactor, appId, masterObjectName, masterRecordId, objectName, foreignKey}){
|
|
53896
|
+
return `/app/${appId}/${masterObjectName}/${masterRecordId}/${objectName}/grid?related_field_name=${foreignKey}`;
|
|
53897
|
+
},
|
|
53898
|
+
|
|
53899
|
+
};
|
|
53900
|
+
|
|
53854
53901
|
const getBuilderContext = ()=>{
|
|
53855
53902
|
if(typeof window === "undefined"){
|
|
53856
53903
|
return {};
|
|
@@ -53925,437 +53972,109 @@ function getRootUrl(defaultRootUrl){
|
|
|
53925
53972
|
return defaultRootUrl || '';
|
|
53926
53973
|
}
|
|
53927
53974
|
|
|
53928
|
-
|
|
53929
|
-
|
|
53930
|
-
|
|
53931
|
-
|
|
53932
|
-
|
|
53933
|
-
|
|
53934
|
-
|
|
53935
|
-
|
|
53936
|
-
|
|
53937
|
-
|
|
53938
|
-
|
|
53939
|
-
|
|
53940
|
-
|
|
53941
|
-
|
|
53942
|
-
|
|
53943
|
-
|
|
53944
|
-
|
|
53945
|
-
|
|
53946
|
-
|
|
53947
|
-
|
|
53948
|
-
|
|
53949
|
-
|
|
53950
|
-
|
|
53951
|
-
|
|
53952
|
-
|
|
53953
|
-
|
|
53954
|
-
|
|
53955
|
-
|
|
53956
|
-
|
|
53957
|
-
|
|
53958
|
-
|
|
53959
|
-
|
|
53960
|
-
|
|
53961
|
-
|
|
53962
|
-
|
|
53963
|
-
|
|
53964
|
-
if(_templateType === 'JavaScript'){
|
|
53965
|
-
return `/app/${appId}/${objectName}/view/${recordId}?side_object=<%=item.objectName%>&side_listview_id=<%=item.listName%>`;
|
|
53975
|
+
async function getFieldsTemplate(fields, display){
|
|
53976
|
+
let expandFields = [];
|
|
53977
|
+
if(display != false){
|
|
53978
|
+
display = true;
|
|
53979
|
+
}
|
|
53980
|
+
let fieldsName = ['_id'];
|
|
53981
|
+
let displayFields = [];
|
|
53982
|
+
let fieldsArr = [];
|
|
53983
|
+
if(lodash.exports.isArray(fields)){
|
|
53984
|
+
fieldsArr = fields;
|
|
53985
|
+
}else {
|
|
53986
|
+
fieldsArr = lodash.exports.values(fields);
|
|
53987
|
+
}
|
|
53988
|
+
for (const field of fieldsArr) {
|
|
53989
|
+
//graphql 的 ui\display 中使用的字段需要先在query中查询. 否则会返回null
|
|
53990
|
+
if(field.expand){
|
|
53991
|
+
expandFields.push(field);
|
|
53992
|
+
}else {
|
|
53993
|
+
if(field.name.indexOf('.') < 0){
|
|
53994
|
+
if(display && (field.type == 'lookup' || field.type == 'master_detail')){
|
|
53995
|
+
fieldsName.push(`${field.name}`);
|
|
53996
|
+
displayFields.push(`${field.name}`);
|
|
53997
|
+
}else {
|
|
53998
|
+
fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
|
|
53999
|
+
}
|
|
54000
|
+
if(lodash.exports.includes(['time','date','datetime','boolean','number','currency'], field.type)){
|
|
54001
|
+
fieldsName.push(`${field.name}`);
|
|
54002
|
+
}
|
|
54003
|
+
if(lodash.exports.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
|
|
54004
|
+
displayFields.push(`${field.name}`);
|
|
54005
|
+
}
|
|
54006
|
+
}else {
|
|
54007
|
+
objectFieldName = field.name.split('.')[0];
|
|
54008
|
+
fieldsName.push(objectFieldName);
|
|
54009
|
+
displayFields.push(objectFieldName);
|
|
54010
|
+
}
|
|
53966
54011
|
}
|
|
53967
|
-
|
|
53968
|
-
},
|
|
53969
|
-
getObjectRelatedViewPath({formFactor, appId, masterObjectName, masterRecordId, objectName, foreignKey}){
|
|
53970
|
-
return `/app/${appId}/${masterObjectName}/${masterRecordId}/${objectName}/grid?related_field_name=${foreignKey}`;
|
|
53971
|
-
},
|
|
53972
|
-
|
|
53973
|
-
};
|
|
53974
|
-
|
|
53975
|
-
/*
|
|
53976
|
-
* @Author: baozhoutao@steedos.com
|
|
53977
|
-
* @Date: 2022-07-20 16:29:22
|
|
53978
|
-
* @LastEditors: liaodaxue
|
|
53979
|
-
* @LastEditTime: 2023-09-11 17:19:53
|
|
53980
|
-
* @Description:
|
|
53981
|
-
*/
|
|
53982
|
-
|
|
53983
|
-
function getImageFieldUrl(url) {
|
|
53984
|
-
if (window.Meteor && window.Meteor.isCordova != true) {
|
|
53985
|
-
// '//'的位置
|
|
53986
|
-
const doubleSlashIndex = url.indexOf('//');
|
|
53987
|
-
const urlIndex = url.indexOf('/', doubleSlashIndex + 2);
|
|
53988
|
-
const rootUrl = url.substring(urlIndex);
|
|
53989
|
-
return rootUrl;
|
|
53990
|
-
}
|
|
53991
|
-
return url;
|
|
53992
|
-
}
|
|
54012
|
+
}
|
|
53993
54013
|
|
|
53994
|
-
|
|
53995
|
-
|
|
53996
|
-
|
|
54014
|
+
displayFields = lodash.exports.uniq(displayFields);
|
|
54015
|
+
fieldsName = lodash.exports.uniq(fieldsName);
|
|
54016
|
+
let expandFieldsQuery = "";
|
|
54017
|
+
if(expandFields.length > 0){
|
|
54018
|
+
lodash.exports.each(expandFields, function(field){
|
|
54019
|
+
expandFieldsQuery = expandFieldsQuery + `${field.expandInfo.fieldName}__expand{${field.expandInfo.displayName}}`;
|
|
54020
|
+
});
|
|
54021
|
+
}
|
|
53997
54022
|
|
|
53998
|
-
|
|
53999
|
-
|
|
54000
|
-
|
|
54001
|
-
|
|
54002
|
-
var b = parseInt(backgroundColor.substr(4, 2), 16);
|
|
54003
|
-
var brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
54004
|
-
return brightness < 128 ? "#ffffff" : "#000000";
|
|
54023
|
+
if(displayFields.length > 0){
|
|
54024
|
+
return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
|
|
54025
|
+
}
|
|
54026
|
+
return lodash.exports.trimEnd(`${fieldsName.join(' ')},${expandFieldsQuery}`, ",")
|
|
54005
54027
|
}
|
|
54006
54028
|
|
|
54007
|
-
function
|
|
54008
|
-
|
|
54009
|
-
|
|
54010
|
-
|
|
54011
|
-
|
|
54012
|
-
|
|
54013
|
-
|
|
54029
|
+
async function getFindQuery(object, recordId, fields, options){
|
|
54030
|
+
let limit = options.limit || 10;
|
|
54031
|
+
let queryOptions = `(top: ${limit})`;
|
|
54032
|
+
if(recordId){
|
|
54033
|
+
queryOptions = `(filters:["_id", "=", "${recordId}"], top: ${limit})`;
|
|
54034
|
+
}
|
|
54035
|
+
let alias = "data";
|
|
54036
|
+
if(options){
|
|
54037
|
+
if(options.alias){
|
|
54038
|
+
alias = options.alias;
|
|
54039
|
+
}
|
|
54014
54040
|
|
|
54015
|
-
|
|
54016
|
-
|
|
54017
|
-
(view, name) => {
|
|
54018
|
-
if (name === listNameAll) {
|
|
54019
|
-
listViewAll = view;
|
|
54020
|
-
if(!listViewAll.name){
|
|
54021
|
-
listViewAll.name = name;
|
|
54041
|
+
if(options.filters){
|
|
54042
|
+
queryOptions = `(filters:${options.filters})`;
|
|
54022
54043
|
}
|
|
54023
|
-
|
|
54024
|
-
|
|
54025
|
-
listViewLookup = view;
|
|
54026
|
-
if(!listViewLookup.name){
|
|
54027
|
-
listViewLookup.name = name;
|
|
54044
|
+
if(options.queryOptions){
|
|
54045
|
+
queryOptions = `(${options.queryOptions})`;
|
|
54028
54046
|
}
|
|
54029
|
-
}
|
|
54030
54047
|
}
|
|
54031
|
-
|
|
54032
|
-
|
|
54033
|
-
|
|
54034
|
-
}
|
|
54035
|
-
|
|
54036
|
-
function getNumberTpl(field){
|
|
54037
|
-
return `<span>\${_display.${field.name}}</span>`
|
|
54038
|
-
}
|
|
54039
|
-
|
|
54040
|
-
function getTimeTpl(field){
|
|
54041
|
-
return `<span>\${_display.${field.name}}</span>`
|
|
54042
|
-
}
|
|
54043
|
-
|
|
54044
|
-
function getDateTpl(field){
|
|
54045
|
-
return `<span>\${_display.${field.name}}</span>`
|
|
54046
|
-
}
|
|
54048
|
+
var treeFields = '';
|
|
54049
|
+
if(object.enable_tree && lodash.exports.includes(lodash.exports.keys(object.fields), 'parent') && lodash.exports.includes(lodash.exports.keys(object.fields), 'children')){
|
|
54050
|
+
treeFields = ',parent,children';
|
|
54051
|
+
}
|
|
54047
54052
|
|
|
54053
|
+
var cfsFields = '';
|
|
54054
|
+
if(object.name === 'cms_files'){
|
|
54055
|
+
cfsFields = ',versions';
|
|
54056
|
+
}
|
|
54048
54057
|
|
|
54049
|
-
|
|
54050
|
-
|
|
54051
|
-
}
|
|
54058
|
+
const countQuery = options.count === false ? "" : `,count:${object.name}__count(filters:{__filters})`;
|
|
54059
|
+
// const moreQuerie = options.moreQueries?.length ? ("," + options.moreQueries.map(function(item){
|
|
54060
|
+
// // 把最外层的{}去除
|
|
54061
|
+
// return item.replace(/^{/,"").replace(/}$/,"");
|
|
54062
|
+
// }).join(",")) : "";
|
|
54052
54063
|
|
|
54053
|
-
|
|
54054
|
-
|
|
54064
|
+
return {
|
|
54065
|
+
orderBy: "${orderBy}",
|
|
54066
|
+
orderDir: "${orderDir}",
|
|
54067
|
+
pageNo: "${page}",
|
|
54068
|
+
pageSize: "${perPage}",
|
|
54069
|
+
query: `{${alias}:${object.name}${queryOptions}{${await getFieldsTemplate(fields, options.expand)}${treeFields}${cfsFields}}${countQuery}}`
|
|
54070
|
+
}
|
|
54055
54071
|
}
|
|
54056
54072
|
|
|
54057
|
-
function
|
|
54058
|
-
|
|
54059
|
-
|
|
54060
|
-
|
|
54061
|
-
|
|
54062
|
-
async function getRefObjectNameFieldName(field){
|
|
54063
|
-
const refUiSchema = await getUISchema(field.reference_to);
|
|
54064
|
-
const NAME_FIELD_KEY = refUiSchema.NAME_FIELD_KEY || 'name';
|
|
54065
|
-
return NAME_FIELD_KEY;
|
|
54066
|
-
}
|
|
54067
|
-
|
|
54068
|
-
function getSelectTpl(field){
|
|
54069
|
-
return `<span>\${_display.${field.name}}</span>`
|
|
54070
|
-
}
|
|
54071
|
-
function getSelectMap(selectOptions){
|
|
54072
|
-
let map = {};
|
|
54073
|
-
lodash.exports.forEach(selectOptions,(option)=>{
|
|
54074
|
-
const optionValue = option.value + '';
|
|
54075
|
-
const optionColor = option.color + '';
|
|
54076
|
-
if(optionColor){
|
|
54077
|
-
const background = optionColor.charAt(0) === '#' ? optionColor : '#'+optionColor;
|
|
54078
|
-
const color = getContrastColor(background);
|
|
54079
|
-
const optionColorStyle = 'background:'+background+';color:'+color+';line-height:1.5rem';
|
|
54080
|
-
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
54081
|
-
}else {
|
|
54082
|
-
map[optionValue] = option.label;
|
|
54083
|
-
}
|
|
54084
|
-
});
|
|
54085
|
-
return map;
|
|
54086
|
-
}
|
|
54087
|
-
|
|
54088
|
-
function getNameTplUrl(field, ctx){
|
|
54089
|
-
if(ctx.objectName === 'cms_files'){
|
|
54090
|
-
return `\${context.rootUrl}/api/files/files/\${versions[0]}?download=true`
|
|
54091
|
-
}
|
|
54092
|
-
const href = Router.getObjectDetailPath({
|
|
54093
|
-
...ctx, formFactor: ctx.formFactor, appId: "${appId}", objectName: ctx.objectName || "${objectName}", recordId: `\${${ctx.idFieldName}}`
|
|
54094
|
-
});
|
|
54095
|
-
return href;
|
|
54096
|
-
}
|
|
54097
|
-
|
|
54098
|
-
function getNameTpl(field, ctx){
|
|
54099
|
-
const href = getNameTplUrl(field, ctx);
|
|
54100
|
-
let linkTarget = "";
|
|
54101
|
-
if(ctx && ctx.isLookup){
|
|
54102
|
-
linkTarget = "target='_blank'";
|
|
54103
|
-
}
|
|
54104
|
-
return `<a href="${href}" ${linkTarget}>\${${field.name}}</a>`
|
|
54105
|
-
}
|
|
54106
|
-
|
|
54107
|
-
function getRelatedFieldTpl(field, ctx){
|
|
54108
|
-
let tpl = '';
|
|
54109
|
-
if(!field.reference_to && (field.optionsFunction || field._optionsFunction || field.options)){
|
|
54110
|
-
if(field.isTableField){
|
|
54111
|
-
return `\${${field.name}}`
|
|
54112
|
-
}else {
|
|
54113
|
-
return `\${${field.name}__label}`
|
|
54114
|
-
}
|
|
54115
|
-
}
|
|
54116
|
-
|
|
54117
|
-
let linkTarget = "";
|
|
54118
|
-
if(ctx && ctx.isLookup){
|
|
54119
|
-
linkTarget = "target='_blank'";
|
|
54120
|
-
}
|
|
54121
|
-
|
|
54122
|
-
const onlyDisplayLookLabel = ctx.onlyDisplayLookLabel;
|
|
54123
|
-
|
|
54124
|
-
let fieldDataStrTpl = `data._display.${field.name}`;
|
|
54125
|
-
|
|
54126
|
-
if(field.isTableField){
|
|
54127
|
-
fieldDataStrTpl = `data.${field.name}`;
|
|
54128
|
-
}
|
|
54129
|
-
|
|
54130
|
-
if(_.isString(field.reference_to) || !field.reference_to){
|
|
54131
|
-
if(field.multiple){
|
|
54132
|
-
let labelTpl = `<%=item.label%>`;
|
|
54133
|
-
if(!onlyDisplayLookLabel){
|
|
54134
|
-
const href = Router.getObjectDetailPath({
|
|
54135
|
-
formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
|
|
54136
|
-
});
|
|
54137
|
-
labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
|
|
54138
|
-
}
|
|
54139
|
-
tpl = `
|
|
54140
|
-
<% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item,index) { %> <% if(index>0 && index<${fieldDataStrTpl}.length){ %> , <% } %> ${labelTpl} <% }); %><% } %>
|
|
54141
|
-
`;
|
|
54142
|
-
}else {
|
|
54143
|
-
let labelTpl = `\${_display.${field.name}.label}`;
|
|
54144
|
-
let objectNameTpl = `\${_display.${field.name}.objectName}`;
|
|
54145
|
-
let recordIdTpl = `\${_display.${field.name}.value}`;
|
|
54146
|
-
if(field.isTableField){
|
|
54147
|
-
labelTpl = `\${${field.name}.label}`;
|
|
54148
|
-
objectNameTpl = `\${${field.name}.objectName}`;
|
|
54149
|
-
recordIdTpl = `\${${field.name}.value}`;
|
|
54150
|
-
}
|
|
54151
|
-
if(!onlyDisplayLookLabel){
|
|
54152
|
-
const href = Router.getObjectDetailPath({
|
|
54153
|
-
formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
|
|
54154
|
-
});
|
|
54155
|
-
labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
|
|
54156
|
-
}
|
|
54157
|
-
tpl = labelTpl;
|
|
54158
|
-
}
|
|
54159
|
-
|
|
54160
|
-
|
|
54161
|
-
}else {
|
|
54162
|
-
let labelTpl = `<%=item.label%>`;
|
|
54163
|
-
if(!onlyDisplayLookLabel){
|
|
54164
|
-
const href = Router.getObjectDetailPath({
|
|
54165
|
-
formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
|
|
54166
|
-
});
|
|
54167
|
-
labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
|
|
54168
|
-
}
|
|
54169
|
-
tpl = `
|
|
54170
|
-
<% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item) { %> ${labelTpl} <% }); %><% } %>
|
|
54171
|
-
`;
|
|
54172
|
-
}
|
|
54173
|
-
return tpl
|
|
54174
|
-
}
|
|
54175
|
-
|
|
54176
|
-
async function getLookupTpl(field, ctx){
|
|
54177
|
-
if(!field.reference_to){
|
|
54178
|
-
return getSelectTpl(field)
|
|
54179
|
-
}
|
|
54180
|
-
const NAME_FIELD_KEY = await getRefObjectNameFieldName(field);
|
|
54181
|
-
if(field.multiple){
|
|
54182
|
-
const href = Router.getObjectDetailPath({
|
|
54183
|
-
formFactor: ctx.formFactor, appId: ctx.appId, objectName: field.reference_to, recordId: `<%=item._id%>`, _templateType: "JavaScript"
|
|
54184
|
-
});
|
|
54185
|
-
return `
|
|
54186
|
-
<% if (data.${field.name} && data.${field.name}.length) { %><% data.${field.name}.forEach(function(item) { %> <a href="${href}"><%=item.${NAME_FIELD_KEY}%></a> <% }); %><% } %>
|
|
54187
|
-
`
|
|
54188
|
-
}else {
|
|
54189
|
-
const href = Router.getObjectDetailPath({
|
|
54190
|
-
formFactor: ctx.formFactor, appId: ctx.appId, objectName: field.reference_to, recordId: `\${${field.name}._id}`
|
|
54191
|
-
});
|
|
54192
|
-
return `<a href="${href}">\${${field.name}.${NAME_FIELD_KEY}}</a>`
|
|
54193
|
-
}
|
|
54194
|
-
|
|
54195
|
-
}
|
|
54196
|
-
|
|
54197
|
-
function getSwitchTpl(field){
|
|
54198
|
-
let fieldDataStrTpl = `data._display.${field.name}`;
|
|
54199
|
-
if(field.isTableField){
|
|
54200
|
-
fieldDataStrTpl = `data.${field.name}`;
|
|
54201
|
-
}
|
|
54202
|
-
return `<% if (data.${field.name}) { %>
|
|
54203
|
-
<span class="slds-icon_container slds-icon-utility-check slds-current-color" title="<%=${fieldDataStrTpl}%>">
|
|
54204
|
-
<span ><%= ${fieldDataStrTpl} === "√" ? "<svg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='currentColor' class='w-4 h-4'><path stroke-linecap='round' stroke-linejoin='round' d='M4.5 12.75l6 6 9-13.5' /></svg>" : ${fieldDataStrTpl} %></span>
|
|
54205
|
-
</span>
|
|
54206
|
-
<% } %>`
|
|
54207
|
-
}
|
|
54208
|
-
|
|
54209
|
-
function getPasswordTpl(field){
|
|
54210
|
-
return `<% if (data.${field.name}) { %>
|
|
54211
|
-
<span>······</span>
|
|
54212
|
-
<% } %>`
|
|
54213
|
-
}
|
|
54214
|
-
|
|
54215
|
-
function getLocationTpl(field){
|
|
54216
|
-
return `\${${field.name} ? ${field.name}.address : ''}`
|
|
54217
|
-
}
|
|
54218
|
-
|
|
54219
|
-
async function getFieldTpl (field, options){
|
|
54220
|
-
if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel){
|
|
54221
|
-
return getNameTpl(field, options)
|
|
54222
|
-
}
|
|
54223
|
-
switch (field.type) {
|
|
54224
|
-
case 'password':
|
|
54225
|
-
return getPasswordTpl(field);
|
|
54226
|
-
case 'boolean':
|
|
54227
|
-
return getSwitchTpl(field);
|
|
54228
|
-
case 'toggle':
|
|
54229
|
-
return getSwitchTpl(field);
|
|
54230
|
-
case 'select':
|
|
54231
|
-
return getSelectTpl(field);
|
|
54232
|
-
case 'time':
|
|
54233
|
-
return getTimeTpl(field);
|
|
54234
|
-
case 'date':
|
|
54235
|
-
return getDateTpl(field);
|
|
54236
|
-
case 'datetime':
|
|
54237
|
-
return getDateTimeTpl(field);
|
|
54238
|
-
case 'lookup':
|
|
54239
|
-
return await getRelatedFieldTpl(field, options);
|
|
54240
|
-
case 'master_detail':
|
|
54241
|
-
return await getRelatedFieldTpl(field, options);
|
|
54242
|
-
case 'location':
|
|
54243
|
-
return await getLocationTpl(field);
|
|
54244
|
-
case 'number':
|
|
54245
|
-
case 'currency':
|
|
54246
|
-
return await getNumberTpl(field);
|
|
54247
|
-
case 'percent':
|
|
54248
|
-
case 'formula':
|
|
54249
|
-
case 'summary':
|
|
54250
|
-
return getUiFieldTpl(field)
|
|
54251
|
-
case 'filesize':
|
|
54252
|
-
return getUiFileSizeTpl(field)
|
|
54253
|
-
}
|
|
54254
|
-
}
|
|
54255
|
-
|
|
54256
|
-
async function getFieldsTemplate(fields, display){
|
|
54257
|
-
let expandFields = [];
|
|
54258
|
-
if(display != false){
|
|
54259
|
-
display = true;
|
|
54260
|
-
}
|
|
54261
|
-
let fieldsName = ['_id'];
|
|
54262
|
-
let displayFields = [];
|
|
54263
|
-
let fieldsArr = [];
|
|
54264
|
-
if(lodash.exports.isArray(fields)){
|
|
54265
|
-
fieldsArr = fields;
|
|
54266
|
-
}else {
|
|
54267
|
-
fieldsArr = lodash.exports.values(fields);
|
|
54268
|
-
}
|
|
54269
|
-
for (const field of fieldsArr) {
|
|
54270
|
-
//graphql 的 ui\display 中使用的字段需要先在query中查询. 否则会返回null
|
|
54271
|
-
if(field.expand){
|
|
54272
|
-
expandFields.push(field);
|
|
54273
|
-
}else {
|
|
54274
|
-
if(field.name.indexOf('.') < 0){
|
|
54275
|
-
if(display && (field.type == 'lookup' || field.type == 'master_detail')){
|
|
54276
|
-
fieldsName.push(`${field.name}`);
|
|
54277
|
-
displayFields.push(`${field.name}`);
|
|
54278
|
-
}else {
|
|
54279
|
-
fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
|
|
54280
|
-
}
|
|
54281
|
-
if(lodash.exports.includes(['time','date','datetime','boolean','number','currency'], field.type)){
|
|
54282
|
-
fieldsName.push(`${field.name}`);
|
|
54283
|
-
}
|
|
54284
|
-
if(lodash.exports.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
|
|
54285
|
-
displayFields.push(`${field.name}`);
|
|
54286
|
-
}
|
|
54287
|
-
}else {
|
|
54288
|
-
objectFieldName = field.name.split('.')[0];
|
|
54289
|
-
fieldsName.push(objectFieldName);
|
|
54290
|
-
displayFields.push(objectFieldName);
|
|
54291
|
-
}
|
|
54292
|
-
}
|
|
54293
|
-
}
|
|
54294
|
-
|
|
54295
|
-
displayFields = lodash.exports.uniq(displayFields);
|
|
54296
|
-
fieldsName = lodash.exports.uniq(fieldsName);
|
|
54297
|
-
let expandFieldsQuery = "";
|
|
54298
|
-
if(expandFields.length > 0){
|
|
54299
|
-
lodash.exports.each(expandFields, function(field){
|
|
54300
|
-
expandFieldsQuery = expandFieldsQuery + `${field.expandInfo.fieldName}__expand{${field.expandInfo.displayName}}`;
|
|
54301
|
-
});
|
|
54302
|
-
}
|
|
54303
|
-
|
|
54304
|
-
if(displayFields.length > 0){
|
|
54305
|
-
return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
|
|
54306
|
-
}
|
|
54307
|
-
return lodash.exports.trimEnd(`${fieldsName.join(' ')},${expandFieldsQuery}`, ",")
|
|
54308
|
-
}
|
|
54309
|
-
|
|
54310
|
-
async function getFindQuery(object, recordId, fields, options){
|
|
54311
|
-
let limit = options.limit || 10;
|
|
54312
|
-
let queryOptions = `(top: ${limit})`;
|
|
54313
|
-
if(recordId){
|
|
54314
|
-
queryOptions = `(filters:["_id", "=", "${recordId}"], top: ${limit})`;
|
|
54315
|
-
}
|
|
54316
|
-
let alias = "data";
|
|
54317
|
-
if(options){
|
|
54318
|
-
if(options.alias){
|
|
54319
|
-
alias = options.alias;
|
|
54320
|
-
}
|
|
54321
|
-
|
|
54322
|
-
if(options.filters){
|
|
54323
|
-
queryOptions = `(filters:${options.filters})`;
|
|
54324
|
-
}
|
|
54325
|
-
if(options.queryOptions){
|
|
54326
|
-
queryOptions = `(${options.queryOptions})`;
|
|
54327
|
-
}
|
|
54328
|
-
}
|
|
54329
|
-
var treeFields = '';
|
|
54330
|
-
if(object.enable_tree && lodash.exports.includes(lodash.exports.keys(object.fields), 'parent') && lodash.exports.includes(lodash.exports.keys(object.fields), 'children')){
|
|
54331
|
-
treeFields = ',parent,children';
|
|
54332
|
-
}
|
|
54333
|
-
|
|
54334
|
-
var cfsFields = '';
|
|
54335
|
-
if(object.name === 'cms_files'){
|
|
54336
|
-
cfsFields = ',versions';
|
|
54337
|
-
}
|
|
54338
|
-
|
|
54339
|
-
const countQuery = options.count === false ? "" : `,count:${object.name}__count(filters:{__filters})`;
|
|
54340
|
-
// const moreQuerie = options.moreQueries?.length ? ("," + options.moreQueries.map(function(item){
|
|
54341
|
-
// // 把最外层的{}去除
|
|
54342
|
-
// return item.replace(/^{/,"").replace(/}$/,"");
|
|
54343
|
-
// }).join(",")) : "";
|
|
54344
|
-
|
|
54345
|
-
return {
|
|
54346
|
-
orderBy: "${orderBy}",
|
|
54347
|
-
orderDir: "${orderDir}",
|
|
54348
|
-
pageNo: "${page}",
|
|
54349
|
-
pageSize: "${perPage}",
|
|
54350
|
-
query: `{${alias}:${object.name}${queryOptions}{${await getFieldsTemplate(fields, options.expand)}${treeFields}${cfsFields}}${countQuery}}`
|
|
54351
|
-
}
|
|
54352
|
-
}
|
|
54353
|
-
|
|
54354
|
-
function getApi$2 (isMobile){
|
|
54355
|
-
if(isMobile);else {
|
|
54356
|
-
// return __meteor_runtime_config__.ROOT_URL_PATH_PREFIX + "/graphql"
|
|
54357
|
-
return `\${context.rootUrl}/graphql?reload=\${additionalFilters}`
|
|
54358
|
-
}
|
|
54073
|
+
function getApi$2 (isMobile){
|
|
54074
|
+
if(isMobile);else {
|
|
54075
|
+
// return __meteor_runtime_config__.ROOT_URL_PATH_PREFIX + "/graphql"
|
|
54076
|
+
return `\${context.rootUrl}/graphql?reload=\${additionalFilters}`
|
|
54077
|
+
}
|
|
54359
54078
|
}
|
|
54360
54079
|
|
|
54361
54080
|
var frontend_field_group_generalization$1 = "General";
|
|
@@ -54808,6 +54527,67 @@ async function getListSchema$1(fields, options){
|
|
|
54808
54527
|
}
|
|
54809
54528
|
}
|
|
54810
54529
|
|
|
54530
|
+
/*
|
|
54531
|
+
* @Author: baozhoutao@steedos.com
|
|
54532
|
+
* @Date: 2022-07-20 16:29:22
|
|
54533
|
+
* @LastEditors: liaodaxue
|
|
54534
|
+
* @LastEditTime: 2023-09-11 17:19:53
|
|
54535
|
+
* @Description:
|
|
54536
|
+
*/
|
|
54537
|
+
|
|
54538
|
+
function getImageFieldUrl(url) {
|
|
54539
|
+
if (window.Meteor && window.Meteor.isCordova != true) {
|
|
54540
|
+
// '//'的位置
|
|
54541
|
+
const doubleSlashIndex = url.indexOf('//');
|
|
54542
|
+
const urlIndex = url.indexOf('/', doubleSlashIndex + 2);
|
|
54543
|
+
const rootUrl = url.substring(urlIndex);
|
|
54544
|
+
return rootUrl;
|
|
54545
|
+
}
|
|
54546
|
+
return url;
|
|
54547
|
+
}
|
|
54548
|
+
|
|
54549
|
+
if(typeof window != 'undefined'){
|
|
54550
|
+
window.getImageFieldUrl = getImageFieldUrl;
|
|
54551
|
+
}
|
|
54552
|
+
|
|
54553
|
+
function getContrastColor(bgColor) {
|
|
54554
|
+
var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
|
|
54555
|
+
var r = parseInt(backgroundColor.substr(0, 2), 16);
|
|
54556
|
+
var g = parseInt(backgroundColor.substr(2, 2), 16);
|
|
54557
|
+
var b = parseInt(backgroundColor.substr(4, 2), 16);
|
|
54558
|
+
var brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
54559
|
+
return brightness < 128 ? "#ffffff" : "#000000";
|
|
54560
|
+
}
|
|
54561
|
+
|
|
54562
|
+
function getLookupListView(refObjectConfig) {
|
|
54563
|
+
if(!refObjectConfig){
|
|
54564
|
+
return null;
|
|
54565
|
+
}
|
|
54566
|
+
const listNameAll = "all";
|
|
54567
|
+
const listNameLookup = "lookup";
|
|
54568
|
+
let listViewAll, listViewLookup;
|
|
54569
|
+
|
|
54570
|
+
_.each(
|
|
54571
|
+
refObjectConfig.list_views,
|
|
54572
|
+
(view, name) => {
|
|
54573
|
+
if (name === listNameAll) {
|
|
54574
|
+
listViewAll = view;
|
|
54575
|
+
if(!listViewAll.name){
|
|
54576
|
+
listViewAll.name = name;
|
|
54577
|
+
}
|
|
54578
|
+
}
|
|
54579
|
+
else if (name === listNameLookup) {
|
|
54580
|
+
listViewLookup = view;
|
|
54581
|
+
if(!listViewLookup.name){
|
|
54582
|
+
listViewLookup.name = name;
|
|
54583
|
+
}
|
|
54584
|
+
}
|
|
54585
|
+
}
|
|
54586
|
+
);
|
|
54587
|
+
let listView = listViewLookup || listViewAll;
|
|
54588
|
+
return listView;
|
|
54589
|
+
}
|
|
54590
|
+
|
|
54811
54591
|
/*
|
|
54812
54592
|
* @Author: baozhoutao@steedos.com
|
|
54813
54593
|
* @Date: 2022-11-01 15:51:00
|
|
@@ -56056,6 +55836,7 @@ const getSetListviewFiltersButtonSchema = ()=>{
|
|
|
56056
55836
|
}
|
|
56057
55837
|
}
|
|
56058
55838
|
],
|
|
55839
|
+
"className": "steedos-overflow-visible-dialog",
|
|
56059
55840
|
"showCloseButton": true,
|
|
56060
55841
|
"showErrorMsg": true,
|
|
56061
55842
|
"showLoading": true,
|
|
@@ -56642,7 +56423,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
|
|
|
56642
56423
|
"value": crudKeywords,
|
|
56643
56424
|
"clearable": true,
|
|
56644
56425
|
"clearAndSubmit": true,
|
|
56645
|
-
"searchImediately":
|
|
56426
|
+
"searchImediately": false
|
|
56646
56427
|
}
|
|
56647
56428
|
]
|
|
56648
56429
|
}
|
|
@@ -57523,7 +57304,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
57523
57304
|
if(refObjectConfig.name === 'organizations'){
|
|
57524
57305
|
labelFieldName = 'name';
|
|
57525
57306
|
}
|
|
57526
|
-
pickerSchema = await getTableSchema
|
|
57307
|
+
pickerSchema = await getTableSchema(tableFields, {
|
|
57527
57308
|
labelFieldName,
|
|
57528
57309
|
top: top,
|
|
57529
57310
|
isLookup: true,
|
|
@@ -58013,7 +57794,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
|
|
|
58013
57794
|
actions: false
|
|
58014
57795
|
});
|
|
58015
57796
|
}else {
|
|
58016
|
-
pickerSchema = await getTableSchema
|
|
57797
|
+
pickerSchema = await getTableSchema(tableFields, {
|
|
58017
57798
|
labelFieldName: refObjectConfig.NAME_FIELD_KEY,
|
|
58018
57799
|
top: top,
|
|
58019
57800
|
isLookup: true,
|
|
@@ -58663,7 +58444,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
58663
58444
|
suffix: "%",
|
|
58664
58445
|
pipeIn: (value, data) => {
|
|
58665
58446
|
if(value){
|
|
58666
|
-
|
|
58447
|
+
// 因为例如 1.11 * 100 的值不是111,所以调整下。
|
|
58448
|
+
const result = value*100;
|
|
58449
|
+
return Number(result.toFixed(field.scale));
|
|
58667
58450
|
}
|
|
58668
58451
|
return value;
|
|
58669
58452
|
},
|
|
@@ -58762,295 +58545,907 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
58762
58545
|
return value; // 切换到数字之后的默认值
|
|
58763
58546
|
}
|
|
58764
58547
|
}
|
|
58765
|
-
};
|
|
58766
|
-
break;
|
|
58767
|
-
case 'avatar':
|
|
58768
|
-
convertData = getAmisFileSchema(field, readonly);
|
|
58769
|
-
break;
|
|
58770
|
-
case 'image':
|
|
58771
|
-
convertData = getAmisFileSchema(field, readonly);
|
|
58772
|
-
break;
|
|
58773
|
-
case 'file':
|
|
58774
|
-
convertData = getAmisFileSchema(field, readonly);
|
|
58548
|
+
};
|
|
58549
|
+
break;
|
|
58550
|
+
case 'avatar':
|
|
58551
|
+
convertData = getAmisFileSchema(field, readonly);
|
|
58552
|
+
break;
|
|
58553
|
+
case 'image':
|
|
58554
|
+
convertData = getAmisFileSchema(field, readonly);
|
|
58555
|
+
break;
|
|
58556
|
+
case 'file':
|
|
58557
|
+
convertData = getAmisFileSchema(field, readonly);
|
|
58558
|
+
break;
|
|
58559
|
+
case 'formula':
|
|
58560
|
+
if(readonly){
|
|
58561
|
+
convertData = {
|
|
58562
|
+
type: 'static-tpl',
|
|
58563
|
+
tpl: getUiFieldTpl(field)
|
|
58564
|
+
};
|
|
58565
|
+
}
|
|
58566
|
+
break;
|
|
58567
|
+
case 'summary':
|
|
58568
|
+
if(readonly){
|
|
58569
|
+
convertData = {
|
|
58570
|
+
type: 'static-tpl',
|
|
58571
|
+
tpl: getUiFieldTpl(field)
|
|
58572
|
+
};
|
|
58573
|
+
}
|
|
58574
|
+
break;
|
|
58575
|
+
case 'code':
|
|
58576
|
+
convertData = {
|
|
58577
|
+
type: "editor",
|
|
58578
|
+
disabled: readonly ? true : false,
|
|
58579
|
+
language: field.language,
|
|
58580
|
+
editorDidMount: new Function('editor', 'monaco', field.editorDidMount)
|
|
58581
|
+
};
|
|
58582
|
+
break;
|
|
58583
|
+
case 'toggle':
|
|
58584
|
+
convertData = {
|
|
58585
|
+
type: "switch",
|
|
58586
|
+
name: field.name,
|
|
58587
|
+
label: field.label,
|
|
58588
|
+
width: field.width,
|
|
58589
|
+
toggled: field.toggled,
|
|
58590
|
+
disabled: readonly,
|
|
58591
|
+
};
|
|
58592
|
+
break;
|
|
58593
|
+
case 'grid':
|
|
58594
|
+
if(field.subFields){
|
|
58595
|
+
convertData = {
|
|
58596
|
+
type: 'input-table',
|
|
58597
|
+
showIndex: true,
|
|
58598
|
+
columnsTogglable: false,
|
|
58599
|
+
strictMode:false,
|
|
58600
|
+
affixHeader: false, // 是否固定表头, 不固定表头, 否则form有y轴滚动条时, 表头会跟随滚动条滚动.
|
|
58601
|
+
needConfirm: false,
|
|
58602
|
+
editable: !readonly,
|
|
58603
|
+
addable: !readonly,
|
|
58604
|
+
removable: !readonly,
|
|
58605
|
+
draggable: !readonly,
|
|
58606
|
+
columns: []
|
|
58607
|
+
};
|
|
58608
|
+
// console.log(`convertData ==2====>`, field, convertData)
|
|
58609
|
+
for (const subField of field.subFields) {
|
|
58610
|
+
const subFieldName = subField.name.replace(`${field._prefix || ''}${field.name}.$.`, '').replace(`${field.name}.`, '');
|
|
58611
|
+
const gridSub = await convertSFieldToAmisField(Object.assign({}, subField, {name: subFieldName, isTableField: true}), readonly, ctx);
|
|
58612
|
+
if(gridSub){
|
|
58613
|
+
delete gridSub.name;
|
|
58614
|
+
delete gridSub.label;
|
|
58615
|
+
const gridItemSchema = {
|
|
58616
|
+
name: subFieldName,
|
|
58617
|
+
label: subField.label,
|
|
58618
|
+
quickEdit: readonly ? false : gridSub
|
|
58619
|
+
};
|
|
58620
|
+
if(["lookup", "boolean", "toggle"].indexOf(subField.type) > -1){
|
|
58621
|
+
gridItemSchema.type = gridSub.type;
|
|
58622
|
+
gridItemSchema.tpl = gridSub.tpl;
|
|
58623
|
+
}
|
|
58624
|
+
convertData.columns.push(Object.assign({}, gridItemSchema, subField.amis, {name: subFieldName}));
|
|
58625
|
+
}
|
|
58626
|
+
}
|
|
58627
|
+
}
|
|
58775
58628
|
break;
|
|
58776
|
-
case '
|
|
58777
|
-
if(
|
|
58629
|
+
case 'object':
|
|
58630
|
+
if(field.subFields){
|
|
58778
58631
|
convertData = {
|
|
58779
|
-
type: '
|
|
58780
|
-
|
|
58632
|
+
type: 'combo',
|
|
58633
|
+
items: []
|
|
58781
58634
|
};
|
|
58635
|
+
// console.log(`convertData ======>`, field, convertData)
|
|
58636
|
+
for (let subField of field.subFields) {
|
|
58637
|
+
let subFieldName = subField.name.replace(`${field.name}.$.`, '').replace(`${field.name}.`, '');
|
|
58638
|
+
if(subField.type === 'grid'){
|
|
58639
|
+
subField = await getGridFieldSubFields(subField, ctx.__formFields);
|
|
58640
|
+
}else {
|
|
58641
|
+
if(readonly){
|
|
58642
|
+
subFieldName = `${field.name}.${subFieldName}`;
|
|
58643
|
+
}
|
|
58644
|
+
}
|
|
58645
|
+
const gridSub = await convertSFieldToAmisField(Object.assign({}, subField, {name: subFieldName}), readonly, ctx);
|
|
58646
|
+
if(gridSub){
|
|
58647
|
+
delete gridSub.name;
|
|
58648
|
+
delete gridSub.label;
|
|
58649
|
+
convertData.items.push(
|
|
58650
|
+
Object.assign({}, gridSub, {label: subField.label}, subField.amis, {
|
|
58651
|
+
name: subFieldName
|
|
58652
|
+
})
|
|
58653
|
+
);
|
|
58654
|
+
}
|
|
58655
|
+
}
|
|
58656
|
+
}
|
|
58657
|
+
break;
|
|
58658
|
+
}
|
|
58659
|
+
if(!lodash.exports.isEmpty(convertData)){
|
|
58660
|
+
if(field.is_wide || convertData.type === 'group'){
|
|
58661
|
+
convertData.className = 'col-span-2 m-1';
|
|
58662
|
+
}else {
|
|
58663
|
+
convertData.className = 'm-1';
|
|
58664
|
+
}
|
|
58665
|
+
if(readonly){
|
|
58666
|
+
convertData.className = `${convertData.className} border-b`;
|
|
58667
|
+
}
|
|
58668
|
+
if(readonly){
|
|
58669
|
+
convertData.quickEdit = false;
|
|
58670
|
+
}
|
|
58671
|
+
|
|
58672
|
+
let fieldTypeClassName = ' steedos-' + convertData.type + (readonly ? '-readonly' : '-edit');
|
|
58673
|
+
if (convertData.className) {
|
|
58674
|
+
convertData.className = convertData.className + fieldTypeClassName;
|
|
58675
|
+
} else {
|
|
58676
|
+
convertData.className = fieldTypeClassName;
|
|
58677
|
+
}
|
|
58678
|
+
|
|
58679
|
+
if(field.visible_on && !ctx.inFilterForm){
|
|
58680
|
+
// convertData.visibleOn = `\$${field.visible_on.substring(1, field.visible_on.length -1).replace(/formData./g, '')}`;
|
|
58681
|
+
if(field.visible_on.startsWith("{{")){
|
|
58682
|
+
convertData.visibleOn = `${field.visible_on.substring(2, field.visible_on.length -2).replace(/formData./g, 'data.')}`;
|
|
58683
|
+
}else {
|
|
58684
|
+
convertData.visibleOn = `${field.visible_on.replace(/formData./g, 'data.')}`;
|
|
58685
|
+
}
|
|
58686
|
+
}
|
|
58687
|
+
|
|
58688
|
+
if(lodash.exports.isString(baseData.required)){
|
|
58689
|
+
if(baseData.required.startsWith("{{")){
|
|
58690
|
+
baseData.requiredOn = `${baseData.required.substring(2, baseData.required.length -2).replace(/formData./g, 'data.')}`;
|
|
58691
|
+
delete baseData.required;
|
|
58692
|
+
}
|
|
58693
|
+
}
|
|
58694
|
+
|
|
58695
|
+
if(convertData.type === 'group'){
|
|
58696
|
+
convertData.body[0] = Object.assign({}, baseData, convertData.body[0], { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name});
|
|
58697
|
+
return convertData
|
|
58698
|
+
}
|
|
58699
|
+
// if(ctx.mode === 'edit'){
|
|
58700
|
+
return Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name}, field.amis, {name: baseData.name});
|
|
58701
|
+
// }else{
|
|
58702
|
+
// return Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name});
|
|
58703
|
+
// }
|
|
58704
|
+
}
|
|
58705
|
+
|
|
58706
|
+
}
|
|
58707
|
+
|
|
58708
|
+
async function getFieldSearchable(perField, permissionFields, ctx){
|
|
58709
|
+
if(!ctx){
|
|
58710
|
+
ctx = {};
|
|
58711
|
+
}
|
|
58712
|
+
let field = perField;
|
|
58713
|
+
if(field.type === 'grid'){
|
|
58714
|
+
field = await getGridFieldSubFields(perField, permissionFields);
|
|
58715
|
+
}else if(perField.type === 'object'){
|
|
58716
|
+
field = await getObjectFieldSubFields(perField, permissionFields);
|
|
58717
|
+
}
|
|
58718
|
+
|
|
58719
|
+
let fieldNamePrefix = '__searchable__';
|
|
58720
|
+
if(field.name.indexOf(".") < 0){
|
|
58721
|
+
let _field = lodash.exports.cloneDeep(field);
|
|
58722
|
+
if(lodash.exports.includes(['textarea', 'html', 'code', 'autonumber'], field.type)){
|
|
58723
|
+
_field.type = 'text';
|
|
58724
|
+
}
|
|
58725
|
+
|
|
58726
|
+
if(lodash.exports.includes(['formula', 'summary'], field.type)){
|
|
58727
|
+
_field.type = field.data_type;
|
|
58728
|
+
_field.precision = field.precision;
|
|
58729
|
+
_field.scale = field.scale;
|
|
58730
|
+
}
|
|
58731
|
+
else if(field.type === "select" && field.data_type && field.data_type != "text"){
|
|
58732
|
+
_field.type = field.data_type;
|
|
58733
|
+
}
|
|
58734
|
+
|
|
58735
|
+
if(_field.type === 'number' || _field.type === 'currency'){
|
|
58736
|
+
_field.type = 'input-array';
|
|
58737
|
+
_field.inline = true;
|
|
58738
|
+
_field.addable = false;
|
|
58739
|
+
_field.removable = false;
|
|
58740
|
+
_field.value = [null,null];
|
|
58741
|
+
_field.items = {
|
|
58742
|
+
type: "input-number"
|
|
58743
|
+
};
|
|
58744
|
+
_field.is_wide = true;
|
|
58745
|
+
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
58746
|
+
}
|
|
58747
|
+
|
|
58748
|
+
if(_field.type ==='date'){
|
|
58749
|
+
_field.type = 'input-date-range';
|
|
58750
|
+
_field.is_wide = true;
|
|
58751
|
+
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
58752
|
+
}
|
|
58753
|
+
if(_field.type === 'datetime'){
|
|
58754
|
+
_field.type = 'input-datetime-range';
|
|
58755
|
+
_field.is_wide = true;
|
|
58756
|
+
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
58757
|
+
}
|
|
58758
|
+
if(_field.type === 'time'){
|
|
58759
|
+
_field.type = 'input-time-range';
|
|
58760
|
+
_field.is_wide = true;
|
|
58761
|
+
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
58762
|
+
}
|
|
58763
|
+
if(_field.reference_to === 'users'){
|
|
58764
|
+
_field.reference_to = 'space_users';
|
|
58765
|
+
_field.reference_to_field = 'user';
|
|
58766
|
+
}
|
|
58767
|
+
_field.readonly = false;
|
|
58768
|
+
_field.disabled = false;
|
|
58769
|
+
_field.multiple = true;
|
|
58770
|
+
_field.is_wide = false;
|
|
58771
|
+
_field.defaultValue = undefined;
|
|
58772
|
+
_field.required = false;
|
|
58773
|
+
_field.hidden = false;
|
|
58774
|
+
_field.omit = false;
|
|
58775
|
+
|
|
58776
|
+
if(_field.amis){
|
|
58777
|
+
delete _field.amis.static;
|
|
58778
|
+
delete _field.amis.staticOn;
|
|
58779
|
+
delete _field.amis.disabled;
|
|
58780
|
+
delete _field.amis.disabledOn;
|
|
58781
|
+
delete _field.amis.required;
|
|
58782
|
+
delete _field.amis.requiredOn;
|
|
58783
|
+
delete _field.amis.visible;
|
|
58784
|
+
delete _field.amis.visibleOn;
|
|
58785
|
+
delete _field.amis.hidden;
|
|
58786
|
+
delete _field.amis.hiddenOn;
|
|
58787
|
+
delete _field.amis.autoFill;
|
|
58788
|
+
}
|
|
58789
|
+
|
|
58790
|
+
const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
|
|
58791
|
+
if(amisField){
|
|
58792
|
+
return Object.assign({}, amisField,{
|
|
58793
|
+
submitOnChange: true
|
|
58794
|
+
});
|
|
58795
|
+
}
|
|
58796
|
+
}
|
|
58797
|
+
}
|
|
58798
|
+
|
|
58799
|
+
if(typeof window != 'undefined'){
|
|
58800
|
+
window.getFieldSearchable = getFieldSearchable;
|
|
58801
|
+
}
|
|
58802
|
+
|
|
58803
|
+
|
|
58804
|
+
function isFieldTypeSearchable(fieldType) {
|
|
58805
|
+
return !lodash.exports.includes(
|
|
58806
|
+
[
|
|
58807
|
+
"grid",
|
|
58808
|
+
"avatar",
|
|
58809
|
+
"image",
|
|
58810
|
+
"object",
|
|
58811
|
+
"[object]",
|
|
58812
|
+
"[Object]",
|
|
58813
|
+
"[grid]",
|
|
58814
|
+
"[text]",
|
|
58815
|
+
"audio",
|
|
58816
|
+
"file",
|
|
58817
|
+
],
|
|
58818
|
+
fieldType
|
|
58819
|
+
)
|
|
58820
|
+
}
|
|
58821
|
+
|
|
58822
|
+
if (typeof window != 'undefined') {
|
|
58823
|
+
window.isFieldTypeSearchable = isFieldTypeSearchable;
|
|
58824
|
+
}
|
|
58825
|
+
|
|
58826
|
+
|
|
58827
|
+
function isFieldQuickSearchable(field, nameFieldKey) {
|
|
58828
|
+
let fieldSearchable = field.searchable;
|
|
58829
|
+
if(fieldSearchable !== false && field.name === nameFieldKey){
|
|
58830
|
+
// 对象上名称字段的searchable默认认为是true
|
|
58831
|
+
fieldSearchable = true;
|
|
58832
|
+
}
|
|
58833
|
+
if (fieldSearchable && QUICK_SEARCHABLE_FIELD_TYPES.indexOf(field.type) > -1) {
|
|
58834
|
+
return true;
|
|
58835
|
+
}
|
|
58836
|
+
return false;
|
|
58837
|
+
}
|
|
58838
|
+
|
|
58839
|
+
/******************************************************************************
|
|
58840
|
+
Copyright (c) Microsoft Corporation.
|
|
58841
|
+
|
|
58842
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
58843
|
+
purpose with or without fee is hereby granted.
|
|
58844
|
+
|
|
58845
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
58846
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
58847
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
58848
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
58849
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
58850
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
58851
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
58852
|
+
***************************************************************************** */
|
|
58853
|
+
|
|
58854
|
+
var __assign = function() {
|
|
58855
|
+
__assign = Object.assign || function __assign(t) {
|
|
58856
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
58857
|
+
s = arguments[i];
|
|
58858
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
58859
|
+
}
|
|
58860
|
+
return t;
|
|
58861
|
+
};
|
|
58862
|
+
return __assign.apply(this, arguments);
|
|
58863
|
+
};
|
|
58864
|
+
|
|
58865
|
+
// 方便取值的时候能够把上层的取到,但是获取的时候不会全部把所有的数据获取到。
|
|
58866
|
+
function createObject(superProps, props, properties) {
|
|
58867
|
+
if (superProps && Object.isFrozen(superProps)) {
|
|
58868
|
+
superProps = cloneObject(superProps);
|
|
58869
|
+
}
|
|
58870
|
+
var obj = superProps
|
|
58871
|
+
? Object.create(superProps, __assign(__assign({}, properties), { __super: {
|
|
58872
|
+
value: superProps,
|
|
58873
|
+
writable: false,
|
|
58874
|
+
enumerable: false
|
|
58875
|
+
} }))
|
|
58876
|
+
: Object.create(Object.prototype, properties);
|
|
58877
|
+
props &&
|
|
58878
|
+
isObject(props) &&
|
|
58879
|
+
Object.keys(props).forEach(function (key) { return (obj[key] = props[key]); });
|
|
58880
|
+
return obj;
|
|
58881
|
+
}
|
|
58882
|
+
function cloneObject(target, persistOwnProps) {
|
|
58883
|
+
if (persistOwnProps === void 0) { persistOwnProps = true; }
|
|
58884
|
+
var obj = target && target.__super
|
|
58885
|
+
? Object.create(target.__super, {
|
|
58886
|
+
__super: {
|
|
58887
|
+
value: target.__super,
|
|
58888
|
+
writable: false,
|
|
58889
|
+
enumerable: false
|
|
58782
58890
|
}
|
|
58783
|
-
|
|
58784
|
-
|
|
58785
|
-
|
|
58786
|
-
|
|
58787
|
-
|
|
58788
|
-
|
|
58789
|
-
|
|
58891
|
+
})
|
|
58892
|
+
: Object.create(Object.prototype);
|
|
58893
|
+
persistOwnProps &&
|
|
58894
|
+
target &&
|
|
58895
|
+
Object.keys(target).forEach(function (key) { return (obj[key] = target[key]); });
|
|
58896
|
+
return obj;
|
|
58897
|
+
}
|
|
58898
|
+
function isObject(obj) {
|
|
58899
|
+
var typename = typeof obj;
|
|
58900
|
+
return (obj &&
|
|
58901
|
+
typename !== 'string' &&
|
|
58902
|
+
typename !== 'number' &&
|
|
58903
|
+
typename !== 'boolean' &&
|
|
58904
|
+
typename !== 'function' &&
|
|
58905
|
+
!Array.isArray(obj));
|
|
58906
|
+
}
|
|
58907
|
+
|
|
58908
|
+
/*
|
|
58909
|
+
* @Author: baozhoutao@steedos.com
|
|
58910
|
+
* @Date: 2022-07-05 15:55:39
|
|
58911
|
+
* @LastEditors: liaodaxue
|
|
58912
|
+
* @LastEditTime: 2023-10-20 11:38:25
|
|
58913
|
+
* @Description:
|
|
58914
|
+
*/
|
|
58915
|
+
|
|
58916
|
+
let UI_SCHEMA_CACHE = {};
|
|
58917
|
+
|
|
58918
|
+
let UISchemaFunction;
|
|
58919
|
+
|
|
58920
|
+
if('undefined' != typeof window){
|
|
58921
|
+
if(!window.UI_SCHEMA_CACHE){
|
|
58922
|
+
window.UI_SCHEMA_CACHE = UI_SCHEMA_CACHE;
|
|
58923
|
+
}
|
|
58924
|
+
UI_SCHEMA_CACHE = window.UI_SCHEMA_CACHE;
|
|
58925
|
+
}
|
|
58926
|
+
|
|
58927
|
+
const setUISchemaCache = (key, value) => {
|
|
58928
|
+
UI_SCHEMA_CACHE[key] = value;
|
|
58929
|
+
};
|
|
58930
|
+
|
|
58931
|
+
const getUISchemaCache = (key) => {
|
|
58932
|
+
return lodash.exports.cloneDeep(UI_SCHEMA_CACHE[key]);
|
|
58933
|
+
};
|
|
58934
|
+
|
|
58935
|
+
const hasUISchemaCache = (key) => {
|
|
58936
|
+
return lodash.exports.has(UI_SCHEMA_CACHE, key);
|
|
58937
|
+
};
|
|
58938
|
+
|
|
58939
|
+
function getListViewColumns(listView, formFactor) {
|
|
58940
|
+
let listViewColumns = [];
|
|
58941
|
+
if (formFactor === "SMALL") {
|
|
58942
|
+
listViewColumns = !lodash.exports.isEmpty(listView.mobile_columns)
|
|
58943
|
+
? listView.mobile_columns
|
|
58944
|
+
: lodash.exports.slice(listView.columns, 0, 4);
|
|
58945
|
+
} else {
|
|
58946
|
+
listViewColumns = listView.columns;
|
|
58947
|
+
}
|
|
58948
|
+
return listViewColumns;
|
|
58949
|
+
}
|
|
58950
|
+
function getListViewSort(listView) {
|
|
58951
|
+
let sort = '';
|
|
58952
|
+
if(listView && listView.sort && listView.sort.length){
|
|
58953
|
+
lodash.exports.each(listView.sort,function(item,index){
|
|
58954
|
+
if(lodash.exports.isArray(item)){
|
|
58955
|
+
const field_name = item[0];
|
|
58956
|
+
const order = item[1] || '';
|
|
58957
|
+
let sortStr = field_name + ' ' + order;
|
|
58958
|
+
sortStr = index > 0 ? ','+sortStr : sortStr;
|
|
58959
|
+
sort += sortStr;
|
|
58960
|
+
}else {
|
|
58961
|
+
let sortStr = item.field_name + ' ' + item.order;
|
|
58962
|
+
sortStr = index > 0 ? ','+sortStr : sortStr;
|
|
58963
|
+
sort += sortStr;
|
|
58790
58964
|
}
|
|
58791
|
-
|
|
58792
|
-
|
|
58793
|
-
|
|
58794
|
-
|
|
58795
|
-
|
|
58796
|
-
|
|
58797
|
-
|
|
58798
|
-
|
|
58799
|
-
|
|
58800
|
-
|
|
58801
|
-
|
|
58802
|
-
|
|
58803
|
-
|
|
58804
|
-
|
|
58805
|
-
|
|
58806
|
-
|
|
58807
|
-
|
|
58808
|
-
|
|
58809
|
-
break;
|
|
58810
|
-
case 'grid':
|
|
58811
|
-
if(field.subFields){
|
|
58812
|
-
convertData = {
|
|
58813
|
-
type: 'input-table',
|
|
58814
|
-
showIndex: true,
|
|
58815
|
-
columnsTogglable: false,
|
|
58816
|
-
strictMode:false,
|
|
58817
|
-
affixHeader: false, // 是否固定表头, 不固定表头, 否则form有y轴滚动条时, 表头会跟随滚动条滚动.
|
|
58818
|
-
needConfirm: false,
|
|
58819
|
-
editable: !readonly,
|
|
58820
|
-
addable: !readonly,
|
|
58821
|
-
removable: !readonly,
|
|
58822
|
-
draggable: !readonly,
|
|
58823
|
-
columns: []
|
|
58824
|
-
};
|
|
58825
|
-
// console.log(`convertData ==2====>`, field, convertData)
|
|
58826
|
-
for (const subField of field.subFields) {
|
|
58827
|
-
const subFieldName = subField.name.replace(`${field._prefix || ''}${field.name}.$.`, '').replace(`${field.name}.`, '');
|
|
58828
|
-
const gridSub = await convertSFieldToAmisField(Object.assign({}, subField, {name: subFieldName, isTableField: true}), readonly, ctx);
|
|
58829
|
-
if(gridSub){
|
|
58830
|
-
delete gridSub.name;
|
|
58831
|
-
delete gridSub.label;
|
|
58832
|
-
const gridItemSchema = {
|
|
58833
|
-
name: subFieldName,
|
|
58834
|
-
label: subField.label,
|
|
58835
|
-
quickEdit: readonly ? false : gridSub
|
|
58836
|
-
};
|
|
58837
|
-
if(["lookup", "boolean", "toggle"].indexOf(subField.type) > -1){
|
|
58838
|
-
gridItemSchema.type = gridSub.type;
|
|
58839
|
-
gridItemSchema.tpl = gridSub.tpl;
|
|
58840
|
-
}
|
|
58841
|
-
convertData.columns.push(Object.assign({}, gridItemSchema, subField.amis, {name: subFieldName}));
|
|
58842
|
-
}
|
|
58965
|
+
});
|
|
58966
|
+
}
|
|
58967
|
+
return sort;
|
|
58968
|
+
}
|
|
58969
|
+
function getListViewFilter(listView){
|
|
58970
|
+
if(!listView){
|
|
58971
|
+
return ;
|
|
58972
|
+
}
|
|
58973
|
+
try {
|
|
58974
|
+
const userId = getUserId();
|
|
58975
|
+
let filters = listView.filters;
|
|
58976
|
+
if(listView.filter_scope === 'mine'){
|
|
58977
|
+
if(___default.isEmpty(filters)){
|
|
58978
|
+
filters = [["owner", "=", userId]];
|
|
58979
|
+
}else {
|
|
58980
|
+
if(___default.isString(filters) && ___default.startsWith(___default.trim(filters), "function")){
|
|
58981
|
+
filters = new Function(`return ${filters}`);
|
|
58982
|
+
filters = filters();
|
|
58843
58983
|
}
|
|
58844
|
-
|
|
58845
|
-
|
|
58846
|
-
|
|
58847
|
-
|
|
58848
|
-
|
|
58849
|
-
type: 'combo',
|
|
58850
|
-
items: []
|
|
58851
|
-
};
|
|
58852
|
-
// console.log(`convertData ======>`, field, convertData)
|
|
58853
|
-
for (let subField of field.subFields) {
|
|
58854
|
-
let subFieldName = subField.name.replace(`${field.name}.$.`, '').replace(`${field.name}.`, '');
|
|
58855
|
-
if(subField.type === 'grid'){
|
|
58856
|
-
subField = await getGridFieldSubFields(subField, ctx.__formFields);
|
|
58857
|
-
}else {
|
|
58858
|
-
if(readonly){
|
|
58859
|
-
subFieldName = `${field.name}.${subFieldName}`;
|
|
58860
|
-
}
|
|
58861
|
-
}
|
|
58862
|
-
const gridSub = await convertSFieldToAmisField(Object.assign({}, subField, {name: subFieldName}), readonly, ctx);
|
|
58863
|
-
if(gridSub){
|
|
58864
|
-
delete gridSub.name;
|
|
58865
|
-
delete gridSub.label;
|
|
58866
|
-
convertData.items.push(
|
|
58867
|
-
Object.assign({}, gridSub, {label: subField.label}, subField.amis, {
|
|
58868
|
-
name: subFieldName
|
|
58869
|
-
})
|
|
58870
|
-
);
|
|
58871
|
-
}
|
|
58984
|
+
if(___default.isArray(filters)){
|
|
58985
|
+
filters.push(["owner", "=", userId]);
|
|
58986
|
+
}else {
|
|
58987
|
+
console.debug(`listView filters is not array`, listView);
|
|
58988
|
+
throw new Error('filters is not array')
|
|
58872
58989
|
}
|
|
58873
58990
|
}
|
|
58874
|
-
|
|
58991
|
+
};
|
|
58992
|
+
return filters;
|
|
58993
|
+
} catch (error) {
|
|
58994
|
+
console.error(error);
|
|
58995
|
+
}
|
|
58996
|
+
}
|
|
58997
|
+
|
|
58998
|
+
function formatUISchemaCache(objectName, uiSchema){
|
|
58999
|
+
setUISchemaCache(objectName, uiSchema);
|
|
59000
|
+
lodash.exports.each(uiSchema.fields, (field)=>{
|
|
59001
|
+
try {
|
|
59002
|
+
if(field.type === "lookup" && field._reference_to && ___default.isString(field._reference_to)){
|
|
59003
|
+
field.reference_to = eval(`(${field._reference_to})`)();
|
|
59004
|
+
}
|
|
59005
|
+
} catch (exception) {
|
|
59006
|
+
field.reference_to = undefined;
|
|
59007
|
+
console.error(exception);
|
|
59008
|
+
}
|
|
59009
|
+
});
|
|
59010
|
+
lodash.exports.each(uiSchema.list_views, (v, k)=>{
|
|
59011
|
+
v.name = k;
|
|
59012
|
+
if(!lodash.exports.has(v, 'columns')){
|
|
59013
|
+
v.columns = uiSchema.list_views.all.columns;
|
|
59014
|
+
}
|
|
59015
|
+
});
|
|
59016
|
+
}
|
|
59017
|
+
|
|
59018
|
+
async function getUISchema(objectName, force) {
|
|
59019
|
+
if (!objectName) {
|
|
59020
|
+
return;
|
|
59021
|
+
}
|
|
59022
|
+
if (hasUISchemaCache(objectName) && !force) {
|
|
59023
|
+
return getUISchemaCache(objectName);
|
|
59024
|
+
}
|
|
59025
|
+
let uiSchema = null;
|
|
59026
|
+
try {
|
|
59027
|
+
if(UISchemaFunction);
|
|
59028
|
+
else {
|
|
59029
|
+
const url = `/service/api/@${objectName.replace(/\./g, "_")}/uiSchema`;
|
|
59030
|
+
uiSchema = await fetchAPI(url, { method: "get" });
|
|
59031
|
+
}
|
|
59032
|
+
if(!uiSchema){
|
|
59033
|
+
return ;
|
|
59034
|
+
}
|
|
59035
|
+
formatUISchemaCache(objectName, uiSchema);
|
|
59036
|
+
} catch (error) {
|
|
59037
|
+
console.error(`getUISchema`, objectName, error);
|
|
59038
|
+
setUISchemaCache(objectName, null);
|
|
59039
|
+
}
|
|
59040
|
+
return getUISchemaCache(objectName);
|
|
59041
|
+
}
|
|
59042
|
+
|
|
59043
|
+
function getUISchemaSync(objectName, force) {
|
|
59044
|
+
if (!objectName) {
|
|
59045
|
+
return;
|
|
58875
59046
|
}
|
|
58876
|
-
if(
|
|
58877
|
-
|
|
58878
|
-
|
|
58879
|
-
|
|
58880
|
-
|
|
58881
|
-
|
|
58882
|
-
|
|
58883
|
-
|
|
59047
|
+
if (hasUISchemaCache(objectName) && !force) {
|
|
59048
|
+
return getUISchemaCache(objectName);
|
|
59049
|
+
}
|
|
59050
|
+
let uiSchema = null;
|
|
59051
|
+
try {
|
|
59052
|
+
|
|
59053
|
+
const url = `/service/api/@${objectName.replace(/\./g, "_")}/uiSchema`;
|
|
59054
|
+
uiSchema = Steedos.authRequest(url, {
|
|
59055
|
+
type: 'GET',
|
|
59056
|
+
async: false,
|
|
59057
|
+
});
|
|
59058
|
+
|
|
59059
|
+
if(!uiSchema){
|
|
59060
|
+
return ;
|
|
58884
59061
|
}
|
|
58885
|
-
|
|
58886
|
-
|
|
59062
|
+
formatUISchemaCache(objectName, uiSchema);
|
|
59063
|
+
} catch (error) {
|
|
59064
|
+
console.error(`getUISchema`, objectName, error);
|
|
59065
|
+
setUISchemaCache(objectName, null);
|
|
59066
|
+
}
|
|
59067
|
+
return getUISchemaCache(objectName);
|
|
59068
|
+
}
|
|
59069
|
+
|
|
59070
|
+
// 获取列表视图
|
|
59071
|
+
async function getListSchema(
|
|
59072
|
+
appName,
|
|
59073
|
+
objectName,
|
|
59074
|
+
listViewName,
|
|
59075
|
+
ctx = {}
|
|
59076
|
+
) {
|
|
59077
|
+
const uiSchema = await getUISchema(objectName);
|
|
59078
|
+
if(!uiSchema){
|
|
59079
|
+
return {}
|
|
59080
|
+
}
|
|
59081
|
+
const listView = lodash.exports.find(
|
|
59082
|
+
uiSchema.list_views,
|
|
59083
|
+
(listView, name) => {
|
|
59084
|
+
// 传入listViewName空值则取第一个
|
|
59085
|
+
if(!listViewName){
|
|
59086
|
+
listViewName = name;
|
|
59087
|
+
}
|
|
59088
|
+
return name === listViewName || listView._id === listViewName;
|
|
58887
59089
|
}
|
|
59090
|
+
);
|
|
58888
59091
|
|
|
58889
|
-
|
|
58890
|
-
|
|
58891
|
-
|
|
58892
|
-
|
|
58893
|
-
|
|
59092
|
+
if (!listView) {
|
|
59093
|
+
return { uiSchema };
|
|
59094
|
+
}
|
|
59095
|
+
|
|
59096
|
+
// 直接返回自定义的列表视图schema
|
|
59097
|
+
if(listView.enable_amis_schema && listView.amis_schema){
|
|
59098
|
+
const amisSchema = lodash.exports.isString(listView.amis_schema) ? JSON.parse(listView.amis_schema) : listView.amis_schema;
|
|
59099
|
+
return {
|
|
59100
|
+
uiSchema,
|
|
59101
|
+
isCustomAmisSchema: true,
|
|
59102
|
+
amisSchema
|
|
59103
|
+
};
|
|
59104
|
+
}
|
|
59105
|
+
|
|
59106
|
+
let listViewColumns = getListViewColumns(listView, ctx.formFactor);
|
|
59107
|
+
let sort = getListViewSort(listView);
|
|
59108
|
+
let listviewFilter = getListViewFilter(listView);
|
|
59109
|
+
let listview_filters = listView && listView._filters;
|
|
59110
|
+
// 返回 calendar 组件
|
|
59111
|
+
if(listView.type === "calendar"){
|
|
59112
|
+
const amisSchema = {
|
|
59113
|
+
"type": "steedos-object-calendar",
|
|
59114
|
+
"objectApiName": objectName,
|
|
59115
|
+
"filters": listviewFilter,
|
|
59116
|
+
"filtersFunction": listview_filters,
|
|
59117
|
+
"sort": sort,
|
|
59118
|
+
...listView.options
|
|
59119
|
+
};
|
|
59120
|
+
return {
|
|
59121
|
+
uiSchema,
|
|
59122
|
+
isCalendar: true,
|
|
59123
|
+
amisSchema
|
|
59124
|
+
};
|
|
59125
|
+
}
|
|
59126
|
+
|
|
59127
|
+
const defaults = ctx.defaults || {};
|
|
59128
|
+
|
|
59129
|
+
// // 未自定义header 且显示header的时候, 使用系统header
|
|
59130
|
+
// if(!defaults.headerSchema && ctx.showHeader){
|
|
59131
|
+
// defaults.headerSchema = getObjectListHeader(uiSchema, listViewName);
|
|
59132
|
+
// }
|
|
59133
|
+
|
|
59134
|
+
// // 如果不显示header,则清理掉
|
|
59135
|
+
// if(!ctx.showHeader){
|
|
59136
|
+
// defaults.headerSchema = null;
|
|
59137
|
+
// }
|
|
59138
|
+
|
|
59139
|
+
defaults.headerSchema = null;
|
|
59140
|
+
|
|
59141
|
+
/**
|
|
59142
|
+
* 本次存储代码段
|
|
59143
|
+
*/
|
|
59144
|
+
try {
|
|
59145
|
+
const listViewPropsStoreKey = location.pathname + "/crud";
|
|
59146
|
+
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
59147
|
+
/**
|
|
59148
|
+
* localListViewProps规范来自crud请求api中api.data.$self参数值的。
|
|
59149
|
+
* 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
|
|
59150
|
+
* __searchable__...:顶部放大镜搜索条件
|
|
59151
|
+
* filter:右侧过滤器
|
|
59152
|
+
* perPage:每页条数
|
|
59153
|
+
* page:当前页码
|
|
59154
|
+
* orderBy:排序字段
|
|
59155
|
+
* orderDir:排序方向
|
|
59156
|
+
*/
|
|
59157
|
+
if (localListViewProps) {
|
|
59158
|
+
localListViewProps = JSON.parse(localListViewProps);
|
|
59159
|
+
// localListViewProps.perPage = 3;
|
|
59160
|
+
let listSchema = {};
|
|
59161
|
+
if(localListViewProps.orderBy){
|
|
59162
|
+
listSchema.orderBy = localListViewProps.orderBy;
|
|
59163
|
+
}
|
|
59164
|
+
if(localListViewProps.orderDir){
|
|
59165
|
+
listSchema.orderDir = localListViewProps.orderDir;
|
|
58894
59166
|
}
|
|
58895
59167
|
|
|
58896
|
-
if(
|
|
58897
|
-
|
|
58898
|
-
|
|
58899
|
-
|
|
58900
|
-
}else {
|
|
58901
|
-
convertData.visibleOn = `${field.visible_on.replace(/formData./g, 'data.')}`;
|
|
58902
|
-
}
|
|
59168
|
+
if(localListViewProps.perPage){
|
|
59169
|
+
listSchema.defaultParams = {
|
|
59170
|
+
perPage: localListViewProps.perPage
|
|
59171
|
+
};
|
|
58903
59172
|
}
|
|
59173
|
+
defaults.listSchema = lodash.exports.defaultsDeep({}, listSchema, defaults.listSchema || {});
|
|
59174
|
+
}
|
|
59175
|
+
}
|
|
59176
|
+
catch (ex) {
|
|
59177
|
+
console.error("本地存储中crud参数解析异常:", ex);
|
|
59178
|
+
}
|
|
58904
59179
|
|
|
58905
|
-
|
|
58906
|
-
|
|
58907
|
-
|
|
58908
|
-
|
|
59180
|
+
ctx.defaults = defaults;
|
|
59181
|
+
|
|
59182
|
+
if (listViewName == "recent") {
|
|
59183
|
+
listview_filters = `
|
|
59184
|
+
function(filters, data) {
|
|
59185
|
+
var result = Steedos.authRequest('/graphql', {
|
|
59186
|
+
type: 'POST',
|
|
59187
|
+
async: false,
|
|
59188
|
+
data: JSON.stringify({
|
|
59189
|
+
query: '{object_recent_viewed(filters: [["record.o","=","' + data.objectName + '"],["space","=","' + data.context.tenantId + '"],["owner","=","' + data.context.userId + '"]],sort:"modified desc",top:50){ _id,record} }'
|
|
59190
|
+
}),
|
|
59191
|
+
});
|
|
59192
|
+
var _ids = []
|
|
59193
|
+
result.data.object_recent_viewed.forEach(function (item) {
|
|
59194
|
+
_ids = _ids.concat(item.record.ids)
|
|
59195
|
+
})
|
|
59196
|
+
return ["_id", "=", _ids];
|
|
58909
59197
|
}
|
|
58910
|
-
|
|
59198
|
+
`;
|
|
59199
|
+
}
|
|
59200
|
+
const amisSchema = {
|
|
59201
|
+
"type": "steedos-object-table",
|
|
59202
|
+
"objectApiName": objectName,
|
|
59203
|
+
"columns": listViewColumns,
|
|
59204
|
+
"extraColumns": listView.extra_columns,
|
|
59205
|
+
"filters": listviewFilter,
|
|
59206
|
+
"filtersFunction": listview_filters,
|
|
59207
|
+
"sort": sort,
|
|
59208
|
+
"ctx": ctx,
|
|
59209
|
+
"requestAdaptor": listView.requestAdaptor || ctx.requestAdaptor,
|
|
59210
|
+
"adaptor": listView.adaptor || ctx.adaptor,
|
|
59211
|
+
"headerToolbarItems": ctx.headerToolbarItems,
|
|
59212
|
+
"filterVisible": ctx.filterVisible,
|
|
59213
|
+
"rowClassNameExpr": ctx.rowClassNameExpr,
|
|
59214
|
+
"crudDataFilter": ctx.crudDataFilter,
|
|
59215
|
+
"onCrudDataFilter": ctx.onCrudDataFilter
|
|
59216
|
+
};
|
|
59217
|
+
// console.log(`getListSchema===>`,amisSchema)
|
|
59218
|
+
return {
|
|
59219
|
+
uiSchema,
|
|
59220
|
+
amisSchema,
|
|
59221
|
+
};
|
|
59222
|
+
}
|
|
58911
59223
|
|
|
58912
|
-
|
|
58913
|
-
|
|
58914
|
-
|
|
59224
|
+
|
|
59225
|
+
if(typeof window != 'undefined'){
|
|
59226
|
+
window.getUISchema = getUISchema;
|
|
59227
|
+
window.getUISchemaSync = getUISchemaSync;
|
|
59228
|
+
window.getListSchema = getListSchema;
|
|
59229
|
+
}
|
|
59230
|
+
|
|
59231
|
+
function getNumberTpl(field){
|
|
59232
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
59233
|
+
}
|
|
59234
|
+
|
|
59235
|
+
function getTimeTpl(field){
|
|
59236
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
59237
|
+
}
|
|
59238
|
+
|
|
59239
|
+
function getDateTpl(field){
|
|
59240
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
59241
|
+
}
|
|
59242
|
+
|
|
59243
|
+
|
|
59244
|
+
function getDateTimeTpl(field){
|
|
59245
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
59246
|
+
}
|
|
59247
|
+
|
|
59248
|
+
function getUiFieldTpl(field){
|
|
59249
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
59250
|
+
}
|
|
59251
|
+
|
|
59252
|
+
function getUiFileSizeTpl(field){
|
|
59253
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
59254
|
+
}
|
|
59255
|
+
|
|
59256
|
+
//TODO 处理name字段
|
|
59257
|
+
async function getRefObjectNameFieldName(field){
|
|
59258
|
+
const refUiSchema = await getUISchema(field.reference_to);
|
|
59259
|
+
const NAME_FIELD_KEY = refUiSchema.NAME_FIELD_KEY || 'name';
|
|
59260
|
+
return NAME_FIELD_KEY;
|
|
59261
|
+
}
|
|
59262
|
+
|
|
59263
|
+
function getSelectTpl(field){
|
|
59264
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
59265
|
+
}
|
|
59266
|
+
function getSelectMap(selectOptions){
|
|
59267
|
+
let map = {};
|
|
59268
|
+
lodash.exports.forEach(selectOptions,(option)=>{
|
|
59269
|
+
const optionValue = option.value + '';
|
|
59270
|
+
const optionColor = option.color + '';
|
|
59271
|
+
if(optionColor){
|
|
59272
|
+
const background = optionColor.charAt(0) === '#' ? optionColor : '#'+optionColor;
|
|
59273
|
+
const color = getContrastColor(background);
|
|
59274
|
+
const optionColorStyle = 'background:'+background+';color:'+color+';line-height:1.5rem';
|
|
59275
|
+
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
59276
|
+
}else {
|
|
59277
|
+
map[optionValue] = option.label;
|
|
58915
59278
|
}
|
|
58916
|
-
|
|
58917
|
-
|
|
58918
|
-
// }else{
|
|
58919
|
-
// return Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name});
|
|
58920
|
-
// }
|
|
58921
|
-
}
|
|
58922
|
-
|
|
59279
|
+
});
|
|
59280
|
+
return map;
|
|
58923
59281
|
}
|
|
58924
59282
|
|
|
58925
|
-
|
|
58926
|
-
if(
|
|
58927
|
-
|
|
59283
|
+
function getNameTplUrl(field, ctx){
|
|
59284
|
+
if(ctx.objectName === 'cms_files'){
|
|
59285
|
+
return `\${context.rootUrl}/api/files/files/\${versions[0]}?download=true`
|
|
58928
59286
|
}
|
|
58929
|
-
|
|
58930
|
-
|
|
58931
|
-
|
|
58932
|
-
|
|
58933
|
-
|
|
59287
|
+
const href = Router.getObjectDetailPath({
|
|
59288
|
+
...ctx, formFactor: ctx.formFactor, appId: "${appId}", objectName: ctx.objectName || "${objectName}", recordId: `\${${ctx.idFieldName}}`
|
|
59289
|
+
});
|
|
59290
|
+
return href;
|
|
59291
|
+
}
|
|
59292
|
+
|
|
59293
|
+
function getNameTpl(field, ctx){
|
|
59294
|
+
const href = getNameTplUrl(field, ctx);
|
|
59295
|
+
let linkTarget = "";
|
|
59296
|
+
if(ctx && ctx.isLookup){
|
|
59297
|
+
linkTarget = "target='_blank'";
|
|
58934
59298
|
}
|
|
59299
|
+
return `<a href="${href}" ${linkTarget}>\${${field.name}}</a>`
|
|
59300
|
+
}
|
|
58935
59301
|
|
|
58936
|
-
|
|
58937
|
-
|
|
58938
|
-
|
|
58939
|
-
if(
|
|
58940
|
-
|
|
59302
|
+
function getRelatedFieldTpl(field, ctx){
|
|
59303
|
+
let tpl = '';
|
|
59304
|
+
if(!field.reference_to && (field.optionsFunction || field._optionsFunction || field.options)){
|
|
59305
|
+
if(field.isTableField){
|
|
59306
|
+
return `\${${field.name}}`
|
|
59307
|
+
}else {
|
|
59308
|
+
return `\${${field.name}__label}`
|
|
58941
59309
|
}
|
|
59310
|
+
}
|
|
58942
59311
|
|
|
58943
|
-
|
|
58944
|
-
|
|
58945
|
-
|
|
58946
|
-
|
|
58947
|
-
}
|
|
58948
|
-
else if(field.type === "select" && field.data_type && field.data_type != "text"){
|
|
58949
|
-
_field.type = field.data_type;
|
|
58950
|
-
}
|
|
59312
|
+
let linkTarget = "";
|
|
59313
|
+
if(ctx && ctx.isLookup){
|
|
59314
|
+
linkTarget = "target='_blank'";
|
|
59315
|
+
}
|
|
58951
59316
|
|
|
58952
|
-
|
|
58953
|
-
_field.type = 'input-array';
|
|
58954
|
-
_field.inline = true;
|
|
58955
|
-
_field.addable = false;
|
|
58956
|
-
_field.removable = false;
|
|
58957
|
-
_field.value = [null,null];
|
|
58958
|
-
_field.items = {
|
|
58959
|
-
type: "input-number"
|
|
58960
|
-
};
|
|
58961
|
-
_field.is_wide = true;
|
|
58962
|
-
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
58963
|
-
}
|
|
59317
|
+
const onlyDisplayLookLabel = ctx.onlyDisplayLookLabel;
|
|
58964
59318
|
|
|
58965
|
-
|
|
58966
|
-
_field.type = 'input-date-range';
|
|
58967
|
-
_field.is_wide = true;
|
|
58968
|
-
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
58969
|
-
}
|
|
58970
|
-
if(_field.type === 'datetime'){
|
|
58971
|
-
_field.type = 'input-datetime-range';
|
|
58972
|
-
_field.is_wide = true;
|
|
58973
|
-
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
58974
|
-
}
|
|
58975
|
-
if(_field.type === 'time'){
|
|
58976
|
-
_field.type = 'input-time-range';
|
|
58977
|
-
_field.is_wide = true;
|
|
58978
|
-
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
58979
|
-
}
|
|
58980
|
-
if(_field.reference_to === 'users'){
|
|
58981
|
-
_field.reference_to = 'space_users';
|
|
58982
|
-
_field.reference_to_field = 'user';
|
|
58983
|
-
}
|
|
58984
|
-
_field.readonly = false;
|
|
58985
|
-
_field.disabled = false;
|
|
58986
|
-
_field.multiple = true;
|
|
58987
|
-
_field.is_wide = false;
|
|
58988
|
-
_field.defaultValue = undefined;
|
|
58989
|
-
_field.required = false;
|
|
58990
|
-
_field.hidden = false;
|
|
58991
|
-
_field.omit = false;
|
|
59319
|
+
let fieldDataStrTpl = `data._display.${field.name}`;
|
|
58992
59320
|
|
|
58993
|
-
|
|
58994
|
-
|
|
58995
|
-
|
|
58996
|
-
|
|
58997
|
-
|
|
58998
|
-
|
|
58999
|
-
|
|
59000
|
-
|
|
59001
|
-
|
|
59002
|
-
|
|
59003
|
-
|
|
59004
|
-
|
|
59321
|
+
if(field.isTableField){
|
|
59322
|
+
fieldDataStrTpl = `data.${field.name}`;
|
|
59323
|
+
}
|
|
59324
|
+
|
|
59325
|
+
if(_.isString(field.reference_to) || !field.reference_to){
|
|
59326
|
+
if(field.multiple){
|
|
59327
|
+
let labelTpl = `<%=item.label%>`;
|
|
59328
|
+
if(!onlyDisplayLookLabel){
|
|
59329
|
+
const href = Router.getObjectDetailPath({
|
|
59330
|
+
formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
|
|
59331
|
+
});
|
|
59332
|
+
labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
|
|
59333
|
+
}
|
|
59334
|
+
tpl = `
|
|
59335
|
+
<% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item,index) { %> <% if(index>0 && index<${fieldDataStrTpl}.length){ %> , <% } %> ${labelTpl} <% }); %><% } %>
|
|
59336
|
+
`;
|
|
59337
|
+
}else {
|
|
59338
|
+
let labelTpl = `\${_display.${field.name}.label}`;
|
|
59339
|
+
let objectNameTpl = `\${_display.${field.name}.objectName}`;
|
|
59340
|
+
let recordIdTpl = `\${_display.${field.name}.value}`;
|
|
59341
|
+
if(field.isTableField){
|
|
59342
|
+
labelTpl = `\${${field.name}.label}`;
|
|
59343
|
+
objectNameTpl = `\${${field.name}.objectName}`;
|
|
59344
|
+
recordIdTpl = `\${${field.name}.value}`;
|
|
59345
|
+
}
|
|
59346
|
+
if(!onlyDisplayLookLabel){
|
|
59347
|
+
const href = Router.getObjectDetailPath({
|
|
59348
|
+
formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
|
|
59349
|
+
});
|
|
59350
|
+
labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
|
|
59351
|
+
}
|
|
59352
|
+
tpl = labelTpl;
|
|
59005
59353
|
}
|
|
59006
59354
|
|
|
59007
|
-
|
|
59008
|
-
|
|
59009
|
-
|
|
59010
|
-
|
|
59355
|
+
|
|
59356
|
+
}else {
|
|
59357
|
+
let labelTpl = `<%=item.label%>`;
|
|
59358
|
+
if(!onlyDisplayLookLabel){
|
|
59359
|
+
const href = Router.getObjectDetailPath({
|
|
59360
|
+
formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
|
|
59011
59361
|
});
|
|
59362
|
+
labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
|
|
59012
59363
|
}
|
|
59364
|
+
tpl = `
|
|
59365
|
+
<% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item) { %> ${labelTpl} <% }); %><% } %>
|
|
59366
|
+
`;
|
|
59013
59367
|
}
|
|
59368
|
+
return tpl
|
|
59014
59369
|
}
|
|
59015
59370
|
|
|
59016
|
-
|
|
59017
|
-
|
|
59371
|
+
async function getLookupTpl(field, ctx){
|
|
59372
|
+
if(!field.reference_to){
|
|
59373
|
+
return getSelectTpl(field)
|
|
59374
|
+
}
|
|
59375
|
+
const NAME_FIELD_KEY = await getRefObjectNameFieldName(field);
|
|
59376
|
+
if(field.multiple){
|
|
59377
|
+
const href = Router.getObjectDetailPath({
|
|
59378
|
+
formFactor: ctx.formFactor, appId: ctx.appId, objectName: field.reference_to, recordId: `<%=item._id%>`, _templateType: "JavaScript"
|
|
59379
|
+
});
|
|
59380
|
+
return `
|
|
59381
|
+
<% if (data.${field.name} && data.${field.name}.length) { %><% data.${field.name}.forEach(function(item) { %> <a href="${href}"><%=item.${NAME_FIELD_KEY}%></a> <% }); %><% } %>
|
|
59382
|
+
`
|
|
59383
|
+
}else {
|
|
59384
|
+
const href = Router.getObjectDetailPath({
|
|
59385
|
+
formFactor: ctx.formFactor, appId: ctx.appId, objectName: field.reference_to, recordId: `\${${field.name}._id}`
|
|
59386
|
+
});
|
|
59387
|
+
return `<a href="${href}">\${${field.name}.${NAME_FIELD_KEY}}</a>`
|
|
59388
|
+
}
|
|
59389
|
+
|
|
59018
59390
|
}
|
|
59019
59391
|
|
|
59020
|
-
|
|
59021
|
-
|
|
59022
|
-
|
|
59023
|
-
|
|
59024
|
-
|
|
59025
|
-
|
|
59026
|
-
|
|
59027
|
-
|
|
59028
|
-
|
|
59029
|
-
|
|
59030
|
-
"[grid]",
|
|
59031
|
-
"[text]",
|
|
59032
|
-
"audio",
|
|
59033
|
-
"file",
|
|
59034
|
-
],
|
|
59035
|
-
fieldType
|
|
59036
|
-
)
|
|
59392
|
+
function getSwitchTpl(field){
|
|
59393
|
+
let fieldDataStrTpl = `data._display.${field.name}`;
|
|
59394
|
+
if(field.isTableField){
|
|
59395
|
+
fieldDataStrTpl = `data.${field.name}`;
|
|
59396
|
+
}
|
|
59397
|
+
return `<% if (data.${field.name}) { %>
|
|
59398
|
+
<span class="slds-icon_container slds-icon-utility-check slds-current-color" title="<%=${fieldDataStrTpl}%>">
|
|
59399
|
+
<span ><%= ${fieldDataStrTpl} === "√" ? "<svg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='currentColor' class='w-4 h-4'><path stroke-linecap='round' stroke-linejoin='round' d='M4.5 12.75l6 6 9-13.5' /></svg>" : ${fieldDataStrTpl} %></span>
|
|
59400
|
+
</span>
|
|
59401
|
+
<% } %>`
|
|
59037
59402
|
}
|
|
59038
59403
|
|
|
59039
|
-
|
|
59040
|
-
|
|
59404
|
+
function getPasswordTpl(field){
|
|
59405
|
+
return `<% if (data.${field.name}) { %>
|
|
59406
|
+
<span>······</span>
|
|
59407
|
+
<% } %>`
|
|
59041
59408
|
}
|
|
59042
59409
|
|
|
59410
|
+
function getLocationTpl(field){
|
|
59411
|
+
return `\${${field.name} ? ${field.name}.address : ''}`
|
|
59412
|
+
}
|
|
59043
59413
|
|
|
59044
|
-
function
|
|
59045
|
-
|
|
59046
|
-
|
|
59047
|
-
// 对象上名称字段的searchable默认认为是true
|
|
59048
|
-
fieldSearchable = true;
|
|
59414
|
+
async function getFieldTpl (field, options){
|
|
59415
|
+
if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel){
|
|
59416
|
+
return getNameTpl(field, options)
|
|
59049
59417
|
}
|
|
59050
|
-
|
|
59051
|
-
|
|
59418
|
+
switch (field.type) {
|
|
59419
|
+
case 'password':
|
|
59420
|
+
return getPasswordTpl(field);
|
|
59421
|
+
case 'boolean':
|
|
59422
|
+
return getSwitchTpl(field);
|
|
59423
|
+
case 'toggle':
|
|
59424
|
+
return getSwitchTpl(field);
|
|
59425
|
+
case 'select':
|
|
59426
|
+
return getSelectTpl(field);
|
|
59427
|
+
case 'time':
|
|
59428
|
+
return getTimeTpl(field);
|
|
59429
|
+
case 'date':
|
|
59430
|
+
return getDateTpl(field);
|
|
59431
|
+
case 'datetime':
|
|
59432
|
+
return getDateTimeTpl(field);
|
|
59433
|
+
case 'lookup':
|
|
59434
|
+
return await getRelatedFieldTpl(field, options);
|
|
59435
|
+
case 'master_detail':
|
|
59436
|
+
return await getRelatedFieldTpl(field, options);
|
|
59437
|
+
case 'location':
|
|
59438
|
+
return await getLocationTpl(field);
|
|
59439
|
+
case 'number':
|
|
59440
|
+
case 'currency':
|
|
59441
|
+
return await getNumberTpl(field);
|
|
59442
|
+
case 'percent':
|
|
59443
|
+
case 'formula':
|
|
59444
|
+
case 'summary':
|
|
59445
|
+
return getUiFieldTpl(field)
|
|
59446
|
+
case 'filesize':
|
|
59447
|
+
return getUiFileSizeTpl(field)
|
|
59052
59448
|
}
|
|
59053
|
-
return false;
|
|
59054
59449
|
}
|
|
59055
59450
|
|
|
59056
59451
|
/*
|
|
@@ -59503,7 +59898,7 @@ function getFieldWidth(width){
|
|
|
59503
59898
|
|
|
59504
59899
|
async function getTableColumns(fields, options){
|
|
59505
59900
|
const columns = [];
|
|
59506
|
-
if(!options.isLookup){
|
|
59901
|
+
if(!options.isLookup && !options.isInputTable){
|
|
59507
59902
|
//将_display放入crud的columns中,可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
59508
59903
|
columns.push({name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
|
|
59509
59904
|
columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
|
|
@@ -59646,7 +60041,7 @@ async function getTableColumns(fields, options){
|
|
|
59646
60041
|
}
|
|
59647
60042
|
}
|
|
59648
60043
|
// columns.push(getOperation(fields));
|
|
59649
|
-
if(!options.isLookup && !lodash.exports.some(columns, { name: options.labelFieldName })){
|
|
60044
|
+
if(!options.isLookup && !options.isInputTable && !lodash.exports.some(columns, { name: options.labelFieldName })){
|
|
59650
60045
|
// 没有名称字段时显示序号字段为链接,lookup弹出的picker不需要此功能
|
|
59651
60046
|
const href = Router.getObjectDetailPath({
|
|
59652
60047
|
...options, formFactor: options.formFactor, appId: "${appId}", objectName: options.objectName || "${objectName}", recordId: `\${${options.idFieldName}}`
|
|
@@ -59830,624 +60225,232 @@ async function getMobileTableColumns(fields, options){
|
|
|
59830
60225
|
"api": {
|
|
59831
60226
|
"url": url,
|
|
59832
60227
|
"method": "get",
|
|
59833
|
-
"headers": {
|
|
59834
|
-
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
59835
|
-
}
|
|
59836
|
-
}
|
|
59837
|
-
},
|
|
59838
|
-
"actionType": "download"
|
|
59839
|
-
}
|
|
59840
|
-
],
|
|
59841
|
-
"weight": 0
|
|
59842
|
-
}
|
|
59843
|
-
}
|
|
59844
|
-
};
|
|
59845
|
-
}
|
|
59846
|
-
|
|
59847
|
-
}
|
|
59848
|
-
|
|
59849
|
-
columns.push(column);
|
|
59850
|
-
|
|
59851
|
-
|
|
59852
|
-
return columns;
|
|
59853
|
-
}
|
|
59854
|
-
|
|
59855
|
-
function getDefaultParams(options){
|
|
59856
|
-
return {
|
|
59857
|
-
perPage: options.top || options.perPage || config.listView.perPage
|
|
59858
|
-
}
|
|
59859
|
-
}
|
|
59860
|
-
|
|
59861
|
-
function getButtonVisibleOn(button){
|
|
59862
|
-
let visible= button.visible;
|
|
59863
|
-
|
|
59864
|
-
if(button._visible){
|
|
59865
|
-
visible = button._visible;
|
|
59866
|
-
}
|
|
59867
|
-
|
|
59868
|
-
if(lodash.exports.isBoolean(visible)){
|
|
59869
|
-
visible = visible.toString();
|
|
59870
|
-
}
|
|
59871
|
-
|
|
59872
|
-
if(visible){
|
|
59873
|
-
// if(visible.indexOf("Meteor.") > 0 || visible.indexOf("Creator.") > 0 || visible.indexOf("Session.") > 0){
|
|
59874
|
-
// console.warn('无效的visible', visible)
|
|
59875
|
-
// return 'false';
|
|
59876
|
-
// }
|
|
59877
|
-
if(visible.trim().startsWith('function')){
|
|
59878
|
-
return `${visible}(objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)`
|
|
59879
|
-
}
|
|
59880
|
-
return visible;
|
|
59881
|
-
}
|
|
59882
|
-
|
|
59883
|
-
if(button.type === 'amis_button'){
|
|
59884
|
-
const amisSchema = button.amis_schema;
|
|
59885
|
-
if(amisSchema && amisSchema.body && amisSchema.body.length > 0){
|
|
59886
|
-
const btn1 = amisSchema.body[0];
|
|
59887
|
-
return btn1.visibleOn
|
|
59888
|
-
}
|
|
59889
|
-
}
|
|
59890
|
-
}
|
|
59891
|
-
|
|
59892
|
-
async function getTableOperation(ctx){
|
|
59893
|
-
const buttons = ctx.buttons;
|
|
59894
|
-
const operationButtons = [];
|
|
59895
|
-
lodash.exports.each(buttons, (button)=>{
|
|
59896
|
-
if(lodash.exports.isBoolean(button.visible)){
|
|
59897
|
-
button.visible = button.visible.toString();
|
|
59898
|
-
}
|
|
59899
|
-
// operationButtons.push({
|
|
59900
|
-
// type: 'button',
|
|
59901
|
-
// label: button.label,
|
|
59902
|
-
// visibleOn: button.visible ? `${button.visible}` : (button._visible ? `${button._visible}` : null),
|
|
59903
|
-
// onEvent: {
|
|
59904
|
-
// click: {
|
|
59905
|
-
// actions: []
|
|
59906
|
-
// }
|
|
59907
|
-
// }
|
|
59908
|
-
// })
|
|
59909
|
-
|
|
59910
|
-
operationButtons.push({
|
|
59911
|
-
type: 'steedos-object-button',
|
|
59912
|
-
name: button.name,
|
|
59913
|
-
objectName: button.objectName,
|
|
59914
|
-
visibleOn: getButtonVisibleOn(button),
|
|
59915
|
-
className: 'antd-Button--default'
|
|
59916
|
-
});
|
|
59917
|
-
});
|
|
59918
|
-
if(operationButtons.length < 1){
|
|
59919
|
-
return ;
|
|
59920
|
-
}
|
|
59921
|
-
return {
|
|
59922
|
-
type: 'operation',
|
|
59923
|
-
label: "",
|
|
59924
|
-
fixed: 'right',
|
|
59925
|
-
labelClassName: 'text-center',
|
|
59926
|
-
className: 'text-center steedos-listview-operation w-10',
|
|
59927
|
-
buttons: [
|
|
59928
|
-
{
|
|
59929
|
-
"type": "steedos-dropdown-button",
|
|
59930
|
-
"label": "xxx",
|
|
59931
|
-
"buttons": operationButtons,
|
|
59932
|
-
"placement": "bottomRight",
|
|
59933
|
-
"overlayClassName": "shadow !min-w-[160px]",
|
|
59934
|
-
"trigger": ["click"],
|
|
59935
|
-
"id": "u:c2140a365019",
|
|
59936
|
-
onOpenApi: {
|
|
59937
|
-
url: `\${context.rootUrl}/service/api/@\${objectName}/recordPermissions/\${_id}`,
|
|
59938
|
-
method: "get",
|
|
59939
|
-
requestAdaptor: "api.data={}; return api;",
|
|
59940
|
-
headers: {
|
|
59941
|
-
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
59942
|
-
},
|
|
59943
|
-
adaptor: `
|
|
59944
|
-
payload = {
|
|
59945
|
-
record: {
|
|
59946
|
-
recordPermissions: payload
|
|
59947
|
-
}
|
|
59948
|
-
};
|
|
59949
|
-
return payload;
|
|
59950
|
-
`,
|
|
59951
|
-
}
|
|
59952
|
-
}
|
|
59953
|
-
]
|
|
59954
|
-
}
|
|
59955
|
-
}
|
|
59956
|
-
|
|
59957
|
-
async function getDefaultCrudCard(columns, options) {
|
|
59958
|
-
let labelFieldName = options?.labelFieldName || "name";
|
|
59959
|
-
let titleColumn, bodyColumns = [];
|
|
59960
|
-
columns.forEach(function (item) {
|
|
59961
|
-
delete item.quickEdit;
|
|
59962
|
-
delete item.width;
|
|
59963
|
-
if (item.name === labelFieldName) {
|
|
59964
|
-
titleColumn = item;
|
|
59965
|
-
}
|
|
59966
|
-
else {
|
|
59967
|
-
if (item.name !== "_index") {
|
|
59968
|
-
bodyColumns.push(item);
|
|
59969
|
-
}
|
|
59970
|
-
}
|
|
59971
|
-
});
|
|
59972
|
-
let card = {
|
|
59973
|
-
"header": {
|
|
59974
|
-
"title": titleColumn.tpl
|
|
59975
|
-
},
|
|
59976
|
-
body: bodyColumns,
|
|
59977
|
-
// useCardLabel: false,
|
|
59978
|
-
toolbar: []
|
|
59979
|
-
};
|
|
59980
|
-
let hideToolbarOperation = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
|
|
59981
|
-
if(!hideToolbarOperation){
|
|
59982
|
-
let toolbarOperation = await getTableOperation(options);
|
|
59983
|
-
if (toolbarOperation) {
|
|
59984
|
-
toolbarOperation.className += " inline-block w-auto";
|
|
59985
|
-
}
|
|
59986
|
-
card.toolbar.push(toolbarOperation);
|
|
59987
|
-
}
|
|
59988
|
-
return card;
|
|
59989
|
-
}
|
|
59990
|
-
|
|
59991
|
-
async function getTableSchema$1(fields, options){
|
|
59992
|
-
if(!options){
|
|
59993
|
-
options = {};
|
|
59994
|
-
}
|
|
59995
|
-
let { isLookup, hiddenColumnOperation } = options;
|
|
59996
|
-
const defaults = options.defaults;
|
|
59997
|
-
const listSchema = (defaults && defaults.listSchema) || {};
|
|
59998
|
-
|
|
59999
|
-
let columns = [];
|
|
60000
|
-
let useMobileColumns = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
|
|
60001
|
-
if(isLookup){
|
|
60002
|
-
// 在lookup手机端列表模式调式好之前不使用getMobileTableColumns
|
|
60003
|
-
useMobileColumns = false;
|
|
60004
|
-
}
|
|
60005
|
-
if(listSchema.mode && listSchema.mode !== "table"){
|
|
60006
|
-
// 如果指定的mode,则不走我们内置的手机端列表效果,使用steedos组件内部开发的默认card/list效果,或者由用户自己实现card/list模式的crud列表
|
|
60007
|
-
useMobileColumns = false;
|
|
60008
|
-
}
|
|
60009
|
-
if(useMobileColumns){
|
|
60010
|
-
columns = await getMobileTableColumns(fields, options);
|
|
60011
|
-
}
|
|
60012
|
-
else {
|
|
60013
|
-
columns = await getTableColumns(fields, options);
|
|
60014
|
-
|
|
60015
|
-
if(listSchema.mode === "cards"){
|
|
60016
|
-
let card = listSchema.card;
|
|
60017
|
-
if(!card){
|
|
60018
|
-
card = await getDefaultCrudCard(columns, options);
|
|
60019
|
-
}
|
|
60020
|
-
return {
|
|
60021
|
-
mode: "cards",
|
|
60022
|
-
perPageAvailable: [5, 10, 20, 50, 100, 500],
|
|
60023
|
-
name: "thelist",
|
|
60024
|
-
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
60025
|
-
className: "",
|
|
60026
|
-
draggable: false,
|
|
60027
|
-
defaultParams: getDefaultParams(options),
|
|
60028
|
-
card: card,
|
|
60029
|
-
syncLocation: false,
|
|
60030
|
-
keepItemSelectionOnPageChange: true,
|
|
60031
|
-
checkOnItemClick: isLookup ? true : false,
|
|
60032
|
-
labelTpl: `\${${options.labelFieldName}}`,
|
|
60033
|
-
autoFillHeight: false, // 自动高度效果不理想,先关闭
|
|
60034
|
-
columnsTogglable: false
|
|
60035
|
-
}
|
|
60036
|
-
}
|
|
60037
|
-
|
|
60038
|
-
if(!isLookup && !hiddenColumnOperation){
|
|
60039
|
-
columns.push(await getTableOperation(options));
|
|
60040
|
-
}
|
|
60041
|
-
}
|
|
60042
|
-
|
|
60043
|
-
return {
|
|
60044
|
-
mode: "table",
|
|
60045
|
-
perPageAvailable: [5, 10, 20, 50, 100, 500],
|
|
60046
|
-
name: "thelist",
|
|
60047
|
-
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
60048
|
-
className: "",
|
|
60049
|
-
draggable: false,
|
|
60050
|
-
defaultParams: getDefaultParams(options),
|
|
60051
|
-
columns: columns,
|
|
60052
|
-
syncLocation: false,
|
|
60053
|
-
keepItemSelectionOnPageChange: true,
|
|
60054
|
-
checkOnItemClick: isLookup ? true : false,
|
|
60055
|
-
labelTpl: `\${${options.labelFieldName}}`,
|
|
60056
|
-
autoFillHeight: false, // 自动高度效果不理想,先关闭
|
|
60057
|
-
columnsTogglable: false,
|
|
60058
|
-
}
|
|
60059
|
-
}
|
|
60060
|
-
|
|
60061
|
-
/******************************************************************************
|
|
60062
|
-
Copyright (c) Microsoft Corporation.
|
|
60063
|
-
|
|
60064
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
60065
|
-
purpose with or without fee is hereby granted.
|
|
60066
|
-
|
|
60067
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
60068
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
60069
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
60070
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
60071
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
60072
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
60073
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
60074
|
-
***************************************************************************** */
|
|
60075
|
-
|
|
60076
|
-
var __assign = function() {
|
|
60077
|
-
__assign = Object.assign || function __assign(t) {
|
|
60078
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
60079
|
-
s = arguments[i];
|
|
60080
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
60081
|
-
}
|
|
60082
|
-
return t;
|
|
60083
|
-
};
|
|
60084
|
-
return __assign.apply(this, arguments);
|
|
60085
|
-
};
|
|
60086
|
-
|
|
60087
|
-
// 方便取值的时候能够把上层的取到,但是获取的时候不会全部把所有的数据获取到。
|
|
60088
|
-
function createObject(superProps, props, properties) {
|
|
60089
|
-
if (superProps && Object.isFrozen(superProps)) {
|
|
60090
|
-
superProps = cloneObject(superProps);
|
|
60228
|
+
"headers": {
|
|
60229
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
60230
|
+
}
|
|
60231
|
+
}
|
|
60232
|
+
},
|
|
60233
|
+
"actionType": "download"
|
|
60234
|
+
}
|
|
60235
|
+
],
|
|
60236
|
+
"weight": 0
|
|
60237
|
+
}
|
|
60238
|
+
}
|
|
60239
|
+
};
|
|
60240
|
+
}
|
|
60241
|
+
|
|
60091
60242
|
}
|
|
60092
|
-
var obj = superProps
|
|
60093
|
-
? Object.create(superProps, __assign(__assign({}, properties), { __super: {
|
|
60094
|
-
value: superProps,
|
|
60095
|
-
writable: false,
|
|
60096
|
-
enumerable: false
|
|
60097
|
-
} }))
|
|
60098
|
-
: Object.create(Object.prototype, properties);
|
|
60099
|
-
props &&
|
|
60100
|
-
isObject(props) &&
|
|
60101
|
-
Object.keys(props).forEach(function (key) { return (obj[key] = props[key]); });
|
|
60102
|
-
return obj;
|
|
60103
|
-
}
|
|
60104
|
-
function cloneObject(target, persistOwnProps) {
|
|
60105
|
-
if (persistOwnProps === void 0) { persistOwnProps = true; }
|
|
60106
|
-
var obj = target && target.__super
|
|
60107
|
-
? Object.create(target.__super, {
|
|
60108
|
-
__super: {
|
|
60109
|
-
value: target.__super,
|
|
60110
|
-
writable: false,
|
|
60111
|
-
enumerable: false
|
|
60112
|
-
}
|
|
60113
|
-
})
|
|
60114
|
-
: Object.create(Object.prototype);
|
|
60115
|
-
persistOwnProps &&
|
|
60116
|
-
target &&
|
|
60117
|
-
Object.keys(target).forEach(function (key) { return (obj[key] = target[key]); });
|
|
60118
|
-
return obj;
|
|
60119
|
-
}
|
|
60120
|
-
function isObject(obj) {
|
|
60121
|
-
var typename = typeof obj;
|
|
60122
|
-
return (obj &&
|
|
60123
|
-
typename !== 'string' &&
|
|
60124
|
-
typename !== 'number' &&
|
|
60125
|
-
typename !== 'boolean' &&
|
|
60126
|
-
typename !== 'function' &&
|
|
60127
|
-
!Array.isArray(obj));
|
|
60128
|
-
}
|
|
60129
|
-
|
|
60130
|
-
/*
|
|
60131
|
-
* @Author: baozhoutao@steedos.com
|
|
60132
|
-
* @Date: 2022-07-05 15:55:39
|
|
60133
|
-
* @LastEditors: liaodaxue
|
|
60134
|
-
* @LastEditTime: 2023-10-20 11:38:25
|
|
60135
|
-
* @Description:
|
|
60136
|
-
*/
|
|
60137
60243
|
|
|
60138
|
-
|
|
60244
|
+
columns.push(column);
|
|
60245
|
+
|
|
60139
60246
|
|
|
60140
|
-
|
|
60247
|
+
return columns;
|
|
60248
|
+
}
|
|
60141
60249
|
|
|
60142
|
-
|
|
60143
|
-
|
|
60144
|
-
|
|
60250
|
+
function getDefaultParams(options){
|
|
60251
|
+
return {
|
|
60252
|
+
perPage: options.top || options.perPage || config.listView.perPage
|
|
60145
60253
|
}
|
|
60146
|
-
UI_SCHEMA_CACHE = window.UI_SCHEMA_CACHE;
|
|
60147
60254
|
}
|
|
60148
60255
|
|
|
60149
|
-
|
|
60150
|
-
|
|
60151
|
-
};
|
|
60152
|
-
|
|
60153
|
-
const getUISchemaCache = (key) => {
|
|
60154
|
-
return lodash.exports.cloneDeep(UI_SCHEMA_CACHE[key]);
|
|
60155
|
-
};
|
|
60156
|
-
|
|
60157
|
-
const hasUISchemaCache = (key) => {
|
|
60158
|
-
return lodash.exports.has(UI_SCHEMA_CACHE, key);
|
|
60159
|
-
};
|
|
60256
|
+
function getButtonVisibleOn(button){
|
|
60257
|
+
let visible= button.visible;
|
|
60160
60258
|
|
|
60161
|
-
|
|
60162
|
-
|
|
60163
|
-
if (formFactor === "SMALL") {
|
|
60164
|
-
listViewColumns = !lodash.exports.isEmpty(listView.mobile_columns)
|
|
60165
|
-
? listView.mobile_columns
|
|
60166
|
-
: lodash.exports.slice(listView.columns, 0, 4);
|
|
60167
|
-
} else {
|
|
60168
|
-
listViewColumns = listView.columns;
|
|
60259
|
+
if(button._visible){
|
|
60260
|
+
visible = button._visible;
|
|
60169
60261
|
}
|
|
60170
|
-
|
|
60171
|
-
|
|
60172
|
-
|
|
60173
|
-
let sort = '';
|
|
60174
|
-
if(listView && listView.sort && listView.sort.length){
|
|
60175
|
-
lodash.exports.each(listView.sort,function(item,index){
|
|
60176
|
-
if(lodash.exports.isArray(item)){
|
|
60177
|
-
const field_name = item[0];
|
|
60178
|
-
const order = item[1] || '';
|
|
60179
|
-
let sortStr = field_name + ' ' + order;
|
|
60180
|
-
sortStr = index > 0 ? ','+sortStr : sortStr;
|
|
60181
|
-
sort += sortStr;
|
|
60182
|
-
}else {
|
|
60183
|
-
let sortStr = item.field_name + ' ' + item.order;
|
|
60184
|
-
sortStr = index > 0 ? ','+sortStr : sortStr;
|
|
60185
|
-
sort += sortStr;
|
|
60186
|
-
}
|
|
60187
|
-
});
|
|
60262
|
+
|
|
60263
|
+
if(lodash.exports.isBoolean(visible)){
|
|
60264
|
+
visible = visible.toString();
|
|
60188
60265
|
}
|
|
60189
|
-
|
|
60190
|
-
|
|
60191
|
-
|
|
60192
|
-
|
|
60193
|
-
return ;
|
|
60266
|
+
|
|
60267
|
+
if(visible){
|
|
60268
|
+
// if(visible.indexOf("Meteor.") > 0 || visible.indexOf("Creator.") > 0 || visible.indexOf("Session.") > 0){
|
|
60269
|
+
// console.warn('无效的visible', visible)
|
|
60270
|
+
// return 'false';
|
|
60271
|
+
// }
|
|
60272
|
+
if(visible.trim().startsWith('function')){
|
|
60273
|
+
return `${visible}(objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)`
|
|
60274
|
+
}
|
|
60275
|
+
return visible;
|
|
60194
60276
|
}
|
|
60195
|
-
|
|
60196
|
-
|
|
60197
|
-
|
|
60198
|
-
if(
|
|
60199
|
-
|
|
60200
|
-
|
|
60201
|
-
|
|
60202
|
-
if(___default.isString(filters) && ___default.startsWith(___default.trim(filters), "function")){
|
|
60203
|
-
filters = new Function(`return ${filters}`);
|
|
60204
|
-
filters = filters();
|
|
60205
|
-
}
|
|
60206
|
-
if(___default.isArray(filters)){
|
|
60207
|
-
filters.push(["owner", "=", userId]);
|
|
60208
|
-
}else {
|
|
60209
|
-
console.debug(`listView filters is not array`, listView);
|
|
60210
|
-
throw new Error('filters is not array')
|
|
60211
|
-
}
|
|
60212
|
-
}
|
|
60213
|
-
};
|
|
60214
|
-
return filters;
|
|
60215
|
-
} catch (error) {
|
|
60216
|
-
console.error(error);
|
|
60277
|
+
|
|
60278
|
+
if(button.type === 'amis_button'){
|
|
60279
|
+
const amisSchema = button.amis_schema;
|
|
60280
|
+
if(amisSchema && amisSchema.body && amisSchema.body.length > 0){
|
|
60281
|
+
const btn1 = amisSchema.body[0];
|
|
60282
|
+
return btn1.visibleOn
|
|
60283
|
+
}
|
|
60217
60284
|
}
|
|
60218
60285
|
}
|
|
60219
60286
|
|
|
60220
|
-
function
|
|
60221
|
-
|
|
60222
|
-
|
|
60223
|
-
|
|
60224
|
-
|
|
60225
|
-
|
|
60226
|
-
}
|
|
60227
|
-
} catch (exception) {
|
|
60228
|
-
field.reference_to = undefined;
|
|
60229
|
-
console.error(exception);
|
|
60230
|
-
}
|
|
60231
|
-
});
|
|
60232
|
-
lodash.exports.each(uiSchema.list_views, (v, k)=>{
|
|
60233
|
-
v.name = k;
|
|
60234
|
-
if(!lodash.exports.has(v, 'columns')){
|
|
60235
|
-
v.columns = uiSchema.list_views.all.columns;
|
|
60287
|
+
async function getTableOperation(ctx){
|
|
60288
|
+
const buttons = ctx.buttons;
|
|
60289
|
+
const operationButtons = [];
|
|
60290
|
+
lodash.exports.each(buttons, (button)=>{
|
|
60291
|
+
if(lodash.exports.isBoolean(button.visible)){
|
|
60292
|
+
button.visible = button.visible.toString();
|
|
60236
60293
|
}
|
|
60237
|
-
|
|
60238
|
-
|
|
60294
|
+
// operationButtons.push({
|
|
60295
|
+
// type: 'button',
|
|
60296
|
+
// label: button.label,
|
|
60297
|
+
// visibleOn: button.visible ? `${button.visible}` : (button._visible ? `${button._visible}` : null),
|
|
60298
|
+
// onEvent: {
|
|
60299
|
+
// click: {
|
|
60300
|
+
// actions: []
|
|
60301
|
+
// }
|
|
60302
|
+
// }
|
|
60303
|
+
// })
|
|
60239
60304
|
|
|
60240
|
-
|
|
60241
|
-
|
|
60242
|
-
|
|
60243
|
-
|
|
60244
|
-
|
|
60245
|
-
|
|
60305
|
+
operationButtons.push({
|
|
60306
|
+
type: 'steedos-object-button',
|
|
60307
|
+
name: button.name,
|
|
60308
|
+
objectName: button.objectName,
|
|
60309
|
+
visibleOn: getButtonVisibleOn(button),
|
|
60310
|
+
className: 'antd-Button--default'
|
|
60311
|
+
});
|
|
60312
|
+
});
|
|
60313
|
+
if(operationButtons.length < 1){
|
|
60314
|
+
return ;
|
|
60246
60315
|
}
|
|
60247
|
-
|
|
60248
|
-
|
|
60249
|
-
|
|
60250
|
-
|
|
60251
|
-
|
|
60252
|
-
|
|
60253
|
-
|
|
60254
|
-
|
|
60255
|
-
|
|
60256
|
-
|
|
60257
|
-
|
|
60258
|
-
|
|
60259
|
-
|
|
60260
|
-
|
|
60316
|
+
return {
|
|
60317
|
+
type: 'operation',
|
|
60318
|
+
label: " ",
|
|
60319
|
+
fixed: 'right',
|
|
60320
|
+
labelClassName: 'text-center',
|
|
60321
|
+
className: 'text-center steedos-listview-operation w-10',
|
|
60322
|
+
buttons: [
|
|
60323
|
+
{
|
|
60324
|
+
"type": "steedos-dropdown-button",
|
|
60325
|
+
"label": "xxx",
|
|
60326
|
+
"buttons": operationButtons,
|
|
60327
|
+
"placement": "bottomRight",
|
|
60328
|
+
"overlayClassName": "shadow !min-w-[160px]",
|
|
60329
|
+
"trigger": ["click"],
|
|
60330
|
+
"id": "u:c2140a365019",
|
|
60331
|
+
onOpenApi: {
|
|
60332
|
+
url: `\${context.rootUrl}/service/api/@\${objectName}/recordPermissions/\${_id}`,
|
|
60333
|
+
method: "get",
|
|
60334
|
+
requestAdaptor: "api.data={}; return api;",
|
|
60335
|
+
headers: {
|
|
60336
|
+
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
60337
|
+
},
|
|
60338
|
+
adaptor: `
|
|
60339
|
+
payload = {
|
|
60340
|
+
record: {
|
|
60341
|
+
recordPermissions: payload
|
|
60342
|
+
}
|
|
60343
|
+
};
|
|
60344
|
+
return payload;
|
|
60345
|
+
`,
|
|
60346
|
+
}
|
|
60347
|
+
}
|
|
60348
|
+
]
|
|
60261
60349
|
}
|
|
60262
|
-
return getUISchemaCache(objectName);
|
|
60263
60350
|
}
|
|
60264
60351
|
|
|
60265
|
-
function
|
|
60266
|
-
|
|
60267
|
-
|
|
60268
|
-
|
|
60269
|
-
|
|
60270
|
-
|
|
60271
|
-
|
|
60272
|
-
|
|
60273
|
-
try {
|
|
60274
|
-
|
|
60275
|
-
const url = `/service/api/@${objectName.replace(/\./g, "_")}/uiSchema`;
|
|
60276
|
-
uiSchema = Steedos.authRequest(url, {
|
|
60277
|
-
type: 'GET',
|
|
60278
|
-
async: false,
|
|
60279
|
-
});
|
|
60280
|
-
|
|
60281
|
-
if(!uiSchema){
|
|
60282
|
-
return ;
|
|
60352
|
+
async function getDefaultCrudCard(columns, options) {
|
|
60353
|
+
let labelFieldName = options?.labelFieldName || "name";
|
|
60354
|
+
let titleColumn, bodyColumns = [];
|
|
60355
|
+
columns.forEach(function (item) {
|
|
60356
|
+
delete item.quickEdit;
|
|
60357
|
+
delete item.width;
|
|
60358
|
+
if (item.name === labelFieldName) {
|
|
60359
|
+
titleColumn = item;
|
|
60283
60360
|
}
|
|
60284
|
-
|
|
60285
|
-
|
|
60286
|
-
|
|
60287
|
-
|
|
60361
|
+
else {
|
|
60362
|
+
if (item.name !== "_index") {
|
|
60363
|
+
bodyColumns.push(item);
|
|
60364
|
+
}
|
|
60365
|
+
}
|
|
60366
|
+
});
|
|
60367
|
+
let card = {
|
|
60368
|
+
"header": {
|
|
60369
|
+
"title": titleColumn.tpl
|
|
60370
|
+
},
|
|
60371
|
+
body: bodyColumns,
|
|
60372
|
+
// useCardLabel: false,
|
|
60373
|
+
toolbar: []
|
|
60374
|
+
};
|
|
60375
|
+
let hideToolbarOperation = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
|
|
60376
|
+
if(!hideToolbarOperation){
|
|
60377
|
+
let toolbarOperation = await getTableOperation(options);
|
|
60378
|
+
if (toolbarOperation) {
|
|
60379
|
+
toolbarOperation.className += " inline-block w-auto";
|
|
60380
|
+
}
|
|
60381
|
+
card.toolbar.push(toolbarOperation);
|
|
60288
60382
|
}
|
|
60289
|
-
return
|
|
60383
|
+
return card;
|
|
60290
60384
|
}
|
|
60291
60385
|
|
|
60292
|
-
|
|
60293
|
-
|
|
60294
|
-
|
|
60295
|
-
objectName,
|
|
60296
|
-
listViewName,
|
|
60297
|
-
ctx = {}
|
|
60298
|
-
) {
|
|
60299
|
-
const uiSchema = await getUISchema(objectName);
|
|
60300
|
-
if(!uiSchema){
|
|
60301
|
-
return {}
|
|
60386
|
+
async function getTableSchema(fields, options){
|
|
60387
|
+
if(!options){
|
|
60388
|
+
options = {};
|
|
60302
60389
|
}
|
|
60303
|
-
|
|
60304
|
-
|
|
60305
|
-
|
|
60306
|
-
// 传入listViewName空值则取第一个
|
|
60307
|
-
if(!listViewName){
|
|
60308
|
-
listViewName = name;
|
|
60309
|
-
}
|
|
60310
|
-
return name === listViewName || listView._id === listViewName;
|
|
60311
|
-
}
|
|
60312
|
-
);
|
|
60390
|
+
let { isLookup, hiddenColumnOperation } = options;
|
|
60391
|
+
const defaults = options.defaults;
|
|
60392
|
+
const listSchema = (defaults && defaults.listSchema) || {};
|
|
60313
60393
|
|
|
60314
|
-
|
|
60315
|
-
|
|
60394
|
+
let columns = [];
|
|
60395
|
+
let useMobileColumns = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
|
|
60396
|
+
if(isLookup){
|
|
60397
|
+
// 在lookup手机端列表模式调式好之前不使用getMobileTableColumns
|
|
60398
|
+
useMobileColumns = false;
|
|
60316
60399
|
}
|
|
60317
|
-
|
|
60318
|
-
|
|
60319
|
-
|
|
60320
|
-
const amisSchema = lodash.exports.isString(listView.amis_schema) ? JSON.parse(listView.amis_schema) : listView.amis_schema;
|
|
60321
|
-
return {
|
|
60322
|
-
uiSchema,
|
|
60323
|
-
isCustomAmisSchema: true,
|
|
60324
|
-
amisSchema
|
|
60325
|
-
};
|
|
60400
|
+
if(listSchema.mode && listSchema.mode !== "table"){
|
|
60401
|
+
// 如果指定的mode,则不走我们内置的手机端列表效果,使用steedos组件内部开发的默认card/list效果,或者由用户自己实现card/list模式的crud列表
|
|
60402
|
+
useMobileColumns = false;
|
|
60326
60403
|
}
|
|
60327
|
-
|
|
60328
|
-
|
|
60329
|
-
let sort = getListViewSort(listView);
|
|
60330
|
-
let listviewFilter = getListViewFilter(listView);
|
|
60331
|
-
let listview_filters = listView && listView._filters;
|
|
60332
|
-
// 返回 calendar 组件
|
|
60333
|
-
if(listView.type === "calendar"){
|
|
60334
|
-
const amisSchema = {
|
|
60335
|
-
"type": "steedos-object-calendar",
|
|
60336
|
-
"objectApiName": objectName,
|
|
60337
|
-
"filters": listviewFilter,
|
|
60338
|
-
"filtersFunction": listview_filters,
|
|
60339
|
-
"sort": sort,
|
|
60340
|
-
...listView.options
|
|
60341
|
-
};
|
|
60342
|
-
return {
|
|
60343
|
-
uiSchema,
|
|
60344
|
-
isCalendar: true,
|
|
60345
|
-
amisSchema
|
|
60346
|
-
};
|
|
60404
|
+
if(useMobileColumns){
|
|
60405
|
+
columns = await getMobileTableColumns(fields, options);
|
|
60347
60406
|
}
|
|
60407
|
+
else {
|
|
60408
|
+
columns = await getTableColumns(fields, options);
|
|
60348
60409
|
|
|
60349
|
-
|
|
60350
|
-
|
|
60351
|
-
|
|
60352
|
-
|
|
60353
|
-
|
|
60354
|
-
|
|
60355
|
-
|
|
60356
|
-
|
|
60357
|
-
|
|
60358
|
-
|
|
60359
|
-
|
|
60360
|
-
|
|
60361
|
-
|
|
60362
|
-
|
|
60363
|
-
|
|
60364
|
-
|
|
60365
|
-
|
|
60366
|
-
|
|
60367
|
-
|
|
60368
|
-
|
|
60369
|
-
|
|
60370
|
-
* localListViewProps规范来自crud请求api中api.data.$self参数值的。
|
|
60371
|
-
* 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
|
|
60372
|
-
* __searchable__...:顶部放大镜搜索条件
|
|
60373
|
-
* filter:右侧过滤器
|
|
60374
|
-
* perPage:每页条数
|
|
60375
|
-
* page:当前页码
|
|
60376
|
-
* orderBy:排序字段
|
|
60377
|
-
* orderDir:排序方向
|
|
60378
|
-
*/
|
|
60379
|
-
if (localListViewProps) {
|
|
60380
|
-
localListViewProps = JSON.parse(localListViewProps);
|
|
60381
|
-
// localListViewProps.perPage = 3;
|
|
60382
|
-
let listSchema = {};
|
|
60383
|
-
if(localListViewProps.orderBy){
|
|
60384
|
-
listSchema.orderBy = localListViewProps.orderBy;
|
|
60385
|
-
}
|
|
60386
|
-
if(localListViewProps.orderDir){
|
|
60387
|
-
listSchema.orderDir = localListViewProps.orderDir;
|
|
60410
|
+
if(listSchema.mode === "cards"){
|
|
60411
|
+
let card = listSchema.card;
|
|
60412
|
+
if(!card){
|
|
60413
|
+
card = await getDefaultCrudCard(columns, options);
|
|
60414
|
+
}
|
|
60415
|
+
return {
|
|
60416
|
+
mode: "cards",
|
|
60417
|
+
perPageAvailable: [5, 10, 20, 50, 100, 500],
|
|
60418
|
+
name: "thelist",
|
|
60419
|
+
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
60420
|
+
className: "",
|
|
60421
|
+
draggable: false,
|
|
60422
|
+
defaultParams: getDefaultParams(options),
|
|
60423
|
+
card: card,
|
|
60424
|
+
syncLocation: false,
|
|
60425
|
+
keepItemSelectionOnPageChange: true,
|
|
60426
|
+
checkOnItemClick: isLookup ? true : false,
|
|
60427
|
+
labelTpl: `\${${options.labelFieldName}}`,
|
|
60428
|
+
autoFillHeight: false, // 自动高度效果不理想,先关闭
|
|
60429
|
+
columnsTogglable: false
|
|
60430
|
+
}
|
|
60388
60431
|
}
|
|
60389
60432
|
|
|
60390
|
-
if(
|
|
60391
|
-
|
|
60392
|
-
perPage: localListViewProps.perPage
|
|
60393
|
-
};
|
|
60433
|
+
if(!isLookup && !hiddenColumnOperation){
|
|
60434
|
+
columns.push(await getTableOperation(options));
|
|
60394
60435
|
}
|
|
60395
|
-
defaults.listSchema = lodash.exports.defaultsDeep({}, listSchema, defaults.listSchema || {});
|
|
60396
|
-
}
|
|
60397
|
-
}
|
|
60398
|
-
catch (ex) {
|
|
60399
|
-
console.error("本地存储中crud参数解析异常:", ex);
|
|
60400
60436
|
}
|
|
60401
60437
|
|
|
60402
|
-
ctx.defaults = defaults;
|
|
60403
|
-
|
|
60404
|
-
if (listViewName == "recent") {
|
|
60405
|
-
listview_filters = `
|
|
60406
|
-
function(filters, data) {
|
|
60407
|
-
var result = Steedos.authRequest('/graphql', {
|
|
60408
|
-
type: 'POST',
|
|
60409
|
-
async: false,
|
|
60410
|
-
data: JSON.stringify({
|
|
60411
|
-
query: '{object_recent_viewed(filters: [["record.o","=","' + data.objectName + '"],["space","=","' + data.context.tenantId + '"],["owner","=","' + data.context.userId + '"]],sort:"modified desc",top:50){ _id,record} }'
|
|
60412
|
-
}),
|
|
60413
|
-
});
|
|
60414
|
-
var _ids = []
|
|
60415
|
-
result.data.object_recent_viewed.forEach(function (item) {
|
|
60416
|
-
_ids = _ids.concat(item.record.ids)
|
|
60417
|
-
})
|
|
60418
|
-
return ["_id", "=", _ids];
|
|
60419
|
-
}
|
|
60420
|
-
`;
|
|
60421
|
-
}
|
|
60422
|
-
const amisSchema = {
|
|
60423
|
-
"type": "steedos-object-table",
|
|
60424
|
-
"objectApiName": objectName,
|
|
60425
|
-
"columns": listViewColumns,
|
|
60426
|
-
"extraColumns": listView.extra_columns,
|
|
60427
|
-
"filters": listviewFilter,
|
|
60428
|
-
"filtersFunction": listview_filters,
|
|
60429
|
-
"sort": sort,
|
|
60430
|
-
"ctx": ctx,
|
|
60431
|
-
"requestAdaptor": listView.requestAdaptor || ctx.requestAdaptor,
|
|
60432
|
-
"adaptor": listView.adaptor || ctx.adaptor,
|
|
60433
|
-
"headerToolbarItems": ctx.headerToolbarItems,
|
|
60434
|
-
"filterVisible": ctx.filterVisible,
|
|
60435
|
-
"rowClassNameExpr": ctx.rowClassNameExpr,
|
|
60436
|
-
"crudDataFilter": ctx.crudDataFilter,
|
|
60437
|
-
"onCrudDataFilter": ctx.onCrudDataFilter
|
|
60438
|
-
};
|
|
60439
|
-
// console.log(`getListSchema===>`,amisSchema)
|
|
60440
60438
|
return {
|
|
60441
|
-
|
|
60442
|
-
|
|
60443
|
-
|
|
60444
|
-
|
|
60445
|
-
|
|
60446
|
-
|
|
60447
|
-
|
|
60448
|
-
|
|
60449
|
-
|
|
60450
|
-
|
|
60439
|
+
mode: "table",
|
|
60440
|
+
perPageAvailable: [5, 10, 20, 50, 100, 500],
|
|
60441
|
+
name: "thelist",
|
|
60442
|
+
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
60443
|
+
className: "",
|
|
60444
|
+
draggable: false,
|
|
60445
|
+
defaultParams: getDefaultParams(options),
|
|
60446
|
+
columns: columns,
|
|
60447
|
+
syncLocation: false,
|
|
60448
|
+
keepItemSelectionOnPageChange: true,
|
|
60449
|
+
checkOnItemClick: isLookup ? true : false,
|
|
60450
|
+
labelTpl: `\${${options.labelFieldName}}`,
|
|
60451
|
+
autoFillHeight: false, // 自动高度效果不理想,先关闭
|
|
60452
|
+
columnsTogglable: false,
|
|
60453
|
+
}
|
|
60451
60454
|
}
|
|
60452
60455
|
|
|
60453
60456
|
function useCombinedRefs(...refs) {
|