@steedos-widgets/amis-lib 3.6.2-beta.11 → 3.6.2-beta.12

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
@@ -381,6 +381,9 @@ const Router = {
381
381
  if(uiSchema.enable_split){
382
382
  defaultDisplay = "split";
383
383
  }
384
+ if(window.innerWidth <= 768){
385
+ return "grid";
386
+ }
384
387
  return value ? value : defaultDisplay;
385
388
  },
386
389
 
@@ -2064,7 +2067,7 @@ async function getQuickEditSchema(field, options){
2064
2067
  }
2065
2068
 
2066
2069
  function getFieldWidth(width){
2067
- const defaultWidth = "unset";//用于使table内的td标签下生成div,实现将快速编辑按钮固定在右侧的效果,并不是为了unset效果
2070
+ const defaultWidth = null;
2068
2071
  if(typeof width == 'string'){
2069
2072
  if(isNaN(width)){
2070
2073
  return width || defaultWidth;
@@ -2094,14 +2097,14 @@ async function getTableColumns(fields, options){
2094
2097
  //增加quickEdit属性,实现快速编辑
2095
2098
  const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
2096
2099
  let className = "";
2097
- if(field.wrap != true){
2098
- if(field.wrap != false && field.is_wide){
2099
- className += " break-words ";
2100
- }else {
2100
+ if(/Safari/.test(navigator.userAgent)){
2101
+ className += " whitespace-nowrap ";
2102
+ }else {
2103
+ if(field.wrap != true){
2101
2104
  className += " whitespace-nowrap ";
2105
+ }else {
2106
+ className += " break-words ";
2102
2107
  }
2103
- }else {
2104
- className += " break-words ";
2105
2108
  }
2106
2109
  let columnItem;
2107
2110
  if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
@@ -10659,17 +10662,13 @@ function getReferenceToSync(field) {
10659
10662
 
10660
10663
  function getLookupSapceUserTreeSchema(isMobile){
10661
10664
  let apiAdaptor = `
10662
- // console.log("===getLookupSapceUserTreeSchema===", JSON.stringify(payload));
10663
10665
  const records = payload.data.options;
10664
- let isTreeOptionsComputed = false;
10665
- if(records.length === 1 && records[0].children){
10666
- isTreeOptionsComputed = true;
10667
- }
10668
- if(isTreeOptionsComputed){
10669
- return payload;
10670
- }
10671
10666
  const treeRecords = [];
10672
- const getChildren = (records, childrenIds) => {
10667
+ const getChildren = (currentRecord, records, childrenIds) => {
10668
+ if (currentRecord.children && typeof currentRecord.children[0] === "object") {
10669
+ // 考虑api配置了cache缓存的话,不会请求接口但是会重新进这个接收适配器脚本且payload.data.options返回的会是上一次计算结果,这里直接返回计算过的children
10670
+ return currentRecord.children;
10671
+ }
10673
10672
  if (!childrenIds) {
10674
10673
  return;
10675
10674
  }
@@ -10678,7 +10677,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10678
10677
  });
10679
10678
  _.each(children, (item) => {
10680
10679
  if (item.children) {
10681
- item.children = getChildren(records, item.children)
10680
+ item.children = getChildren(item, records, item.children)
10682
10681
  }else{
10683
10682
  item.children = [];
10684
10683
  }
@@ -10704,7 +10703,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10704
10703
 
10705
10704
  _.each(records, (record) => {
10706
10705
  if (record.noParent == 1) {
10707
- treeRecords.push(Object.assign({}, record, { children: getChildren(records, record.children) }));
10706
+ treeRecords.push(Object.assign({}, record, { children: getChildren(record, records, record.children) }));
10708
10707
  }
10709
10708
  });
10710
10709
  console.log(treeRecords)
@@ -12550,7 +12549,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12550
12549
  }else {
12551
12550
  convertData.className = 'm-0';
12552
12551
  }
12553
- if(readonly){
12552
+ if(readonly && ctx.mode !== 'edit'){
12554
12553
  convertData.className = `${convertData.className} border-b`;
12555
12554
  }
12556
12555
  if(readonly){
@@ -12832,6 +12831,13 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
12832
12831
  }
12833
12832
  }
12834
12833
 
12834
+ fieldSetBody.forEach((field)=>{
12835
+ //判断label是否存在,不存在时将label的空占位元素隐藏
12836
+ if(!field.label){
12837
+ field.labelClassName = "none";
12838
+ }
12839
+ });
12840
+
12835
12841
  // fieldSet 已支持显隐控制
12836
12842
  const sectionFieldsVisibleOn = ___namespace.map(___namespace.compact(___namespace.map(fieldSetBody, 'visibleOn')), (visibleOn) => {
12837
12843
  let visible = visibleOn;
@@ -12974,7 +12980,7 @@ function uuidv4() {
12974
12980
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12975
12981
  * @Date: 2023-11-15 09:50:22
12976
12982
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12977
- * @LastEditTime: 2024-01-21 23:40:13
12983
+ * @LastEditTime: 2024-01-22 15:59:32
12978
12984
  */
12979
12985
 
12980
12986
  function getTablePrimaryKey(props){
@@ -13236,37 +13242,41 @@ function getFormPagination(props, mode) {
13236
13242
  let __formId = "${formId}";
13237
13243
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13238
13244
  let pageChangeDirection = context.props.pageChangeDirection;
13245
+ let mode = "${mode}";
13239
13246
  // event.data中的index和__page分别表示当前要把表单数据提交到的行索引和用于标定下一页页码的当前页页码
13240
13247
  // 一般来说__page = index + 1,但是可以让event.data中传入__page和index值不是这种联系。
13241
13248
  // 比如__page设置为3,index设置为0表示把当前表单数据提交到第一页,但是跳转到第4页,弹出的表单中底下的新增和复制按钮依赖了此功能
13242
13249
  // let currentPage = currentIndex + 1;
13243
13250
  let currentPage = event.data.__page;
13244
13251
  let currentIndex = event.data.index;
13245
- // 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
13246
- let currentFormValues = scope.getComponentById(__formId).getValues();
13247
- // 这里不clone的话,其值会带上__super属性
13248
- currentFormValues = _.clone(currentFormValues);
13249
- var parent = event.data.parent;
13250
- var __parentIndex = event.data.__parentIndex;
13251
- if(parent){
13252
- fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13253
- // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13254
- fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
13255
- children: fieldValue[__parentIndex].children,
13256
- __fix_rerender_after_children_modified_tag: new Date().getTime()
13252
+ if(mode !== "readonly"){
13253
+ // 新建编辑时,翻页才需要把当前页表单保存,只读时直接翻页即可
13254
+ // 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
13255
+ let currentFormValues = scope.getComponentById(__formId).getValues();
13256
+ // 这里不clone的话,其值会带上__super属性
13257
+ currentFormValues = _.clone(currentFormValues);
13258
+ var parent = event.data.parent;
13259
+ var __parentIndex = event.data.__parentIndex;
13260
+ if(parent){
13261
+ fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13262
+ // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13263
+ fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
13264
+ children: fieldValue[__parentIndex].children,
13265
+ __fix_rerender_after_children_modified_tag: new Date().getTime()
13266
+ });
13267
+ }
13268
+ else{
13269
+ fieldValue[currentIndex] = currentFormValues;
13270
+ }
13271
+ // 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
13272
+ doAction({
13273
+ "componentId": "${props.id}",
13274
+ "actionType": "setValue",
13275
+ "args": {
13276
+ "value": fieldValue
13277
+ }
13257
13278
  });
13258
13279
  }
13259
- else{
13260
- fieldValue[currentIndex] = currentFormValues;
13261
- }
13262
- // 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
13263
- doAction({
13264
- "componentId": "${props.id}",
13265
- "actionType": "setValue",
13266
- "args": {
13267
- "value": fieldValue
13268
- }
13269
- });
13270
13280
 
13271
13281
  // 以下是翻页逻辑,翻到下一页并把下一页内容显示到表单上
13272
13282
  let targetPage;
@@ -13326,7 +13336,7 @@ function getFormPagination(props, mode) {
13326
13336
  {
13327
13337
  "type": "tpl",
13328
13338
  // 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
13329
- "tpl": "${__page}/${__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length}"
13339
+ "tpl": "${__page}/${__super.parent ? COMPACT(__tableItems[__parentIndex]['children']).length : COMPACT(__tableItems).length}"
13330
13340
  },
13331
13341
  {
13332
13342
  "type": "button",
@@ -13336,7 +13346,7 @@ function getFormPagination(props, mode) {
13336
13346
  "pageChangeDirection": "next",
13337
13347
  // "disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
13338
13348
  // 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
13339
- "disabledOn": showPagination ? "${__page >= (__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length)}" : "true",
13349
+ "disabledOn": showPagination ? "${__page >= (__super.parent ? COMPACT(__tableItems[__parentIndex]['children']).length : COMPACT(__tableItems).length)}" : "true",
13340
13350
  "size": "sm",
13341
13351
  "id": buttonNextId,
13342
13352
  "onEvent": {
@@ -13997,7 +14007,10 @@ async function getButtonActions(props, mode) {
13997
14007
  // 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
13998
14008
  // 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
13999
14009
  // "__tableItems": `\${${props.name}|json|toJson}`
14000
- "__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
14010
+ // "__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
14011
+ // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
14012
+ // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
14013
+ "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
14001
14014
  },
14002
14015
  }
14003
14016
  }
@@ -14180,7 +14193,7 @@ const getAmisInputTableSchema = async (props) => {
14180
14193
  let amis = props["input-table"] || props.amis || {};//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
14181
14194
  let inputTableSchema = {
14182
14195
  "type": "input-table",
14183
- "label": props.label,
14196
+ "mode": "normal",
14184
14197
  "name": props.name,
14185
14198
  //不可以addable/editable/removable设置为true,因为会在原生的操作列显示操作按钮图标,此开关实测只控制这个按钮显示不会影响功能
14186
14199
  // "addable": props.addable,
@@ -14294,7 +14307,16 @@ const getAmisInputTableSchema = async (props) => {
14294
14307
  }
14295
14308
  let schema = {
14296
14309
  "type": "service",
14297
- "body": schemaBody,
14310
+ "body": [
14311
+ {
14312
+ "type": "control",
14313
+ "body": schemaBody,
14314
+ "label": props.label,
14315
+ "labelClassName": props.label ? props.labelClassName : "none",
14316
+ "labelRemark": props.labelRemark,
14317
+ "labelAlign": props.labelAlign
14318
+ }
14319
+ ],
14298
14320
  "className": props.className,
14299
14321
  "id": serviceId
14300
14322
  };