@@ -15,7 +15,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- 已读/未读 -->
|
<!-- 已读/未读 -->
|
||||||
<!-- <span v-if="v.read" class="el-tag el-tag--success el-tag--mini read">已读</span> -->
|
<!-- <span v-if="v.read" class="el-tag el-tag--success el-tag--mini read">已读</span> -->
|
||||||
<button v-if="!v.read" class="el-tag el-tag--danger el-tag--mini read" @click="handleSee(v)">查看画面</button>
|
<button class="el-tag el-tag--danger el-tag--mini read" @click="handleSee(v)">查看画面</button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<el-empty v-else :description="'消息为空'"></el-empty>
|
<el-empty v-else :description="'消息为空'"></el-empty>
|
||||||
|
|||||||
30
src/store/modules/equipmentList.ts
Normal file
30
src/store/modules/equipmentList.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { defineStore } from 'pinia';
|
||||||
|
import { ref, computed } from 'vue';
|
||||||
|
import { getDevicetList } from '@/api/equipmentList/index';
|
||||||
|
|
||||||
|
export const useDeviceStore = defineStore('devices', () => {
|
||||||
|
// --- State (状态) ---
|
||||||
|
// 相当于 Vuex 中的 state,用 ref 或 reactive 定义
|
||||||
|
const deviceList = ref();
|
||||||
|
|
||||||
|
// --- Getters (计算属性) ---
|
||||||
|
// 相当于 Vuex 中的 getters,直接用 computed 定义
|
||||||
|
|
||||||
|
// --- Actions (动作) ---
|
||||||
|
// 相当于 Vuex 中的 actions/mutations,直接写同步或异步函数
|
||||||
|
async function getdeviceList(query?: any) {
|
||||||
|
try {
|
||||||
|
const response = await getDevicetList(query);
|
||||||
|
console.log('获取设备列表:', response);
|
||||||
|
deviceList.value = response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取设备列表失败', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ⚠️ 核心点:必须把需要暴露出去的变量和方法 return 出去!
|
||||||
|
return {
|
||||||
|
deviceList,
|
||||||
|
getdeviceList
|
||||||
|
};
|
||||||
|
});
|
||||||
@@ -118,6 +118,12 @@
|
|||||||
<script setup name="WarningList" lang="ts">
|
<script setup name="WarningList" lang="ts">
|
||||||
import { listDemo, updateDemo } from '@/api/WarningList/index';
|
import { listDemo, updateDemo } from '@/api/WarningList/index';
|
||||||
//import { DemoVO, DemoQuery, DemoForm } from '@/api/WarningList/types';
|
//import { DemoVO, DemoQuery, DemoForm } from '@/api/WarningList/types';
|
||||||
|
import { useDeviceStore } from '@/store/modules/equipmentList';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
|
|
||||||
|
const deviceStore = useDeviceStore();
|
||||||
|
const { deviceList } = storeToRefs(deviceStore);
|
||||||
|
const { getdeviceList } = deviceStore;
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||||
|
|
||||||
@@ -256,5 +262,6 @@ const submitForm = async () => {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getList();
|
getList();
|
||||||
|
getdeviceList();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import type { UploadProps, UploadUserFile } from 'element-plus';
|
|||||||
import { uploadDemo, getDemo, updateDemo } from '@/api/systemList/index';
|
import { uploadDemo, getDemo, updateDemo } from '@/api/systemList/index';
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
import { Plus } from '@element-plus/icons-vue';
|
import { Plus } from '@element-plus/icons-vue';
|
||||||
|
import router from '@/router';
|
||||||
|
|
||||||
const uploadUrl = import.meta.env.VITE_BASE_API + '/system/logo/upload';
|
const uploadUrl = import.meta.env.VITE_BASE_API + '/system/logo/upload';
|
||||||
|
|
||||||
@@ -84,6 +85,8 @@ const save = async () => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log('保存成功', res);
|
console.log('保存成功', res);
|
||||||
ElMessage.success('保存成功');
|
ElMessage.success('保存成功');
|
||||||
|
// 刷新当前路由
|
||||||
|
router.go(0);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error('保存失败', err);
|
console.error('保存失败', err);
|
||||||
|
|||||||
Reference in New Issue
Block a user