"use strict"; const common_vendor = require("../../common/vendor.js"); const request_api = require("../../request/api.js"); if (!Array) { 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_picker2 + _easycom_u_popup2 + _component_TabBar)(); } 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_picker + _easycom_u_popup)(); } const _sfc_main = { __name: "membermanagemen", setup(__props) { const list = common_vendor.ref([]); request_api.getMemberList().then((res) => { list.value = res.data; }); const showPopup = common_vendor.ref(false); const showDeptPicker = common_vendor.ref(false); const formData = common_vendor.reactive({ username: "", nickname: "", phone: "", password: "", department: "" }); 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; } const params = { userName: formData.username, nickName: formData.nickname || "", phonenumber: formData.phone || "", password: formData.password, roleType: "common" }; try { const res = await request_api.addMember(params); if (res.code === 0) { common_vendor.index.showToast({ title: "添加成功", icon: "success" }); showPopup.value = false; formData.username = ""; formData.nickname = ""; formData.phone = ""; formData.password = ""; formData.department = ""; } else { common_vendor.index.showToast({ title: res.msg || "添加失败", icon: "none" }); } } catch (error) { console.error("添加成员失败:", error); common_vendor.index.showToast({ title: "请求失败", icon: "none" }); } }; const Lock = (item) => { const isLocked = item.lockStatus === 1; const actionText = isLocked ? "解锁" : "锁定"; const newLockStatus = 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: newLockStatus }); if (result.code === 0) { common_vendor.index.showToast({ title: `${actionText}成功`, icon: "success" }); item.lockStatus = newLockStatus; item.statusName = newLockStatus === 1 ? "已锁定" : "正常"; } else { common_vendor.index.showToast({ title: result.msg || `${actionText}失败`, icon: "none" }); } } catch (error) { console.error(`${actionText}成员失败:`, error); common_vendor.index.showToast({ title: "请求失败", icon: "none" }); } } } }); }; const show = common_vendor.ref(false); const columns = common_vendor.reactive([ ["湘西自治州和谐网络科技有限公司", "湘西自治州和谐云科技有限公司"] ]); const deptColumns = common_vendor.reactive([ ["湘西自治州和谐网络科技有限公司", "湘西自治州和谐云科技有限公司", "研发部门", "深圳总公司", "若依科技"] ]); const onDeptConfirm = (e) => { console.log("选择的部门:", e); if (e.value && e.value.length > 0) { formData.department = e.value[0]; } showDeptPicker.value = false; }; return (_ctx, _cache) => { return { a: common_vendor.f(list.value, (item, index, i0) => { return { a: common_vendor.o(($event) => show.value = true, item.id), b: "06d9f81b-0-" + i0, c: common_vendor.t(item.nickName), d: common_vendor.t(item.statusName), e: common_vendor.t(item.phonenumber), f: common_vendor.t(item.lockStatus === 1 ? "解锁" : "锁定"), g: common_vendor.o(($event) => Lock(item), item.id), h: item.id }; }), b: common_vendor.p({ show: show.value, columns }), c: common_vendor.o(($event) => showPopup.value = true), d: common_vendor.o(($event) => showPopup.value = false), e: formData.username, f: common_vendor.o(($event) => formData.username = $event.detail.value), g: formData.nickname, h: common_vendor.o(($event) => formData.nickname = $event.detail.value), i: formData.phone, j: common_vendor.o(($event) => formData.phone = $event.detail.value), k: formData.password, l: common_vendor.o(($event) => formData.password = $event.detail.value), m: common_vendor.t(formData.department || "请选择主部门"), n: common_vendor.n(formData.department ? "" : "text-gray"), o: common_vendor.o(($event) => showDeptPicker.value = true), p: common_vendor.o(onDeptConfirm), q: common_vendor.o(($event) => showDeptPicker.value = false), r: common_vendor.o(($event) => showDeptPicker.value = false), s: common_vendor.p({ show: showDeptPicker.value, columns: deptColumns }), t: common_vendor.o(($event) => showPopup.value = false), v: common_vendor.o(handleSubmit), w: common_vendor.o(($event) => showPopup.value = false), x: common_vendor.p({ show: showPopup.value, mode: "center", round: "20" }) }; }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-06d9f81b"]]); wx.createPage(MiniProgramPage);