@steedos-widgets/amis-object 1.2.12 → 1.2.13
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/amis-object.cjs.css +3 -0
- package/dist/amis-object.cjs.js +135 -12
- package/dist/amis-object.cjs.js.map +1 -1
- package/dist/amis-object.esm.css +3 -0
- package/dist/amis-object.esm.js +135 -12
- package/dist/amis-object.esm.js.map +1 -1
- package/dist/amis-object.umd.css +3 -0
- package/dist/amis-object.umd.js +135 -12
- package/dist/amis-object.umd.js.map +1 -1
- package/dist/assets.json +11 -11
- package/package.json +3 -3
package/dist/amis-object.cjs.css
CHANGED
|
@@ -1237,6 +1237,9 @@ body {
|
|
|
1237
1237
|
-moz-column-gap: 1rem;
|
|
1238
1238
|
column-gap: 1rem;
|
|
1239
1239
|
}
|
|
1240
|
+
.steedos-amis-form .antd-Collapse .antd-Collapse-header.hidden {
|
|
1241
|
+
display: none !important;
|
|
1242
|
+
}
|
|
1240
1243
|
|
|
1241
1244
|
@media (max-width: 768px) {
|
|
1242
1245
|
.record-detail-header-name {
|
package/dist/amis-object.cjs.js
CHANGED
|
@@ -2255,7 +2255,23 @@ const getSchema$1 = (uiSchema) => {
|
|
|
2255
2255
|
{
|
|
2256
2256
|
name: "template_url",
|
|
2257
2257
|
label: "导入模板",
|
|
2258
|
-
type: "
|
|
2258
|
+
type: "button-group",
|
|
2259
|
+
buttons: [
|
|
2260
|
+
{
|
|
2261
|
+
type: "button",
|
|
2262
|
+
label: "下载",
|
|
2263
|
+
visibleOn: "${template_url}",
|
|
2264
|
+
level: "link",
|
|
2265
|
+
actionType: "download",
|
|
2266
|
+
api:{
|
|
2267
|
+
url: "${template_url}",
|
|
2268
|
+
method: "get",
|
|
2269
|
+
headers: {
|
|
2270
|
+
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
],
|
|
2259
2275
|
options: {
|
|
2260
2276
|
html: true
|
|
2261
2277
|
},
|
|
@@ -5015,12 +5031,13 @@ const getSettingListviewToolbarButtonSchema = ()=>{
|
|
|
5015
5031
|
"type": "dropdown-button",
|
|
5016
5032
|
"trigger": "click",
|
|
5017
5033
|
"icon": "fa fa-cog",
|
|
5034
|
+
"tooltip": "列表视图控制",
|
|
5018
5035
|
"btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
5019
5036
|
"align": "right",
|
|
5020
5037
|
"visibleOn": "${!isLookup}",
|
|
5021
5038
|
"buttons": [
|
|
5022
5039
|
{
|
|
5023
|
-
"label": "
|
|
5040
|
+
"label": "列表视图控制",
|
|
5024
5041
|
"children": [
|
|
5025
5042
|
getNewListviewButtonSchema(),
|
|
5026
5043
|
getCopyListviewButtonSchema(),
|
|
@@ -5054,9 +5071,11 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
|
|
|
5054
5071
|
"rightIconClassName": "m-l-sm"
|
|
5055
5072
|
}
|
|
5056
5073
|
];
|
|
5074
|
+
const displayAsLabel = displayAs === 'split'? "分栏视图" : "表格";
|
|
5057
5075
|
return {
|
|
5058
5076
|
"type": "dropdown-button",
|
|
5059
5077
|
"icon": "fa fa-table-columns",
|
|
5078
|
+
"tooltip": `显示为 ${displayAsLabel}`,
|
|
5060
5079
|
"btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
5061
5080
|
"align": "right",
|
|
5062
5081
|
"visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
|
|
@@ -5136,6 +5155,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5136
5155
|
// "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
|
|
5137
5156
|
"type": "button",
|
|
5138
5157
|
"align": "right",
|
|
5158
|
+
"tooltip": "刷新",
|
|
5139
5159
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
5140
5160
|
"label": "",
|
|
5141
5161
|
"icon": "fa fa-sync",
|
|
@@ -5155,6 +5175,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5155
5175
|
"label": "",
|
|
5156
5176
|
"icon": "fa fa-search",
|
|
5157
5177
|
"type": "button",
|
|
5178
|
+
"tooltip": "搜索",
|
|
5158
5179
|
"badge": {
|
|
5159
5180
|
"offset": [
|
|
5160
5181
|
-5,
|
|
@@ -5199,6 +5220,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5199
5220
|
{
|
|
5200
5221
|
"type": "reload",
|
|
5201
5222
|
"align": "right",
|
|
5223
|
+
"tooltip": "刷新",
|
|
5202
5224
|
"tooltipPlacement": "bottom",
|
|
5203
5225
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500"
|
|
5204
5226
|
},
|
|
@@ -5206,6 +5228,8 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5206
5228
|
filterVisible ? {
|
|
5207
5229
|
"label": "",
|
|
5208
5230
|
"icon": "fa fa-search",
|
|
5231
|
+
"tooltip": "搜索",
|
|
5232
|
+
"tooltipPlacement": "bottom",
|
|
5209
5233
|
"type": "button",
|
|
5210
5234
|
"align": "right",
|
|
5211
5235
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
@@ -6230,8 +6254,8 @@ async function getIdsPickerSchema(field, readonly, ctx){
|
|
|
6230
6254
|
/*
|
|
6231
6255
|
* @Author: baozhoutao@steedos.com
|
|
6232
6256
|
* @Date: 2023-01-13 17:27:54
|
|
6233
|
-
* @LastEditors:
|
|
6234
|
-
* @LastEditTime: 2023-
|
|
6257
|
+
* @LastEditors: Please set LastEditors
|
|
6258
|
+
* @LastEditTime: 2023-05-31 13:34:22
|
|
6235
6259
|
* @Description:
|
|
6236
6260
|
*/
|
|
6237
6261
|
|
|
@@ -6273,8 +6297,12 @@ const getMarkdownFieldSchema = (field, readonly, ctx)=>{
|
|
|
6273
6297
|
const getHtmlFieldSchema = (field, readonly, ctx)=>{
|
|
6274
6298
|
if(readonly){
|
|
6275
6299
|
return {
|
|
6276
|
-
"type": "
|
|
6277
|
-
"
|
|
6300
|
+
"type": "control",
|
|
6301
|
+
"label": field.label,
|
|
6302
|
+
"body": {
|
|
6303
|
+
"type": "html",
|
|
6304
|
+
"name": field.name
|
|
6305
|
+
}
|
|
6278
6306
|
}
|
|
6279
6307
|
}else {
|
|
6280
6308
|
return {
|
|
@@ -6301,8 +6329,8 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
|
|
|
6301
6329
|
/*
|
|
6302
6330
|
* @Author: baozhoutao@steedos.com
|
|
6303
6331
|
* @Date: 2022-10-28 14:52:55
|
|
6304
|
-
* @LastEditors:
|
|
6305
|
-
* @LastEditTime:
|
|
6332
|
+
* @LastEditors: Please set LastEditors
|
|
6333
|
+
* @LastEditTime: 2023-05-31 13:25:53
|
|
6306
6334
|
* @Description:
|
|
6307
6335
|
*/
|
|
6308
6336
|
|
|
@@ -6851,8 +6879,19 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
6851
6879
|
break;
|
|
6852
6880
|
case 'url':
|
|
6853
6881
|
convertData = {
|
|
6854
|
-
type: getAmisStaticFieldType('url', readonly)
|
|
6882
|
+
type: getAmisStaticFieldType('url', readonly, field)
|
|
6855
6883
|
};
|
|
6884
|
+
if(readonly && field.show_as_qr){
|
|
6885
|
+
convertData = {
|
|
6886
|
+
type: "control",
|
|
6887
|
+
label: field.label,
|
|
6888
|
+
body: {
|
|
6889
|
+
type: "qr-code",
|
|
6890
|
+
codeSize: 128,
|
|
6891
|
+
name: field.name
|
|
6892
|
+
}
|
|
6893
|
+
};
|
|
6894
|
+
}
|
|
6856
6895
|
break;
|
|
6857
6896
|
case 'email':
|
|
6858
6897
|
convertData = {
|
|
@@ -6887,6 +6926,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
6887
6926
|
case 'code':
|
|
6888
6927
|
convertData = {
|
|
6889
6928
|
type: "editor",
|
|
6929
|
+
disabled: readonly ? true : false,
|
|
6890
6930
|
language: field.language,
|
|
6891
6931
|
editorDidMount: new Function('editor', 'monaco', field.editorDidMount)
|
|
6892
6932
|
};
|
|
@@ -7544,12 +7584,43 @@ const getSections = async (permissionFields, formFields, ctx) => {
|
|
|
7544
7584
|
const fieldSchemaArray = getFieldSchemaArray(formFields);
|
|
7545
7585
|
const _sections = ___default__namespace.groupBy(fieldSchemaArray, 'group');
|
|
7546
7586
|
const sections = [];
|
|
7587
|
+
var sectionHeaderVisibleOn=[];
|
|
7547
7588
|
for (const key in _sections) {
|
|
7548
7589
|
const section = await getSection(formFields, permissionFields, fieldSchemaArray, key, ctx);
|
|
7549
7590
|
if(section.body.length > 0){
|
|
7591
|
+
if(section.visibleOn){
|
|
7592
|
+
sectionHeaderVisibleOn.push(section.visibleOn);
|
|
7593
|
+
}
|
|
7550
7594
|
sections.push(section);
|
|
7551
7595
|
}
|
|
7552
7596
|
}
|
|
7597
|
+
/*
|
|
7598
|
+
为了实现只有一个分组时隐藏该分组标题,需要分三种情况(分组如果没有visibleon属性就代表一定显示,有visibleon需要进行判断)
|
|
7599
|
+
1.所有分组中只有一个分组没有visibleon,还需要判断其他有visibleon的分组是否显示,只有其他都不显示时,才需要隐藏标题;反之,有任何一个显示,就不需要隐藏标题
|
|
7600
|
+
2.所有分组都有visibleon
|
|
7601
|
+
2.1 当前分组为隐藏时,标题就设置为隐藏
|
|
7602
|
+
2.2 当前分组为显示时,其他分组只要有一个是显示,就显示该分组标题
|
|
7603
|
+
2.3 当前分组为显示时,其他分组都隐藏,就隐藏该分组标题
|
|
7604
|
+
3.所有分组中有两个以上的分组没有visibleon(这种情况不用处理)
|
|
7605
|
+
*/
|
|
7606
|
+
if(ctx.mode == "edit"){
|
|
7607
|
+
if (sections.length - sectionHeaderVisibleOn.length == 1) {
|
|
7608
|
+
sections.forEach((section) => {
|
|
7609
|
+
section.headingClassName = {
|
|
7610
|
+
"hidden": `!(${sectionHeaderVisibleOn.join(" || ") || 'false'})`
|
|
7611
|
+
};
|
|
7612
|
+
});
|
|
7613
|
+
} else if (sections.length == sectionHeaderVisibleOn.length) {
|
|
7614
|
+
sections.forEach((section, index) => {
|
|
7615
|
+
var tempSectionHeaderVisibleOn = sectionHeaderVisibleOn.slice();
|
|
7616
|
+
tempSectionHeaderVisibleOn.splice(index, 1);
|
|
7617
|
+
section.headingClassName = {
|
|
7618
|
+
"hidden": `!((${tempSectionHeaderVisibleOn.join(" || ") || 'false'}) && ${sectionHeaderVisibleOn[index]})`
|
|
7619
|
+
};
|
|
7620
|
+
});
|
|
7621
|
+
}
|
|
7622
|
+
}
|
|
7623
|
+
|
|
7553
7624
|
return sections;
|
|
7554
7625
|
};
|
|
7555
7626
|
|
|
@@ -8064,6 +8135,8 @@ async function getTableColumns$1(fields, options){
|
|
|
8064
8135
|
type = 'tpl';
|
|
8065
8136
|
}else if(field.type === 'html'){
|
|
8066
8137
|
type = 'markdown';
|
|
8138
|
+
}else if(field.type === 'url' && field.show_as_qr){
|
|
8139
|
+
type = 'qr-code';
|
|
8067
8140
|
}
|
|
8068
8141
|
let className = "";
|
|
8069
8142
|
if(field.type === 'textarea'){
|
|
@@ -8091,7 +8164,13 @@ async function getTableColumns$1(fields, options){
|
|
|
8091
8164
|
|
|
8092
8165
|
}
|
|
8093
8166
|
// columns.push(getOperation(fields));
|
|
8094
|
-
|
|
8167
|
+
if(!___default__namespace.some(columns, { name: options.labelFieldName })){
|
|
8168
|
+
const href = Router$1.getObjectDetailPath({
|
|
8169
|
+
...options, formFactor: options.formFactor, appId: "${appId}", objectName: options.objectName || "${objectName}", recordId: `\${${options.idFieldName}}`
|
|
8170
|
+
});
|
|
8171
|
+
columns[0].type = "tpl";
|
|
8172
|
+
columns[0].tpl = `<a href="${href}">\${${columns[0].name}}</a>`;
|
|
8173
|
+
}
|
|
8095
8174
|
return columns;
|
|
8096
8175
|
}
|
|
8097
8176
|
|
|
@@ -8457,6 +8536,8 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8457
8536
|
|
|
8458
8537
|
const fileFields = {};
|
|
8459
8538
|
const fileFieldsKeys = [];
|
|
8539
|
+
// 含有optionsFunction属性, 无reference_to属性的lookup字段
|
|
8540
|
+
const lookupFields = {};
|
|
8460
8541
|
fields.forEach((item)=>{
|
|
8461
8542
|
if(___default__namespace.includes(['image','avatar','file'], item.type)){
|
|
8462
8543
|
fileFieldsKeys.push(item.name);
|
|
@@ -8466,6 +8547,9 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8466
8547
|
multiple: item.multiple
|
|
8467
8548
|
};
|
|
8468
8549
|
}
|
|
8550
|
+
if(___default__namespace.includes(['lookup'], item.type) && !item.reference_to ){
|
|
8551
|
+
lookupFields[item.name] = item;
|
|
8552
|
+
}
|
|
8469
8553
|
});
|
|
8470
8554
|
|
|
8471
8555
|
let valueField = mainObject.key_field || '_id';
|
|
@@ -8482,6 +8566,7 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8482
8566
|
api.data.filter = "$filter";
|
|
8483
8567
|
api.data.loaded = "${loaded}";
|
|
8484
8568
|
api.data.listViewId = "${listViewId}";
|
|
8569
|
+
api.data.listName = "${listName}";
|
|
8485
8570
|
api.requestAdaptor = `
|
|
8486
8571
|
// selfData 中的数据由 CRUD 控制. selfData中,只能获取到 CRUD 给定的data. 无法从数据链中获取数据.
|
|
8487
8572
|
let selfData = JSON.parse(JSON.stringify(api.data.$self));
|
|
@@ -8512,9 +8597,13 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8512
8597
|
console.error("本地存储中crud参数解析异常:", ex);
|
|
8513
8598
|
}
|
|
8514
8599
|
${baseFilters ? `var systemFilters = ${JSON.stringify(baseFilters)};` : 'var systemFilters = [];'}
|
|
8600
|
+
var _ids = []
|
|
8515
8601
|
const filtersFunction = ${filtersFunction};
|
|
8516
8602
|
if(filtersFunction){
|
|
8517
8603
|
const _filters = filtersFunction(systemFilters, api.data.$self);
|
|
8604
|
+
if(api.data.listName == "recent"){
|
|
8605
|
+
_ids = _filters[2]
|
|
8606
|
+
}
|
|
8518
8607
|
if(_filters && _filters.length > 0){
|
|
8519
8608
|
if(_.isEmpty(systemFilters)){
|
|
8520
8609
|
systemFilters = _filters || [];
|
|
@@ -8626,6 +8715,7 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8626
8715
|
filters = [filters, 'and', userFilters]
|
|
8627
8716
|
}
|
|
8628
8717
|
}
|
|
8718
|
+
api.data._ids = _ids;
|
|
8629
8719
|
api.data = {
|
|
8630
8720
|
query: api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim())
|
|
8631
8721
|
}
|
|
@@ -8633,6 +8723,11 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8633
8723
|
return api;
|
|
8634
8724
|
`;
|
|
8635
8725
|
api.adaptor = `
|
|
8726
|
+
if(api.body.listName == "recent"){
|
|
8727
|
+
payload.data.rows = _.sortBy(payload.data.rows, function(item){
|
|
8728
|
+
return _.indexOf(api.body._ids, item._id)
|
|
8729
|
+
});
|
|
8730
|
+
}
|
|
8636
8731
|
const enable_tree = ${mainObject.enable_tree};
|
|
8637
8732
|
if(!enable_tree){
|
|
8638
8733
|
_.each(payload.data.rows, function(item, index){
|
|
@@ -8643,9 +8738,10 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8643
8738
|
}
|
|
8644
8739
|
window.postMessage(Object.assign({type: "listview.loaded"}), "*");
|
|
8645
8740
|
let fileFields = ${JSON.stringify(fileFields)};
|
|
8741
|
+
let lookupFields = ${JSON.stringify(lookupFields)};
|
|
8646
8742
|
_.each(payload.data.rows, function(item, index){
|
|
8647
8743
|
_.each(fileFields , (field, key)=>{
|
|
8648
|
-
if(item[key] && item._display && item._display
|
|
8744
|
+
if(item[key] && item._display && item._display[key]){
|
|
8649
8745
|
let value = item._display[key];
|
|
8650
8746
|
if(!_.isArray(value)){
|
|
8651
8747
|
value = [value]
|
|
@@ -8657,6 +8753,14 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8657
8753
|
}
|
|
8658
8754
|
}
|
|
8659
8755
|
})
|
|
8756
|
+
_.each(lookupFields , (field, key)=>{
|
|
8757
|
+
if(item[key]){
|
|
8758
|
+
if(field._optionsFunction){
|
|
8759
|
+
const optionsFunction = eval("(" + field._optionsFunction+ ")")(item);
|
|
8760
|
+
item[key + '__label'] = _.map(_.filter(optionsFunction, function(option){return _.includes(item[key], option.value)}), 'label').join(' ');
|
|
8761
|
+
}
|
|
8762
|
+
}
|
|
8763
|
+
})
|
|
8660
8764
|
})
|
|
8661
8765
|
|
|
8662
8766
|
if(enable_tree){
|
|
@@ -9986,6 +10090,24 @@ async function getListSchema(
|
|
|
9986
10090
|
|
|
9987
10091
|
ctx.defaults = defaults;
|
|
9988
10092
|
|
|
10093
|
+
if (listViewName == "recent") {
|
|
10094
|
+
listview_filters = `
|
|
10095
|
+
function(filters, data) {
|
|
10096
|
+
var result = Steedos.authRequest('/graphql', {
|
|
10097
|
+
type: 'POST',
|
|
10098
|
+
async: false,
|
|
10099
|
+
data: JSON.stringify({
|
|
10100
|
+
query: '{object_recent_viewed(filters: [["record.o","=","' + data.objectName + '"],["space","=","' + data.context.tenantId + '"],["owner","=","' + data.context.userId + '"]],sort:"modified desc",top:50){ _id,record} }'
|
|
10101
|
+
}),
|
|
10102
|
+
});
|
|
10103
|
+
var _ids = []
|
|
10104
|
+
result.data.object_recent_viewed.forEach(function (item) {
|
|
10105
|
+
_ids = _ids.concat(item.record.ids)
|
|
10106
|
+
})
|
|
10107
|
+
return ["_id", "=", _ids];
|
|
10108
|
+
}
|
|
10109
|
+
`;
|
|
10110
|
+
}
|
|
9989
10111
|
const amisSchema = {
|
|
9990
10112
|
"type": "steedos-object-table",
|
|
9991
10113
|
"objectApiName": objectName,
|
|
@@ -13721,6 +13843,7 @@ var AmisObjectListView = function (props) { return __awaiter(void 0, void 0, voi
|
|
|
13721
13843
|
// className不传入crud组件,crud单独识别crudClassName属性
|
|
13722
13844
|
listSchema.className = crudClassName;
|
|
13723
13845
|
listSchema.onEvent = {}; // 为啥要将一个内置event放在此处?
|
|
13846
|
+
// 下面expression中_isRelated参数判断的是列表视图分栏模式下,新建、编辑、删除相关子表记录时不应该刷新左侧(主表)列表视图组件
|
|
13724
13847
|
listSchema.onEvent["@data.changed.".concat(objectApiName)] = {
|
|
13725
13848
|
"actions": [
|
|
13726
13849
|
{
|
|
@@ -15300,7 +15423,7 @@ var getSelectFlowSchema = function (id, props) {
|
|
|
15300
15423
|
"method": "post",
|
|
15301
15424
|
"url": "${context.rootUrl}/graphql?keywords=${keywords}",
|
|
15302
15425
|
"requestAdaptor": "\n const keywords = api.body.keywords || '';\n const appId = '".concat(data.app_id || '', "';\n api.data = {\n query: `\n {\n options: flows__getList(action: \"").concat(action, "\", keywords: \"${keywords}\", appId: \"${appId}\", distributeInstanceId: \"").concat(distributeInstanceId, "\", distributeStepId: \"").concat(distributeStepId, "\"){\n value:_id\n label:name\n children: flows{\n value: _id,\n label: name\n }\n }\n }\n `\n }\n "),
|
|
15303
|
-
"adaptor": "\n payload.data.options?.forEach(function(item,index) {\n if(!item.children || item.children.length == 0){\n payload.data.options.splice(index)\n }\n })\n return payload;\n ",
|
|
15426
|
+
"adaptor": "\n payload.data.options?.forEach(function(item,index) {\n if(!item.children || item.children.length == 0){\n payload.data.options.splice(index,1)\n }\n })\n return payload;\n ",
|
|
15304
15427
|
"headers": {
|
|
15305
15428
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
15306
15429
|
}
|