@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.esm.js CHANGED
@@ -354,6 +354,9 @@ const Router = {
354
354
  if(uiSchema.enable_split){
355
355
  defaultDisplay = "split";
356
356
  }
357
+ if(window.innerWidth <= 768){
358
+ return "grid";
359
+ }
357
360
  return value ? value : defaultDisplay;
358
361
  },
359
362
 
@@ -2037,7 +2040,7 @@ async function getQuickEditSchema(field, options){
2037
2040
  }
2038
2041
 
2039
2042
  function getFieldWidth(width){
2040
- const defaultWidth = "unset";//用于使table内的td标签下生成div,实现将快速编辑按钮固定在右侧的效果,并不是为了unset效果
2043
+ const defaultWidth = null;
2041
2044
  if(typeof width == 'string'){
2042
2045
  if(isNaN(width)){
2043
2046
  return width || defaultWidth;
@@ -2067,14 +2070,14 @@ async function getTableColumns(fields, options){
2067
2070
  //增加quickEdit属性,实现快速编辑
2068
2071
  const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
2069
2072
  let className = "";
2070
- if(field.wrap != true){
2071
- if(field.wrap != false && field.is_wide){
2072
- className += " break-words ";
2073
- }else {
2073
+ if(/Safari/.test(navigator.userAgent)){
2074
+ className += " whitespace-nowrap ";
2075
+ }else {
2076
+ if(field.wrap != true){
2074
2077
  className += " whitespace-nowrap ";
2078
+ }else {
2079
+ className += " break-words ";
2075
2080
  }
2076
- }else {
2077
- className += " break-words ";
2078
2081
  }
2079
2082
  let columnItem;
2080
2083
  if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
@@ -10632,17 +10635,13 @@ function getReferenceToSync(field) {
10632
10635
 
10633
10636
  function getLookupSapceUserTreeSchema(isMobile){
10634
10637
  let apiAdaptor = `
10635
- // console.log("===getLookupSapceUserTreeSchema===", JSON.stringify(payload));
10636
10638
  const records = payload.data.options;
10637
- let isTreeOptionsComputed = false;
10638
- if(records.length === 1 && records[0].children){
10639
- isTreeOptionsComputed = true;
10640
- }
10641
- if(isTreeOptionsComputed){
10642
- return payload;
10643
- }
10644
10639
  const treeRecords = [];
10645
- const getChildren = (records, childrenIds) => {
10640
+ const getChildren = (currentRecord, records, childrenIds) => {
10641
+ if (currentRecord.children && typeof currentRecord.children[0] === "object") {
10642
+ // 考虑api配置了cache缓存的话,不会请求接口但是会重新进这个接收适配器脚本且payload.data.options返回的会是上一次计算结果,这里直接返回计算过的children
10643
+ return currentRecord.children;
10644
+ }
10646
10645
  if (!childrenIds) {
10647
10646
  return;
10648
10647
  }
@@ -10651,7 +10650,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10651
10650
  });
10652
10651
  _.each(children, (item) => {
10653
10652
  if (item.children) {
10654
- item.children = getChildren(records, item.children)
10653
+ item.children = getChildren(item, records, item.children)
10655
10654
  }else{
10656
10655
  item.children = [];
10657
10656
  }
@@ -10677,7 +10676,7 @@ function getLookupSapceUserTreeSchema(isMobile){
10677
10676
 
10678
10677
  _.each(records, (record) => {
10679
10678
  if (record.noParent == 1) {
10680
- treeRecords.push(Object.assign({}, record, { children: getChildren(records, record.children) }));
10679
+ treeRecords.push(Object.assign({}, record, { children: getChildren(record, records, record.children) }));
10681
10680
  }
10682
10681
  });
10683
10682
  console.log(treeRecords)
@@ -12523,7 +12522,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12523
12522
  }else {
12524
12523
  convertData.className = 'm-0';
12525
12524
  }
12526
- if(readonly){
12525
+ if(readonly && ctx.mode !== 'edit'){
12527
12526
  convertData.className = `${convertData.className} border-b`;
12528
12527
  }
12529
12528
  if(readonly){
@@ -12805,6 +12804,13 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
12805
12804
  }
12806
12805
  }
12807
12806
 
12807
+ fieldSetBody.forEach((field)=>{
12808
+ //判断label是否存在,不存在时将label的空占位元素隐藏
12809
+ if(!field.label){
12810
+ field.labelClassName = "none";
12811
+ }
12812
+ });
12813
+
12808
12814
  // fieldSet 已支持显隐控制
12809
12815
  const sectionFieldsVisibleOn = _$1.map(_$1.compact(_$1.map(fieldSetBody, 'visibleOn')), (visibleOn) => {
12810
12816
  let visible = visibleOn;
@@ -12947,7 +12953,7 @@ function uuidv4() {
12947
12953
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12948
12954
  * @Date: 2023-11-15 09:50:22
12949
12955
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12950
- * @LastEditTime: 2024-01-21 23:40:13
12956
+ * @LastEditTime: 2024-01-22 15:59:32
12951
12957
  */
12952
12958
 
12953
12959
  function getTablePrimaryKey(props){
@@ -13209,37 +13215,41 @@ function getFormPagination(props, mode) {
13209
13215
  let __formId = "${formId}";
13210
13216
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13211
13217
  let pageChangeDirection = context.props.pageChangeDirection;
13218
+ let mode = "${mode}";
13212
13219
  // event.data中的index和__page分别表示当前要把表单数据提交到的行索引和用于标定下一页页码的当前页页码
13213
13220
  // 一般来说__page = index + 1,但是可以让event.data中传入__page和index值不是这种联系。
13214
13221
  // 比如__page设置为3,index设置为0表示把当前表单数据提交到第一页,但是跳转到第4页,弹出的表单中底下的新增和复制按钮依赖了此功能
13215
13222
  // let currentPage = currentIndex + 1;
13216
13223
  let currentPage = event.data.__page;
13217
13224
  let currentIndex = event.data.index;
13218
- // 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
13219
- let currentFormValues = scope.getComponentById(__formId).getValues();
13220
- // 这里不clone的话,其值会带上__super属性
13221
- currentFormValues = _.clone(currentFormValues);
13222
- var parent = event.data.parent;
13223
- var __parentIndex = event.data.__parentIndex;
13224
- if(parent){
13225
- fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13226
- // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13227
- fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
13228
- children: fieldValue[__parentIndex].children,
13229
- __fix_rerender_after_children_modified_tag: new Date().getTime()
13225
+ if(mode !== "readonly"){
13226
+ // 新建编辑时,翻页才需要把当前页表单保存,只读时直接翻页即可
13227
+ // 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
13228
+ let currentFormValues = scope.getComponentById(__formId).getValues();
13229
+ // 这里不clone的话,其值会带上__super属性
13230
+ currentFormValues = _.clone(currentFormValues);
13231
+ var parent = event.data.parent;
13232
+ var __parentIndex = event.data.__parentIndex;
13233
+ if(parent){
13234
+ fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13235
+ // 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
13236
+ fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
13237
+ children: fieldValue[__parentIndex].children,
13238
+ __fix_rerender_after_children_modified_tag: new Date().getTime()
13239
+ });
13240
+ }
13241
+ else{
13242
+ fieldValue[currentIndex] = currentFormValues;
13243
+ }
13244
+ // 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
13245
+ doAction({
13246
+ "componentId": "${props.id}",
13247
+ "actionType": "setValue",
13248
+ "args": {
13249
+ "value": fieldValue
13250
+ }
13230
13251
  });
13231
13252
  }
13232
- else{
13233
- fieldValue[currentIndex] = currentFormValues;
13234
- }
13235
- // 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
13236
- doAction({
13237
- "componentId": "${props.id}",
13238
- "actionType": "setValue",
13239
- "args": {
13240
- "value": fieldValue
13241
- }
13242
- });
13243
13253
 
13244
13254
  // 以下是翻页逻辑,翻到下一页并把下一页内容显示到表单上
13245
13255
  let targetPage;
@@ -13299,7 +13309,7 @@ function getFormPagination(props, mode) {
13299
13309
  {
13300
13310
  "type": "tpl",
13301
13311
  // 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
13302
- "tpl": "${__page}/${__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length}"
13312
+ "tpl": "${__page}/${__super.parent ? COMPACT(__tableItems[__parentIndex]['children']).length : COMPACT(__tableItems).length}"
13303
13313
  },
13304
13314
  {
13305
13315
  "type": "button",
@@ -13309,7 +13319,7 @@ function getFormPagination(props, mode) {
13309
13319
  "pageChangeDirection": "next",
13310
13320
  // "disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
13311
13321
  // 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
13312
- "disabledOn": showPagination ? "${__page >= (__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length)}" : "true",
13322
+ "disabledOn": showPagination ? "${__page >= (__super.parent ? COMPACT(__tableItems[__parentIndex]['children']).length : COMPACT(__tableItems).length)}" : "true",
13313
13323
  "size": "sm",
13314
13324
  "id": buttonNextId,
13315
13325
  "onEvent": {
@@ -13970,7 +13980,10 @@ async function getButtonActions(props, mode) {
13970
13980
  // 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
13971
13981
  // 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
13972
13982
  // "__tableItems": `\${${props.name}|json|toJson}`
13973
- "__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13983
+ // "__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13984
+ // 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
13985
+ // 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
13986
+ "__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
13974
13987
  },
13975
13988
  }
13976
13989
  }
@@ -14153,7 +14166,7 @@ const getAmisInputTableSchema = async (props) => {
14153
14166
  let amis = props["input-table"] || props.amis || {};//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
14154
14167
  let inputTableSchema = {
14155
14168
  "type": "input-table",
14156
- "label": props.label,
14169
+ "mode": "normal",
14157
14170
  "name": props.name,
14158
14171
  //不可以addable/editable/removable设置为true,因为会在原生的操作列显示操作按钮图标,此开关实测只控制这个按钮显示不会影响功能
14159
14172
  // "addable": props.addable,
@@ -14267,7 +14280,16 @@ const getAmisInputTableSchema = async (props) => {
14267
14280
  }
14268
14281
  let schema = {
14269
14282
  "type": "service",
14270
- "body": schemaBody,
14283
+ "body": [
14284
+ {
14285
+ "type": "control",
14286
+ "body": schemaBody,
14287
+ "label": props.label,
14288
+ "labelClassName": props.label ? props.labelClassName : "none",
14289
+ "labelRemark": props.labelRemark,
14290
+ "labelAlign": props.labelAlign
14291
+ }
14292
+ ],
14271
14293
  "className": props.className,
14272
14294
  "id": serviceId
14273
14295
  };