421 lines
18 KiB
Vue
421 lines
18 KiB
Vue
<template>
|
|
<section class="content">
|
|
<div class="box box-primary">
|
|
<div class="box-body">
|
|
<!-- Content Header (Page header) -->
|
|
<section class="content-header">
|
|
<h1 id="itemTitle"></h1>
|
|
</section>
|
|
<div id="toolbar">
|
|
<div class="col-sm-12">
|
|
<label for="erbanNo" class="col-sm-4 control-label">用户ID:</label>
|
|
<div class="col-sm-8"><input type="text" class="form-control" name="erbanNo" id="erbanNo"
|
|
placeholder="输入用户ID"></div>
|
|
</div>
|
|
<div class="col-sm-12">
|
|
<button id="btnSearch" class="btn btn-default">
|
|
<i class="glyphicon glyphicon-search"></i>查询
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- .content -->
|
|
<div id="table"></div>
|
|
|
|
</div>
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<div class="modal fade" id="changeInviteModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
|
|
<div class="modal-dialog" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
|
|
aria-hidden="true">×</span>
|
|
</button>
|
|
<h4 class="modal-title" id="addTeamModalLabel">换绑邀请码</h4>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form class="form-horizontal" id="changeInviteForm">
|
|
<input type="hidden" name="uid" id="modal_uid" />
|
|
<div class="form-group">
|
|
<label for="query-groupSelector" class="col-sm-3 control-label">所属团队</label>
|
|
<div class="col-sm-9">
|
|
<select onchange="initTeamSelector(this.options[this.selectedIndex].value)"
|
|
id="query-groupSelector" class="form-control" data-btn-class="btn-warning">
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="query-teamSelector" class="col-sm-3 control-label">所属小组</label>
|
|
<div class="col-sm-9">
|
|
<select id="query-teamSelector"
|
|
onchange="initMemberSelector(this.options[this.selectedIndex].value)"
|
|
class="form-control" data-btn-class="btn-warning"></select>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="query-memberSelector" class="col-sm-3 control-label">成员名称</label>
|
|
<div class="col-sm-9">
|
|
<select id="query-memberSelector"
|
|
onchange="initInvitecodeSelector(this.options[this.selectedIndex].value)"
|
|
class="form-control" data-btn-class="btn-warning"></select>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="query-invitecodeSelector" class="col-sm-3 control-label">邀请码</label>
|
|
<div class="col-sm-9">
|
|
<select id="query-invitecodeSelector" class="form-control"
|
|
data-btn-class="btn-warning"></select>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
|
<button type="button" class="btn btn-primary" id="saveChange">确定</button>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import TableHelper from '@/utils/bootstrap-table-helper';
|
|
|
|
|
|
const TEAM_ROLE = {
|
|
"1": '组员',
|
|
"2": '组长',
|
|
"3": '团长',
|
|
};
|
|
let flowTeams;
|
|
let flowTeamsMap = {};
|
|
|
|
let flowGroups = [];
|
|
let flowGroupsMap = {};
|
|
let memberList = [];
|
|
let groupName = '';
|
|
export default {
|
|
name: "FlowTeamInvitecodeManageView",
|
|
setup() {
|
|
// 初始化小组选择器
|
|
function initTeamSelector(groupId) {
|
|
const options = [];
|
|
options.push('<option value="">选择小组</option>')
|
|
$.ajax({
|
|
type: "get",
|
|
url: "/admin/flowTeam/listTeamByGroupId",
|
|
data: {
|
|
groupId: groupId
|
|
},
|
|
dataType: "json",
|
|
success: function (json) {
|
|
if (json.success) {
|
|
for (let i = 0; i < json.data.length; i++) {
|
|
const flowTeam = json.data[i];
|
|
//拼接成多个<option><option/>
|
|
options.push('<option value="' + flowTeam.teamId + '">' + flowTeam.teamName + '</option>')
|
|
}
|
|
$('#query-teamSelector').html(options.join(' '));
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
// 初始化成员选择器
|
|
function initMemberSelector(teamId) {
|
|
const options = [];
|
|
options.push('<option value="">选择成员</option>')
|
|
$.ajax({
|
|
type: "get",
|
|
url: "/admin/flowTeam/listMember",
|
|
data: {
|
|
teamId: teamId
|
|
},
|
|
dataType: "json",
|
|
success: function (json) {
|
|
if (json.success) {
|
|
for (let i = 0; i < json.data.length; i++) {
|
|
const flowTeam = json.data[i];
|
|
//拼接成多个<option><option/>
|
|
options.push('<option value="' + flowTeam.memberId + '">' + flowTeam.memberName + '</option>')
|
|
}
|
|
$('#query-memberSelector').html(options.join(' '));
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
|
|
// 初始化邀请码选择器
|
|
function initInvitecodeSelector(memberId) {
|
|
const options = [];
|
|
options.push('<option value="">选择邀请码</option>')
|
|
$.ajax({
|
|
type: "get",
|
|
url: "/admin/flowTeam/listMemberInviteCode",
|
|
data: {
|
|
memberId: memberId
|
|
},
|
|
dataType: "json",
|
|
success: function (json) {
|
|
if (json.success) {
|
|
for (let i = 0; i < json.data.length; i++) {
|
|
const flowTeam = json.data[i];
|
|
//拼接成多个<option><option/>
|
|
options.push('<option >' + flowTeam.inviteCode + '</option>')
|
|
}
|
|
$('#query-invitecodeSelector').html(options.join(' '));
|
|
}
|
|
}
|
|
});
|
|
}
|
|
window.initTeamSelector = initTeamSelector;
|
|
window.initMemberSelector = initMemberSelector;
|
|
window.initInvitecodeSelector = initInvitecodeSelector;
|
|
return {
|
|
initTeamSelector,
|
|
initMemberSelector,
|
|
initInvitecodeSelector
|
|
};
|
|
},
|
|
created() {
|
|
this.$nextTick(function () {
|
|
this.initData();
|
|
});
|
|
},
|
|
methods: {
|
|
initData() {
|
|
// 加载流量团队配置
|
|
$.ajax({
|
|
type: "get",
|
|
url: "/admin/flowTeam/listTeam",
|
|
dataType: "json",
|
|
async: false,
|
|
success: function (json) {
|
|
if (json.success) {
|
|
if (json.data) {
|
|
flowTeams = json.data;
|
|
for (let i = 0; i < flowTeams.length; i++) {
|
|
const flowTeam = flowTeams[i];
|
|
flowTeamsMap[flowTeam.teamId] = flowTeam;
|
|
}
|
|
} else {
|
|
flowTeams = [];
|
|
flowTeamsMap = {};
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
// 加载流量团队配置
|
|
$.ajax({
|
|
type: "get",
|
|
url: "/admin/flowteam/group/listGroupByPage",
|
|
data: {
|
|
page: 1,
|
|
pageSize: 2147483647,
|
|
groupName: ''
|
|
},
|
|
dataType: "json",
|
|
async: false,
|
|
success: function (json) {
|
|
console.log("init group success", json);
|
|
flowGroups = json.rows;
|
|
if (flowGroups.length > 0) {
|
|
for (let i = 0; i < flowGroups.length; i++) {
|
|
const flowGroup = flowGroups[i];
|
|
flowGroupsMap[flowGroup.groupId] = flowGroup;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
initGroupSelector();
|
|
$(function () {
|
|
$('#table').bootstrapTable('destroy');
|
|
$('#table').bootstrapTable({
|
|
columns: [
|
|
{ field: 'uid', title: 'uid', align: 'center', visible: false, width: '5%' },
|
|
{ field: 'nick', title: '被邀请用户昵称', align: 'center', width: '5%' },
|
|
{ field: 'groupName', title: '所属团队', align: 'center', width: '5%' },
|
|
{ field: 'teamName', title: '所属小组', align: 'center', width: '5%', },
|
|
{ field: 'memberName', title: '所属成员', align: 'center', width: '5%' },
|
|
{ field: 'inviteCode', title: '所属邀请码', align: 'center', width: '5%' },
|
|
{
|
|
field: 'inviteTime', title: '邀请时间', align: 'center', width: '5%',
|
|
formatter: function (val) {
|
|
var date = new Date(val);
|
|
return date.format('yyyy-MM-dd hh:mm:ss');
|
|
}
|
|
},
|
|
{
|
|
field: 'source',
|
|
title: '邀请码填写类型',
|
|
align: 'center',
|
|
width: '5%',
|
|
formatter: function (val) {
|
|
let value = '';
|
|
if (val == 0) {
|
|
value = '自填';
|
|
} else if (val == 1) {
|
|
value = '补填';
|
|
}
|
|
return value;
|
|
}
|
|
},
|
|
{
|
|
field: 'memberId',
|
|
title: '操作',
|
|
align: 'center',
|
|
width: '10%',
|
|
formatter: function (val, row, index) {
|
|
return '<button id="btn-del" name="btnEdit" class="btn btn-sm btn-primary opt-del" data-idx=' + row.uid + '>' +
|
|
'<i class="glyphicon glyphicon-edit"></i>解绑</button>' +
|
|
'<button class="btn btn-sm btn-success opt-change" data-idx=' + row.uid + '>' +
|
|
'<i class="glyphicon glyphicon-edit"></i>换绑</button>';
|
|
}
|
|
}
|
|
],
|
|
undefinedText: 0,
|
|
cache: false,
|
|
striped: true,
|
|
showRefresh: false,
|
|
pageSize: 20,
|
|
pagination: true,
|
|
pageList: [20, 50, 100, 200, 300, 500],
|
|
search: false,
|
|
sidePagination: "server", //表示服务端请求
|
|
queryParamsType: "undefined",
|
|
queryParams: function queryParams(params) { //设置查询参数
|
|
var param = {
|
|
page: params.pageNumber,
|
|
pageSize: params.pageSize,
|
|
erbanNo: $('#erbanNo').val(),
|
|
};
|
|
return param;
|
|
},
|
|
toolbar: '#toolbar',
|
|
url: '/admin/flowteam/group/listFlowTeamInfoWithUser',
|
|
onLoadSuccess: function (data) { //加载成功时执行
|
|
console.log("load success", data);
|
|
},
|
|
onLoadError: function () { //加载失败时执行
|
|
console.log("load fail");
|
|
}
|
|
});
|
|
|
|
// 查询刷新
|
|
$('#btnSearch').on('click', function () {
|
|
TableHelper.doRefresh('#table');
|
|
});
|
|
|
|
//新建标签
|
|
$("#addBtn").click(function () {
|
|
$('#groupId').val(''),
|
|
$('#modal_groupName').val(''),
|
|
$("#addGroupModal").modal('show');
|
|
});
|
|
|
|
// 换绑
|
|
$('#table').on('click', '.opt-change', function () {
|
|
const uid = $(this).attr('data-idx');
|
|
$('#modal_uid').val(uid);
|
|
$('#query-groupSelector').val('');
|
|
$('#query-teamSelector').val('');
|
|
$('#query-memberSelector').val('');
|
|
$('#query-invitecodeSelector').val('');
|
|
$("#changeInviteModal").modal('show');
|
|
});
|
|
|
|
$('#saveChange').click(function () {
|
|
const requestParam = {
|
|
uid: $('#modal_uid').val(),
|
|
groupId: $('#query-groupSelector').val(),
|
|
teamId: $('#query-teamSelector').val(),
|
|
memberId: $('#query-memberSelector').val(),
|
|
inviteCode: $('#query-invitecodeSelector').val(),
|
|
optType: 1
|
|
};
|
|
console.log('requestParam', JSON.stringify(requestParam))
|
|
$.ajax({
|
|
type: "post",
|
|
url: "/admin/flowteam/group/updateFlowTeamInviteInfo",
|
|
data: JSON.stringify(requestParam),
|
|
dataType: "json",
|
|
contentType: 'application/json',
|
|
success: function (json) {
|
|
if (json.success) {
|
|
$("#tipMsg").text("换绑成功");
|
|
$("#tipModal").modal('show');
|
|
$("#changeInviteModal").modal('hide');
|
|
TableHelper.doRefresh("#table");
|
|
} else {
|
|
$("#tipMsg").text("换绑失败." + json.message);
|
|
$("#tipModal").modal('show');
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
// 解绑
|
|
$('#table').on('click', '.opt-del', function () {
|
|
const uid = $(this).attr('data-idx');
|
|
if (confirm('确认要解绑该邀请码吗?(注:该操作不可恢复!!)')) {
|
|
const requestParam = {
|
|
uid: uid,
|
|
optType: 2,
|
|
};
|
|
$.ajax({
|
|
type: "post",
|
|
url: "/admin/flowteam/group/updateFlowTeamInviteInfo",
|
|
data: JSON.stringify(requestParam),
|
|
dataType: "json",
|
|
contentType: 'application/json',
|
|
success: function (json) {
|
|
if (json.success) {
|
|
$("#tipMsg").text("换绑成功");
|
|
$("#tipModal").modal('show');
|
|
TableHelper.doRefresh("#table");
|
|
} else {
|
|
$("#tipMsg").text("换绑失败." + json.message);
|
|
$("#tipModal").modal('show');
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
},
|
|
|
|
};
|
|
|
|
// 初始化团队选择器
|
|
function initGroupSelector() {
|
|
const options = [];
|
|
options.push('<option value="">选择团队</option>')
|
|
for (var i = 0; i < flowGroups.length; i++) {
|
|
var item = flowGroups[i];
|
|
//拼接成多个<option><option/>
|
|
options.push('<option value="' + item.groupId + '">' + item.groupName + '</option>')
|
|
}
|
|
$("#query-groupSelector").html(options.join(' '));
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
#teamInfoModal .modal-dialog {
|
|
width: 60%;
|
|
height: 50%;
|
|
}
|
|
</style> |