You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dandelionPlatformToB-uni-v3/root/merchantManagement/childGroup.vue

385 lines
14 KiB
Vue

6 days ago
<template>
<div class="child-group-container g_flex_column_between g_bg_page">
<scroll-view class="g_flex_1" enable-flex :style="{ 'min-height': `calc(100vh - ${0}px)` }" :scroll-y="true">
<div class="g_flex_column_between" :style="{ 'min-height': `calc(100vh - ${0}px)` }">
<div class>
<div class="g_h_10"></div>
<div class="r_box g_ml_10 g_mr_10" style="border-radius: 8px;background-color: #fff;">
6 days ago
<div v-for="(item, index) in memberList" :key="'m_' + item.id" @click="editMember(item)"
class="g_flex_row_between g_fs_18" style="padding: 0 10px">
<div class="g_flex_c g_flex_none g_mr_10">
<img :src="item.avatar || 'https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/pugongying/default.svg'"
alt="" style="width: 40px;height: 40px;border-radius: 50%;">
</div>
<div class="g_flex_column_between g_flex_1"
:style="(index === memberList.length - 1 && teamList.length === 0) ? 'padding: 9px 0;' : 'border-bottom: 0.5px solid #eee;padding: 9px 0;'"
>
<div class="g_flex_1 g_flex_row_start" style="font-size: 17px;color: rgba(0, 0, 0, 0.9);">
{{ item.aliasName || item.userName }}
<div class="g_flex_column_center">
<div class="g_flex_row_start">
<div class="g_fs_12 g_pl_2 g_h_18 g_pr_2 g_radius_4 g_flex_c g_ml_4"
v-for="(role, rIndex) in getDisplayRoles(item.agencyRoleNameList)"
:key="rIndex"
:class="role !== '...' ? (role == '创建人' ? 'creator' : role == '管理员' ? 'manager' : 'member') : ''"
v-show="role && role.trim()">
{{ role }}
</div>
</div>
</div>
</div>
<div class="g_flex_none" style="font-size: 14px;color: #999999;">
@{{ agencyInfo.fullName }}
</div>
</div>
</div>
<div v-for="(item, index) in teamList" :key="'t_' + item.id" @click="goChildGroup(item)"
class="g_flex_row_start" style="padding: 0 10px;">
6 days ago
<div class="g_flex_none g_flex_column_center" style="margin-right: 10px;">
<div class="g_flex_c" style="width: 40px;height: 40px;background-color: rgba(2, 122, 255, 0.1);color: #1890ff;border-radius: 50%;">
<i class="iconfont icon-folder-fill" style="font-size: 20px;"></i>
</div>
</div>
<div class="g_flex_1 g_flex_column_center"
6 days ago
:style="index === teamList.length - 1 ? 'padding: 9px 0;height: 60px;' : 'border-bottom: 0.5px solid #eee;padding: 9px 0;height: 60px;'"
6 days ago
>
<div style="font-size: 17px;color: rgba(2, 122, 255, 1);" class="g_ell_1">
{{ item.teamName }}({{ item.userNum }})
</div>
</div>
</div>
6 days ago
<div v-if="memberList.length === 0 && teamList.length === 0" class="g_text_c g_c_9" style="padding: 40px 0;">
暂无数据
6 days ago
</div>
</div>
<div class="g_h_40"></div>
</div>
</div>
</scroll-view>
6 days ago
<u-popup v-model="addMemberShow" mode="bottom" z-index="999999" border-radius="12" :closeable="false" :mask-close-able="true" @close="addMemberShow = false">
<view class="g_text_c g_bg_f_5 g_fs_17">
<view class="g_bg_f">
<view class="g_c_3">
<view class="g_p_16 g_border_e_t" @click="goPage('/root/merchantManagement/addOrUpdataMember')"></view>
<view class="g_p_16 g_border_e_t" @click="goPage('/root/merchantManagement/memberApplyQRCode')"></view>
</view>
</view>
<view class="g_p_16 g_mt_10 g_bg_f" style="padding-bottom: calc(constant(safe-area-inset-bottom) + 16px); padding-bottom: calc(env(safe-area-inset-bottom) + 16px)" @click="addMemberShow = false">取消</view>
</view>
</u-popup>
<u-popup v-model="operateShow" mode="bottom" z-index="999999" border-radius="12" :closeable="false" :mask-close-able="true" @close="operateShow = false">
<view class="g_text_c g_bg_f_5 g_fs_17">
<view class="g_bg_f">
<view class="g_c_3">
6 days ago
<view class="g_p_16 g_border_e_t" @click="onOperate('editName')"></view>
<view class="g_p_16 g_border_e_t" @click="onOperate('delete')"></view>
6 days ago
</view>
</view>
<view class="g_p_16 g_mt_10 g_bg_f" style="padding-bottom: calc(constant(safe-area-inset-bottom) + 16px); padding-bottom: calc(env(safe-area-inset-bottom) + 16px)" @click="operateShow = false">取消</view>
</view>
</u-popup>
6 days ago
<u-modal v-model="editNameShow" width="90%" negativeTop="150" :showTitle="false" :showConfirmButton="false" :maskCloseAble="true">
<div class="g_fs_17 g_text_c">
<div style="padding: 32px 24px">
6 days ago
<div class="g_text_c g_fw_600 g_c_0 g_mb_16">修改当前部门名称</div>
6 days ago
<div class="">
<u-input v-model="editNameValue"
:customStyle="{
fontSize: '17px',
borderRadius: '4px',
backgroundColor: '#fff',
}"
height="80"
border
border-color="#dddddd"
placeholder="请输入部门名称"
placeholder-style="color:#999;font-size: 17px;"
/>
</div>
</div>
<div class="g_flex_row_center flex_center g_fw_600 g_border_e_t">
<div class="g_flex_1 g_text_c g_border_e_r" hover-class="thover" @click="editNameShow = false" style="height: 56px;line-height: 56px;font-size: 17px;color: #333;">取消</div>
<div class="g_flex_1 g_text_c g_c_sub" hover-class="thover" @click="submitEditName" style="height: 56px;line-height: 56px;font-size: 17px;color: #576b95;">
<u-loading mode="circle" size="16" v-if="editNameLoading"></u-loading>
<span v-else></span>
</div>
</div>
</div>
</u-modal>
<u-modal v-model="deleteShow" width="90%" negativeTop="150" :showTitle="false" :showConfirmButton="false" :maskCloseAble="true">
<div class="g_fs_17 g_text_c">
<div style="padding: 32px 24px">
<div style="font-size: 17px;color: #000;">确定将"{{ pageTitle }}"删除吗?</div>
</div>
<div class="g_flex_row_center flex_center g_fw_600 g_border_e_t">
<div class="g_flex_1 g_text_c g_border_e_r" hover-class="thover" @click="deleteShow = false" style="height: 56px;line-height: 56px;font-size: 17px;color: #333;">取消</div>
<div class="g_flex_1 g_text_c g_c_sub" hover-class="thover" @click="submitDelete" style="height: 56px;line-height: 56px;font-size: 17px;color: #576b95;">
<u-loading mode="circle" size="16" v-if="deleteLoading"></u-loading>
<span v-else></span>
</div>
</div>
</div>
</u-modal>
6 days ago
<u-modal v-model="addTeamShow" width="90%" negativeTop="150" :showTitle="false" :showConfirmButton="false" :maskCloseAble="true">
<div class="g_fs_17 g_text_c">
<div style="padding: 32px 24px">
<div class="g_text_c g_fw_600 g_c_0 g_mb_16">添加子部门</div>
<div class="">
<u-input v-model="teamName"
:customStyle="{
fontSize: '17px',
borderRadius: '4px',
backgroundColor: '#fff',
}"
height="80"
border
border-color="#dddddd"
placeholder="请输入子部门名称"
placeholder-style="color:#999;font-size: 17px;"
/>
</div>
</div>
<div class="g_flex_row_center flex_center g_fw_600 g_border_e_t">
<div class="g_flex_1 g_text_c g_border_e_r" hover-class="thover" @click="addTeamShow = false" style="height: 56px;line-height: 56px;font-size: 17px;color: #333;">取消</div>
<div class="g_flex_1 g_text_c g_c_sub" hover-class="thover" @click="submitAddTeam" style="height: 56px;line-height: 56px;font-size: 17px;color: #576b95;">
<u-loading mode="circle" size="16" v-if="addTeamLoading"></u-loading>
<span v-else></span>
</div>
</div>
</div>
</u-modal>
6 days ago
<div style="height: 40px;"></div>
<g-panel-fixed>
<slot>
<div class="g_flex_row_between" style="padding: 0 10px;">
6 days ago
<div style="font-size: 17px;color: rgba(2, 122, 255, 1);" @click="addMemberShow = true">添加成员</div>
6 days ago
<div v-if="!hideAddTeam" style="font-size: 17px;color: rgba(2, 122, 255, 1);" @click="addTeamShow = true"></div>
6 days ago
<div style="font-size: 17px;color: rgba(2, 122, 255, 1);" @click="operateShow = true">操作</div>
6 days ago
<div style="font-size: 17px;color: rgba(2, 122, 255, 1);" @click="goPage('/root/person/info?active=1')"></div>
</div>
</slot>
</g-panel-fixed>
</div>
</template>
<script>
export default {
data() {
return {
6 days ago
memberList: [],
6 days ago
teamList: [],
currentId: "",
currentParentId: "",
pageTitle: "",
6 days ago
addMemberShow: false,
operateShow: false,
6 days ago
editNameShow: false,
editNameLoading: false,
editNameValue: "",
deleteShow: false,
deleteLoading: false,
6 days ago
addTeamShow: false,
addTeamLoading: false,
teamName: "",
hideAddTeam: false,
6 days ago
agencyInfo: uni.getStorageSync("agencyInfo"),
6 days ago
};
},
onLoad(options) {
this.currentId = options.id || "";
this.currentParentId = options.pId || "";
this.pageTitle = decodeURIComponent(options.teamName || "");
this.editNameValue = this.pageTitle;
uni.setNavigationBarTitle({
title: this.pageTitle,
});
},
onShow() {
6 days ago
this.getList();
6 days ago
},
methods: {
6 days ago
compare(a, b) {
let sortList = ["创建人", "管理员", "成员"];
if (sortList.includes(a) && sortList.includes(b)) {
return sortList.indexOf(a) - sortList.indexOf(b);
} else if (sortList.includes(a)) {
return -1;
} else if (sortList.includes(b)) {
return 1;
} else {
return a.localeCompare(b);
}
},
getDisplayRoles(roles) {
if (!roles || roles.length <= 2) {
return (roles || []).filter(role => role && role.trim());
}
const filteredRoles = (roles || []).filter(role => role && role.trim());
if (filteredRoles.length <= 3) {
return filteredRoles;
}
return [...filteredRoles.slice(0, 3), '...'];
},
getList() {
let that = this;
uni.showLoading({
title: "加载中...",
});
that.G.Post('/yishoudan/agency/team/list', {}, (teamRes) => {
let currentChild = that.findChildById(teamRes.list, that.currentId);
that.teamList = currentChild ? (currentChild.childs || []) : [];
6 days ago
that.hideAddTeam = currentChild && currentChild.levels > 4;
6 days ago
that.G.Get(that.api.order_peopleList, {
pageSize: 500,
agencyTeamIds: that.currentId,
}, (res) => {
that.memberList = res.recordList || [];
that.memberList.forEach((item) => {
item.agencyRoleNameList = item.agencyRoleName.split("");
item.agencyRoleNameList = item.agencyRoleNameList.sort(that.compare);
});
uni.hideLoading();
});
});
},
editMember(_item) {
uni.navigateTo({
url: "/root/merchantManagement/addOrUpdataMember?info=" + JSON.stringify(_item),
});
6 days ago
},
goChildGroup(item) {
uni.setStorageSync("childGroup_childs", item.childs || []);
uni.navigateTo({
url: `/root/merchantManagement/childGroup?id=${item.id}&teamName=${encodeURIComponent(item.teamName)}&pId=${this.currentId}`,
});
},
goPage(url) {
uni.navigateTo({
url,
});
6 days ago
this.addMemberShow = false;
this.operateShow = false;
},
onOperate(type) {
this.operateShow = false;
if (type === 'editName') {
this.editNameValue = this.pageTitle;
this.editNameShow = true;
} else if (type === 'delete') {
this.deleteShow = true;
}
6 days ago
},
submitEditName() {
if (!this.editNameValue || !this.editNameValue.trim()) {
uni.showToast({
title: "请输入部门名称",
icon: "none",
});
return;
}
if (this.editNameLoading) return;
this.editNameLoading = true;
this.G.Post("/yishoudan/agency/team/update", {
teamName: this.editNameValue.trim(),
recordId: this.currentId,
parentId: this.currentParentId,
}, (res) => {
this.editNameLoading = false;
uni.showToast({
title: "修改成功",
icon: "success",
});
this.editNameShow = false;
this.pageTitle = this.editNameValue.trim();
uni.setNavigationBarTitle({
title: this.pageTitle,
});
6 days ago
this.getList();
6 days ago
}, (err) => {
this.editNameLoading = false;
});
},
submitDelete() {
if (this.deleteLoading) return;
this.deleteLoading = true;
6 days ago
this.G.Post(`/yishoudan/agency/team/del/${this.currentId}`, {}, (res) => {
6 days ago
this.deleteLoading = false;
uni.showToast({
title: "删除成功",
icon: "success",
});
uni.navigateBack();
}, (err) => {
this.deleteLoading = false;
});
},
6 days ago
submitAddTeam() {
if (!this.teamName || !this.teamName.trim()) {
uni.showToast({
title: "请输入子部门名称",
icon: "none",
});
return;
}
if (this.addTeamLoading) return;
this.addTeamLoading = true;
this.G.Post("/yishoudan/agency/team/add", {
teamName: this.teamName.trim(),
parentId: this.currentId,
}, (res) => {
this.addTeamLoading = false;
uni.showToast({
title: "添加成功",
icon: "success",
});
this.addTeamShow = false;
this.teamName = "";
this.getList();
}, (err) => {
this.addTeamLoading = false;
});
},
6 days ago
findChildById(list, id) {
for (let item of list) {
if (String(item.id) === String(id)) {
return item;
}
if (item.childs && item.childs.length > 0) {
let found = this.findChildById(item.childs, id);
if (found) return found;
}
}
return null;
},
},
};
</script>
<style lang="scss">
6 days ago
.creator {
color: #fff;
background-color: #ff4d4f;
zoom: 0.9;
line-height: 18px;
}
.member {
color: #fff;
background-color: rgba(0, 0, 0, 0.25);
zoom: 0.9;
line-height: 18px;
}
.manager {
background-color: rgba(0, 145, 255, 1);
color: #fff;
zoom: 0.9;
line-height: 18px;
}
6 days ago
</style>