This commit is contained in:
parent
1ae12a2609
commit
6c5a60748d
|
|
@ -137,6 +137,7 @@
|
||||||
<th>规格型号</th>
|
<th>规格型号</th>
|
||||||
<th>装备编码</th>
|
<th>装备编码</th>
|
||||||
<th>数量</th>
|
<th>数量</th>
|
||||||
|
<th>使用到期时间</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
@ -147,6 +148,11 @@
|
||||||
<td>{{ item.devModel }}</td>
|
<td>{{ item.devModel }}</td>
|
||||||
<td>{{ item.devCode }}</td>
|
<td>{{ item.devCode }}</td>
|
||||||
<td>{{item.devNum}}</td>
|
<td>{{item.devNum}}</td>
|
||||||
|
<td>
|
||||||
|
{{ item.useStartTime ? item.useStartTime : '-' }}
|
||||||
|
至
|
||||||
|
{{ item.useEndTime ? item.useEndTime : '-' }}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,8 @@
|
||||||
<th>规格型号</th>
|
<th>规格型号</th>
|
||||||
<th>装备编码</th>
|
<th>装备编码</th>
|
||||||
<th>数量</th>
|
<th>数量</th>
|
||||||
|
<th>最大使用年限</th>
|
||||||
|
<th>剩余使用年限</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
@ -150,6 +152,8 @@
|
||||||
<td>{{ item.devModel }}</td>
|
<td>{{ item.devModel }}</td>
|
||||||
<td>{{ item.devCode }}</td>
|
<td>{{ item.devCode }}</td>
|
||||||
<td>{{item.devNum}}</td>
|
<td>{{item.devNum}}</td>
|
||||||
|
<td>{{item.maxWorkingHours}}</td>
|
||||||
|
<td>{{item.remainingHours}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,7 @@
|
||||||
<th>规格型号</th>
|
<th>规格型号</th>
|
||||||
<th>装备编码</th>
|
<th>装备编码</th>
|
||||||
<th>数量</th>
|
<th>数量</th>
|
||||||
|
<th>使用到期时间</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
@ -134,6 +135,11 @@
|
||||||
<td>{{ item.devModel }}</td>
|
<td>{{ item.devModel }}</td>
|
||||||
<td>{{ item.devCode }}</td>
|
<td>{{ item.devCode }}</td>
|
||||||
<td>{{item.devNum}}</td>
|
<td>{{item.devNum}}</td>
|
||||||
|
<td>
|
||||||
|
{{ item.useStartTime ? item.useStartTime : '-' }}
|
||||||
|
至
|
||||||
|
{{ item.useEndTime ? item.useEndTime : '-' }}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@
|
||||||
<el-table-column align="center" prop="feature1" label="特征项1"/>
|
<el-table-column align="center" prop="feature1" label="特征项1"/>
|
||||||
<el-table-column align="center" prop="featureValue1" label="特征值1"/>
|
<el-table-column align="center" prop="featureValue1" label="特征值1"/>
|
||||||
|
|
||||||
<el-table-column align="center" label="操作" :width="220">
|
<el-table-column align="center" label="操作" :width="199" fixed="right">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-popconfirm
|
<el-popconfirm
|
||||||
width="220"
|
width="220"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="auto">
|
||||||
<el-form-item label="厂家编号" prop="supplierCode">
|
<el-form-item label="厂家编号" prop="supplierCode">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="queryParams.supplierCode"
|
v-model="queryParams.supplierCode"
|
||||||
|
|
@ -41,45 +41,49 @@
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status" >
|
||||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable style="width: 120px;">
|
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable style="width: 215px;">
|
||||||
<el-option label="启用" :value="1" />
|
<el-option label="启用" :value="1" />
|
||||||
<el-option label="停用" :value="0" />
|
<el-option label="停用" :value="0" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item>
|
<el-form-item style="margin-left: 10px">
|
||||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
|
||||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<el-row :gutter="10" class="mb8">
|
<div class="action-bar">
|
||||||
<el-col :span="1.5">
|
<el-row :gutter="10" style="margin-bottom: 10px">
|
||||||
<el-button
|
<el-col :span="1.5">
|
||||||
type="primary"
|
<el-button
|
||||||
plain
|
type="primary"
|
||||||
icon="el-icon-plus"
|
plain
|
||||||
size="mini"
|
icon="el-icon-plus"
|
||||||
@click="handleAdd"
|
size="mini"
|
||||||
v-hasPermi="['machinery:type:add']"
|
@click="handleAdd"
|
||||||
>新增</el-button
|
v-hasPermi="['machinery:type:add']"
|
||||||
>
|
>新增</el-button
|
||||||
</el-col>
|
>
|
||||||
<el-col :span="1.5">
|
</el-col>
|
||||||
<el-button
|
<el-col :span="1.5">
|
||||||
type="warning"
|
<el-button
|
||||||
plain
|
type="warning"
|
||||||
icon="el-icon-download"
|
plain
|
||||||
size="mini"
|
icon="el-icon-download"
|
||||||
@click="handleExport"
|
size="mini"
|
||||||
>导出
|
@click="handleExport"
|
||||||
</el-button>
|
>导出
|
||||||
</el-col>
|
</el-button>
|
||||||
<right-toolbar
|
</el-col>
|
||||||
:showSearch.sync="showSearch"
|
<right-toolbar
|
||||||
@queryTable="getList"
|
:showSearch.sync="showSearch"
|
||||||
></right-toolbar>
|
@queryTable="getList"
|
||||||
</el-row>
|
></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="houseList" ref="multipleTable" row-key="supplierId">
|
<el-table v-loading="loading" :data="houseList" ref="multipleTable" row-key="supplierId">
|
||||||
|
|
@ -772,7 +776,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
handleExport() {
|
handleExport() {
|
||||||
this.download('/material/wh_house_info/export', {
|
this.download('/material-mall/ma_supplier_info/export', {
|
||||||
...this.queryParams
|
...this.queryParams
|
||||||
}, `仓库管理_${new Date().getTime()}.xlsx`)
|
}, `仓库管理_${new Date().getTime()}.xlsx`)
|
||||||
},
|
},
|
||||||
|
|
@ -866,4 +870,13 @@
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 新增:统一的操作栏容器样式,用于将所有按钮和工具栏放在右侧 */
|
||||||
|
.action-bar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end !important; /* 关键:整体内容靠右对齐 */
|
||||||
|
gap: 10px; /* 统一设置内部元素的间距 */
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@
|
||||||
<el-form-item label="工具编码" prop="toolCode">
|
<el-form-item label="工具编码" prop="toolCode">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="queryParams.toolCode"
|
v-model="queryParams.toolCode"
|
||||||
placeholder="请输入规格型号"
|
placeholder="请输入工具编码"
|
||||||
clearable
|
clearable
|
||||||
@keyup.enter.native="handleQuery"
|
@keyup.enter.native="handleQuery"
|
||||||
style="width: 240px"
|
style="width: 240px"
|
||||||
|
|
@ -73,7 +73,7 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- 表单按钮 -->
|
<!-- 表单按钮 -->
|
||||||
<el-form-item style="margin-left:1100px">
|
<el-form-item style="margin-left: 1100px">
|
||||||
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
|
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
|
||||||
<el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
|
<el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
@ -154,7 +154,7 @@
|
||||||
<el-form-item label="施工类型" prop="greatGrandparentName">
|
<el-form-item label="施工类型" prop="greatGrandparentName">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="dialogForm.greatGrandparentName"
|
v-model="dialogForm.greatGrandparentName"
|
||||||
placeholder="请输入工具专业"
|
placeholder="请输入施工类型"
|
||||||
readonly
|
readonly
|
||||||
style="width: 240px"
|
style="width: 240px"
|
||||||
/>
|
/>
|
||||||
|
|
@ -162,19 +162,19 @@
|
||||||
<el-form-item label="工具类型" prop="grandparentTypeName">
|
<el-form-item label="工具类型" prop="grandparentTypeName">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="dialogForm.grandparentTypeName"
|
v-model="dialogForm.grandparentTypeName"
|
||||||
placeholder="请输入工具专业"
|
placeholder="请输入工具类型"
|
||||||
readonly
|
readonly
|
||||||
style="width: 240px"
|
style="width: 240px"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="工具名称" prop="parentTypeName">
|
<el-form-item label="工具名称" prop="parentTypeName">
|
||||||
<el-input v-model="dialogForm.parentTypeName" placeholder="请输入工具专业" readonly style="width: 240px" />
|
<el-input v-model="dialogForm.parentTypeName" placeholder="请输入工具名称" readonly style="width: 240px" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="规格型号" prop="typeName">
|
<el-form-item label="规格型号" prop="typeName">
|
||||||
<el-input v-model="dialogForm.typeName" placeholder="请输入工具专业" readonly style="width: 240px" />
|
<el-input v-model="dialogForm.typeName" placeholder="请输入规格型号" readonly style="width: 240px" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="工具编码" prop="toolCode">
|
<el-form-item label="工具编码" prop="toolCode">
|
||||||
<el-input v-model="dialogForm.toolCode" placeholder="请输入工具专业" readonly style="width: 240px" />
|
<el-input v-model="dialogForm.toolCode" placeholder="请输入工具编码" readonly style="width: 240px" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="计量单位" prop="unitName">
|
<el-form-item label="计量单位" prop="unitName">
|
||||||
<el-select v-model="dialogForm.unitName" placeholder="请选择计量单位" clearable style="width: 240px">
|
<el-select v-model="dialogForm.unitName" placeholder="请选择计量单位" clearable style="width: 240px">
|
||||||
|
|
@ -242,7 +242,7 @@
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="工具状态">
|
<el-form-item label="工具状态">
|
||||||
<el-input v-model="dialogForm.identifyCode" readonly style="width: 240px" />
|
<el-input v-model="dialogForm.statusName" readonly style="width: 240px" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<div v-for="(item, index) in dialogForm.propertyVoList" :key="index">
|
<div v-for="(item, index) in dialogForm.propertyVoList" :key="index">
|
||||||
<el-form-item label="特征项">
|
<el-form-item label="特征项">
|
||||||
|
|
@ -266,15 +266,89 @@
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 附件区域(仅修改这里的图标显示) -->
|
||||||
<el-form-item label="附件" prop="fileList">
|
<el-form-item label="附件" prop="fileList">
|
||||||
<FileUpload
|
<div class="custom-file-upload">
|
||||||
v-model="dialogForm.fileList"
|
<el-upload
|
||||||
:value="dialogForm.fileList"
|
multiple
|
||||||
:limit="9"
|
:action="uploadFileUrl"
|
||||||
:fileType="['doc', 'xls', 'pdf', 'jpg', 'jpeg', 'png']"
|
:before-upload="handleBeforeUpload"
|
||||||
:isView="isView"
|
:file-list="dialogForm.fileList"
|
||||||
@input="handleImage"
|
:limit="9"
|
||||||
/>
|
:on-error="handleUploadError"
|
||||||
|
:on-exceed="handleExceed"
|
||||||
|
:on-success="handleUploadSuccess"
|
||||||
|
:show-file-list="false"
|
||||||
|
:headers="headers"
|
||||||
|
ref="fileUpload"
|
||||||
|
:disabled="isView"
|
||||||
|
>
|
||||||
|
<!-- 上传按钮 -->
|
||||||
|
<el-button size="mini" type="primary">选取文件</el-button>
|
||||||
|
<!-- 上传提示 -->
|
||||||
|
<div class="el-upload__tip" slot="tip" v-if="showTip">
|
||||||
|
请上传大小不超过5MB格式为 doc、xls、pdf、jpg、jpeg、png 的文件
|
||||||
|
</div>
|
||||||
|
</el-upload>
|
||||||
|
|
||||||
|
<!-- 文件列表(图标统一靠左) -->
|
||||||
|
<transition-group class="upload-file-list" name="el-fade-in-linear" tag="ul">
|
||||||
|
<li
|
||||||
|
:key="file.uid"
|
||||||
|
class="file-item"
|
||||||
|
v-for="(file, index) in dialogForm.fileList"
|
||||||
|
>
|
||||||
|
<!-- 图标统一靠左 -->
|
||||||
|
<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)"
|
||||||
|
src="@/assets/images/pdf.png"
|
||||||
|
class="file-type-icon"
|
||||||
|
alt="图片文件"
|
||||||
|
/>
|
||||||
|
<i v-else class="el-icon-file file-default-icon"></i>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-link
|
||||||
|
:href="file.url"
|
||||||
|
:underline="false"
|
||||||
|
target="_blank"
|
||||||
|
class="file-name-link"
|
||||||
|
>
|
||||||
|
{{ getFileName(file.name) }}
|
||||||
|
</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>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
|
|
@ -289,12 +363,11 @@
|
||||||
<script>
|
<script>
|
||||||
import { getListCodeApi, getToolSelectApi, updateByIdApi } from '@/api/toolsManage'
|
import { getListCodeApi, getToolSelectApi, updateByIdApi } from '@/api/toolsManage'
|
||||||
import { getManufacturerSelectApi } from '@/api/EquipmentLedger'
|
import { getManufacturerSelectApi } from '@/api/EquipmentLedger'
|
||||||
import FileUpload from '@/components/FileUpload'
|
import { getToken } from '@/utils/auth'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CodeToolsLedger',
|
name: 'CodeToolsLedger',
|
||||||
dicts: ['dev_unit_type'],
|
dicts: ['dev_unit_type'],
|
||||||
components: { FileUpload },
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
|
@ -330,21 +403,18 @@ export default {
|
||||||
prop: "status",
|
prop: "status",
|
||||||
width: 120,
|
width: 120,
|
||||||
render: (h, { row }) => {
|
render: (h, { row }) => {
|
||||||
// 定义状态与 el-tag 属性的映射关系
|
|
||||||
// 这样做比 switch/case 更清晰,也更容易维护
|
|
||||||
const statusOptions = {
|
const statusOptions = {
|
||||||
0: { text: "在库", type: "success" },
|
0: { text: "在库", type: "success" },
|
||||||
1: { text: "在用", type: "info" },
|
1: { text: "在用", type: "info" },
|
||||||
2: { text: "在修", type: "warning" },
|
2: { text: "在修", type: "warning" },
|
||||||
3: { text: "已报废", type: "danger" },
|
3: { text: "已报废", type: "danger" },
|
||||||
};
|
};
|
||||||
// 获取当前状态对应的配置,如果没有则用默认值
|
|
||||||
const option = statusOptions[row.status] || {
|
const option = statusOptions[row.status] || {
|
||||||
text: "未知状态",
|
text: "未知状态",
|
||||||
type: "",
|
type: "",
|
||||||
};
|
};
|
||||||
return h(
|
return h(
|
||||||
"el-tag", // 1. 要创建的组件是 el-tag
|
"el-tag",
|
||||||
{
|
{
|
||||||
props: {
|
props: {
|
||||||
type: option.type,
|
type: option.type,
|
||||||
|
|
@ -355,7 +425,6 @@ export default {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
{ label: '下次检验时间', prop: 'nextCheckDate' },
|
{ label: '下次检验时间', prop: 'nextCheckDate' },
|
||||||
{ label: '生产厂家', prop: 'supplierName', width: 200 },
|
{ label: '生产厂家', prop: 'supplierName', width: 200 },
|
||||||
{ label: '出厂日期', prop: 'productionDate' },
|
{ label: '出厂日期', prop: 'productionDate' },
|
||||||
|
|
@ -380,10 +449,20 @@ export default {
|
||||||
originCost: null,
|
originCost: null,
|
||||||
identifyCode: '',
|
identifyCode: '',
|
||||||
nextCheckDate: '',
|
nextCheckDate: '',
|
||||||
|
statusName: '',
|
||||||
propertyVoList: [],
|
propertyVoList: [],
|
||||||
fileList: null,
|
fileList: [], // 初始化文件列表为数组
|
||||||
},
|
},
|
||||||
manufacturerSelect: [],
|
manufacturerSelect: [],
|
||||||
|
// 上传相关配置(从FileUpload组件迁移)
|
||||||
|
uploadFileUrl: process.env.VUE_APP_BASE_API + '/file/upload', // 上传文件服务器地址
|
||||||
|
headers: {
|
||||||
|
Authorization: 'Bearer ' + getToken()
|
||||||
|
},
|
||||||
|
fileSize: 5, // 文件大小限制(MB)
|
||||||
|
fileType: ['doc', 'xls', 'pdf', 'jpg', 'jpeg', 'png'], // 允许上传的文件类型
|
||||||
|
showTip: true, // 是否显示上传提示
|
||||||
|
number: 0, // 上传文件计数
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|
@ -482,34 +561,135 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleDialog(row, type) {
|
handleDialog(row, type) {
|
||||||
this.dialogTitle = type ? '编码设备管理' : '编码设备详情'
|
this.dialogTitle = type ? '编码设备详情' : '编码设备编辑'
|
||||||
this.isView = type
|
this.isView = type
|
||||||
this.dialogVisible = true
|
this.dialogVisible = true
|
||||||
this.getManufacturerSelect()
|
this.getManufacturerSelect()
|
||||||
|
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.dialogForm.resetFields()
|
this.$refs.dialogForm.resetFields()
|
||||||
this.dialogForm = { ...this.dialogForm, ...row }
|
// 深拷贝行数据
|
||||||
if (!this.dialogForm.propertyVoList || this.dialogForm.propertyVoList.length == 0) {
|
this.dialogForm = { ...this.dialogForm, ...JSON.parse(JSON.stringify(row)) }
|
||||||
this.dialogForm.propertyVoList = [
|
// 处理状态名称
|
||||||
{
|
const statusMap = { 0: '在库', 1: '在用', 2: '在修', 3: '已报废' }
|
||||||
propertyName: '',
|
this.dialogForm.statusName = statusMap[this.dialogForm.status] || '未知状态'
|
||||||
propertyValue: '',
|
// 确保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()
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
console.log('🚀 ~ this.dialogForm:', this.dialogForm)
|
console.log('🚀 ~ this.dialogForm:', this.dialogForm)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleImage(file) {
|
// 上传前校检格式和大小(从FileUpload组件迁移)
|
||||||
console.log('🚀 ~ file:', file)
|
handleBeforeUpload(file) {
|
||||||
console.log('🚀 ~ file.url:', this.dialogForm.fileList)
|
// 校检文件类型
|
||||||
|
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,
|
||||||
|
uid: file.uid
|
||||||
|
}
|
||||||
|
this.dialogForm.fileList.push(newFile)
|
||||||
|
this.$message.success('文件上传成功')
|
||||||
|
} else {
|
||||||
|
this.$message.error(res.msg || '上传失败')
|
||||||
|
}
|
||||||
|
this.number--
|
||||||
|
},
|
||||||
|
// 删除文件
|
||||||
|
handleDeleteFile(index) {
|
||||||
|
this.$confirm('确定要删除该文件吗?', '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => {
|
||||||
|
this.dialogForm.fileList.splice(index, 1)
|
||||||
|
this.$message.success('文件删除成功')
|
||||||
|
}).catch(() => {
|
||||||
|
// 取消删除
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 获取文件名称(从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)
|
||||||
},
|
},
|
||||||
async submit() {
|
async submit() {
|
||||||
console.log('🚀 ~ methods.submit:', this.dialogForm)
|
console.log('🚀 ~ methods.submit:', this.dialogForm)
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
try {
|
try {
|
||||||
await updateByIdApi(this.dialogForm)
|
// 处理文件列表为字符串格式(如果接口需要)
|
||||||
|
const submitForm = {
|
||||||
|
...this.dialogForm,
|
||||||
|
fileList: this.dialogForm.fileList.map(file => file.url).join(',')
|
||||||
|
}
|
||||||
|
await updateByIdApi(submitForm)
|
||||||
this.$message({
|
this.$message({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
message: '操作成功!',
|
message: '操作成功!',
|
||||||
|
|
@ -518,6 +698,7 @@ export default {
|
||||||
this.getList()
|
this.getList()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('🚀 ~ error:', error)
|
console.log('🚀 ~ error:', error)
|
||||||
|
this.$message.error('操作失败,请重试')
|
||||||
} finally {
|
} finally {
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
}
|
}
|
||||||
|
|
@ -527,7 +708,77 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
::v-deep .el-input-number.is-without-controls .el-input__inner {
|
// 核心样式:确保图标统一靠左
|
||||||
text-align: left;
|
.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;
|
||||||
|
border: 1px solid #e4e7ed;
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 图标容器(关键:固定宽度确保图标对齐)
|
||||||
|
.file-icon-container {
|
||||||
|
width: 24px; // 固定宽度,确保所有图标左对齐且对齐线一致
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-start; // 强制靠左
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 图标样式
|
||||||
|
.file-type-icon {
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue