提交 2db1ce5d authored 作者: 钟是志's avatar 钟是志

Merge remote-tracking branch 'origin/master'

......@@ -5,7 +5,8 @@ import React, {Component} from 'react';
import {checkIsImage} from '@/webPublic/one_stop_public/libs/UploadCom';
import { getModal, getPopconfirm, isFromIframe } from '@/webPublic/one_stop_public/utils/utils';
const FileViewer = CLIENT_TYPE === 'mobile' ? null : require('react-file-viewer');
// const FileViewer = CLIENT_TYPE === 'mobile' ? null : require('react-file-viewer');
const FileViewer = null;
const Modal = getModal();
const Popconfirm = getPopconfirm();
......@@ -130,12 +131,12 @@ export default class index extends Component {
<a onClick={this.download}>
下载文件
</a>
{FileViewer && (
{/* {FileViewer && (
<FileViewer
fileType={type}
filePath={path}
/>
)}
)}*/}
</div>
)}
</Modal>
......
......@@ -6,6 +6,7 @@ import styles from "./style.less";
import { checkIsImage } from "./UploadCom";
import Viewer from "react-viewer";
import { getToken } from '@/webPublic/one_stop_public/utils/token';
import { getHeaders } from '@/webPublic/zyd_public/utils/utils';
// 为黔南职院单独写的 上传组件 用于 bug 20576 个人就业信息/求职创业补贴申报,201801010006 119242 上传图片加限制,跟签约派遣上传图片加限制一样
......@@ -101,6 +102,7 @@ export default class UploadComDiyForQnZy extends React.Component {
name: "file",
multiple: isMultiple,
accept: accept,
...getHeaders(),
action: config.uploadUrl,
showUploadList: false,
onChange: this.changeUrl,
......
......@@ -8,6 +8,7 @@ import { delCookie, setCookie } from '@/webPublic/one_stop_public/utils/cookie';
export function setToken(value, time) {
if (getToken() !== value) {
setCookie('token', value);
sessionStorage.removeItem('cacheMobile');
localStorage.setItem('antd-pro-token-onestop', value);
localStorage.setItem('antd-pro-token', value);
localStorage.setItem('wisdom-school-token', value);
......
/**
*
* 一站式请勿使用此组件
* 2020年5月9日 拖拽组件
* 钟是志
* 黔南的 录取通知书打印 位置设置
* */
import React, { Fragment, Component } from 'react';
import styles from './index.less';
import { message } from 'antd';
import ButtonDiy from '@/baseComponent/ButtonDiy';
import Shell from '@/baseComponent/Shell';
import { ModalConfirm } from '@/baseComponent/Modal';
let startX = 0;
let startY = 0;
export default class FormatSetting extends Component {
constructor() {
super();
document.onmousedown = function(evt) {
startX = evt.offsetX;
startY = evt.offsetY;
};
}
dragEventList = () => {
const { updateFormatSettingObject } = this.props;
let draggedRef = null;
document.addEventListener(
'dragstart',
function(event) {
// 保存拖动元素的引用(ref.)
draggedRef = event.target;
// 使其半透明
event.target.style.opacity = 0.5;
},
false,
);
document.addEventListener(
'dragend',
function(event) {
// 重置透明度
event.target.style.opacity = '';
},
false,
);
/* 放下目标节点时触发事件 */
document.addEventListener(
'dragover',
function(event) {
// 阻止默认动作
event.preventDefault();
},
false,
);
document.addEventListener(
'drop',
function(event) {
// 阻止默认动作(如打开一些元素的链接)
event.preventDefault();
// 将拖动的元素到所选择的放置目标节点中
let infoClientRect = document.getElementById('dropZone').getBoundingClientRect();
let leftNew = Math.ceil(event.clientX - infoClientRect.left) - startX;
let topNew = Math.ceil(event.clientY - infoClientRect.top) - startY;
if (
leftNew < 0 ||
leftNew > infoClientRect.width ||
topNew < 0 ||
topNew > infoClientRect.height
) {
message.warn('拖拽到了图片区域外部!');
return false;
} else {
console.log(leftNew, topNew);
}
if (event.target.id === 'dropZone') {
// const left = event.offsetX;
// const top = event.offsetY;
updateFormatSettingObject(draggedRef.id, leftNew, topNew);
draggedRef.style.left = leftNew; // `${left}px`;
draggedRef.style.top = topNew; // `${top}px`;
}
},
false,
);
};
componentDidMount() {
this.dragEventList();
}
initConfig = () => {
ModalConfirm('您确定初始化打印录取通知书格式吗?', {
onOk: () => {
this.props.initConfig();
},
});
};
render() {
const { bgImage, formatSettingObject, saveConfig } = this.props;
return (
<Fragment>
<Shell
styleShell={{
marginTop: '0',
marginBottom: '20px',
}}>
<div
style={{
height: '54px',
padding: '12px 0 12px 12px',
}}>
<ButtonDiy name="保存" className="primary" handleClick={saveConfig} />
<ButtonDiy name={'初始化格式'} handleClick={this.initConfig} />
</div>
</Shell>
<div className={styles.outSideDiv}>
<div>
<img
src={bgImage}
id={'dropZone'}
draggable={false}
className={styles.bgimage}
alt={'背景图'}
/>
{formatSettingObject.map((x, index) => {
return (
<div
draggable={true}
className={styles.inSideItem}
key={index}
id={x.name}
style={x.style}>
{x.name}
</div>
);
})}
</div>
</div>
</Fragment>
);
}
}
/***
* formatSettingObject: {
* content_set: {
* font: "宋体"
isNeedConfig: true
key: "JjqCiRYamxs"
name: "content_set"
size: "12"
style: {top: 300, left: 50}
title: "--详细内容--"
* }
* }
*
* */
......@@ -148,8 +148,8 @@ export default function request(
}
const defaultOptions = {
// credentials: 'omit',
credentials: 'include',
// credentials: 'omit', // 确保浏览器不在请求中包含凭据
credentials: 'include', // 为了让浏览器发送包含凭据的请求(即使是跨域源)
mode: 'cors',
};
let newOptions = { ...defaultOptions, ...options };
......
......@@ -5,88 +5,91 @@ import { getInfo } from '@/highOrderComponent/Service';
import { Divider } from 'antd';
import config from '@/config/config';
import {
setSysConfig,
getSysConfig as getSysConfigLocalStorage,
setSysConfig,
getSysConfig as getSysConfigLocalStorage,
} from '@/webPublic/zyd_private/utils/basiclayout';
import { getOneStopConfig } from '@/webPublic/zyd_public/utils/utils';
function formatUploadFile(fileList) {
if (!fileList || !Array.isArray(fileList)) return [];
return JSON.stringify(
fileList.map((i) => ({
uid: i.uid,
name: i.name,
status: i.status,
url: i.filePath || i.response.filePath,
})),
);
if (!fileList || !Array.isArray(fileList)) return [];
return JSON.stringify(
fileList.map((i) => ({
uid: i.uid,
name: i.name,
status: i.status,
url: i.filePath || i.response.filePath,
})),
);
}
export const valueTypes = {
0: {
name: '文本',
inputComponent: 'input',
},
1: {
name: '文件',
inputComponent: 'upload',
formatToServer: formatUploadFile, // 新增或保存时候转换格式
formatToEdit: (str) => {
const fileArr = JSON.parse(str);
if (!Array.isArray(fileArr)) return [];
return fileArr;
}, // 编辑时,转换成可以在表单回显的格式
render: (val) => {
// 在列表上的显示方式
return JSON.parse(val).map((item, i) => (
<>
{i > 0 && <Divider type="vertical" />}
<a
target="_blank"
rel="noopener noreferrer"
key={item.uid}
href={item.url && (item.url.startsWith('http') ? item.url : config.dfs + item.url)}>
{item.name}
</a>
</>
));
},
},
2: {
name: '富文本',
inputComponent: 'input',
},
0: {
name: '文本',
inputComponent: 'input',
},
1: {
name: '文件',
inputComponent: 'upload',
formatToServer: formatUploadFile, // 新增或保存时候转换格式
formatToEdit: (str) => {
const fileArr = JSON.parse(str);
if (!Array.isArray(fileArr)) return [];
return fileArr;
}, // 编辑时,转换成可以在表单回显的格式
render: (val) => {
// 在列表上的显示方式
return JSON.parse(val)
.map((item, i) => (
<>
{i > 0 && <Divider type="vertical"/>}
<a
target="_blank"
rel="noopener noreferrer"
key={item.uid}
href={item.url && (item.url.startsWith('http') ? item.url : config.dfs + item.url)}>
{item.name}
</a>
</>
));
},
},
2: {
name: '富文本',
inputComponent: 'input',
},
};
export function getSysConfig() {
return getInfo({ pageSize: 10000 }, '/WebConfigApi/getPage?oauthPub=true').then((res) => {
if (res && res.rows && res.rows.length) {
const formattered = res.rows.reduce((acc, cur) => {
console.log(valueTypes, cur.valueType);
let index = cur.valueType || '0';
const { formatToEdit } = valueTypes[index];
let { value } = cur;
if (formatToEdit && typeof formatToEdit === 'function') {
value = formatToEdit(value);
}
return {
...acc,
[cur.dictCode]: value,
};
}, {});
setSysConfig(formattered);
return formattered;
}
});
return getInfo({ pageSize: 10000 }, '/WebConfigApi/getPage?oauthPub=true')
.then((res) => {
if (res && res.rows && res.rows.length) {
const formattered = res.rows.reduce((acc, cur) => {
console.log(valueTypes, cur.valueType);
let index = cur.valueType || '0';
const { formatToEdit } = valueTypes[index];
let { value } = cur;
if (formatToEdit && typeof formatToEdit === 'function') {
value = formatToEdit(value);
}
return {
...acc,
[cur.dictCode]: value,
};
}, {});
setSysConfig(formattered);
return formattered;
}
});
}
export default async function setTokenAndInitSystem() {
let token = getUrlInfo().token;
if (token && token.length > 10 && getToken() !== token) {
return new Promise((resolve, reject) => {
resolve(Promise.all([setToken(token), getSysConfig(), getOneStopConfig()]));
});
}
return new Promise((resolve, reject) => {
resolve(true);
});
export default function setTokenAndInitSystem() {
let token = getUrlInfo().token;
if (token && token.length > 10 && getToken() !== token) {
setToken(token);
}
if (!getSysConfigLocalStorage()) {
getSysConfig();
}
getOneStopConfig();
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论