PageButton.js 3.7 KB
Newer Older
1 2 3 4 5 6
import React from 'react';
import { message } from 'antd';
import { redText } from '@/pages/zydxg/CheckManage/PiciSetting/publicFunc';
import { isJSON } from '@/webPublic/one_stop_public/copy';
import ConfirmModal from '@/pages/zydzs/AdmissionActivityManage/ActivityPublish/CheckInSituation_parent/ConfirmModal';
import ButtonDiy from '@/baseComponent/ButtonDiy';
7 8 9 10 11
import {
	A4Height,
	A4Width,
	defaultConfigInfo,
} from '@/webPublic/zyd_private/DragAndPrint/ViewPrint/config';
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

/**
 *
 backgroundUrl: "http://scjoyedu.eicp.net:51337/dsf/test108/u/upload/202005/27135813bxl6.jpg"
 callUrl: "/PublicPrintApi/studentCard/printed"
 code: "studentCard"
 config: [{content: "${name}", errCode: "", errLog: "", errMsg: "", fieldCode: "name", fieldFont: "黑体",…},…]
 errCode: ""
 errLog: ""
 errMsg: ""
 hasPrintBackground: true
 high: null
 queryUrl: "/PublicPrintApi/studentCard/query"
 respcode: "00"
 respdesc: ""
 wide: null
 * */

export default ({ configAll, location }) => {
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
	const outSideData = {
		...configAll,
	};
	delete outSideData.config;
	const { config } = configAll;
	return [
		{
			type: 'basicConfig',
			component: 'ModalForm',
			nameSpan: { big: 8, small: 10 },
			values: {
				...outSideData,
				info: !outSideData.info ? JSON.stringify(defaultConfigInfo) : outSideData.info,
			},
			url: '/PublicPrintApi/update',
			name: '基础项配置',
			beforeSubmit: (props, formValues) => {
				if (formValues && formValues.backgroundUrl && isJSON(formValues)) {
					formValues.backgroundUrl = JSON.parse(formValues.backgroundUrl).url;
				}
				if (
					formValues &&
					formValues.backgroundUrl &&
					typeof formValues.backgroundUrl === 'object'
				) {
					formValues.backgroundUrl = formValues.backgroundUrl.url;
				}
				const data = {
					...outSideData,
					...formValues,
				};
				delete data.config;
				return data;
			},
			fields: [
				{
					key: 'code',
					name: '编码',
					type: 'input',
					disabled: true,
				},
				{
					key: 'backgroundUrl',
					name: '背景模版图片',
					required: true,
					type: 'buttonUpload',
					accept: 'image/*',
				},
				{
					key: 'hasPrintBackground',
					name: '是否打印背景模版',
					type: 'select',
					options: [
						{
							key: 'true',
							name: '打印',
						},
						{
							key: 'false',
							name: '隐藏',
						},
					],
				},
				{
					key: 'printMeth',
					name: '打印方向',
					type: 'select',
					options: [
						{
							key: '1',
							name: '横向',
						},
						{
							key: '2',
							name: '竖向',
						},
					],
				},
				{
					key: 'high',
					name: '渲染HTML高度(单位厘米)',
					type: 'inputNumber',
					precision: 1,
					min: 5,
					max: 200,
				},
				{
					key: 'wide',
					name: '渲染HTML宽度(单位厘米)',
					type: 'inputNumber',
					precision: 1,
					min: 5,
					max: 200,
				},
				{
					key: 'info',
					name: '其他配置信息JSON',
					type: 'textarea',
				},
				{
					type: 'component',
					render: () => {
						return (
							<p style={{ color: 'red' }}>
								提示:
								{'{"paperHeight":"29.7cm","paperWidth":"21cm"} A4渲染高度28.5 A4渲染宽度19.7'}
							</p>
						);
					},
				},
			],
		},
		{
			type: 'return',
			name: '返回',
			component: 'RenderComponent',
			render: () => {
				if (location && location.state) {
					return (
						<ButtonDiy
							name="返回"
							className="defaultRed"
							key={'return'}
							handleClick={() => {
								window.history.back(-1);
							}}
						/>
					);
				} else {
					return null;
				}
			},
		},
		{
			type: 'remark',
			name: '备注',
			component: 'RenderComponent',
			render: () => {
				return <span key={'remark'}>{redText('谨慎修改,如不清楚配置项意义,请联系开发人员.')}</span>;
			},
		},
	];
173
};