Commit 89befeef authored by 胡占生's avatar 胡占生 🇨🇳

Merge branch 'developer' of http://git.censoft.com.cn/ai-yunshou/ai-yunshou-vue into developer

parents e48045d6 0dbe1947
import { onMounted, ref, watch } from "vue";
import request from "@/utils/request";
import { ElMessageBox } from "element-plus";
function useIndex(apis, callback) {
const visible = ref(false);
const search = ref({});
const form = ref({
regionName: "",
});
const list = ref([]);
const page = ref({
pageNum: 1,
pageSize: 10,
total: 0,
});
watch(
() => visible.value,
(newVal) => {
if (newVal == false) {
form.value = {};
}
}
);
watch([() => page.value.pageNum, () => page.value.pageSize], (val) => {
getList();
});
function toEdit(data) {
getDetail(data.id);
visible.value = true;
}
function toAdd() {
visible.value = true;
}
function toDel(data, immclose = true) {
//弹框确认
return new Promise((resolve) => {
ElMessageBox.confirm("是否删除?").then(() => {
request({
url: apis.delete + data.id,
method: "delete",
}).then((res) => {
if (immclose) {
visible.value = false;
getList();
}
resolve();
});
});
});
}
function getList(params) {
request({
url: apis.list,
method: "get",
params: { ...params, ...page.value, ...search.value },
}).then((res) => {
list.value = res.data || res.rows;
page.value.total = res.total;
});
}
function getDetail(id) {
return request({
url: apis.detail + id,
method: "get",
}).then((res) => {
callback && callback(res);
form.value = res.data;
return res;
});
}
function toSubmit(immclose = true) {
return new Promise((resolve, reject) => {
if (form.value.id) {
request({
url: apis.edit,
method: "put",
data: form.value,
}).then((res) => {
if (immclose) {
visible.value = false;
getList();
}
resolve();
});
} else {
request({
url: apis.add,
method: "post",
data: form.value,
}).then((res) => {
if (immclose) {
visible.value = false;
getList();
}
resolve();
});
}
});
}
function toClose() {
visible.value = false;
}
function toOpen() {
visible.value = false;
}
onMounted(() => {
if (apis.list) {
getList();
}
});
return {
visible,
form,
list,
page,
toEdit,
toAdd,
toDel,
getDetail,
toClose,
toSubmit,
getList,
toOpen,
};
}
export { useIndex };
.areaNodes {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
}
.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
...@@ -25,7 +25,7 @@ export default defineConfig(({ mode, command }) => { ...@@ -25,7 +25,7 @@ export default defineConfig(({ mode, command }) => {
}, },
// vite 相关配置 // vite 相关配置
server: { server: {
port: 80, port: 8090,
host: true, host: true,
open: true, open: true,
proxy: { proxy: {
...@@ -33,6 +33,7 @@ export default defineConfig(({ mode, command }) => { ...@@ -33,6 +33,7 @@ export default defineConfig(({ mode, command }) => {
'/dev-api': { '/dev-api': {
// target: 'http://192.168.14.43:8111/ai', // target: 'http://192.168.14.43:8111/ai',
target: 'http://192.168.4.206:80/ai', target: 'http://192.168.4.206:80/ai',
// target:'http://192.168.14.43:8111/ai',
changeOrigin: true, changeOrigin: true,
rewrite: (p) => p.replace(/^\/dev-api/, '') rewrite: (p) => p.replace(/^\/dev-api/, '')
}, },
......
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