fix:质检发货资料类型选择问题

This commit is contained in:
miguannan
2026-05-22 09:42:29 +08:00
parent 53589c2f4f
commit 814eef5cc9

View File

@@ -11,7 +11,13 @@
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-select
v-model="filter.materials_type"
placeholder="资料类型"
clearable
size="small"
style="width: 160px; margin-left: 10px;"
@change="handleMaterialsTypeChange">
<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>
@@ -228,6 +234,7 @@ export default {
fileName: '',
currentFileName: '',
query_triggered: false,
useDefaultMaterialsType: true,
total: 0,
currPage: 1,
pageSize: 10,
@@ -238,6 +245,7 @@ export default {
newMaterials: {
materials_intro: '',
create_time: '',
materials_type: '',
project_id: 0
},
editMaterials: {
@@ -254,9 +262,7 @@ export default {
},
mounted() {
this.get_material_type_list()
if (!Array.isArray(this.materials_type)) {
this.filter.materials_type = this.materials_type
}
this.resetDefaultMaterialsType()
},
created() {
@@ -301,7 +307,7 @@ export default {
},
handleReset() {
this.filter.dateRange = null
this.filter.materials_type = ''
this.resetDefaultMaterialsType()
this.currPage = 1
this.pageSize = 10
this.total = 0
@@ -317,6 +323,37 @@ export default {
this.currPage = val
this.get_materials_info_list()
},
handleMaterialsTypeChange() {
this.useDefaultMaterialsType = false
},
resetDefaultMaterialsType() {
this.useDefaultMaterialsType = true
this.filter.materials_type = Array.isArray(this.materials_type) ? '' : this.materials_type
},
hasSelectedMaterialType(value) {
return value !== '' && value !== undefined && value !== null
},
buildMaterialsQueryParams() {
const param = {
materials_owner: this.materials_owner,
materials_class: this.materials_class,
currPage: this.currPage,
pageSize: this.pageSize
}
if (this.hasSelectedMaterialType(this.filter.materials_type)) {
param.materials_type = this.filter.materials_type
} else if (this.useDefaultMaterialsType && this.hasSelectedMaterialType(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]
}
return param
},
confirmEdit() {
const formData = {
materials_id: this.editMaterials.materials_id,
@@ -429,12 +466,15 @@ export default {
},
confirmAddMaterials() {
if (this.newMaterials.materials_intro.trim() === '') {
const materialsIntro = (this.newMaterials.materials_intro || '').trim()
const materialsUrl = (this.materials_url || '').trim()
if (materialsIntro === '') {
this.$message.warning('请输入文件描述')
return
}
console.log(this.materials_url)
if (this.materials_url.trim() === '') {
if (materialsUrl === '') {
this.$message.warning('请选择文件')
return
}
@@ -443,7 +483,7 @@ export default {
materials_class: this.materials_class,
materials_owner: this.materials_owner,
materials_type: this.newMaterials.materials_type,
materials_intro: this.newMaterials.materials_intro,
materials_intro: materialsIntro,
materials_url: this.materials_url,
materials_file_name: this.fileName,
create_time: this.newMaterials.create_time
@@ -468,23 +508,7 @@ export default {
},
get_materials_info_list() {
var param = {
materials_owner: this.materials_owner,
materials_class: this.materials_class,
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]
}
var param = this.buildMaterialsQueryParams()
material.GetMaterialsInfo(param).then(response => {
const data = response.data.data