From ce70be666bcd78a7e16e739040488cf7e7256cc2 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 31 五月 2021 15:49:43 +0800 Subject: [PATCH] 2021-05-31 --- src/tabviews/treepage/index.jsx | 20 + src/templates/zshare/modalform/index.jsx | 46 ++ src/utils/utils-datamanage.js | 18 - src/views/printTemplate/index.jsx | 6 src/menu/components/share/sourcecomponent/inputform/index.jsx | 20 src/tabviews/formtab/formgroup/index.jsx | 55 --- src/views/printTemplate/mutilform/index.jsx | 69 +--- src/templates/zshare/formconfig.jsx | 45 +++ src/templates/zshare/modalform/datatable/index.jsx | 40 -- src/tabviews/calendar/index.jsx | 21 + src/tabviews/zshare/mutilform/index.jsx | 37 -- src/api/index.js | 21 src/menu/picturecontroller/editform/index.jsx | 63 +--- src/tabviews/custom/index.jsx | 6 src/views/billprint/index.jsx | 32 + src/tabviews/subtable/index.jsx | 20 + src/templates/zshare/modalform/datatable/index.scss | 6 src/tabviews/subtabtable/index.jsx | 20 + src/tabviews/zshare/fileupload/index.jsx | 207 ++++++++++++- src/tabviews/commontable/index.jsx | 21 + src/tabviews/zshare/fileupload/index.scss | 15 + src/views/appmanage/submutilform/index.jsx | 24 - 22 files changed, 495 insertions(+), 317 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index 950a545..87db4d9 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -771,22 +771,17 @@ param = this.encryptParam(param) + let url = '/webapi/SaveBase64Image' if (param.rduri) { - let url = param.rduri.replace(/webapi(.*)$/, 'webapi/SaveBase64Image') + url = param.rduri.replace(/webapi(.*)$/, 'webapi/SaveBase64Image') delete param.rduri - - return axios({ - url, - method: 'post', - data: param - }) - } else { - return axios({ - url: '/webapi/SaveBase64Image', - method: 'post', - data: param - }) } + + return axios({ + url, + method: 'post', + data: param + }) } /** diff --git a/src/menu/components/share/sourcecomponent/inputform/index.jsx b/src/menu/components/share/sourcecomponent/inputform/index.jsx index 0312024..f178a9e 100644 --- a/src/menu/components/share/sourcecomponent/inputform/index.jsx +++ b/src/menu/components/share/sourcecomponent/inputform/index.jsx @@ -27,7 +27,6 @@ originlist: [], list: [], pagelist: [], - fileList: [], searchKey: '', pageSize: 12, pageIndex: 1, @@ -79,7 +78,7 @@ let list = originlist let pagelist = list.filter((item, index) => index < this.state.pageSize) - this.setState({originlist, list, url: '', searchKey: '', pageIndex: 1, fileList: [], pagelist}) + this.setState({originlist, list, url: '', searchKey: '', pageIndex: 1, pagelist}) } changeSearch = () => { @@ -100,12 +99,8 @@ this.setState({pageIndex: page, pagelist}) } - changeFile = (vals) => { - this.setState({fileList: vals}) - - if (vals && vals[0] && vals[0].status === 'done' && vals[0].response) { - this.setState({url: vals[0].response}) - } + changeFile = (val) => { + this.setState({url: val}) } selectItem = (item) => { @@ -162,7 +157,7 @@ render () { const { type, keyword } = this.props - const { list, url, pagelist, fileList, searchKey, pageIndex, pageSize, selectId, editvisible, card } = this.state + const { list, url, pagelist, searchKey, pageIndex, pageSize, selectId, editvisible, card } = this.state return ( <div className="mk-source-pop-wrap"> @@ -170,7 +165,12 @@ <TextArea id="source-input" value={url} rows={4} onChange={this.changeValue}/> </Form.Item> : null} {keyword === 'upload' ? <Form.Item label="涓婁紶" labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={{xs: { span: 24 }, sm: { span: 20 }}}> - <FileUpload value={fileList} onChange={this.changeFile} accept={type === 'video' ? '.mp4,.webm,.ogg' : '.jpg,.png,.gif,.pjp,.pjpeg,.jpeg,.jfif,.webp'} maxFile={1} fileType={type === 'video' ? 'text' : 'picture'} /> + <FileUpload config={{ + initval: '', + suffix: type === 'video' ? '.mp4,.webm,.ogg' : '.jpg,.png,.gif,.pjp,.pjpeg,.jpeg,.jfif,.webp', + maxfile: 1, + fileType: type === 'video' ? 'text' : 'picture' + }} onChange={this.changeFile} /> </Form.Item> : null} {keyword === 'system' ? <Search value={searchKey} placeholder="" onChange={(e) => this.setState({searchKey: e.target.value})} onSearch={this.changeSearch} enterButton/> : null} diff --git a/src/menu/picturecontroller/editform/index.jsx b/src/menu/picturecontroller/editform/index.jsx index e12d46d..934ebd7 100644 --- a/src/menu/picturecontroller/editform/index.jsx +++ b/src/menu/picturecontroller/editform/index.jsx @@ -1,6 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Radio, notification } from 'antd' +import { Form, Row, Col, Input, Radio } from 'antd' import FileUpload from '@/tabviews/zshare/fileupload' import './index.scss' @@ -14,7 +14,6 @@ } state = { - urls: [], linkurl: '', plusType: 'upload' } @@ -24,29 +23,8 @@ return new Promise((resolve, reject) => { this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { - if (values.urls && values.urls[0].status === 'error') { - notification.warning({ - top: 92, - message: '璇烽噸鏂颁笂浼犳枃浠讹紒', - duration: 5 - }) - return - } else if (values.urls && values.urls[0] && values.urls[0].status !== 'done') { - notification.warning({ - top: 92, - message: '鏂囦欢涓婁紶涓紝璇风◢鍚庯紒', - duration: 5 - }) - return - } else if (values.urls && values.urls[0] && values.urls[0].response) { - values.linkurl = values.urls[0].response - } else { - notification.warning({ - top: 92, - message: '鏈幏鍙栧埌鏂囦欢璺緞锛�', - duration: 5 - }) - return + if (values.urls) { + values.linkurl = values.urls } resolve(values) } else { @@ -57,28 +35,19 @@ } changeType = (val) => { - const { linkurl, urls } = this.state - let _urls = this.props.form.getFieldValue('urls') || '' - let _url = this.props.form.getFieldValue('linkurl') || '' + let _url = '' if (val === 'input') { - if (_urls && _urls[0] && _urls[0].status === 'done' && (_urls[0].url || _urls[0].response)) { - _url = _urls[0].url || _urls[0].response - } else { - _url = linkurl || '' - } - } else { - _urls = urls.filter(item => item.status === 'done') - _url = linkurl + _url = this.props.form.getFieldValue('urls') || '' } - this.setState({plusType: val, urls: _urls, linkurl: _url}) + this.setState({plusType: val, linkurl: _url}) } render() { const { getFieldDecorator } = this.props.form const { card } = this.props - const { urls, linkurl, plusType } = this.state + const { linkurl, plusType } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -103,7 +72,7 @@ {!card.id && card.typecharone === 'image' && plusType === 'upload' ? <Col span={24}> <Form.Item label="鍥剧墖涓婁紶"> {getFieldDecorator('urls', { - initialValue: urls, + initialValue: '', rules: [ { required: true, @@ -111,14 +80,19 @@ } ] })( - <FileUpload accept=".jpg,.png,.gif,.pjp,.pjpeg,.jpeg,.jfif,.webp" maxFile={1} fileType={'picture'} /> + <FileUpload config={{ + initval: '', + suffix: '.jpg,.png,.gif,.pjp,.pjpeg,.jpeg,.jfif,.webp', + maxfile: 1, + fileType: 'picture' + }} /> )} </Form.Item> </Col> : null} {!card.id && card.typecharone === 'video' && plusType === 'upload' ? <Col span={24}> <Form.Item label="瑙嗛涓婁紶"> {getFieldDecorator('urls', { - initialValue: urls, + initialValue: '', rules: [ { required: true, @@ -126,7 +100,12 @@ } ] })( - <FileUpload accept=".mp4,.webm,.ogg" maxFile={1} fileType={'text'} /> + <FileUpload config={{ + initval: '', + suffix: '.mp4,.webm,.ogg', + maxfile: 1, + fileType: 'text' + }}/> )} </Form.Item> </Col> : null} diff --git a/src/tabviews/calendar/index.jsx b/src/tabviews/calendar/index.jsx index 54acf75..c1f446a 100644 --- a/src/tabviews/calendar/index.jsx +++ b/src/tabviews/calendar/index.jsx @@ -169,6 +169,27 @@ config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') _customScript = _customScript.replace(/@\$|\$@/ig, '') } + + let userName = sessionStorage.getItem('User_Name') || '' + let fullName = sessionStorage.getItem('Full_Name') || '' + let city = sessionStorage.getItem('city') || '' + + if (sessionStorage.getItem('isEditState') === 'true') { + userName = sessionStorage.getItem('CloudUserName') || '' + fullName = sessionStorage.getItem('CloudFullName') || '' + } + + let regs = [ + { reg: /@userName@/ig, value: `'${userName}'` }, + { reg: /@fullName@/ig, value: `'${fullName}'` }, + { reg: /@login_city@/ig, value: `'${city}'` } + ] + + regs.forEach(cell => { + config.setting.dataresource = config.setting.dataresource.replace(cell.reg, cell.value) + _customScript = _customScript.replace(cell.reg, cell.value) + }) + if (config.urlFields) { let _param = param || {} config.urlFields.forEach(field => { diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index ed33f98..481b3e5 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -236,6 +236,27 @@ config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '') } + + let userName = sessionStorage.getItem('User_Name') || '' + let fullName = sessionStorage.getItem('Full_Name') || '' + let city = sessionStorage.getItem('city') || '' + + if (sessionStorage.getItem('isEditState') === 'true') { + userName = sessionStorage.getItem('CloudUserName') || '' + fullName = sessionStorage.getItem('CloudFullName') || '' + } + + let regs = [ + { reg: /@userName@/ig, value: `'${userName}'` }, + { reg: /@fullName@/ig, value: `'${fullName}'` }, + { reg: /@login_city@/ig, value: `'${city}'` } + ] + + regs.forEach(cell => { + config.setting.dataresource = config.setting.dataresource.replace(cell.reg, cell.value) + config.setting.customScript = config.setting.customScript.replace(cell.reg, cell.value) + }) + if (config.urlFields) { let _param = param || {} config.urlFields.forEach(field => { diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index 9e7a7c8..7236e4d 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -170,9 +170,9 @@ } let regs = [ - { reg: /@userName@/ig, value: userName }, - { reg: /@fullName@/ig, value: fullName }, - { reg: /@login_city@/ig, value: city } + { reg: /@userName@/ig, value: `'${userName}'` }, + { reg: /@fullName@/ig, value: `'${fullName}'` }, + { reg: /@login_city@/ig, value: `'${city}'` } ] if (window.GLOB.externalDatabase !== null) { diff --git a/src/tabviews/formtab/formgroup/index.jsx b/src/tabviews/formtab/formgroup/index.jsx index aed3d1a..e03fbc1 100644 --- a/src/tabviews/formtab/formgroup/index.jsx +++ b/src/tabviews/formtab/formgroup/index.jsx @@ -4,7 +4,6 @@ import { Form, Row, Col, Input, InputNumber, Select, DatePicker, notification, Collapse } from 'antd' import moment from 'moment' import { formRule } from '@/utils/option.js' -import Utils from '@/utils/utils.js' import FileUpload from '@/tabviews/zshare/fileupload' import './index.scss' @@ -71,24 +70,6 @@ _fieldsvalue[key] = _val } else if (datatype[key] === 'fileupload') { let _val = nextProps.data[key] ? nextProps.data[key] : '' - - if (_val) { - try { - _val = _val.split(',').map((url, index) => { - return { - uid: `${index}`, - name: url.slice(url.lastIndexOf('/') + 1), - status: 'done', - url: url, - origin: true - } - }) - } catch { - _val = [] - } - } else { - _val = [] - } _fieldsvalue[key] = _val } else if (datatype[key] === 'text' || datatype[key] === 'textarea') { @@ -521,30 +502,11 @@ </Col> ) } else if (item.type === 'fileupload') { - let filelist = this.props.data ? this.props.data[item.field] : item.initval - if (filelist && this.state.readin[item.field]) { - try { - filelist = filelist.split(',').map((url, index) => { - return { - uid: `${index}`, - name: url.slice(url.lastIndexOf('/') + 1), - status: 'done', - url: url, - origin: true - } - }) - } catch { - filelist = [] - } - } else { - filelist = [] - } - fields.push( <Col span={24 / cols} key={index}> <Form.Item label={item.label}> {getFieldDecorator(item.field, { - initialValue: filelist, + initialValue: item.initval, rules: [ { required: item.required === 'true', @@ -552,7 +514,7 @@ } ] })( - <FileUpload /> + <FileUpload config={item}/> )} </Form.Item> </Col> @@ -674,19 +636,8 @@ _value = values[key] ? values[key].join(',') : '' } else if (this.state.datatype[key] === 'fileupload') { - let vals = [] + _value = values[key] - if (values[key] && values[key].length > 0) { - values[key].forEach(_val => { - if (_val.origin && _val.url) { - vals.push(_val.url) - } else if (!_val.origin && _val.status === 'done' && _val.response) { - vals.push(Utils.getrealurl(_val.response)) - } - }) - } - - _value = vals.join(',') } else if (this.state.datatype[key] === 'text' || this.state.datatype[key] === 'textarea') { _value = values[key].replace(/\t*|\v*/g, '') // 鍘婚櫎鍒惰〃绗� diff --git a/src/tabviews/subtable/index.jsx b/src/tabviews/subtable/index.jsx index bbd103c..dcd0099 100644 --- a/src/tabviews/subtable/index.jsx +++ b/src/tabviews/subtable/index.jsx @@ -306,6 +306,26 @@ config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '') } + + let userName = sessionStorage.getItem('User_Name') || '' + let fullName = sessionStorage.getItem('Full_Name') || '' + let city = sessionStorage.getItem('city') || '' + + if (sessionStorage.getItem('isEditState') === 'true') { + userName = sessionStorage.getItem('CloudUserName') || '' + fullName = sessionStorage.getItem('CloudFullName') || '' + } + + let regs = [ + { reg: /@userName@/ig, value: `'${userName}'` }, + { reg: /@fullName@/ig, value: `'${fullName}'` }, + { reg: /@login_city@/ig, value: `'${city}'` } + ] + + regs.forEach(cell => { + config.setting.dataresource = config.setting.dataresource.replace(cell.reg, cell.value) + config.setting.customScript = config.setting.customScript.replace(cell.reg, cell.value) + }) } this.setState({ diff --git a/src/tabviews/subtabtable/index.jsx b/src/tabviews/subtabtable/index.jsx index 34ff03e..af27534 100644 --- a/src/tabviews/subtabtable/index.jsx +++ b/src/tabviews/subtabtable/index.jsx @@ -281,6 +281,26 @@ config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '') } + + let userName = sessionStorage.getItem('User_Name') || '' + let fullName = sessionStorage.getItem('Full_Name') || '' + let city = sessionStorage.getItem('city') || '' + + if (sessionStorage.getItem('isEditState') === 'true') { + userName = sessionStorage.getItem('CloudUserName') || '' + fullName = sessionStorage.getItem('CloudFullName') || '' + } + + let regs = [ + { reg: /@userName@/ig, value: `'${userName}'` }, + { reg: /@fullName@/ig, value: `'${fullName}'` }, + { reg: /@login_city@/ig, value: `'${city}'` } + ] + + regs.forEach(cell => { + config.setting.dataresource = config.setting.dataresource.replace(cell.reg, cell.value) + config.setting.customScript = config.setting.customScript.replace(cell.reg, cell.value) + }) } this.setState({ diff --git a/src/tabviews/treepage/index.jsx b/src/tabviews/treepage/index.jsx index 5590efc..835e4a3 100644 --- a/src/tabviews/treepage/index.jsx +++ b/src/tabviews/treepage/index.jsx @@ -171,6 +171,26 @@ config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '') } + + let userName = sessionStorage.getItem('User_Name') || '' + let fullName = sessionStorage.getItem('Full_Name') || '' + let city = sessionStorage.getItem('city') || '' + + if (sessionStorage.getItem('isEditState') === 'true') { + userName = sessionStorage.getItem('CloudUserName') || '' + fullName = sessionStorage.getItem('CloudFullName') || '' + } + + let regs = [ + { reg: /@userName@/ig, value: `'${userName}'` }, + { reg: /@fullName@/ig, value: `'${fullName}'` }, + { reg: /@login_city@/ig, value: `'${city}'` } + ] + + regs.forEach(cell => { + config.setting.dataresource = config.setting.dataresource.replace(cell.reg, cell.value) + config.setting.customScript = config.setting.customScript.replace(cell.reg, cell.value) + }) } this.setState({ diff --git a/src/tabviews/zshare/fileupload/index.jsx b/src/tabviews/zshare/fileupload/index.jsx index 41910b9..32ecbc4 100644 --- a/src/tabviews/zshare/fileupload/index.jsx +++ b/src/tabviews/zshare/fileupload/index.jsx @@ -1,6 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { fromJS } from 'immutable' +import { is, fromJS } from 'immutable' import moment from 'moment' import { Upload, Button, Icon, Progress, notification } from 'antd' import SparkMD5 from 'spark-md5' @@ -16,23 +16,74 @@ class FileUpload extends Component { static propTpyes = { - value: PropTypes.array, // 鏂囦欢鏁扮粍 - accept: PropTypes.any, // 鏂囦欢鏍煎紡 - maxFile: PropTypes.any, // 鏈�澶ф枃浠舵暟 - fileType: PropTypes.string // 鏂囦欢鏄剧ず绫诲瀷 + config: PropTypes.object, // 琛ㄥ崟淇℃伅 + onChange: PropTypes.func, // 琛ㄥ崟鍙樺寲 } state = { percent: 0, + accept: '', + accepts: null, + maxFile: null, + rduri: '', + limit: 2, + compress: false, + fileType: 'text', showprogress: false, filelist: [] } UNSAFE_componentWillMount () { - const { value } = this.props - if (!value) return + const { config } = this.props - this.setState({filelist: fromJS(value).toJS()}) + let filelist = [] + if (config.initval) { + try { + filelist = config.initval.split(',').map((url, index) => { + return { + uid: `${index}`, + name: url.slice(url.lastIndexOf('/') + 1), + status: 'done', + url: url, + origin: true + } + }) + } catch { + filelist = [] + } + } + + let accept = '' + let accepts = null + let compress = false + if (config.compress === 'true') { + compress = true + accepts = ['.jpg', '.png', '.gif', '.jpeg'] + accept = accepts.join(',') + } else if (config.suffix) { + accepts = config.suffix.split(',') + accept = config.suffix + } + let rduri = config.rduri || '' + + if (window.GLOB.systemType === 'production') { + rduri = config.proRduri || '' + } + + this.setState({ + rduri, + accept, + accepts, + filelist, + compress, + limit: config.limit || 2, + maxFile: config.maxfile && config.maxfile > 0 ? config.maxfile : null, + fileType: config.fileType || 'text' + }) + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.state), fromJS(nextState)) } onChange = ({ fileList }) => { @@ -44,14 +95,24 @@ }) this.setState({filelist: fileList}) - this.props.onChange(fileList) } onRemove = file => { const files = this.state.filelist.filter(v => v.uid !== file.uid) this.setState({filelist: files}) - this.props.onChange(files) + + let vals = [] + + files.forEach(item => { + if (item.origin && item.url) { + vals.push(item.url) + } else if (!item.origin && item.status === 'done' && item.response) { + vals.push(item.response) + } + }) + + this.props.onChange(vals.join(',')) } onUpdate = (url) => { @@ -63,19 +124,31 @@ filelist[filelist.length -1].origin = false } + filelist = filelist.filter(item => !!(item.url || item.response)) + + let vals = [] + + filelist.forEach(item => { + if (item.origin && item.url) { + vals.push(item.url) + } else if (!item.origin && item.status === 'done' && item.response) { + vals.push(item.response) + } + }) + this.setState({filelist}) - this.props.onChange(filelist) + this.props.onChange(vals.join(',')) } - onDelete = (msg) => { + onFail = (msg) => { let filelist = this.state.filelist.map(item => { if (!item.url && !item.response && !item.status) { item.status = 'error' } return item }) - this.setState({filelist, showprogress: false}) - this.props.onChange(filelist) + + this.setState({filelist, showprogress: false, percent: 0}) notification.warning({ top: 92, @@ -110,7 +183,7 @@ if (res.urlPath) { this.onUpdate(res.urlPath) } else { - this.onDelete() + this.onFail() } this.setState({ percent: 100 @@ -124,7 +197,7 @@ }) } } else { - this.onDelete(res.message) + this.onFail(res.message) } }) } @@ -140,12 +213,11 @@ } beforeUpload = (file) => { - const { accept } = this.props + const { accepts, compress, limit, rduri } = this.state - if (accept && file.name) { - let types = accept.split(',') + if (accepts && file.name) { let pass = false - types.forEach(type => { + accepts.forEach(type => { if (new RegExp(type + '$', 'ig').test(file.name)) { pass = true } @@ -165,6 +237,89 @@ showprogress: true, percent: 0 }) + + if (compress) { + let reader = new FileReader() + let fileSize = file.size / 1024 / 1024 + let compressRate = 0.9 + + if (fileSize / limit > 5) { + compressRate = 0.4 + } else if (fileSize / limit > 4) { + compressRate = 0.5 + } else if (fileSize / limit > 3) { + compressRate = 0.6 + } else if (fileSize / limit > 2) { + compressRate = 0.7 + } else if (fileSize > limit) { + compressRate = 0.8 + } + + reader.onload = (e) => { + let img = new Image() + let maxW = 640 + + img.onload = () => { + let cvs = document.createElement( 'canvas') + let ctx = cvs.getContext( '2d') + + if (img.width > maxW) { + img.height *= maxW / img.width + img.width = maxW + } + + cvs.width = img.width + cvs.height = img.height + + ctx.clearRect(0, 0, cvs.width, cvs.height) + ctx.drawImage(img, 0, 0, img.width, img.height) + + let param = {Base64Img: cvs.toDataURL('image/jpeg', compressRate)} + + if (rduri) { + param.rduri = rduri + } + + Api.fileuploadbase64(param).then(result => { + if (result.status && result.Images) { + let url = service + result.Images + + if (rduri) { + url = rduri.replace(/webapi(.*)$/, '') + result.Images + } + + this.onUpdate(url) + + this.setState({ + percent: 100 + }, () => { + setTimeout(() => { + this.setState({ + showprogress: false, + percent: 0 + }) + }, 200) + }) + } else { + this.onFail(result.message) + } + }) + } + + img.onerror = () => { + this.onFail('鍥剧墖璇诲彇澶辫触锛�') + } + + img.src = e.target.result + } + + reader.onerror = () => { + this.onFail('鏂囦欢璇诲彇澶辫触锛�') + } + + reader.readAsDataURL(file) + return false + } // 鍏煎鎬х殑澶勭悊 let blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice @@ -234,11 +389,10 @@ } chunkFileReader.onerror = () => { - this.onDelete() - console.warn('File reading failed.') + this.onFail('鏂囦欢璇诲彇澶辫触锛�') } totalFileReader.onerror = () => { - this.onDelete() + this.onFail('鏂囦欢璇诲彇澶辫触锛�') } let loadNext = () => { @@ -270,12 +424,11 @@ } render() { - const { maxFile, fileType, accept } = this.props - const { showprogress, percent, filelist } = this.state + const { showprogress, percent, filelist, maxFile, fileType, accept } = this.state let uploadable = 'fileupload-form-container ' - if (maxFile && maxFile > 0 && filelist.length >= maxFile) { + if (maxFile && filelist.length >= maxFile) { uploadable += 'limit-fileupload' } @@ -285,7 +438,7 @@ listType: fileType, fileList: filelist, action: null, - accept: accept || '', + accept: accept, method: 'post', multiple: false, onChange: this.onChange, diff --git a/src/tabviews/zshare/fileupload/index.scss b/src/tabviews/zshare/fileupload/index.scss index 5841f7b..6b612d6 100644 --- a/src/tabviews/zshare/fileupload/index.scss +++ b/src/tabviews/zshare/fileupload/index.scss @@ -4,6 +4,12 @@ bottom: -20px; left: 0px; } + + .ant-upload-select-picture-card { + .ant-progress-small.ant-progress-line { + bottom: 0px; + } + } .ant-upload-list-picture-card .ant-upload-list-item { width: 90px; @@ -12,6 +18,12 @@ .ant-upload.ant-upload-select-picture-card { width: 90px; height: 90px; + } + a[href^="data"] { + pointer-events: none; + .anticon-eye-o { + display: none; + } } } .fileupload-form-container.limit-fileupload { @@ -26,4 +38,7 @@ } } } + > .ant-upload-select-picture-card { + display: none; + } } \ No newline at end of file diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index 4a77963..80d4c3a 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -1105,25 +1105,6 @@ </Col> ) } else if (item.type === 'fileupload') { - let filelist = this.props.data ? this.props.data[item.field] : item.initval - if (filelist && item.readin) { - try { - filelist = filelist.split(',').map((url, index) => { - return { - uid: `${index}`, - name: url.slice(url.lastIndexOf('/') + 1), - status: 'done', - url: url, - origin: true - } - }) - } catch { - filelist = [] - } - } else { - filelist = [] - } - fields.push( <Col span={item.span || 24} key={index}> <Form.Item @@ -1138,7 +1119,7 @@ } > {getFieldDecorator(item.field, { - initialValue: filelist, + initialValue: item.initval || '', rules: [ { required: item.required === 'true', @@ -1146,7 +1127,7 @@ } ] })( - <FileUpload accept={item.suffix} maxFile={item.maxfile} fileType={item.fileType || 'text'} /> + <FileUpload config={item}/> )} </Form.Item> </Col> @@ -1326,20 +1307,6 @@ } else if (item.type === 'multiselect' || item.type === 'checkbox') { _value = _value ? _value.join(',') : '' - } else if (item.type === 'fileupload') { - let vals = [] - - if (_value && _value.length > 0) { - _value.forEach(_val => { - if (_val.origin && _val.url) { - vals.push(_val.url) - } else if (!_val.origin && _val.status === 'done' && _val.response) { - vals.push(_val.response) - } - }) - } - - _value = vals.join(',') } else if (item.type === 'text' || item.type === 'textarea') { _value = _value.replace(/\t*|\v*/g, '') // 鍘婚櫎鍒惰〃绗� diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index 9b6375b..74f69e9 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -2559,6 +2559,51 @@ forbid: appType === 'mob' }, { + type: 'radio', + key: 'compress', + label: '鍓嶇鍘嬬缉', + initVal: card.compress || 'false', + tooltip: '鍓嶇鍘嬬缉蹇呴』涓哄浘鐗囥��', + options: [{ + value: 'true', + text: Formdict['model.true'] + }, { + value: 'false', + text: Formdict['model.false'] + }] + }, + { + type: 'number', + key: 'limit', + min: 0.01, + max: 1000, + precision: 2, + label: '璧风偣锛圡锛�', + initVal: card.limit || 2, + tooltip: '鍘嬬缉璧风偣锛屽皬浜庤捣鐐瑰�肩殑鏂囦欢涓嶈繘琛屽帇缂┿��', + required: true + }, + { + type: 'textarea', + key: 'rduri', + label: '杞瓨鎺ュ彛', + rows: 1, + initVal: card.rduri || '', + tooltip: '鍥剧墖杞瓨鍦ㄥ悓涓�鍗曠偣鏈嶅姟鍣ㄤ笅鐨勫叾浠栦笟鍔$郴缁熴��', + required: false, + readonly: false + }, + { + type: 'textarea', + key: 'proRduri', + label: '姝e紡鎺ュ彛', + rows: 1, + initVal: card.proRduri || '', + tooltip: '姝e紡绯荤粺杞瓨鎺ュ彛锛屽浘鐗囪浆瀛樺湪鍚屼竴鍗曠偣鏈嶅姟鍣ㄤ笅鐨勫叾浠栦笟鍔$郴缁熴��', + required: false, + readonly: false + }, + { type: 'text', key: 'suffix', label: '鍚庣紑鍚�', diff --git a/src/templates/zshare/modalform/datatable/index.jsx b/src/templates/zshare/modalform/datatable/index.jsx index 50e0cc6..e7a12a1 100644 --- a/src/templates/zshare/modalform/datatable/index.jsx +++ b/src/templates/zshare/modalform/datatable/index.jsx @@ -70,9 +70,14 @@ class EditableCell extends Component { getInput = (form) => { - const { inputType } = this.props + const { inputType, record } = this.props if (inputType === 'file') { - return <FileUpload maxFile={1} fileType="picture-card"/> + return <FileUpload config={{ + initval: record ? (record.$url || '') : '', + suffix: '', + maxfile: 1, + fileType: 'picture-card' + }}/> } else { return <Input onPressEnter={() => this.getValue(form)} /> } @@ -85,15 +90,6 @@ return } - if (row.$url && Array.isArray(row.$url)) { - if (!row.$url[0]) { - row.$url = '' - } else if (row.$url[0].origin) { - row.$url = row.$url[0].url || '' - } else if (!row.$url[0].origin && row.$url[0].status === 'done' && row.$url[0].response) { - row.$url = row.$url[0].response - } - } this.props.onSave({...record, ...row}) }) } @@ -116,18 +112,6 @@ if (record && dataIndex) { _val = record[dataIndex] - } - - if (dataIndex === '$url' && _val) { - _val = [{ - uid: `10086`, - name: _val.slice(_val.lastIndexOf('/') + 1), - status: 'done', - url: _val, - origin: true - }] - } else if (dataIndex === '$url') { - _val = [] } return ( @@ -289,16 +273,6 @@ form.validateFields((error, row) => { if (error) { return; - } - - if (row.$url && Array.isArray(row.$url)) { - if (!row.$url[0]) { - row.$url = '' - } else if (row.$url[0].origin) { - row.$url = row.$url[0].url || '' - } else if (!row.$url[0].origin && row.$url[0].status === 'done' && row.$url[0].response) { - row.$url = row.$url[0].response - } } const newData = [...this.state.data] diff --git a/src/templates/zshare/modalform/datatable/index.scss b/src/templates/zshare/modalform/datatable/index.scss index e80b7bf..6d5ee71 100644 --- a/src/templates/zshare/modalform/datatable/index.scss +++ b/src/templates/zshare/modalform/datatable/index.scss @@ -21,17 +21,11 @@ padding: 16px 10px; } .fileupload-form-container .ant-upload-list-picture-card .ant-upload-list-item { - width: 70px; - height: 70px; margin: 0; padding: 2px; .ant-upload-list-item-info > span { height: 100%; } - } - .fileupload-form-container .ant-upload.ant-upload-select-picture-card { - width: 70px; - height: 70px; } } .operation-btn { diff --git a/src/templates/zshare/modalform/index.jsx b/src/templates/zshare/modalform/index.jsx index 20b9e85..6225afa 100644 --- a/src/templates/zshare/modalform/index.jsx +++ b/src/templates/zshare/modalform/index.jsx @@ -22,7 +22,7 @@ checkcard: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'linkSubField', 'fieldlength', 'span', 'labelwidth', 'display', 'tooltip', 'extra', 'width', 'multiple'], multiselect: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra'], link: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'setAll', 'linkField', 'span', 'labelwidth', 'tooltip', 'extra', 'emptyText', 'enter'], - fileupload: ['readonly', 'required', 'readin', 'fieldlength', 'maxfile', 'fileType', 'span', 'labelwidth', 'tooltip', 'extra', 'suffix'], + fileupload: ['readonly', 'required', 'readin', 'fieldlength', 'maxfile', 'fileType', 'span', 'labelwidth', 'tooltip', 'extra', 'compress'], switch: ['initval', 'openVal', 'closeVal', 'openText', 'closeText', 'readonly', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra'], date: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode'], datemonth: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType'], @@ -49,6 +49,7 @@ openType: null, resourceType: null, supField: '', + compress: 'false', display: 'text', enter: '', cFields: [], @@ -62,6 +63,7 @@ let resourceType = '' let supField = '' let display = '' + let compress = 'false' let enter = '' let cFields = [] let linkSubFields = [] @@ -69,6 +71,8 @@ formlist.forEach(cell => { if (cell.key === 'type') { type = cell.initVal + } else if (cell.key === 'compress') { + compress = cell.initVal } else if (cell.key === 'display') { display = cell.initVal } else if (cell.key === 'enter') { @@ -92,10 +96,11 @@ } }) - let _options = this.getOptions(type, resourceType, supField, display, enter) + let _options = this.getOptions(type, resourceType, supField, display, enter, compress) this.setState({ enter: enter, + compress: compress, openType: type, supField: supField, display: display, @@ -143,7 +148,7 @@ } } - getOptions = (type, resourceType, supField, display, enter) => { + getOptions = (type, resourceType, supField, display, enter, compress) => { let _options = ['label', 'field', 'type', 'blacklist', 'writein', ...fromJS(modalTypeOptions[type]).toJS()] if (type === 'hint') { @@ -169,6 +174,12 @@ } else if (resourceType === '1') { // 鏁版嵁婧� _options.push('dataSource', 'cardValField', 'fields', 'orderBy', 'orderType', 'database') } + } + } else if (type === 'fileupload') { + if (compress === 'true') { + _options.push('limit', 'rduri', 'proRduri') + } else { + _options.push('suffix') } } @@ -201,7 +212,7 @@ fieldValue.enter = 'false' } - let _options = this.getOptions(value, this.state.resourceType, this.state.supField, this.state.display, enter) + let _options = this.getOptions(value, this.state.resourceType, this.state.supField, this.state.display, enter, this.state.compress) this.setState({ openType: value, @@ -314,10 +325,10 @@ } onChange = (e, key) => { - const { openType } = this.state + const { openType, compress } = this.state let value = e.target.value if (key === 'resourceType') { - let _options = this.getOptions(openType, value, this.state.supField, this.state.display, this.state.enter) + let _options = this.getOptions(openType, value, this.state.supField, this.state.display, this.state.enter, compress) this.setState({ resourceType: value, @@ -327,7 +338,7 @@ }) }) } else if (key === 'display') { - let _options = this.getOptions(openType, this.state.resourceType, this.state.supField, value, this.state.enter) + let _options = this.getOptions(openType, this.state.resourceType, this.state.supField, value, this.state.enter, compress) this.setState({ display: value, @@ -336,8 +347,18 @@ return form }) }) + } else if (key === 'compress') { + let _options = this.getOptions(openType, this.state.resourceType, this.state.supField, this.state.display, this.state.enter, value) + + this.setState({ + compress: value, + formlist: this.state.formlist.map(form => { + form.show = _options.includes(form.key) + return form + }) + }) } else if (key === 'enter') { - let _options = this.getOptions(openType, this.state.resourceType, this.state.supField, this.state.display, value) + let _options = this.getOptions(openType, this.state.resourceType, this.state.supField, this.state.display, value, compress) this.setState({ enter: value, @@ -620,7 +641,12 @@ } else if (item.type === 'textarea') { fields.push( <Col span={24} key={index}> - <Form.Item className="text-msg" label={item.label}> + <Form.Item className="text-msg" label={item.tooltip ? + <Tooltip placement="topLeft" overlayClassName={item.tooltipClass} title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> {getFieldDecorator(item.key, { initialValue: item.initVal, rules: [ @@ -629,7 +655,7 @@ message: this.props.dict['form.required.input'] + item.label + '!' } ] - })(<TextArea rows={4} />)} + })(<TextArea rows={item.rows || 4} />)} </Form.Item> </Col> ) diff --git a/src/utils/utils-datamanage.js b/src/utils/utils-datamanage.js index d0f759b..b995699 100644 --- a/src/utils/utils-datamanage.js +++ b/src/utils/utils-datamanage.js @@ -125,15 +125,6 @@ } }) regoptions.push({ - reg: new RegExp('@login_city@', 'ig'), - value: `'${city}'` - }, { - reg: new RegExp('@userName@', 'ig'), - value: `'${userName}'` - }, { - reg: new RegExp('@fullName@', 'ig'), - value: `'${fullName}'` - }, { reg: new RegExp('@orderBy@', 'ig'), value: orderBy }, { @@ -265,15 +256,6 @@ } }) regoptions.push({ - reg: new RegExp('@login_city@', 'ig'), - value: `'${city}'` - }, { - reg: new RegExp('@userName@', 'ig'), - value: `'${userName}'` - }, { - reg: new RegExp('@fullName@', 'ig'), - value: `'${fullName}'` - }, { reg: new RegExp('@orderBy@', 'ig'), value: orderBy }, { diff --git a/src/views/appmanage/submutilform/index.jsx b/src/views/appmanage/submutilform/index.jsx index 712464f..611f749 100644 --- a/src/views/appmanage/submutilform/index.jsx +++ b/src/views/appmanage/submutilform/index.jsx @@ -23,11 +23,6 @@ return new Promise(resolve => { this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { - if (values.favicon && values.favicon.length > 0 && values.favicon[0].status === 'done') { - values.favicon = values.favicon[0].response || values.favicon[0].url || '' - } else { - values.favicon = '' - } resolve(values) } }) @@ -56,16 +51,10 @@ } } - let filelist = [] + let file = '' if (type === 'edit' && card && card.favicon) { - filelist = [{ - uid: `favicon`, - name: card.favicon.slice(card.favicon.lastIndexOf('/') + 1), - status: 'done', - url: card.favicon, - origin: true - }] + file = card.favicon } return ( @@ -179,8 +168,13 @@ <Col span={12}> <Form.Item label="鍥炬爣"> {getFieldDecorator('favicon', { - initialValue: filelist - })(<FileUpload accept=".jpg,.png,.gif,.pjp,.pjpeg,.jpeg,.jfif,.webp,.ico" maxFile={1} fileType={'text'} />)} + initialValue: file + })(<FileUpload config={{ + initval: file, + suffix: '.jpg,.png,.gif,.pjp,.pjpeg,.jpeg,.jfif,.webp,.ico', + maxfile: 1, + fileType: 'text' + }}/>)} </Form.Item> </Col> </Row> diff --git a/src/views/billprint/index.jsx b/src/views/billprint/index.jsx index 6adefcc..048ff2e 100644 --- a/src/views/billprint/index.jsx +++ b/src/views/billprint/index.jsx @@ -156,6 +156,29 @@ let _pars = [] config.components = config.components.filter(item => !['tabs', 'search'].includes(item.type)) + + let userName = sessionStorage.getItem('User_Name') || '' + let fullName = sessionStorage.getItem('Full_Name') || '' + let city = sessionStorage.getItem('city') || '' + + if (sessionStorage.getItem('isEditState') === 'true') { + userName = sessionStorage.getItem('CloudUserName') || '' + fullName = sessionStorage.getItem('CloudFullName') || '' + } + + let regs = [ + { reg: /@userName@/ig, value: `'${userName}'` }, + { reg: /@fullName@/ig, value: `'${fullName}'` }, + { reg: /@login_city@/ig, value: `'${city}'` } + ] + + if (window.GLOB.externalDatabase !== null) { + regs.push({ + reg: /@db@/ig, + value: window.GLOB.externalDatabase + }) + } + config.components = config.components.map(component => { if (component.action) component.action = [] if (component.search) component.search = [] @@ -203,11 +226,10 @@ _customScript = _customScript.replace(/@\$|\$@/ig, '') } - // 澶栬仈鏁版嵁搴撴浛鎹� - if (window.GLOB.externalDatabase !== null) { - component.setting.dataresource = component.setting.dataresource.replace(/@db@/ig, window.GLOB.externalDatabase) - _customScript = _customScript.replace(/@db@/ig, window.GLOB.externalDatabase) - } + regs.forEach(cell => { + component.setting.dataresource = component.setting.dataresource.replace(cell.reg, cell.value) + _customScript = _customScript.replace(cell.reg, cell.value) + }) component.setting.customScript = _customScript // 鏁寸悊鍚庤嚜瀹氫箟鑴氭湰 diff --git a/src/views/printTemplate/index.jsx b/src/views/printTemplate/index.jsx index e6e46a6..af5cce2 100644 --- a/src/views/printTemplate/index.jsx +++ b/src/views/printTemplate/index.jsx @@ -681,12 +681,6 @@ } else if (res.type === 'qrcode') { res.url = qrurl } else if (res.type === 'image') { - if (res.value && res.value.length > 0) { - let url = res.value[0].url || res.value[0].response - res.value = url || '' - } else { - res.value = '' - } res.url = imgurl } diff --git a/src/views/printTemplate/mutilform/index.jsx b/src/views/printTemplate/mutilform/index.jsx index f26ae33..46471dd 100644 --- a/src/views/printTemplate/mutilform/index.jsx +++ b/src/views/printTemplate/mutilform/index.jsx @@ -52,6 +52,9 @@ formlist: nextProps.formlist.map(item => { if (item.key === 'cusfield' && isCusField) { item.hidden = false + } else if (item.key === 'value' && item.type === 'fileupload') { + item.hidden = true + item.initval = fieldsvalue.value } return item @@ -60,15 +63,17 @@ if (!isCusField) { delete fieldsvalue.cusfield } - if (nextProps.editItem.type === 'image' && fieldsvalue.value) { - fieldsvalue.value = [{ - uid: '1', - name: fieldsvalue.value, - status: 'done', - url: fieldsvalue.value - }] - } else if (nextProps.editItem.type === 'image') { - fieldsvalue.value = [] + if (nextProps.editItem.type === 'image') { + this.setState({ + formlist: this.state.formlist.map(item => { + if (item.key === 'value' && item.type === 'fileupload') { + item.hidden = false + } + + return item + }) + }) + delete fieldsvalue.value } this.props.form.setFieldsValue(fieldsvalue) @@ -112,17 +117,9 @@ this.handleSubmit() } - updateImg = (list) => { - if (list && list.length > 0) { - let url = list[0].url || list[0].response - if (url) { - this.props.form.setFieldsValue({ value: list }) - this.handleSubmit() - } - } else { - this.props.form.setFieldsValue({ value: [] }) - this.handleSubmit() - } + updateImg = (val) => { + this.props.form.setFieldsValue({ value: val }) + this.handleSubmit() } resetForm = (param) => { @@ -134,15 +131,9 @@ if (_param.field !== 'other_field') { delete _param.cusfield } - if (param.type === 'image' && param.value) { - _param.value = [{ - uid: '1', - name: param.value, - status: 'done', - url: param.value - }] - } else if (param.type === 'image') { - _param.value = [] + + if (param.type === 'image') { + delete _param.value } this.props.form.setFieldsValue(_param) @@ -238,21 +229,11 @@ </Col> ) } else if (item.type === 'fileupload') { - let filelist = [] - if (item.initval) { - filelist = [{ - uid: '1', - name: item.initval, - status: 'done', - url: item.initval - }] - } - fields.push( <Col span={24} key={index}> <Form.Item label={item.label}> {getFieldDecorator(item.key, { - initialValue: filelist, + initialValue: item.initval || '', rules: [ { required: item.required, @@ -260,7 +241,12 @@ } ] })( - <FileUpload maxFile={1} fileType={'text'} onChange={this.updateImg} /> + <FileUpload config={{ + initval: item.initval || '', + suffix: '', + maxfile: 1, + fileType: 'text' + }} onChange={this.updateImg} /> )} </Form.Item> </Col> @@ -298,7 +284,6 @@ if (!err) { values.uuid = this.props.editItem.uuid values.type = this.props.editItem.type - resolve(values) } }) -- Gitblit v1.8.0