Commit 30fa284e authored by wp song's avatar wp song

111

parent 3a6a6699
import { onMounted, ref, watch } from "vue";
import request from "@/utils/request";
import { ElMessageBox } from "element-plus";
function useIndex(apis) {
const visible = ref(false);
const form = ref({
regionName:''
});
const list = ref([]);
watch(
() => visible,
(newVal) => {
if (newVal == false) {
form.value = {};
}
}
);
function toView() {}
function toEdit(data) {
getDetail(data.id);
visible.value = true;
}
function toAdd() {
visible.value = true;
}
function toDel(data) {
//弹框确认
ElMessageBox.confirm("是否删除该区域?").then(() => {
request({
url: apis.delete + data.id,
method: "delete",
}).then((res) => {
visible.value = false;
getList();
});
});
}
function getList() {
request({
url: apis.list,
method: "get",
}).then((res) => {
list.value = res.data;
});
}
function getDetail(id) {
return request({
url: apis.detail + id,
method: "get",
}).then((res) => {
form.value = res.data;
});
}
function toSubmit() {
if (form.value.id) {
request({
url: apis.edit,
method: "put",
data: form.value,
}).then((res) => {
visible.value = false;
getList();
});
} else {
request({
url: apis.add,
method: "post",
data: form.value,
}).then((res) => {
visible.value = false;
getList();
});
}
}
function toClose() {
visible.value = false;
}
onMounted(() => {
getList();
});
return {
visible,
form,
list,
toView,
toEdit,
toAdd,
toDel,
getDetail,
toClose,
toSubmit,
};
}
export { useIndex };
.areaNodes{
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
}
\ No newline at end of file
......@@ -25,13 +25,14 @@ export default defineConfig(({ mode, command }) => {
},
// vite 相关配置
server: {
port: 80,
port: 8090,
host: true,
open: true,
proxy: {
// https://cn.vitejs.dev/config/#server-proxy
'/dev-api': {
target: 'http://192.168.4.206:80/ai',
// target:'http://192.168.14.43:8111/ai',
changeOrigin: true,
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