| | |
| | | |
| | | searchText += item.key + ' ' + item.match + ' \'' + str + item.value + str + '\'' |
| | | } else if (item.type === 'multiselect') { |
| | | let str = item.match === '=' ? '' : '%' |
| | | let options = item.value.map(val => { |
| | | return item.key + ' ' + item.match + ' \'' + str + val + str + '\'' |
| | | }) |
| | | |
| | | searchText += '(' + options.join(' OR ') + ')' |
| | | searchText += `'${item.value}' ` + item.match + ' \'%\'+' + item.key + '+\'%\'' |
| | | } else if (item.type === 'date') { |
| | | let _val = item.value |
| | | let timetail = ' 00:00:00.000' |
| | |
| | | searchText += '(' + item.key + ' ' + item.match + ' \'' + item.value + '\')' |
| | | } |
| | | }) |
| | | |
| | | return searchText |
| | | } |
| | | |
| | |
| | | let _sql = '' |
| | | |
| | | if (item.intertype === 'inner' && !item.innerFunc) { |
| | | let _uniquesql = '' |
| | | if (btn.uniques && btn.uniques.length > 0) { |
| | | btn.uniques.forEach(unique => { |
| | | if (unique.status === 'false') return |
| | | |
| | | let _fields = unique.field.split(',') |
| | | let _fields_ = _fields.map(_field => { |
| | | return `a.${_field}=b.${_field}` |
| | | }) |
| | | _fields_ = _fields_.join(' and ') |
| | | |
| | | if (unique.verifyType !== 'physical') { |
| | | _fields_ += ' and b.deleted=0' |
| | | } |
| | | |
| | | _uniquesql += ` |
| | | Set @tbid='' |
| | | Select top 1 @tbid=${_fields.join('+\' \'+')} from (select 1 as n,${unique.field} from @${item.sheet} ) a group by ${unique.field} having sum(n)>1 |
| | | |
| | | If @tbid!='' |
| | | Begin |
| | | select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 重复' |
| | | goto aaa |
| | | end |
| | | |
| | | Set @tbid='' |
| | | Select top 1 @tbid=${_fields.join('+\' \'+')} from @${item.sheet} a |
| | | Inner join ${item.sheet} b on ${_fields_} |
| | | |
| | | If @tbid!='' |
| | | Begin |
| | | select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 与已有数据重复' |
| | | goto aaa |
| | | end |
| | | ` |
| | | }) |
| | | |
| | | if (_uniquesql) { |
| | | _uniquesql = 'Declare @tbid Nvarchar(512)' + _uniquesql |
| | | } |
| | | } |
| | | |
| | | let declarefields = [] |
| | | let fields = [] |
| | | |
| | |
| | | |
| | | Insert into @${item.sheet} (${fields},jskey) |
| | | ${_Ltext} |
| | | ${_uniquesql} |
| | | ${_insert} |
| | | Delete @${item.sheet} |
| | | |
| | |
| | | let _formFieldValue = {} |
| | | // 需要声明的变量集 |
| | | // let _vars = ['tbid', 'ErrorCode', 'retmsg', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'UserName', 'FullName', 'ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey'] |
| | | // let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey'] |
| | | let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode'] |
| | | |
| | | // 主键字段 |
| | |
| | | ` |
| | | |
| | | // let _initvars = ['ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey'] // 已赋值字段集 |
| | | // let _initvars = ['id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey'] // 已赋值字段集 |
| | | let _initvars = [] // 已赋值字段集 |
| | | let _initfields = [] |
| | | let _declarefields = [] |
| | |
| | | ` |
| | | } |
| | | |
| | | // 添加时主键为空 改为前台生成 |
| | | // if (btn.sqlType === 'insert') { |
| | | // primaryId = '' |
| | | // } |
| | | |
| | | // 去除禁用的验证 |
| | | if (verify.contrasts) { |
| | | verify.contrasts = verify.contrasts.filter(item => item.status !== 'false') |
| | |
| | | verify.scripts = verify.scripts.filter(item => item.status !== 'false') |
| | | } |
| | | |
| | | // 初始化凭证字段 |
| | | _sql += `select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='' |
| | | let userName = sessionStorage.getItem('User_Name') || '' |
| | | let fullName = sessionStorage.getItem('Full_Name') || '' |
| | | |
| | | if (sessionStorage.getItem('isEditState') === 'true') { |
| | | userName = sessionStorage.getItem('CloudUserName') || '' |
| | | fullName = sessionStorage.getItem('CloudFullName') || '' |
| | | } |
| | | |
| | | // 初始化凭证及用户信息字段 |
| | | _sql += `select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}' |
| | | ` |
| | | |
| | | // 启用账期验证 |
| | |
| | | let _fieldValue = [] // 表单键值对field=value |
| | | let _value = [] // 表单值,用于错误提示 |
| | | let _labels = item.fieldlabel.split(',') // 表单提示文字 |
| | | let arr = [] // 验证主键 |
| | | |
| | | item.field.split(',').forEach((_field, index) => { |
| | | let _fval = `'${_formFieldValue[_field]}'` |
| | |
| | | if (_field.toLowerCase() === 'bid' && !hasBid) { // 表单中没有bid则使用系统bid变量 |
| | | _fval = '@BID@' |
| | | } |
| | | arr.push(_field.toLowerCase()) |
| | | |
| | | _fieldValue.push(`${_field}=${_fval}`) |
| | | _value.push(`${_labels[index] || ''}:${_formFieldValue[_field] || ''}`) |
| | | }) |
| | |
| | | _verifyType = ' and deleted=0' |
| | | } |
| | | |
| | | if (!arr.includes(primaryKey.toLowerCase())) { |
| | | _fieldValue.push(`${primaryKey} !='${primaryId}'`) |
| | | } |
| | | |
| | | _sql += `select @tbid='', @ErrorCode='',@retmsg='' |
| | | select @tbid='X' from ${btn.sql} where ${_fieldValue.join(' and ')} and ${primaryKey} !='${primaryId}'${_verifyType} |
| | | select @tbid='X' from ${btn.sql} where ${_fieldValue.join(' and ')}${_verifyType} |
| | | If @tbid!='' |
| | | Begin |
| | | select @ErrorCode='${item.errorCode}',@retmsg='${_value.join(', ')} 已存在' |
| | |
| | | ` |
| | | } |
| | | |
| | | // 用于取用户信息 |
| | | let _user = `select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID@ |
| | | ` |
| | | |
| | | let primaryKeyName = ['id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey'].includes(primaryKey.toLowerCase()) ? primaryKey + '@' : primaryKey |
| | | |
| | | let _actionType = null |
| | |
| | | } |
| | | }) |
| | | |
| | | if (!keys.includes(primaryKey)) { |
| | | keys.push(primaryKey) |
| | | if (!keys.includes(primaryKey.toLowerCase())) { |
| | | keys.push(primaryKey.toLowerCase()) |
| | | values.push('\'' + primaryId + '\'') |
| | | } |
| | | if (!keys.includes('createuserid')) { |
| | |
| | | |
| | | keys = keys.join(',') |
| | | values = values.join(',') |
| | | _sql += _user |
| | | _sql += `insert into ${btn.sql} (${keys}) select ${values};` |
| | | } else if (_actionType === 'update') { |
| | | let _form = [] |
| | |
| | | } |
| | | }) |
| | | } |
| | | _sql += _user |
| | | _sql += `insert into snote (remark,createuserid,CreateUser,CreateStaff) select '删除表:${btn.sql} 数据: ${_msg}${primaryKey}='+@${primaryKeyName},@userid@,@username,@fullname delete ${btn.sql} where ${primaryKey}=@${primaryKeyName};` |
| | | } |
| | | |
| | |
| | | static getexcelInfunc (param, btn, menu) { |
| | | let _verify = btn.verify |
| | | |
| | | let _uniquesql = '' |
| | | if (_verify.uniques && _verify.uniques.length > 0) { |
| | | _verify.uniques.forEach(unique => { |
| | | if (unique.status === 'false') return |
| | | |
| | | let _fields = unique.field.split(',') |
| | | let _fields_ = _fields.map(_field => { |
| | | return `a.${_field}=b.${_field}` |
| | | }) |
| | | _fields_ = _fields_.join(' and ') |
| | | |
| | | if (unique.verifyType !== 'physical') { |
| | | _fields_ += ' and b.deleted=0' |
| | | } |
| | | |
| | | _uniquesql += ` |
| | | Set @tbid='' |
| | | Select top 1 @tbid=${_fields.join('+\' \'+')} from (select 1 as n,${unique.field} from @${btn.sheet} ) a group by ${unique.field} having sum(n)>1 |
| | | |
| | | If @tbid!='' |
| | | Begin |
| | | select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 重复' |
| | | goto aaa |
| | | end |
| | | |
| | | Set @tbid='' |
| | | Select top 1 @tbid=${_fields.join('+\' \'+')} from @${btn.sheet} a |
| | | Inner join ${btn.sheet} b on ${_fields_} |
| | | |
| | | If @tbid!='' |
| | | Begin |
| | | select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 与已有数据重复' |
| | | goto aaa |
| | | end |
| | | ` |
| | | }) |
| | | |
| | | if (_uniquesql) { |
| | | _uniquesql = ` |
| | | Declare @tbid Nvarchar(512) |
| | | ${_uniquesql}` |
| | | } |
| | | } |
| | | |
| | | let declarefields = [] |
| | | let fields = [] |
| | | |
| | |
| | | |
| | | exec s_KeyWords_Replace |
| | | @LText=@LText, @BID=@BID,@LoginUID=@LoginUID,@SessionUid=@SessionUid,@UserID=@UserID,@ID=@ID |
| | | |
| | | ${_uniquesql} |
| | | Insert into ${btn.sheet} (${fields},createuserid,createuser,createstaff,bid) |
| | | Select ${fields},@userid,@username,@fullname,@BID From @${btn.sheet} |
| | | |