zjk
2026-06-09 3c770a6deeada7ddfea03120285c8a9ba2ed8720
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<script setup lang="tsx">
import type { DataTableColumns } from 'naive-ui'
import { NButton, NSpace, NTooltip } from 'naive-ui'
import { computed, onActivated, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import OperationLogModal from '@/components/custom/OperationLogModal.vue'
import Pagination from '@/components/common/Pagination.vue'
import SearchPanel from '@/components/custom/SearchPanel.vue'
import { useBoolean } from '@/hooks'
import { deleteTestPlanById, fetchTestPlanPageList } from '@/service/api/copyText'
 
const router = useRouter()
const dialog = useDialog()
const message = useMessage()
 
const { bool: loading, setTrue: startLoading, setFalse: endLoading } = useBoolean(false)
 
interface TestPlanRow {
  id: number
  planName: string
  pointNum: number
  vehicleNum: number
  orderNum: number
}
 
 
const initialModel = {
  planName: '',
}
const model = ref({ ...initialModel })
 
const pageParams = ref({
  pageNum: 1,
  pageSize: 10,
})
const count = ref(0)
const listData = ref<TestPlanRow[]>([])
 
const tableScrollX = 1000
 
function handleResetSearch() {
  model.value = { ...initialModel }
  pageParams.value.pageNum = 1
  getList()
}
 
async function getList() {
  startLoading()
  try {
    const planName = model.value.planName?.trim()
    const res = await fetchTestPlanPageList({
      ...pageParams.value,
      planName: planName || undefined,
    })
    if (res.code === 200) {
      listData.value = res.data?.records || []
      count.value = res.data?.total || 0
      return
    }
    listData.value = []
    count.value = 0
  }
  finally {
    endLoading()
  }
}
 
function changePage(page: number, size: number) {
  pageParams.value.pageNum = page
  pageParams.value.pageSize = size
  getList()
}
 
function handleSearch() {
  pageParams.value.pageNum = 1
  getList()
}
 
function handleAdd() {
  router.push({ name: 'testPlanAdd' })
}
 
const showOperationLogModal = ref(false)
 
function handleOpenOperationLog() {
  showOperationLogModal.value = true
}
 
function handleDetail(row: TestPlanRow) {
  router.push({ name: 'testPlanAdd', query: { id: String(row.id), mode: 'detail' } })
}
 
function handleEdit(row: TestPlanRow) {
  router.push({ name: 'testPlanAdd', query: { id: String(row.id), mode: 'edit' } })
}
 
function handleDelete(row: TestPlanRow) {
  dialog.create({
    title: '确认删除该测试计划吗?',
    content: '',
    positiveText: '确定',
    negativeText: '取消',
    maskClosable: false,
    autoFocus: false,
    onPositiveClick: async () => {
      const res = await deleteTestPlanById(row.id)
      if (res.code === 200) {
        message.success('删除成功')
        getList()
      }
    },
  })
}
 
const columns = computed<DataTableColumns<TestPlanRow>>(() => [
  {
    title: '计划ID',
    key: 'id',
    width: 120,
    align: 'left',
    resizable: true,
    ellipsis: true,
  },
  {
    title: '计划名称',
    key: 'planName',
    width: 260,
    align: 'left',
    resizable: true,
    ellipsis: true,
    render(row) {
      return (
        <NTooltip trigger="hover">
          {{
            trigger: () => (
              <div
                class="cursor-pointer text-ellipsis whitespace-nowrap w-full overflow-hidden text-[#0068FF]"
                onClick={() => handleDetail(row)}
              >
                {row.planName}
              </div>
            ),
            default: () => row.planName,
          }}
        </NTooltip>
      )
    },
  },
  {
    title: '关联点位数',
    key: 'pointNum',
    width: 140,
    align: 'left',
    resizable: true,
    ellipsis: true,
  },
  {
    title: '关联订单数',
    key: 'orderNum',
    width: 140,
    align: 'left',
    resizable: true,
    ellipsis: true,
  },
  {
    title: '关联车辆数',
    key: 'vehicleNum',
    width: 140,
    align: 'left',
    resizable: true,
    ellipsis: true,
  },
  {
    title: '操作',
    key: 'actions',
    width: 200,
    align: 'left',
    fixed: 'right',
    render: (row: TestPlanRow) => {
      return (
        <NSpace justify="start">
          <NButton v-permission="112" text type="primary" onClick={() => handleDetail(row)}>
            详情
          </NButton>
          <NButton v-permission="113" text type="primary" onClick={() => handleEdit(row)}>
            编辑
          </NButton>
          <NButton v-permission="114" text type="primary" onClick={() => handleDelete(row)}>
            删除
          </NButton>
        </NSpace>
      )
    },
  },
])
 
const filterItems = computed(() => [
  {
    label: '计划名称',
    path: 'planName',
    render: () => <n-input v-model:value={model.value.planName} placeholder="请输入" clearable />,
  },
])
 
onMounted(() => {
  getList()
})
 
onActivated(() => {
  if (window.sessionStorage.getItem('testPlanListNeedRefresh') === '1') {
    window.sessionStorage.removeItem('testPlanListNeedRefresh')
    getList()
  }
})
</script>
 
<template>
  <div class="roboTaxi">
    <div class="roboTaxi-form-card mb-12px">
      <n-form :model="model" label-placement="left" inline :show-feedback="false">
        <SearchPanel>
          <n-gi v-for="item in filterItems" :key="item.path">
            <n-form-item :label="item.label" :path="item.path">
              <component :is="item.render" />
            </n-form-item>
          </n-gi>
          <template #action>
            <NButton @click="handleResetSearch">
              {{ $t('common.reset') }}
            </NButton>
            <NButton type="primary" @click="handleSearch">
              {{ $t('common.search') }}
            </NButton>
          </template>
        </SearchPanel>
      </n-form>
    </div>
 
    <n-card
      class="flex-1 robotaxi-table-card"
      content-style="display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0;"
    >
      <template #header>
        <n-flex justify="space-between">
          <NButton v-permission="115" @click="handleOpenOperationLog">
            操作日志
          </NButton>
          <NButton v-permission="111" type="primary" secondary @click="handleAdd">
            添加测试计划
          </NButton>
        </n-flex>
      </template>
 
      <div class="flex-1 flex flex-col h-full" style="min-width: 0; overflow: hidden">
        <n-data-table
          class="flex-1"
          :columns="columns"
          :data="listData"
          :loading="loading"
          flex-height
          :bordered="false"
          :scroll-x="tableScrollX"
          :header-height="18"
          :row-height="18"
        >
          <template #empty>
            <div class="flex-center">
              <img src="/src/assets/element-img/no-data.png" style="width:123px;height:125px">
            </div>
          </template>
        </n-data-table>
        <Pagination
          :count="count"
          :page="pageParams.pageNum"
          :page-size="pageParams.pageSize"
          class="robotaxi-pagination mt-12px"
          @change="changePage"
        />
      </div>
    </n-card>
 
    <OperationLogModal v-model:show="showOperationLogModal" />
  </div>
</template>
 
<style scoped></style>