|
@ -1,38 +1,28 @@ |
|
|
<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" |
|
|
:rowClassName="(record: any, index: number) => (index % 2 === 1 ? 'table-striped' : undefined)" |
|
|
size="middle" |
|
|
:pagination="pagination"> |
|
|
:columns="columns" |
|
|
|
|
|
:data-source="data" |
|
|
|
|
|
:rowClassName="(record:any, index:number) => (index % 2 === 1 ? 'table-striped' : undefined)" |
|
|
|
|
|
: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="取消" |
|
|
@confirm="del_(record.id, record.key-1)"> |
|
|
@confirm="del_(record.id, record.key - 1)"> |
|
|
<Divider type="vertical" /> |
|
|
<Divider type="vertical" /> |
|
|
<a href="#" >删除</a> |
|
|
<a href="#">删除</a> |
|
|
</Popconfirm> |
|
|
</Popconfirm> |
|
|
</template> |
|
|
</template> |
|
|
</Table> |
|
|
</Table> |
|
|
</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 { |
|
@ -59,7 +49,7 @@ const columns = [ |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
]; |
|
|
]; |
|
|
let data =ref(); |
|
|
let data = ref(); |
|
|
// let data = [ |
|
|
// let data = [ |
|
|
// { |
|
|
// { |
|
|
// key: '1', |
|
|
// key: '1', |
|
@ -165,41 +155,70 @@ const pagination = ref({ |
|
|
function loadTreeData() { |
|
|
function loadTreeData() { |
|
|
cameraApi.GetList().then((res: any) => { |
|
|
cameraApi.GetList().then((res: any) => { |
|
|
let list: Array<any> = res.data.data; |
|
|
let list: Array<any> = res.data.data; |
|
|
if(list.length!=0){ |
|
|
if (list.length != 0) { |
|
|
list=list.map((item:any,index:number)=>{ |
|
|
list = list.map((item: any, index: number) => { |
|
|
item.key=index+1 |
|
|
item.key = index + 1 |
|
|
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 |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
loadTreeData() |
|
|
|
|
|
function edit_(item:any){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
|
|
loadTreeData() |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//编辑 |
|
|
|
|
|
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; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
function del_(key:any,index:number){ |
|
|
} |
|
|
cameraApi.Delete({id:key}).then((res:any)=>{ |
|
|
else { |
|
|
let resData=res.data |
|
|
visible.value = true; |
|
|
if(resData){ |
|
|
} |
|
|
|
|
|
//清空 |
|
|
|
|
|
editData.value = null |
|
|
|
|
|
}; |
|
|
|
|
|
//删除 |
|
|
|
|
|
function del_(key: any, index: number) { |
|
|
|
|
|
cameraApi.Delete({ id: key }).then((res: any) => { |
|
|
|
|
|
let resData = res.data |
|
|
|
|
|
if (resData) { |
|
|
Msg.success("删除成功") |
|
|
Msg.success("删除成功") |
|
|
data.value.splice(index,1) |
|
|
data.value.splice(index, 1) |
|
|
data.value=data.value.map((item:any,i:number)=>{ |
|
|
data.value = data.value.map((item: any, i: number) => { |
|
|
if(index<item.key){ |
|
|
if (index < item.key) { |
|
|
item.key-- |
|
|
item.key-- |
|
|
} |
|
|
} |
|
|
return item |
|
|
return item |
|
@ -207,18 +226,27 @@ function del_(key:any,index:number){ |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//监听 重新获取 |
|
|
|
|
|
watch(visible, (nv, ov) => { |
|
|
|
|
|
loadTreeData() |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<style scoped lang='less'> |
|
|
<style scoped lang='less'> |
|
|
.user-edit{ |
|
|
.user-edit { |
|
|
padding: 20px; |
|
|
padding: 20px; |
|
|
// 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; |
|
|
} |
|
|
} |
|
|
</style> |
|
|
</style> |