@steedos-widgets/amis-lib 1.3.8 → 1.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/index.cjs.js +223 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +223 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +211 -193
- package/dist/index.umd.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lib/input_table.d.ts +20 -0
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -182,6 +182,217 @@ const amisRender = (root, schema, data = {}, env = {}, options) => {
|
|
|
182
182
|
return amis.embed(root, schema, data, Object.assign(getEvn(router), env));
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
+
/*
|
|
186
|
+
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
187
|
+
* @Date: 2023-11-15 09:50:22
|
|
188
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
189
|
+
* @LastEditTime: 2023-11-16 18:38:21
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @param {*} props
|
|
194
|
+
* @param {*} mode edit/new/readonly
|
|
195
|
+
*/
|
|
196
|
+
function getFormFields$1(props, mode = "edit") {
|
|
197
|
+
return props.fields || [];
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @param {*} props
|
|
202
|
+
* @param {*} mode edit/new/readonly
|
|
203
|
+
*/
|
|
204
|
+
function getInputTableColumns(props) {
|
|
205
|
+
return props.fields.map(function(item){
|
|
206
|
+
return Object.assign({}, item, {
|
|
207
|
+
"type": "static"
|
|
208
|
+
});
|
|
209
|
+
}) || [];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @param {*} props
|
|
214
|
+
* @param {*} mode edit/new/readonly
|
|
215
|
+
*/
|
|
216
|
+
function getForm(props, mode = "edit") {
|
|
217
|
+
let schema = {
|
|
218
|
+
"type": "form",
|
|
219
|
+
"title": "表单",
|
|
220
|
+
"body": getFormFields$1(props, mode)
|
|
221
|
+
};
|
|
222
|
+
if (mode === "edit") {
|
|
223
|
+
Object.assign(schema, {
|
|
224
|
+
"onEvent": {
|
|
225
|
+
"submit": {
|
|
226
|
+
"weight": 0,
|
|
227
|
+
"actions": [
|
|
228
|
+
{
|
|
229
|
+
"actionType": "setValue",
|
|
230
|
+
"args": {
|
|
231
|
+
"index": "${index}",
|
|
232
|
+
"value": {
|
|
233
|
+
"&": "$$"
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
"componentId": props.id
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
else if (mode === "new") {
|
|
244
|
+
Object.assign(schema, {
|
|
245
|
+
"onEvent": {
|
|
246
|
+
"submit": {
|
|
247
|
+
"weight": 0,
|
|
248
|
+
"actions": [
|
|
249
|
+
{
|
|
250
|
+
"componentId": props.id,
|
|
251
|
+
"actionType": "addItem",
|
|
252
|
+
"args": {
|
|
253
|
+
"index": `\${${props.name}.length || 9000}`,//这里加9000是因为字段如果没放在form组件内,props.name.length拿不到值
|
|
254
|
+
"item": {
|
|
255
|
+
"&": "$$"
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
return schema;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function getButtonNew(props) {
|
|
268
|
+
return {
|
|
269
|
+
"label": "新增",
|
|
270
|
+
"type": "button",
|
|
271
|
+
"icon": "fa fa-plus",
|
|
272
|
+
"onEvent": {
|
|
273
|
+
"click": {
|
|
274
|
+
"actions": [
|
|
275
|
+
{
|
|
276
|
+
"actionType": "dialog",
|
|
277
|
+
"dialog": {
|
|
278
|
+
"type": "dialog",
|
|
279
|
+
"title": "弹框标题",
|
|
280
|
+
"body": [
|
|
281
|
+
getForm(props, "new")
|
|
282
|
+
],
|
|
283
|
+
"showCloseButton": true,
|
|
284
|
+
"showErrorMsg": true,
|
|
285
|
+
"showLoading": true,
|
|
286
|
+
"className": "app-popover",
|
|
287
|
+
"closeOnEsc": false
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
]
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
"level": "primary"
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function getButtonEdit(props) {
|
|
298
|
+
return {
|
|
299
|
+
"type": "button",
|
|
300
|
+
"label": "编辑",
|
|
301
|
+
"onEvent": {
|
|
302
|
+
"click": {
|
|
303
|
+
"actions": [
|
|
304
|
+
{
|
|
305
|
+
"actionType": "dialog",
|
|
306
|
+
"dialog": {
|
|
307
|
+
"type": "dialog",
|
|
308
|
+
"title": "弹框标题",
|
|
309
|
+
"body": [
|
|
310
|
+
getForm(props, "edit")
|
|
311
|
+
],
|
|
312
|
+
"showCloseButton": true,
|
|
313
|
+
"showErrorMsg": true,
|
|
314
|
+
"showLoading": true,
|
|
315
|
+
"className": "app-popover",
|
|
316
|
+
"closeOnEsc": false
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
]
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function getButtonDelete(props) {
|
|
326
|
+
return {
|
|
327
|
+
"type": "button",
|
|
328
|
+
"label": "删除",
|
|
329
|
+
"onEvent": {
|
|
330
|
+
"click": {
|
|
331
|
+
"actions": [
|
|
332
|
+
{
|
|
333
|
+
"actionType": "deleteItem",
|
|
334
|
+
"args": {
|
|
335
|
+
"index": "${index+','}" //这里不加逗号后续会报错,语法是逗号分隔可以删除多行
|
|
336
|
+
},
|
|
337
|
+
"componentId": props.id
|
|
338
|
+
}
|
|
339
|
+
]
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const getAmisInputTableSchema = async (props, readonly) => {
|
|
346
|
+
if (!props.id) {
|
|
347
|
+
props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
|
|
348
|
+
}
|
|
349
|
+
let buttonNewSchema = getButtonNew(props);
|
|
350
|
+
let buttonEditSchema = getButtonEdit(props);
|
|
351
|
+
let buttonDeleteSchema = getButtonDelete(props);
|
|
352
|
+
let buttonsForColumnOperations = [];
|
|
353
|
+
if(props.editable){
|
|
354
|
+
buttonsForColumnOperations.push(buttonEditSchema);
|
|
355
|
+
}
|
|
356
|
+
if(props.removable){
|
|
357
|
+
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
358
|
+
}
|
|
359
|
+
let inputTableSchema = {
|
|
360
|
+
"type": "input-table",
|
|
361
|
+
"label": props.label,
|
|
362
|
+
"name": props.name,
|
|
363
|
+
"addable": props.addable,
|
|
364
|
+
"editable": props.editable,
|
|
365
|
+
// "removable": props.removable, //不可以removable设置为true,因为会在原生的操作列显示减号操作按钮,此开关实测只控制这个按钮显示不会影响删除功能
|
|
366
|
+
"draggable": props.draggable,
|
|
367
|
+
"showIndex": props.showIndex,
|
|
368
|
+
"perPage": props.perPage,
|
|
369
|
+
"id": props.id,
|
|
370
|
+
"columns": getInputTableColumns(props),
|
|
371
|
+
"needConfirm": false,
|
|
372
|
+
"strictMode": true,
|
|
373
|
+
"showTableAddBtn": false,
|
|
374
|
+
"showFooterAddBtn": false
|
|
375
|
+
};
|
|
376
|
+
if(buttonsForColumnOperations.length){
|
|
377
|
+
inputTableSchema.columns.push({
|
|
378
|
+
"name": "__op__",
|
|
379
|
+
"type": "static",
|
|
380
|
+
"body": buttonsForColumnOperations
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
let schema = {
|
|
384
|
+
"type": "wrapper",
|
|
385
|
+
"size": "none",
|
|
386
|
+
"body": [
|
|
387
|
+
inputTableSchema
|
|
388
|
+
]
|
|
389
|
+
};
|
|
390
|
+
if(props.addable){
|
|
391
|
+
schema.body.push(buttonNewSchema);
|
|
392
|
+
}
|
|
393
|
+
return schema;
|
|
394
|
+
};
|
|
395
|
+
|
|
185
396
|
/*
|
|
186
397
|
* @Author: baozhoutao@steedos.com
|
|
187
398
|
* @Date: 2022-07-04 11:24:28
|
|
@@ -911,6 +1122,7 @@ function getSaveDataTpl(fields){
|
|
|
911
1122
|
delete formData.initialValues;
|
|
912
1123
|
delete formData.editFormInited;
|
|
913
1124
|
delete formData.isLookup;
|
|
1125
|
+
delete formData.selectedRowResponseResult;
|
|
914
1126
|
${getScriptForReadonlyFields(fields)}
|
|
915
1127
|
${getScriptForRemoveUrlPrefixForImgFields(fields)}
|
|
916
1128
|
${getScriptForSimplifiedValueForFileFields(fields)}
|
|
@@ -7813,7 +8025,7 @@ var config = {
|
|
|
7813
8025
|
};
|
|
7814
8026
|
|
|
7815
8027
|
async function getQuickEditSchema(field, options){
|
|
7816
|
-
//判断在amis3.2
|
|
8028
|
+
//判断在amis3.2以上环境下,放开批量编辑与lookup的单元格编辑
|
|
7817
8029
|
let isAmisVersionforBatchEdit = false;
|
|
7818
8030
|
if(window.amisRequire && window.amisRequire('amis')){
|
|
7819
8031
|
isAmisVersionforBatchEdit = window.amisRequire('amis').version[0] >= 3 && window.amisRequire('amis').version[2] >= 2;
|
|
@@ -8214,6 +8426,10 @@ async function getQuickEditSchema(field, options){
|
|
|
8214
8426
|
} else {
|
|
8215
8427
|
quickEditSchema = false;
|
|
8216
8428
|
}
|
|
8429
|
+
//amis3.2以下禁用lookup的单元格编辑
|
|
8430
|
+
if(field.type == "lookup" && !isAmisVersionforBatchEdit){
|
|
8431
|
+
quickEditSchema = false;
|
|
8432
|
+
}
|
|
8217
8433
|
//TODO:附件多选时会覆盖老数据,暂时禁用
|
|
8218
8434
|
if(field.type == "file" && field.multiple){
|
|
8219
8435
|
quickEditSchema = false;
|
|
@@ -8244,9 +8460,9 @@ function getFieldWidth(width){
|
|
|
8244
8460
|
async function getTableColumns(fields, options){
|
|
8245
8461
|
const columns = [];
|
|
8246
8462
|
if(!options.isLookup){
|
|
8247
|
-
columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
|
|
8248
8463
|
//将_display放入crud的columns中,可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
8249
8464
|
columns.push({name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
|
|
8465
|
+
columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
|
|
8250
8466
|
}
|
|
8251
8467
|
const allowEdit = options.permissions?.allowEdit && !options.isLookup && options.enable_inline_edit != false;
|
|
8252
8468
|
|
|
@@ -8338,14 +8554,14 @@ async function getTableColumns(fields, options){
|
|
|
8338
8554
|
}
|
|
8339
8555
|
else {
|
|
8340
8556
|
const tpl = await getFieldTpl(field, options);
|
|
8341
|
-
let type = 'text';
|
|
8557
|
+
let type = 'static-text';
|
|
8342
8558
|
if(tpl){
|
|
8343
8559
|
type = 'static';
|
|
8344
8560
|
}else if(field.type === 'html'){
|
|
8345
|
-
type = 'markdown';
|
|
8561
|
+
type = 'static-markdown';
|
|
8346
8562
|
}else if(field.type === 'url'){
|
|
8347
8563
|
if(field.show_as_qr){
|
|
8348
|
-
type = 'qr-code';
|
|
8564
|
+
type = 'static-qr-code';
|
|
8349
8565
|
}else {
|
|
8350
8566
|
type = 'input-url';
|
|
8351
8567
|
}
|
|
@@ -9497,6 +9713,7 @@ function getSaveApi(object, recordId, fields, options){
|
|
|
9497
9713
|
},
|
|
9498
9714
|
adaptor: `
|
|
9499
9715
|
if(payload.errors){
|
|
9716
|
+
delete payload.data;
|
|
9500
9717
|
payload.status = 2;
|
|
9501
9718
|
payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
|
|
9502
9719
|
}
|
|
@@ -14756,5 +14973,5 @@ const getInstanceInfo = async ({ instanceId, box }) => {
|
|
|
14756
14973
|
};
|
|
14757
14974
|
};
|
|
14758
14975
|
|
|
14759
|
-
export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn$1 as getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getGlobalNowData, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailButtonsSchemas, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectListViewButtonsSchemas, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListButtonsSchemas, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getReferenceTo, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
|
|
14976
|
+
export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getAmisInputTableSchema, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn$1 as getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getGlobalNowData, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailButtonsSchemas, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectListViewButtonsSchemas, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListButtonsSchemas, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getReferenceTo, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
|
|
14760
14977
|
//# sourceMappingURL=index.esm.js.map
|