Merge remote-tracking branch 'origin/material-ui' into material-ui

This commit is contained in:
syruan 2025-10-31 14:44:09 +08:00
commit 22219febee
6 changed files with 1107 additions and 107 deletions

View File

@ -41,10 +41,11 @@
"clipboard": "2.0.8",
"core-js": "3.25.3",
"crypto-js": "^4.2.0",
"docx": "^9.5.1",
"echarts": "5.4.0",
"element-ui": "2.15.14",
"exceljs": "^4.4.0",
"file-saver": "2.0.5",
"file-saver": "^2.0.5",
"fuse.js": "6.4.3",
"highlight.js": "9.18.5",
"html2canvas": "^1.4.1",

View File

@ -207,3 +207,19 @@ export function getCheckInfo(data) {
})
}
export function getProjectList(data) {
return request({
url: '/material/material_maMachine/getProjectList',
method: 'get',
params: data,
})
}
export function getDepartNameList(data) {
return request({
url: '/material/material_maMachine/getDepartNameList',
method: 'get',
params: data,
})
}

View File

@ -5,39 +5,86 @@
<el-col :span="8" :offset="0">
<el-card shadow="always" :body-style="{ padding: '20px' }" style="min-width: 400px; overflow-y: auto">
<!-- card body -->
<el-form-item label="转出单位" prop="backUnitId">
<treeselect
v-model="maForm.backUnitId"
:disabled="isEdit || isDetail"
:options="uniteList"
:normalizer="normalizer"
:show-count="true"
style="width: 100%"
:disable-branch-nodes="true"
noChildrenText="没有数据了"
noOptionsText="没有数据"
noResultsText="没有搜索结果"
placeholder="请选择转出单位"
@select="uniteChange"
/>
</el-form-item>
<el-form-item label="转出工程" prop="backProId">
<treeselect
v-model="maForm.backProId"
:disabled="isEdit || isDetail"
:options="projectList"
:normalizer="normalizer"
:show-count="true"
style="width: 100%"
:disable-branch-nodes="true"
noChildrenText="没有数据了"
noOptionsText="没有数据"
noResultsText="没有搜索结果"
placeholder="请选择转出工程"
@select="projectChange"
/>
</el-form-item>
<el-form-item label="转出人" prop="backMan">
<!-- 分公司 -->
<el-form-item label="分公司" prop="impUnitName">
<el-select
v-model="maForm.impUnitName"
placeholder="请选择分公司"
clearable
filterable
style="width: 100%"
:disabled="isEdit"
@change="onImpUnitChange"
>
<el-option
v-for="item in impUnitOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<!-- 项目部 -->
<el-form-item label="项目部" prop="departName">
<el-select
v-model="maForm.departName"
placeholder="请选择项目部"
clearable
filterable
style="width: 100%"
:disabled="!maForm.impUnitName || isEdit"
@change="onDepartChange"
>
<el-option
v-for="item in departOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<!-- 工程 -->
<el-form-item label="转出工程" prop="backProId">
<el-select
v-model="maForm.backProId"
placeholder="请选择工程"
clearable
filterable
style="width: 100%"
:disabled="!maForm.departName || isEdit || isDetail"
@change="onProjectChange"
>
<el-option
v-for="item in impProOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<!-- 单位树结构 -->
<el-form-item label="转出单位" prop="backUnitId">
<treeselect
v-model="maForm.backUnitId"
:disabled="!maForm.backProId || isEdit || isDetail"
:options="uniteList"
:normalizer="normalizer"
:show-count="true"
style="width: 100%"
:disable-branch-nodes="true"
noChildrenText="没有数据了"
noOptionsText="没有数据"
noResultsText="没有搜索结果"
placeholder="请选择转出单位"
@select="uniteChange"
/>
</el-form-item>
<el-form-item label="转出人" prop="backMan">
<el-input
v-model="maForm.backMan"
placeholder="请输入转出人"
@ -71,10 +118,64 @@
<el-col :span="8" :offset="0">
<el-card shadow="always" :body-style="{ padding: '20px' }" style="min-width: 400px; overflow-y: auto">
<!-- card body -->
<el-form-item label="分公司" prop="impUnitNameTwo">
<el-select
v-model="maForm.impUnitNameTwo"
placeholder="请选择分公司"
clearable
filterable
style="width: 100%"
@change="onImpUnitChangeTwo"
>
<el-option
v-for="item in impUnitOptionsTwo"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<!-- 项目部 -->
<el-form-item label="项目部" prop="departNameTwo">
<el-select
v-model="maForm.departNameTwo"
placeholder="请选择项目部"
clearable
filterable
style="width: 100%"
:disabled="!maForm.impUnitNameTwo"
@change="onDepartChangeTwo"
>
<el-option
v-for="item in departOptionsTwo"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="转入工程" prop="leaseProId">
<el-select
v-model="maForm.leaseProId"
placeholder="请选择工程"
clearable
filterable
style="width: 100%"
:disabled="!maForm.departNameTwo || isDetail"
@change="onProjectChangeTwo"
>
<el-option
v-for="item in leaseProjectList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="转入单位" prop="leaseUnitId">
<treeselect
v-model="maForm.leaseUnitId"
:disabled="isDetail"
:disabled="!maForm.leaseProId || isDetail"
:options="lessUniteList"
:normalizer="normalizer"
:show-count="true"
@ -84,25 +185,10 @@
noOptionsText="没有数据"
noResultsText="没有搜索结果"
placeholder="请选择转入单位"
@select="leaseUniteChange"
/>
</el-form-item>
<el-form-item label="转入工程" prop="leaseProId">
<treeselect
v-model="maForm.leaseProId"
:disabled="isDetail"
:options="leaseProjectList"
:normalizer="normalizer"
:show-count="true"
style="width: 100%"
:disable-branch-nodes="true"
noChildrenText="没有数据了"
noOptionsText="没有数据"
noResultsText="没有搜索结果"
placeholder="请选择转入工程"
@select="leaseProjectChange"
/>
</el-form-item>
<el-form-item label="转入人" prop="leaseMan">
<el-input
v-model="maForm.leaseMan"
@ -335,13 +421,21 @@
<script>
import { getMaTypeOpt } from '@/api/ma/base'
import {getListProject, getListUnite, getAgreement, getUnitProDepList} from '@/api/lease/apply'
import {
getListProject,
getListUnite,
getAgreement,
getUnitProDepList,
getProjectList,
getDepartNameList
} from '@/api/lease/apply'
import { downloadFile, downloadFileData } from '@/utils/download'
import { getUseringData, receiveSubmitTwo, receiveEdit, receiveDetail, getEquipmentThreeTypes } from '@/api/business/index'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { getToken } from '@/utils/auth'
import Pagination from '@/components/Pagination'
import {getImpUnitListApi} from "@/api/materialsStation";
export default {
name: 'DirectApply',
@ -444,6 +538,20 @@ export default {
},
//
rules: {
impUnitName: [
{
required: true,
message: '请选择转出分公司',
trigger: 'blur'
}
],
departName: [
{
required: true,
message: '请选择转出项目部',
trigger: 'blur'
}
],
backUnitId: [
{
required: true,
@ -517,7 +625,12 @@ export default {
dialogVisible: false,
uploadKey: Date.now(),
uploadUrl: process.env.VUE_APP_BASE_API + '/file/upload', //
headers: { Authorization: 'Bearer ' + getToken() }
headers: { Authorization: 'Bearer ' + getToken() },
impUnitOptions: [], //
departOptions: [],//
impProOptions: [],//
impUnitOptionsTwo: [], //
departOptionsTwo: [],//
}
},
computed: {
@ -549,11 +662,14 @@ export default {
const obj = Object.assign({}, this.$route, { title: '直转申请' })
this.$tab.updatePage(obj)
}
this.projectInfoList() //
if (this.isEdit || this.isDetail) {
console.log('isEdit', this.isEdit)
this.getTaskInfo()
} else {
this.getImpUnitOptions()
}
this.getImpUnitOptionsTwo()
console.log(this.$store, 'this.$store.getters')
console.log(this.$route.query, 'this.$route.query')
},
@ -573,6 +689,187 @@ export default {
}
},
methods: {
/** 获取分公司下拉 */
async getImpUnitOptions() {
try {
const res = await getImpUnitListApi()
this.impUnitOptions = res.data.map(item => ({
label: item.impUnitName,
value: item.impUnitName
}))
if (this.impUnitOptions.length === 1) {
this.maForm.impUnitName = this.impUnitOptions[0].value
await this.onImpUnitChange(this.maForm.impUnitName)
}
} catch (e) {
console.error('获取分公司下拉失败:', e)
}
},
/** 分公司变化 */
async onImpUnitChange(value) {
this.maForm.departName = ''
this.maForm.backProId = ''
this.maForm.backUnitId = undefined
this.departOptions = []
this.impProOptions = []
this.uniteList = []
if (!value) return
const res = await getDepartNameList({ impUnitName: value })
this.departOptions = res.data.map(item => ({
label: item.departName,
value: item.departName
}))
if (this.departOptions.length === 1) {
this.maForm.departName = this.departOptions[0].value
await this.onDepartChange(this.maForm.departName)
}
},
/** 项目部变化 */
async onDepartChange(value) {
this.maForm.backProId = ''
this.maForm.backUnitId = undefined
this.impProOptions = []
this.uniteList = []
if (!value) return
const res = await getProjectList({ departName: value })
this.impProOptions = res.data.map(item => ({
label: item.proName,
value: item.proId
}))
if (this.impProOptions.length === 1) {
this.maForm.backProId = this.impProOptions[0].value
await this.onProjectChange(this.maForm.backProId)
}
},
/** 工程变化 */
async onProjectChange(value) {
//
this.maForm.backUnitId = undefined
this.uniteList = []
//
if (!value) return
try {
let edit =true;
if (this.isEdit){
edit=false
}
const res = await getUnitProDepList({ projectId: value, enableFilter: edit })
this.uniteList = res.data || []
//
const leafNodes = []
const findLeaf = nodes => {
nodes.forEach(n => {
if (!n.children || n.children.length === 0) {
leafNodes.push(n)
} else {
findLeaf(n.children)
}
})
}
findLeaf(this.uniteList)
if (leafNodes.length === 1) {
this.maForm.backUnitId = leafNodes[0].id || leafNodes[0].value
await this.getAgreementId()
}
} catch (e) {
console.error('获取单位列表失败:', e)
}
},
/** 获取转入分公司下拉 */
async getImpUnitOptionsTwo() {
try {
const params = {
enableFilter: false
}
const res = await getImpUnitListApi(params)
this.impUnitOptionsTwo = res.data.map(item => ({
label: item.impUnitName,
value: item.impUnitName
}))
if (this.impUnitOptionsTwo.length === 1) {
this.maForm.impUnitNameTwo = this.impUnitOptionsTwo[0].value
await this.onImpUnitChangeTwo(this.maForm.impUnitNameTwo)
}
} catch (e) {
console.error('获取分公司下拉失败:', e)
}
},
/** 分公司变化 */
async onImpUnitChangeTwo(value) {
this.maForm.departNameTwo = ''
this.maForm.leaseProId = ''
this.maForm.leaseUnitId = undefined
this.departOptionsTwo = []
this.leaseProjectList = []
this.lessUniteList = []
if (!value) return
const res = await getDepartNameList({ impUnitName: value ,enableFilter: false})
this.departOptionsTwo = res.data.map(item => ({
label: item.departName,
value: item.departName
}))
if (this.departOptionsTwo.length === 1) {
this.maForm.departNameTwo = this.departOptionsTwo[0].value
await this.onDepartChangeTwo(this.maForm.departNameTwo)
}
},
/** 转入项目部变化 */
async onDepartChangeTwo(value) {
this.maForm.leaseProId = ''
this.maForm.leaseUnitId = undefined
this.leaseProjectList = []
this.lessUniteList = []
if (!value) return
const res = await getProjectList({ departName: value,enableFilter: false })
this.leaseProjectList = res.data.map(item => ({
label: item.proName,
value: item.proId
}))
if (this.leaseProjectList.length === 1) {
this.maForm.leaseProId = this.leaseProjectList[0].value
await this.onProjectChangeTwo(this.maForm.leaseProId)
}
},
/** 转入工程变化 */
async onProjectChangeTwo(value) {
//
this.maForm.leaseUnitId = undefined
this.lessUniteList = []
//
if (!value) return
try {
const res = await getUnitProDepList({ projectId: value, enableFilter: false })
this.lessUniteList = res.data || []
//
const leafNodes = []
const findLeaf = nodes => {
nodes.forEach(n => {
if (!n.children || n.children.length === 0) {
leafNodes.push(n)
} else {
findLeaf(n.children)
}
})
}
findLeaf(this.lessUniteList)
if (leafNodes.length === 1) {
this.maForm.leaseUnitId = leafNodes[0].id || leafNodes[0].value
await this.getLeaseAgreementId()
}
} catch (e) {
console.error('获取单位列表失败:', e)
}
},
//
handleQuery() {
//
@ -790,12 +1087,13 @@ export default {
this.getTypeModelNameOpt(val)
},
uniteChange(val) {
setTimeout(() => {
getListProject({ unitId: this.maForm.backUnitId,enableFilter: true }).then(response => {
this.projectList = response.data
this.maForm.backProId = null
})
}, 500)
// setTimeout(() => {
// getListProject({ unitId: this.maForm.backUnitId,enableFilter: true }).then(response => {
// this.projectList = response.data
// this.maForm.backProId = null
// })
// }, 500)
this.getAgreementId()
},
projectChange(val) {
setTimeout(() => {
@ -814,51 +1112,12 @@ export default {
}, 500)
},
leaseProjectChange(val) {
setTimeout(() => {
getListUnite({}).then(res => {
this.leaseUniteList = res.data
})
// setTimeout(() => {
// getListUnite({}).then(res => {
// this.leaseUniteList = res.data
// })
this.getLeaseAgreementId()
}, 500)
},
/** 租赁单位和工程-下拉选 */
projectInfoList() {
console.log("kkkkkkkkkkk",this.isEdit)
if (!this.isEdit) {
//
getUnitProDepList({ projectId: null,enableFilter: true }).then(response => {
this.uniteList = response.data
})
//
getListProject({ unitId: null,enableFilter: true }).then(response => {
this.projectList = response.data
})
//
getUnitProDepList({ projectId: null }).then(response => {
this.lessUniteList = response.data
})
//
getListProject({ unitId: null }).then(response => {
this.leaseProjectList = response.data
})
} else {
//
getUnitProDepList({ projectId: null,enableFilter: true }).then(response => {
this.uniteList = response.data
})
//
getListProject({ unitId: this.maForm.backUnitId,enableFilter: true }).then(response => {
this.projectList = response.data
})
//
getUnitProDepList({ projectId: null }).then(response => {
this.lessUniteList = response.data
})
//
getListProject({ unitId: this.maForm.leaseUnitId }).then(response => {
this.leaseProjectList = response.data
})
}
// }, 500)
},
//---
async getTaskInfo() {
@ -867,8 +1126,44 @@ export default {
const res = await receiveDetail({ id: this.id })
console.log('🚀 ~ getTaskInfo ~ res:', res)
this.maForm = res.data
this.maForm.impUnitName=res.data.backImpUnitName
this.maForm.departName=res.data.backDepartName
this.maForm.impUnitNameTwo=res.data.leaseImpUnitName
this.maForm.departNameTwo=res.data.leaseDepartName
this.maForm.leaseUnitId=res.data.leaseUnitId
this.multipleSelectionTemp = res.data.directApplyDetails
this.getList()
//
if (this.maForm.departName){
const res = await getProjectList({ departName: this.maForm.departName })
this.impProOptions = res.data.map(item => ({
label: item.proName,
value: item.proId
}))
// if (this.impProOptions.length === 1) {
// this.maForm.backProId = this.impProOptions[0].value
await this.onProjectChange(this.maForm.backProId)
// }
}
if (this.maForm.impUnitNameTwo){
const res = await getDepartNameList({ impUnitName: this.maForm.impUnitNameTwo ,enableFilter: false})
this.departOptionsTwo = res.data.map(item => ({
label: item.departName,
value: item.departName
}))
}
if (this.maForm.departNameTwo){
const res = await getProjectList({ departName: this.maForm.departNameTwo,enableFilter: false })
this.leaseProjectList = res.data.map(item => ({
label: item.proName,
value: item.proId
}))
// if (this.leaseProjectList.length === 1) {
// this.maForm.leaseProId = this.leaseProjectList[0].value
await this.onProjectChangeTwo(this.maForm.leaseProId)
// }
}
await this.getList()
console.log('🚀 ~ getTaskInfo ~ this.equipmentList:', this.equipmentList)
loading.close()
} catch (error) {

View File

@ -235,7 +235,8 @@
<div slot="footer" class="dialog-footer" style="text-align: center">
<el-button type="primary" @click="print"> </el-button>
<el-button type="success" @click="handleExportAgreement"> </el-button>
<!-- <el-button type="success" @click="handleExportAgreement"> </el-button> -->
<el-button type="success" @click="exportWord"> </el-button>
<el-button @click="openPrint = false"> </el-button>
</div>
</el-dialog>
@ -324,6 +325,20 @@ import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import printJS from 'print-js'
import ExcelJS from 'exceljs'
import {
Document,
Packer,
Paragraph,
TextRun,
Table,
TableRow,
TableCell,
AlignmentType,
WidthType,
BorderStyle,
PageOrientation
} from 'docx'
export default {
name: 'ApplyHome',
dicts: ['cost_status'],
@ -806,6 +821,335 @@ export default {
// this.download('material/agreementInfo/export', {
// ...this.queryParams
// }, `_${new Date().getTime()}.xlsx`)
},
async exportWord() {
const data = this.agreementContent
// ====== ======
const cellOpts = {
margins: { top: 300, bottom: 300, left: 40, right: 40 }, //
verticalAlign: 'center',
borders: {
top: { style: BorderStyle.SINGLE, size: 1 },
bottom: { style: BorderStyle.SINGLE, size: 1 },
left: { style: BorderStyle.SINGLE, size: 1 },
right: { style: BorderStyle.SINGLE, size: 1 }
}
}
const noBorder = {
top: { style: BorderStyle.NONE },
bottom: { style: BorderStyle.NONE },
left: { style: BorderStyle.NONE },
right: { style: BorderStyle.NONE }
}
// ====== ======
const doc = new Document({
sections: [
{
properties: {
page: {
size: { width: 11900, height: 16840, orientation: PageOrientation.PORTRAIT },
margin: { top: 720, right: 720, bottom: 720, left: 720 }
}
},
children: [
// ===== =====
new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 100, after: 200 },
children: [new TextRun({ text: '机具设备有偿使用费结算协议书', bold: true, size: 32 })]
}),
// ===== =====
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({
children: [
new TableCell({
width: { size: 70, type: WidthType.PERCENTAGE },
borders: noBorder,
children: [new Paragraph({ text: '' })]
}),
new TableCell({
width: { size: 30, type: WidthType.PERCENTAGE },
borders: noBorder,
children: [
new Paragraph({
alignment: AlignmentType.LEFT,
text: `协议号:${data.agreementCode || ''}`,
spacing: { before: 0, after: 0 },
margins: { top: 100, bottom: 100 }
})
]
})
]
}),
new TableRow({
children: [
new TableCell({
width: { size: 70, type: WidthType.PERCENTAGE },
borders: noBorder,
children: [new Paragraph({ text: '' })]
}),
new TableCell({
width: { size: 30, type: WidthType.PERCENTAGE },
borders: noBorder,
children: [
new Paragraph({
alignment: AlignmentType.LEFT,
text: `编号:`,
spacing: { before: 0, after: 0 },
margins: { top: 100, bottom: 100 }
})
]
})
]
})
]
}),
// === Paragraph ===
new Paragraph({
text: '',
spacing: { before: 100, after: 100 } //
}),
// ===== =====
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
//
new TableRow({
children: [
new TableCell({
...cellOpts,
width: { size: 25, type: WidthType.PERCENTAGE },
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: '工程名称:'
})
]
}),
new TableCell({
...cellOpts,
width: { size: 75, type: WidthType.PERCENTAGE },
columnSpan: 3,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: data.projectName
})
]
})
]
}),
// +
new TableRow({
children: [
new TableCell({
...cellOpts,
width: { size: 25, type: WidthType.PERCENTAGE },
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: '承租单位:'
})
]
}),
new TableCell({
...cellOpts,
width: { size: 40, type: WidthType.PERCENTAGE },
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: data.unitName
})
]
}),
new TableCell({
...cellOpts,
width: { size: 10, type: WidthType.PERCENTAGE },
children: [
new Paragraph({ alignment: AlignmentType.CENTER, text: '日期:' })
]
}),
new TableCell({
...cellOpts,
width: { size: 25, type: WidthType.PERCENTAGE },
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: data.applyTime
})
]
})
]
}),
//
new TableRow({
children: [
new TableCell({
...cellOpts,
columnSpan: 4,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: '结算项目及金额(元)',
bold: true
})
]
})
]
}),
//
...[
['一、施工机具有偿使用费:', `${Number(data.leaseCost).toFixed(2)}`],
['二、施工机具维修费:', `${Number(data.repairCost).toFixed(2)}`],
['三、施工机具丢失费:', `${Number(data.loseCost).toFixed(2)}`],
['四、施工机具损坏赔偿费:', `${Number(data.scrapCost).toFixed(2)}`],
['五、施工机具租赁减免费:', `${Number(data.reductionCost).toFixed(2)}`]
].map(
([label, value]) =>
new TableRow({
children: [
new TableCell({
...cellOpts,
columnSpan: 2,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: label
})
]
}),
new TableCell({
...cellOpts,
columnSpan: 2,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: value
})
]
})
]
})
),
//
new TableRow({
children: [
new TableCell({
...cellOpts,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: '费用合计金额(大写):'
})
]
}),
new TableCell({
...cellOpts,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: data.costAllUpper
})
]
}),
new TableCell({
...cellOpts,
columnSpan: 2,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: `${Number(data.costAll).toFixed(2)}`
})
]
})
]
}),
//
new TableRow({
children: [
new TableCell({
...cellOpts,
children: [
new Paragraph({ alignment: AlignmentType.CENTER, text: '说明:' })
]
}),
new TableCell({
...cellOpts,
columnSpan: 3,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: '本协议一式两份,甲方一份,乙方一份,经双方签字后生效。'
})
]
})
]
}),
//
new TableRow({
children: [
new TableCell({
...cellOpts,
children: [
new Paragraph({ alignment: AlignmentType.CENTER, text: '备注:' })
]
}),
new TableCell({
...cellOpts,
columnSpan: 3,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: '此费用仅为在机具设备分公司发生费用,未计从项目部领用机具费用。'
})
]
})
]
})
]
}),
//
new Paragraph({ text: '', spacing: { before: 200 } }),
// ===== =====
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({
children: ['部门负责人:', '承租负责人:', '核算员:'].map(
text =>
new TableCell({
borders: noBorder,
children: [new Paragraph({ alignment: AlignmentType.LEFT, text })],
margins: { top: 200, bottom: 200 } //
})
)
})
]
})
]
}
]
})
const blob = await Packer.toBlob(doc)
saveAs(blob, `机具设备有偿使用费结算协议书-${data.agreementCode}.docx`)
}
}
}

View File

@ -268,8 +268,9 @@
</div>
<div slot="footer" class="dialog-footer" style="text-align: center">
<el-button @click="exportExcel">导出Excel</el-button>
<!-- <el-button @click="exportExcel">导出Excel</el-button> -->
<el-button type="primary" @click="print"> </el-button>
<el-button type="success" @click="exportWord">导出</el-button>
<el-button @click="openPrint = false"> </el-button>
</div>
</el-dialog>
@ -286,6 +287,19 @@ import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { formatTime } from '@/utils/bonus'
import { saveAs } from 'file-saver'
import ExcelJS from 'exceljs'
import {
Document,
Packer,
Paragraph,
TextRun,
Table,
TableRow,
TableCell,
AlignmentType,
WidthType,
BorderStyle,
PageOrientation
} from 'docx'
export default {
name: 'ExamHome',
@ -657,6 +671,335 @@ export default {
// ======= =======
const buf = await workbook.xlsx.writeBuffer()
saveAs(new Blob([buf]), `机具设备有偿使用费结算协议书-${data.agreementCode}_${formatTime(new Date())}.xlsx`)
},
async exportWord() {
const data = this.agreementContent
// ====== ======
const cellOpts = {
margins: { top: 300, bottom: 300, left: 40, right: 40 }, //
verticalAlign: 'center',
borders: {
top: { style: BorderStyle.SINGLE, size: 1 },
bottom: { style: BorderStyle.SINGLE, size: 1 },
left: { style: BorderStyle.SINGLE, size: 1 },
right: { style: BorderStyle.SINGLE, size: 1 }
}
}
const noBorder = {
top: { style: BorderStyle.NONE },
bottom: { style: BorderStyle.NONE },
left: { style: BorderStyle.NONE },
right: { style: BorderStyle.NONE }
}
// ====== ======
const doc = new Document({
sections: [
{
properties: {
page: {
size: { width: 11900, height: 16840, orientation: PageOrientation.PORTRAIT },
margin: { top: 720, right: 720, bottom: 720, left: 720 }
}
},
children: [
// ===== =====
new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 100, after: 200 },
children: [new TextRun({ text: '机具设备有偿使用费结算协议书', bold: true, size: 32 })]
}),
// ===== =====
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({
children: [
new TableCell({
width: { size: 70, type: WidthType.PERCENTAGE },
borders: noBorder,
children: [new Paragraph({ text: '' })]
}),
new TableCell({
width: { size: 30, type: WidthType.PERCENTAGE },
borders: noBorder,
children: [
new Paragraph({
alignment: AlignmentType.LEFT,
text: `协议号:${data.agreementCode || ''}`,
spacing: { before: 0, after: 0 }
})
],
margins: { top: 100, bottom: 100 } //
})
]
}),
new TableRow({
children: [
new TableCell({
width: { size: 70, type: WidthType.PERCENTAGE },
borders: noBorder,
children: [new Paragraph({ text: '' })]
}),
new TableCell({
width: { size: 30, type: WidthType.PERCENTAGE },
borders: noBorder,
children: [
new Paragraph({
alignment: AlignmentType.LEFT,
text: `编号:`,
spacing: { before: 0, after: 0 }
})
],
margins: { top: 100, bottom: 100 } //
})
]
})
]
}),
// === Paragraph ===
new Paragraph({
text: '',
spacing: { before: 100, after: 100 } //
}),
// ===== =====
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
//
new TableRow({
children: [
new TableCell({
...cellOpts,
width: { size: 25, type: WidthType.PERCENTAGE },
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: '工程名称:'
})
]
}),
new TableCell({
...cellOpts,
width: { size: 75, type: WidthType.PERCENTAGE },
columnSpan: 3,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: data.projectName
})
]
})
]
}),
// +
new TableRow({
children: [
new TableCell({
...cellOpts,
width: { size: 25, type: WidthType.PERCENTAGE },
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: '承租单位:'
})
]
}),
new TableCell({
...cellOpts,
width: { size: 40, type: WidthType.PERCENTAGE },
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: data.unitName
})
]
}),
new TableCell({
...cellOpts,
width: { size: 10, type: WidthType.PERCENTAGE },
children: [
new Paragraph({ alignment: AlignmentType.CENTER, text: '日期:' })
]
}),
new TableCell({
...cellOpts,
width: { size: 25, type: WidthType.PERCENTAGE },
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: data.applyTime
})
]
})
]
}),
//
new TableRow({
children: [
new TableCell({
...cellOpts,
columnSpan: 4,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: '结算项目及金额(元)',
bold: true
})
]
})
]
}),
//
...[
['一、施工机具有偿使用费:', `${Number(data.leaseCost).toFixed(2)}`],
['二、施工机具维修费:', `${Number(data.repairCost).toFixed(2)}`],
['三、施工机具丢失费:', `${Number(data.loseCost).toFixed(2)}`],
['四、施工机具损坏赔偿费:', `${Number(data.scrapCost).toFixed(2)}`],
['五、施工机具租赁减免费:', `${Number(data.reductionCost).toFixed(2)}`]
].map(
([label, value]) =>
new TableRow({
children: [
new TableCell({
...cellOpts,
columnSpan: 2,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: label
})
]
}),
new TableCell({
...cellOpts,
columnSpan: 2,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: value
})
]
})
]
})
),
//
new TableRow({
children: [
new TableCell({
...cellOpts,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: '费用合计金额(大写):'
})
]
}),
new TableCell({
...cellOpts,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: data.costAllUpper
})
]
}),
new TableCell({
...cellOpts,
columnSpan: 2,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: `${Number(data.costAll).toFixed(2)}`
})
]
})
]
}),
//
new TableRow({
children: [
new TableCell({
...cellOpts,
children: [
new Paragraph({ alignment: AlignmentType.CENTER, text: '说明:' })
]
}),
new TableCell({
...cellOpts,
columnSpan: 3,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: '本协议一式两份,甲方一份,乙方一份,经双方签字后生效。'
})
]
})
]
}),
//
new TableRow({
children: [
new TableCell({
...cellOpts,
children: [
new Paragraph({ alignment: AlignmentType.CENTER, text: '备注:' })
]
}),
new TableCell({
...cellOpts,
columnSpan: 3,
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
text: '此费用仅为在机具设备分公司发生费用,未计从项目部领用机具费用。'
})
]
})
]
})
]
}),
//
new Paragraph({ text: '', spacing: { before: 200 } }),
// ===== =====
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
rows: [
new TableRow({
children: ['部门负责人:', '承租负责人:', '核算员:'].map(
text =>
new TableCell({
borders: noBorder,
children: [new Paragraph({ alignment: AlignmentType.LEFT, text })],
margins: { top: 200, bottom: 200 } //
})
)
})
]
})
]
}
]
})
const blob = await Packer.toBlob(doc)
saveAs(blob, `机具设备有偿使用费结算协议书-${data.agreementCode}.docx`)
}
}
}

View File

@ -188,6 +188,7 @@ export default {
time: [],
startTime: undefined,
endTime: undefined,
taskStatus: '',
},
queryInBoundInfo:{
pageNum: 1,