fix:质检发货资料相关修复
This commit is contained in:
@@ -55,6 +55,7 @@ class Material extends Common
|
||||
$insert_info['create_time'] = $param['create_time'];
|
||||
|
||||
db('materials_info')->insert($insert_info);
|
||||
return $this->sendSuccess('添加成功');
|
||||
}
|
||||
|
||||
|
||||
@@ -79,24 +80,44 @@ class Material extends Common
|
||||
//项目基础信息
|
||||
else if (1 == $param['materials_class'] )
|
||||
{
|
||||
$MaterialsInfoList = db('materials_info')
|
||||
->alias('p')
|
||||
$currPage = empty($param['currPage']) ? 1 : $param['currPage'];
|
||||
$pageSize = empty($param['pageSize']) ? 10 : $param['pageSize'];
|
||||
|
||||
$countQuery = db('materials_info')->alias('p')
|
||||
->where('p.materials_class', $param['materials_class'])
|
||||
->where('p.materials_owner', $param['materials_owner']);
|
||||
$listQuery = db('materials_info')->alias('p')
|
||||
->join('materials_type s', 's.type_id = p.materials_type', 'left')
|
||||
->where('p.materials_class', $param['materials_class'])
|
||||
->where('p.materials_owner', $param['materials_owner']);
|
||||
|
||||
if (isset($param['materials_type']) && is_array($param['materials_type']) && count($param['materials_type']) > 0) {
|
||||
$MaterialsInfoList->whereIn('p.materials_type', $param['materials_type']);
|
||||
} elseif (isset($param['materials_type'])) {
|
||||
$MaterialsInfoList->where('p.materials_type', $param['materials_type']);
|
||||
if (!empty($param['materials_type'])) {
|
||||
if (is_array($param['materials_type'])) {
|
||||
$countQuery->whereIn('p.materials_type', $param['materials_type']);
|
||||
$listQuery->whereIn('p.materials_type', $param['materials_type']);
|
||||
} else {
|
||||
$countQuery->where('p.materials_type', $param['materials_type']);
|
||||
$listQuery->where('p.materials_type', $param['materials_type']);
|
||||
}
|
||||
}
|
||||
|
||||
$MaterialsInfoList = $MaterialsInfoList
|
||||
if (!empty($param['start_time'])) {
|
||||
$countQuery->where('p.create_time', '>=', $param['start_time']);
|
||||
$listQuery->where('p.create_time', '>=', $param['start_time']);
|
||||
}
|
||||
if (!empty($param['end_time'])) {
|
||||
$countQuery->where('p.create_time', '<=', $param['end_time']);
|
||||
$listQuery->where('p.create_time', '<=', $param['end_time']);
|
||||
}
|
||||
|
||||
$total = $countQuery->count();
|
||||
$list = $listQuery
|
||||
->page($currPage, $pageSize)
|
||||
->order('p.create_time desc')
|
||||
->field('p.*, s.type_name as materials_type_name')
|
||||
->select();
|
||||
|
||||
return $this->sendSuccess($MaterialsInfoList);
|
||||
return $this->sendSuccess(['list' => $list, 'total' => $total]);
|
||||
}
|
||||
|
||||
//问题单信息
|
||||
|
||||
@@ -56,7 +56,7 @@ class Role extends Common
|
||||
$results = db('system_router')->alias('router')
|
||||
->join('system_role', 'system_role.router_id = router.id OR system_role.router_id LIKE concat(router.id, \',%\') OR system_role.router_id LIKE concat(\'%,\', router.id) OR system_role.router_id LIKE concat(\'%,\', router.id, \',%\') OR system_role.router_id LIKE concat(\'%,\', router.id, \',%\')', 'LEFT')
|
||||
->field('router.*, GROUP_CONCAT(system_role.role_name) as roles')
|
||||
->group('router.path')
|
||||
->group('router.id')
|
||||
->select();
|
||||
$this->sendSuccess($results);
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ class Material extends Common
|
||||
$insert_info['create_time'] = $param['create_time'];
|
||||
|
||||
db('materials_info')->insert($insert_info);
|
||||
return $this->sendSuccess('添加成功');
|
||||
}
|
||||
|
||||
|
||||
@@ -78,15 +79,38 @@ class Material extends Common
|
||||
//项目基础信息
|
||||
else if (1 == $param['materials_class'] )
|
||||
{
|
||||
$MaterialsInfoList = db('materials_info')->alias('p')
|
||||
$currPage = empty($param['currPage']) ? 1 : $param['currPage'];
|
||||
$pageSize = empty($param['pageSize']) ? 10 : $param['pageSize'];
|
||||
|
||||
$countQuery = db('materials_info')->alias('p')
|
||||
->where('p.materials_class', $param['materials_class'])
|
||||
->where('p.materials_owner', $param['materials_owner']);
|
||||
$listQuery = db('materials_info')->alias('p')
|
||||
->join('materials_type s', 's.type_id = p.materials_type', 'left')
|
||||
->where('p.materials_class', $param['materials_class'])
|
||||
->where('p.materials_owner', $param['materials_owner'])
|
||||
->where('p.materials_type', $param['materials_type'])
|
||||
->where('p.materials_owner', $param['materials_owner']);
|
||||
|
||||
if (!empty($param['materials_type'])) {
|
||||
$countQuery->where('p.materials_type', $param['materials_type']);
|
||||
$listQuery->where('p.materials_type', $param['materials_type']);
|
||||
}
|
||||
|
||||
if (!empty($param['start_time'])) {
|
||||
$countQuery->where('p.create_time', '>=', $param['start_time']);
|
||||
$listQuery->where('p.create_time', '>=', $param['start_time']);
|
||||
}
|
||||
if (!empty($param['end_time'])) {
|
||||
$countQuery->where('p.create_time', '<=', $param['end_time']);
|
||||
$listQuery->where('p.create_time', '<=', $param['end_time']);
|
||||
}
|
||||
|
||||
$total = $countQuery->count();
|
||||
$list = $listQuery
|
||||
->page($currPage, $pageSize)
|
||||
->order('p.create_time desc')
|
||||
->field('p.*, s.type_name as materials_type_name')
|
||||
->select();
|
||||
return $this->sendSuccess($MaterialsInfoList);
|
||||
return $this->sendSuccess(['list' => $list, 'total' => $total]);
|
||||
}
|
||||
|
||||
//问题单信息
|
||||
|
||||
@@ -56,7 +56,7 @@ class Role extends Common
|
||||
$results = db('system_router')->alias('router')
|
||||
->join('system_role', 'system_role.router_id = router.id OR system_role.router_id LIKE concat(router.id, \',%\') OR system_role.router_id LIKE concat(\'%,\', router.id) OR system_role.router_id LIKE concat(\'%,\', router.id, \',%\') OR system_role.router_id LIKE concat(\'%,\', router.id, \',%\')', 'LEFT')
|
||||
->field('router.*, GROUP_CONCAT(system_role.role_name) as roles')
|
||||
->group('router.path')
|
||||
->group('router.id')
|
||||
->select();
|
||||
$this->sendSuccess($results);
|
||||
}
|
||||
|
||||
@@ -1,58 +1,118 @@
|
||||
<template>
|
||||
<div>
|
||||
<div slot="header" class="clearfix" v-if="edid_authority == true">
|
||||
<el-button style="float: right; " size="mini" class="el-icon-circle-plus-outline" type="primary"
|
||||
@click="createMaterials">添加</el-button>
|
||||
<div slot="header" class="clearfix" style="display: flex; align-items: center; justify-content: space-between;">
|
||||
<div class="filter-bar">
|
||||
<el-date-picker
|
||||
v-model="filter.dateRange"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
value-format="yyyy-MM-dd"
|
||||
size="small"
|
||||
style="width: 240px;"/>
|
||||
<el-select v-model="filter.materials_type" placeholder="资料类型" clearable size="small" style="width: 160px; margin-left: 10px;">
|
||||
<el-option label="全部" value=""/>
|
||||
<el-option v-for="item in materials_type_list" :key="item.type_id" :label="item.type_name" :value="item.type_id"/>
|
||||
</el-select>
|
||||
<el-button type="primary" size="small" icon="el-icon-search" style="margin-left: 10px;" @click="handleQuery">查询</el-button>
|
||||
<el-button size="small" icon="el-icon-refresh" style="margin-left: 4px;" @click="handleReset">重置</el-button>
|
||||
</div>
|
||||
<el-table :data="materials_info_list" border fit highlight-current-row
|
||||
style="width: 100%; margin-left: 2px; margin-top: 20px;" height="80vh">
|
||||
<el-table-column prop="materials_id" label="ID" align="left">
|
||||
</el-table-column>
|
||||
<el-table-column prop="materials_type_name" label="资料类型" align="left">
|
||||
</el-table-column>
|
||||
<el-table-column prop="materials_intro" label="资料简介" align="left">
|
||||
</el-table-column>
|
||||
<el-table-column prop="create_time" label="时间" align="left">
|
||||
</el-table-column>
|
||||
<div v-if="edid_authority == true">
|
||||
<el-button size="mini" class="el-icon-circle-plus-outline" type="primary" @click="createMaterials">添加</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<el-table
|
||||
v-if="query_triggered"
|
||||
:data="materials_info_list"
|
||||
border
|
||||
fit
|
||||
highlight-current-row
|
||||
style="width: 100%; margin-left: 2px; margin-top: 20px;"
|
||||
height="80vh">
|
||||
<el-table-column prop="materials_id" label="ID" align="left"/>
|
||||
<el-table-column prop="materials_type_name" label="资料类型" align="left"/>
|
||||
<el-table-column prop="materials_intro" label="资料简介" align="left"/>
|
||||
<el-table-column prop="create_time" label="时间" align="left"/>
|
||||
|
||||
<el-table-column fixed="right" label="操作" width="250px">
|
||||
<template slot-scope="scope">
|
||||
<el-button class="el-icon-view" v-if="scope.row.contract_url != ''" @click="showImg(scope.row)"
|
||||
size="mini" type="primary"></el-button>
|
||||
<el-button @click="update(scope.row)" size="mini" class="el-icon-edit" type="primary"
|
||||
v-if="edid_authority == true"></el-button>
|
||||
<el-button class="el-icon-delete" @click="handleClick(scope.row)" size="mini"
|
||||
type="danger"></el-button>
|
||||
<el-button
|
||||
v-if="scope.row.contract_url != ''"
|
||||
class="el-icon-view"
|
||||
size="mini"
|
||||
type="primary"
|
||||
@click="showImg(scope.row)"/>
|
||||
<el-button
|
||||
v-if="edid_authority == true"
|
||||
size="mini"
|
||||
class="el-icon-edit"
|
||||
type="primary"
|
||||
@click="update(scope.row)"/>
|
||||
<el-button
|
||||
class="el-icon-delete"
|
||||
size="mini"
|
||||
type="danger"
|
||||
@click="handleClick(scope.row)"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
v-if="query_triggered"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:current-page.sync="currPage"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
style="margin-top: 15px; text-align: right;"
|
||||
background
|
||||
layout="total, prev, pager, next, sizes, jumper"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"/>
|
||||
<div v-if="!query_triggered" style="text-align: center; margin-top: 80px; color: #909399;">
|
||||
请选择筛选条件后点击查询
|
||||
</div>
|
||||
|
||||
<!-- 添加合同信息对话框 -->
|
||||
<el-dialog title="添加文件" :visible.sync="dialogVisibleCreateMaterials" :close-on-click-modal="false" width="30%"
|
||||
<el-dialog
|
||||
:visible.sync="dialogVisibleCreateMaterials"
|
||||
:close-on-click-modal="false"
|
||||
title="添加文件"
|
||||
width="30%"
|
||||
append-to-body>
|
||||
<el-form :model="newMaterials" label-width="80px">
|
||||
<el-form-item label="文件简介">
|
||||
<el-input v-model="newMaterials.materials_intro"></el-input>
|
||||
<el-input v-model="newMaterials.materials_intro"/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="资料类型">
|
||||
<el-select v-model="newMaterials.materials_type" filterable placeholder="资料类型" style="width: 100%;">
|
||||
<el-option v-for="item in materials_type_list" :key="item.type_id" :label="item.type_name"
|
||||
:value="item.type_id">
|
||||
</el-option>
|
||||
<el-option
|
||||
v-for="item in materials_type_list"
|
||||
:key="item.type_id"
|
||||
:label="item.type_name"
|
||||
:value="item.type_id"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="文件时间">
|
||||
<el-date-picker v-model="newMaterials.create_time" type="date" format="yyyy-MM-dd"
|
||||
value-format="yyyy-MM-dd" placeholder="选择日期时间">
|
||||
</el-date-picker>
|
||||
<el-date-picker
|
||||
v-model="newMaterials.create_time"
|
||||
type="date"
|
||||
format="yyyy-MM-dd"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="选择日期时间"/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="添加文件">
|
||||
<el-upload class="upload-demo" :action="upload_url" :on-preview="handlePreview"
|
||||
:on-remove="handleRemove" :on-success="handleNewSuccess" :before-upload="beforeUpload"
|
||||
:file-list="fileList" accept=".jpg,.jpeg,.png,.pdf,.pptx,.xlsx,.xls,.docx,.doc,.ppt,.zip,.rar">
|
||||
<el-upload
|
||||
:action="upload_url"
|
||||
:on-preview="handlePreview"
|
||||
:on-remove="handleRemove"
|
||||
:on-success="handleNewSuccess"
|
||||
:before-upload="beforeUpload"
|
||||
:file-list="fileList"
|
||||
class="upload-demo"
|
||||
accept=".jpg,.jpeg,.png,.pdf,.pptx,.xlsx,.xls,.docx,.doc,.ppt,.zip,.rar">
|
||||
<el-button size="small" type="primary">点击上传</el-button>
|
||||
<div slot="tip" class="el-upload__tip">
|
||||
支持jpg/jpeg/png/pdf/pptx/xlsx/xls/docx/doc/ppt/zip/rar文件,不超过100MB
|
||||
@@ -67,32 +127,50 @@
|
||||
</el-dialog>
|
||||
|
||||
<!-- 编辑协议对话框 -->
|
||||
<el-dialog title="编辑协议信息" :visible.sync="dialogVisibleEditMaterials" :close-on-click-modal="false" width="30%"
|
||||
<el-dialog
|
||||
:visible.sync="dialogVisibleEditMaterials"
|
||||
:close-on-click-modal="false"
|
||||
title="编辑协议信息"
|
||||
width="30%"
|
||||
append-to-body>
|
||||
<el-form :model="editMaterials" label-width="80px">
|
||||
<el-form-item label="文件简介">
|
||||
<el-input v-model="editMaterials.materials_intro"></el-input>
|
||||
<el-input v-model="editMaterials.materials_intro"/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="文件时间">
|
||||
<el-date-picker v-model="editMaterials.create_time" type="date" format="yyyy-MM-dd"
|
||||
value-format="yyyy-MM-dd" placeholder="选择日期时间">
|
||||
</el-date-picker>
|
||||
<el-date-picker
|
||||
v-model="editMaterials.create_time"
|
||||
type="date"
|
||||
format="yyyy-MM-dd"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="选择日期时间"/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="资料类型">
|
||||
<el-select v-model="editMaterials.materials_type" filterable placeholder="资料类型"
|
||||
<el-select
|
||||
v-model="editMaterials.materials_type"
|
||||
filterable
|
||||
placeholder="资料类型"
|
||||
style="width: 100%;">
|
||||
<el-option v-for="item in materials_type_list" :key="item.type_id" :label="item.type_name"
|
||||
:value="item.type_id">
|
||||
</el-option>
|
||||
<el-option
|
||||
v-for="item in materials_type_list"
|
||||
:key="item.type_id"
|
||||
:label="item.type_name"
|
||||
:value="item.type_id"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="添加文件">
|
||||
<el-upload class="upload-demo" :action="upload_url" :on-preview="handlePreview"
|
||||
:on-remove="handleRemove" :on-success="handleNewSuccess" :before-upload="beforeUpload"
|
||||
:file-list="fileList" accept=".jpg,.jpeg,.png,.pdf,.pptx,.xlsx,.xls,.docx,.doc,.ppt,.zip,.rar">
|
||||
<el-upload
|
||||
:action="upload_url"
|
||||
:on-preview="handlePreview"
|
||||
:on-remove="handleRemove"
|
||||
:on-success="handleNewSuccess"
|
||||
:before-upload="beforeUpload"
|
||||
:file-list="fileList"
|
||||
class="upload-demo"
|
||||
accept=".jpg,.jpeg,.png,.pdf,.pptx,.xlsx,.xls,.docx,.doc,.ppt,.zip,.rar">
|
||||
<el-button size="small" type="primary">点击上传</el-button>
|
||||
<div slot="tip" class="el-upload__tip">
|
||||
支持jpg/jpeg/png/pdf/pptx/xlsx/xls/docx/doc/ppt/zip/rar文件,不超过100MB
|
||||
@@ -107,9 +185,9 @@
|
||||
</el-dialog>
|
||||
|
||||
<!-- 显示文件对话框 -->
|
||||
<el-dialog title="文件信息" :visible.sync="dialogVisibleShowFile" width="80%" append-to-body>
|
||||
<el-dialog :visible.sync="dialogVisibleShowFile" title="文件信息" width="80%" append-to-body>
|
||||
<img v-if="isImage" :src="previewUrl" alt="Preview" style="max-width: 40%; max-height: 30%;">
|
||||
<iframe v-else-if="isPDF" :src="previewUrl" frameborder="0" style="width: 100%; height: 600px;"></iframe>
|
||||
<iframe v-else-if="isPDF" :src="previewUrl" frameborder="0" style="width: 100%; height: 600px;"/>
|
||||
<div v-else>
|
||||
<p>该文件类型({{ fileExtension }})需要下载后查看</p>
|
||||
<el-button type="primary" @click="downloadFile(previewUrl)">
|
||||
@@ -126,34 +204,44 @@
|
||||
import project from '@/api/project'
|
||||
import material from '@/api/material'
|
||||
|
||||
|
||||
export default {
|
||||
name: 'Materials',
|
||||
// materials_class 资料分类 1项目 2问题 3story 4task
|
||||
// materials_type 具体文件属性,技术文件,会议纪要,问题描述等
|
||||
// materials_owner:资料属于那个项目或问题或story或task
|
||||
props: ['materials_class', 'materials_owner', 'materials_type', 'edid_authority'],
|
||||
props: {
|
||||
materials_class: { type: Number, default: 1 },
|
||||
materials_owner: { type: [Number, String], default: 0 },
|
||||
materials_type: { type: [Number, Array], default: undefined },
|
||||
edid_authority: { type: Boolean, default: false }
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
upload_url: process.env.BASE_WMS_API + '/upload/uploadFile',
|
||||
materials_info_list: [],
|
||||
fileExtension: '', // 新增文件类型显示
|
||||
fileExtension: '',
|
||||
isImage: false,
|
||||
isPDF: false,
|
||||
materials_type_list: [],
|
||||
materials_url: '',
|
||||
fileName: '',
|
||||
currentFileName: '',
|
||||
query_triggered: false,
|
||||
total: 0,
|
||||
currPage: 1,
|
||||
pageSize: 10,
|
||||
filter: {
|
||||
dateRange: null,
|
||||
materials_type: ''
|
||||
},
|
||||
newMaterials: {
|
||||
materials_intro: '',
|
||||
materials_intro: 0,
|
||||
create_time: '',
|
||||
project_id: 0
|
||||
},
|
||||
editMaterials: {
|
||||
materials_id: '',
|
||||
materials_intro: 0,
|
||||
materials_intro: '',
|
||||
create_time: '',
|
||||
project_id: 0,
|
||||
@@ -161,12 +249,14 @@ export default {
|
||||
},
|
||||
dialogVisibleCreateMaterials: false,
|
||||
dialogVisibleEditMaterials: false,
|
||||
dialogVisibleShowFile: false,
|
||||
};
|
||||
dialogVisibleShowFile: false
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.get_materials_info_list()
|
||||
this.get_material_type_list()
|
||||
if (!Array.isArray(this.materials_type)) {
|
||||
this.filter.materials_type = this.materials_type
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
@@ -180,34 +270,54 @@ export default {
|
||||
this.$message({
|
||||
message: res.data.message,
|
||||
type: 'success'
|
||||
});
|
||||
})
|
||||
this.get_materials_info_list()
|
||||
} else {
|
||||
this.$message({
|
||||
message: res.data.message,
|
||||
type: 'error'
|
||||
});
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '已取消删除'
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
},
|
||||
// 新增下载方法
|
||||
// 在下载方法中添加文件名保留
|
||||
downloadFile(url) {
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', this.currentFileName); // 使用数据库中的文件名
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.setAttribute('download', this.currentFileName)
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
},
|
||||
handleQuery() {
|
||||
this.currPage = 1
|
||||
this.query_triggered = true
|
||||
this.get_materials_info_list()
|
||||
},
|
||||
handleReset() {
|
||||
this.filter.dateRange = null
|
||||
this.filter.materials_type = ''
|
||||
this.currPage = 1
|
||||
this.pageSize = 10
|
||||
this.total = 0
|
||||
this.query_triggered = false
|
||||
this.materials_info_list = []
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.pageSize = val
|
||||
this.currPage = 1
|
||||
this.get_materials_info_list()
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.currPage = val
|
||||
this.get_materials_info_list()
|
||||
},
|
||||
confirmEdit() {
|
||||
// 获取表单数据
|
||||
const formData = {
|
||||
materials_id: this.editMaterials.materials_id,
|
||||
create_time: this.editMaterials.create_time,
|
||||
@@ -215,22 +325,22 @@ export default {
|
||||
materials_intro: this.editMaterials.materials_intro,
|
||||
materials_type: this.editMaterials.materials_type,
|
||||
materials_file_name: this.fileName
|
||||
};
|
||||
}
|
||||
|
||||
console.log(formData);
|
||||
console.log(formData)
|
||||
|
||||
// 调用后端接口更新数据
|
||||
project.EditProjectMaterialsInfo(formData).then(response => {
|
||||
if (response.data.code === 20000) {
|
||||
this.$message.success('更新成功')
|
||||
this.dialogVisibleEditMaterials = false
|
||||
this.get_materials_info_list() // 刷新资产列表
|
||||
this.get_materials_info_list()
|
||||
} else {
|
||||
this.$message.error('更新失败:' + response.data.message)
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error(error)
|
||||
this.$message.error('请求失败,请稍后重试')
|
||||
});
|
||||
})
|
||||
},
|
||||
|
||||
update(row) {
|
||||
@@ -242,11 +352,10 @@ export default {
|
||||
this.editMaterials.materials_type = row.materials_type
|
||||
this.dialogVisibleEditMaterials = true
|
||||
|
||||
// 清空文件列表
|
||||
this.fileList = [];
|
||||
this.fileList = []
|
||||
|
||||
const url = this.editMaterials.materials_url
|
||||
const ext = url.split('.').pop().toLowerCase();
|
||||
const ext = url.split('.').pop().toLowerCase()
|
||||
|
||||
if (ext === 'jpg' || ext === 'jpeg' || ext === 'png') {
|
||||
this.isImage = true
|
||||
@@ -254,8 +363,6 @@ export default {
|
||||
} else if (ext === 'pdf') {
|
||||
this.isImage = false
|
||||
this.isPDF = true
|
||||
} else if (ext === '') {
|
||||
|
||||
} else {
|
||||
this.$message.error('不支持的文件类型预览')
|
||||
}
|
||||
@@ -284,20 +391,20 @@ export default {
|
||||
'jpg', 'jpeg', 'png', 'pdf',
|
||||
'pptx', 'xlsx', 'xls', 'docx',
|
||||
'doc', 'ppt', 'zip', 'rar'
|
||||
];
|
||||
const extension = file.name.split('.').pop().toLowerCase();
|
||||
const isAllowed = allowedExtensions.includes(extension);
|
||||
const isLt100M = file.size / 1024 / 1024 < 100;
|
||||
]
|
||||
const extension = file.name.split('.').pop().toLowerCase()
|
||||
const isAllowed = allowedExtensions.includes(extension)
|
||||
const isLt100M = file.size / 1024 / 1024 < 100
|
||||
|
||||
if (!isAllowed) {
|
||||
this.$message.error('不支持的文件类型!');
|
||||
return false;
|
||||
this.$message.error('不支持的文件类型!')
|
||||
return false
|
||||
}
|
||||
if (!isLt100M) {
|
||||
this.$message.error('文件大小不能超过100MB!');
|
||||
return false;
|
||||
this.$message.error('文件大小不能超过100MB!')
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
return true
|
||||
},
|
||||
|
||||
showImg(row) {
|
||||
@@ -305,8 +412,9 @@ export default {
|
||||
const ext = url.split('.').pop().toLowerCase()
|
||||
this.currentFileName = row.materials_file_name
|
||||
this.isImage = false
|
||||
this.isPDF = true
|
||||
this.isPDF = false
|
||||
this.fileExtension = ext // 记录文件扩展名
|
||||
this.fileExtension = ext
|
||||
|
||||
if (['jpg', 'jpeg', 'png'].includes(ext)) {
|
||||
this.previewUrl = process.env.BASE_WMS_FILE + url
|
||||
@@ -315,20 +423,20 @@ export default {
|
||||
this.previewUrl = process.env.BASE_WMS_FILE + url
|
||||
this.isPDF = true
|
||||
} else {
|
||||
this.previewUrl = process.env.BASE_WMS_FILE + url // 必须设置预览URL
|
||||
this.previewUrl = process.env.BASE_WMS_FILE + url
|
||||
}
|
||||
this.dialogVisibleShowFile = true
|
||||
},
|
||||
|
||||
confirmAddMaterials() {
|
||||
if (this.newMaterials.materials_intro.trim() === '') {
|
||||
this.$message.warning('请输入文件描述');
|
||||
return;
|
||||
this.$message.warning('请输入文件描述')
|
||||
return
|
||||
}
|
||||
console.log(this.materials_url)
|
||||
if (this.materials_url.trim() === '') {
|
||||
this.$message.warning('请选择文件');
|
||||
return;
|
||||
this.$message.warning('请选择文件')
|
||||
return
|
||||
}
|
||||
|
||||
var param = {
|
||||
@@ -339,47 +447,68 @@ export default {
|
||||
materials_url: this.materials_url,
|
||||
materials_file_name: this.fileName,
|
||||
create_time: this.newMaterials.create_time
|
||||
};
|
||||
}
|
||||
|
||||
material.AddMaterialsInfo(param).then(response => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '添加成功'
|
||||
});
|
||||
})
|
||||
this.dialogVisibleCreateMaterials = false
|
||||
this.query_triggered = true
|
||||
this.currPage = 1
|
||||
this.get_materials_info_list()
|
||||
}).catch(error => {
|
||||
console.error(error)
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: '添加失败,请重试' + error.toString()
|
||||
});
|
||||
});
|
||||
this.dialogVisibleCreateMaterials = false;
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
get_materials_info_list() {
|
||||
var param = {
|
||||
materials_owner: this.materials_owner,
|
||||
materials_class: this.materials_class,
|
||||
materials_type: this.materials_type
|
||||
currPage: this.currPage,
|
||||
pageSize: this.pageSize
|
||||
}
|
||||
|
||||
if (this.filter.materials_type !== '') {
|
||||
param.materials_type = this.filter.materials_type
|
||||
} else if (!Array.isArray(this.materials_type)) {
|
||||
param.materials_type = this.materials_type
|
||||
}
|
||||
|
||||
if (this.filter.dateRange && this.filter.dateRange.length === 2) {
|
||||
param.start_time = this.filter.dateRange[0]
|
||||
param.end_time = this.filter.dateRange[1]
|
||||
}
|
||||
|
||||
material.GetMaterialsInfo(param).then(response => {
|
||||
this.materials_info_list = response.data.data
|
||||
console.log(this.materials_info_list);
|
||||
const data = response.data.data
|
||||
if (data && data.list !== undefined) {
|
||||
this.materials_info_list = data.list
|
||||
this.total = data.total
|
||||
} else {
|
||||
this.materials_info_list = data
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
get_material_type_list() {
|
||||
material.GetMaterialsType().then(response => {
|
||||
this.materials_type_list = response.data.data
|
||||
//console.log(this.issue_type_list);
|
||||
})
|
||||
},
|
||||
|
||||
createMaterials() {
|
||||
this.newMaterials.materials_intro = ''
|
||||
this.newMaterials.create_time = ''
|
||||
this.newMaterials.materials_type = this.filter.materials_type || ''
|
||||
this.materials_url = ''
|
||||
this.fileList = [];
|
||||
this.fileList = []
|
||||
this.dialogVisibleCreateMaterials = true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user