17 changed files with 396 additions and 52 deletions
@ -1 +1 @@ |
|||||
API_URL=http://localhost:4001 |
VITE_API_URL=http://localhost:4001 |
||||
|
@ -0,0 +1,14 @@ |
|||||
|
import http from 'utils/axios'; |
||||
|
|
||||
|
const apiUrl = import.meta.env.VITE_API_URL; |
||||
|
const users = `${apiUrl}/gateway/tall3/v3.0/users`; |
||||
|
const corrosion = `${apiUrl}/gateway/corrosion`; |
||||
|
|
||||
|
// 根据userId 获取token
|
||||
|
export const getToken = userId => http.get(`${users}/userId`, { params: { userId } }); |
||||
|
|
||||
|
// 获取设备列表
|
||||
|
export const getDevices = () => http.get(`${corrosion}/devices`); |
||||
|
|
||||
|
// 获取设备列表 完整信息
|
||||
|
export const getDevicesAll = () => http.get(`${corrosion}/devices/all`); |
@ -0,0 +1,19 @@ |
|||||
|
<template> |
||||
|
<el-dialog v-model="show" title="编辑设备信息" width="80%" :before-close="handleClose"> |
||||
|
<span>This is a message</span> |
||||
|
<template #footer> |
||||
|
<span class="dialog-footer"> |
||||
|
<el-button @click="$emit('toggle-mdoal')">Cancel</el-button> |
||||
|
<el-button type="primary" @click="$emit('toggle-mdoal')">Confirm</el-button> |
||||
|
</span> |
||||
|
</template> |
||||
|
</el-dialog> |
||||
|
</template> |
||||
|
|
||||
|
<script setup> |
||||
|
import { defineProps, defineEmits } from 'vue'; |
||||
|
|
||||
|
defineProps({ show: Boolean }); |
||||
|
|
||||
|
defineEmits(['toggle-mdoal']); |
||||
|
</script> |
@ -0,0 +1,31 @@ |
|||||
|
<template> |
||||
|
<el-form :inline="true" :model="searchDevice" ref="searchDeviceForm"> |
||||
|
<el-form-item label="选择站点"> |
||||
|
<el-select v-model="searchDevice.device" placeholder="请选择站点"> |
||||
|
<el-option label="全部" value=""></el-option> |
||||
|
<el-option :label="item.address" :value="item.deviceId" v-for="item in devices" :key="item.deviceId"></el-option> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
<el-form-item> |
||||
|
<el-button type="primary" @click="onSubmit">查询</el-button> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
</template> |
||||
|
|
||||
|
<script setup> |
||||
|
import { reactive, ref, computed } from 'vue'; |
||||
|
import { useStore } from 'vuex'; |
||||
|
|
||||
|
const searchDevice = reactive({ device: '' }); |
||||
|
|
||||
|
const searchDeviceForm = ref(null); // form |
||||
|
|
||||
|
const store = useStore(); |
||||
|
const devices = computed(() => store.state.device.devices); |
||||
|
|
||||
|
const onSubmit = () => { |
||||
|
searchDeviceForm.value.validate(valid => { |
||||
|
console.log(valid, { ...searchDevice }); |
||||
|
}); |
||||
|
}; |
||||
|
</script> |
@ -1,9 +1,11 @@ |
|||||
import 'virtual:windi.css'; |
import 'virtual:windi.css'; |
||||
|
import 'element-plus/dist/index.css'; |
||||
|
|
||||
import { createApp } from 'vue'; |
import { createApp } from 'vue'; |
||||
import App from './App.vue'; |
import App from './App.vue'; |
||||
import router from './routers/index'; |
import router from './routers/index'; |
||||
|
import store from './store/index'; |
||||
|
|
||||
const app = createApp(App); |
const app = createApp(App); |
||||
|
|
||||
app.use(router).mount('#app'); |
app.use(router).use(store).mount('#app'); |
||||
|
@ -0,0 +1,58 @@ |
|||||
|
import { getDevices, getDevicesAll } from 'apis/index'; |
||||
|
|
||||
|
const user = { |
||||
|
namespaced: true, |
||||
|
|
||||
|
state: { |
||||
|
devices: [], |
||||
|
devicesAll: null, |
||||
|
}, |
||||
|
|
||||
|
getters: {}, |
||||
|
|
||||
|
mutations: { |
||||
|
/** |
||||
|
* 设置devices数据 |
||||
|
* @param {*} state |
||||
|
* @param {array} devices |
||||
|
*/ |
||||
|
setDevices(state, devices) { |
||||
|
state.devices = devices; |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 设置devicesAll的数据 |
||||
|
* @param {*} state |
||||
|
* @param {*} devices |
||||
|
*/ |
||||
|
setDevicesAll(state, devices) { |
||||
|
state.devicesAll = devices; |
||||
|
}, |
||||
|
}, |
||||
|
|
||||
|
actions: { |
||||
|
// 获取设备列表(站点列表)
|
||||
|
async getDevices({ commit }) { |
||||
|
try { |
||||
|
const data = await getDevices(); |
||||
|
commit('setDevices', data || []); |
||||
|
return data; |
||||
|
} catch (error) { |
||||
|
throw new Error(error); |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
// 获取设备列表(站点列表) 完整信息
|
||||
|
async getDevicesAll({ commit }) { |
||||
|
try { |
||||
|
const data = await getDevicesAll(); |
||||
|
commit('setDevicesAll', data || null); |
||||
|
return data; |
||||
|
} catch (error) { |
||||
|
throw new Error(error); |
||||
|
} |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
|
||||
|
export default user; |
@ -0,0 +1,11 @@ |
|||||
|
import { createStore } from 'vuex'; |
||||
|
import device from './device'; |
||||
|
import user from './user'; |
||||
|
|
||||
|
export default createStore({ |
||||
|
modules: { user, device }, |
||||
|
state: {}, |
||||
|
getters: {}, |
||||
|
mutations: {}, |
||||
|
actions: {}, |
||||
|
}); |
@ -0,0 +1,53 @@ |
|||||
|
import { getToken } from 'apis/index'; |
||||
|
|
||||
|
export default { |
||||
|
namespaced: true, |
||||
|
|
||||
|
state: { user: null }, |
||||
|
|
||||
|
getters: { |
||||
|
token({ user }) { |
||||
|
if (!user) return null; |
||||
|
return user.token; |
||||
|
}, |
||||
|
userId({ user }) { |
||||
|
if (!user) return null; |
||||
|
return user.userId; |
||||
|
}, |
||||
|
}, |
||||
|
|
||||
|
mutations: { |
||||
|
/** |
||||
|
* 设置state.user |
||||
|
* @param {*} state |
||||
|
* @param {object|null} user 用户信息 |
||||
|
*/ |
||||
|
setUser(state, user) { |
||||
|
state.user = user; |
||||
|
if (user) { |
||||
|
localStorage.setItem('token', user.token); |
||||
|
localStorage.setItem('user', user); |
||||
|
} else { |
||||
|
localStorage.removeItem('token'); |
||||
|
localStorage.removeItem('user'); |
||||
|
} |
||||
|
}, |
||||
|
}, |
||||
|
|
||||
|
actions: { |
||||
|
/** |
||||
|
* 根据userId获取token级user信息 |
||||
|
* @param {*} param0 |
||||
|
* @param {string} userId 用户id |
||||
|
*/ |
||||
|
async getTokenByUserId({ commit }, userId) { |
||||
|
try { |
||||
|
const data = await getToken(userId); |
||||
|
commit('setUser', data || null); |
||||
|
return data; |
||||
|
} catch (error) { |
||||
|
throw new Error(error); |
||||
|
} |
||||
|
}, |
||||
|
}, |
||||
|
}; |
@ -1,26 +1,117 @@ |
|||||
<template> |
<template> |
||||
<el-form ref="form" :model="form" :inline="true" label-width="120px"> |
<SearchBar /> |
||||
<el-form-item label="Activity zone"> |
|
||||
<el-select v-model="form.region" placeholder="please select your zone"> |
<template v-if="devicesAll && devicesAll.data"> |
||||
<el-option label="Zone one" value="shanghai"></el-option> |
<el-table :data="devicesAll.data" style="width: 100%" :style="{ 'max-height': contentHeight + 'px' }"> |
||||
<el-option label="Zone two" value="beijing"></el-option> |
<el-table-column type="expand"> |
||||
</el-select> |
<template #default="props"> |
||||
</el-form-item> |
<el-row :gutter="20" class="px-6 text-gray-400"> |
||||
|
<el-col :span="9">链路地址:{{ props.row.linkAddress }}</el-col> |
||||
<!-- <el-form-item label="Activity form"> |
<el-col :span="9">探头编号:{{ props.row.probNo }}</el-col> |
||||
<el-input v-model="form.desc"></el-input> |
<el-col :span="9">设备朝向:{{ props.row.deviceDirection }}</el-col> |
||||
</el-form-item> --> |
<el-col :span="9">试样:{{ props.row.simple }}</el-col> |
||||
<el-form-item> |
<el-col :span="9">安装位置:{{ props.row.installLocation }}</el-col> |
||||
<el-button type="primary" @click="onSubmit">Create</el-button> |
<el-col :span="9">sim1:{{ props.row.sim1 }}</el-col> |
||||
<el-button>Cancel</el-button> |
<el-col :span="18">与主站后台联调情况:{{ props.row.joint }}</el-col> |
||||
</el-form-item> |
<el-col :span="18">备注:{{ props.row.remark }}</el-col> |
||||
</el-form> |
</el-row> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column label="ID" prop="deviceId" width="100" /> |
||||
|
<el-table-column label="完整ID" prop="deviceFullId" width="150" /> |
||||
|
<el-table-column label="地点" prop="address" width="150" /> |
||||
|
<el-table-column label="地区" prop="area" width="120" /> |
||||
|
<el-table-column label="联系人" prop="contact" width="100" /> |
||||
|
<el-table-column label="联系电话" prop="phone" width="150" /> |
||||
|
<el-table-column label="安装时间" prop="installTime" width="200" /> |
||||
|
<el-table-column label="正式运行时间" prop="runTime" width="200" /> |
||||
|
<el-table-column fixed="right" label="操作" width="148"> |
||||
|
<template #default> |
||||
|
<el-popconfirm title="确定要删除此设备吗?" @confirm="handleDelete"> |
||||
|
<template #reference> |
||||
|
<el-button type="danger" plain size="mini">删除</el-button> |
||||
|
</template> |
||||
|
</el-popconfirm> |
||||
|
|
||||
|
<el-button type="primary" plain size="mini" @click="editting = true">编辑</el-button> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
</el-table> |
||||
|
|
||||
|
<el-pagination |
||||
|
background |
||||
|
:current-page="devicesAll.page.page" |
||||
|
:page-size="devicesAll.page.size" |
||||
|
:default-page-size="10" |
||||
|
:page-count="devicesAll.page.total" |
||||
|
class="my-3 float-right" |
||||
|
@size-change="onSizeChange" |
||||
|
@current-change="onCurrentPageChange" |
||||
|
@prev-click="onPrev" |
||||
|
@next-click="onNext" |
||||
|
></el-pagination> |
||||
|
</template> |
||||
|
|
||||
|
<!-- 编辑设备信息 --> |
||||
|
<DeviceEdit :show="editting" @toggle-mdoal="editting = false" /> |
||||
</template> |
</template> |
||||
|
|
||||
<script setup> |
<script setup> |
||||
// import { ref } from 'vue'; |
import { computed, onMounted, ref } from 'vue'; |
||||
|
import { useStore } from 'vuex'; |
||||
|
import SearchBar from 'components/search-bar.vue'; |
||||
|
import DeviceEdit from 'components/device-edit.vue'; |
||||
|
|
||||
|
let timer = null; |
||||
|
const store = useStore(); |
||||
|
const token = computed(() => store.getters['user/token']); |
||||
|
const devicesAll = computed(() => store.state.device.devicesAll); |
||||
|
let contentHeight = 600; |
||||
|
const editting = ref(false); |
||||
|
|
||||
|
// 获取设备完整信息列表 |
||||
|
const getDevicesAllData = () => { |
||||
|
if (token) { |
||||
|
store.dispatch('device/getDevicesAll'); |
||||
|
timer && clearTimeout(timer); |
||||
|
timer = null; |
||||
|
} else { |
||||
|
timer = setTimeout(() => { |
||||
|
getDevicesAllData(); |
||||
|
}); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
getDevicesAllData(); |
||||
|
|
||||
|
// 设置表格高度 |
||||
|
onMounted(() => { |
||||
|
const winHeight = document.documentElement.clientHeight; |
||||
|
contentHeight = winHeight - 150; |
||||
|
}); |
||||
|
|
||||
|
// 当前页码变化 |
||||
|
const onCurrentPageChange = e => { |
||||
|
console.log(e); |
||||
|
}; |
||||
|
|
||||
|
// 每页条数变化 |
||||
|
const onSizeChange = e => { |
||||
|
console.log(e); |
||||
|
}; |
||||
|
|
||||
|
// 下一页 |
||||
|
const onNext = e => { |
||||
|
console.log(e); |
||||
|
}; |
||||
|
|
||||
|
// 上一页 |
||||
|
const onPrev = e => { |
||||
|
console.log(e); |
||||
|
}; |
||||
|
|
||||
// const data = { |
// 删除设备 |
||||
// deviceId: '', // 设备id |
const handleDelete = () => { |
||||
// } |
console.log('delete'); |
||||
|
}; |
||||
</script> |
</script> |
||||
|
@ -1,28 +1,25 @@ |
|||||
import Components from 'unplugin-vue-components/vite' |
import Components from 'unplugin-vue-components/vite'; |
||||
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' |
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'; |
||||
import WindiCSS from 'vite-plugin-windicss'; |
import WindiCSS from 'vite-plugin-windicss'; |
||||
import { defineConfig } from 'vite' |
import { defineConfig } from 'vite'; |
||||
import path from 'path'; |
import path from 'path'; |
||||
import vue from '@vitejs/plugin-vue' |
import vue from '@vitejs/plugin-vue'; |
||||
|
|
||||
const resolve = dir => path.join(__dirname, dir); |
const resolve = dir => path.join(__dirname, dir); |
||||
|
|
||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||
export default defineConfig({ |
export default defineConfig({ |
||||
plugins: [ |
plugins: [vue(), WindiCSS(), Components({ resolvers: [ElementPlusResolver()] })], |
||||
vue(), |
|
||||
WindiCSS(), |
|
||||
Components({ |
|
||||
resolvers: [ElementPlusResolver()], |
|
||||
}), |
|
||||
], |
|
||||
resolve: { |
resolve: { |
||||
alias: { |
alias: { |
||||
'~': __dirname, |
'~': __dirname, |
||||
'@': resolve('src'), |
'@': resolve('src'), |
||||
'views': resolve('src/views'), |
views: resolve('src/views'), |
||||
'components': resolve('src/components'), |
components: resolve('src/components'), |
||||
'assets': resolve('src/assets'), |
assets: resolve('src/assets'), |
||||
} |
utils: resolve('src/utils'), |
||||
} |
store: resolve('src/store'), |
||||
}) |
apis: resolve('src/apis'), |
||||
|
}, |
||||
|
}, |
||||
|
}); |
||||
|
Loading…
Reference in new issue