| | |
| | | import React, { Component } from 'react' |
| | | import { Input, Button, message } from 'antd' |
| | | |
| | | import sqlFormatter from '@/utils/sqlFormatter.js' |
| | | import Utils from '@/utils/utils.js' |
| | | |
| | | import './index.scss' |
| | |
| | | cell.dataSource = `select * from @db@${cell.dataSource}` |
| | | |
| | | if (item.WhereField) { |
| | | cell.dataSource += ' where ' + item.WhereField.replace(/^\s*\(|\)\s*$/g, '') |
| | | if (/\(/.test(item.WhereField) && item.WhereField.match(/\(/g).length === 1) { |
| | | cell.dataSource += ' where ' + item.WhereField.replace(/^\s*\(|\)\s*$/g, '') |
| | | } else { |
| | | cell.dataSource += ' where ' + item.WhereField |
| | | } |
| | | } |
| | | } |
| | | |
| | | cell.dataSource = cell.dataSource.replace(/@userid[^0-9a-z_@]/ig, (w) => w.replace(/@UserID/i, '@UserID@')) |
| | | cell.dataSource = this.sqltrans(cell.dataSource) |
| | | |
| | | if (item.multiple === 'true') { |
| | | cell.type = 'multiselect' |
| | |
| | | tb = 'select * from @db@' + data.QueryFrom |
| | | } |
| | | if (tb && data.AppendWhere) { |
| | | tb += ` where ${data.AppendWhere.replace(/^\s*\(|\)\s*$/g, '')}` |
| | | if (/\(/.test(data.AppendWhere) && data.AppendWhere.match(/\(/g).length === 1) { |
| | | tb += ` where ${data.AppendWhere.replace(/^\s*\(|\)\s*$/g, '')}` |
| | | } else { |
| | | tb += ` where ${data.AppendWhere}` |
| | | } |
| | | } |
| | | |
| | | tb = tb.replace(/@ID[^0-9a-z_@]/ig, (w) => w.replace(/@ID/i, '@ID@')) |
| | | tb = tb.replace(/@BID[^0-9a-z_@]/ig, (w) => w.replace(/@BID/i, '@BID@')) |
| | | tb = tb.replace(/@userid[^0-9a-z_@]/ig, (w) => w.replace(/@UserID/i, '@UserID@')) |
| | | |
| | | tb = tb.replace(/@ID@\s+nvarchar\(/ig, '@ID nvarchar(') |
| | | tb = tb.replace(/@BID@\s+nvarchar\(/ig, '@BID nvarchar(') |
| | | tb = tb.replace(/@userid@\s+nvarchar\(/ig, '@UserID nvarchar(') |
| | | tb = this.sqltrans(tb) |
| | | |
| | | result = { |
| | | tableName: '@db@' + data.TableName, |
| | |
| | | } else if (['remark', 'address'].includes(cell.field)) { |
| | | cell.datatype = 'Nvarchar(256)' |
| | | } |
| | | } else if (item.Type === 'image') { |
| | | cell.datatype = 'Nvarchar(256)' |
| | | } else if (item.Type === 'number') { |
| | | cell.datatype = 'Int' |
| | | } |
| | |
| | | |
| | | if (item.Type === 'text') { |
| | | cell.textFormat = 'none' |
| | | } else if (item.Type === 'image') { |
| | | cell.type = 'picture' |
| | | cell.span = 24 |
| | | cell.lenWidRadio = '1:1' |
| | | cell.backgroundSize = 'cover' |
| | | cell.scale = 'true' |
| | | cell.lostTip = 'true' |
| | | } else if (item.Type === 'number') { |
| | | cell.type = 'number' |
| | | cell.Width = 80 |
| | |
| | | uuid: Utils.getuuid(), |
| | | label: item.Label, |
| | | field: item.FieldName.toLowerCase(), |
| | | initval: item.DefaultVal || '', |
| | | initval: item.InitVal || '', |
| | | type: 'text', |
| | | span: 12, |
| | | labelwidth: 33.3, |
| | |
| | | cell.readonly = 'true' |
| | | } |
| | | |
| | | if (item.Validate && /required:\s?true/.test(item.Validate)) { |
| | | cell.required = 'true' |
| | | } else { |
| | | cell.required = 'false' |
| | | } |
| | | |
| | | if (item.InputType === 'text') { |
| | | if (item.Validate && /required:\s?true/.test(item.Validate)) { |
| | | cell.required = 'true' |
| | | } else { |
| | | cell.required = 'false' |
| | | } |
| | | |
| | | } else if (item.InputType === 'textarea') { |
| | | cell.type = 'textarea' |
| | | cell.fieldlength = 8000 |
| | | cell.maxRows = 6 |
| | | cell.span = 24 |
| | | cell.labelwidth = 16.2 |
| | | } else if (item.InputType === 'date') { |
| | | cell.type = 'date' |
| | | cell.initval = '' |
| | | cell.precision = 'day' |
| | | cell.declareType = 'datetime' |
| | | } else if (item.InputType === 'hidden') { |
| | | cell.type = 'text' |
| | | cell.hidden = 'true' |
| | | } else if (item.InputType === 'image') { |
| | | cell.type = 'fileupload' |
| | | cell.fieldlength = 512 |
| | | cell.fileType = 'text' |
| | | cell.compress = 'false' |
| | | } else if (item.InputType === 'spinner') { |
| | | cell.type = 'number' |
| | | cell.required = 'true' |
| | | cell.initval = cell.initval ? +cell.initval : '' |
| | | cell.decimal = 0 |
| | | cell.min = item.MinValue ? +item.MinValue : '' |
| | | cell.max = item.MAXValue ? +item.MAXValue : '' |
| | | } else if (item.InputType === 'select') { |
| | | if (item.Validate && /required:\s?true/.test(item.Validate)) { |
| | | cell.required = 'true' |
| | | } else { |
| | | cell.required = 'false' |
| | | } |
| | | cell.type = 'select' |
| | | cell.resourceType = '1' |
| | | cell.valueField = item.IdField |
| | |
| | | cell.dataSource = `select * from @db@${cell.dataSource}` |
| | | |
| | | if (item.WhereField) { |
| | | cell.dataSource += ' where ' + item.WhereField.replace(/^\s*\(|\)\s*$/g, '') |
| | | if (/\(/.test(item.WhereField) && item.WhereField.match(/\(/g).length === 1) { |
| | | cell.dataSource += ' where ' + item.WhereField.replace(/^\s*\(|\)\s*$/g, '') |
| | | } else { |
| | | cell.dataSource += ' where ' + item.WhereField |
| | | } |
| | | } |
| | | } |
| | | |
| | | cell.dataSource = cell.dataSource.replace(/@userid[^0-9a-z_@]/ig, (w) => w.replace(/@UserID/i, '@UserID@')) |
| | | cell.dataSource = this.sqltrans(cell.dataSource) |
| | | |
| | | if (item.Multi === 'true') { |
| | | cell.type = 'multiselect' |
| | |
| | | result = result.replace(/@ID@\s+nvarchar\(/ig, '@ID nvarchar(') |
| | | result = result.replace(/@BID@\s+nvarchar\(/ig, '@BID nvarchar(') |
| | | result = result.replace(/@userid@\s+nvarchar\(/ig, '@UserID nvarchar(') |
| | | |
| | | result = this.handleFormat(result) |
| | | } |
| | | |
| | | this.setState({value: result}) |
| | | } |
| | | |
| | | sqltrans = (sql) => { |
| | | sql = sql.replace(/@ID[^0-9a-z_@]/ig, (w) => w.replace(/@ID/i, '@ID@')) |
| | | sql = sql.replace(/@BID[^0-9a-z_@]/ig, (w) => w.replace(/@BID/i, '@BID@')) |
| | | sql = sql.replace(/@userid[^0-9a-z_@]/ig, (w) => w.replace(/@UserID/i, '@UserID@')) |
| | | |
| | | sql = sql.replace(/@ID@\s+nvarchar\(/ig, '@ID nvarchar(') |
| | | sql = sql.replace(/@BID@\s+nvarchar\(/ig, '@BID nvarchar(') |
| | | sql = sql.replace(/@userid@\s+nvarchar\(/ig, '@UserID nvarchar(') |
| | | |
| | | // 系统表 |
| | | let tables = ['sPermission', 'V_DealerType', "areas","BDCRMChannel","BDCRMChannelProduct","BDCRMCustomer","BDCRMCustomerAccount","BDCRMCustomerAccountFI","BDCRMCustomerChannel","BDCRMCustomerCoupon","BDCRMCustomerPerson","BDCRMCustomerpricediffCoupon","BDCRMCustomersMateriel","BDCRMCustomersMateriel_Log","BDCRMCustomersOrg","BDCRMCustomersOrgCredit","BDCRMCustomersSales","BDCRMCustomersSO","BDDMSAllocation","BDDMSAreas","BDDMSDealerMateriel","BDDMSDealerMaterielBatch","BDDMSDealers","BDDMSIntegral","BDDMSLogistics","BDEShopIndexGroup","BDFactory","BDFactoryPerson","BDFCCPayCondition","BDFCCVoucher","BDMESTechDeviceAffairUser","BDQCCheckPlanProduct","BDSRMSupplier","BDWMSClassify","BDWMSMateriel","BDWMSMaterielClassify","BDWMSMaterielFactory","BDWMSMaterielFactoryKeepFit","BDWMSMaterielImages","BDWMSMaterielPacking","BDWMSMaterielStockType","BDWMSMaterielUnit","BDWMSWareHouse","CRMCouponBlacklist","CRMCouponWhitelist","CRMMarketingActiChannel","CRMMarketingActiChannel_Log","CRMMarketingActiCustomer","CRMMarketingActiCustomer_Log","CRMMarketingActivities","CRMMarketingActivities_Log","CRMMarketingActivitiesUnitPrice","CRMMarketingActivitiesUnitPrice_Log","CRMSaleOrder","CRMSaleOrderDetail","CRMSaleOrderDetailForSale","CRMSaleOrderDiscount","CRMSaleOrderForSale","CRMSalesForecast","CRMZdmsBillList","CRMZdmsBillList_log","DMSFlGoodsOrderBarCode","DMSIntegralOrdeDetail","DMSIntegralOrder","DMSScrapOrderBarCode","DMSStatistics","DOCFramework","DOCFramParagraph","DOCLanguagePacks","DOCMenus","DOCTitle","EShopOrderSendExpress","EShopShopping","EShopShopping_Log","EShopShopping_Order","EShopShopping_Order_Log","FCCAccountStatement","FCCAccountStatementDetail","FCCInvoiceDN","FCCInvoiceDNDetail","FCCInvoiceNoteOrder_ZMKP","FCCInvoiceNoteOrder_ZMKP_Log","FCCInvoiceNoteOrderDetail_ZMKP","FCCInvoiceNoteOrderDetailForPDF_ZMKP","FCCInvoiceOrder","FCCInvoiceOrderSP","FCCMonthlyBills","FCCMonthlyBillsBalance","FCCMonthlyBillsPayment","FCCMonthlyBillsRecev","FCCRecePayVoucher","INV_IHEAD","INV_NOTY_SMS","INV_ZBAPI_DMS_SAP_JIANDN","INV_ZdmsBillList","KUNOsMain","KUNOsMain_PARAMS","KUNOsMain_TABLES","MESOrder","MESOrderDetail","MSNList","MSNListRecv","OMSDeliverNotice","OMSDeliverNoticeBarCode","OMSDeliverNoticeDetail","OMSDeliverNoticeExpress","QCBarcode","QCBarCode","QCExpirationDateSet","QCFlow","QCRecallConfirmBarcode","QCRecallConfirmDetail","QCRecallConfirmOrder","QCRecallList","QCRecallListDetail","QCRecallSendBarcode","QCRecallSendDetail","QCRecallSendOrder","sBDA_Color","sBDA_Color_Affair","sBDA_Statistics","sBDA_Where","sDataDictionary","sdebug","sDurgs","sExProcTime","sExRate","sGridMyReport","sIOT","sMap","sOrganization","sOrganizationAccount","spage_gather","spage_gather_detail","sRightsForFields","SRMPurchaseOrder","SRMPurchaseOrderDetail","SRoles","sSystemParameters","Susers","sVersion","sWorkflow","sWorkflowDetail","sWorkflowDetailButton","sWorkflowDetailFour","sWorkflowDetailRoles","sWorkflowDetailTree","sWorkflowKeyWords","sWorkflowKeyWordsULog","sWorkflowlog","sWorkflowMSNlog","sWorkflowRpermission","sWorkflowStatus","Tmp_DMSIntegralOrder","TMP_IT_LIPS","TMP_IT_LIPS_WareSpaceCode","TMP_TAB_DN_log","Tmp_WMSSalesOut","Tmp_WMSSalesOutBarCodeForScan","Tmp_WMSSalesOutBarCodeForScanFct","Tmp_WMSSalesOutBarCodeForScanOne","Tmp_WMSSalesOutBarCodeForScanThird","Tmp_WMSSalesOutBarCodeForScanTwo","Tmp_WMSSalesOutDetail","WMSAllocated","WMSAllocatedBarCode","WMSAllocatedDetail","WMSAllocatedNewBNLog","WMSAllocatedTotalLog","WMSInventoryOrder","WMSInventoryOrderBarCode","WMSInventoryOrderDetail","WMSRGIN","WMSRGINBarCode","WMSRGINDetail","WMSRGINNewBNLog","WMSRGINTotalLog","WMSSalesOut","WMSSalesOutBarCode","WMSSalesOutBarCodeForScanFct","WMSSalesOutBarCodeOne","WMSSalesOutBarCodeSalesEnd","WMSSalesOutBarCodeSalesEndRecv","WMSSalesOutBarCodeTwo","WMSSalesOutBarCodeTwoRecv","WMSSalesOutDetail","WMSSalesOutDetailOne","WMSSalesOutDetailSalesEnd","WMSSalesOutDetailTwo","WMSSalesOutInvoice","WMSSalesOutNewBNLog","WMSSalesOutNewBNLogOne","WMSSalesOutNewBNLogTwo","WMSSalesOutNewBNLogTwoRecv","WMSSalesOutOne","WMSSalesOutSalesEnd","WMSSalesOutST","WMSSalesOutSTBarCode","WMSSalesOutSTBarCodeRecv","WMSSalesOutSTDetail","WMSSalesOutSTNewBNLog","WMSSalesOutSTNewBNLogRecv","WMSSalesOutSTTotalLog","WMSSalesOutSTTotalLogRecv","WMSSalesOutTotalLog","WMSSalesOutTotalLogOne","WMSSalesOutTotalLogTwo","WMSSalesOutTotalLogTwoRecv","WMSSalesOutTwo","WMSStock","WMSStockBarCode","WMSStockBarCodeFrozenLog","WMSStockBarCodeOne","WMSStockBarCodeSalesEnd","WMSStockBarCodeST","WMSStockBarCodeTwo","WMSStockBatch","WMSStockBatchOne","WMSStockBatchST","WMSStockBatchTwo","WMSStockTotal","WMSStockTotalForSap","WMSStockTotalOne","WMSStockTotalST","WMSStockTotalTwo","WMSStockUnOrFreezLog","WMSTransWareSpace","ZBAPI_DMS_SAP_JIANBILLING_DATE"] |
| | | |
| | | tables.forEach(tb => { |
| | | sql = sql.replace(new RegExp(`[^0-9a-z_]from\\s+${tb}[^0-9a-z_]`, 'ig'), (w) => w.replace(/from\s+/i, 'from @db@')) |
| | | }) |
| | | |
| | | sql = this.handleFormat(sql) |
| | | |
| | | return sql |
| | | } |
| | | |
| | | handleFormat = (_sql) => { |
| | | let arr = [] |
| | | _sql = _sql.replace(/@[0-9a-zA-Z_]+@/g, (word) => { |
| | | let uuid = Utils.getuuid() |
| | | arr.push({id: uuid, value: word}) |
| | | return uuid |
| | | }) |
| | | |
| | | _sql = sqlFormatter.format(_sql.replace(/\s{2,}/g, ' ')) |
| | | |
| | | _sql = _sql.replace(/\$\s\*\s\//g, '$*/').replace(/\*\s\//g, '*/') |
| | | |
| | | arr.forEach(item => { |
| | | _sql = _sql.replace(item.id, item.value) |
| | | }) |
| | | |
| | | _sql = _sql.replace(/,\n\s*/g, ',') |
| | | _sql = _sql.replace(/@db@\s+[a-zA-Z]/g, (w) => { |
| | | return w.replace(/\s+/g, '') |
| | | }) |
| | | |
| | | return _sql |
| | | } |
| | | |
| | | copy = () => { |
| | | const { type, value } = this.state |
| | | |
| | |
| | | border: 1px solid #1890ff; |
| | | min-height: 200px; |
| | | padding: 5px; |
| | | word-break: break-all; |
| | | } |
| | | } |
| | | } |