lanan-system-vue/src/views/partner/file/file.vue
2024-09-01 21:18:38 +08:00

402 lines
13 KiB
Vue

<template>
<div class="app-container">
<!-- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">-->
<!-- <el-form-item label="文件名称" prop="fileName">-->
<!-- <el-input-->
<!-- v-model="queryParams.fileName"-->
<!-- placeholder="请输入文件名称"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="提醒时间">-->
<!-- <el-date-picker-->
<!-- v-model="daterangeWarnTime"-->
<!-- style="width: 240px"-->
<!-- value-format="yyyy-MM-dd"-->
<!-- type="daterange"-->
<!-- range-separator="-"-->
<!-- start-placeholder="开始日期"-->
<!-- end-placeholder="结束日期"-->
<!-- ></el-date-picker>-->
<!-- </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"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
size="mini"
@click="backFile()"
>返回</el-button>
</el-col>
</el-row>
<!-- <el-table v-loading="loading" :data="inspectionFileList" @selection-change="handleSelectionChange">-->
<!-- <el-table-column type="selection" width="55" align="center" />-->
<!-- <el-table-column label="" align="center" prop="id" />-->
<!-- <el-table-column label="类型1文件夹2文件" align="center" prop="type" />-->
<!-- <el-table-column label="文件名称" align="center" prop="fileName" />-->
<!-- <el-table-column label="文件路径" align="center" prop="filePath" />-->
<!-- <el-table-column label="提醒时间" align="center" prop="warnTime" width="180">-->
<!-- <template slot-scope="scope">-->
<!-- <span>{{ parseTime(scope.row.warnTime, '{y}-{m}-{d}') }}</span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="创建时间" align="center" prop="createTime" width="180">-->
<!-- <template slot-scope="scope">-->
<!-- <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <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="['inspectionFile:inspectionFile:edit']"-->
<!-- >修改</el-button>-->
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
<!-- icon="el-icon-delete"-->
<!-- @click="handleDelete(scope.row)"-->
<!-- v-hasPermi="['inspectionFile:inspectionFile: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"-->
<!-- />-->
<div class="content-box">
<el-card class="box-card" v-for="(item,index) in inspectionFileList" :key="index" >
<div v-if="item.type == 1" @click="fatherji(item.id)" >
<img src="../../../assets/images/wenjianjia.png" style="width: 100px;height: 100px;">
<div>{{item.fileName}}</div>
</div>
<div v-if="item.type == 2" >
<img src="../../../assets/images/wenjian.png" style="width: 100px;height: 100px;">
<div>{{item.fileName}}</div>
</div>
<div class="bjandshanchu">
<div class="one" @click="handleE(item)">编辑</div>
<div class="two" v-if="item.type =='2'" @click="downloadFile(item)" >下载</div>
<div class="three" @click="Deleteanniu(item.id)">删除</div>
</div>
</el-card>
</div>
<!-- 添加或修改inspectionFile对话框 -->
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<!-- <el-form-item label="店铺主键" prop="partnerId">-->
<!-- <el-input v-model="form.partnerId" placeholder="请输入店铺主键" />-->
<!-- </el-form-item>-->
<!-- <el-form-item label="父节点" prop="fatherId">-->
<!-- <el-input v-model="form.fatherId" placeholder="请输入父节点" />-->
<!-- </el-form-item>-->
<el-form-item label="文件名称" prop="fileName">
<el-input v-model="form.fileName" placeholder="请输入文件名称" />
</el-form-item>
<el-form-item label="类型" prop="type" v-if="this.title ==='新增'">
<el-radio-group v-model="form.type">
<el-radio :label="'1'">文件夹</el-radio>
<el-radio :label="'2'">文件</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="文件路径" v-if="form.type==='2'" prop="filePath">
<insp-file-upload
:fileSize="30"
:limit="1"
:fileType="['doc', 'xls', 'ppt', 'txt', 'pdf','png','jpg','jpeg','gif','docx','xlsx','pptx','wps']"
v-model="form.filePath"/>
</el-form-item>
<el-form-item label="提醒时间" prop="warnTime">
<el-date-picker clearable
v-model="form.warnTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择提醒时间">
</el-date-picker>
</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 { listInspectionFile, getInspectionFile, delInspectionFile, addInspectionFile, updateInspectionFile } from "../api/file";
import inspFileUpload from '@/components/FileUpload/index.vue'
export default {
name: "InspectionFile",
components:{inspFileUpload},
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// inspectionFile表格数据
inspectionFileList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 提醒时间时间范围
daterangeWarnTime: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
type: null,
fatherId:null,
},
fatherId:'',
oldFatherId:'',
// 表单参数
form: {},
// 表单校验
rules: {
}
};
},
created() {
this.getList();
},
methods: {
backFile(){
if (this.fatherId){
getInspectionFile(this.fatherId).then(response => {
this.queryParams.fatherId = response.data.fatherId
this.fatherId = response.data.fatherId
this.queryParams.pageNum =1
this.getList()
});
}
},
/** 查询inspectionFile列表 */
getList() {
this.loading = true;
this.queryParams.params = {};
if (null != this.daterangeWarnTime && '' != this.daterangeWarnTime) {123
this.queryParams.params["beginWarnTime"] = this.daterangeWarnTime[0];
this.queryParams.params["endWarnTime"] = this.daterangeWarnTime[1];
}
listInspectionFile(this.queryParams).then(response => {
this.inspectionFileList = response.rows;
this.queryParams.fatherId = response.rows[0].fatherId;
this.total = response.total;
this.loading = false;
});
},
fatherji(id){
this.oldFatherId = this.fatherId
this.fatherId = id
this.queryParams.fatherId = id
this.inspectionFileList=[]
this.queryParams.pageNum =1
this.getList()
},
downloadFile(item) {
// 创建一个 <a> 元素
// const link = document.createElement('a');
// link.href = "https://www.nuoyunr.com/cdJdc"+item.filePath; // 文件路径
// var lastIndexOf = item.filePath.lastIndexOf(".");
// link.download = item.fileName+item.filePath.substr(lastIndexOf); // 下载的文件名
window.open(item.filePath);
// // 触发下载
// link.click();
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
partnerId: null,
type: null,
fatherId: null,
fileName: null,
filePath: null,
warnTime: null,
createTime: null,
createBy: null,
updateTime: null,
updateBy: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.daterangeWarnTime = [];
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "新增";
},
handleE(item) {
this.reset(item);
this.form = item;
this.open = true;
this.title = "修改";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getInspectionFile(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改inspectionFile";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateInspectionFile(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
this.form.fatherId = this.fatherId
addInspectionFile(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
//新建删除
Deleteanniu(id){
this.$modal.confirm('是否确认删除inspectionFile编号为"' + id + '"的数据项?').then(function() {
return delInspectionFile(id);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除inspectionFile编号为"' + ids + '"的数据项?').then(function() {
return delInspectionFile(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('inspectionFile/inspectionFile/export', {
...this.queryParams
}, `inspectionFile_${new Date().getTime()}.xlsx`)
}
}
};
</script>
<style scoped>
.content-box{
display: flex;
flex-wrap: wrap;
box-sizing: border-box;
width: 100%;
}
.box-card{
width: 160px;
text-align: center;
margin-bottom: 15px;
margin-right: 15px;
}
.bjandshanchu{
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
}
.one{
color: #67C23A;
cursor: pointer;
}
.two{
color: #409EFF;
cursor: pointer;
}
.three{
color: #F56C6C;
cursor: pointer;
}
</style>