| | |
| | | let verify = btn.verify || {} |
| | | let _formFieldValue = {} |
| | | // 需要声明的变量集 |
| | | let _vars = ['tbid', 'ErrorCode', 'retmsg', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'UserName', 'FullName', 'ID', 'BID'] |
| | | let _vars = ['tbid', 'ErrorCode', 'retmsg', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'UserName', 'FullName', 'ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey'] |
| | | |
| | | // 主键字段 |
| | | let primaryKey = setting.primaryKey || 'id' |
| | |
| | | let _sql = `Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50) |
| | | ` |
| | | |
| | | let _initvars = ['ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey'] // 已赋值字段集 |
| | | let _initfields = [] |
| | | let _declarefields = [] |
| | | |
| | | // 获取字段键值对 |
| | | if (formdata) { |
| | | formdata.forEach(form => { |
| | | _formFieldValue[form.key] = form.value |
| | | |
| | | if (!_initvars.includes(form.key)) { |
| | | _initvars.push(form.key) |
| | | _initfields.push(`@${form.key}='${form.value}'`) |
| | | } |
| | | |
| | | if (!_vars.includes(form.key)) { |
| | | _vars.push(form.key) |
| | | |
| | | let _type = `nvarchar(${form.fieldlen})` |
| | | |
| | | if (form.type.match(/date/ig)) { |
| | | _type = 'datetime' |
| | | } else if (form.type === 'number') { |
| | | _type = `decimal(18,${form.fieldlen})` |
| | | } |
| | | |
| | | _declarefields.push(`@${form.key} ${_type}`) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | // 添加数据中字段,表单值优先 |
| | | if (data) { |
| | | // 添加数据中字段,表单值优先(按钮不选行时跳过) |
| | | if (data && btn.Ot !== 'notRequired') { |
| | | _formFieldValue = {...data, ..._formFieldValue} |
| | | |
| | | if (logcolumns && logcolumns.length > 0) { |
| | | logcolumns.forEach(col => { |
| | | if (!_initvars.includes(col.field)) { |
| | | _initvars.push(col.field) |
| | | |
| | | let _val = data.hasOwnProperty(col.field) ? data[col.field] : '' |
| | | _initfields.push(`@${col.field}='${_val}'`) |
| | | } |
| | | |
| | | if (!_vars.includes(col.field)) { |
| | | _vars.push(col.field) |
| | | |
| | | let _type = `nvarchar(${col.fieldlength || 50})` |
| | | |
| | | if (col.type === 'number') { |
| | | let _length = (col.decimal || col.decimal === 0) ? col.decimal : 18 |
| | | _type = `decimal(18,${_length})` |
| | | } else if (col.type === 'picture' || col.type === 'textarea') { |
| | | _type = `nvarchar(${col.fieldlength || 512})` |
| | | } |
| | | |
| | | _declarefields.push(`@${col.field} ${_type}`) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | // 变量声明 |
| | | _declarefields = _declarefields.join(',') |
| | | if (_declarefields) { |
| | | _sql += `,${_declarefields} |
| | | ` |
| | | } |
| | | |
| | | // 变量赋值 |
| | | _initfields = _initfields.join(',') |
| | | if (_initfields) { |
| | | _sql += `select ${_initfields} |
| | | ` |
| | | } |
| | | |
| | | // 添加时主键为空 |
| | | if (btn.sqlType === 'insert') { |
| | | primaryId = '' |
| | | } |
| | | |
| | | // 声明表单及列表数据字段,初始化赋值 |
| | | let keys = Object.keys(_formFieldValue) |
| | | let _initfields = [] |
| | | let _initvars = ['ID', 'BID'] |
| | | let _formfields = [] |
| | | keys.forEach(key => { |
| | | if (!_initvars.includes(key)) { |
| | | _initvars.push(key) |
| | | _initfields.push(`@${key}='${_formFieldValue[key]}'`) |
| | | } |
| | | |
| | | if (!_vars.includes(key)) { |
| | | _vars.push(key) |
| | | _formfields.push(`@${key} nvarchar(50)`) |
| | | } |
| | | }) |
| | | |
| | | _formfields = _formfields.join(',') |
| | | if (_formfields) { |
| | | _sql += `,${_formfields} |
| | | ` |
| | | } |
| | | |
| | | _initfields = _initfields.join(',') |
| | | if (_initfields) { |
| | | _sql += `select ${_initfields} |
| | | ` |
| | | } |
| | | |
| | | // 去除禁用的验证 |
| | |
| | | } |
| | | |
| | | // 初始化凭证字段 |
| | | _sql += `select @BVoucher='',@FIBVoucherDate='',@FiYear='' |
| | | _sql += `select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='' |
| | | ` |
| | | |
| | | // 启用账期验证 |
| | |
| | | } else if ((btn.OpenType === 'prompt' || btn.OpenType === 'exec') && btn.sqlType === 'delete' && verify.default !== 'false') { // 物理删除 |
| | | let _msg = '' |
| | | if (data && logcolumns && logcolumns.length > 0) { |
| | | let _index = 0 |
| | | logcolumns.forEach(col => { |
| | | _msg += col.label + '=' + data[col.field] + ',' |
| | | if (col.Hide !== 'true' && _index < 4) { |
| | | _msg += col.label + '=' + data[col.field] + ',' |
| | | _index++ |
| | | } |
| | | }) |
| | | } |
| | | _sql += _user |