riku
2024-09-02 02349238af964e19a46da93e20466a48d755a453
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<template>
  <el-button
    type="primary"
    icon="Memo"
    class="el-button-custom p-events-auto"
    @click="dialogVisible = !dialogVisible"
  >
    设备管理
  </el-button>
  <CardDialog v-model="dialogVisible" title="走航设备管理">
    <el-row class="mission-table">
      <el-col :span="20">
        <el-table
          :data="deviceStore.deviceList"
          table-layout="fixed"
          size="small"
          :show-overflow-tooltip="true"
          border
          height="64vh"
          row-class-name="t-row"
          cell-class-name="t-cell"
          header-row-class-name="t-header-row"
          header-cell-class-name="t-header-cell"
        >
          <el-table-column
            type="index"
            label="序号"
            align="center"
            width="50"
          />
          <el-table-column prop="deviceType" label="设备类型" align="center" />
          <el-table-column prop="deviceCode" label="设备编号" align="center" />
          <el-table-column
            prop="createTime"
            label="创建时间"
            align="center"
            :formatter="timeFormatter"
          />
          <el-table-column label="管理" width="140" align="center">
            <template #default="{ row }">
              <el-button
                type="primary"
                size="small"
                class="el-button-custom"
                @click="deleteDevice(row)"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </el-col>
      <el-col :span="4" class="flex-col">
        <div>
          <!-- todo 设备创建 -->
        </div>
      </el-col>
    </el-row>
  </CardDialog>
  <MessageBox
    v-model="msgBoxVisible"
    :on-confirm="onConfirm"
    title="删除走航任务"
    msg="确认是否删除该走航任务"
    confirmText="删除"
  ></MessageBox>
</template>
<script>
import moment from 'moment';
import deviceApi from '@/api/deviceApi';
import { mapStores } from 'pinia';
import { useDeviceStore } from '@/stores/device';
import { useFetchData } from '@/composables/fetchData';
 
export default {
  setup() {
    const { loading, fetchData } = useFetchData();
    return { loading, fetchData };
  },
  props: {},
  data() {
    return {
      dialogVisible: false,
      msgBoxVisible: false,
      onConfirm: undefined
    };
  },
  computed: {
    ...mapStores(useDeviceStore)
  },
  methods: {
    deleteDevice(row) {
      this.onConfirm = () => {
        this.deviceStore.deleteDevice(row.deviceCode);
      };
      this.msgBoxVisible = true;
    },
    timeFormatter(row, col, cellValue, index) {
      return moment(cellValue).format('YYYY-MM-DD HH:mm:ss');
    }
  }
};
</script>