Commit 78b37d55 authored by cellee's avatar cellee

合同编辑实现在线预览

Signed-off-by: cellee's avatarcellee <893264950@qq.com>
parent b692d874
......@@ -32,7 +32,7 @@ import { tipList } from '@/utils/tip';
import FileViewer from 'react-file-viewer';
import PDF from 'react-pdf-js';
import { stringSplit } from '@/utils/string';
import { randomString } from '@/utils/string';
const ContractContent = (props: any) => {
const { Contract, dispatch, FileImg, loading } = props;
......@@ -174,7 +174,17 @@ const ContractContent = (props: any) => {
}
if (file.status == 'done') {
message.success(file.name + ' Upload Successful !');
setFileList([...fileList, file]);
// 实现在线预览
let obj = {
uid: randomString(12),
name: file.name,
status: 'done',
type: file.name.match(/\.([^\.]+)$/)[1].toLowerCase(),
url: file.response.data,
};
setFileList([...fileList, obj]);
// 添加到表单
form.setFieldsValue({
upload: 'ok',
......
......@@ -93,3 +93,16 @@ export const stringTab = (string: any) => {
// message.error("Ower Name Should be limit 2~30!",3)
// }
// }
// 生成随机字符串
export const randomString = (len?: any) => {
len = len || 32;
var $chars =
'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
var maxPos = $chars.length;
var pwd = '';
for (let i = 0; i < len; i++) {
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment