| | |
| | | { |
| | | type: 'radio', |
| | | field: 'goback', |
| | | label: '空值返回', |
| | | label: appType === 'mob' ? '空值返回' : '空值关闭', |
| | | initval: wrap.goback || 'false', |
| | | tooltip: '当查询数据为空时,返回上一界面。', |
| | | tooltip: appType === 'mob' ? '当查询数据为空时,返回上一界面。' : '当查询数据为空时,关闭当前标签页。', |
| | | required: false, |
| | | options: [ |
| | | {value: 'true', label: '是'}, |
| | | {value: 'false', label: '否'}, |
| | | {value: 'true', label: '是'}, |
| | | ], |
| | | forbid: subtype !== 'propcard' || appType !== 'mob' |
| | | forbid: subtype !== 'propcard' || appType === 'pc' |
| | | }, |
| | | { |
| | | type: 'radio', |
| | |
| | | height: 45px; |
| | | padding-top: 5px; |
| | | .ant-input-group-wrapper { |
| | | width: 40%; |
| | | max-width: 400px; |
| | | width: 65%; |
| | | float: right; |
| | | } |
| | | } |
| | |
| | | ], |
| | | controlFields: [ |
| | | {field: 'linkUrl', values: ['fixed']}, |
| | | {field: 'focus', values: ['input']}, |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | field: 'focus', |
| | | label: '自动聚焦', |
| | | initval: wrap.focus || 'true', |
| | | required: false, |
| | | options: [ |
| | | {value: 'true', label: '是'}, |
| | | {value: 'false', label: '否'}, |
| | | ], |
| | | forbid: appType === 'mob' |
| | | }, |
| | | { |
| | | type: 'textarea', |
| | | field: 'linkUrl', |
| | | label: '地址链接', |
| | |
| | | } else if (value === 'excelIn') { |
| | | _fieldval.intertype = 'system' |
| | | _fieldval.Ot = 'notRequired' |
| | | |
| | | _fieldval.execSuccess = 'grid' |
| | | _fieldval.label = '导入Excel' |
| | | _fieldval.class = 'dgreen' |
| | | this.record.Ot = 'notRequired' |
| | | this.record.label = '导入Excel' |
| | | this.record.class = 'dgreen' |
| | | |
| | | |
| | | this.record.execSuccess = 'grid' |
| | | } else if (value === 'excelOut') { |
| | | _fieldval.intertype = 'system' |
| | | _fieldval.label = '导出Excel' |
| | |
| | | } else if (appType === 'pc') { |
| | | opentypes = opentypes.filter(item => item.value !== 'tab') |
| | | funTypes = [ |
| | | { value: 'refund', text: '退款' }, |
| | | { value: 'changeuser', text: '切换用户' }, |
| | | ] |
| | | pageTemps = [ |
| | |
| | | BData={data.$$BData || ''} |
| | | disabled={_disabled} |
| | | setting={cards.setting} |
| | | columns={cards.columns} |
| | | selectedData={_data} |
| | | /> |
| | | </Col> |
| | |
| | | data: _data, |
| | | loading: false |
| | | }, () => { |
| | | if (selected !== 'false') { |
| | | this.checkTopLine() |
| | | if (config.wrap.goback === 'true' && _data.$$empty) { |
| | | this.timer && this.timer.stop() |
| | | |
| | | MKEmitter.emit('closeTabView', config.$pageId) |
| | | } else { |
| | | this.transferLine() |
| | | if (selected !== 'false') { |
| | | this.checkTopLine() |
| | | } else { |
| | | this.transferLine() |
| | | } |
| | | this.autoExec() |
| | | } |
| | | this.autoExec() |
| | | }) |
| | | |
| | | if (config.timer && config.clearField) { |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | |
| | | if (config.wrap.linkType === 'input' && config.wrap.focus !== 'false') { |
| | | setTimeout(() => { |
| | | let node = document.getElementById(config.uuid) |
| | | node && node.select && node.select() |
| | | }, 200) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | |
| | | .ant-input-search { |
| | | margin-top: 5px; |
| | | width: 40%; |
| | | max-width: 400px; |
| | | width: 65%; |
| | | float: right; |
| | | } |
| | | } |
| | |
| | | |
| | | component.setting.useMSearch = component.setting.useMSearch === 'true' |
| | | |
| | | if (component.wrap && component.wrap.goback === 'true') { |
| | | component.setting.sync = 'false' |
| | | } |
| | | |
| | | if (component.setting.interType !== 'system') { // 不使用系统函数时 |
| | | component.setting.sync = 'false' |
| | | component.setting.laypage = component.setting.laypage === 'true' |
| | |
| | | }) |
| | | viewParam.arr_field = viewParam.arr_field.join(',') |
| | | |
| | | viewParam.orderBy = btn.verify.order || viewParam.orderBy |
| | | viewParam.orderBy = btn.verify.order || '' |
| | | } |
| | | } |
| | | if (btn.intertype === 'system' && btn.verify.enable === 'true') { |
| | |
| | | btn={item} |
| | | BData={BData} |
| | | setting={setting} |
| | | columns={columns} |
| | | selectedData={selectedData} |
| | | /> |
| | | ) |
| | |
| | | MenuID: PropTypes.string, // 菜单ID |
| | | btn: PropTypes.object, // 按钮 |
| | | setting: PropTypes.any, // 页面通用设置 |
| | | columns: PropTypes.array, |
| | | disabled: PropTypes.any, // 行按钮禁用 |
| | | } |
| | | |
| | |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (btn.intertype === 'system' && btn.verify.dataType === 'custom' && (!btn.verify.setting || btn.verify.columns.length === 0)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义打印数据请设置数据源!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | triggerNormalPrint = (data, formlist) => { |
| | | const { btn } = this.props |
| | | let formdata = {} |
| | | let baseCount = 1 |
| | | let baseType = '' |
| | | let baseTemp = btn.verify.Template || '' |
| | | |
| | | formlist.forEach(_data => { |
| | | formdata[_data.key] = _data.value |
| | | |
| | | if (!_data.value) return |
| | | |
| | | if (_data.key.toLowerCase() === 'printcount') { |
| | | baseCount = +_data.value |
| | | } else if (_data.key.toLowerCase() === 'printtype') { |
| | | baseType = _data.value |
| | | } else if (_data.key.toLowerCase() === 'templateid') { |
| | | baseTemp = _data.value |
| | | } |
| | | let _key = _data.key.toLowerCase() |
| | | formdata[_key] = _data.value |
| | | }) |
| | | |
| | | let printlist = [] |
| | | let templates = [] |
| | | |
| | | if (isNaN(baseCount) || baseCount < 1) { |
| | | baseCount = 1 |
| | | } |
| | | |
| | | new Promise(resolve => { |
| | | if (btn.intertype === 'system') { // 使用系统时,直接从表格或表单中选取数据 |
| | | if (btn.intertype === 'system' && btn.verify.dataType !== 'custom') { // 使用系统时,直接从表格或表单中选取数据 |
| | | if (btn.Ot === 'notRequired') { |
| | | let printcell = {} |
| | | |
| | | printcell.printType = baseType |
| | | printcell.printCount = baseCount |
| | | printcell.templateID = baseTemp |
| | | printcell.printType = formdata.printtype || '' |
| | | printcell.printCount = +(formdata.printcount || 1) |
| | | printcell.templateID = formdata.templateid || btn.verify.Template || '' |
| | | |
| | | printcell.data = [formdata] |
| | | |
| | | if (isNaN(printcell.printCount) || printcell.printCount < 1) { |
| | | printcell.printCount = 1 |
| | | } |
| | | |
| | | templates.push(printcell.templateID) |
| | | |
| | | printlist.push(printcell) |
| | | } else { |
| | | data.forEach(cell => { |
| | | let _cell = {...cell, ...formdata} |
| | | let _cell = {} |
| | | |
| | | Object.keys(cell).forEach(key => { |
| | | let _key = key.toLowerCase() |
| | | _cell[_key] = cell[key] |
| | | }) |
| | | |
| | | _cell = {..._cell, ...formdata} |
| | | |
| | | let printcell = {data: [_cell]} |
| | | |
| | | printcell.templateID = baseTemp |
| | | printcell.printType = baseType |
| | | printcell.printCount = 0 |
| | | |
| | | Object.keys(_cell).forEach(key => { |
| | | if (!_cell[key]) return |
| | | |
| | | let _key = key.toLowerCase() |
| | | |
| | | if (_key === 'templateid') { |
| | | printcell.templateID = _cell[key] |
| | | } else if (_key === 'printtype') { |
| | | printcell.printType = _cell[key] |
| | | } else if (_key === 'printcount') { |
| | | printcell.printCount = +_cell[key] |
| | | } |
| | | }) |
| | | printcell.printType = _cell.printtype || '' |
| | | printcell.printCount = +(_cell.printcount || 1) |
| | | printcell.templateID = _cell.templateid || btn.verify.Template || '' |
| | | |
| | | if (isNaN(printcell.printCount) || printcell.printCount < 1) { |
| | | printcell.printCount = baseCount |
| | | printcell.printCount = 1 |
| | | } |
| | | |
| | | templates.push(printcell.templateID) |
| | |
| | | }) |
| | | } |
| | | |
| | | resolve(true) |
| | | if (btn.verify.printMode === 'custom') { |
| | | this.execCustomPrint(printlist, formdata) |
| | | resolve(false) |
| | | } else { |
| | | resolve(true) |
| | | } |
| | | } else { |
| | | this.getprintdata(btn, data, formdata, formlist).then(result => { |
| | | if (result.next) { |
| | | result.list.forEach(cell => { |
| | | // 系统打印数据,校验data字段 |
| | | if (btn.verify.printMode !== 'custom' && (!cell.data || cell.data.length === 0)) return |
| | | if (!result.next) { |
| | | resolve(false) |
| | | return |
| | | } |
| | | |
| | | let templateID = baseTemp |
| | | let printType = baseType |
| | | let printCount = 0 |
| | | // 自定义打印 |
| | | if (btn.verify.printMode === 'custom') { |
| | | this.execCustomPrint(result.list, formdata) |
| | | resolve(false) |
| | | return |
| | | } |
| | | |
| | | Object.keys(cell).forEach(key => { |
| | | if (!cell[key]) return |
| | | result.list.forEach(cell => { |
| | | // 系统打印数据,校验data字段 |
| | | if (!cell.data || cell.data.length === 0) return |
| | | |
| | | cell.data.forEach(item => { |
| | | let _item = {...formdata} |
| | | |
| | | _item.printtype = cell.printtype || '' |
| | | _item.printcount = cell.printcount || 1 |
| | | _item.templateid = cell.templateid || '' |
| | | |
| | | Object.keys(item).forEach(key => { |
| | | let _key = key.toLowerCase() |
| | | |
| | | if (_key === 'templateid') { |
| | | templateID = cell[key] |
| | | } else if (_key === 'printtype') { |
| | | printType = cell[key] |
| | | } else if (_key === 'printcount') { |
| | | printCount = +cell[key] |
| | | } |
| | | _item[_key] = item[key] |
| | | }) |
| | | |
| | | cell.templateID = templateID |
| | | cell.printType = printType |
| | | cell.printCount = printCount |
| | | let printcell = {data: [_item]} |
| | | |
| | | printcell.printType = _item.printtype || '' |
| | | printcell.printCount = +(_item.printcount || 1) |
| | | printcell.templateID = _item.templateid || btn.verify.Template || '' |
| | | |
| | | if (isNaN(cell.printCount) || cell.printCount < 1) { |
| | | cell.printCount = baseCount |
| | | if (isNaN(printcell.printCount) || printcell.printCount < 1) { |
| | | printcell.printCount = 1 |
| | | } |
| | | |
| | | templates.push(cell.templateID) |
| | | templates.push(printcell.templateID) |
| | | |
| | | printlist.push(cell) |
| | | printlist.push(printcell) |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | resolve(result.next) |
| | | resolve(true) |
| | | }) |
| | | } |
| | | }).then(res => { |
| | | // 获取打印模板 getTemp |
| | | if (!res) return false |
| | | |
| | | if (btn.verify.printMode === 'custom') { |
| | | this.execCustomPrint(printlist, formdata) |
| | | |
| | | return false |
| | | } |
| | | |
| | | templates = Array.from(new Set(templates)) // 去重 |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | this.execPrint(printlist, _temps, formdata) |
| | | this.execPrint(printlist, _temps) |
| | | }, 500) |
| | | } else { |
| | | this.execPrint(printlist, _temps, formdata) |
| | | this.execPrint(printlist, _temps) |
| | | } |
| | | } else { |
| | | this.execError(errorMsg) |
| | |
| | | }) |
| | | |
| | | new Promise(resolve => { |
| | | if (btn.intertype === 'system') { // 使用系统时,直接从表格或表单中选取数据 |
| | | if (btn.intertype === 'system' && btn.verify.dataType !== 'custom') { // 使用系统时,直接从表格或表单中选取数据 |
| | | if (btn.Ot === 'notRequired') { |
| | | if (formlist.length > 0) { |
| | | list = [formdata] |
| | |
| | | * @description 获取打印数据 |
| | | */ |
| | | getprintdata = (btn, data, formdata, formlist) => { |
| | | const { setting } = this.props |
| | | const { setting, BID } = this.props |
| | | |
| | | let _list = [] |
| | | return new Promise(resolve => { |
| | | let params = [] |
| | | let param = {} |
| | | |
| | | if (this.props.BID) { |
| | | param.BID = this.props.BID |
| | | } |
| | | |
| | | if (btn.Ot === 'notRequired') { |
| | | let _param = { ...param, ...formdata } |
| | | params.push(_param) |
| | | } else if (btn.Ot === 'requiredSgl') { |
| | | if (setting.primaryKey) { |
| | | param[setting.primaryKey] = data[0][setting.primaryKey] |
| | | } |
| | | |
| | | let _param = { ...param, ...formdata } |
| | | |
| | | params.push(_param) |
| | | } else if (btn.Ot === 'requiredOnce') { |
| | | if (setting.primaryKey) { |
| | | let ids = data.map(d => { return d[setting.primaryKey]}) |
| | | ids = ids.filter(Boolean) |
| | | ids = ids.join(',') |
| | | if (btn.intertype === 'system' && btn.verify.dataType === 'custom') { |
| | | if (btn.Ot === 'notRequired') { |
| | | let _param = this.getDefaultSql(formlist, null, '') |
| | | |
| | | param[setting.primaryKey] = ids |
| | | } |
| | | |
| | | let _param = { ...param, ...formdata } |
| | | |
| | | params.push(_param) |
| | | } else if (btn.Ot === 'required') { |
| | | params = data.map((cell, index) => { |
| | | let _param = { ...param } |
| | | |
| | | params.push(_param) |
| | | } else if (btn.Ot === 'requiredSgl') { |
| | | let ID = '' |
| | | if (setting.primaryKey) { |
| | | _param[setting.primaryKey] = cell[setting.primaryKey] |
| | | ID = data[0][setting.primaryKey] || '' |
| | | } |
| | | |
| | | let _cell = {} |
| | | if (index !== 0) { |
| | | Object.keys(cell).forEach(key => { |
| | | _cell[key.toLowerCase()] = cell[key] |
| | | }) |
| | | let _param = this.getDefaultSql(formlist, data[0], ID) |
| | | |
| | | params.push(_param) |
| | | } else if (btn.Ot === 'requiredOnce') { |
| | | let ID = '' |
| | | |
| | | if (setting.primaryKey) { |
| | | let ids = data.map(d => { return d[setting.primaryKey]}) |
| | | ids = ids.filter(Boolean) |
| | | ID = ids.join(',') |
| | | } |
| | | |
| | | formlist.forEach(_data => { |
| | | if (index !== 0 && _data.readin && _cell.hasOwnProperty(_data.key.toLowerCase())) { |
| | | _param[_data.key] = _cell[_data.key.toLowerCase()] |
| | | } else { |
| | | _param[_data.key] = _data.value |
| | | let _param = this.getDefaultSql(formlist, data[0], ID) |
| | | |
| | | params.push(_param) |
| | | } else if (btn.Ot === 'required') { |
| | | params = data.map(cell => { |
| | | let ID = '' |
| | | if (setting.primaryKey) { |
| | | ID = cell[setting.primaryKey] || '' |
| | | } |
| | | |
| | | return this.getDefaultSql(formlist, cell, ID) |
| | | }) |
| | | return _param |
| | | }) |
| | | } |
| | | } else { |
| | | if (btn.Ot === 'notRequired') { |
| | | let _param = { ...formdata } |
| | | |
| | | if (BID) { |
| | | _param.BID = BID |
| | | } |
| | | |
| | | params.push(_param) |
| | | } else if (btn.Ot === 'requiredSgl') { |
| | | let _param = { ...formdata } |
| | | |
| | | if (setting.primaryKey) { |
| | | _param[setting.primaryKey] = data[0][setting.primaryKey] |
| | | } |
| | | |
| | | if (BID) { |
| | | _param.BID = BID |
| | | } |
| | | |
| | | params.push(_param) |
| | | } else if (btn.Ot === 'requiredOnce') { |
| | | let _param = { ...formdata } |
| | | |
| | | if (setting.primaryKey) { |
| | | let ids = data.map(d => { return d[setting.primaryKey]}) |
| | | ids = ids.filter(Boolean) |
| | | ids = ids.join(',') |
| | | |
| | | _param[setting.primaryKey] = ids |
| | | } |
| | | |
| | | if (BID) { |
| | | _param.BID = BID |
| | | } |
| | | |
| | | params.push(_param) |
| | | } else if (btn.Ot === 'required') { |
| | | params = data.map((cell, index) => { |
| | | let _param = {} |
| | | |
| | | if (setting.primaryKey) { |
| | | _param[setting.primaryKey] = cell[setting.primaryKey] |
| | | } |
| | | |
| | | if (BID) { |
| | | _param.BID = BID |
| | | } |
| | | |
| | | let _cell = {} |
| | | if (index !== 0) { |
| | | Object.keys(cell).forEach(key => { |
| | | _cell[key.toLowerCase()] = cell[key] |
| | | }) |
| | | } |
| | | |
| | | formlist.forEach(_data => { |
| | | if (index !== 0 && _data.readin && _cell.hasOwnProperty(_data.key.toLowerCase())) { |
| | | _param[_data.key] = _cell[_data.key.toLowerCase()] |
| | | } else { |
| | | _param[_data.key] = _data.value |
| | | } |
| | | }) |
| | | return _param |
| | | }) |
| | | } |
| | | } |
| | | |
| | | if (btn.intertype === 'inner') { |
| | | params = params.map(_param => { |
| | | _param.func = btn.innerFunc |
| | | |
| | | return _param |
| | | }) |
| | | if (btn.intertype === 'inner' || btn.intertype === 'system') { |
| | | if (btn.intertype === 'inner') { |
| | | params = params.map(_param => { |
| | | _param.func = btn.innerFunc |
| | | |
| | | return _param |
| | | }) |
| | | } |
| | | |
| | | if (params.length <= 20) { |
| | | let deffers = params.map(par => { |
| | |
| | | } |
| | | }) |
| | | if (!errorMsg) { |
| | | resolve({next: true, list: result}) |
| | | resolve({next: true, list: result.map(res => { |
| | | Object.keys(res).forEach(key => { |
| | | let _key = key.toLowerCase() |
| | | if (['templateid', 'printtype', 'printcount'].includes(_key)) { |
| | | res[_key] = res[key] |
| | | } |
| | | }) |
| | | |
| | | return res |
| | | })}) |
| | | } else { |
| | | this.execError(errorMsg) |
| | | resolve({next: false, list: []}) |
| | |
| | | this.printOuterLoopRequest(params, btn, _list, resolve) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 获取默认存储过程请求参数 |
| | | */ |
| | | getDefaultSql = (formlist, data, ID) => { |
| | | const { BID, btn, columns } = this.props |
| | | |
| | | let arrFields = btn.verify.columns.map(col => col.field).join(',') |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_TableData', |
| | | obj_name: 'data', |
| | | exec_type: 'y', |
| | | arr_field: arrFields, |
| | | default_sql: btn.verify.setting.defaultSql |
| | | } |
| | | |
| | | if (BID) { |
| | | param.BID = BID |
| | | } |
| | | if (ID) { |
| | | param.ID = ID |
| | | } |
| | | |
| | | let userName = sessionStorage.getItem('User_Name') || '' |
| | | let fullName = sessionStorage.getItem('Full_Name') || '' |
| | | let RoleID = sessionStorage.getItem('role_id') || '' |
| | | let departmentcode = sessionStorage.getItem('departmentcode') || '' |
| | | let organization = sessionStorage.getItem('organization') || '' |
| | | let mk_user_type = sessionStorage.getItem('mk_user_type') || '' |
| | | let nation = sessionStorage.getItem('nation') || '' |
| | | let province = sessionStorage.getItem('province') || '' |
| | | let city = sessionStorage.getItem('city') || '' |
| | | let district = sessionStorage.getItem('district') || '' |
| | | let address = sessionStorage.getItem('address') || '' |
| | | |
| | | let _dataresource = btn.verify.setting.dataresource |
| | | let _customScript = '' |
| | | |
| | | btn.verify.scripts && btn.verify.scripts.forEach(script => { |
| | | if (script.status !== 'false') { |
| | | _customScript += ` |
| | | ${script.sql} |
| | | ` |
| | | } |
| | | }) |
| | | |
| | | if (btn.verify.setting.defaultSql === 'false') { |
| | | _dataresource = '' |
| | | } |
| | | |
| | | if (/\s/.test(_dataresource)) { |
| | | _dataresource = '(' + _dataresource + ') tb' |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | _dataresource = _dataresource.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') |
| | | _dataresource = _dataresource.replace(/@\$/ig, '*/') |
| | | _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') |
| | | _customScript = _customScript.replace(/@\$/ig, '*/') |
| | | } else { |
| | | _dataresource = _dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | |
| | | let initsql = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) |
| | | Select @ErrorCode='',@retmsg ='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}' |
| | | ` |
| | | |
| | | let _vars = [] |
| | | let _initvars = [] |
| | | let _declare = [] |
| | | // 获取字段键值对 |
| | | formlist.forEach(form => { |
| | | let _key = form.key.toLowerCase() |
| | | |
| | | if (_vars.includes(_key)) return |
| | | |
| | | _vars.push(_key) |
| | | |
| | | if (form.type === 'number' || form.type === 'rate') { |
| | | let val = form.value |
| | | if (isNaN(val)) { |
| | | val = 0 |
| | | } |
| | | _initvars.push(`@${_key}=${val}`) |
| | | } else if (['date', 'datemonth'].includes(form.type)) { |
| | | _initvars.push(`@${_key}='${form.value || '1949-10-01'}'`) |
| | | } else { |
| | | _initvars.push(`@${_key}='${form.value}'`) |
| | | } |
| | | |
| | | if (form.fieldlen && form.fieldlen > 2048) { |
| | | form.fieldlen = 'max' |
| | | } |
| | | |
| | | let _type = `nvarchar(${form.fieldlen})` |
| | | |
| | | if (form.type.match(/date/ig)) { |
| | | _type = 'datetime' |
| | | } else if (form.type === 'number') { |
| | | _type = `decimal(18,${form.fieldlen})` |
| | | } else if (form.type === 'rate') { |
| | | _type = `decimal(18,2)` |
| | | } |
| | | |
| | | _declare.push(`@${_key} ${_type}`) |
| | | }) |
| | | |
| | | if (_declare.length > 0) { |
| | | initsql += `/* 表单变量 */ |
| | | Declare ${_declare.join(',')} |
| | | select ${_initvars.join(',')} |
| | | ` |
| | | |
| | | _declare = [] |
| | | _initvars = [] |
| | | } |
| | | |
| | | if (data && columns && columns.length > 0) { |
| | | let datavars = {} |
| | | |
| | | Object.keys(data).forEach(key => { |
| | | datavars[key.toLowerCase()] = data[key] |
| | | }) |
| | | |
| | | columns.forEach(col => { |
| | | if (!col.field || !col.datatype) return |
| | | |
| | | let _key = col.field.toLowerCase() |
| | | |
| | | if (_vars.includes(_key)) return |
| | | |
| | | let _val = datavars.hasOwnProperty(_key) ? datavars[_key] : '' |
| | | |
| | | if (/^date/ig.test(col.datatype) && !_val) { |
| | | _val = '1949-10-01' |
| | | } |
| | | |
| | | _initvars.push(`@${_key}='${_val}'`) |
| | | _declare.push(`@${_key} ${col.datatype}`) |
| | | }) |
| | | } |
| | | |
| | | if (_declare.length > 0) { |
| | | initsql += `/* 显示列变量 */ |
| | | Declare ${_declare.join(',')} |
| | | select ${_initvars.join(',')} |
| | | ` |
| | | } |
| | | |
| | | |
| | | if (_customScript) { |
| | | _customScript = `${initsql} |
| | | ${_customScript} |
| | | ` |
| | | } |
| | | |
| | | _dataresource = _dataresource.replace(/@select\$|\$select@/ig, '') |
| | | _customScript = _customScript.replace(/@select\$|\$select@/ig, '') |
| | | _dataresource = _dataresource.replace(/\$sum@/ig, '/*') |
| | | _dataresource = _dataresource.replace(/@sum\$/ig, '*/') |
| | | _customScript = _customScript.replace(/\$sum@/ig, '/*') |
| | | _customScript = _customScript.replace(/@sum\$/ig, '*/') |
| | | |
| | | _dataresource = _dataresource.replace(/@ID@/ig, `'${ID}'`) |
| | | _customScript = _customScript.replace(/@ID@/ig, `'${ID}'`) |
| | | _dataresource = _dataresource.replace(/@BID@/ig, `'${BID || ''}'`) |
| | | _customScript = _customScript.replace(/@BID@/ig, `'${BID || ''}'`) |
| | | _dataresource = _dataresource.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) |
| | | _customScript = _customScript.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) |
| | | _dataresource = _dataresource.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) |
| | | _customScript = _customScript.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) |
| | | _dataresource = _dataresource.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) |
| | | _customScript = _customScript.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) |
| | | _dataresource = _dataresource.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) |
| | | _customScript = _customScript.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) |
| | | |
| | | |
| | | let LText = '' |
| | | |
| | | if (_dataresource) { |
| | | LText = `/*system_query*/select ${arrFields} from (select ${arrFields} ,ROW_NUMBER() over(order by ${btn.verify.setting.order}) as rows from ${_dataresource}) tmptable order by tmptable.rows ` |
| | | } |
| | | |
| | | if (_customScript) { |
| | | if (LText) { |
| | | LText = `${LText} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ |
| | | ` |
| | | } else { |
| | | _customScript = `${_customScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ |
| | | ` |
| | | } |
| | | } else { |
| | | LText = `${initsql} |
| | | ${LText} |
| | | ` |
| | | } |
| | | |
| | | // 测试系统打印查询语句 |
| | | if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) { |
| | | _customScript && console.info(`${btn.logLabel ? `/*${btn.logLabel} 自定义脚本*/\n` : ''}${LText ? '' : '/*不执行默认sql*/\n'}${_customScript}`) |
| | | LText && console.info(`${btn.logLabel ? `/*${btn.logLabel} 数据源*/\n` : ''}` + LText.replace(/\n\s{8}/ig, '\n')) |
| | | } |
| | | |
| | | if (btn.logLabel) { |
| | | param.menuname = btn.logLabel |
| | | } |
| | | |
| | | param.custom_script = Utils.formatOptions(_customScript) |
| | | param.LText = Utils.formatOptions(LText) |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | |
| | | if (window.GLOB.probation) { |
| | | param.s_debug_type = 'Y' |
| | | } |
| | | |
| | | return param |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | return Api.genericInterface(_callbackparam) |
| | | } else if (response.status) { |
| | | Object.keys(response).forEach(key => { |
| | | let _key = key.toLowerCase() |
| | | if (['templateid', 'printtype', 'printcount'].includes(_key)) { |
| | | response[_key] = response[key] |
| | | } |
| | | }) |
| | | |
| | | _list.push(response) |
| | | |
| | |
| | | if (!response) return |
| | | |
| | | if (response.status) { |
| | | Object.keys(response).forEach(key => { |
| | | let _key = key.toLowerCase() |
| | | if (['templateid', 'printtype', 'printcount'].includes(_key)) { |
| | | response[_key] = response[key] |
| | | } |
| | | }) |
| | | |
| | | _list.push(response) |
| | | |
| | | // 一次请求成功,进行下一项请求 |
| | |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | Object.keys(res).forEach(key => { |
| | | let _key = key.toLowerCase() |
| | | if (['templateid', 'printtype', 'printcount'].includes(_key)) { |
| | | res[_key] = res[key] |
| | | } |
| | | }) |
| | | _list.push(res) |
| | | |
| | | if (params.length === 0) { |
| | |
| | | } |
| | | |
| | | configParam.elements.forEach(element => { |
| | | let _field = element.field |
| | | let _field = element.field || '' |
| | | |
| | | if (_field === 'other_field') { |
| | | _field = element.cusfield || '' |
| | |
| | | Name: element.name || '', |
| | | Type: element.type, |
| | | Value: element.value || '', |
| | | Field: _field, |
| | | Field: _field.toLowerCase(), |
| | | Left: element.left + offsetLeft, |
| | | Top: element.top + offsetTop, |
| | | Width: element.width, |
| | |
| | | item.ImageWidth = element.imgWidth |
| | | item.ImageHeight = element.imgHeight |
| | | item.Trimming = '' |
| | | if (element.productValue && window.GLOB.systemType === 'production') { |
| | | item.Value = element.productValue |
| | | imgs.push(item.Value) |
| | | } else if (item.Value) { |
| | | imgs.push(item.Value) |
| | | if (!item.Field) { |
| | | if (element.productValue && window.GLOB.systemType === 'production') { |
| | | item.Value = element.productValue |
| | | imgs.push(item.Value) |
| | | } else if (item.Value) { |
| | | imgs.push(item.Value) |
| | | } |
| | | } |
| | | } else if (item.Type === 'text') { |
| | | item.FontFamily = element.fontFamily |
| | |
| | | return { |
| | | error: error, |
| | | config: _configparam, |
| | | fields: fields, |
| | | nonEFields: nonEFields, |
| | | fields: Array.from(new Set(fields)), |
| | | nonEFields: Array.from(new Set(nonEFields)), |
| | | imgs: imgs |
| | | } |
| | | } |
| | |
| | | }) |
| | | } |
| | | |
| | | execPrint = (list, template, formdata) => { |
| | | execPrint = (list, template) => { |
| | | const { btn } = this.props |
| | | let _errors = [] |
| | | |
| | |
| | | _datalist.forEach(res => { |
| | | res.data.forEach(_cell => { |
| | | for (let i = 0; i < res.printCount; i++) { |
| | | _data.push({...formdata, ..._cell}) |
| | | _data.push(_cell) |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | let _fields = Array.from(new Set(template[key].fields)) |
| | | let _nonEFields = Array.from(new Set(template[key].nonEFields)) |
| | | let lacks = [] |
| | | let emptys = [] |
| | | |
| | | _data.forEach(d => { |
| | | _fields.forEach(f => { |
| | | template[key].fields.forEach(f => { |
| | | if (!d.hasOwnProperty(f)) { |
| | | lacks.push(f) |
| | | } else if (_nonEFields.includes(f) && !d[f] && d[f] !== 0) { |
| | | } else if (template[key].nonEFields.includes(f) && !d[f] && d[f] !== 0) { |
| | | emptys.push(f) |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | if (lacks.length > 0 || emptys.length > 0) { |
| | | lacks = Array.from(new Set(lacks)) |
| | | emptys = Array.from(new Set(emptys)) |
| | | |
| | | _errors.push({ |
| | | title: template[key].config.Title, |
| | | lacks: lacks, |
| | |
| | | return |
| | | } |
| | | |
| | | // let lackItems = printerList.filter(cell => cell.task.printer === 'lackprinter')[0] |
| | | |
| | | if (!socket || socket.readyState !== 1 || socket.url !== 'ws://' + btn.verify.linkUrl) { |
| | | socket = new WebSocket('ws://' + btn.verify.linkUrl) |
| | | } else { |
| | | // if (lackItems) { |
| | | // let request = { |
| | | // requestID: '', |
| | | // version: '', |
| | | // cmd: 'getPrinters' |
| | | // } |
| | | // socket.send(JSON.stringify(request)) |
| | | // } else { |
| | | this.syncMessageSend(printerList) |
| | | this.syncMessageSend(printerList) |
| | | |
| | | this.execSuccess({ |
| | | ErrCode: 'S', |
| | | message: '', |
| | | ErrMesg: '打印请求已发出。', |
| | | status: true |
| | | }) |
| | | // } |
| | | this.execSuccess({ |
| | | ErrCode: 'S', |
| | | message: '', |
| | | ErrMesg: '打印请求已发出。', |
| | | status: true |
| | | }) |
| | | } |
| | | |
| | | // 打开Socket |
| | | socket.onopen = () =>{ |
| | | // if (lackItems) { |
| | | // let request = { |
| | | // requestID: '', |
| | | // version: '', |
| | | // cmd: 'getPrinters' |
| | | // } |
| | | // socket.send(JSON.stringify(request)) |
| | | // } else { |
| | | this.syncMessageSend(printerList) |
| | | this.syncMessageSend(printerList) |
| | | |
| | | this.execSuccess({ |
| | | ErrCode: 'S', |
| | | message: '', |
| | | ErrMesg: '打印请求已发出。', |
| | | status: true |
| | | }) |
| | | // } |
| | | this.execSuccess({ |
| | | ErrCode: 'S', |
| | | message: '', |
| | | ErrMesg: '打印请求已发出。', |
| | | status: true |
| | | }) |
| | | } |
| | | // 监听消息 |
| | | socket.onmessage = (event) => { |
| | |
| | | btn={item} |
| | | BData={BData} |
| | | setting={setting} |
| | | columns={columns} |
| | | selectedData={[data]} |
| | | /> |
| | | ) |
| | |
| | | }) |
| | | } else if (item.regular === 'email') { |
| | | _rules.push({ |
| | | pattern: /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/, |
| | | pattern: /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/, |
| | | message: item.regularText || '请正确输入邮箱地址' |
| | | }) |
| | | } |
| | |
| | | |
| | | _fieldval.label = '导入Excel' |
| | | _fieldval.class = 'dgreen' |
| | | _fieldval.execSuccess = 'grid' |
| | | this.record.Ot = 'notRequired' |
| | | this.record.label = '导入Excel' |
| | | this.record.class = 'dgreen' |
| | | this.record.execSuccess = 'grid' |
| | | } else if (value === 'excelOut') { |
| | | _fieldval.intertype = 'system' |
| | | _fieldval.label = '导出Excel' |
| | |
| | | } else if (card.OpenType === 'funcbutton' && card.funcType === 'print') { |
| | | return <VerifyPrint |
| | | card={card} |
| | | columns={config.columns} |
| | | columns={[]} |
| | | // columns={config.columns} |
| | | wrappedComponentRef={(inst) => this.verifyRef = inst} |
| | | /> |
| | | } else if (card.OpenType === 'funcbutton' && card.funcType === 'megvii') { |
| | |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | const { card } = this.props |
| | | let _verify = fromJS(card.verify || {range: 1}).toJS() |
| | | let _verify = fromJS(card.verify || {}).toJS() |
| | | let _columns = _verify.columns || [] |
| | | |
| | | delete _verify.dataresource |
| | | |
| | | // 旧数据兼容 |
| | | _columns = _columns.map(col => { |
| | |
| | | return col |
| | | }) |
| | | |
| | | if (!_verify.hasOwnProperty('range')) { |
| | | _verify.range = 1 |
| | | } |
| | | |
| | | this.setState({ |
| | | verify: { |
| | | ..._verify, |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Form, Row, Col, Button, notification, Modal, Tooltip, Radio, Select } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | import { Form, Row, Col, Button, notification, Tooltip, Select } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | |
| | | |
| | | class CustomForm extends Component { |
| | | static propTpyes = { |
| | | scripts: PropTypes.array, // 自定义脚本列表 |
| | | usefulfields: PropTypes.any, // 可用字段 |
| | | systemScripts: PropTypes.array, // 系统脚本 |
| | | scriptsChange: PropTypes.func // 表单 |
| | | searches: PropTypes.any, // 搜索条件 |
| | | linefields: PropTypes.any, |
| | | scriptsChange: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | editItem: null, |
| | | systemScripts: [], |
| | | usefulfields: null, |
| | | loading: false, |
| | | verifySql: '' |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | this.resetfield(this.props.usefulfields) |
| | | this.resetfield(this.props.searches) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | if (nextProps.usefulfields && !is(fromJS(this.props.usefulfields), fromJS(nextProps.usefulfields))) { |
| | | this.resetfield(nextProps.usefulfields) |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | if (!is(fromJS(this.props.searches), fromJS(nextProps.searches))) { |
| | | this.resetfield(nextProps.searches) |
| | | } |
| | | } |
| | | |
| | | resetfield = (columns) => { |
| | | columns = columns.filter(item => item.Column !== '$Index') |
| | | let fields = columns.map(item => item.Column) |
| | | componentDidMount () { |
| | | this.getsysScript() |
| | | } |
| | | |
| | | let _sql = `Declare @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100),@ErrorCode nvarchar(50), @retmsg nvarchar(4000) |
| | | ` |
| | | getsysScript = () => { |
| | | if (sessionStorage.getItem('mk_sys_scripts')) { |
| | | this.setState({ |
| | | systemScripts: JSON.parse(sessionStorage.getItem('mk_sys_scripts')) |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort` |
| | | |
| | | _scriptSql = Utils.formatOptions(_scriptSql) |
| | | |
| | | let _sParam = { |
| | | func: 'sPC_Get_SelectedList', |
| | | LText: _scriptSql, |
| | | obj_name: 'data', |
| | | arr_field: 'funcname,longparam' |
| | | } |
| | | |
| | | _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp) |
| | | _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 云端数据验证 |
| | | |
| | | Api.getSystemConfig(_sParam).then(res => { |
| | | if (res.status) { |
| | | let _scripts = res.data.map(item => { |
| | | return { |
| | | name: item.funcname, |
| | | value: window.decodeURIComponent(window.atob(item.longparam)) |
| | | } |
| | | }) |
| | | |
| | | sessionStorage.setItem('mk_sys_scripts', JSON.stringify(_scripts)) |
| | | |
| | | this.setState({ |
| | | systemScripts: _scripts |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | resetfield = (searches) => { |
| | | let _usefulFields = [] |
| | | searches.forEach(item => { |
| | | if (!item.field) return |
| | | |
| | | if (item.type === 'group') { |
| | | _usefulFields.push(item.field) |
| | | _usefulFields.push(item.datefield) |
| | | _usefulFields.push(item.datefield + '1') |
| | | } else if (['dateweek', 'datemonth', 'daterange'].includes(item.type)) { |
| | | _usefulFields.push(item.field) |
| | | _usefulFields.push(item.field + '1') |
| | | } else if (item.type === 'date' && _usefulFields.includes(item.field)) { |
| | | _usefulFields.push(item.field + '1') |
| | | } else { |
| | | _usefulFields.push(item.field) |
| | | } |
| | | }) |
| | | |
| | | this.setState({ |
| | | verifySql: _sql, |
| | | usefulfields: fields.join(', ') |
| | | usefulfields: _usefulFields.join(', ') |
| | | }) |
| | | } |
| | | |
| | |
| | | return |
| | | } |
| | | |
| | | let tail = ` |
| | | aaa: |
| | | ` |
| | | |
| | | let _initCustomScript = '' // 初始化脚本 |
| | | let _prevCustomScript = '' // 默认sql前执行脚本 |
| | | let _backCustomScript = '' // 默认sql后执行脚本 |
| | | |
| | | this.props.scripts.forEach(item => { |
| | | if (item.status === 'false') return |
| | | |
| | | if (item.position === 'init') { |
| | | _initCustomScript += ` |
| | | /* 初始化脚本 */ |
| | | ${values.uuid === item.uuid ? values.sql : item.sql} |
| | | ` |
| | | } else if (item.position === 'front') { |
| | | _prevCustomScript += ` |
| | | /* 默认sql前脚本 */ |
| | | ${values.uuid === item.uuid ? values.sql : item.sql} |
| | | ` |
| | | } else { |
| | | _backCustomScript += ` |
| | | /* 默认sql后脚本 */ |
| | | ${values.uuid === item.uuid ? values.sql : item.sql} |
| | | ` |
| | | } |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | |
| | | if (!values.uuid) { |
| | | if (values.position === 'init') { |
| | | _initCustomScript += ` |
| | | /* 初始化脚本 */ |
| | | ${values.sql} |
| | | ` |
| | | } else if (values.position === 'front') { |
| | | _prevCustomScript += ` |
| | | /* 默认sql前脚本 */ |
| | | ${values.sql} |
| | | ` |
| | | } else { |
| | | _backCustomScript += ` |
| | | /* 默认sql后脚本 */ |
| | | ${values.sql} |
| | | ` |
| | | } |
| | | } |
| | | |
| | | let param = { |
| | | func: 's_debug_sql', |
| | | exec_type: 'y', |
| | | LText: this.state.verifySql + _initCustomScript + _prevCustomScript + _backCustomScript + tail |
| | | } |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${param.timestamp}'`) |
| | | param.LText = param.LText.replace(/\n/g, ' ') |
| | | |
| | | // 外联数据库替换 |
| | | if (window.GLOB.externalDatabase !== null) { |
| | | param.LText = param.LText.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | |
| | | this.setState({loading: true}) |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | this.props.scriptsChange(values, (status) => { |
| | | if (status) { |
| | | this.setState({ |
| | | loading: false, |
| | | editItem: null |
| | | }, () => { |
| | | this.props.scriptsChange(values) |
| | | }) |
| | | this.props.form.setFieldsValue({ |
| | | sql: '' |
| | | }) |
| | | } else { |
| | | this.setState({loading: false}) |
| | | |
| | | Modal.error({ |
| | | title: res.message |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | } |
| | | }) |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { systemScripts, sheet } = this.props |
| | | const { usefulfields } = this.state |
| | | const { sheet, linefields } = this.props |
| | | const { usefulfields, systemScripts } = this.state |
| | | const { getFieldDecorator } = this.props.form |
| | | const formItemLayout = { |
| | | labelCol: { |
| | |
| | | <Col span={24} className="sqlfield"> |
| | | <Form.Item label={'可用字段'}> |
| | | <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'公共值,请按照@xxx@格式使用。'}><span style={{color: '#1890ff'}}>BID, ID, LoginUID, SessionUid, UserID, Appkey, time_id</span></Tooltip>, |
| | | <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'系统变量,系统会定义变量并赋值。'}><span style={{color: '#fa8c16'}}>UserName, FullName, RoleID, mk_departmentcode, mk_organization, mk_user_type, mk_nation, mk_province, mk_city, mk_district, mk_address</span></Tooltip>, |
| | | {usefulfields} |
| | | <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'系统变量,系统会定义变量并赋值。'}><span style={{color: '#fa8c16'}}>UserName, FullName, RoleID, mk_departmentcode, mk_organization, mk_user_type, mk_nation, mk_province, mk_city, mk_district, mk_address</span></Tooltip> |
| | | {usefulfields ? <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'搜索条件,请按照@xxx@格式使用。'}>, {usefulfields}</Tooltip> : null} |
| | | {linefields ? <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'表单及行变量,系统会定义变量并赋值。'}>, {linefields}</Tooltip> : null} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={8} style={{whiteSpace: 'nowrap'}}> |
| | | {/* <Col span={8} style={{whiteSpace: 'nowrap'}}> |
| | | <Form.Item style={{marginBottom: 0}} label={ |
| | | <Tooltip placement="bottomLeft" title={'自定义脚本与默认sql位置关系。'}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={10}> |
| | | </Col> */} |
| | | <Col span={8}> |
| | | <Form.Item style={{marginBottom: 0}} label={'快捷添加'}> |
| | | <Select |
| | | showSearch |
| | |
| | | |
| | | class SettingForm extends Component { |
| | | static propTpyes = { |
| | | btnType: PropTypes.any, |
| | | setting: PropTypes.object, // 数据源配置 |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { setting } = this.props |
| | | const { setting, btnType } = this.props |
| | | |
| | | this.setState({ |
| | | dataType: setting.dataType, |
| | | dataType: btnType === 'print' ? 'custom' : setting.dataType, |
| | | defaultSql: setting.defaultSql || 'true' |
| | | }) |
| | | } |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { setting } = this.props |
| | | const { setting, btnType } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { dataType, defaultSql } = this.state |
| | | |
| | |
| | | <div className="excelout-datasource-wrap"> |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | | <Col span={8}> |
| | | {btnType !== 'print' ? <Col span={8}> |
| | | <Form.Item label="导出数据"> |
| | | {getFieldDecorator('dataType', { |
| | | initialValue: setting.dataType |
| | |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | </Col> : null} |
| | | {dataType === 'custom' ? <Col className="short-label" span={8}> |
| | | <Form.Item label="表名"> |
| | | {getFieldDecorator('tableName', { |
| | |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {dataType === 'custom' && defaultSql === 'true' ? <Col className="short-label" span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="排序方式为空时,使用表格或组件中的排序方式。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 排序方式 |
| | | </Tooltip> |
| | | }> |
| | | <Form.Item label="排序方式"> |
| | | {getFieldDecorator('order', { |
| | | initialValue: setting.order || '', |
| | | rules: [ |
| | |
| | | })(<Input placeholder={'ID asc, UID desc'} autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {dataType === 'custom' ? <Col span={8}> |
| | | {dataType === 'custom' && btnType !== 'print' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="不使用搜索条件时,不会进行搜索条件的拼接与相关统计字段的替换。注:自定义数据来源时,只使用内部搜索。"> |
| | | <Tooltip placement="topLeft" title="不使用搜索条件时,不会进行搜索条件的拼接与相关统计字段的替换。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 搜索条件 |
| | | </Tooltip> |
| | |
| | | state = { |
| | | verify: {}, |
| | | activeKey: 'setting', |
| | | systemScripts: [], |
| | | defaultscript: '', // 自定义脚本 |
| | | excelColumns: [ |
| | | { |
| | |
| | | searches: searches, |
| | | activeKey: card.intertype === 'system' && _verify.dataType === 'custom' ? 'setting' : 'columns', |
| | | defaultscript: defaultscript |
| | | }) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | this.getsysScript() |
| | | } |
| | | |
| | | getsysScript = () => { |
| | | if (sessionStorage.getItem('mk_sys_scripts')) { |
| | | this.setState({ |
| | | systemScripts: JSON.parse(sessionStorage.getItem('mk_sys_scripts')) |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort` |
| | | |
| | | _scriptSql = Utils.formatOptions(_scriptSql) |
| | | |
| | | let _sParam = { |
| | | func: 'sPC_Get_SelectedList', |
| | | LText: _scriptSql, |
| | | obj_name: 'data', |
| | | arr_field: 'funcname,longparam' |
| | | } |
| | | |
| | | _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp) |
| | | _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 云端数据验证 |
| | | |
| | | Api.getSystemConfig(_sParam).then(res => { |
| | | if (res.status) { |
| | | let _scripts = res.data.map(item => { |
| | | return { |
| | | name: item.funcname, |
| | | value: window.decodeURIComponent(window.atob(item.longparam)) |
| | | } |
| | | }) |
| | | |
| | | sessionStorage.setItem('mk_sys_scripts', JSON.stringify(_scripts)) |
| | | |
| | | this.setState({ |
| | | systemScripts: _scripts |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | scriptsChange = (values) => { |
| | | scriptsChange = (values, callback) => { |
| | | let verify = JSON.parse(JSON.stringify(this.state.verify)) |
| | | |
| | | if (values.uuid) { |
| | |
| | | loading: false, |
| | | verify: verify |
| | | }) |
| | | callback(true) |
| | | }, () => { // 验证失败 |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | callback(false) |
| | | }, verify.scripts) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | let timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | let sql = SettingUtils.getDebugSql(verify, scripts, searches, Utils, timestamp) |
| | | let sql = SettingUtils.getDebugSql(verify, scripts, (verify.useSearch === 'true' ? searches : []), Utils, timestamp) |
| | | let param = { |
| | | func: 's_debug_sql', |
| | | exec_type: 'y', |
| | |
| | | |
| | | render() { |
| | | const { card } = this.props |
| | | const { verify, excelColumns, defaultscript, scriptsColumns, activeKey, loading } = this.state |
| | | const { verify, excelColumns, defaultscript, scriptsColumns, activeKey, loading, searches } = this.state |
| | | const { getFieldDecorator } = this.props.form |
| | | const formItemLayout = { |
| | | labelCol: { |
| | |
| | | <CustomScript |
| | | btn={card} |
| | | sheet={verify.tableName} |
| | | usefulfields={verify.columns} |
| | | scripts={verify.scripts} |
| | | systemScripts={this.state.systemScripts} |
| | | searches={verify.useSearch === 'true' ? searches : []} |
| | | scriptsChange={this.scriptsChange} |
| | | wrappedComponentRef={(inst) => this.scriptsForm = inst} |
| | | /> |
| | |
| | | }) |
| | | arr_field = arr_field.join(',') |
| | | |
| | | if (!arr_field) { |
| | | arr_field = '*' |
| | | } |
| | | |
| | | let _customScript = '' |
| | | scripts && scripts.forEach(script => { |
| | | if (script.status === 'false') return |
| | |
| | | |
| | | if (verify.defaultSql === 'false') { |
| | | _dataresource = '' |
| | | } |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(item => { |
| | | let reg = new RegExp('\\$ex@' + item.func_code + '@ex\\$', 'ig') |
| | | _dataresource = _dataresource.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) |
| | | _customScript = _customScript.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | } |
| | | |
| | | _dataresource = _dataresource.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${timestamp}'`) |
| | |
| | | } |
| | | |
| | | // 数据源处理, 存在显示列时 |
| | | if (arr_field && _dataresource) { |
| | | if (_dataresource) { |
| | | if (/\s/.test(_dataresource)) { |
| | | _dataresource = '(' + _dataresource + ') tb' |
| | | } |
| | | |
| | | if (verify.order) { |
| | | _dataresource = `select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${verify.order}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` |
| | | _dataresource = `/*system_query*/select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${verify.order}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` |
| | | } else { |
| | | _dataresource = `select ${arr_field} from ${_dataresource} ${_search}` |
| | | _dataresource = `/*system_query*/select ${arr_field} from ${_dataresource} ${_search}` |
| | | } |
| | | } |
| | | |
| | |
| | | import React, {Component} from 'react' |
| | | import { fromJS } from 'immutable' |
| | | import { Table, Input, Popconfirm, Form } from 'antd' |
| | | import { ArrowUpOutlined, ArrowDownOutlined, PlusOutlined, DeleteOutlined } from '@ant-design/icons' |
| | | import Utils from '@/utils/utils.js' |
| | |
| | | this.setState({ |
| | | dataSource: _data |
| | | }) |
| | | |
| | | this.props.onChange(fromJS(_data).toJS()) |
| | | } |
| | | |
| | | handleDelete = key => { |
| | | const dataSource = [...this.state.dataSource] |
| | | this.setState({ dataSource: dataSource.filter(item => item.key !== key) }) |
| | | const dataSource = [...this.state.dataSource].filter(item => item.key !== key) |
| | | this.setState({ dataSource: dataSource }) |
| | | this.props.onChange(fromJS(dataSource).toJS()) |
| | | } |
| | | |
| | | handleAdd = () => { |
| | |
| | | Value: `${count}`, |
| | | Text: `${count}` |
| | | } |
| | | let list = [...dataSource, newData] |
| | | |
| | | this.setState({ |
| | | dataSource: [...dataSource, newData], |
| | | dataSource: list, |
| | | count: count + 1 |
| | | }) |
| | | this.props.onChange(fromJS(list).toJS()) |
| | | } |
| | | |
| | | handleSave = row => { |
| | |
| | | ...row |
| | | }) |
| | | this.setState({ dataSource: newData }) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps () { |
| | | |
| | | this.props.onChange(fromJS(newData).toJS()) |
| | | } |
| | | |
| | | render() { |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Tabs, Row, Col, Button, notification, Modal, message, InputNumber, Input, Select, Radio, Tooltip } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Tabs, Row, Col, Button, notification, Modal, message, InputNumber, Input, Select, Radio, Tooltip, Typography, Popconfirm, Spin } from 'antd' |
| | | import { QuestionCircleOutlined, EditOutlined, StopOutlined, CheckCircleOutlined, SwapOutlined, DeleteOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import SettingUtils from './utils.jsx' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import DataSource from '../verifyexcelout/datasource' |
| | | import CustomScript from '../verifyexcelout/customscript' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import ColForm from '@/menu/datasource/verifycard/columnform' |
| | | import EditTable from './editable' |
| | | |
| | | import './index.scss' |
| | | |
| | | const EditMTable = asyncComponent(() => import('@/templates/zshare/editTable')) |
| | | const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent')) |
| | | const { Paragraph } = Typography |
| | | const { TabPane } = Tabs |
| | | |
| | | class VerifyCard extends Component { |
| | |
| | | state = { |
| | | verify: {}, |
| | | templates: [], |
| | | loading: false, |
| | | activeKey: 'base', |
| | | selectimg: '', |
| | | printMode: 'normal' |
| | | dataType: 'line', |
| | | printMode: 'normal', |
| | | usefulfields: '', |
| | | declareSql: '', |
| | | scriptsColumns: [ |
| | | { |
| | | title: 'SQL', |
| | | dataIndex: 'sql', |
| | | width: '60%', |
| | | render: (text) => { |
| | | let title = text.match(/^\s*\/\*.+\*\//) |
| | | title = title && title[0] ? title[0] : '' |
| | | let _text = title ? text.replace(title, '') : text |
| | | |
| | | return ( |
| | | <div> |
| | | {title ? <span style={{color: '#a50'}}>{title}<span style={{fontSize: '12px', marginLeft: '5px'}}>{_text.length}</span></span> : null} |
| | | <Paragraph copyable={{ text: text }} ellipsis={{ rows: 4, expandable: true }}>{_text}</Paragraph> |
| | | </div> |
| | | ) |
| | | } |
| | | }, |
| | | { |
| | | title: '执行位置', |
| | | dataIndex: 'position', |
| | | width: '10%', |
| | | render: (text, record) => { |
| | | if (record.position === 'init') { |
| | | return <span style={{color: 'orange'}}>初始化</span> |
| | | } else if (record.position === 'front') { |
| | | return <span style={{color: '#26C281'}}>sql前</span> |
| | | } else { |
| | | return <span style={{color: '#1890ff'}}>sql后</span> |
| | | } |
| | | } |
| | | }, |
| | | { |
| | | title: '状态', |
| | | dataIndex: 'status', |
| | | width: '10%', |
| | | render: (text, record) => record.status === 'false' ? |
| | | ( |
| | | <div style={{color: '#ff4d4f'}}> |
| | | 禁用 |
| | | <StopOutlined style={{marginLeft: '5px'}} /> |
| | | </div> |
| | | ) : |
| | | ( |
| | | <div style={{color: '#26C281'}}> |
| | | 启用 |
| | | <CheckCircleOutlined style={{marginLeft: '5px'}}/> |
| | | </div> |
| | | ) |
| | | }, |
| | | { |
| | | title: '操作', |
| | | align: 'center', |
| | | width: '140px', |
| | | dataIndex: 'operation', |
| | | render: (text, record) => |
| | | (<div style={{textAlign: 'center'}}> |
| | | <span className="operation-btn" title="编辑" onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><EditOutlined /></span> |
| | | <span className="operation-btn" title="状态切换" onClick={() => this.handleStatus(record, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span> |
| | | <Popconfirm |
| | | overlayClassName="popover-confirm" |
| | | title="确定删除吗?" |
| | | onConfirm={() => this.handleDelete(record, 'scripts') |
| | | }> |
| | | <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span> |
| | | </Popconfirm> |
| | | </div>) |
| | | } |
| | | ], |
| | | colColumns: [ |
| | | { |
| | | title: '名称', |
| | | dataIndex: 'label', |
| | | inputType: 'input', |
| | | editable: true, |
| | | width: '28%' |
| | | }, |
| | | { |
| | | title: '字段', |
| | | dataIndex: 'field', |
| | | inputType: 'input', |
| | | editable: true, |
| | | unique: true, |
| | | copy: true, |
| | | rules: [{ |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_' |
| | | }], |
| | | width: '28%' |
| | | }, |
| | | { |
| | | title: '数据类型', |
| | | dataIndex: 'datatype', |
| | | inputType: 'select', |
| | | options: [ |
| | | { value: 'Nvarchar(10)', text: 'Nvarchar(10)' }, |
| | | { value: 'Nvarchar(20)', text: 'Nvarchar(20)' }, |
| | | { value: 'Nvarchar(50)', text: 'Nvarchar(50)' }, |
| | | { value: 'Nvarchar(100)', text: 'Nvarchar(100)' }, |
| | | { value: 'Nvarchar(256)', text: 'Nvarchar(256)' }, |
| | | { value: 'Nvarchar(512)', text: 'Nvarchar(512)' }, |
| | | { value: 'Nvarchar(1024)', text: 'Nvarchar(1024)' }, |
| | | { value: 'Nvarchar(2048)', text: 'Nvarchar(2048)' }, |
| | | { value: 'Nvarchar(max)', text: 'Nvarchar(max)' }, |
| | | { value: 'Int', text: 'Int' }, |
| | | { value: 'Decimal(18,0)', text: 'Decimal(18,0)' }, |
| | | { value: 'Decimal(18,1)', text: 'Decimal(18,1)' }, |
| | | { value: 'Decimal(18,2)', text: 'Decimal(18,2)' }, |
| | | { value: 'Decimal(18,3)', text: 'Decimal(18,3)' }, |
| | | { value: 'Decimal(18,4)', text: 'Decimal(18,4)' }, |
| | | { value: 'Decimal(18,5)', text: 'Decimal(18,5)' }, |
| | | { value: 'Decimal(18,6)', text: 'Decimal(18,6)' }, |
| | | { value: 'Decimal(18,7)', text: 'Decimal(18,7)' }, |
| | | { value: 'Decimal(18,8)', text: 'Decimal(18,8)' }, |
| | | { value: 'Decimal(18,9)', text: 'Decimal(18,9)' }, |
| | | { value: 'Decimal(18,10)', text: 'Decimal(18,10)' }, |
| | | { value: 'Decimal(18,11)', text: 'Decimal(18,11)' }, |
| | | { value: 'Decimal(18,12)', text: 'Decimal(18,12)' }, |
| | | { value: 'Decimal(18,13)', text: 'Decimal(18,13)' }, |
| | | { value: 'Decimal(18,14)', text: 'Decimal(18,14)' }, |
| | | { value: 'Decimal(18,15)', text: 'Decimal(18,15)' }, |
| | | { value: 'Decimal(18,16)', text: 'Decimal(18,16)' }, |
| | | { value: 'Decimal(18,17)', text: 'Decimal(18,17)' }, |
| | | { value: 'Decimal(18,18)', text: 'Decimal(18,18)' }, |
| | | { value: 'date', text: 'date' }, |
| | | { value: 'datetime', text: 'datetime' }, |
| | | ], |
| | | editable: true, |
| | | width: '25%', |
| | | } |
| | | ] |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | let _verify = this.props.card.verify || {} |
| | | const { columns, card } = this.props |
| | | let _verify = fromJS(card.verify || {}).toJS() |
| | | |
| | | _verify.Template = _verify.Template || '' |
| | | _verify.printerTypeList = _verify.printerTypeList || [] |
| | | _verify.linkType = _verify.linkType || 'system' |
| | | _verify.printMode = _verify.printMode || 'normal' |
| | | _verify.scripts = _verify.scripts || [] |
| | | _verify.columns = _verify.columns || [] |
| | | |
| | | let _usefulfields = [] |
| | | let _declare = [] |
| | | let _select = [] |
| | | let fieldArr = [] |
| | | |
| | | let _sql = '' |
| | | |
| | | if (card.execMode === 'pop' && card.modal && card.modal.fields) { |
| | | card.modal.fields.forEach(_f => { |
| | | if (!_f.field || fieldArr.includes(_f.field.toLowerCase())) return |
| | | |
| | | fieldArr.push(_f.field.toLowerCase()) |
| | | |
| | | _usefulfields.push(_f.field) |
| | | |
| | | let _fieldlen = _f.fieldlength || 50 |
| | | |
| | | if (_f.type === 'number') { |
| | | _fieldlen = _f.decimal ? _f.decimal : 0 |
| | | } |
| | | |
| | | if (_fieldlen > 2048) { |
| | | _fieldlen = 'max' |
| | | } |
| | | |
| | | let _type = `nvarchar(${_fieldlen})` |
| | | |
| | | if (_f.type.match(/date/ig)) { |
| | | _type = 'datetime' |
| | | _select.push(`@${_f.field}='1949-10-01'`) |
| | | } else if (_f.type === 'number') { |
| | | _type = `decimal(18,${_fieldlen})` |
| | | _select.push(`@${_f.field}=0`) |
| | | } else if (_f.type === 'rate') { |
| | | _type = `decimal(18,2)` |
| | | _select.push(`@${_f.field}=0`) |
| | | } else { |
| | | _select.push(`@${_f.field}=''`) |
| | | } |
| | | |
| | | _declare.push(`@${_f.field} ${_type}`) |
| | | }) |
| | | |
| | | if (_declare.length > 0) { |
| | | _sql = `/* 表单变量 */ |
| | | Declare ${_declare.join(', ')} |
| | | Select ${_select.join(', ')} |
| | | ` |
| | | } |
| | | _declare = [] |
| | | _select = [] |
| | | } |
| | | |
| | | if (columns && columns.length > 0 && card.Ot !== 'notRequired') { |
| | | columns.forEach(_f => { |
| | | if (!_f.field || fieldArr.includes(_f.field.toLowerCase()) || !_f.datatype) return |
| | | |
| | | fieldArr.push(_f.field.toLowerCase()) |
| | | _usefulfields.push(_f.field) |
| | | |
| | | if (/decimal/ig.test(_f.datatype)) { |
| | | _select.push(`@${_f.field}=0`) |
| | | } else { |
| | | _select.push(`@${_f.field}=''`) |
| | | } |
| | | |
| | | _declare.push(`@${_f.field} ${_f.datatype}`) |
| | | }) |
| | | |
| | | if (_declare.length > 0) { |
| | | _sql += `/* 显示列变量 */ |
| | | Declare ${_declare.join(', ')} |
| | | Select ${_select.join(', ')} |
| | | ` |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | verify: _verify, |
| | | declareSql: _sql, |
| | | usefulfields: _usefulfields.join(', '), |
| | | dataType: _verify.dataType || 'line', |
| | | linkType: _verify.linkType, |
| | | printMode: _verify.printMode, |
| | | printFunc: _verify.printFunc || '// Function(data, form, printer, notification) data-打印数据列表,form-表单信息(不存在时为{}),printer-打印设置,notification-信息提示控件' |
| | |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | | const { verify } = this.state |
| | | const { verify, activeKey } = this.state |
| | | // 表单提交时检查输入值是否正确 |
| | | return new Promise((resolve, reject) => { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | let _verify = {...verify, ...values} |
| | | |
| | | if (this.refs.editTable && this.refs.editTable.state) { |
| | | let printTypes = this.refs.editTable.state.dataSource |
| | | if (activeKey === 'base') { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (err) return |
| | | |
| | | let emptys = printTypes.filter(item => !item.Value || !item.Text) |
| | | let valMap = new Map() |
| | | let isvalid = true |
| | | resolve({...verify, ...values}) |
| | | }) |
| | | } else if (activeKey === 'print') { |
| | | if (verify.printerTypeList.length > 0) { |
| | | let printTypes = verify.printerTypeList.map(item => item.Value) |
| | | printTypes = Array.from(new Set(printTypes)) |
| | | |
| | | printTypes.forEach(item => { |
| | | if (valMap.has(item.Value)) { |
| | | isvalid = false |
| | | } else { |
| | | valMap.set(item.Value, item.Text) |
| | | } |
| | | if (verify.printerTypeList.length > printTypes.length) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '打印类型中Value字段不可重复!', |
| | | duration: 5 |
| | | }) |
| | | |
| | | if (emptys.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '打印类型表格中Value、Text字段不可为空!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (!isvalid) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '打印类型表格中Value字段不可重复!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | _verify.printerTypeList = printTypes |
| | | return |
| | | } |
| | | |
| | | resolve(_verify) |
| | | } else { |
| | | } |
| | | resolve(verify) |
| | | } else if (activeKey === 'setting') { |
| | | this.settingForm.handleConfirm().then(res => { |
| | | let _verify = {...verify, setting: res} |
| | | this.setState({ |
| | | verify: _verify |
| | | }, () => { |
| | | this.setState({loading: true}) |
| | | this.sqlverify(() => { // 验证成功 |
| | | resolve(_verify) |
| | | }, () => { // 验证失败 |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | }, _verify.scripts) |
| | | }) |
| | | }) |
| | | } else if (activeKey === 'scripts') { |
| | | if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '链接地址与打印模板不可为空!', |
| | | message: '存在未保存脚本,请点击确定保存,或点击取消放弃修改!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | }) |
| | | |
| | | this.setState({loading: true}) |
| | | this.sqlverify(() => { // 验证成功 |
| | | resolve(verify) |
| | | }, () => { // 验证失败 |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | }, verify.scripts) |
| | | } else { |
| | | resolve(verify) |
| | | } |
| | | }) |
| | | } |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | changeDataType = (e) => { |
| | | let value = e.target.value |
| | | |
| | | this.setState({ |
| | | dataType: value |
| | | }) |
| | | } |
| | | |
| | | // 标签切换 |
| | | tabchange = (val) => { |
| | | const { activeKey, verify } = this.state |
| | | |
| | | if (activeKey === 'base') { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (err) return |
| | | |
| | | this.setState({ |
| | | verify: {...verify, ...values}, |
| | | activeKey: val |
| | | }) |
| | | }) |
| | | } else if (activeKey === 'print') { |
| | | if (verify.printerTypeList.length > 0) { |
| | | let printTypes = verify.printerTypeList.map(item => item.Value) |
| | | printTypes = Array.from(new Set(printTypes)) |
| | | |
| | | if (verify.printerTypeList.length > printTypes.length) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '打印类型中Value字段不可重复!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | } |
| | | this.setState({ |
| | | activeKey: val |
| | | }) |
| | | } else if (activeKey === 'setting') { |
| | | this.settingForm.handleConfirm().then(res => { |
| | | this.setState({ |
| | | verify: {...verify, setting: res} |
| | | }, () => { |
| | | this.setState({loading: true}) |
| | | this.sqlverify(() => { // 验证成功 |
| | | this.setState({ |
| | | activeKey: val, |
| | | loading: false |
| | | }) |
| | | }, () => { // 验证失败 |
| | | this.setState({ |
| | | activeKey: val, |
| | | loading: false |
| | | }) |
| | | }, verify.scripts) |
| | | }) |
| | | }) |
| | | } else if (activeKey === 'scripts') { |
| | | if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '存在未保存脚本,请点击确定保存,或点击取消放弃修改!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.setState({loading: true}) |
| | | this.sqlverify(() => { // 验证成功 |
| | | this.setState({ |
| | | activeKey: val, |
| | | loading: false |
| | | }) |
| | | }, () => { // 验证失败 |
| | | this.setState({ |
| | | activeKey: val, |
| | | loading: false |
| | | }) |
| | | }, verify.scripts) |
| | | } else { |
| | | this.setState({ |
| | | activeKey: val |
| | | }) |
| | | } |
| | | } |
| | | |
| | | scriptsChange = (values, callback) => { |
| | | let verify = JSON.parse(JSON.stringify(this.state.verify)) |
| | | |
| | | if (values.uuid) { |
| | | verify.scripts = verify.scripts.map(item => { |
| | | if (item.uuid === values.uuid) { |
| | | return values |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | } else { |
| | | values.uuid = Utils.getuuid() |
| | | verify.scripts.push(values) |
| | | } |
| | | |
| | | this.setState({loading: true}) |
| | | |
| | | this.sqlverify(() => { // 验证成功 |
| | | this.setState({ |
| | | loading: false, |
| | | verify: verify |
| | | }) |
| | | callback(true) |
| | | }, () => { // 验证失败 |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | callback(false) |
| | | }, verify.scripts) |
| | | } |
| | | |
| | | sqlverify = (_resolve, _reject, scripts) => { |
| | | const { verify, declareSql } = this.state |
| | | |
| | | let timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | let sql = SettingUtils.getDebugSql(verify.setting || {}, verify.columns, scripts, declareSql, timestamp) |
| | | let param = { |
| | | func: 's_debug_sql', |
| | | exec_type: 'y', |
| | | LText: sql |
| | | } |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.timestamp = timestamp |
| | | param.secretkey = Utils.encrypt('', timestamp) |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | _resolve() |
| | | } else { |
| | | _reject() |
| | | Modal.error({ |
| | | title: result.message |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | columnChange = (values, resolve) => { |
| | | let verify = fromJS(this.state.verify).toJS() |
| | | |
| | | let fields = verify.columns.map(item => item.field.toLowerCase()) |
| | | if (fields.includes(values.field.toLowerCase())) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '字段已存在!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | resolve() |
| | | |
| | | values.uuid = Utils.getuuid() |
| | | verify.columns.push(values) |
| | | |
| | | this.setState({verify}) |
| | | } |
| | | |
| | | updatefields = (columns) => { |
| | | let verify = fromJS(this.state.verify).toJS() |
| | | verify.columns = columns |
| | | |
| | | this.setState({verify}) |
| | | } |
| | | |
| | | render() { |
| | | const { card } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { verify, linkType, printMode, printFunc } = this.state |
| | | const { verify, linkType, printMode, printFunc, scriptsColumns, dataType, loading, activeKey, usefulfields, colColumns } = this.state |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | |
| | | } |
| | | |
| | | return ( |
| | | <div> |
| | | <div className="verify-card-print-box"> |
| | | {card.label ? <div className="mk-com-name">{card.label} - 验证信息</div> : null} |
| | | <Tabs defaultActiveKey="1" className="verify-card-print-box" onChange={this.tabchange}> |
| | | <TabPane tab="打印验证" key="1"> |
| | | {loading && <Spin size="large" />} |
| | | <Tabs activeKey={activeKey} onChange={this.tabchange}> |
| | | <TabPane tab="打印验证" key="base"> |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | | <Col span={8}> |
| | |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col>} |
| | | {card.intertype === 'system' ? <Col span={8}> |
| | | <Form.Item label="数据类型"> |
| | | {getFieldDecorator('dataType', { |
| | | initialValue: dataType || 'line' |
| | | })( |
| | | <Radio.Group onChange={this.changeDataType}> |
| | | <Radio value="line">行数据</Radio> |
| | | <Radio value="custom">自定义</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {printMode === 'custom' ? <Col span={24}> |
| | | <Form.Item label={'处理函数'} className="printFunc"> |
| | | {getFieldDecorator('printFunc', { |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {printMode !== 'custom' ? <Col span={8} offset={printMode === 'RFID' ? 16 : 0}> |
| | | {printMode !== 'custom' ? <Col span={8} offset={16}> |
| | | <img className="legend" src={this.state.selectimg} alt=""/> |
| | | </Col> : null } |
| | | </Row> |
| | |
| | | 打印类型 |
| | | {verify.printerTypeList.length ? <span className="count-tip">{verify.printerTypeList.length}</span> : null} |
| | | </span> |
| | | } disabled={printMode === 'RFID'} key="2"> |
| | | } disabled={printMode === 'RFID'} key="print"> |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | | <Col span={24} className="print-tip"> |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24}> |
| | | <EditTable data={verify.printerTypeList} ref="editTable"/> |
| | | <EditTable data={verify.printerTypeList} onChange={(list) => this.setState({verify: {...verify, printerTypeList: list}})}/> |
| | | </Col> |
| | | </Row> |
| | | </Form> |
| | | </TabPane> |
| | | <TabPane tab="信息提示" key="7"> |
| | | {card.intertype === 'system' ? <TabPane tab="数据源" disabled={dataType !== 'custom'} key="setting"> |
| | | <DataSource setting={verify.setting || {}} btnType="print" wrappedComponentRef={(inst) => this.settingForm = inst}/> |
| | | </TabPane> : null} |
| | | {card.intertype === 'system' ? <TabPane tab={ |
| | | <span> |
| | | 字段集 |
| | | {verify.columns.length ? <span className="count-tip">{verify.columns.length}</span> : null} |
| | | </span> |
| | | } key="columns"> |
| | | <ColForm columnChange={this.columnChange}/> |
| | | <FieldsComponent |
| | | config={verify} |
| | | type="fields" |
| | | updatefield={this.updatefields} |
| | | /> |
| | | <EditMTable actions={['edit', 'move', 'copy', 'del', 'clear']} type="datasourcefield" data={verify.columns} columns={colColumns} onChange={(columns) => this.setState({verify: {...verify, columns}})}/> |
| | | </TabPane> : null} |
| | | {card.intertype === 'system' ? <TabPane tab={ |
| | | <span> |
| | | 自定义脚本 |
| | | {verify.scripts.length ? <span className="count-tip">{verify.scripts.length}</span> : null} |
| | | </span> |
| | | } key="scripts" disabled={dataType !== 'custom'} id="mk-exout-script"> |
| | | <CustomScript |
| | | btn={card} |
| | | sheet={verify.setting ? verify.setting.tableName : ''} |
| | | searches={[]} |
| | | linefields={usefulfields} |
| | | scriptsChange={this.scriptsChange} |
| | | wrappedComponentRef={(inst) => this.scriptsForm = inst} |
| | | /> |
| | | <EditMTable actions={['move']} data={verify.scripts} columns={scriptsColumns} onChange={(scripts) => {this.setState({verify: {...verify, scripts}})}}/> |
| | | </TabPane> : null} |
| | | <TabPane tab="信息提示" key="message"> |
| | | <div style={{textAlign: 'center', fontSize: '13px', marginBottom: '10px'}}>打印信息中如果存在网络资源(图片),请确保资源可以正常访问,资源不存在时会报数据异常。</div> |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | |
| | | .verify-card-print-box { |
| | | position: relative; |
| | | .ant-tabs-nav-scroll { |
| | | text-align: center; |
| | | } |
| | |
| | | color: #1890ff; |
| | | font-size: 12px; |
| | | } |
| | | .verify-form { |
| | | .sql { |
| | | .ant-col-sm-8 { |
| | | width: 10.5%; |
| | | } |
| | | .ant-col-sm-16 { |
| | | width: 89.5%; |
| | | padding-top: 4px; |
| | | } |
| | | .CodeMirror { |
| | | height: 350px; |
| | | } |
| | | } |
| | | .sqlfield { |
| | | .ant-form-item { |
| | | margin-bottom: 5px; |
| | | } |
| | | .ant-form-item-control { |
| | | line-height: 24px; |
| | | } |
| | | .ant-form-item-label { |
| | | line-height: 25px; |
| | | } |
| | | .ant-form-item-children { |
| | | line-height: 22px; |
| | | } |
| | | .ant-col-sm-8 { |
| | | width: 10.5%; |
| | | } |
| | | .ant-col-sm-16 { |
| | | width: 89.5%; |
| | | } |
| | | } |
| | | .add { |
| | | padding-top: 4px; |
| | | } |
| | | } |
| | | .ant-spin { |
| | | position: absolute; |
| | | top: calc(50% - 16px); |
| | | left: calc(50% - 16px); |
| | | z-index: 1; |
| | | } |
| | | .quickly-add { |
| | | position: absolute; |
| | | width: 100px; |
| | | right: 24px; |
| | | top: 5px; |
| | | z-index: 2; |
| | | } |
| | | } |
| | | .print-template-setting { |
| | | .ant-select-dropdown-menu-item { |
New file |
| | |
| | | |
| | | export default class SettingUtils { |
| | | static getDebugSql (setting, columns, scripts, declareSql, timestamp) { |
| | | let sql = '' |
| | | let _dataresource = setting.dataresource || '' |
| | | |
| | | let _customScript = '' |
| | | scripts && scripts.forEach(script => { |
| | | if (script.status === 'false') return |
| | | _customScript += ` |
| | | ${script.sql} |
| | | ` |
| | | }) |
| | | |
| | | if (_customScript) { |
| | | _customScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) select @ErrorCode='',@retmsg ='' |
| | | ${declareSql} |
| | | ${_customScript} |
| | | ` |
| | | } |
| | | |
| | | if (setting.defaultSql === 'false') { |
| | | _dataresource = '' |
| | | } |
| | | |
| | | _dataresource = _dataresource.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${timestamp}'`) |
| | | _customScript = _customScript.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${timestamp}'`) |
| | | _dataresource = _dataresource.replace(/@\$|\$@/ig, '') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '') |
| | | |
| | | // 外联数据库替换 |
| | | if (window.GLOB.externalDatabase !== null) { |
| | | _dataresource = _dataresource.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | _customScript = _customScript.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | } |
| | | |
| | | let arr_field = columns.map(col => col.field) |
| | | arr_field = arr_field.join(',') |
| | | |
| | | if (!arr_field) { |
| | | arr_field = '*' |
| | | } |
| | | |
| | | // 数据源处理, 存在显示列时 |
| | | if (_dataresource) { |
| | | if (/\s/.test(_dataresource)) { |
| | | _dataresource = '(' + _dataresource + ') tb' |
| | | } |
| | | |
| | | if (setting.order) { |
| | | _dataresource = `/*system_query*/select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${setting.order}) as rows from ${_dataresource}) tmptable order by tmptable.rows` |
| | | } else { |
| | | _dataresource = `/*system_query*/select ${arr_field} from ${_dataresource}` |
| | | } |
| | | } |
| | | |
| | | if (_customScript) { |
| | | sql = `/* sql 验证 */ |
| | | ${_customScript} |
| | | ${_dataresource} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ |
| | | ` |
| | | } else { |
| | | sql = `/* sql 验证 */ |
| | | declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) select @ErrorCode='',@retmsg ='' |
| | | ${declareSql} |
| | | ${_dataresource}` |
| | | } |
| | | sql = sql.replace(/\n\s{8}/ig, '\n') |
| | | console.info(sql) |
| | | sql = sql.replace(/\n/g, ' ') |
| | | |
| | | return sql |
| | | } |
| | | } |
| | |
| | | _fields.push(...group.sublist) |
| | | }) |
| | | resolve(_fields) |
| | | } else if (card.modal) { |
| | | } else if (card.modal && card.OpenType === 'pop') { |
| | | _fields = card.modal.fields || [] |
| | | resolve(_fields) |
| | | } else if (card.OpenType === 'pop') { |
| | |
| | | if (cell.eleType !== 'button') return |
| | | if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) { |
| | | action.push(cell) |
| | | } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { |
| | | action.push(cell) |
| | | } else if (cell.OpenType === 'popview') { |
| | | if (pops) { |
| | | pops.push({...cell, parentId: config.uuid}) |
| | |
| | | item.backElements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) { |
| | | action.push(cell) |
| | | } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { |
| | | action.push(cell) |
| | | } else if (cell.OpenType === 'popview') { |
| | | if (pops) { |
| | |
| | | col.elements.forEach(cell => { |
| | | if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) { |
| | | action.push(cell) |
| | | } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { |
| | | action.push(cell) |
| | | } else if (cell.OpenType === 'popview') { |
| | | if (pops) { |
| | | pops.push({...cell, parentId: config.uuid}) |
| | |
| | | if (cell.eleType !== 'button') return |
| | | if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) { |
| | | action.push(cell) |
| | | } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { |
| | | action.push(cell) |
| | | } else if (cell.OpenType === 'popview') { |
| | | if (pops) { |
| | | pops.push({...cell, parentId: config.uuid}) |
| | |
| | | |
| | | config.action && config.action.forEach(cell => { |
| | | if (['pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) { |
| | | action.push(cell) |
| | | } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { |
| | | action.push(cell) |
| | | } else if (cell.OpenType === 'popview') { |
| | | if (pops) { |
| | |
| | | tbs && cuts.push(...tbs) |
| | | }) |
| | | } |
| | | } else if (btn.OpenType === 'funcbutton') { |
| | | if (btn.intertype !== 'system' || !btn.verify || !btn.verify.setting) return |
| | | if (btn.verify.dataType === 'custom') { |
| | | if (btn.verify.setting.defaultSql !== 'false') { |
| | | let tbs = btn.verify.setting.dataresource.match(cutreg) |
| | | tbs && cuts.push(...tbs) |
| | | } |
| | | btn.verify.scripts && btn.verify.scripts.forEach(script => { |
| | | if (script.status === 'false') return |
| | | let tbs = script.sql.match(cutreg) |
| | | tbs && cuts.push(...tbs) |
| | | }) |
| | | } |
| | | } else if (btn.OpenType === 'excelOut') { |
| | | if (btn.intertype !== 'system' || !btn.verify) return |
| | | if (btn.verify.dataType === 'custom') { |