招标解析
This commit is contained in:
parent
c6fef5519c
commit
cd327898f5
|
|
@ -78,7 +78,11 @@
|
||||||
v-if="selectionShow && isSelectShow" />
|
v-if="selectionShow && isSelectShow" />
|
||||||
<el-table-column width="45" align="center" label="" v-if="isRadioShow">
|
<el-table-column width="45" align="center" label="" v-if="isRadioShow">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-radio :label="getRowUniqueId(scope.row)" v-model="currentRowId">
|
<el-radio
|
||||||
|
:label="getRowUniqueId(scope.row, scope.$index)"
|
||||||
|
v-model="currentRowId"
|
||||||
|
@change="handleRadioChange(scope.row, scope.$index)"
|
||||||
|
>
|
||||||
<span></span>
|
<span></span>
|
||||||
</el-radio>
|
</el-radio>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -194,6 +198,11 @@ export default {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
// 单选框唯一标识的字段名(如 'id', 'proId', 'bidId' 等)
|
||||||
|
radioKey: {
|
||||||
|
type: String,
|
||||||
|
default: 'id',
|
||||||
|
},
|
||||||
// 测试时使用的数据源
|
// 测试时使用的数据源
|
||||||
testTableList: {
|
testTableList: {
|
||||||
type: Array,
|
type: Array,
|
||||||
|
|
@ -429,10 +438,17 @@ export default {
|
||||||
this.total = res.total
|
this.total = res.total
|
||||||
// 数据刷新后,如果之前选中的行不在当前列表中,清空选中状态
|
// 数据刷新后,如果之前选中的行不在当前列表中,清空选中状态
|
||||||
if (this.isRadioShow && this.currentRowId) {
|
if (this.isRadioShow && this.currentRowId) {
|
||||||
const exists = this.tableList.some(
|
let exists = false
|
||||||
(row) =>
|
for (let i = 0; i < this.tableList.length; i++) {
|
||||||
this.getRowUniqueId(row) === this.currentRowId,
|
const row = this.tableList[i]
|
||||||
)
|
const uniqueId = this.getRowUniqueId(row, i)
|
||||||
|
if (uniqueId === this.currentRowId) {
|
||||||
|
exists = true
|
||||||
|
// 更新当前行数据引用
|
||||||
|
this.currentRowData = row
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
this.currentRowId = null
|
this.currentRowId = null
|
||||||
this.currentRowData = null
|
this.currentRowData = null
|
||||||
|
|
@ -546,16 +562,62 @@ export default {
|
||||||
this.selectedData = e
|
this.selectedData = e
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取行的唯一标识(优先使用id,否则使用索引)
|
// 获取行的唯一标识(优先使用 radioKey 指定的字段)
|
||||||
getRowUniqueId(row) {
|
getRowUniqueId(row, index) {
|
||||||
return row.id || row.proId || row.bidId || JSON.stringify(row)
|
// 优先使用 radioKey 指定的字段作为唯一标识
|
||||||
|
if (this.radioKey && row[this.radioKey] !== undefined && row[this.radioKey] !== null && row[this.radioKey] !== '') {
|
||||||
|
return String(row[this.radioKey])
|
||||||
|
}
|
||||||
|
// 如果 radioKey 指定的字段不存在,尝试使用常见的ID字段
|
||||||
|
if (row.id !== undefined && row.id !== null && row.id !== '') {
|
||||||
|
return String(row.id)
|
||||||
|
}
|
||||||
|
if (row.proId !== undefined && row.proId !== null && row.proId !== '') {
|
||||||
|
return String(row.proId)
|
||||||
|
}
|
||||||
|
if (row.bidId !== undefined && row.bidId !== null && row.bidId !== '') {
|
||||||
|
return String(row.bidId)
|
||||||
|
}
|
||||||
|
// 如果都没有,使用索引作为后备(确保唯一性)
|
||||||
|
// 注意:如果数据没有唯一ID,使用索引可能导致分页切换时选中状态丢失
|
||||||
|
const rowIndex = index !== undefined ? index : this.tableList.findIndex(r => r === row)
|
||||||
|
// 使用行的内容生成一个稳定的哈希值作为唯一标识
|
||||||
|
try {
|
||||||
|
const rowStr = JSON.stringify(row)
|
||||||
|
// 简单的哈希函数,确保相同内容返回相同值
|
||||||
|
let hash = 0
|
||||||
|
for (let i = 0; i < rowStr.length; i++) {
|
||||||
|
const char = rowStr.charCodeAt(i)
|
||||||
|
hash = ((hash << 5) - hash) + char
|
||||||
|
hash = hash & hash // Convert to 32bit integer
|
||||||
|
}
|
||||||
|
return `hash_${Math.abs(hash)}_${rowIndex}`
|
||||||
|
} catch (e) {
|
||||||
|
// 如果序列化失败,使用索引
|
||||||
|
return `index_${rowIndex}`
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 处理单选框变化事件
|
||||||
|
handleRadioChange(row, index) {
|
||||||
|
if (this.isRadioShow && row) {
|
||||||
|
const uniqueId = this.getRowUniqueId(row, index)
|
||||||
|
// 只有当值真正改变时才更新,避免重复触发
|
||||||
|
if (this.currentRowId !== uniqueId) {
|
||||||
|
this.currentRowId = uniqueId
|
||||||
|
this.currentRowData = row
|
||||||
|
// 注意:这里不直接 emit,让 watch 中的监听器来处理,避免重复触发
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// 处理表格当前行变化(用于高亮)
|
// 处理表格当前行变化(用于高亮)
|
||||||
handleCurrentChange(currentRow) {
|
handleCurrentChange(currentRow) {
|
||||||
if (this.isRadioShow && currentRow) {
|
if (this.isRadioShow && currentRow) {
|
||||||
this.currentRowId = this.getRowUniqueId(currentRow)
|
const index = this.tableList.findIndex(r => r === currentRow)
|
||||||
|
const uniqueId = this.getRowUniqueId(currentRow, index)
|
||||||
|
this.currentRowId = uniqueId
|
||||||
|
this.currentRowData = currentRow
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -613,12 +675,21 @@ export default {
|
||||||
// 监听单选框选中值的变化
|
// 监听单选框选中值的变化
|
||||||
currentRowId(newVal, oldVal) {
|
currentRowId(newVal, oldVal) {
|
||||||
if (this.isRadioShow && newVal && newVal !== oldVal) {
|
if (this.isRadioShow && newVal && newVal !== oldVal) {
|
||||||
// 找到对应的行数据
|
// 找到对应的行数据和索引
|
||||||
const row = this.tableList.find(r => this.getRowUniqueId(r) === newVal)
|
let foundRow = null
|
||||||
if (row) {
|
let foundIndex = -1
|
||||||
const index = this.tableList.findIndex(r => this.getRowUniqueId(r) === newVal)
|
for (let i = 0; i < this.tableList.length; i++) {
|
||||||
this.currentRowData = row
|
const row = this.tableList[i]
|
||||||
this.$emit('radio-change', row, index)
|
const uniqueId = this.getRowUniqueId(row, i)
|
||||||
|
if (uniqueId === newVal) {
|
||||||
|
foundRow = row
|
||||||
|
foundIndex = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (foundRow) {
|
||||||
|
this.currentRowData = foundRow
|
||||||
|
this.$emit('radio-change', foundRow, foundIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@
|
||||||
<TableModel :showSearch="false" :showOperation="false" :showRightTools="false"
|
<TableModel :showSearch="false" :showOperation="false" :showRightTools="false"
|
||||||
ref="detailTableRef" :columnsList="detailColumnsList" :request-api="getBidListAPI"
|
ref="detailTableRef" :columnsList="detailColumnsList" :request-api="getBidListAPI"
|
||||||
:sendParams="sendParams" :handleColWidth="180" :isRadioShow="true"
|
:sendParams="sendParams" :handleColWidth="180" :isRadioShow="true"
|
||||||
@radio-change="handleRadioChange" :indexNumShow="false" :isShowtableCardStyle="false">
|
@radio-change="handleRadioChange" :indexNumShow="false" :isShowtableCardStyle="false" :radioKey="radioKey">
|
||||||
<template slot="tableTitle">
|
<template slot="tableTitle">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<img src="@/assets/enterpriseLibrary/basic-info.png" alt="标的信息">
|
<img src="@/assets/enterpriseLibrary/basic-info.png" alt="标的信息">
|
||||||
|
|
@ -171,7 +171,8 @@ export default {
|
||||||
},
|
},
|
||||||
rules: {},
|
rules: {},
|
||||||
dialogVisible:false,
|
dialogVisible:false,
|
||||||
fileData:{}
|
fileData:{},
|
||||||
|
radioKey: 'bidId',
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,16 @@
|
||||||
<template slot="tableActions">
|
<template slot="tableActions">
|
||||||
<el-button @click="handleAdd" v-hasPermi="['analysis:analysis:add']" class="add-btn"><i
|
<el-button @click="handleAdd" v-hasPermi="['analysis:analysis:add']" class="add-btn"><i
|
||||||
class="el-icon-plus"></i> 新建项目</el-button>
|
class="el-icon-plus"></i> 新建项目</el-button>
|
||||||
<el-button @click="handleOnlyOffice">预览文档</el-button>
|
<!-- <el-button @click="handleOnlyOffice">预览文档</el-button>
|
||||||
<el-button @click="handleDocumentSearch">文档搜索功能</el-button>
|
<el-button @click="handleDocumentSearch">文档搜索功能</el-button>
|
||||||
<el-button @click="handleDocumentSearchWord">Word文档搜索功能</el-button>
|
<el-button @click="handleDocumentSearchWord">Word文档搜索功能</el-button>
|
||||||
<el-button @click="handleDocumentExcel">Excel文档查看</el-button>
|
<el-button @click="handleDocumentExcel">Excel文档查看</el-button>
|
||||||
<el-button @click="handleTestMQ">测试MQ</el-button>
|
<el-button @click="handleTestMQ">测试MQ</el-button> -->
|
||||||
</template>
|
</template>
|
||||||
<template slot="analysisStatus" slot-scope="{ data }">
|
<template slot="analysisStatus" slot-scope="{ data }">
|
||||||
<el-tag v-if="data.analysisStatus === 0" type="info">解析中</el-tag>
|
<el-tag v-if="data.analysisStatus === '0'" type="info">解析中</el-tag>
|
||||||
<el-tag v-else-if="data.analysisStatus === 1" type="success">解析成功</el-tag>
|
<el-tag v-else-if="data.analysisStatus === '1'" type="success">解析成功</el-tag>
|
||||||
<el-tag v-else-if="data.analysisStatus === 2" type="danger">解析失败</el-tag>
|
<el-tag v-else-if="data.analysisStatus === '2'" type="danger">解析失败</el-tag>
|
||||||
</template>
|
</template>
|
||||||
<template slot="handle" slot-scope="{ data }">
|
<template slot="handle" slot-scope="{ data }">
|
||||||
<el-button type="text" v-hasPermi="['enterpriseLibrary:analysis:detail']" class="action-btn"
|
<el-button type="text" v-hasPermi="['enterpriseLibrary:analysis:detail']" class="action-btn"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue