zhudie 2 лет назад
Родитель
Сommit
d319541845

+ 1 - 1
src/api/push/push.ts

@@ -5,7 +5,7 @@ export interface RobotType {
   robotName?: string;
   robotUrl?: string;
   workshopCodes?: string;
-  workshopName?: string;
+  workshopName?: string[];
   isPush?: boolean;
   tenantId?: number;
   isDelete?: boolean;

+ 5 - 40
src/views/alarm-push/PushAlarm.vue

@@ -2,7 +2,7 @@
   <div class="push-page">
     <el-card :bordered="false" class="proCard" style="position: relative">
       <BasicTable
-        :columns="getColumns(flattendWorkspaces)"
+        :columns="columns"
         :data-source="robotPushList"
         :row-key="(row) => row.id"
         :action-column="actionColumn"
@@ -34,49 +34,24 @@
       @sub-edit="editSubRobot"
     />
   </div>
-  <!-- <AddCamera class="add-popover" v-model="showAddPopover" />
-    <EditCamera class="add-popover" v-model="showEditPopover" :edit-data="editCameraData" />
-    <ShareCamera class="add-popover" v-model="addSharedPopover" :share-data="shareCameraData" />
-    <EditSharedCamera
-      class="add-popover"
-      v-model="showSharedPopover"
-      @update-unadd="updateUnaddAmount"
-    /> -->
-  <!-- </div> -->
 </template>
 
 <script setup lang="ts">
-  import { h, onBeforeMount, onBeforeUnmount, onMounted, reactive, ref } from 'vue';
+  import { h, onMounted, reactive, ref } from 'vue';
   import { BasicTable, TableActionIcons } from '@/components/Table';
   import { BasicColumn } from '@/components/Table';
-  import { getColumns } from './constant';
-  // import { columns } from './overviewColumns';
+  import { columns } from './constant';
   import { Plus } from '@element-plus/icons-vue';
   import editIcon from '@/assets/images/table/table-edit.png';
   import deleteIcon from '@/assets/images/table/table-delete.png';
-  import { deleteCameraItem } from '@/api/camera/camera-overview';
   import AddRobot from './component/AddRobot.vue';
   import { ElMessage, ElMessageBox } from 'element-plus';
   import { RobotType } from '@/api/push/push';
   import usePush from './usePush';
-  import useSceneInfos from '@/hooks/useSceneInfos';
 
   const usePushRobot = usePush();
-  const {
-    robotPushList,
-    total,
-    page,
-    size,
-    loading,
-    robotSearch,
-    getRobotList,
-    robotAdd,
-    robotDel,
-    robotEdit,
-  } = usePushRobot;
-
-  const sceneInfos = useSceneInfos();
-  const { flattendWorkspaces, getScenesTree } = sceneInfos;
+  const { robotPushList, total, page, size, loading, getRobotList, robotAdd, robotDel, robotEdit } =
+    usePushRobot;
 
   onMounted(() => {
     getRobotList();
@@ -170,18 +145,8 @@
   //编辑
   const handleEdit = (row) => {
     robotList.value = row;
-    console.log('row', row);
-
     showDrawer.value = true;
-    // showEditPopover.value = true;
-    // editCameraData.value = row;
   };
-
-  onBeforeMount(() => {
-    getScenesTree({ level: 3, valueKey: 'code', labelKey: 'name', disabled: true });
-  });
-
-  onBeforeUnmount(() => {});
 </script>
 
 <style scoped>

+ 16 - 18
src/views/alarm-push/component/AddRobot.vue

@@ -51,9 +51,6 @@
       <div style="position: absolute; left: 108px; bottom: 67px">
         <el-button @click="resetDrawer">重置</el-button>
         <el-button type="primary" @click="subDrawer"> 提交 </el-button>
-        <!-- <el-button type="primary" v-if="props.comEdit" @click="editedSub(ruleFormRef)">
-          提交
-        </el-button> -->
       </div>
     </el-drawer></div
   >
@@ -65,14 +62,9 @@
   import { RobotType } from '@/api/push/push';
   import useSceneInfos from '@/hooks/useSceneInfos';
   import { cloneDeep } from 'lodash-es';
-  // import usePush from '../usePush';
-
-  // const usePushRobot = usePush();
-  // const { robotPushList, total, page, size, robotSearch, robotAdd, robotDel, robotEdit } =
-  //   usePushRobot;
 
   const sceneInfos = useSceneInfos();
-  const { scenesTree, flattendWorkspaces, getScenesTree } = sceneInfos;
+  const { scenesTree, flattenedWorkshops, getScenesTree } = sceneInfos;
 
   const props = defineProps<{
     robotList: RobotType | null;
@@ -94,7 +86,7 @@
     robotName: '',
     robotUrl: '',
     workshopCodes: '',
-    workshopName: '',
+    workshopName: [],
     isPush: true,
   });
 
@@ -109,7 +101,7 @@
     ruleForm.value.robotName = '';
     ruleForm.value.robotUrl = '';
     ruleForm.value.workshopCodes = '';
-    ruleForm.value.workshopName = '';
+    ruleForm.value.workshopName = [];
     ruleForm.value.isPush = true;
   };
   //提交
@@ -123,7 +115,6 @@
         isPush: ruleForm.value.isPush,
       };
       emits('subEdit', data);
-      //   robotEdit(data);
     } else {
       const data = {
         robotName: ruleForm.value.robotName,
@@ -136,18 +127,25 @@
   };
 
   const handleTreeSelect = (code: string) => {
-    ruleForm.value.workshopCodes = flattendWorkspaces.value.find((item) => item.code === code).id;
+    console.log('code', code);
+    console.log('flattendWorkspaces', flattenedWorkshops.value);
+    console.log('name', ruleForm.value.workshopName);
+
+    ruleForm.value.workshopCodes = JSON.stringify(
+      flattenedWorkshops.value
+        .filter((item) => code.includes(item.code))
+        .map(({ code, name }) => ({ code, name })),
+    );
   };
 
   onBeforeMount(() => {
     getScenesTree({ level: 2, valueKey: 'code', labelKey: 'name', disabled: true });
     if (props.robotList) {
       ruleForm.value = cloneDeep(props.robotList);
-
-      // ruleForm.value.workshopName = flattendWorkspaces.value.find(
-      //   (item) => item.id === ruleForm.value.workshopCodes,
-      // ).name;
-      // console.log('ruleForm.value', ruleForm.value);
+      console.log('props.robotList', props.robotList);
+      ruleForm.value.workshopName = JSON.parse(ruleForm.value.workshopCodes!).map(
+        (item) => item.code,
+      );
     }
   });
 </script>

+ 32 - 41
src/views/alarm-push/constant.ts

@@ -1,49 +1,40 @@
 import { BasicColumn } from '@/components/Table';
 import { h } from 'vue';
 
-export const getColumns = (flattendWorkspaces): BasicColumn[] => {
-  return [
-    {
-      label: '序号',
-      minWidth: 60,
-      type: 'index',
-      fixed: 'left',
-    },
-    {
-      label: '机器人名称',
-      prop: 'robotName',
-      minWidth: 100,
-    },
-    {
-      label: '机器人地址',
-      prop: 'robotUrl',
-      minWidth: 140,
-    },
-    {
-      label: '场景',
-      prop: 'workshopCodes',
-      minWidth: 120,
-      render(record) {
-        return h(
-          'span',
-          {},
-          {
-            default: () => {
-              return flattendWorkspaces?.find(
-                (item) => item.id === Number(record.row.workshopCodes),
-              )?.name;
-            },
+export const columns: BasicColumn[] = [
+  {
+    label: '序号',
+    minWidth: 60,
+    type: 'index',
+    fixed: 'left',
+  },
+  {
+    label: '机器人名称',
+    prop: 'robotName',
+    minWidth: 100,
+  },
+  {
+    label: '机器人地址',
+    prop: 'robotUrl',
+    minWidth: 140,
+  },
+  {
+    label: '场景',
+    prop: 'workshopCodes',
+    minWidth: 120,
+    render(record) {
+      return h(
+        'span',
+        {},
+        {
+          default: () => {
+            const toParse = JSON.parse(record.row.workshopCodes);
+            return toParse.map((item) => item.name).join(' , ');
           },
-        );
-      },
+        },
+      );
     },
-  ];
-};
-
-export const robotDataList = [
-  { robotName: 123, robotUrl: 'https//sss', workshopCodes: 'a大厅' },
-  { robotName: 123, robotUrl: 'https//sss1', workshopCodes: 'b大厅' },
-  { robotName: 123, robotUrl: 'https//sss12', workshopCodes: 'c大厅' },
+  },
 ];
 
 export enum ENABLED {