@@ -1,14 +0,0 @@ | |||
# 资源公共路径,需要以 /开头和结尾 | |||
VITE_PUBLIC_PATH = '/' | |||
# 是否启用MOCK | |||
VITE_APP_USE_MOCK = false | |||
# proxy | |||
VITE_PROXY = [["/api-local","http://127.0.0.1:8002"],["/api-mock","http://127.0.0.1:8003"]] | |||
# base api | |||
VITE_APP_GLOB_BASE_API = '/api-local' | |||
# mock base api | |||
VITE_APP_GLOB_BASE_API_MOCK = '/api-mock' |
@@ -1,40 +0,0 @@ | |||
import { defineStore } from 'pinia' | |||
import { getEquipment } from '@/api/equipment' | |||
export const useTaskStore = defineStore({ | |||
id: 'taskStore', | |||
state: async () => ({ | |||
taskState: [ | |||
{ | |||
label: '任务待分配', | |||
value: 5 | |||
}, | |||
{ | |||
label: '任务已分配', | |||
value: 10 | |||
}, | |||
{ | |||
label: '飞手已接单', | |||
value: 15 | |||
}, | |||
{ | |||
label: '任务飞行中', | |||
value: 20 | |||
}, | |||
{ | |||
label: '任务已完成', | |||
value: 25 | |||
} | |||
], | |||
equipmentList: await getEquipment() | |||
}), | |||
getters: { | |||
getTaskState() { | |||
return this.taskState; | |||
}, | |||
getEquipmentState() { | |||
console.log(this.equipmentList); | |||
} | |||
} | |||
}) |
@@ -54,3 +54,29 @@ export const POWER_TYPE = [ | |||
{ label: '油动', value: 2 }, | |||
{ label: '混合', value: 3 } | |||
] | |||
/** | |||
* 状态 | |||
*/ | |||
export const TASK_STATUS = [ | |||
{ | |||
label: '任务待分配', | |||
value: 5 | |||
}, | |||
{ | |||
label: '任务已分配', | |||
value: 10 | |||
}, | |||
{ | |||
label: '飞手已接单', | |||
value: 15 | |||
}, | |||
{ | |||
label: '任务飞行中', | |||
value: 20 | |||
}, | |||
{ | |||
label: '任务已完成', | |||
value: 25 | |||
} | |||
] |
@@ -1,67 +0,0 @@ | |||
import { router } from '@/router' | |||
import { getToken, removeToken } from '@/utils/token' | |||
import { isWithoutToken } from './help' | |||
export function setupInterceptor(service) { | |||
service.interceptors.request.use( | |||
async(config) => { | |||
// 防止缓存,给get请求加上时间戳 | |||
if (config.method === 'get') { | |||
config.params = { ...config.params, t: new Date().getTime() } | |||
} | |||
// 处理不需要token的请求 | |||
if (isWithoutToken(config)) { | |||
return config | |||
} | |||
// const token = getToken() | |||
const token = 'token' | |||
if (token) { | |||
config.headers.Authorization = token | |||
return config | |||
} | |||
/** | |||
* * 未登录或者token过期的情况下 | |||
* * 跳转登录页重新登录,携带当前路由及参数,登录成功会回到原来的页面 | |||
*/ | |||
const { currentRoute } = router | |||
router.replace({ | |||
path: '/login', | |||
query: { ...currentRoute.query, redirect: currentRoute.path } | |||
}) | |||
return Promise.reject({ code: '-1', message: '未登录' }) | |||
}, | |||
(error) => Promise.reject(error) | |||
) | |||
service.interceptors.response.use( | |||
(response) => { | |||
const { method } = response?.config | |||
const { code } = response?.data | |||
const { currentRoute } = router | |||
switch (code) { | |||
case 0: | |||
if (method !== 'get') { | |||
$message.success(response.data.msg) | |||
} | |||
break | |||
case -1: | |||
$message.error(response.data.msg) | |||
break | |||
case 401: | |||
// 未登录(可能是token过期或者无效了) | |||
removeToken() | |||
router.replace({ | |||
path: '/login', | |||
query: { ...currentRoute.query, redirect: currentRoute.path } | |||
}) | |||
break | |||
default: | |||
break | |||
} | |||
return response?.data | |||
}, | |||
(error) => { | |||
return Promise.reject(error) | |||
} | |||
) | |||
} |
@@ -2,7 +2,7 @@ | |||
<div class="head"> | |||
<n-steps size="small" :current="current" :status="'process'"> | |||
<n-step :title="it.label" v-for="(it, i) in stepList" :key="i + it.label" /> | |||
<n-step :title="it.label" v-for="(it, i) in TASK_STATUS" :key="i + it.label" /> | |||
</n-steps> | |||
</div> | |||
@@ -34,7 +34,7 @@ | |||
<script setup name="DrawComp"> | |||
import { ref, computed, reactive, onMounted } from 'vue' | |||
import { useTaskStore } from '@/store/task' | |||
import { TASK_STATUS } from '@/utils/dictionary' | |||
const props = defineProps({ | |||
detail: Object | |||
@@ -84,8 +84,6 @@ let basicInfo = reactive([ | |||
}, | |||
]) | |||
const stepList = computed(() => useTaskStore().getTaskState) | |||
const current = ref(2) | |||
@@ -1,15 +1,18 @@ | |||
<template> | |||
<!-- 搜索 --> | |||
<headSearch :info="search" @search="handleSearch" @reset="handleSearch" /> | |||
<!-- 表格 --> | |||
<data-table ref="tableRef" :columns="columns" :row-key="(row) => row.id" :request="loadDataTable" size="large" | |||
@update:checked-row-keys="handleCheck"> | |||
<template #tableTitle> | |||
<n-button type="primary" @click="handleModal"> 新建 </n-button> | |||
</template> | |||
</data-table> | |||
<div> | |||
<n-card> | |||
<!-- 搜索 --> | |||
<headSearch :info="search" @search="handleSearch" @reset="handleSearch" /> | |||
<!-- 表格 --> | |||
<data-table ref="tableRef" :columns="columns" :row-key="(row) => row.id" :request="loadDataTable" size="large" | |||
@update:checked-row-keys="handleCheck"> | |||
<template #tableTitle> | |||
<n-button type="primary" @click="handleModal"> 新建 </n-button> | |||
</template> | |||
</data-table> | |||
</n-card> | |||
</div> | |||
<!-- 新增、编辑弹窗 --> | |||
<UserModal v-if="modalShow" v-model:visible="modalShow" :type="modalType" :data="rowData" @reload="handleSearch" /> | |||
@@ -17,7 +20,7 @@ | |||
<!-- 详情 - 抽屉 --> | |||
<n-drawer v-model:show="showDraw" :width="'calc(100vw - 210px)'" :placement="'right'" resizable> | |||
<n-drawer-content closable> | |||
<draw-comp :detail="detail"/> | |||
<draw-comp :detail="detail" /> | |||
</n-drawer-content> | |||
</n-drawer> | |||
@@ -1,7 +1,5 @@ | |||
import { ref, reactive, computed } from 'vue' | |||
import { useTaskStore } from '@/store/task' | |||
const list = computed(() => useTaskStore().getTaskState) | |||
import { TASK_STATUS } from '@/utils/dictionary' | |||
export const search = reactive({ | |||
search: [ | |||
@@ -11,7 +9,7 @@ export const search = reactive({ | |||
key: 'status', | |||
props: { | |||
placeholder: '请输入任务状态', | |||
options: list | |||
options: TASK_STATUS | |||
} | |||
}, | |||
{ |
@@ -28,34 +28,15 @@ async function getRowData(row, type) { | |||
data.showDraw = true | |||
} | |||
// 设置状态 | |||
function setStatus(row) { | |||
setUserStatus({ id: row.data.id, status: row.value }).then(res => { | |||
if (res.code === 0) { | |||
handleSearch() | |||
$message.success(res.msg) | |||
} else { | |||
$message.error(res.msg) | |||
} | |||
}).catch(e => { | |||
console.log(e) | |||
}) | |||
} | |||
/** | |||
* @description: 重置密码 | |||
* @param {Number} id 选中数据id | |||
* @description: 编辑 | |||
* @return {*} | |||
*/ | |||
function handlePasswordReset(id) { | |||
resetPassword({ id }) | |||
.then(res => { | |||
if (res.code === 0) { | |||
handleSearch() | |||
} | |||
}).catch(e => { | |||
console.log(e) | |||
}) | |||
data.rowData = row | |||
data.modalType = type | |||
data.modalShow = true | |||
} | |||
/** | |||
@@ -139,13 +120,11 @@ const data = reactive({ | |||
}, | |||
{ | |||
label: '编辑', | |||
type: 'popconfirm', | |||
type: 'button', | |||
props: { | |||
onPositiveClick: handlePasswordReset.bind(null, row.id) | |||
}, | |||
ButtonProps: { | |||
type: 'primary', | |||
text: true, | |||
type: 'primary' | |||
onPositiveClick: handlePasswordReset.bind(null, row.id) | |||
}, | |||
auth: 'basic_list' | |||
}, |