| | |
| | | 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', 'id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey'] |
| | | let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname'] |
| | | |
| | | // 主键字段 |
| | | let primaryKey = setting.primaryKey || 'id' |
| | |
| | | ` |
| | | |
| | | // let _initvars = ['ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey'] // 已赋值字段集 |
| | | let _initvars = ['id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey'] // 已赋值字段集 |
| | | // let _initvars = ['id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey'] // 已赋值字段集 |
| | | let _initvars = [] // 已赋值字段集 |
| | | let _initfields = [] |
| | | let _declarefields = [] |
| | | |
| | |
| | | |
| | | if (!_initvars.includes(_key)) { |
| | | _initvars.push(_key) |
| | | _initfields.push(`@${_key}='${form.value}'`) |
| | | |
| | | if (form.type === 'number' && typeof(form.value) === 'number') { |
| | | _initfields.push(`@${_key}=${form.value}`) |
| | | } else { |
| | | _initfields.push(`@${_key}='${form.value}'`) |
| | | } |
| | | } |
| | | |
| | | if (!_vars.includes(_key)) { |
| | |
| | | _initvars.push(_key) |
| | | |
| | | let _val = data.hasOwnProperty(col.field) ? data[col.field] : '' |
| | | _initfields.push(`@${_key}='${_val}'`) |
| | | |
| | | if (col.type === 'number' && typeof(_val) === 'number') { |
| | | _initfields.push(`@${_key}=${_val}`) |
| | | } else { |
| | | _initfields.push(`@${_key}='${_val}'`) |
| | | } |
| | | } |
| | | |
| | | if (!_vars.includes(_key)) { |
| | |
| | | let _type = `nvarchar(${col.fieldlength || 50})` |
| | | |
| | | if (col.type === 'number') { |
| | | let _length = (col.decimal || col.decimal === 0) ? col.decimal : 18 |
| | | let _length = col.decimal ? col.decimal : 0 |
| | | _type = `decimal(18,${_length})` |
| | | } else if (col.type === 'picture' || col.type === 'textarea') { |
| | | _type = `nvarchar(${col.fieldlength || 512})` |
| | |
| | | |
| | | // 唯一性验证,必须存在表单(表单存在时,主键均为单值),必须填写数据源 |
| | | if (formdata && verify.uniques && verify.uniques.length > 0) { |
| | | let hasBid = false // 检验表单及列字段中是否有bid |
| | | let _keys_ = Object.keys(_formFieldValue).map(key => key.toLowerCase()) |
| | | if (_keys_.includes('bid')) { |
| | | hasBid = true |
| | | } |
| | | |
| | | verify.uniques.forEach(item => { |
| | | let _fieldValue = [] // 表单键值对field=value |
| | | let _value = [] // 表单值,用于错误提示 |
| | |
| | | |
| | | item.field.split(',').forEach((_field, index) => { |
| | | let _fval = `'${_formFieldValue[_field]}'` |
| | | if (['id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey'].includes(_field.toLowerCase())) { |
| | | _fval = '@' + _field + '@' |
| | | // if (['id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey'].includes(_field.toLowerCase())) { |
| | | // _fval = '@' + _field + '@' |
| | | // } |
| | | if (_field.toLowerCase() === 'bid' && !hasBid) { // 表单中没有bid则使用系统bid变量 |
| | | _fval = '@BID@' |
| | | } |
| | | _fieldValue.push(`${_field}=${_fval}`) |
| | | _value.push(`${_labels[index] || ''}:${_formFieldValue[_field] || ''}`) |
| | |
| | | }) |
| | | } |
| | | |
| | | let _updateconfig = '' |
| | | let hasvoucher = false |
| | | |
| | | // 凭证-显示列中选取,必须选行 |
| | | if (verify.voucher && verify.voucher.enabled && data) { |
| | | let _voucher = verify.voucher |
| | | |
| | | _updateconfig = ',BVoucher=@BVoucher,FIBVoucherDate=@FIBVoucherDate,FiYear=@FiYear' |
| | | hasvoucher = true |
| | | |
| | | _sql += `exec s_BVoucher_Create |
| | | @Bill ='${data[_voucher.linkField]}', |
| | |
| | | if (btn.OpenType === 'pop' && btn.sqlType === 'insert' && verify.default !== 'false') { |
| | | let keys = [] |
| | | let values = [] |
| | | |
| | | formdata.forEach(item => { |
| | | if (item.type === 'funcvar') { |
| | | keys.push(item.key) |
| | | keys.push(item.key.toLowerCase()) |
| | | values.push('@' + item.key) |
| | | } else if (item.type === 'number') { |
| | | keys.push(item.key) |
| | | keys.push(item.key.toLowerCase()) |
| | | values.push(item.value) |
| | | } else { |
| | | keys.push(item.key) |
| | | keys.push(item.key.toLowerCase()) |
| | | values.push('\'' + item.value + '\'') |
| | | } |
| | | }) |
| | | |
| | | if (!keys.includes('createuserid')) { |
| | | keys.push('createuserid') |
| | | values.push('@userid@') |
| | | } |
| | | if (!keys.includes('createuser')) { |
| | | keys.push('createuser') |
| | | values.push('@username') |
| | | } |
| | | if (!keys.includes('createstaff')) { |
| | | keys.push('createstaff') |
| | | values.push('@fullname') |
| | | } |
| | | if (!keys.includes('bid')) { |
| | | keys.push('bid') |
| | | values.push('@BID@') |
| | | } |
| | | |
| | | keys = keys.join(',') |
| | | values = values.join(',') |
| | | _sql += _user |
| | | _sql += `insert into ${btn.sql} (${keys},createuserid,CreateUser,CreateStaff,BID) select ${values},@userid@,@username,@fullname,@BID@;` |
| | | _sql += `insert into ${btn.sql} (${keys}) select ${values};` |
| | | } else if (btn.OpenType === 'pop' && btn.sqlType === 'update' && verify.default !== 'false') { |
| | | let _form = [] |
| | | let _arr = [] |
| | | |
| | | formdata.forEach(item => { |
| | | _arr.push(item.key.toLowerCase()) |
| | | |
| | | if (item.type === 'funcvar') { |
| | | _form.push(item.key + '=@' + item.key) |
| | | } else if (item.type === 'number') { |
| | |
| | | _form.push(item.key + '=\'' + item.value + '\'') |
| | | } |
| | | }) |
| | | |
| | | if (!_arr.includes('modifydate')) { |
| | | _form.push('modifydate=getdate()') |
| | | } |
| | | if (!_arr.includes('modifyuserid')) { |
| | | _form.push('modifyuserid=@userid@') |
| | | } |
| | | if (hasvoucher) { |
| | | if (!_arr.includes('bvoucher')) { |
| | | _form.push('BVoucher=@BVoucher') |
| | | } |
| | | if (!_arr.includes('fibvoucherdate')) { |
| | | _form.push('FIBVoucherDate=@FIBVoucherDate') |
| | | } |
| | | if (!_arr.includes('fiyear')) { |
| | | _form.push('FiYear=@FiYear') |
| | | } |
| | | } |
| | | |
| | | _form = _form.join(',') |
| | | _sql += `update ${btn.sql} set ${_form},modifydate=getdate(),modifyuserid=@userid@${_updateconfig} where ${primaryKey}=@${primaryKeyName};` |
| | | _sql += `update ${btn.sql} set ${_form} where ${primaryKey}=@${primaryKeyName};` |
| | | } else if ((btn.OpenType === 'prompt' || btn.OpenType === 'exec') && btn.sqlType === 'LogicDelete' && verify.default !== 'false') { // 逻辑删除 |
| | | _sql += `update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${primaryKey}=@${primaryKeyName};` |
| | | } else if ((btn.OpenType === 'prompt' || btn.OpenType === 'exec') && btn.sqlType === 'delete' && verify.default !== 'false') { // 物理删除 |