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 }) {
 | 
			
		||||
  try {
 | 
			
		||||
    const dayjs = (await import('dayjs')).default;
 | 
			
		||||
    const localeSetting = { invalidDate: '-' };
 | 
			
		||||
    dayjs.updateLocale('en', localeSetting);
 | 
			
		||||
 | 
			
		||||
    eval(jsCode);
 | 
			
		||||
    // NOTE: 示例代码, 仿照此例配置即可
 | 
			
		||||
    // {
 | 
			
		||||
    //   import('dayjs')
 | 
			
		||||
    //     .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_pay = form.getValuesIn(path.replace('.date_fix', '.date_pay'));
 | 
			
		||||
 | 
			
		||||
    //       const date_receive = form.getValuesIn(path.replace('.date_fix', '.date_receive'));
 | 
			
		||||
    //       const date_show = date_pay || date_receive;
 | 
			
		||||
    //   const date_receive = form.getValuesIn(path.replace('.date_fix', '.date_receive'));
 | 
			
		||||
    //   const date_show = date_pay || date_receive;
 | 
			
		||||
 | 
			
		||||
    //       const formartedDate = dayjs(date_show ?? '-').format('YYYY-MM-DD');
 | 
			
		||||
    //       setResult({
 | 
			
		||||
    //         childrenType: 'jsx',
 | 
			
		||||
    //         items: [
 | 
			
		||||
    //           {
 | 
			
		||||
    //             children: formartedDate,
 | 
			
		||||
    //           },
 | 
			
		||||
    //         ],
 | 
			
		||||
    //       });
 | 
			
		||||
    //     })
 | 
			
		||||
    //     .catch((error) => {
 | 
			
		||||
    //       // 处理加载模块时的错误
 | 
			
		||||
    //       console.error('Failed to load module:', error);
 | 
			
		||||
    //     });
 | 
			
		||||
    //   const formartedDate = dayjs(date_show ?? '-').format('YYYY-MM-DD');
 | 
			
		||||
    //   console.log('%c Line:81 🌰 formartedDate', 'font-size:18px;color:#4fff4B;background:#3f7cff', formartedDate);
 | 
			
		||||
    //   setResult({
 | 
			
		||||
    //     childrenType: 'jsx',
 | 
			
		||||
    //     items: [
 | 
			
		||||
    //       {
 | 
			
		||||
    //         children: formartedDate,
 | 
			
		||||
    //       },
 | 
			
		||||
    //     ],
 | 
			
		||||
    //   });
 | 
			
		||||
    // }
 | 
			
		||||
  } catch (error) {
 | 
			
		||||
    setResult({
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user