Ver Fonte

fix:任务制定-报送资料要求-修改、删除按钮点击Bug

cb_luzhixia há 1 mês atrás
pai
commit
1d494cccf5

+ 22 - 2
src/views/costAudit/projectInfo/auditTaskManage/taskCustomizedRelease/auditNoticeTab.vue

@@ -728,7 +728,7 @@
             this.$emit('refresh', this.project.projectId) // 通知父组件刷新
           } catch (error) {
             // 错误处理
-            this.$message.error('操作失败:' + (error.message || '未知错误'))
+            // this.$message.error('操作失败:' + (error.message || '未知错误'))
           } finally {
             // 关闭遮罩层
             loading.close()
@@ -800,7 +800,27 @@
       },
 
       // 下载文档
-      handleDownloadDocument(row) {},
+      handleDownloadDocument(row) {
+        if (!row.electronicDocumentUrl) {
+          this.$message.error('暂无电子文档可供下载!')
+          return
+        }
+
+        try {
+          // 构建完整的文件URL
+          const fileUrl = row.electronicDocumentUrl.startsWith('http')
+            ? row.electronicDocumentUrl
+            : window.context.form + row.electronicDocumentUrl
+
+          // 直接在新窗口打开(浏览器会自动处理下载)
+          window.open(fileUrl, '_blank')
+
+          this.$message.success('文档下载开始!')
+        } catch (error) {
+          console.error('下载失败:', error)
+          this.$message.error('文档下载失败:' + (error.message || '未知错误'))
+        }
+      },
     },
   }
 </script>

+ 126 - 113
src/views/costAudit/projectInfo/auditTaskManage/taskCustomizedRelease/index.js

@@ -131,118 +131,6 @@ export const taskMixin = {
         addScenario: false,
         saveScenario: false,
       },
-      // 数据列表聚合
-      materialData: {
-        list: [],
-        pagination: {
-          currentPage: 1,
-          pageSize: 50,
-          total: 0,
-        },
-        materialDialogTitle: '添加',
-        materialDialogVisible: false,
-        saveMaterial: false,
-        addMaterial: false,
-        materialColumns: [
-          {
-            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,
-            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,
-              },
-            ],
-          },
-        ],
-      },
-      surveyData: {
-        list: [],
-        pagination: {
-          currentPage: 1,
-          pageSize: 50,
-          total: 0,
-        },
-        surveyColumns: [
-          {
-            prop: 'surveyTemplateName',
-            label: '成本调查表',
-            minWidth: 200,
-            align: 'left',
-            showOverflowTooltip: true,
-          },
-          {
-            prop: 'type',
-            label: '资料类型',
-            width: 120,
-            align: 'center',
-          },
-          {
-            prop: 'isMust',
-            label: '是否必填',
-            width: 100,
-            align: 'center',
-          },
-          {
-            prop: 'action',
-            label: '操作',
-            width: 120,
-            align: 'center',
-          },
-        ],
-      },
 
       workflowData: {
         list: [],
@@ -420,7 +308,132 @@ export const taskMixin = {
       },
     }
   },
-  computed: {},
+  computed: {
+    surveyData() {
+      return {
+        list: [],
+        pagination: {
+          currentPage: 1,
+          pageSize: 50,
+          total: 0,
+        },
+        surveyColumns: [
+          {
+            prop: 'surveyTemplateName',
+            label: '成本调查表',
+            width: 300,
+            align: 'left',
+            showOverflowTooltip: true,
+          },
+          {
+            prop: 'templateType',
+            label: '资料类型',
+            width: 120,
+            align: 'center',
+            formatter: (row) => {
+              return row.templateType == '1'
+                ? '单记录'
+                : row.templateType == '2'
+                ? '固定表'
+                : '动态表'
+            },
+          },
+          // {
+          //   prop: 'isMust',
+          //   label: '是否必填',
+          //   width: 100,
+          //   align: 'center',
+          // },
+          {
+            prop: 'action',
+            label: '操作',
+            width: 120,
+            align: 'center',
+          },
+        ],
+      }
+    },
+    // 数据列表聚合
+    materialData() {
+      return {
+        list: [],
+        pagination: {
+          currentPage: 1,
+          pageSize: 50,
+          total: 0,
+        },
+        materialDialogTitle: '添加',
+        materialDialogVisible: false,
+        saveMaterial: false,
+        addMaterial: false,
+        materialColumns: [
+          {
+            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,
+              },
+            ],
+          },
+        ],
+      }
+    },
+  },
   watch: {
     activeTab: {
       handler(newVal) {

+ 0 - 1
src/views/costAudit/projectInfo/auditTaskManage/taskCustomizedRelease/index.vue

@@ -316,7 +316,6 @@
         })
       },
       getUnitName(unitId) {
-        // 直接处理unitId值,而不是row对象
         if (unitId && typeof unitId === 'string' && unitId.includes(',')) {
           // 如果包含逗号,分割成数组并查找对应的unitName
           const unitIds = unitId.split(',')

+ 189 - 53
src/views/costAudit/projectInfo/auditTaskManage/taskCustomizedRelease/materialTab.vue

@@ -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()
       },
     },
   }

+ 92 - 26
src/views/costAudit/projectInfo/auditTaskManage/taskCustomizedRelease/surveyTab.vue

@@ -1,9 +1,11 @@
 <template>
   <div>
+    <!-- 表格组件 -->
     <CostAuditTable
+      style="width: 50%"
+      :data="surveyData.list"
       :table-data="surveyData.list"
       :columns="getSurveyColumns()"
-      :show-index="true"
       :show-action-column="true"
     ></CostAuditTable>
     <!-- 成本调查表查看弹窗 -->
@@ -19,6 +21,8 @@
 <script>
   import CostAuditTable from '@/components/costAudit/CostAuditTable.vue'
   import SurveyDialog from '@/views/costAudit/baseInfo/catalogManage/surveyDialog.vue'
+  // 引入获取调查模板数据的API
+  import { getCostSurveyTemplates } from '@/api/catalogManage.js'
   export default {
     components: {
       CostAuditTable,
@@ -34,10 +38,6 @@
         type: Boolean,
         default: false,
       },
-      surveyData: {
-        type: Object,
-        default: () => {},
-      },
     },
     data() {
       return {
@@ -55,42 +55,108 @@
           // 动态表列表
           dynamicTable: [],
         },
+        // 内部管理调查数据
+        surveyData: {
+          list: [],
+        },
       }
     },
+    watch: {
+      // 监听project变化,确保有项目ID时刷新数据
+      project: {
+        handler(newVal) {
+          if (newVal && newVal.projectId) {
+            this.loadSurveyData()
+          }
+        },
+        deep: true,
+        immediate: true,
+      },
+    },
     mounted() {
-      // this.getSurveyData()
+      // 组件挂载时加载数据
+      if (this.project && this.project.projectId) {
+        this.loadSurveyData()
+      }
     },
 
     methods: {
+      // 加载调查模板数据
+      loadSurveyData() {
+        if (!this.project || !this.project.projectId) {
+          console.warn('项目ID不存在,无法加载调查模板数据')
+          return
+        }
+
+        const params = {
+          catalogId: this.project.catalogId,
+        }
+        getCostSurveyTemplates(params)
+          .then((res) => {
+            // 尝试多种可能的数据结构
+            if (res && res.value) {
+              this.surveyData.list = Array.isArray(res.value) ? res.value : []
+            }
+          })
+          .catch((error) => {
+            console.error('加载调查模板数据失败:', error)
+            this.surveyData.list = []
+          })
+      },
+
       // 获取带操作按钮的表格列配置
       getSurveyColumns() {
-        const columns = JSON.parse(
-          JSON.stringify(this.surveyData.surveyColumns || [])
-        )
-        const actionColumn = columns.find((col) => col.prop === 'action')
-        if (actionColumn) {
-          actionColumn.actions = [
-            {
-              name: 'view',
-              label: '查看模板',
-              type: 'text',
-              onClick: this.handleViewTemplate,
+        // 组件自身定义的列配置,不再依赖父组件
+        return [
+          {
+            prop: 'surveyTemplateName',
+            label: '模板名称',
+            minWidth: 180,
+            align: 'left',
+          },
+          {
+            prop: 'templateType',
+            label: '模板类型',
+            width: 120,
+            align: 'center',
+            formatter: (row) => {
+              return row.templateType == '1'
+                ? '单记录'
+                : row.templateType == '2'
+                ? '固定表'
+                : '动态表'
             },
-          ]
-        }
-        return columns
+          },
+          {
+            prop: 'action',
+            label: '操作',
+            align: 'center',
+            width: 120,
+            actions: [
+              {
+                name: 'view',
+                label: '查看模板',
+                type: 'text',
+                onClick: this.handleViewTemplate,
+              },
+            ],
+          },
+        ]
       },
       // 查看成本调查表内容弹窗
       handleViewTemplate(data) {
         // 设置表单数据
         this.contentEditForm = {
           surveyTemplateName: data.surveyTemplateName || '',
-          templateType: data.templateType || '',
-          data:
-            {
-              ...data,
-              surveyId: data.surveyTemplateId,
-            } || {},
+          templateType: data.templateType || '1',
+          data: {
+            ...data,
+            surveyId: data.surveyTemplateId,
+          },
+          // 确保表单有必要的字段
+          tableHeaders: data.tableHeaders || [],
+          fixedTable: data.fixedTable || [],
+          dynamicTable: data.dynamicTable || [],
         }
         // 设置弹窗标题
         this.contentEditDialogTitle = '查看'