@steedos-widgets/amis-lib 1.3.22-beta.3 → 3.6.0-beta.4

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/index.cjs.js CHANGED
@@ -409,8 +409,8 @@ const Router = {
409
409
  /*
410
410
  * @Author: baozhoutao@steedos.com
411
411
  * @Date: 2022-07-20 16:29:22
412
- * @LastEditors: liaodaxue
413
- * @LastEditTime: 2023-09-11 17:19:53
412
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
413
+ * @LastEditTime: 2023-12-28 14:59:08
414
414
  * @Description:
415
415
  */
416
416
 
@@ -467,6 +467,21 @@ function getLookupListView(refObjectConfig) {
467
467
  return listView;
468
468
  }
469
469
 
470
+
471
+ /**
472
+ * 获取可比较的amis版本号
473
+ * @returns 只返回前两位版本,第三位忽略,比如3.6.3返回3.6
474
+ */
475
+ function getComparableAmisVersion() {
476
+ let amis = (window.amisRequire && window.amisRequire('amis')) || window.Amis;
477
+ let amisVersion = amis && amis.version;
478
+ if(amisVersion){
479
+ let comparableVersions = amisVersion.split(".");
480
+ let comparableVersion = parseFloat(comparableVersions[0].toString() + "." + comparableVersions[1].toString());
481
+ return comparableVersion;
482
+ }
483
+ }
484
+
470
485
  /*
471
486
  * @Author: baozhoutao@steedos.com
472
487
  * @Date: 2022-05-23 09:53:08
@@ -1825,7 +1840,7 @@ async function getQuickEditSchema(field, options){
1825
1840
  "actions":[
1826
1841
  {
1827
1842
  "actionType": "setValue",
1828
- "componentId": `service_listview_${options.objectName}`,
1843
+ "componentId": quickEditId,
1829
1844
  "args": {
1830
1845
  "value":{
1831
1846
  "quickedit_record_permissions_loading": true
@@ -1850,7 +1865,7 @@ async function getQuickEditSchema(field, options){
1850
1865
  },
1851
1866
  {
1852
1867
  "actionType": "setValue",
1853
- "componentId": `service_listview_${options.objectName}`,
1868
+ "componentId": quickEditId,
1854
1869
  "args": {
1855
1870
  "value":{
1856
1871
  "quickedit_record_permissions_loading": false
@@ -1859,7 +1874,7 @@ async function getQuickEditSchema(field, options){
1859
1874
  },
1860
1875
  {
1861
1876
  "actionType": "setValue",
1862
- "componentId": `service_listview_${options.objectName}`,
1877
+ "componentId": quickEditId,
1863
1878
  "args": {
1864
1879
  "value":{
1865
1880
  "quickedit_record_permissions": "${event.data}"
@@ -2038,8 +2053,6 @@ function getFieldWidth(width){
2038
2053
  async function getTableColumns(fields, options){
2039
2054
  const columns = [];
2040
2055
  if(!options.isLookup && !options.isInputTable){
2041
- //将_display放入crud的columns中,可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
2042
- columns.push({name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
2043
2056
  if(!options.enable_tree){
2044
2057
  columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
2045
2058
  }
@@ -2197,8 +2210,8 @@ async function getTableColumns(fields, options){
2197
2210
  const href = Router.getObjectDetailPath({
2198
2211
  ...options, formFactor: options.formFactor, appId: "${appId}", objectName: options.objectName || "${objectName}", recordId: `\${${options.idFieldName}}`
2199
2212
  });
2200
- columns[1].type = "tpl";
2201
- columns[1].tpl = `<a href="${href}">\${${columns[1].name}}</a>`;
2213
+ columns[0].type = "tpl";
2214
+ columns[0].tpl = `<a href="${href}">\${${columns[0].name}}</a>`;
2202
2215
  }
2203
2216
  return columns;
2204
2217
  }
@@ -2584,6 +2597,7 @@ async function getTableSchema$1(fields, options){
2584
2597
  if(!isLookup && !hiddenColumnOperation){
2585
2598
  columns.push(await getTableOperation(options));
2586
2599
  }
2600
+
2587
2601
  }
2588
2602
 
2589
2603
  return {
@@ -3692,6 +3706,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
3692
3706
  "dialog": {
3693
3707
  "type": "dialog",
3694
3708
  "title": title,
3709
+ data,
3695
3710
  "body": [
3696
3711
  {
3697
3712
  "type": "steedos-object-form",
@@ -8364,6 +8379,11 @@ async function getObjectCRUD(objectSchema, fields, options){
8364
8379
  crudModeClassName = `steedos-crud-mode-${body.mode}`;
8365
8380
  }
8366
8381
 
8382
+ if(body.columns && options.formFactor != 'SMALL'){
8383
+ //将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
8384
+ body.columns.splice(body.columns.length - 1, 0, {name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
8385
+ }
8386
+
8367
8387
  if (defaults) {
8368
8388
  const headerSchema = defaults.headerSchema;
8369
8389
  const footerSchema = defaults.footerSchema;
@@ -8388,6 +8408,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8388
8408
  body = wrappedBody;
8389
8409
  }
8390
8410
  }
8411
+
8391
8412
  // console.timeEnd('getObjectCRUD');
8392
8413
  // TODO: data应该只留loaded,其他属性都改为从上层传递下来
8393
8414
  return {
@@ -10590,6 +10611,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
10590
10611
  */
10591
10612
  return payload;
10592
10613
  }
10614
+ if(!payload.data.rows){
10615
+ payload.data.rows = [];
10616
+ }
10593
10617
  if(enable_tree){
10594
10618
  const records = payload.data.rows;
10595
10619
  const treeRecords = [];
@@ -10870,7 +10894,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
10870
10894
  sendOn.push(`this.${fName}`);
10871
10895
  });
10872
10896
  if(depend_on.length > 0){
10873
- apiInfo.url = `${apiInfo.url}?${depend_on.join('&')}`;
10897
+ apiInfo.url = `${apiInfo.url}&${depend_on.join('&')}`;
10874
10898
  apiInfo.sendOn = `${sendOn.join(' && ')}`;
10875
10899
  }
10876
10900
  }
@@ -10978,6 +11002,13 @@ async function lookupToAmisSelect(field, readonly, ctx){
10978
11002
  autoComplete: apiInfo,
10979
11003
  searchable: true,
10980
11004
  };
11005
+ let amisVersion = getComparableAmisVersion();
11006
+ if(amisVersion >= 3.6){
11007
+ // amis 3.6中不加source会造成子表组件中弹出行编辑窗口的lookup字段有时不请求接口(概率现象,同一个地方反复操作有时请求有时不请求)
11008
+ // 但是同时配置autoComplete和source会多请求一次接口
11009
+ // TODO:应该想办法把是否字段在子表组件内,即ctx.isInputTable,如果不在子表组件内不需要加source
11010
+ data.source = apiInfo;
11011
+ }
10981
11012
  //删除xlink:href中的rootUrl前缀,解决客户端svg为空的问题
10982
11013
  const select_menuTpl = `<span class='flex items-center mt-0.5'>
10983
11014
  <span role='img' aria-label='smile' class='anticon anticon-smile'>
@@ -11337,9 +11368,9 @@ const OMIT_FIELDS = ['created', 'created_by', 'modified', 'modified_by'];
11337
11368
  // const Lookup = require('./lookup');
11338
11369
 
11339
11370
  function getBaseFields(readonly){
11340
- let calssName = 'm-1';
11371
+ let className = 'm-0';
11341
11372
  if(readonly){
11342
- calssName = `${calssName}`;
11373
+ className = `${className}`;
11343
11374
  }
11344
11375
  return [
11345
11376
  {
@@ -11347,7 +11378,7 @@ function getBaseFields(readonly){
11347
11378
  label: "创建人",
11348
11379
  type: "static",
11349
11380
  labelClassName: 'text-left',
11350
- className: calssName,
11381
+ className: className,
11351
11382
  tpl: getCreatedInfoTpl()
11352
11383
  },
11353
11384
  {
@@ -11355,7 +11386,7 @@ function getBaseFields(readonly){
11355
11386
  label: "修改人",
11356
11387
  type: "static",
11357
11388
  labelClassName: 'text-left',
11358
- className: calssName,
11389
+ className: className,
11359
11390
  tpl: getModifiedInfoTpl()
11360
11391
  }
11361
11392
  ]
@@ -12051,9 +12082,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12051
12082
  }
12052
12083
  if(!___namespace.isEmpty(convertData)){
12053
12084
  if(field.is_wide || convertData.type === 'group'){
12054
- convertData.className = 'col-span-2 m-1';
12085
+ convertData.className = 'col-span-2 m-0';
12055
12086
  }else {
12056
- convertData.className = 'm-1';
12087
+ convertData.className = 'm-0';
12057
12088
  }
12058
12089
  if(readonly){
12059
12090
  convertData.className = `${convertData.className} border-b`;
@@ -12459,7 +12490,7 @@ async function getFormBody(permissionFields, formFields, ctx){
12459
12490
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12460
12491
  * @Date: 2023-11-15 09:50:22
12461
12492
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12462
- * @LastEditTime: 2023-12-25 13:13:56
12493
+ * @LastEditTime: 2023-12-28 15:54:36
12463
12494
  */
12464
12495
 
12465
12496
  /**
@@ -12487,20 +12518,22 @@ function getInputTableCell(field, showAsInlineEditMode) {
12487
12518
  name: field.name,
12488
12519
  quickEdit: {
12489
12520
  "type": "steedos-field",
12490
- "config": field,
12491
- hideLabel: true
12521
+ "config": Object.assign({}, field, {
12522
+ label: false
12523
+ })
12492
12524
  }
12493
12525
  }
12494
12526
  }
12495
12527
  else {
12496
12528
  return {
12497
12529
  "type": "steedos-field",
12498
- "config": field,
12530
+ "config": Object.assign({}, field, {
12531
+ label: false
12532
+ }),
12499
12533
  "static": true,
12500
12534
  "readonly": true,
12501
12535
  label: field.label,
12502
- name: field.name,
12503
- hideLabel: true
12536
+ name: field.name
12504
12537
  }
12505
12538
  }
12506
12539
  }
@@ -12746,7 +12779,9 @@ function getFormPaginationWrapper(props, form, mode) {
12746
12779
  let __wrapperServiceId = "${tableServiceId}";
12747
12780
  let wrapperService = scope.getComponentById(__wrapperServiceId);
12748
12781
  let wrapperServiceData = wrapperService.getData();
12749
- let lastestFieldValue = wrapperServiceData["${props.name}"] || [];//这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
12782
+ // 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
12783
+ // 这里如果不.clone的话,在弹出窗口中显示的子表组件,添加行后点窗口的取消按钮关闭窗口后无法把之前的操作还原,即把之前添加的行自动移除
12784
+ let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"] || []);
12750
12785
  //不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
12751
12786
  let mode = "${mode}";
12752
12787
  if(mode === "new"){
@@ -12936,6 +12971,11 @@ async function getButtonActions(props, mode) {
12936
12971
  let dialogId = getComponentId("dialog", props.id);
12937
12972
  let buttonNextId = getComponentId("button_next", props.id);
12938
12973
  let formPaginationId = getComponentId("form_pagination", props.id);
12974
+ let parentFormData = "${__super.__super.__super.__super || {}}";
12975
+ let amisVersion = getComparableAmisVersion();
12976
+ if(amisVersion < 3.6){
12977
+ parentFormData = "${__super.__super || {}}";
12978
+ }
12939
12979
  if (mode == "new" || mode == "edit") {
12940
12980
  // let actionShowNewDialog = {
12941
12981
  // "actionType": "dialog",
@@ -13077,7 +13117,8 @@ async function getButtonActions(props, mode) {
13077
13117
  // 换成从__super来映射上级表单数据是因为对象列表视图界面中每行下拉菜单中的编辑按钮弹出的表单中的子表所在作用域中没有record变量
13078
13118
  // 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
13079
13119
  // "__parentForm": "${__super.__super || {}}",
13080
- "__parentForm": mode == "new" ? "$$" : "${__super.__super || {}}",
13120
+ // "__parentForm": mode == "new" ? "$$" : "${__super.__super || {}}",
13121
+ "__parentForm": mode == "new" ? "$$" : parentFormData,
13081
13122
  "global": "${global}",
13082
13123
  "uiSchema": "${uiSchema}",
13083
13124
  "index": "${index}",
@@ -13170,7 +13211,7 @@ async function getButtonActions(props, mode) {
13170
13211
  // 换成从__super来映射上级表单数据是因为对象列表视图界面中每行下拉菜单中的编辑按钮弹出的表单中的子表所在作用域中没有record变量
13171
13212
  // 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
13172
13213
  // "__parentForm": "${__super.__super || {}}",
13173
- "__parentForm": "${__super.__super || {}}",
13214
+ "__parentForm": parentFormData,
13174
13215
  "global": "${global}",
13175
13216
  "uiSchema": "${uiSchema}",
13176
13217
  "index": "${index}",
@@ -13338,7 +13379,7 @@ const getAmisInputTableSchema = async (props) => {
13338
13379
  "name": "__op__",
13339
13380
  "type": "operation",
13340
13381
  "buttons": buttonsForColumnOperations,
13341
- "width": buttonsForColumnOperations.length > 1 ? "46px" : "20px"
13382
+ "width": buttonsForColumnOperations.length > 1 ? "60px" : "20px"
13342
13383
  });
13343
13384
  }
13344
13385
  if (showAsInlineEditMode) {