From 24bfb39e86c7a265803486bc4b546ea2bfaef4a5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 02 四月 2023 23:40:30 +0800 Subject: [PATCH] 2023-04-02 --- src/tabviews/zshare/actionList/printbutton/index.jsx | 111 ++++++++++++++++++++++++++++++++----------------------- 1 files changed, 64 insertions(+), 47 deletions(-) diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index 9bdf99e..0dceae9 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/index.jsx @@ -2115,70 +2115,87 @@ btnconfig.fields.forEach(item => { if (!item.field) return - let _readin = item.readin !== 'false' - let _initval = item.initval - if (item.type === 'linkMain' || item.type === 'funcvar') { + let _item = { + key: item.field, + readin: item.readin !== 'false' && item.readin !== 'top', + fieldlen: item.fieldlength || 50, + writein: item.writein !== 'false', + type: item.type, + value: item.initval + } + + let key = item.field.toLowerCase() + let _readin = item.readin !== 'false' + + if (_item.type === 'date') { // 鏃堕棿鍏煎 + _item.precision = item.precision || 'day' + } else if (_item.type === 'datetime') { + _item.type = 'date' + _item.precision = 'second' + } else if (['funcvar', 'linkMain'].includes(_item.type)) { _readin = false - } else if (['select', 'link', 'radio'].includes(item.type)) { // 閫変腑绗竴椤� - if (typeof(_initval) === 'string' && _initval.indexOf('$first') > -1) { - _initval = '' + _item.readin = false + } else if (['select', 'link', 'radio'].includes(_item.type)) { // 閫変腑绗竴椤� + if (/^\s*\$first\s*$/.test(_item.value)) { + _item.value = '' if (item.resourceType === '0' && item.options[0] && item.options[0].Value) { - _initval = item.options[0].Value + _item.value = item.options[0].Value } } } - if (item.type === 'linkMain' && BData.hasOwnProperty(item.field.toLowerCase())) { - _initval = BData[item.field.toLowerCase()] - } else if (_readin && _data.hasOwnProperty(item.field.toLowerCase())) { - _initval = _data[item.field.toLowerCase()] - } else if (item.type === 'date' && _initval) { - _initval = moment().subtract(_initval, 'days').format('YYYY-MM-DD') - } else if (item.type === 'datemonth' && _initval) { - _initval = moment().subtract(_initval, 'month').format('YYYY-MM') - } else if (item.type === 'datetime' && _initval) { - _initval = moment().subtract(_initval, 'days').format('YYYY-MM-DD HH:mm:ss') + if (_item.type === 'funcvar') { + _item.value = '' + } else if (_item.type === 'linkMain' && BData.hasOwnProperty(key)) { + _item.value = BData[key] + } else if (_readin && _data.hasOwnProperty(key)) { + _item.value = _data[key] + } else if (_item.type === 'date' && _item.value) { + _item.value = moment().subtract(_item.value, 'days').format(_item.precision === 'day' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss') + } else if (_item.type === 'datemonth' && _item.value) { + _item.value = moment().subtract(_item.value, 'month').format('YYYY-MM') } - let _fieldlen = item.fieldlength || 50 - if (item.type === 'textarea' || item.type === 'fileupload' || item.type === 'multiselect') { - _fieldlen = item.fieldlength || 512 - } else if (item.type === 'number') { - _fieldlen = item.decimal ? item.decimal : 0 - } else if (item.type === 'rate') { - item.rateCount = item.rateCount || 5 - let allowHalf = item.allowHalf === 'true' + _item.value = _item.value === undefined ? '' : _item.value - if (allowHalf) { - _initval = parseFloat(_initval) - if (_initval % 0.5 !== 0) { - _initval = parseInt(_initval) + if (_item.type === 'number' || item.declare === 'decimal') { + _item.type = 'number' + _item.fieldlen = item.decimal || 0 + } else if (['text', 'textarea', 'linkMain'].includes(_item.type)) { + _item.value = _item.value + '' + _item.value = _item.value.replace(/\t*|\v*/g, '') // 鍘婚櫎鍒惰〃绗� + + if (item.interception !== 'false') { // 鍘婚櫎棣栧熬绌烘牸 + _item.value = _item.value.replace(/(^\s*|\s*$)/g, '') + } + if (_item.type === 'text' && /@appkey@|@SessionUid@|@bid@/ig.test(_item.value)) { // 鐗规畩瀛楁鏇挎崲 + _item.value = _item.value.replace(/^(\s*)@appkey@(\s*)$/ig, window.GLOB.appkey).replace(/^(\s*)@SessionUid@(\s*)$/ig, (localStorage.getItem('SessionUid') || '')).replace(/^(\s*)@bid@(\s*)$/ig, (this.props.BID || '')) + } + if (_item.type === 'text' && item.lenControl && item.lenControl !== 'limit') { + if (item.lenControl === 'left') { + _item.value = _item.value.substr(0, item.fieldlength) + } else { + _item.value = _item.value.slice(-item.fieldlength) } - } else { - _initval = parseInt(_initval) } + } else if (_item.type === 'datemonth') { + _item.type = 'text' + } else if (_item.type === 'date') { + _item.type = item.declareType === 'nvarchar(50)' ? 'text' : 'date' + } else if (_item.type === 'rate') { + let count = item.rateCount || 5 + _item.value = parseInt(_item.value) - if (isNaN(_initval) || _initval < 0) { - _initval = 0 - } else if (_initval > item.rateCount) { - _initval = item.rateCount + if (isNaN(_item.value) || _item.value < 0) { + _item.value = 0 + } else if (_item.value > count) { + _item.value = count } } - if (_initval === undefined) { - _initval = '' - } - - result.push({ - key: item.field, - readonly: item.readonly === 'true', - readin: item.readin !== 'false' && item.readin !== 'top', - fieldlen: _fieldlen, - type: item.type, - value: _initval - }) + result.push(_item) }) if (btnconfig.setting.display === 'exec') { -- Gitblit v1.8.0