-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneratexlsx.js
25 lines (24 loc) · 19.5 KB
/
generatexlsx.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var i18ntranslator = require('../dist/i18ntranslator.min')
var fs = require('fs')
var path = require('path')
// 入口函数
var jsonOld = i18ntranslator.readXlsx('./bdtranslate/source.xlsx')
var json = [{"key":"佰","value":"Bai"},{"key":"拾","value":"Ten"},{"key":"元","value":"element"},{"key":"角","value":"horn"},{"key":"分","value":"branch"},{"key":"十","value":"Ten"},{"key":"亿","value":"Billion"},{"key":"千","value":"thousand"},{"key":"百","value":"hundred"},{"key":"十","value":"Ten"},{"key":"万","value":"ten thousand"},{"key":"千","value":"thousand"},{"key":"百","value":"hundred"},{"key":"十","value":"Ten"},{"key":"亿","value":"Billion"},{"key":"千","value":"thousand"},{"key":"百","value":"hundred"},{"key":"十","value":"Ten"},{"key":"万","value":"ten thousand"},{"key":"千","value":"thousand"},{"key":"百","value":"hundred"},{"key":"十","value":"Ten"},{"key":"元","value":"element"},{"key":"角","value":"horn"},{"key":"分","value":"branch"},{"key":"零","value":"Zero"},{"key":"壹","value":"One"},{"key":"贰","value":"Two"},{"key":"叁","value":"Three"},{"key":"肆","value":"Four"},{"key":"伍","value":"Five"},{"key":"陆","value":"Six"},{"key":"柒","value":"Seven"},{"key":"捌","value":"Eight"},{"key":"玖","value":"Nine"},{"key":"一","value":"One"},{"key":"二","value":"Two"},{"key":"三","value":"Three"},{"key":"四","value":"Four"},{"key":"五","value":"Five"},{"key":"六","value":"Six"},{"key":"七","value":"Seven"},{"key":"八","value":"Eight"},{"key":"九","value":"Nine"},{"key":"点","value":"spot"},{"key":"加载模板文件报错,原因:[","value":"Load template file error, reason: ["},{"key":"导出合同单 VO 为null","value":"Export contract form VO to null"},{"key":"映射属性错误","value":"Mapping attribute error"},{"key":"映射属性错误","value":"Mapping attribute error"},{"key":"加载模板文件报错,原因:[","value":"Load template file error, reason: ["},{"key":"未查到合同","value":"No contract found"},{"key":"合同","value":"contract"},{"key":"零元整","value":"Zero integer"},{"key":"零元整","value":"Zero integer"},{"key":"映射属性错误","value":"Mapping attribute error"},{"key":"映射属性错误","value":"Mapping attribute error"},{"key":"调用PoiUtil.copySheet()方法时,targetSheet、sourceSheet、targetWork、sourceWork都不能为空,故抛出该异常!","value":"When calling the PoiUtil. copySheet () method, targetSheet, sourceSheet, targetWork, sourceWork can not be empty, so throw the exception!"},{"key":"调用PoiUtil.copySheet()方法时,targetSheet、sourceSheet、targetWork、sourceWork都不能为空,故抛出该异常!","value":"When calling the PoiUtil. copySheet () method, targetSheet, sourceSheet, targetWork, sourceWork can not be empty, so throw the exception!"},{"key":"调用PoiUtil.copySheet()方法时,targetSheet、sourceSheet、targetWork、sourceWork都不能为空,故抛出该异常!","value":"When calling the PoiUtil. copySheet () method, targetSheet, sourceSheet, targetWork, sourceWork can not be empty, so throw the exception!"},{"key":"调用PoiUtil.copyRow()方法时,targetRow、sourceRow、targetWork、sourceWork、targetPatriarch都不能为空,故抛出该异常!","value":"When calling the PoiUtil. copyRow () method, targetRow, sourceRow, targetWork, sourceWork, targetPatriarch can not be empty, so throw the exception!"},{"key":"查询出错","value":"Query error"},{"key":"参数为空","value":"The parameter is empty."},{"key":"参数为空","value":"The parameter is empty."},{"key":"参数为空","value":"The parameter is empty."},{"key":"输入的数量不正确","value":"The number of inputs is incorrect"},{"key":"输入数量超过合同总数","value":"The number of inputs exceeds the total number of contracts"},{"key":"部分需求单状态已发生改变,请刷新后重试","value":"Some single states of requirements have changed. Please refresh and try again."},{"key":"输入的数量不得为0","value":"The number of inputs must not be zero"},{"key":"部分合同已执行数量已发生改变,请刷新后重试","value":"Some contracts have been executed in different quantities. Please refresh them and try again."},{"key":"有其他人正在操作,请耐心等待。。。。。","value":"Others are operating, please wait patiently..."},{"key":"id为空","value":"ID is empty."},{"key":"获取用户或企业信息失败","value":"Failure to obtain user or enterprise information"},{"key":"参数为空","value":"The parameter is empty."},{"key":"参数为空","value":"The parameter is empty."},{"key":"传入的合同-物料表为空","value":"Imported contract - Material sheet is empty"},{"key":"获取用户或企业信息失败","value":"Failure to obtain user or enterprise information"},{"key":"查询失败","value":"Query failed"},{"key":"查询失败","value":"Query failed"},{"key":"查询失败","value":"Query failed"},{"key":"保存失败","value":"Save failed"},{"key":"推送erp报错","value":"Push ERP to report wrong"},{"key":"保存信息不能为空!","value":"Save information can not be empty!"},{"key":"合同已被卖方接受,不能取消发布。","value":"The contract has been accepted by the seller and cannot be cancelled."},{"key":"取消发布失败","value":"Failure to cancel publication"},{"key":"签订日期,生效日期不得为空","value":"The date of signing shall not be empty."},{"key":"终止日期不得早于当前日期","value":"The termination date shall not be earlier than the current date."},{"key":"合同生成失败","value":"Contract generation failure"},{"key":"保存信息不能为空!","value":"Save information can not be empty!"},{"key":"保存信息不能为空!","value":"Save information can not be empty!"},{"key":"参数为空","value":"The parameter is empty."},{"key":"未查询到合同信息","value":"No contract information was queried"},{"key":"保存失败","value":"Save failed"},{"key":"保存失败","value":"Save failed"},{"key":"参数为空","value":"The parameter is empty."},{"key":"参数为空","value":"The parameter is empty."},{"key":"查询失败","value":"Query failed"},{"key":"获取企业信息失败,请重新登陆","value":"Failed to obtain enterprise information, please re-login"},{"key":"成功获取模板","value":"Template successfully acquired"},{"key":"获取模板失败","value":"Failed to get template"},{"key":"请选中要生成电子合同的采购合同!","value":"Please select the purchase contract to generate the electronic contract!"},{"key":"当前合同已生成电子合同,请刷新界面!","value":"The current contract has generated an electronic contract, please refresh the interface!"},{"key":"发送合同失败,详细信息:","value":"Failure to send contract details:"},{"key":"您选择的合同已发送或没有符合条件的合同!只有采购合同主状态为“待发布/卖方已变更/卖方已接受/买方已接受”且审批状态为“未提交审批、审批拒绝”的合同才可以发送OA!","value":"The contract you choose has been sent or does not meet the requirements of the contract! Only when the main state of the procurement contract is \"to be issued / the seller has changed / the seller has accepted / the buyer has accepted\" and the approval state is \"not submitted for approval, approval rejection\" can the contract be sent OA!"},{"key":"发送合同到OA成功!","value":"Send the contract to OA successfully!"},{"key":"回写合同失败,回写数据为空!","value":"Write-back contract failed, write-back data is empty!"},{"key":"回写合同失败!详细日志:","value":"Write-back contract failed! Detailed log:"},{"key":"回写合同结束!","value":"Write back the end of the contract!"},{"key":"查询失败","value":"Query failed"},{"key":"单据状态回写成功!","value":"Document Status Write Back Successfully!"},{"key":"参数为空","value":"The parameter is empty."},{"key":"未查询到合同信息","value":"No contract information was queried"},{"key":"当前合同的流程定义未查询到,请重新确认!","value":"The process definition of the current contract has not been queried, please reconfirm!"},{"key":"调用云审接口,进行[提交],耗时(ms):{}==================================================================","value":"Calling the cloud audit interface for [submission] takes time (ms): {}===================================================================================================================="},{"key":"普通合同","value":"Ordinary contract"},{"key":"协议框架","value":"Protocol framework"},{"key":"没有配置APPID!","value":"No APPID configured!"},{"key":"没有配置网关URL!","value":"No gateway URL configured!"},{"key":"调用云审接口进行查询立项审批历史失败!","value":"Invoking cloud audit interface for query and approval history failed!"},{"key":"查询失败","value":"Query failed"},{"key":"当前用户没有权限!","value":"Current users do not have permission!"},{"key":"quote have stoped","value":"Quote have stoped"},{"key":"Pending","value":"Pending"},{"key":"in inquirying","value":"In inquirying"},{"key":"have quoationed","value":"Have quoationed"},{"key":"have placed order","value":"Have placed order"},{"key":"have placed order to ERP","value":"Have placed order to ERP"},{"key":"have payed","value":"Have payed"},{"key":"YC inquirying","value":"YC inquirying"},{"key":"1688 cancel inquiry,YC Requirement need inquiry","value":"1688 cancel inquiry, YC Requirement need inquiry"},{"key":"YC Requirement cancel publish,need inquiry","value":"YC Requirement cancel publish, need inquiry"},{"key":"(abandon status)ERP buying requirement cancel publish YC Requirement","value":"(abandon status) ERP purchase requirement cancel publish YC Requirement"},{"key":"have generated inquiry","value":"Have generated inquiry"},{"key":"inquiry ended(decisioned)","value":"Inquiry ended (decision)"},{"key":"have distributed","value":"Have distributed"},{"key":"inviting bids","value":"Inviting bids"},{"key":"No turn-on time","value":"No turn-on time"},{"key":"发布","value":"Release"},{"key":"轮谈判","value":"Round negotiation"},{"key":"当前用户没有权限!","value":"Current users do not have permission!"},{"key":"获取登陆企业失败","value":"Failure to acquire landing enterprise"},{"key":"查询监督权限出错,请重试","value":"Error in query supervisory authority, please try again"},{"key":"当前用户没有权限!","value":"Current users do not have permission!"},{"key":"调用网关向OA发送合同数据失败:详细日志:","value":"Invoking gateway to send contract data to OA failed: detailed log:"},{"key":"加载模板文件报错,原因:[","value":"Load template file error, reason: ["},{"key":"定标单","value":"Calibration list"},{"key":"映射属性错误","value":"Mapping attribute error"},{"key":"映射属性错误","value":"Mapping attribute error"},{"key":"调用PoiUtil.copySheet()方法时,targetSheet、sourceSheet、targetWork、sourceWork都不能为空,故抛出该异常!","value":"When calling the PoiUtil. copySheet () method, targetSheet, sourceSheet, targetWork, sourceWork can not be empty, so throw the exception!"},{"key":"调用PoiUtil.copySheet()方法时,targetSheet、sourceSheet、targetWork、sourceWork都不能为空,故抛出该异常!","value":"When calling the PoiUtil. copySheet () method, targetSheet, sourceSheet, targetWork, sourceWork can not be empty, so throw the exception!"},{"key":"调用PoiUtil.copySheet()方法时,targetSheet、sourceSheet、targetWork、sourceWork都不能为空,故抛出该异常!","value":"When calling the PoiUtil. copySheet () method, targetSheet, sourceSheet, targetWork, sourceWork can not be empty, so throw the exception!"},{"key":"调用PoiUtil.copyRow()方法时,targetRow、sourceRow、targetWork、sourceWork、targetPatriarch都不能为空,故抛出该异常!","value":"When calling the PoiUtil. copyRow () method, targetRow, sourceRow, targetWork, sourceWork, targetPatriarch can not be empty, so throw the exception!"},{"key":"调用PoiUtil.copyCell()方法时,targetCell、sourceCell、targetWork、sourceWork都不能为空,故抛出该异常!","value":"When calling the PoiUtil. copyCell () method, targetCell, sourceCell, targetWork, sourceWork can not be empty, so throw the exception!"},{"key":"调用PoiUtil.copyCommentr()方法时,targetCell、sourceCell、targetPatriarch都不能为空,故抛出该异常!","value":"When calling the PoiUtil. copyCommentr () method, targetCell, sourceCell, targetPatriarch can't be empty, so throw the exception!"},{"key":"调用PoiUtil.mergerRegion()方法时,targetSheet或者sourceSheet不能为空,故抛出该异常!","value":"When the PoiUtil. mergerRegion () method is called, the targetSheet or sourceSheet cannot be empty, so the exception is thrown!"},{"key":"调用PoiUtil.mergerRegion()方法时,targetSheet或者sourceSheet不能为空,故抛出该异常!","value":"When the PoiUtil. mergerRegion () method is called, the targetSheet or sourceSheet cannot be empty, so the exception is thrown!"},{"key":"元","value":"element"},{"key":"万","value":"ten thousand"},{"key":"萬","value":"Ten thousand"},{"key":"亿","value":"Billion"},{"key":"整","value":"whole"},{"key":"分","value":"branch"},{"key":"零元","value":"Zero element"},{"key":"负","value":"negative"},{"key":"拾","value":"Ten"},{"key":"亿","value":"Billion"},{"key":"仟","value":"Thousand"},{"key":"佰","value":"Bai"},{"key":"拾","value":"Ten"},{"key":"萬","value":"Ten thousand"},{"key":"仟","value":"Thousand"},{"key":"佰","value":"Bai"},{"key":"拾","value":"Ten"},{"key":"亿","value":"Billion"},{"key":"仟","value":"Thousand"},{"key":"佰","value":"Bai"},{"key":"拾","value":"Ten"},{"key":"萬","value":"Ten thousand"},{"key":"仟","value":"Thousand"},{"key":"佰","value":"Bai"},{"key":"拾","value":"Ten"},{"key":"元","value":"element"},{"key":"角","value":"horn"},{"key":"分","value":"branch"},{"key":"拾","value":"Ten"},{"key":"亿","value":"Billion"},{"key":"仟","value":"Thousand"},{"key":"佰","value":"Bai"},{"key":"拾","value":"Ten"},{"key":"万","value":"ten thousand"},{"key":"仟","value":"Thousand"},{"key":"佰","value":"Bai"},{"key":"拾","value":"Ten"},{"key":"亿","value":"Billion"},{"key":"仟","value":"Thousand"},{"key":"佰","value":"Bai"},{"key":"拾","value":"Ten"},{"key":"万","value":"ten thousand"},{"key":"仟","value":"Thousand"},{"key":"调用PoiUtil.copyCell()方法时,targetCell、sourceCell、targetWork、sourceWork都不能为空,故抛出该异常!","value":"When calling the PoiUtil. copyCell () method, targetCell, sourceCell, targetWork, sourceWork can not be empty, so throw the exception!"},{"key":"调用PoiUtil.copyCommentr()方法时,targetCell、sourceCell、targetPatriarch都不能为空,故抛出该异常!","value":"When calling the PoiUtil. copyCommentr () method, targetCell, sourceCell, targetPatriarch can't be empty, so throw the exception!"},{"key":"调用PoiUtil.mergerRegion()方法时,targetSheet或者sourceSheet不能为空,故抛出该异常!","value":"When the PoiUtil. mergerRegion () method is called, the targetSheet or sourceSheet cannot be empty, so the exception is thrown!"},{"key":"调用PoiUtil.mergerRegion()方法时,targetSheet或者sourceSheet不能为空,故抛出该异常!","value":"When the PoiUtil. mergerRegion () method is called, the targetSheet or sourceSheet cannot be empty, so the exception is thrown!"},{"key":"合同.xls","value":"Contract.Xls"},{"key":"列表查询出错","value":"Error in list query"},{"key":"查询失败","value":"Query failed"},{"key":"保存信息不能为空!","value":"Save information can not be empty!"},{"key":"修改异常","value":"Modification exception"},{"key":"保存失败","value":"Save failed"},{"key":"查询失败","value":"Query failed"},{"key":"插入失败","value":"Insert failure"},{"key":"插入失败","value":"Insert failure"},{"key":"合同编码为空","value":"The contract code is empty."},{"key":"合同类型为空","value":"The contract type is empty."},{"key":"采购员为空","value":"Buyer is empty."},{"key":"采购组织为空","value":"The procurement organization is empty."},{"key":"供应商为空","value":"Supplier is empty"},{"key":"合同名称为空","value":"The name of the contract is empty."},{"key":"物料列表为空","value":"Material list is empty."},{"key":"合同生效日期为空","value":"The effective date of the contract is null"},{"key":"合同签订日期为空","value":"The date of signing the contract is empty"},{"key":"签订日期在截止日期之后","value":"Signing date after deadline"},{"key":"部分预付比例不得为空","value":"Partial prepayment ratio shall not be empty"},{"key":"物料id为空","value":"Material ID is empty."},{"key":"物料id格式错误","value":"Material ID format error"},{"key":"物料数量请填数字","value":"Please fill in the number of materials"},{"key":"物料单位为空","value":"Material units are empty."},{"key":"单价为空","value":"The unit price is empty."},{"key":"单价请填数字","value":"Unit price please fill in the figures."},{"key":"含税单价为空","value":"The unit price with tax is empty."},{"key":"含税单价请填数字","value":"Please fill in the figures for the unit price with tax"},{"key":"税率为空","value":"The tax rate is empty."},{"key":"税率请填数字","value":"Tax rates please fill in the figures."},{"key":"价税合计为空","value":"The total value tax is empty."},{"key":"价税合计请填数字","value":"Please fill in the figures for the total value and tax"},{"key":"数量填写不正确","value":"Incorrect quantity filling"},{"key":"合同生效日期为空","value":"The effective date of the contract is null"},{"key":"合同截止日期为空","value":"The contract deadline is empty"},{"key":"合同签订日期为空","value":"The date of signing the contract is empty"},{"key":"失效日期不得早于当前日期","value":"The expiration date shall not be earlier than the current date"},{"key":"Pending","value":"Pending"},{"key":"not have publish","value":"Not have publish"},{"key":"in approval","value":"In approval"},{"key":"accepting quoation","value":"Accepting quoation"},{"key":"have quoationed","value":"Have quoationed"},{"key":"have recommend supplier","value":"Have recommend supplier"},{"key":"have decisioned","value":"Have decisioned"},{"key":"have discard bid document","value":"Have discard bid document"},{"key":"e-commerce have placed order","value":"E-commerce have placed order"},{"key":"have placed order","value":"Have placed order"},{"key":"have placed order to ERP","value":"Have placed order to ERP"},{"key":"have payed","value":"Have payed"},{"key":"YC inquirying","value":"YC inquirying"},{"key":"1688 cancel inquiry,YC inquiry order deleted","value":"1688 cancel inquiry, YC inquiry order deleted"},{"key":"have opened","value":"Have opened"},{"key":"bid have opened","value":"Bid have opened"},{"key":"talks have seved","value":"Talks have seved"},{"key":"talks have published","value":"Talks have published"},{"key":"talks details have published","value":"Talks details have published"}]
jsonOld.forEach(function (item) {
if (!item.value || item.value =='not translated' || item.value == 'Not Translate' || item.value == 'Not translated') {
json.forEach(function (translated) {
if (item.key == translated.key) {
item.value = translated.value
}
})
}
})
var data = {}
jsonOld.forEach(function (item) {
if (data[item.key]) {
data[item.key + Math.random()] = item.value
} else {
data[item.key] = item.value
}
})
i18ntranslator.writeXlsx(data, './bdtranslate/result.xlsx');