|
|
@@ -12,12 +12,12 @@
|
|
|
添加材料
|
|
|
</el-button>
|
|
|
<CostAuditTable
|
|
|
- :table-data="materialData.list"
|
|
|
- :columns="materialData.materialColumns"
|
|
|
+ :table-data="materialList"
|
|
|
+ :columns="materialColumns"
|
|
|
:show-index="true"
|
|
|
:show-pagination="true"
|
|
|
:show-action-column="true"
|
|
|
- :pagination="materialData.pagination"
|
|
|
+ :pagination="pagination"
|
|
|
@pagination-change="handlePaginationChange"
|
|
|
>
|
|
|
<template #orderNum="scope">
|
|
|
@@ -28,11 +28,34 @@
|
|
|
@blur="handleSortChange(scope.row)"
|
|
|
></el-input>
|
|
|
</template>
|
|
|
+ <template #action="scope">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ size="mini"
|
|
|
+ plain
|
|
|
+ icon="el-icon-edit"
|
|
|
+ :disabled="isView"
|
|
|
+ @click="handleEditMaterial(scope.row)"
|
|
|
+ >
|
|
|
+ 修改
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ type="danger"
|
|
|
+ size="mini"
|
|
|
+ plain
|
|
|
+ icon="el-icon-delete"
|
|
|
+ :disabled="isView"
|
|
|
+ @click="handleDeleteMaterial(scope.row)"
|
|
|
+ >
|
|
|
+ 删除
|
|
|
+ </el-button>
|
|
|
+ />
|
|
|
+ </template>
|
|
|
</CostAuditTable>
|
|
|
<legal-dialog
|
|
|
ref="legalDialog"
|
|
|
- :dialog-visible="materialData.materialDialogVisible"
|
|
|
- :dialog-title="materialData.materialDialogTitle"
|
|
|
+ :dialog-visible="materialDialogVisible"
|
|
|
+ :dialog-title="materialDialogTitle"
|
|
|
:template-data="templateData"
|
|
|
:template-columns="templateColumns"
|
|
|
:form-data="formData.material"
|
|
|
@@ -46,14 +69,17 @@
|
|
|
addCostProjectMaterial,
|
|
|
updateCostProjectMaterial,
|
|
|
deleteCostProjectMaterial,
|
|
|
+ getCostProjectMaterialPageList,
|
|
|
} from '@/api/taskCustomizedRelease.js'
|
|
|
import CostAuditTable from '@/components/costAudit/CostAuditTable.vue'
|
|
|
import LegalDialog from '@/views/costAudit/baseInfo/catalogManage/legalDialog.vue'
|
|
|
+ import { dictMixin } from '@/mixins/useDict'
|
|
|
export default {
|
|
|
components: {
|
|
|
CostAuditTable,
|
|
|
LegalDialog,
|
|
|
},
|
|
|
+ mixins: [dictMixin],
|
|
|
props: {
|
|
|
// 父组件传递的参数
|
|
|
project: {
|
|
|
@@ -64,13 +90,13 @@
|
|
|
type: Boolean,
|
|
|
default: false,
|
|
|
},
|
|
|
- materialData: {
|
|
|
- type: Object,
|
|
|
- default: () => {},
|
|
|
- },
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ dictData: {
|
|
|
+ materialType: [], //资料类别
|
|
|
+ formatAsk: [], //格式要求
|
|
|
+ },
|
|
|
// 模板相关数据
|
|
|
templateData: [],
|
|
|
templateColumns: [
|
|
|
@@ -93,20 +119,142 @@
|
|
|
formData: {
|
|
|
material: {},
|
|
|
},
|
|
|
+ addMaterial: false,
|
|
|
+ materialDialogVisible: false,
|
|
|
+ materialDialogTitle: '添加',
|
|
|
+ // 简化数据结构,避免嵌套对象可能导致的数据绑定问题
|
|
|
+ materialList: [],
|
|
|
+ pagination: {
|
|
|
+ currentPage: 1,
|
|
|
+ pageSize: 50,
|
|
|
+ total: 0,
|
|
|
+ },
|
|
|
+ materialColumns: [],
|
|
|
}
|
|
|
},
|
|
|
+ computed: {},
|
|
|
watch: {
|
|
|
- materialData: {
|
|
|
- handler(val) {
|
|
|
- if (val) {
|
|
|
- this.formData.material = val.material
|
|
|
+ // 监听project变化,确保有项目ID时刷新数据
|
|
|
+ project: {
|
|
|
+ handler(newVal) {
|
|
|
+ if (newVal && newVal.projectId) {
|
|
|
+ this.loadMaterialData()
|
|
|
}
|
|
|
},
|
|
|
deep: true,
|
|
|
},
|
|
|
},
|
|
|
- mounted() {},
|
|
|
+ mounted() {
|
|
|
+ // 组件挂载时先初始化表格列配置
|
|
|
+ this.materialColumns = this.getMaterialColumns()
|
|
|
+ // 然后加载数据
|
|
|
+ if (this.project && this.project.projectId) {
|
|
|
+ this.loadMaterialData()
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ // 获取表格列配置
|
|
|
+ getMaterialColumns() {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ prop: 'informationType',
|
|
|
+ label: '材料分类',
|
|
|
+ width: 120,
|
|
|
+ align: 'center',
|
|
|
+ formatter: (row) => {
|
|
|
+ return this.getDictName('materialType', row.informationType)
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'informationName',
|
|
|
+ label: '材料名称',
|
|
|
+ minWidth: 200,
|
|
|
+ align: 'left',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'informationRequire',
|
|
|
+ label: '材料要求说明',
|
|
|
+ minWidth: 300,
|
|
|
+ align: 'left',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'formatRequired',
|
|
|
+ label: '格式要求',
|
|
|
+ width: 120,
|
|
|
+ align: 'center',
|
|
|
+ formatter: (row) => {
|
|
|
+ return this.getDictName('formatAsk', row.formatRequired)
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'orderNum',
|
|
|
+ label: '排序',
|
|
|
+ width: 120,
|
|
|
+ align: 'center',
|
|
|
+ slotName: 'orderNum',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'action',
|
|
|
+ label: '操作',
|
|
|
+ align: 'center',
|
|
|
+ width: 200,
|
|
|
+ slotName: 'action',
|
|
|
+ actions: [
|
|
|
+ {
|
|
|
+ name: 'edit',
|
|
|
+ label: '修改',
|
|
|
+ type: 'text',
|
|
|
+ size: 'mini',
|
|
|
+ onClick: this.handleEditMaterial,
|
|
|
+ disabled: this.isView,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'delete',
|
|
|
+ label: '删除',
|
|
|
+ type: 'text',
|
|
|
+ size: 'mini',
|
|
|
+ className: 'delete-btn',
|
|
|
+ onClick: this.handleDeleteMaterial,
|
|
|
+ disabled: this.isView,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ },
|
|
|
+
|
|
|
+ // 加载材料数据
|
|
|
+ loadMaterialData() {
|
|
|
+ // 确保project和projectId存在
|
|
|
+ if (!this.project || !this.project.projectId) {
|
|
|
+ console.warn('项目ID不存在,无法加载材料数据')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const { currentPage, pageSize } = this.pagination
|
|
|
+ const params = {
|
|
|
+ projectId: this.project.projectId,
|
|
|
+ page: currentPage,
|
|
|
+ size: pageSize,
|
|
|
+ }
|
|
|
+ getCostProjectMaterialPageList(params)
|
|
|
+ .then((res) => {
|
|
|
+ if (res && res.value && res.value.value) {
|
|
|
+ this.materialList = Array.isArray(res.value.value.records)
|
|
|
+ ? res.value.value.records
|
|
|
+ : []
|
|
|
+ this.pagination.total = Number(res.value.value.total) || 0
|
|
|
+ } else {
|
|
|
+ this.materialList = []
|
|
|
+ this.pagination.total = 0
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ console.error('加载材料数据失败:', error)
|
|
|
+ // 错误时清空数据避免显示异常
|
|
|
+ this.materialList = []
|
|
|
+ this.pagination.total = 0
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
// 排序变更
|
|
|
handleSortChange(row) {
|
|
|
// 排序逻辑
|
|
|
@@ -117,7 +265,7 @@
|
|
|
updateCostProjectMaterial(data)
|
|
|
.then((res) => {
|
|
|
this.$message.success('修改成功')
|
|
|
- this.$emit('refresh')
|
|
|
+ this.loadMaterialData()
|
|
|
})
|
|
|
.catch(() => {})
|
|
|
},
|
|
|
@@ -133,24 +281,16 @@
|
|
|
orderNum: 1,
|
|
|
isRequired: '0',
|
|
|
}
|
|
|
- // 通知父组件更新状态
|
|
|
- this.$emit('update:materialData', {
|
|
|
- ...this.materialData,
|
|
|
- addMaterial: true,
|
|
|
- materialDialogVisible: true,
|
|
|
- materialDialogTitle: '添加',
|
|
|
- })
|
|
|
+ this.materialDialogVisible = true
|
|
|
+ this.materialDialogTitle = '添加'
|
|
|
+ // 移除可能导致数据依赖新增操作的逻辑
|
|
|
},
|
|
|
|
|
|
// 编辑材料
|
|
|
handleEditMaterial(row) {
|
|
|
this.formData.material = { ...row }
|
|
|
- // 通知父组件更新状态
|
|
|
- this.$emit('update:materialData', {
|
|
|
- ...this.materialData,
|
|
|
- materialDialogTitle: '修改',
|
|
|
- materialDialogVisible: true,
|
|
|
- })
|
|
|
+ this.materialDialogVisible = true
|
|
|
+ this.materialDialogTitle = '修改'
|
|
|
},
|
|
|
|
|
|
// 删除材料
|
|
|
@@ -168,7 +308,7 @@
|
|
|
try {
|
|
|
deleteCostProjectMaterial(row.id).then((res) => {
|
|
|
this.$message.success('删除成功')
|
|
|
- this.$emit('refresh')
|
|
|
+ this.loadMaterialData()
|
|
|
})
|
|
|
} catch (error) {
|
|
|
console.error('删除失败:', error)
|
|
|
@@ -185,41 +325,37 @@
|
|
|
...formData,
|
|
|
projectId: this.project.projectId,
|
|
|
}
|
|
|
- if (!formData.id) {
|
|
|
- addCostProjectMaterial(data).then((res) => {
|
|
|
- this.$message.success('添加成功')
|
|
|
+ updateCostProjectMaterial(data)
|
|
|
+ .then((res) => {
|
|
|
+ this.$message.success('保存成功')
|
|
|
this.$refs.legalDialog.setSubmitting(false)
|
|
|
- // 通知父组件关闭弹窗并刷新数据
|
|
|
- this.$emit('update:materialData', {
|
|
|
- ...this.materialData,
|
|
|
- materialDialogVisible: false,
|
|
|
- })
|
|
|
- this.$emit('refresh')
|
|
|
+ this.materialDialogVisible = false
|
|
|
+ this.loadMaterialData()
|
|
|
})
|
|
|
- } else {
|
|
|
- updateCostProjectMaterial(data).then((res) => {
|
|
|
- this.$message.success('修改成功')
|
|
|
+ .catch(() => {
|
|
|
this.$refs.legalDialog.setSubmitting(false)
|
|
|
- // 通知父组件关闭弹窗并刷新数据
|
|
|
- this.$emit('update:materialData', {
|
|
|
- ...this.materialData,
|
|
|
- materialDialogVisible: false,
|
|
|
- })
|
|
|
- this.$emit('refresh')
|
|
|
})
|
|
|
- }
|
|
|
},
|
|
|
handleLegalSubmit() {},
|
|
|
handleMaterialCancel() {
|
|
|
- this.$emit('update:materialData', {
|
|
|
- ...this.materialData,
|
|
|
- materialDialogVisible: false,
|
|
|
- })
|
|
|
+ this.formData.material = {
|
|
|
+ informationType: '',
|
|
|
+ informationName: '',
|
|
|
+ informationRequire: '',
|
|
|
+ formatRequired: '',
|
|
|
+ templateId: '',
|
|
|
+ surveyTemplateName: '',
|
|
|
+ orderNum: 1,
|
|
|
+ isRequired: '0',
|
|
|
+ }
|
|
|
+ this.materialDialogVisible = false
|
|
|
},
|
|
|
getTemplateOptions() {},
|
|
|
templatePaginationChange() {},
|
|
|
handlePaginationChange({ currentPage, pageSize }) {
|
|
|
- this.$emit('paginationChange', { currentPage, pageSize })
|
|
|
+ this.pagination.currentPage = currentPage
|
|
|
+ this.pagination.pageSize = pageSize
|
|
|
+ this.loadMaterialData()
|
|
|
},
|
|
|
},
|
|
|
}
|