@steedos-widgets/sortable 1.3.8 → 1.3.10
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 +1253 -1249
- package/dist/sortable.cjs.js.map +1 -1
- package/dist/sortable.esm.js +1253 -1249
- package/dist/sortable.esm.js.map +1 -1
- package/dist/sortable.umd.js +1253 -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
|
|
@@ -23828,7 +23608,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
23828
23608
|
if(refObjectConfig.name === 'organizations'){
|
|
23829
23609
|
labelFieldName = 'name';
|
|
23830
23610
|
}
|
|
23831
|
-
pickerSchema = await getTableSchema
|
|
23611
|
+
pickerSchema = await getTableSchema(tableFields, {
|
|
23832
23612
|
labelFieldName,
|
|
23833
23613
|
top: top,
|
|
23834
23614
|
isLookup: true,
|
|
@@ -24318,7 +24098,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
24318
24098
|
actions: false
|
|
24319
24099
|
});
|
|
24320
24100
|
}else {
|
|
24321
|
-
pickerSchema = await getTableSchema
|
|
24101
|
+
pickerSchema = await getTableSchema(tableFields, {
|
|
24322
24102
|
labelFieldName: refObjectConfig.NAME_FIELD_KEY,
|
|
24323
24103
|
top: top,
|
|
24324
24104
|
isLookup: true,
|
|
@@ -25067,295 +24847,907 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
25067
24847
|
return value; // 切换到数字之后的默认值
|
|
25068
24848
|
}
|
|
25069
24849
|
}
|
|
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);
|
|
24850
|
+
};
|
|
24851
|
+
break;
|
|
24852
|
+
case 'avatar':
|
|
24853
|
+
convertData = getAmisFileSchema(field, readonly);
|
|
24854
|
+
break;
|
|
24855
|
+
case 'image':
|
|
24856
|
+
convertData = getAmisFileSchema(field, readonly);
|
|
24857
|
+
break;
|
|
24858
|
+
case 'file':
|
|
24859
|
+
convertData = getAmisFileSchema(field, readonly);
|
|
24860
|
+
break;
|
|
24861
|
+
case 'formula':
|
|
24862
|
+
if(readonly){
|
|
24863
|
+
convertData = {
|
|
24864
|
+
type: 'static-tpl',
|
|
24865
|
+
tpl: getUiFieldTpl(field)
|
|
24866
|
+
};
|
|
24867
|
+
}
|
|
24868
|
+
break;
|
|
24869
|
+
case 'summary':
|
|
24870
|
+
if(readonly){
|
|
24871
|
+
convertData = {
|
|
24872
|
+
type: 'static-tpl',
|
|
24873
|
+
tpl: getUiFieldTpl(field)
|
|
24874
|
+
};
|
|
24875
|
+
}
|
|
24876
|
+
break;
|
|
24877
|
+
case 'code':
|
|
24878
|
+
convertData = {
|
|
24879
|
+
type: "editor",
|
|
24880
|
+
disabled: readonly ? true : false,
|
|
24881
|
+
language: field.language,
|
|
24882
|
+
editorDidMount: new Function('editor', 'monaco', field.editorDidMount)
|
|
24883
|
+
};
|
|
24884
|
+
break;
|
|
24885
|
+
case 'toggle':
|
|
24886
|
+
convertData = {
|
|
24887
|
+
type: "switch",
|
|
24888
|
+
name: field.name,
|
|
24889
|
+
label: field.label,
|
|
24890
|
+
width: field.width,
|
|
24891
|
+
toggled: field.toggled,
|
|
24892
|
+
disabled: readonly,
|
|
24893
|
+
};
|
|
24894
|
+
break;
|
|
24895
|
+
case 'grid':
|
|
24896
|
+
if(field.subFields){
|
|
24897
|
+
convertData = {
|
|
24898
|
+
type: 'input-table',
|
|
24899
|
+
showIndex: true,
|
|
24900
|
+
columnsTogglable: false,
|
|
24901
|
+
strictMode:false,
|
|
24902
|
+
affixHeader: false, // 是否固定表头, 不固定表头, 否则form有y轴滚动条时, 表头会跟随滚动条滚动.
|
|
24903
|
+
needConfirm: false,
|
|
24904
|
+
editable: !readonly,
|
|
24905
|
+
addable: !readonly,
|
|
24906
|
+
removable: !readonly,
|
|
24907
|
+
draggable: !readonly,
|
|
24908
|
+
columns: []
|
|
24909
|
+
};
|
|
24910
|
+
// console.log(`convertData ==2====>`, field, convertData)
|
|
24911
|
+
for (const subField of field.subFields) {
|
|
24912
|
+
const subFieldName = subField.name.replace(`${field._prefix || ''}${field.name}.$.`, '').replace(`${field.name}.`, '');
|
|
24913
|
+
const gridSub = await convertSFieldToAmisField(Object.assign({}, subField, {name: subFieldName, isTableField: true}), readonly, ctx);
|
|
24914
|
+
if(gridSub){
|
|
24915
|
+
delete gridSub.name;
|
|
24916
|
+
delete gridSub.label;
|
|
24917
|
+
const gridItemSchema = {
|
|
24918
|
+
name: subFieldName,
|
|
24919
|
+
label: subField.label,
|
|
24920
|
+
quickEdit: readonly ? false : gridSub
|
|
24921
|
+
};
|
|
24922
|
+
if(["lookup", "boolean", "toggle"].indexOf(subField.type) > -1){
|
|
24923
|
+
gridItemSchema.type = gridSub.type;
|
|
24924
|
+
gridItemSchema.tpl = gridSub.tpl;
|
|
24925
|
+
}
|
|
24926
|
+
convertData.columns.push(Object.assign({}, gridItemSchema, subField.amis, {name: subFieldName}));
|
|
24927
|
+
}
|
|
24928
|
+
}
|
|
24929
|
+
}
|
|
25080
24930
|
break;
|
|
25081
|
-
case '
|
|
25082
|
-
if(
|
|
24931
|
+
case 'object':
|
|
24932
|
+
if(field.subFields){
|
|
25083
24933
|
convertData = {
|
|
25084
|
-
type: '
|
|
25085
|
-
|
|
24934
|
+
type: 'combo',
|
|
24935
|
+
items: []
|
|
25086
24936
|
};
|
|
24937
|
+
// console.log(`convertData ======>`, field, convertData)
|
|
24938
|
+
for (let subField of field.subFields) {
|
|
24939
|
+
let subFieldName = subField.name.replace(`${field.name}.$.`, '').replace(`${field.name}.`, '');
|
|
24940
|
+
if(subField.type === 'grid'){
|
|
24941
|
+
subField = await getGridFieldSubFields(subField, ctx.__formFields);
|
|
24942
|
+
}else {
|
|
24943
|
+
if(readonly){
|
|
24944
|
+
subFieldName = `${field.name}.${subFieldName}`;
|
|
24945
|
+
}
|
|
24946
|
+
}
|
|
24947
|
+
const gridSub = await convertSFieldToAmisField(Object.assign({}, subField, {name: subFieldName}), readonly, ctx);
|
|
24948
|
+
if(gridSub){
|
|
24949
|
+
delete gridSub.name;
|
|
24950
|
+
delete gridSub.label;
|
|
24951
|
+
convertData.items.push(
|
|
24952
|
+
Object.assign({}, gridSub, {label: subField.label}, subField.amis, {
|
|
24953
|
+
name: subFieldName
|
|
24954
|
+
})
|
|
24955
|
+
);
|
|
24956
|
+
}
|
|
24957
|
+
}
|
|
24958
|
+
}
|
|
24959
|
+
break;
|
|
24960
|
+
}
|
|
24961
|
+
if(!lodash.exports.isEmpty(convertData)){
|
|
24962
|
+
if(field.is_wide || convertData.type === 'group'){
|
|
24963
|
+
convertData.className = 'col-span-2 m-1';
|
|
24964
|
+
}else {
|
|
24965
|
+
convertData.className = 'm-1';
|
|
24966
|
+
}
|
|
24967
|
+
if(readonly){
|
|
24968
|
+
convertData.className = `${convertData.className} border-b`;
|
|
24969
|
+
}
|
|
24970
|
+
if(readonly){
|
|
24971
|
+
convertData.quickEdit = false;
|
|
24972
|
+
}
|
|
24973
|
+
|
|
24974
|
+
let fieldTypeClassName = ' steedos-' + convertData.type + (readonly ? '-readonly' : '-edit');
|
|
24975
|
+
if (convertData.className) {
|
|
24976
|
+
convertData.className = convertData.className + fieldTypeClassName;
|
|
24977
|
+
} else {
|
|
24978
|
+
convertData.className = fieldTypeClassName;
|
|
24979
|
+
}
|
|
24980
|
+
|
|
24981
|
+
if(field.visible_on && !ctx.inFilterForm){
|
|
24982
|
+
// convertData.visibleOn = `\$${field.visible_on.substring(1, field.visible_on.length -1).replace(/formData./g, '')}`;
|
|
24983
|
+
if(field.visible_on.startsWith("{{")){
|
|
24984
|
+
convertData.visibleOn = `${field.visible_on.substring(2, field.visible_on.length -2).replace(/formData./g, 'data.')}`;
|
|
24985
|
+
}else {
|
|
24986
|
+
convertData.visibleOn = `${field.visible_on.replace(/formData./g, 'data.')}`;
|
|
24987
|
+
}
|
|
24988
|
+
}
|
|
24989
|
+
|
|
24990
|
+
if(lodash.exports.isString(baseData.required)){
|
|
24991
|
+
if(baseData.required.startsWith("{{")){
|
|
24992
|
+
baseData.requiredOn = `${baseData.required.substring(2, baseData.required.length -2).replace(/formData./g, 'data.')}`;
|
|
24993
|
+
delete baseData.required;
|
|
24994
|
+
}
|
|
24995
|
+
}
|
|
24996
|
+
|
|
24997
|
+
if(convertData.type === 'group'){
|
|
24998
|
+
convertData.body[0] = Object.assign({}, baseData, convertData.body[0], { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name});
|
|
24999
|
+
return convertData
|
|
25000
|
+
}
|
|
25001
|
+
// if(ctx.mode === 'edit'){
|
|
25002
|
+
return Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name}, field.amis, {name: baseData.name});
|
|
25003
|
+
// }else{
|
|
25004
|
+
// return Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name});
|
|
25005
|
+
// }
|
|
25006
|
+
}
|
|
25007
|
+
|
|
25008
|
+
}
|
|
25009
|
+
|
|
25010
|
+
async function getFieldSearchable(perField, permissionFields, ctx){
|
|
25011
|
+
if(!ctx){
|
|
25012
|
+
ctx = {};
|
|
25013
|
+
}
|
|
25014
|
+
let field = perField;
|
|
25015
|
+
if(field.type === 'grid'){
|
|
25016
|
+
field = await getGridFieldSubFields(perField, permissionFields);
|
|
25017
|
+
}else if(perField.type === 'object'){
|
|
25018
|
+
field = await getObjectFieldSubFields(perField, permissionFields);
|
|
25019
|
+
}
|
|
25020
|
+
|
|
25021
|
+
let fieldNamePrefix = '__searchable__';
|
|
25022
|
+
if(field.name.indexOf(".") < 0){
|
|
25023
|
+
let _field = lodash.exports.cloneDeep(field);
|
|
25024
|
+
if(lodash.exports.includes(['textarea', 'html', 'code', 'autonumber'], field.type)){
|
|
25025
|
+
_field.type = 'text';
|
|
25026
|
+
}
|
|
25027
|
+
|
|
25028
|
+
if(lodash.exports.includes(['formula', 'summary'], field.type)){
|
|
25029
|
+
_field.type = field.data_type;
|
|
25030
|
+
_field.precision = field.precision;
|
|
25031
|
+
_field.scale = field.scale;
|
|
25032
|
+
}
|
|
25033
|
+
else if(field.type === "select" && field.data_type && field.data_type != "text"){
|
|
25034
|
+
_field.type = field.data_type;
|
|
25035
|
+
}
|
|
25036
|
+
|
|
25037
|
+
if(_field.type === 'number' || _field.type === 'currency'){
|
|
25038
|
+
_field.type = 'input-array';
|
|
25039
|
+
_field.inline = true;
|
|
25040
|
+
_field.addable = false;
|
|
25041
|
+
_field.removable = false;
|
|
25042
|
+
_field.value = [null,null];
|
|
25043
|
+
_field.items = {
|
|
25044
|
+
type: "input-number"
|
|
25045
|
+
};
|
|
25046
|
+
_field.is_wide = true;
|
|
25047
|
+
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
25048
|
+
}
|
|
25049
|
+
|
|
25050
|
+
if(_field.type ==='date'){
|
|
25051
|
+
_field.type = 'input-date-range';
|
|
25052
|
+
_field.is_wide = true;
|
|
25053
|
+
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
25054
|
+
}
|
|
25055
|
+
if(_field.type === 'datetime'){
|
|
25056
|
+
_field.type = 'input-datetime-range';
|
|
25057
|
+
_field.is_wide = true;
|
|
25058
|
+
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
25059
|
+
}
|
|
25060
|
+
if(_field.type === 'time'){
|
|
25061
|
+
_field.type = 'input-time-range';
|
|
25062
|
+
_field.is_wide = true;
|
|
25063
|
+
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
25064
|
+
}
|
|
25065
|
+
if(_field.reference_to === 'users'){
|
|
25066
|
+
_field.reference_to = 'space_users';
|
|
25067
|
+
_field.reference_to_field = 'user';
|
|
25068
|
+
}
|
|
25069
|
+
_field.readonly = false;
|
|
25070
|
+
_field.disabled = false;
|
|
25071
|
+
_field.multiple = true;
|
|
25072
|
+
_field.is_wide = false;
|
|
25073
|
+
_field.defaultValue = undefined;
|
|
25074
|
+
_field.required = false;
|
|
25075
|
+
_field.hidden = false;
|
|
25076
|
+
_field.omit = false;
|
|
25077
|
+
|
|
25078
|
+
if(_field.amis){
|
|
25079
|
+
delete _field.amis.static;
|
|
25080
|
+
delete _field.amis.staticOn;
|
|
25081
|
+
delete _field.amis.disabled;
|
|
25082
|
+
delete _field.amis.disabledOn;
|
|
25083
|
+
delete _field.amis.required;
|
|
25084
|
+
delete _field.amis.requiredOn;
|
|
25085
|
+
delete _field.amis.visible;
|
|
25086
|
+
delete _field.amis.visibleOn;
|
|
25087
|
+
delete _field.amis.hidden;
|
|
25088
|
+
delete _field.amis.hiddenOn;
|
|
25089
|
+
delete _field.amis.autoFill;
|
|
25090
|
+
}
|
|
25091
|
+
|
|
25092
|
+
const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
|
|
25093
|
+
if(amisField){
|
|
25094
|
+
return Object.assign({}, amisField,{
|
|
25095
|
+
submitOnChange: true
|
|
25096
|
+
});
|
|
25097
|
+
}
|
|
25098
|
+
}
|
|
25099
|
+
}
|
|
25100
|
+
|
|
25101
|
+
if(typeof window != 'undefined'){
|
|
25102
|
+
window.getFieldSearchable = getFieldSearchable;
|
|
25103
|
+
}
|
|
25104
|
+
|
|
25105
|
+
|
|
25106
|
+
function isFieldTypeSearchable(fieldType) {
|
|
25107
|
+
return !lodash.exports.includes(
|
|
25108
|
+
[
|
|
25109
|
+
"grid",
|
|
25110
|
+
"avatar",
|
|
25111
|
+
"image",
|
|
25112
|
+
"object",
|
|
25113
|
+
"[object]",
|
|
25114
|
+
"[Object]",
|
|
25115
|
+
"[grid]",
|
|
25116
|
+
"[text]",
|
|
25117
|
+
"audio",
|
|
25118
|
+
"file",
|
|
25119
|
+
],
|
|
25120
|
+
fieldType
|
|
25121
|
+
)
|
|
25122
|
+
}
|
|
25123
|
+
|
|
25124
|
+
if (typeof window != 'undefined') {
|
|
25125
|
+
window.isFieldTypeSearchable = isFieldTypeSearchable;
|
|
25126
|
+
}
|
|
25127
|
+
|
|
25128
|
+
|
|
25129
|
+
function isFieldQuickSearchable(field, nameFieldKey) {
|
|
25130
|
+
let fieldSearchable = field.searchable;
|
|
25131
|
+
if(fieldSearchable !== false && field.name === nameFieldKey){
|
|
25132
|
+
// 对象上名称字段的searchable默认认为是true
|
|
25133
|
+
fieldSearchable = true;
|
|
25134
|
+
}
|
|
25135
|
+
if (fieldSearchable && QUICK_SEARCHABLE_FIELD_TYPES.indexOf(field.type) > -1) {
|
|
25136
|
+
return true;
|
|
25137
|
+
}
|
|
25138
|
+
return false;
|
|
25139
|
+
}
|
|
25140
|
+
|
|
25141
|
+
/******************************************************************************
|
|
25142
|
+
Copyright (c) Microsoft Corporation.
|
|
25143
|
+
|
|
25144
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
25145
|
+
purpose with or without fee is hereby granted.
|
|
25146
|
+
|
|
25147
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
25148
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
25149
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
25150
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
25151
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
25152
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
25153
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
25154
|
+
***************************************************************************** */
|
|
25155
|
+
|
|
25156
|
+
var __assign = function() {
|
|
25157
|
+
__assign = Object.assign || function __assign(t) {
|
|
25158
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
25159
|
+
s = arguments[i];
|
|
25160
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
25161
|
+
}
|
|
25162
|
+
return t;
|
|
25163
|
+
};
|
|
25164
|
+
return __assign.apply(this, arguments);
|
|
25165
|
+
};
|
|
25166
|
+
|
|
25167
|
+
// 方便取值的时候能够把上层的取到,但是获取的时候不会全部把所有的数据获取到。
|
|
25168
|
+
function createObject(superProps, props, properties) {
|
|
25169
|
+
if (superProps && Object.isFrozen(superProps)) {
|
|
25170
|
+
superProps = cloneObject(superProps);
|
|
25171
|
+
}
|
|
25172
|
+
var obj = superProps
|
|
25173
|
+
? Object.create(superProps, __assign(__assign({}, properties), { __super: {
|
|
25174
|
+
value: superProps,
|
|
25175
|
+
writable: false,
|
|
25176
|
+
enumerable: false
|
|
25177
|
+
} }))
|
|
25178
|
+
: Object.create(Object.prototype, properties);
|
|
25179
|
+
props &&
|
|
25180
|
+
isObject(props) &&
|
|
25181
|
+
Object.keys(props).forEach(function (key) { return (obj[key] = props[key]); });
|
|
25182
|
+
return obj;
|
|
25183
|
+
}
|
|
25184
|
+
function cloneObject(target, persistOwnProps) {
|
|
25185
|
+
if (persistOwnProps === void 0) { persistOwnProps = true; }
|
|
25186
|
+
var obj = target && target.__super
|
|
25187
|
+
? Object.create(target.__super, {
|
|
25188
|
+
__super: {
|
|
25189
|
+
value: target.__super,
|
|
25190
|
+
writable: false,
|
|
25191
|
+
enumerable: false
|
|
25087
25192
|
}
|
|
25088
|
-
|
|
25089
|
-
|
|
25090
|
-
|
|
25091
|
-
|
|
25092
|
-
|
|
25093
|
-
|
|
25094
|
-
|
|
25193
|
+
})
|
|
25194
|
+
: Object.create(Object.prototype);
|
|
25195
|
+
persistOwnProps &&
|
|
25196
|
+
target &&
|
|
25197
|
+
Object.keys(target).forEach(function (key) { return (obj[key] = target[key]); });
|
|
25198
|
+
return obj;
|
|
25199
|
+
}
|
|
25200
|
+
function isObject(obj) {
|
|
25201
|
+
var typename = typeof obj;
|
|
25202
|
+
return (obj &&
|
|
25203
|
+
typename !== 'string' &&
|
|
25204
|
+
typename !== 'number' &&
|
|
25205
|
+
typename !== 'boolean' &&
|
|
25206
|
+
typename !== 'function' &&
|
|
25207
|
+
!Array.isArray(obj));
|
|
25208
|
+
}
|
|
25209
|
+
|
|
25210
|
+
/*
|
|
25211
|
+
* @Author: baozhoutao@steedos.com
|
|
25212
|
+
* @Date: 2022-07-05 15:55:39
|
|
25213
|
+
* @LastEditors: liaodaxue
|
|
25214
|
+
* @LastEditTime: 2023-10-20 11:38:25
|
|
25215
|
+
* @Description:
|
|
25216
|
+
*/
|
|
25217
|
+
|
|
25218
|
+
let UI_SCHEMA_CACHE = {};
|
|
25219
|
+
|
|
25220
|
+
let UISchemaFunction;
|
|
25221
|
+
|
|
25222
|
+
if('undefined' != typeof window){
|
|
25223
|
+
if(!window.UI_SCHEMA_CACHE){
|
|
25224
|
+
window.UI_SCHEMA_CACHE = UI_SCHEMA_CACHE;
|
|
25225
|
+
}
|
|
25226
|
+
UI_SCHEMA_CACHE = window.UI_SCHEMA_CACHE;
|
|
25227
|
+
}
|
|
25228
|
+
|
|
25229
|
+
const setUISchemaCache = (key, value) => {
|
|
25230
|
+
UI_SCHEMA_CACHE[key] = value;
|
|
25231
|
+
};
|
|
25232
|
+
|
|
25233
|
+
const getUISchemaCache = (key) => {
|
|
25234
|
+
return lodash.exports.cloneDeep(UI_SCHEMA_CACHE[key]);
|
|
25235
|
+
};
|
|
25236
|
+
|
|
25237
|
+
const hasUISchemaCache = (key) => {
|
|
25238
|
+
return lodash.exports.has(UI_SCHEMA_CACHE, key);
|
|
25239
|
+
};
|
|
25240
|
+
|
|
25241
|
+
function getListViewColumns(listView, formFactor) {
|
|
25242
|
+
let listViewColumns = [];
|
|
25243
|
+
if (formFactor === "SMALL") {
|
|
25244
|
+
listViewColumns = !lodash.exports.isEmpty(listView.mobile_columns)
|
|
25245
|
+
? listView.mobile_columns
|
|
25246
|
+
: lodash.exports.slice(listView.columns, 0, 4);
|
|
25247
|
+
} else {
|
|
25248
|
+
listViewColumns = listView.columns;
|
|
25249
|
+
}
|
|
25250
|
+
return listViewColumns;
|
|
25251
|
+
}
|
|
25252
|
+
function getListViewSort(listView) {
|
|
25253
|
+
let sort = '';
|
|
25254
|
+
if(listView && listView.sort && listView.sort.length){
|
|
25255
|
+
lodash.exports.each(listView.sort,function(item,index){
|
|
25256
|
+
if(lodash.exports.isArray(item)){
|
|
25257
|
+
const field_name = item[0];
|
|
25258
|
+
const order = item[1] || '';
|
|
25259
|
+
let sortStr = field_name + ' ' + order;
|
|
25260
|
+
sortStr = index > 0 ? ','+sortStr : sortStr;
|
|
25261
|
+
sort += sortStr;
|
|
25262
|
+
}else {
|
|
25263
|
+
let sortStr = item.field_name + ' ' + item.order;
|
|
25264
|
+
sortStr = index > 0 ? ','+sortStr : sortStr;
|
|
25265
|
+
sort += sortStr;
|
|
25095
25266
|
}
|
|
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
|
-
}
|
|
25267
|
+
});
|
|
25268
|
+
}
|
|
25269
|
+
return sort;
|
|
25270
|
+
}
|
|
25271
|
+
function getListViewFilter(listView){
|
|
25272
|
+
if(!listView){
|
|
25273
|
+
return ;
|
|
25274
|
+
}
|
|
25275
|
+
try {
|
|
25276
|
+
const userId = getUserId();
|
|
25277
|
+
let filters = listView.filters;
|
|
25278
|
+
if(listView.filter_scope === 'mine'){
|
|
25279
|
+
if(___default.isEmpty(filters)){
|
|
25280
|
+
filters = [["owner", "=", userId]];
|
|
25281
|
+
}else {
|
|
25282
|
+
if(___default.isString(filters) && ___default.startsWith(___default.trim(filters), "function")){
|
|
25283
|
+
filters = new Function(`return ${filters}`);
|
|
25284
|
+
filters = filters();
|
|
25148
25285
|
}
|
|
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
|
-
}
|
|
25286
|
+
if(___default.isArray(filters)){
|
|
25287
|
+
filters.push(["owner", "=", userId]);
|
|
25288
|
+
}else {
|
|
25289
|
+
console.debug(`listView filters is not array`, listView);
|
|
25290
|
+
throw new Error('filters is not array')
|
|
25177
25291
|
}
|
|
25178
25292
|
}
|
|
25179
|
-
|
|
25293
|
+
};
|
|
25294
|
+
return filters;
|
|
25295
|
+
} catch (error) {
|
|
25296
|
+
console.error(error);
|
|
25180
25297
|
}
|
|
25181
|
-
|
|
25182
|
-
|
|
25183
|
-
|
|
25184
|
-
|
|
25185
|
-
|
|
25298
|
+
}
|
|
25299
|
+
|
|
25300
|
+
function formatUISchemaCache(objectName, uiSchema){
|
|
25301
|
+
setUISchemaCache(objectName, uiSchema);
|
|
25302
|
+
lodash.exports.each(uiSchema.fields, (field)=>{
|
|
25303
|
+
try {
|
|
25304
|
+
if(field.type === "lookup" && field._reference_to && ___default.isString(field._reference_to)){
|
|
25305
|
+
field.reference_to = eval(`(${field._reference_to})`)();
|
|
25306
|
+
}
|
|
25307
|
+
} catch (exception) {
|
|
25308
|
+
field.reference_to = undefined;
|
|
25309
|
+
console.error(exception);
|
|
25186
25310
|
}
|
|
25187
|
-
|
|
25188
|
-
|
|
25311
|
+
});
|
|
25312
|
+
lodash.exports.each(uiSchema.list_views, (v, k)=>{
|
|
25313
|
+
v.name = k;
|
|
25314
|
+
if(!lodash.exports.has(v, 'columns')){
|
|
25315
|
+
v.columns = uiSchema.list_views.all.columns;
|
|
25189
25316
|
}
|
|
25190
|
-
|
|
25191
|
-
|
|
25317
|
+
});
|
|
25318
|
+
}
|
|
25319
|
+
|
|
25320
|
+
async function getUISchema(objectName, force) {
|
|
25321
|
+
if (!objectName) {
|
|
25322
|
+
return;
|
|
25323
|
+
}
|
|
25324
|
+
if (hasUISchemaCache(objectName) && !force) {
|
|
25325
|
+
return getUISchemaCache(objectName);
|
|
25326
|
+
}
|
|
25327
|
+
let uiSchema = null;
|
|
25328
|
+
try {
|
|
25329
|
+
if(UISchemaFunction);
|
|
25330
|
+
else {
|
|
25331
|
+
const url = `/service/api/@${objectName.replace(/\./g, "_")}/uiSchema`;
|
|
25332
|
+
uiSchema = await fetchAPI(url, { method: "get" });
|
|
25333
|
+
}
|
|
25334
|
+
if(!uiSchema){
|
|
25335
|
+
return ;
|
|
25192
25336
|
}
|
|
25337
|
+
formatUISchemaCache(objectName, uiSchema);
|
|
25338
|
+
} catch (error) {
|
|
25339
|
+
console.error(`getUISchema`, objectName, error);
|
|
25340
|
+
setUISchemaCache(objectName, null);
|
|
25341
|
+
}
|
|
25342
|
+
return getUISchemaCache(objectName);
|
|
25343
|
+
}
|
|
25193
25344
|
|
|
25194
|
-
|
|
25195
|
-
|
|
25196
|
-
|
|
25197
|
-
|
|
25198
|
-
|
|
25345
|
+
function getUISchemaSync(objectName, force) {
|
|
25346
|
+
if (!objectName) {
|
|
25347
|
+
return;
|
|
25348
|
+
}
|
|
25349
|
+
if (hasUISchemaCache(objectName) && !force) {
|
|
25350
|
+
return getUISchemaCache(objectName);
|
|
25351
|
+
}
|
|
25352
|
+
let uiSchema = null;
|
|
25353
|
+
try {
|
|
25354
|
+
|
|
25355
|
+
const url = `/service/api/@${objectName.replace(/\./g, "_")}/uiSchema`;
|
|
25356
|
+
uiSchema = Steedos.authRequest(url, {
|
|
25357
|
+
type: 'GET',
|
|
25358
|
+
async: false,
|
|
25359
|
+
});
|
|
25360
|
+
|
|
25361
|
+
if(!uiSchema){
|
|
25362
|
+
return ;
|
|
25199
25363
|
}
|
|
25364
|
+
formatUISchemaCache(objectName, uiSchema);
|
|
25365
|
+
} catch (error) {
|
|
25366
|
+
console.error(`getUISchema`, objectName, error);
|
|
25367
|
+
setUISchemaCache(objectName, null);
|
|
25368
|
+
}
|
|
25369
|
+
return getUISchemaCache(objectName);
|
|
25370
|
+
}
|
|
25200
25371
|
|
|
25201
|
-
|
|
25202
|
-
|
|
25203
|
-
|
|
25204
|
-
|
|
25205
|
-
|
|
25206
|
-
|
|
25372
|
+
// 获取列表视图
|
|
25373
|
+
async function getListSchema(
|
|
25374
|
+
appName,
|
|
25375
|
+
objectName,
|
|
25376
|
+
listViewName,
|
|
25377
|
+
ctx = {}
|
|
25378
|
+
) {
|
|
25379
|
+
const uiSchema = await getUISchema(objectName);
|
|
25380
|
+
if(!uiSchema){
|
|
25381
|
+
return {}
|
|
25382
|
+
}
|
|
25383
|
+
const listView = lodash.exports.find(
|
|
25384
|
+
uiSchema.list_views,
|
|
25385
|
+
(listView, name) => {
|
|
25386
|
+
// 传入listViewName空值则取第一个
|
|
25387
|
+
if(!listViewName){
|
|
25388
|
+
listViewName = name;
|
|
25207
25389
|
}
|
|
25390
|
+
return name === listViewName || listView._id === listViewName;
|
|
25208
25391
|
}
|
|
25392
|
+
);
|
|
25209
25393
|
|
|
25210
|
-
|
|
25211
|
-
|
|
25212
|
-
|
|
25213
|
-
|
|
25214
|
-
|
|
25394
|
+
if (!listView) {
|
|
25395
|
+
return { uiSchema };
|
|
25396
|
+
}
|
|
25397
|
+
|
|
25398
|
+
// 直接返回自定义的列表视图schema
|
|
25399
|
+
if(listView.enable_amis_schema && listView.amis_schema){
|
|
25400
|
+
const amisSchema = lodash.exports.isString(listView.amis_schema) ? JSON.parse(listView.amis_schema) : listView.amis_schema;
|
|
25401
|
+
return {
|
|
25402
|
+
uiSchema,
|
|
25403
|
+
isCustomAmisSchema: true,
|
|
25404
|
+
amisSchema
|
|
25405
|
+
};
|
|
25406
|
+
}
|
|
25407
|
+
|
|
25408
|
+
let listViewColumns = getListViewColumns(listView, ctx.formFactor);
|
|
25409
|
+
let sort = getListViewSort(listView);
|
|
25410
|
+
let listviewFilter = getListViewFilter(listView);
|
|
25411
|
+
let listview_filters = listView && listView._filters;
|
|
25412
|
+
// 返回 calendar 组件
|
|
25413
|
+
if(listView.type === "calendar"){
|
|
25414
|
+
const amisSchema = {
|
|
25415
|
+
"type": "steedos-object-calendar",
|
|
25416
|
+
"objectApiName": objectName,
|
|
25417
|
+
"filters": listviewFilter,
|
|
25418
|
+
"filtersFunction": listview_filters,
|
|
25419
|
+
"sort": sort,
|
|
25420
|
+
...listView.options
|
|
25421
|
+
};
|
|
25422
|
+
return {
|
|
25423
|
+
uiSchema,
|
|
25424
|
+
isCalendar: true,
|
|
25425
|
+
amisSchema
|
|
25426
|
+
};
|
|
25427
|
+
}
|
|
25428
|
+
|
|
25429
|
+
const defaults = ctx.defaults || {};
|
|
25430
|
+
|
|
25431
|
+
// // 未自定义header 且显示header的时候, 使用系统header
|
|
25432
|
+
// if(!defaults.headerSchema && ctx.showHeader){
|
|
25433
|
+
// defaults.headerSchema = getObjectListHeader(uiSchema, listViewName);
|
|
25434
|
+
// }
|
|
25435
|
+
|
|
25436
|
+
// // 如果不显示header,则清理掉
|
|
25437
|
+
// if(!ctx.showHeader){
|
|
25438
|
+
// defaults.headerSchema = null;
|
|
25439
|
+
// }
|
|
25440
|
+
|
|
25441
|
+
defaults.headerSchema = null;
|
|
25442
|
+
|
|
25443
|
+
/**
|
|
25444
|
+
* 本次存储代码段
|
|
25445
|
+
*/
|
|
25446
|
+
try {
|
|
25447
|
+
const listViewPropsStoreKey = location.pathname + "/crud";
|
|
25448
|
+
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
25449
|
+
/**
|
|
25450
|
+
* localListViewProps规范来自crud请求api中api.data.$self参数值的。
|
|
25451
|
+
* 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
|
|
25452
|
+
* __searchable__...:顶部放大镜搜索条件
|
|
25453
|
+
* filter:右侧过滤器
|
|
25454
|
+
* perPage:每页条数
|
|
25455
|
+
* page:当前页码
|
|
25456
|
+
* orderBy:排序字段
|
|
25457
|
+
* orderDir:排序方向
|
|
25458
|
+
*/
|
|
25459
|
+
if (localListViewProps) {
|
|
25460
|
+
localListViewProps = JSON.parse(localListViewProps);
|
|
25461
|
+
// localListViewProps.perPage = 3;
|
|
25462
|
+
let listSchema = {};
|
|
25463
|
+
if(localListViewProps.orderBy){
|
|
25464
|
+
listSchema.orderBy = localListViewProps.orderBy;
|
|
25465
|
+
}
|
|
25466
|
+
if(localListViewProps.orderDir){
|
|
25467
|
+
listSchema.orderDir = localListViewProps.orderDir;
|
|
25215
25468
|
}
|
|
25216
25469
|
|
|
25217
|
-
if(
|
|
25218
|
-
|
|
25219
|
-
|
|
25470
|
+
if(localListViewProps.perPage){
|
|
25471
|
+
listSchema.defaultParams = {
|
|
25472
|
+
perPage: localListViewProps.perPage
|
|
25473
|
+
};
|
|
25220
25474
|
}
|
|
25221
|
-
|
|
25222
|
-
|
|
25223
|
-
// }else{
|
|
25224
|
-
// return Object.assign({}, baseData, convertData, { labelClassName: 'text-left', clearValueOnHidden: true, fieldName: field.name});
|
|
25225
|
-
// }
|
|
25475
|
+
defaults.listSchema = lodash.exports.defaultsDeep({}, listSchema, defaults.listSchema || {});
|
|
25476
|
+
}
|
|
25226
25477
|
}
|
|
25227
|
-
|
|
25478
|
+
catch (ex) {
|
|
25479
|
+
console.error("本地存储中crud参数解析异常:", ex);
|
|
25480
|
+
}
|
|
25481
|
+
|
|
25482
|
+
ctx.defaults = defaults;
|
|
25483
|
+
|
|
25484
|
+
if (listViewName == "recent") {
|
|
25485
|
+
listview_filters = `
|
|
25486
|
+
function(filters, data) {
|
|
25487
|
+
var result = Steedos.authRequest('/graphql', {
|
|
25488
|
+
type: 'POST',
|
|
25489
|
+
async: false,
|
|
25490
|
+
data: JSON.stringify({
|
|
25491
|
+
query: '{object_recent_viewed(filters: [["record.o","=","' + data.objectName + '"],["space","=","' + data.context.tenantId + '"],["owner","=","' + data.context.userId + '"]],sort:"modified desc",top:50){ _id,record} }'
|
|
25492
|
+
}),
|
|
25493
|
+
});
|
|
25494
|
+
var _ids = []
|
|
25495
|
+
result.data.object_recent_viewed.forEach(function (item) {
|
|
25496
|
+
_ids = _ids.concat(item.record.ids)
|
|
25497
|
+
})
|
|
25498
|
+
return ["_id", "=", _ids];
|
|
25499
|
+
}
|
|
25500
|
+
`;
|
|
25501
|
+
}
|
|
25502
|
+
const amisSchema = {
|
|
25503
|
+
"type": "steedos-object-table",
|
|
25504
|
+
"objectApiName": objectName,
|
|
25505
|
+
"columns": listViewColumns,
|
|
25506
|
+
"extraColumns": listView.extra_columns,
|
|
25507
|
+
"filters": listviewFilter,
|
|
25508
|
+
"filtersFunction": listview_filters,
|
|
25509
|
+
"sort": sort,
|
|
25510
|
+
"ctx": ctx,
|
|
25511
|
+
"requestAdaptor": listView.requestAdaptor || ctx.requestAdaptor,
|
|
25512
|
+
"adaptor": listView.adaptor || ctx.adaptor,
|
|
25513
|
+
"headerToolbarItems": ctx.headerToolbarItems,
|
|
25514
|
+
"filterVisible": ctx.filterVisible,
|
|
25515
|
+
"rowClassNameExpr": ctx.rowClassNameExpr,
|
|
25516
|
+
"crudDataFilter": ctx.crudDataFilter,
|
|
25517
|
+
"onCrudDataFilter": ctx.onCrudDataFilter
|
|
25518
|
+
};
|
|
25519
|
+
// console.log(`getListSchema===>`,amisSchema)
|
|
25520
|
+
return {
|
|
25521
|
+
uiSchema,
|
|
25522
|
+
amisSchema,
|
|
25523
|
+
};
|
|
25524
|
+
}
|
|
25525
|
+
|
|
25526
|
+
|
|
25527
|
+
if(typeof window != 'undefined'){
|
|
25528
|
+
window.getUISchema = getUISchema;
|
|
25529
|
+
window.getUISchemaSync = getUISchemaSync;
|
|
25530
|
+
window.getListSchema = getListSchema;
|
|
25531
|
+
}
|
|
25532
|
+
|
|
25533
|
+
function getNumberTpl(field){
|
|
25534
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
25535
|
+
}
|
|
25536
|
+
|
|
25537
|
+
function getTimeTpl(field){
|
|
25538
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
25539
|
+
}
|
|
25540
|
+
|
|
25541
|
+
function getDateTpl(field){
|
|
25542
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
25543
|
+
}
|
|
25544
|
+
|
|
25545
|
+
|
|
25546
|
+
function getDateTimeTpl(field){
|
|
25547
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
25548
|
+
}
|
|
25549
|
+
|
|
25550
|
+
function getUiFieldTpl(field){
|
|
25551
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
25552
|
+
}
|
|
25553
|
+
|
|
25554
|
+
function getUiFileSizeTpl(field){
|
|
25555
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
25556
|
+
}
|
|
25557
|
+
|
|
25558
|
+
//TODO 处理name字段
|
|
25559
|
+
async function getRefObjectNameFieldName(field){
|
|
25560
|
+
const refUiSchema = await getUISchema(field.reference_to);
|
|
25561
|
+
const NAME_FIELD_KEY = refUiSchema.NAME_FIELD_KEY || 'name';
|
|
25562
|
+
return NAME_FIELD_KEY;
|
|
25563
|
+
}
|
|
25564
|
+
|
|
25565
|
+
function getSelectTpl(field){
|
|
25566
|
+
return `<span>\${_display.${field.name}}</span>`
|
|
25567
|
+
}
|
|
25568
|
+
function getSelectMap(selectOptions){
|
|
25569
|
+
let map = {};
|
|
25570
|
+
lodash.exports.forEach(selectOptions,(option)=>{
|
|
25571
|
+
const optionValue = option.value + '';
|
|
25572
|
+
const optionColor = option.color + '';
|
|
25573
|
+
if(optionColor){
|
|
25574
|
+
const background = optionColor.charAt(0) === '#' ? optionColor : '#'+optionColor;
|
|
25575
|
+
const color = getContrastColor(background);
|
|
25576
|
+
const optionColorStyle = 'background:'+background+';color:'+color+';line-height:1.5rem';
|
|
25577
|
+
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
25578
|
+
}else {
|
|
25579
|
+
map[optionValue] = option.label;
|
|
25580
|
+
}
|
|
25581
|
+
});
|
|
25582
|
+
return map;
|
|
25228
25583
|
}
|
|
25229
25584
|
|
|
25230
|
-
|
|
25231
|
-
if(
|
|
25232
|
-
|
|
25585
|
+
function getNameTplUrl(field, ctx){
|
|
25586
|
+
if(ctx.objectName === 'cms_files'){
|
|
25587
|
+
return `\${context.rootUrl}/api/files/files/\${versions[0]}?download=true`
|
|
25233
25588
|
}
|
|
25234
|
-
|
|
25235
|
-
|
|
25236
|
-
|
|
25237
|
-
|
|
25238
|
-
|
|
25589
|
+
const href = Router.getObjectDetailPath({
|
|
25590
|
+
...ctx, formFactor: ctx.formFactor, appId: "${appId}", objectName: ctx.objectName || "${objectName}", recordId: `\${${ctx.idFieldName}}`
|
|
25591
|
+
});
|
|
25592
|
+
return href;
|
|
25593
|
+
}
|
|
25594
|
+
|
|
25595
|
+
function getNameTpl(field, ctx){
|
|
25596
|
+
const href = getNameTplUrl(field, ctx);
|
|
25597
|
+
let linkTarget = "";
|
|
25598
|
+
if(ctx && ctx.isLookup){
|
|
25599
|
+
linkTarget = "target='_blank'";
|
|
25239
25600
|
}
|
|
25601
|
+
return `<a href="${href}" ${linkTarget}>\${${field.name}}</a>`
|
|
25602
|
+
}
|
|
25240
25603
|
|
|
25241
|
-
|
|
25242
|
-
|
|
25243
|
-
|
|
25244
|
-
if(
|
|
25245
|
-
|
|
25604
|
+
function getRelatedFieldTpl(field, ctx){
|
|
25605
|
+
let tpl = '';
|
|
25606
|
+
if(!field.reference_to && (field.optionsFunction || field._optionsFunction || field.options)){
|
|
25607
|
+
if(field.isTableField){
|
|
25608
|
+
return `\${${field.name}}`
|
|
25609
|
+
}else {
|
|
25610
|
+
return `\${${field.name}__label}`
|
|
25246
25611
|
}
|
|
25612
|
+
}
|
|
25247
25613
|
|
|
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
|
-
}
|
|
25614
|
+
let linkTarget = "";
|
|
25615
|
+
if(ctx && ctx.isLookup){
|
|
25616
|
+
linkTarget = "target='_blank'";
|
|
25617
|
+
}
|
|
25256
25618
|
|
|
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
|
-
}
|
|
25619
|
+
const onlyDisplayLookLabel = ctx.onlyDisplayLookLabel;
|
|
25269
25620
|
|
|
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;
|
|
25621
|
+
let fieldDataStrTpl = `data._display.${field.name}`;
|
|
25297
25622
|
|
|
25298
|
-
|
|
25299
|
-
|
|
25300
|
-
|
|
25301
|
-
|
|
25302
|
-
|
|
25303
|
-
|
|
25304
|
-
|
|
25305
|
-
|
|
25306
|
-
|
|
25307
|
-
|
|
25308
|
-
|
|
25309
|
-
|
|
25623
|
+
if(field.isTableField){
|
|
25624
|
+
fieldDataStrTpl = `data.${field.name}`;
|
|
25625
|
+
}
|
|
25626
|
+
|
|
25627
|
+
if(_.isString(field.reference_to) || !field.reference_to){
|
|
25628
|
+
if(field.multiple){
|
|
25629
|
+
let labelTpl = `<%=item.label%>`;
|
|
25630
|
+
if(!onlyDisplayLookLabel){
|
|
25631
|
+
const href = Router.getObjectDetailPath({
|
|
25632
|
+
formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
|
|
25633
|
+
});
|
|
25634
|
+
labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
|
|
25635
|
+
}
|
|
25636
|
+
tpl = `
|
|
25637
|
+
<% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item,index) { %> <% if(index>0 && index<${fieldDataStrTpl}.length){ %> , <% } %> ${labelTpl} <% }); %><% } %>
|
|
25638
|
+
`;
|
|
25639
|
+
}else {
|
|
25640
|
+
let labelTpl = `\${_display.${field.name}.label}`;
|
|
25641
|
+
let objectNameTpl = `\${_display.${field.name}.objectName}`;
|
|
25642
|
+
let recordIdTpl = `\${_display.${field.name}.value}`;
|
|
25643
|
+
if(field.isTableField){
|
|
25644
|
+
labelTpl = `\${${field.name}.label}`;
|
|
25645
|
+
objectNameTpl = `\${${field.name}.objectName}`;
|
|
25646
|
+
recordIdTpl = `\${${field.name}.value}`;
|
|
25647
|
+
}
|
|
25648
|
+
if(!onlyDisplayLookLabel){
|
|
25649
|
+
const href = Router.getObjectDetailPath({
|
|
25650
|
+
formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
|
|
25651
|
+
});
|
|
25652
|
+
labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
|
|
25653
|
+
}
|
|
25654
|
+
tpl = labelTpl;
|
|
25310
25655
|
}
|
|
25311
25656
|
|
|
25312
|
-
|
|
25313
|
-
|
|
25314
|
-
|
|
25315
|
-
|
|
25657
|
+
|
|
25658
|
+
}else {
|
|
25659
|
+
let labelTpl = `<%=item.label%>`;
|
|
25660
|
+
if(!onlyDisplayLookLabel){
|
|
25661
|
+
const href = Router.getObjectDetailPath({
|
|
25662
|
+
formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
|
|
25316
25663
|
});
|
|
25664
|
+
labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
|
|
25317
25665
|
}
|
|
25666
|
+
tpl = `
|
|
25667
|
+
<% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item) { %> ${labelTpl} <% }); %><% } %>
|
|
25668
|
+
`;
|
|
25318
25669
|
}
|
|
25670
|
+
return tpl
|
|
25319
25671
|
}
|
|
25320
25672
|
|
|
25321
|
-
|
|
25322
|
-
|
|
25673
|
+
async function getLookupTpl(field, ctx){
|
|
25674
|
+
if(!field.reference_to){
|
|
25675
|
+
return getSelectTpl(field)
|
|
25676
|
+
}
|
|
25677
|
+
const NAME_FIELD_KEY = await getRefObjectNameFieldName(field);
|
|
25678
|
+
if(field.multiple){
|
|
25679
|
+
const href = Router.getObjectDetailPath({
|
|
25680
|
+
formFactor: ctx.formFactor, appId: ctx.appId, objectName: field.reference_to, recordId: `<%=item._id%>`, _templateType: "JavaScript"
|
|
25681
|
+
});
|
|
25682
|
+
return `
|
|
25683
|
+
<% if (data.${field.name} && data.${field.name}.length) { %><% data.${field.name}.forEach(function(item) { %> <a href="${href}"><%=item.${NAME_FIELD_KEY}%></a> <% }); %><% } %>
|
|
25684
|
+
`
|
|
25685
|
+
}else {
|
|
25686
|
+
const href = Router.getObjectDetailPath({
|
|
25687
|
+
formFactor: ctx.formFactor, appId: ctx.appId, objectName: field.reference_to, recordId: `\${${field.name}._id}`
|
|
25688
|
+
});
|
|
25689
|
+
return `<a href="${href}">\${${field.name}.${NAME_FIELD_KEY}}</a>`
|
|
25690
|
+
}
|
|
25691
|
+
|
|
25323
25692
|
}
|
|
25324
25693
|
|
|
25325
|
-
|
|
25326
|
-
|
|
25327
|
-
|
|
25328
|
-
|
|
25329
|
-
|
|
25330
|
-
|
|
25331
|
-
|
|
25332
|
-
|
|
25333
|
-
|
|
25334
|
-
|
|
25335
|
-
"[grid]",
|
|
25336
|
-
"[text]",
|
|
25337
|
-
"audio",
|
|
25338
|
-
"file",
|
|
25339
|
-
],
|
|
25340
|
-
fieldType
|
|
25341
|
-
)
|
|
25694
|
+
function getSwitchTpl(field){
|
|
25695
|
+
let fieldDataStrTpl = `data._display.${field.name}`;
|
|
25696
|
+
if(field.isTableField){
|
|
25697
|
+
fieldDataStrTpl = `data.${field.name}`;
|
|
25698
|
+
}
|
|
25699
|
+
return `<% if (data.${field.name}) { %>
|
|
25700
|
+
<span class="slds-icon_container slds-icon-utility-check slds-current-color" title="<%=${fieldDataStrTpl}%>">
|
|
25701
|
+
<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>
|
|
25702
|
+
</span>
|
|
25703
|
+
<% } %>`
|
|
25342
25704
|
}
|
|
25343
25705
|
|
|
25344
|
-
|
|
25345
|
-
|
|
25706
|
+
function getPasswordTpl(field){
|
|
25707
|
+
return `<% if (data.${field.name}) { %>
|
|
25708
|
+
<span>······</span>
|
|
25709
|
+
<% } %>`
|
|
25346
25710
|
}
|
|
25347
25711
|
|
|
25712
|
+
function getLocationTpl(field){
|
|
25713
|
+
return `\${${field.name} ? ${field.name}.address : ''}`
|
|
25714
|
+
}
|
|
25348
25715
|
|
|
25349
|
-
function
|
|
25350
|
-
|
|
25351
|
-
|
|
25352
|
-
// 对象上名称字段的searchable默认认为是true
|
|
25353
|
-
fieldSearchable = true;
|
|
25716
|
+
async function getFieldTpl (field, options){
|
|
25717
|
+
if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel){
|
|
25718
|
+
return getNameTpl(field, options)
|
|
25354
25719
|
}
|
|
25355
|
-
|
|
25356
|
-
|
|
25720
|
+
switch (field.type) {
|
|
25721
|
+
case 'password':
|
|
25722
|
+
return getPasswordTpl(field);
|
|
25723
|
+
case 'boolean':
|
|
25724
|
+
return getSwitchTpl(field);
|
|
25725
|
+
case 'toggle':
|
|
25726
|
+
return getSwitchTpl(field);
|
|
25727
|
+
case 'select':
|
|
25728
|
+
return getSelectTpl(field);
|
|
25729
|
+
case 'time':
|
|
25730
|
+
return getTimeTpl(field);
|
|
25731
|
+
case 'date':
|
|
25732
|
+
return getDateTpl(field);
|
|
25733
|
+
case 'datetime':
|
|
25734
|
+
return getDateTimeTpl(field);
|
|
25735
|
+
case 'lookup':
|
|
25736
|
+
return await getRelatedFieldTpl(field, options);
|
|
25737
|
+
case 'master_detail':
|
|
25738
|
+
return await getRelatedFieldTpl(field, options);
|
|
25739
|
+
case 'location':
|
|
25740
|
+
return await getLocationTpl(field);
|
|
25741
|
+
case 'number':
|
|
25742
|
+
case 'currency':
|
|
25743
|
+
return await getNumberTpl(field);
|
|
25744
|
+
case 'percent':
|
|
25745
|
+
case 'formula':
|
|
25746
|
+
case 'summary':
|
|
25747
|
+
return getUiFieldTpl(field)
|
|
25748
|
+
case 'filesize':
|
|
25749
|
+
return getUiFileSizeTpl(field)
|
|
25357
25750
|
}
|
|
25358
|
-
return false;
|
|
25359
25751
|
}
|
|
25360
25752
|
|
|
25361
25753
|
/*
|
|
@@ -25374,7 +25766,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
25374
25766
|
};
|
|
25375
25767
|
|
|
25376
25768
|
async function getQuickEditSchema(field, options){
|
|
25377
|
-
//判断在amis3.2
|
|
25769
|
+
//判断在amis3.2以上环境下,放开批量编辑与lookup的单元格编辑
|
|
25378
25770
|
let isAmisVersionforBatchEdit = false;
|
|
25379
25771
|
if(window.amisRequire && window.amisRequire('amis')){
|
|
25380
25772
|
isAmisVersionforBatchEdit = window.amisRequire('amis').version[0] >= 3 && window.amisRequire('amis').version[2] >= 2;
|
|
@@ -25775,6 +26167,10 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
25775
26167
|
} else {
|
|
25776
26168
|
quickEditSchema = false;
|
|
25777
26169
|
}
|
|
26170
|
+
//amis3.2以下禁用lookup的单元格编辑
|
|
26171
|
+
if(field.type == "lookup" && !isAmisVersionforBatchEdit){
|
|
26172
|
+
quickEditSchema = false;
|
|
26173
|
+
}
|
|
25778
26174
|
//TODO:附件多选时会覆盖老数据,暂时禁用
|
|
25779
26175
|
if(field.type == "file" && field.multiple){
|
|
25780
26176
|
quickEditSchema = false;
|
|
@@ -25804,10 +26200,10 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
25804
26200
|
|
|
25805
26201
|
async function getTableColumns(fields, options){
|
|
25806
26202
|
const columns = [];
|
|
25807
|
-
if(!options.isLookup){
|
|
25808
|
-
columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
|
|
26203
|
+
if(!options.isLookup && !options.isInputTable){
|
|
25809
26204
|
//将_display放入crud的columns中,可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
25810
26205
|
columns.push({name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
|
|
26206
|
+
columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
|
|
25811
26207
|
}
|
|
25812
26208
|
const allowEdit = options.permissions?.allowEdit && !options.isLookup && options.enable_inline_edit != false;
|
|
25813
26209
|
|
|
@@ -25899,14 +26295,14 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
25899
26295
|
}
|
|
25900
26296
|
else {
|
|
25901
26297
|
const tpl = await getFieldTpl(field, options);
|
|
25902
|
-
let type = 'text';
|
|
26298
|
+
let type = 'static-text';
|
|
25903
26299
|
if(tpl){
|
|
25904
26300
|
type = 'static';
|
|
25905
26301
|
}else if(field.type === 'html'){
|
|
25906
|
-
type = 'markdown';
|
|
26302
|
+
type = 'static-markdown';
|
|
25907
26303
|
}else if(field.type === 'url'){
|
|
25908
26304
|
if(field.show_as_qr){
|
|
25909
|
-
type = 'qr-code';
|
|
26305
|
+
type = 'static-qr-code';
|
|
25910
26306
|
}else {
|
|
25911
26307
|
type = 'input-url';
|
|
25912
26308
|
}
|
|
@@ -25947,7 +26343,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
25947
26343
|
}
|
|
25948
26344
|
}
|
|
25949
26345
|
// columns.push(getOperation(fields));
|
|
25950
|
-
if(!options.isLookup && !lodash.exports.some(columns, { name: options.labelFieldName })){
|
|
26346
|
+
if(!options.isLookup && !options.isInputTable && !lodash.exports.some(columns, { name: options.labelFieldName })){
|
|
25951
26347
|
// 没有名称字段时显示序号字段为链接,lookup弹出的picker不需要此功能
|
|
25952
26348
|
const href = Router.getObjectDetailPath({
|
|
25953
26349
|
...options, formFactor: options.formFactor, appId: "${appId}", objectName: options.objectName || "${objectName}", recordId: `\${${options.idFieldName}}`
|
|
@@ -26131,624 +26527,232 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
26131
26527
|
"api": {
|
|
26132
26528
|
"url": url,
|
|
26133
26529
|
"method": "get",
|
|
26134
|
-
"headers": {
|
|
26135
|
-
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
26136
|
-
}
|
|
26137
|
-
}
|
|
26138
|
-
},
|
|
26139
|
-
"actionType": "download"
|
|
26140
|
-
}
|
|
26141
|
-
],
|
|
26142
|
-
"weight": 0
|
|
26143
|
-
}
|
|
26144
|
-
}
|
|
26145
|
-
};
|
|
26146
|
-
}
|
|
26147
|
-
|
|
26148
|
-
}
|
|
26149
|
-
|
|
26150
|
-
columns.push(column);
|
|
26151
|
-
|
|
26152
|
-
|
|
26153
|
-
return columns;
|
|
26154
|
-
}
|
|
26155
|
-
|
|
26156
|
-
function getDefaultParams(options){
|
|
26157
|
-
return {
|
|
26158
|
-
perPage: options.top || options.perPage || config.listView.perPage
|
|
26159
|
-
}
|
|
26160
|
-
}
|
|
26161
|
-
|
|
26162
|
-
function getButtonVisibleOn(button){
|
|
26163
|
-
let visible= button.visible;
|
|
26164
|
-
|
|
26165
|
-
if(button._visible){
|
|
26166
|
-
visible = button._visible;
|
|
26167
|
-
}
|
|
26168
|
-
|
|
26169
|
-
if(lodash.exports.isBoolean(visible)){
|
|
26170
|
-
visible = visible.toString();
|
|
26171
|
-
}
|
|
26172
|
-
|
|
26173
|
-
if(visible){
|
|
26174
|
-
// if(visible.indexOf("Meteor.") > 0 || visible.indexOf("Creator.") > 0 || visible.indexOf("Session.") > 0){
|
|
26175
|
-
// console.warn('无效的visible', visible)
|
|
26176
|
-
// return 'false';
|
|
26177
|
-
// }
|
|
26178
|
-
if(visible.trim().startsWith('function')){
|
|
26179
|
-
return `${visible}(objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)`
|
|
26180
|
-
}
|
|
26181
|
-
return visible;
|
|
26182
|
-
}
|
|
26183
|
-
|
|
26184
|
-
if(button.type === 'amis_button'){
|
|
26185
|
-
const amisSchema = button.amis_schema;
|
|
26186
|
-
if(amisSchema && amisSchema.body && amisSchema.body.length > 0){
|
|
26187
|
-
const btn1 = amisSchema.body[0];
|
|
26188
|
-
return btn1.visibleOn
|
|
26189
|
-
}
|
|
26190
|
-
}
|
|
26191
|
-
}
|
|
26192
|
-
|
|
26193
|
-
async function getTableOperation(ctx){
|
|
26194
|
-
const buttons = ctx.buttons;
|
|
26195
|
-
const operationButtons = [];
|
|
26196
|
-
lodash.exports.each(buttons, (button)=>{
|
|
26197
|
-
if(lodash.exports.isBoolean(button.visible)){
|
|
26198
|
-
button.visible = button.visible.toString();
|
|
26199
|
-
}
|
|
26200
|
-
// operationButtons.push({
|
|
26201
|
-
// type: 'button',
|
|
26202
|
-
// label: button.label,
|
|
26203
|
-
// visibleOn: button.visible ? `${button.visible}` : (button._visible ? `${button._visible}` : null),
|
|
26204
|
-
// onEvent: {
|
|
26205
|
-
// click: {
|
|
26206
|
-
// actions: []
|
|
26207
|
-
// }
|
|
26208
|
-
// }
|
|
26209
|
-
// })
|
|
26210
|
-
|
|
26211
|
-
operationButtons.push({
|
|
26212
|
-
type: 'steedos-object-button',
|
|
26213
|
-
name: button.name,
|
|
26214
|
-
objectName: button.objectName,
|
|
26215
|
-
visibleOn: getButtonVisibleOn(button),
|
|
26216
|
-
className: 'antd-Button--default'
|
|
26217
|
-
});
|
|
26218
|
-
});
|
|
26219
|
-
if(operationButtons.length < 1){
|
|
26220
|
-
return ;
|
|
26221
|
-
}
|
|
26222
|
-
return {
|
|
26223
|
-
type: 'operation',
|
|
26224
|
-
label: "",
|
|
26225
|
-
fixed: 'right',
|
|
26226
|
-
labelClassName: 'text-center',
|
|
26227
|
-
className: 'text-center steedos-listview-operation w-10',
|
|
26228
|
-
buttons: [
|
|
26229
|
-
{
|
|
26230
|
-
"type": "steedos-dropdown-button",
|
|
26231
|
-
"label": "xxx",
|
|
26232
|
-
"buttons": operationButtons,
|
|
26233
|
-
"placement": "bottomRight",
|
|
26234
|
-
"overlayClassName": "shadow !min-w-[160px]",
|
|
26235
|
-
"trigger": ["click"],
|
|
26236
|
-
"id": "u:c2140a365019",
|
|
26237
|
-
onOpenApi: {
|
|
26238
|
-
url: `\${context.rootUrl}/service/api/@\${objectName}/recordPermissions/\${_id}`,
|
|
26239
|
-
method: "get",
|
|
26240
|
-
requestAdaptor: "api.data={}; return api;",
|
|
26241
|
-
headers: {
|
|
26242
|
-
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
26243
|
-
},
|
|
26244
|
-
adaptor: `
|
|
26245
|
-
payload = {
|
|
26246
|
-
record: {
|
|
26247
|
-
recordPermissions: payload
|
|
26248
|
-
}
|
|
26249
|
-
};
|
|
26250
|
-
return payload;
|
|
26251
|
-
`,
|
|
26252
|
-
}
|
|
26253
|
-
}
|
|
26254
|
-
]
|
|
26255
|
-
}
|
|
26256
|
-
}
|
|
26257
|
-
|
|
26258
|
-
async function getDefaultCrudCard(columns, options) {
|
|
26259
|
-
let labelFieldName = options?.labelFieldName || "name";
|
|
26260
|
-
let titleColumn, bodyColumns = [];
|
|
26261
|
-
columns.forEach(function (item) {
|
|
26262
|
-
delete item.quickEdit;
|
|
26263
|
-
delete item.width;
|
|
26264
|
-
if (item.name === labelFieldName) {
|
|
26265
|
-
titleColumn = item;
|
|
26266
|
-
}
|
|
26267
|
-
else {
|
|
26268
|
-
if (item.name !== "_index") {
|
|
26269
|
-
bodyColumns.push(item);
|
|
26270
|
-
}
|
|
26271
|
-
}
|
|
26272
|
-
});
|
|
26273
|
-
let card = {
|
|
26274
|
-
"header": {
|
|
26275
|
-
"title": titleColumn.tpl
|
|
26276
|
-
},
|
|
26277
|
-
body: bodyColumns,
|
|
26278
|
-
// useCardLabel: false,
|
|
26279
|
-
toolbar: []
|
|
26280
|
-
};
|
|
26281
|
-
let hideToolbarOperation = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
|
|
26282
|
-
if(!hideToolbarOperation){
|
|
26283
|
-
let toolbarOperation = await getTableOperation(options);
|
|
26284
|
-
if (toolbarOperation) {
|
|
26285
|
-
toolbarOperation.className += " inline-block w-auto";
|
|
26286
|
-
}
|
|
26287
|
-
card.toolbar.push(toolbarOperation);
|
|
26288
|
-
}
|
|
26289
|
-
return card;
|
|
26290
|
-
}
|
|
26291
|
-
|
|
26292
|
-
async function getTableSchema$1(fields, options){
|
|
26293
|
-
if(!options){
|
|
26294
|
-
options = {};
|
|
26295
|
-
}
|
|
26296
|
-
let { isLookup, hiddenColumnOperation } = options;
|
|
26297
|
-
const defaults = options.defaults;
|
|
26298
|
-
const listSchema = (defaults && defaults.listSchema) || {};
|
|
26299
|
-
|
|
26300
|
-
let columns = [];
|
|
26301
|
-
let useMobileColumns = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
|
|
26302
|
-
if(isLookup){
|
|
26303
|
-
// 在lookup手机端列表模式调式好之前不使用getMobileTableColumns
|
|
26304
|
-
useMobileColumns = false;
|
|
26305
|
-
}
|
|
26306
|
-
if(listSchema.mode && listSchema.mode !== "table"){
|
|
26307
|
-
// 如果指定的mode,则不走我们内置的手机端列表效果,使用steedos组件内部开发的默认card/list效果,或者由用户自己实现card/list模式的crud列表
|
|
26308
|
-
useMobileColumns = false;
|
|
26309
|
-
}
|
|
26310
|
-
if(useMobileColumns){
|
|
26311
|
-
columns = await getMobileTableColumns(fields, options);
|
|
26312
|
-
}
|
|
26313
|
-
else {
|
|
26314
|
-
columns = await getTableColumns(fields, options);
|
|
26315
|
-
|
|
26316
|
-
if(listSchema.mode === "cards"){
|
|
26317
|
-
let card = listSchema.card;
|
|
26318
|
-
if(!card){
|
|
26319
|
-
card = await getDefaultCrudCard(columns, options);
|
|
26320
|
-
}
|
|
26321
|
-
return {
|
|
26322
|
-
mode: "cards",
|
|
26323
|
-
perPageAvailable: [5, 10, 20, 50, 100, 500],
|
|
26324
|
-
name: "thelist",
|
|
26325
|
-
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
26326
|
-
className: "",
|
|
26327
|
-
draggable: false,
|
|
26328
|
-
defaultParams: getDefaultParams(options),
|
|
26329
|
-
card: card,
|
|
26330
|
-
syncLocation: false,
|
|
26331
|
-
keepItemSelectionOnPageChange: true,
|
|
26332
|
-
checkOnItemClick: isLookup ? true : false,
|
|
26333
|
-
labelTpl: `\${${options.labelFieldName}}`,
|
|
26334
|
-
autoFillHeight: false, // 自动高度效果不理想,先关闭
|
|
26335
|
-
columnsTogglable: false
|
|
26336
|
-
}
|
|
26337
|
-
}
|
|
26338
|
-
|
|
26339
|
-
if(!isLookup && !hiddenColumnOperation){
|
|
26340
|
-
columns.push(await getTableOperation(options));
|
|
26341
|
-
}
|
|
26342
|
-
}
|
|
26343
|
-
|
|
26344
|
-
return {
|
|
26345
|
-
mode: "table",
|
|
26346
|
-
perPageAvailable: [5, 10, 20, 50, 100, 500],
|
|
26347
|
-
name: "thelist",
|
|
26348
|
-
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
26349
|
-
className: "",
|
|
26350
|
-
draggable: false,
|
|
26351
|
-
defaultParams: getDefaultParams(options),
|
|
26352
|
-
columns: columns,
|
|
26353
|
-
syncLocation: false,
|
|
26354
|
-
keepItemSelectionOnPageChange: true,
|
|
26355
|
-
checkOnItemClick: isLookup ? true : false,
|
|
26356
|
-
labelTpl: `\${${options.labelFieldName}}`,
|
|
26357
|
-
autoFillHeight: false, // 自动高度效果不理想,先关闭
|
|
26358
|
-
columnsTogglable: false,
|
|
26359
|
-
}
|
|
26360
|
-
}
|
|
26361
|
-
|
|
26362
|
-
/******************************************************************************
|
|
26363
|
-
Copyright (c) Microsoft Corporation.
|
|
26364
|
-
|
|
26365
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
26366
|
-
purpose with or without fee is hereby granted.
|
|
26367
|
-
|
|
26368
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
26369
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
26370
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
26371
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
26372
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
26373
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
26374
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
26375
|
-
***************************************************************************** */
|
|
26376
|
-
|
|
26377
|
-
var __assign = function() {
|
|
26378
|
-
__assign = Object.assign || function __assign(t) {
|
|
26379
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
26380
|
-
s = arguments[i];
|
|
26381
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
26382
|
-
}
|
|
26383
|
-
return t;
|
|
26384
|
-
};
|
|
26385
|
-
return __assign.apply(this, arguments);
|
|
26386
|
-
};
|
|
26387
|
-
|
|
26388
|
-
// 方便取值的时候能够把上层的取到,但是获取的时候不会全部把所有的数据获取到。
|
|
26389
|
-
function createObject(superProps, props, properties) {
|
|
26390
|
-
if (superProps && Object.isFrozen(superProps)) {
|
|
26391
|
-
superProps = cloneObject(superProps);
|
|
26530
|
+
"headers": {
|
|
26531
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
26532
|
+
}
|
|
26533
|
+
}
|
|
26534
|
+
},
|
|
26535
|
+
"actionType": "download"
|
|
26536
|
+
}
|
|
26537
|
+
],
|
|
26538
|
+
"weight": 0
|
|
26539
|
+
}
|
|
26540
|
+
}
|
|
26541
|
+
};
|
|
26542
|
+
}
|
|
26543
|
+
|
|
26392
26544
|
}
|
|
26393
|
-
var obj = superProps
|
|
26394
|
-
? Object.create(superProps, __assign(__assign({}, properties), { __super: {
|
|
26395
|
-
value: superProps,
|
|
26396
|
-
writable: false,
|
|
26397
|
-
enumerable: false
|
|
26398
|
-
} }))
|
|
26399
|
-
: Object.create(Object.prototype, properties);
|
|
26400
|
-
props &&
|
|
26401
|
-
isObject(props) &&
|
|
26402
|
-
Object.keys(props).forEach(function (key) { return (obj[key] = props[key]); });
|
|
26403
|
-
return obj;
|
|
26404
|
-
}
|
|
26405
|
-
function cloneObject(target, persistOwnProps) {
|
|
26406
|
-
if (persistOwnProps === void 0) { persistOwnProps = true; }
|
|
26407
|
-
var obj = target && target.__super
|
|
26408
|
-
? Object.create(target.__super, {
|
|
26409
|
-
__super: {
|
|
26410
|
-
value: target.__super,
|
|
26411
|
-
writable: false,
|
|
26412
|
-
enumerable: false
|
|
26413
|
-
}
|
|
26414
|
-
})
|
|
26415
|
-
: Object.create(Object.prototype);
|
|
26416
|
-
persistOwnProps &&
|
|
26417
|
-
target &&
|
|
26418
|
-
Object.keys(target).forEach(function (key) { return (obj[key] = target[key]); });
|
|
26419
|
-
return obj;
|
|
26420
|
-
}
|
|
26421
|
-
function isObject(obj) {
|
|
26422
|
-
var typename = typeof obj;
|
|
26423
|
-
return (obj &&
|
|
26424
|
-
typename !== 'string' &&
|
|
26425
|
-
typename !== 'number' &&
|
|
26426
|
-
typename !== 'boolean' &&
|
|
26427
|
-
typename !== 'function' &&
|
|
26428
|
-
!Array.isArray(obj));
|
|
26429
|
-
}
|
|
26430
|
-
|
|
26431
|
-
/*
|
|
26432
|
-
* @Author: baozhoutao@steedos.com
|
|
26433
|
-
* @Date: 2022-07-05 15:55:39
|
|
26434
|
-
* @LastEditors: liaodaxue
|
|
26435
|
-
* @LastEditTime: 2023-10-20 11:38:25
|
|
26436
|
-
* @Description:
|
|
26437
|
-
*/
|
|
26438
26545
|
|
|
26439
|
-
|
|
26546
|
+
columns.push(column);
|
|
26547
|
+
|
|
26440
26548
|
|
|
26441
|
-
|
|
26549
|
+
return columns;
|
|
26550
|
+
}
|
|
26442
26551
|
|
|
26443
|
-
|
|
26444
|
-
|
|
26445
|
-
|
|
26552
|
+
function getDefaultParams(options){
|
|
26553
|
+
return {
|
|
26554
|
+
perPage: options.top || options.perPage || config.listView.perPage
|
|
26446
26555
|
}
|
|
26447
|
-
UI_SCHEMA_CACHE = window.UI_SCHEMA_CACHE;
|
|
26448
26556
|
}
|
|
26449
26557
|
|
|
26450
|
-
|
|
26451
|
-
|
|
26452
|
-
};
|
|
26453
|
-
|
|
26454
|
-
const getUISchemaCache = (key) => {
|
|
26455
|
-
return lodash.exports.cloneDeep(UI_SCHEMA_CACHE[key]);
|
|
26456
|
-
};
|
|
26457
|
-
|
|
26458
|
-
const hasUISchemaCache = (key) => {
|
|
26459
|
-
return lodash.exports.has(UI_SCHEMA_CACHE, key);
|
|
26460
|
-
};
|
|
26558
|
+
function getButtonVisibleOn(button){
|
|
26559
|
+
let visible= button.visible;
|
|
26461
26560
|
|
|
26462
|
-
|
|
26463
|
-
|
|
26464
|
-
if (formFactor === "SMALL") {
|
|
26465
|
-
listViewColumns = !lodash.exports.isEmpty(listView.mobile_columns)
|
|
26466
|
-
? listView.mobile_columns
|
|
26467
|
-
: lodash.exports.slice(listView.columns, 0, 4);
|
|
26468
|
-
} else {
|
|
26469
|
-
listViewColumns = listView.columns;
|
|
26561
|
+
if(button._visible){
|
|
26562
|
+
visible = button._visible;
|
|
26470
26563
|
}
|
|
26471
|
-
|
|
26472
|
-
|
|
26473
|
-
|
|
26474
|
-
let sort = '';
|
|
26475
|
-
if(listView && listView.sort && listView.sort.length){
|
|
26476
|
-
lodash.exports.each(listView.sort,function(item,index){
|
|
26477
|
-
if(lodash.exports.isArray(item)){
|
|
26478
|
-
const field_name = item[0];
|
|
26479
|
-
const order = item[1] || '';
|
|
26480
|
-
let sortStr = field_name + ' ' + order;
|
|
26481
|
-
sortStr = index > 0 ? ','+sortStr : sortStr;
|
|
26482
|
-
sort += sortStr;
|
|
26483
|
-
}else {
|
|
26484
|
-
let sortStr = item.field_name + ' ' + item.order;
|
|
26485
|
-
sortStr = index > 0 ? ','+sortStr : sortStr;
|
|
26486
|
-
sort += sortStr;
|
|
26487
|
-
}
|
|
26488
|
-
});
|
|
26564
|
+
|
|
26565
|
+
if(lodash.exports.isBoolean(visible)){
|
|
26566
|
+
visible = visible.toString();
|
|
26489
26567
|
}
|
|
26490
|
-
|
|
26491
|
-
|
|
26492
|
-
|
|
26493
|
-
|
|
26494
|
-
return ;
|
|
26568
|
+
|
|
26569
|
+
if(visible){
|
|
26570
|
+
// if(visible.indexOf("Meteor.") > 0 || visible.indexOf("Creator.") > 0 || visible.indexOf("Session.") > 0){
|
|
26571
|
+
// console.warn('无效的visible', visible)
|
|
26572
|
+
// return 'false';
|
|
26573
|
+
// }
|
|
26574
|
+
if(visible.trim().startsWith('function')){
|
|
26575
|
+
return `${visible}(objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data)`
|
|
26576
|
+
}
|
|
26577
|
+
return visible;
|
|
26495
26578
|
}
|
|
26496
|
-
|
|
26497
|
-
|
|
26498
|
-
|
|
26499
|
-
if(
|
|
26500
|
-
|
|
26501
|
-
|
|
26502
|
-
|
|
26503
|
-
if(___default.isString(filters) && ___default.startsWith(___default.trim(filters), "function")){
|
|
26504
|
-
filters = new Function(`return ${filters}`);
|
|
26505
|
-
filters = filters();
|
|
26506
|
-
}
|
|
26507
|
-
if(___default.isArray(filters)){
|
|
26508
|
-
filters.push(["owner", "=", userId]);
|
|
26509
|
-
}else {
|
|
26510
|
-
console.debug(`listView filters is not array`, listView);
|
|
26511
|
-
throw new Error('filters is not array')
|
|
26512
|
-
}
|
|
26513
|
-
}
|
|
26514
|
-
};
|
|
26515
|
-
return filters;
|
|
26516
|
-
} catch (error) {
|
|
26517
|
-
console.error(error);
|
|
26579
|
+
|
|
26580
|
+
if(button.type === 'amis_button'){
|
|
26581
|
+
const amisSchema = button.amis_schema;
|
|
26582
|
+
if(amisSchema && amisSchema.body && amisSchema.body.length > 0){
|
|
26583
|
+
const btn1 = amisSchema.body[0];
|
|
26584
|
+
return btn1.visibleOn
|
|
26585
|
+
}
|
|
26518
26586
|
}
|
|
26519
26587
|
}
|
|
26520
26588
|
|
|
26521
|
-
function
|
|
26522
|
-
|
|
26523
|
-
|
|
26524
|
-
|
|
26525
|
-
|
|
26526
|
-
|
|
26527
|
-
}
|
|
26528
|
-
} catch (exception) {
|
|
26529
|
-
field.reference_to = undefined;
|
|
26530
|
-
console.error(exception);
|
|
26531
|
-
}
|
|
26532
|
-
});
|
|
26533
|
-
lodash.exports.each(uiSchema.list_views, (v, k)=>{
|
|
26534
|
-
v.name = k;
|
|
26535
|
-
if(!lodash.exports.has(v, 'columns')){
|
|
26536
|
-
v.columns = uiSchema.list_views.all.columns;
|
|
26589
|
+
async function getTableOperation(ctx){
|
|
26590
|
+
const buttons = ctx.buttons;
|
|
26591
|
+
const operationButtons = [];
|
|
26592
|
+
lodash.exports.each(buttons, (button)=>{
|
|
26593
|
+
if(lodash.exports.isBoolean(button.visible)){
|
|
26594
|
+
button.visible = button.visible.toString();
|
|
26537
26595
|
}
|
|
26538
|
-
|
|
26539
|
-
|
|
26596
|
+
// operationButtons.push({
|
|
26597
|
+
// type: 'button',
|
|
26598
|
+
// label: button.label,
|
|
26599
|
+
// visibleOn: button.visible ? `${button.visible}` : (button._visible ? `${button._visible}` : null),
|
|
26600
|
+
// onEvent: {
|
|
26601
|
+
// click: {
|
|
26602
|
+
// actions: []
|
|
26603
|
+
// }
|
|
26604
|
+
// }
|
|
26605
|
+
// })
|
|
26540
26606
|
|
|
26541
|
-
|
|
26542
|
-
|
|
26543
|
-
|
|
26544
|
-
|
|
26545
|
-
|
|
26546
|
-
|
|
26607
|
+
operationButtons.push({
|
|
26608
|
+
type: 'steedos-object-button',
|
|
26609
|
+
name: button.name,
|
|
26610
|
+
objectName: button.objectName,
|
|
26611
|
+
visibleOn: getButtonVisibleOn(button),
|
|
26612
|
+
className: 'antd-Button--default'
|
|
26613
|
+
});
|
|
26614
|
+
});
|
|
26615
|
+
if(operationButtons.length < 1){
|
|
26616
|
+
return ;
|
|
26547
26617
|
}
|
|
26548
|
-
|
|
26549
|
-
|
|
26550
|
-
|
|
26551
|
-
|
|
26552
|
-
|
|
26553
|
-
|
|
26554
|
-
|
|
26555
|
-
|
|
26556
|
-
|
|
26557
|
-
|
|
26558
|
-
|
|
26559
|
-
|
|
26560
|
-
|
|
26561
|
-
|
|
26618
|
+
return {
|
|
26619
|
+
type: 'operation',
|
|
26620
|
+
label: " ",
|
|
26621
|
+
fixed: 'right',
|
|
26622
|
+
labelClassName: 'text-center',
|
|
26623
|
+
className: 'text-center steedos-listview-operation w-10',
|
|
26624
|
+
buttons: [
|
|
26625
|
+
{
|
|
26626
|
+
"type": "steedos-dropdown-button",
|
|
26627
|
+
"label": "xxx",
|
|
26628
|
+
"buttons": operationButtons,
|
|
26629
|
+
"placement": "bottomRight",
|
|
26630
|
+
"overlayClassName": "shadow !min-w-[160px]",
|
|
26631
|
+
"trigger": ["click"],
|
|
26632
|
+
"id": "u:c2140a365019",
|
|
26633
|
+
onOpenApi: {
|
|
26634
|
+
url: `\${context.rootUrl}/service/api/@\${objectName}/recordPermissions/\${_id}`,
|
|
26635
|
+
method: "get",
|
|
26636
|
+
requestAdaptor: "api.data={}; return api;",
|
|
26637
|
+
headers: {
|
|
26638
|
+
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
26639
|
+
},
|
|
26640
|
+
adaptor: `
|
|
26641
|
+
payload = {
|
|
26642
|
+
record: {
|
|
26643
|
+
recordPermissions: payload
|
|
26644
|
+
}
|
|
26645
|
+
};
|
|
26646
|
+
return payload;
|
|
26647
|
+
`,
|
|
26648
|
+
}
|
|
26649
|
+
}
|
|
26650
|
+
]
|
|
26562
26651
|
}
|
|
26563
|
-
return getUISchemaCache(objectName);
|
|
26564
26652
|
}
|
|
26565
26653
|
|
|
26566
|
-
function
|
|
26567
|
-
|
|
26568
|
-
|
|
26569
|
-
|
|
26570
|
-
|
|
26571
|
-
|
|
26572
|
-
|
|
26573
|
-
|
|
26574
|
-
try {
|
|
26575
|
-
|
|
26576
|
-
const url = `/service/api/@${objectName.replace(/\./g, "_")}/uiSchema`;
|
|
26577
|
-
uiSchema = Steedos.authRequest(url, {
|
|
26578
|
-
type: 'GET',
|
|
26579
|
-
async: false,
|
|
26580
|
-
});
|
|
26581
|
-
|
|
26582
|
-
if(!uiSchema){
|
|
26583
|
-
return ;
|
|
26654
|
+
async function getDefaultCrudCard(columns, options) {
|
|
26655
|
+
let labelFieldName = options?.labelFieldName || "name";
|
|
26656
|
+
let titleColumn, bodyColumns = [];
|
|
26657
|
+
columns.forEach(function (item) {
|
|
26658
|
+
delete item.quickEdit;
|
|
26659
|
+
delete item.width;
|
|
26660
|
+
if (item.name === labelFieldName) {
|
|
26661
|
+
titleColumn = item;
|
|
26584
26662
|
}
|
|
26585
|
-
|
|
26586
|
-
|
|
26587
|
-
|
|
26588
|
-
|
|
26663
|
+
else {
|
|
26664
|
+
if (item.name !== "_index") {
|
|
26665
|
+
bodyColumns.push(item);
|
|
26666
|
+
}
|
|
26667
|
+
}
|
|
26668
|
+
});
|
|
26669
|
+
let card = {
|
|
26670
|
+
"header": {
|
|
26671
|
+
"title": titleColumn.tpl
|
|
26672
|
+
},
|
|
26673
|
+
body: bodyColumns,
|
|
26674
|
+
// useCardLabel: false,
|
|
26675
|
+
toolbar: []
|
|
26676
|
+
};
|
|
26677
|
+
let hideToolbarOperation = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
|
|
26678
|
+
if(!hideToolbarOperation){
|
|
26679
|
+
let toolbarOperation = await getTableOperation(options);
|
|
26680
|
+
if (toolbarOperation) {
|
|
26681
|
+
toolbarOperation.className += " inline-block w-auto";
|
|
26682
|
+
}
|
|
26683
|
+
card.toolbar.push(toolbarOperation);
|
|
26589
26684
|
}
|
|
26590
|
-
return
|
|
26685
|
+
return card;
|
|
26591
26686
|
}
|
|
26592
26687
|
|
|
26593
|
-
|
|
26594
|
-
|
|
26595
|
-
|
|
26596
|
-
objectName,
|
|
26597
|
-
listViewName,
|
|
26598
|
-
ctx = {}
|
|
26599
|
-
) {
|
|
26600
|
-
const uiSchema = await getUISchema(objectName);
|
|
26601
|
-
if(!uiSchema){
|
|
26602
|
-
return {}
|
|
26688
|
+
async function getTableSchema(fields, options){
|
|
26689
|
+
if(!options){
|
|
26690
|
+
options = {};
|
|
26603
26691
|
}
|
|
26604
|
-
|
|
26605
|
-
|
|
26606
|
-
|
|
26607
|
-
// 传入listViewName空值则取第一个
|
|
26608
|
-
if(!listViewName){
|
|
26609
|
-
listViewName = name;
|
|
26610
|
-
}
|
|
26611
|
-
return name === listViewName || listView._id === listViewName;
|
|
26612
|
-
}
|
|
26613
|
-
);
|
|
26692
|
+
let { isLookup, hiddenColumnOperation } = options;
|
|
26693
|
+
const defaults = options.defaults;
|
|
26694
|
+
const listSchema = (defaults && defaults.listSchema) || {};
|
|
26614
26695
|
|
|
26615
|
-
|
|
26616
|
-
|
|
26696
|
+
let columns = [];
|
|
26697
|
+
let useMobileColumns = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
|
|
26698
|
+
if(isLookup){
|
|
26699
|
+
// 在lookup手机端列表模式调式好之前不使用getMobileTableColumns
|
|
26700
|
+
useMobileColumns = false;
|
|
26617
26701
|
}
|
|
26618
|
-
|
|
26619
|
-
|
|
26620
|
-
|
|
26621
|
-
const amisSchema = lodash.exports.isString(listView.amis_schema) ? JSON.parse(listView.amis_schema) : listView.amis_schema;
|
|
26622
|
-
return {
|
|
26623
|
-
uiSchema,
|
|
26624
|
-
isCustomAmisSchema: true,
|
|
26625
|
-
amisSchema
|
|
26626
|
-
};
|
|
26702
|
+
if(listSchema.mode && listSchema.mode !== "table"){
|
|
26703
|
+
// 如果指定的mode,则不走我们内置的手机端列表效果,使用steedos组件内部开发的默认card/list效果,或者由用户自己实现card/list模式的crud列表
|
|
26704
|
+
useMobileColumns = false;
|
|
26627
26705
|
}
|
|
26628
|
-
|
|
26629
|
-
|
|
26630
|
-
let sort = getListViewSort(listView);
|
|
26631
|
-
let listviewFilter = getListViewFilter(listView);
|
|
26632
|
-
let listview_filters = listView && listView._filters;
|
|
26633
|
-
// 返回 calendar 组件
|
|
26634
|
-
if(listView.type === "calendar"){
|
|
26635
|
-
const amisSchema = {
|
|
26636
|
-
"type": "steedos-object-calendar",
|
|
26637
|
-
"objectApiName": objectName,
|
|
26638
|
-
"filters": listviewFilter,
|
|
26639
|
-
"filtersFunction": listview_filters,
|
|
26640
|
-
"sort": sort,
|
|
26641
|
-
...listView.options
|
|
26642
|
-
};
|
|
26643
|
-
return {
|
|
26644
|
-
uiSchema,
|
|
26645
|
-
isCalendar: true,
|
|
26646
|
-
amisSchema
|
|
26647
|
-
};
|
|
26706
|
+
if(useMobileColumns){
|
|
26707
|
+
columns = await getMobileTableColumns(fields, options);
|
|
26648
26708
|
}
|
|
26709
|
+
else {
|
|
26710
|
+
columns = await getTableColumns(fields, options);
|
|
26649
26711
|
|
|
26650
|
-
|
|
26651
|
-
|
|
26652
|
-
|
|
26653
|
-
|
|
26654
|
-
|
|
26655
|
-
|
|
26656
|
-
|
|
26657
|
-
|
|
26658
|
-
|
|
26659
|
-
|
|
26660
|
-
|
|
26661
|
-
|
|
26662
|
-
|
|
26663
|
-
|
|
26664
|
-
|
|
26665
|
-
|
|
26666
|
-
|
|
26667
|
-
|
|
26668
|
-
|
|
26669
|
-
|
|
26670
|
-
|
|
26671
|
-
* localListViewProps规范来自crud请求api中api.data.$self参数值的。
|
|
26672
|
-
* 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
|
|
26673
|
-
* __searchable__...:顶部放大镜搜索条件
|
|
26674
|
-
* filter:右侧过滤器
|
|
26675
|
-
* perPage:每页条数
|
|
26676
|
-
* page:当前页码
|
|
26677
|
-
* orderBy:排序字段
|
|
26678
|
-
* orderDir:排序方向
|
|
26679
|
-
*/
|
|
26680
|
-
if (localListViewProps) {
|
|
26681
|
-
localListViewProps = JSON.parse(localListViewProps);
|
|
26682
|
-
// localListViewProps.perPage = 3;
|
|
26683
|
-
let listSchema = {};
|
|
26684
|
-
if(localListViewProps.orderBy){
|
|
26685
|
-
listSchema.orderBy = localListViewProps.orderBy;
|
|
26686
|
-
}
|
|
26687
|
-
if(localListViewProps.orderDir){
|
|
26688
|
-
listSchema.orderDir = localListViewProps.orderDir;
|
|
26712
|
+
if(listSchema.mode === "cards"){
|
|
26713
|
+
let card = listSchema.card;
|
|
26714
|
+
if(!card){
|
|
26715
|
+
card = await getDefaultCrudCard(columns, options);
|
|
26716
|
+
}
|
|
26717
|
+
return {
|
|
26718
|
+
mode: "cards",
|
|
26719
|
+
perPageAvailable: [5, 10, 20, 50, 100, 500],
|
|
26720
|
+
name: "thelist",
|
|
26721
|
+
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
26722
|
+
className: "",
|
|
26723
|
+
draggable: false,
|
|
26724
|
+
defaultParams: getDefaultParams(options),
|
|
26725
|
+
card: card,
|
|
26726
|
+
syncLocation: false,
|
|
26727
|
+
keepItemSelectionOnPageChange: true,
|
|
26728
|
+
checkOnItemClick: isLookup ? true : false,
|
|
26729
|
+
labelTpl: `\${${options.labelFieldName}}`,
|
|
26730
|
+
autoFillHeight: false, // 自动高度效果不理想,先关闭
|
|
26731
|
+
columnsTogglable: false
|
|
26732
|
+
}
|
|
26689
26733
|
}
|
|
26690
26734
|
|
|
26691
|
-
if(
|
|
26692
|
-
|
|
26693
|
-
perPage: localListViewProps.perPage
|
|
26694
|
-
};
|
|
26735
|
+
if(!isLookup && !hiddenColumnOperation){
|
|
26736
|
+
columns.push(await getTableOperation(options));
|
|
26695
26737
|
}
|
|
26696
|
-
defaults.listSchema = lodash.exports.defaultsDeep({}, listSchema, defaults.listSchema || {});
|
|
26697
|
-
}
|
|
26698
|
-
}
|
|
26699
|
-
catch (ex) {
|
|
26700
|
-
console.error("本地存储中crud参数解析异常:", ex);
|
|
26701
26738
|
}
|
|
26702
26739
|
|
|
26703
|
-
ctx.defaults = defaults;
|
|
26704
|
-
|
|
26705
|
-
if (listViewName == "recent") {
|
|
26706
|
-
listview_filters = `
|
|
26707
|
-
function(filters, data) {
|
|
26708
|
-
var result = Steedos.authRequest('/graphql', {
|
|
26709
|
-
type: 'POST',
|
|
26710
|
-
async: false,
|
|
26711
|
-
data: JSON.stringify({
|
|
26712
|
-
query: '{object_recent_viewed(filters: [["record.o","=","' + data.objectName + '"],["space","=","' + data.context.tenantId + '"],["owner","=","' + data.context.userId + '"]],sort:"modified desc",top:50){ _id,record} }'
|
|
26713
|
-
}),
|
|
26714
|
-
});
|
|
26715
|
-
var _ids = []
|
|
26716
|
-
result.data.object_recent_viewed.forEach(function (item) {
|
|
26717
|
-
_ids = _ids.concat(item.record.ids)
|
|
26718
|
-
})
|
|
26719
|
-
return ["_id", "=", _ids];
|
|
26720
|
-
}
|
|
26721
|
-
`;
|
|
26722
|
-
}
|
|
26723
|
-
const amisSchema = {
|
|
26724
|
-
"type": "steedos-object-table",
|
|
26725
|
-
"objectApiName": objectName,
|
|
26726
|
-
"columns": listViewColumns,
|
|
26727
|
-
"extraColumns": listView.extra_columns,
|
|
26728
|
-
"filters": listviewFilter,
|
|
26729
|
-
"filtersFunction": listview_filters,
|
|
26730
|
-
"sort": sort,
|
|
26731
|
-
"ctx": ctx,
|
|
26732
|
-
"requestAdaptor": listView.requestAdaptor || ctx.requestAdaptor,
|
|
26733
|
-
"adaptor": listView.adaptor || ctx.adaptor,
|
|
26734
|
-
"headerToolbarItems": ctx.headerToolbarItems,
|
|
26735
|
-
"filterVisible": ctx.filterVisible,
|
|
26736
|
-
"rowClassNameExpr": ctx.rowClassNameExpr,
|
|
26737
|
-
"crudDataFilter": ctx.crudDataFilter,
|
|
26738
|
-
"onCrudDataFilter": ctx.onCrudDataFilter
|
|
26739
|
-
};
|
|
26740
|
-
// console.log(`getListSchema===>`,amisSchema)
|
|
26741
26740
|
return {
|
|
26742
|
-
|
|
26743
|
-
|
|
26744
|
-
|
|
26745
|
-
|
|
26746
|
-
|
|
26747
|
-
|
|
26748
|
-
|
|
26749
|
-
|
|
26750
|
-
|
|
26751
|
-
|
|
26741
|
+
mode: "table",
|
|
26742
|
+
perPageAvailable: [5, 10, 20, 50, 100, 500],
|
|
26743
|
+
name: "thelist",
|
|
26744
|
+
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
26745
|
+
className: "",
|
|
26746
|
+
draggable: false,
|
|
26747
|
+
defaultParams: getDefaultParams(options),
|
|
26748
|
+
columns: columns,
|
|
26749
|
+
syncLocation: false,
|
|
26750
|
+
keepItemSelectionOnPageChange: true,
|
|
26751
|
+
checkOnItemClick: isLookup ? true : false,
|
|
26752
|
+
labelTpl: `\${${options.labelFieldName}}`,
|
|
26753
|
+
autoFillHeight: false, // 自动高度效果不理想,先关闭
|
|
26754
|
+
columnsTogglable: false,
|
|
26755
|
+
}
|
|
26752
26756
|
}
|
|
26753
26757
|
|
|
26754
26758
|
function useCombinedRefs(...refs) {
|