优化后,再次提交

This commit is contained in:
王利强
2026-05-03 09:08:56 +08:00
parent 721ef0ad54
commit 805747d1d9
1243 changed files with 46213 additions and 221 deletions

View File

@@ -0,0 +1,140 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const request_three_one_api_area = require("../../request/three_one_api/area.js");
if (!Math) {
AreaFormPopup();
}
const AreaFormPopup = () => "../../components/AreaFormPopup.js";
const _sfc_main = {
__name: "management",
setup(__props) {
const areaList = common_vendor.ref([]);
const showPopup = common_vendor.ref(false);
const isEdit = common_vendor.ref(false);
const currentEditId = common_vendor.ref(null);
const submitting = common_vendor.ref(false);
const editData = common_vendor.ref({});
common_vendor.onMounted(() => {
loadAreaList();
});
const loadAreaList = async () => {
try {
const res = await request_three_one_api_area.getAreaList();
if (res.code === 0) {
areaList.value = res.data.records || [];
}
} catch (err) {
common_vendor.index.__f__("error", "at pages/area/management.vue:79", "获取区域列表失败:", err);
}
};
const openAddPopup = () => {
isEdit.value = false;
currentEditId.value = null;
editData.value = {};
showPopup.value = true;
};
const openEditPopup = async (item) => {
try {
const res = await request_three_one_api_area.getAreaDetail({ id: item.id });
if (res.code === 0) {
isEdit.value = true;
currentEditId.value = item.id;
editData.value = {
name: res.data.name || "",
color: res.data.color || "#FF5733"
};
showPopup.value = true;
}
} catch (err) {
common_vendor.index.__f__("error", "at pages/area/management.vue:105", "获取区域详情失败:", err);
common_vendor.index.showToast({ title: "获取详情失败", icon: "none" });
}
};
const handlePopupClose = () => {
isEdit.value = false;
currentEditId.value = null;
editData.value = {};
};
const handleSubmit = async (formData) => {
submitting.value = true;
try {
const submitData = {
name: formData.name,
color: formData.color
};
let res;
if (isEdit.value) {
submitData.id = currentEditId.value;
res = await request_three_one_api_area.updateArea(submitData);
} else {
res = await request_three_one_api_area.addArea(submitData);
}
if (res.code === 0) {
showPopup.value = false;
common_vendor.index.showToast({
title: isEdit.value ? "修改成功" : "新增成功",
icon: "success"
});
loadAreaList();
}
} catch (err) {
common_vendor.index.__f__("error", "at pages/area/management.vue:144", "提交失败:", err);
common_vendor.index.showToast({ title: "操作失败", icon: "none" });
} finally {
submitting.value = false;
}
};
const handleDelete = (item) => {
common_vendor.index.showModal({
title: "确认删除",
content: "确定要删除该区域吗?",
confirmColor: "#e54d42",
success: async (res) => {
if (res.confirm) {
try {
const result = await request_three_one_api_area.deleteArea({ id: item.id });
if (result.code === 0) {
common_vendor.index.showToast({ title: "删除成功", icon: "success" });
loadAreaList();
}
} catch (err) {
common_vendor.index.__f__("error", "at pages/area/management.vue:166", "删除失败:", err);
common_vendor.index.showToast({ title: "删除失败", icon: "none" });
}
}
}
});
};
return (_ctx, _cache) => {
return common_vendor.e({
a: areaList.value.length > 0
}, areaList.value.length > 0 ? {
b: common_vendor.f(areaList.value, (item, k0, i0) => {
return {
a: common_vendor.t(item.name || "区域名称"),
b: item.color,
c: common_vendor.t(item.color),
d: common_vendor.o(($event) => openEditPopup(item), item.id),
e: common_vendor.o(($event) => handleDelete(item), item.id),
f: item.id
};
})
} : {}, {
c: common_vendor.o(openAddPopup),
d: common_vendor.o(handleSubmit),
e: common_vendor.o(handlePopupClose),
f: common_vendor.o(($event) => showPopup.value = $event),
g: common_vendor.p({
isEdit: isEdit.value,
editData: editData.value,
loading: submitting.value,
visible: showPopup.value
}),
h: common_vendor.gei(_ctx, "")
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-847f15e8"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/area/management.js.map