Forráskód Böngészése

驾驶舱组件管理功能开发

wyn 2 hónapja
szülő
commit
fa2b2c61e9

+ 35 - 0
src/api/system/cockpitComponent/index.ts

@@ -0,0 +1,35 @@
+import request from '@/config/axios'
+
+
+export interface uiComponentSaveReqVO{
+  id:number,
+  componentName:string,
+  componentCategory:string,
+  componentThumbnail?:string,
+  componentFilePath:string,
+}
+
+// 查询组件列表
+export const getUiComponentPage=async(params:PageParam)=>{
+  return await request.get({url:'/sys/ui-component/getUiComponentPage',params})
+}
+
+//获得组件详细信息
+export const selectUiComponentById=async(id:number)=>{
+  return await request.get({url:'/sys/ui-component/selectUiComponentById',params:{id:id}})
+}
+
+//创建组件
+export const insertUiComponent=async(data:uiComponentSaveReqVO)=>{
+  return  await request.post({url:'/sys/ui-component/insertUiComponent',data})
+}
+
+// 更新组件
+export const updateUiComponent=async(data:uiComponentSaveReqVO)=>{
+  return await request.put({url:'/sys/ui-component/updateUiComponent',data})
+}
+
+// 批量删除组件
+export const deleteUiComponentList=async(ids:[])=>{
+  return await request.delete({url:'/sys/ui-component/deleteUiComponentList?ids='+ids})
+}

+ 4 - 0
src/api/system/rolePage/index.ts

@@ -0,0 +1,4 @@
+import request from '@/config/axios'
+
+
+// export const

+ 80 - 0
src/router/modules/remaining.ts

@@ -117,6 +117,86 @@ const remainingRouter: AppRouteRecordRaw[] = [
       }
     ]
   },
+  // {
+  //   path:'/CockpitComponent',
+  //   component: () => import('@/views/system/cockpitComponent'),
+  //   name: 'CockpitComponent',
+  //   meta: {
+  //     hidden: true,
+  //   },
+  // },
+  // {
+  //   path:'/CockpitComponent',
+  //   component: Layout,
+  //   name: 'CockpitComponent',
+  //   meta: {
+  //     hidden: true,
+  //   },
+  // },
+
+  {
+    path: '/rolePage',
+    component: Layout,
+    name: 'rolePage',
+    meta: {
+      hidden: true,
+    },
+    children: [
+      {
+        path: 'RP/create',
+        component: () => import('@/views/system/rolePage/rolePageForm.vue'),
+        name: 'RolePage',
+        meta: {
+          title: '驾驶舱组件新增',
+          noCache: false,
+          hidden: true,
+          canTo: true,
+          icon: 'ep:view',
+          activeMenu: '/rolePage/RP/rolePageForm'
+        }
+      },
+      // {
+      //   path: 'CW/update',
+      //   component: () => import('@/views/CustomWorkflow/CW/UpdateView.vue'),
+      //   name: 'UpdateView',
+      //   meta: {
+      //     title: '自定义作业流程修改',
+      //     noCache: true,
+      //     hidden: true,
+      //     canTo: true,
+      //     icon: 'ep:view',
+      //     activeMenu: '/CustomWorkflow/CW/UpdateView'
+      //   }
+      // },
+      // {
+      //   path: 'CW/view',
+      //   component: () => import('@/views/CustomWorkflow/CW/CheckView.vue'),
+      //   name: 'CheckView',
+      //   meta: {
+      //     title: '自定义作业流程查看',
+      //     noCache: true,
+      //     hidden: true,
+      //     canTo: true,
+      //     icon: 'ep:view',
+      //     activeMenu: '/CustomWorkflow/CW/CheckView'
+      //   },
+      //
+      // },
+      // {
+      //   path: 'CW/TableStepDetail',
+      //   component: () => import('@/views/CustomWorkflow/CW/TableStepDetail.vue'),
+      //   name: 'WorkflowTableStepDetail',
+      //   meta: {
+      //     title: '步骤操作说明',
+      //     noCache: true,
+      //     hidden: true,
+      //     canTo: true,
+      //     icon: 'ep:view',
+      //     activeMenu: '/CustomWorkflow/CW/TableStepDetail'
+      //   }
+      // },
+    ]
+  },
   {
     path: '/CustomWorkflow',
     component: Layout,

+ 3 - 1
src/utils/dict.ts

@@ -311,5 +311,7 @@ export enum DICT_TYPE {
   ACTION_NOTICE_RULES = 'action_notice_rules',
   ADVANCE_NOTICE_RULES = 'advance_notice_rules',
   NOTICE_TIME_TYPE = 'notice_time_type',
-  TODO_FINISHED_QUERY_TYPE ='todo_finished_query_type'
+  TODO_FINISHED_QUERY_TYPE ='todo_finished_query_type',
+COCKPIT_COMPONENT_TYPE='cockpit_component_type'
+
 }

+ 1 - 0
src/views/Basicdata/mapconfig/index.vue

@@ -152,6 +152,7 @@ const getList = async () => {
   }
 }
 
+
 /** 搜索按钮操作 */
 const handleQuery = () => {
   queryParams.pageNo = 1

+ 133 - 0
src/views/system/cockpitComponent/componentForm.vue

@@ -0,0 +1,133 @@
+<template>
+  <Dialog v-model="dialogVisible" :title="dialogTitle" width="800">
+    <el-form
+      ref="formRef"
+      v-loading="formLoading"
+      :model="formData"
+      :rules="formRules"
+      label-width="110px"
+    >
+      <el-form-item label="组件名称" prop="componentName">
+        <el-input v-model="formData.componentName" placeholder="请输入组件名称" style="width: 300px" />
+      </el-form-item>
+      <el-form-item label="组件路径" prop="componentFilePath" >
+        <el-input v-model="formData.componentFilePath" placeholder="请输入组件路径" style="width: 300px"/>
+      </el-form-item>
+      <el-form-item label="组件类型" prop="componentCategory">
+        <el-select v-model="formData.componentCategory" style="width: 300px">
+          <el-option v-for="dict in getStrDictOptions(DICT_TYPE.COCKPIT_COMPONENT_TYPE)"
+                     :key="dict.value"
+                     :label="dict.label"
+                     :value="dict.value"
+          />
+        </el-select>
+      </el-form-item>
+
+      <el-form-item label="组件缩略图" prop="componentThumbnail">
+        <UploadImg
+          :limit="1"
+          v-model="formData.componentThumbnail"
+          :fileSize="5"
+        />
+      </el-form-item>
+
+    </el-form>
+    <template #footer>
+      <el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
+      <el-button @click="dialogVisible = false">取 消</el-button>
+    </template>
+  </Dialog>
+</template>
+
+<script setup lang="ts">
+import * as cockpitApi from '@/api/system/cockpitComponent/index'
+import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
+
+
+
+const { t } = useI18n() // 国际化
+const message = useMessage() // 消息弹窗
+
+const dialogVisible = ref(false) // 弹窗的是否展示
+const dialogTitle = ref('') // 弹窗的标题
+const formLoading = ref(false) // 表单的加载中
+const formType = ref('') // 表单的类型:create - 新增;update - 修改
+const formData = ref({
+  id: undefined,
+  componentName:'',
+  componentFilePath:'',
+  componentThumbnail:'',
+  componentCategory:''
+})
+const formRules = reactive({
+  componentName: [{ required: true, message: '组件名称不能为空', trigger: 'blur' }],
+  componentFilePath: [{ required: true, message: '组件路径不能为空', trigger: 'blur' }],
+  componentCategory: [{ required: true, message: '组件类型不能为空', trigger: 'blur' }]
+})
+const formRef = ref() // 表单 Ref
+
+
+const open=async(type:string,id?:number)=>{
+  dialogVisible.value = true
+  dialogTitle.value = t('action.' + type)
+  formType.value = type
+  resetForm()
+  // 修改时,设置数据
+  if (id) {
+    formLoading.value = true
+    try {
+      formData.value = await cockpitApi.selectUiComponentById(id)
+    } finally {
+      formLoading.value = false
+    }
+  }
+}
+defineExpose({ open }) // 提供 open 方法,用于打开弹窗
+
+/** 提交表单 */
+const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
+
+const submitForm=async()=>{
+//   校验表单
+  if(!formRef) return
+  const valid =await formRef.value.validate()
+  if(!valid) return
+//   提交请求
+  formLoading.value = true
+  try{
+    const data=formData.value
+    if(formType.value == 'create'){
+      await cockpitApi.insertUiComponent(data)
+      message.success(t('common.createSuccess'))
+    }else{
+      await cockpitApi.updateUiComponent(data)
+      message.success(t('common.updateSuccess'))
+    }
+    dialogVisible.value = false
+    // 发送操作成功的事件
+    emit('success')
+  } finally {
+    formLoading.value = false
+  }
+}
+
+
+/** 重置表单 */
+const resetForm = () => {
+  formData.value = {
+    id: undefined,
+    componentName:'',
+    componentFilePath:'',
+    componentThumbnail:'',
+    componentCategory:''
+  }
+  formRef.value?.resetFields()
+}
+
+
+
+</script>
+
+<style scoped lang="scss">
+
+</style>

+ 206 - 0
src/views/system/cockpitComponent/index.vue

@@ -0,0 +1,206 @@
+<template>
+  <ContentWrap>
+    <!-- 搜索工作栏 -->
+    <el-form
+      class="-mb-15px"
+      :model="queryParams"
+      ref="queryFormRef"
+      :inline="true"
+      label-width="68px"
+    >
+      <el-form-item label="组件名称" prop="componentName">
+        <el-input
+          v-model="queryParams.componentName"
+          placeholder="请输入组件名称"
+          clearable
+          class="!w-240px"
+          @keyup.enter="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="组件路径" prop="componentFilePath">
+        <el-input
+          v-model="queryParams.componentFilePath"
+          placeholder="请输入组件路径"
+          clearable
+          class="!w-240px"
+          @keyup.enter="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item>
+        <el-button @click="handleQuery">
+          <Icon icon="ep:search" class="mr-5px" />
+          搜索
+        </el-button>
+        <el-button @click="resetQuery">
+          <Icon icon="ep:refresh" class="mr-5px" />
+          重置
+        </el-button>
+        <el-button
+          type="primary"
+          plain
+          @click="openForm('create')"
+          v-hasPermi="['iscs:map:create']"
+        >
+          <Icon icon="ep:plus" class="mr-5px" />
+          新增
+        </el-button>
+        <el-button
+          type="danger"
+          plain
+          :disabled="multiple"
+          @click="handleDelete"
+          v-hasPermi="['iscs:map:delete']"
+        >
+          <Icon icon="ep:delete" class="mr-5px" />
+          批量删除
+        </el-button>
+      </el-form-item>
+    </el-form>
+  </ContentWrap>
+  <!-- 列表 -->
+  <ContentWrap>
+    <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
+      <el-table-column type="selection" width="55" align="center" />
+      <el-table-column label="组件编号" align="center" prop="id" />
+      <el-table-column label="组件名称" align="center" prop="componentName" />
+      <el-table-column label="组件类型" align="center" prop="componentCategory">
+        <template #default="scope">
+          <dict-tag :type="DICT_TYPE.COCKPIT_COMPONENT_TYPE" :value="scope.row.componentCategory" />
+        </template>
+      </el-table-column>
+      <el-table-column label="组件缩略图" align="left" prop="componentThumbnail" :show-overflow-tooltip="true">
+        <template #default="scope">
+          <div class="img-box" v-if="scope.row.componentThumbnail">
+            <el-image
+              style="width: 75px; height: 75px"
+              :preview-teleported="true"
+              class="images"
+              :hide-on-click-modal="true"
+              :src="scope.row.componentThumbnail"
+              :zoom-rate="1.2"
+              :preview-src-list="[scope.row.componentThumbnail]"
+              :initial-index="1"
+            />
+            <Icon icon="ep:zoom-in" class="eye-icon" />
+          </div>
+          <span v-else>-</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="组件路径" align="center" prop="componentFilePath" />
+      <el-table-column label="操作" align="center">
+        <template #default="scope">
+          <el-button
+            link
+            type="primary"
+            @click="openForm('update', scope.row.id)"
+            v-hasPermi="['iscs:map:update']"
+          >
+            编辑
+          </el-button>
+          <el-button
+            link
+            type="danger"
+            @click="handleDelete(scope.row.id)"
+            v-hasPermi="['iscs:map:delete']"
+          >
+            删除
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <!-- 分页 -->
+    <Pagination
+      :total="total"
+      v-model:page="queryParams.pageNo"
+      v-model:limit="queryParams.pageSize"
+      @pagination="getList"
+    />
+  </ContentWrap>
+
+  <!-- 表单弹窗:添加/修改 -->
+<ComponentForm ref="formRef" @success="getList"/>
+</template>
+
+<script setup lang="ts">
+import * as cockpitApi from '@/api/system/cockpitComponent/index'
+import ComponentForm from './componentForm.vue'
+import {DICT_TYPE} from "@/utils/dict";
+
+const message = useMessage() // 消息弹窗
+const { t } = useI18n() // 国际化
+const loading = ref(true) // 列表的加载中
+const total = ref(0) // 列表的总页数
+const tableList=ref([])
+const queryFormRef = ref() // 搜索的表单
+const ids = ref() // 选中的数据
+const multiple = ref(true) // 非多个禁用
+const formRef = ref()
+const queryParams = reactive({
+  pageNo: 1,
+  pageSize: 10,
+  componentName:'',
+  componentFilePath:''
+})
+
+onMounted(()=>{
+  getList()
+})
+
+// 获取组件数据
+const getList=async()=>{
+  loading.value = true
+try{
+const data=await cockpitApi.getUiComponentPage(queryParams)
+  tableList.value=data.list
+  console.log(data, tableList.value,'shuju')
+}finally {
+  loading.value = false
+}
+}
+
+
+// 搜索按钮
+const handleQuery=()=>{
+  queryParams.pageNo=1;
+  getList()
+}
+
+//重置按钮
+const resetQuery=()=>{
+  queryFormRef.value?.resetFields()
+  handleQuery()
+}
+
+// 表格数据选择
+const handleSelectionChange=(selection:any[])=>{
+  ids.value=selection.map((item)=>item.id)
+  multiple.value=!selection.length
+}
+
+
+// 新增/修改
+const openForm = (type: string, id?: number) => {
+  formRef.value?.open(type, id)
+}
+// 删除
+const handleDelete=async(id?:number)=>{
+  try{
+    await message.delConfirm()
+    // 类型守卫处理
+    const realId = id instanceof PointerEvent
+      ? ids.value
+      : id || ids.value;
+    await cockpitApi.deleteUiComponentList(realId)
+    message.success(t('common.delSuccess'))
+    await getList()
+  }catch (error) {
+    console.error('删除失败:', error)
+    message.error(t('common.delFailed'))
+  }
+}
+
+</script>
+
+<style scoped lang="scss">
+
+</style>

+ 6 - 0
src/views/system/rolePage/index.vue

@@ -0,0 +1,6 @@
+<template>
+  <div>角色页面</div>
+</template>
+<script setup lang="ts"></script>
+
+<style scoped lang="scss"></style>

+ 11 - 0
src/views/system/rolePage/rolePageForm.vue

@@ -0,0 +1,11 @@
+<script setup lang="ts">
+
+</script>
+
+<template>
+
+</template>
+
+<style scoped lang="scss">
+
+</style>