优化后,再次提交
This commit is contained in:
230
unpackage/dist/dev/mp-weixin/pages/membermanagemen/membermanagemen.js
vendored
Normal file
230
unpackage/dist/dev/mp-weixin/pages/membermanagemen/membermanagemen.js
vendored
Normal file
@@ -0,0 +1,230 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const request_api = require("../../request/api.js");
|
||||
if (!Array) {
|
||||
const _easycom_up_input2 = common_vendor.resolveComponent("up-input");
|
||||
const _easycom_up_picker2 = common_vendor.resolveComponent("up-picker");
|
||||
const _easycom_u_popup2 = common_vendor.resolveComponent("u-popup");
|
||||
const _component_TabBar = common_vendor.resolveComponent("TabBar");
|
||||
(_easycom_up_input2 + _easycom_up_picker2 + _easycom_u_popup2 + _component_TabBar)();
|
||||
}
|
||||
const _easycom_up_input = () => "../../uni_modules/uview-plus/components/u-input/u-input.js";
|
||||
const _easycom_up_picker = () => "../../uni_modules/uview-plus/components/u-picker/u-picker.js";
|
||||
const _easycom_u_popup = () => "../../uni_modules/uview-plus/components/u-popup/u-popup.js";
|
||||
if (!Math) {
|
||||
(_easycom_up_input + _easycom_up_picker + _easycom_u_popup)();
|
||||
}
|
||||
const _sfc_main = {
|
||||
__name: "membermanagemen",
|
||||
setup(__props) {
|
||||
const userInfo = common_vendor.ref({
|
||||
deptId: "",
|
||||
deptName: "",
|
||||
nickName: "",
|
||||
role: "",
|
||||
userId: "",
|
||||
username: ""
|
||||
});
|
||||
const roleText = common_vendor.computed(() => {
|
||||
const role = userInfo.value.role;
|
||||
if (role === "manage" || role === "admin") {
|
||||
return "管理人员";
|
||||
} else if (role === "common") {
|
||||
return "执行人员";
|
||||
}
|
||||
return "成员";
|
||||
});
|
||||
const getUserInfo = () => {
|
||||
try {
|
||||
const userInfoStr = common_vendor.index.getStorageSync("userInfo");
|
||||
if (userInfoStr) {
|
||||
userInfo.value = JSON.parse(userInfoStr);
|
||||
common_vendor.index.__f__("log", "at pages/membermanagemen/membermanagemen.vue:142", "用户信息:", userInfo.value);
|
||||
}
|
||||
} catch (error) {
|
||||
common_vendor.index.__f__("error", "at pages/membermanagemen/membermanagemen.vue:145", "获取用户信息失败:", error);
|
||||
}
|
||||
};
|
||||
const list = common_vendor.ref([]);
|
||||
const fetchMemberList = async () => {
|
||||
try {
|
||||
const res = await request_api.getMemberList();
|
||||
if (res.code === 0 && res.data) {
|
||||
list.value = res.data;
|
||||
common_vendor.index.__f__("log", "at pages/membermanagemen/membermanagemen.vue:158", "成员列表:", res.data);
|
||||
}
|
||||
} catch (error) {
|
||||
common_vendor.index.__f__("error", "at pages/membermanagemen/membermanagemen.vue:161", "获取成员列表失败:", error);
|
||||
}
|
||||
};
|
||||
const showPopup = common_vendor.ref(false);
|
||||
const showRolePicker = common_vendor.ref(false);
|
||||
const selectedRoleName = common_vendor.ref("");
|
||||
const formData = common_vendor.reactive({
|
||||
username: "",
|
||||
nickname: "",
|
||||
phone: "",
|
||||
password: "",
|
||||
roleType: ""
|
||||
});
|
||||
const roleColumns = common_vendor.reactive([
|
||||
["管理员", "普通成员"]
|
||||
]);
|
||||
const roleMap = {
|
||||
"管理员": "manage",
|
||||
"普通成员": "common"
|
||||
};
|
||||
const onRoleConfirm = (e) => {
|
||||
if (e.value && e.value.length > 0) {
|
||||
selectedRoleName.value = e.value[0];
|
||||
formData.roleType = roleMap[e.value[0]];
|
||||
}
|
||||
showRolePicker.value = false;
|
||||
};
|
||||
const resetForm = () => {
|
||||
formData.username = "";
|
||||
formData.nickname = "";
|
||||
formData.phone = "";
|
||||
formData.password = "";
|
||||
formData.roleType = "";
|
||||
selectedRoleName.value = "";
|
||||
};
|
||||
const handleSubmit = async () => {
|
||||
if (!formData.username) {
|
||||
common_vendor.index.showToast({ title: "请输入用户名", icon: "none" });
|
||||
return;
|
||||
}
|
||||
if (!formData.password || formData.password.length < 6 || formData.password.length > 16) {
|
||||
common_vendor.index.showToast({ title: "请输入6-16位密码", icon: "none" });
|
||||
return;
|
||||
}
|
||||
if (!formData.roleType) {
|
||||
common_vendor.index.showToast({ title: "请选择角色类型", icon: "none" });
|
||||
return;
|
||||
}
|
||||
const params = {
|
||||
userName: formData.username,
|
||||
nickName: formData.nickname || "",
|
||||
phonenumber: formData.phone || "",
|
||||
password: formData.password,
|
||||
roleType: formData.roleType
|
||||
};
|
||||
try {
|
||||
const res = await request_api.addMember(params);
|
||||
if (res.code === 0) {
|
||||
common_vendor.index.showToast({ title: "添加成功", icon: "success" });
|
||||
showPopup.value = false;
|
||||
resetForm();
|
||||
fetchMemberList();
|
||||
} else {
|
||||
common_vendor.index.showToast({ title: res.msg || "添加失败", icon: "none" });
|
||||
}
|
||||
} catch (error) {
|
||||
common_vendor.index.__f__("error", "at pages/membermanagemen/membermanagemen.vue:244", "添加成员失败:", error);
|
||||
common_vendor.index.showToast({ title: "请求失败", icon: "none" });
|
||||
}
|
||||
};
|
||||
const Lock = (item) => {
|
||||
const isLocked = item.status === "1";
|
||||
const actionText = isLocked ? "解锁" : "锁定";
|
||||
const newStatus = isLocked ? "0" : "1";
|
||||
common_vendor.index.showModal({
|
||||
title: "提示",
|
||||
content: `确定要${actionText}该成员吗?`,
|
||||
confirmColor: "#2667E9",
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
const result = await request_api.lockOrUnlockMember({
|
||||
userId: item.userId,
|
||||
lockStatus: Number(newStatus)
|
||||
});
|
||||
if (result.code === 0) {
|
||||
common_vendor.index.showToast({ title: `${actionText}成功`, icon: "success" });
|
||||
item.status = newStatus;
|
||||
item.statusName = newStatus === "1" ? "已锁定" : "正常";
|
||||
} else {
|
||||
common_vendor.index.showToast({ title: result.msg || `${actionText}失败`, icon: "none" });
|
||||
}
|
||||
} catch (error) {
|
||||
common_vendor.index.__f__("error", "at pages/membermanagemen/membermanagemen.vue:275", `${actionText}成员失败:`, error);
|
||||
common_vendor.index.showToast({ title: "请求失败", icon: "none" });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
common_vendor.onMounted(() => {
|
||||
getUserInfo();
|
||||
fetchMemberList();
|
||||
});
|
||||
return (_ctx, _cache) => {
|
||||
return {
|
||||
a: common_vendor.t(userInfo.value.deptName || "未知部门"),
|
||||
b: common_vendor.t(roleText.value),
|
||||
c: common_vendor.f(list.value, (item, index, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(item.nickName),
|
||||
b: common_vendor.t(item.statusName),
|
||||
c: common_vendor.n(item.statusName === "正常" ? "status-normal" : "status-locked"),
|
||||
d: common_vendor.t(item.phonenumber || "未设置"),
|
||||
e: common_vendor.t(item.status === "1" ? "解锁" : "锁定"),
|
||||
f: common_vendor.o(($event) => Lock(item), item.userId),
|
||||
g: item.userId,
|
||||
h: index < list.value.length - 1 ? 1 : ""
|
||||
};
|
||||
}),
|
||||
d: common_vendor.o(($event) => showPopup.value = true),
|
||||
e: common_vendor.o(($event) => showPopup.value = false),
|
||||
f: common_vendor.o(($event) => formData.username = $event),
|
||||
g: common_vendor.p({
|
||||
placeholder: "请输入用户名",
|
||||
border: "surround",
|
||||
modelValue: formData.username
|
||||
}),
|
||||
h: common_vendor.o(($event) => formData.nickname = $event),
|
||||
i: common_vendor.p({
|
||||
placeholder: "请输入昵称",
|
||||
border: "surround",
|
||||
modelValue: formData.nickname
|
||||
}),
|
||||
j: common_vendor.o(($event) => formData.phone = $event),
|
||||
k: common_vendor.p({
|
||||
placeholder: "请输入手机号",
|
||||
type: "number",
|
||||
border: "surround",
|
||||
modelValue: formData.phone
|
||||
}),
|
||||
l: common_vendor.o(($event) => formData.password = $event),
|
||||
m: common_vendor.p({
|
||||
placeholder: "请输入密码(6-16位)",
|
||||
password: true,
|
||||
border: "surround",
|
||||
modelValue: formData.password
|
||||
}),
|
||||
n: common_vendor.t(selectedRoleName.value || "请选择角色类型"),
|
||||
o: common_vendor.n(selectedRoleName.value ? "" : "text-gray"),
|
||||
p: common_vendor.o(($event) => showRolePicker.value = true),
|
||||
q: common_vendor.o(onRoleConfirm),
|
||||
r: common_vendor.o(($event) => showRolePicker.value = false),
|
||||
s: common_vendor.o(($event) => showRolePicker.value = false),
|
||||
t: common_vendor.p({
|
||||
show: showRolePicker.value,
|
||||
columns: roleColumns
|
||||
}),
|
||||
v: common_vendor.o(($event) => showPopup.value = false),
|
||||
w: common_vendor.o(handleSubmit),
|
||||
x: common_vendor.o(($event) => showPopup.value = false),
|
||||
y: common_vendor.p({
|
||||
show: showPopup.value,
|
||||
mode: "center",
|
||||
round: "20"
|
||||
}),
|
||||
z: common_vendor.gei(_ctx, "")
|
||||
};
|
||||
};
|
||||
}
|
||||
};
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-06d9f81b"]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/membermanagemen/membermanagemen.js.map
|
||||
Reference in New Issue
Block a user