Commit 657abc7f authored by wp song's avatar wp song

点位管理

parent f98e1f1c
import { onMounted, ref, watch } from "vue"; import { onMounted, ref, watch } from "vue";
import request from "@/utils/request"; import request from "@/utils/request";
import { ElMessageBox } from "element-plus"; import { ElMessageBox } from "element-plus";
function useIndex(apis) { function useIndex(apis, callback) {
const visible = ref(false); const visible = ref(false);
const search = ref({});
const form = ref({ const form = ref({
regionName:'' regionName: "",
}); });
const list = ref([]); const list = ref([]);
const page = ref({
pageNum: 1,
pageSize: 10,
total: 0,
});
watch( watch(
() => visible, () => visible.value,
(newVal) => { (newVal) => {
if (newVal == false) { if (newVal == false) {
form.value = {}; form.value = {};
} }
} }
); );
function toView() {} watch([() => page.value.pageNum, () => page.value.pageSize], (val) => {
getList();
});
function toEdit(data) { function toEdit(data) {
getDetail(data.id); getDetail(data.id);
visible.value = true; visible.value = true;
...@@ -25,24 +33,31 @@ function useIndex(apis) { ...@@ -25,24 +33,31 @@ function useIndex(apis) {
function toAdd() { function toAdd() {
visible.value = true; visible.value = true;
} }
function toDel(data) { function toDel(data, immclose = true) {
//弹框确认 //弹框确认
ElMessageBox.confirm("是否删除该区域?").then(() => { return new Promise((resolve) => {
request({ ElMessageBox.confirm("是否删除?").then(() => {
url: apis.delete + data.id, request({
method: "delete", url: apis.delete + data.id,
}).then((res) => { method: "delete",
visible.value = false; }).then((res) => {
getList(); if (immclose) {
visible.value = false;
getList();
}
resolve();
});
}); });
}); });
} }
function getList() { function getList(params) {
request({ request({
url: apis.list, url: apis.list,
method: "get", method: "get",
params: { ...params, ...page.value, ...search.value },
}).then((res) => { }).then((res) => {
list.value = res.data; list.value = res.data || res.rows;
page.value.total = res.total;
}); });
} }
function getDetail(id) { function getDetail(id) {
...@@ -50,50 +65,66 @@ function useIndex(apis) { ...@@ -50,50 +65,66 @@ function useIndex(apis) {
url: apis.detail + id, url: apis.detail + id,
method: "get", method: "get",
}).then((res) => { }).then((res) => {
callback && callback(res);
form.value = res.data; form.value = res.data;
return res;
}); });
} }
function toSubmit() { function toSubmit(immclose = true) {
if (form.value.id) { return new Promise((resolve, reject) => {
request({ if (form.value.id) {
url: apis.edit, request({
method: "put", url: apis.edit,
data: form.value, method: "put",
}).then((res) => { data: form.value,
visible.value = false; }).then((res) => {
getList(); if (immclose) {
}); visible.value = false;
} else { getList();
request({ }
url: apis.add, resolve();
method: "post", });
data: form.value, } else {
}).then((res) => { request({
visible.value = false; url: apis.add,
getList(); method: "post",
}); data: form.value,
} }).then((res) => {
if (immclose) {
visible.value = false;
getList();
}
resolve();
});
}
});
} }
function toClose() { function toClose() {
visible.value = false; visible.value = false;
} }
function toOpen() {
visible.value = false;
}
onMounted(() => { onMounted(() => {
getList(); if (apis.list) {
getList();
}
}); });
return { return {
visible, visible,
form, form,
list, list,
toView, page,
toEdit, toEdit,
toAdd, toAdd,
toDel, toDel,
getDetail, getDetail,
toClose, toClose,
toSubmit, toSubmit,
getList,
toOpen,
}; };
} }
......
.areaNodes{ .areaNodes {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
width: 100%; width: 100%;
} }
\ No newline at end of file
.pagination-right {
display: flex;
justify-content: flex-end;
width: 100%;
margin-top: 20px;
}
.el-tree {
:deep(.is-current) {
& > .el-tree-node__content {
background-color: var(--el-color-primary-light-9);
}
}
}
// 随机生成十个颜色
export const colors = () => {
const r = Math.floor(Math.random() * 256);
const g = Math.floor(Math.random() * 256);
const b = Math.floor(Math.random() * 256);
const a = 0.8;
return `rgba(${r},${g},${b},${a})`;
};
export function drawImage(video){
const img = video;
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
canvas.width = img.offsetWidth;
canvas.height = img.offsetHeight;
ctx.drawImage(img, 0, 0, canvas.width, canvas.height); // 绘制图片
return canvas.toDataURL("image/jpg")
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment