fix: code field (#1071)
Reviewed-on: daoyoucloud/tachybase#1071 Reviewed-by: sealday <zhanglin@daoyoucloud.com> Co-authored-by: bai.zixv <bai.zixv@foxmail.com> Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
This commit is contained in:
parent
dc175f789f
commit
15fd844617
@ -65,34 +65,28 @@ function useAction(props: CodeFieldProps): string | React.ReactNode {
|
|||||||
|
|
||||||
async function dynamicCode({ jsCode, form, path, recordData, result }, { setResult, formatFunc }) {
|
async function dynamicCode({ jsCode, form, path, recordData, result }, { setResult, formatFunc }) {
|
||||||
try {
|
try {
|
||||||
|
const dayjs = (await import('dayjs')).default;
|
||||||
|
const localeSetting = { invalidDate: '-' };
|
||||||
|
dayjs.updateLocale('en', localeSetting);
|
||||||
|
|
||||||
eval(jsCode);
|
eval(jsCode);
|
||||||
// NOTE: 示例代码, 仿照此例配置即可
|
// NOTE: 示例代码, 仿照此例配置即可
|
||||||
// {
|
// {
|
||||||
// import('dayjs')
|
// const date_pay = form.getValuesIn(path.replace('.date_fix', '.date_pay'));
|
||||||
// .then((module) => {
|
|
||||||
// // 使用加载的模块
|
|
||||||
// const dayjs = module.default; // 假设模块默认导出了一个函数
|
|
||||||
// const localeSetting = { invalidDate: '-' };
|
|
||||||
// dayjs.updateLocale('en', localeSetting);
|
|
||||||
// const date_pay = form.getValuesIn(path.replace('.date_fix', '.date_pay'));
|
|
||||||
|
|
||||||
// const date_receive = form.getValuesIn(path.replace('.date_fix', '.date_receive'));
|
// const date_receive = form.getValuesIn(path.replace('.date_fix', '.date_receive'));
|
||||||
// const date_show = date_pay || date_receive;
|
// const date_show = date_pay || date_receive;
|
||||||
|
|
||||||
// const formartedDate = dayjs(date_show ?? '-').format('YYYY-MM-DD');
|
// const formartedDate = dayjs(date_show ?? '-').format('YYYY-MM-DD');
|
||||||
// setResult({
|
// console.log('%c Line:81 🌰 formartedDate', 'font-size:18px;color:#4fff4B;background:#3f7cff', formartedDate);
|
||||||
// childrenType: 'jsx',
|
// setResult({
|
||||||
// items: [
|
// childrenType: 'jsx',
|
||||||
// {
|
// items: [
|
||||||
// children: formartedDate,
|
// {
|
||||||
// },
|
// children: formartedDate,
|
||||||
// ],
|
// },
|
||||||
// });
|
// ],
|
||||||
// })
|
// });
|
||||||
// .catch((error) => {
|
|
||||||
// // 处理加载模块时的错误
|
|
||||||
// console.error('Failed to load module:', error);
|
|
||||||
// });
|
|
||||||
// }
|
// }
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setResult({
|
setResult({
|
||||||
|
Loading…
Reference in New Issue
Block a user