Commit 78a911fa authored by 耿迪迪's avatar 耿迪迪

工艺流程图

parent ac4f58dd
package com.zehong.web.controller.safe;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.TTechnologyProcess;
import com.zehong.system.service.ITTechnologyProcessService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;
/**
* 工业流程图Controller
*
* @author zehong
* @date 2026-07-15
*/
@RestController
@RequestMapping("/safe/process")
public class TTechnologyProcessController extends BaseController
{
@Autowired
private ITTechnologyProcessService tTechnologyProcessService;
/**
* 查询工业流程图列表
*/
//@PreAuthorize("@ss.hasPermi('safe:process:list')")
@GetMapping("/list")
public TableDataInfo list(TTechnologyProcess tTechnologyProcess)
{
startPage();
List<TTechnologyProcess> list = tTechnologyProcessService.selectTTechnologyProcessList(tTechnologyProcess);
return getDataTable(list);
}
/**
* 导出工业流程图列表
*/
//@PreAuthorize("@ss.hasPermi('safe:process:export')")
@Log(title = "工业流程图", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TTechnologyProcess tTechnologyProcess)
{
List<TTechnologyProcess> list = tTechnologyProcessService.selectTTechnologyProcessList(tTechnologyProcess);
ExcelUtil<TTechnologyProcess> util = new ExcelUtil<TTechnologyProcess>(TTechnologyProcess.class);
return util.exportExcel(list, "工业流程图数据");
}
/**
* 获取工业流程图详细信息
*/
//@PreAuthorize("@ss.hasPermi('safe:process:query')")
@GetMapping(value = "/{processId}")
public AjaxResult getInfo(@PathVariable("processId") Long processId)
{
return AjaxResult.success(tTechnologyProcessService.selectTTechnologyProcessById(processId));
}
/**
* 新增工业流程图
*/
//@PreAuthorize("@ss.hasPermi('safe:process:add')")
@Log(title = "工业流程图", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TTechnologyProcess tTechnologyProcess)
{
return toAjax(tTechnologyProcessService.insertTTechnologyProcess(tTechnologyProcess));
}
/**
* 修改工业流程图
*/
//@PreAuthorize("@ss.hasPermi('safe:process:edit')")
@Log(title = "工业流程图", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TTechnologyProcess tTechnologyProcess)
{
return toAjax(tTechnologyProcessService.updateTTechnologyProcess(tTechnologyProcess));
}
/**
* 删除工业流程图
*/
//@PreAuthorize("@ss.hasPermi('safe:process:remove')")
@Log(title = "工业流程图", businessType = BusinessType.DELETE)
@DeleteMapping("/{processIds}")
public AjaxResult remove(@PathVariable Long[] processIds)
{
return toAjax(tTechnologyProcessService.deleteTTechnologyProcessByIds(processIds));
}
}
package com.zehong.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
/**
* 工业流程图对象 t_technology_process
*
* @author zehong
* @date 2026-07-15
*/
public class TTechnologyProcess extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long processId;
/** 标题 */
@Excel(name = "标题")
private String title;
/** 内容 */
@Excel(name = "内容")
private String content;
/** 附件 */
@Excel(name = "附件")
private String attachment;
/** 是否删除(0正常,1删除) */
@Excel(name = "是否删除(0正常,1删除)")
private String isDel;
/** 备注 */
@Excel(name = "备注")
private String remarks;
public void setProcessId(Long processId)
{
this.processId = processId;
}
public Long getProcessId()
{
return processId;
}
public void setTitle(String title)
{
this.title = title;
}
public String getTitle()
{
return title;
}
public void setContent(String content)
{
this.content = content;
}
public String getContent()
{
return content;
}
public void setAttachment(String attachment)
{
this.attachment = attachment;
}
public String getAttachment()
{
return attachment;
}
public void setIsDel(String isDel)
{
this.isDel = isDel;
}
public String getIsDel()
{
return isDel;
}
public void setRemarks(String remarks)
{
this.remarks = remarks;
}
public String getRemarks()
{
return remarks;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("processId", getProcessId())
.append("title", getTitle())
.append("content", getContent())
.append("attachment", getAttachment())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("isDel", getIsDel())
.append("remarks", getRemarks())
.toString();
}
}
package com.zehong.system.mapper;
import java.util.List;
import com.zehong.system.domain.TTechnologyProcess;
/**
* 工业流程图Mapper接口
*
* @author zehong
* @date 2026-07-15
*/
public interface TTechnologyProcessMapper
{
/**
* 查询工业流程图
*
* @param processId 工业流程图ID
* @return 工业流程图
*/
public TTechnologyProcess selectTTechnologyProcessById(Long processId);
/**
* 查询工业流程图列表
*
* @param tTechnologyProcess 工业流程图
* @return 工业流程图集合
*/
public List<TTechnologyProcess> selectTTechnologyProcessList(TTechnologyProcess tTechnologyProcess);
/**
* 新增工业流程图
*
* @param tTechnologyProcess 工业流程图
* @return 结果
*/
public int insertTTechnologyProcess(TTechnologyProcess tTechnologyProcess);
/**
* 修改工业流程图
*
* @param tTechnologyProcess 工业流程图
* @return 结果
*/
public int updateTTechnologyProcess(TTechnologyProcess tTechnologyProcess);
/**
* 删除工业流程图
*
* @param processId 工业流程图ID
* @return 结果
*/
public int deleteTTechnologyProcessById(Long processId);
/**
* 批量删除工业流程图
*
* @param processIds 需要删除的数据ID
* @return 结果
*/
public int deleteTTechnologyProcessByIds(Long[] processIds);
}
package com.zehong.system.service;
import java.util.List;
import com.zehong.system.domain.TTechnologyProcess;
/**
* 工业流程图Service接口
*
* @author zehong
* @date 2026-07-15
*/
public interface ITTechnologyProcessService
{
/**
* 查询工业流程图
*
* @param processId 工业流程图ID
* @return 工业流程图
*/
public TTechnologyProcess selectTTechnologyProcessById(Long processId);
/**
* 查询工业流程图列表
*
* @param tTechnologyProcess 工业流程图
* @return 工业流程图集合
*/
public List<TTechnologyProcess> selectTTechnologyProcessList(TTechnologyProcess tTechnologyProcess);
/**
* 新增工业流程图
*
* @param tTechnologyProcess 工业流程图
* @return 结果
*/
public int insertTTechnologyProcess(TTechnologyProcess tTechnologyProcess);
/**
* 修改工业流程图
*
* @param tTechnologyProcess 工业流程图
* @return 结果
*/
public int updateTTechnologyProcess(TTechnologyProcess tTechnologyProcess);
/**
* 批量删除工业流程图
*
* @param processIds 需要删除的工业流程图ID
* @return 结果
*/
public int deleteTTechnologyProcessByIds(Long[] processIds);
/**
* 删除工业流程图信息
*
* @param processId 工业流程图ID
* @return 结果
*/
public int deleteTTechnologyProcessById(Long processId);
}
package com.zehong.system.service.impl;
import java.util.List;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TTechnologyProcessMapper;
import com.zehong.system.domain.TTechnologyProcess;
import com.zehong.system.service.ITTechnologyProcessService;
/**
* 工业流程图Service业务层处理
*
* @author zehong
* @date 2026-07-15
*/
@Service
public class TTechnologyProcessServiceImpl implements ITTechnologyProcessService
{
@Autowired
private TTechnologyProcessMapper tTechnologyProcessMapper;
/**
* 查询工业流程图
*
* @param processId 工业流程图ID
* @return 工业流程图
*/
@Override
public TTechnologyProcess selectTTechnologyProcessById(Long processId)
{
return tTechnologyProcessMapper.selectTTechnologyProcessById(processId);
}
/**
* 查询工业流程图列表
*
* @param tTechnologyProcess 工业流程图
* @return 工业流程图
*/
@Override
public List<TTechnologyProcess> selectTTechnologyProcessList(TTechnologyProcess tTechnologyProcess)
{
return tTechnologyProcessMapper.selectTTechnologyProcessList(tTechnologyProcess);
}
/**
* 新增工业流程图
*
* @param tTechnologyProcess 工业流程图
* @return 结果
*/
@Override
public int insertTTechnologyProcess(TTechnologyProcess tTechnologyProcess)
{
tTechnologyProcess.setCreateTime(DateUtils.getNowDate());
tTechnologyProcess.setCreateTime(DateUtils.getNowDate());
tTechnologyProcess.setCreateBy(SecurityUtils.getLoginUser().getUser().getNickName());
return tTechnologyProcessMapper.insertTTechnologyProcess(tTechnologyProcess);
}
/**
* 修改工业流程图
*
* @param tTechnologyProcess 工业流程图
* @return 结果
*/
@Override
public int updateTTechnologyProcess(TTechnologyProcess tTechnologyProcess)
{
tTechnologyProcess.setUpdateTime(DateUtils.getNowDate());
tTechnologyProcess.setUpdateTime(DateUtils.getNowDate());
tTechnologyProcess.setUpdateBy(SecurityUtils.getLoginUser().getUser().getNickName());
return tTechnologyProcessMapper.updateTTechnologyProcess(tTechnologyProcess);
}
/**
* 批量删除工业流程图
*
* @param processIds 需要删除的工业流程图ID
* @return 结果
*/
@Override
public int deleteTTechnologyProcessByIds(Long[] processIds)
{
return tTechnologyProcessMapper.deleteTTechnologyProcessByIds(processIds);
}
/**
* 删除工业流程图信息
*
* @param processId 工业流程图ID
* @return 结果
*/
@Override
public int deleteTTechnologyProcessById(Long processId)
{
return tTechnologyProcessMapper.deleteTTechnologyProcessById(processId);
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zehong.system.mapper.TTechnologyProcessMapper">
<resultMap type="TTechnologyProcess" id="TTechnologyProcessResult">
<result property="processId" column="process_id" />
<result property="title" column="title" />
<result property="content" column="content" />
<result property="attachment" column="attachment" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="isDel" column="is_del" />
<result property="remarks" column="remarks" />
</resultMap>
<sql id="selectTTechnologyProcessVo">
select process_id, title, content, attachment, create_by, create_time, update_by, update_time, is_del, remarks from t_technology_process
</sql>
<select id="selectTTechnologyProcessList" parameterType="TTechnologyProcess" resultMap="TTechnologyProcessResult">
<include refid="selectTTechnologyProcessVo"/>
<where>
<if test="title != null and title != ''"> and title like concat('%', #{title}, '%')</if>
<if test="content != null and content != ''"> and content = #{content}</if>
<if test="attachment != null and attachment != ''"> and attachment = #{attachment}</if>
<if test="isDel != null and isDel != ''"> and is_del = #{isDel}</if>
<if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if>
</where>
</select>
<select id="selectTTechnologyProcessById" parameterType="Long" resultMap="TTechnologyProcessResult">
<include refid="selectTTechnologyProcessVo"/>
where process_id = #{processId}
</select>
<insert id="insertTTechnologyProcess" parameterType="TTechnologyProcess" useGeneratedKeys="true" keyProperty="processId">
insert into t_technology_process
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="title != null">title,</if>
<if test="content != null">content,</if>
<if test="attachment != null">attachment,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="isDel != null">is_del,</if>
<if test="remarks != null">remarks,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="title != null">#{title},</if>
<if test="content != null">#{content},</if>
<if test="attachment != null">#{attachment},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="isDel != null">#{isDel},</if>
<if test="remarks != null">#{remarks},</if>
</trim>
</insert>
<update id="updateTTechnologyProcess" parameterType="TTechnologyProcess">
update t_technology_process
<trim prefix="SET" suffixOverrides=",">
<if test="title != null">title = #{title},</if>
<if test="content != null">content = #{content},</if>
<if test="attachment != null">attachment = #{attachment},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="remarks != null">remarks = #{remarks},</if>
</trim>
where process_id = #{processId}
</update>
<delete id="deleteTTechnologyProcessById" parameterType="Long">
delete from t_technology_process where process_id = #{processId}
</delete>
<delete id="deleteTTechnologyProcessByIds" parameterType="String">
delete from t_technology_process where process_id in
<foreach item="processId" collection="array" open="(" separator="," close=")">
#{processId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
import request from '@/utils/request'
// 查询工业流程图列表
export function listProcess(query) {
return request({
url: '/safe/process/list',
method: 'get',
params: query
})
}
// 查询工业流程图详细
export function getProcess(processId) {
return request({
url: '/safe/process/' + processId,
method: 'get'
})
}
// 新增工业流程图
export function addProcess(data) {
return request({
url: '/safe/process',
method: 'post',
data: data
})
}
// 修改工业流程图
export function updateProcess(data) {
return request({
url: '/safe/process',
method: 'put',
data: data
})
}
// 删除工业流程图
export function delProcess(processId) {
return request({
url: '/safe/process/' + processId,
method: 'delete'
})
}
// 导出工业流程图
export function exportProcess(query) {
return request({
url: '/safe/process/export',
method: 'get',
params: query
})
}
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="标题" prop="title">
<el-input
v-model="queryParams.title"
placeholder="请输入标题"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<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-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['safe:process:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['safe:process:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['safe:process:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
:loading="exportLoading"
@click="handleExport"
v-hasPermi="['safe:process:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="processList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="标题" align="center" prop="title" />
<el-table-column label="内容" align="center" prop="content" />
<el-table-column label="附件" align="center" prop="attachment" >
<template slot-scope="scope">
<div v-if="scope.row.attachment">
<el-dropdown trigger="click" placement="bottom">
<span style="color: #1c84c6; cursor: pointer;text-align: center">
查看附件 ({{ JSON.parse(scope.row.attachment).length }}) <i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
v-for="(file, index) in JSON.parse(scope.row.attachment)"
:key="index"
>
<a
@click="downloadFile(file)"
style="color: #1c84c6; text-decoration: none; display: block;"
>
<i class="el-icon-document"></i> {{ file.name || `附件${index + 1}` }}
</a>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="创建人" align="center" prop="createBy" />
<el-table-column label="创建时间" align="center" prop="createTime" />
<el-table-column label="备注" align="center" prop="remarks" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['safe:process:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['safe:process:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改工业流程图对话框 -->
<el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row>
<el-col :span="12">
<el-form-item label="标题" prop="title">
<el-input v-model="form.title" placeholder="请输入标题" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="内容" prop="content">
<el-input type="textarea" :autosize="{ minRows: 4}" v-model="form.content" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="附件" prop="attachment">
<!--<fileUpload v-model="form.attachment"/>-->
<MultipleFileUpload v-model="form.attachment" ref="attachment"/>
</el-form-item>
<el-form-item label="备注" prop="remarks">
<el-input type="textarea" v-model="form.remarks" placeholder="请输入备注" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listProcess, getProcess, delProcess, addProcess, updateProcess, exportProcess } from "@/api/safe/process";
import Editor from '@/components/Editor';
import MultipleFileUpload from '@/components/MultipleFileUpload';
export default {
name: "Process",
components: {
Editor,
MultipleFileUpload
},
data() {
return {
// 遮罩层
loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组
ids: [],
titles: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 工业流程图表格数据
processList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
title: null,
content: null,
attachment: null,
isDel: null,
remarks: null
},
// 表单参数
form: {},
// 表单校验
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 查询工业流程图列表 */
getList() {
this.loading = true;
listProcess(this.queryParams).then(response => {
this.processList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
processId: null,
title: null,
content: null,
attachment: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
isDel: null,
remarks: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.processId);
this.titles = selection.map(item => item.title);
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加工业流程图";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const processId = row.processId || this.ids
getProcess(processId).then(response => {
this.form = response.data;
this.$nextTick(() => {
if(this.form.attachment){
this.$refs.attachment.fileList = JSON.parse(this.form.attachment)
}
})
this.open = true;
this.title = "修改工业流程图";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.processId != null) {
updateProcess(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addProcess(this.form).then(response => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const processIds = row.processId || this.ids;
const titles = row.title || this.titles;
this.$confirm('是否确认删除工业流程图标题为"' + titles + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delProcess(processIds);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有工业流程图数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true;
return exportProcess(queryParams);
}).then(response => {
this.download(response.msg);
this.exportLoading = false;
}).catch(() => {});
},
async downloadFile(file) {
try {
const response = await fetch(file.url)
const blob = await response.blob()
// 创建下载链接
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = file.name // 这里可以自定义文件名
document.body.appendChild(link)
link.click()
// 清理
document.body.removeChild(link)
window.URL.revokeObjectURL(url)
this.$message.success('开始下载')
} catch (error) {
console.error('下载失败:', error)
this.$message.error('下载失败,请重试')
// 降级方案:直接打开新窗口
window.open(file.url, '_blank')
}
}
}
};
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment