@@ -1,202 +1,124 @@
< template >
< div >
< div slot = "header" class = "clearfix" style = "display: flex; align-items: center; justify-content: space-between;" >
< div class = "filter-b ar" >
< el-date-picker
v-model = "filter.dateRange"
type = "d aterange"
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 = "全部 " v alue = "" / >
< 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 >
< 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" / >
< div >
< div slot = "header" class = "clearfix" v-if = "e did_authority == true" >
< el -button style = "float: right; " size = "mini" class = "el-icon-circle-plus-outline" type = "prim ary "
@click ="createMaterials" > 添加 < / el -button >
< / div >
< el-table :data = "m aterials_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 >
< el-table-column fixed = "right" label = "操作" width = "250px" >
< template slot -scope = " scope " >
< 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-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 >
< / template >
< / el-table-column >
< / el-table >
< ! - - 添加合同信息对话框 - - >
< el-dialog
:visible.sync = "dialogVisibleCreateMaterials"
:close-on-click- moda l = "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 -form -item >
<!- - 添加合同信息对话框 -- >
< el-dialog title = "添加文件" :visible.sync = "dialogVisibleCreateMaterials" :close-on-click-modal = "false" width = "30%"
append -to -body >
< el-form : mode l = "newMaterials" label -width = " 80px " >
< el-form-item label = "文件简介" >
< el-input v-model = "newMaterials.materials_intro" > < / el -input >
< / 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-select >
< / 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-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-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-form-item >
< el-form-item label = "添加文件" >
< 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
< /div >
< / el-upload >
< / el-form-item >
< / el-form >
< span slot = "footer" class = "dialog-footer" >
< el-button @click ="dialogVisibleCreateMaterials = false" > 取 消 < / el -button >
< el-button type = "primary" @click ="confirmAddMaterials" > 确 定 < / el -button >
< / span >
< / el-dialog >
< 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-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
< / div >
< / el-upload >
< / el-form-item >
< / el-form >
< span slot = "footer " class = "dialog-footer " >
< el-button @click ="dialogVisibleCreateMaterials = false" > 取 消 < / el -button >
< el-button type = "primary" @click ="confirmAddMaterials" > 确 定 < /el -button >
< / span >
< / el-dialog >
<!-- 编辑协议对话框 -- >
< el-dialog
:visible.sync = "dialogVisibleEditMaterials"
:close-on-click- moda l = "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 -form -item >
<!-- 编辑协议对话框 -- >
< el-dialog title = "编辑协议信息" :visible.sync = "dialogVisibleEditMaterials" :close-on-click-modal = "false" width = "30%"
append -to -body >
< el-form : mode l = "editMaterials" label -width = " 80px " >
< el-form-item label = "文件简介" >
< el-input v-model = "editMaterials.materials_intro" > < / el -input >
< / 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-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-form-item >
< el-form-item label = "资料类型" >
< 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-select >
< / el-form-item >
< el-form-item label = "资料类型" >
< 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-select >
< / el-form-item >
< el-form-item label = "添加文件" >
< 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
< / div >
< / el-upload >
< / el-form-item >
< / el-form >
< span slot = "footer" class = "dialog-footer" >
< el-button @click ="dialogVisibleEditMaterials = false" > 取 消 < / el -button >
< el-button type = "primary" @click ="confirmEdit" > 确 定 < / el -button >
< / span >
< / el-dialog >
< 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-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
< / div >
< / el-upload >
< / el-form-item >
< / el-form >
< span slot = "footer " class = "dialog-footer " >
< el-button @click ="dialogVisibleEditMaterials = false" > 取 消 < / el -button >
< el-button type = "primary" @click ="confirmEdit" > 确 定 < / el -button >
< / span >
< / el-dialog >
<!-- 显示文件对话框 -- >
< 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;" / >
< div v-else >
< p > 该文件类型 ( { { fileExtension } } ) 需要下载后查看 < / p >
< el-button type = "primary" @click ="downloadFile(previewUrl)" >
立即下载 {{ fileExtension.toUpperCase ( ) }} 文件
< / el -button >
< / div >
< / el-dialog >
<!-- 显示文件对话框 -- >
< el-dialog title = "文件信息" :visible.sync = "dialogVisibleShowFile" 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 >
< div v-else >
< p > 该文件类型 ( { { fileExtension } } ) 需要下载后查看 < / p >
< el-button type = "primary" @click ="downloadFile(previewUrl)" >
立即下载 {{ fileExtension.toUpperCase ( ) }} 文件
< / el -button >
< / div >
< / el-dialog >
< / div >
< / div >
< / template >
< script >
@@ -204,315 +126,264 @@
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 : { type : Number , default : 1 } ,
materials _owner : { type : [ Number , String ] , default : 0 } ,
materials _type : { type : [ Number , Array ] , default : undefined } ,
edid _authority : { type : Boolean , default : false }
} ,
name : 'Materials' ,
//materials_class 资料分类 1项目 2问题 3story 4task
//materials_type 具体文件属性,技术文件,会议纪要,问题描述等
//materials_owner:资料属于那个项目或问题或story或task
props : [ 'materials_class' , 'materials_owner' , 'materials_type' , 'edid_authority' ] ,
data ( ) {
return {
upload _url : process . env . BASE _WMS _API + '/upload/uploadFile' ,
materials _info _list : [ ] ,
fileExtension : '' ,
isImage : false ,
isPDF : false ,
materials _type _list : [ ] ,
materials _url : '' ,
fileName : '' ,
currentFileName : '' ,
query _triggered : false ,
total : 0 ,
currPage : 1 ,
pageSiz e : 10 ,
filter : {
dateRange : null ,
m aterials _type : ''
} ,
newMaterials : {
materials _intro : '' ,
create _time : '' ,
project _id : 0
} ,
editMaterials : {
materials _id : '' ,
materials _intro : '' ,
create _time : '' ,
project _id : 0 ,
materials _type : 0
} ,
dialogVisibleCreateMaterials : false ,
dialogVisibleEditMaterials : false ,
dialogVisibleShowFile : false
}
} ,
mounted ( ) {
this . get _material _type _list ( )
if ( ! Array . isArray ( this . materials _type ) ) {
this . filter . materials _type = this . materials _type
}
} ,
created ( ) {
data ( ) {
return {
upload _url : process . env . BASE _WMS _API + '/upload/uploadFile' ,
materials _info _list : [ ] ,
fileExtension : '' , // 新增文件类型显示
isImage : false ,
isPDF : false ,
materials _type _list : [ ] ,
materials _url : '' ,
fileName : '' ,
currentFileName : '' ,
newMaterials : {
materials _intro : '' ,
materials _intro : 0 ,
create _tim e : '' ,
project _id : 0
} ,
editM aterials : {
materials _id : '' ,
materials _intro : 0 ,
materials _intro : '' ,
create _time : '' ,
project _id : 0 ,
materials _type : 0
} ,
dialogVisibleCreateMaterials : false ,
dialogVisibleEditMaterials : false ,
dialogVisibleShowFile : false ,
} ;
} ,
mounted ( ) {
this . get _materials _info _list ( )
this . get _material _type _list ( )
} ,
created ( ) {
} ,
methods : {
handleClick ( row ) {
console . log ( row )
this . $confirm ( '您确定要删除当前记录吗?' ) . then ( ( ) => {
project . DelProMaterialsInfo ( { materials _id : row . materials _id } ) . then ( res => {
if ( res . data . code === 20000 ) {
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 . remove Child( 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 ,
materials _url : this . materials _url ,
materials _intro : this . editMaterials . materials _intro ,
materials _type : this . editMaterials . materials _type ,
materials _file _name : this . fileName
}
} ,
methods : {
handleClick ( row ) {
console . log ( row )
this . $confirm ( '您确定要删除当前记录吗?' ) . then ( ( ) => {
project . DelProMaterialsInfo ( { materials _id : row . materials _id } ) . then ( res => {
if ( res . data . code === 20000 ) {
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 . append Child( link ) ;
link . click ( ) ;
document . body . removeChild ( link ) ;
} ,
confirmEdit ( ) {
// 获取表单数据
const formData = {
materials _id : this . editMaterials . materials _id ,
create _time : this . editMaterials . create _time ,
materials _url : this . materials _url ,
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 ( )
} else {
this . $message . error ( '更新失败:' + response . data . message )
}
} ) . catch ( error => {
console . error ( error )
this . $message . error ( '请求失败,请稍后重试' )
} )
} ,
// 调用后端接口更新数据
project . EditProjectMaterialsInfo ( formData ) . then ( response => {
if ( response . data . code === 20000 ) {
this . $message . success ( '更新成功' )
this . dialogVisibleEditMaterials = false
this . get _materials _info _list ( ) // 刷新资产列表
} else {
this . $message . error ( '更新失败:' + response . data . message )
}
} ) . catch ( error => {
this . $message . error ( '请求失败,请稍后重试' )
} ) ;
} ,
update ( row ) {
this . editMaterials . project _id = row . project _id
this . editMaterials . materials _intro = row . materials _intro
this . editMaterials . materials _url = ''
this . editMaterials . create _time = row . create _time
this . editMaterials . materials _id = row . materials _id
this . editMaterials . materials _type = row . materials _type
this . dialogVisibleEditMaterials = true
update ( row ) {
this . editMaterials . project _id = row . project _id
this . editMaterials . materials _intro = row . materials _intro
this . editMaterials . materials _url = ''
this . editMaterials . create _time = row . create _time
this . editMaterials . materials _id = row . materials _id
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 url = this . editMaterials . materials _url
const ext = url . split ( '.' ) . pop ( ) . toLowerCase ( ) ;
if ( ext === 'jpg' || ext === 'jpeg' || ext === 'png' ) {
this . isImage = true
this . isPDF = false
} else if ( ext === 'pdf' ) {
this . isImage = false
this . isPDF = true
} else {
this . $message . error ( '不支持的文件类型预览' )
}
} ,
if ( ext === 'jpg' || ext === 'jpeg' || ext === 'png' ) {
this . isImage = true
this . isPDF = false
} else if ( ext === 'pdf' ) {
this . isImage = false
this . isPDF = true
} else if ( ext === '' ) {
handleNewSuccess ( file , fileList ) {
this . materials _url = file . url
this . fileName = file . name
console . log ( file . url )
console . log ( file . name )
} ,
} else {
this . $message . error ( '不支持的文件类型预览' )
}
} ,
handleEdit Success ( file , fileList ) {
this . materials _url = file . url
this . fileName = file . name
} ,
handleNew Success ( file , fileList ) {
this . materials _url = file . url
this . fileName = file . name
console . log ( file . url )
console . log ( file . name )
} ,
handleRemove ( file , fileList ) {
console . log ( file , fileList )
} ,
handlePreview ( file ) {
console . log ( file )
} ,
beforeUpload ( file ) {
const allowedExtensions = [
'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
handleEditSuccess ( file , fileList ) {
this . materials _url = file . url
this . fileName = file . name
} ,
if ( ! isAllowed ) {
this . $message . error ( '不支持的文件类型!' )
return false
}
if ( ! isLt100M ) {
this . $message . error ( '文件大小不能超过100MB! ' )
return false
}
return true
} ,
handleRemove ( file , fileList ) {
console . log ( file , fileList )
} ,
handlePreview ( file ) {
console . log ( file )
} ,
beforeUpload ( file ) {
const allowedExtensions = [
'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 ;
showImg ( row ) {
const url = row . materials _url
const ext = url . split ( '.' ) . pop ( ) . toLowerCase ( )
this . currentFileName = row . materials _file _name
this . isImage = false
this . isPDF = true
this . isPDF = false
this . fileExtension = ext
if ( ! isAllowed ) {
this . $message . error ( '不支持的文件类型!' ) ;
return false ;
}
if ( ! isLt100M ) {
this . $message . error ( '文件大小不能超过100MB! ' ) ;
return false ;
}
return true ;
} ,
if ( [ 'jpg' , 'jpeg' , 'png' ] . includes ( ext ) ) {
this . previewU rl = p rocess . env . BASE _WMS _FILE + url
this . isImage = true
} else if ( ext === 'pdf' ) {
this . previewUrl = process . env . BASE _WMS _FILE + url
this . isPDF = tru e
} else {
this . previewUrl = process . env . BASE _WMS _FILE + url
}
this . dialogVisibleShowFile = true
} ,
showImg ( row ) {
const u rl = row . materials _ url
const ext = url . split ( '.' ) . pop ( ) . toLowerCase ( )
this . currentFileName = row . materials _file _name
this . isImage = false
this . isPDF = fals e
this . fileExtension = ext // 记录文件扩展名
confirmAddMaterials ( ) {
if ( this . newMaterials . materials _intro . trim ( ) === '' ) {
this . $message . warning ( '请输入文件描述' )
return
}
console . log ( this . materials _url )
if ( this . materials _url . trim ( ) === '' ) {
this . $message . warning ( '请选择文件' )
return
}
if ( [ 'jpg' , 'jpeg' , 'png' ] . includes ( ext ) ) {
this . previewUrl = process . env . BASE _WMS _FILE + url
this . isImage = true
} else if ( ext === 'pdf' ) {
this . previewUrl = process . env . BASE _WMS _FILE + url
this . isPDF = true
} else {
this . previewUrl = process . env . BASE _WMS _FILE + url // 必须设置预览URL
}
this . dialogVisibleShowFile = true
} ,
var param = {
materials _class : this . materials _class ,
materials _owner : this . materials _owner ,
materials _type : this . newMaterials . materials _type ,
materials _intro : this . newMaterials . materials _intro ,
materials _url : this . materials _url ,
materials _file _name : this . fileName ,
create _time : this . newMaterials . create _time
}
confirmAddMaterials ( ) {
if ( this . newMaterials . materials _intro . trim ( ) === '' ) {
this . $message . warning ( '请输入文件描述' ) ;
return ;
}
console . log ( this . materials _url )
if ( this . materials _url . trim ( ) === '' ) {
this . $message . warning ( '请选择文件' ) ;
return ;
}
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 ( )
} )
} )
} ,
var param = {
materials _class : this . materials _class ,
materials _owner : this . materials _owner ,
materials _type : this . newMaterials . materials _type ,
materials _intro : this . newMaterials . materials _intro ,
materials _url : this . materials _url ,
materials _file _name : this . fileName ,
create _time : this . newMaterials . create _time
} ;
get _materials _info _list ( ) {
var param = {
materials _owner : this . materials _owner ,
materials _class : this . materials _class ,
currPage : this . currPage ,
pageSize : this . pageSize
}
material . AddMaterialsInfo ( param ) . then ( response => {
this . $message ( {
type : 'success' ,
message : '添加成功'
} ) ;
this . get _materials _info _list ( )
} ) . catch ( error => {
this . $message ( {
type : 'error' ,
message : '添加失败,请重试' + error . toString ( )
} ) ;
} ) ;
this . dialogVisibleCreateMaterials = false ;
} ,
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
}
get _ materials_info _list ( ) {
var param = {
materials _owner : this . materials _owner ,
materials _class : this . materials _class ,
materials _type : this . materials _type
}
material . GetMaterialsInfo ( param ) . then ( response => {
this . materials _info _list = response . data . data
console . log ( this . materials _info _list ) ;
} )
} ,
if ( this . filter . dateRange && this . filter . dateRange . length === 2 ) {
param . start _time = this . filter . dateRange [ 0 ]
param . end _time = this . filter . dateRange [ 1 ]
}
get _material _type _list ( ) {
material . GetMaterialsType ( ) . then ( response => {
this . materials _type _list = response . data . data
//console.log(this.issue_type_list);
} )
} ,
material . GetMaterialsInfo ( param ) . then ( response => {
const data = response . data . d ata
if ( data && data . list != = undefined ) {
this . materials _info _list = data . list
this . total = data . total
} e lse {
this . materials _info _list = data
}
} )
} ,
createMaterials ( ) {
this . newMaterials . m aterials _intro = ''
this . newMaterials . create _time = ''
this . materials _url = ''
this . fileList = [ ] ;
this . dialogVisibleCreateMateria ls = true
}
get _material _type _list ( ) {
material . GetMaterialsType ( ) . then ( response => {
this . materials _type _list = response . data . data
} )
} ,
createMaterials ( ) {
this . newMaterials . materials _intro = ''
this . newMaterials . create _time = ''
this . newMaterials . materials _type = this . filter . materials _type || ''
this . materials _url = ''
this . fileList = [ ]
this . dialogVisibleCreateMaterials = true
}
}
}
}
< / script >
< style >
@@ -526,4 +397,4 @@ export default {
color : # e6a23c ;
margin - bottom : 15 px ;
}
< / style >
< / style >