From 1408adcc4a7e951c3b5970e43bc9d29629918c09 Mon Sep 17 00:00:00 2001 From: jinye Date: Fri, 12 Apr 2024 20:46:07 +0800 Subject: [PATCH 01/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dtransfer=20?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E6=A8=A1=E5=BC=8F=E6=97=B6=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E8=A1=8C=E6=97=B6=E6=97=A0=E6=B3=95=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=E6=9C=80=E6=96=B0=E5=80=BC=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-editor/src/renderer/TransferTableControl.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/amis-editor/src/renderer/TransferTableControl.tsx b/packages/amis-editor/src/renderer/TransferTableControl.tsx index c5b87ceeb..ed9ebe45e 100644 --- a/packages/amis-editor/src/renderer/TransferTableControl.tsx +++ b/packages/amis-editor/src/renderer/TransferTableControl.tsx @@ -497,6 +497,7 @@ const TransferTableControl = BaseOptionControl(TransferTableOption); @FormItem({ type: 'ae-transferTableControl', + strictMode: false, renderLabel: false }) export class TransferTableControlRenderer extends TransferTableControl {} From 7bc980a504d015e723e370b3635f33c08bf58c0c Mon Sep 17 00:00:00 2001 From: jinye Date: Mon, 15 Apr 2024 21:08:22 +0800 Subject: [PATCH 02/46] =?UTF-8?q?feat:=E6=97=B6=E9=97=B4=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=8C=83=E5=9B=B4=E7=BB=84=E4=BB=B6=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E8=AE=BE=E7=BD=AEpopOverContainerSelector=E5=B1=9E?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zh-CN/components/form/input-date-range.md | 128 +++++++++--------- docs/zh-CN/components/form/input-date.md | 29 ++-- .../components/form/input-datetime-range.md | 25 ++-- docs/zh-CN/components/form/input-datetime.md | 31 +++-- .../components/form/input-month-range.md | 29 ++-- docs/zh-CN/components/form/input-month.md | 15 +- .../components/form/input-quarter-range.md | 29 ++-- .../zh-CN/components/form/input-time-range.md | 19 +-- docs/zh-CN/components/form/input-time.md | 17 +-- .../zh-CN/components/form/input-year-range.md | 27 ++-- .../amis-ui/src/components/DatePicker.tsx | 3 + .../src/components/DateRangePicker.tsx | 3 + .../amis/src/renderers/Form/InputDate.tsx | 6 + .../src/renderers/Form/InputDateRange.tsx | 6 + .../src/renderers/Form/InputMonthRange.tsx | 1 + .../src/renderers/Form/InputQuarterRange.tsx | 1 + .../src/renderers/Form/InputYearRange.tsx | 1 + 17 files changed, 198 insertions(+), 172 deletions(-) diff --git a/docs/zh-CN/components/form/input-date-range.md b/docs/zh-CN/components/form/input-date-range.md index 0d12db6fa..f40b20307 100755 --- a/docs/zh-CN/components/form/input-date-range.md +++ b/docs/zh-CN/components/form/input-date-range.md @@ -234,58 +234,58 @@ order: 15 > `3.5.0`及以上版本 -默认情况下,日期范围选择器组件的绑定值的开始时间为所选时间当天的0点(使用`moment().startOf('day')`处理),结束时间为所选时间当天的23时59分59秒999毫秒(使用`moment().endOf('day')`处理)。如果设置了`timeFormat`(时间格式),则会基于`timeFormat`配置决定**最小时间单位**,举例: +默认情况下,日期范围选择器组件的绑定值的开始时间为所选时间当天的 0 点(使用`moment().startOf('day')`处理),结束时间为所选时间当天的 23 时 59 分 59 秒 999 毫秒(使用`moment().endOf('day')`处理)。如果设置了`timeFormat`(时间格式),则会基于`timeFormat`配置决定**最小时间单位**,举例: - 不设置`timeFormat`(时间格式),默认按照天(day)级处理: - ```typescript - moment().startOf('day'); // 2008-08-08 00:00:00.000 - moment().endOf('day'); // 2008-08-08 23:59:59.999 - ``` + ```typescript + moment().startOf('day'); // 2008-08-08 00:00:00.000 + moment().endOf('day'); // 2008-08-08 23:59:59.999 + ``` - `timeFormat`(时间格式)为 `"HH:mm:ss"`,则会按照秒(second)级处理: - ```typescript - moment().startOf('second'); // 2008-08-08 08:08:08.000 - moment().endOf('second'); // 2008-08-08 08:08:08.999 - ``` + ```typescript + moment().startOf('second'); // 2008-08-08 08:08:08.000 + moment().endOf('second'); // 2008-08-08 08:08:08.999 + ``` - `timeFormat`(时间格式)为 `"HH:mm"`,则会按照分钟(minute)级处理: - ```typescript - moment().startOf('minute'); // 2008-08-08 08:08:00.000 - moment().endOf('minute'); // 2008-08-08 08:08:59.999 - ``` + ```typescript + moment().startOf('minute'); // 2008-08-08 08:08:00.000 + moment().endOf('minute'); // 2008-08-08 08:08:59.999 + ``` - `timeFormat`(时间格式)为 `"HH"`,则会按照小时(hour)级处理: - ```typescript - moment().startOf('hour'); // 2008-08-08 08:00:00.000 - moment().endOf('hour'); // 2008-08-08 08:59:59.999 - ``` + ```typescript + moment().startOf('hour'); // 2008-08-08 08:00:00.000 + moment().endOf('hour'); // 2008-08-08 08:59:59.999 + ``` 部分情况下,即使配置`timeFormat`也无法满足需求,此时可以使用`transform`函数对时间值做进一步处理, 函数签名如下: ```typescript interface TransFormFunc { - ( - /* 当前值,Moment对象 */ - value: moment.Moment, - config: { - /* 操作类型,start:起始时间;end:结束时间 */ - type: 'start' | 'end'; - /* 初始值,最近一次选择的时间值 */ - originValue: moment.Moment, - /* 时间格式 */ - timeFormat: string - }, - /* 当前组件的属性 */ - props: any, - /* 当前组件数据域 */ - data: any, - /* moment函数 */ - moment: moment - ): moment.Moment; + ( + /* 当前值,Moment对象 */ + value: moment.Moment, + config: { + /* 操作类型,start:起始时间;end:结束时间 */ + type: 'start' | 'end'; + /* 初始值,最近一次选择的时间值 */ + originValue: moment.Moment; + /* 时间格式 */ + timeFormat: string; + }, + /* 当前组件的属性 */ + props: any, + /* 当前组件数据域 */ + data: any, + /* moment函数 */ + moment: moment + ): moment.Moment; } ``` @@ -316,46 +316,42 @@ interface TransFormFunc { ```typescript function transform(value, config, props, data) { - const now = moment(); + const now = moment(); - if (config.type === 'end') { - value.set({ - hours: now.hours(), - minutes: now.minutes(), - seconds: now.seconds(), - milliseconds: now.milliseconds() - }); - } + if (config.type === 'end') { + value.set({ + hours: now.hours(), + minutes: now.minutes(), + seconds: now.seconds(), + milliseconds: now.milliseconds() + }); + } - return value; + return value; } ``` - - - ## 属性表 除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置 -| 属性名 | 类型 | 默认值 | 说明 | 版本 | -| ------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------- | ---------------------------------------------------------------------------- | ----------------------- | -| valueFormat | `string` | `X` | [日期选择器值格式](./date#%E5%80%BC%E6%A0%BC%E5%BC%8F) | 3.4.0 版本后支持 | -| displayFormat | `string` | `YYYY-MM-DD` | [日期选择器显示格式](./date#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) | 3.4.0 版本后支持 | -| placeholder | `string` | `"请选择日期范围"` | 占位文本 | -| shortcuts | `string \| string[] \| Array<{label: string; startDate: string; endDate: string}>` | `"yesterday,7daysago,prevweek,thismonth,prevmonth,prevquarter"` | 日期范围快捷键 | `3.1.0`版本后支持表达式 | -| minDate | `string` | | 限制最小日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | -| maxDate | `string` | | 限制最大日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | -| minDuration | `string` | | 限制最小跨度,如: 2days | -| maxDuration | `string` | | 限制最大跨度,如:1year | -| utc | `boolean` | `false` | [保存 UTC 值](./date#utc) | -| clearable | `boolean` | `true` | 是否可清除 | -| embed | `boolean` | `false` | 是否内联模式 | -| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` | -| extraName | `string` | | 是否存成两个字段 | `3.3.0` | -| transform | `string` | | 日期数据处理函数,用来处理选择日期之后的的值,返回值为 `Moment`对象 | `3.5.0` | - - +| 属性名 | 类型 | 默认值 | 说明 | 版本 | +| ------------------------ | ---------------------------------------------------------------------------------- | --------------------------------------------------------------- | ---------------------------------------------------------------------------- | ----------------------- | +| valueFormat | `string` | `X` | [日期选择器值格式](./date#%E5%80%BC%E6%A0%BC%E5%BC%8F) | 3.4.0 版本后支持 | +| displayFormat | `string` | `YYYY-MM-DD` | [日期选择器显示格式](./date#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) | 3.4.0 版本后支持 | +| placeholder | `string` | `"请选择日期范围"` | 占位文本 | +| shortcuts | `string \| string[] \| Array<{label: string; startDate: string; endDate: string}>` | `"yesterday,7daysago,prevweek,thismonth,prevmonth,prevquarter"` | 日期范围快捷键 | `3.1.0`版本后支持表达式 | +| minDate | `string` | | 限制最小日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | +| maxDate | `string` | | 限制最大日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | +| minDuration | `string` | | 限制最小跨度,如: 2days | +| maxDuration | `string` | | 限制最大跨度,如:1year | +| utc | `boolean` | `false` | [保存 UTC 值](./date#utc) | +| clearable | `boolean` | `true` | 是否可清除 | +| embed | `boolean` | `false` | 是否内联模式 | +| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` | +| extraName | `string` | | 是否存成两个字段 | `3.3.0` | +| transform | `string` | | 日期数据处理函数,用来处理选择日期之后的的值,返回值为 `Moment`对象 | `3.5.0` | +| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` | ## 事件表 diff --git a/docs/zh-CN/components/form/input-date.md b/docs/zh-CN/components/form/input-date.md index f3fa3f766..dde6d03b5 100755 --- a/docs/zh-CN/components/form/input-date.md +++ b/docs/zh-CN/components/form/input-date.md @@ -412,20 +412,21 @@ order: 13 除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置 -| 属性名 | 类型 | 默认值 | 说明 | 版本 | -| ------------- | -------------------------------------------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------- | -| value | `string` | | [默认值](./date#%E9%BB%98%E8%AE%A4%E5%80%BC) | -| valueFormat | `string` | `X` | 日期选择器值格式,更多格式类型请参考 [文档](https://momentjs.com/docs/#/displaying/format/) | 3.4.0 版本后支持 | -| displayFormat | `string` | `YYYY-MM-DD` | 日期选择器显示格式,即时间戳格式,更多格式类型请参考 [文档](https://momentjs.com/docs/#/displaying/format/) | 3.4.0 版本后支持 | -| closeOnSelect | `boolean` | `false` | 点选日期后,是否马上关闭选择框 | -| placeholder | `string` | `"请选择日期"` | 占位文本 | -| shortcuts | `string \| string[] \| Array<{"label": string; date: string}>` | | 日期快捷键,字符串格式为预设值,对象格式支持写表达式 | `3.1.0`版本后支持表达式 | -| minDate | `string` | | 限制最小日期 | -| maxDate | `string` | | 限制最大日期 | -| utc | `boolean` | `false` | 保存 utc 值 | -| clearable | `boolean` | `true` | 是否可清除 | -| embed | `boolean` | `false` | 是否内联模式 | -| disabledDate | `string` | | 用字符函数来控制哪些天不可以被点选 | +| 属性名 | 类型 | 默认值 | 说明 | 版本 | +| ------------------------ | -------------------------------------------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------- | +| value | `string` | | [默认值](./date#%E9%BB%98%E8%AE%A4%E5%80%BC) | +| valueFormat | `string` | `X` | 日期选择器值格式,更多格式类型请参考 [文档](https://momentjs.com/docs/#/displaying/format/) | 3.4.0 版本后支持 | +| displayFormat | `string` | `YYYY-MM-DD` | 日期选择器显示格式,即时间戳格式,更多格式类型请参考 [文档](https://momentjs.com/docs/#/displaying/format/) | 3.4.0 版本后支持 | +| closeOnSelect | `boolean` | `false` | 点选日期后,是否马上关闭选择框 | +| placeholder | `string` | `"请选择日期"` | 占位文本 | +| shortcuts | `string \| string[] \| Array<{"label": string; date: string}>` | | 日期快捷键,字符串格式为预设值,对象格式支持写表达式 | `3.1.0`版本后支持表达式 | +| minDate | `string` | | 限制最小日期 | +| maxDate | `string` | | 限制最大日期 | +| utc | `boolean` | `false` | 保存 utc 值 | +| clearable | `boolean` | `true` | 是否可清除 | +| embed | `boolean` | `false` | 是否内联模式 | +| disabledDate | `string` | | 用字符函数来控制哪些天不可以被点选 | +| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` | ## 事件表 diff --git a/docs/zh-CN/components/form/input-datetime-range.md b/docs/zh-CN/components/form/input-datetime-range.md index d223e9497..efba86203 100755 --- a/docs/zh-CN/components/form/input-datetime-range.md +++ b/docs/zh-CN/components/form/input-datetime-range.md @@ -126,18 +126,19 @@ order: 16 除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置 -| 属性名 | 类型 | 默认值 | 说明 | 版本 | -| ------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | ----------------------- | -| valueFormat | `string` | `X` | [日期时间选择器值格式](./input-datetime#%E5%80%BC%E6%A0%BC%E5%BC%8F) | 3.4.0 版本后支持 | -| displayFormat | `string` | `YYYY-MM-DD` | [日期时间选择器显示格式](./input-datetime#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) | 3.4.0 版本后支持 | -| placeholder | `string` | `"请选择日期范围"` | 占位文本 | -| shortcuts | `string \| string[] \| Array<{label: string; startDate: string; endDate: string}>` | `"yesterday,7daysago,prevweek,thismonth,prevmonth,prevquarter"` | 日期范围快捷键,详情参考[快捷键](./input-date-range#快捷键) | `3.1.0`版本后支持表达式 | -| minDate | `string` | | 限制最小日期时间,用法同 [限制范围](./input-datetime#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | -| maxDate | `string` | | 限制最大日期时间,用法同 [限制范围](./input-datetime#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | -| utc | `boolean` | `false` | [保存 UTC 值](./input-datetime#utc) | -| clearable | `boolean` | `true` | 是否可清除 | -| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` | -| extraName | `string` | | 是否存成两个字段 | `3.3.0` | +| 属性名 | 类型 | 默认值 | 说明 | 版本 | +| ------------------------ | ---------------------------------------------------------------------------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | ----------------------- | +| valueFormat | `string` | `X` | [日期时间选择器值格式](./input-datetime#%E5%80%BC%E6%A0%BC%E5%BC%8F) | 3.4.0 版本后支持 | +| displayFormat | `string` | `YYYY-MM-DD` | [日期时间选择器显示格式](./input-datetime#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) | 3.4.0 版本后支持 | +| placeholder | `string` | `"请选择日期范围"` | 占位文本 | +| shortcuts | `string \| string[] \| Array<{label: string; startDate: string; endDate: string}>` | `"yesterday,7daysago,prevweek,thismonth,prevmonth,prevquarter"` | 日期范围快捷键,详情参考[快捷键](./input-date-range#快捷键) | `3.1.0`版本后支持表达式 | +| minDate | `string` | | 限制最小日期时间,用法同 [限制范围](./input-datetime#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | +| maxDate | `string` | | 限制最大日期时间,用法同 [限制范围](./input-datetime#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | +| utc | `boolean` | `false` | [保存 UTC 值](./input-datetime#utc) | +| clearable | `boolean` | `true` | 是否可清除 | +| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` | +| extraName | `string` | | 是否存成两个字段 | `3.3.0` | +| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` | ## 事件表 diff --git a/docs/zh-CN/components/form/input-datetime.md b/docs/zh-CN/components/form/input-datetime.md index 6c4c5dc77..3b46ee2b1 100755 --- a/docs/zh-CN/components/form/input-datetime.md +++ b/docs/zh-CN/components/form/input-datetime.md @@ -411,21 +411,22 @@ order: 14 除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置 -| 属性名 | 类型 | 默认值 | 说明 | 版本 | -| --------------- | -------------------------------------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------- | ----------------------- | -| value | `string` | | [默认值](./datetime#%E9%BB%98%E8%AE%A4%E5%80%BC) | -| valueFormat | `string` | `X` | 日期时间选择器值格式,更多格式类型请参考 [文档](https://momentjs.com/docs/#/displaying/format/) | 3.4.0 版本后支持 | -| displayFormat | `string` | `YYYY-MM-DD HH:mm:ss` | 日期时间选择器显示格式,即时间戳格式,更多格式类型请参考 [文档](https://momentjs.com/docs/#/displaying/format/) | 3.4.0 版本后支持 | -| placeholder | `string` | `"请选择日期以及时间"` | 占位文本 | -| shortcuts | `string \| string[] \| Array<{"label": string; date: string}>` | | 日期时间快捷键 | `3.1.0`版本后支持表达式 | -| minDate | `string` | | 限制最小日期时间 | -| maxDate | `string` | | 限制最大日期时间 | -| utc | `boolean` | `false` | 保存 utc 值 | -| clearable | `boolean` | `true` | 是否可清除 | -| embed | `boolean` | `false` | 是否内联 | -| timeConstraints | `object` | `true` | 请参考 [input-time](./input-time#控制输入范围) 里的说明 | -| isEndDate | `boolean` | `false` | 如果配置为 true,会自动默认为 23:59:59 秒 | -| disabledDate | `string` | | 用字符函数来控制哪些天不可以被点选 | +| 属性名 | 类型 | 默认值 | 说明 | 版本 | +| ------------------------ | -------------------------------------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------- | ----------------------- | +| value | `string` | | [默认值](./datetime#%E9%BB%98%E8%AE%A4%E5%80%BC) | +| valueFormat | `string` | `X` | 日期时间选择器值格式,更多格式类型请参考 [文档](https://momentjs.com/docs/#/displaying/format/) | 3.4.0 版本后支持 | +| displayFormat | `string` | `YYYY-MM-DD HH:mm:ss` | 日期时间选择器显示格式,即时间戳格式,更多格式类型请参考 [文档](https://momentjs.com/docs/#/displaying/format/) | 3.4.0 版本后支持 | +| placeholder | `string` | `"请选择日期以及时间"` | 占位文本 | +| shortcuts | `string \| string[] \| Array<{"label": string; date: string}>` | | 日期时间快捷键 | `3.1.0`版本后支持表达式 | +| minDate | `string` | | 限制最小日期时间 | +| maxDate | `string` | | 限制最大日期时间 | +| utc | `boolean` | `false` | 保存 utc 值 | +| clearable | `boolean` | `true` | 是否可清除 | +| embed | `boolean` | `false` | 是否内联 | +| timeConstraints | `object` | `true` | 请参考 [input-time](./input-time#控制输入范围) 里的说明 | +| isEndDate | `boolean` | `false` | 如果配置为 true,会自动默认为 23:59:59 秒 | +| disabledDate | `string` | | 用字符函数来控制哪些天不可以被点选 | +| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0`版本后支持 | ## 事件表 diff --git a/docs/zh-CN/components/form/input-month-range.md b/docs/zh-CN/components/form/input-month-range.md index fb2ab457d..d7f3b7824 100644 --- a/docs/zh-CN/components/form/input-month-range.md +++ b/docs/zh-CN/components/form/input-month-range.md @@ -67,20 +67,21 @@ order: 15 除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置 -| 属性名 | 类型 | 默认值 | 说明 | 版本 | -| ----------- | --------- | ------------------ | ---------------------------------------------------------------------------- | ------- | -| format | `string` | `X` | [日期选择器值格式](./date#%E5%80%BC%E6%A0%BC%E5%BC%8F) | -| inputFormat | `string` | `YYYY-DD` | [日期选择器显示格式](./date#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) | -| placeholder | `string` | `"请选择月份范围"` | 占位文本 | -| minDate | `string` | | 限制最小日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | -| maxDate | `string` | | 限制最大日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | -| minDuration | `string` | | 限制最小跨度,如: 2days | -| maxDuration | `string` | | 限制最大跨度,如:1year | -| utc | `boolean` | `false` | [保存 UTC 值](./date#utc) | -| clearable | `boolean` | `true` | 是否可清除 | -| embed | `boolean` | `false` | 是否内联模式 | -| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` | -| extraName | `string` | | 是否存成两个字段 | `3.3.0` | +| 属性名 | 类型 | 默认值 | 说明 | 版本 | +| ------------------------ | --------- | ------------------ | ---------------------------------------------------------------------------- | ------- | +| format | `string` | `X` | [日期选择器值格式](./date#%E5%80%BC%E6%A0%BC%E5%BC%8F) | +| inputFormat | `string` | `YYYY-DD` | [日期选择器显示格式](./date#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) | +| placeholder | `string` | `"请选择月份范围"` | 占位文本 | +| minDate | `string` | | 限制最小日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | +| maxDate | `string` | | 限制最大日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | +| minDuration | `string` | | 限制最小跨度,如: 2days | +| maxDuration | `string` | | 限制最大跨度,如:1year | +| utc | `boolean` | `false` | [保存 UTC 值](./date#utc) | +| clearable | `boolean` | `true` | 是否可清除 | +| embed | `boolean` | `false` | 是否内联模式 | +| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` | +| extraName | `string` | | 是否存成两个字段 | `3.3.0` | +| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` | ## 事件表 diff --git a/docs/zh-CN/components/form/input-month.md b/docs/zh-CN/components/form/input-month.md index 2ebc28000..198553e36 100755 --- a/docs/zh-CN/components/form/input-month.md +++ b/docs/zh-CN/components/form/input-month.md @@ -146,13 +146,14 @@ order: 81 除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置 -| 属性名 | 类型 | 默认值 | 说明 | 版本 | -| ------------- | --------- | -------------- | ----------------------------------------------------------------------------------- | ------- | -| value | `string` | | [默认值](./date#%E9%BB%98%E8%AE%A4%E5%80%BC) | -| valueFormat | `string` | `X` | 月份选择器值格式,更多格式类型请参考 [moment](http://momentjs.com/) | `3.4.0` | -| displayFormat | `string` | `YYYY-MM` | 月份选择器显示格式,即时间戳格式,更多格式类型请参考 [moment](http://momentjs.com/) | `3.4.0` | -| placeholder | `string` | `"请选择月份"` | 占位文本 | -| clearable | `boolean` | `true` | 是否可清除 | +| 属性名 | 类型 | 默认值 | 说明 | 版本 | +| ------------------------ | --------- | -------------- | ----------------------------------------------------------------------------------- | ------- | +| value | `string` | | [默认值](./date#%E9%BB%98%E8%AE%A4%E5%80%BC) | +| valueFormat | `string` | `X` | 月份选择器值格式,更多格式类型请参考 [moment](http://momentjs.com/) | `3.4.0` | +| displayFormat | `string` | `YYYY-MM` | 月份选择器显示格式,即时间戳格式,更多格式类型请参考 [moment](http://momentjs.com/) | `3.4.0` | +| placeholder | `string` | `"请选择月份"` | 占位文本 | +| clearable | `boolean` | `true` | 是否可清除 | +| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` | ## 事件表 diff --git a/docs/zh-CN/components/form/input-quarter-range.md b/docs/zh-CN/components/form/input-quarter-range.md index 3a26dcc2f..ba7d0b584 100644 --- a/docs/zh-CN/components/form/input-quarter-range.md +++ b/docs/zh-CN/components/form/input-quarter-range.md @@ -66,20 +66,21 @@ order: 15 除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置 -| 属性名 | 类型 | 默认值 | 说明 | 版本 | -| ------------- | --------- | ------------------ | ---------------------------------------------------------------------------- | ------- | -| valueFormat | `string` | `X` | [日期选择器值格式](./date#%E5%80%BC%E6%A0%BC%E5%BC%8F) | `3.4.0` | -| displayFormat | `string` | `YYYY-DD` | [日期选择器显示格式](./date#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) | `3.4.0` | -| placeholder | `string` | `"请选择季度范围"` | 占位文本 | -| minDate | `string` | | 限制最小日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | -| maxDate | `string` | | 限制最大日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | -| minDuration | `string` | | 限制最小跨度,如: 2quarter | -| maxDuration | `string` | | 限制最大跨度,如:4quarter | -| utc | `boolean` | `false` | [保存 UTC 值](./date#utc) | -| clearable | `boolean` | `true` | 是否可清除 | -| embed | `boolean` | `false` | 是否内联模式 | -| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` | -| extraName | `string` | | 是否存成两个字段 | `3.3.0` | +| 属性名 | 类型 | 默认值 | 说明 | 版本 | +| ------------------------ | --------- | ------------------ | ---------------------------------------------------------------------------- | ------- | +| valueFormat | `string` | `X` | [日期选择器值格式](./date#%E5%80%BC%E6%A0%BC%E5%BC%8F) | `3.4.0` | +| displayFormat | `string` | `YYYY-DD` | [日期选择器显示格式](./date#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) | `3.4.0` | +| placeholder | `string` | `"请选择季度范围"` | 占位文本 | +| minDate | `string` | | 限制最小日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | +| maxDate | `string` | | 限制最大日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | +| minDuration | `string` | | 限制最小跨度,如: 2quarter | +| maxDuration | `string` | | 限制最大跨度,如:4quarter | +| utc | `boolean` | `false` | [保存 UTC 值](./date#utc) | +| clearable | `boolean` | `true` | 是否可清除 | +| embed | `boolean` | `false` | 是否内联模式 | +| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` | +| extraName | `string` | | 是否存成两个字段 | `3.3.0` | +| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` | ## 事件表 diff --git a/docs/zh-CN/components/form/input-time-range.md b/docs/zh-CN/components/form/input-time-range.md index fa388914e..32d62c5fc 100644 --- a/docs/zh-CN/components/form/input-time-range.md +++ b/docs/zh-CN/components/form/input-time-range.md @@ -88,15 +88,16 @@ order: 15 除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置 -| 属性名 | 类型 | 默认值 | 说明 | 版本 | -| ------------- | --------- | ------------------ | --------------------------------------------------------------------- | ------- | -| valueFormat | `string` | `HH:mm` | [时间范围选择器值格式](./date#%E5%80%BC%E6%A0%BC%E5%BC%8F) | `3.4.0` | -| displayFormat | `string` | `HH:mm` | [时间范围选择器显示格式](./date#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) | `3.4.0` | -| placeholder | `string` | `"请选择时间范围"` | 占位文本 | -| clearable | `boolean` | `true` | 是否可清除 | -| embed | `boolean` | `false` | 是否内联模式 | -| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` | -| extraName | `string` | | 是否存成两个字段 | `3.3.0` | +| 属性名 | 类型 | 默认值 | 说明 | 版本 | +| ------------------------ | --------- | ------------------ | --------------------------------------------------------------------- | ------- | +| valueFormat | `string` | `HH:mm` | [时间范围选择器值格式](./date#%E5%80%BC%E6%A0%BC%E5%BC%8F) | `3.4.0` | +| displayFormat | `string` | `HH:mm` | [时间范围选择器显示格式](./date#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) | `3.4.0` | +| placeholder | `string` | `"请选择时间范围"` | 占位文本 | +| clearable | `boolean` | `true` | 是否可清除 | +| embed | `boolean` | `false` | 是否内联模式 | +| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` | +| extraName | `string` | | 是否存成两个字段 | `3.3.0` | +| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` | ## 事件表 diff --git a/docs/zh-CN/components/form/input-time.md b/docs/zh-CN/components/form/input-time.md index d13add90a..6eb358056 100755 --- a/docs/zh-CN/components/form/input-time.md +++ b/docs/zh-CN/components/form/input-time.md @@ -250,14 +250,15 @@ order: 58 除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置 -| 属性名 | 类型 | 默认值 | 说明 | 版本 | -| --------------- | --------- | -------------- | ----------------------------------------------------------------------------------- | ---------------- | -| value | `string` | | [默认值](./date#%E9%BB%98%E8%AE%A4%E5%80%BC) | -| valueFormat | `string` | `X` | 时间选择器值格式,更多格式类型请参考 [moment](http://momentjs.com/) | 3.4.0 版本后支持 | -| displayFormat | `string` | `HH:mm` | 时间选择器显示格式,即时间戳格式,更多格式类型请参考 [moment](http://momentjs.com/) | 3.4.0 版本后支持 | -| placeholder | `string` | `"请选择时间"` | 占位文本 | -| clearable | `boolean` | `true` | 是否可清除 | -| timeConstraints | `object` | `true` | | +| 属性名 | 类型 | 默认值 | 说明 | 版本 | +| ------------------------ | --------- | -------------- | ----------------------------------------------------------------------------------- | ---------------- | +| value | `string` | | [默认值](./date#%E9%BB%98%E8%AE%A4%E5%80%BC) | +| valueFormat | `string` | `X` | 时间选择器值格式,更多格式类型请参考 [moment](http://momentjs.com/) | 3.4.0 版本后支持 | +| displayFormat | `string` | `HH:mm` | 时间选择器显示格式,即时间戳格式,更多格式类型请参考 [moment](http://momentjs.com/) | 3.4.0 版本后支持 | +| placeholder | `string` | `"请选择时间"` | 占位文本 | +| clearable | `boolean` | `true` | 是否可清除 | +| timeConstraints | `object` | `true` | | +| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` | ## 事件表 diff --git a/docs/zh-CN/components/form/input-year-range.md b/docs/zh-CN/components/form/input-year-range.md index 35660599b..b5fac2a28 100644 --- a/docs/zh-CN/components/form/input-year-range.md +++ b/docs/zh-CN/components/form/input-year-range.md @@ -67,19 +67,20 @@ order: 15 除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置 -| 属性名 | 类型 | 默认值 | 说明 | 版本 | -| ------------- | --------- | ------------------ | ---------------------------------------------------------------------------- | ------- | -| valueFormat | `string` | `X` | [年份选择器值格式](./date#%E5%80%BC%E6%A0%BC%E5%BC%8F) | `3.4.0` | -| displayFormat | `string` | `YYYY` | [年份选择器显示格式](./date#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) | `3.4.0` | -| placeholder | `string` | `"请选择年份范围"` | 占位文本 | -| minDate | `string` | | 限制最小日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | -| maxDate | `string` | | 限制最大日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | -| minDuration | `string` | | 限制最小跨度,如: 2year | -| maxDuration | `string` | | 限制最大跨度,如:4year | -| utc | `boolean` | `false` | [保存 UTC 值](./date#utc) | -| clearable | `boolean` | `true` | 是否可清除 | -| embed | `boolean` | `false` | 是否内联模式 | -| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` | +| 属性名 | 类型 | 默认值 | 说明 | 版本 | +| ------------------------ | --------- | ------------------ | ---------------------------------------------------------------------------- | ------- | +| valueFormat | `string` | `X` | [年份选择器值格式](./date#%E5%80%BC%E6%A0%BC%E5%BC%8F) | `3.4.0` | +| displayFormat | `string` | `YYYY` | [年份选择器显示格式](./date#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) | `3.4.0` | +| placeholder | `string` | `"请选择年份范围"` | 占位文本 | +| minDate | `string` | | 限制最小日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | +| maxDate | `string` | | 限制最大日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) | +| minDuration | `string` | | 限制最小跨度,如: 2year | +| maxDuration | `string` | | 限制最大跨度,如:4year | +| utc | `boolean` | `false` | [保存 UTC 值](./date#utc) | +| clearable | `boolean` | `true` | 是否可清除 | +| embed | `boolean` | `false` | 是否内联模式 | +| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` | +| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` | ## 事件表 diff --git a/packages/amis-ui/src/components/DatePicker.tsx b/packages/amis-ui/src/components/DatePicker.tsx index ef3f82e0d..fdd22cddd 100644 --- a/packages/amis-ui/src/components/DatePicker.tsx +++ b/packages/amis-ui/src/components/DatePicker.tsx @@ -307,6 +307,7 @@ export interface DateProps extends LocaleProps, ThemeProps { }; }; popOverContainer?: any; + popOverContainerSelector?: string; label?: string | false; borderMode?: 'full' | 'half' | 'none'; // 是否为内嵌模式,如果开启就不是 picker 了,直接页面点选。 @@ -929,6 +930,7 @@ export class DatePicker extends React.Component { viewMode, timeConstraints, popOverContainer, + popOverContainerSelector, clearable, shortcuts, utc, @@ -1130,6 +1132,7 @@ export class DatePicker extends React.Component { this.dom.current} onHide={this.close} container={popOverContainer || (() => findDOMNode(this))} + containerSelector={popOverContainerSelector} rootClose={false} placement={overlayPlacement} show diff --git a/packages/amis/src/renderers/Form/InputDate.tsx b/packages/amis/src/renderers/Form/InputDate.tsx index b57770b00..4eecdf169 100644 --- a/packages/amis/src/renderers/Form/InputDate.tsx +++ b/packages/amis/src/renderers/Form/InputDate.tsx @@ -128,6 +128,11 @@ export interface DateControlSchema extends InputDateBaseControlSchema { * 限制最大日期 */ maxDate?: string; + + /** + * 弹窗容器选择器 + */ + popOverContainerSelector?: string; } /** @@ -692,6 +697,7 @@ export default class DateControl extends React.PureComponent< ? env?.getModalContainer : rest.popOverContainer || env.getModalContainer } + popOverContainerSelector={rest.popOverContainerSelector} {...this.state} valueFormat={valueFormat || format} minDateRaw={this.props.minDate} diff --git a/packages/amis/src/renderers/Form/InputDateRange.tsx b/packages/amis/src/renderers/Form/InputDateRange.tsx index 1888cd2b9..1c540a4d5 100644 --- a/packages/amis/src/renderers/Form/InputDateRange.tsx +++ b/packages/amis/src/renderers/Form/InputDateRange.tsx @@ -122,6 +122,11 @@ export interface DateRangeControlSchema extends FormBaseControlSchema { * (value: moment.Moment, config: {type: 'start' | 'end'; originValue: moment.Moment, timeFormat: string}, props: any, data: any, moment: moment) => moment.Moment; */ transform?: string; + + /** + * 弹窗容器选择器 + */ + popOverContainerSelector?: string; } export interface DateRangeProps @@ -326,6 +331,7 @@ export default class DateRangeControl extends React.Component { ? env?.getModalContainer : rest.popOverContainer || env.getModalContainer } + popOverContainerSelector={rest.popOverContainerSelector} onRef={this.getRef} data={data} valueFormat={valueFormat || format} diff --git a/packages/amis/src/renderers/Form/InputMonthRange.tsx b/packages/amis/src/renderers/Form/InputMonthRange.tsx index f919dfd5c..9122d6af9 100644 --- a/packages/amis/src/renderers/Form/InputMonthRange.tsx +++ b/packages/amis/src/renderers/Form/InputMonthRange.tsx @@ -51,6 +51,7 @@ export default class MonthRangeControl extends InputDateRange { ? env?.getModalContainer : rest.popOverContainer || env.getModalContainer } + popOverContainerSelector={rest.popOverContainerSelector} onRef={this.getRef} data={data} {...rest} diff --git a/packages/amis/src/renderers/Form/InputQuarterRange.tsx b/packages/amis/src/renderers/Form/InputQuarterRange.tsx index 4515de8cb..b6fac803b 100644 --- a/packages/amis/src/renderers/Form/InputQuarterRange.tsx +++ b/packages/amis/src/renderers/Form/InputQuarterRange.tsx @@ -49,6 +49,7 @@ export default class QuarterRangeControl extends InputDateRange { ? env?.getModalContainer : rest.popOverContainer || env.getModalContainer } + popOverContainerSelector={rest.popOverContainerSelector} onRef={this.getRef} data={data} {...rest} diff --git a/packages/amis/src/renderers/Form/InputYearRange.tsx b/packages/amis/src/renderers/Form/InputYearRange.tsx index ca8e6dc8a..07d9bf69f 100644 --- a/packages/amis/src/renderers/Form/InputYearRange.tsx +++ b/packages/amis/src/renderers/Form/InputYearRange.tsx @@ -50,6 +50,7 @@ export default class YearRangeControl extends InputDateRange { ? env?.getModalContainer : rest.popOverContainer || env.getModalContainer } + popOverContainerSelector={rest.popOverContainerSelector} onRef={this.getRef} data={data} {...rest} From a07d1311b6afa6ce9f28564f9e762d422e304668 Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Wed, 17 Apr 2024 09:57:44 +0800 Subject: [PATCH 03/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8B=96?= =?UTF-8?q?=E6=8B=BD=E5=90=8E=E5=87=BA=E7=8E=B0=E8=A1=A8=E5=8D=95=E9=A1=B9?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#10042)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis/src/renderers/Form/Combo.tsx | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/amis/src/renderers/Form/Combo.tsx b/packages/amis/src/renderers/Form/Combo.tsx index d6618371e..e144addfc 100644 --- a/packages/amis/src/renderers/Form/Combo.tsx +++ b/packages/amis/src/renderers/Form/Combo.tsx @@ -382,7 +382,6 @@ export default class ComboControl extends React.Component { 'itemsWrapperClassName' ]; - subForms: Array = []; subFormDefaultValues: Array<{ index: number; values: any; @@ -976,15 +975,17 @@ export default class ComboControl extends React.Component { } else if (nullable && !rawValue) { return; // 不校验 } else if (value.length) { + const subForms = this.subForms; return Promise.all( value.map(async (values: any, index: number) => { - const subForm = this.subForms[index]; + const subForm = subForms[index]; if (subForm) { return subForm.validate(true, false, false); } else { // 那些还没有渲染出来的数据 // 因为有可能存在分页,有可能存在懒加载,所以没办法直接用 subForm 去校验了 - const subForm = this.subForms[Object.keys(this.subForms)[0] as any]; + // todo 唯一校验会失效,如果 combo 中某个字段是唯一的,这个校验方式有问题 + const subForm = subForms[Object.keys(subForms)[0] as any]; if (subForm) { const form: IFormStore = subForm.props.store; let valid = false; @@ -1108,23 +1109,28 @@ export default class ComboControl extends React.Component { } refsMap: { - [propName: number]: any; + [propName: string]: any; } = {}; makeFormRef = memoize( (index: number) => (ref: any) => this.formRef(ref, index) ); + get subForms() { + return Object.keys(this.refsMap) + .map(key => parseInt(key, 10)) + .sort() + .map(key => this.refsMap[key]); + } + formRef(ref: any, index: number = 0) { if (ref) { while (ref && ref.getWrappedInstance) { ref = ref.getWrappedInstance(); } - this.subForms[index] = ref; this.refsMap[index] = ref; } else { const form = this.refsMap[index]; - this.subForms = this.subForms.filter(item => item !== form); this.subFormDefaultValues = this.subFormDefaultValues.filter( ({index: dIndex}) => dIndex !== index ); @@ -1253,10 +1259,9 @@ export default class ComboControl extends React.Component { const {onChange} = this.props; onChange(null); - Array.isArray(this.subForms) && - this.subForms.forEach(subForm => { - subForm.clearErrors(); - }); + this.subForms.forEach(subForm => { + subForm.clearErrors(); + }); } renderPlaceholder() { From 6970b5242fd5aec873b7fd1b2cd22b49ec88293b Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Wed, 17 Apr 2024 09:57:57 +0800 Subject: [PATCH 04/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E4=B8=AD=E5=85=B3=E9=97=AD=E5=8A=A8=E4=BD=9C=E4=B8=AD?= =?UTF-8?q?=E6=89=93=E5=BC=80=E5=BC=B9=E7=AA=97=E5=90=8E=E7=BB=AD=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=8A=A8=E4=BD=9C=E4=B8=8D=E6=89=A7=E8=A1=8C=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#10044)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../amis-core/src/actions/DialogAction.ts | 65 +++++++++++++------ .../amis-core/src/actions/DrawerAction.ts | 31 ++++++--- packages/amis-editor-core/src/store/editor.ts | 3 +- packages/amis/src/renderers/Dialog.tsx | 13 ++++ packages/amis/src/renderers/Drawer.tsx | 9 +++ 5 files changed, 89 insertions(+), 32 deletions(-) diff --git a/packages/amis-core/src/actions/DialogAction.ts b/packages/amis-core/src/actions/DialogAction.ts index 171b04117..bc5cfa0c8 100644 --- a/packages/amis-core/src/actions/DialogAction.ts +++ b/packages/amis-core/src/actions/DialogAction.ts @@ -83,16 +83,27 @@ export class DialogAction implements RendererAction { return; } - let ret = renderer.props.onAction?.( - event, - { - actionType: 'dialog', - dialog: action.dialog, - reload: 'none', - data: action.rawData - }, - action.data - ); + let ret = renderer.handleAction + ? renderer.handleAction( + event, + { + actionType: 'dialog', + dialog: action.dialog, + reload: 'none', + data: action.rawData + }, + action.data + ) + : renderer.props.onAction?.( + event, + { + actionType: 'dialog', + dialog: action.dialog, + reload: 'none', + data: action.rawData + }, + action.data + ); event.pendingPromise.push(ret); if (action.waitForAction) { @@ -211,17 +222,29 @@ export class ConfirmAction implements RendererAction { // 自定义弹窗内容 const confirmed = await new Promise((resolve, reject) => { - renderer.props.onAction?.( - event, - { - actionType: 'dialog', - dialog: modal, - data: action.rawData, - reload: 'none', - callback: (result: boolean) => resolve(result) - }, - action.data - ); + renderer.handleAction + ? renderer.handleAction( + event, + { + actionType: 'dialog', + dialog: modal, + data: action.rawData, + reload: 'none', + callback: (result: boolean) => resolve(result) + }, + action.data + ) + : renderer.props.onAction?.( + event, + { + actionType: 'dialog', + dialog: modal, + data: action.rawData, + reload: 'none', + callback: (result: boolean) => resolve(result) + }, + action.data + ); }); return confirmed; diff --git a/packages/amis-core/src/actions/DrawerAction.ts b/packages/amis-core/src/actions/DrawerAction.ts index 15d08823a..71ebaf46a 100644 --- a/packages/amis-core/src/actions/DrawerAction.ts +++ b/packages/amis-core/src/actions/DrawerAction.ts @@ -41,16 +41,27 @@ export class DrawerAction implements RendererAction { if ((action as any).$$id !== undefined) { return; } - let ret = renderer.props.onAction?.( - event, - { - actionType: 'drawer', - drawer: action.drawer, - reload: 'none', - data: action.rawData - }, - action.data - ); + let ret = renderer.handleAction + ? renderer.handleAction( + event, + { + actionType: 'drawer', + drawer: action.drawer, + reload: 'none', + data: action.rawData + }, + action.data + ) + : renderer.props.onAction?.( + event, + { + actionType: 'drawer', + drawer: action.drawer, + reload: 'none', + data: action.rawData + }, + action.data + ); event.pendingPromise.push(ret); if (action.waitForAction) { diff --git a/packages/amis-editor-core/src/store/editor.ts b/packages/amis-editor-core/src/store/editor.ts index d2eef65fb..a1d193598 100644 --- a/packages/amis-editor-core/src/store/editor.ts +++ b/packages/amis-editor-core/src/store/editor.ts @@ -1013,7 +1013,7 @@ export const MainStore = types // 获取弹窗大纲列表 get modals(): Array { - const schema = self.schema; + const schema = {...self.schema}; const modals: Array = []; Object.keys(schema.definitions || {}).forEach(key => { const definition = schema.definitions[key]; @@ -1024,6 +1024,7 @@ export const MainStore = types }); } }); + delete schema.definitions; JSONTraverse(schema, (value: any, key: string, host: any) => { if ( key === 'actionType' && diff --git a/packages/amis/src/renderers/Dialog.tsx b/packages/amis/src/renderers/Dialog.tsx index d4e5504b3..a41b1b0a5 100644 --- a/packages/amis/src/renderers/Dialog.tsx +++ b/packages/amis/src/renderers/Dialog.tsx @@ -278,6 +278,10 @@ export default class Dialog extends React.Component { if (rendererEvent?.prevented) { return; } + + if (rendererEvent?.pendingPromise.length) { + await rendererEvent.allDone(); + } // clear error store.updateMessage(); onClose(confirmed); @@ -1008,6 +1012,10 @@ export class DialogRenderer extends Dialog { return; } + if (rendererEvent?.pendingPromise.length) { + await rendererEvent.allDone(); + } + store.setCurrentAction(action, this.props.resolveDefinitions); // clear error store.updateMessage(); @@ -1022,10 +1030,15 @@ export class DialogRenderer extends Dialog { 'confirm', createObject(this.props.data, data) ); + if (rendererEvent?.prevented) { return; } + if (rendererEvent?.pendingPromise.length) { + await rendererEvent.allDone(); + } + store.setCurrentAction(action, this.props.resolveDefinitions); const handleResult = this.tryChildrenToHandle( { diff --git a/packages/amis/src/renderers/Drawer.tsx b/packages/amis/src/renderers/Drawer.tsx index fc158bf5c..ad566adef 100644 --- a/packages/amis/src/renderers/Drawer.tsx +++ b/packages/amis/src/renderers/Drawer.tsx @@ -309,6 +309,9 @@ export default class Drawer extends React.Component { if (rendererEvent?.prevented) { return; } + if (rendererEvent?.pendingPromise.length) { + await rendererEvent.allDone(); + } // clear error store.updateMessage(); onClose(); @@ -954,6 +957,9 @@ export class DrawerRenderer extends Drawer { if (rendererEvent?.prevented) { return; } + if (rendererEvent?.pendingPromise.length) { + await rendererEvent.allDone(); + } store.setCurrentAction(action, this.props.resolveDefinitions); onClose(); if (action.close) { @@ -969,6 +975,9 @@ export class DrawerRenderer extends Drawer { if (rendererEvent?.prevented) { return; } + if (rendererEvent?.pendingPromise.length) { + await rendererEvent.allDone(); + } store.setCurrentAction(action, this.props.resolveDefinitions); this.tryChildrenToHandle(action, data) || onClose(); } else if (action.actionType === 'drawer') { From f5aecd7849bf565a965170ed96f972f7f476be53 Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Wed, 17 Apr 2024 10:15:45 +0800 Subject: [PATCH 05/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E5=BC=B9=E7=AA=97=E4=B8=AD=E5=BC=B9=E7=AA=97=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=87=BA=E7=8E=B0=E9=87=8D=E5=A4=8D=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#10047)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-editor-core/src/store/editor.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/amis-editor-core/src/store/editor.ts b/packages/amis-editor-core/src/store/editor.ts index a1d193598..4c8c8d2fb 100644 --- a/packages/amis-editor-core/src/store/editor.ts +++ b/packages/amis-editor-core/src/store/editor.ts @@ -1013,7 +1013,7 @@ export const MainStore = types // 获取弹窗大纲列表 get modals(): Array { - const schema = {...self.schema}; + const schema = self.schema; const modals: Array = []; Object.keys(schema.definitions || {}).forEach(key => { const definition = schema.definitions[key]; @@ -1024,7 +1024,6 @@ export const MainStore = types }); } }); - delete schema.definitions; JSONTraverse(schema, (value: any, key: string, host: any) => { if ( key === 'actionType' && @@ -1032,7 +1031,12 @@ export const MainStore = types ) { const key = value === 'drawer' ? 'drawer' : 'dialog'; const body = host[key] || host['args']; - if (body && !body.$ref) { + if ( + body && + !body.$ref && + body.$$id && + !modals.find(m => (m as any).$$originId === body.$$id) + ) { modals.push({ ...body, actionType: value From d5299267efdd4f3cbb0e77c59edeb80a142c79a6 Mon Sep 17 00:00:00 2001 From: qkiroc <30946345+qkiroc@users.noreply.github.com> Date: Wed, 17 Apr 2024 00:25:39 -0700 Subject: [PATCH 06/46] =?UTF-8?q?feat:=20card=20subTitle=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=9B=B4=E5=A4=9A=E6=B8=B2=E6=9F=93=E6=96=B9=E5=BC=8F=20(#1003?= =?UTF-8?q?7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: card subTitle支持更多渲染方式 * feat: card subTitle支持更多渲染方式 * feat: card subTitle支持更多渲染方式 --------- Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com> --- packages/amis/src/renderers/Card.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/amis/src/renderers/Card.tsx b/packages/amis/src/renderers/Card.tsx index cad481107..27eaf551d 100644 --- a/packages/amis/src/renderers/Card.tsx +++ b/packages/amis/src/renderers/Card.tsx @@ -86,7 +86,7 @@ export interface CardSchema extends BaseSchema { /** * 副标题 */ - subTitle?: SchemaTpl; + subTitle?: SchemaTpl | Schema; subTitleClassName?: SchemaClassName; subTitlePlaceholder?: string; @@ -593,8 +593,8 @@ export class CardRenderer extends React.Component { if (header) { const {subTitle: subTitleTpl} = header || {}; - const subTitle = filter(subTitleTpl, data); - return subTitle ? render('sub-title', subTitleTpl!) : undefined; + // const subTitle = filter(subTitleTpl, data); + return subTitleTpl ? render('sub-title', subTitleTpl, data) : undefined; } return; } From a0b96570f1cbac344a03727b0ede335b08e1be7f Mon Sep 17 00:00:00 2001 From: qkiroc <30946345+qkiroc@users.noreply.github.com> Date: Wed, 17 Apr 2024 17:37:38 +0800 Subject: [PATCH 07/46] =?UTF-8?q?chore:=20=E4=BF=AE=E6=94=B9crad=20subTitl?= =?UTF-8?q?e=E5=A3=B0=E6=98=8E=20(#10054)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: card subTitle支持更多渲染方式 * feat: card subTitle支持更多渲染方式 * feat: card subTitle支持更多渲染方式 * chore: 修改card subTitle声明 --------- Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com> Co-authored-by: liaoxuezhi <2betop.cn@gmail.com> --- packages/amis/src/renderers/Card.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/amis/src/renderers/Card.tsx b/packages/amis/src/renderers/Card.tsx index 27eaf551d..a837de3bf 100644 --- a/packages/amis/src/renderers/Card.tsx +++ b/packages/amis/src/renderers/Card.tsx @@ -18,6 +18,7 @@ import Copyable, {SchemaCopyable} from './Copyable'; import { BaseSchema, SchemaClassName, + SchemaCollection, SchemaExpression, SchemaObject, SchemaTpl, @@ -86,7 +87,7 @@ export interface CardSchema extends BaseSchema { /** * 副标题 */ - subTitle?: SchemaTpl | Schema; + subTitle?: SchemaCollection; subTitleClassName?: SchemaClassName; subTitlePlaceholder?: string; From f359bdf327dd34b8eaf5d2851585301cea2180b1 Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Thu, 18 Apr 2024 12:55:18 +0800 Subject: [PATCH 08/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20form=20?= =?UTF-8?q?=E7=9A=84=20flush=20=E9=80=BB=E8=BE=91=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E4=BC=9A=E5=87=BA=E7=8E=B0=E4=B8=80=E7=9B=B4=E7=AD=89=E5=BE=85?= =?UTF-8?q?=E8=87=AA=E5=B7=B1=E7=9A=84=E9=97=AE=E9=A2=98=20(#10059)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-core/src/factory.tsx | 5 ++ packages/amis-core/src/renderers/Form.tsx | 79 +++++++++++-------- .../amis/src/renderers/Form/InputDate.tsx | 8 +- .../src/renderers/Form/InputDateRange.tsx | 8 +- packages/amis/src/renderers/Table2/index.tsx | 9 ++- 5 files changed, 65 insertions(+), 44 deletions(-) diff --git a/packages/amis-core/src/factory.tsx b/packages/amis-core/src/factory.tsx index afc5319e3..f5307ef0f 100644 --- a/packages/amis-core/src/factory.tsx +++ b/packages/amis-core/src/factory.tsx @@ -85,6 +85,11 @@ export interface RendererProps [propName: string]: any; }; onBroadcast?: (type: string, rawEvent: RendererEvent, ctx: any) => any; + dispatchEvent: ( + e: React.UIEvent | React.BaseSyntheticEvent | string, + data: any, + renderer?: React.Component + ) => Promise>; mobileUI?: boolean; [propName: string]: any; } diff --git a/packages/amis-core/src/renderers/Form.tsx b/packages/amis-core/src/renderers/Form.tsx index abe19a46a..ef49890e4 100644 --- a/packages/amis-core/src/renderers/Form.tsx +++ b/packages/amis-core/src/renderers/Form.tsx @@ -994,7 +994,9 @@ export default class Form extends React.Component { this.flushing = true; const hooks = this.hooks['flush'] || []; await Promise.all(hooks.map(fn => fn())); - await this.lazyEmitChange.flush(); + if (!this.emitting) { + await this.lazyEmitChange.flush(); + } } finally { this.flushing = false; } @@ -1065,46 +1067,53 @@ export default class Form extends React.Component { } emittedData: any = null; + emitting = false; async emitChange(submit: boolean, skipIfNothingChanges: boolean = false) { - const {onChange, store, submitOnChange, dispatchEvent, data} = this.props; + try { + this.emitting = true; - if (!isAlive(store)) { - return; - } + const {onChange, store, submitOnChange, dispatchEvent, data} = this.props; - const diff = difference(store.data, store.pristine); - if ( - skipIfNothingChanges && - (!Object.keys(diff).length || isEqual(store.data, this.emittedData)) - ) { - return; - } + if (!isAlive(store)) { + return; + } - this.emittedData = store.data; - // 提前准备好 onChange 的参数。 - // 因为 store.data 会在 await 期间被 WithStore.componentDidUpdate 中的 store.initData 改变。导致数据丢失 - const changeProps = [store.data, diff, this.props]; - const dispatcher = await dispatchEvent( - 'change', - createObject(data, store.data) - ); - if (!dispatcher?.prevented) { - onChange && onChange.apply(null, changeProps); - } + const diff = difference(store.data, store.pristine); + if ( + skipIfNothingChanges && + (!Object.keys(diff).length || isEqual(store.data, this.emittedData)) + ) { + return; + } - store.clearRestError(); - - if (submit || (submitOnChange && store.inited)) { - await this.handleAction( - undefined, - { - type: 'submit', - // 如果这里不跳过,会相互依赖死循环,flush 会 让 emiteChange 立即执行 - // handleAction 里面又会调用 flush - skipFormFlush: true - }, - store.data + this.emittedData = store.data; + // 提前准备好 onChange 的参数。 + // 因为 store.data 会在 await 期间被 WithStore.componentDidUpdate 中的 store.initData 改变。导致数据丢失 + const changeProps = [store.data, diff, this.props]; + const dispatcher = await dispatchEvent( + 'change', + createObject(data, store.data) ); + if (!dispatcher?.prevented) { + onChange && onChange.apply(null, changeProps); + } + + store.clearRestError(); + + if (submit || (submitOnChange && store.inited)) { + await this.handleAction( + undefined, + { + type: 'submit', + // 如果这里不跳过,会相互依赖死循环,flush 会 让 emiteChange 立即执行 + // handleAction 里面又会调用 flush + skipFormFlush: true + }, + store.data + ); + } + } finally { + this.emitting = false; } } diff --git a/packages/amis/src/renderers/Form/InputDate.tsx b/packages/amis/src/renderers/Form/InputDate.tsx index 4eecdf169..9267f98e7 100644 --- a/packages/amis/src/renderers/Form/InputDate.tsx +++ b/packages/amis/src/renderers/Form/InputDate.tsx @@ -593,9 +593,11 @@ export default class DateControl extends React.PureComponent< 'change', resolveEventData(this.props, {value: nextValue}) ); - if (dispatcher?.prevented) { - return; - } + // 因为前面没有 await,所以这里的 dispatcher.prevented 是不准确的。 + // 为什么没写 onChange,我估计是不能让 onChange 太慢执行 + // if (dispatcher?.prevented) { + // return; + // } this.props.onChange(nextValue); } diff --git a/packages/amis/src/renderers/Form/InputDateRange.tsx b/packages/amis/src/renderers/Form/InputDateRange.tsx index 1c540a4d5..b295352cd 100644 --- a/packages/amis/src/renderers/Form/InputDateRange.tsx +++ b/packages/amis/src/renderers/Form/InputDateRange.tsx @@ -281,9 +281,11 @@ export default class DateRangeControl extends React.Component { 'change', resolveEventData(this.props, {value: nextValue}) ); - if (dispatcher?.prevented) { - return; - } + // 因为前面没有 await,所以这里的 dispatcher.prevented 是不准确的。 + // 为什么没写 onChange,我估计是不能让 onChange 太慢执行 + // if (dispatcher?.prevented) { + // return; + // } this.props.onChange(nextValue); } diff --git a/packages/amis/src/renderers/Table2/index.tsx b/packages/amis/src/renderers/Table2/index.tsx index f0bc37166..10bef2ed4 100644 --- a/packages/amis/src/renderers/Table2/index.tsx +++ b/packages/amis/src/renderers/Table2/index.tsx @@ -1610,7 +1610,7 @@ export default class Table2 extends React.Component { selectedRows: Array, selectedRowKeys: Array, unSelectedRows: Array - ) { + ): Promise { const {dispatchEvent, data, store} = this.props; const rendererEvent = await dispatchEvent( @@ -1629,7 +1629,7 @@ export default class Table2 extends React.Component { } @autobind - async handleSort(payload: SortProps) { + async handleSort(payload: SortProps): Promise { const {dispatchEvent, data, onSort} = this.props; const rendererEvent = await dispatchEvent( 'columnSort', @@ -1647,7 +1647,10 @@ export default class Table2 extends React.Component { } @autobind - async handleFilter(payload: {filterName: string; filterValue: string}) { + async handleFilter(payload: { + filterName: string; + filterValue: string; + }): Promise { const {dispatchEvent, data, onSearch} = this.props; const rendererEvent = await dispatchEvent( From 12a999f4edfbd959fd404ce31027dc6b15b3cf58 Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Thu, 18 Apr 2024 17:10:11 +0800 Subject: [PATCH 09/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8A=A8?= =?UTF-8?q?=E4=BD=9C=E9=9D=A2=E6=9D=BF=E4=B8=AD=E5=BC=B9=E7=AA=97=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#10063)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../amis-editor-core/src/component/Panel/DialogList.tsx | 9 +++++++-- .../amis-editor/src/renderer/event-control/helper.tsx | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/amis-editor-core/src/component/Panel/DialogList.tsx b/packages/amis-editor-core/src/component/Panel/DialogList.tsx index 0c6f77821..b837f600b 100644 --- a/packages/amis-editor-core/src/component/Panel/DialogList.tsx +++ b/packages/amis-editor-core/src/component/Panel/DialogList.tsx @@ -2,7 +2,7 @@ import {ClassNamesFn} from 'amis-core'; import {observer} from 'mobx-react'; import React from 'react'; import {EditorStoreType} from '../../store/editor'; -import {modalsToDefinitions, translateSchema} from '../../util'; +import {JSONGetById, modalsToDefinitions, translateSchema} from '../../util'; import {Button, Icon, ListMenu, PopOverContainer, confirm} from 'amis'; export interface DialogListProps { @@ -48,7 +48,12 @@ export default observer(function DialogList({ type: 'dialog', ...(modal as any), definitions: modalsToDefinitions( - store.modals.filter((m: any) => m.$$id !== modalId) + store.modals.filter( + (m: any) => + // 不要把自己下发,不允许弹窗自己再弹出自己 + // 不要下发自己内容里面内嵌的弹窗,否则会导致子弹窗里面的弹窗列表重复 + m.$$id !== modalId && !JSONGetById(modal, m.$$id) + ) ) }, onChange: ({definitions, ...modal}: any, diff: any) => { diff --git a/packages/amis-editor/src/renderer/event-control/helper.tsx b/packages/amis-editor/src/renderer/event-control/helper.tsx index c0fab80a8..93a18ea2f 100644 --- a/packages/amis-editor/src/renderer/event-control/helper.tsx +++ b/packages/amis-editor/src/renderer/event-control/helper.tsx @@ -327,7 +327,12 @@ export const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => { type: 'dialog', ...modal, definitions: modalsToDefinitions( - store.modals.filter((m: any) => m.$$id !== modalId) + store.modals.filter( + (m: any) => + // 不要把自己下发,不允许弹窗自己再弹出自己 + // 不要下发自己内容里面内嵌的弹窗,否则会导致子弹窗里面的弹窗列表重复 + m.$$id !== modalId && !JSONGetById(modal, m.$$id) + ) ) }, onChange: ({definitions, ...modal}: any, diff: any) => { From cb6feedae31214987457fe529df92054bb108b90 Mon Sep 17 00:00:00 2001 From: wuduoyi Date: Thu, 18 Apr 2024 20:01:49 +0800 Subject: [PATCH 10/46] =?UTF-8?q?chore:=20=E5=87=8F=E5=B0=8F=20Excel=20?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=8D=95=E5=85=83=E6=A0=BC=E7=9A=84=20paddin?= =?UTF-8?q?g=20=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis/package.json | 2 +- packages/office-viewer/package.json | 2 +- packages/office-viewer/src/excel/render/Consts.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/amis/package.json b/packages/amis/package.json index 596ed63f3..12a6c8ea9 100644 --- a/packages/amis/package.json +++ b/packages/amis/package.json @@ -62,7 +62,7 @@ "moment": "^2.19.4", "moment-timezone": "^0.5.34", "mpegts.js": "^1.6.10", - "office-viewer": "^0.3.10", + "office-viewer": "^0.3.11", "prop-types": "^15.6.1", "qrcode.react": "^3.1.0", "react-cropper": "^2.1.8", diff --git a/packages/office-viewer/package.json b/packages/office-viewer/package.json index 7a114b687..6803910a5 100644 --- a/packages/office-viewer/package.json +++ b/packages/office-viewer/package.json @@ -1,6 +1,6 @@ { "name": "office-viewer", - "version": "0.3.10", + "version": "0.3.11", "description": "office 文档在线预览", "main": "lib/index.js", "module": "esm/index.js", diff --git a/packages/office-viewer/src/excel/render/Consts.ts b/packages/office-viewer/src/excel/render/Consts.ts index fa33ca330..4428b64c4 100644 --- a/packages/office-viewer/src/excel/render/Consts.ts +++ b/packages/office-viewer/src/excel/render/Consts.ts @@ -12,7 +12,7 @@ export const AUTO_COLOR = '#000000'; /** * 单元格的 padding */ -export const PADDING_SIZE = 4; +export const PADDING_SIZE = 2; /** * 最长列数,从 0 开始 From 41a6fbdef33dfb7a2db529f0592dbad56116e735 Mon Sep 17 00:00:00 2001 From: qkiroc <30946345+qkiroc@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:10:15 +0800 Subject: [PATCH 11/46] =?UTF-8?q?style:=20=E4=BC=98=E5=8C=96collapse?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=AB=AF=E6=A0=B7=E5=BC=8F=20(#10064)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com> --- packages/amis-ui/scss/_components.scss | 1 + packages/amis-ui/scss/components/_collapse.scss | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/amis-ui/scss/_components.scss b/packages/amis-ui/scss/_components.scss index e2b7d7b90..78897d573 100644 --- a/packages/amis-ui/scss/_components.scss +++ b/packages/amis-ui/scss/_components.scss @@ -2040,6 +2040,7 @@ --Collapse-content-color: var(--collapse-default-content-color); --Collapse-content-fontSize: var(--collapse-default-content-fontSize); --Collapse-content-fontWeight: var(--collapse-default-content-fontWeight); + --Collapse-mobile-marginBottom: var(--sizes-size-9); // 选项卡 --Tabs-borderColor: var(--colors-neutral-line-8); diff --git a/packages/amis-ui/scss/components/_collapse.scss b/packages/amis-ui/scss/components/_collapse.scss index d794f38bd..a09a9487f 100644 --- a/packages/amis-ui/scss/components/_collapse.scss +++ b/packages/amis-ui/scss/components/_collapse.scss @@ -223,7 +223,7 @@ .#{$ns}Collapse { border: none; position: relative; - + margin-bottom: var(--Collapse-mobile-marginBottom); &::before { @include hairline-bottom(var(--collapse-default-bottom-border-color)); } From 8563dd04ea5312ab1ec3a2498047b1eca72e2026 Mon Sep 17 00:00:00 2001 From: qkiroc <30946345+qkiroc@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:10:52 +0800 Subject: [PATCH 12/46] =?UTF-8?q?style:=20=E4=BC=98=E5=8C=96picker?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=9C=A8inline=E6=A8=A1=E5=BC=8F=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E5=AE=BD=E5=BA=A6=20(#10065)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * style: 优化picker组件在inline模式下的宽度 * chore: 解决react hook使用的的警告 --------- Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com> --- packages/amis-core/src/components/CustomStyle.tsx | 3 --- packages/amis-ui/scss/components/form/_picker.scss | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/amis-core/src/components/CustomStyle.tsx b/packages/amis-core/src/components/CustomStyle.tsx index 832c8329a..976ef672d 100644 --- a/packages/amis-core/src/components/CustomStyle.tsx +++ b/packages/amis-core/src/components/CustomStyle.tsx @@ -20,9 +20,6 @@ export const styleIdCount = new Map(); export default function (props: CustomStyleProps) { const {config, env, data} = props; const {themeCss, classNames, id, defaultData, wrapperCustomStyle} = config; - if (!themeCss && !wrapperCustomStyle) { - return null; - } useEffect(() => { if (styleIdCount.has(id)) { diff --git a/packages/amis-ui/scss/components/form/_picker.scss b/packages/amis-ui/scss/components/form/_picker.scss index 0ed39b440..244e46d74 100644 --- a/packages/amis-ui/scss/components/form/_picker.scss +++ b/packages/amis-ui/scss/components/form/_picker.scss @@ -175,7 +175,8 @@ } } -.#{$ns}PickerControl.is-inline { +.#{$ns}PickerControl.is-inline, +.#{$ns}Form-item--inline { .#{$ns}Picker { display: inline-block; min-width: px2rem(150px); From c9073e97165ba80106845b6f49386f588533321e Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Fri, 19 Apr 2024 15:24:04 +0800 Subject: [PATCH 13/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E4=B8=AD=E7=9A=84=E5=BC=B9=E7=AA=97=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E4=B8=AD=E5=87=BA=E7=8E=B0=E9=87=8D=E5=A4=8D=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#10073)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../amis-editor-core/src/component/Editor.tsx | 4 +- .../src/component/Panel/DialogList.tsx | 20 +++---- .../src/component/Panel/Outline.tsx | 4 +- .../src/component/SubEditor.tsx | 1 + packages/amis-editor-core/src/manager.ts | 18 +++++- packages/amis-editor-core/src/store/editor.ts | 56 ++++++++++++++----- packages/amis-editor-core/src/util.ts | 42 ++++++++++++-- .../event-control/DialogActionPanel.tsx | 20 +++++-- .../src/renderer/event-control/helper.tsx | 11 +--- 9 files changed, 126 insertions(+), 50 deletions(-) diff --git a/packages/amis-editor-core/src/component/Editor.tsx b/packages/amis-editor-core/src/component/Editor.tsx index 663b3f26f..949d5aaed 100644 --- a/packages/amis-editor-core/src/component/Editor.tsx +++ b/packages/amis-editor-core/src/component/Editor.tsx @@ -40,6 +40,7 @@ export interface EditorProps extends PluginEventListener { superEditorData?: any; withSuperDataSchema?: boolean; /** 当前 Editor 为 SubEditor 时触发的宿主节点 */ + hostManager?: EditorManager; hostNode?: EditorNodeType; dataBindingChange?: ( value: string, @@ -154,6 +155,7 @@ export default class Editor extends Component { onChange, showCustomRenderersPanel, superEditorData, + hostManager, ...rest } = props; @@ -179,7 +181,7 @@ export default class Editor extends Component { this.store.setShowCustomRenderersPanel(showCustomRenderersPanel); } - this.manager = new EditorManager(config, this.store); + this.manager = new EditorManager(config, this.store, hostManager); // 子编辑器不再重新设置 editorStore if (!(props.isSubEditor && (window as any).editorStore)) { diff --git a/packages/amis-editor-core/src/component/Panel/DialogList.tsx b/packages/amis-editor-core/src/component/Panel/DialogList.tsx index b837f600b..e29d8876a 100644 --- a/packages/amis-editor-core/src/component/Panel/DialogList.tsx +++ b/packages/amis-editor-core/src/component/Panel/DialogList.tsx @@ -4,17 +4,20 @@ import React from 'react'; import {EditorStoreType} from '../../store/editor'; import {JSONGetById, modalsToDefinitions, translateSchema} from '../../util'; import {Button, Icon, ListMenu, PopOverContainer, confirm} from 'amis'; +import {EditorManager} from '../../manager'; export interface DialogListProps { classnames: ClassNamesFn; store: EditorStoreType; + manager: EditorManager; } export default observer(function DialogList({ classnames: cx, - store + store, + manager }: DialogListProps) { - const modals = store.modals; + const modals = store.modals.filter(item => !item.disabled); const handleAddDialog = React.useCallback(() => { const modal = { @@ -29,7 +32,7 @@ export default observer(function DialogList({ ] }; - store.openSubEditor({ + manager.openSubEditor({ title: '编辑弹窗', value: modal, onChange: ({definitions, ...modal}: any, diff: any) => { @@ -42,19 +45,12 @@ export default observer(function DialogList({ const index = parseInt(event.currentTarget.getAttribute('data-index')!, 10); const modal = store.modals[index]; const modalId = modal.$$id!; - store.openSubEditor({ + manager.openSubEditor({ title: '编辑弹窗', value: { type: 'dialog', ...(modal as any), - definitions: modalsToDefinitions( - store.modals.filter( - (m: any) => - // 不要把自己下发,不允许弹窗自己再弹出自己 - // 不要下发自己内容里面内嵌的弹窗,否则会导致子弹窗里面的弹窗列表重复 - m.$$id !== modalId && !JSONGetById(modal, m.$$id) - ) - ) + definitions: modalsToDefinitions(store.modals, {}, modal) }, onChange: ({definitions, ...modal}: any, diff: any) => { store.updateModal(modalId, modal, definitions); diff --git a/packages/amis-editor-core/src/component/Panel/Outline.tsx b/packages/amis-editor-core/src/component/Panel/Outline.tsx index d5b6376c5..ceeba2047 100644 --- a/packages/amis-editor-core/src/component/Panel/Outline.tsx +++ b/packages/amis-editor-core/src/component/Panel/Outline.tsx @@ -273,7 +273,7 @@ export class OutlinePanel extends React.Component { render() { const {curSearchElemKey} = this.state; - const {store} = this.props; + const {store, manager} = this.props; const outlineTabsKey = store.outlineTabsKey || 'component-outline'; const options = store.outline; @@ -341,7 +341,7 @@ export class OutlinePanel extends React.Component { eventKey={'dialog-outline'} title={'弹窗列表'} > - + )} diff --git a/packages/amis-editor-core/src/component/SubEditor.tsx b/packages/amis-editor-core/src/component/SubEditor.tsx index 0014a38f1..bade8e13b 100644 --- a/packages/amis-editor-core/src/component/SubEditor.tsx +++ b/packages/amis-editor-core/src/component/SubEditor.tsx @@ -146,6 +146,7 @@ export class SubEditor extends React.Component { ref={store.subEditorRef} onChange={onChange} data={store.subEditorContext?.data} + hostManager={manager} hostNode={store.subEditorContext?.hostNode} superEditorData={superEditorData} schemaFilter={manager.config.schemaFilter} diff --git a/packages/amis-editor-core/src/manager.ts b/packages/amis-editor-core/src/manager.ts index 6dce26006..298e59ece 100644 --- a/packages/amis-editor-core/src/manager.ts +++ b/packages/amis-editor-core/src/manager.ts @@ -215,7 +215,8 @@ export class EditorManager { constructor( readonly config: EditorManagerConfig, - readonly store: EditorStoreType + readonly store: EditorStoreType, + readonly parent?: EditorManager ) { // 传给 amis 渲染器的默认 env this.env = { @@ -1358,6 +1359,20 @@ export class EditorManager { * @param config */ openSubEditor(config: SubEditorContext) { + if ( + ['dialog', 'drawer', 'confirmDialog'].includes(config.value.type) && + this.parent + ) { + let parent: EditorManager | undefined = this.parent; + while (parent) { + if (parent.store.schema.$$id === config.value.$$id) { + toast.warning('所选弹窗已经被打开,不能多次打开'); + return; + } + + parent = parent.parent; + } + } this.store.openSubEditor(config); } @@ -2212,6 +2227,7 @@ export class EditorManager { this.trigger('dispose', { data: this }); + delete (this as any).parent; this.toDispose.forEach(fn => fn()); this.toDispose = []; this.plugins.forEach(p => p.dispose?.()); diff --git a/packages/amis-editor-core/src/store/editor.ts b/packages/amis-editor-core/src/store/editor.ts index 4c8c8d2fb..6129d8943 100644 --- a/packages/amis-editor-core/src/store/editor.ts +++ b/packages/amis-editor-core/src/store/editor.ts @@ -133,6 +133,10 @@ export type EditorModalBody = (DialogSchema | DrawerSchema) & { // 如果是公共弹窗,在 definitions 中的 key $$ref?: string; + // 内嵌弹窗会转成公共弹窗下发给子弹窗,否则子弹窗里面无法选择 + // 这类会在 definition 里面标记原始位置 + $$originId?: string; + // 弹出方式 actionType?: string; }; @@ -548,10 +552,14 @@ export const MainStore = types return undefined; } + const isSubEditor = self.isSubEditor; + return JSONPipeOut( JSONGetById(self.schema, self.activeId), getEnv(self).isHiddenProps || ((key, props) => + // 如果是子弹窗,不显示 definitions,要是通过代码模式改了,就麻烦了 + (isSubEditor && key === 'definitions') || (key.substring(0, 2) === '$$' && key !== '$$comments' && key !== '$$commonSchema') || @@ -1015,15 +1023,7 @@ export const MainStore = types get modals(): Array { const schema = self.schema; const modals: Array = []; - Object.keys(schema.definitions || {}).forEach(key => { - const definition = schema.definitions[key]; - if (['dialog', 'drawer'].includes(definition.type)) { - modals.push({ - ...definition, - $$ref: key - }); - } - }); + JSONTraverse(schema, (value: any, key: string, host: any) => { if ( key === 'actionType' && @@ -1031,12 +1031,7 @@ export const MainStore = types ) { const key = value === 'drawer' ? 'drawer' : 'dialog'; const body = host[key] || host['args']; - if ( - body && - !body.$ref && - body.$$id && - !modals.find(m => (m as any).$$originId === body.$$id) - ) { + if (body && !body.$ref) { modals.push({ ...body, actionType: value @@ -1045,6 +1040,37 @@ export const MainStore = types } return value; }); + + // 公共组件排在前面 + Object.keys(schema.definitions || {}) + .reverse() + .forEach(key => { + const definition = schema.definitions[key]; + if (['dialog', 'drawer'].includes(definition.type)) { + // 不要把已经内嵌弹窗中的弹窗再放到外面 + if ( + definition.$$originId && + modals.find(item => item.$$id === definition.$$originId) + ) { + return; + } + + modals.unshift({ + ...definition, + $$ref: key + }); + } + }); + + // 子弹窗时,自己就是个弹窗 + if (['dialog', 'drawer', 'confirmDialog'].includes(schema.type)) { + modals.unshift({ + ...schema, + // 如果还包含这个,子弹窗里面收集弹窗的时候会出现多份内嵌弹窗 + definitions: undefined + }); + } + return modals; }, diff --git a/packages/amis-editor-core/src/util.ts b/packages/amis-editor-core/src/util.ts index 9c685c06c..14b087c31 100644 --- a/packages/amis-editor-core/src/util.ts +++ b/packages/amis-editor-core/src/util.ts @@ -1397,7 +1397,12 @@ export const scrollToActive = debounce((selector: string) => { } }, 200); -export function addModal(schema: any, modal: any, definitions?: any) { +export function addModal( + schema: any, + modal: any, + definitions?: any, + isKeyValid?: (key: string) => boolean +) { schema = {...schema, definitions: {...schema.definitions}}; // 如果有传入definitions,则合并到schema中 @@ -1407,7 +1412,10 @@ export function addModal(schema: any, modal: any, definitions?: any) { let idx = 1; while (true) { - if (!schema.definitions[`modal-ref-${idx}`]) { + if ( + !schema.definitions[`modal-ref-${idx}`] && + (!isKeyValid || isKeyValid(`modal-ref-${idx}`)) + ) { break; } idx++; @@ -1435,16 +1443,42 @@ export function addModal(schema: any, modal: any, definitions?: any) { */ export function modalsToDefinitions( modals: Array, - definitions: any = {} + definitions: any = {}, + edtingModal?: EditorModalBody ) { let schema = { definitions }; + modals.forEach((modal, idx) => { + if ( + edtingModal && + (edtingModal.$$ref + ? edtingModal.$$ref === modal.$$ref + : edtingModal.$$id === modal.$$id) + ) { + // 自己不需要转成 definitions + return; + } else if ( + !modal.$$ref && + modal.$$id && + (JSONGetById(schema.definitions, modal.$$id) || + (edtingModal && JSONGetById(edtingModal, modal.$$id))) + ) { + // 内嵌弹窗,已经包含在 definitions 里面了 + // 不需要转成 definitions + return; + } + if (modal.$$ref) { schema.definitions[modal.$$ref] = JSONPipeIn(modal); } else { - [schema] = addModal(schema, {...modal, $$originId: modal.$$id}); + [schema] = addModal( + schema, + {...modal, $$originId: modal.$$id}, + undefined, + key => !modals.find(m => m.$$ref && m.$$ref === key) + ); } }); return schema.definitions; diff --git a/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx b/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx index 1142aca40..736d7c49a 100644 --- a/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx +++ b/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx @@ -79,7 +79,7 @@ function DialogActionPanel({ subscribeSchemaSubmit((schema: any, nodeSchema: any, id: string) => { const rawActions = JSONGetById(schema, id)?.onEvent[eventKey]?.actions; if (!rawActions || !Array.isArray(rawActions)) { - throw new Error('动作配置错误'); + return; } const actionSchema = @@ -88,8 +88,9 @@ function DialogActionPanel({ ? rawActions.length - 1 : actionIndex ]; - const modals: Array = actionSchema.__actionModals; + const modals: Array = actionSchema?.__actionModals; if (!Array.isArray(modals)) { + // 不是编辑确定触发的,直接返回 return schema; } @@ -288,6 +289,7 @@ function DialogActionPanel({ actionSchema.actionType === 'drawer' ? 'drawer' : 'dialog' ] || actionSchema.args; + const schema = store.schema; const modals: Array = store.modals.map(modal => { const isCurrentActionModal = modal.$$id === dialogBody?.$$id; @@ -310,7 +312,11 @@ function DialogActionPanel({ value: modal.$$id, modal: modal, isCurrentActionModal, - data: modal.data + data: modal.data, + // 当前编辑的弹窗不让再里面再次弹出 + disabled: modal.$$ref + ? modal.$$ref === schema.$$ref + : modal.$$id === schema.$$id }; }); @@ -458,7 +464,7 @@ function DialogActionPanel({ skipForm?: boolean, closePopOver?: () => void ) => { - store.openSubEditor({ + manager.openSubEditor({ title: '新建弹窗', value: { type: 'dialog', @@ -513,7 +519,7 @@ function DialogActionPanel({ if (!currentModal) { return; } - store.openSubEditor({ + manager.openSubEditor({ title: '编辑弹窗', value: { type: 'dialog', @@ -526,7 +532,9 @@ function DialogActionPanel({ ], ...(currentModal.modal as any), definitions: modalsToDefinitions( - modals.filter(item => !item.isActive).map(item => item.modal) + modals.map(item => item.modal), + {}, + currentModal.modal ) }, onChange: ({definitions, ...modal}: any, diff: any) => { diff --git a/packages/amis-editor/src/renderer/event-control/helper.tsx b/packages/amis-editor/src/renderer/event-control/helper.tsx index 93a18ea2f..c76d27208 100644 --- a/packages/amis-editor/src/renderer/event-control/helper.tsx +++ b/packages/amis-editor/src/renderer/event-control/helper.tsx @@ -321,19 +321,12 @@ export const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => { e.stopPropagation(); const modalId = modal.$$id; - store.openSubEditor({ + manager.openSubEditor({ title: '编辑弹窗', value: { type: 'dialog', ...modal, - definitions: modalsToDefinitions( - store.modals.filter( - (m: any) => - // 不要把自己下发,不允许弹窗自己再弹出自己 - // 不要下发自己内容里面内嵌的弹窗,否则会导致子弹窗里面的弹窗列表重复 - m.$$id !== modalId && !JSONGetById(modal, m.$$id) - ) - ) + definitions: modalsToDefinitions(store.modals, {}, modal) }, onChange: ({definitions, ...modal}: any, diff: any) => { store.updateModal(modalId, modal, definitions); From cffd4b31220660a3f754b3d8406909c77c6e65d0 Mon Sep 17 00:00:00 2001 From: wuduoyi Date: Fri, 19 Apr 2024 15:43:28 +0800 Subject: [PATCH 14/46] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=20citydb=20clos?= =?UTF-8?q?es=20#10046?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-ui/src/components/CityDB.ts | 983 +++------------------- scripts/convert-citydb.ts | 26 + 2 files changed, 120 insertions(+), 889 deletions(-) create mode 100644 scripts/convert-citydb.ts diff --git a/packages/amis-ui/src/components/CityDB.ts b/packages/amis-ui/src/components/CityDB.ts index 2c92cc648..2ddd78cd8 100644 --- a/packages/amis-ui/src/components/CityDB.ts +++ b/packages/amis-ui/src/components/CityDB.ts @@ -1,9 +1,8 @@ -// 数据来源:https://lbs.amap.com/api/webservice/download +// 使用 script/convert-citydb.ts 来生成下面的配置 const db: { - [propName: string]: any; + [propName: string]: string; } = { 110000: '北京市', - 110100: '北京市市辖区', 110101: '东城区', 110102: '西城区', 110105: '朝阳区', @@ -21,7 +20,6 @@ const db: { 110118: '密云区', 110119: '延庆区', 120000: '天津市', - 120100: '天津市市辖区', 120101: '和平区', 120102: '河东区', 120103: '河西区', @@ -40,7 +38,6 @@ const db: { 120119: '蓟州区', 130000: '河北省', 130100: '石家庄市', - 130101: '石家庄市市辖区', 130102: '长安区', 130104: '桥西区', 130105: '新华区', @@ -64,7 +61,6 @@ const db: { 130183: '晋州市', 130184: '新乐市', 130200: '唐山市', - 130201: '唐山市市辖区', 130202: '路南区', 130203: '路北区', 130204: '古冶区', @@ -80,7 +76,6 @@ const db: { 130283: '迁安市', 130284: '滦州市', 130300: '秦皇岛市', - 130301: '秦皇岛市市辖区', 130302: '海港区', 130303: '山海关区', 130304: '北戴河区', @@ -89,7 +84,6 @@ const db: { 130322: '昌黎县', 130324: '卢龙县', 130400: '邯郸市', - 130401: '邯郸市市辖区', 130402: '邯山区', 130403: '丛台区', 130404: '复兴区', @@ -109,16 +103,14 @@ const db: { 130435: '曲周县', 130481: '武安市', 130500: '邢台市', - 130501: '邢台市市辖区', - 130502: '桥东区', - 130503: '桥西区', - 130521: '邢台县', + 130502: '襄都区', + 130503: '信都区', + 130505: '任泽区', + 130506: '南和区', 130522: '临城县', 130523: '内丘县', 130524: '柏乡县', 130525: '隆尧县', - 130526: '任县', - 130527: '南和县', 130528: '宁晋县', 130529: '巨鹿县', 130530: '新河县', @@ -130,7 +122,6 @@ const db: { 130581: '南宫市', 130582: '沙河市', 130600: '保定市', - 130601: '保定市市辖区', 130602: '竞秀区', 130606: '莲池区', 130607: '满城区', @@ -156,7 +147,6 @@ const db: { 130683: '安国市', 130684: '高碑店市', 130700: '张家口市', - 130701: '张家口市市辖区', 130702: '桥东区', 130703: '桥西区', 130705: '宣化区', @@ -174,7 +164,6 @@ const db: { 130731: '涿鹿县', 130732: '赤城县', 130800: '承德市', - 130801: '承德市市辖区', 130802: '双桥区', 130803: '双滦区', 130804: '鹰手营子矿区', @@ -187,7 +176,6 @@ const db: { 130828: '围场满族蒙古族自治县', 130881: '平泉市', 130900: '沧州市', - 130901: '沧州市市辖区', 130902: '新华区', 130903: '运河区', 130921: '沧县', @@ -205,7 +193,6 @@ const db: { 130983: '黄骅市', 130984: '河间市', 131000: '廊坊市', - 131001: '廊坊市市辖区', 131002: '安次区', 131003: '广阳区', 131022: '固安县', @@ -217,7 +204,6 @@ const db: { 131081: '霸州市', 131082: '三河市', 131100: '衡水市', - 131101: '衡水市市辖区', 131102: '桃城区', 131103: '冀州区', 131121: '枣强县', @@ -231,7 +217,6 @@ const db: { 131182: '深州市', 140000: '山西省', 140100: '太原市', - 140101: '太原市市辖区', 140105: '小店区', 140106: '迎泽区', 140107: '杏花岭区', @@ -243,7 +228,6 @@ const db: { 140123: '娄烦县', 140181: '古交市', 140200: '大同市', - 140201: '大同市市辖区', 140212: '新荣区', 140213: '平城区', 140214: '云冈区', @@ -255,14 +239,12 @@ const db: { 140225: '浑源县', 140226: '左云县', 140300: '阳泉市', - 140301: '阳泉市市辖区', 140302: '城区', 140303: '矿区', 140311: '郊区', 140321: '平定县', 140322: '盂县', 140400: '长治市', - 140401: '长治市市辖区', 140403: '潞州区', 140404: '上党区', 140405: '屯留区', @@ -276,7 +258,6 @@ const db: { 140430: '沁县', 140431: '沁源县', 140500: '晋城市', - 140501: '晋城市市辖区', 140502: '城区', 140521: '沁水县', 140522: '阳城县', @@ -284,7 +265,6 @@ const db: { 140525: '泽州县', 140581: '高平市', 140600: '朔州市', - 140601: '朔州市市辖区', 140602: '朔城区', 140603: '平鲁区', 140621: '山阴县', @@ -292,20 +272,18 @@ const db: { 140623: '右玉县', 140681: '怀仁市', 140700: '晋中市', - 140701: '晋中市市辖区', 140702: '榆次区', + 140703: '太谷区', 140721: '榆社县', 140722: '左权县', 140723: '和顺县', 140724: '昔阳县', 140725: '寿阳县', - 140726: '太谷县', 140727: '祁县', 140728: '平遥县', 140729: '灵石县', 140781: '介休市', 140800: '运城市', - 140801: '运城市市辖区', 140802: '盐湖区', 140821: '临猗县', 140822: '万荣县', @@ -320,7 +298,6 @@ const db: { 140881: '永济市', 140882: '河津市', 140900: '忻州市', - 140901: '忻州市市辖区', 140902: '忻府区', 140921: '定襄县', 140922: '五台县', @@ -336,7 +313,6 @@ const db: { 140932: '偏关县', 140981: '原平市', 141000: '临汾市', - 141001: '临汾市市辖区', 141002: '尧都区', 141021: '曲沃县', 141022: '翼城县', @@ -355,7 +331,6 @@ const db: { 141081: '侯马市', 141082: '霍州市', 141100: '吕梁市', - 141101: '吕梁市市辖区', 141102: '离石区', 141121: '文水县', 141122: '交城县', @@ -371,7 +346,6 @@ const db: { 141182: '汾阳市', 150000: '内蒙古自治区', 150100: '呼和浩特市', - 150101: '呼和浩特市市辖区', 150102: '新城区', 150103: '回民区', 150104: '玉泉区', @@ -382,7 +356,6 @@ const db: { 150124: '清水河县', 150125: '武川县', 150200: '包头市', - 150201: '包头市市辖区', 150202: '东河区', 150203: '昆都仑区', 150204: '青山区', @@ -393,12 +366,10 @@ const db: { 150222: '固阳县', 150223: '达尔罕茂明安联合旗', 150300: '乌海市', - 150301: '乌海市市辖区', 150302: '海勃湾区', 150303: '海南区', 150304: '乌达区', 150400: '赤峰市', - 150401: '赤峰市市辖区', 150402: '红山区', 150403: '元宝山区', 150404: '松山区', @@ -412,7 +383,6 @@ const db: { 150429: '宁城县', 150430: '敖汉旗', 150500: '通辽市', - 150501: '通辽市市辖区', 150502: '科尔沁区', 150521: '科尔沁左翼中旗', 150522: '科尔沁左翼后旗', @@ -422,7 +392,6 @@ const db: { 150526: '扎鲁特旗', 150581: '霍林郭勒市', 150600: '鄂尔多斯市', - 150601: '鄂尔多斯市市辖区', 150602: '东胜区', 150603: '康巴什区', 150621: '达拉特旗', @@ -433,7 +402,6 @@ const db: { 150626: '乌审旗', 150627: '伊金霍洛旗', 150700: '呼伦贝尔市', - 150701: '呼伦贝尔市市辖区', 150702: '海拉尔区', 150703: '扎赉诺尔区', 150721: '阿荣旗', @@ -449,7 +417,6 @@ const db: { 150784: '额尔古纳市', 150785: '根河市', 150800: '巴彦淖尔市', - 150801: '巴彦淖尔市市辖区', 150802: '临河区', 150821: '五原县', 150822: '磴口县', @@ -458,7 +425,6 @@ const db: { 150825: '乌拉特后旗', 150826: '杭锦后旗', 150900: '乌兰察布市', - 150901: '乌兰察布市市辖区', 150902: '集宁区', 150921: '卓资县', 150922: '化德县', @@ -496,7 +462,6 @@ const db: { 152923: '额济纳旗', 210000: '辽宁省', 210100: '沈阳市', - 210101: '沈阳市市辖区', 210102: '和平区', 210103: '沈河区', 210104: '大东区', @@ -511,7 +476,6 @@ const db: { 210124: '法库县', 210181: '新民市', 210200: '大连市', - 210201: '大连市市辖区', 210202: '中山区', 210203: '西岗区', 210204: '沙河口区', @@ -523,7 +487,6 @@ const db: { 210281: '瓦房店市', 210283: '庄河市', 210300: '鞍山市', - 210301: '鞍山市市辖区', 210302: '铁东区', 210303: '铁西区', 210304: '立山区', @@ -532,7 +495,6 @@ const db: { 210323: '岫岩满族自治县', 210381: '海城市', 210400: '抚顺市', - 210401: '抚顺市市辖区', 210402: '新抚区', 210403: '东洲区', 210404: '望花区', @@ -541,7 +503,6 @@ const db: { 210422: '新宾满族自治县', 210423: '清原满族自治县', 210500: '本溪市', - 210501: '本溪市市辖区', 210502: '平山区', 210503: '溪湖区', 210504: '明山区', @@ -549,7 +510,6 @@ const db: { 210521: '本溪满族自治县', 210522: '桓仁满族自治县', 210600: '丹东市', - 210601: '丹东市市辖区', 210602: '元宝区', 210603: '振兴区', 210604: '振安区', @@ -557,7 +517,6 @@ const db: { 210681: '东港市', 210682: '凤城市', 210700: '锦州市', - 210701: '锦州市市辖区', 210702: '古塔区', 210703: '凌河区', 210711: '太和区', @@ -566,7 +525,6 @@ const db: { 210781: '凌海市', 210782: '北镇市', 210800: '营口市', - 210801: '营口市市辖区', 210802: '站前区', 210803: '西市区', 210804: '鲅鱼圈区', @@ -574,7 +532,6 @@ const db: { 210881: '盖州市', 210882: '大石桥市', 210900: '阜新市', - 210901: '阜新市市辖区', 210902: '海州区', 210903: '新邱区', 210904: '太平区', @@ -583,7 +540,6 @@ const db: { 210921: '阜新蒙古族自治县', 210922: '彰武县', 211000: '辽阳市', - 211001: '辽阳市市辖区', 211002: '白塔区', 211003: '文圣区', 211004: '宏伟区', @@ -592,13 +548,11 @@ const db: { 211021: '辽阳县', 211081: '灯塔市', 211100: '盘锦市', - 211101: '盘锦市市辖区', 211102: '双台子区', 211103: '兴隆台区', 211104: '大洼区', 211122: '盘山县', 211200: '铁岭市', - 211201: '铁岭市市辖区', 211202: '银州区', 211204: '清河区', 211221: '铁岭县', @@ -607,7 +561,6 @@ const db: { 211281: '调兵山市', 211282: '开原市', 211300: '朝阳市', - 211301: '朝阳市市辖区', 211302: '双塔区', 211303: '龙城区', 211321: '朝阳县', @@ -616,7 +569,6 @@ const db: { 211381: '北票市', 211382: '凌源市', 211400: '葫芦岛市', - 211401: '葫芦岛市市辖区', 211402: '连山区', 211403: '龙港区', 211404: '南票区', @@ -625,7 +577,6 @@ const db: { 211481: '兴城市', 220000: '吉林省', 220100: '长春市', - 220101: '长春市市辖区', 220102: '南关区', 220103: '宽城区', 220104: '朝阳区', @@ -636,8 +587,8 @@ const db: { 220122: '农安县', 220182: '榆树市', 220183: '德惠市', + 220184: '公主岭市', 220200: '吉林市', - 220201: '吉林市市辖区', 220202: '昌邑区', 220203: '龙潭区', 220204: '船营区', @@ -648,21 +599,17 @@ const db: { 220283: '舒兰市', 220284: '磐石市', 220300: '四平市', - 220301: '四平市市辖区', 220302: '铁西区', 220303: '铁东区', 220322: '梨树县', 220323: '伊通满族自治县', - 220381: '公主岭市', 220382: '双辽市', 220400: '辽源市', - 220401: '辽源市市辖区', 220402: '龙山区', 220403: '西安区', 220421: '东丰县', 220422: '东辽县', 220500: '通化市', - 220501: '通化市市辖区', 220502: '东昌区', 220503: '二道江区', 220521: '通化县', @@ -671,7 +618,6 @@ const db: { 220581: '梅河口市', 220582: '集安市', 220600: '白山市', - 220601: '白山市市辖区', 220602: '浑江区', 220605: '江源区', 220621: '抚松县', @@ -679,14 +625,12 @@ const db: { 220623: '长白朝鲜族自治县', 220681: '临江市', 220700: '松原市', - 220701: '松原市市辖区', 220702: '宁江区', 220721: '前郭尔罗斯蒙古族自治县', 220722: '长岭县', 220723: '乾安县', 220781: '扶余市', 220800: '白城市', - 220801: '白城市市辖区', 220802: '洮北区', 220821: '镇赉县', 220822: '通榆县', @@ -703,7 +647,6 @@ const db: { 222426: '安图县', 230000: '黑龙江省', 230100: '哈尔滨市', - 230101: '哈尔滨市市辖区', 230102: '道里区', 230103: '南岗区', 230104: '道外区', @@ -723,7 +666,6 @@ const db: { 230183: '尚志市', 230184: '五常市', 230200: '齐齐哈尔市', - 230201: '齐齐哈尔市市辖区', 230202: '龙沙区', 230203: '建华区', 230204: '铁锋区', @@ -741,7 +683,6 @@ const db: { 230231: '拜泉县', 230281: '讷河市', 230300: '鸡西市', - 230301: '鸡西市市辖区', 230302: '鸡冠区', 230303: '恒山区', 230304: '滴道区', @@ -752,7 +693,6 @@ const db: { 230381: '虎林市', 230382: '密山市', 230400: '鹤岗市', - 230401: '鹤岗市市辖区', 230402: '向阳区', 230403: '工农区', 230404: '南山区', @@ -762,7 +702,6 @@ const db: { 230421: '萝北县', 230422: '绥滨县', 230500: '双鸭山市', - 230501: '双鸭山市市辖区', 230502: '尖山区', 230503: '岭东区', 230505: '四方台区', @@ -772,7 +711,6 @@ const db: { 230523: '宝清县', 230524: '饶河县', 230600: '大庆市', - 230601: '大庆市市辖区', 230602: '萨尔图区', 230603: '龙凤区', 230604: '让胡路区', @@ -783,26 +721,17 @@ const db: { 230623: '林甸县', 230624: '杜尔伯特蒙古族自治县', 230700: '伊春市', - 230701: '伊春市市辖区', - 230702: '伊春区', - 230703: '南岔区', - 230704: '友好区', - 230705: '西林区', - 230706: '翠峦区', - 230707: '新青区', - 230708: '美溪区', - 230709: '金山屯区', - 230710: '五营区', - 230711: '乌马河区', - 230712: '汤旺河区', - 230713: '带岭区', - 230714: '乌伊岭区', - 230715: '红星区', - 230716: '上甘岭区', + 230717: '伊美区', + 230718: '乌翠区', + 230719: '友好区', 230722: '嘉荫县', + 230723: '汤旺县', + 230724: '丰林县', + 230725: '大箐山县', + 230726: '南岔县', + 230751: '金林区', 230781: '铁力市', 230800: '佳木斯市', - 230801: '佳木斯市市辖区', 230803: '向阳区', 230804: '前进区', 230805: '东风区', @@ -814,13 +743,11 @@ const db: { 230882: '富锦市', 230883: '抚远市', 230900: '七台河市', - 230901: '七台河市市辖区', 230902: '新兴区', 230903: '桃山区', 230904: '茄子河区', 230921: '勃利县', 231000: '牡丹江市', - 231001: '牡丹江市市辖区', 231002: '东安区', 231003: '阳明区', 231004: '爱民区', @@ -832,15 +759,13 @@ const db: { 231085: '穆棱市', 231086: '东宁市', 231100: '黑河市', - 231101: '黑河市市辖区', 231102: '爱辉区', - 231121: '嫩江县', 231123: '逊克县', 231124: '孙吴县', 231181: '北安市', 231182: '五大连池市', + 231183: '嫩江市', 231200: '绥化市', - 231201: '绥化市市辖区', 231202: '北林区', 231221: '望奎县', 231222: '兰西县', @@ -857,7 +782,6 @@ const db: { 232721: '呼玛县', 232722: '塔河县', 310000: '上海市', - 310100: '上海市市辖区', 310101: '黄浦区', 310104: '徐汇区', 310105: '长宁区', @@ -876,7 +800,6 @@ const db: { 310151: '崇明区', 320000: '江苏省', 320100: '南京市', - 320101: '南京市市辖区', 320102: '玄武区', 320104: '秦淮区', 320105: '建邺区', @@ -889,7 +812,6 @@ const db: { 320117: '溧水区', 320118: '高淳区', 320200: '无锡市', - 320201: '无锡市市辖区', 320205: '锡山区', 320206: '惠山区', 320211: '滨湖区', @@ -898,7 +820,6 @@ const db: { 320281: '江阴市', 320282: '宜兴市', 320300: '徐州市', - 320301: '徐州市市辖区', 320302: '鼓楼区', 320303: '云龙区', 320305: '贾汪区', @@ -910,7 +831,6 @@ const db: { 320381: '新沂市', 320382: '邳州市', 320400: '常州市', - 320401: '常州市市辖区', 320402: '天宁区', 320404: '钟楼区', 320411: '新北区', @@ -918,29 +838,24 @@ const db: { 320413: '金坛区', 320481: '溧阳市', 320500: '苏州市', - 320501: '苏州市市辖区', 320505: '虎丘区', 320506: '吴中区', 320507: '相城区', 320508: '姑苏区', 320509: '吴江区', - 320571: '苏州工业园区', 320581: '常熟市', 320582: '张家港市', 320583: '昆山市', 320585: '太仓市', 320600: '南通市', - 320601: '南通市市辖区', - 320602: '崇川区', - 320611: '港闸区', 320612: '通州区', + 320613: '崇川区', + 320614: '海门区', 320623: '如东县', 320681: '启东市', 320682: '如皋市', - 320684: '海门市', 320685: '海安市', 320700: '连云港市', - 320701: '连云港市市辖区', 320703: '连云区', 320706: '海州区', 320707: '赣榆区', @@ -948,7 +863,6 @@ const db: { 320723: '灌云县', 320724: '灌南县', 320800: '淮安市', - 320801: '淮安市市辖区', 320803: '淮安区', 320804: '淮阴区', 320812: '清江浦区', @@ -957,7 +871,6 @@ const db: { 320830: '盱眙县', 320831: '金湖县', 320900: '盐城市', - 320901: '盐城市市辖区', 320902: '亭湖区', 320903: '盐都区', 320904: '大丰区', @@ -968,7 +881,6 @@ const db: { 320925: '建湖县', 320981: '东台市', 321000: '扬州市', - 321001: '扬州市市辖区', 321002: '广陵区', 321003: '邗江区', 321012: '江都区', @@ -976,7 +888,6 @@ const db: { 321081: '仪征市', 321084: '高邮市', 321100: '镇江市', - 321101: '镇江市市辖区', 321102: '京口区', 321111: '润州区', 321112: '丹徒区', @@ -984,7 +895,6 @@ const db: { 321182: '扬中市', 321183: '句容市', 321200: '泰州市', - 321201: '泰州市市辖区', 321202: '海陵区', 321203: '高港区', 321204: '姜堰区', @@ -992,7 +902,6 @@ const db: { 321282: '靖江市', 321283: '泰兴市', 321300: '宿迁市', - 321301: '宿迁市市辖区', 321302: '宿城区', 321311: '宿豫区', 321322: '沭阳县', @@ -1000,10 +909,7 @@ const db: { 321324: '泗洪县', 330000: '浙江省', 330100: '杭州市', - 330101: '杭州市市辖区', 330102: '上城区', - 330103: '下城区', - 330104: '江干区', 330105: '拱墅区', 330106: '西湖区', 330108: '滨江区', @@ -1011,11 +917,12 @@ const db: { 330110: '余杭区', 330111: '富阳区', 330112: '临安区', + 330113: '临平区', + 330114: '钱塘区', 330122: '桐庐县', 330127: '淳安县', 330182: '建德市', 330200: '宁波市', - 330201: '宁波市市辖区', 330203: '海曙区', 330205: '江北区', 330206: '北仑区', @@ -1027,7 +934,6 @@ const db: { 330281: '余姚市', 330282: '慈溪市', 330300: '温州市', - 330301: '温州市市辖区', 330302: '鹿城区', 330303: '龙湾区', 330304: '瓯海区', @@ -1039,8 +945,8 @@ const db: { 330329: '泰顺县', 330381: '瑞安市', 330382: '乐清市', + 330383: '龙港市', 330400: '嘉兴市', - 330401: '嘉兴市市辖区', 330402: '南湖区', 330411: '秀洲区', 330421: '嘉善县', @@ -1049,14 +955,12 @@ const db: { 330482: '平湖市', 330483: '桐乡市', 330500: '湖州市', - 330501: '湖州市市辖区', 330502: '吴兴区', 330503: '南浔区', 330521: '德清县', 330522: '长兴县', 330523: '安吉县', 330600: '绍兴市', - 330601: '绍兴市市辖区', 330602: '越城区', 330603: '柯桥区', 330604: '上虞区', @@ -1064,7 +968,6 @@ const db: { 330681: '诸暨市', 330683: '嵊州市', 330700: '金华市', - 330701: '金华市市辖区', 330702: '婺城区', 330703: '金东区', 330723: '武义县', @@ -1075,7 +978,6 @@ const db: { 330783: '东阳市', 330784: '永康市', 330800: '衢州市', - 330801: '衢州市市辖区', 330802: '柯城区', 330803: '衢江区', 330822: '常山县', @@ -1083,13 +985,11 @@ const db: { 330825: '龙游县', 330881: '江山市', 330900: '舟山市', - 330901: '舟山市市辖区', 330902: '定海区', 330903: '普陀区', 330921: '岱山县', 330922: '嵊泗县', 331000: '台州市', - 331001: '台州市市辖区', 331002: '椒江区', 331003: '黄岩区', 331004: '路桥区', @@ -1100,7 +1000,6 @@ const db: { 331082: '临海市', 331083: '玉环市', 331100: '丽水市', - 331101: '丽水市市辖区', 331102: '莲都区', 331121: '青田县', 331122: '缙云县', @@ -1112,7 +1011,6 @@ const db: { 331181: '龙泉市', 340000: '安徽省', 340100: '合肥市', - 340101: '合肥市市辖区', 340102: '瑶海区', 340103: '庐阳区', 340104: '蜀山区', @@ -1123,17 +1021,14 @@ const db: { 340124: '庐江县', 340181: '巢湖市', 340200: '芜湖市', - 340201: '芜湖市市辖区', 340202: '镜湖区', - 340203: '弋江区', 340207: '鸠江区', - 340208: '三山区', - 340221: '芜湖县', - 340222: '繁昌县', + 340209: '弋江区', + 340210: '湾沚区', + 340212: '繁昌区', 340223: '南陵县', - 340225: '无为县', + 340281: '无为市', 340300: '蚌埠市', - 340301: '蚌埠市市辖区', 340302: '龙子湖区', 340303: '蚌山区', 340304: '禹会区', @@ -1142,7 +1037,6 @@ const db: { 340322: '五河县', 340323: '固镇县', 340400: '淮南市', - 340401: '淮南市市辖区', 340402: '大通区', 340403: '田家庵区', 340404: '谢家集区', @@ -1151,7 +1045,6 @@ const db: { 340421: '凤台县', 340422: '寿县', 340500: '马鞍山市', - 340501: '马鞍山市市辖区', 340503: '花山区', 340504: '雨山区', 340506: '博望区', @@ -1159,31 +1052,27 @@ const db: { 340522: '含山县', 340523: '和县', 340600: '淮北市', - 340601: '淮北市市辖区', 340602: '杜集区', 340603: '相山区', 340604: '烈山区', 340621: '濉溪县', 340700: '铜陵市', - 340701: '铜陵市市辖区', 340705: '铜官区', 340706: '义安区', 340711: '郊区', 340722: '枞阳县', 340800: '安庆市', - 340801: '安庆市市辖区', 340802: '迎江区', 340803: '大观区', 340811: '宜秀区', 340822: '怀宁县', - 340824: '潜山市', 340825: '太湖县', 340826: '宿松县', 340827: '望江县', 340828: '岳西县', 340881: '桐城市', + 340882: '潜山市', 341000: '黄山市', - 341001: '黄山市市辖区', 341002: '屯溪区', 341003: '黄山区', 341004: '徽州区', @@ -1192,7 +1081,6 @@ const db: { 341023: '黟县', 341024: '祁门县', 341100: '滁州市', - 341101: '滁州市市辖区', 341102: '琅琊区', 341103: '南谯区', 341122: '来安县', @@ -1202,7 +1090,6 @@ const db: { 341181: '天长市', 341182: '明光市', 341200: '阜阳市', - 341201: '阜阳市市辖区', 341202: '颍州区', 341203: '颍东区', 341204: '颍泉区', @@ -1212,14 +1099,12 @@ const db: { 341226: '颍上县', 341282: '界首市', 341300: '宿州市', - 341301: '宿州市市辖区', 341302: '埇桥区', 341321: '砀山县', 341322: '萧县', 341323: '灵璧县', 341324: '泗县', 341500: '六安市', - 341501: '六安市市辖区', 341502: '金安区', 341503: '裕安区', 341504: '叶集区', @@ -1228,29 +1113,25 @@ const db: { 341524: '金寨县', 341525: '霍山县', 341600: '亳州市', - 341601: '亳州市市辖区', 341602: '谯城区', 341621: '涡阳县', 341622: '蒙城县', 341623: '利辛县', 341700: '池州市', - 341701: '池州市市辖区', 341702: '贵池区', 341721: '东至县', 341722: '石台县', 341723: '青阳县', 341800: '宣城市', - 341801: '宣城市市辖区', 341802: '宣州区', 341821: '郎溪县', - 341822: '广德县', 341823: '泾县', 341824: '绩溪县', 341825: '旌德县', 341881: '宁国市', + 341882: '广德市', 350000: '福建省', 350100: '福州市', - 350101: '福州市市辖区', 350102: '鼓楼区', 350103: '台江区', 350104: '仓山区', @@ -1265,7 +1146,6 @@ const db: { 350128: '平潭县', 350181: '福清市', 350200: '厦门市', - 350201: '厦门市市辖区', 350203: '思明区', 350205: '海沧区', 350206: '湖里区', @@ -1273,28 +1153,24 @@ const db: { 350212: '同安区', 350213: '翔安区', 350300: '莆田市', - 350301: '莆田市市辖区', 350302: '城厢区', 350303: '涵江区', 350304: '荔城区', 350305: '秀屿区', 350322: '仙游县', 350400: '三明市', - 350401: '三明市市辖区', - 350402: '梅列区', - 350403: '三元区', + 350404: '三元区', + 350405: '沙县区', 350421: '明溪县', 350423: '清流县', 350424: '宁化县', 350425: '大田县', 350426: '尤溪县', - 350427: '沙县', 350428: '将乐县', 350429: '泰宁县', 350430: '建宁县', 350481: '永安市', 350500: '泉州市', - 350501: '泉州市市辖区', 350502: '鲤城区', 350503: '丰泽区', 350504: '洛江区', @@ -1308,20 +1184,18 @@ const db: { 350582: '晋江市', 350583: '南安市', 350600: '漳州市', - 350601: '漳州市市辖区', 350602: '芗城区', 350603: '龙文区', + 350604: '龙海区', + 350605: '长泰区', 350622: '云霄县', 350623: '漳浦县', 350624: '诏安县', - 350625: '长泰县', 350626: '东山县', 350627: '南靖县', 350628: '平和县', 350629: '华安县', - 350681: '龙海市', 350700: '南平市', - 350701: '南平市市辖区', 350702: '延平区', 350703: '建阳区', 350721: '顺昌县', @@ -1333,7 +1207,6 @@ const db: { 350782: '武夷山市', 350783: '建瓯市', 350800: '龙岩市', - 350801: '龙岩市市辖区', 350802: '新罗区', 350803: '永定区', 350821: '长汀县', @@ -1342,7 +1215,6 @@ const db: { 350825: '连城县', 350881: '漳平市', 350900: '宁德市', - 350901: '宁德市市辖区', 350902: '蕉城区', 350921: '霞浦县', 350922: '古田县', @@ -1354,31 +1226,27 @@ const db: { 350982: '福鼎市', 360000: '江西省', 360100: '南昌市', - 360101: '南昌市市辖区', 360102: '东湖区', 360103: '西湖区', 360104: '青云谱区', - 360105: '湾里区', 360111: '青山湖区', 360112: '新建区', + 360113: '红谷滩区', 360121: '南昌县', 360123: '安义县', 360124: '进贤县', 360200: '景德镇市', - 360201: '景德镇市市辖区', 360202: '昌江区', 360203: '珠山区', 360222: '浮梁县', 360281: '乐平市', 360300: '萍乡市', - 360301: '萍乡市市辖区', 360302: '安源区', 360313: '湘东区', 360321: '莲花县', 360322: '上栗县', 360323: '芦溪县', 360400: '九江市', - 360401: '九江市市辖区', 360402: '濂溪区', 360403: '浔阳区', 360404: '柴桑区', @@ -1393,16 +1261,13 @@ const db: { 360482: '共青城市', 360483: '庐山市', 360500: '新余市', - 360501: '新余市市辖区', 360502: '渝水区', 360521: '分宜县', 360600: '鹰潭市', - 360601: '鹰潭市市辖区', 360602: '月湖区', 360603: '余江区', 360681: '贵溪市', 360700: '赣州市', - 360701: '赣州市市辖区', 360702: '章贡区', 360703: '南康区', 360704: '赣县区', @@ -1411,8 +1276,7 @@ const db: { 360724: '上犹县', 360725: '崇义县', 360726: '安远县', - 360727: '龙南县', - 360728: '定南县', + 360728: '定南�县', 360729: '全南县', 360730: '宁都县', 360731: '于都县', @@ -1421,8 +1285,8 @@ const db: { 360734: '寻乌县', 360735: '石城县', 360781: '瑞金市', + 360783: '龙南市', 360800: '吉安市', - 360801: '吉安市市辖区', 360802: '吉州区', 360803: '青原区', 360821: '吉安县', @@ -1437,7 +1301,6 @@ const db: { 360830: '永新县', 360881: '井冈山市', 360900: '宜春市', - 360901: '宜春市市辖区', 360902: '袁州区', 360921: '奉新县', 360922: '万载县', @@ -1449,7 +1312,6 @@ const db: { 360982: '樟树市', 360983: '高安市', 361000: '抚州市', - 361001: '抚州市市辖区', 361002: '临川区', 361003: '东乡区', 361021: '南城县', @@ -1462,10 +1324,9 @@ const db: { 361028: '资溪县', 361030: '广昌县', 361100: '上饶市', - 361101: '上饶市市辖区', 361102: '信州区', 361103: '广丰区', - 361121: '上饶县', + 361104: '广信区', 361123: '玉山县', 361124: '铅山县', 361125: '横峰县', @@ -1477,7 +1338,6 @@ const db: { 361181: '德兴市', 370000: '山东省', 370100: '济南市', - 370101: '济南市市辖区', 370102: '历下区', 370103: '市中区', 370104: '槐荫区', @@ -1491,7 +1351,6 @@ const db: { 370124: '平阴县', 370126: '商河县', 370200: '青岛市', - 370201: '青岛市市辖区', 370202: '市南区', 370203: '市北区', 370211: '黄岛区', @@ -1503,7 +1362,6 @@ const db: { 370283: '平度市', 370285: '莱西市', 370300: '淄博市', - 370301: '淄博市市辖区', 370302: '淄川区', 370303: '张店区', 370304: '博山区', @@ -1513,7 +1371,6 @@ const db: { 370322: '高青县', 370323: '沂源县', 370400: '枣庄市', - 370401: '枣庄市市辖区', 370402: '市中区', 370403: '薛城区', 370404: '峄城区', @@ -1521,28 +1378,24 @@ const db: { 370406: '山亭区', 370481: '滕州市', 370500: '东营市', - 370501: '东营市市辖区', 370502: '东营区', 370503: '河口区', 370505: '垦利区', 370522: '利津县', 370523: '广饶县', 370600: '烟台市', - 370601: '烟台市市辖区', 370602: '芝罘区', 370611: '福山区', 370612: '牟平区', 370613: '莱山区', - 370634: '长岛县', + 370614: '蓬莱区', 370681: '龙口市', 370682: '莱阳市', 370683: '莱州市', - 370684: '蓬莱市', 370685: '招远市', 370686: '栖霞市', 370687: '海阳市', 370700: '潍坊市', - 370701: '潍坊市市辖区', 370702: '潍城区', 370703: '寒亭区', 370704: '坊子区', @@ -1556,7 +1409,6 @@ const db: { 370785: '高密市', 370786: '昌邑市', 370800: '济宁市', - 370801: '济宁市市辖区', 370811: '任城区', 370812: '兖州区', 370826: '微山县', @@ -1569,7 +1421,6 @@ const db: { 370881: '曲阜市', 370883: '邹城市', 370900: '泰安市', - 370901: '泰安市市辖区', 370902: '泰山区', 370911: '岱岳区', 370921: '宁阳县', @@ -1577,19 +1428,16 @@ const db: { 370982: '新泰市', 370983: '肥城市', 371000: '威海市', - 371001: '威海市市辖区', 371002: '环翠区', 371003: '文登区', 371082: '荣成市', 371083: '乳山市', 371100: '日照市', - 371101: '日照市市辖区', 371102: '东港区', 371103: '岚山区', 371121: '五莲县', 371122: '莒县', 371300: '临沂市', - 371301: '临沂市市辖区', 371302: '兰山区', 371311: '罗庄区', 371312: '河东区', @@ -1603,7 +1451,6 @@ const db: { 371328: '蒙阴县', 371329: '临沭县', 371400: '德州市', - 371401: '德州市市辖区', 371402: '德城区', 371403: '陵城区', 371422: '宁津县', @@ -1616,17 +1463,15 @@ const db: { 371481: '乐陵市', 371482: '禹城市', 371500: '聊城市', - 371501: '聊城市市辖区', 371502: '东昌府区', + 371503: '茌平区', 371521: '阳谷县', 371522: '莘县', - 371523: '茌平县', 371524: '东阿县', 371525: '冠县', 371526: '高唐县', 371581: '临清市', 371600: '滨州市', - 371601: '滨州市市辖区', 371602: '滨城区', 371603: '沾化区', 371621: '惠民县', @@ -1635,7 +1480,6 @@ const db: { 371625: '博兴县', 371681: '邹平市', 371700: '菏泽市', - 371701: '菏泽市市辖区', 371702: '牡丹区', 371703: '定陶区', 371721: '曹县', @@ -1647,7 +1491,6 @@ const db: { 371728: '东明县', 410000: '河南省', 410100: '郑州市', - 410101: '郑州市市辖区', 410102: '中原区', 410103: '二七区', 410104: '管城回族区', @@ -1661,7 +1504,6 @@ const db: { 410184: '新郑市', 410185: '登封市', 410200: '开封市', - 410201: '开封市市辖区', 410202: '龙亭区', 410203: '顺河回族区', 410204: '鼓楼区', @@ -1672,14 +1514,13 @@ const db: { 410223: '尉氏县', 410225: '兰考县', 410300: '洛阳市', - 410301: '洛阳市市辖区', 410302: '老城区', 410303: '西工区', 410304: '瀍河回族区', 410305: '涧西区', - 410306: '吉利区', + 410307: '偃师区', + 410308: '孟津区', 410311: '洛龙区', - 410322: '孟津县', 410323: '新安县', 410324: '栾川县', 410325: '嵩县', @@ -1687,9 +1528,7 @@ const db: { 410327: '宜阳县', 410328: '洛宁县', 410329: '伊川县', - 410381: '偃师市', 410400: '平顶山市', - 410401: '平顶山市市辖区', 410402: '新华区', 410403: '卫东区', 410404: '石龙区', @@ -1701,7 +1540,6 @@ const db: { 410481: '舞钢市', 410482: '汝州市', 410500: '安阳市', - 410501: '安阳市市辖区', 410502: '文峰区', 410503: '北关区', 410505: '殷都区', @@ -1712,14 +1550,12 @@ const db: { 410527: '内黄县', 410581: '林州市', 410600: '鹤壁市', - 410601: '鹤壁市市辖区', 410602: '鹤山区', 410603: '山城区', 410611: '淇滨区', 410621: '浚县', 410622: '淇县', 410700: '新乡市', - 410701: '新乡市市辖区', 410702: '红旗区', 410703: '卫滨区', 410704: '凤泉区', @@ -1729,11 +1565,10 @@ const db: { 410725: '原阳县', 410726: '延津县', 410727: '封丘县', - 410728: '长垣县', 410781: '卫辉市', 410782: '辉县市', + 410783: '长垣市', 410800: '焦作市', - 410801: '焦作市市辖区', 410802: '解放区', 410803: '中站区', 410804: '马村区', @@ -1745,7 +1580,6 @@ const db: { 410882: '沁阳市', 410883: '孟州市', 410900: '濮阳市', - 410901: '濮阳市市辖区', 410902: '华龙区', 410922: '清丰县', 410923: '南乐县', @@ -1753,7 +1587,6 @@ const db: { 410927: '台前县', 410928: '濮阳县', 411000: '许昌市', - 411001: '许昌市市辖区', 411002: '魏都区', 411003: '建安区', 411024: '鄢陵县', @@ -1761,14 +1594,12 @@ const db: { 411081: '禹州市', 411082: '长葛市', 411100: '漯河市', - 411101: '漯河市市辖区', 411102: '源汇区', 411103: '郾城区', 411104: '召陵区', 411121: '舞阳县', 411122: '临颍县', 411200: '三门峡市', - 411201: '三门峡市市辖区', 411202: '湖滨区', 411203: '陕州区', 411221: '渑池县', @@ -1776,7 +1607,6 @@ const db: { 411281: '义马市', 411282: '灵宝市', 411300: '南阳市', - 411301: '南阳市市辖区', 411302: '宛城区', 411303: '卧龙区', 411321: '南召县', @@ -1791,7 +1621,6 @@ const db: { 411330: '桐柏县', 411381: '邓州市', 411400: '商丘市', - 411401: '商丘市市辖区', 411402: '梁园区', 411403: '睢阳区', 411421: '民权县', @@ -1802,7 +1631,6 @@ const db: { 411426: '夏邑县', 411481: '永城市', 411500: '信阳市', - 411501: '信阳市市辖区', 411502: '浉河区', 411503: '平桥区', 411521: '罗山县', @@ -1814,19 +1642,17 @@ const db: { 411527: '淮滨县', 411528: '息县', 411600: '周口市', - 411601: '周口市市辖区', 411602: '川汇区', + 411603: '淮阳区', 411621: '扶沟县', 411622: '西华县', 411623: '商水县', 411624: '沈丘县', 411625: '郸城县', - 411626: '淮阳县', 411627: '太康县', 411628: '鹿邑县', 411681: '项城市', 411700: '驻马店市', - 411701: '驻马店市市辖区', 411702: '驿城区', 411721: '西平县', 411722: '上蔡县', @@ -1837,11 +1663,9 @@ const db: { 411727: '汝南县', 411728: '遂平县', 411729: '新蔡县', - 419000: '省直辖县', 419001: '济源市', 420000: '湖北省', 420100: '武汉市', - 420101: '武汉市市辖区', 420102: '江岸区', 420103: '江汉区', 420104: '硚口区', @@ -1856,7 +1680,6 @@ const db: { 420116: '黄陂区', 420117: '新洲区', 420200: '黄石市', - 420201: '黄石市市辖区', 420202: '黄石港区', 420203: '西塞山区', 420204: '下陆区', @@ -1864,7 +1687,6 @@ const db: { 420222: '阳新县', 420281: '大冶市', 420300: '十堰市', - 420301: '十堰市市辖区', 420302: '茅箭区', 420303: '张湾区', 420304: '郧阳区', @@ -1874,7 +1696,6 @@ const db: { 420325: '房县', 420381: '丹江口市', 420500: '宜昌市', - 420501: '宜昌市市辖区', 420502: '西陵区', 420503: '伍家岗区', 420504: '点军区', @@ -1889,7 +1710,6 @@ const db: { 420582: '当阳市', 420583: '枝江市', 420600: '襄阳市', - 420601: '襄阳市市辖区', 420602: '襄城区', 420606: '樊城区', 420607: '襄州区', @@ -1900,19 +1720,16 @@ const db: { 420683: '枣阳市', 420684: '宜城市', 420700: '鄂州市', - 420701: '鄂州市市辖区', 420702: '梁子湖区', 420703: '华容区', 420704: '鄂城区', 420800: '荆门市', - 420801: '荆门市市辖区', 420802: '东宝区', 420804: '掇刀区', 420822: '沙洋县', 420881: '钟祥市', 420882: '京山市', 420900: '孝感市', - 420901: '孝感市市辖区', 420902: '孝南区', 420921: '孝昌县', 420922: '大悟县', @@ -1921,17 +1738,15 @@ const db: { 420982: '安陆市', 420984: '汉川市', 421000: '荆州市', - 421001: '荆州市市辖区', 421002: '沙市区', 421003: '荆州区', 421022: '公安县', - 421023: '监利县', 421024: '江陵县', 421081: '石首市', 421083: '洪湖市', 421087: '松滋市', + 421088: '监利市', 421100: '黄冈市', - 421101: '黄冈市市辖区', 421102: '黄州区', 421121: '团风县', 421122: '红安县', @@ -1943,7 +1758,6 @@ const db: { 421181: '麻城市', 421182: '武穴市', 421200: '咸宁市', - 421201: '咸宁市市辖区', 421202: '咸安区', 421221: '嘉鱼县', 421222: '通城县', @@ -1951,7 +1765,6 @@ const db: { 421224: '通山县', 421281: '赤壁市', 421300: '随州市', - 421301: '随州市市辖区', 421303: '曾都区', 421321: '随县', 421381: '广水市', @@ -1964,14 +1777,12 @@ const db: { 422826: '咸丰县', 422827: '来凤县', 422828: '鹤峰县', - 429000: '省直辖县', 429004: '仙桃市', 429005: '潜江市', 429006: '天门市', 429021: '神农架林区', 430000: '湖南省', 430100: '长沙市', - 430101: '长沙市市辖区', 430102: '芙蓉区', 430103: '天心区', 430104: '岳麓区', @@ -1982,7 +1793,6 @@ const db: { 430181: '浏阳市', 430182: '宁乡市', 430200: '株洲市', - 430201: '株洲市市辖区', 430202: '荷塘区', 430203: '芦淞区', 430204: '石峰区', @@ -1993,14 +1803,12 @@ const db: { 430225: '炎陵县', 430281: '醴陵市', 430300: '湘潭市', - 430301: '湘潭市市辖区', 430302: '雨湖区', 430304: '岳塘区', 430321: '湘潭县', 430381: '湘乡市', 430382: '韶山市', 430400: '衡阳市', - 430401: '衡阳市市辖区', 430405: '珠晖区', 430406: '雁峰区', 430407: '石鼓区', @@ -2014,11 +1822,9 @@ const db: { 430481: '耒阳市', 430482: '常宁市', 430500: '邵阳市', - 430501: '邵阳市市辖区', 430502: '双清区', 430503: '大祥区', 430511: '北塔区', - 430521: '邵东县', 430522: '新邵县', 430523: '邵阳县', 430524: '隆回县', @@ -2027,8 +1833,8 @@ const db: { 430528: '新宁县', 430529: '城步苗族自治县', 430581: '武冈市', + 430582: '邵东市', 430600: '岳阳市', - 430601: '岳阳市市辖区', 430602: '岳阳楼区', 430603: '云溪区', 430611: '君山区', @@ -2039,7 +1845,6 @@ const db: { 430681: '汨罗市', 430682: '临湘市', 430700: '常德市', - 430701: '常德市市辖区', 430702: '武陵区', 430703: '鼎城区', 430721: '安乡县', @@ -2050,13 +1855,11 @@ const db: { 430726: '石门县', 430781: '津市市', 430800: '张家界市', - 430801: '张家界市市辖区', 430802: '永定区', 430811: '武陵源区', 430821: '慈利县', 430822: '桑植县', 430900: '益阳市', - 430901: '益阳市市辖区', 430902: '资阳区', 430903: '赫山区', 430921: '南县', @@ -2064,7 +1867,6 @@ const db: { 430923: '安化县', 430981: '沅江市', 431000: '郴州市', - 431001: '郴州市市辖区', 431002: '北湖区', 431003: '苏仙区', 431021: '桂阳县', @@ -2077,10 +1879,8 @@ const db: { 431028: '安仁县', 431081: '资兴市', 431100: '永州市', - 431101: '永州市市辖区', 431102: '零陵区', 431103: '冷水滩区', - 431121: '祁阳县', 431122: '东安县', 431123: '双牌县', 431124: '道县', @@ -2089,8 +1889,8 @@ const db: { 431127: '蓝山县', 431128: '新田县', 431129: '江华瑶族自治县', + 431181: '祁阳市', 431200: '怀化市', - 431201: '怀化市市辖区', 431202: '鹤城区', 431221: '中方县', 431222: '沅陵县', @@ -2104,7 +1904,6 @@ const db: { 431230: '通道侗族自治县', 431281: '洪江市', 431300: '娄底市', - 431301: '娄底市市辖区', 431302: '娄星区', 431321: '双峰县', 431322: '新化县', @@ -2121,7 +1920,6 @@ const db: { 433130: '龙山县', 440000: '广东省', 440100: '广州市', - 440101: '广州市市辖区', 440103: '荔湾区', 440104: '越秀区', 440105: '海珠区', @@ -2134,7 +1932,6 @@ const db: { 440117: '从化区', 440118: '增城区', 440200: '韶关市', - 440201: '韶关市市辖区', 440203: '武江区', 440204: '浈江区', 440205: '曲江区', @@ -2146,7 +1943,6 @@ const db: { 440281: '乐昌市', 440282: '南雄市', 440300: '深圳市', - 440301: '深圳市市辖区', 440303: '罗湖区', 440304: '福田区', 440305: '南山区', @@ -2157,12 +1953,10 @@ const db: { 440310: '坪山区', 440311: '光明区', 440400: '珠海市', - 440401: '珠海市市辖区', 440402: '香洲区', 440403: '斗门区', 440404: '金湾区', 440500: '汕头市', - 440501: '汕头市市辖区', 440507: '龙湖区', 440511: '金平区', 440512: '濠江区', @@ -2171,14 +1965,12 @@ const db: { 440515: '澄海区', 440523: '南澳县', 440600: '佛山市', - 440601: '佛山市市辖区', 440604: '禅城区', 440605: '南海区', 440606: '顺德区', 440607: '三水区', 440608: '高明区', 440700: '江门市', - 440701: '江门市市辖区', 440703: '蓬江区', 440704: '江海区', 440705: '新会区', @@ -2187,7 +1979,6 @@ const db: { 440784: '鹤山市', 440785: '恩平市', 440800: '湛江市', - 440801: '湛江市市辖区', 440802: '赤坎区', 440803: '霞山区', 440804: '坡头区', @@ -2198,14 +1989,12 @@ const db: { 440882: '雷州市', 440883: '吴川市', 440900: '茂名市', - 440901: '茂名市市辖区', 440902: '茂南区', 440904: '电白区', 440981: '高州市', 440982: '化州市', 440983: '信宜市', 441200: '肇庆市', - 441201: '肇庆市市辖区', 441202: '端州区', 441203: '鼎湖区', 441204: '高要区', @@ -2215,14 +2004,12 @@ const db: { 441226: '德庆县', 441284: '四会市', 441300: '惠州市', - 441301: '惠州市市辖区', 441302: '惠城区', 441303: '惠阳区', 441322: '博罗县', 441323: '惠东县', 441324: '龙门县', 441400: '梅州市', - 441401: '梅州市市辖区', 441402: '梅江区', 441403: '梅县区', 441422: '大埔县', @@ -2232,13 +2019,11 @@ const db: { 441427: '蕉岭县', 441481: '兴宁市', 441500: '汕尾市', - 441501: '汕尾市市辖区', 441502: '城区', 441521: '海丰县', 441523: '陆河县', 441581: '陆丰市', 441600: '河源市', - 441601: '河源市市辖区', 441602: '源城区', 441621: '紫金县', 441622: '龙川县', @@ -2246,13 +2031,11 @@ const db: { 441624: '和平县', 441625: '东源县', 441700: '阳江市', - 441701: '阳江市市辖区', 441702: '江城区', 441704: '阳东区', 441721: '阳西县', 441781: '阳春市', 441800: '清远市', - 441801: '清远市市辖区', 441802: '清城区', 441803: '清新区', 441821: '佛冈县', @@ -2262,80 +2045,18 @@ const db: { 441881: '英德市', 441882: '连州市', 441900: '东莞市', - 441901: '中堂镇', - 441903: '南城街道', - 441904: '长安镇', - 441905: '东坑镇', - 441906: '樟木头镇', - 441907: '莞城街道', - 441908: '石龙镇', - 441909: '桥头镇', - 441910: '万江街道', - 441911: '麻涌镇', - 441912: '虎门镇', - 441913: '谢岗镇', - 441914: '石碣镇', - 441915: '茶山镇', - 441916: '东城街道', - 441917: '洪梅镇', - 441918: '道滘镇', - 441919: '高埗镇', - 441920: '企石镇', - 441921: '凤岗镇', - 441922: '大岭山镇', - 441923: '松山湖', - 441924: '清溪镇', - 441925: '望牛墩镇', - 441926: '厚街镇', - 441927: '常平镇', - 441928: '寮步镇', - 441929: '石排镇', - 441930: '横沥镇', - 441931: '塘厦镇', - 441932: '黄江镇', - 441933: '大朗镇', - 441934: '东莞港', - 441935: '东莞生态园', - 441990: '沙田镇', 442000: '中山市', - 442001: '南头镇', - 442002: '神湾镇', - 442003: '东凤镇', - 442004: '五桂山街道', - 442005: '黄圃镇', - 442006: '小榄镇', - 442007: '石岐街道', - 442008: '横栏镇', - 442009: '三角镇', - 442010: '三乡镇', - 442011: '港口镇', - 442012: '沙溪镇', - 442013: '板芙镇', - 442015: '东升镇', - 442016: '阜沙镇', - 442017: '民众镇', - 442018: '东区街道', - 442019: '火炬开发区街道办事处', - 442020: '西区街道', - 442021: '南区街道', - 442022: '古镇镇', - 442023: '坦洲镇', - 442024: '大涌镇', - 442025: '南朗镇', 445100: '潮州市', - 445101: '潮州市市辖区', 445102: '湘桥区', 445103: '潮安区', 445122: '饶平县', 445200: '揭阳市', - 445201: '揭阳市市辖区', 445202: '榕城区', 445203: '揭东区', 445222: '揭西县', 445224: '惠来县', 445281: '普宁市', 445300: '云浮市', - 445301: '云浮市市辖区', 445302: '云城区', 445303: '云安区', 445321: '新兴县', @@ -2343,7 +2064,6 @@ const db: { 445381: '罗定市', 450000: '广西壮族自治区', 450100: '南宁市', - 450101: '南宁市市辖区', 450102: '兴宁区', 450103: '青秀区', 450105: '江南区', @@ -2355,9 +2075,8 @@ const db: { 450124: '马山县', 450125: '上林县', 450126: '宾阳县', - 450127: '横县', + 450181: '横州市', 450200: '柳州市', - 450201: '柳州市市辖区', 450202: '城中区', 450203: '鱼峰区', 450204: '柳南区', @@ -2369,7 +2088,6 @@ const db: { 450225: '融水苗族自治县', 450226: '三江侗族自治县', 450300: '桂林市', - 450301: '桂林市市辖区', 450302: '秀峰区', 450303: '叠彩区', 450304: '象山区', @@ -2388,7 +2106,6 @@ const db: { 450332: '恭城瑶族自治县', 450381: '荔浦市', 450400: '梧州市', - 450401: '梧州市市辖区', 450403: '万秀区', 450405: '长洲区', 450406: '龙圩区', @@ -2397,32 +2114,27 @@ const db: { 450423: '蒙山县', 450481: '岑溪市', 450500: '北海市', - 450501: '北海市市辖区', 450502: '海城区', 450503: '银海区', 450512: '铁山港区', 450521: '合浦县', 450600: '防城港市', - 450601: '防城港市市辖区', 450602: '港口区', 450603: '防城区', 450621: '上思县', 450681: '东兴市', 450700: '钦州市', - 450701: '钦州市市辖区', 450702: '钦南区', 450703: '钦北区', 450721: '灵山县', 450722: '浦北县', 450800: '贵港市', - 450801: '贵港市市辖区', 450802: '港北区', 450803: '港南区', 450804: '覃塘区', 450821: '平南县', 450881: '桂平市', 450900: '玉林市', - 450901: '玉林市市辖区', 450902: '玉州区', 450903: '福绵区', 450921: '容县', @@ -2431,11 +2143,9 @@ const db: { 450924: '兴业县', 450981: '北流市', 451000: '百色市', - 451001: '百色市市辖区', 451002: '右江区', - 451021: '田阳县', + 451003: '田阳区', 451022: '田东县', - 451023: '平果县', 451024: '德保县', 451026: '那坡县', 451027: '凌云县', @@ -2444,15 +2154,14 @@ const db: { 451030: '西林县', 451031: '隆林各族自治县', 451081: '靖西市', + 451082: '平果市', 451100: '贺州市', - 451101: '贺州市市辖区', 451102: '八步区', 451103: '平桂区', 451121: '昭平县', 451122: '钟山县', 451123: '富川瑶族自治县', 451200: '河池市', - 451201: '河池市市辖区', 451202: '金城江区', 451203: '宜州区', 451221: '南丹县', @@ -2465,7 +2174,6 @@ const db: { 451228: '都安瑶族自治县', 451229: '大化瑶族自治县', 451300: '来宾市', - 451301: '来宾市市辖区', 451302: '兴宾区', 451321: '忻城县', 451322: '象州县', @@ -2473,7 +2181,6 @@ const db: { 451324: '金秀瑶族自治县', 451381: '合山市', 451400: '崇左市', - 451401: '崇左市市辖区', 451402: '江州区', 451421: '扶绥县', 451422: '宁明县', @@ -2483,42 +2190,19 @@ const db: { 451481: '凭祥市', 460000: '海南省', 460100: '海口市', - 460101: '海口市市辖区', 460105: '秀英区', 460106: '龙华区', 460107: '琼山区', 460108: '美兰区', 460200: '三亚市', - 460201: '三亚市市辖区', 460202: '海棠区', 460203: '吉阳区', 460204: '天涯区', 460205: '崖州区', 460300: '三沙市', - 460301: '三沙市市辖区', - 460321: '西沙群岛', - 460322: '南沙群岛', - 460323: '中沙群岛的岛礁及其海域', + 460301: '西沙区', + 460302: '南沙区', 460400: '儋州市', - 460401: '那大镇', - 460402: '和庆镇', - 460403: '南丰镇', - 460404: '大成镇', - 460405: '雅星镇', - 460406: '兰洋镇', - 460407: '光村镇', - 460408: '木棠镇', - 460409: '海头镇', - 460410: '峨蔓镇', - 460411: '王五镇', - 460412: '白马井镇', - 460413: '中和镇', - 460414: '排浦镇', - 460415: '东成镇', - 460416: '新州镇', - 460417: '洋浦经济开发区', - 460418: '华南热作学院', - 469000: '省直辖县', 469001: '五指山市', 469002: '琼海市', 469005: '文昌市', @@ -2535,7 +2219,6 @@ const db: { 469029: '保亭黎族苗族自治县', 469030: '琼中黎族苗族自治县', 500000: '重庆市', - 500100: '重庆市市辖区', 500101: '万州区', 500102: '涪陵区', 500103: '渝中区', @@ -2562,7 +2245,6 @@ const db: { 500154: '开州区', 500155: '梁平区', 500156: '武隆区', - 500200: '重庆市郊县', 500229: '城口县', 500230: '丰都县', 500231: '垫江县', @@ -2577,7 +2259,6 @@ const db: { 500243: '彭水苗族土家族自治县', 510000: '四川省', 510100: '成都市', - 510101: '成都市市辖区', 510104: '锦江区', 510105: '青羊区', 510106: '金牛区', @@ -2589,17 +2270,16 @@ const db: { 510115: '温江区', 510116: '双流区', 510117: '郫都区', + 510118: '新津区', 510121: '金堂县', 510129: '大邑县', 510131: '蒲江县', - 510132: '新津县', 510181: '都江堰市', 510182: '彭州市', 510183: '邛崃市', 510184: '崇州市', 510185: '简阳市', 510300: '自贡市', - 510301: '自贡市市辖区', 510302: '自流井区', 510303: '贡井区', 510304: '大安区', @@ -2607,14 +2287,12 @@ const db: { 510321: '荣县', 510322: '富顺县', 510400: '攀枝花市', - 510401: '攀枝花市市辖区', 510402: '东区', 510403: '西区', 510411: '仁和区', 510421: '米易县', 510422: '盐边县', 510500: '泸州市', - 510501: '泸州市市辖区', 510502: '江阳区', 510503: '纳溪区', 510504: '龙马潭区', @@ -2623,7 +2301,6 @@ const db: { 510524: '叙永县', 510525: '古蔺县', 510600: '德阳市', - 510601: '德阳市市辖区', 510603: '旌阳区', 510604: '罗江区', 510623: '中江县', @@ -2631,7 +2308,6 @@ const db: { 510682: '什邡市', 510683: '绵竹市', 510700: '绵阳市', - 510701: '绵阳市市辖区', 510703: '涪城区', 510704: '游仙区', 510705: '安州区', @@ -2642,7 +2318,6 @@ const db: { 510727: '平武县', 510781: '江油市', 510800: '广元市', - 510801: '广元市市辖区', 510802: '利州区', 510811: '昭化区', 510812: '朝天区', @@ -2651,21 +2326,18 @@ const db: { 510823: '剑阁县', 510824: '苍溪县', 510900: '遂宁市', - 510901: '遂宁市市辖区', 510903: '船山区', 510904: '安居区', 510921: '蓬溪县', - 510922: '射洪县', 510923: '大英县', + 510981: '射洪市', 511000: '内江市', - 511001: '内江市市辖区', 511002: '市中区', 511011: '东兴区', 511024: '威远县', 511025: '资中县', 511083: '隆昌市', 511100: '乐山市', - 511101: '乐山市市辖区', 511102: '市中区', 511111: '沙湾区', 511112: '五通桥区', @@ -2678,7 +2350,6 @@ const db: { 511133: '马边彝族自治县', 511181: '峨眉山市', 511300: '南充市', - 511301: '南充市市辖区', 511302: '顺庆区', 511303: '高坪区', 511304: '嘉陵区', @@ -2689,7 +2360,6 @@ const db: { 511325: '西充县', 511381: '阆中市', 511400: '眉山市', - 511401: '眉山市市辖区', 511402: '东坡区', 511403: '彭山区', 511421: '仁寿县', @@ -2697,7 +2367,6 @@ const db: { 511424: '丹棱县', 511425: '青神县', 511500: '宜宾市', - 511501: '宜宾市市辖区', 511502: '翠屏区', 511503: '南溪区', 511504: '叙州区', @@ -2709,7 +2378,6 @@ const db: { 511528: '兴文县', 511529: '屏山县', 511600: '广安市', - 511601: '广安市市辖区', 511602: '广安区', 511603: '前锋区', 511621: '岳池县', @@ -2717,7 +2385,6 @@ const db: { 511623: '邻水县', 511681: '华蓥市', 511700: '达州市', - 511701: '达州市市辖区', 511702: '通川区', 511703: '达川区', 511722: '宣汉县', @@ -2726,7 +2393,6 @@ const db: { 511725: '渠县', 511781: '万源市', 511800: '雅安市', - 511801: '雅安市市辖区', 511802: '雨城区', 511803: '名山区', 511822: '荥经县', @@ -2736,14 +2402,12 @@ const db: { 511826: '芦山县', 511827: '宝兴县', 511900: '巴中市', - 511901: '巴中市市辖区', 511902: '巴州区', 511903: '恩阳区', 511921: '通江县', 511922: '南江县', 511923: '平昌县', 512000: '资阳市', - 512001: '资阳市市辖区', 512002: '雁江区', 512021: '安岳县', 512022: '乐至县', @@ -2782,10 +2446,10 @@ const db: { 513338: '得荣县', 513400: '凉山彝族自治州', 513401: '西昌市', + 513402: '会理市', 513422: '木里藏族自治县', 513423: '盐源县', 513424: '德昌县', - 513425: '会理县', 513426: '会东县', 513427: '宁南县', 513428: '普格县', @@ -2800,7 +2464,6 @@ const db: { 513437: '雷波县', 520000: '贵州省', 520100: '贵阳市', - 520101: '贵阳市市辖区', 520102: '南明区', 520103: '云岩区', 520111: '花溪区', @@ -2814,10 +2477,9 @@ const db: { 520200: '六盘水市', 520201: '钟山区', 520203: '六枝特区', - 520221: '水城县', + 520204: '水城区', 520281: '盘州市', 520300: '遵义市', - 520301: '遵义市市辖区', 520302: '红花岗区', 520303: '汇川区', 520304: '播州区', @@ -2833,7 +2495,6 @@ const db: { 520381: '赤水市', 520382: '仁怀市', 520400: '安顺市', - 520401: '安顺市市辖区', 520402: '西秀区', 520403: '平坝区', 520422: '普定县', @@ -2843,12 +2504,12 @@ const db: { 520500: '毕节市', 520502: '七星关区', 520521: '大方县', - 520522: '黔西县', 520523: '金沙县', 520524: '织金县', 520525: '纳雍县', 520526: '威宁彝族回族苗族自治县', 520527: '赫章县', + 520581: '黔西市', 520600: '铜仁市', 520602: '碧江区', 520603: '万山区', @@ -2901,7 +2562,6 @@ const db: { 522732: '三都水族自治县', 530000: '云南省', 530100: '昆明市', - 530101: '昆明市市辖区', 530102: '五华区', 530103: '盘龙区', 530111: '官渡区', @@ -2917,7 +2577,6 @@ const db: { 530129: '寻甸回族彝族自治县', 530181: '安宁市', 530300: '曲靖市', - 530301: '曲靖市市辖区', 530302: '麒麟区', 530303: '沾益区', 530304: '马龙区', @@ -2928,25 +2587,22 @@ const db: { 530326: '会泽县', 530381: '宣威市', 530400: '玉溪市', - 530401: '玉溪市市辖区', 530402: '红塔区', 530403: '江川区', - 530422: '澄江县', 530423: '通海县', 530424: '华宁县', 530425: '易门县', 530426: '峨山彝族自治县', 530427: '新平彝族傣族自治县', 530428: '元江哈尼族彝族傣族自治县', + 530481: '澄江市', 530500: '保山市', - 530501: '保山市市辖区', 530502: '隆阳区', 530521: '施甸县', 530523: '龙陵县', 530524: '昌宁县', 530581: '腾冲市', 530600: '昭通市', - 530601: '昭通市市辖区', 530602: '昭阳区', 530621: '鲁甸县', 530622: '巧家县', @@ -2959,14 +2615,12 @@ const db: { 530629: '威信县', 530681: '水富市', 530700: '丽江市', - 530701: '丽江市市辖区', 530702: '古城区', 530721: '玉龙纳西族自治县', 530722: '永胜县', 530723: '华坪县', 530724: '宁蒗彝族自治县', 530800: '普洱市', - 530801: '普洱市市辖区', 530802: '思茅区', 530821: '宁洱哈尼族彝族自治县', 530822: '墨江哈尼族自治县', @@ -2978,7 +2632,6 @@ const db: { 530828: '澜沧拉祜族自治县', 530829: '西盟佤族自治县', 530900: '临沧市', - 530901: '临沧市市辖区', 530902: '临翔区', 530921: '凤庆县', 530922: '云县', @@ -2989,6 +2642,7 @@ const db: { 530927: '沧源佤族自治县', 532300: '楚雄彝族自治州', 532301: '楚雄市', + 532302: '禄丰市', 532322: '双柏县', 532323: '牟定县', 532324: '南华县', @@ -2997,7 +2651,6 @@ const db: { 532327: '永仁县', 532328: '元谋县', 532329: '武定县', - 532331: '禄丰县', 532500: '红河哈尼族彝族自治州', 532501: '个旧市', 532502: '开远市', @@ -3055,7 +2708,6 @@ const db: { 533423: '维西傈僳族自治县', 540000: '西藏自治区', 540100: '拉萨市', - 540101: '拉萨市市辖区', 540102: '城关区', 540103: '堆龙德庆区', 540104: '达孜区', @@ -3098,7 +2750,7 @@ const db: { 540400: '林芝市', 540402: '巴宜区', 540421: '工布江达县', - 540422: '米林县', + 540422: '米林市', 540423: '墨脱县', 540424: '波密县', 540425: '察隅县', @@ -3114,7 +2766,7 @@ const db: { 540527: '洛扎县', 540528: '加查县', 540529: '隆子县', - 540530: '错那县', + 540530: '错那市', 540531: '浪卡子县', 540600: '那曲市', 540602: '色尼区', @@ -3138,7 +2790,6 @@ const db: { 542527: '措勤县', 610000: '陕西省', 610100: '西安市', - 610101: '西安市市辖区', 610102: '新城区', 610103: '碑林区', 610104: '莲湖区', @@ -3153,17 +2804,15 @@ const db: { 610122: '蓝田县', 610124: '周至县', 610200: '铜川市', - 610201: '铜川市市辖区', 610202: '王益区', 610203: '印台区', 610204: '耀州区', 610222: '宜君县', 610300: '宝鸡市', - 610301: '宝鸡市市辖区', 610302: '渭滨区', 610303: '金台区', 610304: '陈仓区', - 610322: '凤翔县', + 610305: '凤翔区', 610323: '岐山县', 610324: '扶风县', 610326: '眉县', @@ -3173,7 +2822,6 @@ const db: { 610330: '凤县', 610331: '太白县', 610400: '咸阳市', - 610401: '咸阳市市辖区', 610402: '秦都区', 610403: '杨陵区', 610404: '渭城区', @@ -3189,7 +2837,6 @@ const db: { 610481: '兴平市', 610482: '彬州市', 610500: '渭南市', - 610501: '渭南市市辖区', 610502: '临渭区', 610503: '华州区', 610522: '潼关县', @@ -3202,12 +2849,10 @@ const db: { 610581: '韩城市', 610582: '华阴市', 610600: '延安市', - 610601: '延安市市辖区', 610602: '宝塔区', 610603: '安塞区', 610621: '延长县', 610622: '延川县', - 610623: '子长县', 610625: '志丹县', 610626: '吴起县', 610627: '甘泉县', @@ -3216,8 +2861,8 @@ const db: { 610630: '宜川县', 610631: '黄龙县', 610632: '黄陵县', + 610681: '子长市', 610700: '汉中市', - 610701: '汉中市市辖区', 610702: '汉台区', 610703: '南郑区', 610722: '城固县', @@ -3230,7 +2875,6 @@ const db: { 610729: '留坝县', 610730: '佛坪县', 610800: '榆林市', - 610801: '榆林市市辖区', 610802: '榆阳区', 610803: '横山区', 610822: '府谷县', @@ -3244,7 +2888,6 @@ const db: { 610831: '子洲县', 610881: '神木市', 610900: '安康市', - 610901: '安康市市辖区', 610902: '汉滨区', 610921: '汉阴县', 610922: '石泉县', @@ -3253,10 +2896,9 @@ const db: { 610925: '岚皋县', 610926: '平利县', 610927: '镇坪县', - 610928: '旬阳县', 610929: '白河县', + 610981: '旬阳市', 611000: '商洛市', - 611001: '商洛市市辖区', 611002: '商州区', 611021: '洛南县', 611022: '丹凤县', @@ -3266,7 +2908,6 @@ const db: { 611026: '柞水县', 620000: '甘肃省', 620100: '兰州市', - 620101: '兰州市市辖区', 620102: '城关区', 620103: '七里河区', 620104: '西固区', @@ -3276,20 +2917,16 @@ const db: { 620122: '皋兰县', 620123: '榆中县', 620200: '嘉峪关市', - 620201: '嘉峪关市市辖区', 620300: '金昌市', - 620301: '金昌市市辖区', 620302: '金川区', 620321: '永昌县', 620400: '白银市', - 620401: '白银市市辖区', 620402: '白银区', 620403: '平川区', 620421: '靖远县', 620422: '会宁县', 620423: '景泰县', 620500: '天水市', - 620501: '天水市市辖区', 620502: '秦州区', 620503: '麦积区', 620521: '清水县', @@ -3298,13 +2935,11 @@ const db: { 620524: '武山县', 620525: '张家川回族自治县', 620600: '武威市', - 620601: '武威市市辖区', 620602: '凉州区', 620621: '民勤县', 620622: '古浪县', 620623: '天祝藏族自治县', 620700: '张掖市', - 620701: '张掖市市辖区', 620702: '甘州区', 620721: '肃南裕固族自治县', 620722: '民乐县', @@ -3312,7 +2947,6 @@ const db: { 620724: '高台县', 620725: '山丹县', 620800: '平凉市', - 620801: '平凉市市辖区', 620802: '崆峒区', 620821: '泾川县', 620822: '灵台县', @@ -3321,7 +2955,6 @@ const db: { 620826: '静宁县', 620881: '华亭市', 620900: '酒泉市', - 620901: '酒泉市市辖区', 620902: '肃州区', 620921: '金塔县', 620922: '瓜州县', @@ -3330,7 +2963,6 @@ const db: { 620981: '玉门市', 620982: '敦煌市', 621000: '庆阳市', - 621001: '庆阳市市辖区', 621002: '西峰区', 621021: '庆城县', 621022: '环县', @@ -3340,7 +2972,6 @@ const db: { 621026: '宁县', 621027: '镇原县', 621100: '定西市', - 621101: '定西市市辖区', 621102: '安定区', 621121: '通渭县', 621122: '陇西县', @@ -3349,7 +2980,6 @@ const db: { 621125: '漳县', 621126: '岷县', 621200: '陇南市', - 621201: '陇南市市辖区', 621202: '武都区', 621221: '成县', 621222: '文县', @@ -3379,13 +3009,12 @@ const db: { 623027: '夏河县', 630000: '青海省', 630100: '西宁市', - 630101: '西宁市市辖区', 630102: '城东区', 630103: '城中区', 630104: '城西区', 630105: '城北区', + 630106: '湟中区', 630121: '大通回族土族自治县', - 630122: '湟中县', 630123: '湟源县', 630200: '海东市', 630202: '乐都区', @@ -3400,7 +3029,7 @@ const db: { 632223: '海晏县', 632224: '刚察县', 632300: '黄南藏族自治州', - 632321: '同仁县', + 632301: '同仁市', 632322: '尖扎县', 632323: '泽库县', 632324: '河南蒙古族自治县', @@ -3434,7 +3063,6 @@ const db: { 632825: '海西蒙古族藏族自治州直辖', 640000: '宁夏回族自治区', 640100: '银川市', - 640101: '银川市市辖区', 640104: '兴庆区', 640105: '西夏区', 640106: '金凤区', @@ -3442,32 +3070,27 @@ const db: { 640122: '贺兰县', 640181: '灵武市', 640200: '石嘴山市', - 640201: '石嘴山市市辖区', 640202: '大武口区', 640205: '惠农区', 640221: '平罗县', 640300: '吴忠市', - 640301: '吴忠市市辖区', 640302: '利通区', 640303: '红寺堡区', 640323: '盐池县', 640324: '同心县', 640381: '青铜峡市', 640400: '固原市', - 640401: '固原市市辖区', 640402: '原州区', 640422: '西吉县', 640423: '隆德县', 640424: '泾源县', 640425: '彭阳县', 640500: '中卫市', - 640501: '中卫市市辖区', 640502: '沙坡头区', 640521: '中宁县', 640522: '海原县', 650000: '新疆维吾尔自治区', 650100: '乌鲁木齐市', - 650101: '乌鲁木齐市市辖区', 650102: '天山区', 650103: '沙依巴克区', 650104: '新市区', @@ -3477,7 +3100,6 @@ const db: { 650109: '米东区', 650121: '乌鲁木齐县', 650200: '克拉玛依市', - 650201: '克拉玛依市市辖区', 650202: '独山子区', 650203: '克拉玛依区', 650204: '白碱滩区', @@ -3515,8 +3137,8 @@ const db: { 652829: '博湖县', 652900: '阿克苏地区', 652901: '阿克苏市', + 652902: '库车市', 652922: '温宿县', - 652923: '库车县', 652924: '沙雅县', 652925: '新和县', 652926: '拜城县', @@ -3565,8 +3187,8 @@ const db: { 654200: '塔城地区', 654201: '塔城市', 654202: '乌苏市', + 654203: '沙湾市', 654221: '额敏县', - 654223: '沙湾县', 654224: '托里县', 654225: '裕民县', 654226: '和布克赛尔蒙古自治县', @@ -3578,7 +3200,6 @@ const db: { 654324: '哈巴河县', 654325: '青河县', 654326: '吉木乃县', - 659000: '自治区直辖县级行政区划', 659001: '石河子市', 659002: '阿拉尔市', 659003: '图木舒克市', @@ -3588,453 +3209,37 @@ const db: { 659007: '双河市', 659008: '可克达拉市', 659009: '昆玉市', - 710100: '台北市', - 710200: '高雄市', - 710300: '台南市', - 710400: '台中市', - 710500: '金门县', - 710600: '南投县', - 710700: '基隆市', - 710800: '新竹市', - 710900: '嘉义市', - 711100: '新北市', - 711200: '宜兰县', - 711300: '新竹县', - 711400: '桃园县', - 711500: '苗栗县', - 711520: '头份市', - 711130: '万里区', - 711132: '板桥区', - 711133: '汐止区', - 711134: '深坑区', - 711135: '石碇区', - 711136: '瑞芳区', - 711137: '平溪区', - 711138: '双溪区', - 711139: '贡寮区', - 711140: '新店区', - 711141: '坪林区', - 711142: '乌来区', - 711143: '永和区', - 711144: '中和区', - 711145: '土城区', - 711146: '三峡区', - 711147: '树林区', - 711148: '莺歌区', - 711149: '三重区', - 711150: '新庄区', - 711151: '泰山区', - 711152: '林口区', - 711153: '芦洲区', - 711154: '五股区', - 711155: '八里区', - 711156: '淡水区', - 711157: '三芝区', - 711158: '石门区', - 711287: '宜兰市', - 711288: '头城镇', - 711289: '礁溪乡', - 711290: '壮围乡', - 711291: '员山乡', - 711292: '罗东镇', - 711293: '三星乡', - 711294: '大同乡', - 711295: '五结乡', - 711296: '冬山乡', - 711297: '苏澳镇', - 711298: '南澳乡', - 711299: '钓鱼台', - 711387: '竹北市', - 711388: '湖口乡', - 711389: '新丰乡', - 711390: '新埔镇', - 711391: '关西镇', - 711392: '芎林乡', - 711393: '宝山乡', - 711394: '竹东镇', - 711395: '五峰乡', - 711396: '横山乡', - 711397: '尖石乡', - 711398: '北埔乡', - 711399: '峨眉乡', - 711414: '中坜区', - 711415: '平镇区', - 711417: '杨梅区', - 711418: '新屋区', - 711419: '观音区', - 711420: '桃园区', - 711421: '龟山区', - 711422: '八德区', - 711423: '大溪区', - 711425: '大园区', - 711426: '芦竹区', - 711487: '中坜市', - 711488: '平镇市', - 711489: '龙潭乡', - 711490: '杨梅市', - 711491: '新屋乡', - 711492: '观音乡', - 711493: '桃园市', - 711494: '龟山乡', - 711495: '八德市', - 711496: '大溪镇', - 711497: '复兴乡', - 711498: '大园乡', - 711499: '芦竹乡', - 711582: '竹南镇', - 711583: '头份镇', - 711584: '三湾乡', - 711585: '南庄乡', - 711586: '狮潭乡', - 711587: '后龙镇', - 711588: '通霄镇', - 711589: '苑里镇', - 711590: '苗栗市', - 711591: '造桥乡', - 711592: '头屋乡', - 711593: '公馆乡', - 711594: '大湖乡', - 711595: '泰安乡', - 711596: '铜锣乡', - 711597: '三义乡', - 711598: '西湖乡', - 711599: '卓兰镇', - 711736: '员林市', - 711774: '彰化市', - 711775: '芬园乡', - 711776: '花坛乡', - 711777: '秀水乡', - 711778: '鹿港镇', - 711779: '福兴乡', - 711780: '线西乡', - 711781: '和美镇', - 711782: '伸港乡', - 711783: '员林镇', - 711784: '社头乡', - 711785: '永靖乡', - 711786: '埔心乡', - 711787: '溪湖镇', - 711788: '大村乡', - 711789: '埔盐乡', - 711790: '田中镇', - 711791: '北斗镇', - 711792: '田尾乡', - 711793: '埤头乡', - 711794: '溪州乡', - 711795: '竹塘乡', - 711796: '二林镇', - 711797: '大城乡', - 711798: '芳苑乡', - 711799: '二水乡', - 711982: '番路乡', - 711983: '梅山乡', - 711984: '竹崎乡', - 711985: '阿里山乡', - 711986: '中埔乡', - 711987: '大埔乡', - 711988: '水上乡', - 711989: '鹿草乡', - 711990: '太保市', - 711991: '朴子市', - 711992: '东石乡', - 711993: '六脚乡', - 711994: '新港乡', - 711995: '民雄乡', - 711996: '大林镇', - 711997: '溪口乡', - 711998: '义竹乡', - 711999: '布袋镇', - 711700: '彰化县', - 711900: '嘉义县', - 712100: '云林县', - 712400: '屏东县', - 712500: '台东县', - 712600: '花莲县', - 712700: '澎湖县', - 712800: '连江县', - 712180: '斗南镇', - 712181: '大埤乡', - 712182: '虎尾镇', - 712183: '土库镇', - 712184: '褒忠乡', - 712185: '东势乡', - 712186: '台西乡', - 712187: '仑背乡', - 712188: '麦寮乡', - 712189: '斗六市', - 712190: '林内乡', - 712191: '古坑乡', - 712192: '莿桐乡', - 712193: '西螺镇', - 712194: '二仑乡', - 712195: '北港镇', - 712196: '水林乡', - 712197: '口湖乡', - 712198: '四湖乡', - 712199: '元长乡', - 712451: '崁顶乡', - 712467: '屏东市', - 712468: '三地门乡', - 712469: '雾台乡', - 712470: '玛家乡', - 712471: '九如乡', - 712472: '里港乡', - 712473: '高树乡', - 712474: '盐埔乡', - 712475: '长治乡', - 712476: '麟洛乡', - 712477: '竹田乡', - 712478: '内埔乡', - 712479: '万丹乡', - 712480: '潮州镇', - 712481: '泰武乡', - 712482: '来义乡', - 712483: '万峦乡', - 712484: '莰顶乡', - 712485: '新埤乡', - 712486: '南州乡', - 712487: '林边乡', - 712488: '东港镇', - 712489: '琉球乡', - 712490: '佳冬乡', - 712491: '新园乡', - 712492: '枋寮乡', - 712493: '枋山乡', - 712494: '春日乡', - 712495: '狮子乡', - 712496: '车城乡', - 712497: '牡丹乡', - 712498: '恒春镇', - 712499: '满州乡', - 712584: '台东市', - 712585: '绿岛乡', - 712586: '兰屿乡', - 712587: '延平乡', - 712588: '卑南乡', - 712589: '鹿野乡', - 712590: '关山镇', - 712591: '海端乡', - 712592: '池上乡', - 712593: '东河乡', - 712594: '成功镇', - 712595: '长滨乡', - 712596: '金峰乡', - 712597: '大武乡', - 712598: '达仁乡', - 712599: '太麻里乡', - 712686: '花莲市', - 712687: '新城乡', - 712688: '太鲁阁', - 712689: '秀林乡', - 712690: '吉安乡', - 712691: '寿丰乡', - 712692: '凤林镇', - 712693: '光复乡', - 712694: '丰滨乡', - 712695: '瑞穗乡', - 712696: '万荣乡', - 712697: '玉里镇', - 712698: '卓溪乡', - 712699: '富里乡', - 712794: '马公市', - 712795: '西屿乡', - 712796: '望安乡', - 712797: '七美乡', - 712798: '白沙乡', - 712799: '湖西乡', - 712896: '南竿乡', - 712897: '北竿乡', - 712898: '东引乡', - 712899: '莒光乡', + 659010: '胡杨河市', + 659011: '新星市', 710000: '台湾省', - 710101: '中正区', - 710102: '大同区', - 710103: '中山区', - 710104: '松山区', - 710105: '大安区', - 710106: '万华区', - 710107: '信义区', - 710108: '士林区', - 710109: '北投区', - 710110: '内湖区', - 710111: '南港区', - 710112: '文山区', - 710199: '其它区', - 710201: '新兴区', - 710202: '前金区', - 710203: '芩雅区', - 710204: '盐埕区', - 710205: '鼓山区', - 710206: '旗津区', - 710207: '前镇区', - 710208: '三民区', - 710209: '左营区', - 710210: '楠梓区', - 710211: '小港区', - 710241: '苓雅区', - 710242: '仁武区', - 710243: '大社区', - 710244: '冈山区', - 710245: '路竹区', - 710246: '阿莲区', - 710247: '田寮区', - 710248: '燕巢区', - 710249: '桥头区', - 710250: '梓官区', - 710251: '弥陀区', - 710252: '永安区', - 710253: '湖内区', - 710254: '凤山区', - 710255: '大寮区', - 710256: '林园区', - 710257: '鸟松区', - 710258: '大树区', - 710259: '旗山区', - 710260: '美浓区', - 710261: '六龟区', - 710262: '内门区', - 710263: '杉林区', - 710264: '甲仙区', - 710265: '桃源区', - 710266: '那玛夏区', - 710267: '茂林区', - 710268: '茄萣区', - 710299: '其它区', - 710301: '中西区', - 710302: '东区', - 710303: '南区', - 710304: '北区', - 710305: '安平区', - 710306: '安南区', - 710339: '永康区', - 710340: '归仁区', - 710341: '新化区', - 710342: '左镇区', - 710343: '玉井区', - 710344: '楠西区', - 710345: '南化区', - 710346: '仁德区', - 710347: '关庙区', - 710348: '龙崎区', - 710349: '官田区', - 710350: '麻豆区', - 710351: '佳里区', - 710352: '西港区', - 710353: '七股区', - 710354: '将军区', - 710355: '学甲区', - 710356: '北门区', - 710357: '新营区', - 710358: '后壁区', - 710359: '白河区', - 710360: '东山区', - 710361: '六甲区', - 710362: '下营区', - 710363: '柳营区', - 710364: '盐水区', - 710365: '善化区', - 710366: '大内区', - 710367: '山上区', - 710368: '新市区', - 710369: '安定区', - 710399: '其它区', - 710401: '中区', - 710402: '东区', - 710403: '南区', - 710404: '西区', - 710405: '北区', - 710406: '北屯区', - 710407: '西屯区', - 710408: '南屯区', - 710431: '太平区', - 710432: '大里区', - 710433: '雾峰区', - 710434: '乌日区', - 710435: '丰原区', - 710436: '后里区', - 710437: '石冈区', - 710438: '东势区', - 710439: '和平区', - 710440: '新社区', - 710441: '潭子区', - 710442: '大雅区', - 710443: '神冈区', - 710444: '大肚区', - 710445: '沙鹿区', - 710446: '龙井区', - 710447: '梧栖区', - 710448: '清水区', - 710449: '大甲区', - 710450: '外埔区', - 710451: '大安区', - 710499: '其它区', - 710507: '金沙镇', - 710508: '金湖镇', - 710509: '金宁乡', - 710510: '金城镇', - 710511: '烈屿乡', - 710512: '乌坵乡', - 710614: '南投市', - 710615: '中寮乡', - 710616: '草屯镇', - 710617: '国姓乡', - 710618: '埔里镇', - 710619: '仁爱乡', - 710620: '名间乡', - 710621: '集集镇', - 710622: '水里乡', - 710623: '鱼池乡', - 710624: '信义乡', - 710625: '竹山镇', - 710626: '鹿谷乡', - 710701: '仁爱区', - 710702: '信义区', - 710703: '中正区', - 710704: '中山区', - 710705: '安乐区', - 710706: '暖暖区', - 710707: '七堵区', - 710799: '其它区', - 710801: '东区', - 710802: '北区', - 710803: '香山区', - 710899: '其它区', - 710901: '东区', - 710902: '西区', - 710999: '其它区', - 810100: '香港岛', - 810200: '九龙', - 810300: '新界', - 820100: '澳门半岛', - 820200: '离岛', 810000: '香港特别行政区', - 810101: '中西区', - 810102: '湾仔区', - 810103: '东区', - 810104: '南区', - 810201: '九龙城区', - 810202: '油尖旺区', - 810203: '深水埗区', - 810204: '黄大仙区', - 810205: '观塘区', - 810301: '北区', - 810302: '大埔区', - 810303: '沙田区', - 810304: '西贡区', - 810305: '元朗区', - 810306: '屯门区', - 810307: '荃湾区', - 810308: '葵青区', - 810309: '离岛区', + 810001: '中西区', + 810002: '湾仔区', + 810003: '东区', + 810004: '南区', + 810005: '油尖旺区', + 810006: '深水埗区', + 810007: '九龙城区', + 810008: '黄大仙区', + 810009: '观塘区', + 810010: '荃湾区', + 810011: '屯门区', + 810012: '元朗区', + 810013: '北区', + 810014: '大埔区', + 810015: '西贡区', + 810016: '沙田区', + 810017: '葵青区', + 810018: '离岛区', 820000: '澳门特别行政区', - 820102: '花地玛堂区', - 820103: '花王堂区', - 820104: '望德堂区', - 820105: '大堂区', - 820106: '风顺堂区', - 820202: '嘉模堂区', - 820203: '路氹填海区', - 820204: '圣方济各堂区' + 820001: '花地玛堂区', + 820002: '花王堂区', + 820003: '望德堂区', + 820004: '大堂区', + 820005: '风顺堂区', + 820006: '嘉模堂区', + 820007: '路凼填海区', + 820008: '圣方济各堂区' }; export const province: Array = []; diff --git a/scripts/convert-citydb.ts b/scripts/convert-citydb.ts new file mode 100644 index 000000000..f670dbad2 --- /dev/null +++ b/scripts/convert-citydb.ts @@ -0,0 +1,26 @@ +/** + * 将 https://lbs.amap.com/api/webservice/download 中的 json 转成 json 格式 + */ + +import {raw} from 'express'; +import process from 'node:process'; + +import XLSX from 'xlsx'; + +const file = process.argv[2]; + +const workbook = XLSX.readFile(file); + +const worksheet = workbook.Sheets[workbook.SheetNames[0]]; +const rawData = XLSX.utils.sheet_to_json(worksheet) as Array<{ + 中文名: string; + adcode: string; +}>; + +const cityDb: Record = {}; + +for (const row of rawData) { + cityDb[row.adcode] = row['中文名']; +} + +console.log(JSON.stringify(cityDb, null, 2)); From ef8f87c7e17af45f33136d4925ab36d1240d9e48 Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Sun, 21 Apr 2024 12:14:30 +0800 Subject: [PATCH 15/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E4=B8=AD=E5=BC=95=E7=94=A8=E5=BC=B9=E7=AA=97=E8=87=AA?= =?UTF-8?q?=E5=B7=B1=E7=9A=84=E7=BC=96=E8=BE=91=E5=99=A8=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#10078)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-editor-core/src/manager.ts | 3 +- packages/amis-editor-core/src/store/editor.ts | 41 +++++++++++++++++-- packages/amis-editor-core/src/util.ts | 4 +- .../event-control/DialogActionPanel.tsx | 17 ++++++++ .../event-control/action-config-dialog.tsx | 3 +- .../src/renderer/event-control/index.tsx | 17 +++++++- 6 files changed, 77 insertions(+), 8 deletions(-) diff --git a/packages/amis-editor-core/src/manager.ts b/packages/amis-editor-core/src/manager.ts index 298e59ece..0fa6a03ef 100644 --- a/packages/amis-editor-core/src/manager.ts +++ b/packages/amis-editor-core/src/manager.ts @@ -1364,8 +1364,9 @@ export class EditorManager { this.parent ) { let parent: EditorManager | undefined = this.parent; + const id = config.value.$$originId || config.value.$$id; while (parent) { - if (parent.store.schema.$$id === config.value.$$id) { + if (parent.store.schema.$$id === id) { toast.warning('所选弹窗已经被打开,不能多次打开'); return; } diff --git a/packages/amis-editor-core/src/store/editor.ts b/packages/amis-editor-core/src/store/editor.ts index 6129d8943..db01dda07 100644 --- a/packages/amis-editor-core/src/store/editor.ts +++ b/packages/amis-editor-core/src/store/editor.ts @@ -1031,7 +1031,11 @@ export const MainStore = types ) { const key = value === 'drawer' ? 'drawer' : 'dialog'; const body = host[key] || host['args']; - if (body && !body.$ref) { + if ( + body && + !body.$ref && + !modals.find(item => item.$$id === body.$$id) + ) { modals.push({ ...body, actionType: value @@ -1064,6 +1068,11 @@ export const MainStore = types // 子弹窗时,自己就是个弹窗 if (['dialog', 'drawer', 'confirmDialog'].includes(schema.type)) { + const idx = modals.findIndex(item => item.$$id === schema.$$id); + if (~idx) { + modals.splice(idx, 1); + } + modals.unshift({ ...schema, // 如果还包含这个,子弹窗里面收集弹窗的时候会出现多份内嵌弹窗 @@ -1163,7 +1172,9 @@ export const MainStore = types setSchema(json: any) { const newSchema = JSONPipeIn(json || {}); - if (self.schema) { + // schema 里面始终有个 $$id + // 如果超过一个元素,说明不是个空配置了,就不要直接替换了。 + if (self.schema && Object.keys(self.schema).length > 1) { // 不直接替换,主要是为了不要重新生成 $$id 什么的。 const changes = diff( self.schema, @@ -1791,6 +1802,7 @@ export const MainStore = types throw new Error('modal not found'); } + modal = JSONPipeIn(modal); if (definitions && isPlainObject(definitions)) { schema = mergeDefinitions(schema, definitions, modal); } @@ -1834,7 +1846,30 @@ export const MainStore = types args: undefined, dialog: undefined, drawer: undefined, - [newHostKey]: JSONPipeIn(modal) + [newHostKey]: modal + }); + } + + // 如果弹窗里面又弹窗指向自己,那么也要更新 + let refIds: string[] = []; + JSONTraverse(modal, (value: any, key: string, host: any) => { + if (key === '$ref' && host.$$originId === id) { + refIds.push(host.$$id); + } + }); + if (refIds.length) { + let refKey = ''; + [schema, refKey] = addModal(schema, modal); + schema = JSONUpdate(schema, parent.$$id, { + [newHostKey]: JSONPipeIn({ + $ref: refKey + }) + }); + refIds.forEach(refId => { + schema = JSONUpdate(schema, refId, { + $ref: refKey, + $$originId: undefined + }); }); } diff --git a/packages/amis-editor-core/src/util.ts b/packages/amis-editor-core/src/util.ts index 14b087c31..fb94f936a 100644 --- a/packages/amis-editor-core/src/util.ts +++ b/packages/amis-editor-core/src/util.ts @@ -1518,7 +1518,9 @@ export function mergeDefinitions( const {$$originId, ...def} = definitions[key]; - if ($$originId) { + if (schema.$$id === $$originId) { + schema = JSONUpdate(schema, $$originId, JSONPipeIn(def)); + } else if ($$originId) { const parent = JSONGetParentById(schema, $$originId); if (!parent) { throw new Error('Can not find modal action.'); diff --git a/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx b/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx index 736d7c49a..b7c3302bc 100644 --- a/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx +++ b/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx @@ -2,6 +2,7 @@ import { EditorManager, JSONGetById, JSONGetParentById, + JSONGetPathById, JSONPipeIn, JSONPipeOut, JSONUpdate, @@ -186,6 +187,7 @@ function DialogActionPanel({ // 没找到很可能是在主页面里面的弹窗 // 还得继续把 originId 给到上一层去处理 schema.definitions[currentModal.modal.$$ref].$$originId = originInd; + newActionSchema[modalType].$$originId = originInd; } } } else { @@ -218,6 +220,21 @@ function DialogActionPanel({ true ); + // 自己就是个弹窗,可能有 definition 里面引用自己 + if (['dialog', 'drawer', 'confirmDialog'].includes(schema.type)) { + const id = schema.$$originId || schema.$$id; + Object.keys(schema.definitions).forEach(key => { + const definition = schema.definitions[key]; + const exits = JSONGetById(definition, id); + if (exits) { + schema.definitions[key] = JSONUpdate(schema.definitions[key], id, { + ...schema, + definitions: undefined + }); + } + }); + } + // 原来的动作也要更新 if (originActionId && newRefName) { schema = JSONUpdate( diff --git a/packages/amis-editor/src/renderer/event-control/action-config-dialog.tsx b/packages/amis-editor/src/renderer/event-control/action-config-dialog.tsx index 74ccbc961..6ff0605ad 100644 --- a/packages/amis-editor/src/renderer/event-control/action-config-dialog.tsx +++ b/packages/amis-editor/src/renderer/event-control/action-config-dialog.tsx @@ -41,7 +41,8 @@ interface ActionDialogProp { ) => JSX.Element; subscribeSchemaSubmit: ( - fn: (schema: any, value: any, id: string, diff?: any) => any + fn: (schema: any, value: any, id: string, diff?: any) => any, + once?: boolean ) => () => void; subscribeActionSubmit: (fn: (value: any) => any) => () => void; } diff --git a/packages/amis-editor/src/renderer/event-control/index.tsx b/packages/amis-editor/src/renderer/event-control/index.tsx index 5453b6248..46021e08c 100644 --- a/packages/amis-editor/src/renderer/event-control/index.tsx +++ b/packages/amis-editor/src/renderer/event-control/index.tsx @@ -78,7 +78,8 @@ interface EventControlProps extends FormControlProps { // 监听面板提交事件 // 更改后写入 store 前触发 subscribeSchemaSubmit: ( - fn: (schema: any, value: any, id: string, diff?: any) => any + fn: (schema: any, value: any, id: string, diff?: any) => any, + once?: boolean ) => () => void; } @@ -978,6 +979,18 @@ export class EventControl extends React.Component< onClose() { this.removeDataSchema(); this.setState({showAcionDialog: false}); + this.unSubscribeSchemaSubmit?.(); + delete this.unSubscribeSchemaSubmit; + } + + unSubscribeSchemaSubmit?: () => void; + @autobind + subscribeSchemaSubmit( + fn: (schema: any, value: any, id: string, diff?: any) => any, + once?: boolean + ) { + this.unSubscribeSchemaSubmit = this.props.subscribeSchemaSubmit(fn, once); + return this.unSubscribeSchemaSubmit; } removeDataSchema() { @@ -1389,7 +1402,7 @@ export class EventControl extends React.Component< onSubmit={this.onSubmit} onClose={this.onClose} render={this.props.render} - subscribeSchemaSubmit={subscribeSchemaSubmit} + subscribeSchemaSubmit={this.subscribeSchemaSubmit} subscribeActionSubmit={this.subscribeSubmit} /> From f02f967363c697f992c97e8c0fa509234aaa34f3 Mon Sep 17 00:00:00 2001 From: wuduoyi Date: Mon, 22 Apr 2024 14:29:38 +0800 Subject: [PATCH 16/46] =?UTF-8?q?=E8=A1=A5=E5=85=85=E4=B9=8B=E5=89=8D?= =?UTF-8?q?=E7=9A=84=E8=BE=96=E5=8C=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-ui/src/components/CityDB.ts | 285 +++++++++++++++++++++- 1 file changed, 284 insertions(+), 1 deletion(-) diff --git a/packages/amis-ui/src/components/CityDB.ts b/packages/amis-ui/src/components/CityDB.ts index 2ddd78cd8..8a06f08ec 100644 --- a/packages/amis-ui/src/components/CityDB.ts +++ b/packages/amis-ui/src/components/CityDB.ts @@ -3239,7 +3239,290 @@ const db: { 820005: '风顺堂区', 820006: '嘉模堂区', 820007: '路凼填海区', - 820008: '圣方济各堂区' + 820008: '圣方济各堂区', + // 下面这些是手动补的 + 110100: '北京市市辖区', + 120100: '天津市市辖区', + 130101: '石家庄市市辖区', + 130201: '唐山市市辖区', + 130301: '秦皇岛市市辖区', + 130401: '邯郸市市辖区', + 130501: '邢台市市辖区', + 130601: '保定市市辖区', + 130701: '张家口市市辖区', + 130801: '承德市市辖区', + 130901: '沧州市市辖区', + 131001: '廊坊市市辖区', + 131101: '衡水市市辖区', + 140101: '太原市市辖区', + 140201: '大同市市辖区', + 140301: '阳泉市市辖区', + 140401: '长治市市辖区', + 140501: '晋城市市辖区', + 140601: '朔州市市辖区', + 140701: '晋中市市辖区', + 140801: '运城市市辖区', + 140901: '忻州市市辖区', + 141001: '临汾市市辖区', + 141101: '吕梁市市辖区', + 150101: '呼和浩特市市辖区', + 150201: '包头市市辖区', + 150301: '乌海市市辖区', + 150401: '赤峰市市辖区', + 150501: '通辽市市辖区', + 150601: '鄂尔多斯市市辖区', + 150701: '呼伦贝尔市市辖区', + 150801: '巴彦淖尔市市辖区', + 150901: '乌兰察布市市辖区', + 210101: '沈阳市市辖区', + 210201: '大连市市辖区', + 210301: '鞍山市市辖区', + 210401: '抚顺市市辖区', + 210501: '本溪市市辖区', + 210601: '丹东市市辖区', + 210701: '锦州市市辖区', + 210801: '营口市市辖区', + 210901: '阜新市市辖区', + 211001: '辽阳市市辖区', + 211101: '盘锦市市辖区', + 211201: '铁岭市市辖区', + 211301: '朝阳市市辖区', + 211401: '葫芦岛市市辖区', + 220101: '长春市市辖区', + 220201: '吉林市市辖区', + 220301: '四平市市辖区', + 220401: '辽源市市辖区', + 220501: '通化市市辖区', + 220601: '白山市市辖区', + 220701: '松原市市辖区', + 220801: '白城市市辖区', + 230101: '哈尔滨市市辖区', + 230201: '齐齐哈尔市市辖区', + 230301: '鸡西市市辖区', + 230401: '鹤岗市市辖区', + 230501: '双鸭山市市辖区', + 230601: '大庆市市辖区', + 230701: '伊春市市辖区', + 230801: '佳木斯市市辖区', + 230901: '七台河市市辖区', + 231001: '牡丹江市市辖区', + 231101: '黑河市市辖区', + 231201: '绥化市市辖区', + 310100: '上海市市辖区', + 320101: '南京市市辖区', + 320201: '无锡市市辖区', + 320301: '徐州市市辖区', + 320401: '常州市市辖区', + 320501: '苏州市市辖区', + 320601: '南通市市辖区', + 320701: '连云港市市辖区', + 320801: '淮安市市辖区', + 320901: '盐城市市辖区', + 321001: '扬州市市辖区', + 321101: '镇江市市辖区', + 321201: '泰州市市辖区', + 321301: '宿迁市市辖区', + 330101: '杭州市市辖区', + 330201: '宁波市市辖区', + 330301: '温州市市辖区', + 330401: '嘉兴市市辖区', + 330501: '湖州市市辖区', + 330601: '绍兴市市辖区', + 330701: '金华市市辖区', + 330801: '衢州市市辖区', + 330901: '舟山市市辖区', + 331001: '台州市市辖区', + 331101: '丽水市市辖区', + 340101: '合肥市市辖区', + 340201: '芜湖市市辖区', + 340301: '蚌埠市市辖区', + 340401: '淮南市市辖区', + 340501: '马鞍山市市辖区', + 340601: '淮北市市辖区', + 340701: '铜陵市市辖区', + 340801: '安庆市市辖区', + 341001: '黄山市市辖区', + 341101: '滁州市市辖区', + 341201: '阜阳市市辖区', + 341301: '宿州市市辖区', + 341501: '六安市市辖区', + 341601: '亳州市市辖区', + 341701: '池州市市辖区', + 341801: '宣城市市辖区', + 350101: '福州市市辖区', + 350201: '厦门市市辖区', + 350301: '莆田市市辖区', + 350401: '三明市市辖区', + 350501: '泉州市市辖区', + 350601: '漳州市市辖区', + 350701: '南平市市辖区', + 350801: '龙岩市市辖区', + 350901: '宁德市市辖区', + 360101: '南昌市市辖区', + 360201: '景德镇市市辖区', + 360301: '萍乡市市辖区', + 360401: '九江市市辖区', + 360501: '新余市市辖区', + 360601: '鹰潭市市辖区', + 360701: '赣州市市辖区', + 360801: '吉安市市辖区', + 360901: '宜春市市辖区', + 361001: '抚州市市辖区', + 361101: '上饶市市辖区', + 370101: '济南市市辖区', + 370201: '青岛市市辖区', + 370301: '淄博市市辖区', + 370401: '枣庄市市辖区', + 370501: '东营市市辖区', + 370601: '烟台市市辖区', + 370701: '潍坊市市辖区', + 370801: '济宁市市辖区', + 370901: '泰安市市辖区', + 371001: '威海市市辖区', + 371101: '日照市市辖区', + 371301: '临沂市市辖区', + 371401: '德州市市辖区', + 371501: '聊城市市辖区', + 371601: '滨州市市辖区', + 371701: '菏泽市市辖区', + 410101: '郑州市市辖区', + 410201: '开封市市辖区', + 410301: '洛阳市市辖区', + 410401: '平顶山市市辖区', + 410501: '安阳市市辖区', + 410601: '鹤壁市市辖区', + 410701: '新乡市市辖区', + 410801: '焦作市市辖区', + 410901: '濮阳市市辖区', + 411001: '许昌市市辖区', + 411101: '漯河市市辖区', + 411201: '三门峡市市辖区', + 411301: '南阳市市辖区', + 411401: '商丘市市辖区', + 411501: '信阳市市辖区', + 411601: '周口市市辖区', + 411701: '驻马店市市辖区', + 420101: '武汉市市辖区', + 420201: '黄石市市辖区', + 420301: '十堰市市辖区', + 420501: '宜昌市市辖区', + 420601: '襄阳市市辖区', + 420701: '鄂州市市辖区', + 420801: '荆门市市辖区', + 420901: '孝感市市辖区', + 421001: '荆州市市辖区', + 421101: '黄冈市市辖区', + 421201: '咸宁市市辖区', + 421301: '随州市市辖区', + 430101: '长沙市市辖区', + 430201: '株洲市市辖区', + 430301: '湘潭市市辖区', + 430401: '衡阳市市辖区', + 430501: '邵阳市市辖区', + 430601: '岳阳市市辖区', + 430701: '常德市市辖区', + 430801: '张家界市市辖区', + 430901: '益阳市市辖区', + 431001: '郴州市市辖区', + 431101: '永州市市辖区', + 431201: '怀化市市辖区', + 431301: '娄底市市辖区', + 440101: '广州市市辖区', + 440201: '韶关市市辖区', + 440301: '深圳市市辖区', + 440401: '珠海市市辖区', + 440501: '汕头市市辖区', + 440601: '佛山市市辖区', + 440701: '江门市市辖区', + 440801: '湛江市市辖区', + 440901: '茂名市市辖区', + 441201: '肇庆市市辖区', + 441301: '惠州市市辖区', + 441401: '梅州市市辖区', + 441501: '汕尾市市辖区', + 441601: '河源市市辖区', + 441701: '阳江市市辖区', + 441801: '清远市市辖区', + 445101: '潮州市市辖区', + 445201: '揭阳市市辖区', + 445301: '云浮市市辖区', + 450101: '南宁市市辖区', + 450201: '柳州市市辖区', + 450301: '桂林市市辖区', + 450401: '梧州市市辖区', + 450501: '北海市市辖区', + 450601: '防城港市市辖区', + 450701: '钦州市市辖区', + 450801: '贵港市市辖区', + 450901: '玉林市市辖区', + 451001: '百色市市辖区', + 451101: '贺州市市辖区', + 451201: '河池市市辖区', + 451301: '来宾市市辖区', + 451401: '崇左市市辖区', + 460101: '海口市市辖区', + 460201: '三亚市市辖区', + 500100: '重庆市市辖区', + 510101: '成都市市辖区', + 510301: '自贡市市辖区', + 510401: '攀枝花市市辖区', + 510501: '泸州市市辖区', + 510601: '德阳市市辖区', + 510701: '绵阳市市辖区', + 510801: '广元市市辖区', + 510901: '遂宁市市辖区', + 511001: '内江市市辖区', + 511101: '乐山市市辖区', + 511301: '南充市市辖区', + 511401: '眉山市市辖区', + 511501: '宜宾市市辖区', + 511601: '广安市市辖区', + 511701: '达州市市辖区', + 511801: '雅安市市辖区', + 511901: '巴中市市辖区', + 512001: '资阳市市辖区', + 520101: '贵阳市市辖区', + 520301: '遵义市市辖区', + 520401: '安顺市市辖区', + 530101: '昆明市市辖区', + 530301: '曲靖市市辖区', + 530401: '玉溪市市辖区', + 530501: '保山市市辖区', + 530601: '昭通市市辖区', + 530701: '丽江市市辖区', + 530801: '普洱市市辖区', + 530901: '临沧市市辖区', + 540101: '拉萨市市辖区', + 610101: '西安市市辖区', + 610201: '铜川市市辖区', + 610301: '宝鸡市市辖区', + 610401: '咸阳市市辖区', + 610501: '渭南市市辖区', + 610601: '延安市市辖区', + 610701: '汉中市市辖区', + 610801: '榆林市市辖区', + 610901: '安康市市辖区', + 611001: '商洛市市辖区', + 620101: '兰州市市辖区', + 620201: '嘉峪关市市辖区', + 620301: '金昌市市辖区', + 620401: '白银市市辖区', + 620501: '天水市市辖区', + 620601: '武威市市辖区', + 620701: '张掖市市辖区', + 620801: '平凉市市辖区', + 620901: '酒泉市市辖区', + 621001: '庆阳市市辖区', + 621101: '定西市市辖区', + 621201: '陇南市市辖区', + 630101: '西宁市市辖区', + 640101: '银川市市辖区', + 640201: '石嘴山市市辖区', + 640301: '吴忠市市辖区', + 640401: '固原市市辖区', + 640501: '中卫市市辖区', + 650101: '乌鲁木齐市市辖区', + 650201: '克拉玛依市市辖区' }; export const province: Array = []; From 5f678f04c5a0fceafaad355c4c2ba87c12a2cb33 Mon Sep 17 00:00:00 2001 From: lvxiaojiao Date: Mon, 22 Apr 2024 15:30:53 +0800 Subject: [PATCH 17/46] =?UTF-8?q?fix:=E5=8F=91=E9=80=81=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=8A=A8=E4=BD=9C=E7=9A=84sendOn=E9=85=8D=E7=BD=AE=E4=B8=8D?= =?UTF-8?q?=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-core/src/actions/AjaxAction.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/amis-core/src/actions/AjaxAction.ts b/packages/amis-core/src/actions/AjaxAction.ts index e5d77da1f..2bde45731 100644 --- a/packages/amis-core/src/actions/AjaxAction.ts +++ b/packages/amis-core/src/actions/AjaxAction.ts @@ -3,6 +3,7 @@ import {normalizeApi, normalizeApiResponseData} from '../utils/api'; import {ServerError} from '../utils/errors'; import {createObject, isEmpty} from '../utils/helper'; import {RendererEvent} from '../utils/renderer-event'; +import {evalExpressionWithConditionBuilder} from '../utils/tpl'; import { RendererAction, ListenerAction, @@ -58,6 +59,17 @@ export class AjaxAction implements RendererAction { const messages = (action?.api as ApiObject)?.messages; let api = normalizeApi(action.api); + // 发送请求前,判断是否需要发送 + const sendOn = await evalExpressionWithConditionBuilder( + api.sendOn, + action.data ?? {}, + false + ); + + if (!sendOn) { + return; + } + // 如果没配置data数据映射,则给一个空对象,避免将当前数据域作为接口请求参数 if ((api as any)?.data == undefined) { api = { From 3b3086e20915591baf27fcaac52fe139107d859d Mon Sep 17 00:00:00 2001 From: lvxiaojiao Date: Mon, 22 Apr 2024 15:47:10 +0800 Subject: [PATCH 18/46] =?UTF-8?q?fix:=E5=8F=91=E9=80=81=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=8A=A8=E4=BD=9C=E7=9A=84sendOn=E9=85=8D=E7=BD=AE=E4=B8=8D?= =?UTF-8?q?=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-core/src/actions/AjaxAction.ts | 18 ++++--- .../__snapshots__/ajax.test.tsx.snap | 30 +++++++++++ .../amis/__tests__/event-action/ajax.test.tsx | 54 ++++++++++++++++++- 3 files changed, 93 insertions(+), 9 deletions(-) diff --git a/packages/amis-core/src/actions/AjaxAction.ts b/packages/amis-core/src/actions/AjaxAction.ts index 2bde45731..07777dbe4 100644 --- a/packages/amis-core/src/actions/AjaxAction.ts +++ b/packages/amis-core/src/actions/AjaxAction.ts @@ -59,15 +59,17 @@ export class AjaxAction implements RendererAction { const messages = (action?.api as ApiObject)?.messages; let api = normalizeApi(action.api); - // 发送请求前,判断是否需要发送 - const sendOn = await evalExpressionWithConditionBuilder( - api.sendOn, - action.data ?? {}, - false - ); + if (api.sendOn !== undefined) { + // 发送请求前,判断是否需要发送 + const sendOn = await evalExpressionWithConditionBuilder( + api.sendOn, + action.data ?? {}, + false + ); - if (!sendOn) { - return; + if (!sendOn) { + return; + } } // 如果没配置data数据映射,则给一个空对象,避免将当前数据域作为接口请求参数 diff --git a/packages/amis/__tests__/event-action/__snapshots__/ajax.test.tsx.snap b/packages/amis/__tests__/event-action/__snapshots__/ajax.test.tsx.snap index 1237115e3..cde48b055 100644 --- a/packages/amis/__tests__/event-action/__snapshots__/ajax.test.tsx.snap +++ b/packages/amis/__tests__/event-action/__snapshots__/ajax.test.tsx.snap @@ -103,3 +103,33 @@ exports[`EventAction:ajax args 1`] = ` `; + +exports[`EventAction:ajax sendOn 1`] = ` +
+
+
+
+
+ +
+
+
+
+
+`; diff --git a/packages/amis/__tests__/event-action/ajax.test.tsx b/packages/amis/__tests__/event-action/ajax.test.tsx index 90c0ab5c5..ba451a9ef 100644 --- a/packages/amis/__tests__/event-action/ajax.test.tsx +++ b/packages/amis/__tests__/event-action/ajax.test.tsx @@ -757,7 +757,6 @@ test('EventAction:ajax silent', async () => { await waitFor(() => { expect(fetcher).toHaveBeenCalledTimes(4); - debugger; expect(fetcher.mock.calls[0][0].url).toEqual('/api/xxx1'); expect(fetcher.mock.calls[1][0].url).toEqual('/api/xxx2'); expect(fetcher.mock.calls[2][0].url).toEqual('/api/xxx3'); @@ -765,3 +764,56 @@ test('EventAction:ajax silent', async () => { expect(notify).toBeCalledTimes(2); }); }); + +test('EventAction:ajax sendOn', async () => { + const fetcher = jest.fn().mockImplementation(() => + Promise.resolve({ + data: { + status: 0, + msg: 'ok', + data: { + age: 18 + } + } + }) + ); + const {getByText, container}: any = render( + amisRender( + { + type: 'page', + body: [ + { + type: 'button', + label: '发送请求', + level: 'primary', + onEvent: { + click: { + actions: [ + { + actionType: 'ajax', + api: { + url: '/api/xxx', + method: 'get', + sendOn: '${1 !== 1}' + } + } + ] + } + } + } + ] + }, + {}, + makeEnv({ + fetcher + }) + ) + ); + + fireEvent.click(getByText('发送请求')); + await waitFor(() => { + expect(fetcher).toHaveBeenCalledTimes(0); + }); + + expect(container).toMatchSnapshot(); +}); From c3bcbf2a70ca7f18a75420c8c75c6a2c2eead83f Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Mon, 22 Apr 2024 17:28:05 +0800 Subject: [PATCH 19/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E7=BC=96=E8=BE=91=E9=97=AE=E9=A2=98=20(#10083)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-editor-core/src/util.ts | 67 +++++++++++++++++---------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/packages/amis-editor-core/src/util.ts b/packages/amis-editor-core/src/util.ts index fb94f936a..725c0c18b 100644 --- a/packages/amis-editor-core/src/util.ts +++ b/packages/amis-editor-core/src/util.ts @@ -1506,11 +1506,6 @@ export function mergeDefinitions( let schema = originSchema; Object.keys(definitions).forEach(key => { - // 弹窗里面用到了才更新 - if (!refs.includes(key)) { - return; - } - // 要修改就复制一份,避免污染原始数据 if (schema === originSchema) { schema = {...schema, definitions: {...schema.definitions}}; @@ -1518,28 +1513,50 @@ export function mergeDefinitions( const {$$originId, ...def} = definitions[key]; - if (schema.$$id === $$originId) { - schema = JSONUpdate(schema, $$originId, JSONPipeIn(def)); - } else if ($$originId) { + if ($$originId) { const parent = JSONGetParentById(schema, $$originId); - if (!parent) { - throw new Error('Can not find modal action.'); - } - const modalType = def.type === 'drawer' ? 'drawer' : 'dialog'; - schema = JSONUpdate(schema, parent.$$id, { - ...parent, - __actionModals: undefined, - args: undefined, - dialog: undefined, - drawer: undefined, - actionType: def.actionType ?? modalType, - [modalType]: JSONPipeIn({ - $ref: key - }) - }); - schema.definitions[key] = JSONPipeIn(def); - } else { + // 当前更新弹窗里面用到了需要转成 ref + if (refs.includes(key)) { + if (schema.$$id === $$originId) { + schema = JSONUpdate(schema, $$originId, JSONPipeIn(def)); + return; + } + + if (!parent) { + throw new Error('Can not find modal action.'); + } + + const modalType = def.type === 'drawer' ? 'drawer' : 'dialog'; + schema = JSONUpdate(schema, parent.$$id, { + ...parent, + __actionModals: undefined, + args: undefined, + dialog: undefined, + drawer: undefined, + actionType: def.actionType ?? modalType, + [modalType]: JSONPipeIn({ + $ref: key + }) + }); + schema.definitions[key] = JSONPipeIn(def); + } else if (parent) { + // 没用到,可能修改了弹窗的内容为引用其他弹窗,同样需要更新,但是不会提取为 definitions + const modalType = def.type === 'drawer' ? 'drawer' : 'dialog'; + schema = JSONUpdate(schema, parent.$$id, { + ...parent, + __actionModals: undefined, + args: undefined, + dialog: undefined, + drawer: undefined, + actionType: def.actionType ?? modalType, + [modalType]: JSONPipeIn({ + ...def, + $$originId: undefined + }) + }); + } + } else if (refs.includes(key)) { schema.definitions[key] = JSONPipeIn(def); } }); From 1cc4be45ead22fc7cb641671fb6dfcfae60f685f Mon Sep 17 00:00:00 2001 From: sidrong <529672493@qq.com> Date: Tue, 23 Apr 2024 15:37:04 +0800 Subject: [PATCH 20/46] Update Form.tsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改dispatchInited方法,主要解决:当跳转到包含Form的新页面,新页面还没加载完成时,快速后退导致的报错:Uncaught (in promise) Error: [mobx-state-tree] You are trying to read or write to an object that is no longer part of a state tree. --- packages/amis-core/src/renderers/Form.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/amis-core/src/renderers/Form.tsx b/packages/amis-core/src/renderers/Form.tsx index ef49890e4..37aac8079 100644 --- a/packages/amis-core/src/renderers/Form.tsx +++ b/packages/amis-core/src/renderers/Form.tsx @@ -713,7 +713,7 @@ export default class Form extends React.Component { async dispatchInited(value: any) { const {data, store, dispatchEvent} = this.props; - if (store.fetching) { + if (!isAlive(store) || store.fetching) { return value; } From 9b80305323f90295485368c9bb3b4910d7614362 Mon Sep 17 00:00:00 2001 From: yupeng12 Date: Tue, 23 Apr 2024 16:26:58 +0800 Subject: [PATCH 21/46] =?UTF-8?q?feat:=20=E8=A1=A5=E5=85=85CRUD2=20testid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-ui/src/components/table/Cell.tsx | 6 +++++- packages/amis-ui/src/components/table/Row.tsx | 6 +++++- packages/amis-ui/src/components/table/index.tsx | 8 +++++++- packages/amis/src/renderers/CRUD2.tsx | 1 - packages/amis/src/renderers/Operation.tsx | 14 ++++++++++++-- packages/amis/src/renderers/Table2/index.tsx | 11 +++++++++-- 6 files changed, 38 insertions(+), 8 deletions(-) diff --git a/packages/amis-ui/src/components/table/Cell.tsx b/packages/amis-ui/src/components/table/Cell.tsx index e6efd50db..22832f258 100644 --- a/packages/amis-ui/src/components/table/Cell.tsx +++ b/packages/amis-ui/src/components/table/Cell.tsx @@ -8,6 +8,7 @@ import React from 'react'; import {ThemeProps, ClassNamesFn} from 'amis-core'; import {ColumnProps} from './index'; +import type {TestIdBuilder} from 'amis-core'; const zIndex = 1; @@ -26,6 +27,7 @@ export interface Props extends ThemeProps { col?: string; index?: number; classnames: ClassNamesFn; + testIdBuilder?: TestIdBuilder; } export default class BodyCell extends React.PureComponent { @@ -48,7 +50,8 @@ export default class BodyCell extends React.PureComponent { depth, col, wrapperComponent: Component, - classnames: cx + classnames: cx, + testIdBuilder } = this.props; return ( @@ -62,6 +65,7 @@ export default class BodyCell extends React.PureComponent { style={fixed ? {position: 'sticky', zIndex, ...style} : {...style}} data-depth={depth || null} data-col={col} + {...testIdBuilder?.getTestId()} > {children} diff --git a/packages/amis-ui/src/components/table/Row.tsx b/packages/amis-ui/src/components/table/Row.tsx index fba9a64db..a33b76240 100644 --- a/packages/amis-ui/src/components/table/Row.tsx +++ b/packages/amis-ui/src/components/table/Row.tsx @@ -18,6 +18,7 @@ import { hasFixedColumn, levelsSplit } from './util'; +import type {TestIdBuilder} from 'amis-core'; export interface Props extends ThemeProps { data: any; @@ -53,6 +54,7 @@ export interface Props extends ThemeProps { expandedRowClassName: string; expandedRowRender?: Function; isExpanded: boolean; + testIdBuilder?: TestIdBuilder; [propName: string]: any; // 对应checkbox属性 } @@ -204,6 +206,7 @@ class BodyRow extends React.PureComponent { onMouseLeave, onClick, onChange, + testIdBuilder, ...rest } = this.props; @@ -223,6 +226,7 @@ class BodyRow extends React.PureComponent { const cells = tdColumns.map((item, i) => { // 为了支持灵活合并单元格,renderers层的Table2传递的render方法,返回{children: , props: {rowSpan, colSpan}} // 但直接使用amis-ui的table,render方法一般直接返回ReactElement + const cellIDBuilder = testIdBuilder?.getChild(`cell-${i}`); const render = item.render && typeof item.render === 'function' ? item.render(data[item.name], data, rowIndex, i, levelsSplit(levels)) @@ -256,6 +260,7 @@ class BodyRow extends React.PureComponent { [`${className}`]: !!className })} col={i > -1 ? i.toString() : undefined} + testIdBuilder={cellIDBuilder} >
{ ); }); - const rowClassNameClass = rowClassName && typeof rowClassName === 'function' ? rowClassName(data, rowIndex) diff --git a/packages/amis-ui/src/components/table/index.tsx b/packages/amis-ui/src/components/table/index.tsx index 7b536e296..0a5ec8ee6 100644 --- a/packages/amis-ui/src/components/table/index.tsx +++ b/packages/amis-ui/src/components/table/index.tsx @@ -43,6 +43,8 @@ import { getSortData } from './util'; +import type {TestIdBuilder} from 'amis-core'; + export interface ColumnProps { title: string | React.ReactNode | Function; name: string; @@ -176,6 +178,7 @@ export interface TableProps extends ThemeProps, LocaleProps, SpinnerExtraProps { */ autoFillHeight?: boolean | AutoFillHeightObject; lazyRenderAfter?: boolean; + testIdBuilder?: TestIdBuilder; } export interface ScrollProps { @@ -995,7 +998,8 @@ export class Table extends React.PureComponent { columns, lazyRenderAfter, classPrefix, - classnames: cx + classnames: cx, + testIdBuilder } = this.props; const rowSelectionKeyField = this.getRowSelectionKeyField(); @@ -1003,6 +1007,7 @@ export class Table extends React.PureComponent { this.state.selectedRowKeys, key => key === data[rowSelectionKeyField] ); + const rowTIDBuilder = testIdBuilder?.getChild(`row-${rowIndex}`); const childrenColumnName = this.getChildrenColumnName(); // 当前行是否可展开 @@ -1070,6 +1075,7 @@ export class Table extends React.PureComponent { lazyRenderAfter={lazyRenderAfter} classnames={cx} classPrefix={classPrefix} + testIdBuilder={rowTIDBuilder} {...checkboxProps} />, children diff --git a/packages/amis/src/renderers/CRUD2.tsx b/packages/amis/src/renderers/CRUD2.tsx index 1389f465c..78c521d42 100644 --- a/packages/amis/src/renderers/CRUD2.tsx +++ b/packages/amis/src/renderers/CRUD2.tsx @@ -1313,7 +1313,6 @@ export default class CRUD2 extends React.Component { columnsTogglable, headerToolbarClassName, footerToolbarClassName, - testid, ...rest } = this.props; diff --git a/packages/amis/src/renderers/Operation.tsx b/packages/amis/src/renderers/Operation.tsx index 4664946d0..f80f983d7 100644 --- a/packages/amis/src/renderers/Operation.tsx +++ b/packages/amis/src/renderers/Operation.tsx @@ -36,7 +36,14 @@ export class OperationField extends React.Component { static defaultProps: Partial = {}; render() { - const {className, style, buttons, render, classnames: cx} = this.props; + const { + className, + style, + buttons, + render, + classnames: cx, + testIdBuilder + } = this.props; return (
@@ -53,7 +60,10 @@ export class OperationField extends React.Component { ...(button as any) }, { - key: index + key: index, + testIdBuilder: testIdBuilder?.getChild( + `button-${button.testid || button.id || index}` + ) } ) ) diff --git a/packages/amis/src/renderers/Table2/index.tsx b/packages/amis/src/renderers/Table2/index.tsx index 10bef2ed4..d6c48944f 100644 --- a/packages/amis/src/renderers/Table2/index.tsx +++ b/packages/amis/src/renderers/Table2/index.tsx @@ -57,6 +57,8 @@ import './TableCell'; import './ColumnToggler'; import {SchemaQuickEdit} from '../QuickEdit'; +import type {TestIdBuilder} from 'amis-core'; + /** * Table 表格2渲染器。 * 文档:https://aisuda.bce.baidu.com/amis/zh-CN/components/table2 @@ -877,7 +879,8 @@ export default class Table2 extends React.Component { itemBadge, data, classnames: cx, - env + env, + testIdBuilder } = this.props; const cols: Array = []; @@ -950,6 +953,9 @@ export default class Table2 extends React.Component { const item = store.getRowByIndex(rowIndex, [...(levels || [])]) || {}; + const itemIDBuilder = testIdBuilder?.getChild( + `row-${rowIndex}-cell-${colIndex}` + ); const obj = { children: this.renderCellSchema(column, { @@ -982,7 +988,8 @@ export default class Table2 extends React.Component { }, row: item, showBadge, - itemBadge + itemBadge, + testIdBuilder: itemIDBuilder }), props }; From b48173a314f4eae55c607d2f5c2ceb00f5a75ac2 Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Tue, 23 Apr 2024 19:51:07 +0800 Subject: [PATCH 22/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E7=BC=96=E8=BE=91=E5=B5=8C=E5=A5=97=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#10089)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../amis-editor/examples/component/Doc.tsx | 1 - .../event-control/DialogActionPanel.tsx | 98 ++++++++++++++----- 2 files changed, 73 insertions(+), 26 deletions(-) diff --git a/packages/amis-editor/examples/component/Doc.tsx b/packages/amis-editor/examples/component/Doc.tsx index 03d6e59a6..2d4a02a0a 100644 --- a/packages/amis-editor/examples/component/Doc.tsx +++ b/packages/amis-editor/examples/component/Doc.tsx @@ -13,7 +13,6 @@ export interface DocProps { export function mdComment(fun: Function) { const txt = fun.toString(); - debugger; return txt; } diff --git a/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx b/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx index b7c3302bc..289cf2ca4 100644 --- a/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx +++ b/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx @@ -12,7 +12,7 @@ import { } from 'amis-editor-core'; import React from 'react'; import {observer} from 'mobx-react'; -import {JSONTraverse, JSONValueMap, RendererProps} from 'amis-core'; +import {JSONTraverse, JSONValueMap, RendererProps, guid} from 'amis-core'; import { Button, FormField, @@ -41,6 +41,9 @@ export interface LocalModal { isNew?: boolean; isModified?: boolean; isActive?: boolean; + + // 是否被引用 + isRefered?: boolean; // 是否为当前动作内嵌的弹窗 isCurrentActionModal?: boolean; @@ -104,16 +107,33 @@ function DialogActionPanel({ .filter( item => item.isModified && item !== currentModal && item.modal.$$ref ) - .forEach(({modal}) => { + .forEach(({modal, isRefered}) => { const {$$originId: originId, ...def} = modal as any; if (originId) { const parent = JSONGetParentById(schema, originId); - if (!parent) { + if (id === originId) { + return; + } else if (!parent) { // 找不到就丢回去,上层去处理 def.$$originId = originId; + } else if (isRefered === false) { + const modalType = def.type === 'drawer' ? 'drawer' : 'dialog'; + schema = JSONUpdate(schema, parent.$$id, { + ...parent, + __actionModals: undefined, + args: undefined, + dialog: undefined, + drawer: undefined, + actionType: def.actionType ?? modalType, + [modalType]: JSONPipeIn({ + ...modal, + $$originId: undefined, + $$ref: undefined + }) + }); + // 不要写下面的 defintions 了 + return; } else { - // TODO 这里要不要再加个判断? - // 只更新当前动作中关联的弹窗? const modalType = def.type === 'drawer' ? 'drawer' : 'dialog'; schema = JSONUpdate(schema, parent.$$id, { ...parent, @@ -196,6 +216,8 @@ function DialogActionPanel({ // 然后都引用这个 definition let refKey: string = ''; [schema, refKey] = addModal(schema, currentModal.modal); + // 需要记录原始的弹窗 id,方便上层处理合并 + schema.definitions[refKey].$$originId = currentModal.modal.$$id; newActionSchema = { ...actionSchema, __actionModals: undefined, @@ -235,6 +257,30 @@ function DialogActionPanel({ }); } + // 如果弹窗里面又弹窗指向自己,那么也要更新 + const currentModalId = currentModal.modal.$$id; + let refIds: string[] = []; + JSONTraverse(currentModal.modal, (value: any, key: string, host: any) => { + if (key === '$ref' && host.$$originId === currentModalId) { + refIds.push(host.$$id); + } + }); + if (refIds.length) { + let refKey = ''; + [schema, refKey] = addModal(schema, currentModal.modal); + schema = JSONUpdate(schema, actionSchema.$$id, { + [modalType]: JSONPipeIn({ + $ref: refKey + }) + }); + refIds.forEach(refId => { + schema = JSONUpdate(schema, refId, { + $ref: refKey, + $$originId: undefined + }); + }); + } + // 原来的动作也要更新 if (originActionId && newRefName) { schema = JSONUpdate( @@ -419,11 +465,6 @@ function DialogActionPanel({ let arr = members; Object.keys(definitions).forEach(key => { - // 弹窗里面用到了才更新 - if (!refs.includes(key)) { - return; - } - // 要修改就复制一份,避免污染原始数据 if (arr === members) { arr = members.concat(); @@ -431,7 +472,9 @@ function DialogActionPanel({ const {$$originId, ...modal} = definitions[key]; const idx = arr.findIndex(item => - $$originId ? item.value === $$originId : item.modal.$$ref === key + $$originId + ? (item.modal.$$originId || item.modal.$$id) === $$originId + : item.modal.$$ref === key ); const label = `${ modal.editorSetting?.displayName || modal.title || '未命名弹窗' @@ -449,9 +492,10 @@ function DialogActionPanel({ label: label, tip: tip, modal: {...modal, $$ref: key, $$originId}, - isModified: true + isModified: true, + isRefered: refs.includes(key) }); - } else { + } else if (refs.includes(key)) { if ($$originId) { throw new Error('Definition merge exception'); } @@ -481,21 +525,25 @@ function DialogActionPanel({ skipForm?: boolean, closePopOver?: () => void ) => { + const modal = { + $$id: guid(), + type: 'dialog', + title: '未命名弹窗', + body: [ + { + type: 'tpl', + tpl: '弹窗内容' + } + ], + definitions: modalsToDefinitions(modals.map(item => item.modal)) + }; + const modalId = modal.$$id; manager.openSubEditor({ title: '新建弹窗', - value: { - type: 'dialog', - title: '未命名弹窗', - body: [ - { - type: 'tpl', - tpl: '弹窗内容' - } - ], - definitions: modalsToDefinitions(modals.map(item => item.modal)) - }, + value: modal, onChange: ({definitions, ...modal}: any, diff: any) => { - modal = JSONPipeIn(modal); + // 不能变 $$id 如果有内部有引用,就找不到了 + modal = JSONPipeIn({...modal, $$id: modalId}); let arr = modals.concat(); if (!arr.some(item => item.isNew)) { arr.push({ From ffe15c573585d17c2d809d6cca6bb5ab2a6a9829 Mon Sep 17 00:00:00 2001 From: yupeng12 Date: Wed, 24 Apr 2024 14:56:20 +0800 Subject: [PATCH 23/46] =?UTF-8?q?feat:=20CRUD2=20head=20=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=94=AF=E6=8C=81testid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-ui/src/components/icons.tsx | 7 ++++- .../amis-ui/src/components/table/Head.tsx | 14 ++++++++- .../src/components/table/HeadCellDropDown.tsx | 3 ++ .../src/components/table/HeadCellFilter.tsx | 10 ++++++- .../src/components/table/HeadCellSort.tsx | 14 +++++++-- .../amis-ui/src/components/table/index.tsx | 5 +++- .../Table2/HeadCellSearchDropdown.tsx | 30 +++++++++++++++---- packages/amis/src/renderers/Table2/index.tsx | 1 + 8 files changed, 72 insertions(+), 12 deletions(-) diff --git a/packages/amis-ui/src/components/icons.tsx b/packages/amis-ui/src/components/icons.tsx index 018ed2cbd..2a6b1e3b8 100644 --- a/packages/amis-ui/src/components/icons.tsx +++ b/packages/amis-ui/src/components/icons.tsx @@ -110,6 +110,7 @@ import ScaleOrigin from '../icons/scale-origin.svg'; import If from '../icons/if.svg'; import isObject from 'lodash/isObject'; +import type {TestIdBuilder} from 'amis-core'; // 兼容原来的用法,后续不直接试用。 @@ -284,10 +285,12 @@ export function Icon({ onTouchMove, onTouchEnd, onTouchCancel, - style + style, + testIdBuilder }: { icon: string; iconContent?: string; + testIdBuilder?: TestIdBuilder; } & React.ComponentProps) { let cx = iconCx || cxClass; @@ -356,6 +359,7 @@ export function Icon({ className={cx(iconContent, className, classNameProp)} ref={refFn} style={style} + {...testIdBuilder?.getTestId()} >
); } @@ -370,6 +374,7 @@ export function Icon({ // @ts-ignore icon={icon} style={style} + {...testIdBuilder?.getTestId()} /> ); } diff --git a/packages/amis-ui/src/components/table/Head.tsx b/packages/amis-ui/src/components/table/Head.tsx index afa96bf4b..e751f8f97 100644 --- a/packages/amis-ui/src/components/table/Head.tsx +++ b/packages/amis-ui/src/components/table/Head.tsx @@ -23,6 +23,7 @@ import Cell from './Cell'; import HeadCellSort from './HeadCellSort'; import HeadCellFilter from './HeadCellFilter'; import HeadCellSelect from './HeadCellSelect'; +import type {TestIdBuilder} from 'amis-core'; export interface Props extends ThemeProps { draggable: boolean; @@ -48,6 +49,7 @@ export interface Props extends ThemeProps { onSelectAll: Function; onFilter?: Function; onResizeMouseDown: Function; + testIdBuilder?: TestIdBuilder; } export default class Head extends React.PureComponent { @@ -121,7 +123,8 @@ export default class Head extends React.PureComponent { onSort, onSelectAll, onFilter, - onResizeMouseDown + onResizeMouseDown, + testIdBuilder } = this.props; const {thColumns, tdColumns} = getBuildColumns(columns); @@ -177,6 +180,7 @@ export default class Head extends React.PureComponent { col="drag" classnames={cx} classPrefix={classPrefix} + testIdBuilder={testIdBuilder?.getChild(`drag-${index}`)} > ) : null} {!draggable && selectable && index === 0 ? ( @@ -189,6 +193,7 @@ export default class Head extends React.PureComponent { col="select" classnames={cx} classPrefix={classPrefix} + testIdBuilder={testIdBuilder?.getChild(`select-${index}`)} > {rowSelectionType !== 'radio' ? [ @@ -234,6 +239,9 @@ export default class Head extends React.PureComponent { onSort={(payload: SortProps) => { onSort && onSort(payload, item); }} + testIdBuilder={testIdBuilder?.getChild( + `sort-${colIndex}` + )} > ); } @@ -247,6 +255,9 @@ export default class Head extends React.PureComponent { column={item} popOverContainer={popOverContainer} onFilter={onFilter} + testIdBuilder={testIdBuilder?.getChild( + `filter-${colIndex}` + )} > ); } @@ -301,6 +312,7 @@ export default class Head extends React.PureComponent { })} depth={item.depth} col={String(colIndex)} + testIdBuilder={testIdBuilder?.getChild(`cell-${colIndex}`)} > {typeof item.title === 'function' ? item.title(children) diff --git a/packages/amis-ui/src/components/table/HeadCellDropDown.tsx b/packages/amis-ui/src/components/table/HeadCellDropDown.tsx index 575c5ef5f..85e91a4d4 100644 --- a/packages/amis-ui/src/components/table/HeadCellDropDown.tsx +++ b/packages/amis-ui/src/components/table/HeadCellDropDown.tsx @@ -16,6 +16,8 @@ import { PopOver } from 'amis-core'; +import type {TestIdBuilder} from 'amis-core'; + export interface FilterPayload { closeDropdown?: boolean; } @@ -38,6 +40,7 @@ export interface Props extends ThemeProps, LocaleProps { setSelectedKeys?: (keys: Array | string) => void; classnames: ClassNamesFn; classPrefix: string; + testIdBuilder?: TestIdBuilder; } export interface State { diff --git a/packages/amis-ui/src/components/table/HeadCellFilter.tsx b/packages/amis-ui/src/components/table/HeadCellFilter.tsx index 4b5aaa35a..22af4904f 100644 --- a/packages/amis-ui/src/components/table/HeadCellFilter.tsx +++ b/packages/amis-ui/src/components/table/HeadCellFilter.tsx @@ -21,6 +21,7 @@ import HeadCellDropDown, { import CheckBox from '../Checkbox'; import Button from '../Button'; import {Icon} from '../icons'; +import type {TestIdBuilder} from 'amis-core'; export interface Props extends ThemeProps, LocaleProps { column: any; @@ -30,6 +31,7 @@ export interface Props extends ThemeProps, LocaleProps { popOverContainer?: () => HTMLElement; classnames: ClassNamesFn; classPrefix: string; + testIdBuilder?: TestIdBuilder; } export interface OptionProps { @@ -92,7 +94,8 @@ export class HeadCellFilter extends React.PureComponent { column, popOverContainer, classnames: cx, - classPrefix: ns + classPrefix: ns, + testIdBuilder } = this.props; const filterProps = { @@ -110,6 +113,7 @@ export class HeadCellFilter extends React.PureComponent { onClick={() => this.handleClick(confirm, setSelectedKeys, [option.value]) } + {...testIdBuilder?.getChild(`${index}`).getTestId()} > {option.text} @@ -126,6 +130,7 @@ export class HeadCellFilter extends React.PureComponent { ) } checked={option.selected} + testIdBuilder={testIdBuilder?.getChild(`ckbx-${index}`)} > {option.text} @@ -140,6 +145,7 @@ export class HeadCellFilter extends React.PureComponent { size={'xs'} level={'primary'} onClick={() => this.handleConfirmClick(confirm)} + testIdBuilder={testIdBuilder?.getChild(`btn-confirm`)} > 确定 @@ -148,6 +154,7 @@ export class HeadCellFilter extends React.PureComponent { onClick={() => this.handleCancelClick(confirm, setSelectedKeys) } + testIdBuilder={testIdBuilder?.getChild(`btn-cancel`)} > 取消 @@ -169,6 +176,7 @@ export class HeadCellFilter extends React.PureComponent { icon="column-filter" className="icon" iconContent="table-filter-icon" + testIdBuilder={testIdBuilder?.getChild(`icon`)} /> } active={ diff --git a/packages/amis-ui/src/components/table/HeadCellSort.tsx b/packages/amis-ui/src/components/table/HeadCellSort.tsx index f84e6ec8f..0a4bcfb45 100644 --- a/packages/amis-ui/src/components/table/HeadCellSort.tsx +++ b/packages/amis-ui/src/components/table/HeadCellSort.tsx @@ -14,12 +14,14 @@ import { } from 'amis-core'; import {Icon} from '../icons'; import {ColumnProps} from './index'; +import type {TestIdBuilder} from 'amis-core'; export interface Props extends ThemeProps, LocaleProps { column: ColumnProps; onSort?: (payload: {orderBy: string; orderDir: string}) => any; active?: boolean; classnames: ClassNamesFn; + testIdBuilder?: TestIdBuilder; } export interface State { @@ -50,11 +52,12 @@ export class HeadCellSort extends React.PureComponent { } render() { - const {active, column, onSort, classnames: cx} = this.props; + const {active, column, onSort, classnames: cx, testIdBuilder} = this.props; return ( { let sortPayload: State = { orderBy: '', @@ -97,6 +100,7 @@ export class HeadCellSort extends React.PureComponent { icon="sort-desc" className="icon" iconContent="table-sort-down" + testIdBuilder={testIdBuilder?.getChild('desc')} /> { active && this.state.orderDir === 'asc' ? 'is-active' : '' )} > - + { icon="sort-default" className="icon" iconContent="table-sort-default" + testIdBuilder={testIdBuilder?.getChild('default')} /> diff --git a/packages/amis-ui/src/components/table/index.tsx b/packages/amis-ui/src/components/table/index.tsx index 0a5ec8ee6..8d0795e69 100644 --- a/packages/amis-ui/src/components/table/index.tsx +++ b/packages/amis-ui/src/components/table/index.tsx @@ -685,9 +685,11 @@ export class Table extends React.PureComponent { dataSource, onSort, onSelectAll, - onFilter + onFilter, + testIdBuilder } = this.props; + console.log(testIdBuilder); const rowSelectionKeyField = this.getRowSelectionKeyField(); const dataList = rowSelection && rowSelection.getCheckboxProps @@ -754,6 +756,7 @@ export class Table extends React.PureComponent { }} onFilter={onFilter} onResizeMouseDown={this.onResizeMouseDown.bind(this)} + testIdBuilder={testIdBuilder?.getChild('head')} > ); } diff --git a/packages/amis/src/renderers/Table2/HeadCellSearchDropdown.tsx b/packages/amis/src/renderers/Table2/HeadCellSearchDropdown.tsx index 56edfa56f..463406c39 100644 --- a/packages/amis/src/renderers/Table2/HeadCellSearchDropdown.tsx +++ b/packages/amis/src/renderers/Table2/HeadCellSearchDropdown.tsx @@ -46,7 +46,14 @@ export class HeadCellSearchDropDown extends React.Component< } buildSchema() { - const {searchable, sortable, name, label, translate: __} = this.props; + const { + searchable, + sortable, + name, + label, + translate: __, + testIdBuilder + } = this.props; let schema: any; @@ -58,7 +65,8 @@ export class HeadCellSearchDropDown extends React.Component< type: 'text', name, placeholder: label, - clearable: true + clearable: true, + testid: testIdBuilder?.getChild(name)?.getTestIdValue() } ] }; @@ -81,6 +89,9 @@ export class HeadCellSearchDropDown extends React.Component< { type: searchable.type || 'text', name: searchable.name || name, + testid: testIdBuilder + ?.getChild(searchable.name || name) + ?.getTestIdValue(), placeholder: label, ...searchable } @@ -132,23 +143,27 @@ export class HeadCellSearchDropDown extends React.Component< wrapperComponent: 'div', wrapWithPanel: true, title: false, + testid: testIdBuilder?.getChild('form')?.getTestIdValue(), actions: [ { type: 'button', label: __('reset'), - actionType: 'clear-and-submit' + actionType: 'clear-and-submit', + testid: testIdBuilder?.getChild('btn-reset')?.getTestIdValue() }, { type: 'button', label: __('cancel'), - actionType: 'cancel' + actionType: 'cancel', + testid: testIdBuilder?.getChild('btn-cancel')?.getTestIdValue() }, { label: __('search'), type: 'submit', - primary: true + primary: true, + testid: testIdBuilder?.getChild('btn-search')?.getTestIdValue() } ] }; @@ -242,7 +257,8 @@ export class HeadCellSearchDropDown extends React.Component< orderBy, popOverContainer, classPrefix: ns, - classnames: cx + classnames: cx, + testIdBuilder } = this.props; const formSchema = this.buildSchema(); @@ -261,6 +277,7 @@ export class HeadCellSearchDropDown extends React.Component< icon="search" className="icon" iconContent="table-search-icon" + testIdBuilder={testIdBuilder?.getChild('search-icon')} /> } popOverContainer={ @@ -284,6 +301,7 @@ export class HeadCellSearchDropDown extends React.Component< } }) as JSX.Element; }} + testIdBuilder={testIdBuilder} > ); } diff --git a/packages/amis/src/renderers/Table2/index.tsx b/packages/amis/src/renderers/Table2/index.tsx index d6c48944f..879fb7950 100644 --- a/packages/amis/src/renderers/Table2/index.tsx +++ b/packages/amis/src/renderers/Table2/index.tsx @@ -1054,6 +1054,7 @@ export default class Table2 extends React.Component { searchable={column.searchable} onSearch={this.handleSearch} key={'th-search-' + col} + testIdBuilder={testIdBuilder?.getChild(`head-search-${col}`)} /> ); } From a29b0dab556fdd42432c30ab529da059e0442863 Mon Sep 17 00:00:00 2001 From: 2betop <2betop.cn@gmail.com> Date: Wed, 24 Apr 2024 18:39:28 +0800 Subject: [PATCH 24/46] =?UTF-8?q?fix:=20revert=20#9941=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=BC=B9=E7=AA=97=E4=B8=8B=E6=9C=89=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=20form=20=E6=97=B6=E6=95=B0=E6=8D=AE=E6=B7=B7=E4=B9=B1?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-core/src/store/modal.ts | 11 ++++++++++- packages/amis/src/renderers/Dialog.tsx | 13 +++++++------ packages/amis/src/renderers/Drawer.tsx | 16 +++++++++------- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/packages/amis-core/src/store/modal.ts b/packages/amis-core/src/store/modal.ts index a61b6512a..dd193190d 100644 --- a/packages/amis-core/src/store/modal.ts +++ b/packages/amis-core/src/store/modal.ts @@ -4,12 +4,17 @@ import {createObject} from '../utils/helper'; export const ModalStore = ServiceStore.named('ModalStore') .props({ + form: types.frozen(), entered: false, resizeCoord: 0, schema: types.frozen() }) .views(self => { - return {}; + return { + get formData() { + return createObject(self.data, self.form); + } + }; }) .actions(self => { return { @@ -17,7 +22,11 @@ export const ModalStore = ServiceStore.named('ModalStore') self.entered = value; }, + setFormData(obj: any) { + self.form = obj; + }, reset() { + self.form = {}; self.reInitData({}, true); }, diff --git a/packages/amis/src/renderers/Dialog.tsx b/packages/amis/src/renderers/Dialog.tsx index a41b1b0a5..9b77ff2ce 100644 --- a/packages/amis/src/renderers/Dialog.tsx +++ b/packages/amis/src/renderers/Dialog.tsx @@ -423,7 +423,7 @@ export default class Dialog extends React.Component { handleFormInit(data: any) { const {store} = this.props; - store.updateData(data); + store.setFormData(data); } handleFormChange(data: any, name?: string) { @@ -435,13 +435,13 @@ export default class Dialog extends React.Component { return; } - store.updateData(data); + store.setFormData(data); } handleFormSaved(data: any, response: any) { const {store} = this.props; - store.updateData({ + store.setFormData({ ...data, ...response }); @@ -553,7 +553,7 @@ export default class Dialog extends React.Component { ) : null} {actions.map((action, key) => render(`action/${key}`, action, { - data: store.data, + data: store.formData, onAction: this.handleAction, key, disabled: action.disabled || store.loading || !show @@ -684,7 +684,7 @@ export default class Dialog extends React.Component { }) )} > - {filter(__(title), store.data)} + {filter(__(title), store.formData)}
) : title ? ( @@ -714,7 +714,7 @@ export default class Dialog extends React.Component { ) : null} {render('title', title, { - data: store.data, + data: store.formData, onAction: this.handleAction })} @@ -730,6 +730,7 @@ export default class Dialog extends React.Component { {header ? render('header', header, { + data: store.formData, onAction: this.handleAction }) : null} diff --git a/packages/amis/src/renderers/Drawer.tsx b/packages/amis/src/renderers/Drawer.tsx index ad566adef..1249e07bf 100644 --- a/packages/amis/src/renderers/Drawer.tsx +++ b/packages/amis/src/renderers/Drawer.tsx @@ -423,25 +423,24 @@ export default class Drawer extends React.Component { handleFormInit(data: any) { const {store} = this.props; - store.updateData(data); + store.setFormData(data); } handleFormChange(data: any, name?: string) { const {store} = this.props; + // 如果 drawer 里面不放 form,而是直接放表单项就会进到这里来。 if (typeof name === 'string') { - data = { - [name]: data - }; + store.changeValue(name, data); + return; } - - store.updateData(data); + store.setFormData(data); } handleFormSaved(data: any, response: any) { const {store} = this.props; - store.updateData({ + store.setFormData({ ...data, ...response }); @@ -551,6 +550,7 @@ export default class Drawer extends React.Component { {actions.map((action, key) => render(`action/${key}`, action, { onAction: this.handleAction, + data: store.formData, key, disabled: action.disabled || store.loading }) @@ -681,6 +681,7 @@ export default class Drawer extends React.Component { )} > {render('title', title, { + data: store.formData, onConfirm: this.handleDrawerConfirm, onClose: this.handleDrawerClose, onAction: this.handleAction @@ -689,6 +690,7 @@ export default class Drawer extends React.Component { ) : null} {header ? render('header', header, { + data: store.formData, onConfirm: this.handleDrawerConfirm, onClose: this.handleDrawerClose, onAction: this.handleAction From 5fefed787cb19ff2cda1608ca17ce76d84ff8d6f Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Wed, 24 Apr 2024 19:40:37 +0800 Subject: [PATCH 25/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=86=85=E5=B5=8C=E5=BC=B9=E7=AA=97=E4=B8=AD=E5=86=85?= =?UTF-8?q?=E5=B5=8C=E5=BC=B9=E7=AA=97=E5=A4=B1=E6=95=88=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#10100)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-editor-core/scss/_outline.scss | 2 + packages/amis-editor-core/src/util.ts | 29 ++++++++------ .../event-control/DialogActionPanel.tsx | 40 ++++++++++++------- 3 files changed, 45 insertions(+), 26 deletions(-) diff --git a/packages/amis-editor-core/scss/_outline.scss b/packages/amis-editor-core/scss/_outline.scss index 947fddc28..537789855 100644 --- a/packages/amis-editor-core/scss/_outline.scss +++ b/packages/amis-editor-core/scss/_outline.scss @@ -253,6 +253,8 @@ > span { flex: 1; min-width: 0; + overflow: hidden; + text-overflow: ellipsis; } a.ae-DialogList-iconBtn { diff --git a/packages/amis-editor-core/src/util.ts b/packages/amis-editor-core/src/util.ts index 725c0c18b..4724e2569 100644 --- a/packages/amis-editor-core/src/util.ts +++ b/packages/amis-editor-core/src/util.ts @@ -1543,18 +1543,23 @@ export function mergeDefinitions( } else if (parent) { // 没用到,可能修改了弹窗的内容为引用其他弹窗,同样需要更新,但是不会提取为 definitions const modalType = def.type === 'drawer' ? 'drawer' : 'dialog'; - schema = JSONUpdate(schema, parent.$$id, { - ...parent, - __actionModals: undefined, - args: undefined, - dialog: undefined, - drawer: undefined, - actionType: def.actionType ?? modalType, - [modalType]: JSONPipeIn({ - ...def, - $$originId: undefined - }) - }); + const origin = parent[modalType] || {}; + + // 这样处理是为了不要修改原来的 $$id + const changes = diff(origin, def, (path, key) => key === '$$id'); + if (changes) { + const newModal = patchDiff(origin, changes); + delete newModal.$$originId; + schema = JSONUpdate(schema, parent.$$id, { + ...parent, + __actionModals: undefined, + args: undefined, + dialog: undefined, + drawer: undefined, + actionType: def.actionType ?? modalType, + [modalType]: newModal + }); + } } } else if (refs.includes(key)) { schema.definitions[key] = JSONPipeIn(def); diff --git a/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx b/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx index 289cf2ca4..7643d595b 100644 --- a/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx +++ b/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx @@ -7,8 +7,10 @@ import { JSONPipeOut, JSONUpdate, addModal, + diff, getVariables, - modalsToDefinitions + modalsToDefinitions, + patchDiff } from 'amis-editor-core'; import React from 'react'; import {observer} from 'mobx-react'; @@ -118,19 +120,29 @@ function DialogActionPanel({ def.$$originId = originId; } else if (isRefered === false) { const modalType = def.type === 'drawer' ? 'drawer' : 'dialog'; - schema = JSONUpdate(schema, parent.$$id, { - ...parent, - __actionModals: undefined, - args: undefined, - dialog: undefined, - drawer: undefined, - actionType: def.actionType ?? modalType, - [modalType]: JSONPipeIn({ - ...modal, - $$originId: undefined, - $$ref: undefined - }) - }); + + // 这样处理是为了不要修改原来的 $$id + const origin = parent[modalType] || {}; + const changes = diff( + origin, + modal, + (path, key) => key === '$$id' + ); + if (changes) { + const newModal = patchDiff(origin, changes); + delete newModal.$$originId; + delete newModal.$$ref; + schema = JSONUpdate(schema, parent.$$id, { + ...parent, + __actionModals: undefined, + args: undefined, + dialog: undefined, + drawer: undefined, + actionType: def.actionType ?? modalType, + [modalType]: newModal + }); + } + // 不要写下面的 defintions 了 return; } else { From 6279ca0c0e2c2cc4de6e7868948b716760df8afc Mon Sep 17 00:00:00 2001 From: lvxiaojiao Date: Wed, 24 Apr 2024 16:11:09 +0800 Subject: [PATCH 26/46] =?UTF-8?q?fix:=E5=88=B7=E6=96=B0crud=E6=9C=AA?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E5=88=87=E5=88=B7=E6=96=B0service=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis/src/renderers/CRUD.tsx | 3 ++- packages/amis/src/renderers/CRUD2.tsx | 3 ++- packages/amis/src/renderers/Cards.tsx | 17 ++++++----------- packages/amis/src/renderers/List.tsx | 18 ++++++------------ packages/amis/src/renderers/Table/index.tsx | 18 ++++++------------ packages/amis/src/renderers/Table2/index.tsx | 17 ++++++----------- 6 files changed, 28 insertions(+), 48 deletions(-) diff --git a/packages/amis/src/renderers/CRUD.tsx b/packages/amis/src/renderers/CRUD.tsx index 891a58002..a62dbfd83 100644 --- a/packages/amis/src/renderers/CRUD.tsx +++ b/packages/amis/src/renderers/CRUD.tsx @@ -2762,7 +2762,8 @@ export default class CRUD extends React.Component { headerToolbarRender: this.renderHeaderToolbar, footerToolbarRender: this.renderFooterToolbar, data: store.mergedData, - loading: store.loading + loading: store.loading, + host: this } )} {render( diff --git a/packages/amis/src/renderers/CRUD2.tsx b/packages/amis/src/renderers/CRUD2.tsx index 78c521d42..bb56f972a 100644 --- a/packages/amis/src/renderers/CRUD2.tsx +++ b/packages/amis/src/renderers/CRUD2.tsx @@ -1381,7 +1381,8 @@ export default class CRUD2 extends React.Component { onSort: this.handleQuerySearch, onSelect: this.handleSelect, data: store.mergedData, - loading: store.loading + loading: store.loading, + host: this } )} {/* spinner可以交给孩子处理 */} diff --git a/packages/amis/src/renderers/Cards.tsx b/packages/amis/src/renderers/Cards.tsx index 2b771f07b..917fa9a7a 100644 --- a/packages/amis/src/renderers/Cards.tsx +++ b/packages/amis/src/renderers/Cards.tsx @@ -1123,11 +1123,9 @@ export class CardsRenderer extends Cards { * 因为Cards在scope上注册,导致getComponentByName查询组件时会优先找到Cards,和CRUD联动的动作都会失效 * 这里先做兼容处理,把动作交给上层的CRUD处理 */ - if (Array.isArray(parents) && parents.length) { - // CRUD的name会透传给Cards,这样可以保证找到CRUD - const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name); - - return crud?.receive?.(values, subPath); + if (this.props?.host) { + // CRUD会把自己透传给Cards,这样可以保证找到CRUD + return this.props.host.receive?.(values, subPath); } if (subPath) { @@ -1151,13 +1149,10 @@ export class CardsRenderer extends Cards { } const scoped = this.context as IScopedContext; - const parents = scoped?.parent?.getComponents(); - if (Array.isArray(parents) && parents.length) { - // CRUD的name会透传给Cards,这样可以保证找到CRUD - const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name); - - return crud?.reload?.(subPath, query, ctx); + if (this.props?.host) { + // CRUD会把自己透传给Cards,这样可以保证找到CRUD + return this.props.host.reload?.(subPath, query, ctx); } if (subPath) { diff --git a/packages/amis/src/renderers/List.tsx b/packages/amis/src/renderers/List.tsx index ad3be5e71..94bcd15df 100644 --- a/packages/amis/src/renderers/List.tsx +++ b/packages/amis/src/renderers/List.tsx @@ -1112,17 +1112,14 @@ export class ListRenderer extends List { receive(values: any, subPath?: string) { const scoped = this.context as IScopedContext; - const parents = scoped?.parent?.getComponents(); /** * 因为List在scope上注册,导致getComponentByName查询组件时会优先找到List,和CRUD联动的动作都会失效 * 这里先做兼容处理,把动作交给上层的CRUD处理 */ - if (Array.isArray(parents) && parents.length) { - // CRUD的name会透传给List,这样可以保证找到CRUD - const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name); - - return crud?.receive?.(values, subPath); + if (this.props?.host) { + // CRUD会把自己透传给List,这样可以保证找到CRUD + return this.props.host.receive?.(values, subPath); } if (subPath) { @@ -1146,13 +1143,10 @@ export class ListRenderer extends List { } const scoped = this.context as IScopedContext; - const parents = scoped?.parent?.getComponents(); - if (Array.isArray(parents) && parents.length) { - // CRUD的name会透传给List,这样可以保证找到CRUD - const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name); - - return crud?.reload?.(subPath, query, ctx); + if (this.props?.host) { + // CRUD会把自己透传给List,这样可以保证找到CRUD + return this.props?.host.reload?.(subPath, query, ctx); } if (subPath) { diff --git a/packages/amis/src/renderers/Table/index.tsx b/packages/amis/src/renderers/Table/index.tsx index 460865372..55a8c54ac 100644 --- a/packages/amis/src/renderers/Table/index.tsx +++ b/packages/amis/src/renderers/Table/index.tsx @@ -2842,17 +2842,14 @@ export default class Table extends React.Component { export class TableRenderer extends Table { receive(values: any, subPath?: string) { const scoped = this.context as IScopedContext; - const parents = scoped?.parent?.getComponents(); /** * 因为Table在scope上注册,导致getComponentByName查询组件时会优先找到Table,和CRUD联动的动作都会失效 * 这里先做兼容处理,把动作交给上层的CRUD处理 */ - if (Array.isArray(parents) && parents.length) { - // CRUD的name会透传给Table,这样可以保证找到CRUD - const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name); - - return crud?.receive?.(values, subPath); + if (this.props?.host) { + // CRUD会把自己透传给Table,这样可以保证找到CRUD + return this.props.host.receive?.(values, subPath); } if (subPath) { @@ -2904,13 +2901,10 @@ export class TableRenderer extends Table { } const scoped = this.context as IScopedContext; - const parents = scoped?.parent?.getComponents(); - if (Array.isArray(parents) && parents.length) { - // CRUD的name会透传给Table,这样可以保证找到CRUD - const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name); - - return crud?.reload?.(subPath, query, ctx); + if (this.props?.host) { + // CRUD会把自己透传给Table,这样可以保证找到CRUD + return this.props.host.reload?.(subPath, query, ctx); } if (subPath) { diff --git a/packages/amis/src/renderers/Table2/index.tsx b/packages/amis/src/renderers/Table2/index.tsx index 879fb7950..9b0c7063d 100644 --- a/packages/amis/src/renderers/Table2/index.tsx +++ b/packages/amis/src/renderers/Table2/index.tsx @@ -2131,17 +2131,14 @@ export default class Table2 extends React.Component { export class TableRenderer extends Table2 { receive(values: any, subPath?: string) { const scoped = this.context as IScopedContext; - const parents = scoped?.parent?.getComponents(); /** * 因为Table在scope上注册,导致getComponentByName查询组件时会优先找到Table,和CRUD联动的动作都会失效 * 这里先做兼容处理,把动作交给上层的CRUD处理 */ - if (Array.isArray(parents) && parents.length) { - // CRUD的name会透传给Table,这样可以保证找到CRUD - const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name); - - return crud?.receive?.(values, subPath); + if (this.props?.host) { + // CRUD会把自己透传给Table,这样可以保证找到CRUD + return this.props.host.receive?.(values, subPath); } if (subPath) { @@ -2153,11 +2150,9 @@ export class TableRenderer extends Table2 { const scoped = this.context as IScopedContext; const parents = scoped?.parent?.getComponents(); - if (Array.isArray(parents) && parents.length) { - // CRUD的name会透传给Table,这样可以保证找到CRUD - const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name); - - return crud?.reload?.(subPath, query, ctx); + if (this.props?.host) { + // CRUD会把自己透传给Table,这样可以保证找到CRUD + return this.props.host.reload?.(subPath, query, ctx); } if (subPath) { From 759d4534d9ddbe7bc2758c3ffb07c0679e084461 Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Wed, 24 Apr 2024 21:42:04 +0800 Subject: [PATCH 27/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E4=BF=AE=E6=94=B9=E6=97=A0=E6=B3=95=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=9A=84=E9=97=AE=E9=A2=98=20(#10102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-editor-core/src/store/editor.ts | 87 ++++++++++++------ packages/amis-editor-core/src/util.ts | 52 ++++++----- .../event-control/DialogActionPanel.tsx | 91 ++++++++++++------- 3 files changed, 147 insertions(+), 83 deletions(-) diff --git a/packages/amis-editor-core/src/store/editor.ts b/packages/amis-editor-core/src/store/editor.ts index db01dda07..3af09017d 100644 --- a/packages/amis-editor-core/src/store/editor.ts +++ b/packages/amis-editor-core/src/store/editor.ts @@ -553,18 +553,27 @@ export const MainStore = types } const isSubEditor = self.isSubEditor; + const isHiddenProps = getEnv(self).isHiddenProps; return JSONPipeOut( JSONGetById(self.schema, self.activeId), - getEnv(self).isHiddenProps || - ((key, props) => - // 如果是子弹窗,不显示 definitions,要是通过代码模式改了,就麻烦了 - (isSubEditor && key === 'definitions') || + (key, props) => { + if (isSubEditor && key === 'definitions') { + return true; + } + + if (typeof isHiddenProps === 'function') { + return isHiddenProps(key, props); + } + + return ( (key.substring(0, 2) === '$$' && key !== '$$comments' && key !== '$$commonSchema') || typeof props === 'function' || // pipeIn 和 pipeOut - key.substring(0, 2) === '__') + key.substring(0, 2) === '__' + ); + } ); }, @@ -1812,7 +1821,7 @@ export const MainStore = types ? 'drawer' : 'dialog'; - schema = JSONUpdate(schema, id, modal); + schema = JSONUpdate(schema, id, modal, true); // 如果编辑的是公共弹窗 if (!parent.actionType) { @@ -1829,25 +1838,35 @@ export const MainStore = types modalKey && newHostKey !== (value === 'drawer' ? 'drawer' : 'dialog') ) { - schema = JSONUpdate(schema, host.$$id, { - actionType: (modal as any).actionType || modal.type, - args: undefined, - dialog: undefined, - drawer: undefined, - [newHostKey]: host[value === 'drawer' ? 'drawer' : 'dialog'] - }); + schema = JSONUpdate( + schema, + host.$$id, + { + actionType: (modal as any).actionType || modal.type, + args: undefined, + dialog: undefined, + drawer: undefined, + [newHostKey]: host[value === 'drawer' ? 'drawer' : 'dialog'] + }, + true + ); } return value; }); } else { // 内嵌弹窗只用改自己就行了 - schema = JSONUpdate(schema, parent.$$id, { - actionType: (modal as any).actionType || modal.type, - args: undefined, - dialog: undefined, - drawer: undefined, - [newHostKey]: modal - }); + schema = JSONUpdate( + schema, + parent.$$id, + { + actionType: (modal as any).actionType || modal.type, + args: undefined, + dialog: undefined, + drawer: undefined, + [newHostKey]: modal + }, + true + ); } // 如果弹窗里面又弹窗指向自己,那么也要更新 @@ -1860,16 +1879,26 @@ export const MainStore = types if (refIds.length) { let refKey = ''; [schema, refKey] = addModal(schema, modal); - schema = JSONUpdate(schema, parent.$$id, { - [newHostKey]: JSONPipeIn({ - $ref: refKey - }) - }); + schema = JSONUpdate( + schema, + parent.$$id, + { + [newHostKey]: JSONPipeIn({ + $ref: refKey + }) + }, + true + ); refIds.forEach(refId => { - schema = JSONUpdate(schema, refId, { - $ref: refKey, - $$originId: undefined - }); + schema = JSONUpdate( + schema, + refId, + { + $ref: refKey, + $$originId: undefined + }, + true + ); }); } diff --git a/packages/amis-editor-core/src/util.ts b/packages/amis-editor-core/src/util.ts index 4724e2569..36551414d 100644 --- a/packages/amis-editor-core/src/util.ts +++ b/packages/amis-editor-core/src/util.ts @@ -1519,7 +1519,7 @@ export function mergeDefinitions( // 当前更新弹窗里面用到了需要转成 ref if (refs.includes(key)) { if (schema.$$id === $$originId) { - schema = JSONUpdate(schema, $$originId, JSONPipeIn(def)); + schema = JSONUpdate(schema, $$originId, JSONPipeIn(def), true); return; } @@ -1528,17 +1528,22 @@ export function mergeDefinitions( } const modalType = def.type === 'drawer' ? 'drawer' : 'dialog'; - schema = JSONUpdate(schema, parent.$$id, { - ...parent, - __actionModals: undefined, - args: undefined, - dialog: undefined, - drawer: undefined, - actionType: def.actionType ?? modalType, - [modalType]: JSONPipeIn({ - $ref: key - }) - }); + schema = JSONUpdate( + schema, + parent.$$id, + { + ...parent, + __actionModals: undefined, + args: undefined, + dialog: undefined, + drawer: undefined, + actionType: def.actionType ?? modalType, + [modalType]: JSONPipeIn({ + $ref: key + }) + }, + true + ); schema.definitions[key] = JSONPipeIn(def); } else if (parent) { // 没用到,可能修改了弹窗的内容为引用其他弹窗,同样需要更新,但是不会提取为 definitions @@ -1550,15 +1555,20 @@ export function mergeDefinitions( if (changes) { const newModal = patchDiff(origin, changes); delete newModal.$$originId; - schema = JSONUpdate(schema, parent.$$id, { - ...parent, - __actionModals: undefined, - args: undefined, - dialog: undefined, - drawer: undefined, - actionType: def.actionType ?? modalType, - [modalType]: newModal - }); + schema = JSONUpdate( + schema, + parent.$$id, + { + ...parent, + __actionModals: undefined, + args: undefined, + dialog: undefined, + drawer: undefined, + actionType: def.actionType ?? modalType, + [modalType]: newModal + }, + true + ); } } } else if (refs.includes(key)) { diff --git a/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx b/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx index 7643d595b..36aa81e60 100644 --- a/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx +++ b/packages/amis-editor/src/renderer/event-control/DialogActionPanel.tsx @@ -132,32 +132,42 @@ function DialogActionPanel({ const newModal = patchDiff(origin, changes); delete newModal.$$originId; delete newModal.$$ref; - schema = JSONUpdate(schema, parent.$$id, { - ...parent, - __actionModals: undefined, - args: undefined, - dialog: undefined, - drawer: undefined, - actionType: def.actionType ?? modalType, - [modalType]: newModal - }); + schema = JSONUpdate( + schema, + parent.$$id, + { + ...parent, + __actionModals: undefined, + args: undefined, + dialog: undefined, + drawer: undefined, + actionType: def.actionType ?? modalType, + [modalType]: newModal + }, + true + ); } // 不要写下面的 defintions 了 return; } else { const modalType = def.type === 'drawer' ? 'drawer' : 'dialog'; - schema = JSONUpdate(schema, parent.$$id, { - ...parent, - __actionModals: undefined, - args: undefined, - dialog: undefined, - drawer: undefined, - actionType: def.actionType ?? modalType, - [modalType]: JSONPipeIn({ - $ref: modal.$$ref! - }) - }); + schema = JSONUpdate( + schema, + parent.$$id, + { + ...parent, + __actionModals: undefined, + args: undefined, + dialog: undefined, + drawer: undefined, + actionType: def.actionType ?? modalType, + [modalType]: JSONPipeIn({ + $ref: modal.$$ref! + }) + }, + true + ); } } schema.definitions[modal.$$ref!] = JSONPipeIn(def); @@ -261,10 +271,15 @@ function DialogActionPanel({ const definition = schema.definitions[key]; const exits = JSONGetById(definition, id); if (exits) { - schema.definitions[key] = JSONUpdate(schema.definitions[key], id, { - ...schema, - definitions: undefined - }); + schema.definitions[key] = JSONUpdate( + schema.definitions[key], + id, + { + ...schema, + definitions: undefined + }, + true + ); } }); } @@ -280,16 +295,26 @@ function DialogActionPanel({ if (refIds.length) { let refKey = ''; [schema, refKey] = addModal(schema, currentModal.modal); - schema = JSONUpdate(schema, actionSchema.$$id, { - [modalType]: JSONPipeIn({ - $ref: refKey - }) - }); + schema = JSONUpdate( + schema, + actionSchema.$$id, + { + [modalType]: JSONPipeIn({ + $ref: refKey + }) + }, + true + ); refIds.forEach(refId => { - schema = JSONUpdate(schema, refId, { - $ref: refKey, - $$originId: undefined - }); + schema = JSONUpdate( + schema, + refId, + { + $ref: refKey, + $$originId: undefined + }, + true + ); }); } From 285638248dca10dd94056f1c38c76dc98e3f85e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=A4=9A=E7=9B=8A?= Date: Thu, 25 Apr 2024 10:32:54 +0800 Subject: [PATCH 28/46] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=20github=20wo?= =?UTF-8?q?rkflow=EF=BC=8C=E6=8B=86=E5=88=86=E7=B2=92=E5=BA=A6=E6=96=B9?= =?UTF-8?q?=E4=BE=BF=E5=AE=9A=E4=BD=8D=E9=97=AE=E9=A2=98=20(#10071)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gh-pages.yml | 2 +- .github/workflows/pr-test.yml | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index b1c67a6a3..b2869cb98 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: - node-version: [16.x] + node-version: [18.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index e5d989a8d..1b7c7f999 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: - node-version: [16.x] + node-version: [18.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: @@ -30,11 +30,26 @@ jobs: cd packages/office-viewer npm i --legacy-peer-deps cd ../../ + - name: build amis-formula + run: | npm run build --workspace amis-formula + - name: build amis-core + run: | npm run build --workspace amis-core + - name: build amis-ui + run: | npm run build --workspace amis-ui + - name: build amis + run: | npm run build --workspace amis + - name: check schema.json + run: | + cp ./packages/amis/schema.json . + - name: build amis-editor-core + run: | npm run build --workspace amis-editor-core + - name: build amis-editor + run: | npm run build --workspace amis-editor - name: typescript check env: From fae6b44ee58cd4196e7482e3ed9d6fa4473b7464 Mon Sep 17 00:00:00 2001 From: 2betop <2betop.cn@gmail.com> Date: Thu, 25 Apr 2024 10:40:50 +0800 Subject: [PATCH 29/46] =?UTF-8?q?chore:=20node=20=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E5=88=B0=2020?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gh-pages.yml | 2 +- .github/workflows/pr-test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index b2869cb98..f86e53ea6 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: - node-version: [18.x] + node-version: [20.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index 1b7c7f999..8a2d278c2 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: - node-version: [18.x] + node-version: [20.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: From 0837b30dc4e0fb3c2f8f09a3031820ef6090b2be Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2698393+2betop@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:47:19 +0800 Subject: [PATCH 30/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20inputArray=20?= =?UTF-8?q?=E5=9C=A8=E7=BC=96=E8=BE=91=E5=99=A8=E4=B8=AD=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98=20(#10104)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-editor-core/src/util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/amis-editor-core/src/util.ts b/packages/amis-editor-core/src/util.ts index 36551414d..e74fb8c21 100644 --- a/packages/amis-editor-core/src/util.ts +++ b/packages/amis-editor-core/src/util.ts @@ -194,7 +194,7 @@ export function JSONPipeOut( }); return flag ? ret : obj; } - if (!isObject(obj) || isObservable(obj)) { + if (!isPlainObject(obj)) { return obj; } From 0d60f9100f583ab906cfa1f39a522f03c6628122 Mon Sep 17 00:00:00 2001 From: qkiroc <30946345+qkiroc@users.noreply.github.com> Date: Thu, 25 Apr 2024 19:18:13 +0800 Subject: [PATCH 31/46] =?UTF-8?q?fix(editor):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E8=A7=84=E5=88=99=E4=BF=AE=E6=94=B9=E5=90=8E?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E4=B8=8D=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#10113)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com> --- packages/amis-editor/src/renderer/ValidationControl.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/amis-editor/src/renderer/ValidationControl.tsx b/packages/amis-editor/src/renderer/ValidationControl.tsx index 65d513fc7..4efc99a6c 100644 --- a/packages/amis-editor/src/renderer/ValidationControl.tsx +++ b/packages/amis-editor/src/renderer/ValidationControl.tsx @@ -406,6 +406,7 @@ export default class ValidationControl extends React.Component< @FormItem({ type: 'ae-validationControl', - renderLabel: false + renderLabel: false, + strictMode: false }) export class ValidationControlRenderer extends ValidationControl {} From ce03ffac9de4fd1e5f3e11d31073dda0cd0e6d1d Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2698393+2betop@users.noreply.github.com> Date: Thu, 25 Apr 2024 19:19:25 +0800 Subject: [PATCH 32/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20crud=20?= =?UTF-8?q?=E4=B8=AD=20filter=20=E5=BC=80=E5=90=AF=20submitOnChnage=20?= =?UTF-8?q?=E5=90=8E=E6=97=A0=E6=B3=95=E5=88=86=E9=A1=B5=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#10115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-core/src/renderers/Form.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/amis-core/src/renderers/Form.tsx b/packages/amis-core/src/renderers/Form.tsx index ef49890e4..e9dd2d57e 100644 --- a/packages/amis-core/src/renderers/Form.tsx +++ b/packages/amis-core/src/renderers/Form.tsx @@ -1068,7 +1068,7 @@ export default class Form extends React.Component { emittedData: any = null; emitting = false; - async emitChange(submit: boolean, skipIfNothingChanges: boolean = false) { + async emitChange(submit: boolean, emitedFromWatch: boolean = false) { try { this.emitting = true; @@ -1080,7 +1080,7 @@ export default class Form extends React.Component { const diff = difference(store.data, store.pristine); if ( - skipIfNothingChanges && + emitedFromWatch && (!Object.keys(diff).length || isEqual(store.data, this.emittedData)) ) { return; @@ -1100,7 +1100,8 @@ export default class Form extends React.Component { store.clearRestError(); - if (submit || (submitOnChange && store.inited)) { + // 只有主动修改表单项触发的 change 才会触发 submit + if (!emitedFromWatch && (submit || (submitOnChange && store.inited))) { await this.handleAction( undefined, { From 3a5be0655666fd6bda42804bf6eeaf0347d04907 Mon Sep 17 00:00:00 2001 From: F-jianchao <161407305+F-jianchao@users.noreply.github.com> Date: Fri, 26 Apr 2024 11:56:19 +0800 Subject: [PATCH 33/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8F=B3?= =?UTF-8?q?=E5=87=BB=E8=8F=9C=E5=8D=95=E5=90=8E=E6=8A=A5=E9=94=99=20(#1012?= =?UTF-8?q?1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-editor-core/src/component/Editor.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/amis-editor-core/src/component/Editor.tsx b/packages/amis-editor-core/src/component/Editor.tsx index 949d5aaed..c23384226 100644 --- a/packages/amis-editor-core/src/component/Editor.tsx +++ b/packages/amis-editor-core/src/component/Editor.tsx @@ -421,6 +421,7 @@ export default class Editor extends Component { // 右键菜单 @autobind async handleContextMenu(e: React.MouseEvent) { + e.persist(); await closeContextMenus(); let targetId: string = ''; let region = ''; From 0d47d55ba8a6dab17892015171feb1667224d070 Mon Sep 17 00:00:00 2001 From: lvxiaojiao Date: Sun, 28 Apr 2024 16:36:41 +0800 Subject: [PATCH 34/46] =?UTF-8?q?style:=E6=9B=B4=E6=96=B0=E5=8A=A8?= =?UTF-8?q?=E4=BD=9C=E9=9D=A2=E6=9D=BF=E7=9A=84=E7=BC=96=E8=BE=91icon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-editor/src/renderer/event-control/index.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/amis-editor/src/renderer/event-control/index.tsx b/packages/amis-editor/src/renderer/event-control/index.tsx index 46021e08c..0960aefc2 100644 --- a/packages/amis-editor/src/renderer/event-control/index.tsx +++ b/packages/amis-editor/src/renderer/event-control/index.tsx @@ -1261,10 +1261,7 @@ export class EventControl extends React.Component< } )} > - +
Date: Wed, 3 Apr 2024 14:17:40 +0800 Subject: [PATCH 35/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E5=8D=A1=E6=96=B0=E5=A2=9E=E9=80=89=E9=A1=B9=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=89=8D=E5=90=8E=E6=97=A0=E6=8F=92=E5=85=A5=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-editor/src/plugin/Tabs.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/amis-editor/src/plugin/Tabs.tsx b/packages/amis-editor/src/plugin/Tabs.tsx index 03a1e8492..4b10041ad 100644 --- a/packages/amis-editor/src/plugin/Tabs.tsx +++ b/packages/amis-editor/src/plugin/Tabs.tsx @@ -145,11 +145,13 @@ export class TabsPlugin extends BasePlugin { minLength: 1, scaffold: { title: '选项卡', - body: { - type: 'tpl', - tpl: '内容', - inline: false - } + body: [ + { + type: 'tpl', + tpl: '内容', + inline: false + } + ] }, items: [ getSchemaTpl('title', { From 37e6369364398f30b9d78d448e21a8e34196636e Mon Sep 17 00:00:00 2001 From: zhangtao07 Date: Fri, 19 Apr 2024 17:17:43 +0800 Subject: [PATCH 36/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dcrud2=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=99=A8=E5=86=85=E8=AE=BE=E7=BD=AE=E5=A4=9A=E5=88=97?= =?UTF-8?q?=E5=8F=B3=E4=BE=A7=E5=9B=BA=E5=AE=9A=E6=98=BE=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-ui/src/components/table/Head.tsx | 13 +++++++++++-- packages/amis-ui/src/components/table/util.ts | 4 +++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/amis-ui/src/components/table/Head.tsx b/packages/amis-ui/src/components/table/Head.tsx index e751f8f97..437acf377 100644 --- a/packages/amis-ui/src/components/table/Head.tsx +++ b/packages/amis-ui/src/components/table/Head.tsx @@ -60,8 +60,17 @@ export default class Head extends React.PureComponent { tdColumns: Array; prependColumns(columns: Array) { - const {rowSelectionFixed, expandableFixed, draggable} = this.props; - if (draggable) { + const { + rowSelectionFixed, + expandableFixed, + draggable, + selectable, + expandable + } = this.props; + if (expandable) { + columns.unshift({}); + } + if (draggable || selectable) { columns.unshift({}); } else { if (expandableFixed) { diff --git a/packages/amis-ui/src/components/table/util.ts b/packages/amis-ui/src/components/table/util.ts index 255a2312c..c06dea830 100644 --- a/packages/amis-ui/src/components/table/util.ts +++ b/packages/amis-ui/src/components/table/util.ts @@ -234,7 +234,9 @@ function getAfterRightWidth( for (let i = doms.length - 0; i > index; i--) { if (columns && columns[i] && isFixedRightColumn(columns[i].fixed)) { const dom = doms[i] as HTMLElement; - width += dom.offsetWidth; + if (dom) { + width += dom.offsetWidth; + } } } return width; From 31f6d53e7613177b8cf8d176ad69369dc2e0c8ea Mon Sep 17 00:00:00 2001 From: zhangtao07 Date: Mon, 22 Apr 2024 19:08:40 +0800 Subject: [PATCH 37/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dcrud2=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E7=89=B9=E6=80=A7=E5=8A=A8=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-editor/src/plugin/CRUD2/BaseCRUD.tsx | 8 ++++++-- packages/amis/src/renderers/Table2/index.tsx | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/amis-editor/src/plugin/CRUD2/BaseCRUD.tsx b/packages/amis-editor/src/plugin/CRUD2/BaseCRUD.tsx index a73d24889..4219c8361 100644 --- a/packages/amis-editor/src/plugin/CRUD2/BaseCRUD.tsx +++ b/packages/amis-editor/src/plugin/CRUD2/BaseCRUD.tsx @@ -756,7 +756,7 @@ export class BaseCRUDPlugin extends BasePlugin { return data; }, onChange: (value: string, oldValue: any, model: any, form: any) => { - const schema = form.data; + const schema = cloneDeep(form.data); if (oldValue) { deepRemove(schema, item => { return oldValue === 'more' @@ -796,6 +796,10 @@ export class BaseCRUDPlugin extends BasePlugin { this.addFeatToToolbar(schema, newCompSchema, 'footer', 'right'); } + form.setValues({ + footerToolbar: schema.footerToolbar, + headerToolbar: schema.headerToolbar + }); } }, getSchemaTpl('switch', { @@ -831,7 +835,7 @@ export class BaseCRUDPlugin extends BasePlugin { type: 'input-number', label: tipedLabel( '每页数量', - '无限加载时,根据此项设置其每页加载数量,留空即不限制' + '无限加载时,根据此项设置其每页加载数量,留空则默认10条' ), clearValueOnEmpty: true, clearable: true, diff --git a/packages/amis/src/renderers/Table2/index.tsx b/packages/amis/src/renderers/Table2/index.tsx index 9b0c7063d..616b236cf 100644 --- a/packages/amis/src/renderers/Table2/index.tsx +++ b/packages/amis/src/renderers/Table2/index.tsx @@ -1533,6 +1533,15 @@ export default class Table2 extends React.Component { // todo onAction && onAction(e, action, ctx); + + /** + * 因为Table在scope上注册,导致getComponentByName查询组件时会优先找到Table,和CRUD联动的动作都会失效 + * 这里先做兼容处理,把动作交给上层的CRUD处理 + */ + const scoped = this.context as IScopedContext; + if (scoped?.parent?.component?.props?.type === 'crud2') { + return scoped.parent.component.doAction?.(action, ctx); + } } renderActions(region: string) { From c7be86a96ca2811344306ee29c95e2f3ccad8ad3 Mon Sep 17 00:00:00 2001 From: zhangtao07 Date: Sun, 28 Apr 2024 10:41:07 +0800 Subject: [PATCH 38/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dcrud2=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=88=97=E8=A1=A8=E7=AE=A1=E7=90=86=E7=BC=96=E8=BE=91?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../amis-editor/src/plugin/TableCell2.tsx | 9 ++++---- .../src/renderer/FeatureControl.tsx | 21 +++++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/packages/amis-editor/src/plugin/TableCell2.tsx b/packages/amis-editor/src/plugin/TableCell2.tsx index 49f24ec1c..dbd80d2b8 100644 --- a/packages/amis-editor/src/plugin/TableCell2.tsx +++ b/packages/amis-editor/src/plugin/TableCell2.tsx @@ -1,8 +1,8 @@ -import React from 'react'; +import React, {StrictMode} from 'react'; import get from 'lodash/get'; import flattenDeep from 'lodash/flattenDeep'; import {Button, Icon} from 'amis'; -import {getVariable, isObject} from 'amis-core'; +import {dataMapping, getVariable, isObject} from 'amis-core'; import { BasePlugin, BasicRendererInfo, @@ -610,6 +610,7 @@ export class TableCell2Plugin extends BasePlugin { body: [ { type: 'ae-feature-control', + strictMode: false, // 注意需要添加这个才能及时获取表单data变更 label: false, manager, addable: true, @@ -652,8 +653,8 @@ export class TableCell2Plugin extends BasePlugin { schema.buttons.push({ label: '新增按钮', level: 'link' - }), - onBulkChange(schema); + }); + onBulkChange(schema); } }; } diff --git a/packages/amis-editor/src/renderer/FeatureControl.tsx b/packages/amis-editor/src/renderer/FeatureControl.tsx index c37fdf3e7..c934b0fb9 100644 --- a/packages/amis-editor/src/renderer/FeatureControl.tsx +++ b/packages/amis-editor/src/renderer/FeatureControl.tsx @@ -6,7 +6,7 @@ import React from 'react'; import {findDOMNode} from 'react-dom'; import Sortable from 'sortablejs'; import cx from 'classnames'; -import clone from 'lodash/clone'; +import cloneDeep from 'lodash/cloneDeep'; import remove from 'lodash/remove'; import isPlainObject from 'lodash/isPlainObject'; import {FormItem, Button, Icon, FormControlProps, autobind} from 'amis'; @@ -106,21 +106,23 @@ export default class FeatureControl extends React.Component< @autobind handleRemove(item: FeatureOption, index: number) { const {removeFeature, data, onBulkChange} = this.props; + const schema = cloneDeep(data); const {inUseFeat, unUseFeat} = this.state; - item.remove?.(data); - removeFeature?.(item, data); - onBulkChange?.(data); + item.remove?.(schema); + removeFeature?.(item, schema); remove(inUseFeat, item); item.add && unUseFeat.push(item); + onBulkChange?.(schema); this.setState({inUseFeat, unUseFeat}); } handleSort(e: any) { const {data, onBulkChange, onSort} = this.props; - onSort?.(data, e); - onBulkChange?.(data); + let schema = cloneDeep(data); + onSort?.(schema, e); + onBulkChange?.(schema); } @autobind @@ -131,7 +133,7 @@ export default class FeatureControl extends React.Component< inUseFeat.push(item); remove(unUseFeat, item); - const schema = clone(data); + const schema = cloneDeep(data); item.add?.(schema); addFeature?.(item, schema); onBulkChange?.(schema); @@ -187,6 +189,7 @@ export default class FeatureControl extends React.Component< const value = this.state.inUseFeat.concat(); value[e.oldIndex] = value.splice(e.newIndex, 1, value[e.oldIndex])[0]; + this.setState({inUseFeat: value}, () => { this.handleSort({ oldIndex: e.oldIndex, @@ -208,7 +211,7 @@ export default class FeatureControl extends React.Component< @autobind handleCheck(res: boolean, index: number) { const {data, onBulkChange, onItemCheck} = this.props; - const schema = clone(data); + const schema = cloneDeep(data); onItemCheck?.(res, index, schema); onBulkChange?.(schema); } @@ -282,7 +285,7 @@ export default class FeatureControl extends React.Component< } if (customAction && typeof customAction === 'function') { - const schema = customAction({onBulkChange, schema: clone(data)}); + const schema = customAction({onBulkChange, schema: cloneDeep(data)}); if (isPlainObject(schema) && typeof schema.type === 'string') { return render('custom-action', schema); From 9167d288259d34cea2bcb0b2f9c2a79d183f8016 Mon Sep 17 00:00:00 2001 From: zhangtao07 Date: Sun, 28 Apr 2024 19:05:05 +0800 Subject: [PATCH 39/46] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Deach=E7=BB=84?= =?UTF-8?q?=E4=BB=B6items=E6=95=B0=E7=BB=84=E6=97=B6=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-editor/src/plugin/Each.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/amis-editor/src/plugin/Each.tsx b/packages/amis-editor/src/plugin/Each.tsx index ed2550785..ba9ae2888 100644 --- a/packages/amis-editor/src/plugin/Each.tsx +++ b/packages/amis-editor/src/plugin/Each.tsx @@ -363,7 +363,11 @@ export class EachPlugin extends BasePlugin { props.value = [{}, {}]; props.className = `${props.className || ''} ae-Editor-list`; - if (props.items && !props.items.className?.includes('eachItem')) { + if ( + props.items && + !props.items.className?.includes('eachItem') && + !Array.isArray(props.items) + ) { props.items = merge( { className: `${props.items.className || ''} ae-Editor-eachItem` From afa9389dd8d37c5eb47d6efa74e63be233afe075 Mon Sep 17 00:00:00 2001 From: zhangtao07 Date: Sun, 28 Apr 2024 19:37:15 +0800 Subject: [PATCH 40/46] =?UTF-8?q?refactor:=20table2=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=94=B9=E6=88=90crud2=E4=B8=8B=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis/src/renderers/CRUD2.tsx | 10 ++++++++++ packages/amis/src/renderers/Table2/index.tsx | 9 --------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/amis/src/renderers/CRUD2.tsx b/packages/amis/src/renderers/CRUD2.tsx index bb56f972a..350a3165f 100644 --- a/packages/amis/src/renderers/CRUD2.tsx +++ b/packages/amis/src/renderers/CRUD2.tsx @@ -1066,6 +1066,15 @@ export default class CRUD2 extends React.Component { // ); } + @autobind + handleAction( + e: React.UIEvent | undefined, + action: ActionObject, + ctx: object + ) { + return this.doAction(action, ctx); + } + unSelectItem(item: any, index: number) { const {store} = this.props; const selected = store.selectedItems.concat(); @@ -1380,6 +1389,7 @@ export default class CRUD2 extends React.Component { onSearch: this.handleQuerySearch, onSort: this.handleQuerySearch, onSelect: this.handleSelect, + onAction: this.handleAction, data: store.mergedData, loading: store.loading, host: this diff --git a/packages/amis/src/renderers/Table2/index.tsx b/packages/amis/src/renderers/Table2/index.tsx index 616b236cf..9b0c7063d 100644 --- a/packages/amis/src/renderers/Table2/index.tsx +++ b/packages/amis/src/renderers/Table2/index.tsx @@ -1533,15 +1533,6 @@ export default class Table2 extends React.Component { // todo onAction && onAction(e, action, ctx); - - /** - * 因为Table在scope上注册,导致getComponentByName查询组件时会优先找到Table,和CRUD联动的动作都会失效 - * 这里先做兼容处理,把动作交给上层的CRUD处理 - */ - const scoped = this.context as IScopedContext; - if (scoped?.parent?.component?.props?.type === 'crud2') { - return scoped.parent.component.doAction?.(action, ctx); - } } renderActions(region: string) { From 68b4314cda828286ef764744f5990a406fe67a1c Mon Sep 17 00:00:00 2001 From: lvxiaojiao Date: Mon, 29 Apr 2024 15:56:43 +0800 Subject: [PATCH 41/46] =?UTF-8?q?fix:inputTable=E5=88=A0=E9=99=A4=E8=A1=8C?= =?UTF-8?q?=E5=8A=A8=E4=BD=9C=E6=B2=A1=E6=9C=89=E8=A7=A6=E5=8F=91change?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis/src/renderers/Form/InputTable.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/amis/src/renderers/Form/InputTable.tsx b/packages/amis/src/renderers/Form/InputTable.tsx index fb6786d84..fe1e382a6 100644 --- a/packages/amis/src/renderers/Form/InputTable.tsx +++ b/packages/amis/src/renderers/Form/InputTable.tsx @@ -496,8 +496,9 @@ export default class FormTable extends React.Component { return msg; } - async emitValue() { - const items = this.state.items.filter(item => !item.__isPlaceholder); + async emitValue(value?: any[]) { + const items = + value ?? this.state.items.filter(item => !item.__isPlaceholder); const {onChange} = this.props; const isPrevented = await this.dispatchEvent('change'); isPrevented || onChange?.(items); @@ -1019,7 +1020,13 @@ export default class FormTable extends React.Component { const originItems = newValue; newValue = spliceTree(newValue, indexes, 1); this.reUseRowId(newValue, originItems, indexes); - onChange(newValue); + + // change value + const prevented = await this.emitValue(newValue); + if (prevented) { + return; + } + this.dispatchEvent('deleteSuccess', { value: newValue, index: indexes[indexes.length - 1], From 1e197fb99ee4a792c1085c7ee51c345cfbe52d79 Mon Sep 17 00:00:00 2001 From: lvxiaojiao Date: Fri, 26 Apr 2024 20:48:27 +0800 Subject: [PATCH 42/46] =?UTF-8?q?fix:=E8=A1=A8=E5=8D=95=E9=A1=B9reset?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=87=8D=E7=BD=AE=E4=B8=BA=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/zh-CN/components/calendar.md | 10 +- .../components/form/button-group-select.md | 184 ++++++++- docs/zh-CN/components/form/chain-select.md | 141 ++++++- docs/zh-CN/components/form/checkbox.md | 114 ++++- docs/zh-CN/components/form/checkboxes.md | 179 +++++++- docs/zh-CN/components/form/combo.md | 118 +++++- docs/zh-CN/components/form/diff-editor.md | 149 ++++++- docs/zh-CN/components/form/editor.md | 145 ++++++- docs/zh-CN/components/form/input-city.md | 111 ++++- .../zh-CN/components/form/input-date-range.md | 103 ++++- docs/zh-CN/components/form/input-date.md | 111 ++++- .../components/form/input-datetime-range.md | 2 +- docs/zh-CN/components/form/input-datetime.md | 10 +- docs/zh-CN/components/form/input-excel.md | 136 +++++- docs/zh-CN/components/form/input-file.md | 36 +- docs/zh-CN/components/form/input-image.md | 32 ++ docs/zh-CN/components/form/input-kv.md | 10 +- .../components/form/input-month-range.md | 2 +- docs/zh-CN/components/form/input-month.md | 10 +- docs/zh-CN/components/form/input-number.md | 101 +++++ .../components/form/input-quarter-range.md | 2 +- docs/zh-CN/components/form/input-quarter.md | 10 +- docs/zh-CN/components/form/input-range.md | 137 ++++++- docs/zh-CN/components/form/input-rating.md | 117 +++++- docs/zh-CN/components/form/input-table.md | 2 +- docs/zh-CN/components/form/input-tag.md | 160 +++++++- docs/zh-CN/components/form/input-text.md | 170 ++++++++ .../zh-CN/components/form/input-time-range.md | 2 +- docs/zh-CN/components/form/input-time.md | 10 +- docs/zh-CN/components/form/input-tree.md | 136 +++++- .../zh-CN/components/form/input-year-range.md | 2 +- docs/zh-CN/components/form/input-year.md | 10 +- docs/zh-CN/components/form/list-select.md | 172 +++++++- docs/zh-CN/components/form/location-picker.md | 131 +++++- .../components/form/matrix-checkboxes.md | 253 +++++++++++- docs/zh-CN/components/form/nestedselect.md | 222 +++++++++- docs/zh-CN/components/form/radio.md | 114 ++++- docs/zh-CN/components/form/radios.md | 192 ++++++++- docs/zh-CN/components/form/select.md | 157 ++++++- docs/zh-CN/components/form/switch.md | 94 ++++- .../components/form/tabs-transfer-picker.md | 388 +++++++++++++++++- docs/zh-CN/components/form/tabs-transfer.md | 388 +++++++++++++++++- docs/zh-CN/components/form/textarea.md | 145 ++++++- docs/zh-CN/components/form/transfer-picker.md | 193 ++++++++- docs/zh-CN/components/form/transfer.md | 184 ++++++++- docs/zh-CN/components/form/treeselect.md | 136 +++++- packages/amis-editor/src/locale/en-US.ts | 4 +- packages/amis-editor/src/locale/zh-CN.ts | 3 +- packages/amis-editor/src/plugin/Calendar.tsx | 2 +- .../src/plugin/Form/ButtonGroupSelect.tsx | 2 +- .../src/plugin/Form/ChainedSelect.tsx | 2 +- .../amis-editor/src/plugin/Form/Checkbox.tsx | 2 +- .../src/plugin/Form/Checkboxes.tsx | 2 +- .../src/plugin/Form/CodeEditor.tsx | 2 +- .../amis-editor/src/plugin/Form/Combo.tsx | 2 +- .../src/plugin/Form/DiffEditor.tsx | 2 +- .../amis-editor/src/plugin/Form/InputDate.tsx | 2 +- .../src/plugin/Form/InputDateRange.tsx | 2 +- .../src/plugin/Form/InputExcel.tsx | 2 +- .../amis-editor/src/plugin/Form/InputKV.tsx | 2 +- .../src/plugin/Form/InputRange.tsx | 2 +- .../src/plugin/Form/InputRating.tsx | 2 +- .../src/plugin/Form/InputTable.tsx | 2 +- .../amis-editor/src/plugin/Form/InputText.tsx | 2 +- .../src/plugin/Form/ListSelect.tsx | 2 +- .../src/plugin/Form/LocationPicker.tsx | 2 +- .../src/plugin/Form/NestedSelect.tsx | 2 +- .../amis-editor/src/plugin/Form/Radios.tsx | 2 +- .../amis-editor/src/plugin/Form/Select.tsx | 2 +- .../amis-editor/src/plugin/Form/Switch.tsx | 10 + .../amis-editor/src/plugin/Form/Textarea.tsx | 2 +- .../src/components/DateRangePicker.tsx | 12 +- .../renderers/form/locationPicker.test.tsx | 1 - .../__tests__/renderers/Form/text.test.tsx | 44 +- .../src/renderers/Form/ButtonGroupSelect.tsx | 10 +- .../amis/src/renderers/Form/ChainedSelect.tsx | 9 +- packages/amis/src/renderers/Form/Checkbox.tsx | 9 +- .../amis/src/renderers/Form/Checkboxes.tsx | 9 +- packages/amis/src/renderers/Form/Combo.tsx | 9 +- .../amis/src/renderers/Form/DiffEditor.tsx | 9 +- packages/amis/src/renderers/Form/Editor.tsx | 9 +- .../amis/src/renderers/Form/InputCity.tsx | 9 +- .../amis/src/renderers/Form/InputDate.tsx | 11 +- .../src/renderers/Form/InputDateRange.tsx | 11 +- .../amis/src/renderers/Form/InputExcel.tsx | 9 +- .../amis/src/renderers/Form/InputNumber.tsx | 14 +- .../amis/src/renderers/Form/InputRange.tsx | 45 +- .../amis/src/renderers/Form/InputRating.tsx | 9 +- .../amis/src/renderers/Form/InputTable.tsx | 9 +- packages/amis/src/renderers/Form/InputTag.tsx | 9 +- .../amis/src/renderers/Form/InputText.tsx | 37 +- .../amis/src/renderers/Form/InputTree.tsx | 9 +- .../amis/src/renderers/Form/ListSelect.tsx | 9 +- .../src/renderers/Form/LocationPicker.tsx | 11 +- .../src/renderers/Form/MatrixCheckboxes.tsx | 8 +- .../amis/src/renderers/Form/NestedSelect.tsx | 9 +- packages/amis/src/renderers/Form/Radio.tsx | 9 +- packages/amis/src/renderers/Form/Radios.tsx | 9 +- packages/amis/src/renderers/Form/Select.tsx | 11 +- packages/amis/src/renderers/Form/Switch.tsx | 22 +- .../amis/src/renderers/Form/TabsTransfer.tsx | 15 +- .../src/renderers/Form/TabsTransferPicker.tsx | 15 +- packages/amis/src/renderers/Form/Textarea.tsx | 14 +- packages/amis/src/renderers/Form/Transfer.tsx | 11 +- .../src/renderers/Form/TransferPicker.tsx | 11 +- .../amis/src/renderers/Form/TreeSelect.tsx | 12 +- 106 files changed, 5432 insertions(+), 319 deletions(-) diff --git a/docs/zh-CN/components/calendar.md b/docs/zh-CN/components/calendar.md index 89d6b9fd7..46f79bfde 100644 --- a/docs/zh-CN/components/calendar.md +++ b/docs/zh-CN/components/calendar.md @@ -231,8 +231,8 @@ order: 36 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ------------------------ | ------------------------------------------------------ | -| clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| setValue | `value: string` 更新的值 | 更新数据 | +| 动作名称 | 动作配置 | 说明 | +| -------- | ------------------------ | ------------------------------------------------ | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| setValue | `value: string` 更新的值 | 更新数据 | diff --git a/docs/zh-CN/components/form/button-group-select.md b/docs/zh-CN/components/form/button-group-select.md index 9d188972b..191554c19 100755 --- a/docs/zh-CN/components/form/button-group-select.md +++ b/docs/zh-CN/components/form/button-group-select.md @@ -264,6 +264,188 @@ order: 6 | 动作名称 | 动作配置 | 说明 | | -------- | ------------------------ | ------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) | | setValue | `value: string` 更新的值 | 更新数据 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "button-group-select", + "label": "选项", + "name": "type", + "id": "clear_type", + "options": [ + { + "label": "Option A", + "value": "a" + }, + { + "label": "Option B", + "value": "b" + }, + { + "label": "Option C", + "value": "c" + } + ], + "value": "b" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_type" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "data": { + "abc": { + "type": "c" + } + }, + "body": [ + { + "type": "button-group-select", + "label": "选项", + "name": "type", + "id": "reset_type", + "options": [ + { + "label": "Option A", + "value": "a" + }, + { + "label": "Option B", + "value": "b" + }, + { + "label": "Option C", + "value": "c" + } + ], + "value": "b" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_type" + } + ] + } + } + } + ] +} +``` + +### reload + +只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "button-group-select", + "label": "选项", + "name": "type", + "id": "reload_type", + "source": "/api/mock2/form/getOptions?waitSeconds=1" + }, + { + "type": "button", + "label": "重新加载", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reload", + "componentId": "reload_type" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "button-group-select", + "label": "选项", + "name": "type", + "id": "setvalue_type", + "options": [ + { + "label": "Option A", + "value": "a" + }, + { + "label": "Option B", + "value": "b" + }, + { + "label": "Option C", + "value": "c" + } + ], + "value": "b" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_type", + "args": { + "value": "c" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/chain-select.md b/docs/zh-CN/components/form/chain-select.md index ae315491f..8a2ac5efe 100755 --- a/docs/zh-CN/components/form/chain-select.md +++ b/docs/zh-CN/components/form/chain-select.md @@ -102,6 +102,145 @@ order: 7 | 动作名称 | 动作配置 | 说明 | | -------- | ------------------------ | ------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) | | setValue | `value: string` 更新的值 | 更新数据,多个值用`,`分隔 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "type", + "id": "clear_type", + "type": "chained-select", + "label": "链式下拉", + "source": "/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4", + "value": "a,b" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_type" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "type", + "id": "reset_type", + "type": "chained-select", + "label": "链式下拉", + "source": "/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4", + "value": "a,b" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_type" + } + ] + } + } + } + ] +} +``` + +### reload + +只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "type", + "id": "reload_type", + "type": "chained-select", + "label": "链式下拉", + "source": "/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4", + "value": "a,b" + }, + { + "type": "button", + "label": "重新加载", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reload", + "componentId": "reload_type" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "type", + "id": "setvalue_type", + "type": "chained-select", + "label": "链式下拉", + "source": "/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4", + "value": "a,b" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_type", + "args": { + "value": "c" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/checkbox.md b/docs/zh-CN/components/form/checkbox.md index b37cbe198..c5dde7bac 100755 --- a/docs/zh-CN/components/form/checkbox.md +++ b/docs/zh-CN/components/form/checkbox.md @@ -143,8 +143,112 @@ order: 8 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ------------------------------------------- | ------------------------------------------------------ | -| clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| setValue | `value: string \|number \|boolean` 更新的值 | 更新数据 | +| 动作名称 | 动作配置 | 说明 | +| -------- | ------------------------------------------- | ------------------------------------------------ | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| setValue | `value: string \|number \|boolean` 更新的值 | 更新数据 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "checkbox", + "label": "选项", + "name": "type", + "id": "clear_type", + "option": "选项说明", + "value": true + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_type" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "checkbox", + "label": "选项", + "name": "type", + "id": "reset_type", + "option": "选项说明", + "value": true + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_type" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "checkbox", + "label": "选项", + "name": "type", + "id": "setvalue_type", + "option": "选项说明", + "value": true + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_type", + "args": { + "value": false + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/checkboxes.md b/docs/zh-CN/components/form/checkboxes.md index 09e6c0768..5638059c2 100755 --- a/docs/zh-CN/components/form/checkboxes.md +++ b/docs/zh-CN/components/form/checkboxes.md @@ -682,6 +682,183 @@ order: 9 | 动作名称 | 动作配置 | 说明 | | -------- | ------------------------ | ------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) | | setValue | `value: string` 更新的值 | 更新数据,多个值用`,`分隔 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "checkboxes", + "label": "选项", + "name": "type", + "id": "clear_type", + "options": [ + { + "label": "Option A", + "value": "a" + }, + { + "label": "Option B", + "value": "b" + }, + { + "label": "Option C", + "value": "c" + } + ], + "value": "b" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_type" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "checkboxes", + "label": "选项", + "name": "type", + "id": "reset_type", + "options": [ + { + "label": "Option A", + "value": "a" + }, + { + "label": "Option B", + "value": "b" + }, + { + "label": "Option C", + "value": "c" + } + ], + "value": "b" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_type" + } + ] + } + } + } + ] +} +``` + +### reload + +只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "checkboxes", + "label": "选项", + "name": "type", + "id": "reload_type", + "source": "/api/mock2/form/getOptions?waitSeconds=1" + }, + { + "type": "button", + "label": "重新加载", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reload", + "componentId": "reload_type" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "checkboxes", + "label": "选项", + "name": "type", + "id": "setvalue_type", + "options": [ + { + "label": "Option A", + "value": "a" + }, + { + "label": "Option B", + "value": "b" + }, + { + "label": "Option C", + "value": "c" + } + ], + "value": "b" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_type", + "args": { + "value": "c" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/combo.md b/docs/zh-CN/components/form/combo.md index 7b31ae492..f40ae1ca2 100755 --- a/docs/zh-CN/components/form/combo.md +++ b/docs/zh-CN/components/form/combo.md @@ -1134,9 +1134,113 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层 | -------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | | addItem | `item: object` 新增项的值 | 只有开启`multiple`模式才能使用, `multiple`模式下,给新增项添加默认值 | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | setValue | `value: object \| Array` 更新的值
`index?: number` 指定更新的数据索引, 1.10.1 及以上版本引入 | 更新数据,对象数组针对开启`multiple`模式, `multiple`模式下可以通过指定`index`来更新指定索引的数据 | +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "combo", + "name": "type", + "id": "clear_type", + "label": "用户", + "items": [ + { + "name": "text", + "label": "名字", + "type": "input-text" + }, + { + "name": "gender", + "label": "性别", + "type": "select", + "options": [ + "男", + "女" + ] + } + ], + "value": { + "text": "amis", + "gender": "男" + } + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_type" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "combo", + "name": "type", + "id": "reset_type", + "label": "用户", + "items": [ + { + "name": "text", + "label": "名字", + "type": "input-text" + }, + { + "name": "gender", + "label": "性别", + "type": "select", + "options": [ + "男", + "女" + ] + } + ], + "value": { + "text": "amis", + "gender": "男" + } + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_type" + } + ] + } + } + } + ] +} +``` + ### setValue #### 复制数值 @@ -1145,12 +1249,12 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层 此示例主要用来演示如何通过已有数据快速填充 combo 某条数据。点击 copy 按钮会弹出一个 crud 列表,点击对应行上的复制按钮,将选中数据填充到外层的 combo. -注意事项: - -1. 需要给 combo 设置个 id 属性,用来给事件动作指定目标用。 -2. 弹窗按钮配置了数据映射 `{comboIndex: "${index}"}` 因为 crud 的行数据上也有 index 变量,派送动作时获取 index 变量是 crud 所在行的序号。所以弹出弹窗的时候,先把 combo 的序号赋值给 comboIndex -3. crud 操作栏里面添加了个按钮,close: true 设置是让动作完成后关闭弹窗。 -4. 按钮里面添加了 onEvent 配置,click 时做 `setValue` 动作,并设置参数 index 为 '${comboIndex}' 值为 `${&}`。其中 `${&}` 是特殊语法,用来取整个上下数据。 +> 注意事项: +> +> 1. 需要给 combo 设置个 id 属性,用来给事件动作指定目标用。 +> 2. 弹窗按钮配置了数据映射 `{comboIndex: "${index}"}` 因为 crud 的行数据上也有 index 变量,派送动作时获取 index 变量是 crud 所在行的序号。所以弹出弹窗的时候,先把 combo 的序号赋值给 comboIndex +> 3. crud 操作栏里面添加了个按钮,close: true 设置是让动作完成后关闭弹窗。 +> 4. 按钮里面添加了 onEvent 配置,click 时做 `setValue` 动作,并设置参数 index 为 '${comboIndex}' 值为 `${&}`。其中 `${&}` 是特殊语法,用来取整个上下数据。 ```schema: scope="body" { diff --git a/docs/zh-CN/components/form/diff-editor.md b/docs/zh-CN/components/form/diff-editor.md index e1d4f30eb..c6e8167a9 100755 --- a/docs/zh-CN/components/form/diff-editor.md +++ b/docs/zh-CN/components/form/diff-editor.md @@ -100,9 +100,146 @@ order: 17 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ---------------------------------------- | ------------------------------------------------------ | -| clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| focus | - | 获取焦点,焦点落在右侧编辑面板 | -| setValue | `value: string` 更新的右侧编辑面板中的值 | 更新数据 | +| 动作名称 | 动作配置 | 说明 | +| -------- | ---------------------------------------- | ------------------------------------------------ | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| focus | - | 获取焦点,焦点落在右侧编辑面板 | +| setValue | `value: string` 更新的右侧编辑面板中的值 | 更新数据 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "diff-editor", + "name": "diff", + "id": "clear_text", + "label": "Diff-Editor", + "diffValue": "hello world", + "value": "hello" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "id": "reset_text", + "type": "diff-editor", + "name": "diff", + "label": "Diff-Editor", + "diffValue": "hello world", + "value": "hello" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### focus + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "id": "focus_text", + "type": "diff-editor", + "name": "diff", + "label": "Diff-Editor", + "diffValue": "hello world", + "value": "hello" + }, + { + "type": "button", + "label": "聚焦", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "focus", + "componentId": "focus_text" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "id": "setvalue_text", + "type": "diff-editor", + "name": "diff", + "label": "Diff-Editor", + "diffValue": "hello world", + "value": "hello" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": "amis go go go!" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/editor.md b/docs/zh-CN/components/form/editor.md index 445572de8..d153a4a88 100755 --- a/docs/zh-CN/components/form/editor.md +++ b/docs/zh-CN/components/form/editor.md @@ -181,9 +181,142 @@ amis 的编辑器是基于 monaco 开发的,如果想进行深度定制,比 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ------------------------ | ------------------------------------------------------ | -| clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| focus | - | 获取焦点 | -| setValue | `value: string` 更新的值 | 更新数据 | +| 动作名称 | 动作配置 | 说明 | +| -------- | ------------------------ | ------------------------------------------------ | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| focus | - | 获取焦点 | +| setValue | `value: string` 更新的值 | 更新数据 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "editor", + "name": "editor", + "label": "编辑器", + "id": "clear_text", + "value": "hello" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "editor", + "id": "reset_text", + "name": "editor", + "label": "编辑器", + "value": "hello" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### focus + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "editor", + "id": "focus_text", + "name": "editor", + "label": "编辑器", + "value": "hello" + }, + { + "type": "button", + "label": "聚焦", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "focus", + "componentId": "focus_text" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "editor", + "id": "setvalue_text", + "name": "editor", + "label": "编辑器", + "value": "hello" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": "amis go go go!" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-city.md b/docs/zh-CN/components/form/input-city.md index 9e01cdf62..38516ebe9 100755 --- a/docs/zh-CN/components/form/input-city.md +++ b/docs/zh-CN/components/form/input-city.md @@ -145,8 +145,109 @@ order: 10 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ---------------------------------- | ------------------------------------------------------ | -| clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| setValue | `value: string \| number` 更新的值 | 更新数据 | +| 动作名称 | 动作配置 | 说明 | +| -------- | ---------------------------------- | ------------------------------------------------ | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| setValue | `value: string \| number` 更新的值 | 更新数据 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "city", + "type": "input-city", + "label": "城市", + "id": "clear_text", + "value": "110000" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "city", + "type": "input-city", + "label": "城市", + "id": "reset_text", + "value": "110000" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "city", + "type": "input-city", + "label": "城市", + "id": "setvalue_text", + "value": "110000" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": "110100" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-date-range.md b/docs/zh-CN/components/form/input-date-range.md index f40b20307..9a3b424f3 100755 --- a/docs/zh-CN/components/form/input-date-range.md +++ b/docs/zh-CN/components/form/input-date-range.md @@ -372,5 +372,106 @@ function transform(value, config, props, data) { | 动作名称 | 动作配置 | 说明 | | -------- | ------------------------------------------- | ----------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,,依赖格式`format`,例如:'1650556800,1652889599' | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-date-range", + "name": "date", + "label": "日期", + "id": "clear_text", + "value": "1714060800,1714319999" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-date-range", + "name": "date", + "label": "日期", + "id": "reset_text", + "value": "1714060800,1714319999" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-date-range", + "name": "date", + "label": "日期", + "id": "setvalue_text", + "value": "1714060800,1714319999" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": "1714060800,1714492799" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-date.md b/docs/zh-CN/components/form/input-date.md index dde6d03b5..90bff3912 100755 --- a/docs/zh-CN/components/form/input-date.md +++ b/docs/zh-CN/components/form/input-date.md @@ -444,8 +444,109 @@ order: 13 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ---------------------------- | ------------------------------------------------------ | -| clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1650556800' | +| 动作名称 | 动作配置 | 说明 | +| -------- | ---------------------------- | ------------------------------------------------ | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1650556800' | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-date", + "name": "date", + "label": "日期", + "id": "clear_text", + "value": "1714060800" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-date", + "name": "date", + "label": "日期", + "id": "reset_text", + "value": "1714060800" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-date", + "name": "date", + "label": "日期", + "id": "setvalue_text", + "value": "1714060800" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": "1714233600" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-datetime-range.md b/docs/zh-CN/components/form/input-datetime-range.md index efba86203..d2fffc5f7 100755 --- a/docs/zh-CN/components/form/input-datetime-range.md +++ b/docs/zh-CN/components/form/input-datetime-range.md @@ -159,5 +159,5 @@ order: 16 | 动作名称 | 动作配置 | 说明 | | -------- | ------------------------------------------- | -------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1650556800,1652889599' | diff --git a/docs/zh-CN/components/form/input-datetime.md b/docs/zh-CN/components/form/input-datetime.md index 3b46ee2b1..e506ce027 100755 --- a/docs/zh-CN/components/form/input-datetime.md +++ b/docs/zh-CN/components/form/input-datetime.md @@ -444,8 +444,8 @@ order: 14 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ---------------------------- | ------------------------------------------------------ | -| clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1650556800' | +| 动作名称 | 动作配置 | 说明 | +| -------- | ---------------------------- | ------------------------------------------------ | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1650556800' | diff --git a/docs/zh-CN/components/form/input-excel.md b/docs/zh-CN/components/form/input-excel.md index 4653409a9..74405529c 100644 --- a/docs/zh-CN/components/form/input-excel.md +++ b/docs/zh-CN/components/form/input-excel.md @@ -275,17 +275,16 @@ interface InputExcelData { } ``` - ## 属性表 -| 属性名 | 类型 | 默认值 | 说明 | 版本 | -| ------------ | ----------------------- | ------------------------------- | ------------------ | ------- | -| allSheets | `boolean` | false | 是否解析所有 sheet | -| parseMode | `'array'` 或 `'object'` | 'object' | 解析模式 | -| includeEmpty | `boolean` | true | 是否包含空值 | -| plainText | `boolean` | true | 是否解析为纯文本 | -| placeholder | `string` | `"拖拽 Excel 到这,或点击上传"` | 占位文本提示 | `2.8.1` | -| autoFill | `Record` | | 自动填充 | `3.5.0` | +| 属性名 | 类型 | 默认值 | 说明 | 版本 | +| ------------ | ------------------------ | ------------------------------- | ------------------ | ------- | +| allSheets | `boolean` | false | 是否解析所有 sheet | +| parseMode | `'array'` 或 `'object'` | 'object' | 解析模式 | +| includeEmpty | `boolean` | true | 是否包含空值 | +| plainText | `boolean` | true | 是否解析为纯文本 | +| placeholder | `string` | `"拖拽 Excel 到这,或点击上传"` | 占位文本提示 | `2.8.1` | +| autoFill | `Record` | | 自动填充 | `3.5.0` | ## 事件表 @@ -301,8 +300,117 @@ interface InputExcelData { 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ---------------------------------------------- | ------------------------------------------------------ | -| clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| setValue | `value: Array` 更新的 excel 解析后数据 | 更新数据 | +| 动作名称 | 动作配置 | 说明 | +| -------- | ---------------------------------------------- | ------------------------------------------------ | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| setValue | `value: Array` 更新的 excel 解析后数据 | 更新数据 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-excel", + "name": "excel", + "label": "上传 Excel", + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-excel", + "name": "excel", + "label": "上传 Excel", + "id": "reset_text", + "value": [ + { + "ID": "1", + "NAME": "amis" + } + ] + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-excel", + "name": "excel", + "label": "上传 Excel", + "id": "setvalue_text" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": [ + { + "ID": "1", + "NAME": "amis" + } + ] + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-file.md b/docs/zh-CN/components/form/input-file.md index 10b6e8fd3..aa2c5d685 100755 --- a/docs/zh-CN/components/form/input-file.md +++ b/docs/zh-CN/components/form/input-file.md @@ -185,7 +185,7 @@ order: 21 ## 作为表单项上传 -如果不希望 InputFile 组件在提交Form之前上传,可以配置 `asBlob` 或者 `asBase64`,采用这种方式后,组件不再自己上传了,而是直接把文件数据作为表单项的值,文件内容会在 Form 表单提交的接口里面一起带上。 +如果不希望 InputFile 组件在提交 Form 之前上传,可以配置 `asBlob` 或者 `asBase64`,采用这种方式后,组件不再自己上传了,而是直接把文件数据作为表单项的值,文件内容会在 Form 表单提交的接口里面一起带上。 ```schema: scope="body" { @@ -435,7 +435,6 @@ order: 21 } ``` - ## 属性表 除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置 @@ -502,3 +501,36 @@ order: 21 | 动作名称 | 动作配置 | 说明 | | -------- | -------- | ---- | | clear | - | 清空 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-file", + "name": "file", + "label": "File", + "accept": "*", + "receiver": "/api/upload/file", + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-image.md b/docs/zh-CN/components/form/input-image.md index a31cfb068..b8e097655 100755 --- a/docs/zh-CN/components/form/input-image.md +++ b/docs/zh-CN/components/form/input-image.md @@ -733,3 +733,35 @@ app.listen(8080, function () {}); | 动作名称 | 动作配置 | 说明 | | -------- | -------- | ---- | | clear | - | 清空 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-image", + "name": "image", + "label": "Image", + "receiver": "/api/upload/file", + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-kv.md b/docs/zh-CN/components/form/input-kv.md index c04b9c956..353f2f339 100644 --- a/docs/zh-CN/components/form/input-kv.md +++ b/docs/zh-CN/components/form/input-kv.md @@ -222,8 +222,8 @@ key 只能是字符串,因此输入格式是 `input-text`,但 value 格式 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ------------------------ | ------------------------------------------------------ | -| clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| setValue | `value: object` 更新的值 | 更新数据 | +| 动作名称 | 动作配置 | 说明 | +| -------- | ------------------------ | ------------------------------------------------ | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| setValue | `value: object` 更新的值 | 更新数据 | diff --git a/docs/zh-CN/components/form/input-month-range.md b/docs/zh-CN/components/form/input-month-range.md index d7f3b7824..fcdf1e4de 100644 --- a/docs/zh-CN/components/form/input-month-range.md +++ b/docs/zh-CN/components/form/input-month-range.md @@ -102,5 +102,5 @@ order: 15 | 动作名称 | 动作配置 | 说明 | | -------- | ------------------------------------------- | -------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1646064000,1651334399' | diff --git a/docs/zh-CN/components/form/input-month.md b/docs/zh-CN/components/form/input-month.md index 198553e36..5d185e696 100755 --- a/docs/zh-CN/components/form/input-month.md +++ b/docs/zh-CN/components/form/input-month.md @@ -171,8 +171,8 @@ order: 81 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ---------------------------- | ------------------------------------------------------ | -| clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`valueFormat`,例如:'1646064000' | +| 动作名称 | 动作配置 | 说明 | +| -------- | ---------------------------- | --------------------------------------------------- | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`valueFormat`,例如:'1646064000' | diff --git a/docs/zh-CN/components/form/input-number.md b/docs/zh-CN/components/form/input-number.md index d41ba35e0..67a962d65 100755 --- a/docs/zh-CN/components/form/input-number.md +++ b/docs/zh-CN/components/form/input-number.md @@ -314,3 +314,104 @@ order: 32 | clear | - | 清空 | | reset | - | 将值重置为 `resetValue`,若没有配置 `resetValue`,则清空 | | setValue | `value: number` 更新的数值 | 更新数据 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-number", + "name": "number", + "label": "数字", + "id": "clear_text", + "value": 1 + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-number", + "name": "number", + "label": "数字", + "id": "reset_text", + "value": 1 + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-number", + "name": "number", + "label": "数字", + "id": "setvalue_text", + "value": 1 + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": 2 + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-quarter-range.md b/docs/zh-CN/components/form/input-quarter-range.md index ba7d0b584..00a210b07 100644 --- a/docs/zh-CN/components/form/input-quarter-range.md +++ b/docs/zh-CN/components/form/input-quarter-range.md @@ -101,5 +101,5 @@ order: 15 | 动作名称 | 动作配置 | 说明 | | -------- | ------------------------------------------- | -------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1640966400,1664553600' | diff --git a/docs/zh-CN/components/form/input-quarter.md b/docs/zh-CN/components/form/input-quarter.md index 3438eb3c5..ee48f6ae7 100644 --- a/docs/zh-CN/components/form/input-quarter.md +++ b/docs/zh-CN/components/form/input-quarter.md @@ -42,8 +42,8 @@ order: 62 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ---------------------------- | ------------------------------------------------------ | -| clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1640966400' | +| 动作名称 | 动作配置 | 说明 | +| -------- | ---------------------------- | ------------------------------------------------ | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1640966400' | diff --git a/docs/zh-CN/components/form/input-range.md b/docs/zh-CN/components/form/input-range.md index 87e4bf2fc..9990b52a7 100755 --- a/docs/zh-CN/components/form/input-range.md +++ b/docs/zh-CN/components/form/input-range.md @@ -232,7 +232,7 @@ order: 38 ## 显示单位 -在打开`showInput`输入框且设置了`unit`单位的前提下,开启`showInputUnit`可在input框中显示已配置的单位。 +在打开`showInput`输入框且设置了`unit`单位的前提下,开启`showInputUnit`可在 input 框中显示已配置的单位。 ```schema: scope="body" { @@ -311,18 +311,18 @@ order: 38 | showSteps | `boolean` | `false` | 是否显示步长 | | parts | `number` or `number[]` | `1` | 分割的块数
主持数组传入分块的节点 | | marks | { [number | string]: string | number | SchemaObject } or { [number | string]: { style: CSSProperties, label: string } } | | 刻度标记
- 支持自定义样式
- 设置百分比 | -| tooltipVisible | `boolean` | `false` | 是否显示滑块标签 | -| tooltipPlacement | `auto` or `bottom` or `left` or `right` | `top` | 滑块标签的位置,默认`auto`,方向自适应
前置条件:tooltipVisible 不为 false 时有效 | -| tipFormatter | `function` | | 控制滑块标签显隐函数
前置条件:tooltipVisible 不为 false 时有效 | -| multiple | `boolean` | `false` | 支持选择范围 | -| joinValues | `boolean` | `true` | 默认为 `true`,选择的 `value` 会通过 `delimiter` 连接起来,否则直接将以`{min: 1, max: 100}`的形式提交
前置条件:开启`multiple`时有效 | -| delimiter | `string` | `,` | 分隔符 | -| unit | `string` | | 单位 | -| clearable | `boolean` | `false` | 是否可清除
前置条件:开启`showInput`时有效 | -| showInput | `boolean` | `false` | 是否显示输入框 | -| showInputUnit | `boolean` | `false` | 是否显示输入框单位
前置条件:开启`showInput`且配置了`unit`单位时有效 |`6.0.0`后支持变量 -| onChange | `function` | | 当 组件 的值发生改变时,会触发 onChange 事件,并把改变后的值作为参数传入 | -| onAfterChange | `function` | | 与 `onmouseup` 触发时机一致,把当前值作为参数传入 | +| tooltipVisible | `boolean` | `false` | 是否显示滑块标签 | +| tooltipPlacement | `auto` or `bottom` or `left` or `right` | `top` | 滑块标签的位置,默认`auto`,方向自适应
前置条件:tooltipVisible 不为 false 时有效 | +| tipFormatter | `function` | | 控制滑块标签显隐函数
前置条件:tooltipVisible 不为 false 时有效 | +| multiple | `boolean` | `false` | 支持选择范围 | +| joinValues | `boolean` | `true` | 默认为 `true`,选择的 `value` 会通过 `delimiter` 连接起来,否则直接将以`{min: 1, max: 100}`的形式提交
前置条件:开启`multiple`时有效 | +| delimiter | `string` | `,` | 分隔符 | +| unit | `string` | | 单位 | +| clearable | `boolean` | `false` | 是否可清除
前置条件:开启`showInput`时有效 | +| showInput | `boolean` | `false` | 是否显示输入框 | +| showInputUnit | `boolean` | `false` | 是否显示输入框单位
前置条件:开启`showInput`且配置了`unit`单位时有效 | `6.0.0`后支持变量 | +| onChange | `function` | | 当 组件 的值发生改变时,会触发 onChange 事件,并把改变后的值作为参数传入 | +| onAfterChange | `function` | | 与 `onmouseup` 触发时机一致,把当前值作为参数传入 | ## 事件表 @@ -433,8 +433,109 @@ order: 38 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ---------------------------------------------------------------- | ---------------------------------------------------------- | -| clear | - | 清除输入框
前置条件:showInput 和 clearable 都为 true | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| setValue | `value: number \| string \| {min: number, max: number}` 更新的值 | 更新数据 | +| 动作名称 | 动作配置 | 说明 | +| -------- | ---------------------------------------------------------------- | ------------------------------------------------ | +| clear | - | 清除输入框 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| setValue | `value: number \| string \| {min: number, max: number}` 更新的值 | 更新数据 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-range", + "label": "滑块", + "name": "range", + "value": 20, + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-range", + "label": "滑块", + "name": "range", + "value": 20, + "id": "reset_text" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-range", + "label": "滑块", + "name": "range", + "value": 20, + "id": "setvalue_text" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": 30 + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-rating.md b/docs/zh-CN/components/form/input-rating.md index 1253e530e..1fe8e9bb5 100755 --- a/docs/zh-CN/components/form/input-rating.md +++ b/docs/zh-CN/components/form/input-rating.md @@ -174,8 +174,115 @@ order: 37 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ------------------------ | ------------------------------------------------------ | -| clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| setValue | `value: number` 更新的值 | 更新数据 | +| 动作名称 | 动作配置 | 说明 | +| -------- | ------------------------ | ------------------------------------------------ | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| setValue | `value: number` 更新的值 | 更新数据 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-rating", + "name": "rating", + "label": "评分", + "count": 5, + "value": 3.5, + "half": true, + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-rating", + "name": "rating", + "label": "评分", + "count": 5, + "value": 3.5, + "half": true, + "id": "reset_text" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-rating", + "name": "rating", + "label": "评分", + "count": 5, + "value": 3.5, + "half": true, + "id": "setvalue_text" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": 4 + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-table.md b/docs/zh-CN/components/form/input-table.md index 3405d888a..2f0f8388c 100755 --- a/docs/zh-CN/components/form/input-table.md +++ b/docs/zh-CN/components/form/input-table.md @@ -2549,7 +2549,7 @@ order: 54 "label": "表格表单", "id": "reset-input-table", "name": "table", - "resetValue": [ + "value": [ { "a": "a-resetValue1", "b": "b-resetValue1" diff --git a/docs/zh-CN/components/form/input-tag.md b/docs/zh-CN/components/form/input-tag.md index c48274690..869415af2 100755 --- a/docs/zh-CN/components/form/input-tag.md +++ b/docs/zh-CN/components/form/input-tag.md @@ -256,6 +256,164 @@ order: 55 | 动作名称 | 动作配置 | 说明 | | -------- | ------------------------ | ------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) | | setValue | `value: string` 更新的值 | 更新数据,多个值用`,`分隔 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-tag", + "name": "tag", + "label": "标签", + "placeholder": "请选择标签", + "options": [ + "Aaron Rodgers", + "Tom Brady", + "Charlse Woodson", + "Aaron Jones" + ], + "value": "Charlse Woodson", + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-tag", + "name": "tag", + "label": "标签", + "placeholder": "请选择标签", + "options": [ + "Aaron Rodgers", + "Tom Brady", + "Charlse Woodson", + "Aaron Jones" + ], + "value": "Charlse Woodson", + "id": "reset_text" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### reload + +只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-tag", + "name": "tag", + "label": "标签", + "placeholder": "请选择标签", + "id": "reload_type", + "source": "/api/mock2/form/getOptions?waitSeconds=1", + "value": "a" + }, + { + "type": "button", + "label": "重新加载", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reload", + "componentId": "reload_type" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-tag", + "name": "tag", + "label": "标签", + "placeholder": "请选择标签", + "options": [ + "Aaron Rodgers", + "Tom Brady", + "Charlse Woodson", + "Aaron Jones" + ], + "value": "Charlse Woodson", + "id": "setvalue_text" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": "Tom Brady" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-text.md b/docs/zh-CN/components/form/input-text.md index 37123841c..465c0180e 100755 --- a/docs/zh-CN/components/form/input-text.md +++ b/docs/zh-CN/components/form/input-text.md @@ -626,3 +626,173 @@ order: 56 | focus | - | 获取焦点 | | reload | - | 刷新(重新加载),只针对配置了`source`的输入框有效 | | setValue | `value: string` 更新的值 | 更新数据,开启`multiple`多选时用`,`分隔 | + +### clear + +如果配置了`clearValueOnEmpty: true`,则清空时将置为`undefined`,否则置为空字符串。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "text", + "id": "clear_text", + "type": "input-text", + "label": "text", + "value": "清空我" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "text", + "id": "reset_text", + "type": "input-text", + "label": "text", + "value": "重置我" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### focus + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "text", + "id": "focus_text", + "type": "input-text", + "label": "text", + "value": "聚焦我" + }, + { + "type": "button", + "label": "聚焦", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "focus", + "componentId": "focus_text" + } + ] + } + } + } + ] +} +``` + +### reload + +只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "text", + "id": "reload_text", + "type": "input-text", + "label": "text", + "value": "a", + "source": "/api/mock2/form/getOptions?waitSeconds=1" + }, + { + "type": "button", + "label": "重新加载", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reload", + "componentId": "reload_text" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "text", + "id": "setvalue_text", + "type": "input-text", + "label": "text", + "value": "amis" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": "amis go go go!" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-time-range.md b/docs/zh-CN/components/form/input-time-range.md index 32d62c5fc..3bd9d609b 100644 --- a/docs/zh-CN/components/form/input-time-range.md +++ b/docs/zh-CN/components/form/input-time-range.md @@ -118,5 +118,5 @@ order: 15 | 动作名称 | 动作配置 | 说明 | | -------- | ------------------------------------------- | -------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1617206400,1743436800' | diff --git a/docs/zh-CN/components/form/input-time.md b/docs/zh-CN/components/form/input-time.md index 6eb358056..d420fc860 100755 --- a/docs/zh-CN/components/form/input-time.md +++ b/docs/zh-CN/components/form/input-time.md @@ -276,8 +276,8 @@ order: 58 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ---------------------------- | ------------------------------------------------------ | -| clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1648746120' | +| 动作名称 | 动作配置 | 说明 | +| -------- | ---------------------------- | ------------------------------------------------ | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1648746120' | diff --git a/docs/zh-CN/components/form/input-tree.md b/docs/zh-CN/components/form/input-tree.md index 1a60c987d..887c2fe48 100755 --- a/docs/zh-CN/components/form/input-tree.md +++ b/docs/zh-CN/components/form/input-tree.md @@ -1453,5 +1453,139 @@ true false false [{label: 'A/B/C', value: 'a/b/c'},{label: 'A | delete | value: ` any` | 删除数据项的 value,(如果配置了 valueField,以 valueField 的字段值为准) | | reload | - | 刷新 | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-tree", + "name": "tree", + "label": "Tree", + "options": [ + { + "label": "Folder A", + "value": 1, + "children": [ + { + "label": "file A", + "value": 2 + }, + { + "label": "Folder B", + "value": 3, + "children": [ + { + "label": "file b1", + "value": 3.1 + }, + { + "label": "file b2", + "value": 3.2 + } + ] + } + ] + }, + { + "label": "file C", + "value": 4 + }, + { + "label": "file D", + "value": 5 + } + ], + "value": 5, + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "input-tree", + "name": "tree", + "label": "Tree", + "options": [ + { + "label": "Folder A", + "value": 1, + "children": [ + { + "label": "file A", + "value": 2 + }, + { + "label": "Folder B", + "value": 3, + "children": [ + { + "label": "file b1", + "value": 3.1 + }, + { + "label": "file b2", + "value": 3.2 + } + ] + } + ] + }, + { + "label": "file C", + "value": 4 + }, + { + "label": "file D", + "value": 5 + } + ], + "value": 5, + "id": "reset_text" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-year-range.md b/docs/zh-CN/components/form/input-year-range.md index b5fac2a28..25033800e 100644 --- a/docs/zh-CN/components/form/input-year-range.md +++ b/docs/zh-CN/components/form/input-year-range.md @@ -101,5 +101,5 @@ order: 15 | 动作名称 | 动作配置 | 说明 | | -------- | ------------------------------------------- | -------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1648746120,1648760760' | diff --git a/docs/zh-CN/components/form/input-year.md b/docs/zh-CN/components/form/input-year.md index 7ea3903ca..638f5c0db 100644 --- a/docs/zh-CN/components/form/input-year.md +++ b/docs/zh-CN/components/form/input-year.md @@ -42,8 +42,8 @@ order: 61 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ---------------------------- | ------------------------------------------------------ | -| clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1617206400' | +| 动作名称 | 动作配置 | 说明 | +| -------- | ---------------------------- | ------------------------------------------------ | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1617206400' | diff --git a/docs/zh-CN/components/form/list-select.md b/docs/zh-CN/components/form/list-select.md index e3897c708..27af913d2 100755 --- a/docs/zh-CN/components/form/list-select.md +++ b/docs/zh-CN/components/form/list-select.md @@ -147,6 +147,176 @@ ListSelect 一般用来实现选择,可以单选也可以多选,和 Radio/Ch | 动作名称 | 动作配置 | 说明 | | -------- | -------------------------------------- | --------------------------------------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) | | setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "list-select", + "name": "select", + "label": "单选", + "clearable": true, + "options": [ + { + "label": "Option A", + "value": "a" + }, + { + "label": "Option B", + "value": "b" + } + ], + "value": "a", + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "list-select", + "name": "select", + "label": "单选", + "clearable": true, + "options": [ + { + "label": "Option A", + "value": "a" + }, + { + "label": "Option B", + "value": "b" + } + ], + "value": "a", + "id": "reset_text" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### reload + +只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "list-select", + "name": "select", + "label": "单选", + "clearable": true, + "id": "reload_type", + "source": "/api/mock2/form/getOptions?waitSeconds=1", + "value": "a" + }, + { + "type": "button", + "label": "重新加载", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reload", + "componentId": "reload_type" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "list-select", + "name": "select", + "label": "单选", + "clearable": true, + "options": [ + { + "label": "Option A", + "value": "a" + }, + { + "label": "Option B", + "value": "b" + } + ], + "value": "a", + "id": "setvalue_text" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": "b" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/location-picker.md b/docs/zh-CN/components/form/location-picker.md index e9f26a257..4102f64d6 100644 --- a/docs/zh-CN/components/form/location-picker.md +++ b/docs/zh-CN/components/form/location-picker.md @@ -123,8 +123,129 @@ order: 30 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | -------- | ------------------------------------------------------ | -| clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| setValue | `value` | 参考 [`LocationData`](#LocationData) | +| 动作名称 | 动作配置 | 说明 | +| -------- | -------- | ------------------------------------------------ | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| setValue | `value` | 参考 [`LocationData`](#LocationData) | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "location-picker", + "name": "location", + "ak": "LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7", + "label": "地址", + "value": { + "address":"北京市西城区府右街131号", + "lat":39.916383659908185, + "lng":116.38854914523102, + "city":"北京市", + "vendor":"baidu" + }, + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "location-picker", + "name": "location", + "ak": "LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7", + "label": "地址", + "value": { + "address":"北京市西城区府右街131号", + "lat":39.916383659908185, + "lng":116.38854914523102, + "city":"北京市", + "vendor":"baidu" + }, + "id": "reset_text" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "location-picker", + "name": "location", + "ak": "LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7", + "label": "地址", + "id": "setvalue_text" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": { + "address":"北京市西城区府右街131号", + "lat":39.916383659908185, + "lng":116.38854914523102, + "city":"北京市", + "vendor":"baidu" + } + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/matrix-checkboxes.md b/docs/zh-CN/components/form/matrix-checkboxes.md index 02394c6a4..5f7764a69 100755 --- a/docs/zh-CN/components/form/matrix-checkboxes.md +++ b/docs/zh-CN/components/form/matrix-checkboxes.md @@ -383,6 +383,257 @@ row 模式,每行只能单选某个单元格 | 动作名称 | 动作配置 | 说明 | | -------- | ----------------------- | ------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) | | setValue | `value: Array` 更新的值 | 更新数据 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "matrix-checkboxes", + "name": "matrix", + "label": "Matrix", + "rowLabel": "行标题说明", + "columns": [ + { + "label": "列1" + }, + { + "label": "列2" + } + ], + "rows": [ + { + "label": "行1" + }, + { + "label": "行2" + } + ], + "value": [ + [ + { + "label": "列1", + "checked": true + }, + { + "label": "列1", + "checked": false + } + ], + [ + { + "label": "列2", + "checked": false + }, + { + "label": "列2", + "checked": true + } + ] + ], + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "matrix-checkboxes", + "name": "matrix", + "label": "Matrix", + "rowLabel": "行标题说明", + "columns": [ + { + "label": "列1" + }, + { + "label": "列2" + } + ], + "rows": [ + { + "label": "行1" + }, + { + "label": "行2" + } + ], + "value": [ + [ + { + "label": "列1", + "checked": true + }, + { + "label": "列1", + "checked": false + } + ], + [ + { + "label": "列2", + "checked": false + }, + { + "label": "列2", + "checked": true + } + ] + ], + "id": "reset_text" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### reload + +只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "list-select", + "name": "select", + "label": "单选", + "clearable": true, + "id": "reload_type", + "source": "/api/mock2/form/getOptions?waitSeconds=1", + "value": "a" + }, + { + "type": "button", + "label": "重新加载", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reload", + "componentId": "reload_type" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "matrix-checkboxes", + "name": "matrix", + "label": "Matrix", + "rowLabel": "行标题说明", + "columns": [ + { + "label": "列1" + }, + { + "label": "列2" + } + ], + "rows": [ + { + "label": "行1" + }, + { + "label": "行2" + } + ], + "value": "a", + "id": "setvalue_text" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": [ + [ + { + "label": "列1", + "checked": true + }, + { + "label": "列1", + "checked": true + } + ], + [ + { + "label": "列2", + "checked": false + }, + { + "label": "列2", + "checked": true + } + ] + ] + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/nestedselect.md b/docs/zh-CN/components/form/nestedselect.md index b1a01a9d8..2131d3de7 100755 --- a/docs/zh-CN/components/form/nestedselect.md +++ b/docs/zh-CN/components/form/nestedselect.md @@ -844,6 +844,226 @@ order: 31 | 动作名称 | 动作配置 | 说明 | | -------- | ------------------------ | ------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) | | setValue | `value: string` 更新的值 | 更新数据,开启`multiple`时,多个值用`,`分隔 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "nested-select", + "name": "nestedSelect", + "label": "级联选择器", + "options": [ + { + "label": "A", + "value": "a" + }, + { + "label": "B", + "value": "b", + "children": [ + { + "label": "B-1", + "value": "b-1" + }, + { + "label": "B-2", + "value": "b-2" + }, + { + "label": "B-3", + "value": "b-3" + } + ] + }, + { + "label": "C", + "value": "c" + } + ], + "value": "a", + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "nested-select", + "name": "nestedSelect", + "label": "级联选择器", + "options": [ + { + "label": "A", + "value": "a" + }, + { + "label": "B", + "value": "b", + "children": [ + { + "label": "B-1", + "value": "b-1" + }, + { + "label": "B-2", + "value": "b-2" + }, + { + "label": "B-3", + "value": "b-3" + } + ] + }, + { + "label": "C", + "value": "c" + } + ], + "value": "a", + "id": "reset_text" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### reload + +只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "nested-select", + "name": "nestedSelect", + "label": "级联选择器", + "id": "reload_type", + "source": "/api/mock2/form/getTreeOptions", + "value": "a" + }, + { + "type": "button", + "label": "重新加载", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reload", + "componentId": "reload_type" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "nested-select", + "name": "nestedSelect", + "label": "级联选择器", + "options": [ + { + "label": "A", + "value": "a" + }, + { + "label": "B", + "value": "b", + "children": [ + { + "label": "B-1", + "value": "b-1" + }, + { + "label": "B-2", + "value": "b-2" + }, + { + "label": "B-3", + "value": "b-3" + } + ] + }, + { + "label": "C", + "value": "c" + } + ], + "value": "a", + "id": "setvalue_text" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": "b" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/radio.md b/docs/zh-CN/components/form/radio.md index fb49428a8..0df0cc71b 100644 --- a/docs/zh-CN/components/form/radio.md +++ b/docs/zh-CN/components/form/radio.md @@ -210,8 +210,112 @@ order: 8 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ------------------------------------------- | ------------------------------------------------------ | -| clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| setValue | `value: string \|number \|boolean` 更新的值 | 更新数据 | +| 动作名称 | 动作配置 | 说明 | +| -------- | ------------------------------------------- | ------------------------------------------------ | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| setValue | `value: string \|number \|boolean` 更新的值 | 更新数据 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "radio", + "label": "选项", + "name": "type", + "id": "clear_type", + "option": "选项说明", + "value": true + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_type" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "radio", + "label": "选项", + "name": "type", + "id": "reset_type", + "option": "选项说明", + "value": false + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_type" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "radio", + "label": "选项", + "name": "type", + "id": "setvalue_type", + "option": "选项说明", + "value": true + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_type", + "args": { + "value": false + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/radios.md b/docs/zh-CN/components/form/radios.md index 10cf4dbb1..38f28f1b1 100644 --- a/docs/zh-CN/components/form/radios.md +++ b/docs/zh-CN/components/form/radios.md @@ -313,6 +313,196 @@ api 返回内容需要包含 options 字段 | 动作名称 | 动作配置 | 说明 | | -------- | ------------------------ | ------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) | | setValue | `value: string` 更新的值 | 更新数据 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "radios", + "type": "radios", + "label": "radios", + "options": [ + { + "label": "OptionA", + "value": "a" + }, + { + "label": "OptionB", + "value": "b" + }, + { + "label": "OptionC", + "value": "c" + }, + { + "label": "OptionD", + "value": "d" + } + ], + "value": "a", + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "radios", + "type": "radios", + "label": "radios", + "options": [ + { + "label": "OptionA", + "value": "a" + }, + { + "label": "OptionB", + "value": "b" + }, + { + "label": "OptionC", + "value": "c" + }, + { + "label": "OptionD", + "value": "d" + } + ], + "value": "a", + "id": "reset_text" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### reload + +只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "radios", + "type": "radios", + "label": "radios", + "id": "reload_type", + "source": "/api/mock2/form/getOptions", + "value": "a" + }, + { + "type": "button", + "label": "重新加载", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reload", + "componentId": "reload_type" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "radios", + "type": "radios", + "label": "radios", + "options": [ + { + "label": "OptionA", + "value": "a" + }, + { + "label": "OptionB", + "value": "b" + }, + { + "label": "OptionC", + "value": "c" + }, + { + "label": "OptionD", + "value": "d" + } + ], + "value": "a", + "id": "setvalue_text" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": "b" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/select.md b/docs/zh-CN/components/form/select.md index 0fe1b3545..4dafc0b60 100755 --- a/docs/zh-CN/components/form/select.md +++ b/docs/zh-CN/components/form/select.md @@ -1566,10 +1566,112 @@ leftOptions 动态加载,默认 source 接口是返回 options 部分,而 le | 动作名称 | 动作配置 | 说明 | | -------- | -------------------------------------- | --------------------------------------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) | | setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 | +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "select", + "type": "select", + "label": "select", + "options": [ + { + "label": "OptionA", + "value": "a" + }, + { + "label": "OptionB", + "value": "b" + }, + { + "label": "OptionC", + "value": "c" + }, + { + "label": "OptionD", + "value": "d" + } + ], + "value": "a", + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "select", + "type": "select", + "label": "select", + "options": [ + { + "label": "OptionA", + "value": "a" + }, + { + "label": "OptionB", + "value": "b" + }, + { + "label": "OptionC", + "value": "c" + }, + { + "label": "OptionD", + "value": "d" + } + ], + "value": "a", + "id": "reset_text" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + ### 刷新数据源 reload ```schema: scope="body" @@ -1635,3 +1737,56 @@ leftOptions 动态加载,默认 source 接口是返回 options 部分,而 le ] } ``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "select", + "type": "select", + "label": "select", + "options": [ + { + "label": "OptionA", + "value": "a" + }, + { + "label": "OptionB", + "value": "b" + }, + { + "label": "OptionC", + "value": "c" + }, + { + "label": "OptionD", + "value": "d" + } + ], + "value": "a", + "id": "setvalue_text" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": "b" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/switch.md b/docs/zh-CN/components/form/switch.md index c54949916..647899ec0 100755 --- a/docs/zh-CN/components/form/switch.md +++ b/docs/zh-CN/components/form/switch.md @@ -102,7 +102,7 @@ order: 51 } ``` -### 使用Schema配置文本 +### 使用 Schema 配置文本 > `3.6.0` 版本之后支持 @@ -142,7 +142,6 @@ order: 51 } ``` - ## 默认值 和其它表单项一样,如果要设置默认值,可以使用 value 属性 @@ -294,15 +293,15 @@ order: 51 除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置 -| 属性名 | 类型 | 默认值 | 说明 | 版本 | -| ---------- | --------------------------- | ------- | -------------------- | --- | -| option | `string` | | 选项说明 | -| onText | `string \| IconSchema \| SchemaCollection` | | 开启时开关显示的内容 | `3.6.0`支持Schema | -| offText | `string \| IconSchema \| SchemaCollection` | | 关闭时开关显示的内容 | `3.6.0`支持Schema | -| trueValue | `boolean \| string \| number` | `true` | 标识真值 | -| falseValue | `boolean \| string \| number` | `false` | 标识假值 | -| size | `"sm" \| "md"` | `"md"` | 开关大小 | -| loading | `boolean` | `false` | 是否处于加载状态 | `3.6.0` | +| 属性名 | 类型 | 默认值 | 说明 | 版本 | +| ---------- | ------------------------------------------ | ------- | -------------------- | ------------------ | +| option | `string` | | 选项说明 | +| onText | `string \| IconSchema \| SchemaCollection` | | 开启时开关显示的内容 | `3.6.0`支持 Schema | +| offText | `string \| IconSchema \| SchemaCollection` | | 关闭时开关显示的内容 | `3.6.0`支持 Schema | +| trueValue | `boolean \| string \| number` | `true` | 标识真值 | +| falseValue | `boolean \| string \| number` | `false` | 标识假值 | +| size | `"sm" \| "md"` | `"md"` | 开关大小 | +| loading | `boolean` | `false` | 是否处于加载状态 | `3.6.0` | IconSchema 配置 | 属性名 | 类型 | 默认值 | 说明 | @@ -420,9 +419,76 @@ switch 值更新时弹出确认提示,确认后发送请求。 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ------------------------------------- | -------- | -| setValue | `value: string \| boolean` 更新的数据 | 更新数据 | +| 动作名称 | 动作配置 | 说明 | +| -------- | ------------------------------------- | ---------------------------------------------------------------------- | --- | +| clear | - | 清空,6.3.1 及以上版本支持 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue`,6.3.1 及以上版本支持 | | +| setValue | `value: string \| boolean` 更新的数据 | 更新数据 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "switch", + "label": "开关", + "type": "switch", + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "switch", + "label": "开关", + "type": "switch", + "id": "reset_text", + "value": true + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` ### setValue diff --git a/docs/zh-CN/components/form/tabs-transfer-picker.md b/docs/zh-CN/components/form/tabs-transfer-picker.md index df2c7d3b6..3a44d5aed 100644 --- a/docs/zh-CN/components/form/tabs-transfer-picker.md +++ b/docs/zh-CN/components/form/tabs-transfer-picker.md @@ -169,5 +169,391 @@ icon: | 动作名称 | 动作配置 | 说明 | | -------- | -------------------------------------- | --------------------------------------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "label": "穿梭选择器", + "type": "tabs-transfer-picker", + "name": "a", + "sortable": true, + "selectMode": "tree", + "options": [ + { + "label": "成员", + "selectMode": "tree", + "searchable": true, + "children": [ + { + "label": "法师", + "children": [ + { + "label": "诸葛亮", + "value": "zhugeliang" + } + ] + }, + { + "label": "战士", + "children": [ + { + "label": "曹操", + "value": "caocao" + }, + { + "label": "钟无艳", + "value": "zhongwuyan" + } + ] + }, + { + "label": "打野", + "children": [ + { + "label": "李白", + "value": "libai" + }, + { + "label": "韩信", + "value": "hanxin" + }, + { + "label": "云中君", + "value": "yunzhongjun" + } + ] + } + ] + }, + { + "label": "用户", + "selectMode": "chained", + "children": [ + { + "label": "法师", + "children": [ + { + "label": "诸葛亮", + "value": "zhugeliang2" + } + ] + }, + { + "label": "战士", + "children": [ + { + "label": "曹操", + "value": "caocao2" + }, + { + "label": "钟无艳", + "value": "zhongwuyan2" + } + ] + }, + { + "label": "打野", + "children": [ + { + "label": "李白", + "value": "libai2" + }, + { + "label": "韩信", + "value": "hanxin2" + }, + { + "label": "云中君", + "value": "yunzhongjun2" + } + ] + } + ] + } + ], + "value": "zhugeliang", + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "label": "穿梭选择器", + "type": "tabs-transfer-picker", + "name": "a", + "sortable": true, + "selectMode": "tree", + "options": [ + { + "label": "成员", + "selectMode": "tree", + "searchable": true, + "children": [ + { + "label": "法师", + "children": [ + { + "label": "诸葛亮", + "value": "zhugeliang" + } + ] + }, + { + "label": "战士", + "children": [ + { + "label": "曹操", + "value": "caocao" + }, + { + "label": "钟无艳", + "value": "zhongwuyan" + } + ] + }, + { + "label": "打野", + "children": [ + { + "label": "李白", + "value": "libai" + }, + { + "label": "韩信", + "value": "hanxin" + }, + { + "label": "云中君", + "value": "yunzhongjun" + } + ] + } + ] + }, + { + "label": "用户", + "selectMode": "chained", + "children": [ + { + "label": "法师", + "children": [ + { + "label": "诸葛亮", + "value": "zhugeliang2" + } + ] + }, + { + "label": "战士", + "children": [ + { + "label": "曹操", + "value": "caocao2" + }, + { + "label": "钟无艳", + "value": "zhongwuyan2" + } + ] + }, + { + "label": "打野", + "children": [ + { + "label": "李白", + "value": "libai2" + }, + { + "label": "韩信", + "value": "hanxin2" + }, + { + "label": "云中君", + "value": "yunzhongjun2" + } + ] + } + ] + } + ], + "value": "zhugeliang", + "id": "reset_text" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "label": "穿梭选择器", + "type": "tabs-transfer-picker", + "name": "a", + "sortable": true, + "selectMode": "tree", + "options": [ + { + "label": "成员", + "selectMode": "tree", + "searchable": true, + "children": [ + { + "label": "法师", + "children": [ + { + "label": "诸葛亮", + "value": "zhugeliang" + } + ] + }, + { + "label": "战士", + "children": [ + { + "label": "曹操", + "value": "caocao" + }, + { + "label": "钟无艳", + "value": "zhongwuyan" + } + ] + }, + { + "label": "打野", + "children": [ + { + "label": "李白", + "value": "libai" + }, + { + "label": "韩信", + "value": "hanxin" + }, + { + "label": "云中君", + "value": "yunzhongjun" + } + ] + } + ] + }, + { + "label": "用户", + "selectMode": "chained", + "children": [ + { + "label": "法师", + "children": [ + { + "label": "诸葛亮", + "value": "zhugeliang2" + } + ] + }, + { + "label": "战士", + "children": [ + { + "label": "曹操", + "value": "caocao2" + }, + { + "label": "钟无艳", + "value": "zhongwuyan2" + } + ] + }, + { + "label": "打野", + "children": [ + { + "label": "李白", + "value": "libai2" + }, + { + "label": "韩信", + "value": "hanxin2" + }, + { + "label": "云中君", + "value": "yunzhongjun2" + } + ] + } + ] + } + ], + "value": "zhugeliang", + "id": "setvalue_text" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": "yunzhongjun2" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/tabs-transfer.md b/docs/zh-CN/components/form/tabs-transfer.md index e55ebdabe..5f04d1427 100644 --- a/docs/zh-CN/components/form/tabs-transfer.md +++ b/docs/zh-CN/components/form/tabs-transfer.md @@ -631,7 +631,393 @@ icon: | 动作名称 | 动作配置 | 说明 | | ------------ | -------------------------------------- | --------------------------------------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | selectAll | - | 全选 | | changeTabKey | `activeKey: number` 选中的 Tab | 修改当前选中 tab,来选择其他选项 | | setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "label": "组合穿梭器", + "type": "tabs-transfer", + "name": "a", + "sortable": true, + "selectMode": "tree", + "options": [ + { + "label": "成员", + "selectMode": "tree", + "searchable": true, + "children": [ + { + "label": "法师", + "children": [ + { + "label": "诸葛亮", + "value": "zhugeliang" + } + ] + }, + { + "label": "战士", + "children": [ + { + "label": "曹操", + "value": "caocao" + }, + { + "label": "钟无艳", + "value": "zhongwuyan" + } + ] + }, + { + "label": "打野", + "children": [ + { + "label": "李白", + "value": "libai" + }, + { + "label": "韩信", + "value": "hanxin" + }, + { + "label": "云中君", + "value": "yunzhongjun" + } + ] + } + ] + }, + { + "label": "用户", + "selectMode": "chained", + "children": [ + { + "label": "法师", + "children": [ + { + "label": "诸葛亮", + "value": "zhugeliang2" + } + ] + }, + { + "label": "战士", + "children": [ + { + "label": "曹操", + "value": "caocao2" + }, + { + "label": "钟无艳", + "value": "zhongwuyan2" + } + ] + }, + { + "label": "打野", + "children": [ + { + "label": "李白", + "value": "libai2" + }, + { + "label": "韩信", + "value": "hanxin2" + }, + { + "label": "云中君", + "value": "yunzhongjun2" + } + ] + } + ] + } + ], + "value": "zhugeliang", + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "label": "组合穿梭器", + "type": "tabs-transfer", + "name": "a", + "sortable": true, + "selectMode": "tree", + "options": [ + { + "label": "成员", + "selectMode": "tree", + "searchable": true, + "children": [ + { + "label": "法师", + "children": [ + { + "label": "诸葛亮", + "value": "zhugeliang" + } + ] + }, + { + "label": "战士", + "children": [ + { + "label": "曹操", + "value": "caocao" + }, + { + "label": "钟无艳", + "value": "zhongwuyan" + } + ] + }, + { + "label": "打野", + "children": [ + { + "label": "李白", + "value": "libai" + }, + { + "label": "韩信", + "value": "hanxin" + }, + { + "label": "云中君", + "value": "yunzhongjun" + } + ] + } + ] + }, + { + "label": "用户", + "selectMode": "chained", + "children": [ + { + "label": "法师", + "children": [ + { + "label": "诸葛亮", + "value": "zhugeliang2" + } + ] + }, + { + "label": "战士", + "children": [ + { + "label": "曹操", + "value": "caocao2" + }, + { + "label": "钟无艳", + "value": "zhongwuyan2" + } + ] + }, + { + "label": "打野", + "children": [ + { + "label": "李白", + "value": "libai2" + }, + { + "label": "韩信", + "value": "hanxin2" + }, + { + "label": "云中君", + "value": "yunzhongjun2" + } + ] + } + ] + } + ], + "value": "zhugeliang", + "id": "reset_text" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "label": "组合穿梭器", + "type": "tabs-transfer", + "name": "a", + "sortable": true, + "selectMode": "tree", + "options": [ + { + "label": "成员", + "selectMode": "tree", + "searchable": true, + "children": [ + { + "label": "法师", + "children": [ + { + "label": "诸葛亮", + "value": "zhugeliang" + } + ] + }, + { + "label": "战士", + "children": [ + { + "label": "曹操", + "value": "caocao" + }, + { + "label": "钟无艳", + "value": "zhongwuyan" + } + ] + }, + { + "label": "打野", + "children": [ + { + "label": "李白", + "value": "libai" + }, + { + "label": "韩信", + "value": "hanxin" + }, + { + "label": "云中君", + "value": "yunzhongjun" + } + ] + } + ] + }, + { + "label": "用户", + "selectMode": "chained", + "children": [ + { + "label": "法师", + "children": [ + { + "label": "诸葛亮", + "value": "zhugeliang2" + } + ] + }, + { + "label": "战士", + "children": [ + { + "label": "曹操", + "value": "caocao2" + }, + { + "label": "钟无艳", + "value": "zhongwuyan2" + } + ] + }, + { + "label": "打野", + "children": [ + { + "label": "李白", + "value": "libai2" + }, + { + "label": "韩信", + "value": "hanxin2" + }, + { + "label": "云中君", + "value": "yunzhongjun2" + } + ] + } + ] + } + ], + "value": "zhugeliang", + "id": "setvalue_text" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": "yunzhongjun2" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/textarea.md b/docs/zh-CN/components/form/textarea.md index e580607d2..1fbf06f3c 100755 --- a/docs/zh-CN/components/form/textarea.md +++ b/docs/zh-CN/components/form/textarea.md @@ -121,9 +121,142 @@ order: 57 当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。 -| 动作名称 | 动作配置 | 说明 | -| -------- | ------------------------ | ------------------------------------------------------ | -| clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | -| focus | - | 获取焦点 | -| setValue | `value: string` 更新的值 | 更新数据 | +| 动作名称 | 动作配置 | 说明 | +| -------- | ------------------------ | ------------------------------------------------ | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| focus | - | 获取焦点 | +| setValue | `value: string` 更新的值 | 更新数据 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "text", + "id": "clear_text", + "type": "textarea", + "label": "text", + "value": "清空我" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "text", + "id": "reset_text", + "type": "textarea", + "label": "text", + "value": "重置我" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### focus + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "text", + "id": "focus_text", + "type": "textarea", + "label": "text", + "value": "聚焦我" + }, + { + "type": "button", + "label": "聚焦", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "focus", + "componentId": "focus_text" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "name": "text", + "id": "setvalue_text", + "type": "textarea", + "label": "text", + "value": "amis" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": "amis go go go!" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/transfer-picker.md b/docs/zh-CN/components/form/transfer-picker.md index 932d68fa8..391679d88 100644 --- a/docs/zh-CN/components/form/transfer-picker.md +++ b/docs/zh-CN/components/form/transfer-picker.md @@ -117,12 +117,13 @@ icon: ``` ## 属性表 + 下面属性为`transfer-picker`独占属性, 更多属性用法,参考[穿梭器(Transfer)](./transfer) -| 属性名 | 类型 | 默认值 | 说明 -| ----------------- | --------- | ------- | ------------------------------------------------- -| borderMode | `'full'` \| `'half'` \| `'none'` | | 边框模式,`'full'`为全边框,`'half'`为半边框,`'none'`为没边框 | -| pickerSize | string | | 弹窗大小,支持: xs、sm、md、lg、xl、full | +| 属性名 | 类型 | 默认值 | 说明 | +| ---------- | -------------------------------- | ------ | -------------------------------------------------------------- | +| borderMode | `'full'` \| `'half'` \| `'none'` | | 边框模式,`'full'`为全边框,`'half'`为半边框,`'none'`为没边框 | +| pickerSize | string | | 弹窗大小,支持: xs、sm、md、lg、xl、full | ## 事件表 @@ -143,5 +144,187 @@ icon: | 动作名称 | 动作配置 | 说明 | | -------- | -------------------------------------- | --------------------------------------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "label": "默认", + "type": "transfer-picker", + "name": "transfer", + "value": "zhugeliang,libai", + "options": [ + { + "label": "诸葛亮", + "value": "zhugeliang" + }, + { + "label": "曹操", + "value": "caocao" + }, + { + "label": "钟无艳", + "value": "zhongwuyan" + }, + { + "label": "李白", + "value": "libai" + }, + { + "label": "韩信", + "value": "hanxin" + }, + { + "label": "云中君", + "value": "yunzhongjun" + } + ], + "value": "zhugeliang", + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "label": "默认", + "type": "transfer-picker", + "name": "transfer", + "value": "zhugeliang,libai", + "options": [ + { + "label": "诸葛亮", + "value": "zhugeliang" + }, + { + "label": "曹操", + "value": "caocao" + }, + { + "label": "钟无艳", + "value": "zhongwuyan" + }, + { + "label": "李白", + "value": "libai" + }, + { + "label": "韩信", + "value": "hanxin" + }, + { + "label": "云中君", + "value": "yunzhongjun" + } + ], + "value": "zhugeliang", + "id": "reset_text" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "label": "默认", + "type": "transfer-picker", + "name": "transfer", + "value": "zhugeliang,libai", + "options": [ + { + "label": "诸葛亮", + "value": "zhugeliang" + }, + { + "label": "曹操", + "value": "caocao" + }, + { + "label": "钟无艳", + "value": "zhongwuyan" + }, + { + "label": "李白", + "value": "libai" + }, + { + "label": "韩信", + "value": "hanxin" + }, + { + "label": "云中君", + "value": "yunzhongjun" + } + ], + "value": "zhugeliang", + "id": "setvalue_text" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": "yunzhongjun" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/transfer.md b/docs/zh-CN/components/form/transfer.md index 337ab0d49..6c0a4ff02 100644 --- a/docs/zh-CN/components/form/transfer.md +++ b/docs/zh-CN/components/form/transfer.md @@ -1101,7 +1101,189 @@ icon: | 动作名称 | 动作配置 | 说明 | | ----------- | ------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | clearSearch | `left: boolean` 左侧搜索、`right:boolean`右侧搜索 | 默认清除所有搜索态,可以单独配置`left`、`right`为`true`来清空对应左侧或者右侧面板(`3.4.0`及以上版本支持) | | selectAll | - | 全选 | | setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "label": "默认", + "type": "transfer", + "name": "transfer", + "value": "zhugeliang,libai", + "options": [ + { + "label": "诸葛亮", + "value": "zhugeliang" + }, + { + "label": "曹操", + "value": "caocao" + }, + { + "label": "钟无艳", + "value": "zhongwuyan" + }, + { + "label": "李白", + "value": "libai" + }, + { + "label": "韩信", + "value": "hanxin" + }, + { + "label": "云中君", + "value": "yunzhongjun" + } + ], + "value": "zhugeliang", + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "label": "默认", + "type": "transfer", + "name": "transfer", + "value": "zhugeliang,libai", + "options": [ + { + "label": "诸葛亮", + "value": "zhugeliang" + }, + { + "label": "曹操", + "value": "caocao" + }, + { + "label": "钟无艳", + "value": "zhongwuyan" + }, + { + "label": "李白", + "value": "libai" + }, + { + "label": "韩信", + "value": "hanxin" + }, + { + "label": "云中君", + "value": "yunzhongjun" + } + ], + "value": "zhugeliang", + "id": "reset_text" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` + +### setValue + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "label": "默认", + "type": "transfer", + "name": "transfer", + "value": "zhugeliang,libai", + "options": [ + { + "label": "诸葛亮", + "value": "zhugeliang" + }, + { + "label": "曹操", + "value": "caocao" + }, + { + "label": "钟无艳", + "value": "zhongwuyan" + }, + { + "label": "李白", + "value": "libai" + }, + { + "label": "韩信", + "value": "hanxin" + }, + { + "label": "云中君", + "value": "yunzhongjun" + } + ], + "value": "zhugeliang", + "id": "setvalue_text" + }, + { + "type": "button", + "label": "赋值", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "setValue", + "componentId": "setvalue_text", + "args": { + "value": "yunzhongjun" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/treeselect.md b/docs/zh-CN/components/form/treeselect.md index ca0c1ff97..546eaaed6 100755 --- a/docs/zh-CN/components/form/treeselect.md +++ b/docs/zh-CN/components/form/treeselect.md @@ -823,5 +823,139 @@ order: 60 | delete | value: ` any` | 删除数据项的 value,(如果配置了 valueField,以 valueField 的字段值为准) | | reload | - | 刷新 | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 | + +### clear + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "tree-select", + "name": "tree", + "label": "Tree", + "options": [ + { + "label": "Folder A", + "value": 1, + "children": [ + { + "label": "file A", + "value": 2 + }, + { + "label": "Folder B", + "value": 3, + "children": [ + { + "label": "file b1", + "value": 3.1 + }, + { + "label": "file b2", + "value": 3.2 + } + ] + } + ] + }, + { + "label": "file C", + "value": 4 + }, + { + "label": "file D", + "value": 5 + } + ], + "value": 5, + "id": "clear_text" + }, + { + "type": "button", + "label": "清空", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "clear", + "componentId": "clear_text" + } + ] + } + } + } + ] +} +``` + +### reset + +如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。 + +```schema: scope="body" +{ + "type": "form", + "debug": true, + "body": [ + { + "type": "tree-select", + "name": "tree", + "label": "Tree", + "options": [ + { + "label": "Folder A", + "value": 1, + "children": [ + { + "label": "file A", + "value": 2 + }, + { + "label": "Folder B", + "value": 3, + "children": [ + { + "label": "file b1", + "value": 3.1 + }, + { + "label": "file b2", + "value": 3.2 + } + ] + } + ] + }, + { + "label": "file C", + "value": 4 + }, + { + "label": "file D", + "value": 5 + } + ], + "value": 5, + "id": "reset_text" + }, + { + "type": "button", + "label": "重置", + "onEvent": { + "click": { + "actions": [ + { + "actionType": "reset", + "componentId": "reset_text" + } + ] + } + } + } + ] +} +``` diff --git a/packages/amis-editor/src/locale/en-US.ts b/packages/amis-editor/src/locale/en-US.ts index 7a33903b3..d49a0a220 100644 --- a/packages/amis-editor/src/locale/en-US.ts +++ b/packages/amis-editor/src/locale/en-US.ts @@ -632,9 +632,7 @@ extendLocale('en-US', { '528609917710d813a55e5a6cecf1e458': 'Selected value', '288f0c404c4e546aa3683ff5054e85e2': 'Clear', 'c374a44713fa5ff5da2565beb398c7d3': 'Delete selected value', - '8db57ba01ffb9bf29c1656de5f0208f5': - 'Reset the value to resetValue. If the resetValue is not configured, the value is cleared.', - '8f40db3b25528063f1b6a59602a05cd5': 'Value assignment', + '8db57ba01ffb9bf29c1656de5f0208f5': 'Reset the value to the initial value.', '944908c981a86bfa0cfab9360ab38184': 'Allow the button to occupy the parent container fully. The width of individual buttons is adaptive.', 'ac3880323853de9adc4f66bc06d438ff': 'Button style', diff --git a/packages/amis-editor/src/locale/zh-CN.ts b/packages/amis-editor/src/locale/zh-CN.ts index d8d7ed8d2..21a5e60e0 100644 --- a/packages/amis-editor/src/locale/zh-CN.ts +++ b/packages/amis-editor/src/locale/zh-CN.ts @@ -636,8 +636,7 @@ extendLocale('zh-CN', { '528609917710d813a55e5a6cecf1e458': '选中值', '288f0c404c4e546aa3683ff5054e85e2': '清空', 'c374a44713fa5ff5da2565beb398c7d3': '清除选中值', - '8db57ba01ffb9bf29c1656de5f0208f5': - '将值重置为resetValue,若没有配置resetValue,则清空', + '8db57ba01ffb9bf29c1656de5f0208f5': '将值重置为初始值', '8f40db3b25528063f1b6a59602a05cd5': '赋值', '944908c981a86bfa0cfab9360ab38184': '使按钮宽度占满父容器,各按钮宽度自适应', '0b98b0bea3db6ae5b67a09c7bb2d032b': '按钮选中样式', diff --git a/packages/amis-editor/src/plugin/Calendar.tsx b/packages/amis-editor/src/plugin/Calendar.tsx index 2902b70fa..6230e7363 100644 --- a/packages/amis-editor/src/plugin/Calendar.tsx +++ b/packages/amis-editor/src/plugin/Calendar.tsx @@ -131,7 +131,7 @@ export class CalendarPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/ButtonGroupSelect.tsx b/packages/amis-editor/src/plugin/Form/ButtonGroupSelect.tsx index 033ddfb80..9de5d9d35 100644 --- a/packages/amis-editor/src/plugin/Form/ButtonGroupSelect.tsx +++ b/packages/amis-editor/src/plugin/Form/ButtonGroupSelect.tsx @@ -100,7 +100,7 @@ export class ButtonGroupControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'reload', diff --git a/packages/amis-editor/src/plugin/Form/ChainedSelect.tsx b/packages/amis-editor/src/plugin/Form/ChainedSelect.tsx index 6d8c30545..770f55da6 100644 --- a/packages/amis-editor/src/plugin/Form/ChainedSelect.tsx +++ b/packages/amis-editor/src/plugin/Form/ChainedSelect.tsx @@ -88,7 +88,7 @@ export class ChainedSelectControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'reload', diff --git a/packages/amis-editor/src/plugin/Form/Checkbox.tsx b/packages/amis-editor/src/plugin/Form/Checkbox.tsx index bafe5e255..1f00333f4 100644 --- a/packages/amis-editor/src/plugin/Form/Checkbox.tsx +++ b/packages/amis-editor/src/plugin/Form/Checkbox.tsx @@ -108,7 +108,7 @@ export class CheckboxControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/Checkboxes.tsx b/packages/amis-editor/src/plugin/Form/Checkboxes.tsx index 076bcafd1..6f615b9a9 100644 --- a/packages/amis-editor/src/plugin/Form/Checkboxes.tsx +++ b/packages/amis-editor/src/plugin/Form/Checkboxes.tsx @@ -113,7 +113,7 @@ export class CheckboxesControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'reload', diff --git a/packages/amis-editor/src/plugin/Form/CodeEditor.tsx b/packages/amis-editor/src/plugin/Form/CodeEditor.tsx index 3d7250038..b8a42372c 100644 --- a/packages/amis-editor/src/plugin/Form/CodeEditor.tsx +++ b/packages/amis-editor/src/plugin/Form/CodeEditor.tsx @@ -120,7 +120,7 @@ export class CodeEditorControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'focus', diff --git a/packages/amis-editor/src/plugin/Form/Combo.tsx b/packages/amis-editor/src/plugin/Form/Combo.tsx index c56afd1cf..519fe0b06 100644 --- a/packages/amis-editor/src/plugin/Form/Combo.tsx +++ b/packages/amis-editor/src/plugin/Form/Combo.tsx @@ -254,7 +254,7 @@ export class ComboControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'addItem', diff --git a/packages/amis-editor/src/plugin/Form/DiffEditor.tsx b/packages/amis-editor/src/plugin/Form/DiffEditor.tsx index 004b2d812..214cc8047 100644 --- a/packages/amis-editor/src/plugin/Form/DiffEditor.tsx +++ b/packages/amis-editor/src/plugin/Form/DiffEditor.tsx @@ -127,7 +127,7 @@ export class DiffEditorControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'focus', diff --git a/packages/amis-editor/src/plugin/Form/InputDate.tsx b/packages/amis-editor/src/plugin/Form/InputDate.tsx index bb2463f9a..2020cf2cc 100644 --- a/packages/amis-editor/src/plugin/Form/InputDate.tsx +++ b/packages/amis-editor/src/plugin/Form/InputDate.tsx @@ -253,7 +253,7 @@ export class DateControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/InputDateRange.tsx b/packages/amis-editor/src/plugin/Form/InputDateRange.tsx index 168409660..d4a33e17a 100644 --- a/packages/amis-editor/src/plugin/Form/InputDateRange.tsx +++ b/packages/amis-editor/src/plugin/Form/InputDateRange.tsx @@ -299,7 +299,7 @@ export class DateRangeControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/InputExcel.tsx b/packages/amis-editor/src/plugin/Form/InputExcel.tsx index c52aa6f68..0471c0dc2 100644 --- a/packages/amis-editor/src/plugin/Form/InputExcel.tsx +++ b/packages/amis-editor/src/plugin/Form/InputExcel.tsx @@ -85,7 +85,7 @@ export class ExcelControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/InputKV.tsx b/packages/amis-editor/src/plugin/Form/InputKV.tsx index 997149755..5d548ecef 100644 --- a/packages/amis-editor/src/plugin/Form/InputKV.tsx +++ b/packages/amis-editor/src/plugin/Form/InputKV.tsx @@ -118,7 +118,7 @@ export class KVControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/InputRange.tsx b/packages/amis-editor/src/plugin/Form/InputRange.tsx index 56446ad7c..05da18d95 100644 --- a/packages/amis-editor/src/plugin/Form/InputRange.tsx +++ b/packages/amis-editor/src/plugin/Form/InputRange.tsx @@ -160,7 +160,7 @@ export class RangeControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/InputRating.tsx b/packages/amis-editor/src/plugin/Form/InputRating.tsx index 4ebb4e39f..2c4693465 100644 --- a/packages/amis-editor/src/plugin/Form/InputRating.tsx +++ b/packages/amis-editor/src/plugin/Form/InputRating.tsx @@ -85,7 +85,7 @@ export class RateControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/InputTable.tsx b/packages/amis-editor/src/plugin/Form/InputTable.tsx index 360f2de7a..3b5f4dd53 100644 --- a/packages/amis-editor/src/plugin/Form/InputTable.tsx +++ b/packages/amis-editor/src/plugin/Form/InputTable.tsx @@ -1094,7 +1094,7 @@ export class TableControlPlugin extends BasePlugin { // { // actionType: 'reset', // actionLabel: '重置', - // description: '将值重置为resetValue,若没有配置resetValue,则清空' + // description: '将值重置为初始值' // }, { actionType: 'clear', diff --git a/packages/amis-editor/src/plugin/Form/InputText.tsx b/packages/amis-editor/src/plugin/Form/InputText.tsx index 69002e7b2..0062242f8 100644 --- a/packages/amis-editor/src/plugin/Form/InputText.tsx +++ b/packages/amis-editor/src/plugin/Form/InputText.tsx @@ -190,7 +190,7 @@ export class TextControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'reload', diff --git a/packages/amis-editor/src/plugin/Form/ListSelect.tsx b/packages/amis-editor/src/plugin/Form/ListSelect.tsx index 4efd30e77..cc64ddcc8 100644 --- a/packages/amis-editor/src/plugin/Form/ListSelect.tsx +++ b/packages/amis-editor/src/plugin/Form/ListSelect.tsx @@ -107,7 +107,7 @@ export class ListControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'reload', diff --git a/packages/amis-editor/src/plugin/Form/LocationPicker.tsx b/packages/amis-editor/src/plugin/Form/LocationPicker.tsx index 1c90c6f37..edcc9a093 100644 --- a/packages/amis-editor/src/plugin/Form/LocationPicker.tsx +++ b/packages/amis-editor/src/plugin/Form/LocationPicker.tsx @@ -95,7 +95,7 @@ export class LocationControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/NestedSelect.tsx b/packages/amis-editor/src/plugin/Form/NestedSelect.tsx index 74f77a68c..ee1d91931 100644 --- a/packages/amis-editor/src/plugin/Form/NestedSelect.tsx +++ b/packages/amis-editor/src/plugin/Form/NestedSelect.tsx @@ -201,7 +201,7 @@ export class NestedSelectControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'reload', diff --git a/packages/amis-editor/src/plugin/Form/Radios.tsx b/packages/amis-editor/src/plugin/Form/Radios.tsx index 90d904d9b..d853a0cf0 100644 --- a/packages/amis-editor/src/plugin/Form/Radios.tsx +++ b/packages/amis-editor/src/plugin/Form/Radios.tsx @@ -103,7 +103,7 @@ export class RadiosControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'reload', diff --git a/packages/amis-editor/src/plugin/Form/Select.tsx b/packages/amis-editor/src/plugin/Form/Select.tsx index 64b9d6171..8b0bc18b7 100644 --- a/packages/amis-editor/src/plugin/Form/Select.tsx +++ b/packages/amis-editor/src/plugin/Form/Select.tsx @@ -176,7 +176,7 @@ export class SelectControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'reload', diff --git a/packages/amis-editor/src/plugin/Form/Switch.tsx b/packages/amis-editor/src/plugin/Form/Switch.tsx index 292b46b26..21f09ba59 100644 --- a/packages/amis-editor/src/plugin/Form/Switch.tsx +++ b/packages/amis-editor/src/plugin/Form/Switch.tsx @@ -94,6 +94,16 @@ export class SwitchControlPlugin extends BasePlugin { // 动作定义 actions: RendererPluginAction[] = [ + { + actionType: 'clear', + actionLabel: '清空', + description: '清除选中值' + }, + { + actionType: 'reset', + actionLabel: '重置', + description: '将值重置为初始值' + }, { actionType: 'setValue', actionLabel: '赋值', diff --git a/packages/amis-editor/src/plugin/Form/Textarea.tsx b/packages/amis-editor/src/plugin/Form/Textarea.tsx index d4d9dd6a7..b6b2ee576 100644 --- a/packages/amis-editor/src/plugin/Form/Textarea.tsx +++ b/packages/amis-editor/src/plugin/Form/Textarea.tsx @@ -119,7 +119,7 @@ export class TextareaControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-ui/src/components/DateRangePicker.tsx b/packages/amis-ui/src/components/DateRangePicker.tsx index fd52bcf8d..4454f6892 100644 --- a/packages/amis-ui/src/components/DateRangePicker.tsx +++ b/packages/amis-ui/src/components/DateRangePicker.tsx @@ -1446,9 +1446,8 @@ export class DateRangePicker extends React.Component< } // 重置 - reset() { + reset(resetValue?: any) { const { - resetValue, onChange, format, valueFormat, @@ -1458,17 +1457,16 @@ export class DateRangePicker extends React.Component< displayFormat, data } = this.props; - if (!resetValue) { - return; - } + + const tmpResetValue = resetValue ?? this.props.resetValue; const {startDate, endDate} = DateRangePicker.unFormatValue( - resetValue, + tmpResetValue, valueFormat || (format as string), joinValues, delimiter, data ); - onChange(resetValue); + onChange?.(tmpResetValue); this.setState({ startInputValue: startDate?.format(displayFormat || inputFormat), endInputValue: endDate?.format(displayFormat || inputFormat) diff --git a/packages/amis/__tests__/event-action/renderers/form/locationPicker.test.tsx b/packages/amis/__tests__/event-action/renderers/form/locationPicker.test.tsx index 3904cae1b..b8ed14cca 100755 --- a/packages/amis/__tests__/event-action/renderers/form/locationPicker.test.tsx +++ b/packages/amis/__tests__/event-action/renderers/form/locationPicker.test.tsx @@ -15,7 +15,6 @@ test('EventAction:locationPicker', async () => { id: 'location-picker', ak: 'LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7', coordinatesType: 'bd09', - value: '', name: 'location', resetValue: { address: '北京市东城区天安门广场中央', diff --git a/packages/amis/__tests__/renderers/Form/text.test.tsx b/packages/amis/__tests__/renderers/Form/text.test.tsx index f49ee0226..7e48345fb 100644 --- a/packages/amis/__tests__/renderers/Form/text.test.tsx +++ b/packages/amis/__tests__/renderers/Form/text.test.tsx @@ -1,5 +1,11 @@ import React = require('react'); -import {render, cleanup, fireEvent, waitFor, screen} from '@testing-library/react'; +import { + render, + cleanup, + fireEvent, + waitFor, + screen +} from '@testing-library/react'; import '../../../src'; import {render as amisRender} from '../../../src'; import {makeEnv, replaceReactAriaIds, wait} from '../../helper'; @@ -354,36 +360,40 @@ describe('Renderer:text with options and multiple', () => { test('Renderer:text with options auto ellipsis', async () => { const longText = 'OptionB (with long suffix for testing ellipsis)'; const {container} = await setup({ - "name": "text", - "type": "input-text", - "label": "text", - "multiple": true, - "options": [ + name: 'text', + type: 'input-text', + label: 'text', + multiple: true, + options: [ { - "label": "OptionA", - "value": "a" + label: 'OptionA', + value: 'a' }, { - "label": longText, - "value": "b" + label: longText, + value: 'b' }, { - "label": "OptionC", - "value": "c" + label: 'OptionC', + value: 'c' }, { - "label": "OptionD", - "value": "d" + label: 'OptionD', + value: 'd' } ] }); - const textControl = container.querySelector('.cxd-TextControl-input') as HTMLElement; + const textControl = container.querySelector( + '.cxd-TextControl-input' + ) as HTMLElement; fireEvent.click(textControl); await wait(300); replaceReactAriaIds(container); - const listItems = container.querySelectorAll('.cxd-TextControl-sugs .cxd-TextControl-sugItem'); + const listItems = container.querySelectorAll( + '.cxd-TextControl-sugs .cxd-TextControl-sugItem' + ); expect(listItems.length).toBe(4); // 选中长文本项 @@ -503,7 +513,7 @@ test('Renderer:text with resetValue and trimContents', async () => { await wait(500); - expect(input.value).toBe('reset-value'); + expect(input.value).toBe('text-value'); // trimContents const textControl = container.querySelector( diff --git a/packages/amis/src/renderers/Form/ButtonGroupSelect.tsx b/packages/amis/src/renderers/Form/ButtonGroupSelect.tsx index 952a2c791..c58b4a8ad 100644 --- a/packages/amis/src/renderers/Form/ButtonGroupSelect.tsx +++ b/packages/amis/src/renderers/Form/ButtonGroupSelect.tsx @@ -2,7 +2,9 @@ import React from 'react'; import { OptionsControl, OptionsControlProps, - FormOptionsControl + FormOptionsControl, + filter, + getVariable } from 'amis-core'; import {Option, TestIdBuilder} from 'amis-core'; import {ActionObject, isObject} from 'amis-core'; @@ -49,13 +51,15 @@ export default class ButtonGroupControl extends React.Component< }; doAction(action: ActionObject, data: object, throwErrors: boolean) { - const {resetValue, onChange} = this.props; + const {resetValue, onChange, formStore, store, name} = this.props; const actionType = action?.actionType as string; if (actionType === 'clear') { onChange(''); } else if (actionType === 'reset') { - onChange(resetValue ?? ''); + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + onChange(pristineVal ?? ''); } } diff --git a/packages/amis/src/renderers/Form/ChainedSelect.tsx b/packages/amis/src/renderers/Form/ChainedSelect.tsx index c2138cb0f..aabf8bac3 100644 --- a/packages/amis/src/renderers/Form/ChainedSelect.tsx +++ b/packages/amis/src/renderers/Form/ChainedSelect.tsx @@ -5,7 +5,8 @@ import { OptionsControlProps, Option, FormOptionsControl, - resolveEventData + resolveEventData, + getVariable } from 'amis-core'; import {Select, Spinner} from 'amis-ui'; import {Api, ApiObject} from 'amis-core'; @@ -89,13 +90,15 @@ export default class ChainedSelectControl extends React.Component< } doAction(action: ActionObject, data: object, throwErrors: boolean) { - const {resetValue, onChange} = this.props; + const {resetValue, onChange, formStore, store, name} = this.props; const actionType = action?.actionType as string; if (actionType === 'clear') { onChange(''); } else if (actionType === 'reset') { - onChange(resetValue ?? ''); + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + onChange(pristineVal ?? ''); } } diff --git a/packages/amis/src/renderers/Form/Checkbox.tsx b/packages/amis/src/renderers/Form/Checkbox.tsx index d2c3b33c0..fb52fffe6 100644 --- a/packages/amis/src/renderers/Form/Checkbox.tsx +++ b/packages/amis/src/renderers/Form/Checkbox.tsx @@ -3,7 +3,8 @@ import { FormItem, FormControlProps, FormBaseControl, - resolveEventData + resolveEventData, + getVariable } from 'amis-core'; import cx from 'classnames'; import {Checkbox} from 'amis-ui'; @@ -70,13 +71,15 @@ export default class CheckboxControl extends React.Component< }; doAction(action: ActionObject, data: object, throwErrors: boolean) { - const {resetValue, onChange} = this.props; + const {resetValue, onChange, formStore, store, name} = this.props; const actionType = action?.actionType as string; if (actionType === 'clear') { onChange(''); } else if (actionType === 'reset') { - onChange(resetValue ?? ''); + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + onChange(pristineVal ?? ''); } } diff --git a/packages/amis/src/renderers/Form/Checkboxes.tsx b/packages/amis/src/renderers/Form/Checkboxes.tsx index a176b3e1b..d0fa34c89 100644 --- a/packages/amis/src/renderers/Form/Checkboxes.tsx +++ b/packages/amis/src/renderers/Form/Checkboxes.tsx @@ -6,7 +6,8 @@ import { autobind, hasAbility, columnsSplit, - flattenTreeWithLeafNodes + flattenTreeWithLeafNodes, + getVariable } from 'amis-core'; import type {ActionObject, Api, OptionsControlProps, Option} from 'amis-core'; import {Checkbox, Icon, Spinner} from 'amis-ui'; @@ -86,13 +87,15 @@ export default class CheckboxesControl extends React.Component< }; doAction(action: ActionObject, data: object, throwErrors: boolean) { - const {resetValue, onChange} = this.props; + const {resetValue, onChange, formStore, store, name} = this.props; const actionType = action?.actionType as string; if (actionType === 'clear') { onChange(''); } else if (actionType === 'reset') { - onChange(resetValue ?? ''); + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + onChange(pristineVal ?? ''); } } diff --git a/packages/amis/src/renderers/Form/Combo.tsx b/packages/amis/src/renderers/Form/Combo.tsx index e144addfc..da786707d 100644 --- a/packages/amis/src/renderers/Form/Combo.tsx +++ b/packages/amis/src/renderers/Form/Combo.tsx @@ -516,14 +516,19 @@ export default class ComboControl extends React.Component { args?: any ) { const actionType = action?.actionType as string; - const {onChange, resetValue} = this.props; + const {onChange, resetValue, formStore, store, name} = this.props; if (actionType === 'addItem') { this.addItemValue(args?.item ?? {}); } else if (actionType === 'clear') { onChange(''); } else if (actionType === 'reset') { - onChange(resetValue ?? ''); + const pristineVal = + getVariable( + formStore?.pristine ?? store?.parentStore?.pristine, + name + ) ?? resetValue; + onChange(pristineVal ?? ''); } } diff --git a/packages/amis/src/renderers/Form/DiffEditor.tsx b/packages/amis/src/renderers/Form/DiffEditor.tsx index 9ca40ffb8..9ccd621a6 100644 --- a/packages/amis/src/renderers/Form/DiffEditor.tsx +++ b/packages/amis/src/renderers/Form/DiffEditor.tsx @@ -3,7 +3,8 @@ import { FormItem, FormControlProps, FormBaseControl, - resolveEventData + resolveEventData, + getVariable } from 'amis-core'; import {LazyComponent} from 'amis-core'; import {isPureVariable, resolveVariableAndFilter} from 'amis-core'; @@ -119,12 +120,14 @@ export class DiffEditor extends React.Component { args?: any ) { const actionType = action?.actionType as string; - const {onChange, resetValue} = this.props; + const {onChange, resetValue, formStore, store, name} = this.props; if (actionType === 'clear') { onChange(''); } else if (actionType === 'reset') { - onChange(resetValue ?? ''); + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + onChange(pristineVal ?? ''); } else if (actionType === 'focus') { this.focus(); } diff --git a/packages/amis/src/renderers/Form/Editor.tsx b/packages/amis/src/renderers/Form/Editor.tsx index 8ee96b1f6..1e63c1cb4 100644 --- a/packages/amis/src/renderers/Form/Editor.tsx +++ b/packages/amis/src/renderers/Form/Editor.tsx @@ -3,7 +3,8 @@ import { FormItem, FormControlProps, FormBaseControl, - resolveEventData + resolveEventData, + getVariable } from 'amis-core'; import {LazyComponent} from 'amis-core'; import {Editor} from 'amis-ui'; @@ -167,12 +168,14 @@ export default class EditorControl extends React.Component { args?: any ) { const actionType = action?.actionType as string; - const {onChange, resetValue} = this.props; + const {onChange, resetValue, formStore, store, name} = this.props; if (actionType === 'clear') { onChange(''); } else if (actionType === 'reset') { - onChange(resetValue ?? ''); + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + onChange(pristineVal ?? ''); } else if (actionType === 'focus') { this.focus(); } diff --git a/packages/amis/src/renderers/Form/InputCity.tsx b/packages/amis/src/renderers/Form/InputCity.tsx index d4e277be2..2883f1114 100644 --- a/packages/amis/src/renderers/Form/InputCity.tsx +++ b/packages/amis/src/renderers/Form/InputCity.tsx @@ -3,7 +3,8 @@ import { FormItem, FormControlProps, FormBaseControl, - resolveEventData + resolveEventData, + getVariable } from 'amis-core'; import {ClassNamesFn, themeable, ThemeProps} from 'amis-core'; import {Spinner, SpinnerExtraProps} from 'amis-ui'; @@ -515,13 +516,15 @@ export class LocationControl extends React.Component { @autobind doAction(action: ActionObject, data: object, throwErrors: boolean) { - const {resetValue, onChange} = this.props; + const {resetValue, onChange, formStore, store, name} = this.props; const actionType = action?.actionType as string; if (actionType === 'clear') { onChange(''); } else if (actionType === 'reset') { - onChange(resetValue ?? ''); + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + onChange(pristineVal ?? ''); } } diff --git a/packages/amis/src/renderers/Form/InputDate.tsx b/packages/amis/src/renderers/Form/InputDate.tsx index 9267f98e7..7aa7af913 100644 --- a/packages/amis/src/renderers/Form/InputDate.tsx +++ b/packages/amis/src/renderers/Form/InputDate.tsx @@ -5,7 +5,8 @@ import { FormBaseControl, resolveEventData, str2function, - normalizeDate + normalizeDate, + getVariable } from 'amis-core'; import cx from 'classnames'; import {filterDate, isPureVariable, resolveVariableAndFilter} from 'amis-core'; @@ -558,15 +559,17 @@ export default class DateControl extends React.PureComponent< // 动作 doAction(action: ActionObject, data: object, throwErrors: boolean) { - const {resetValue} = this.props; + const {resetValue, formStore, store, name} = this.props; if (action.actionType === 'clear') { this.dateRef?.clear(); return; } - if (action.actionType === 'reset' && resetValue) { - this.dateRef?.reset(resetValue); + if (action.actionType === 'reset') { + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + this.dateRef?.reset(pristineVal); } } diff --git a/packages/amis/src/renderers/Form/InputDateRange.tsx b/packages/amis/src/renderers/Form/InputDateRange.tsx index b295352cd..d9c4bc7d7 100644 --- a/packages/amis/src/renderers/Form/InputDateRange.tsx +++ b/packages/amis/src/renderers/Form/InputDateRange.tsx @@ -3,7 +3,8 @@ import { FormItem, FormControlProps, FormBaseControl, - resolveEventData + resolveEventData, + getVariable } from 'amis-core'; import cx from 'classnames'; import {filterDate, parseDuration} from 'amis-core'; @@ -240,15 +241,17 @@ export default class DateRangeControl extends React.Component { // 动作 doAction(action: ActionObject, data: object, throwErrors: boolean) { - const {resetValue} = this.props; + const {resetValue, formStore, store, name} = this.props; if (action.actionType === 'clear') { this.dateRef?.clear(); return; } - if (action.actionType === 'reset' && resetValue) { - this.dateRef?.reset(); + if (action.actionType === 'reset') { + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + this.dateRef?.reset(pristineVal); } } diff --git a/packages/amis/src/renderers/Form/InputExcel.tsx b/packages/amis/src/renderers/Form/InputExcel.tsx index 6e1f31333..ac481f788 100644 --- a/packages/amis/src/renderers/Form/InputExcel.tsx +++ b/packages/amis/src/renderers/Form/InputExcel.tsx @@ -11,7 +11,8 @@ import { isObject, resolveEventData, dataMapping, - TestIdBuilder + TestIdBuilder, + getVariable } from 'amis-core'; import {FormBaseControlSchema, SchemaTokenizeableString} from '../../Schema'; import type {CellValue, CellRichTextValue} from 'exceljs'; @@ -388,12 +389,14 @@ export default class ExcelControl extends React.PureComponent< doAction(action: any, data: object, throwErrors: boolean) { const actionType = action?.actionType as string; - const {onChange, resetValue} = this.props; + const {onChange, resetValue, formStore, store, name} = this.props; if (actionType === 'clear') { onChange(''); } else if (actionType === 'reset') { - onChange(resetValue ?? ''); + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + onChange(pristineVal ?? ''); } } diff --git a/packages/amis/src/renderers/Form/InputNumber.tsx b/packages/amis/src/renderers/Form/InputNumber.tsx index 6b4219dbb..bab72116e 100644 --- a/packages/amis/src/renderers/Form/InputNumber.tsx +++ b/packages/amis/src/renderers/Form/InputNumber.tsx @@ -8,7 +8,8 @@ import { CustomStyle, formatInputThemeCss, setThemeClassName, - TestIdBuilder + TestIdBuilder, + getVariable } from 'amis-core'; import cx from 'classnames'; import {NumberInput, Select} from 'amis-ui'; @@ -238,7 +239,10 @@ export default class NumberControl extends React.Component< resetValue, big, onChange, - clearValueOnEmpty + clearValueOnEmpty, + formStore, + store, + name } = this.props; if (actionType === 'clear') { @@ -248,12 +252,14 @@ export default class NumberControl extends React.Component< this.filterNum(precision), this.filterNum(step) ); + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; const value = NumberInput.normalizeValue( - resetValue ?? '', + pristineVal ?? '', this.filterNum(min, big), this.filterNum(max, big), finalPrecision, - resetValue ?? '', + pristineVal ?? '', clearValueOnEmpty, big ); diff --git a/packages/amis/src/renderers/Form/InputRange.tsx b/packages/amis/src/renderers/Form/InputRange.tsx index 713334138..a7be12aa1 100644 --- a/packages/amis/src/renderers/Form/InputRange.tsx +++ b/packages/amis/src/renderers/Form/InputRange.tsx @@ -15,7 +15,8 @@ import { isMobile, isPureVariable, resolveVariableAndFilter, - isNumeric + isNumeric, + getVariable } from 'amis-core'; import {Range as InputRange, NumberInput, Icon} from 'amis-ui'; import {FormBaseControlSchema, SchemaObject} from '../../Schema'; @@ -590,26 +591,44 @@ export default class RangeControl extends React.PureComponent< doAction(action: ActionObject, data: object, throwErrors: boolean) { const actionType = action?.actionType as string; - if (!!~['clear', 'reset'].indexOf(actionType)) { - this.clearValue(actionType); + if (actionType === 'reset') { + this.resetValue(); + } else if (actionType === 'clear') { + this.clearValue(); } } + @autobind + resetValue() { + const { + multiple, + min: rawMin, + max: rawMax, + data, + onChange, + formStore, + store, + name, + resetValue + } = this.props; + const min = resolveNumVariable(rawMin, data, 0); + const max = resolveNumVariable(rawMax, data, 100); + + let pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + const value = this.getFormatValue( + pristineVal ?? (multiple ? {min, max} : min) + ); + + onChange?.(value); + } + @autobind clearValue(type: string = 'clear') { const {multiple, min: rawMin, max: rawMax, data, onChange} = this.props; const min = resolveNumVariable(rawMin, data, 0); const max = resolveNumVariable(rawMax, data, 100); - - let resetValue = this.props.resetValue; - - if (type === 'clear') { - resetValue = undefined; - } - - const value = this.getFormatValue( - resetValue ?? (multiple ? {min, max} : min) - ); + const value = this.getFormatValue(multiple ? {min, max} : min); onChange?.(value); } diff --git a/packages/amis/src/renderers/Form/InputRating.tsx b/packages/amis/src/renderers/Form/InputRating.tsx index acb290179..2e43c2f8b 100644 --- a/packages/amis/src/renderers/Form/InputRating.tsx +++ b/packages/amis/src/renderers/Form/InputRating.tsx @@ -3,7 +3,8 @@ import { FormItem, FormControlProps, FormBaseControl, - resolveEventData + resolveEventData, + getVariable } from 'amis-core'; import {autobind, createObject, filter, toNumber} from 'amis-core'; import {ActionObject} from 'amis-core'; @@ -96,12 +97,14 @@ export default class RatingControl extends React.Component { doAction(action: ActionObject, data: object, throwErrors: boolean) { const actionType = action?.actionType as string; - const {onChange, resetValue} = this.props; + const {onChange, resetValue, formStore, store, name} = this.props; if (actionType === 'clear') { onChange?.(''); } else if (actionType === 'reset') { - onChange?.(resetValue ?? ''); + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + onChange?.(pristineVal ?? ''); } } diff --git a/packages/amis/src/renderers/Form/InputTable.tsx b/packages/amis/src/renderers/Form/InputTable.tsx index fb6786d84..7110168db 100644 --- a/packages/amis/src/renderers/Form/InputTable.tsx +++ b/packages/amis/src/renderers/Form/InputTable.tsx @@ -2008,7 +2008,10 @@ export class TableControlRenderer extends FormTable { deleteApi, resetValue, translate: __, - onChange + onChange, + formStore, + store, + name } = this.props; const actionType = action.actionType as string; @@ -2148,7 +2151,9 @@ export class TableControlRenderer extends FormTable { ); return; } else if (actionType === 'reset') { - const newItems = Array.isArray(resetValue) ? resetValue : []; + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + const newItems = Array.isArray(pristineVal) ? pristineVal : []; this.setState( { items: newItems diff --git a/packages/amis/src/renderers/Form/InputTag.tsx b/packages/amis/src/renderers/Form/InputTag.tsx index 42a983885..a8814ec64 100644 --- a/packages/amis/src/renderers/Form/InputTag.tsx +++ b/packages/amis/src/renderers/Form/InputTag.tsx @@ -3,7 +3,8 @@ import { OptionsControl, OptionsControlProps, Option, - resolveEventData + resolveEventData, + getVariable } from 'amis-core'; import Downshift from 'downshift'; import find from 'lodash/find'; @@ -142,13 +143,15 @@ export default class TagControl extends React.PureComponent< } doAction(action: ActionObject, data: object, throwErrors: boolean) { - const {resetValue, onChange} = this.props; + const {resetValue, onChange, formStore, store, name} = this.props; const actionType = action?.actionType as string; if (actionType === 'clear') { onChange?.(''); } else if (actionType === 'reset') { - onChange?.(resetValue ?? ''); + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + onChange?.(pristineVal ?? ''); } } diff --git a/packages/amis/src/renderers/Form/InputText.tsx b/packages/amis/src/renderers/Form/InputText.tsx index 7e0ef20a4..1ba4c37b3 100644 --- a/packages/amis/src/renderers/Form/InputText.tsx +++ b/packages/amis/src/renderers/Form/InputText.tsx @@ -19,7 +19,8 @@ import { createObject, setVariable, ucFirst, - isEffectiveApi + isEffectiveApi, + getVariable } from 'amis-core'; import {Icon, SpinnerExtraProps, Input, Spinner, OverflowTpl} from 'amis-ui'; import {ActionSchema} from '../Action'; @@ -270,7 +271,9 @@ export default class TextControl extends React.PureComponent< ) { const actionType = action?.actionType as string; - if (!!~['clear', 'reset'].indexOf(actionType)) { + if (actionType === 'reset') { + this.resetValue(); + } else if (actionType === 'clear') { this.clearValue(); } else if (actionType === 'focus') { this.focus(); @@ -298,6 +301,34 @@ export default class TextControl extends React.PureComponent< } } + async resetValue() { + const {onChange, dispatchEvent, resetValue, formStore, store, name} = + this.props; + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + + const changeEvent = await dispatchEvent( + 'change', + resolveEventData(this.props, {value: pristineVal}) + ); + + if (changeEvent?.prevented) { + return; + } + + onChange(pristineVal); + + this.setState( + { + inputValue: pristineVal + }, + () => { + this.focus(); + this.loadAutoComplete(); + } + ); + } + async clearValue() { const {onChange, dispatchEvent, clearValueOnEmpty} = this.props; let resetValue = this.props.resetValue; @@ -317,7 +348,7 @@ export default class TextControl extends React.PureComponent< const changeEvent = await dispatchEvent( 'change', - resolveEventData(this.props, {resetValue}) + resolveEventData(this.props, {value: resetValue}) ); if (changeEvent?.prevented) { diff --git a/packages/amis/src/renderers/Form/InputTree.tsx b/packages/amis/src/renderers/Form/InputTree.tsx index b716c8ed5..834cc0302 100644 --- a/packages/amis/src/renderers/Form/InputTree.tsx +++ b/packages/amis/src/renderers/Form/InputTree.tsx @@ -19,7 +19,8 @@ import { hasAbility, findTree, isEffectiveApi, - BaseApiObject + BaseApiObject, + getVariable } from 'amis-core'; import {Spinner, SearchBox} from 'amis-ui'; import {FormOptionsSchema, SchemaApi} from '../../Schema'; @@ -242,12 +243,14 @@ export default class TreeControl extends React.Component { doAction(action: ActionObject, data: any, throwErrors: boolean) { const actionType = action?.actionType as string; - const {resetValue, onChange} = this.props; + const {resetValue, onChange, formStore, store, name} = this.props; if (actionType === 'clear') { onChange?.(''); } else if (actionType === 'reset') { - onChange?.(resetValue ?? ''); + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + onChange?.(pristineVal ?? ''); } else if (action.actionType === 'expand') { this.treeRef.syncUnFolded(this.props, action.args?.openLevel); } else if (action.actionType === 'collapse') { diff --git a/packages/amis/src/renderers/Form/ListSelect.tsx b/packages/amis/src/renderers/Form/ListSelect.tsx index f9810e78f..de14b5c48 100644 --- a/packages/amis/src/renderers/Form/ListSelect.tsx +++ b/packages/amis/src/renderers/Form/ListSelect.tsx @@ -3,7 +3,8 @@ import { OptionsControl, OptionsControlProps, Option, - FormOptionsControl + FormOptionsControl, + getVariable } from 'amis-core'; import {ActionObject, Schema} from 'amis-core'; import {createObject, isEmpty} from 'amis-core'; @@ -68,13 +69,15 @@ export default class ListControl extends React.Component { }; doAction(action: ActionObject, data: object, throwErrors: boolean) { - const {resetValue, onChange} = this.props; + const {resetValue, onChange, formStore, store, name} = this.props; const actionType = action?.actionType as string; if (actionType === 'clear') { onChange?.(''); } else if (actionType === 'reset') { - onChange?.(resetValue ?? ''); + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + onChange?.(pristineVal ?? ''); } } diff --git a/packages/amis/src/renderers/Form/LocationPicker.tsx b/packages/amis/src/renderers/Form/LocationPicker.tsx index 56f0f8ff3..3cb7b18ed 100644 --- a/packages/amis/src/renderers/Form/LocationPicker.tsx +++ b/packages/amis/src/renderers/Form/LocationPicker.tsx @@ -5,7 +5,8 @@ import { ThemeProps, Overlay, PopOver, - autobind + autobind, + getVariable } from 'amis-core'; import { FormItem, @@ -121,14 +122,18 @@ export class LocationControl extends React.Component { } doAction(action: ActionObject, data: object, throwErrors: boolean): any { - const {resetValue, onChange} = this.props; + const {resetValue, onChange, formStore, store, name} = this.props; const actionType = action?.actionType as string; switch (actionType) { case 'clear': onChange(''); break; case 'reset': - onChange?.(resetValue ?? {}); + onChange?.( + getVariable(formStore?.pristine ?? store?.pristine, name) ?? + resetValue ?? + '' + ); break; } } diff --git a/packages/amis/src/renderers/Form/MatrixCheckboxes.tsx b/packages/amis/src/renderers/Form/MatrixCheckboxes.tsx index 35f4b5ad6..497c6e0fb 100644 --- a/packages/amis/src/renderers/Form/MatrixCheckboxes.tsx +++ b/packages/amis/src/renderers/Form/MatrixCheckboxes.tsx @@ -8,6 +8,7 @@ import { FormBaseControl, FormControlProps, FormItem, + getVariable, resolveEventData } from 'amis-core'; import {buildApi, isValidApi, isEffectiveApi} from 'amis-core'; @@ -178,13 +179,16 @@ export default class MatrixCheckbox extends React.Component< } doAction(action: ActionObject, data: object, throwErrors: boolean) { - const {resetValue, onChange} = this.props; + const {resetValue, onChange, formStore, store, name} = this.props; const actionType = action?.actionType as string; if (actionType === 'clear') { onChange?.(''); } else if (actionType === 'reset') { - onChange?.(resetValue ?? ''); + // todo pristine被更新了,需要看看为啥 + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + onChange?.(pristineVal ?? ''); } } diff --git a/packages/amis/src/renderers/Form/NestedSelect.tsx b/packages/amis/src/renderers/Form/NestedSelect.tsx index 42771c596..31411e6b5 100644 --- a/packages/amis/src/renderers/Form/NestedSelect.tsx +++ b/packages/amis/src/renderers/Form/NestedSelect.tsx @@ -27,7 +27,8 @@ import { OptionsControlProps, RootClose, ActionObject, - renderTextByKeyword + renderTextByKeyword, + getVariable } from 'amis-core'; import {findDOMNode} from 'react-dom'; import xor from 'lodash/xor'; @@ -151,13 +152,15 @@ export default class NestedSelectControl extends React.Component< } doAction(action: ActionObject, data: object, throwErrors: boolean) { - const {resetValue, onChange} = this.props; + const {resetValue, onChange, formStore, store, name} = this.props; const actionType = action?.actionType as string; if (actionType === 'clear') { onChange?.(''); } else if (actionType === 'reset') { - onChange?.(resetValue ?? ''); + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + onChange?.(pristineVal ?? ''); } } diff --git a/packages/amis/src/renderers/Form/Radio.tsx b/packages/amis/src/renderers/Form/Radio.tsx index ac7a296cf..ea20b558b 100644 --- a/packages/amis/src/renderers/Form/Radio.tsx +++ b/packages/amis/src/renderers/Form/Radio.tsx @@ -3,7 +3,8 @@ import { FormItem, FormControlProps, FormBaseControl, - resolveEventData + resolveEventData, + getVariable } from 'amis-core'; import cx from 'classnames'; import {Checkbox} from 'amis-ui'; @@ -63,13 +64,15 @@ export default class RadioControl extends React.Component { }; doAction(action: ActionObject, data: object, throwErrors: boolean) { - const {resetValue, onChange} = this.props; + const {resetValue, onChange, formStore, store, name} = this.props; const actionType = action?.actionType as string; if (actionType === 'clear') { onChange(''); } else if (actionType === 'reset') { - onChange(resetValue ?? ''); + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + onChange(pristineVal ?? ''); } } diff --git a/packages/amis/src/renderers/Form/Radios.tsx b/packages/amis/src/renderers/Form/Radios.tsx index a7f7aa8b5..243d31721 100644 --- a/packages/amis/src/renderers/Form/Radios.tsx +++ b/packages/amis/src/renderers/Form/Radios.tsx @@ -7,7 +7,8 @@ import { Option, FormOptionsControl, resolveEventData, - TestIdBuilder + TestIdBuilder, + getVariable } from 'amis-core'; import {autobind, isEmpty, createObject} from 'amis-core'; import {ActionObject} from 'amis-core'; @@ -47,13 +48,15 @@ export default class RadiosControl extends React.Component { }; doAction(action: ActionObject, data: object, throwErrors: boolean) { - const {resetValue, onChange} = this.props; + const {resetValue, onChange, formStore, store, name} = this.props; const actionType = action?.actionType as string; if (actionType === 'clear') { onChange?.(''); } else if (actionType === 'reset') { - onChange?.(resetValue ?? ''); + const pristineVal = + getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue; + onChange?.(pristineVal ?? ''); } } diff --git a/packages/amis/src/renderers/Form/Select.tsx b/packages/amis/src/renderers/Form/Select.tsx index 6971f6f5a..f239bbf0a 100644 --- a/packages/amis/src/renderers/Form/Select.tsx +++ b/packages/amis/src/renderers/Form/Select.tsx @@ -15,7 +15,8 @@ import { isApiOutdated, createObject, autobind, - TestIdBuilder + TestIdBuilder, + getVariable } from 'amis-core'; import {TransferDropDown, Spinner, Select, SpinnerExtraProps} from 'amis-ui'; import {FormOptionsSchema, SchemaApi} from '../../Schema'; @@ -300,6 +301,7 @@ export default class SelectControl extends React.Component { const {onChange, setOptions, options, data, dispatchEvent} = this.props; let additonalOptions: Array = []; + let newValue: string | Option | Array