bonus-ui/src/views/toolsManage/codeToolsLedger/index.vue

1086 lines
37 KiB
Vue
Raw Normal View History

2025-11-13 17:51:15 +08:00
<template>
<!-- 基础页面 -->
2026-01-23 15:39:18 +08:00
<div class="app-container" v-loading="isLoading">
2025-11-14 16:26:33 +08:00
<el-card v-show="showSearch" style="margin-bottom: 20px">
2026-01-23 15:39:18 +08:00
<el-form :model="queryParams" ref="queryForm" size="small" label-width="140px" inline @submit.native.prevent>
2026-01-13 14:10:12 +08:00
<el-form-item label="产权单位" prop="propertyUnitIds">
<el-cascader
clearable
v-model="queryParams.propertyUnitIds"
placeholder="请选择产权单位"
:options="propertyUnitList"
:props="{ label: 'label', value: 'id', children: 'children', checkStrictly: true }"
2026-01-23 15:39:18 +08:00
style="width: 300px"
2026-01-13 14:10:12 +08:00
@change="handleUnitChange"
/>
</el-form-item>
2025-11-14 16:26:33 +08:00
<el-form-item label="工具专业" prop="fourthParentId">
<el-select
v-model="queryParams.fourthParentId"
placeholder="请选择工具专业"
clearable
filterable
@change="(val) => changeType(val, '2')"
2026-01-23 15:39:18 +08:00
style="width: 300px"
2025-11-14 16:26:33 +08:00
>
<el-option v-for="item in fourthParentList" :key="item.id" :label="item.label" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="施工类型" prop="greatGrandparentId">
<el-select
v-model="queryParams.greatGrandparentId"
placeholder="请选择施工类型"
clearable
filterable
:disabled="!queryParams.fourthParentId"
@change="(val) => changeType(val, '3')"
2026-01-23 15:39:18 +08:00
style="width: 300px"
2025-11-14 16:26:33 +08:00
>
<el-option v-for="item in greatGrandparentList" :key="item.id" :label="item.label" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="工具类型" prop="grandparentTypeId">
<el-select
v-model="queryParams.grandparentTypeId"
placeholder="请选择工具类型"
clearable
filterable
:disabled="!queryParams.greatGrandparentId"
@change="(val) => changeType(val, '4')"
2026-01-23 15:39:18 +08:00
style="width: 300px"
2025-11-14 16:26:33 +08:00
>
<el-option v-for="item in grandparentTypeList" :key="item.id" :label="item.label" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="工具名称" prop="parentTypeId">
<el-select
v-model="queryParams.parentTypeId"
placeholder="请选择工具名称"
clearable
filterable
:disabled="!queryParams.grandparentTypeId"
2026-01-23 15:39:18 +08:00
style="width: 300px"
2025-11-14 16:26:33 +08:00
>
<el-option v-for="item in parentTypeList" :key="item.id" :label="item.label" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="规格型号" prop="typeName">
2025-11-13 17:51:15 +08:00
<el-input
2025-11-14 16:26:33 +08:00
v-model="queryParams.typeName"
placeholder="请输入规格型号"
2025-11-13 17:51:15 +08:00
clearable
@keyup.enter.native="handleQuery"
2026-01-23 15:39:18 +08:00
style="width: 300px"
2025-11-13 17:51:15 +08:00
/>
</el-form-item>
2025-11-14 16:26:33 +08:00
<el-form-item label="工具编码" prop="toolCode">
<el-input
v-model="queryParams.toolCode"
2025-11-26 17:05:11 +08:00
placeholder="请输入工具编码"
2025-11-13 17:51:15 +08:00
clearable
2025-11-14 16:26:33 +08:00
@keyup.enter.native="handleQuery"
2026-01-23 15:39:18 +08:00
style="width: 300px"
2025-11-13 17:51:15 +08:00
/>
</el-form-item>
<!-- 表单按钮 -->
2025-12-02 17:54:15 +08:00
<el-form-item style="float: right">
2026-01-19 18:23:33 +08:00
<el-button icon="el-icon-refresh" size="mini" @click="handleReset">重置</el-button>
2026-01-26 18:37:15 +08:00
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
2025-11-13 17:51:15 +08:00
</el-form-item>
</el-form>
</el-card>
2025-12-09 17:23:42 +08:00
<el-card class="content-box">
2025-11-13 17:51:15 +08:00
<el-row :gutter="10" class="mb8">
2026-01-23 15:39:18 +08:00
<el-col :span="8">
2025-11-20 18:02:34 +08:00
<div style="font-size: 20px; font-weight: 800">编码工具台账列表</div>
2025-11-13 17:51:15 +08:00
</el-col>
2026-01-23 15:39:18 +08:00
<el-col :span="16" style="text-align: right;">
2026-01-26 19:51:54 +08:00
<!-- <el-button style="background-color:#fff;border: 1px solid #d9d9d9;color:rgba(0,0,0,.65)" type="primary" size="mini" @click="handleExport">
2026-01-26 11:17:46 +08:00
<svg-icon icon-class="download"/> 导出
2026-01-26 19:51:54 +08:00
</el-button> -->
2026-01-27 14:09:35 +08:00
<el-dropdown size="mini" style="margin-right: 10px;" placement="bottom-start" trigger="click" @visible-change="handleVisibleChange" @command="(command) => handleCommand(command)">
2026-01-26 19:51:54 +08:00
<el-button plain size="mini" class="el-dropdown-link">
2026-01-27 14:09:35 +08:00
导出 <i class="el-icon-arrow-up el-icon--right" :class="{ 'rotate': isDropdownOpen }"></i>
2026-01-26 19:51:54 +08:00
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="handleDownloadPage">导出当前页</el-dropdown-item>
2026-01-27 14:09:35 +08:00
<el-dropdown-item command="handleDownloadAll">导出全部</el-dropdown-item>
2026-01-26 19:51:54 +08:00
</el-dropdown-menu>
</el-dropdown>
2026-01-27 18:50:50 +08:00
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="tableColumns" />
2026-01-23 15:39:18 +08:00
</el-col>
2025-11-13 17:51:15 +08:00
</el-row>
2025-11-14 16:26:33 +08:00
<el-table
:data="tableList"
highlight-current-row
border
stripe
2026-01-25 18:03:37 +08:00
height="546"
2025-11-14 16:26:33 +08:00
style="width: 100%"
>
2025-11-13 17:51:15 +08:00
<el-table-column
type="index"
width="55"
label="序号"
align="center"
:index="(index) => (queryParams.pageNum - 1) * queryParams.pageSize + index + 1"
/>
<el-table-column
v-for="(column, index) in tableColumns"
2026-01-27 18:50:50 +08:00
v-if="column.visible"
2025-11-13 17:51:15 +08:00
show-overflow-tooltip
2026-01-27 18:50:50 +08:00
:key="column.key"
2025-11-13 17:51:15 +08:00
:label="column.label"
:prop="column.prop"
align="center"
2025-12-30 23:30:36 +08:00
:min-width="column.width"
2025-11-13 17:51:15 +08:00
>
2025-12-19 13:25:06 +08:00
<!-- 插槽 -->
2025-11-14 16:26:33 +08:00
<template v-slot="{ row }">
2025-12-19 13:25:06 +08:00
<span v-if="column.prop == 'status'">
<el-tag v-if="row.status == 0" type="success">在库</el-tag>
<el-tag v-if="row.status == 1" type="info">在用</el-tag>
<el-tag v-if="row.status == 2" type="warning">在修</el-tag>
<el-tag v-if="row.status == 3" type="danger">已报废</el-tag>
</span>
<span v-else>{{ row[column.prop] }}</span>
2025-11-13 17:51:15 +08:00
</template>
</el-table-column>
2025-12-30 23:30:36 +08:00
<el-table-column label="操作" align="center" min-width="150">
2025-11-13 17:51:15 +08:00
<template slot-scope="{ row }">
2026-01-19 18:23:33 +08:00
<el-button type="text" @click="handleDialog(row, true)">查看</el-button>
<el-button type="text" @click="handleDialog(row, false)">编辑</el-button>
2025-11-13 17:51:15 +08:00
</template>
2025-11-14 16:26:33 +08:00
</el-table-column>
2025-11-13 17:51:15 +08:00
</el-table>
<!-- 分页 -->
<pagination
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-card>
<!-- 弹框 -->
2026-01-23 15:39:18 +08:00
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="60%">
2025-11-14 16:26:33 +08:00
<el-form
ref="dialogForm"
:model="dialogForm"
2025-12-18 15:50:50 +08:00
:rules="dialogRules"
label-width="115px"
2025-11-14 16:26:33 +08:00
size="small"
inline
@submit.native.prevent
:disabled="isView"
>
<el-form-item label="工具专业" prop="fourthParentName">
<el-input v-model="dialogForm.fourthParentName" placeholder="请输入工具专业" readonly style="width: 240px" />
2025-11-13 17:51:15 +08:00
</el-form-item>
2025-11-14 16:26:33 +08:00
<el-form-item label="施工类型" prop="greatGrandparentName">
<el-input
v-model="dialogForm.greatGrandparentName"
2025-11-26 17:05:11 +08:00
placeholder="请输入施工类型"
2025-11-14 16:26:33 +08:00
readonly
style="width: 240px"
/>
</el-form-item>
<el-form-item label="工具类型" prop="grandparentTypeName">
<el-input
v-model="dialogForm.grandparentTypeName"
2025-11-26 17:05:11 +08:00
placeholder="请输入工具类型"
2025-11-14 16:26:33 +08:00
readonly
style="width: 240px"
/>
</el-form-item>
<el-form-item label="工具名称" prop="parentTypeName">
2025-11-26 17:05:11 +08:00
<el-input v-model="dialogForm.parentTypeName" placeholder="请输入工具名称" readonly style="width: 240px" />
2025-11-14 16:26:33 +08:00
</el-form-item>
<el-form-item label="规格型号" prop="typeName">
2025-11-26 17:05:11 +08:00
<el-input v-model="dialogForm.typeName" placeholder="请输入规格型号" readonly style="width: 240px" />
2025-11-14 16:26:33 +08:00
</el-form-item>
<el-form-item label="工具编码" prop="toolCode">
2025-11-26 17:05:11 +08:00
<el-input v-model="dialogForm.toolCode" placeholder="请输入工具编码" readonly style="width: 240px" />
2025-11-14 16:26:33 +08:00
</el-form-item>
<el-form-item label="计量单位" prop="unitName">
<el-select v-model="dialogForm.unitName" placeholder="请选择计量单位" clearable style="width: 240px">
<el-option
v-for="dict in dict.type.dev_unit_type"
:key="dict.label"
:label="dict.label"
:value="dict.label"
/>
</el-select>
</el-form-item>
<!-- 厂家 -->
2025-12-18 15:50:50 +08:00
<el-form-item label="生产厂家" prop="supplierId">
2025-11-14 16:26:33 +08:00
<el-select v-model="dialogForm.supplierId" placeholder="请选择厂家" clearable style="width: 240px">
<el-option
v-for="item in manufacturerSelect"
:key="item.id"
:label="item.label"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<!-- 出厂日期 -->
2025-12-18 15:50:50 +08:00
<el-form-item label="出厂日期" prop="productionDate">
2025-11-14 16:26:33 +08:00
<el-date-picker
v-model="dialogForm.productionDate"
type="date"
clearable
placeholder="选择出厂日期"
value-format="yyyy-MM-dd"
style="width: 240px"
/>
</el-form-item>
2025-12-18 15:50:50 +08:00
<!-- <el-form-item label="本次检验时间">
<el-date-picker
v-model="dialogForm.lastCheckDate"
type="date"
clearable
placeholder="选择本次检验时间"
value-format="yyyy-MM-dd"
style="width: 240px"
/>
</el-form-item> -->
<el-form-item label="资产原值(万元)" prop="originCost">
2025-11-14 16:26:33 +08:00
<el-input-number
v-model="dialogForm.originCost"
:min="0"
:max="99999999"
:controls="false"
:precision="0"
style="width: 240px"
/>
</el-form-item>
2025-12-18 15:50:50 +08:00
<el-form-item label="原始编码" prop="identifyCode">
2025-11-14 16:26:33 +08:00
<el-input v-model="dialogForm.identifyCode" maxlength="999" style="width: 240px" />
</el-form-item>
<el-form-item label="下次检验时间">
<el-date-picker
v-model="dialogForm.nextCheckDate"
type="date"
clearable
placeholder="选择下次检验时间"
value-format="yyyy-MM-dd"
style="width: 240px"
/>
</el-form-item>
<el-form-item label="工具状态">
2025-11-26 17:05:11 +08:00
<el-input v-model="dialogForm.statusName" readonly style="width: 240px" />
2025-11-14 16:26:33 +08:00
</el-form-item>
<div v-for="(item, index) in dialogForm.propertyVoList" :key="index">
<el-form-item label="特征项">
<el-input v-model="item.propertyName" placeholder="请输入特征项" style="width: 240px" />
</el-form-item>
<el-form-item label="特征值">
<div style="display: flex; align-items: center">
<el-input v-model="item.propertyValue" placeholder="请输入特征值" style="width: 240px" />
<i
v-if="index == dialogForm.propertyVoList.length - 1 && dialogForm.propertyVoList.length < 9 && !isView"
class="el-icon-circle-plus-outline"
@click="handleProperty('add', index)"
style="color: #67c23a; font-size: 24px; margin-left: 8px"
/>
<i
v-if="index != 0 && !isView"
class="el-icon-remove-outline"
@click="handleProperty('remove', index)"
style="color: #f56c6c; font-size: 24px; margin-left: 8px"
/>
</div>
</el-form-item>
</div>
2025-11-26 18:45:27 +08:00
2025-11-26 17:05:11 +08:00
<!-- 附件区域仅修改这里的图标显示 -->
2025-12-15 17:51:13 +08:00
<!-- <el-form-item label="附件" prop="fileList">
2025-11-26 17:05:11 +08:00
<div class="custom-file-upload">
<el-upload
multiple
:action="uploadFileUrl"
:before-upload="handleBeforeUpload"
:file-list="dialogForm.fileList"
:limit="9"
:on-error="handleUploadError"
:on-exceed="handleExceed"
:on-success="handleUploadSuccess"
:show-file-list="false"
:headers="headers"
ref="fileUpload"
:disabled="isView"
>
2025-12-15 17:51:13 +08:00
2025-11-26 17:05:11 +08:00
<el-button size="mini" type="primary">选取文件</el-button>
2025-12-15 17:51:13 +08:00
2025-11-26 17:05:11 +08:00
<div class="el-upload__tip" slot="tip" v-if="showTip">
请上传大小不超过5MB格式为 docxlspdfjpgjpegpng 的文件
</div>
</el-upload>
2025-12-15 17:51:13 +08:00
2025-11-26 18:45:27 +08:00
<transition-group name="el-fade-in-linear" tag="ul">
2025-11-26 17:05:11 +08:00
<li
:key="file.uid"
class="file-item"
v-for="(file, index) in dialogForm.fileList"
>
<el-link
:href="file.url"
:underline="false"
target="_blank"
class="file-name-link"
>
2025-12-15 17:51:13 +08:00
2025-11-26 18:45:27 +08:00
<div class="file-icon-container">
<img
v-if="isPdfFile(file)"
src="@/assets/images/pdf.png"
class="file-type-icon"
alt="PDF文件"
/>
<img
v-else-if="isWordFile(file)"
src="@/assets/images/word.png"
class="file-type-icon"
alt="Word文件"
/>
<img
v-else-if="isExcelFile(file)"
src="@/assets/images/pdf.png"
class="file-type-icon"
alt="Excel文件"
/>
<img
v-else-if="isImageFile(file)"
2025-12-01 09:35:27 +08:00
:src="file.url"
2025-11-26 18:45:27 +08:00
class="file-type-icon"
alt="图片文件"
/>
<i v-else class="el-icon-file file-default-icon"></i>
</div>
2025-11-26 17:05:11 +08:00
</el-link>
<div class="file-action">
<el-link
v-if="!isView"
:underline="false"
@click.stop="handleDeleteFile(index)"
type="danger"
>
删除
</el-link>
</div>
</li>
</transition-group>
</div>
2025-12-15 17:51:13 +08:00
</el-form-item> -->
<el-row :gutter="20">
<el-col :span="24" :offset="0">
<el-form-item label="合格证" prop="certificateList">
<FileUpload
v-model="dialogForm.certificateList"
:value="dialogForm.certificateList"
:limit="3"
:fileSize="10"
:fileType="['jpg', 'png', 'pdf']"
/>
</el-form-item>
</el-col>
<el-col :span="24" :offset="0">
<el-form-item label="检测证书" prop="inspectionList">
<FileUpload
v-model="dialogForm.inspectionList"
:value="dialogForm.inspectionList"
:limit="3"
:fileSize="10"
:fileType="['jpg', 'png', 'pdf']"
/>
</el-form-item>
</el-col>
<el-col :span="24" :offset="0">
<el-form-item label="采购发票" prop="purchaseInvoicesList">
<FileUpload
v-model="dialogForm.purchaseInvoicesList"
:value="dialogForm.purchaseInvoicesList"
:limit="3"
:fileSize="10"
:fileType="['jpg', 'png', 'pdf']"
/>
</el-form-item>
</el-col>
</el-row>
2025-11-13 17:51:15 +08:00
</el-form>
<span slot="footer" class="dialog-footer">
2025-11-14 16:26:33 +08:00
<el-button v-if="!isView" type="primary" @click="submit"> </el-button>
<el-button @click="dialogVisible = false">{{ isView ? '关 闭' : '取 消' }}</el-button>
2025-11-13 17:51:15 +08:00
</span>
</el-dialog>
</div>
</template>
<script>
2025-11-14 16:26:33 +08:00
import { getListCodeApi, getToolSelectApi, updateByIdApi } from '@/api/toolsManage'
import { getManufacturerSelectApi } from '@/api/EquipmentLedger'
2025-11-26 17:05:11 +08:00
import { getToken } from '@/utils/auth'
2025-12-15 17:51:13 +08:00
import FileUpload from '@/components/FileImageUpload'
2026-01-13 14:10:12 +08:00
import { deptTreeSelect } from '@/api/system/user'
2025-11-13 17:51:15 +08:00
export default {
2025-11-14 16:26:33 +08:00
name: 'CodeToolsLedger',
dicts: ['dev_unit_type'],
2025-12-15 17:51:13 +08:00
components: { FileUpload },
2025-11-13 17:51:15 +08:00
data() {
return {
isLoading: false,
showSearch: true,
queryParams: {
pageNum: 1,
pageSize: 10,
2025-11-14 16:26:33 +08:00
parentId: '0',
level: '1',
fourthParentId: null, // 工具专业
greatGrandparentId: null, // 施工类型
grandparentTypeId: null, // 工具类型
parentTypeId: null, // 工具名称
typeName: null, // 规格型号
toolCode: null,
2026-01-13 14:10:12 +08:00
propertyUnitIds: null,
propertyUnitId: null,
2025-11-13 17:51:15 +08:00
},
2026-01-13 14:10:12 +08:00
propertyUnitList: [],
2025-11-14 16:26:33 +08:00
fourthParentList: [],
greatGrandparentList: [],
grandparentTypeList: [],
parentTypeList: [],
2025-11-13 17:51:15 +08:00
total: 0, // 总条数
// 表头
tableColumns: [
2026-01-27 18:50:50 +08:00
{ key: 1,label: '产权单位', prop: 'companyName', width: 100, visible: true, },
{ key: 2,label: '工具专业', prop: 'fourthParentName', width: 100, visible: true, },
{ key: 3,label: '施工类型', prop: 'greatGrandparentName', width: 100, visible: true, },
{ key: 4,label: '工具类型', prop: 'grandparentTypeName', width: 100, visible: true, },
{ key: 5,label: '工具名称', prop: 'parentTypeName', width: 100, visible: true, },
{ key: 6,label: '规格型号', prop: 'typeName', width: 100, visible: true, },
{ key: 7,label: '计量单位', prop: 'unitName', width: 100, visible: true, },
{ key: 8,label: '工具编码', prop: 'toolCode', width: 100, visible: true, },
{ key: 9,label: '工具状态', prop: 'status', width: 100, visible: true, },
{ key: 10,label: '下次检验时间', prop: 'nextCheckDate', visible: true, },
{ key: 11,label: '生产厂家', prop: 'supplierName', width: 100 , visible: true,},
{ key: 12,label: '出厂日期', prop: 'productionDate', width: 100 , visible: true,},
{ key: 13,label: '资产原值', prop: 'originCost', width: 100, visible: true, },
{ key: 14,label: '原始编码', prop: 'identifyCode', width: 100, visible: true, },
2025-11-13 17:51:15 +08:00
],
2026-01-27 18:50:50 +08:00
columns2: [],
2025-11-13 17:51:15 +08:00
// 表格数据
tableList: [],
2025-11-14 16:26:33 +08:00
isView: false,
dialogTitle: '编码设备管理',
2025-11-13 17:51:15 +08:00
dialogVisible: false,
dialogForm: {
2025-11-14 16:26:33 +08:00
fourthParentName: '',
greatGrandparentName: '',
grandparentTypeName: '',
parentTypeName: '',
typeName: '',
unitName: '',
supplierId: '',
productionDate: '',
lastCheckDate: '',
originCost: null,
identifyCode: '',
nextCheckDate: '',
2025-11-26 17:05:11 +08:00
statusName: '',
2025-11-14 16:26:33 +08:00
propertyVoList: [],
2025-12-15 17:51:13 +08:00
// fileList: [], // 初始化文件列表为数组
certificateList: '',
inspectionList: '',
purchaseInvoicesList: '',
2025-11-13 17:51:15 +08:00
},
2025-12-18 15:50:50 +08:00
dialogRules: {
supplierId: [{ required: true, message: '请选择生产厂家', trigger: 'blur' }],
productionDate: [{ required: true, message: '请选择出厂日期', trigger: 'change' }],
originCost: [{ required: true, message: '请输入资产原值', trigger: 'blur' }],
identifyCode: [{ required: true, message: '请输入原始编码', trigger: 'blur' }],
certificateList: [{ required: true, message: '请上传合格证', trigger: 'change' }],
inspectionList: [{ required: true, message: '请上传检测证书', trigger: 'change' }],
2025-12-19 09:52:26 +08:00
// purchaseInvoicesList: [{ required: true, message: '请上传采购发票', trigger: 'change' }],
2025-12-18 15:50:50 +08:00
},
2025-11-14 16:26:33 +08:00
manufacturerSelect: [],
2025-11-26 17:05:11 +08:00
// 上传相关配置从FileUpload组件迁移
uploadFileUrl: process.env.VUE_APP_BASE_API + '/file/upload', // 上传文件服务器地址
headers: {
2025-12-15 17:51:13 +08:00
Authorization: 'Bearer ' + getToken(),
2025-11-26 17:05:11 +08:00
},
fileSize: 5, // 文件大小限制(MB)
2025-12-01 09:35:27 +08:00
fileType: ['doc', 'docx', 'xls', 'xlsx', 'pdf', 'jpg', 'jpeg', 'png'], // 允许上传的文件类型
2025-11-26 17:05:11 +08:00
showTip: true, // 是否显示上传提示
number: 0, // 上传文件计数
2026-01-26 19:51:54 +08:00
isDropdownOpen: false,
2025-11-13 17:51:15 +08:00
}
},
2026-01-13 17:39:06 +08:00
async created() {
2026-01-13 17:51:53 +08:00
await this.getDeptTreeSelect().catch(() => {})
2026-01-13 17:39:06 +08:00
const params = this.$route.query
this.queryParams.propertyUnitId = params?.deptId || ''
const ids = []
if (params?.parentId) {
ids.push(params.parentId)
}
if (params?.deptId) {
ids.push(params.deptId)
}
this.queryParams.propertyUnitIds = [...ids.map(Number)]
2025-11-14 16:26:33 +08:00
this.getList()
this.getSelectList()
2026-01-27 18:50:50 +08:00
this.columns2 = [...this.tableColumns];
2025-11-13 17:51:15 +08:00
},
methods: {
2026-01-13 14:10:12 +08:00
handleUnitChange(value) {
if (value.length === 0) {
this.queryParams.propertyUnitId = undefined
return
}
this.queryParams.propertyUnitId = value[value.length - 1]
},
// 获取产权单位
2026-01-13 17:39:06 +08:00
async getDeptTreeSelect() {
const res = await deptTreeSelect()
this.propertyUnitList = this.filterTree(res.data)
2026-01-13 14:10:12 +08:00
},
filterTree(nodes) {
return nodes
.map((node) => {
if (node.children) {
node.children = this.filterTree(node.children)
}
return node
})
.filter((node) => node.status !== '1')
},
2025-11-26 18:45:27 +08:00
// 处理图片上传变化
handleImageChange(files) {
this.form.mainFileList = files
this.$refs.formRef.validateField('mainFileList')
},
// 处理合格证上传变化
handleCertificateChange(files) {
this.form.certificateList = files
this.$refs.formRef.validateField('certificateList')
},
// 处理检测证书上传变化
handleInspectionChange(files) {
this.form.inspectionList = files
this.$refs.formRef.validateField('inspectionList')
},
// 处理采购发票上传变化
handlePurchaseInvoicesChange(files) {
this.form.purchaseInvoices = files
this.$refs.formRef.validateField('purchaseInvoices')
},
2025-11-13 17:51:15 +08:00
// 查询
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
// 重置
handleReset() {
this.queryParams.pageNum = 1
this.queryParams.pageSize = 10
2025-11-14 16:26:33 +08:00
this.queryParams.parentId = '0'
this.queryParams.level = '1'
this.$refs.queryForm.resetFields()
2025-11-13 17:51:15 +08:00
this.getList()
},
// 获取列表
async getList() {
console.log('列表-查询', this.queryParams)
this.isLoading = true
try {
2025-11-14 16:26:33 +08:00
const params = { ...this.queryParams }
const res = await getListCodeApi(params)
this.tableList = res.rows || []
this.total = res.total || 0
2025-11-13 17:51:15 +08:00
} catch (error) {
this.tableList = []
this.total = 0
} finally {
this.isLoading = false
}
},
2025-11-14 16:26:33 +08:00
// 下拉
async getSelectList() {
try {
const params = { ...this.queryParams }
const res = await getToolSelectApi(params)
if (this.queryParams.level == '1') {
this.fourthParentList = res.data || []
} else if (this.queryParams.level == '2') {
this.greatGrandparentList = res.data || []
} else if (this.queryParams.level == '3') {
this.grandparentTypeList = res.data || []
} else if (this.queryParams.level == '4') {
this.parentTypeList = res.data || []
}
} catch (error) {
console.log('🚀 ~ error:', error)
}
},
changeType(val, level) {
console.log('🚀 ~ val, type:', val, level)
if (level == '2') {
this.queryParams.parentId = val
this.queryParams.greatGrandparentId = null
this.queryParams.grandparentTypeId = null
this.queryParams.parentTypeId = null
this.greatGrandparentList = []
this.grandparentTypeList = []
this.parentTypeList = []
} else if (level == '3') {
this.queryParams.parentId = this.queryParams.greatGrandparentId
this.queryParams.grandparentTypeId = null
this.queryParams.parentTypeId = null
this.grandparentTypeList = []
this.parentTypeList = []
} else if (level == '4') {
this.queryParams.parentId = this.queryParams.grandparentTypeId
this.queryParams.parentTypeId = null
this.parentTypeList = []
}
this.queryParams.level = level
if (!val) return
this.getSelectList()
},
2025-12-12 17:36:56 +08:00
2026-01-26 19:51:54 +08:00
// 导出按钮下拉菜单触发
handleCommand(command) {
2026-01-27 14:09:35 +08:00
switch (command) {
2026-01-26 19:51:54 +08:00
case 'handleDownloadAll':
this.handleExport()
break
case 'handleDownloadPage':
this.handleExportPage()
break
default:
break
}
},
handleVisibleChange(visible) {
this.isDropdownOpen = visible;
},
2025-12-12 17:36:56 +08:00
/**
* 导出数据
*/
2026-01-26 19:51:54 +08:00
handleExportPage() {
2025-12-15 17:51:13 +08:00
this.download(
'/material-mall/toolLedger/export',
{
...this.queryParams,
},
`编码工具台账_${new Date().getTime()}.xlsx`,
)
2025-12-12 17:36:56 +08:00
},
2026-01-26 19:51:54 +08:00
handleExport() {
const params = { ...this.queryParams }
params.pageNum=null
params.pageSize=null
this.download(
'/material-mall/toolLedger/export',params,
`编码工具台账_${new Date().getTime()}.xlsx`,
)
},
2025-12-12 17:36:56 +08:00
2025-11-14 16:26:33 +08:00
// 获取厂家
async getManufacturerSelect() {
try {
const res = await getManufacturerSelectApi()
this.manufacturerSelect = res.data
} catch (error) {}
},
handleProperty(type, index) {
if (type == 'add') {
this.dialogForm.propertyVoList.push({
propertyName: '',
propertyValue: '',
})
} else {
this.dialogForm.propertyVoList.splice(index, 1)
}
},
2025-11-13 17:51:15 +08:00
handleDialog(row, type) {
2025-12-18 17:47:12 +08:00
this.dialogTitle = type ? '编码工具详情' : '编码工具编辑'
2025-11-14 16:26:33 +08:00
this.isView = type
2025-11-13 17:51:15 +08:00
this.dialogVisible = true
2025-11-14 16:26:33 +08:00
this.getManufacturerSelect()
this.$nextTick(() => {
2025-11-13 17:51:15 +08:00
this.$refs.dialogForm.resetFields()
2025-11-26 17:05:11 +08:00
// 深拷贝行数据
this.dialogForm = { ...this.dialogForm, ...JSON.parse(JSON.stringify(row)) }
// 处理状态名称
const statusMap = { 0: '在库', 1: '在用', 2: '在修', 3: '已报废' }
this.dialogForm.statusName = statusMap[this.dialogForm.status] || '未知状态'
2025-11-28 15:40:08 +08:00
if (!this.dialogForm.propertyVoList || this.dialogForm.propertyVoList.length === 0) {
this.dialogForm.propertyVoList.push({
propertyName: '',
propertyValue: '',
})
}
2025-12-15 17:51:13 +08:00
if (this.dialogForm.certificates && this.dialogForm.certificates.length > 0) {
this.dialogForm.certificateList = this.dialogForm.certificates.map((item) => item.fileUrl).join(',')
}
if (this.dialogForm.inspectionReports && this.dialogForm.inspectionReports.length > 0) {
2025-12-15 20:18:53 +08:00
this.dialogForm.inspectionList = this.dialogForm.inspectionReports.map((item) => item.fileUrl).join(',')
2025-12-15 17:51:13 +08:00
}
if (this.dialogForm.purchaseInvoices && this.dialogForm.purchaseInvoices.length > 0) {
this.dialogForm.purchaseInvoicesList = this.dialogForm.purchaseInvoices.map((item) => item.fileUrl).join(',')
}
2025-12-15 20:18:53 +08:00
// // 确保fileList是数组格式
// if (!Array.isArray(this.dialogForm.fileList)) {
// this.dialogForm.fileList = this.dialogForm.fileList
// ? this.dialogForm.fileList.split(',').map((url) => ({
// name: url.split('/').pop(),
// url: url,
// uid: new Date().getTime() + Math.random(),
// }))
// : []
// } else {
// // 为数组中的文件添加uid
// this.dialogForm.fileList = this.dialogForm.fileList.map((file) => ({
// ...file,
// uid: file.uid || new Date().getTime() + Math.random(),
// }))
// }
2025-11-14 16:26:33 +08:00
console.log('🚀 ~ this.dialogForm:', this.dialogForm)
})
2025-11-13 17:51:15 +08:00
},
2025-11-26 17:05:11 +08:00
// 上传前校检格式和大小从FileUpload组件迁移
handleBeforeUpload(file) {
// 校检文件类型
if (this.fileType) {
const fileName = file.name.split('.')
const fileExt = fileName[fileName.length - 1]
const isTypeOk = this.fileType.indexOf(fileExt) >= 0
if (!isTypeOk) {
this.$message.error(`文件格式不正确, 请上传${this.fileType.join('/')}格式文件!`)
return false
}
}
// 校检文件大小
if (this.fileSize) {
const isLt = file.size / 1024 / 1024 < this.fileSize
if (!isLt) {
this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`)
return false
}
}
this.number++
return true
},
// 文件个数超出从FileUpload组件迁移
handleExceed() {
this.$message.error(`上传文件数量不能超过 ${this.limit} 个!`)
},
// 上传失败从FileUpload组件迁移
handleUploadError(err) {
this.$message.error('上传文件失败,请重试')
this.number--
},
// 上传成功回调从FileUpload组件迁移
handleUploadSuccess(res, file) {
if (res.code === 200) {
const newFile = {
name: res.data.url.split('/').pop(),
url: res.data.url,
2025-12-15 17:51:13 +08:00
uid: file.uid,
2025-11-26 17:05:11 +08:00
}
this.dialogForm.fileList.push(newFile)
this.$message.success('文件上传成功')
} else {
this.$message.error(res.msg || '上传失败')
}
this.number--
},
// 删除文件
handleDeleteFile(index) {
this.$confirm('确定要删除该文件吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
2025-12-15 17:51:13 +08:00
type: 'warning',
2025-11-26 17:05:11 +08:00
})
2025-12-15 17:51:13 +08:00
.then(() => {
this.dialogForm.fileList.splice(index, 1)
this.$message.success('文件删除成功')
})
.catch(() => {
// 取消删除
})
2025-11-26 17:05:11 +08:00
},
// 获取文件名称从FileUpload组件迁移
getFileName(name) {
if (name.lastIndexOf('/') > -1) {
return name.slice(name.lastIndexOf('/') + 1)
} else {
return name
}
},
// 判断是否为PDF文件
isPdfFile(file) {
const fileName = this.getFileName(file.name || '')
return fileName.toLowerCase().endsWith('.pdf')
},
// 判断是否为Word文件
isWordFile(file) {
const fileName = this.getFileName(file.name || '')
return fileName.toLowerCase().endsWith('.doc') || fileName.toLowerCase().endsWith('.docx')
},
// 判断是否为Excel文件
isExcelFile(file) {
const fileName = this.getFileName(file.name || '')
return fileName.toLowerCase().endsWith('.xls') || fileName.toLowerCase().endsWith('.xlsx')
},
// 判断是否为图片文件
isImageFile(file) {
const fileName = this.getFileName(file.name || '')
const ext = fileName.toLowerCase().split('.').pop()
return ['jpg', 'jpeg', 'png', 'gif', 'bmp'].includes(ext)
2025-11-13 17:51:15 +08:00
},
2025-11-14 16:26:33 +08:00
async submit() {
console.log('🚀 ~ methods.submit:', this.dialogForm)
2025-12-18 15:50:50 +08:00
// 校验表单
const valid = await this.$refs.dialogForm.validate()
if (!valid) {
return
}
2025-11-14 16:26:33 +08:00
this.isLoading = true
2025-11-13 17:51:15 +08:00
try {
2025-12-15 17:51:13 +08:00
let certificates = [] // 合格证
let inspectionReports = [] // 验收报告
let purchaseInvoices = [] // 采购发票
if (this.dialogForm.certificateList) {
const arr = this.dialogForm.certificateList.split(',')
certificates = arr.map((item) => {
const parts = item.split('/')
return {
fileName: parts[parts.length - 1],
fileUrl: item,
}
})
console.log('🚀 ~ handleSubmit ~ certificates:', certificates)
} else {
// 提示
// this.$message.error('请上传合格证')
// return
}
if (this.dialogForm.inspectionList) {
const arr = this.dialogForm.inspectionList.split(',')
inspectionReports = arr.map((item) => {
const parts = item.split('/')
return {
fileName: parts[parts.length - 1],
fileUrl: item,
}
})
console.log('🚀 ~ handleSubmit ~ inspectionReports:', inspectionReports)
} else {
// 提示
// this.$message.error('请上传检测证书')
// return
}
if (this.dialogForm.purchaseInvoicesList) {
const arr = this.dialogForm.purchaseInvoicesList.split(',')
purchaseInvoices = arr.map((item) => {
const parts = item.split('/')
return {
fileName: parts[parts.length - 1],
fileUrl: item,
}
})
console.log('🚀 ~ handleSubmit ~ purchaseInvoices:', purchaseInvoices)
}
2025-11-26 17:05:11 +08:00
// 处理文件列表为字符串格式(如果接口需要)
const submitForm = {
...this.dialogForm,
2025-12-15 17:51:13 +08:00
certificates,
inspectionReports,
purchaseInvoices,
// fileList: this.dialogForm.fileList.map(file => file.url).join(',')
2025-11-26 17:05:11 +08:00
}
2025-12-15 17:51:13 +08:00
console.log('🚀 ~ submitForm:', submitForm)
2025-11-26 17:05:11 +08:00
await updateByIdApi(submitForm)
2025-11-14 16:26:33 +08:00
this.$message({
type: 'success',
message: '操作成功!',
})
this.dialogVisible = false
this.getList()
2025-11-13 17:51:15 +08:00
} catch (error) {
2025-11-14 16:26:33 +08:00
console.log('🚀 ~ error:', error)
2025-11-26 17:05:11 +08:00
this.$message.error('操作失败,请重试')
2025-11-13 17:51:15 +08:00
} finally {
this.isLoading = false
}
},
},
}
</script>
2025-11-14 16:26:33 +08:00
<style lang="scss" scoped>
2025-11-26 17:05:11 +08:00
// 核心样式:确保图标统一靠左
.custom-file-upload {
width: 100%;
}
// 上传提示文本样式
::v-deep .el-upload__tip {
margin-bottom: 10px;
color: #606266;
}
// 文件列表容器
.upload-file-list {
list-style: none;
padding: 0;
margin: 0;
}
// 文件列表项样式
.file-item {
display: flex;
align-items: center;
padding: 8px 12px;
2025-11-26 18:45:27 +08:00
//border: 1px solid #e4e7ed;
//border-radius: 4px;
2025-11-26 17:05:11 +08:00
margin-bottom: 8px;
width: 100%;
box-sizing: border-box;
}
// 图标容器(关键:固定宽度确保图标对齐)
.file-icon-container {
2025-11-26 18:45:27 +08:00
width: 140px; // 固定宽度,确保所有图标左对齐且对齐线一致
2025-11-26 17:05:11 +08:00
display: flex;
justify-content: flex-start; // 强制靠左
margin-right: 10px;
}
// 图标样式
.file-type-icon {
2025-11-26 18:45:27 +08:00
width: 120px;
height: 120px;
2025-11-26 17:05:11 +08:00
object-fit: contain;
}
.file-default-icon {
font-size: 18px;
color: #606266;
}
// 文件名链接样式
.file-name-link {
color: #606266;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: left; // 文件名也靠左
}
// 操作按钮区域
.file-action {
margin-left: 10px;
white-space: nowrap; // 防止删除按钮换行
}
// 确保删除按钮样式正确
::v-deep .file-action .el-link {
color: #f56c6c;
&:hover {
color: #ff4d4f;
}
2025-11-14 16:26:33 +08:00
}
2025-12-09 17:23:42 +08:00
.content-box {
border-radius: 8px;
2026-01-25 18:03:37 +08:00
height: calc(100vh - 335px);
2025-12-09 17:23:42 +08:00
display: flex;
flex-direction: column;
overflow: hidden;
2025-12-11 19:17:10 +08:00
2025-12-09 17:23:42 +08:00
::v-deep .el-card__body {
display: flex !important;
flex-direction: column !important;
height: 100% !important;
padding: 20px;
}
}
2025-12-18 15:50:50 +08:00
::v-deep .el-input-number.is-without-controls .el-input__inner {
text-align: left;
}
2026-01-19 18:23:33 +08:00
::v-deep.el-tag.el-tag--info {
background-color: #F5F5F5;
border-color: #B3B3B3;
color: #B3B3B3;
}
::v-deep.el-tag.el-tag--warn{
background-color: rgba(255,171,41,0.1);;
border: #FFAB29;
color: #FFAB29;
}
::v-deep.el-tag.el-tag--success {
background-color: rgba(52,226,199,0.1);
border-color: #34E2C7;
color: #34E2C7;
}
::v-deep.el-button--primary{
background: #2CBAB2;
border-color: #2CBAB2;
color: #FFF;
}
/* 紧凑表单行距 */
::v-deep .el-form-item {
margin-bottom: 16px;
}
2026-01-23 15:39:18 +08:00
.app-container{
// height: 100vh;
::v-deep.el-loading-mask{
background-color:#E5EEF5;
}
::v-deep.el-loading-spinner{
position: absolute;
2026-01-23 17:46:17 +08:00
top: 40%;
2026-01-23 15:39:18 +08:00
left: 44%;
width: 12%;
height: 15%;
border-radius: 10px;
background-image: url('../../../../public/lodingCar.gif');
background-size: 100% 100%;
background-repeat: no-repeat;
background-position: center;
}
::v-deep.el-loading-spinner>svg{
display: none;
}
}
2026-01-26 19:51:54 +08:00
.el-icon-arrow-up {
transition: transform 0.3s ease;
}
.el-icon-arrow-up.rotate {
transform: rotate(180deg);
}
2025-11-14 16:26:33 +08:00
</style>