@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.umd.js
CHANGED
|
@@ -20156,6 +20156,53 @@
|
|
|
20156
20156
|
/** Used to infer the `Object` constructor. */
|
|
20157
20157
|
funcToString.call(Object);
|
|
20158
20158
|
|
|
20159
|
+
/*
|
|
20160
|
+
* @Author: baozhoutao@steedos.com
|
|
20161
|
+
* @Date: 2022-08-16 17:02:08
|
|
20162
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
20163
|
+
* @LastEditTime: 2023-06-20 13:50:15
|
|
20164
|
+
* @Description:
|
|
20165
|
+
*/
|
|
20166
|
+
|
|
20167
|
+
|
|
20168
|
+
const Router = {
|
|
20169
|
+
getTabDisplayAs(tab_id){
|
|
20170
|
+
var urlSearch = new URLSearchParams(document.location.search);
|
|
20171
|
+
if(urlSearch.has('display')){
|
|
20172
|
+
return urlSearch.get('display')
|
|
20173
|
+
}
|
|
20174
|
+
const key = `tab_${tab_id}_display`;
|
|
20175
|
+
// const key = `page_display`;
|
|
20176
|
+
const value = localStorage.getItem(key);
|
|
20177
|
+
return value ? value : 'grid'
|
|
20178
|
+
},
|
|
20179
|
+
|
|
20180
|
+
setTabDisplayAs(tab_id, displayAs){
|
|
20181
|
+
const key = `tab_${tab_id}_display`;
|
|
20182
|
+
localStorage.setItem(key, displayAs);
|
|
20183
|
+
},
|
|
20184
|
+
getAppPath({formFactor, appId}){
|
|
20185
|
+
return `/app/${appId}`;
|
|
20186
|
+
},
|
|
20187
|
+
getPagePath(){
|
|
20188
|
+
//TODO
|
|
20189
|
+
},
|
|
20190
|
+
getObjectListViewPath({formFactor, appId, objectName, listViewName}){
|
|
20191
|
+
return `/app/${appId}/${objectName}/grid/${listViewName}`;
|
|
20192
|
+
},
|
|
20193
|
+
getObjectDetailPath(props){
|
|
20194
|
+
const {formFactor, appId, objectName, recordId, listViewName, _templateType} = props;
|
|
20195
|
+
if(_templateType === 'JavaScript'){
|
|
20196
|
+
return `/app/${appId}/${objectName}/view/${recordId}?side_object=<%=item.objectName%>&side_listview_id=<%=item.listName%>`;
|
|
20197
|
+
}
|
|
20198
|
+
return `/app/${appId}/${objectName}/view/${recordId}?side_object=\${objectName}&side_listview_id=\${listName}`;
|
|
20199
|
+
},
|
|
20200
|
+
getObjectRelatedViewPath({formFactor, appId, masterObjectName, masterRecordId, objectName, foreignKey}){
|
|
20201
|
+
return `/app/${appId}/${masterObjectName}/${masterRecordId}/${objectName}/grid?related_field_name=${foreignKey}`;
|
|
20202
|
+
},
|
|
20203
|
+
|
|
20204
|
+
};
|
|
20205
|
+
|
|
20159
20206
|
const getBuilderContext = ()=>{
|
|
20160
20207
|
if(typeof window === "undefined"){
|
|
20161
20208
|
return {};
|
|
@@ -20230,437 +20277,109 @@
|
|
|
20230
20277
|
return defaultRootUrl || '';
|
|
20231
20278
|
}
|
|
20232
20279
|
|
|
20233
|
-
|
|
20234
|
-
|
|
20235
|
-
|
|
20236
|
-
|
|
20237
|
-
|
|
20238
|
-
|
|
20239
|
-
|
|
20240
|
-
|
|
20241
|
-
|
|
20242
|
-
|
|
20243
|
-
|
|
20244
|
-
|
|
20245
|
-
|
|
20246
|
-
|
|
20247
|
-
|
|
20248
|
-
|
|
20249
|
-
|
|
20250
|
-
|
|
20251
|
-
|
|
20252
|
-
|
|
20253
|
-
|
|
20254
|
-
|
|
20255
|
-
|
|
20256
|
-
|
|
20257
|
-
|
|
20258
|
-
|
|
20259
|
-
|
|
20260
|
-
|
|
20261
|
-
|
|
20262
|
-
|
|
20263
|
-
|
|
20264
|
-
|
|
20265
|
-
|
|
20266
|
-
|
|
20267
|
-
|
|
20268
|
-
|
|
20269
|
-
if(_templateType === 'JavaScript'){
|
|
20270
|
-
return `/app/${appId}/${objectName}/view/${recordId}?side_object=<%=item.objectName%>&side_listview_id=<%=item.listName%>`;
|
|
20280
|
+
async function getFieldsTemplate(fields, display){
|
|
20281
|
+
let expandFields = [];
|
|
20282
|
+
if(display != false){
|
|
20283
|
+
display = true;
|
|
20284
|
+
}
|
|
20285
|
+
let fieldsName = ['_id'];
|
|
20286
|
+
let displayFields = [];
|
|
20287
|
+
let fieldsArr = [];
|
|
20288
|
+
if(lodash.exports.isArray(fields)){
|
|
20289
|
+
fieldsArr = fields;
|
|
20290
|
+
}else {
|
|
20291
|
+
fieldsArr = lodash.exports.values(fields);
|
|
20292
|
+
}
|
|
20293
|
+
for (const field of fieldsArr) {
|
|
20294
|
+
//graphql 的 ui\display 中使用的字段需要先在query中查询. 否则会返回null
|
|
20295
|
+
if(field.expand){
|
|
20296
|
+
expandFields.push(field);
|
|
20297
|
+
}else {
|
|
20298
|
+
if(field.name.indexOf('.') < 0){
|
|
20299
|
+
if(display && (field.type == 'lookup' || field.type == 'master_detail')){
|
|
20300
|
+
fieldsName.push(`${field.name}`);
|
|
20301
|
+
displayFields.push(`${field.name}`);
|
|
20302
|
+
}else {
|
|
20303
|
+
fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
|
|
20304
|
+
}
|
|
20305
|
+
if(lodash.exports.includes(['time','date','datetime','boolean','number','currency'], field.type)){
|
|
20306
|
+
fieldsName.push(`${field.name}`);
|
|
20307
|
+
}
|
|
20308
|
+
if(lodash.exports.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
|
|
20309
|
+
displayFields.push(`${field.name}`);
|
|
20310
|
+
}
|
|
20311
|
+
}else {
|
|
20312
|
+
objectFieldName = field.name.split('.')[0];
|
|
20313
|
+
fieldsName.push(objectFieldName);
|
|
20314
|
+
displayFields.push(objectFieldName);
|
|
20315
|
+
}
|
|
20271
20316
|
}
|
|
20272
|
-
|
|
20273
|
-
},
|
|
20274
|
-
getObjectRelatedViewPath({formFactor, appId, masterObjectName, masterRecordId, objectName, foreignKey}){
|
|
20275
|
-
return `/app/${appId}/${masterObjectName}/${masterRecordId}/${objectName}/grid?related_field_name=${foreignKey}`;
|
|
20276
|
-
},
|
|
20277
|
-
|
|
20278
|
-
};
|
|
20279
|
-
|
|
20280
|
-
/*
|
|
20281
|
-
* @Author: baozhoutao@steedos.com
|
|
20282
|
-
* @Date: 2022-07-20 16:29:22
|
|
20283
|
-
* @LastEditors: liaodaxue
|
|
20284
|
-
* @LastEditTime: 2023-09-11 17:19:53
|
|
20285
|
-
* @Description:
|
|
20286
|
-
*/
|
|
20287
|
-
|
|
20288
|
-
function getImageFieldUrl(url) {
|
|
20289
|
-
if (window.Meteor && window.Meteor.isCordova != true) {
|
|
20290
|
-
// '//'的位置
|
|
20291
|
-
const doubleSlashIndex = url.indexOf('//');
|
|
20292
|
-
const urlIndex = url.indexOf('/', doubleSlashIndex + 2);
|
|
20293
|
-
const rootUrl = url.substring(urlIndex);
|
|
20294
|
-
return rootUrl;
|
|
20295
|
-
}
|
|
20296
|
-
return url;
|
|
20297
|
-
}
|
|
20317
|
+
}
|
|
20298
20318
|
|
|
20299
|
-
|
|
20300
|
-
|
|
20301
|
-
|
|
20319
|
+
displayFields = lodash.exports.uniq(displayFields);
|
|
20320
|
+
fieldsName = lodash.exports.uniq(fieldsName);
|
|
20321
|
+
let expandFieldsQuery = "";
|
|
20322
|
+
if(expandFields.length > 0){
|
|
20323
|
+
lodash.exports.each(expandFields, function(field){
|
|
20324
|
+
expandFieldsQuery = expandFieldsQuery + `${field.expandInfo.fieldName}__expand{${field.expandInfo.displayName}}`;
|
|
20325
|
+
});
|
|
20326
|
+
}
|
|
20302
20327
|
|
|
20303
|
-
|
|
20304
|
-
|
|
20305
|
-
|
|
20306
|
-
|
|
20307
|
-
var b = parseInt(backgroundColor.substr(4, 2), 16);
|
|
20308
|
-
var brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
20309
|
-
return brightness < 128 ? "#ffffff" : "#000000";
|
|
20328
|
+
if(displayFields.length > 0){
|
|
20329
|
+
return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
|
|
20330
|
+
}
|
|
20331
|
+
return lodash.exports.trimEnd(`${fieldsName.join(' ')},${expandFieldsQuery}`, ",")
|
|
20310
20332
|
}
|
|
20311
20333
|
|
|
20312
|
-
function
|
|
20313
|
-
|
|
20314
|
-
|
|
20315
|
-
|
|
20316
|
-
|
|
20317
|
-
|
|
20318
|
-
|
|
20334
|
+
async function getFindQuery(object, recordId, fields, options){
|
|
20335
|
+
let limit = options.limit || 10;
|
|
20336
|
+
let queryOptions = `(top: ${limit})`;
|
|
20337
|
+
if(recordId){
|
|
20338
|
+
queryOptions = `(filters:["_id", "=", "${recordId}"], top: ${limit})`;
|
|
20339
|
+
}
|
|
20340
|
+
let alias = "data";
|
|
20341
|
+
if(options){
|
|
20342
|
+
if(options.alias){
|
|
20343
|
+
alias = options.alias;
|
|
20344
|
+
}
|
|
20319
20345
|
|
|
20320
|
-
|
|
20321
|
-
|
|
20322
|
-
(view, name) => {
|
|
20323
|
-
if (name === listNameAll) {
|
|
20324
|
-
listViewAll = view;
|
|
20325
|
-
if(!listViewAll.name){
|
|
20326
|
-
listViewAll.name = name;
|
|
20346
|
+
if(options.filters){
|
|
20347
|
+
queryOptions = `(filters:${options.filters})`;
|
|
20327
20348
|
}
|
|
20328
|
-
|
|
20329
|
-
|
|
20330
|
-
listViewLookup = view;
|
|
20331
|
-
if(!listViewLookup.name){
|
|
20332
|
-
listViewLookup.name = name;
|
|
20349
|
+
if(options.queryOptions){
|
|
20350
|
+
queryOptions = `(${options.queryOptions})`;
|
|
20333
20351
|
}
|
|
20334
|
-
}
|
|
20335
20352
|
}
|
|
20336
|
-
|
|
20337
|
-
|
|
20338
|
-
|
|
20339
|
-
|
|
20340
|
-
|
|
20341
|
-
function getNumberTpl(field){
|
|
20342
|
-
return `<span>\${_display.${field.name}}</span>`
|
|
20343
|
-
}
|
|
20344
|
-
|
|
20345
|
-
function getTimeTpl(field){
|
|
20346
|
-
return `<span>\${_display.${field.name}}</span>`
|
|
20347
|
-
}
|
|
20348
|
-
|
|
20349
|
-
function getDateTpl(field){
|
|
20350
|
-
return `<span>\${_display.${field.name}}</span>`
|
|
20351
|
-
}
|
|
20353
|
+
var treeFields = '';
|
|
20354
|
+
if(object.enable_tree && lodash.exports.includes(lodash.exports.keys(object.fields), 'parent') && lodash.exports.includes(lodash.exports.keys(object.fields), 'children')){
|
|
20355
|
+
treeFields = ',parent,children';
|
|
20356
|
+
}
|
|
20352
20357
|
|
|
20358
|
+
var cfsFields = '';
|
|
20359
|
+
if(object.name === 'cms_files'){
|
|
20360
|
+
cfsFields = ',versions';
|
|
20361
|
+
}
|
|
20353
20362
|
|
|
20354
|
-
|
|
20355
|
-
|
|
20356
|
-
|
|
20363
|
+
const countQuery = options.count === false ? "" : `,count:${object.name}__count(filters:{__filters})`;
|
|
20364
|
+
// const moreQuerie = options.moreQueries?.length ? ("," + options.moreQueries.map(function(item){
|
|
20365
|
+
// // 把最外层的{}去除
|
|
20366
|
+
// return item.replace(/^{/,"").replace(/}$/,"");
|
|
20367
|
+
// }).join(",")) : "";
|
|
20357
20368
|
|
|
20358
|
-
|
|
20359
|
-
|
|
20369
|
+
return {
|
|
20370
|
+
orderBy: "${orderBy}",
|
|
20371
|
+
orderDir: "${orderDir}",
|
|
20372
|
+
pageNo: "${page}",
|
|
20373
|
+
pageSize: "${perPage}",
|
|
20374
|
+
query: `{${alias}:${object.name}${queryOptions}{${await getFieldsTemplate(fields, options.expand)}${treeFields}${cfsFields}}${countQuery}}`
|
|
20375
|
+
}
|
|
20360
20376
|
}
|
|
20361
20377
|
|
|
20362
|
-
function
|
|
20363
|
-
|
|
20364
|
-
|
|
20365
|
-
|
|
20366
|
-
|
|
20367
|
-
async function getRefObjectNameFieldName(field){
|
|
20368
|
-
const refUiSchema = await getUISchema(field.reference_to);
|
|
20369
|
-
const NAME_FIELD_KEY = refUiSchema.NAME_FIELD_KEY || 'name';
|
|
20370
|
-
return NAME_FIELD_KEY;
|
|
20371
|
-
}
|
|
20372
|
-
|
|
20373
|
-
function getSelectTpl(field){
|
|
20374
|
-
return `<span>\${_display.${field.name}}</span>`
|
|
20375
|
-
}
|
|
20376
|
-
function getSelectMap(selectOptions){
|
|
20377
|
-
let map = {};
|
|
20378
|
-
lodash.exports.forEach(selectOptions,(option)=>{
|
|
20379
|
-
const optionValue = option.value + '';
|
|
20380
|
-
const optionColor = option.color + '';
|
|
20381
|
-
if(optionColor){
|
|
20382
|
-
const background = optionColor.charAt(0) === '#' ? optionColor : '#'+optionColor;
|
|
20383
|
-
const color = getContrastColor(background);
|
|
20384
|
-
const optionColorStyle = 'background:'+background+';color:'+color+';line-height:1.5rem';
|
|
20385
|
-
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
20386
|
-
}else {
|
|
20387
|
-
map[optionValue] = option.label;
|
|
20388
|
-
}
|
|
20389
|
-
});
|
|
20390
|
-
return map;
|
|
20391
|
-
}
|
|
20392
|
-
|
|
20393
|
-
function getNameTplUrl(field, ctx){
|
|
20394
|
-
if(ctx.objectName === 'cms_files'){
|
|
20395
|
-
return `\${context.rootUrl}/api/files/files/\${versions[0]}?download=true`
|
|
20396
|
-
}
|
|
20397
|
-
const href = Router.getObjectDetailPath({
|
|
20398
|
-
...ctx, formFactor: ctx.formFactor, appId: "${appId}", objectName: ctx.objectName || "${objectName}", recordId: `\${${ctx.idFieldName}}`
|
|
20399
|
-
});
|
|
20400
|
-
return href;
|
|
20401
|
-
}
|
|
20402
|
-
|
|
20403
|
-
function getNameTpl(field, ctx){
|
|
20404
|
-
const href = getNameTplUrl(field, ctx);
|
|
20405
|
-
let linkTarget = "";
|
|
20406
|
-
if(ctx && ctx.isLookup){
|
|
20407
|
-
linkTarget = "target='_blank'";
|
|
20408
|
-
}
|
|
20409
|
-
return `<a href="${href}" ${linkTarget}>\${${field.name}}</a>`
|
|
20410
|
-
}
|
|
20411
|
-
|
|
20412
|
-
function getRelatedFieldTpl(field, ctx){
|
|
20413
|
-
let tpl = '';
|
|
20414
|
-
if(!field.reference_to && (field.optionsFunction || field._optionsFunction || field.options)){
|
|
20415
|
-
if(field.isTableField){
|
|
20416
|
-
return `\${${field.name}}`
|
|
20417
|
-
}else {
|
|
20418
|
-
return `\${${field.name}__label}`
|
|
20419
|
-
}
|
|
20420
|
-
}
|
|
20421
|
-
|
|
20422
|
-
let linkTarget = "";
|
|
20423
|
-
if(ctx && ctx.isLookup){
|
|
20424
|
-
linkTarget = "target='_blank'";
|
|
20425
|
-
}
|
|
20426
|
-
|
|
20427
|
-
const onlyDisplayLookLabel = ctx.onlyDisplayLookLabel;
|
|
20428
|
-
|
|
20429
|
-
let fieldDataStrTpl = `data._display.${field.name}`;
|
|
20430
|
-
|
|
20431
|
-
if(field.isTableField){
|
|
20432
|
-
fieldDataStrTpl = `data.${field.name}`;
|
|
20433
|
-
}
|
|
20434
|
-
|
|
20435
|
-
if(_.isString(field.reference_to) || !field.reference_to){
|
|
20436
|
-
if(field.multiple){
|
|
20437
|
-
let labelTpl = `<%=item.label%>`;
|
|
20438
|
-
if(!onlyDisplayLookLabel){
|
|
20439
|
-
const href = Router.getObjectDetailPath({
|
|
20440
|
-
formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
|
|
20441
|
-
});
|
|
20442
|
-
labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
|
|
20443
|
-
}
|
|
20444
|
-
tpl = `
|
|
20445
|
-
<% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item,index) { %> <% if(index>0 && index<${fieldDataStrTpl}.length){ %> , <% } %> ${labelTpl} <% }); %><% } %>
|
|
20446
|
-
`;
|
|
20447
|
-
}else {
|
|
20448
|
-
let labelTpl = `\${_display.${field.name}.label}`;
|
|
20449
|
-
let objectNameTpl = `\${_display.${field.name}.objectName}`;
|
|
20450
|
-
let recordIdTpl = `\${_display.${field.name}.value}`;
|
|
20451
|
-
if(field.isTableField){
|
|
20452
|
-
labelTpl = `\${${field.name}.label}`;
|
|
20453
|
-
objectNameTpl = `\${${field.name}.objectName}`;
|
|
20454
|
-
recordIdTpl = `\${${field.name}.value}`;
|
|
20455
|
-
}
|
|
20456
|
-
if(!onlyDisplayLookLabel){
|
|
20457
|
-
const href = Router.getObjectDetailPath({
|
|
20458
|
-
formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
|
|
20459
|
-
});
|
|
20460
|
-
labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
|
|
20461
|
-
}
|
|
20462
|
-
tpl = labelTpl;
|
|
20463
|
-
}
|
|
20464
|
-
|
|
20465
|
-
|
|
20466
|
-
}else {
|
|
20467
|
-
let labelTpl = `<%=item.label%>`;
|
|
20468
|
-
if(!onlyDisplayLookLabel){
|
|
20469
|
-
const href = Router.getObjectDetailPath({
|
|
20470
|
-
formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
|
|
20471
|
-
});
|
|
20472
|
-
labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
|
|
20473
|
-
}
|
|
20474
|
-
tpl = `
|
|
20475
|
-
<% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item) { %> ${labelTpl} <% }); %><% } %>
|
|
20476
|
-
`;
|
|
20477
|
-
}
|
|
20478
|
-
return tpl
|
|
20479
|
-
}
|
|
20480
|
-
|
|
20481
|
-
async function getLookupTpl(field, ctx){
|
|
20482
|
-
if(!field.reference_to){
|
|
20483
|
-
return getSelectTpl(field)
|
|
20484
|
-
}
|
|
20485
|
-
const NAME_FIELD_KEY = await getRefObjectNameFieldName(field);
|
|
20486
|
-
if(field.multiple){
|
|
20487
|
-
const href = Router.getObjectDetailPath({
|
|
20488
|
-
formFactor: ctx.formFactor, appId: ctx.appId, objectName: field.reference_to, recordId: `<%=item._id%>`, _templateType: "JavaScript"
|
|
20489
|
-
});
|
|
20490
|
-
return `
|
|
20491
|
-
<% if (data.${field.name} && data.${field.name}.length) { %><% data.${field.name}.forEach(function(item) { %> <a href="${href}"><%=item.${NAME_FIELD_KEY}%></a> <% }); %><% } %>
|
|
20492
|
-
`
|
|
20493
|
-
}else {
|
|
20494
|
-
const href = Router.getObjectDetailPath({
|
|
20495
|
-
formFactor: ctx.formFactor, appId: ctx.appId, objectName: field.reference_to, recordId: `\${${field.name}._id}`
|
|
20496
|
-
});
|
|
20497
|
-
return `<a href="${href}">\${${field.name}.${NAME_FIELD_KEY}}</a>`
|
|
20498
|
-
}
|
|
20499
|
-
|
|
20500
|
-
}
|
|
20501
|
-
|
|
20502
|
-
function getSwitchTpl(field){
|
|
20503
|
-
let fieldDataStrTpl = `data._display.${field.name}`;
|
|
20504
|
-
if(field.isTableField){
|
|
20505
|
-
fieldDataStrTpl = `data.${field.name}`;
|
|
20506
|
-
}
|
|
20507
|
-
return `<% if (data.${field.name}) { %>
|
|
20508
|
-
<span class="slds-icon_container slds-icon-utility-check slds-current-color" title="<%=${fieldDataStrTpl}%>">
|
|
20509
|
-
<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>
|
|
20510
|
-
</span>
|
|
20511
|
-
<% } %>`
|
|
20512
|
-
}
|
|
20513
|
-
|
|
20514
|
-
function getPasswordTpl(field){
|
|
20515
|
-
return `<% if (data.${field.name}) { %>
|
|
20516
|
-
<span>······</span>
|
|
20517
|
-
<% } %>`
|
|
20518
|
-
}
|
|
20519
|
-
|
|
20520
|
-
function getLocationTpl(field){
|
|
20521
|
-
return `\${${field.name} ? ${field.name}.address : ''}`
|
|
20522
|
-
}
|
|
20523
|
-
|
|
20524
|
-
async function getFieldTpl (field, options){
|
|
20525
|
-
if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel){
|
|
20526
|
-
return getNameTpl(field, options)
|
|
20527
|
-
}
|
|
20528
|
-
switch (field.type) {
|
|
20529
|
-
case 'password':
|
|
20530
|
-
return getPasswordTpl(field);
|
|
20531
|
-
case 'boolean':
|
|
20532
|
-
return getSwitchTpl(field);
|
|
20533
|
-
case 'toggle':
|
|
20534
|
-
return getSwitchTpl(field);
|
|
20535
|
-
case 'select':
|
|
20536
|
-
return getSelectTpl(field);
|
|
20537
|
-
case 'time':
|
|
20538
|
-
return getTimeTpl(field);
|
|
20539
|
-
case 'date':
|
|
20540
|
-
return getDateTpl(field);
|
|
20541
|
-
case 'datetime':
|
|
20542
|
-
return getDateTimeTpl(field);
|
|
20543
|
-
case 'lookup':
|
|
20544
|
-
return await getRelatedFieldTpl(field, options);
|
|
20545
|
-
case 'master_detail':
|
|
20546
|
-
return await getRelatedFieldTpl(field, options);
|
|
20547
|
-
case 'location':
|
|
20548
|
-
return await getLocationTpl(field);
|
|
20549
|
-
case 'number':
|
|
20550
|
-
case 'currency':
|
|
20551
|
-
return await getNumberTpl(field);
|
|
20552
|
-
case 'percent':
|
|
20553
|
-
case 'formula':
|
|
20554
|
-
case 'summary':
|
|
20555
|
-
return getUiFieldTpl(field)
|
|
20556
|
-
case 'filesize':
|
|
20557
|
-
return getUiFileSizeTpl(field)
|
|
20558
|
-
}
|
|
20559
|
-
}
|
|
20560
|
-
|
|
20561
|
-
async function getFieldsTemplate(fields, display){
|
|
20562
|
-
let expandFields = [];
|
|
20563
|
-
if(display != false){
|
|
20564
|
-
display = true;
|
|
20565
|
-
}
|
|
20566
|
-
let fieldsName = ['_id'];
|
|
20567
|
-
let displayFields = [];
|
|
20568
|
-
let fieldsArr = [];
|
|
20569
|
-
if(lodash.exports.isArray(fields)){
|
|
20570
|
-
fieldsArr = fields;
|
|
20571
|
-
}else {
|
|
20572
|
-
fieldsArr = lodash.exports.values(fields);
|
|
20573
|
-
}
|
|
20574
|
-
for (const field of fieldsArr) {
|
|
20575
|
-
//graphql 的 ui\display 中使用的字段需要先在query中查询. 否则会返回null
|
|
20576
|
-
if(field.expand){
|
|
20577
|
-
expandFields.push(field);
|
|
20578
|
-
}else {
|
|
20579
|
-
if(field.name.indexOf('.') < 0){
|
|
20580
|
-
if(display && (field.type == 'lookup' || field.type == 'master_detail')){
|
|
20581
|
-
fieldsName.push(`${field.name}`);
|
|
20582
|
-
displayFields.push(`${field.name}`);
|
|
20583
|
-
}else {
|
|
20584
|
-
fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
|
|
20585
|
-
}
|
|
20586
|
-
if(lodash.exports.includes(['time','date','datetime','boolean','number','currency'], field.type)){
|
|
20587
|
-
fieldsName.push(`${field.name}`);
|
|
20588
|
-
}
|
|
20589
|
-
if(lodash.exports.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
|
|
20590
|
-
displayFields.push(`${field.name}`);
|
|
20591
|
-
}
|
|
20592
|
-
}else {
|
|
20593
|
-
objectFieldName = field.name.split('.')[0];
|
|
20594
|
-
fieldsName.push(objectFieldName);
|
|
20595
|
-
displayFields.push(objectFieldName);
|
|
20596
|
-
}
|
|
20597
|
-
}
|
|
20598
|
-
}
|
|
20599
|
-
|
|
20600
|
-
displayFields = lodash.exports.uniq(displayFields);
|
|
20601
|
-
fieldsName = lodash.exports.uniq(fieldsName);
|
|
20602
|
-
let expandFieldsQuery = "";
|
|
20603
|
-
if(expandFields.length > 0){
|
|
20604
|
-
lodash.exports.each(expandFields, function(field){
|
|
20605
|
-
expandFieldsQuery = expandFieldsQuery + `${field.expandInfo.fieldName}__expand{${field.expandInfo.displayName}}`;
|
|
20606
|
-
});
|
|
20607
|
-
}
|
|
20608
|
-
|
|
20609
|
-
if(displayFields.length > 0){
|
|
20610
|
-
return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
|
|
20611
|
-
}
|
|
20612
|
-
return lodash.exports.trimEnd(`${fieldsName.join(' ')},${expandFieldsQuery}`, ",")
|
|
20613
|
-
}
|
|
20614
|
-
|
|
20615
|
-
async function getFindQuery(object, recordId, fields, options){
|
|
20616
|
-
let limit = options.limit || 10;
|
|
20617
|
-
let queryOptions = `(top: ${limit})`;
|
|
20618
|
-
if(recordId){
|
|
20619
|
-
queryOptions = `(filters:["_id", "=", "${recordId}"], top: ${limit})`;
|
|
20620
|
-
}
|
|
20621
|
-
let alias = "data";
|
|
20622
|
-
if(options){
|
|
20623
|
-
if(options.alias){
|
|
20624
|
-
alias = options.alias;
|
|
20625
|
-
}
|
|
20626
|
-
|
|
20627
|
-
if(options.filters){
|
|
20628
|
-
queryOptions = `(filters:${options.filters})`;
|
|
20629
|
-
}
|
|
20630
|
-
if(options.queryOptions){
|
|
20631
|
-
queryOptions = `(${options.queryOptions})`;
|
|
20632
|
-
}
|
|
20633
|
-
}
|
|
20634
|
-
var treeFields = '';
|
|
20635
|
-
if(object.enable_tree && lodash.exports.includes(lodash.exports.keys(object.fields), 'parent') && lodash.exports.includes(lodash.exports.keys(object.fields), 'children')){
|
|
20636
|
-
treeFields = ',parent,children';
|
|
20637
|
-
}
|
|
20638
|
-
|
|
20639
|
-
var cfsFields = '';
|
|
20640
|
-
if(object.name === 'cms_files'){
|
|
20641
|
-
cfsFields = ',versions';
|
|
20642
|
-
}
|
|
20643
|
-
|
|
20644
|
-
const countQuery = options.count === false ? "" : `,count:${object.name}__count(filters:{__filters})`;
|
|
20645
|
-
// const moreQuerie = options.moreQueries?.length ? ("," + options.moreQueries.map(function(item){
|
|
20646
|
-
// // 把最外层的{}去除
|
|
20647
|
-
// return item.replace(/^{/,"").replace(/}$/,"");
|
|
20648
|
-
// }).join(",")) : "";
|
|
20649
|
-
|
|
20650
|
-
return {
|
|
20651
|
-
orderBy: "${orderBy}",
|
|
20652
|
-
orderDir: "${orderDir}",
|
|
20653
|
-
pageNo: "${page}",
|
|
20654
|
-
pageSize: "${perPage}",
|
|
20655
|
-
query: `{${alias}:${object.name}${queryOptions}{${await getFieldsTemplate(fields, options.expand)}${treeFields}${cfsFields}}${countQuery}}`
|
|
20656
|
-
}
|
|
20657
|
-
}
|
|
20658
|
-
|
|
20659
|
-
function getApi$2 (isMobile){
|
|
20660
|
-
if(isMobile);else {
|
|
20661
|
-
// return __meteor_runtime_config__.ROOT_URL_PATH_PREFIX + "/graphql"
|
|
20662
|
-
return `\${context.rootUrl}/graphql?reload=\${additionalFilters}`
|
|
20663
|
-
}
|
|
20378
|
+
function getApi$2 (isMobile){
|
|
20379
|
+
if(isMobile);else {
|
|
20380
|
+
// return __meteor_runtime_config__.ROOT_URL_PATH_PREFIX + "/graphql"
|
|
20381
|
+
return `\${context.rootUrl}/graphql?reload=\${additionalFilters}`
|
|
20382
|
+
}
|
|
20664
20383
|
}
|
|
20665
20384
|
|
|
20666
20385
|
var frontend_field_group_generalization$1 = "General";
|
|
@@ -21113,6 +20832,67 @@
|
|
|
21113
20832
|
}
|
|
21114
20833
|
}
|
|
21115
20834
|
|
|
20835
|
+
/*
|
|
20836
|
+
* @Author: baozhoutao@steedos.com
|
|
20837
|
+
* @Date: 2022-07-20 16:29:22
|
|
20838
|
+
* @LastEditors: liaodaxue
|
|
20839
|
+
* @LastEditTime: 2023-09-11 17:19:53
|
|
20840
|
+
* @Description:
|
|
20841
|
+
*/
|
|
20842
|
+
|
|
20843
|
+
function getImageFieldUrl(url) {
|
|
20844
|
+
if (window.Meteor && window.Meteor.isCordova != true) {
|
|
20845
|
+
// '//'的位置
|
|
20846
|
+
const doubleSlashIndex = url.indexOf('//');
|
|
20847
|
+
const urlIndex = url.indexOf('/', doubleSlashIndex + 2);
|
|
20848
|
+
const rootUrl = url.substring(urlIndex);
|
|
20849
|
+
return rootUrl;
|
|
20850
|
+
}
|
|
20851
|
+
return url;
|
|
20852
|
+
}
|
|
20853
|
+
|
|
20854
|
+
if(typeof window != 'undefined'){
|
|
20855
|
+
window.getImageFieldUrl = getImageFieldUrl;
|
|
20856
|
+
}
|
|
20857
|
+
|
|
20858
|
+
function getContrastColor(bgColor) {
|
|
20859
|
+
var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
|
|
20860
|
+
var r = parseInt(backgroundColor.substr(0, 2), 16);
|
|
20861
|
+
var g = parseInt(backgroundColor.substr(2, 2), 16);
|
|
20862
|
+
var b = parseInt(backgroundColor.substr(4, 2), 16);
|
|
20863
|
+
var brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
20864
|
+
return brightness < 128 ? "#ffffff" : "#000000";
|
|
20865
|
+
}
|
|
20866
|
+
|
|
20867
|
+
function getLookupListView(refObjectConfig) {
|
|
20868
|
+
if(!refObjectConfig){
|
|
20869
|
+
return null;
|
|
20870
|
+
}
|
|
20871
|
+
const listNameAll = "all";
|
|
20872
|
+
const listNameLookup = "lookup";
|
|
20873
|
+
let listViewAll, listViewLookup;
|
|
20874
|
+
|
|
20875
|
+
_.each(
|
|
20876
|
+
refObjectConfig.list_views,
|
|
20877
|
+
(view, name) => {
|
|
20878
|
+
if (name === listNameAll) {
|
|
20879
|
+
listViewAll = view;
|
|
20880
|
+
if(!listViewAll.name){
|
|
20881
|
+
listViewAll.name = name;
|
|
20882
|
+
}
|
|
20883
|
+
}
|
|
20884
|
+
else if (name === listNameLookup) {
|
|
20885
|
+
listViewLookup = view;
|
|
20886
|
+
if(!listViewLookup.name){
|
|
20887
|
+
listViewLookup.name = name;
|
|
20888
|
+
}
|
|
20889
|
+
}
|
|
20890
|
+
}
|
|
20891
|
+
);
|
|
20892
|
+
let listView = listViewLookup || listViewAll;
|
|
20893
|
+
return listView;
|
|
20894
|
+
}
|
|
20895
|
+
|
|
21116
20896
|
/*
|
|
21117
20897
|
* @Author: baozhoutao@steedos.com
|
|
21118
20898
|
* @Date: 2022-11-01 15:51:00
|
|
@@ -22361,6 +22141,7 @@
|
|
|
22361
22141
|
}
|
|
22362
22142
|
}
|
|
22363
22143
|
],
|
|
22144
|
+
"className": "steedos-overflow-visible-dialog",
|
|
22364
22145
|
"showCloseButton": true,
|
|
22365
22146
|
"showErrorMsg": true,
|
|
22366
22147
|
"showLoading": true,
|
|
@@ -22947,7 +22728,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
22947
22728
|
"value": crudKeywords,
|
|
22948
22729
|
"clearable": true,
|
|
22949
22730
|
"clearAndSubmit": true,
|
|
22950
|
-
"searchImediately":
|
|
22731
|
+
"searchImediately": false
|
|
22951
22732
|
}
|
|
22952
22733
|
]
|
|
22953
22734
|
}
|
|
@@ -23828,7 +23609,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
23828
23609
|
if(refObjectConfig.name === 'organizations'){
|
|
23829
23610
|
labelFieldName = 'name';
|
|
23830
23611
|
}
|
|
23831
|
-
pickerSchema = await getTableSchema
|
|
23612
|
+
pickerSchema = await getTableSchema(tableFields, {
|
|
23832
23613
|
labelFieldName,
|
|
23833
23614
|
top: top,
|
|
23834
23615
|
isLookup: true,
|
|
@@ -24318,7 +24099,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
24318
24099
|
actions: false
|
|
24319
24100
|
});
|
|
24320
24101
|
}else {
|
|
24321
|
-
pickerSchema = await getTableSchema
|
|
24102
|
+
pickerSchema = await getTableSchema(tableFields, {
|
|
24322
24103
|
labelFieldName: refObjectConfig.NAME_FIELD_KEY,
|
|
24323
24104
|
top: top,
|
|
24324
24105
|
isLookup: true,
|
|
@@ -24968,7 +24749,9 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
24968
24749
|
suffix: "%",
|
|
24969
24750
|
pipeIn: (value, data) => {
|
|
24970
24751
|
if(value){
|
|
24971
|
-
|
|
24752
|
+
// 因为例如 1.11 * 100 的值不是111,所以调整下。
|
|
24753
|
+
const result = value*100;
|
|
24754
|
+
return Number(result.toFixed(field.scale));
|
|
24972
24755
|
}
|
|
24973
24756
|
return value;
|
|
24974
24757
|
},
|
|
@@ -25067,295 +24850,907 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
25067
24850
|
return value; // 切换到数字之后的默认值
|
|
25068
24851
|
}
|
|
25069
24852
|
}
|
|
25070
|
-
};
|
|
25071
|
-
break;
|
|
25072
|
-
case 'avatar':
|
|
25073
|
-
convertData = getAmisFileSchema(field, readonly);
|
|
25074
|
-
break;
|
|
25075
|
-
case 'image':
|
|
25076
|
-
convertData = getAmisFileSchema(field, readonly);
|
|
25077
|
-
break;
|
|
25078
|
-
case 'file':
|
|
25079
|
-
convertData = getAmisFileSchema(field, readonly);
|
|
24853
|
+
};
|
|
24854
|
+
break;
|
|
24855
|
+
case 'avatar':
|
|
24856
|
+
convertData = getAmisFileSchema(field, readonly);
|
|
24857
|
+
break;
|
|
24858
|
+
case 'image':
|
|
24859
|
+
convertData = getAmisFileSchema(field, readonly);
|
|
24860
|
+
break;
|
|
24861
|
+
case 'file':
|
|
24862
|
+
convertData = getAmisFileSchema(field, readonly);
|
|
24863
|
+
break;
|
|
24864
|
+
case 'formula':
|
|
24865
|
+
if(readonly){
|
|
24866
|
+
convertData = {
|
|
24867
|
+
type: 'static-tpl',
|
|
24868
|
+
tpl: getUiFieldTpl(field)
|
|
24869
|
+
};
|
|
24870
|
+
}
|
|
24871
|
+
break;
|
|
24872
|
+
case 'summary':
|
|
24873
|
+
if(readonly){
|
|
24874
|
+
convertData = {
|
|
24875
|
+
type: 'static-tpl',
|
|
24876
|
+
tpl: getUiFieldTpl(field)
|
|
24877
|
+
};
|
|
24878
|
+
}
|
|
24879
|
+
break;
|
|
24880
|
+
case 'code':
|
|
24881
|
+
convertData = {
|
|
24882
|
+
type: "editor",
|
|
24883
|
+
disabled: readonly ? true : false,
|
|
24884
|
+
language: field.language,
|
|
24885
|
+
editorDidMount: new Function('editor', 'monaco', field.editorDidMount)
|
|
24886
|
+
};
|
|
24887
|
+
break;
|
|
24888
|
+
case 'toggle':
|
|
24889
|
+
convertData = {
|
|
24890
|
+
type: "switch",
|
|
24891
|
+
name: field.name,
|
|
24892
|
+
label: field.label,
|
|
24893
|
+
width: field.width,
|
|
24894
|
+
toggled: field.toggled,
|
|
24895
|
+
disabled: readonly,
|
|
24896
|
+
};
|
|
24897
|
+
break;
|
|
24898
|
+
case 'grid':
|
|
24899
|
+
if(field.subFields){
|
|
24900
|
+
convertData = {
|
|
24901
|
+
type: 'input-table',
|
|
24902
|
+
showIndex: true,
|
|
24903
|
+
columnsTogglable: false,
|
|
24904
|
+
strictMode:false,
|
|
24905
|
+
affixHeader: false, // 是否固定表头, 不固定表头, 否则form有y轴滚动条时, 表头会跟随滚动条滚动.
|
|
24906
|
+
needConfirm: false,
|
|
24907
|
+
editable: !readonly,
|
|
24908
|
+
addable: !readonly,
|
|
24909
|
+
removable: !readonly,
|
|
24910
|
+
draggable: !readonly,
|
|
24911
|
+
columns: []
|
|
24912
|
+
};
|
|
24913
|
+
// console.log(`convertData ==2====>`, field, convertData)
|
|
24914
|
+
for (const subField of field.subFields) {
|
|
24915
|
+
const subFieldName = subField.name.replace(`${field._prefix || ''}${field.name}.$.`, '').replace(`${field.name}.`, '');
|
|
24916
|
+
const gridSub = await convertSFieldToAmisField(Object.assign({}, subField, {name: subFieldName, isTableField: true}), readonly, ctx);
|
|
24917
|
+
if(gridSub){
|
|
24918
|
+
delete gridSub.name;
|
|
24919
|
+
delete gridSub.label;
|
|
24920
|
+
const gridItemSchema = {
|
|
24921
|
+
name: subFieldName,
|
|
24922
|
+
label: subField.label,
|
|
24923
|
+
quickEdit: readonly ? false : gridSub
|
|
24924
|
+
};
|
|
24925
|
+
if(["lookup", "boolean", "toggle"].indexOf(subField.type) > -1){
|
|
24926
|
+
gridItemSchema.type = gridSub.type;
|
|
24927
|
+
gridItemSchema.tpl = gridSub.tpl;
|
|
24928
|
+
}
|
|
24929
|
+
convertData.columns.push(Object.assign({}, gridItemSchema, subField.amis, {name: subFieldName}));
|
|
24930
|
+
}
|
|
24931
|
+
}
|
|
24932
|
+
}
|
|
25080
24933
|
break;
|
|
25081
|
-
case '
|
|
25082
|
-
if(
|
|
24934
|
+
case 'object':
|
|
24935
|
+
if(field.subFields){
|
|
25083
24936
|
convertData = {
|
|
25084
|
-
type: '
|
|
25085
|
-
|
|
24937
|
+
type: 'combo',
|
|
24938
|
+
items: []
|
|
25086
24939
|
};
|
|
24940
|
+
// console.log(`convertData ======>`, field, convertData)
|
|
24941
|
+
for (let subField of field.subFields) {
|
|
24942
|
+
let subFieldName = subField.name.replace(`${field.name}.$.`, '').replace(`${field.name}.`, '');
|
|
24943
|
+
if(subField.type === 'grid'){
|
|
24944
|
+
subField = await getGridFieldSubFields(subField, ctx.__formFields);
|
|
24945
|
+
}else {
|
|
24946
|
+
if(readonly){
|
|
24947
|
+
subFieldName = `${field.name}.${subFieldName}`;
|
|
24948
|
+
}
|
|
24949
|
+
}
|
|
24950
|
+
const gridSub = await convertSFieldToAmisField(Object.assign({}, subField, {name: subFieldName}), readonly, ctx);
|
|
24951
|
+
if(gridSub){
|
|
24952
|
+
delete gridSub.name;
|
|
24953
|
+
delete gridSub.label;
|
|
24954
|
+
convertData.items.push(
|
|
24955
|
+
Object.assign({}, gridSub, {label: subField.label}, subField.amis, {
|
|
24956
|
+
name: subFieldName
|
|
24957
|
+
})
|
|
24958
|
+
);
|
|
24959
|
+
}
|
|
24960
|
+
}
|
|
24961
|
+
}
|
|
24962
|
+
break;
|
|
24963
|
+
}
|
|
24964
|
+
if(!lodash.exports.isEmpty(convertData)){
|
|
24965
|
+
if(field.is_wide || convertData.type === 'group'){
|
|
24966
|
+
convertData.className = 'col-span-2 m-1';
|
|
24967
|
+
}else {
|
|
24968
|
+
convertData.className = 'm-1';
|
|
24969
|
+
}
|
|
24970
|
+
if(readonly){
|
|
24971
|
+
convertData.className = `${convertData.className} border-b`;
|
|
24972
|
+
}
|
|
24973
|
+
if(readonly){
|
|
24974
|
+
convertData.quickEdit = false;
|
|
24975
|
+
}
|
|
24976
|
+
|
|
24977
|
+
let fieldTypeClassName = ' steedos-' + convertData.type + (readonly ? '-readonly' : '-edit');
|
|
24978
|
+
if (convertData.className) {
|
|
24979
|
+
convertData.className = convertData.className + fieldTypeClassName;
|
|
24980
|
+
} else {
|
|
24981
|
+
convertData.className = fieldTypeClassName;
|
|
24982
|
+
}
|
|
24983
|
+
|
|
24984
|
+
if(field.visible_on && !ctx.inFilterForm){
|
|
24985
|
+
// convertData.visibleOn = `\$${field.visible_on.substring(1, field.visible_on.length -1).replace(/formData./g, '')}`;
|
|
24986
|
+
if(field.visible_on.startsWith("{{")){
|
|
24987
|
+
convertData.visibleOn = `${field.visible_on.substring(2, field.visible_on.length -2).replace(/formData./g, 'data.')}`;
|
|
24988
|
+
}else {
|
|
24989
|
+
convertData.visibleOn = `${field.visible_on.replace(/formData./g, 'data.')}`;
|
|
24990
|
+
}
|
|
24991
|
+
}
|
|
24992
|
+
|
|
24993
|
+
if(lodash.exports.isString(baseData.required)){
|
|
24994
|
+
if(baseData.required.startsWith("{{")){
|
|
24995
|
+
baseData.requiredOn = `${baseData.required.substring(2, baseData.required.length -2).replace(/formData./g, 'data.')}`;
|
|
24996
|
+
delete baseData.required;
|
|
24997
|
+
}
|
|
24998
|
+
}
|
|
24999
|
+
|
|
25000
|
+
if(convertData.type === 'group'){
|
|
25001
|
+
convertData.body[0] = Object.assign({}, baseData, convertData.body[0], { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name});
|
|
25002
|
+
return convertData
|
|
25003
|
+
}
|
|
25004
|
+
// if(ctx.mode === 'edit'){
|
|
25005
|
+
return Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name}, field.amis, {name: baseData.name});
|
|
25006
|
+
// }else{
|
|
25007
|
+
// return Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name});
|
|
25008
|
+
// }
|
|
25009
|
+
}
|
|
25010
|
+
|
|
25011
|
+
}
|
|
25012
|
+
|
|
25013
|
+
async function getFieldSearchable(perField, permissionFields, ctx){
|
|
25014
|
+
if(!ctx){
|
|
25015
|
+
ctx = {};
|
|
25016
|
+
}
|
|
25017
|
+
let field = perField;
|
|
25018
|
+
if(field.type === 'grid'){
|
|
25019
|
+
field = await getGridFieldSubFields(perField, permissionFields);
|
|
25020
|
+
}else if(perField.type === 'object'){
|
|
25021
|
+
field = await getObjectFieldSubFields(perField, permissionFields);
|
|
25022
|
+
}
|
|
25023
|
+
|
|
25024
|
+
let fieldNamePrefix = '__searchable__';
|
|
25025
|
+
if(field.name.indexOf(".") < 0){
|
|
25026
|
+
let _field = lodash.exports.cloneDeep(field);
|
|
25027
|
+
if(lodash.exports.includes(['textarea', 'html', 'code', 'autonumber'], field.type)){
|
|
25028
|
+
_field.type = 'text';
|
|
25029
|
+
}
|
|
25030
|
+
|
|
25031
|
+
if(lodash.exports.includes(['formula', 'summary'], field.type)){
|
|
25032
|
+
_field.type = field.data_type;
|
|
25033
|
+
_field.precision = field.precision;
|
|
25034
|
+
_field.scale = field.scale;
|
|
25035
|
+
}
|
|
25036
|
+
else if(field.type === "select" && field.data_type && field.data_type != "text"){
|
|
25037
|
+
_field.type = field.data_type;
|
|
25038
|
+
}
|
|
25039
|
+
|
|
25040
|
+
if(_field.type === 'number' || _field.type === 'currency'){
|
|
25041
|
+
_field.type = 'input-array';
|
|
25042
|
+
_field.inline = true;
|
|
25043
|
+
_field.addable = false;
|
|
25044
|
+
_field.removable = false;
|
|
25045
|
+
_field.value = [null,null];
|
|
25046
|
+
_field.items = {
|
|
25047
|
+
type: "input-number"
|
|
25048
|
+
};
|
|
25049
|
+
_field.is_wide = true;
|
|
25050
|
+
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
25051
|
+
}
|
|
25052
|
+
|
|
25053
|
+
if(_field.type ==='date'){
|
|
25054
|
+
_field.type = 'input-date-range';
|
|
25055
|
+
_field.is_wide = true;
|
|
25056
|
+
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
25057
|
+
}
|
|
25058
|
+
if(_field.type === 'datetime'){
|
|
25059
|
+
_field.type = 'input-datetime-range';
|
|
25060
|
+
_field.is_wide = true;
|
|
25061
|
+
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
25062
|
+
}
|
|
25063
|
+
if(_field.type === 'time'){
|
|
25064
|
+
_field.type = 'input-time-range';
|
|
25065
|
+
_field.is_wide = true;
|
|
25066
|
+
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
25067
|
+
}
|
|
25068
|
+
if(_field.reference_to === 'users'){
|
|
25069
|
+
_field.reference_to = 'space_users';
|
|
25070
|
+
_field.reference_to_field = 'user';
|
|
25071
|
+
}
|
|
25072
|
+
_field.readonly = false;
|
|
25073
|
+
_field.disabled = false;
|
|
25074
|
+
_field.multiple = true;
|
|
25075
|
+
_field.is_wide = false;
|
|
25076
|
+
_field.defaultValue = undefined;
|
|
25077
|
+
_field.required = false;
|
|
25078
|
+
_field.hidden = false;
|
|
25079
|
+
_field.omit = false;
|
|
25080
|
+
|
|
25081
|
+
if(_field.amis){
|
|
25082
|
+
delete _field.amis.static;
|
|
25083
|
+
delete _field.amis.staticOn;
|
|
25084
|
+
delete _field.amis.disabled;
|
|
25085
|
+
delete _field.amis.disabledOn;
|
|
25086
|
+
delete _field.amis.required;
|
|
25087
|
+
delete _field.amis.requiredOn;
|
|
25088
|
+
delete _field.amis.visible;
|
|
25089
|
+
delete _field.amis.visibleOn;
|
|
25090
|
+
delete _field.amis.hidden;
|
|
25091
|
+
delete _field.amis.hiddenOn;
|
|
25092
|
+
delete _field.amis.autoFill;
|
|
25093
|
+
}
|
|
25094
|
+
|
|
25095
|
+
const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
|
|
25096
|
+
if(amisField){
|
|
25097
|
+
return Object.assign({}, amisField,{
|
|
25098
|
+
submitOnChange: true
|
|
25099
|
+
});
|
|
25100
|
+
}
|
|
25101
|
+
}
|
|
25102
|
+
}
|
|
25103
|
+
|
|
25104
|
+
if(typeof window != 'undefined'){
|
|
25105
|
+
window.getFieldSearchable = getFieldSearchable;
|
|
25106
|
+
}
|
|
25107
|
+
|
|
25108
|
+
|
|
25109
|
+
function isFieldTypeSearchable(fieldType) {
|
|
25110
|
+
return !lodash.exports.includes(
|
|
25111
|
+
[
|
|
25112
|
+
"grid",
|
|
25113
|
+
"avatar",
|
|
25114
|
+
"image",
|
|
25115
|
+
"object",
|
|
25116
|
+
"[object]",
|
|
25117
|
+
"[Object]",
|
|
25118
|
+
"[grid]",
|
|
25119
|
+
"[text]",
|
|
25120
|
+
"audio",
|
|
25121
|
+
"file",
|
|
25122
|
+
],
|
|
25123
|
+
fieldType
|
|
25124
|
+
)
|
|
25125
|
+
}
|
|
25126
|
+
|
|
25127
|
+
if (typeof window != 'undefined') {
|
|
25128
|
+
window.isFieldTypeSearchable = isFieldTypeSearchable;
|
|
25129
|
+
}
|
|
25130
|
+
|
|
25131
|
+
|
|
25132
|
+
function isFieldQuickSearchable(field, nameFieldKey) {
|
|
25133
|
+
let fieldSearchable = field.searchable;
|
|
25134
|
+
if(fieldSearchable !== false && field.name === nameFieldKey){
|
|
25135
|
+
// 对象上名称字段的searchable默认认为是true
|
|
25136
|
+
fieldSearchable = true;
|
|
25137
|
+
}
|
|
25138
|
+
if (fieldSearchable && QUICK_SEARCHABLE_FIELD_TYPES.indexOf(field.type) > -1) {
|
|
25139
|
+
return true;
|
|
25140
|
+
}
|
|
25141
|
+
return false;
|
|
25142
|
+
}
|
|
25143
|
+
|
|
25144
|
+
/******************************************************************************
|
|
25145
|
+
Copyright (c) Microsoft Corporation.
|
|
25146
|
+
|
|
25147
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
25148
|
+
purpose with or without fee is hereby granted.
|
|
25149
|
+
|
|
25150
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
25151
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
25152
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
25153
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
25154
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
25155
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
25156
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
25157
|
+
***************************************************************************** */
|
|
25158
|
+
|
|
25159
|
+
var __assign = function() {
|
|
25160
|
+
__assign = Object.assign || function __assign(t) {
|
|
25161
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
25162
|
+
s = arguments[i];
|
|
25163
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
25164
|
+
}
|
|
25165
|
+
return t;
|
|
25166
|
+
};
|
|
25167
|
+
return __assign.apply(this, arguments);
|
|
25168
|
+
};
|
|
25169
|
+
|
|
25170
|
+
// 方便取值的时候能够把上层的取到,但是获取的时候不会全部把所有的数据获取到。
|
|
25171
|
+
function createObject(superProps, props, properties) {
|
|
25172
|
+
if (superProps && Object.isFrozen(superProps)) {
|
|
25173
|
+
superProps = cloneObject(superProps);
|
|
25174
|
+
}
|
|
25175
|
+
var obj = superProps
|
|
25176
|
+
? Object.create(superProps, __assign(__assign({}, properties), { __super: {
|
|
25177
|
+
value: superProps,
|
|
25178
|
+
writable: false,
|
|
25179
|
+
enumerable: false
|
|
25180
|
+
} }))
|
|
25181
|
+
: Object.create(Object.prototype, properties);
|
|
25182
|
+
props &&
|
|
25183
|
+
isObject(props) &&
|
|
25184
|
+
Object.keys(props).forEach(function (key) { return (obj[key] = props[key]); });
|
|
25185
|
+
return obj;
|
|
25186
|
+
}
|
|
25187
|
+
function cloneObject(target, persistOwnProps) {
|
|
25188
|
+
if (persistOwnProps === void 0) { persistOwnProps = true; }
|
|
25189
|
+
var obj = target && target.__super
|
|
25190
|
+
? Object.create(target.__super, {
|
|
25191
|
+
__super: {
|
|
25192
|
+
value: target.__super,
|
|
25193
|
+
writable: false,
|
|
25194
|
+
enumerable: false
|
|
25087
25195
|
}
|
|
25088
|
-
|
|
25089
|
-
|
|
25090
|
-
|
|
25091
|
-
|
|
25092
|
-
|
|
25093
|
-
|
|
25094
|
-
|
|
25196
|
+
})
|
|
25197
|
+
: Object.create(Object.prototype);
|
|
25198
|
+
persistOwnProps &&
|
|
25199
|
+
target &&
|
|
25200
|
+
Object.keys(target).forEach(function (key) { return (obj[key] = target[key]); });
|
|
25201
|
+
return obj;
|
|
25202
|
+
}
|
|
25203
|
+
function isObject(obj) {
|
|
25204
|
+
var typename = typeof obj;
|
|
25205
|
+
return (obj &&
|
|
25206
|
+
typename !== 'string' &&
|
|
25207
|
+
typename !== 'number' &&
|
|
25208
|
+
typename !== 'boolean' &&
|
|
25209
|
+
typename !== 'function' &&
|
|
25210
|
+
!Array.isArray(obj));
|
|
25211
|
+
}
|
|
25212
|
+
|
|
25213
|
+
/*
|
|
25214
|
+
* @Author: baozhoutao@steedos.com
|
|
25215
|
+
* @Date: 2022-07-05 15:55:39
|
|
25216
|
+
* @LastEditors: liaodaxue
|
|
25217
|
+
* @LastEditTime: 2023-10-20 11:38:25
|
|
25218
|
+
* @Description:
|
|
25219
|
+
*/
|
|
25220
|
+
|
|
25221
|
+
let UI_SCHEMA_CACHE = {};
|
|
25222
|
+
|
|
25223
|
+
let UISchemaFunction;
|
|
25224
|
+
|
|
25225
|
+
if('undefined' != typeof window){
|
|
25226
|
+
if(!window.UI_SCHEMA_CACHE){
|
|
25227
|
+
window.UI_SCHEMA_CACHE = UI_SCHEMA_CACHE;
|
|
25228
|
+
}
|
|
25229
|
+
UI_SCHEMA_CACHE = window.UI_SCHEMA_CACHE;
|
|
25230
|
+
}
|
|
25231
|
+
|
|
25232
|
+
const setUISchemaCache = (key, value) => {
|
|
25233
|
+
UI_SCHEMA_CACHE[key] = value;
|
|
25234
|
+
};
|
|
25235
|
+
|
|
25236
|
+
const getUISchemaCache = (key) => {
|
|
25237
|
+
return lodash.exports.cloneDeep(UI_SCHEMA_CACHE[key]);
|
|
25238
|
+
};
|
|
25239
|
+
|
|
25240
|
+
const hasUISchemaCache = (key) => {
|
|
25241
|
+
return lodash.exports.has(UI_SCHEMA_CACHE, key);
|
|
25242
|
+
};
|
|
25243
|
+
|
|
25244
|
+
function getListViewColumns(listView, formFactor) {
|
|
25245
|
+
let listViewColumns = [];
|
|
25246
|
+
if (formFactor === "SMALL") {
|
|
25247
|
+
listViewColumns = !lodash.exports.isEmpty(listView.mobile_columns)
|
|
25248
|
+
? listView.mobile_columns
|
|
25249
|
+
: lodash.exports.slice(listView.columns, 0, 4);
|
|
25250
|
+
} else {
|
|
25251
|
+
listViewColumns = listView.columns;
|
|
25252
|
+
}
|
|
25253
|
+
return listViewColumns;
|
|
25254
|
+
}
|
|
25255
|
+
function getListViewSort(listView) {
|
|
25256
|
+
let sort = '';
|
|
25257
|
+
if(listView && listView.sort && listView.sort.length){
|
|
25258
|
+
lodash.exports.each(listView.sort,function(item,index){
|
|
25259
|
+
if(lodash.exports.isArray(item)){
|
|
25260
|
+
const field_name = item[0];
|
|
25261
|
+
const order = item[1] || '';
|
|
25262
|
+
let sortStr = field_name + ' ' + order;
|
|
25263
|
+
sortStr = index > 0 ? ','+sortStr : sortStr;
|
|
25264
|
+
sort += sortStr;
|
|
25265
|
+
}else {
|
|
25266
|
+
let sortStr = item.field_name + ' ' + item.order;
|
|
25267
|
+
sortStr = index > 0 ? ','+sortStr : sortStr;
|
|
25268
|
+
sort += sortStr;
|
|
25095
25269
|
}
|
|
25096
|
-
|
|
25097
|
-
|
|
25098
|
-
|
|
25099
|
-
|
|
25100
|
-
|
|
25101
|
-
|
|
25102
|
-
|
|
25103
|
-
|
|
25104
|
-
|
|
25105
|
-
|
|
25106
|
-
|
|
25107
|
-
|
|
25108
|
-
|
|
25109
|
-
|
|
25110
|
-
|
|
25111
|
-
|
|
25112
|
-
|
|
25113
|
-
|
|
25114
|
-
break;
|
|
25115
|
-
case 'grid':
|
|
25116
|
-
if(field.subFields){
|
|
25117
|
-
convertData = {
|
|
25118
|
-
type: 'input-table',
|
|
25119
|
-
showIndex: true,
|
|
25120
|
-
columnsTogglable: false,
|
|
25121
|
-
strictMode:false,
|
|
25122
|
-
affixHeader: false, // 是否固定表头, 不固定表头, 否则form有y轴滚动条时, 表头会跟随滚动条滚动.
|
|
25123
|
-
needConfirm: false,
|
|
25124
|
-
editable: !readonly,
|
|
25125
|
-
addable: !readonly,
|
|
25126
|
-
removable: !readonly,
|
|
25127
|
-
draggable: !readonly,
|
|
25128
|
-
columns: []
|
|
25129
|
-
};
|
|
25130
|
-
// console.log(`convertData ==2====>`, field, convertData)
|
|
25131
|
-
for (const subField of field.subFields) {
|
|
25132
|
-
const subFieldName = subField.name.replace(`${field._prefix || ''}${field.name}.$.`, '').replace(`${field.name}.`, '');
|
|
25133
|
-
const gridSub = await convertSFieldToAmisField(Object.assign({}, subField, {name: subFieldName, isTableField: true}), readonly, ctx);
|
|
25134
|
-
if(gridSub){
|
|
25135
|
-
delete gridSub.name;
|
|
25136
|
-
delete gridSub.label;
|
|
25137
|
-
const gridItemSchema = {
|
|
25138
|
-
name: subFieldName,
|
|
25139
|
-
label: subField.label,
|
|
25140
|
-
quickEdit: readonly ? false : gridSub
|
|
25141
|
-
};
|
|
25142
|
-
if(["lookup", "boolean", "toggle"].indexOf(subField.type) > -1){
|
|
25143
|
-
gridItemSchema.type = gridSub.type;
|
|
25144
|
-
gridItemSchema.tpl = gridSub.tpl;
|
|
25145
|
-
}
|
|
25146
|
-
convertData.columns.push(Object.assign({}, gridItemSchema, subField.amis, {name: subFieldName}));
|
|
25147
|
-
}
|
|
25270
|
+
});
|
|
25271
|
+
}
|
|
25272
|
+
return sort;
|
|
25273
|
+
}
|
|
25274
|
+
function getListViewFilter(listView){
|
|
25275
|
+
if(!listView){
|
|
25276
|
+
return ;
|
|
25277
|
+
}
|
|
25278
|
+
try {
|
|
25279
|
+
const userId = getUserId();
|
|
25280
|
+
let filters = listView.filters;
|
|
25281
|
+
if(listView.filter_scope === 'mine'){
|
|
25282
|
+
if(___default.isEmpty(filters)){
|
|
25283
|
+
filters = [["owner", "=", userId]];
|
|
25284
|
+
}else {
|
|
25285
|
+
if(___default.isString(filters) && ___default.startsWith(___default.trim(filters), "function")){
|
|
25286
|
+
filters = new Function(`return ${filters}`);
|
|
25287
|
+
filters = filters();
|
|
25148
25288
|
}
|
|
25149
|
-
|
|
25150
|
-
|
|
25151
|
-
|
|
25152
|
-
|
|
25153
|
-
|
|
25154
|
-
type: 'combo',
|
|
25155
|
-
items: []
|
|
25156
|
-
};
|
|
25157
|
-
// console.log(`convertData ======>`, field, convertData)
|
|
25158
|
-
for (let subField of field.subFields) {
|
|
25159
|
-
let subFieldName = subField.name.replace(`${field.name}.$.`, '').replace(`${field.name}.`, '');
|
|
25160
|
-
if(subField.type === 'grid'){
|
|
25161
|
-
subField = await getGridFieldSubFields(subField, ctx.__formFields);
|
|
25162
|
-
}else {
|
|
25163
|
-
if(readonly){
|
|
25164
|
-
subFieldName = `${field.name}.${subFieldName}`;
|
|
25165
|
-
}
|
|
25166
|
-
}
|
|
25167
|
-
const gridSub = await convertSFieldToAmisField(Object.assign({}, subField, {name: subFieldName}), readonly, ctx);
|
|
25168
|
-
if(gridSub){
|
|
25169
|
-
delete gridSub.name;
|
|
25170
|
-
delete gridSub.label;
|
|
25171
|
-
convertData.items.push(
|
|
25172
|
-
Object.assign({}, gridSub, {label: subField.label}, subField.amis, {
|
|
25173
|
-
name: subFieldName
|
|
25174
|
-
})
|
|
25175
|
-
);
|
|
25176
|
-
}
|
|
25289
|
+
if(___default.isArray(filters)){
|
|
25290
|
+
filters.push(["owner", "=", userId]);
|
|
25291
|
+
}else {
|
|
25292
|
+
console.debug(`listView filters is not array`, listView);
|
|
25293
|
+
throw new Error('filters is not array')
|
|
25177
25294
|
}
|
|
25178
25295
|
}
|
|
25179
|
-
|
|
25296
|
+
};
|
|
25297
|
+
return filters;
|
|
25298
|
+
} catch (error) {
|
|
25299
|
+
console.error(error);
|
|
25300
|
+
}
|
|
25301
|
+
}
|
|
25302
|
+
|
|
25303
|
+
function formatUISchemaCache(objectName, uiSchema){
|
|
25304
|
+
setUISchemaCache(objectName, uiSchema);
|
|
25305
|
+
lodash.exports.each(uiSchema.fields, (field)=>{
|
|
25306
|
+
try {
|
|
25307
|
+
if(field.type === "lookup" && field._reference_to && ___default.isString(field._reference_to)){
|
|
25308
|
+
field.reference_to = eval(`(${field._reference_to})`)();
|
|
25309
|
+
}
|
|
25310
|
+
} catch (exception) {
|
|
25311
|
+
field.reference_to = undefined;
|
|
25312
|
+
console.error(exception);
|
|
25313
|
+
}
|
|
25314
|
+
});
|
|
25315
|
+
lodash.exports.each(uiSchema.list_views, (v, k)=>{
|
|
25316
|
+
v.name = k;
|
|
25317
|
+
if(!lodash.exports.has(v, 'columns')){
|
|
25318
|
+
v.columns = uiSchema.list_views.all.columns;
|
|
25319
|
+
}
|
|
25320
|
+
});
|
|
25321
|
+
}
|
|
25322
|
+
|
|
25323
|
+
async function getUISchema(objectName, force) {
|
|
25324
|
+
if (!objectName) {
|
|
25325
|
+
return;
|
|
25326
|
+
}
|
|
25327
|
+
if (hasUISchemaCache(objectName) && !force) {
|
|
25328
|
+
return getUISchemaCache(objectName);
|
|
25329
|
+
}
|
|
25330
|
+
let uiSchema = null;
|
|
25331
|
+
try {
|
|
25332
|
+
if(UISchemaFunction);
|
|
25333
|
+
else {
|
|
25334
|
+
const url = `/service/api/@${objectName.replace(/\./g, "_")}/uiSchema`;
|
|
25335
|
+
uiSchema = await fetchAPI(url, { method: "get" });
|
|
25336
|
+
}
|
|
25337
|
+
if(!uiSchema){
|
|
25338
|
+
return ;
|
|
25339
|
+
}
|
|
25340
|
+
formatUISchemaCache(objectName, uiSchema);
|
|
25341
|
+
} catch (error) {
|
|
25342
|
+
console.error(`getUISchema`, objectName, error);
|
|
25343
|
+
setUISchemaCache(objectName, null);
|
|
25344
|
+
}
|
|
25345
|
+
return getUISchemaCache(objectName);
|
|
25346
|
+
}
|
|
25347
|
+
|
|
25348
|
+
function getUISchemaSync(objectName, force) {
|
|
25349
|
+
if (!objectName) {
|
|
25350
|
+
return;
|
|
25180
25351
|
}
|
|
25181
|
-
if(
|
|
25182
|
-
|
|
25183
|
-
|
|
25184
|
-
|
|
25185
|
-
|
|
25186
|
-
|
|
25187
|
-
|
|
25188
|
-
|
|
25352
|
+
if (hasUISchemaCache(objectName) && !force) {
|
|
25353
|
+
return getUISchemaCache(objectName);
|
|
25354
|
+
}
|
|
25355
|
+
let uiSchema = null;
|
|
25356
|
+
try {
|
|
25357
|
+
|
|
25358
|
+
const url = `/service/api/@${objectName.replace(/\./g, "_")}/uiSchema`;
|
|
25359
|
+
uiSchema = Steedos.authRequest(url, {
|
|
25360
|
+
type: 'GET',
|
|
25361
|
+
async: false,
|
|
25362
|
+
});
|
|
25363
|
+
|
|
25364
|
+
if(!uiSchema){
|
|
25365
|
+
return ;
|
|
25189
25366
|
}
|
|
25190
|
-
|
|
25191
|
-
|
|
25367
|
+
formatUISchemaCache(objectName, uiSchema);
|
|
25368
|
+
} catch (error) {
|
|
25369
|
+
console.error(`getUISchema`, objectName, error);
|
|
25370
|
+
setUISchemaCache(objectName, null);
|
|
25371
|
+
}
|
|
25372
|
+
return getUISchemaCache(objectName);
|
|
25373
|
+
}
|
|
25374
|
+
|
|
25375
|
+
// 获取列表视图
|
|
25376
|
+
async function getListSchema(
|
|
25377
|
+
appName,
|
|
25378
|
+
objectName,
|
|
25379
|
+
listViewName,
|
|
25380
|
+
ctx = {}
|
|
25381
|
+
) {
|
|
25382
|
+
const uiSchema = await getUISchema(objectName);
|
|
25383
|
+
if(!uiSchema){
|
|
25384
|
+
return {}
|
|
25385
|
+
}
|
|
25386
|
+
const listView = lodash.exports.find(
|
|
25387
|
+
uiSchema.list_views,
|
|
25388
|
+
(listView, name) => {
|
|
25389
|
+
// 传入listViewName空值则取第一个
|
|
25390
|
+
if(!listViewName){
|
|
25391
|
+
listViewName = name;
|
|
25392
|
+
}
|
|
25393
|
+
return name === listViewName || listView._id === listViewName;
|
|
25192
25394
|
}
|
|
25395
|
+
);
|
|
25193
25396
|
|
|
25194
|
-
|
|
25195
|
-
|
|
25196
|
-
|
|
25197
|
-
|
|
25198
|
-
|
|
25397
|
+
if (!listView) {
|
|
25398
|
+
return { uiSchema };
|
|
25399
|
+
}
|
|
25400
|
+
|
|
25401
|
+
// 直接返回自定义的列表视图schema
|
|
25402
|
+
if(listView.enable_amis_schema && listView.amis_schema){
|
|
25403
|
+
const amisSchema = lodash.exports.isString(listView.amis_schema) ? JSON.parse(listView.amis_schema) : listView.amis_schema;
|
|
25404
|
+
return {
|
|
25405
|
+
uiSchema,
|
|
25406
|
+
isCustomAmisSchema: true,
|
|
25407
|
+
amisSchema
|
|
25408
|
+
};
|
|
25409
|
+
}
|
|
25410
|
+
|
|
25411
|
+
let listViewColumns = getListViewColumns(listView, ctx.formFactor);
|
|
25412
|
+
let sort = getListViewSort(listView);
|
|
25413
|
+
let listviewFilter = getListViewFilter(listView);
|
|
25414
|
+
let listview_filters = listView && listView._filters;
|
|
25415
|
+
// 返回 calendar 组件
|
|
25416
|
+
if(listView.type === "calendar"){
|
|
25417
|
+
const amisSchema = {
|
|
25418
|
+
"type": "steedos-object-calendar",
|
|
25419
|
+
"objectApiName": objectName,
|
|
25420
|
+
"filters": listviewFilter,
|
|
25421
|
+
"filtersFunction": listview_filters,
|
|
25422
|
+
"sort": sort,
|
|
25423
|
+
...listView.options
|
|
25424
|
+
};
|
|
25425
|
+
return {
|
|
25426
|
+
uiSchema,
|
|
25427
|
+
isCalendar: true,
|
|
25428
|
+
amisSchema
|
|
25429
|
+
};
|
|
25430
|
+
}
|
|
25431
|
+
|
|
25432
|
+
const defaults = ctx.defaults || {};
|
|
25433
|
+
|
|
25434
|
+
// // 未自定义header 且显示header的时候, 使用系统header
|
|
25435
|
+
// if(!defaults.headerSchema && ctx.showHeader){
|
|
25436
|
+
// defaults.headerSchema = getObjectListHeader(uiSchema, listViewName);
|
|
25437
|
+
// }
|
|
25438
|
+
|
|
25439
|
+
// // 如果不显示header,则清理掉
|
|
25440
|
+
// if(!ctx.showHeader){
|
|
25441
|
+
// defaults.headerSchema = null;
|
|
25442
|
+
// }
|
|
25443
|
+
|
|
25444
|
+
defaults.headerSchema = null;
|
|
25445
|
+
|
|
25446
|
+
/**
|
|
25447
|
+
* 本次存储代码段
|
|
25448
|
+
*/
|
|
25449
|
+
try {
|
|
25450
|
+
const listViewPropsStoreKey = location.pathname + "/crud";
|
|
25451
|
+
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
25452
|
+
/**
|
|
25453
|
+
* localListViewProps规范来自crud请求api中api.data.$self参数值的。
|
|
25454
|
+
* 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
|
|
25455
|
+
* __searchable__...:顶部放大镜搜索条件
|
|
25456
|
+
* filter:右侧过滤器
|
|
25457
|
+
* perPage:每页条数
|
|
25458
|
+
* page:当前页码
|
|
25459
|
+
* orderBy:排序字段
|
|
25460
|
+
* orderDir:排序方向
|
|
25461
|
+
*/
|
|
25462
|
+
if (localListViewProps) {
|
|
25463
|
+
localListViewProps = JSON.parse(localListViewProps);
|
|
25464
|
+
// localListViewProps.perPage = 3;
|
|
25465
|
+
let listSchema = {};
|
|
25466
|
+
if(localListViewProps.orderBy){
|
|
25467
|
+
listSchema.orderBy = localListViewProps.orderBy;
|
|
25468
|
+
}
|
|
25469
|
+
if(localListViewProps.orderDir){
|
|
25470
|
+
listSchema.orderDir = localListViewProps.orderDir;
|
|
25199
25471
|
}
|
|
25200
25472
|
|
|
25201
|
-
if(
|
|
25202
|
-
|
|
25203
|
-
|
|
25204
|
-
|
|
25205
|
-
}else {
|
|
25206
|
-
convertData.visibleOn = `${field.visible_on.replace(/formData./g, 'data.')}`;
|
|
25207
|
-
}
|
|
25473
|
+
if(localListViewProps.perPage){
|
|
25474
|
+
listSchema.defaultParams = {
|
|
25475
|
+
perPage: localListViewProps.perPage
|
|
25476
|
+
};
|
|
25208
25477
|
}
|
|
25478
|
+
defaults.listSchema = lodash.exports.defaultsDeep({}, listSchema, defaults.listSchema || {});
|
|
25479
|
+
}
|
|
25480
|
+
}
|
|
25481
|
+
catch (ex) {
|
|
25482
|
+
console.error("本地存储中crud参数解析异常:", ex);
|
|
25483
|
+
}
|
|
25209
25484
|
|
|
25210
|
-
|
|
25211
|
-
|
|
25212
|
-
|
|
25213
|
-
|
|
25214
|
-
|
|
25485
|
+
ctx.defaults = defaults;
|
|
25486
|
+
|
|
25487
|
+
if (listViewName == "recent") {
|
|
25488
|
+
listview_filters = `
|
|
25489
|
+
function(filters, data) {
|
|
25490
|
+
var result = Steedos.authRequest('/graphql', {
|
|
25491
|
+
type: 'POST',
|
|
25492
|
+
async: false,
|
|
25493
|
+
data: JSON.stringify({
|
|
25494
|
+
query: '{object_recent_viewed(filters: [["record.o","=","' + data.objectName + '"],["space","=","' + data.context.tenantId + '"],["owner","=","' + data.context.userId + '"]],sort:"modified desc",top:50){ _id,record} }'
|
|
25495
|
+
}),
|
|
25496
|
+
});
|
|
25497
|
+
var _ids = []
|
|
25498
|
+
result.data.object_recent_viewed.forEach(function (item) {
|
|
25499
|
+
_ids = _ids.concat(item.record.ids)
|
|
25500
|
+
})
|
|
25501
|
+
return ["_id", "=", _ids];
|
|
25215
25502
|
}
|
|
25503
|
+
`;
|
|
25504
|
+
}
|
|
25505
|
+
const amisSchema = {
|
|
25506
|
+
"type": "steedos-object-table",
|
|
25507
|
+
"objectApiName": objectName,
|
|
25508
|
+
"columns": listViewColumns,
|
|
25509
|
+
"extraColumns": listView.extra_columns,
|
|
25510
|
+
"filters": listviewFilter,
|
|
25511
|
+
"filtersFunction": listview_filters,
|
|
25512
|
+
"sort": sort,
|
|
25513
|
+
"ctx": ctx,
|
|
25514
|
+
"requestAdaptor": listView.requestAdaptor || ctx.requestAdaptor,
|
|
25515
|
+
"adaptor": listView.adaptor || ctx.adaptor,
|
|
25516
|
+
"headerToolbarItems": ctx.headerToolbarItems,
|
|
25517
|
+
"filterVisible": ctx.filterVisible,
|
|
25518
|
+
"rowClassNameExpr": ctx.rowClassNameExpr,
|
|
25519
|
+
"crudDataFilter": ctx.crudDataFilter,
|
|
25520
|
+
"onCrudDataFilter": ctx.onCrudDataFilter
|
|
25521
|
+
};
|
|
25522
|
+
// console.log(`getListSchema===>`,amisSchema)
|
|
25523
|
+
return {
|
|
25524
|
+
uiSchema,
|
|
25525
|
+
amisSchema,
|
|
25526
|
+
};
|
|
25527
|
+
}
|
|
25216
25528
|
|
|
25217
|
-
|
|
25218
|
-
|
|
25219
|
-
|
|
25529
|
+
|
|
25530
|
+
if(typeof window != 'undefined'){
|
|
25531
|
+
window.getUISchema = getUISchema;
|
|
25532
|
+
window.getUISchemaSync = getUISchemaSync;
|
|
25533
|
+
window.getListSchema = getListSchema;
|
|
25534
|
+
}
|
|
25535
|
+
|
|
25536
|
+
function getNumberTpl(field){
|
|
25537
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
25538
|
+
}
|
|
25539
|
+
|
|
25540
|
+
function getTimeTpl(field){
|
|
25541
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
25542
|
+
}
|
|
25543
|
+
|
|
25544
|
+
function getDateTpl(field){
|
|
25545
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
25546
|
+
}
|
|
25547
|
+
|
|
25548
|
+
|
|
25549
|
+
function getDateTimeTpl(field){
|
|
25550
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
25551
|
+
}
|
|
25552
|
+
|
|
25553
|
+
function getUiFieldTpl(field){
|
|
25554
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
25555
|
+
}
|
|
25556
|
+
|
|
25557
|
+
function getUiFileSizeTpl(field){
|
|
25558
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
25559
|
+
}
|
|
25560
|
+
|
|
25561
|
+
//TODO 处理name字段
|
|
25562
|
+
async function getRefObjectNameFieldName(field){
|
|
25563
|
+
const refUiSchema = await getUISchema(field.reference_to);
|
|
25564
|
+
const NAME_FIELD_KEY = refUiSchema.NAME_FIELD_KEY || 'name';
|
|
25565
|
+
return NAME_FIELD_KEY;
|
|
25566
|
+
}
|
|
25567
|
+
|
|
25568
|
+
function getSelectTpl(field){
|
|
25569
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
25570
|
+
}
|
|
25571
|
+
function getSelectMap(selectOptions){
|
|
25572
|
+
let map = {};
|
|
25573
|
+
lodash.exports.forEach(selectOptions,(option)=>{
|
|
25574
|
+
const optionValue = option.value + '';
|
|
25575
|
+
const optionColor = option.color + '';
|
|
25576
|
+
if(optionColor){
|
|
25577
|
+
const background = optionColor.charAt(0) === '#' ? optionColor : '#'+optionColor;
|
|
25578
|
+
const color = getContrastColor(background);
|
|
25579
|
+
const optionColorStyle = 'background:'+background+';color:'+color+';line-height:1.5rem';
|
|
25580
|
+
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
25581
|
+
}else {
|
|
25582
|
+
map[optionValue] = option.label;
|
|
25220
25583
|
}
|
|
25221
|
-
|
|
25222
|
-
|
|
25223
|
-
// }else{
|
|
25224
|
-
// return Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name});
|
|
25225
|
-
// }
|
|
25226
|
-
}
|
|
25227
|
-
|
|
25584
|
+
});
|
|
25585
|
+
return map;
|
|
25228
25586
|
}
|
|
25229
25587
|
|
|
25230
|
-
|
|
25231
|
-
if(
|
|
25232
|
-
|
|
25588
|
+
function getNameTplUrl(field, ctx){
|
|
25589
|
+
if(ctx.objectName === 'cms_files'){
|
|
25590
|
+
return `\${context.rootUrl}/api/files/files/\${versions[0]}?download=true`
|
|
25233
25591
|
}
|
|
25234
|
-
|
|
25235
|
-
|
|
25236
|
-
|
|
25237
|
-
|
|
25238
|
-
|
|
25592
|
+
const href = Router.getObjectDetailPath({
|
|
25593
|
+
...ctx, formFactor: ctx.formFactor, appId: "${appId}", objectName: ctx.objectName || "${objectName}", recordId: `\${${ctx.idFieldName}}`
|
|
25594
|
+
});
|
|
25595
|
+
return href;
|
|
25596
|
+
}
|
|
25597
|
+
|
|
25598
|
+
function getNameTpl(field, ctx){
|
|
25599
|
+
const href = getNameTplUrl(field, ctx);
|
|
25600
|
+
let linkTarget = "";
|
|
25601
|
+
if(ctx && ctx.isLookup){
|
|
25602
|
+
linkTarget = "target='_blank'";
|
|
25239
25603
|
}
|
|
25604
|
+
return `<a href="${href}" ${linkTarget}>\${${field.name}}</a>`
|
|
25605
|
+
}
|
|
25240
25606
|
|
|
25241
|
-
|
|
25242
|
-
|
|
25243
|
-
|
|
25244
|
-
if(
|
|
25245
|
-
|
|
25607
|
+
function getRelatedFieldTpl(field, ctx){
|
|
25608
|
+
let tpl = '';
|
|
25609
|
+
if(!field.reference_to && (field.optionsFunction || field._optionsFunction || field.options)){
|
|
25610
|
+
if(field.isTableField){
|
|
25611
|
+
return `\${${field.name}}`
|
|
25612
|
+
}else {
|
|
25613
|
+
return `\${${field.name}__label}`
|
|
25246
25614
|
}
|
|
25615
|
+
}
|
|
25247
25616
|
|
|
25248
|
-
|
|
25249
|
-
|
|
25250
|
-
|
|
25251
|
-
|
|
25252
|
-
}
|
|
25253
|
-
else if(field.type === "select" && field.data_type && field.data_type != "text"){
|
|
25254
|
-
_field.type = field.data_type;
|
|
25255
|
-
}
|
|
25617
|
+
let linkTarget = "";
|
|
25618
|
+
if(ctx && ctx.isLookup){
|
|
25619
|
+
linkTarget = "target='_blank'";
|
|
25620
|
+
}
|
|
25256
25621
|
|
|
25257
|
-
|
|
25258
|
-
_field.type = 'input-array';
|
|
25259
|
-
_field.inline = true;
|
|
25260
|
-
_field.addable = false;
|
|
25261
|
-
_field.removable = false;
|
|
25262
|
-
_field.value = [null,null];
|
|
25263
|
-
_field.items = {
|
|
25264
|
-
type: "input-number"
|
|
25265
|
-
};
|
|
25266
|
-
_field.is_wide = true;
|
|
25267
|
-
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
25268
|
-
}
|
|
25622
|
+
const onlyDisplayLookLabel = ctx.onlyDisplayLookLabel;
|
|
25269
25623
|
|
|
25270
|
-
|
|
25271
|
-
_field.type = 'input-date-range';
|
|
25272
|
-
_field.is_wide = true;
|
|
25273
|
-
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
25274
|
-
}
|
|
25275
|
-
if(_field.type === 'datetime'){
|
|
25276
|
-
_field.type = 'input-datetime-range';
|
|
25277
|
-
_field.is_wide = true;
|
|
25278
|
-
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
25279
|
-
}
|
|
25280
|
-
if(_field.type === 'time'){
|
|
25281
|
-
_field.type = 'input-time-range';
|
|
25282
|
-
_field.is_wide = true;
|
|
25283
|
-
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
25284
|
-
}
|
|
25285
|
-
if(_field.reference_to === 'users'){
|
|
25286
|
-
_field.reference_to = 'space_users';
|
|
25287
|
-
_field.reference_to_field = 'user';
|
|
25288
|
-
}
|
|
25289
|
-
_field.readonly = false;
|
|
25290
|
-
_field.disabled = false;
|
|
25291
|
-
_field.multiple = true;
|
|
25292
|
-
_field.is_wide = false;
|
|
25293
|
-
_field.defaultValue = undefined;
|
|
25294
|
-
_field.required = false;
|
|
25295
|
-
_field.hidden = false;
|
|
25296
|
-
_field.omit = false;
|
|
25624
|
+
let fieldDataStrTpl = `data._display.${field.name}`;
|
|
25297
25625
|
|
|
25298
|
-
|
|
25299
|
-
|
|
25300
|
-
|
|
25301
|
-
|
|
25302
|
-
|
|
25303
|
-
|
|
25304
|
-
|
|
25305
|
-
|
|
25306
|
-
|
|
25307
|
-
|
|
25308
|
-
|
|
25309
|
-
|
|
25626
|
+
if(field.isTableField){
|
|
25627
|
+
fieldDataStrTpl = `data.${field.name}`;
|
|
25628
|
+
}
|
|
25629
|
+
|
|
25630
|
+
if(_.isString(field.reference_to) || !field.reference_to){
|
|
25631
|
+
if(field.multiple){
|
|
25632
|
+
let labelTpl = `<%=item.label%>`;
|
|
25633
|
+
if(!onlyDisplayLookLabel){
|
|
25634
|
+
const href = Router.getObjectDetailPath({
|
|
25635
|
+
formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
|
|
25636
|
+
});
|
|
25637
|
+
labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
|
|
25638
|
+
}
|
|
25639
|
+
tpl = `
|
|
25640
|
+
<% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item,index) { %> <% if(index>0 && index<${fieldDataStrTpl}.length){ %> , <% } %> ${labelTpl} <% }); %><% } %>
|
|
25641
|
+
`;
|
|
25642
|
+
}else {
|
|
25643
|
+
let labelTpl = `\${_display.${field.name}.label}`;
|
|
25644
|
+
let objectNameTpl = `\${_display.${field.name}.objectName}`;
|
|
25645
|
+
let recordIdTpl = `\${_display.${field.name}.value}`;
|
|
25646
|
+
if(field.isTableField){
|
|
25647
|
+
labelTpl = `\${${field.name}.label}`;
|
|
25648
|
+
objectNameTpl = `\${${field.name}.objectName}`;
|
|
25649
|
+
recordIdTpl = `\${${field.name}.value}`;
|
|
25650
|
+
}
|
|
25651
|
+
if(!onlyDisplayLookLabel){
|
|
25652
|
+
const href = Router.getObjectDetailPath({
|
|
25653
|
+
formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
|
|
25654
|
+
});
|
|
25655
|
+
labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
|
|
25656
|
+
}
|
|
25657
|
+
tpl = labelTpl;
|
|
25310
25658
|
}
|
|
25311
25659
|
|
|
25312
|
-
|
|
25313
|
-
|
|
25314
|
-
|
|
25315
|
-
|
|
25660
|
+
|
|
25661
|
+
}else {
|
|
25662
|
+
let labelTpl = `<%=item.label%>`;
|
|
25663
|
+
if(!onlyDisplayLookLabel){
|
|
25664
|
+
const href = Router.getObjectDetailPath({
|
|
25665
|
+
formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
|
|
25316
25666
|
});
|
|
25667
|
+
labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
|
|
25317
25668
|
}
|
|
25669
|
+
tpl = `
|
|
25670
|
+
<% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item) { %> ${labelTpl} <% }); %><% } %>
|
|
25671
|
+
`;
|
|
25318
25672
|
}
|
|
25673
|
+
return tpl
|
|
25319
25674
|
}
|
|
25320
25675
|
|
|
25321
|
-
|
|
25322
|
-
|
|
25676
|
+
async function getLookupTpl(field, ctx){
|
|
25677
|
+
if(!field.reference_to){
|
|
25678
|
+
return getSelectTpl(field)
|
|
25679
|
+
}
|
|
25680
|
+
const NAME_FIELD_KEY = await getRefObjectNameFieldName(field);
|
|
25681
|
+
if(field.multiple){
|
|
25682
|
+
const href = Router.getObjectDetailPath({
|
|
25683
|
+
formFactor: ctx.formFactor, appId: ctx.appId, objectName: field.reference_to, recordId: `<%=item._id%>`, _templateType: "JavaScript"
|
|
25684
|
+
});
|
|
25685
|
+
return `
|
|
25686
|
+
<% if (data.${field.name} && data.${field.name}.length) { %><% data.${field.name}.forEach(function(item) { %> <a href="${href}"><%=item.${NAME_FIELD_KEY}%></a> <% }); %><% } %>
|
|
25687
|
+
`
|
|
25688
|
+
}else {
|
|
25689
|
+
const href = Router.getObjectDetailPath({
|
|
25690
|
+
formFactor: ctx.formFactor, appId: ctx.appId, objectName: field.reference_to, recordId: `\${${field.name}._id}`
|
|
25691
|
+
});
|
|
25692
|
+
return `<a href="${href}">\${${field.name}.${NAME_FIELD_KEY}}</a>`
|
|
25693
|
+
}
|
|
25694
|
+
|
|
25323
25695
|
}
|
|
25324
25696
|
|
|
25325
|
-
|
|
25326
|
-
|
|
25327
|
-
|
|
25328
|
-
|
|
25329
|
-
|
|
25330
|
-
|
|
25331
|
-
|
|
25332
|
-
|
|
25333
|
-
|
|
25334
|
-
|
|
25335
|
-
"[grid]",
|
|
25336
|
-
"[text]",
|
|
25337
|
-
"audio",
|
|
25338
|
-
"file",
|
|
25339
|
-
],
|
|
25340
|
-
fieldType
|
|
25341
|
-
)
|
|
25697
|
+
function getSwitchTpl(field){
|
|
25698
|
+
let fieldDataStrTpl = `data._display.${field.name}`;
|
|
25699
|
+
if(field.isTableField){
|
|
25700
|
+
fieldDataStrTpl = `data.${field.name}`;
|
|
25701
|
+
}
|
|
25702
|
+
return `<% if (data.${field.name}) { %>
|
|
25703
|
+
<span class="slds-icon_container slds-icon-utility-check slds-current-color" title="<%=${fieldDataStrTpl}%>">
|
|
25704
|
+
<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>
|
|
25705
|
+
</span>
|
|
25706
|
+
<% } %>`
|
|
25342
25707
|
}
|
|
25343
25708
|
|
|
25344
|
-
|
|
25345
|
-
|
|
25709
|
+
function getPasswordTpl(field){
|
|
25710
|
+
return `<% if (data.${field.name}) { %>
|
|
25711
|
+
<span>······</span>
|
|
25712
|
+
<% } %>`
|
|
25346
25713
|
}
|
|
25347
25714
|
|
|
25715
|
+
function getLocationTpl(field){
|
|
25716
|
+
return `\${${field.name} ? ${field.name}.address : ''}`
|
|
25717
|
+
}
|
|
25348
25718
|
|
|
25349
|
-
function
|
|
25350
|
-
|
|
25351
|
-
|
|
25352
|
-
// 对象上名称字段的searchable默认认为是true
|
|
25353
|
-
fieldSearchable = true;
|
|
25719
|
+
async function getFieldTpl (field, options){
|
|
25720
|
+
if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel){
|
|
25721
|
+
return getNameTpl(field, options)
|
|
25354
25722
|
}
|
|
25355
|
-
|
|
25356
|
-
|
|
25723
|
+
switch (field.type) {
|
|
25724
|
+
case 'password':
|
|
25725
|
+
return getPasswordTpl(field);
|
|
25726
|
+
case 'boolean':
|
|
25727
|
+
return getSwitchTpl(field);
|
|
25728
|
+
case 'toggle':
|
|
25729
|
+
return getSwitchTpl(field);
|
|
25730
|
+
case 'select':
|
|
25731
|
+
return getSelectTpl(field);
|
|
25732
|
+
case 'time':
|
|
25733
|
+
return getTimeTpl(field);
|
|
25734
|
+
case 'date':
|
|
25735
|
+
return getDateTpl(field);
|
|
25736
|
+
case 'datetime':
|
|
25737
|
+
return getDateTimeTpl(field);
|
|
25738
|
+
case 'lookup':
|
|
25739
|
+
return await getRelatedFieldTpl(field, options);
|
|
25740
|
+
case 'master_detail':
|
|
25741
|
+
return await getRelatedFieldTpl(field, options);
|
|
25742
|
+
case 'location':
|
|
25743
|
+
return await getLocationTpl(field);
|
|
25744
|
+
case 'number':
|
|
25745
|
+
case 'currency':
|
|
25746
|
+
return await getNumberTpl(field);
|
|
25747
|
+
case 'percent':
|
|
25748
|
+
case 'formula':
|
|
25749
|
+
case 'summary':
|
|
25750
|
+
return getUiFieldTpl(field)
|
|
25751
|
+
case 'filesize':
|
|
25752
|
+
return getUiFileSizeTpl(field)
|
|
25357
25753
|
}
|
|
25358
|
-
return false;
|
|
25359
25754
|
}
|
|
25360
25755
|
|
|
25361
25756
|
/*
|
|
@@ -25808,7 +26203,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
25808
26203
|
|
|
25809
26204
|
async function getTableColumns(fields, options){
|
|
25810
26205
|
const columns = [];
|
|
25811
|
-
if(!options.isLookup){
|
|
26206
|
+
if(!options.isLookup && !options.isInputTable){
|
|
25812
26207
|
//将_display放入crud的columns中,可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
25813
26208
|
columns.push({name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
|
|
25814
26209
|
columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
|
|
@@ -25951,7 +26346,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
25951
26346
|
}
|
|
25952
26347
|
}
|
|
25953
26348
|
// columns.push(getOperation(fields));
|
|
25954
|
-
if(!options.isLookup && !lodash.exports.some(columns, { name: options.labelFieldName })){
|
|
26349
|
+
if(!options.isLookup && !options.isInputTable && !lodash.exports.some(columns, { name: options.labelFieldName })){
|
|
25955
26350
|
// 没有名称字段时显示序号字段为链接,lookup弹出的picker不需要此功能
|
|
25956
26351
|
const href = Router.getObjectDetailPath({
|
|
25957
26352
|
...options, formFactor: options.formFactor, appId: "${appId}", objectName: options.objectName || "${objectName}", recordId: `\${${options.idFieldName}}`
|
|
@@ -26135,624 +26530,232 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
26135
26530
|
"api": {
|
|
26136
26531
|
"url": url,
|
|
26137
26532
|
"method": "get",
|
|
26138
|
-
"headers": {
|
|
26139
|
-
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
26140
|
-
}
|
|
26141
|
-
}
|
|
26142
|
-
},
|
|
26143
|
-
"actionType": "download"
|
|
26144
|
-
}
|
|
26145
|
-
],
|
|
26146
|
-
"weight": 0
|
|
26147
|
-
}
|
|
26148
|
-
}
|
|
26149
|
-
};
|
|
26150
|
-
}
|
|
26151
|
-
|
|
26152
|
-
}
|
|
26153
|
-
|
|
26154
|
-
columns.push(column);
|
|
26155
|
-
|
|
26156
|
-
|
|
26157
|
-
return columns;
|
|
26158
|
-
}
|
|
26159
|
-
|
|
26160
|
-
function getDefaultParams(options){
|
|
26161
|
-
return {
|
|
26162
|
-
perPage: options.top || options.perPage || config.listView.perPage
|
|
26163
|
-
}
|
|
26164
|
-
}
|
|
26165
|
-
|
|
26166
|
-
function getButtonVisibleOn(button){
|
|
26167
|
-
let visible= button.visible;
|
|
26168
|
-
|
|
26169
|
-
if(button._visible){
|
|
26170
|
-
visible = button._visible;
|
|
26171
|
-
}
|
|
26172
|
-
|
|
26173
|
-
if(lodash.exports.isBoolean(visible)){
|
|
26174
|
-
visible = visible.toString();
|
|
26175
|
-
}
|
|
26176
|
-
|
|
26177
|
-
if(visible){
|
|
26178
|
-
// if(visible.indexOf("Meteor.") > 0 || visible.indexOf("Creator.") > 0 || visible.indexOf("Session.") > 0){
|
|
26179
|
-
// console.warn('无效的visible', visible)
|
|
26180
|
-
// return 'false';
|
|
26181
|
-
// }
|
|
26182
|
-
if(visible.trim().startsWith('function')){
|
|
26183
|
-
return `${visible}(objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)`
|
|
26184
|
-
}
|
|
26185
|
-
return visible;
|
|
26186
|
-
}
|
|
26187
|
-
|
|
26188
|
-
if(button.type === 'amis_button'){
|
|
26189
|
-
const amisSchema = button.amis_schema;
|
|
26190
|
-
if(amisSchema && amisSchema.body && amisSchema.body.length > 0){
|
|
26191
|
-
const btn1 = amisSchema.body[0];
|
|
26192
|
-
return btn1.visibleOn
|
|
26193
|
-
}
|
|
26194
|
-
}
|
|
26195
|
-
}
|
|
26196
|
-
|
|
26197
|
-
async function getTableOperation(ctx){
|
|
26198
|
-
const buttons = ctx.buttons;
|
|
26199
|
-
const operationButtons = [];
|
|
26200
|
-
lodash.exports.each(buttons, (button)=>{
|
|
26201
|
-
if(lodash.exports.isBoolean(button.visible)){
|
|
26202
|
-
button.visible = button.visible.toString();
|
|
26203
|
-
}
|
|
26204
|
-
// operationButtons.push({
|
|
26205
|
-
// type: 'button',
|
|
26206
|
-
// label: button.label,
|
|
26207
|
-
// visibleOn: button.visible ? `${button.visible}` : (button._visible ? `${button._visible}` : null),
|
|
26208
|
-
// onEvent: {
|
|
26209
|
-
// click: {
|
|
26210
|
-
// actions: []
|
|
26211
|
-
// }
|
|
26212
|
-
// }
|
|
26213
|
-
// })
|
|
26214
|
-
|
|
26215
|
-
operationButtons.push({
|
|
26216
|
-
type: 'steedos-object-button',
|
|
26217
|
-
name: button.name,
|
|
26218
|
-
objectName: button.objectName,
|
|
26219
|
-
visibleOn: getButtonVisibleOn(button),
|
|
26220
|
-
className: 'antd-Button--default'
|
|
26221
|
-
});
|
|
26222
|
-
});
|
|
26223
|
-
if(operationButtons.length < 1){
|
|
26224
|
-
return ;
|
|
26225
|
-
}
|
|
26226
|
-
return {
|
|
26227
|
-
type: 'operation',
|
|
26228
|
-
label: "",
|
|
26229
|
-
fixed: 'right',
|
|
26230
|
-
labelClassName: 'text-center',
|
|
26231
|
-
className: 'text-center steedos-listview-operation w-10',
|
|
26232
|
-
buttons: [
|
|
26233
|
-
{
|
|
26234
|
-
"type": "steedos-dropdown-button",
|
|
26235
|
-
"label": "xxx",
|
|
26236
|
-
"buttons": operationButtons,
|
|
26237
|
-
"placement": "bottomRight",
|
|
26238
|
-
"overlayClassName": "shadow !min-w-[160px]",
|
|
26239
|
-
"trigger": ["click"],
|
|
26240
|
-
"id": "u:c2140a365019",
|
|
26241
|
-
onOpenApi: {
|
|
26242
|
-
url: `\${context.rootUrl}/service/api/@\${objectName}/recordPermissions/\${_id}`,
|
|
26243
|
-
method: "get",
|
|
26244
|
-
requestAdaptor: "api.data={}; return api;",
|
|
26245
|
-
headers: {
|
|
26246
|
-
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
26247
|
-
},
|
|
26248
|
-
adaptor: `
|
|
26249
|
-
payload = {
|
|
26250
|
-
record: {
|
|
26251
|
-
recordPermissions: payload
|
|
26252
|
-
}
|
|
26253
|
-
};
|
|
26254
|
-
return payload;
|
|
26255
|
-
`,
|
|
26256
|
-
}
|
|
26257
|
-
}
|
|
26258
|
-
]
|
|
26259
|
-
}
|
|
26260
|
-
}
|
|
26261
|
-
|
|
26262
|
-
async function getDefaultCrudCard(columns, options) {
|
|
26263
|
-
let labelFieldName = options?.labelFieldName || "name";
|
|
26264
|
-
let titleColumn, bodyColumns = [];
|
|
26265
|
-
columns.forEach(function (item) {
|
|
26266
|
-
delete item.quickEdit;
|
|
26267
|
-
delete item.width;
|
|
26268
|
-
if (item.name === labelFieldName) {
|
|
26269
|
-
titleColumn = item;
|
|
26270
|
-
}
|
|
26271
|
-
else {
|
|
26272
|
-
if (item.name !== "_index") {
|
|
26273
|
-
bodyColumns.push(item);
|
|
26274
|
-
}
|
|
26275
|
-
}
|
|
26276
|
-
});
|
|
26277
|
-
let card = {
|
|
26278
|
-
"header": {
|
|
26279
|
-
"title": titleColumn.tpl
|
|
26280
|
-
},
|
|
26281
|
-
body: bodyColumns,
|
|
26282
|
-
// useCardLabel: false,
|
|
26283
|
-
toolbar: []
|
|
26284
|
-
};
|
|
26285
|
-
let hideToolbarOperation = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
|
|
26286
|
-
if(!hideToolbarOperation){
|
|
26287
|
-
let toolbarOperation = await getTableOperation(options);
|
|
26288
|
-
if (toolbarOperation) {
|
|
26289
|
-
toolbarOperation.className += " inline-block w-auto";
|
|
26290
|
-
}
|
|
26291
|
-
card.toolbar.push(toolbarOperation);
|
|
26292
|
-
}
|
|
26293
|
-
return card;
|
|
26294
|
-
}
|
|
26295
|
-
|
|
26296
|
-
async function getTableSchema$1(fields, options){
|
|
26297
|
-
if(!options){
|
|
26298
|
-
options = {};
|
|
26299
|
-
}
|
|
26300
|
-
let { isLookup, hiddenColumnOperation } = options;
|
|
26301
|
-
const defaults = options.defaults;
|
|
26302
|
-
const listSchema = (defaults && defaults.listSchema) || {};
|
|
26303
|
-
|
|
26304
|
-
let columns = [];
|
|
26305
|
-
let useMobileColumns = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
|
|
26306
|
-
if(isLookup){
|
|
26307
|
-
// 在lookup手机端列表模式调式好之前不使用getMobileTableColumns
|
|
26308
|
-
useMobileColumns = false;
|
|
26309
|
-
}
|
|
26310
|
-
if(listSchema.mode && listSchema.mode !== "table"){
|
|
26311
|
-
// 如果指定的mode,则不走我们内置的手机端列表效果,使用steedos组件内部开发的默认card/list效果,或者由用户自己实现card/list模式的crud列表
|
|
26312
|
-
useMobileColumns = false;
|
|
26313
|
-
}
|
|
26314
|
-
if(useMobileColumns){
|
|
26315
|
-
columns = await getMobileTableColumns(fields, options);
|
|
26316
|
-
}
|
|
26317
|
-
else {
|
|
26318
|
-
columns = await getTableColumns(fields, options);
|
|
26319
|
-
|
|
26320
|
-
if(listSchema.mode === "cards"){
|
|
26321
|
-
let card = listSchema.card;
|
|
26322
|
-
if(!card){
|
|
26323
|
-
card = await getDefaultCrudCard(columns, options);
|
|
26324
|
-
}
|
|
26325
|
-
return {
|
|
26326
|
-
mode: "cards",
|
|
26327
|
-
perPageAvailable: [5, 10, 20, 50, 100, 500],
|
|
26328
|
-
name: "thelist",
|
|
26329
|
-
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
26330
|
-
className: "",
|
|
26331
|
-
draggable: false,
|
|
26332
|
-
defaultParams: getDefaultParams(options),
|
|
26333
|
-
card: card,
|
|
26334
|
-
syncLocation: false,
|
|
26335
|
-
keepItemSelectionOnPageChange: true,
|
|
26336
|
-
checkOnItemClick: isLookup ? true : false,
|
|
26337
|
-
labelTpl: `\${${options.labelFieldName}}`,
|
|
26338
|
-
autoFillHeight: false, // 自动高度效果不理想,先关闭
|
|
26339
|
-
columnsTogglable: false
|
|
26340
|
-
}
|
|
26341
|
-
}
|
|
26342
|
-
|
|
26343
|
-
if(!isLookup && !hiddenColumnOperation){
|
|
26344
|
-
columns.push(await getTableOperation(options));
|
|
26345
|
-
}
|
|
26346
|
-
}
|
|
26347
|
-
|
|
26348
|
-
return {
|
|
26349
|
-
mode: "table",
|
|
26350
|
-
perPageAvailable: [5, 10, 20, 50, 100, 500],
|
|
26351
|
-
name: "thelist",
|
|
26352
|
-
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
26353
|
-
className: "",
|
|
26354
|
-
draggable: false,
|
|
26355
|
-
defaultParams: getDefaultParams(options),
|
|
26356
|
-
columns: columns,
|
|
26357
|
-
syncLocation: false,
|
|
26358
|
-
keepItemSelectionOnPageChange: true,
|
|
26359
|
-
checkOnItemClick: isLookup ? true : false,
|
|
26360
|
-
labelTpl: `\${${options.labelFieldName}}`,
|
|
26361
|
-
autoFillHeight: false, // 自动高度效果不理想,先关闭
|
|
26362
|
-
columnsTogglable: false,
|
|
26363
|
-
}
|
|
26364
|
-
}
|
|
26365
|
-
|
|
26366
|
-
/******************************************************************************
|
|
26367
|
-
Copyright (c) Microsoft Corporation.
|
|
26368
|
-
|
|
26369
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
26370
|
-
purpose with or without fee is hereby granted.
|
|
26371
|
-
|
|
26372
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
26373
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
26374
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
26375
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
26376
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
26377
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
26378
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
26379
|
-
***************************************************************************** */
|
|
26380
|
-
|
|
26381
|
-
var __assign = function() {
|
|
26382
|
-
__assign = Object.assign || function __assign(t) {
|
|
26383
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
26384
|
-
s = arguments[i];
|
|
26385
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
26386
|
-
}
|
|
26387
|
-
return t;
|
|
26388
|
-
};
|
|
26389
|
-
return __assign.apply(this, arguments);
|
|
26390
|
-
};
|
|
26391
|
-
|
|
26392
|
-
// 方便取值的时候能够把上层的取到,但是获取的时候不会全部把所有的数据获取到。
|
|
26393
|
-
function createObject(superProps, props, properties) {
|
|
26394
|
-
if (superProps && Object.isFrozen(superProps)) {
|
|
26395
|
-
superProps = cloneObject(superProps);
|
|
26533
|
+
"headers": {
|
|
26534
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
26535
|
+
}
|
|
26536
|
+
}
|
|
26537
|
+
},
|
|
26538
|
+
"actionType": "download"
|
|
26539
|
+
}
|
|
26540
|
+
],
|
|
26541
|
+
"weight": 0
|
|
26542
|
+
}
|
|
26543
|
+
}
|
|
26544
|
+
};
|
|
26545
|
+
}
|
|
26546
|
+
|
|
26396
26547
|
}
|
|
26397
|
-
var obj = superProps
|
|
26398
|
-
? Object.create(superProps, __assign(__assign({}, properties), { __super: {
|
|
26399
|
-
value: superProps,
|
|
26400
|
-
writable: false,
|
|
26401
|
-
enumerable: false
|
|
26402
|
-
} }))
|
|
26403
|
-
: Object.create(Object.prototype, properties);
|
|
26404
|
-
props &&
|
|
26405
|
-
isObject(props) &&
|
|
26406
|
-
Object.keys(props).forEach(function (key) { return (obj[key] = props[key]); });
|
|
26407
|
-
return obj;
|
|
26408
|
-
}
|
|
26409
|
-
function cloneObject(target, persistOwnProps) {
|
|
26410
|
-
if (persistOwnProps === void 0) { persistOwnProps = true; }
|
|
26411
|
-
var obj = target && target.__super
|
|
26412
|
-
? Object.create(target.__super, {
|
|
26413
|
-
__super: {
|
|
26414
|
-
value: target.__super,
|
|
26415
|
-
writable: false,
|
|
26416
|
-
enumerable: false
|
|
26417
|
-
}
|
|
26418
|
-
})
|
|
26419
|
-
: Object.create(Object.prototype);
|
|
26420
|
-
persistOwnProps &&
|
|
26421
|
-
target &&
|
|
26422
|
-
Object.keys(target).forEach(function (key) { return (obj[key] = target[key]); });
|
|
26423
|
-
return obj;
|
|
26424
|
-
}
|
|
26425
|
-
function isObject(obj) {
|
|
26426
|
-
var typename = typeof obj;
|
|
26427
|
-
return (obj &&
|
|
26428
|
-
typename !== 'string' &&
|
|
26429
|
-
typename !== 'number' &&
|
|
26430
|
-
typename !== 'boolean' &&
|
|
26431
|
-
typename !== 'function' &&
|
|
26432
|
-
!Array.isArray(obj));
|
|
26433
|
-
}
|
|
26434
|
-
|
|
26435
|
-
/*
|
|
26436
|
-
* @Author: baozhoutao@steedos.com
|
|
26437
|
-
* @Date: 2022-07-05 15:55:39
|
|
26438
|
-
* @LastEditors: liaodaxue
|
|
26439
|
-
* @LastEditTime: 2023-10-20 11:38:25
|
|
26440
|
-
* @Description:
|
|
26441
|
-
*/
|
|
26442
26548
|
|
|
26443
|
-
|
|
26549
|
+
columns.push(column);
|
|
26550
|
+
|
|
26444
26551
|
|
|
26445
|
-
|
|
26552
|
+
return columns;
|
|
26553
|
+
}
|
|
26446
26554
|
|
|
26447
|
-
|
|
26448
|
-
|
|
26449
|
-
|
|
26555
|
+
function getDefaultParams(options){
|
|
26556
|
+
return {
|
|
26557
|
+
perPage: options.top || options.perPage || config.listView.perPage
|
|
26450
26558
|
}
|
|
26451
|
-
UI_SCHEMA_CACHE = window.UI_SCHEMA_CACHE;
|
|
26452
26559
|
}
|
|
26453
26560
|
|
|
26454
|
-
|
|
26455
|
-
|
|
26456
|
-
};
|
|
26457
|
-
|
|
26458
|
-
const getUISchemaCache = (key) => {
|
|
26459
|
-
return lodash.exports.cloneDeep(UI_SCHEMA_CACHE[key]);
|
|
26460
|
-
};
|
|
26461
|
-
|
|
26462
|
-
const hasUISchemaCache = (key) => {
|
|
26463
|
-
return lodash.exports.has(UI_SCHEMA_CACHE, key);
|
|
26464
|
-
};
|
|
26561
|
+
function getButtonVisibleOn(button){
|
|
26562
|
+
let visible= button.visible;
|
|
26465
26563
|
|
|
26466
|
-
|
|
26467
|
-
|
|
26468
|
-
if (formFactor === "SMALL") {
|
|
26469
|
-
listViewColumns = !lodash.exports.isEmpty(listView.mobile_columns)
|
|
26470
|
-
? listView.mobile_columns
|
|
26471
|
-
: lodash.exports.slice(listView.columns, 0, 4);
|
|
26472
|
-
} else {
|
|
26473
|
-
listViewColumns = listView.columns;
|
|
26564
|
+
if(button._visible){
|
|
26565
|
+
visible = button._visible;
|
|
26474
26566
|
}
|
|
26475
|
-
|
|
26476
|
-
|
|
26477
|
-
|
|
26478
|
-
let sort = '';
|
|
26479
|
-
if(listView && listView.sort && listView.sort.length){
|
|
26480
|
-
lodash.exports.each(listView.sort,function(item,index){
|
|
26481
|
-
if(lodash.exports.isArray(item)){
|
|
26482
|
-
const field_name = item[0];
|
|
26483
|
-
const order = item[1] || '';
|
|
26484
|
-
let sortStr = field_name + ' ' + order;
|
|
26485
|
-
sortStr = index > 0 ? ','+sortStr : sortStr;
|
|
26486
|
-
sort += sortStr;
|
|
26487
|
-
}else {
|
|
26488
|
-
let sortStr = item.field_name + ' ' + item.order;
|
|
26489
|
-
sortStr = index > 0 ? ','+sortStr : sortStr;
|
|
26490
|
-
sort += sortStr;
|
|
26491
|
-
}
|
|
26492
|
-
});
|
|
26567
|
+
|
|
26568
|
+
if(lodash.exports.isBoolean(visible)){
|
|
26569
|
+
visible = visible.toString();
|
|
26493
26570
|
}
|
|
26494
|
-
|
|
26495
|
-
|
|
26496
|
-
|
|
26497
|
-
|
|
26498
|
-
return ;
|
|
26571
|
+
|
|
26572
|
+
if(visible){
|
|
26573
|
+
// if(visible.indexOf("Meteor.") > 0 || visible.indexOf("Creator.") > 0 || visible.indexOf("Session.") > 0){
|
|
26574
|
+
// console.warn('无效的visible', visible)
|
|
26575
|
+
// return 'false';
|
|
26576
|
+
// }
|
|
26577
|
+
if(visible.trim().startsWith('function')){
|
|
26578
|
+
return `${visible}(objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)`
|
|
26579
|
+
}
|
|
26580
|
+
return visible;
|
|
26499
26581
|
}
|
|
26500
|
-
|
|
26501
|
-
|
|
26502
|
-
|
|
26503
|
-
if(
|
|
26504
|
-
|
|
26505
|
-
|
|
26506
|
-
|
|
26507
|
-
if(___default.isString(filters) && ___default.startsWith(___default.trim(filters), "function")){
|
|
26508
|
-
filters = new Function(`return ${filters}`);
|
|
26509
|
-
filters = filters();
|
|
26510
|
-
}
|
|
26511
|
-
if(___default.isArray(filters)){
|
|
26512
|
-
filters.push(["owner", "=", userId]);
|
|
26513
|
-
}else {
|
|
26514
|
-
console.debug(`listView filters is not array`, listView);
|
|
26515
|
-
throw new Error('filters is not array')
|
|
26516
|
-
}
|
|
26517
|
-
}
|
|
26518
|
-
};
|
|
26519
|
-
return filters;
|
|
26520
|
-
} catch (error) {
|
|
26521
|
-
console.error(error);
|
|
26582
|
+
|
|
26583
|
+
if(button.type === 'amis_button'){
|
|
26584
|
+
const amisSchema = button.amis_schema;
|
|
26585
|
+
if(amisSchema && amisSchema.body && amisSchema.body.length > 0){
|
|
26586
|
+
const btn1 = amisSchema.body[0];
|
|
26587
|
+
return btn1.visibleOn
|
|
26588
|
+
}
|
|
26522
26589
|
}
|
|
26523
26590
|
}
|
|
26524
26591
|
|
|
26525
|
-
function
|
|
26526
|
-
|
|
26527
|
-
|
|
26528
|
-
|
|
26529
|
-
|
|
26530
|
-
|
|
26531
|
-
}
|
|
26532
|
-
} catch (exception) {
|
|
26533
|
-
field.reference_to = undefined;
|
|
26534
|
-
console.error(exception);
|
|
26535
|
-
}
|
|
26536
|
-
});
|
|
26537
|
-
lodash.exports.each(uiSchema.list_views, (v, k)=>{
|
|
26538
|
-
v.name = k;
|
|
26539
|
-
if(!lodash.exports.has(v, 'columns')){
|
|
26540
|
-
v.columns = uiSchema.list_views.all.columns;
|
|
26592
|
+
async function getTableOperation(ctx){
|
|
26593
|
+
const buttons = ctx.buttons;
|
|
26594
|
+
const operationButtons = [];
|
|
26595
|
+
lodash.exports.each(buttons, (button)=>{
|
|
26596
|
+
if(lodash.exports.isBoolean(button.visible)){
|
|
26597
|
+
button.visible = button.visible.toString();
|
|
26541
26598
|
}
|
|
26542
|
-
|
|
26543
|
-
|
|
26599
|
+
// operationButtons.push({
|
|
26600
|
+
// type: 'button',
|
|
26601
|
+
// label: button.label,
|
|
26602
|
+
// visibleOn: button.visible ? `${button.visible}` : (button._visible ? `${button._visible}` : null),
|
|
26603
|
+
// onEvent: {
|
|
26604
|
+
// click: {
|
|
26605
|
+
// actions: []
|
|
26606
|
+
// }
|
|
26607
|
+
// }
|
|
26608
|
+
// })
|
|
26544
26609
|
|
|
26545
|
-
|
|
26546
|
-
|
|
26547
|
-
|
|
26548
|
-
|
|
26549
|
-
|
|
26550
|
-
|
|
26610
|
+
operationButtons.push({
|
|
26611
|
+
type: 'steedos-object-button',
|
|
26612
|
+
name: button.name,
|
|
26613
|
+
objectName: button.objectName,
|
|
26614
|
+
visibleOn: getButtonVisibleOn(button),
|
|
26615
|
+
className: 'antd-Button--default'
|
|
26616
|
+
});
|
|
26617
|
+
});
|
|
26618
|
+
if(operationButtons.length < 1){
|
|
26619
|
+
return ;
|
|
26551
26620
|
}
|
|
26552
|
-
|
|
26553
|
-
|
|
26554
|
-
|
|
26555
|
-
|
|
26556
|
-
|
|
26557
|
-
|
|
26558
|
-
|
|
26559
|
-
|
|
26560
|
-
|
|
26561
|
-
|
|
26562
|
-
|
|
26563
|
-
|
|
26564
|
-
|
|
26565
|
-
|
|
26621
|
+
return {
|
|
26622
|
+
type: 'operation',
|
|
26623
|
+
label: " ",
|
|
26624
|
+
fixed: 'right',
|
|
26625
|
+
labelClassName: 'text-center',
|
|
26626
|
+
className: 'text-center steedos-listview-operation w-10',
|
|
26627
|
+
buttons: [
|
|
26628
|
+
{
|
|
26629
|
+
"type": "steedos-dropdown-button",
|
|
26630
|
+
"label": "xxx",
|
|
26631
|
+
"buttons": operationButtons,
|
|
26632
|
+
"placement": "bottomRight",
|
|
26633
|
+
"overlayClassName": "shadow !min-w-[160px]",
|
|
26634
|
+
"trigger": ["click"],
|
|
26635
|
+
"id": "u:c2140a365019",
|
|
26636
|
+
onOpenApi: {
|
|
26637
|
+
url: `\${context.rootUrl}/service/api/@\${objectName}/recordPermissions/\${_id}`,
|
|
26638
|
+
method: "get",
|
|
26639
|
+
requestAdaptor: "api.data={}; return api;",
|
|
26640
|
+
headers: {
|
|
26641
|
+
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
26642
|
+
},
|
|
26643
|
+
adaptor: `
|
|
26644
|
+
payload = {
|
|
26645
|
+
record: {
|
|
26646
|
+
recordPermissions: payload
|
|
26647
|
+
}
|
|
26648
|
+
};
|
|
26649
|
+
return payload;
|
|
26650
|
+
`,
|
|
26651
|
+
}
|
|
26652
|
+
}
|
|
26653
|
+
]
|
|
26566
26654
|
}
|
|
26567
|
-
return getUISchemaCache(objectName);
|
|
26568
26655
|
}
|
|
26569
26656
|
|
|
26570
|
-
function
|
|
26571
|
-
|
|
26572
|
-
|
|
26573
|
-
|
|
26574
|
-
|
|
26575
|
-
|
|
26576
|
-
|
|
26577
|
-
|
|
26578
|
-
try {
|
|
26579
|
-
|
|
26580
|
-
const url = `/service/api/@${objectName.replace(/\./g, "_")}/uiSchema`;
|
|
26581
|
-
uiSchema = Steedos.authRequest(url, {
|
|
26582
|
-
type: 'GET',
|
|
26583
|
-
async: false,
|
|
26584
|
-
});
|
|
26585
|
-
|
|
26586
|
-
if(!uiSchema){
|
|
26587
|
-
return ;
|
|
26657
|
+
async function getDefaultCrudCard(columns, options) {
|
|
26658
|
+
let labelFieldName = options?.labelFieldName || "name";
|
|
26659
|
+
let titleColumn, bodyColumns = [];
|
|
26660
|
+
columns.forEach(function (item) {
|
|
26661
|
+
delete item.quickEdit;
|
|
26662
|
+
delete item.width;
|
|
26663
|
+
if (item.name === labelFieldName) {
|
|
26664
|
+
titleColumn = item;
|
|
26588
26665
|
}
|
|
26589
|
-
|
|
26590
|
-
|
|
26591
|
-
|
|
26592
|
-
|
|
26666
|
+
else {
|
|
26667
|
+
if (item.name !== "_index") {
|
|
26668
|
+
bodyColumns.push(item);
|
|
26669
|
+
}
|
|
26670
|
+
}
|
|
26671
|
+
});
|
|
26672
|
+
let card = {
|
|
26673
|
+
"header": {
|
|
26674
|
+
"title": titleColumn.tpl
|
|
26675
|
+
},
|
|
26676
|
+
body: bodyColumns,
|
|
26677
|
+
// useCardLabel: false,
|
|
26678
|
+
toolbar: []
|
|
26679
|
+
};
|
|
26680
|
+
let hideToolbarOperation = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
|
|
26681
|
+
if(!hideToolbarOperation){
|
|
26682
|
+
let toolbarOperation = await getTableOperation(options);
|
|
26683
|
+
if (toolbarOperation) {
|
|
26684
|
+
toolbarOperation.className += " inline-block w-auto";
|
|
26685
|
+
}
|
|
26686
|
+
card.toolbar.push(toolbarOperation);
|
|
26593
26687
|
}
|
|
26594
|
-
return
|
|
26688
|
+
return card;
|
|
26595
26689
|
}
|
|
26596
26690
|
|
|
26597
|
-
|
|
26598
|
-
|
|
26599
|
-
|
|
26600
|
-
objectName,
|
|
26601
|
-
listViewName,
|
|
26602
|
-
ctx = {}
|
|
26603
|
-
) {
|
|
26604
|
-
const uiSchema = await getUISchema(objectName);
|
|
26605
|
-
if(!uiSchema){
|
|
26606
|
-
return {}
|
|
26691
|
+
async function getTableSchema(fields, options){
|
|
26692
|
+
if(!options){
|
|
26693
|
+
options = {};
|
|
26607
26694
|
}
|
|
26608
|
-
|
|
26609
|
-
|
|
26610
|
-
|
|
26611
|
-
// 传入listViewName空值则取第一个
|
|
26612
|
-
if(!listViewName){
|
|
26613
|
-
listViewName = name;
|
|
26614
|
-
}
|
|
26615
|
-
return name === listViewName || listView._id === listViewName;
|
|
26616
|
-
}
|
|
26617
|
-
);
|
|
26695
|
+
let { isLookup, hiddenColumnOperation } = options;
|
|
26696
|
+
const defaults = options.defaults;
|
|
26697
|
+
const listSchema = (defaults && defaults.listSchema) || {};
|
|
26618
26698
|
|
|
26619
|
-
|
|
26620
|
-
|
|
26699
|
+
let columns = [];
|
|
26700
|
+
let useMobileColumns = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
|
|
26701
|
+
if(isLookup){
|
|
26702
|
+
// 在lookup手机端列表模式调式好之前不使用getMobileTableColumns
|
|
26703
|
+
useMobileColumns = false;
|
|
26621
26704
|
}
|
|
26622
|
-
|
|
26623
|
-
|
|
26624
|
-
|
|
26625
|
-
const amisSchema = lodash.exports.isString(listView.amis_schema) ? JSON.parse(listView.amis_schema) : listView.amis_schema;
|
|
26626
|
-
return {
|
|
26627
|
-
uiSchema,
|
|
26628
|
-
isCustomAmisSchema: true,
|
|
26629
|
-
amisSchema
|
|
26630
|
-
};
|
|
26705
|
+
if(listSchema.mode && listSchema.mode !== "table"){
|
|
26706
|
+
// 如果指定的mode,则不走我们内置的手机端列表效果,使用steedos组件内部开发的默认card/list效果,或者由用户自己实现card/list模式的crud列表
|
|
26707
|
+
useMobileColumns = false;
|
|
26631
26708
|
}
|
|
26632
|
-
|
|
26633
|
-
|
|
26634
|
-
let sort = getListViewSort(listView);
|
|
26635
|
-
let listviewFilter = getListViewFilter(listView);
|
|
26636
|
-
let listview_filters = listView && listView._filters;
|
|
26637
|
-
// 返回 calendar 组件
|
|
26638
|
-
if(listView.type === "calendar"){
|
|
26639
|
-
const amisSchema = {
|
|
26640
|
-
"type": "steedos-object-calendar",
|
|
26641
|
-
"objectApiName": objectName,
|
|
26642
|
-
"filters": listviewFilter,
|
|
26643
|
-
"filtersFunction": listview_filters,
|
|
26644
|
-
"sort": sort,
|
|
26645
|
-
...listView.options
|
|
26646
|
-
};
|
|
26647
|
-
return {
|
|
26648
|
-
uiSchema,
|
|
26649
|
-
isCalendar: true,
|
|
26650
|
-
amisSchema
|
|
26651
|
-
};
|
|
26709
|
+
if(useMobileColumns){
|
|
26710
|
+
columns = await getMobileTableColumns(fields, options);
|
|
26652
26711
|
}
|
|
26712
|
+
else {
|
|
26713
|
+
columns = await getTableColumns(fields, options);
|
|
26653
26714
|
|
|
26654
|
-
|
|
26655
|
-
|
|
26656
|
-
|
|
26657
|
-
|
|
26658
|
-
|
|
26659
|
-
|
|
26660
|
-
|
|
26661
|
-
|
|
26662
|
-
|
|
26663
|
-
|
|
26664
|
-
|
|
26665
|
-
|
|
26666
|
-
|
|
26667
|
-
|
|
26668
|
-
|
|
26669
|
-
|
|
26670
|
-
|
|
26671
|
-
|
|
26672
|
-
|
|
26673
|
-
|
|
26674
|
-
|
|
26675
|
-
* localListViewProps规范来自crud请求api中api.data.$self参数值的。
|
|
26676
|
-
* 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
|
|
26677
|
-
* __searchable__...:顶部放大镜搜索条件
|
|
26678
|
-
* filter:右侧过滤器
|
|
26679
|
-
* perPage:每页条数
|
|
26680
|
-
* page:当前页码
|
|
26681
|
-
* orderBy:排序字段
|
|
26682
|
-
* orderDir:排序方向
|
|
26683
|
-
*/
|
|
26684
|
-
if (localListViewProps) {
|
|
26685
|
-
localListViewProps = JSON.parse(localListViewProps);
|
|
26686
|
-
// localListViewProps.perPage = 3;
|
|
26687
|
-
let listSchema = {};
|
|
26688
|
-
if(localListViewProps.orderBy){
|
|
26689
|
-
listSchema.orderBy = localListViewProps.orderBy;
|
|
26690
|
-
}
|
|
26691
|
-
if(localListViewProps.orderDir){
|
|
26692
|
-
listSchema.orderDir = localListViewProps.orderDir;
|
|
26715
|
+
if(listSchema.mode === "cards"){
|
|
26716
|
+
let card = listSchema.card;
|
|
26717
|
+
if(!card){
|
|
26718
|
+
card = await getDefaultCrudCard(columns, options);
|
|
26719
|
+
}
|
|
26720
|
+
return {
|
|
26721
|
+
mode: "cards",
|
|
26722
|
+
perPageAvailable: [5, 10, 20, 50, 100, 500],
|
|
26723
|
+
name: "thelist",
|
|
26724
|
+
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
26725
|
+
className: "",
|
|
26726
|
+
draggable: false,
|
|
26727
|
+
defaultParams: getDefaultParams(options),
|
|
26728
|
+
card: card,
|
|
26729
|
+
syncLocation: false,
|
|
26730
|
+
keepItemSelectionOnPageChange: true,
|
|
26731
|
+
checkOnItemClick: isLookup ? true : false,
|
|
26732
|
+
labelTpl: `\${${options.labelFieldName}}`,
|
|
26733
|
+
autoFillHeight: false, // 自动高度效果不理想,先关闭
|
|
26734
|
+
columnsTogglable: false
|
|
26735
|
+
}
|
|
26693
26736
|
}
|
|
26694
26737
|
|
|
26695
|
-
if(
|
|
26696
|
-
|
|
26697
|
-
perPage: localListViewProps.perPage
|
|
26698
|
-
};
|
|
26738
|
+
if(!isLookup && !hiddenColumnOperation){
|
|
26739
|
+
columns.push(await getTableOperation(options));
|
|
26699
26740
|
}
|
|
26700
|
-
defaults.listSchema = lodash.exports.defaultsDeep({}, listSchema, defaults.listSchema || {});
|
|
26701
|
-
}
|
|
26702
|
-
}
|
|
26703
|
-
catch (ex) {
|
|
26704
|
-
console.error("本地存储中crud参数解析异常:", ex);
|
|
26705
26741
|
}
|
|
26706
26742
|
|
|
26707
|
-
ctx.defaults = defaults;
|
|
26708
|
-
|
|
26709
|
-
if (listViewName == "recent") {
|
|
26710
|
-
listview_filters = `
|
|
26711
|
-
function(filters, data) {
|
|
26712
|
-
var result = Steedos.authRequest('/graphql', {
|
|
26713
|
-
type: 'POST',
|
|
26714
|
-
async: false,
|
|
26715
|
-
data: JSON.stringify({
|
|
26716
|
-
query: '{object_recent_viewed(filters: [["record.o","=","' + data.objectName + '"],["space","=","' + data.context.tenantId + '"],["owner","=","' + data.context.userId + '"]],sort:"modified desc",top:50){ _id,record} }'
|
|
26717
|
-
}),
|
|
26718
|
-
});
|
|
26719
|
-
var _ids = []
|
|
26720
|
-
result.data.object_recent_viewed.forEach(function (item) {
|
|
26721
|
-
_ids = _ids.concat(item.record.ids)
|
|
26722
|
-
})
|
|
26723
|
-
return ["_id", "=", _ids];
|
|
26724
|
-
}
|
|
26725
|
-
`;
|
|
26726
|
-
}
|
|
26727
|
-
const amisSchema = {
|
|
26728
|
-
"type": "steedos-object-table",
|
|
26729
|
-
"objectApiName": objectName,
|
|
26730
|
-
"columns": listViewColumns,
|
|
26731
|
-
"extraColumns": listView.extra_columns,
|
|
26732
|
-
"filters": listviewFilter,
|
|
26733
|
-
"filtersFunction": listview_filters,
|
|
26734
|
-
"sort": sort,
|
|
26735
|
-
"ctx": ctx,
|
|
26736
|
-
"requestAdaptor": listView.requestAdaptor || ctx.requestAdaptor,
|
|
26737
|
-
"adaptor": listView.adaptor || ctx.adaptor,
|
|
26738
|
-
"headerToolbarItems": ctx.headerToolbarItems,
|
|
26739
|
-
"filterVisible": ctx.filterVisible,
|
|
26740
|
-
"rowClassNameExpr": ctx.rowClassNameExpr,
|
|
26741
|
-
"crudDataFilter": ctx.crudDataFilter,
|
|
26742
|
-
"onCrudDataFilter": ctx.onCrudDataFilter
|
|
26743
|
-
};
|
|
26744
|
-
// console.log(`getListSchema===>`,amisSchema)
|
|
26745
26743
|
return {
|
|
26746
|
-
|
|
26747
|
-
|
|
26748
|
-
|
|
26749
|
-
|
|
26750
|
-
|
|
26751
|
-
|
|
26752
|
-
|
|
26753
|
-
|
|
26754
|
-
|
|
26755
|
-
|
|
26744
|
+
mode: "table",
|
|
26745
|
+
perPageAvailable: [5, 10, 20, 50, 100, 500],
|
|
26746
|
+
name: "thelist",
|
|
26747
|
+
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
26748
|
+
className: "",
|
|
26749
|
+
draggable: false,
|
|
26750
|
+
defaultParams: getDefaultParams(options),
|
|
26751
|
+
columns: columns,
|
|
26752
|
+
syncLocation: false,
|
|
26753
|
+
keepItemSelectionOnPageChange: true,
|
|
26754
|
+
checkOnItemClick: isLookup ? true : false,
|
|
26755
|
+
labelTpl: `\${${options.labelFieldName}}`,
|
|
26756
|
+
autoFillHeight: false, // 自动高度效果不理想,先关闭
|
|
26757
|
+
columnsTogglable: false,
|
|
26758
|
+
}
|
|
26756
26759
|
}
|
|
26757
26760
|
|
|
26758
26761
|
function useCombinedRefs(...refs) {
|