| | |
| | | "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", |
| | | "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" |
| | | }, |
| | | "codemirror": { |
| | | "version": "5.52.2", |
| | | "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.52.2.tgz", |
| | | "integrity": "sha512-WCGCixNUck2HGvY8/ZNI1jYfxPG5cRHv0VjmWuNzbtCLz8qYA5d+je4QhSSCtCaagyeOwMi/HmmPTjBgiTm2lQ==" |
| | | }, |
| | | "codepage": { |
| | | "version": "1.14.0", |
| | | "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.14.0.tgz", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "react-codemirror2": { |
| | | "version": "7.1.0", |
| | | "resolved": "https://registry.npmjs.org/react-codemirror2/-/react-codemirror2-7.1.0.tgz", |
| | | "integrity": "sha512-Rel0QbPnCTjHxgZYt6TkGw4icSZXNyONHb72a+1wWA+PlYJIvzFAv4pZlDPG0rpKpKmy4kSUlkoWgneH7w3A0g==" |
| | | }, |
| | | "react-dev-utils": { |
| | | "version": "9.0.3", |
| | | "resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-9.0.3.tgz", |
| | |
| | | "babel-preset-react-app": "9.0.0", |
| | | "camelcase": "^5.2.0", |
| | | "case-sensitive-paths-webpack-plugin": "2.2.0", |
| | | "codemirror": "^5.52.2", |
| | | "css-loader": "2.1.1", |
| | | "dotenv": "6.2.0", |
| | | "dotenv-expand": "4.2.0", |
| | |
| | | "prop-types": "^15.7.2", |
| | | "react": "^16.9.0", |
| | | "react-app-polyfill": "^1.0.2", |
| | | "react-codemirror2": "^7.1.0", |
| | | "react-dev-utils": "^9.0.3", |
| | | "react-dnd": "^9.4.0", |
| | | "react-dnd-html5-backend": "^9.4.0", |
| | |
| | | formdata[_data.key] = _data.value |
| | | }) |
| | | |
| | | if (!btn.verify || !btn.verify.Template || !btn.verify.linkUrl) { |
| | | // btn.verify.printFunc = ` |
| | | // let _data = data[0] |
| | | // _data = JSON.parse(_data) |
| | | |
| | | // let socket = new WebSocket(_data.wsaddr) |
| | | |
| | | // // 打开Socket |
| | | // socket.onopen = () => { |
| | | // notification.success({ |
| | | // top: 92, |
| | | // message: '打印请求已发出。', |
| | | // duration: 2 |
| | | // }) |
| | | // socket.send(JSON.stringify(_data.data)) |
| | | // } |
| | | // // 监听消息 |
| | | // socket.onmessage = (event) => { |
| | | // let data = '' |
| | | |
| | | // if (event.data) { |
| | | // try { |
| | | // data = JSON.parse(event.data) |
| | | // } catch { |
| | | // notification.warning({ |
| | | // top: 92, |
| | | // message: event.data, |
| | | // duration: 10 |
| | | // }) |
| | | // data = '' |
| | | // } |
| | | // } |
| | | |
| | | // if (data && data.message && !data.status) { |
| | | // notification.warning({ |
| | | // top: 92, |
| | | // message: data.message, |
| | | // duration: 10 |
| | | // }) |
| | | // } |
| | | // } |
| | | |
| | | // socket.onerror = () => { |
| | | // notification.warning({ |
| | | // top: 92, |
| | | // message: '无法连接到:' + _data.wsaddr, |
| | | // duration: 10 |
| | | // }) |
| | | // } |
| | | // ` |
| | | |
| | | if ( |
| | | !btn.verify || |
| | | (btn.verify.printMode === 'normal' && (!btn.verify.Template || !btn.verify.linkUrl)) || |
| | | (btn.verify.printMode === 'custom' && !btn.verify.printFunc) |
| | | ) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请完善打印验证信息!', |
| | |
| | | } |
| | | |
| | | let printlist = [] |
| | | let templates = [btn.verify.Template] |
| | | let templates = [btn.verify.Template || ''] |
| | | let printCount = 1 |
| | | |
| | | if (formdata.printCount && typeof(formdata.printCount) === 'number' && formdata.printCount >= 1) { |
| | |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (btn.verify.printMode === 'custom') { |
| | | this.execCustomPrint(btn, printlist) |
| | | } else { |
| | | resolve('getTemp') |
| | | } |
| | | } else { |
| | | this.getprintdata(btn, data, formdata, formlist).then(result => { |
| | | if (result.next === 'getTemp') { |
| | | result.list.forEach(item => { |
| | | let _cell = item.data |
| | | |
| | |
| | | printlist.push({...formdata, ..._cell}) |
| | | } |
| | | }) |
| | | } else if (result.next === 'customPrint') { |
| | | this.execCustomPrint(btn, result.list) |
| | | } |
| | | |
| | | resolve(result.next) |
| | | }) |
| | | } |
| | | }).then(res => { |
| | | // 获取打印模板 getTemp |
| | | if (!res) return |
| | | if (res !== 'getTemp') return false |
| | | |
| | | templates = Array.from(new Set(templates)) // 去重 |
| | | |
| | |
| | | this.execError(errorMsg, btn) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | execCustomPrint = (btn, printdata) => { |
| | | this.setState({loadingUuid: ''}) |
| | | |
| | | try { |
| | | // eslint-disable-next-line |
| | | let func = new Function('data', 'notification', btn.verify.printFunc) // 最后一个参数当函数体来执行,前面的参数当成函数体的参数。 |
| | | func(printdata, notification) |
| | | } catch (e) { |
| | | console.warn(e) |
| | | } |
| | | } |
| | | |
| | | getprintdata = (btn, data, formdata, formlist) => { |
| | |
| | | let errorMsg = '' |
| | | result.forEach(res => { |
| | | if (res.status) { |
| | | if (btn.verify.printMode === 'custom') { |
| | | // _list.push(res.data) |
| | | _list.push('{"status": true,"message": "","ErrCode": "","ErrMesg": "", "wsaddr": "ws://127.0.0.1:13529","wstype": "local/server","data": [{"cmd": "print","requestID": "202003091036391803ACEAAE08DF7454599AEA243D8959F","version": "1.0","task": {"taskID": "202003091036391803ACEAAE08DF7454599AEA243D8959F","preview": false,"printer": "Microsoft Print To PDF", "documents": [{"documentID": "05512003090002A243D8959F","contents": [{"data": {"Bill": "05512003090002","ReturnProduct": ""},"templateURL": "http://css.positecgroup.com/template/warespaceprint01/2020010810525789956968_U000000001.srt","ectype": "jdpop"}]}]}} ]}') |
| | | } else { |
| | | res.data.forEach(_item => { |
| | | _list.push({data: _item, count: res.printCount}) |
| | | }) |
| | | } |
| | | } else { |
| | | errorMsg = res |
| | | } |
| | | }) |
| | | if (!errorMsg) { |
| | | resolve({next: 'getTemp', list: _list}) |
| | | resolve({next: btn.verify.printMode === 'custom' ? 'customPrint' : 'getTemp', list: _list}) |
| | | } else { |
| | | this.execError(errorMsg, btn) |
| | | resolve({next: false, list: _list}) |
| | |
| | | |
| | | return Api.genericInterface(_callbackparam) |
| | | } else if (response.status) { |
| | | if (btn.verify.printMode === 'custom') { |
| | | _list.push(response.data) |
| | | } else { |
| | | response.data.forEach(_item => { |
| | | _list.push({data: _item, count: response.printCount}) |
| | | }) |
| | | } |
| | | |
| | | // 一次请求成功,进行下一项请求 |
| | | if (params.length === 0) { |
| | | _resolve({next: 'getTemp', list: _list}) |
| | | _resolve({next: btn.verify.printMode === 'custom' ? 'customPrint' : 'getTemp', list: _list}) |
| | | } else { |
| | | this.printOuterLoopRequest(params, btn, _list, _resolve) |
| | | } |
| | |
| | | if (!response) return |
| | | |
| | | if (response.status) { |
| | | if (btn.verify.printMode === 'custom') { |
| | | _list.push(response.data) |
| | | } else { |
| | | response.data.forEach(_item => { |
| | | _list.push({data: _item, count: response.printCount}) |
| | | }) |
| | | } |
| | | |
| | | // 一次请求成功,进行下一项请求 |
| | | if (params.length === 0) { |
| | | _resolve({next: 'getTemp', list: _list}) |
| | | _resolve({next: btn.verify.printMode === 'custom' ? 'customPrint' : 'getTemp', list: _list}) |
| | | } else { |
| | | this.printOuterLoopRequest(params, btn, _list, _resolve) |
| | | } |
| | |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | if (btn.verify.printMode === 'custom') { |
| | | _list.push(res.data) |
| | | } else { |
| | | res.data.forEach(_item => { |
| | | _list.push({data: _item, count: res.printCount}) |
| | | }) |
| | | } |
| | | |
| | | if (params.length === 0) { |
| | | _resolve({next: 'getTemp', list: _list}) |
| | | _resolve({next: btn.verify.printMode === 'custom' ? 'customPrint' : 'getTemp', list: _list}) |
| | | } else { |
| | | this.printInnerLoopRequest(params, btn, _list, _resolve) |
| | | } |
| | |
| | | }) |
| | | } else if (res && res.ErrCode === '-1') { // 完成后不提示 |
| | | |
| | | // } else if (res.Relogin === 'true') { // 切换用户功能 |
| | | // sessionStorage.setItem('avatar', res.icon || '') |
| | | // sessionStorage.setItem('UserID', res.UserID) |
| | | // sessionStorage.setItem('SessionUid', Utils.getuuid()) |
| | | // sessionStorage.setItem('LoginUID', res.LoginUID) |
| | | // sessionStorage.setItem('User_Name', res.UserName) |
| | | |
| | | // window.location.reload() |
| | | // return |
| | | } |
| | | |
| | | if (btn.OpenType === 'pop' && btn.setting && btn.setting.finish !== 'unclose') { |
| | |
| | | import GroupForm from './groupform' |
| | | import EditCard from './editcard' |
| | | import MenuForm from './menuform' |
| | | import Source from './source' |
| | | import { BaseConfig, SearchItems } from './source' |
| | | import './index.scss' |
| | | |
| | | const { Panel } = Collapse |
| | |
| | | originConfig: null, // 原始菜单 |
| | | groupVisible: false, // 全局配置模态框 |
| | | curgroup: null, // 当前组,新建或编辑 |
| | | optionLibs: null // 自定义下拉选项库 |
| | | optionLibs: null, // 自定义下拉选项库 |
| | | sources: null // 表单类型 |
| | | } |
| | | |
| | | /** |
| | |
| | | }) |
| | | } |
| | | } else { |
| | | _config = JSON.parse(JSON.stringify((Source.baseConfig))) |
| | | _config = JSON.parse(JSON.stringify(BaseConfig)) |
| | | } |
| | | |
| | | if (!_config.setting.title) { |
| | |
| | | // 主菜单已有选择的表名,模态框没有表名时,复制主菜单表名 |
| | | _config.tables = _config.tables.length === 0 ? _menu.tables : _config.tables |
| | | |
| | | let _source = JSON.parse(JSON.stringify(SearchItems)) |
| | | if (!!this.props.editTab) { |
| | | _source.push({ |
| | | type: 'form', |
| | | label: this.state.dict['header.form.linkMain'], |
| | | subType: 'linkMain', |
| | | url: '' |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | menu: _menu, |
| | | source: _source, |
| | | optionLibs: optionLibs, |
| | | config: _config, |
| | | selectedTables: _config.tables || [], |
| | |
| | | } |
| | | |
| | | render () { |
| | | const { config } = this.state |
| | | const { config, source } = this.state |
| | | |
| | | return ( |
| | | <div className="modal-form-board"> |
| | |
| | | </Panel> |
| | | <Panel header={this.state.dict['header.menu.form']} key="1"> |
| | | <div className="search-element"> |
| | | {Source.searchItems.map((item, index) => { |
| | | {source.map((item, index) => { |
| | | return (<SourceElement key={index} content={item}/>) |
| | | })} |
| | | </div> |
| | |
| | | |
| | | const CommonDict = (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS |
| | | |
| | | class CommonTableBaseData { |
| | | baseConfig = { |
| | | export const BaseConfig = { |
| | | type: 'Modal', |
| | | setting: { |
| | | title: '', |
| | |
| | | ] |
| | | } |
| | | |
| | | searchItems = [ |
| | | export const SearchItems = [ |
| | | { |
| | | type: 'form', |
| | | label: CommonDict['header.form.text'], |
| | |
| | | url: '' |
| | | } |
| | | ] |
| | | } |
| | | |
| | | export default new CommonTableBaseData() |
| | |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Tabs, Row, Col, Button, notification, Modal, message, InputNumber, Input, Select, Radio } from 'antd' |
| | | import moment from 'moment' |
| | | import {UnControlled as CodeMirror} from 'react-codemirror2' |
| | | import 'codemirror/mode/javascript/javascript' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | |
| | | import 'codemirror/lib/codemirror.css' |
| | | // import 'codemirror/theme/solarized.css' |
| | | import 'codemirror/theme/cobalt.css' |
| | | |
| | | import './index.scss' |
| | | |
| | |
| | | verify: {}, |
| | | templates: [], |
| | | selectimg: '', |
| | | printMode: 'normal' |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | |
| | | ..._verify, |
| | | Template: _verify.Template || '' |
| | | }, |
| | | linkType: _verify.linkType || 'system' |
| | | linkType: _verify.linkType || 'system', |
| | | printMode: _verify.printMode || 'normal', |
| | | printFunc: _verify.printFunc || '// Function(data, notification) // data-打印数据列表,notification-信息提示控件', |
| | | }) |
| | | } |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | changePrintMode = (e) => { |
| | | let value = e.target.value |
| | | |
| | | this.setState({ |
| | | printMode: value |
| | | }) |
| | | } |
| | | |
| | | changeLinkType = (e) => { |
| | | let value = e.target.value |
| | | |
| | |
| | | render() { |
| | | const { getFieldDecorator } = this.props.form |
| | | |
| | | const { verify, linkType } = this.state |
| | | const { verify, linkType, printMode, printFunc } = this.state |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | | <Col span={8}> |
| | | <Form.Item label={'打印模式'}> |
| | | {getFieldDecorator('printMode', { |
| | | initialValue: printMode || 'normal' |
| | | })( |
| | | <Radio.Group onChange={this.changePrintMode}> |
| | | <Radio value="normal">标准</Radio> |
| | | <Radio value="custom">自定义</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | {printMode === 'custom' ? <Col span={24}> |
| | | <Form.Item label={'处理函数'} className="printFunc"> |
| | | {getFieldDecorator('printFunc', { |
| | | initialValue: printFunc || '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.input'] + '处理函数!' |
| | | } |
| | | ] |
| | | })( |
| | | <CodeMirror |
| | | className="code-mirror-area" |
| | | options={{ |
| | | mode: 'text/javascript', |
| | | theme: 'cobalt', |
| | | lineNumbers: true, |
| | | lineWrapping: true |
| | | }} |
| | | onBeforeChange={() => {}} |
| | | /> |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {printMode === 'normal' ? <Col span={8}> |
| | | <Form.Item label={'链接类型'}> |
| | | {getFieldDecorator('linkType', { |
| | | initialValue: linkType || 'system' |
| | |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={8}> |
| | | </Col> : null} |
| | | {printMode === 'normal' ? <Col span={8}> |
| | | <Form.Item label={'链接地址'}> |
| | | {getFieldDecorator('linkUrl', { |
| | | initialValue: verify.linkUrl || '127.0.0.1:13529', |
| | |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" disabled={linkType === 'system'} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={8}> |
| | | </Col> : null } |
| | | {printMode === 'normal' ? <Col span={8}> |
| | | <Form.Item label={'打印模板'}> |
| | | {getFieldDecorator('Template', { |
| | | initialValue: verify.Template || '', |
| | |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={9}> |
| | | <img style={{width: '90%', marginBottom: '25px'}} src={this.state.selectimg} alt=""/> |
| | | </Col> |
| | | </Col> : null } |
| | | {printMode === 'normal' ? <Col span={8} offset={8}> |
| | | <img className="legend" src={this.state.selectimg} alt=""/> |
| | | </Col> : null } |
| | | </Row> |
| | | </Form> |
| | | </TabPane> |
| | |
| | | padding: 0 5px; |
| | | cursor: pointer; |
| | | } |
| | | .legend { |
| | | width: 100%; |
| | | margin-bottom: 25px; |
| | | margin-left: -2px; |
| | | box-shadow: 0px 0px 2px #bcbcbc; |
| | | } |
| | | .printFunc { |
| | | .ant-form-item-label { |
| | | width: 10.7%; |
| | | } |
| | | .ant-form-item-control-wrapper { |
| | | width: 89.3%; |
| | | } |
| | | } |
| | | .code-mirror-area { |
| | | font-size : 14px; |
| | | line-height : 25px; |
| | | } |
| | | } |
| | |
| | | window.addEventListener('resize', this.handleResize) |
| | | |
| | | this.loadconfig() |
| | | |
| | | document.onkeydown = (event) => { |
| | | const { editItemId, editItemType } = this.state |
| | | let e = event || window.event |
| | | let keyCode = e.keyCode || e.which || e.charCode |
| | | |
| | | if (keyCode === 46 && editItemId && editItemType !== 'Template') { |
| | | this.deleteItem() |
| | | } |
| | | } |
| | | } |
| | | |
| | | handleResize = () => { |
| | |
| | | options: fields |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'cusfield', |
| | | label: '自定义', |
| | | initval: item.cusfield || '', |
| | | required: true, |
| | | hidden: true |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'left', |
| | | label: '距左', |