This commit is contained in:
parent
844d783715
commit
e274cc8e7f
|
|
@ -57,18 +57,24 @@
|
|||
<el-input v-model="form.originalValue" placeholder="资产原值(万元)" readonly />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="资产净值(万元)" prop="value">
|
||||
<el-input v-model="form.value" placeholder="资产净值(万元)" readonly />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="生产厂家" prop="manufacturer">
|
||||
<el-input v-model="form.manufacturer" placeholder="生产厂家" readonly />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
</el-row>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="6">
|
||||
<el-form-item label="出厂日期" prop="productionDate">
|
||||
<el-input v-model="form.productionDate" placeholder="出厂日期" readonly />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="6">
|
||||
<el-form-item label="下次维保日期" prop="nextMaintenanceDate">
|
||||
<el-input v-model="form.nextMaintenanceDate" placeholder="下次维保日期" readonly />
|
||||
|
|
@ -84,11 +90,7 @@
|
|||
<el-input clearable maxlength="20" placeholder="最大使用年限" v-model="form.maxServiceLifeYears" readonly />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="计数单位" prop="unit">
|
||||
<el-input v-model="form.unit" placeholder="计数单位" readonly />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<!-- <el-col :span="6">
|
||||
<el-form-item label="管理模式" prop="manageType">
|
||||
<el-input v-model="form.manageTypeName" placeholder="管理方式" readonly />
|
||||
|
|
@ -101,6 +103,11 @@
|
|||
<el-input v-model="form.count" placeholder="装备数量" readonly />
|
||||
</el-form-item>
|
||||
</el-col> -->
|
||||
<el-col :span="6">
|
||||
<el-form-item label="计数单位" prop="unit">
|
||||
<el-input v-model="form.unit" placeholder="计数单位" readonly />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="采购日期" prop="purchaseDate">
|
||||
<el-input v-model="form.purchaseDate" placeholder="采购日期" readonly />
|
||||
|
|
|
|||
|
|
@ -804,6 +804,7 @@ export default {
|
|||
{ key: 17, label: `出厂日期`, prop: 'productionDate', visible: true },
|
||||
{ key: 18, label: `采购日期`, prop: 'purchaseDate', visible: true },
|
||||
{ key: 19, label: `资产原值(万元)`, prop: 'originalValue', visible: true },
|
||||
{ key: 19, label: `资产净值(万元)`, prop: 'value', visible: true },
|
||||
{ key: 20, label: `最大使用年限(年)`, prop: 'maxServiceLifeYears', visible: true },
|
||||
{ key: 21, label: `下次维保日期`, prop: 'nextMaintenanceDate', visible: true },
|
||||
{ key: 22, label: `装备外观`, prop: 'appearanceImages', visible: true },
|
||||
|
|
|
|||
|
|
@ -262,9 +262,42 @@ export default {
|
|||
)
|
||||
},
|
||||
|
||||
// 下载
|
||||
// 下载PDF方法
|
||||
onHandleDownload() {
|
||||
this.download('material-mall/decChange/exportDetails', { id: this.recordId }, `出库记录单.xlsx`)
|
||||
this.downloadPDF('material-mall/decChange/exportDetails', { id: this.recordId }, '出库记录单.pdf');
|
||||
},
|
||||
|
||||
// 封装PDF下载逻辑
|
||||
async downloadPDF(url, params, fileName) {
|
||||
try {
|
||||
// 关键:设置responseType为blob(二进制流)
|
||||
const response = await this.$axios({
|
||||
method: 'post',
|
||||
url: url,
|
||||
data: params, // POST请求参数
|
||||
responseType: 'blob', // 必须指定为blob
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=UTF-8' // 匹配后端接收格式
|
||||
}
|
||||
});
|
||||
|
||||
// 创建下载链接
|
||||
const blob = new Blob([response.data], { type: 'application/pdf' });
|
||||
const downloadUrl = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = downloadUrl;
|
||||
link.download = fileName; // 文件名
|
||||
document.body.appendChild(link);
|
||||
link.click(); // 触发下载
|
||||
|
||||
// 释放资源
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(downloadUrl);
|
||||
|
||||
this.$message.success('PDF导出成功!');
|
||||
} catch (error) {
|
||||
this.$message.error('PDF导出失败:' + (error.message || '未知错误'));
|
||||
}
|
||||
},
|
||||
|
||||
// 打印
|
||||
|
|
@ -319,7 +352,7 @@ export default {
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
|
||||
|
||||
::v-deep .el-card__body {
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,17 @@
|
|||
:label="item.proName"
|
||||
:value="item.proCode"
|
||||
v-for="item in useProjectList"
|
||||
/>
|
||||
style="width: 200px"
|
||||
>
|
||||
<el-tooltip
|
||||
effect="dark"
|
||||
:content="item.proName"
|
||||
placement="right"
|
||||
>
|
||||
<span class="option-text">{{ item.proName }}</span>
|
||||
</el-tooltip>
|
||||
</el-option>
|
||||
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
|
|
|
|||
|
|
@ -85,6 +85,17 @@
|
|||
<el-col :span="1.5">
|
||||
<div style="font-size: 20px; font-weight: 800">编码工具台账列表</div>
|
||||
</el-col>
|
||||
|
||||
<el-button
|
||||
icon="el-icon-download"
|
||||
style="margin-left: 1250px"
|
||||
type="primary"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
>
|
||||
导出数据
|
||||
</el-button>
|
||||
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" />
|
||||
</el-row>
|
||||
|
||||
|
|
@ -565,6 +576,17 @@ export default {
|
|||
if (!val) return
|
||||
this.getSelectList()
|
||||
},
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
*/
|
||||
handleExport() {
|
||||
this.download('/material-mall/toolLedger/export', {
|
||||
...this.queryParams
|
||||
}, `编码工具台账_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
|
||||
|
||||
// 获取厂家
|
||||
async getManufacturerSelect() {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -7,17 +7,13 @@
|
|||
<el-cascader
|
||||
v-model="typeIdList"
|
||||
:options="options"
|
||||
:props="{ value: 'typeId', label: 'typeName' }"
|
||||
:props="{ value: 'typeId', label: 'typeName', checkStrictly: false }"
|
||||
clearable
|
||||
@change="handleChange"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-plus" :disabled="typeIdList.length == 0" @click="handleAdd"
|
||||
>点击填充</el-button
|
||||
>
|
||||
</el-form-item>
|
||||
<!-- 移除原来的“点击填充”按钮 -->
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
|
|
@ -38,9 +34,11 @@
|
|||
:prop="column.prop"
|
||||
align="center"
|
||||
>
|
||||
<!-- 插槽 -->
|
||||
<template v-slot="{ row }" v-if="column.prop == 'applyNum'">
|
||||
<!-- 合并插槽逻辑:用 v-if + v-else-if 区分不同列的输入框 -->
|
||||
<template v-slot="{ row }">
|
||||
<!-- 申请数量输入框 -->
|
||||
<el-input-number
|
||||
v-if="column.prop == 'applyNum'"
|
||||
v-model="row.applyNum"
|
||||
:min="1"
|
||||
:max="9999"
|
||||
|
|
@ -48,12 +46,24 @@
|
|||
:controls="false"
|
||||
style="width: 120px"
|
||||
/>
|
||||
<!-- 单价输入框 -->
|
||||
<el-input-number
|
||||
v-else-if="column.prop == 'originCost'"
|
||||
v-model="row.originCost"
|
||||
:min="0"
|
||||
:max="999999.99"
|
||||
:precision="2"
|
||||
:controls="false"
|
||||
style="width: 120px"
|
||||
/>
|
||||
<!-- 其他列默认显示文本 -->
|
||||
<span v-else>{{ row[column.prop] }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template slot-scope="{ row, $index }">
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(index)" style="color: red"
|
||||
>删除</el-button
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
|
@ -84,6 +94,7 @@ export default {
|
|||
{ label: '工具名称', prop: 'parentTypeName' },
|
||||
{ label: '规格型号', prop: 'typeName' },
|
||||
{ label: '计量单位', prop: 'unitName' },
|
||||
{ label: '单价', prop: 'originCost', width: 150 },
|
||||
{ label: '申请数量', prop: 'applyNum', width: 150 },
|
||||
],
|
||||
dialogList: [],
|
||||
|
|
@ -114,7 +125,7 @@ export default {
|
|||
handleTree(tree) {
|
||||
for (const node of tree) {
|
||||
if (node.level === '5') {
|
||||
// 删除 children
|
||||
// 删除 children,标记为最终可选节点
|
||||
delete node.children
|
||||
} else if (node.children && node.children.length > 0) {
|
||||
// 继续递归下级
|
||||
|
|
@ -123,12 +134,56 @@ export default {
|
|||
}
|
||||
},
|
||||
handleChange(val) {
|
||||
console.log('🚀 ~ val:', val)
|
||||
this.dialogForm.typeId = val ? val[val.length - 1] : ''
|
||||
console.log('🚀 ~ 选中的节点ID路径:', val)
|
||||
// 1. 空值(取消选择)直接返回
|
||||
if (!val || val.length === 0) {
|
||||
this.dialogForm.typeId = ''
|
||||
this.activeLabels = []
|
||||
this.lastNode = null
|
||||
return
|
||||
}
|
||||
|
||||
// 2. 获取最后一级节点信息
|
||||
this.dialogForm.typeId = val[val.length - 1]
|
||||
this.activeLabels = this.getLabelsFromValuePath(val, this.options)
|
||||
this.lastNode = this.findNodeById(this.options, val[val.length - 1])
|
||||
console.log('🚀 ~ this.lastNode:', this.lastNode)
|
||||
console.log('选中的 labels:', this.activeLabels)
|
||||
this.lastNode = this.findNodeById(this.options, this.dialogForm.typeId)
|
||||
|
||||
// 3. 仅当选中最后一级节点(level=5)时,自动填充表格
|
||||
if (this.lastNode?.level === '5') {
|
||||
this.autoAddToTable()
|
||||
}
|
||||
},
|
||||
// 自动添加到表格的核心逻辑(提取原handleAdd的逻辑)
|
||||
autoAddToTable() {
|
||||
const typeId = this.dialogForm.typeId
|
||||
// 去重判断:已添加则提示并返回
|
||||
if (this.dialogList.some((item) => item.typeId === typeId)) {
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '该工具已添加,请勿重复选择!',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 初始化默认值并添加到表格
|
||||
const originCost = this.lastNode?.originCost || 0
|
||||
this.dialogList.unshift({
|
||||
applyId: this.dialogForm.applyId,
|
||||
typeId,
|
||||
fourthParentName: this.activeLabels[0] || '',
|
||||
greatGrandparentName: this.activeLabels[1] || '',
|
||||
grandparentTypeName: this.activeLabels[2] || '',
|
||||
parentTypeName: this.activeLabels[3] || '',
|
||||
typeName: this.activeLabels[4] || '',
|
||||
unitName: this.lastNode.unitName || '',
|
||||
originCost,
|
||||
applyNum: 1,
|
||||
})
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '工具已添加到列表!',
|
||||
duration: 1500, // 缩短提示时长,提升体验
|
||||
})
|
||||
},
|
||||
getLabelsFromValuePath(valuePath, options) {
|
||||
let labels = []
|
||||
|
|
@ -155,29 +210,6 @@ export default {
|
|||
}
|
||||
return null // 没找到
|
||||
},
|
||||
handleAdd() {
|
||||
console.log('🚀 ~ handleAdd:', this.dialogForm.typeId)
|
||||
const typeId = this.typeIdList[this.typeIdList.length - 1]
|
||||
if (this.dialogList.some((item) => item.typeId === typeId)) {
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '该工具已添加!',
|
||||
})
|
||||
return
|
||||
}
|
||||
this.dialogList.unshift({
|
||||
applyId: this.dialogForm.applyId,
|
||||
typeId,
|
||||
fourthParentName: this.activeLabels[0],
|
||||
greatGrandparentName: this.activeLabels[1],
|
||||
grandparentTypeName: this.activeLabels[2],
|
||||
parentTypeName: this.activeLabels[3],
|
||||
typeName: this.activeLabels[4],
|
||||
unitName: this.lastNode.unitName,
|
||||
applyNum: 1,
|
||||
})
|
||||
console.log('🚀 ~ this.dialogList:', this.dialogList)
|
||||
},
|
||||
handleDelete(index) {
|
||||
this.dialogList.splice(index, 1)
|
||||
this.$message({
|
||||
|
|
|
|||
|
|
@ -77,6 +77,15 @@
|
|||
<!-- <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出数据</el-button> -->
|
||||
<div style="font-size: 20; font-weight: 800">工具台账列表</div>
|
||||
</el-col>
|
||||
<el-button
|
||||
icon="el-icon-download"
|
||||
style="margin-left: 1250px"
|
||||
type="primary"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
>
|
||||
导出数据
|
||||
</el-button>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" />
|
||||
</el-row>
|
||||
|
||||
|
|
@ -115,7 +124,7 @@
|
|||
|
||||
<!-- 分页 -->
|
||||
<pagination
|
||||
|
||||
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
|
|
@ -464,21 +473,33 @@ export default {
|
|||
}
|
||||
},
|
||||
// 导出数据
|
||||
// handleExport() {
|
||||
// // 提示
|
||||
// this.$message({
|
||||
// type: 'warning',
|
||||
// message: '导出功能开发中,敬请期待!',
|
||||
// })
|
||||
// try {
|
||||
// let fileName = `导出_${formatTime(new Date())}.xLsx`
|
||||
// let url = '/material/backstage/costPush/exportPushCheck'
|
||||
// const params = { ...this.queryParams }
|
||||
// // this.download(url, params, fileName)
|
||||
// } catch (error) {
|
||||
// console.log('导出数据失败', error)
|
||||
// }
|
||||
// },
|
||||
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
*/
|
||||
handleExport() {
|
||||
// 提示
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '导出功能开发中,敬请期待!',
|
||||
})
|
||||
try {
|
||||
let fileName = `导出_${formatTime(new Date())}.xLsx`
|
||||
let url = '/material/backstage/costPush/exportPushCheck'
|
||||
const params = { ...this.queryParams }
|
||||
// this.download(url, params, fileName)
|
||||
} catch (error) {
|
||||
console.log('导出数据失败', error)
|
||||
}
|
||||
this.download('/material-mall/toolLedger/exportAll', {
|
||||
...this.queryParams
|
||||
}, `工具台账_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
@ -490,7 +511,7 @@ export default {
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
|
||||
|
||||
::v-deep .el-card__body {
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
|
|
|
|||
Loading…
Reference in New Issue