<template>
|
<div class="main">
|
<div class="main_header">
|
<div class="header_item">
|
<!-- <el-button
|
:size="size"
|
icon="el-icon-search"
|
v-if="showButton('search')"
|
@click="searchTechnicalDocmentList(true)"
|
>查询</el-button> -->
|
<el-button
|
class="search_btn"
|
icon="el-icon-plus"
|
v-if="showButton('insert')"
|
@click="propInsert()">新增</el-button>
|
</div>
|
<div class="header_right">
|
<el-button :size="size" icon="el-icon-back" @click="$emit('update:showTechnical', false)">返回</el-button>
|
</div>
|
</div>
|
<div class="main_content">
|
<el-table
|
v-loading="loading"
|
:data="technicalInfoList"
|
height="100%">
|
<el-table-column label="序号" align="center">
|
<template #default="scope">
|
<span>{{(pageNum - 1) * pageSize + scope.$index + 1}}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="fileNum" label="文件编号" align="center"></el-table-column>
|
<el-table-column prop="fileName" label="文件名称" align="center"></el-table-column>
|
<el-table-column prop="version" label="版本号" align="center"></el-table-column>
|
<el-table-column prop="fileAdmin" label="负责人" align="center"></el-table-column>
|
<el-table-column label="文件" align="center">
|
<template #default="{ row }">
|
<el-button class="table_btn" size="mini" @click="propLookFile(row)">查看文件</el-button>
|
</template>
|
</el-table-column>
|
<el-table-column prop="createTime" label="上传时间" align="center"></el-table-column>
|
<el-table-column label="操作" align="center">
|
<template #default="{ row }">
|
<el-button class="table_btn" size="mini" v-if="showButton('update')" @click="propUpdate(row)">修改</el-button>
|
<el-button class="delete_btn" size="mini" v-if="showButton('delete')" @click="deleteInfo(row)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
<div class="main_footer">
|
<el-pagination
|
background
|
@current-change="changePageNum"
|
@size-change="changePageSize"
|
:current-page="pageNum"
|
:page-sizes="[10, 20, 50, 100]"
|
:page-size="pageSize"
|
layout="total, sizes, prev, pager, next, jumper"
|
:total="total">
|
</el-pagination>
|
</div>
|
<!-- 新增技术文件 修改技术文件信息 -->
|
<el-dialog
|
class="prop_dialog"
|
:title="asyncTitle ? '新增技术文件' : '修改技术文件信息'"
|
:visible.sync="asynctechnicalInfo"
|
width="35%">
|
<el-form ref="form" :model="formTechnicalInfo" :rules="rulesTechnicalInfo" label-width="auto" class="rule_form">
|
<el-form-item label="文件名称:" prop="fileName">
|
<el-input v-model="formTechnicalInfo.fileName" :size="size" clearable placeholder="请输入文件名称"></el-input>
|
</el-form-item>
|
<el-form-item label="文件编号:" prop="fileNum">
|
<el-input v-model="formTechnicalInfo.fileNum" :size="size" clearable placeholder="请输入文件名称"></el-input>
|
</el-form-item>
|
<el-form-item label="版本号:" prop="version">
|
<el-input v-model="formTechnicalInfo.version" :size="size" clearable placeholder="请输入文件名称"></el-input>
|
</el-form-item>
|
<el-form-item label="负责人:" prop="fileAdmin">
|
<el-input v-model="formTechnicalInfo.fileAdmin" :size="size" clearable placeholder="请输入文件名称"></el-input>
|
</el-form-item>
|
<el-form-item label="文件上传:" prop="tchFilesList">
|
<upload-file :file-list.sync="formTechnicalInfo.tchFilesList">
|
<template #info>
|
<span>点击上传文件,支持xls、xlsx、ppt、doc、docx、pdf格式</span>
|
</template>
|
</upload-file>
|
</el-form-item>
|
</el-form>
|
<div slot="footer">
|
<el-button :size="size" @click="asynctechnicalInfo = false">取 消</el-button>
|
<el-button :size="size" @click="asyncTitle ? submitInsertForm() : submitUpdateForm()">确 定</el-button>
|
</div>
|
</el-dialog>
|
<!-- 查看文件 -->
|
<look-file :file-list.sync="fileList" :async-file.sync="asyncFile"></look-file>
|
</div>
|
</template>
|
|
<script>
|
import { buttonPinia } from '../../../pinia';
|
import { changeSize, throttle } from '../../../plugins/public';
|
import UploadFile from '../../../components/uploadFile';
|
import LookFile from '../../../components/LookFile';
|
export default {
|
name: 'TechnicalList',
|
props: {
|
showTechnical: {
|
type: Boolean
|
},
|
typeId: {
|
type: String
|
}
|
},
|
data() {
|
var fileMustUpload = (rule, value, callback) => {
|
if (!value) {
|
callback(new Error('请上传项目文件'));
|
} else if (value.length < 0) {
|
callback(new Error('请上传项目文件'));
|
} else {
|
this.$refs.form.clearValidate('proInfoFiles');
|
callback();
|
}
|
};
|
return {
|
size: changeSize(),
|
total: 0,
|
pageNum: 1,
|
pageSize: 10,
|
loading: false,
|
technicalInfoList: [], // 列表信息
|
asyncTitle: true, // true 新增技术文件 false 修改技术文件信息
|
asynctechnicalInfo: false, // 弹窗
|
formTechnicalInfo: {
|
tchFilesList: []
|
}, // 表单信息
|
rulesTechnicalInfo: {
|
fileName: [{
|
required: true,
|
message: '请输入文件名称',
|
trigger: 'blur'
|
}],
|
fileNum: [{
|
required: true,
|
message: '请输入文件编号',
|
trigger: 'blur'
|
}],
|
version: [{
|
required: true,
|
message: '请输入版本号',
|
trigger: 'blur'
|
}],
|
fileAdmin: [{
|
required: true,
|
message: '请输入负责人',
|
trigger: 'blur'
|
}],
|
tchFilesList: [{
|
required: true,
|
message: '请上传文件'
|
}, {
|
validator: fileMustUpload,
|
trigger: ['change']
|
}]
|
}, // 校验规则
|
fileList: [],
|
asyncFile: false
|
}
|
},
|
mounted() {
|
const that = this;
|
// 根据窗口大小动态修改组件尺寸
|
window.onresize = () => {
|
that.size = changeSize();
|
}
|
that.searchTechnicalDocmentList(true);
|
},
|
methods: {
|
// 查询技术文件附件信息
|
async searchTechnicalDocmentFileList(tchId) {
|
const { data } = await this.$api.Project.searchTechnicalDocmentFileList({
|
tchId: tchId
|
});
|
return data;
|
},
|
// 查询技术文件信息
|
searchTechnicalDocmentList(bol) {
|
if(bol) {
|
this.pageNum = 1;
|
}
|
this.loading = true;
|
this.technicalInfoList = [];
|
this.$api.Project.searchTechnicalDocmentList({
|
tchFileTypeId: this.typeId,
|
pageNum: this.pageNum,
|
pageSize: this.pageSize
|
}).then((res) => {
|
if(res.success) {
|
this.total = res.data.total;
|
this.technicalInfoList = res.data.list;
|
}
|
this.loading = false;
|
}).catch(() => {
|
this.loading = false;
|
})
|
},
|
// 打开添加信息
|
propInsert() {
|
this.asyncTitle = true;
|
this.asynctechnicalInfo = true;
|
},
|
// 打开修改信息
|
propUpdate(row) {
|
this.asyncTitle = false;
|
this.asynctechnicalInfo = true;
|
this.$set(this.formTechnicalInfo, 'tchFileTypeId', row.tchFileTypeId);
|
this.$set(this.formTechnicalInfo, 'tchFileId', row.tchFileId);
|
this.$set(this.formTechnicalInfo, 'fileNum', row.fileNum);
|
this.$set(this.formTechnicalInfo, 'fileName', row.fileName);
|
this.$set(this.formTechnicalInfo, 'version', row.version);
|
this.$set(this.formTechnicalInfo, 'fileAdmin', row.fileAdmin);
|
this.searchTechnicalDocmentFileList(row.tchFileId).then((res) => {
|
this.$set(this.formTechnicalInfo, 'tchFilesList', res.list.map(item => {
|
const type = item.tchFileName.split('.');
|
return {
|
id: item.id,
|
type: type[type.length - 1],
|
name: item.tchFileName,
|
url: item.tchFile
|
}
|
}));
|
})
|
},
|
// 打开文件列表
|
propTechnical(row) {
|
this.showTechnical = true;
|
this.tchFileTypeId = row.tchFileTypeId;
|
},
|
// 查看文件
|
propLookFile(row) {
|
this.fileList = [];
|
this.searchTechnicalDocmentFileList(row.tchFileId).then((res) => {
|
const list = res.list.map(item => {
|
const type = item.tchFileName.split('.');
|
return {
|
id: item.id,
|
type: type[type.length - 1],
|
name: item.tchFileName,
|
url: item.tchFile
|
}
|
})
|
this.fileList = list;
|
})
|
this.asyncFile = true;
|
},
|
// 删除信息
|
deleteInfo(row) {
|
this.$confirm("该操作将删除该技术文件信息,是否继续删除?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
this.$api.Project.deleteTechnicalDocmentInfo({tchFileId: row.tchFileId})
|
.then(res => {
|
if(res.statusMsg === 'ok') {
|
this.searchTechnicalDocmentList(true);
|
this.$message.success("删除成功!");
|
} else {
|
this.$message.warning(res.statusMsg);
|
}
|
})
|
})
|
.catch(() => {
|
this.$message.warning("您已取消");
|
})
|
},
|
// 提交添加信息
|
submitInsertForm: throttle(function() {
|
this.$refs.form.validate((valid) => {
|
if(valid) {
|
const params = Object.assign({}, this.formTechnicalInfo);
|
params.tchFileTypeId = this.typeId;
|
params.tchFilesList = params.tchFilesList.map(item => {
|
return {
|
tchFile: item.url
|
}
|
});
|
this.$api.Project.insertTechnicalDocmentInfo(params).then((res) => {
|
if(res.success) {
|
this.asynctechnicalInfo = false;
|
this.searchTechnicalDocmentList(true);
|
this.$$message.success('添加成功!');
|
} else {
|
this.$message.warning(res.statusMsg);
|
}
|
})
|
}
|
})
|
}, 3000),
|
// 提交修改信息
|
submitUpdateForm: throttle(function() {
|
this.$refs.form.validate((valid) => {
|
if(valid) {
|
const params = Object.assign({}, this.formTechnicalInfo);
|
params.tchFilesList = params.tchFilesList.map(item => {
|
return {
|
tchFile: item.url
|
}
|
});
|
this.$api.Project.insertTechnicalDocmentInfo(params).then((res) => {
|
if(res.success) {
|
this.asynctechnicalInfo = false;
|
this.searchTechnicalDocmentList(true);
|
this.$$message.success('修改成功!');
|
} else {
|
this.$message.warning(res.statusMsg);
|
}
|
})
|
}
|
})
|
}, 3000),
|
// 切换页码
|
changePageNum(page) {
|
this.pageNum = page;
|
this.searchTechnicalDocmentList();
|
},
|
// 切换每页条数
|
changePageSize(size) {
|
this.pageSize = size;
|
this.searchTechnicalDocmentList();
|
},
|
// 判断按钮权限信息
|
showButton(str) {
|
const pinia = buttonPinia();
|
return pinia.$state.buttonInfo.includes(str);
|
}
|
},
|
components: {
|
UploadFile,
|
LookFile
|
},
|
watch: {
|
asynctechnicalInfo(bol) {
|
if(!bol) {
|
this.formTechnicalInfo = {
|
tchFilesList: []
|
};
|
this.$refs.form.resetFields();
|
}
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@import '../../../style/layout-main.scss';
|
|
.main_header {
|
position: relative;
|
}
|
|
.header_right {
|
position: absolute;
|
right: 0;
|
}
|
</style>
|