2025-11-24 14:37:40 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="function-table">
|
|
|
|
|
|
<!-- 搜索表单 -->
|
|
|
|
|
|
<el-form :model="searchForm" class="search-form">
|
|
|
|
|
|
<el-form-item label="功能名称">
|
|
|
|
|
|
<el-input
|
2025-11-25 10:34:51 +08:00
|
|
|
|
v-model="searchForm.funcKey"
|
2025-11-24 14:37:40 +08:00
|
|
|
|
placeholder="请输入功能名称"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
style="width: 200px"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="描述">
|
|
|
|
|
|
<el-input
|
2025-11-25 10:34:51 +08:00
|
|
|
|
v-model="searchForm.remark"
|
2025-11-24 14:37:40 +08:00
|
|
|
|
placeholder="请输入描述"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
style="width: 200px"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item>
|
2025-11-25 10:34:51 +08:00
|
|
|
|
<el-button type="primary" @click="getDataList()">搜索</el-button>
|
2025-11-24 14:37:40 +08:00
|
|
|
|
<el-button @click="handleReset">重置</el-button>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 表格操作栏 -->
|
|
|
|
|
|
<div class="table-actions">
|
2025-11-25 10:34:51 +08:00
|
|
|
|
<div class="title">选中左侧的车机版本后,才显示数据</div>
|
2025-11-24 14:37:40 +08:00
|
|
|
|
<el-button type="primary" @click="handleAddFunction">
|
|
|
|
|
|
<el-icon><Plus /></el-icon>
|
|
|
|
|
|
新增功能
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 功能表格 -->
|
|
|
|
|
|
<el-table :data="tableData" style="width: 100%">
|
2025-11-25 10:34:51 +08:00
|
|
|
|
<el-table-column prop="id" label="ID" />
|
|
|
|
|
|
<el-table-column prop="funcKey" label="功能名称"/>
|
|
|
|
|
|
<el-table-column prop="iconUrl" label="图片" >
|
2025-11-24 14:37:40 +08:00
|
|
|
|
<template #default="{ row }">
|
2025-11-25 10:34:51 +08:00
|
|
|
|
<el-image
|
|
|
|
|
|
v-if="row.iconUrl"
|
|
|
|
|
|
style="height: 32px"
|
|
|
|
|
|
:src="getImgUrl(row.iconUrl)"
|
|
|
|
|
|
@click="showViewer(row.iconUrl)">
|
|
|
|
|
|
</el-image>
|
2025-11-24 14:37:40 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2025-11-25 10:34:51 +08:00
|
|
|
|
<el-table-column prop="remark" label="描述" show-overflow-tooltip />
|
|
|
|
|
|
<el-table-column prop="createTime" label="创建日期" ></el-table-column>
|
|
|
|
|
|
<el-table-column label="操作" width="200">
|
2025-11-24 14:37:40 +08:00
|
|
|
|
<template #default="{ row }">
|
2025-11-25 10:34:51 +08:00
|
|
|
|
<el-button link type="primary" @click="handleUpdateFunction(row)">
|
|
|
|
|
|
编辑
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
<el-button link type="primary" @click="handleDeleteFunction(row)">
|
2025-11-24 14:37:40 +08:00
|
|
|
|
删除
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
|
2025-11-25 10:34:51 +08:00
|
|
|
|
<pagination
|
|
|
|
|
|
v-model:limit="searchForm.pageSize"
|
|
|
|
|
|
v-model:page="searchForm.pageNum"
|
|
|
|
|
|
:total="total"
|
|
|
|
|
|
@pagination="getList"
|
2025-11-25 15:40:00 +08:00
|
|
|
|
/>
|
2025-11-25 10:34:51 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 手动控制的预览组件,append-to-body 使其挂载到 body 末尾 -->
|
|
|
|
|
|
<ElImageViewer
|
|
|
|
|
|
v-if="isViewerOpen"
|
|
|
|
|
|
:url-list="[getImgUrl(currentImage)]"
|
|
|
|
|
|
@close="closeViewer"
|
|
|
|
|
|
append-to-body
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
2025-11-24 14:37:40 +08:00
|
|
|
|
<!-- 功能编辑对话框 -->
|
|
|
|
|
|
<FunctionDialog
|
|
|
|
|
|
v-model:visible="functionDialogVisible"
|
|
|
|
|
|
:title="functionDialogTitle"
|
|
|
|
|
|
:form-data="functionFormData"
|
|
|
|
|
|
@confirm="handleFunctionConfirm"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2025-11-25 10:34:51 +08:00
|
|
|
|
import { ref, reactive, watch } from 'vue'
|
|
|
|
|
|
import { ElMessage, ElMessageBox, ElImageViewer } from 'element-plus'
|
2025-11-24 14:37:40 +08:00
|
|
|
|
import { Plus } from '@element-plus/icons-vue'
|
|
|
|
|
|
import FunctionDialog from './FunctionDialog.vue'
|
2025-11-25 10:34:51 +08:00
|
|
|
|
import { addFunction, getFunction, updateFunction, deleteFunction } from '@/api/is/func/index'
|
2025-11-24 14:37:40 +08:00
|
|
|
|
|
2025-11-25 10:34:51 +08:00
|
|
|
|
const props = defineProps({
|
|
|
|
|
|
selectNode: {
|
|
|
|
|
|
type: Object,
|
|
|
|
|
|
default: () => {}
|
2025-11-24 14:37:40 +08:00
|
|
|
|
}
|
2025-11-25 10:34:51 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 表格数据
|
|
|
|
|
|
const tableData = ref([])
|
2025-11-24 14:37:40 +08:00
|
|
|
|
|
2025-11-25 10:34:51 +08:00
|
|
|
|
const total = ref(0)
|
2025-11-24 14:37:40 +08:00
|
|
|
|
// 搜索表单
|
|
|
|
|
|
const searchForm = reactive({
|
2025-11-25 10:34:51 +08:00
|
|
|
|
funcKey: '',
|
|
|
|
|
|
remark: '',
|
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
|
pageSize: 10,
|
2025-11-24 14:37:40 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 对话框相关
|
|
|
|
|
|
const functionDialogVisible = ref(false)
|
|
|
|
|
|
const functionDialogTitle = ref('')
|
|
|
|
|
|
|
|
|
|
|
|
// 表单数据
|
|
|
|
|
|
const functionFormData = reactive({
|
2025-11-25 10:34:51 +08:00
|
|
|
|
funcKey: '',
|
|
|
|
|
|
remark: '',
|
|
|
|
|
|
id: null,
|
|
|
|
|
|
iconUrl: null
|
2025-11-24 14:37:40 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 重置搜索
|
|
|
|
|
|
function handleReset() {
|
2025-11-25 10:34:51 +08:00
|
|
|
|
searchForm.funcKey = ''
|
|
|
|
|
|
searchForm.remark = ''
|
|
|
|
|
|
searchForm.pageSize = 10
|
|
|
|
|
|
searchForm.pageNum = 1
|
|
|
|
|
|
getDataList()
|
2025-11-24 14:37:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-25 10:34:51 +08:00
|
|
|
|
const isAdd = ref(true)
|
|
|
|
|
|
|
2025-11-24 14:37:40 +08:00
|
|
|
|
// 新增功能
|
|
|
|
|
|
function handleAddFunction() {
|
2025-11-25 10:34:51 +08:00
|
|
|
|
if (props.selectNode?.type !== 'version') {
|
|
|
|
|
|
ElMessage.warning('请先选择车机版本')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
isAdd.value = true
|
2025-11-24 14:37:40 +08:00
|
|
|
|
functionDialogTitle.value = '新增功能'
|
2025-11-25 10:34:51 +08:00
|
|
|
|
functionFormData.funcKey = ''
|
|
|
|
|
|
functionFormData.remark = ''
|
|
|
|
|
|
functionFormData.iconUrl = null
|
|
|
|
|
|
functionFormData.id = null
|
2025-11-24 14:37:40 +08:00
|
|
|
|
functionDialogVisible.value = true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 确认功能操作
|
2025-11-25 10:34:51 +08:00
|
|
|
|
async function handleFunctionConfirm(valid, data) {
|
2025-11-24 14:37:40 +08:00
|
|
|
|
if (valid) {
|
|
|
|
|
|
const newFunction = {
|
2025-11-25 10:34:51 +08:00
|
|
|
|
...data,
|
|
|
|
|
|
vehicleConfigId: props.selectNode.id
|
|
|
|
|
|
}
|
|
|
|
|
|
let res
|
|
|
|
|
|
if (isAdd.value) {
|
|
|
|
|
|
res = await addFunction(newFunction)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
res = await updateFunction(newFunction)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
functionDialogVisible.value = false
|
|
|
|
|
|
getDataList()
|
|
|
|
|
|
ElMessage.success(res.msg)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
ElMessage.error(res.msg)
|
2025-11-24 14:37:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 删除功能
|
|
|
|
|
|
function handleDeleteFunction(row) {
|
|
|
|
|
|
ElMessageBox.confirm(
|
2025-11-25 10:34:51 +08:00
|
|
|
|
`确定要删除功能"${row.funcKey}"吗?`,
|
2025-11-24 14:37:40 +08:00
|
|
|
|
'警告',
|
|
|
|
|
|
{
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}
|
2025-11-25 10:34:51 +08:00
|
|
|
|
).then(async () => {
|
|
|
|
|
|
const res = await deleteFunction(row.id)
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
getDataList()
|
|
|
|
|
|
ElMessage.success(res.msg)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
ElMessage.error(res.msg)
|
2025-11-24 14:37:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
|
// 用户取消删除
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-25 10:34:51 +08:00
|
|
|
|
const getDataList = async () => {
|
|
|
|
|
|
if (props.selectNode?.type !== 'version') {
|
|
|
|
|
|
ElMessage.warning('请先选择车机版本')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
const res = await getFunction({
|
|
|
|
|
|
...searchForm,
|
|
|
|
|
|
vehicleConfigId: props.selectNode.id
|
|
|
|
|
|
})
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
tableData.value = res.rows
|
|
|
|
|
|
total.value = res.total
|
|
|
|
|
|
}
|
2025-11-24 14:37:40 +08:00
|
|
|
|
}
|
2025-11-25 10:34:51 +08:00
|
|
|
|
|
|
|
|
|
|
const getImgUrl = (url) => {
|
|
|
|
|
|
return import.meta.env.VITE_API_URL + url
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const isViewerOpen = ref(false);
|
|
|
|
|
|
const currentImage = ref('');
|
|
|
|
|
|
|
|
|
|
|
|
const showViewer = (url) => {
|
|
|
|
|
|
currentImage.value = url;
|
|
|
|
|
|
isViewerOpen.value = true;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const closeViewer = () => {
|
|
|
|
|
|
isViewerOpen.value = false;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleUpdateFunction = (row) => {
|
|
|
|
|
|
functionDialogTitle.value = '编辑功能'
|
|
|
|
|
|
isAdd.value = false
|
|
|
|
|
|
functionFormData.funcKey = row.funcKey
|
|
|
|
|
|
functionFormData.remark = row.remark
|
|
|
|
|
|
functionFormData.id = row.id
|
|
|
|
|
|
functionFormData.iconUrl = row.iconUrl || null
|
|
|
|
|
|
functionDialogVisible.value = true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
watch(() => props.selectNode,
|
|
|
|
|
|
(newVal) => {
|
|
|
|
|
|
if (newVal && newVal.type === 'version') {
|
|
|
|
|
|
getDataList()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
tableData.value = []
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
2025-11-24 14:37:40 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
2025-11-25 10:34:51 +08:00
|
|
|
|
<style lang="scss" scoped>
|
2025-11-24 14:37:40 +08:00
|
|
|
|
.function-table {
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.search-form {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
gap: 16px;
|
|
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.table-actions {
|
|
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
|
display: flex;
|
2025-11-25 10:34:51 +08:00
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
align-items: end;
|
|
|
|
|
|
|
|
|
|
|
|
.title {
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
color: #999;
|
|
|
|
|
|
}
|
2025-11-24 14:37:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
</style>
|