|
|
@@ -79,7 +79,7 @@
|
|
|
</el-table-column>
|
|
|
|
|
|
<!-- 操作列 -->
|
|
|
- <el-table-column label="操作" width="200" align="center" fixed="right">
|
|
|
+ <el-table-column label="操作" width="260" align="center" fixed="right">
|
|
|
<template slot-scope="scope">
|
|
|
<el-button
|
|
|
type="text"
|
|
|
@@ -105,10 +105,27 @@
|
|
|
>
|
|
|
删除
|
|
|
</el-button>
|
|
|
+ <el-button
|
|
|
+ type="text"
|
|
|
+ size="small"
|
|
|
+ :disabled="isViewMode"
|
|
|
+ @click="triggerRowUpload(scope.row)"
|
|
|
+ >
|
|
|
+ 数据上传
|
|
|
+ </el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
|
|
|
+ <!-- 行内复用的隐藏上传输入框 -->
|
|
|
+ <input
|
|
|
+ ref="dynamicUploadInput"
|
|
|
+ type="file"
|
|
|
+ accept=".xls,.xlsx"
|
|
|
+ style="display: none"
|
|
|
+ @change="handleDynamicDataFileChange"
|
|
|
+ />
|
|
|
+
|
|
|
<!-- 分页 -->
|
|
|
<el-pagination
|
|
|
background
|
|
|
@@ -229,6 +246,7 @@
|
|
|
getDynamicTableData,
|
|
|
deleteDynamicTableData,
|
|
|
addDynamicTableData,
|
|
|
+ importData,
|
|
|
getSingleRecordSurveyList,
|
|
|
getSurveyDetail,
|
|
|
} from '@/api/audit/survey'
|
|
|
@@ -302,6 +320,8 @@
|
|
|
return {
|
|
|
dialogVisible: false,
|
|
|
loading: false,
|
|
|
+ uploading: false,
|
|
|
+ pendingUploadRow: null,
|
|
|
// 新增弹窗状态与表单
|
|
|
addDialogVisible: false,
|
|
|
adding: false,
|
|
|
@@ -387,6 +407,48 @@
|
|
|
},
|
|
|
},
|
|
|
methods: {
|
|
|
+ triggerRowUpload(row) {
|
|
|
+ this.pendingUploadRow = row || null
|
|
|
+ const el = this.$refs.dynamicUploadInput
|
|
|
+ if (el && el.click) el.click()
|
|
|
+ },
|
|
|
+ async handleDynamicDataFileChange(e) {
|
|
|
+ const files = e && e.target && e.target.files
|
|
|
+ const file = files && files[0]
|
|
|
+ if (!file) return
|
|
|
+ const sd = this.surveyData || {}
|
|
|
+ const formData = new FormData()
|
|
|
+ formData.append('file', file)
|
|
|
+ const surveyTemplateId =
|
|
|
+ this.surveyTemplateId || sd.surveyTemplateId || ''
|
|
|
+ const auditedUnitId = this.auditedUnitId || sd.auditedUnitId || ''
|
|
|
+ const catalogId = this.catalogId || sd.catalogId || ''
|
|
|
+ const taskId = this.taskId || sd.taskId || ''
|
|
|
+ if (surveyTemplateId)
|
|
|
+ formData.append('surveyTemplateId', surveyTemplateId)
|
|
|
+ if (auditedUnitId) formData.append('auditedUnitId', auditedUnitId)
|
|
|
+ if (catalogId) formData.append('catalogId', catalogId)
|
|
|
+ if (taskId) formData.append('taskId', taskId)
|
|
|
+ formData.append('type', this.requestType)
|
|
|
+ try {
|
|
|
+ this.uploading = true
|
|
|
+ const res = await importData(formData)
|
|
|
+ if (res && res.code === 200) {
|
|
|
+ Message.success('上传成功')
|
|
|
+ this.$emit('refresh')
|
|
|
+ this.loadDynamicTableData()
|
|
|
+ } else {
|
|
|
+ Message.error(res && res.message ? res.message : '上传失败')
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ console.error('上传失败:', err)
|
|
|
+ // Message.error('上传失败')
|
|
|
+ } finally {
|
|
|
+ this.uploading = false
|
|
|
+ this.pendingUploadRow = null
|
|
|
+ if (e && e.target) e.target.value = ''
|
|
|
+ }
|
|
|
+ },
|
|
|
// 加载动态表数据(对接接口)
|
|
|
async loadDynamicTableData() {
|
|
|
// 优先使用接口数据(需要 uploadId、auditedUnitId)
|
|
|
@@ -1365,7 +1427,7 @@
|
|
|
Message.warning('该记录缺少可删除的ID')
|
|
|
return
|
|
|
}
|
|
|
- deleteDynamicTableData({ id: row.id })
|
|
|
+ deleteDynamicTableData({ id: row.id, type: this.requestType })
|
|
|
.then(() => {
|
|
|
Message.success('删除成功')
|
|
|
// 重新加载数据
|