wuqun 2 years ago
parent
commit
adabc0a851
  1. 98
      api/app/lib/utils/constant.js
  2. 132
      api/app/lib/utils/xlsxDownload.js
  3. 4
      web/client/src/sections/business/containers/performanceReport/contractDetails.jsx
  4. 2
      web/client/src/sections/business/containers/performanceReport/invoicingDetails.jsx

98
api/app/lib/utils/constant.js

@ -2,19 +2,91 @@
module.exports = function (app, opts) {
const dayType = {
dayoff: '普假',
workday: '工作日',
festivals: '法定假',
}
const dayType = {
dayoff: '普假',
workday: '工作日',
festivals: '法定假',
}
const overtimeType = {
'发放加班补偿': '折算',
'调休': '调休'
}
const overtimeType = {
'发放加班补偿': '折算',
'调休': '调休'
}
return {
dayType,
overtimeType,
}
const contractDetailsColumnKeys = {
year: '年度',
serialNo: '序号',
number: '编号',
introduction: '简介',
contractNo: '合同编号',
applyDate: '申请日期',
recConDate: '收到合同日期',
contractPaper: '合同纸质版情况',
contractElec: '合同电子版情况',
department: '部门',
business: '业务线',
sale: '销售人员',
customer: '客户名称',
item: '项目名称',
itemType: '项目类型',
amount: '合同金额',
changeAmount: '变更后合同金额',
cInvoicedAmount: '累计开票金额',
cBackAmount: '累计回款金额',
invoicedBack: '开票-回款',
unInvoicedAmount: '未开票金额',
remainConAmount: '剩余合同金额',
backPercent: '回款率',
retentionMoney: '质保金',
retentionPercent: '质保金比例',
retentionTerm: '质保期',
invoiceTax1: '发票税率金额13%',
invoiceTax2: '发票税率金额9%',
invoiceTax3: '发票税率金额6%',
payType: '合同付款方式',
cost: '预支提成及委外费用',
performanceRatio: '业绩折算比例',
realPerformance: '实际业绩',
assessmentPerformance: '考核业绩',
acceptanceDate: '验收日期',
backConfirmDate: '收入确认时间',
recYear: '接单年份',
recMonth: '接单月份',
cusAttribute: '客户属性',
cusType: '客户类型',
industry: '行业',
source: '信息来源',
cusProvince: '客户省份',
cusArea: '项目所在地',
text: '备注',
}
const invoicingDetailsColumnKeys = {
year: '年度',
serialNo: '序号',
number: '编号',
department: '部门',
sale: '销售人员',
contractNo: '合同编号',
customer: '客户名称',
item: '项目名称',
amount: '合同金额',
changeAmount: '变更后合同金额',
invoiceNo: '发票号码',
invoiceType: '开票类型',
invoiceDate: '开票日期',
invoiceAmount: '开票金额',
outputTax: '销项税额',
total: '合计',
taxRate13: '税率13%',
taxRate9: '税率9%',
taxRate6: '税率6%'
}
return {
dayType,
overtimeType,
contractDetailsColumnKeys,
invoicingDetailsColumnKeys
}
}

132
api/app/lib/utils/xlsxDownload.js

@ -7,76 +7,76 @@ const moment = require('moment')
module.exports = function (app, opts) {
//递归创建目录 同步方法
async function makeDir (dir) {
if (!fs.existsSync(dir)) {
makeDir(path.dirname(dir))
fs.mkdirSync(dir, function (err) {
if (err) {
throw err
}
});
}
}
//递归创建目录 同步方法
async function makeDir(dir) {
if (!fs.existsSync(dir)) {
makeDir(path.dirname(dir))
fs.mkdirSync(dir, function (err) {
if (err) {
throw err
}
});
}
}
async function simpleExcelDown ({ data = [], header = [], fileName = moment().format('YYYY-MM-DD HH:mm:ss') } = {}) {
const fileDirPath = path.join(__dirname, `../../downloadFiles`)
makeDir(fileDirPath)
const file = new xlsx.File();
const sheet_1 = file.addSheet('sheet_1');
async function simpleExcelDown({ data = [], header = [], fileName = moment().format('YYYY-MM-DD HH:mm:ss') } = {}) {
const fileDirPath = path.join(__dirname, `../../downloadFiles`)
makeDir(fileDirPath)
const file = new xlsx.File();
const sheet_1 = file.addSheet('sheet_1');
// header
const headerStyle = new xlsx.Style();
headerStyle.align.h = 'center';
headerStyle.align.v = 'center';
headerStyle.border.right = 'thin';
headerStyle.border.rightColor = '#000000';
headerStyle.border.bottom = 'thin';
headerStyle.border.bottomColor = '#000000';
// header
const headerStyle = new xlsx.Style();
headerStyle.align.h = 'center';
headerStyle.align.v = 'center';
headerStyle.border.right = 'thin';
headerStyle.border.rightColor = '#000000';
headerStyle.border.bottom = 'thin';
headerStyle.border.bottomColor = '#000000';
const headerRow = sheet_1.addRow();
const indexCell = headerRow.addCell();
indexCell.value = '序号'
indexCell.style = headerStyle
for (let h of header) {
const cell = headerRow.addCell();
cell.value = h.title;
cell.style = headerStyle
}
const headerRow = sheet_1.addRow();
const indexCell = headerRow.addCell();
indexCell.value = '序号'
indexCell.style = headerStyle
for (let h of header) {
const cell = headerRow.addCell();
cell.value = h.title;
cell.style = headerStyle
}
// data
const style = new xlsx.Style();
style.align.h = 'left';
style.align.v = 'center';
style.border.right = 'thin';
style.border.rightColor = '#000000';
style.border.bottom = 'thin';
style.border.bottomColor = '#000000';
for (let i = 0; i < data.length; i++) {
const row = sheet_1.addRow();
const indexCell = row.addCell();
indexCell.value = i + 1
indexCell.style = headerStyle
for (let h of header) {
const cell = row.addCell();
cell.value = data[i][h.key] || h.defaultValue || '';
cell.style = style
}
}
// data
const style = new xlsx.Style();
style.align.h = 'left';
style.align.v = 'center';
style.border.right = 'thin';
style.border.rightColor = '#000000';
style.border.bottom = 'thin';
style.border.bottomColor = '#000000';
for (let i = 0; i < data.length; i++) {
const row = sheet_1.addRow();
const indexCell = row.addCell();
indexCell.value = i + 1
indexCell.style = headerStyle
for (let h of header) {
const cell = row.addCell();
cell.value = data[i][h.key] || h.defaultValue || '-';
cell.style = style
}
}
const savePath = path.join(fileDirPath, fileName)
await new Promise(function (resolve, reject) {
file.saveAs()
.pipe(fs.createWriteStream(savePath))
.on('finish', () => {
resolve()
});
})
return savePath
}
const savePath = path.join(fileDirPath, fileName)
await new Promise(function (resolve, reject) {
file.saveAs()
.pipe(fs.createWriteStream(savePath))
.on('finish', () => {
resolve()
});
})
return savePath
}
return {
simpleExcelDown,
makeDir
}
return {
simpleExcelDown,
makeDir
}
}

4
web/client/src/sections/business/containers/performanceReport/contractDetails.jsx

@ -48,7 +48,7 @@ const ContractDetails = (props) => {
localStorage.getItem(CONTRACTDETAILS) == null
? localStorage.setItem(
CONTRACTDETAILS,
JSON.stringify(['a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a10', 'a11', 'a12', 'a13', 'a14', 'a15', 'a16'])
JSON.stringify(['year', 'serialNo', 'number', 'introduction', 'contractNo', 'applyDate', 'recConDate', 'department', 'business', 'sale', 'customer', 'item', 'itemType', 'amount'])
)
: "";
attribute();
@ -106,7 +106,7 @@ const ContractDetails = (props) => {
<Select value={keywordTarget} onChange={setKeywordTarget} style={{ width: 150 }} >
<Select.Option value='contractNo'>合同编号</Select.Option>
<Select.Option value='department'>部门</Select.Option>
<Select.Option value='businessLine'>业务线</Select.Option>
<Select.Option value='business'>业务线</Select.Option>
</Select>
</div>
<div style={{ margin: '0px 18px' }}>

2
web/client/src/sections/business/containers/performanceReport/invoicingDetails.jsx

@ -48,7 +48,7 @@ const InvoicingDetails = (props) => {
localStorage.getItem(INVOICINGDETAILS) == null
? localStorage.setItem(
INVOICINGDETAILS,
JSON.stringify(['a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a10', 'a11', 'a13'])
JSON.stringify(['year', 'serialNo', 'number', 'department', 'sale', 'contractNo', 'customer', 'item', 'amount', 'changeAmount', 'invoiceNo', 'invoiceDate'])
)
: "";
attribute();

Loading…
Cancel
Save