|
@ -1,14 +1,9 @@ |
|
|
<template> |
|
|
<template> |
|
|
<div class="user-edit"> |
|
|
<div class="user-edit"> |
|
|
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> |
|
|
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> |
|
|
<Table |
|
|
<Table class="ant-table-striped" size="middle" :columns="columns" :data-source="data" |
|
|
class="ant-table-striped" |
|
|
|
|
|
size="middle" |
|
|
|
|
|
:columns="columns" |
|
|
|
|
|
:data-source="data" |
|
|
|
|
|
:rowClassName="(record: any, index: number) => (index % 2 === 1 ? 'table-striped' : undefined)" |
|
|
:rowClassName="(record: any, index: number) => (index % 2 === 1 ? 'table-striped' : undefined)" |
|
|
:pagination="pagination" |
|
|
:pagination="pagination"> |
|
|
> |
|
|
|
|
|
<template #action="{ record }"> |
|
|
<template #action="{ record }"> |
|
|
<a href="#" @click="edit_(record)">编辑</a> |
|
|
<a href="#" @click="edit_(record)">编辑</a> |
|
|
<Popconfirm v-if="data.length" title="确定删除吗?" ok-text="确定" cancel-text="取消" |
|
|
<Popconfirm v-if="data.length" title="确定删除吗?" ok-text="确定" cancel-text="取消" |
|
@ -21,18 +16,13 @@ |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<!-- 弹出框 --> |
|
|
<!-- 弹出框 --> |
|
|
<a-modal |
|
|
<a-modal v-model:visible="visible" title="设置表单" width="40%" @ok="handleOk" destroyOnClose> |
|
|
v-model:visible="visible" |
|
|
<userEditModal ref="childRef" :editData="editData"></userEditModal> |
|
|
title="设置表单" |
|
|
|
|
|
width="40%" |
|
|
|
|
|
@ok="handleOk" |
|
|
|
|
|
> |
|
|
|
|
|
<userEditModal @handleOk='handleOk'></userEditModal> |
|
|
|
|
|
</a-modal> |
|
|
</a-modal> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script setup lang='ts'> |
|
|
<script setup lang='ts'> |
|
|
import { ref } from"vue"; |
|
|
import { onMounted, ref, watch } from "vue"; |
|
|
import * as cameraApi from '@/axios/cameraBase/cameraApi'; |
|
|
import * as cameraApi from '@/axios/cameraBase/cameraApi'; |
|
|
import userEditModal from '@/views/page/aside/rightMenuItem/userEditModal.vue' |
|
|
import userEditModal from '@/views/page/aside/rightMenuItem/userEditModal.vue' |
|
|
import { |
|
|
import { |
|
@ -171,27 +161,56 @@ function loadTreeData() { |
|
|
return item |
|
|
return item |
|
|
}) |
|
|
}) |
|
|
pagination.value.total = list.length |
|
|
pagination.value.total = list.length |
|
|
console.log(list); |
|
|
// console.log(list); |
|
|
|
|
|
|
|
|
data.value = list |
|
|
data.value = list |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
loadTreeData() |
|
|
loadTreeData() |
|
|
function edit_(item:any){ |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//编辑 |
|
|
|
|
|
let editData = ref() |
|
|
|
|
|
function edit_(item: any) { |
|
|
|
|
|
// console.log(item); |
|
|
|
|
|
editData.value = item |
|
|
|
|
|
visible.value = true |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//添加 |
|
|
//添加 |
|
|
let visible = ref(); |
|
|
let visible = ref(); |
|
|
function handleAdd() { |
|
|
function handleAdd() { |
|
|
visible.value = true; |
|
|
visible.value = true; |
|
|
} |
|
|
} |
|
|
//模态框方法 |
|
|
//模态框方法 |
|
|
const handleOk = (e: MouseEvent) => { |
|
|
const childRef = ref(null); |
|
|
console.log(e); |
|
|
const handleOk = async (e: MouseEvent) => { |
|
|
|
|
|
// console.log(e); |
|
|
|
|
|
let result |
|
|
|
|
|
if (editData.value == null) { |
|
|
|
|
|
result = await childRef.value.add(); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
result = await childRef.value.edit(); |
|
|
|
|
|
} |
|
|
|
|
|
// console.log("result",result); |
|
|
|
|
|
if (result) { //成功关闭弹窗 |
|
|
visible.value = false; |
|
|
visible.value = false; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
visible.value = true; |
|
|
|
|
|
} |
|
|
|
|
|
//清空 |
|
|
|
|
|
editData.value = null |
|
|
|
|
|
}; |
|
|
|
|
|
//删除 |
|
|
function del_(key: any, index: number) { |
|
|
function del_(key: any, index: number) { |
|
|
cameraApi.Delete({ id: key }).then((res: any) => { |
|
|
cameraApi.Delete({ id: key }).then((res: any) => { |
|
|
let resData = res.data |
|
|
let resData = res.data |
|
@ -207,6 +226,13 @@ function del_(key:any,index:number){ |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//监听 重新获取 |
|
|
|
|
|
watch(visible, (nv, ov) => { |
|
|
|
|
|
loadTreeData() |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<style scoped lang='less'> |
|
|
<style scoped lang='less'> |
|
@ -215,9 +241,11 @@ function del_(key:any,index:number){ |
|
|
// background-color: #001529; |
|
|
// background-color: #001529; |
|
|
height: 100%; |
|
|
height: 100%; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.ant-table-striped :deep(.table-striped) td { |
|
|
.ant-table-striped :deep(.table-striped) td { |
|
|
background-color: #fafafa; |
|
|
background-color: #fafafa; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
:deep(.ant-table-cell) { |
|
|
:deep(.ant-table-cell) { |
|
|
color: #000 !important; |
|
|
color: #000 !important; |
|
|
} |
|
|
} |
|
|