| | |
| | | * @param {Array} searches 搜索条件 |
| | | */ |
| | | static initSearchVal (config) { |
| | | if (!config.search) { |
| | | if (!config.search || config.search.length === 0) { |
| | | config.search = [] |
| | | config.$s_keys = [] |
| | | config.$s_req = false |
| | | return |
| | | } |
| | | |
| | |
| | | |
| | | config.checkBid = true |
| | | item.checkShift = true |
| | | if (config.setting) { |
| | | config.setting.checkBid = true |
| | | } |
| | | } |
| | | |
| | | item.initval = '' |
| | |
| | | } |
| | | |
| | | if (d) { |
| | | item.initval = moment(d).subtract(item.initval, 'month').format('YYYY-MM') |
| | | item.initval = moment(d).subtract(item.$initval, 'month').format('YYYY-MM') |
| | | } |
| | | } |
| | | } |
| | |
| | | item.initval = [moment().startOf('month').format(format), moment().endOf('month').format(format)].join(',') |
| | | } else if (item.initval === 'lastMonth') { |
| | | item.initval = [moment().subtract(1, 'months').startOf('month').format(format), moment().subtract(1, 'months').endOf('month').format(format)].join(',') |
| | | } else if (item.initval === 'year') { |
| | | item.initval = [moment().startOf('year').format(format), moment().endOf('year').format(format)].join(',') |
| | | } else if (item.initval === 'lastYear') { |
| | | item.initval = [moment().subtract(1, 'years').startOf('year').format(format), moment().subtract(1, 'years').endOf('year').format(format)].join(',') |
| | | } else if (item.initval) { |
| | | try { |
| | | let _initval = JSON.parse(item.initval) |
| | |
| | | |
| | | config.checkBid = true |
| | | item.checkShift = true |
| | | if (config.setting) { |
| | | config.setting.checkBid = true |
| | | } |
| | | } |
| | | |
| | | item.initval = '' |
| | |
| | | item.initval = [moment(d).startOf('month').format(format), moment(d).endOf('month').format(format)].join(',') |
| | | } else if (item.$initval === 'lastMonth') { |
| | | item.initval = [moment(d).subtract(1, 'months').startOf('month').format(format), moment(d).subtract(1, 'months').endOf('month').format(format)].join(',') |
| | | } else if (item.$initval === 'year') { |
| | | item.initval = [moment(d).startOf('year').format(format), moment(d).endOf('year').format(format)].join(',') |
| | | } else if (item.$initval === 'lastYear') { |
| | | item.initval = [moment(d).subtract(1, 'years').startOf('year').format(format), moment(d).subtract(1, 'years').endOf('year').format(format)].join(',') |
| | | } else { |
| | | try { |
| | | let _initval = JSON.parse(item.$initval) |
| | |
| | | if (/@BID@/ig.test(item.dataSource) && supModule) { |
| | | config.checkBid = true |
| | | item.checkBid = true |
| | | if (config.setting) { |
| | | config.setting.checkBid = true |
| | | } |
| | | } |
| | | if (item.initval === '$first') { |
| | | item.initval = '' |
| | |
| | | |
| | | return item |
| | | }) |
| | | |
| | | if (config.checkBid) { |
| | | if (config.setting) { |
| | | config.setting.checkBid = true |
| | | } |
| | | if (config.type !== 'search') { |
| | | config.$checkBid = true |
| | | } |
| | | } |
| | | |
| | | config.$s_keys = keys |
| | | config.$s_req = required |
| | |
| | | cols.push('A' + cols[i]) |
| | | } |
| | | |
| | | let columns = JSON.parse(JSON.stringify(btn.columns)) |
| | | columns = columns.filter((col, index) => { |
| | | col.colIndex = cols[index] || (index + 1) |
| | | if (col.import !== 'init' && (/^Decimal/ig.test(col.type) || /^int/ig.test(col.type))) { |
| | | col.declen = 0 |
| | | if (/^Decimal/ig.test(col.type)) { |
| | | col.declen = +col.type.match(/\d+/g)[1] |
| | | } |
| | | col.declen = col.declen || 0 |
| | | } |
| | | if (col.required === 'false') { |
| | | delete col.min |
| | | delete col.max |
| | | } |
| | | |
| | | return col.import !== 'false' |
| | | }) |
| | | |
| | | let _Ltext = data.map((item, lindex) => { |
| | | let vals = [] |
| | | btn.columns.forEach((col, cindex) => { |
| | | if (col.import === 'false') return |
| | | |
| | | columns.forEach(col => { |
| | | let val = item[col.Column] !== undefined ? item[col.Column] : '' |
| | | let _colindex = cols[cindex] || (cindex + 1) |
| | | let _position = (_topline + lindex + 1) + '行 ' + _colindex + '列 ' |
| | | let _position = (_topline + lindex + 1) + '行 ' + col.colIndex + '列 ' |
| | | let eLen = errors.length |
| | | |
| | | if (col.import === 'init') { |
| | | if (col.$error) { |
| | | |
| | | } else if (col.import === 'init') { |
| | | if (/^Nvarchar/ig.test(col.type)) { |
| | | val = '' |
| | | } else if (/^Decimal/ig.test(col.type) || /^int/ig.test(col.type)) { |
| | |
| | | |
| | | val = val.replace(/(^\s+$)|\t+|\v+/ig, '') |
| | | |
| | | if (col.interception !== 'false') { |
| | | val = val.replace(/^\s+|\s+$/g, '') |
| | | } |
| | | |
| | | if (!val && col.required === 'true') { // 必填校验 |
| | | errors.push(_position + '内容不可为空') |
| | | } else if (col.limit && val.length > col.limit) { // 长度校验 |
| | |
| | | if (!val || isNaN(val)) { |
| | | val = 0 |
| | | } |
| | | } else if (!val && val !== 0) { |
| | | } |
| | | if (!val && val !== 0) { |
| | | errors.push(_position + '内容不可为空') |
| | | } else if (isNaN(val)) { // 检验是否为数值 |
| | | errors.push(_position + '内容应为数值') |
| | | } else if ((col.min || col.min === 0) && val < col.min) { // 最小值检验 |
| | | } else if (typeof(col.min) === 'number' && val < col.min) { // 最小值检验 |
| | | errors.push(_position + '小于最小值') |
| | | } else if ((col.max || col.max === 0) && val > col.max) { // 最大值检验 |
| | | } else if (typeof(col.max) === 'number' && val > col.max) { // 最大值检验 |
| | | errors.push(_position + '大于最大值') |
| | | } else { |
| | | let _float = (val + '').split('.')[1] |
| | | if (_float && _float.length > col.declen) { |
| | | if (col.declen) { |
| | | errors.push(_position + `数值不可大于${col.declen}位小数`) |
| | | } else { |
| | | errors.push(_position + '数值应为整数') |
| | | } |
| | | } |
| | | } |
| | | } else if (col.type === 'date' || col.type === 'datetime') { |
| | | if (typeof(val) === 'number') { |
| | |
| | | } else { // 时间格式错误 |
| | | errors.push(_position + '时间格式错误') |
| | | } |
| | | } |
| | | |
| | | if (errors.length > eLen) { |
| | | col.$error = true |
| | | } |
| | | |
| | | vals.push(`'${val}'`) |
| | |
| | | * @return {Object} item 按钮信息 |
| | | * @return {Array} data excel数据 |
| | | */ |
| | | export function getEditTableSql (verify, data, columns) { |
| | | export function getEditTableSql (verify, data, columns, setting) { |
| | | let btn = verify |
| | | let userName = sessionStorage.getItem('User_Name') || '' |
| | | let fullName = sessionStorage.getItem('Full_Name') || '' |
| | |
| | | let _fields = unique.field.split(',') |
| | | let _fields_ = _fields.map(_field => `a.${_field}=b.${_field}`) |
| | | _fields_ = _fields_.join(' and ') |
| | | _fields_ += ` and a.jskey != b.${setting.primaryKey || 'id'}` |
| | | |
| | | let _where = [] |
| | | _fields.forEach(f => { |
| | |
| | | |
| | | let declarefields = [] |
| | | let fields = [] |
| | | let upFields = [] |
| | | |
| | | columns.forEach(col => { |
| | | let key = col.field.toLowerCase() |
| | |
| | | |
| | | declarefields.push(`${col.field} ${col.datatype}`) |
| | | fields.push(col.field) |
| | | upFields.push(`${col.field}=t.${col.field}`) |
| | | }) |
| | | |
| | | fields = fields.join(',') |
| | | upFields = upFields.join(',') |
| | | |
| | | let _insert = '' |
| | | if (btn.default !== 'false') { |
| | | _insert = ` |
| | | /* 默认sql */ |
| | | Insert into ${database}${sheet} (${fields},createuserid,createuser,createstaff,bid) |
| | | update a set ${upFields},modifydate=getdate(),modifyuserid='${sessionStorage.getItem('UserID') || ''}',modifyuser=@username,modifystaff=@fullname,deleted=0 |
| | | from (select * from #${sheet} where data_type='upt') t |
| | | inner join ${database}${sheet} a on t.jskey=a.${setting.primaryKey || 'id'} |
| | | |
| | | update a set deleted=1,modifydate=getdate(),modifyuserid='${sessionStorage.getItem('UserID') || ''}',modifyuser=@username,modifystaff=@fullname |
| | | from (select * from #${sheet} where data_type='del') t |
| | | inner join ${database}${sheet} a on t.jskey=a.${setting.primaryKey || 'id'} |
| | | |
| | | delete t from #${sheet} t inner join ${database}${sheet} a on t.jskey=a.${setting.primaryKey || 'id'} |
| | | |
| | | Insert into ${database}${sheet} (${fields},createuserid,createuser,createstaff,bid) |
| | | Select ${fields},'${sessionStorage.getItem('UserID') || ''}',@username,@fullname,'${BID}' From #${sheet} |
| | | ` |
| | | } |
| | |
| | | let primaryId = param.ID |
| | | let BID = param.BID || '' |
| | | let verify = btn.verify || {} |
| | | let datavars = {} // 声明的变量,表单及显示列 |
| | | let _actionType = null |
| | | let _callbacksql = '' |
| | | |
| | |
| | | let _initFormfields = [] |
| | | let _initColfields = [] |
| | | let _declarefields = [] |
| | | let verifyValSql = '' |
| | | let datavars = {} |
| | | |
| | | // 获取字段键值对 |
| | | formdata && formdata.forEach(form => { |
| | | if (form.$verify) { |
| | | verifyValSql += ` |
| | | if @${form.key}=${form.type === 'number' ? 0 : `''`} |
| | | begin |
| | | select @errorcode='E',@retmsg='${form.label},关联主表失效' |
| | | goto aaa |
| | | end |
| | | ` |
| | | } |
| | | |
| | | let _key = form.key.toLowerCase() |
| | | datavars[_key] = form.value |
| | | |
| | |
| | | let val = form.value |
| | | |
| | | if (form.type === 'number' || form.type === 'rate') { |
| | | if (isNaN(val)) { |
| | | if (isNaN(val) || val === '') { |
| | | val = 0 |
| | | } |
| | | _initFormfields.push(`@${_key}=${val}`) |
| | |
| | | let _key = col.field.toLowerCase() |
| | | |
| | | if (!_initvars.includes(_key)) { |
| | | let _val = datavars.hasOwnProperty(_key) ? datavars[_key] : '' |
| | | let _val = _data.hasOwnProperty(_key) ? _data[_key] : '' |
| | | |
| | | if (col.datatype && /^date/ig.test(col.datatype) && !_val) { |
| | | _val = '1949-10-01' |
| | |
| | | |
| | | verify.billcodes.forEach(item => { |
| | | let _key = item.field.toLowerCase() |
| | | let _linkKey = item.linkField ? item.linkField.toLowerCase() : '' |
| | | |
| | | if (!keys.includes(_key)) return // 表单中不含单号生成字段 |
| | | |
| | | let _lpline = '' |
| | | if (item.TypeCharOne === 'Lp') { |
| | | if (_linkKey === 'bid' && BID) { // 替换bid |
| | | if (/^BID$/ig.test(item.linkField)) { |
| | | _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@BID@,48)` |
| | | } else { |
| | | _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@${_linkKey},48)` |
| | | _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@${item.linkField},48)` |
| | | } |
| | | } else if (item.TypeCharOne === 'BN') { |
| | | if (_linkKey === 'bid' && BID) { // 替换bid |
| | | if (/^BID$/ig.test(item.linkField)) { |
| | | _lpline = `set @ModularDetailCode= 'BN'+ right(@BID@,48)` |
| | | } else { |
| | | _lpline = `set @ModularDetailCode= 'BN'+ right(@${_linkKey},48)` |
| | | _lpline = `set @ModularDetailCode= 'BN'+ right(@${item.linkField},48)` |
| | | } |
| | | } else { |
| | | _lpline = `set @ModularDetailCode= right('${item.ModularDetailCode}',50)` |
| | |
| | | |
| | | item.field.split(',').forEach((_field, index) => { |
| | | let _key = _field.toLowerCase() |
| | | let _val = datavars[_key] !== undefined ? datavars[_key] : '' |
| | | let _val = '' |
| | | let _val2 = datavars[_key] !== undefined ? datavars[_key] : '' |
| | | |
| | | arr.push(_key) |
| | | if (_key === 'bid' && !_val) { // 表单中没有bid则使用系统bid变量 |
| | | _val = BID |
| | | if (_key === 'bid') { |
| | | _val = `'${BID}'` |
| | | } else { |
| | | _val = `@${_field}` |
| | | } |
| | | |
| | | _fieldValue.push(`${_key}='${_val}'`) |
| | | _value.push(`${_labels[index] || ''}:${_val || ''}`) |
| | | |
| | | if (_key === 'bid') { |
| | | _val2 = BID |
| | | } |
| | | |
| | | _fieldValue.push(`${_key}=${_val}`) |
| | | _value.push(`${_labels[index] || ''}:${_val2}`) |
| | | }) |
| | | |
| | | if (!arr.includes(primaryKey.toLowerCase())) { |
| | | if (!arr.includes(primaryKey.toLowerCase()) && btn.Ot !== 'notRequired') { |
| | | _fieldValue.push(`${primaryKey} !='${primaryId}'`) |
| | | } |
| | | |
| | |
| | | // 凭证-显示列中选取,必须选行 |
| | | if (verify.voucher && verify.voucher.enabled) { |
| | | let _voucher = verify.voucher |
| | | let linkField = `@${_voucher.linkField}` |
| | | |
| | | if (/^BID$/ig.test(_voucher.linkField)) { |
| | | linkField = `'${BID}'` |
| | | } |
| | | |
| | | hasvoucher = true |
| | | |
| | | _sql += ` |
| | | /* 创建凭证 */ |
| | | exec s_BVoucher_Create |
| | | @Bill ='${_data[_voucher.linkField.toLowerCase()] || ''}', |
| | | @Bill = ${linkField}, |
| | | @BVoucherType ='${_voucher.BVoucherType}', |
| | | @VoucherTypeOne ='${_voucher.VoucherTypeOne}', |
| | | @VoucherTypeTwo ='${_voucher.VoucherTypeTwo}', |
| | |
| | | _sql += _backCustomScript |
| | | } |
| | | |
| | | if (verifyValSql) { |
| | | _sql += verifyValSql |
| | | } |
| | | |
| | | if (window.GLOB.breakpoint) { |
| | | let start = new RegExp('\\/\\*\\$breakpoint_begin_' + window.GLOB.breakpoint + '@', 'ig') |
| | | let end = new RegExp('@breakpoint_end_' + window.GLOB.breakpoint + '\\$\\*\\/', 'ig') |