@steedos-widgets/amis-object 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.
@@ -0,0 +1,20 @@
1
+ export declare const AmisInputTable: (props: any) => Promise<{
2
+ type: string;
3
+ size: string;
4
+ body: {
5
+ type: string;
6
+ label: any;
7
+ name: any;
8
+ addable: any;
9
+ editable: any;
10
+ draggable: any;
11
+ showIndex: any;
12
+ perPage: any;
13
+ id: any;
14
+ columns: any;
15
+ needConfirm: boolean;
16
+ strictMode: boolean;
17
+ showTableAddBtn: boolean;
18
+ showFooterAddBtn: boolean;
19
+ }[];
20
+ }>;
@@ -18,3 +18,4 @@ export * from './AmisGlobalHeader';
18
18
  export * from './AmisSteedosField';
19
19
  export * from './AmisSelectFlow';
20
20
  export * from './AmisInstanceDetail';
21
+ export * from './AmisInputTable';
@@ -1622,6 +1622,9 @@ body.steedos {
1622
1622
  .antd-Select-popover .antd-Select-menu .antd-Select-option .antd-Checkbox--checkbox {
1623
1623
  white-space: nowrap;
1624
1624
  }
1625
+ .antd-Select-popover .antd-Select-menu .antd-Select-option .antd-Checkbox--checkbox > span {
1626
+ vertical-align: middle;
1627
+ }
1625
1628
  }
1626
1629
  .steedos-object-form .steedos-input-rich-text-readonly .antd-RichTextControl {
1627
1630
  border: 0;
@@ -1803,7 +1806,7 @@ body.steedos {
1803
1806
 
1804
1807
  @media (min-width: 767px) {
1805
1808
  /* 列表快速编辑功能样式 */
1806
- .steedos-object-table thead tr th:nth-child(3) {
1809
+ .steedos-object-table thead tr th:nth-child(2) {
1807
1810
  display: none;
1808
1811
  }
1809
1812
  .steedos-object-table tbody td.antd-Field--quickEditable > div {
@@ -3351,6 +3351,217 @@ const amisRender = (root, schema, data = {}, env = {}, options) => {
3351
3351
  return amis.embed(root, schema, data, Object.assign(getEvn(router), env));
3352
3352
  };
3353
3353
 
3354
+ /*
3355
+ * @Author: 殷亮辉 yinlianghui@hotoa.com
3356
+ * @Date: 2023-11-15 09:50:22
3357
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
3358
+ * @LastEditTime: 2023-11-16 18:38:21
3359
+ */
3360
+
3361
+ /**
3362
+ * @param {*} props
3363
+ * @param {*} mode edit/new/readonly
3364
+ */
3365
+ function getFormFields$1(props, mode = "edit") {
3366
+ return props.fields || [];
3367
+ }
3368
+
3369
+ /**
3370
+ * @param {*} props
3371
+ * @param {*} mode edit/new/readonly
3372
+ */
3373
+ function getInputTableColumns(props) {
3374
+ return props.fields.map(function(item){
3375
+ return Object.assign({}, item, {
3376
+ "type": "static"
3377
+ });
3378
+ }) || [];
3379
+ }
3380
+
3381
+ /**
3382
+ * @param {*} props
3383
+ * @param {*} mode edit/new/readonly
3384
+ */
3385
+ function getForm(props, mode = "edit") {
3386
+ let schema = {
3387
+ "type": "form",
3388
+ "title": "表单",
3389
+ "body": getFormFields$1(props, mode)
3390
+ };
3391
+ if (mode === "edit") {
3392
+ Object.assign(schema, {
3393
+ "onEvent": {
3394
+ "submit": {
3395
+ "weight": 0,
3396
+ "actions": [
3397
+ {
3398
+ "actionType": "setValue",
3399
+ "args": {
3400
+ "index": "${index}",
3401
+ "value": {
3402
+ "&": "$$"
3403
+ }
3404
+ },
3405
+ "componentId": props.id
3406
+ }
3407
+ ]
3408
+ }
3409
+ }
3410
+ });
3411
+ }
3412
+ else if (mode === "new") {
3413
+ Object.assign(schema, {
3414
+ "onEvent": {
3415
+ "submit": {
3416
+ "weight": 0,
3417
+ "actions": [
3418
+ {
3419
+ "componentId": props.id,
3420
+ "actionType": "addItem",
3421
+ "args": {
3422
+ "index": `\${${props.name}.length || 9000}`,//这里加9000是因为字段如果没放在form组件内,props.name.length拿不到值
3423
+ "item": {
3424
+ "&": "$$"
3425
+ }
3426
+ }
3427
+ }
3428
+ ]
3429
+ }
3430
+ }
3431
+ });
3432
+ }
3433
+ return schema;
3434
+ }
3435
+
3436
+ function getButtonNew(props) {
3437
+ return {
3438
+ "label": "新增",
3439
+ "type": "button",
3440
+ "icon": "fa fa-plus",
3441
+ "onEvent": {
3442
+ "click": {
3443
+ "actions": [
3444
+ {
3445
+ "actionType": "dialog",
3446
+ "dialog": {
3447
+ "type": "dialog",
3448
+ "title": "弹框标题",
3449
+ "body": [
3450
+ getForm(props, "new")
3451
+ ],
3452
+ "showCloseButton": true,
3453
+ "showErrorMsg": true,
3454
+ "showLoading": true,
3455
+ "className": "app-popover",
3456
+ "closeOnEsc": false
3457
+ }
3458
+ }
3459
+ ]
3460
+ }
3461
+ },
3462
+ "level": "primary"
3463
+ };
3464
+ }
3465
+
3466
+ function getButtonEdit(props) {
3467
+ return {
3468
+ "type": "button",
3469
+ "label": "编辑",
3470
+ "onEvent": {
3471
+ "click": {
3472
+ "actions": [
3473
+ {
3474
+ "actionType": "dialog",
3475
+ "dialog": {
3476
+ "type": "dialog",
3477
+ "title": "弹框标题",
3478
+ "body": [
3479
+ getForm(props, "edit")
3480
+ ],
3481
+ "showCloseButton": true,
3482
+ "showErrorMsg": true,
3483
+ "showLoading": true,
3484
+ "className": "app-popover",
3485
+ "closeOnEsc": false
3486
+ }
3487
+ }
3488
+ ]
3489
+ }
3490
+ }
3491
+ };
3492
+ }
3493
+
3494
+ function getButtonDelete(props) {
3495
+ return {
3496
+ "type": "button",
3497
+ "label": "删除",
3498
+ "onEvent": {
3499
+ "click": {
3500
+ "actions": [
3501
+ {
3502
+ "actionType": "deleteItem",
3503
+ "args": {
3504
+ "index": "${index+','}" //这里不加逗号后续会报错,语法是逗号分隔可以删除多行
3505
+ },
3506
+ "componentId": props.id
3507
+ }
3508
+ ]
3509
+ }
3510
+ }
3511
+ };
3512
+ }
3513
+
3514
+ const getAmisInputTableSchema = async (props, readonly) => {
3515
+ if (!props.id) {
3516
+ props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
3517
+ }
3518
+ let buttonNewSchema = getButtonNew(props);
3519
+ let buttonEditSchema = getButtonEdit(props);
3520
+ let buttonDeleteSchema = getButtonDelete(props);
3521
+ let buttonsForColumnOperations = [];
3522
+ if(props.editable){
3523
+ buttonsForColumnOperations.push(buttonEditSchema);
3524
+ }
3525
+ if(props.removable){
3526
+ buttonsForColumnOperations.push(buttonDeleteSchema);
3527
+ }
3528
+ let inputTableSchema = {
3529
+ "type": "input-table",
3530
+ "label": props.label,
3531
+ "name": props.name,
3532
+ "addable": props.addable,
3533
+ "editable": props.editable,
3534
+ // "removable": props.removable, //不可以removable设置为true,因为会在原生的操作列显示减号操作按钮,此开关实测只控制这个按钮显示不会影响删除功能
3535
+ "draggable": props.draggable,
3536
+ "showIndex": props.showIndex,
3537
+ "perPage": props.perPage,
3538
+ "id": props.id,
3539
+ "columns": getInputTableColumns(props),
3540
+ "needConfirm": false,
3541
+ "strictMode": true,
3542
+ "showTableAddBtn": false,
3543
+ "showFooterAddBtn": false
3544
+ };
3545
+ if(buttonsForColumnOperations.length){
3546
+ inputTableSchema.columns.push({
3547
+ "name": "__op__",
3548
+ "type": "static",
3549
+ "body": buttonsForColumnOperations
3550
+ });
3551
+ }
3552
+ let schema = {
3553
+ "type": "wrapper",
3554
+ "size": "none",
3555
+ "body": [
3556
+ inputTableSchema
3557
+ ]
3558
+ };
3559
+ if(props.addable){
3560
+ schema.body.push(buttonNewSchema);
3561
+ }
3562
+ return schema;
3563
+ };
3564
+
3354
3565
  /*
3355
3566
  * @Author: baozhoutao@steedos.com
3356
3567
  * @Date: 2022-07-04 11:24:28
@@ -4080,6 +4291,7 @@ function getSaveDataTpl(fields){
4080
4291
  delete formData.initialValues;
4081
4292
  delete formData.editFormInited;
4082
4293
  delete formData.isLookup;
4294
+ delete formData.selectedRowResponseResult;
4083
4295
  ${getScriptForReadonlyFields(fields)}
4084
4296
  ${getScriptForRemoveUrlPrefixForImgFields(fields)}
4085
4297
  ${getScriptForSimplifiedValueForFileFields(fields)}
@@ -10982,7 +11194,7 @@ var config = {
10982
11194
  };
10983
11195
 
10984
11196
  async function getQuickEditSchema(field, options){
10985
- //判断在amis3.2以上环境下,放开批量编辑
11197
+ //判断在amis3.2以上环境下,放开批量编辑与lookup的单元格编辑
10986
11198
  let isAmisVersionforBatchEdit = false;
10987
11199
  if(window.amisRequire && window.amisRequire('amis')){
10988
11200
  isAmisVersionforBatchEdit = window.amisRequire('amis').version[0] >= 3 && window.amisRequire('amis').version[2] >= 2;
@@ -11383,6 +11595,10 @@ async function getQuickEditSchema(field, options){
11383
11595
  } else {
11384
11596
  quickEditSchema = false;
11385
11597
  }
11598
+ //amis3.2以下禁用lookup的单元格编辑
11599
+ if(field.type == "lookup" && !isAmisVersionforBatchEdit){
11600
+ quickEditSchema = false;
11601
+ }
11386
11602
  //TODO:附件多选时会覆盖老数据,暂时禁用
11387
11603
  if(field.type == "file" && field.multiple){
11388
11604
  quickEditSchema = false;
@@ -11413,9 +11629,9 @@ function getFieldWidth(width){
11413
11629
  async function getTableColumns$1(fields, options){
11414
11630
  const columns = [];
11415
11631
  if(!options.isLookup){
11416
- columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
11417
11632
  //将_display放入crud的columns中,可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
11418
11633
  columns.push({name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
11634
+ columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
11419
11635
  }
11420
11636
  const allowEdit = options.permissions?.allowEdit && !options.isLookup && options.enable_inline_edit != false;
11421
11637
 
@@ -11507,14 +11723,14 @@ async function getTableColumns$1(fields, options){
11507
11723
  }
11508
11724
  else {
11509
11725
  const tpl = await getFieldTpl(field, options);
11510
- let type = 'text';
11726
+ let type = 'static-text';
11511
11727
  if(tpl){
11512
11728
  type = 'static';
11513
11729
  }else if(field.type === 'html'){
11514
- type = 'markdown';
11730
+ type = 'static-markdown';
11515
11731
  }else if(field.type === 'url'){
11516
11732
  if(field.show_as_qr){
11517
- type = 'qr-code';
11733
+ type = 'static-qr-code';
11518
11734
  }else {
11519
11735
  type = 'input-url';
11520
11736
  }
@@ -12666,6 +12882,7 @@ function getSaveApi(object, recordId, fields, options){
12666
12882
  },
12667
12883
  adaptor: `
12668
12884
  if(payload.errors){
12885
+ delete payload.data;
12669
12886
  payload.status = 2;
12670
12887
  payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
12671
12888
  }
@@ -17942,6 +18159,7 @@ var index_esm$1 = /*#__PURE__*/Object.freeze({
17942
18159
  extendObject: extendObject,
17943
18160
  fetchAPI: fetchAPI,
17944
18161
  filtersToConditions: filtersToConditions,
18162
+ getAmisInputTableSchema: getAmisInputTableSchema,
17945
18163
  getApp: getApp,
17946
18164
  getApps: getApps,
17947
18165
  getAuthToken: getAuthToken,
@@ -20272,8 +20490,8 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
20272
20490
  /*
20273
20491
  * @Author: baozhoutao@steedos.com
20274
20492
  * @Date: 2023-01-14 16:41:24
20275
- * @LastEditors: baozhoutao@steedos.com
20276
- * @LastEditTime: 2023-09-14 13:08:43
20493
+ * @LastEditors: liaodaxue
20494
+ * @LastEditTime: 2023-11-17 10:53:59
20277
20495
  * @Description:
20278
20496
  */
20279
20497
  var getSelectFlowSchema = function (id, props) {
@@ -20425,7 +20643,7 @@ var getSelectFlowSchema = function (id, props) {
20425
20643
  method: "post",
20426
20644
  url: "${context.rootUrl}/graphql?keywords=${keywords}",
20427
20645
  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, "\", allData: ").concat(allData, "){\n value:_id\n label:name\n children: flows{\n value: _id,\n label: name\n }\n }\n }\n `\n }\n "),
20428
- adaptor: "\n var options = payload.data.options;\n if(options){\n options.forEach(function(item,index) {\n if(item.value != 'startFlows' && (!item.children || item.children.length == 0)){\n payload.data.options.splice(index,1)\n }\n })\n }\n // if(payload.data.options.length === 1 && payload.data.options[0].children.length === 1){\n // payload.data.value = payload.data.options[0].children[0].value\n // }\n return payload;\n ",
20646
+ adaptor: "\n var options = payload.data.options;\n if (options) {\n var filteredOptions = options.filter(function(item) {\n return item.value == 'startFlows' || (item.children && item.children.length > 0);\n });\n payload.data.options = filteredOptions;\n }\n // if(payload.data.options.length === 1 && payload.data.options[0].children.length === 1){\n // payload.data.value = payload.data.options[0].children[0].value\n // }\n return payload;\n ",
20429
20647
  "headers": {
20430
20648
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
20431
20649
  }
@@ -20502,6 +20720,20 @@ var AmisInstanceDetail = function (props) { return __awaiter(void 0, void 0, voi
20502
20720
  });
20503
20721
  }); };
20504
20722
 
20723
+ var AmisInputTable = function (props) { return __awaiter(void 0, void 0, void 0, function () {
20724
+ var amisSchema;
20725
+ return __generator(this, function (_a) {
20726
+ switch (_a.label) {
20727
+ case 0:
20728
+ props.$schema, props.fields, props.name, props.id, props.data;
20729
+ return [4 /*yield*/, getAmisInputTableSchema(props)];
20730
+ case 1:
20731
+ amisSchema = _a.sent();
20732
+ return [2 /*return*/, amisSchema];
20733
+ }
20734
+ });
20735
+ }); };
20736
+
20505
20737
  var PageListView = function (props) { return __awaiter(void 0, void 0, void 0, function () {
20506
20738
  var formFactor, appId, objectApiName, display, data, _display, page, listSchema;
20507
20739
  return __generator(this, function (_b) {
@@ -20695,6 +20927,7 @@ exports.AmisAppMenu = AmisAppMenu;
20695
20927
  exports.AmisGlobalFooter = AmisGlobalFooter;
20696
20928
  exports.AmisGlobalHeader = AmisGlobalHeader;
20697
20929
  exports.AmisGlobalHeaderToolbar = AmisGlobalHeaderToolbar;
20930
+ exports.AmisInputTable = AmisInputTable;
20698
20931
  exports.AmisInstanceDetail = AmisInstanceDetail;
20699
20932
  exports.AmisLib = index_esm$1;
20700
20933
  exports.AmisLogo = AmisLogo;