|
@@ -279,11 +279,16 @@ const openInsertDialog = (rows, fromId, aId) => {
|
|
|
}
|
|
|
|
|
|
//设置某一行的样式
|
|
|
+// 修正后的样式函数
|
|
|
const tableRowStyle = ({ row }) => {
|
|
|
- // 只根据inType属性判断样式,确保排序后依然有效
|
|
|
- if (row?.inType === 1) {
|
|
|
- return 'color: orange;'
|
|
|
+ // 返回样式对象而不是 CSS 字符串
|
|
|
+ if (row && row.inType === 1) {
|
|
|
+ return {
|
|
|
+ color: 'orange',
|
|
|
+ backgroundColor: '#fff7e6',
|
|
|
+ }
|
|
|
}
|
|
|
+ return {}
|
|
|
}
|
|
|
|
|
|
// 加载表格数据
|
|
@@ -388,22 +393,30 @@ const resetForm = () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 拖动完成 - 关键修复:确保拖动后保留inType属性
|
|
|
+
|
|
|
const sortTableRowDrop = (rows) => {
|
|
|
- // 拖动后,使用原数据中的inType属性更新新的排序结果
|
|
|
+ // 创建原数据的映射,保留所有属性
|
|
|
+ const originalDataMap = new Map()
|
|
|
+ tableData.value.forEach(row => {
|
|
|
+ originalDataMap.set(row.id, { ...row })
|
|
|
+ })
|
|
|
+
|
|
|
+ // 使用原数据中的完整信息更新新的排序结果
|
|
|
const updatedRows = rows.map(row => {
|
|
|
- // 查找原数据中对应的行,获取inType属性
|
|
|
- const originalRow = tableData.value.find(item => item.id === row.id)
|
|
|
- return {
|
|
|
- ...row,
|
|
|
- // 保留原有的inType属性
|
|
|
- inType: originalRow ? originalRow.inType : row.inType,
|
|
|
+ const originalRow = originalDataMap.get(row.id)
|
|
|
+ if (originalRow) {
|
|
|
+ // 保留所有原数据属性,包括 inType
|
|
|
+ return {
|
|
|
+ ...originalRow,
|
|
|
+ // 保留拖动后可能更新的其他属性
|
|
|
+ ...row,
|
|
|
+ }
|
|
|
}
|
|
|
+ return row
|
|
|
})
|
|
|
|
|
|
tableData.value = updatedRows
|
|
|
}
|
|
|
-
|
|
|
// 暴露方法供外部调用
|
|
|
defineExpose({
|
|
|
openInsertDialog,
|