From 9a11e62adeb8d435b52a361eb62d5b59e1deef2a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 23 五月 2024 21:14:50 +0800 Subject: [PATCH] 2024-05-23 --- src/utils/utils.js | 183 +++++++++++++++++++++++++++++++++------------ 1 files changed, 134 insertions(+), 49 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index 64d2720..ea19a1d 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -854,24 +854,6 @@ } /** - * @description 鑾峰彇浜戠鍥剧墖鐪熷疄璺緞 - * @return {String} url 鍥剧墖璺緞 - */ - static getcloudurl (url) { - if (!url) return '' - - let baseurl = '' - - if (window.GLOB.cloudServiceApi) { - baseurl = window.GLOB.cloudServiceApi.replace(/webapi(.*)$/, '') - } else { - baseurl = window.GLOB.baseurl - } - - return url.match(/^http/) || url.match(/^\/\//) ? url : baseurl + url - } - - /** * @description 鑾峰彇涓嬫媺鎼滅储鏌ヨ鏉′欢 * @return {String} item 鎼滅储鏉′欢淇℃伅 */ @@ -1066,12 +1048,18 @@ } } else if (typeof(val) === 'string') { val = val.replace(/(^\s+$)|\t+|\v+/ig, '') - if (!val && col.required === 'true') { // 鏃堕棿蹇呭~鏍¢獙 - errors.push(_position + '鍐呭涓嶅彲涓虹┖') - } else if (val && !/^[1-9][0-9]{3}/.test(val)) { // 鏃堕棿姝e垯鏍¢獙 + if (!val) { + if (col.required === 'true') { // 鏃堕棿蹇呭~鏍¢獙 + errors.push(_position + '鍐呭涓嶅彲涓虹┖') + } else if (col.type === 'date') { + val = '1949-10-01' + } else if (col.type === 'datetime') { + val = '1949-10-01 00:00:00' + } + } else if (!/^[1-9][0-9]{3}/.test(val)) { // 鏃堕棿姝e垯鏍¢獙 errors.push(_position + '鏃堕棿鏍煎紡閿欒') } - } else { // 鏃堕棿鏍煎紡閿欒 + } else { // 鏃堕棿鏍煎紡閿欒 errors.push(_position + '鏃堕棿鏍煎紡閿欒') } } @@ -1146,9 +1134,15 @@ let _uniquesql = '' if (btn.uniques && btn.uniques.length > 0) { let textFields = [] + let numberFields = [] + let dateFields = [] btn.columns.forEach((col) => { - if (/^Nvarchar/ig.test(col.type)) { + if (/Nvarchar/ig.test(col.type)) { textFields.push(col.Column) + } else if (/Decimal|int/ig.test(col.type)) { + numberFields.push(col.Column) + } else if (/date/ig.test(col.type)) { + dateFields.push(col.Column) } }) @@ -1157,13 +1151,17 @@ let _fields = unique.field.split(',') let _fields_ = _fields.map(_field => `a.${_field}=b.${_field}`) - let _afields = _fields.map(_field => `a.${_field}`) + _fields_ = _fields_.join(' and ') let _where = [] _fields.forEach(f => { if (textFields.includes(f)) { _where.push(`${f}!=''`) + } else if (numberFields.includes(f)) { + _where.push(`${f}!=0`) + } else if (dateFields.includes(f)) { + _where.push(`${f}>'1949-10-01'`) } }) _where = _where.length ? `where ${_where.join(' and ')} ` : '' @@ -1171,6 +1169,20 @@ if (unique.verifyType === 'logic' || unique.verifyType === 'logic_temp') { _fields_ += ' and b.deleted=0' } + + let _afields = [] + _fields = _fields.map(f => { + if (numberFields.includes(f)) { + _afields.push(`cast(a.${f} as nvarchar(50))`) + return `cast(${f} as nvarchar(50))` + } else if (dateFields.includes(f)) { + _afields.push(`CONVERT(nvarchar(50), a.${f}, 21)`) + return `CONVERT(nvarchar(50), ${f}, 21)` + } + _afields.push(`a.${f}`) + + return f + }) _uniquesql += ` /* 閲嶅鎬ч獙璇� */ @@ -1380,17 +1392,54 @@ let _uniquesql = '' if (btn.uniques && btn.uniques.length > 0) { + let textFields = [] + let numberFields = [] + let dateFields = [] + columns.forEach((col) => { + if (/Nvarchar/ig.test(col.datatype)) { + textFields.push(col.field) + } else if (/Decimal|int/ig.test(col.datatype)) { + numberFields.push(col.field) + } else if (/date/ig.test(col.datatype)) { + dateFields.push(col.field) + } + }) btn.uniques.forEach(unique => { if (unique.status === 'false' || !unique.verifyType) return let _fields = unique.field.split(',') let _fields_ = _fields.map(_field => `a.${_field}=b.${_field}`) - let _afields = _fields.map(_field => `a.${_field}`) _fields_ = _fields_.join(' and ') + + let _where = [] + _fields.forEach(f => { + if (textFields.includes(f)) { + _where.push(`${f}!=''`) + } else if (numberFields.includes(f)) { + _where.push(`${f}!=0`) + } else if (dateFields.includes(f)) { + _where.push(`${f}>'1949-10-01'`) + } + }) + _where = _where.length ? `where ${_where.join(' and ')} ` : '' if (unique.verifyType === 'logic' || unique.verifyType === 'logic_temp') { _fields_ += ' and b.deleted=0' } + + let _afields = [] + _fields = _fields.map(f => { + if (numberFields.includes(f)) { + _afields.push(`cast(a.${f} as nvarchar(50))`) + return `cast(${f} as nvarchar(50))` + } else if (dateFields.includes(f)) { + _afields.push(`CONVERT(nvarchar(50), a.${f}, 21)`) + return `CONVERT(nvarchar(50), ${f}, 21)` + } + _afields.push(`a.${f}`) + + return f + }) _uniquesql += ` /* 閲嶅鎬ч獙璇� */ @@ -1404,7 +1453,7 @@ end ${unique.verifyType.indexOf('temp') === -1 ? `Set @tbid='' - Select top 1 @tbid=${_afields.join('+\' \'+')} from #${sheet} a Inner join ${database}${sheet} b on ${_fields_} + Select top 1 @tbid=${_afields.join('+\' \'+')} from ${_where ? `(select * from #${sheet} ${_where})` : `#${sheet}`} a Inner join ${database}${sheet} b on ${_fields_} If @tbid!='' Begin @@ -1885,7 +1934,7 @@ if (_key === 'bid' && !_val) { // 琛ㄥ崟涓病鏈塨id鍒欎娇鐢ㄧ郴缁焍id鍙橀噺 _val = BID } - + _fieldValue.push(`${_key}='${_val}'`) _value.push(`${_labels[index] || ''}锛�${_val || ''}`) }) @@ -2149,6 +2198,7 @@ let status = 0 let statusName = '' let detailId = '' + let sign = '' let error = '' let userid = sessionStorage.getItem('UserID') || '' let checkIds = [] @@ -2197,14 +2247,31 @@ } }) if (!error) { - line = lines[0] + lines = lines.filter(cell => { + if (cell.mkdata.seniorCondition === 'open' && !line) { + cell.mkdata.seniorbers && cell.mkdata.seniorbers.forEach(per => { + if (per.worker_id === userid) { + line = cell + } + }) + + return false + } + + return true + }) + + if (!line) { + line = lines[0] + } } } else if (!_data.hasOwnProperty(branchKey)) { error = '淇℃伅涓棤娴佺▼鎺у埗瀛楁銆�' } else { - let equalLine = null - let gtOrLtLine = [] - let unEqualLine = null + let _def_lines = [] + let _equ_lines = [] + let _unequ_lines = [] + let _or_lines = [] let branchVal = _data[branchKey] if (branchVal && typeof(branchVal) === 'string' && !isNaN(branchVal)) { @@ -2213,45 +2280,58 @@ lines.forEach(item => { if (item.mkdata.execCondition !== 'open') { - line = item + _def_lines.push(item) } else { if (item.mkdata.match === '=') { if (item.mkdata.matchVal === branchVal + '') { - equalLine = item + _equ_lines.push(item) } } else if (item.mkdata.match === '!=') { if (item.mkdata.matchVal !== branchVal + '') { - unEqualLine = item + _unequ_lines.push(item) } } else { if (item.mkdata.match === '<') { if (item.mkdata.matchVal < branchVal) { - gtOrLtLine.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)}) + _or_lines.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)}) } } else if (item.mkdata.match === '>') { if (item.mkdata.matchVal > branchVal) { - gtOrLtLine.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)}) + _or_lines.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)}) } } else if (item.mkdata.match === '<=') { if (item.mkdata.matchVal <= branchVal) { - gtOrLtLine.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)}) + _or_lines.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)}) } } else if (item.mkdata.match === '>=') { if (item.mkdata.matchVal >= branchVal) { - gtOrLtLine.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)}) + _or_lines.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)}) } } } } }) - if (equalLine) { - line = equalLine - } else if (gtOrLtLine.length > 0) { - gtOrLtLine.sort((a, b) => a.dist - b.dist) - line = gtOrLtLine[0] - } else if (unEqualLine) { - line = unEqualLine + _or_lines.sort((a, b) => a.dist - b.dist) + + let _lines = [..._equ_lines, ..._or_lines, ..._unequ_lines, ..._def_lines] + + _lines = _lines.filter(cell => { + if (cell.mkdata.seniorCondition === 'open' && !line) { + cell.mkdata.seniorbers && cell.mkdata.seniorbers.forEach(per => { + if (per.worker_id === userid) { + line = cell + } + }) + + return false + } + + return true + }) + + if (!line) { + line = _lines[0] } } } @@ -2264,6 +2344,7 @@ detailId = line.id status = line.mkdata.status statusName = line.mkdata.statusName + sign = line.mkdata.seniorSign || '' target = flow.cells.filter(cell => cell.id === line.target.cell)[0] line.mkdata.members && line.mkdata.members.forEach(item => { @@ -2288,7 +2369,7 @@ if (!target) { error = '鏈煡璇㈠埌宸ヤ綔娴佺洰鏍囪妭鐐�' - } else if (checkIds.length === 0 && line.mknode !== 'startEdge' && line.mknode !== 'endEdge') { + } else if (checkIds.length === 0 && !['startEdge', 'endEdge', 'throughEdge'].includes(line.mknode)) { error = '鏈幏鍙栧埌涓嬩竴姝ュ鎵逛汉' } else if (line.approvalMethod === 'countersign' && (!node.checkIds || !node.checkIds.includes(userid))) { error = '褰撳墠鐢ㄦ埛涓嶅湪瀹℃壒浜哄垪琛ㄤ腑' @@ -2453,6 +2534,12 @@ } } + if (_backCustomScript) { + _sql += _backCustomScript + } + + _sql = _sql.replace(/@works_flow_sign@/ig, `'${sign}'`) + _sql = _sql.replace(/@check_userids@/ig, `'${checkIds.join(',')}'`) _sql = _sql.replace(/@notice_userids@/ig, `'${noticeIds.join(',')}'`) @@ -2475,9 +2562,7 @@ _sql = _sql.replace(/@statusname@/ig, `'${statusName}'`) _sql = _sql.replace(/@work_group@/ig, `'${sessionStorage.getItem('work_group') || ''}'`) _sql = _sql.replace(/@work_grade@/ig, `'${work_grade}'`) - } - - if (_backCustomScript) { + } else if (_backCustomScript) { _sql += _backCustomScript } -- Gitblit v1.8.0