| | |
| | | _config.buyer = this.formatSetting(_config.buyer, 'buyer') |
| | | _config.detail = this.formatSetting(_config.detail, 'detail') |
| | | _config.detail.uuid = _config.uuid |
| | | _config.buyer.setting.uuid = _config.uuid + 'buyer' |
| | | _config.detail.setting.uuid = _config.uuid + 'detail' |
| | | _config.billOutBtn.uuid = _config.uuid |
| | | _config.billSaveBtn.uuid = _config.uuid |
| | | _config.billOutBtn.logLabel = _config.$menuname + '-' + _config.billOutBtn.label |
| | | _config.billSaveBtn.logLabel = _config.$menuname + '-' + _config.billSaveBtn.label |
| | | |
| | | let book = null |
| | | let pas = {} |
| | |
| | | if (!item.setting.execute) { |
| | | item.setting.dataresource = '' |
| | | } |
| | | if (/\s/.test(item.setting.dataresource)) { |
| | | item.setting.dataresource = '(' + item.setting.dataresource + ') tb' |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | item.setting.dataresource = item.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | |
| | | |
| | | item.setting.customScript = _customScript // 整理后自定义脚本 |
| | | item.setting.tailScript = _tailScript // 后置自定义脚本 |
| | | item.setting.custompage = false |
| | | |
| | | if (/order\s+by\s+sort_id\s*$/i.test(item.setting.dataresource)) { |
| | | item.setting.custompage = true |
| | | } else if (/@pageSize@|@orderBy@|@mk_total/i.test(item.setting.dataresource + item.setting.customScript)) { |
| | | item.setting.custompage = true |
| | | } |
| | | |
| | | item.setting.custompage = /@pageSize@|@orderBy@|@mk_total/i.test(item.setting.dataresource + item.setting.customScript) |
| | | if (/\s/.test(item.setting.dataresource)) { |
| | | item.setting.dataresource = '(' + item.setting.dataresource + ') tb' |
| | | } |
| | | |
| | | return item |
| | | } |
| | |
| | | |
| | | setTimeout(() => { |
| | | this.getBillMsg().then(() => { |
| | | let sql = this.getPreSql(config.billSaveBtn) |
| | | |
| | | let param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: sql, |
| | | exec_type: window.GLOB.execType || 'y', |
| | | timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), |
| | | BID: BID |
| | | let param = null |
| | | if (window.backend && window.GLOB.CacheData.has('sql_' + config.uuid + config.billSaveBtn.type)) { |
| | | param = this.getBackPreParam(config.billSaveBtn) |
| | | } else { |
| | | let sql = this.getPreSql(config.billSaveBtn) |
| | | |
| | | param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: sql, |
| | | exec_type: window.GLOB.execType || 'y', |
| | | timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), |
| | | BID: BID |
| | | } |
| | | |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | param.LText = Utils.formatOptions(param.LText, param.exec_type) |
| | | } |
| | | |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | param.LText = Utils.formatOptions(param.LText, param.exec_type) |
| | | |
| | | this.setState({ |
| | | saveType: 'bill' |
| | |
| | | }) |
| | | if (res.status) { |
| | | if (config.billSaveBtn.reTabId) { |
| | | MKEmitter.emit('reloadMenuView', config.billSaveBtn.reTabId, 'table') |
| | | MKEmitter.emit('reloadMenuView', config.billSaveBtn.reTabId) |
| | | } |
| | | if (config.billSaveBtn.syncComId) { |
| | | MKEmitter.emit('reloadData', config.billSaveBtn.syncComId) |
| | |
| | | |
| | | setTimeout(() => { |
| | | this.getBillMsg().then(() => { |
| | | let sql = this.getPreSql(config.billOutBtn) |
| | | |
| | | let param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: sql, |
| | | script_type: 'Y', |
| | | exec_type: window.GLOB.execType || 'y', |
| | | timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), |
| | | BID: BID |
| | | let param = null |
| | | if (window.backend && window.GLOB.CacheData.has('sql_' + config.uuid + config.billOutBtn.type)) { |
| | | param = this.getBackPreParam(config.billOutBtn) |
| | | } else { |
| | | let sql = this.getPreSql(config.billOutBtn) |
| | | |
| | | param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | LText: sql, |
| | | script_type: 'Y', |
| | | exec_type: window.GLOB.execType || 'y', |
| | | timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), |
| | | BID: BID |
| | | } |
| | | |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | param.LText = Utils.formatOptions(param.LText, param.exec_type) |
| | | } |
| | | |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | param.LText = Utils.formatOptions(param.LText, param.exec_type) |
| | | |
| | | this.setState({ |
| | | saveType: 'out' |
| | |
| | | } |
| | | |
| | | if (window.GLOB.debugger === true) { |
| | | console.info(sql.replace(/\n\s{6}/ig, '\n')) |
| | | window.mkInfo(sql.replace(/\n\s{6}/ig, '\n')) |
| | | } |
| | | |
| | | return sql |
| | | } |
| | | |
| | | getBackPreParam = (btn) => { |
| | | const { config, book, ID, BID, io, details, oriDetails, business_type, invoice_type, from_to_name, from_to_tax_no, from_to_addr, from_to_tel, from_to_bank_name, from_to_account_no, from_to_mob, from_to_email, from_to_code, orgname, tax_no, addr, tel, bank_name, account_no, remark, reviewer, drawer, payee } = this.state |
| | | let ex = window.GLOB.CacheData.get('sql_' + btn.uuid + btn.type) |
| | | let exps = [] |
| | | |
| | | let values = { |
| | | time_id: Utils.getguid(), |
| | | roleid: sessionStorage.getItem('role_id') || '', |
| | | mk_departmentcode: sessionStorage.getItem('departmentcode') || '', |
| | | mk_organization: sessionStorage.getItem('organization') || '', |
| | | mk_user_type: sessionStorage.getItem('mk_user_type') || '', |
| | | mk_nation: sessionStorage.getItem('nation') || '', |
| | | mk_province: sessionStorage.getItem('province') || '', |
| | | mk_city: sessionStorage.getItem('city') || '', |
| | | mk_district: sessionStorage.getItem('district') || '', |
| | | mk_address: sessionStorage.getItem('address') || '', |
| | | id: ID || '', |
| | | bid: BID || '', |
| | | datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', |
| | | datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', |
| | | datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', |
| | | } |
| | | |
| | | if (window.GLOB.externalDatabase !== null) { |
| | | values.db = window.GLOB.externalDatabase |
| | | } |
| | | |
| | | let options = fromJS(oriDetails).toJS() |
| | | let price = 0 |
| | | let tax = 0 |
| | | |
| | | let lines = [] |
| | | details.forEach(line => { |
| | | if (!line.productcode) return |
| | | |
| | | let vals = [line.productcode, line.productname, line.spec, line.unit, line.bill_count, line.unitprice, line.amount_line, line.tax_classify_code, line.tax_classify_name, line.tax_rate, line.tax_amount, line.free_tax_mark || '', line.vat_special_management || '', line.invoice_lp || '', line.tax_item, line.tax_method, line.uuid] |
| | | let data_type = 'add' |
| | | |
| | | price += line.amount_line * 100 |
| | | tax += line.tax_amount * 100 |
| | | |
| | | if (options.length) { |
| | | options = options.filter(option => { |
| | | if (option.uuid === line.uuid) { |
| | | data_type = 'upt' |
| | | return false |
| | | } |
| | | return true |
| | | }) |
| | | } |
| | | |
| | | vals.push(data_type) |
| | | |
| | | lines.push(vals) |
| | | }) |
| | | |
| | | let _total = (price - tax) / 100 |
| | | price = price / 100 |
| | | tax = tax / 100 |
| | | |
| | | if (options.length) { |
| | | options.forEach(line => { |
| | | let vals = [line.productcode, line.productname, line.spec, line.unit, line.bill_count, line.unitprice, line.amount_line, line.tax_classify_code, line.tax_classify_name, line.tax_rate, line.tax_amount, line.free_tax_mark || '', line.vat_special_management || '', line.invoice_lp || '', line.tax_item, line.tax_method, line.uuid, 'del'] |
| | | vals = vals.map(val => typeof(val) === 'number' ? val + '' : val) |
| | | lines.push(vals) |
| | | }) |
| | | } |
| | | |
| | | ex.reps.forEach(n => { |
| | | let key = n.toLowerCase() |
| | | if (values.hasOwnProperty(key)) { |
| | | exps.push({ |
| | | key: n, |
| | | value: values[key] |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | exps.push({ |
| | | key: 'account_id', |
| | | value: book.account_id || '' |
| | | }, { |
| | | key: 'account_year_id', |
| | | value: book.account_year_id || '' |
| | | }, { |
| | | key: 'account_code', |
| | | value: book.account_code || '' |
| | | }, { |
| | | key: 'account_year_code', |
| | | value: book.account_year_code || '' |
| | | }, { |
| | | key: 'invoice_type', |
| | | value: invoice_type |
| | | }, { |
| | | key: 'from_to_name', |
| | | value: from_to_name |
| | | }, { |
| | | key: 'from_to_tax_no', |
| | | value: from_to_tax_no |
| | | }, { |
| | | key: 'from_to_addr', |
| | | value: from_to_addr |
| | | }, { |
| | | key: 'from_to_tel', |
| | | value: from_to_tel |
| | | }, { |
| | | key: 'from_to_bank_name', |
| | | value: from_to_bank_name |
| | | }, { |
| | | key: 'from_to_account_no', |
| | | value: from_to_account_no |
| | | }, { |
| | | key: 'from_to_mob', |
| | | value: from_to_mob |
| | | }, { |
| | | key: 'from_to_email', |
| | | value: from_to_email |
| | | }, { |
| | | key: 'from_to_code', |
| | | value: from_to_code |
| | | }, { |
| | | key: 'orgname', |
| | | value: orgname |
| | | }, { |
| | | key: 'tax_no', |
| | | value: tax_no |
| | | }, { |
| | | key: 'addr', |
| | | value: addr |
| | | }, { |
| | | key: 'tel', |
| | | value: tel |
| | | }, { |
| | | key: 'bank_name', |
| | | value: bank_name |
| | | }, { |
| | | key: 'account_no', |
| | | value: account_no |
| | | }, { |
| | | key: 'remark', |
| | | value: remark |
| | | }, { |
| | | key: 'payee', |
| | | value: payee |
| | | }, { |
| | | key: 'reviewer', |
| | | value: reviewer |
| | | }, { |
| | | key: 'drawer', |
| | | value: drawer |
| | | }, { |
| | | key: 'io', |
| | | value: io |
| | | }, { |
| | | key: 'orgcode', |
| | | value: book.orgcode || '' |
| | | }, { |
| | | key: 'total_net_amount', |
| | | value: _total |
| | | }, { |
| | | key: 'total_tax', |
| | | value: tax |
| | | }, { |
| | | key: 'total_amount', |
| | | value: price |
| | | }, { |
| | | key: 'business_type', |
| | | value: business_type || config.wrap.business_type || '' |
| | | }) |
| | | |
| | | exps.push({ |
| | | key: 'mk_excel_data', |
| | | value: lines |
| | | }) |
| | | |
| | | let md5_id = '' |
| | | if (window.GLOB.probation) { |
| | | md5_id = md5(ex.id + JSON.stringify(exps) + Math.floor(new Date().getTime() / 600000)) |
| | | md5_id = moment().format('YYYYMMDDHHmmss') + md5_id.slice(-18) |
| | | } |
| | | |
| | | return { |
| | | $backend: true, |
| | | $type: 's_TableData_InUpDe', |
| | | data: [{ |
| | | id: ex.id, |
| | | menuname: btn.logLabel || '', |
| | | exps: exps, |
| | | md5_id: md5_id |
| | | }] |
| | | } |
| | | } |
| | | |
| | | getBillMsg = () => { |
| | |
| | | callBackBill = (result) => { |
| | | const { config, BID, ID } = this.state |
| | | |
| | | let btn = config.billOutBtn |
| | | let lines = [] |
| | | let pre = '@' |
| | | let param = null |
| | | |
| | | let getDefaultSql = (obj, tb, bid, level) => { |
| | | let keys = [] |
| | | let vals = [] |
| | | let subObjs = [] |
| | | let id = Utils.getuuid() |
| | | let tbName = pre + tb |
| | | |
| | | delete obj.$$key |
| | | |
| | | Object.keys(obj).forEach(key => { |
| | | let val = obj[key] |
| | | if (val === null || val === undefined) return |
| | | if (typeof(val) === 'object') { |
| | | if (Array.isArray(val)) { |
| | | val.forEach(item => { |
| | | if (typeof(item) !== 'object' || Array.isArray(item)) return |
| | | if (Object.keys(item).length > 0) { |
| | | if (window.backend && window.GLOB.CacheData.has('sql_' + config.uuid + 'billback')) { |
| | | param = this.getCallBackendParam(config.billOutBtn, result) |
| | | } else { |
| | | let btn = config.billOutBtn |
| | | let lines = [] |
| | | let pre = '@' |
| | | |
| | | let getDefaultSql = (obj, tb, bid, level) => { |
| | | let keys = [] |
| | | let vals = [] |
| | | let subObjs = [] |
| | | let id = Utils.getuuid() |
| | | let tbName = pre + tb |
| | | |
| | | delete obj.$$key |
| | | |
| | | Object.keys(obj).forEach(key => { |
| | | let val = obj[key] |
| | | if (val === null || val === undefined) return |
| | | if (typeof(val) === 'object') { |
| | | if (Array.isArray(val)) { |
| | | val.forEach(item => { |
| | | if (typeof(item) !== 'object' || Array.isArray(item)) return |
| | | if (Object.keys(item).length === 0) return |
| | | |
| | | Object.keys(item).forEach(k => { |
| | | if (item[k] === null) { |
| | | item[k] = '' |
| | | } |
| | | }) |
| | | item.$$key = tb + '_' + key |
| | | subObjs.push(item) |
| | | } |
| | | }) |
| | | } else if (Object.keys(val).length > 0) { |
| | | val.$$key = tb + '_' + key |
| | | subObjs.push(val) |
| | | }) |
| | | } else if (Object.keys(val).length > 0) { |
| | | val.$$key = tb + '_' + key |
| | | subObjs.push(val) |
| | | } |
| | | } else { |
| | | if (typeof(val) === 'string') { |
| | | val = val.replace(/'/ig, '"') |
| | | } |
| | | keys.push('[' + key + ']') |
| | | vals.push(`'${val}'`) |
| | | } |
| | | } else { |
| | | if (typeof(val) === 'string') { |
| | | val = val.replace(/'/ig, '"') |
| | | } |
| | | keys.push('[' + key + ']') |
| | | vals.push(`'${val}'`) |
| | | } |
| | | }) |
| | | |
| | | keys = keys.join(',') |
| | | vals = vals.join(',') |
| | | |
| | | lines.push({ |
| | | table: md5(tb + keys), |
| | | insert: `Insert into ${tbName} (${keys ? keys + ',' : ''}[mk_level],[mk_id],[mk_bid])`, |
| | | select: `Select ${keys ? vals + ',' : ''}'${level}','${id}','${bid}'` |
| | | }) |
| | | |
| | | subObjs.forEach(item => { |
| | | getDefaultSql(item, item.$$key, id, level + 1) |
| | | }) |
| | | } |
| | | |
| | | getDefaultSql(result, btn.cbTable, '', 1) |
| | | |
| | | let lineMap = new Map() |
| | | lines.forEach(line => { |
| | | if (lineMap.has(line.table)) { |
| | | let _line = lineMap.get(line.table) |
| | | _line.selects.push(line.select) |
| | | lineMap.set(line.table, _line) |
| | | } else { |
| | | lineMap.set(line.table, { |
| | | table: line.table, |
| | | insert: line.insert, |
| | | selects: [line.select] |
| | | }) |
| | | |
| | | keys = keys.join(',') |
| | | vals = vals.join(',') |
| | | |
| | | lines.push({ |
| | | table: md5(tb + keys), |
| | | insert: `Insert into ${tbName} (${keys ? keys + ',' : ''}[mk_level],[mk_id],[mk_bid])`, |
| | | select: `Select ${keys ? vals + ',' : ''}'${level}','${id}','${bid}'` |
| | | }) |
| | | |
| | | subObjs.forEach(item => { |
| | | getDefaultSql(item, item.$$key, id, level + 1) |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | let param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | BID: BID, |
| | | menuname: config.name + '(回调)' |
| | | } |
| | | |
| | | let callbacksql = this.getBackSql() |
| | | let _prevCustomScript = `${callbacksql} |
| | | ` |
| | | let _backCustomScript = '' |
| | | |
| | | btn.cbScripts.forEach(script => { |
| | | if (script.status === 'false') return |
| | | |
| | | if (script.position === 'front') { |
| | | _prevCustomScript += ` |
| | | /* 自定义脚本 */ |
| | | ${script.sql} |
| | | ` |
| | | } else { |
| | | _backCustomScript += ` |
| | | /* 自定义脚本 */ |
| | | ${script.sql} |
| | | ` |
| | | |
| | | getDefaultSql(result, btn.cbTable, '', 1) |
| | | |
| | | let lineMap = new Map() |
| | | lines.forEach(line => { |
| | | if (lineMap.has(line.table)) { |
| | | let _line = lineMap.get(line.table) |
| | | _line.selects.push(line.select) |
| | | lineMap.set(line.table, _line) |
| | | } else { |
| | | lineMap.set(line.table, { |
| | | table: line.table, |
| | | insert: line.insert, |
| | | selects: [line.select] |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | BID: BID, |
| | | menuname: config.name + '(回调)' |
| | | } |
| | | }) |
| | | |
| | | _backCustomScript += ` |
| | | aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` |
| | | |
| | | let sql = [...lineMap.values()].map(item => (` |
| | | ${item.insert} |
| | | ${item.selects.join(` union all |
| | | `)} |
| | | `)) |
| | | sql = sql.join('') |
| | | sql = _prevCustomScript + sql |
| | | sql = sql + _backCustomScript |
| | | |
| | | sql = sql.replace(/@ID@/ig, `'${ID || ''}'`) |
| | | sql = sql.replace(/@BID@/ig, `'${BID || ''}'`) |
| | | sql = sql.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) |
| | | sql = sql.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) |
| | | sql = sql.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) |
| | | sql = sql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) |
| | | sql = sql.replace(/@lang@/ig, `'${sessionStorage.getItem('lang')}'`) |
| | | sql = sql.replace(/@typename@/ig, `'admin'`) |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | sql = sql.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, `'Y'`) |
| | | } else { |
| | | sql = sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, `''`) |
| | | } |
| | | |
| | | if (window.GLOB.debugger === true) { |
| | | console.info('%c' + config.name + '(回调)', 'color: blue') |
| | | console.info(sql.replace(/\n\s{8}/ig, '\n')) |
| | | } |
| | | |
| | | param.LText = sql |
| | | param.exec_type = window.GLOB.execType || 'y' // 后台解码 |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | param.LText = Utils.formatOptions(param.LText, param.exec_type) |
| | | |
| | | if (window.GLOB.probation) { |
| | | param.s_debug_type = 'Y' |
| | | |
| | | let callbacksql = this.getBackSql() |
| | | let _prevCustomScript = `${callbacksql} |
| | | ` |
| | | let _backCustomScript = '' |
| | | |
| | | btn.cbScripts.forEach(script => { |
| | | if (script.status === 'false') return |
| | | |
| | | if (script.position === 'front') { |
| | | _prevCustomScript += ` |
| | | /* 自定义脚本 */ |
| | | ${script.sql} |
| | | ` |
| | | } else { |
| | | _backCustomScript += ` |
| | | /* 自定义脚本 */ |
| | | ${script.sql} |
| | | ` |
| | | } |
| | | }) |
| | | |
| | | _backCustomScript += ` |
| | | aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` |
| | | |
| | | let sql = [...lineMap.values()].map(item => (` |
| | | ${item.insert} |
| | | ${item.selects.join(` union all |
| | | `)} |
| | | `)) |
| | | sql = sql.join('') |
| | | sql = _prevCustomScript + sql |
| | | sql = sql + _backCustomScript |
| | | |
| | | sql = sql.replace(/@ID@/ig, `'${ID || ''}'`) |
| | | sql = sql.replace(/@BID@/ig, `'${BID || ''}'`) |
| | | sql = sql.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) |
| | | sql = sql.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) |
| | | sql = sql.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) |
| | | sql = sql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) |
| | | sql = sql.replace(/@lang@/ig, `'${sessionStorage.getItem('lang')}'`) |
| | | sql = sql.replace(/@typename@/ig, `'admin'`) |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | sql = sql.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, `'Y'`) |
| | | } else { |
| | | sql = sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, `''`) |
| | | } |
| | | |
| | | if (window.GLOB.debugger === true) { |
| | | window.mkInfo('%c' + config.name + '(回调)', 'color: blue') |
| | | window.mkInfo(sql.replace(/\n\s{8}/ig, '\n')) |
| | | } |
| | | |
| | | param.LText = sql |
| | | param.exec_type = window.GLOB.execType || 'y' // 后台解码 |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | param.LText = Utils.formatOptions(param.LText, param.exec_type) |
| | | |
| | | if (window.GLOB.probation) { |
| | | param.s_debug_type = 'Y' |
| | | } |
| | | } |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | |
| | | }) |
| | | if (res.status) { |
| | | if (config.billOutBtn.reTabId) { |
| | | MKEmitter.emit('reloadMenuView', config.billOutBtn.reTabId, 'table') |
| | | MKEmitter.emit('reloadMenuView', config.billOutBtn.reTabId) |
| | | } |
| | | if (config.billOutBtn.syncComId) { |
| | | MKEmitter.emit('reloadData', config.billOutBtn.syncComId) |
| | |
| | | }) |
| | | } |
| | | |
| | | getCallBackendParam = (btn, result) => { |
| | | const { book, BID, ID } = this.state |
| | | |
| | | let lines = [] |
| | | let tables = [] |
| | | |
| | | btn.verify.cbScripts.forEach(script => { |
| | | if (script.status === 'false') return |
| | | |
| | | if (/\s#[a-z0-9_]+(\s|\()/ig.test(script.sql)) { |
| | | tables.push(...script.sql.match(/\s#[a-z0-9_]+(\s|\()/ig)) |
| | | } |
| | | }) |
| | | |
| | | tables = tables.map(tb => tb.replace(/\s|\(/g, '')) |
| | | |
| | | if (result.$ErrCode) { |
| | | delete result.$ErrCode |
| | | delete result.$ErrMesg |
| | | } |
| | | |
| | | let getDefaultSql = (obj, tb, bid, level) => { |
| | | let vals = {} |
| | | let subObjs = [] |
| | | let id = Utils.getuuid() |
| | | |
| | | delete obj.$$key |
| | | |
| | | Object.keys(obj).forEach(key => { |
| | | let val = obj[key] |
| | | if (val === null || val === undefined) return |
| | | if (typeof(val) === 'object') { |
| | | if (Array.isArray(val)) { |
| | | val.forEach(item => { |
| | | if (typeof(item) !== 'object' || Array.isArray(item)) return |
| | | if (Object.keys(item).length === 0) return |
| | | |
| | | Object.keys(item).forEach(k => { |
| | | if (item[k] === null) { |
| | | item[k] = '' |
| | | } |
| | | }) |
| | | item.$$key = tb + '_' + key |
| | | subObjs.push(item) |
| | | }) |
| | | } else if (Object.keys(val).length > 0) { |
| | | val.$$key = tb + '_' + key |
| | | subObjs.push(val) |
| | | } |
| | | } else { |
| | | if (typeof(val) === 'string') { |
| | | val = val.replace(/'/ig, '"') |
| | | } else { |
| | | val = val + '' |
| | | } |
| | | vals[key] = val |
| | | } |
| | | }) |
| | | |
| | | vals.mk_level = level |
| | | vals.mk_id = id |
| | | vals.mk_bid = bid |
| | | |
| | | let isnew = true |
| | | lines.forEach(line => { |
| | | if (line.tb === tb) { |
| | | line.values.push(vals) |
| | | isnew = false |
| | | } |
| | | }) |
| | | if (isnew) { |
| | | lines.push({ |
| | | tb: tb, |
| | | type: tables.includes('#' + tb) ? '01' : '02', |
| | | values: [vals] |
| | | }) |
| | | } |
| | | |
| | | subObjs.forEach(item => { |
| | | getDefaultSql(item, item.$$key, id, level + 1) |
| | | }) |
| | | } |
| | | |
| | | getDefaultSql(result, btn.cbTable, '', 1) |
| | | |
| | | let ex = window.GLOB.CacheData.get('sql_' + btn.uuid + 'billback') |
| | | let exps = [] |
| | | |
| | | let values = { |
| | | time_id: Utils.getguid(), |
| | | roleid: sessionStorage.getItem('role_id') || '', |
| | | mk_departmentcode: sessionStorage.getItem('departmentcode') || '', |
| | | mk_organization: sessionStorage.getItem('organization') || '', |
| | | mk_user_type: sessionStorage.getItem('mk_user_type') || '', |
| | | mk_nation: sessionStorage.getItem('nation') || '', |
| | | mk_province: sessionStorage.getItem('province') || '', |
| | | mk_city: sessionStorage.getItem('city') || '', |
| | | mk_district: sessionStorage.getItem('district') || '', |
| | | mk_address: sessionStorage.getItem('address') || '', |
| | | id: ID || '', |
| | | bid: BID || '', |
| | | datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', |
| | | datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', |
| | | datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', |
| | | } |
| | | |
| | | if (window.GLOB.externalDatabase !== null) { |
| | | values.db = window.GLOB.externalDatabase |
| | | } |
| | | |
| | | ex.reps.forEach(n => { |
| | | let key = n.toLowerCase() |
| | | if (values.hasOwnProperty(key)) { |
| | | exps.push({ |
| | | key: n, |
| | | value: values[key] |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | exps.push({ |
| | | key: 'account_id', |
| | | value: book.account_id || '' |
| | | }, { |
| | | key: 'account_year_id', |
| | | value: book.account_year_id || '' |
| | | }, { |
| | | key: 'account_code', |
| | | value: book.account_code || '' |
| | | }, { |
| | | key: 'account_year_code', |
| | | value: book.account_year_code || '' |
| | | }) |
| | | |
| | | exps.push({ |
| | | key: 'mk_outer_params', // 回调脚本的数据替换 |
| | | value: lines |
| | | }) |
| | | |
| | | let md5_id = '' |
| | | if (window.GLOB.probation) { |
| | | md5_id = md5('back_' + btn.uuid + JSON.stringify(exps) + Math.floor(new Date().getTime() / 600000)) |
| | | md5_id = moment().format('YYYYMMDDHHmmss') + md5_id.slice(-18) |
| | | } |
| | | |
| | | return { |
| | | $backend: true, |
| | | $type: 's_TableData_InUpDe', |
| | | data: [{ |
| | | id: ex.id, |
| | | menuname: btn.logLabel + '(回调)', |
| | | exps: exps, |
| | | md5_id: md5_id |
| | | }] |
| | | } |
| | | } |
| | | |
| | | getBackSql = () => { |
| | | const { book, BID } = this.state |
| | | |