855 lines
47 KiB
Vue
855 lines
47 KiB
Vue
<template>
|
||
<section class="content">
|
||
<div class="box box-primary">
|
||
<div class="box-body">
|
||
<section class="content-header">
|
||
<h1 id="itemTitle"></h1>
|
||
</section>
|
||
<div id="toolbar">
|
||
<div class="col-sm-12">
|
||
|
||
<label for="erbanNo" class="col-sm-1 control-label">创始人ID:</label>
|
||
<div class="col-sm-2"><input type="text" class="col-sm-2 form-control" name="erbanNo" id="erbanNo"
|
||
placeholder="请输入创始人ID"></div>
|
||
|
||
<label for="status" class="col-sm-1 control-label">状态:</label>
|
||
<select name="status" id="status" class="col-sm-1">
|
||
<option value="0">已解散</option>
|
||
<option value="1" selected="selected">有效</option>
|
||
</select>
|
||
|
||
<label for="createTimeStart" class="col-sm-1 control-label">创建时间:</label>
|
||
<div class="col-sm-2"><input type="text" class="input-sm" name="createTimeStart"
|
||
id="createTimeStart"></div>
|
||
<label for="createTimeEnd" class="col-sm-1 control-label">至:</label>
|
||
<div class="col-sm-2"><input type="text" class="input-sm" name="createTimeEnd" id="createTimeEnd">
|
||
</div>
|
||
</div>
|
||
<div class="col-sm-12">
|
||
<label for="worldNumStart" class="col-sm-1 control-label">人数:</label>
|
||
<div class="col-sm-2"><input type="text" class="col-sm-1 form-control" name="worldNumStart"
|
||
id="worldNumStart" placeholder="请输入人数"></div>
|
||
<label for="worldNumEnd" class="col-sm-1 control-label">至:</label>
|
||
<div class="col-sm-2"><input type="text" class="col-sm-1 form-control" name="worldNumEnd"
|
||
id="worldNumEnd" placeholder="请输入人数"></div>
|
||
|
||
<label for="typeId" class="col-sm-1 control-label">分类:</label>
|
||
<select name="typeId" id="typeId" class="col-sm-1">
|
||
<option value="">全部</option>
|
||
</select>
|
||
|
||
<label for="recommendStatus" class="col-sm-1 control-label">推荐状态:</label>
|
||
<select name="recommendStatus" id="recommendStatus" class="col-sm-1">
|
||
<option value="-1" selected="selected">全部</option>
|
||
<option value="0">未推荐</option>
|
||
<option value="1">推荐中</option>
|
||
<option value="2">待推荐</option>
|
||
</select>
|
||
</div>
|
||
<div class="col-sm-12">
|
||
<button class="btn btn-default" id="search">
|
||
<i class="glyphicon glyphicon-wrench"></i>查询
|
||
</button>
|
||
<button class="btn btn-primary" id="add">
|
||
<i class="glyphicon glyphicon-plus"></i>增加
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- .content -->
|
||
<div id="table"></div>
|
||
</div>
|
||
</section>
|
||
|
||
<!-- 弹窗 -->
|
||
<div class="modal fade" id="worldModal" rabindex='-1' role="dialog" aria-labelledby="modalLabel">
|
||
<div class="modal-dialog" role="document">
|
||
<div class="modal-content">
|
||
|
||
<div class="modal-header">
|
||
<button class="close" type="button" data-dismiss="modal" aria-label="Close">
|
||
<span aria-hidden="true">x</span>
|
||
</button>
|
||
|
||
<div class="modal-title" id="worldModalLabel"></div>
|
||
</div>
|
||
|
||
<div class="modal-body">
|
||
<form action="" id="addForm" class="form-horizontal">
|
||
<input type="hidden" id="modal_id" name="id" />
|
||
<div class="form-group">
|
||
<label for="modal_name" class="col-sm-3 control-label">标题:</label>
|
||
<div class="col-sm-8">
|
||
<input type="text" class="form-control validate[required,maxSize[7]]" name="name"
|
||
id="modal_name" placeholder="请输入内容,限定7个字符内">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="ar_modal_name" class="col-sm-3 control-label">阿语标题:</label>
|
||
<div class="col-sm-8">
|
||
<input type="text" class="form-control validate[required,maxSize[7]]" name="name" id="ar_modal_name" placeholder="请输入内容,限定7个字符内">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="en_modal_name" class="col-sm-3 control-label">英语标题:</label>
|
||
<div class="col-sm-8">
|
||
<input type="text" class="form-control validate[required,maxSize[7]]" name="name" id="en_modal_name" placeholder="请输入内容,限定7个字符内">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="modal_description" class="col-sm-3 control-label">描述:</label>
|
||
<div class="col-sm-8">
|
||
<textarea rows="3" cols="20" class="form-control validate[maxSize[100]]" name="description"
|
||
id="modal_description"
|
||
placeholder="不填写则使用默认描述[最優話題,最熱時事,盡在話題!快與兔友們分享身邊有趣的靈魂吧~],限定100个字符内"></textarea>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="ar_modal_description" class="col-sm-3 control-label">阿语描述:</label>
|
||
<div class="col-sm-8">
|
||
<textarea rows="3" cols="20" class="form-control validate[maxSize[100]]" name="description" id="ar_modal_description"
|
||
placeholder="不填写则使用默认描述[最優話題,最熱時事,盡在話題!快與兔友們分享身邊有趣的靈魂吧~],限定100个字符内"></textarea>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="en_modal_description" class="col-sm-3 control-label">英语描述:</label>
|
||
<div class="col-sm-8">
|
||
<textarea rows="3" cols="20" class="form-control validate[maxSize[100]]" name="description" id="en_modal_description"
|
||
placeholder="不填写则使用默认描述[最優話題,最熱時事,盡在話題!快與兔友們分享身邊有趣的靈魂吧~],限定100个字符内"></textarea>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="modal_notice" class="col-sm-3 control-label">公告:</label>
|
||
<div class="col-sm-8">
|
||
<textarea rows="3" cols="20" class="form-control validate[maxSize[500]]" name="notice"
|
||
id="modal_notice" placeholder="非必填,限定500个字符内"></textarea>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="ar_modal_notice" class="col-sm-3 control-label">阿语公告:</label>
|
||
<div class="col-sm-8">
|
||
<textarea rows="3" cols="20" class="form-control validate[maxSize[500]]" name="notice" id="ar_modal_notice"
|
||
placeholder="非必填,限定500个字符内"></textarea>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="en_modal_notice" class="col-sm-3 control-label">英语公告:</label>
|
||
<div class="col-sm-8">
|
||
<textarea rows="3" cols="20" class="form-control validate[maxSize[500]]" name="notice" id="en_modal_notice"
|
||
placeholder="非必填,限定500个字符内"></textarea>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="modal_worldTypeId" class="col-sm-3 control-label">话题分类:</label>
|
||
<div class="col-sm-8">
|
||
<select id="modal_worldTypeId" name="worldTypeId" class="form-control validate[required]">
|
||
<option value="">请选择...</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="modal_ownerErbanNo" class="col-sm-3 control-label">创始人ID:</label>
|
||
<div class="col-sm-8">
|
||
<input type="text" class="form-control validate[required,integer]" name="ownerErbanNo"
|
||
id="modal_ownerErbanNo" placeholder="请输入创始人平台号">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-3 control-label">头像:</label>
|
||
<div class="col-sm-8">
|
||
<img src="" alt="" id="modal_icon" style="width: 50px; height: 50px;">
|
||
<input type="file" id="uploadFile" name="uploadFile" accept="image/*">
|
||
<button class="btn btn-success" type="button" id="uploadBtn">上传</button>
|
||
<div class="tips">
|
||
<font color="red">请上传图片文件</font>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-3 control-label">标签:</label>
|
||
<div class="col-sm-8">
|
||
<input type="checkbox" id="modal_worldTag_1" name="worldTag" value="1" />最新
|
||
<input type="checkbox" id="modal_worldTag_2" name="worldTag" value="2" />最热
|
||
<input type="checkbox" id="modal_worldTag_3" name="worldTag" value="3" />官方
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="modal_seqNo" class="col-sm-3 control-label">排序:</label>
|
||
<div class="col-sm-8">
|
||
<input type="text" class="form-control validate[custom[integer]]" name="seqNo"
|
||
id="modal_seqNo" value="100" placeholder="请输入排序编号,升序排序,默认值:100">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-3 control-label">是否推荐:</label>
|
||
<div class="col-sm-8">
|
||
<div>
|
||
<input type="radio" name="recommend" value="0">不推荐
|
||
</div>
|
||
<div>
|
||
<input type="radio" name="recommend" value="1">推荐:
|
||
<input type="text" class="input-sm" name="startTime" id="modal_startTime" size="16">
|
||
<label>至</label>
|
||
<input type="text" class="input-sm" name="endTime" id="modal_endTime" size="16">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-3 control-label">权限:</label>
|
||
<div class="col-sm-8">
|
||
<input type="radio" name="agreeFlag" value="true" />申请同意后
|
||
<input type="radio" name="agreeFlag" value="false" />所有人可进
|
||
</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" data-primary="addSave" id="save">保存</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import TableHelper from '@/utils/bootstrap-table-helper';
|
||
|
||
|
||
var worldTags = {
|
||
"1": "最新",
|
||
"2": "最热",
|
||
"3": "官方"
|
||
};
|
||
export default {
|
||
name: "WorldAdminView",
|
||
setup() {
|
||
return {};
|
||
},
|
||
created() {
|
||
this.$nextTick(function () {
|
||
this.initData();
|
||
});
|
||
},
|
||
methods: {
|
||
initData() {
|
||
|
||
$(function () {
|
||
$('#table').bootstrapTable('destroy');
|
||
$('#table').bootstrapTable({
|
||
columns: [
|
||
{ field: 'id', title: 'ID', align: 'center', valign: 'middle', width: '10%' },
|
||
{field: 'name.zh', title: '名称', align: 'left', valign: 'middle', width: '10%'},
|
||
{field: 'name.ar', title: '阿语名称', align: 'left', valign: 'middle', width: '10%'},
|
||
{field: 'name.en', title: '英语名称', align: 'left', valign: 'middle', width: '10%'},
|
||
{
|
||
field: 'icon', title: '头像', align: 'left', valign: 'middle', width: '10%',
|
||
formatter: function (val, row, index) {
|
||
if (null != val && val != '') {
|
||
return '<img src="' + val + '" alt="" style="width: 30px; height: 30px;">';
|
||
}
|
||
return '-';
|
||
}
|
||
},
|
||
{field: 'description.zh', title: '描述', align: 'left', valign: 'middle', width: '10%'},
|
||
{field: 'description.ar', title: '阿语描述', align: 'left', valign: 'middle', width: '10%'},
|
||
{field: 'description.en', title: '英语描述', align: 'left', valign: 'middle', width: '10%'},
|
||
{field: 'notice.zh', title: '公告', align: 'left', valign: 'middle', width: '10%', formatter: function(val, row, index) {
|
||
if(val && val.length > 50) {
|
||
return val.substring(0, 50) + '...<a class="pop" data-toggle="popover" data-container="body" data-placement="top" title="公告" data-content="'+val+'">更多>></a>';
|
||
}
|
||
return val;
|
||
}},
|
||
{field: 'notice.ar', title: '阿语公告', align: 'left', valign: 'middle', width: '10%', formatter: function(val, row, index) {
|
||
if(val && val.length > 50) {
|
||
return val.substring(0, 50) + '...<a class="pop" data-toggle="popover" data-container="body" data-placement="top" title="阿语公告" data-content="'+val+'">更多>></a>';
|
||
}
|
||
return val;
|
||
}},
|
||
{field: 'notice.en', title: '英语公告', align: 'left', valign: 'middle', width: '10%', formatter: function(val, row, index) {
|
||
if(val && val.length > 50) {
|
||
return val.substring(0, 50) + '...<a class="pop" data-toggle="popover" data-container="body" data-placement="top" title="英语公告" data-content="'+val+'">更多>></a>';
|
||
}
|
||
return val;
|
||
}},
|
||
{ field: 'ownerErbanNo', title: '创始人', align: 'left', valign: 'middle', width: '10%' },
|
||
{ field: 'memberNum', title: '人数', align: 'left', valign: 'middle', width: '10%' },
|
||
{
|
||
field: 'recommendStatus', title: '推荐状态', align: 'left', valign: 'middle', width: '10%',
|
||
formatter: function (val, row, index) {
|
||
if ((null == row.startTime || row.startTime == '')
|
||
&& (null == row.endTime || row.getTime == '')) {
|
||
return '未推荐';
|
||
}
|
||
var startTime = new Date(row.startTime).format('yyyy-MM-dd hh:mm');
|
||
var endTime = new Date(row.endTime).format('yyyy-MM-dd hh:mm');
|
||
var date = new Date().getTime();
|
||
if (date >= row.startTime && date < row.endTime) {
|
||
return '<a data-toggle="tooltip" data-placement="bottom" title="' + startTime + '~' + endTime + '">推荐中</a>';
|
||
} else if (date < row.startTime) {
|
||
return '<a data-toggle="tooltip" data-placement="bottom" title="' + startTime + '~' + endTime + '">待推荐</a>';
|
||
} else {
|
||
return '未推荐';
|
||
}
|
||
}
|
||
},
|
||
{ field: 'typeName', title: '分类', align: 'left', valign: 'middle', width: '10%' },
|
||
{
|
||
field: 'worldTag', title: '标签', align: 'left', valign: 'middle', width: '10%',
|
||
formatter: function (val, row, index) {
|
||
if (null != val && val != '') {
|
||
var tagArray = val.split(",");
|
||
var content = '';
|
||
for (var i = 0; i < tagArray.length; i++) {
|
||
var tagIndex = tagArray[i].trim();
|
||
if (tagIndex == null || tagIndex == '') {
|
||
continue;
|
||
}
|
||
content += worldTags[tagIndex] + ",";
|
||
}
|
||
if (content != '') {
|
||
content = content.substr(0, content.length - 1);
|
||
}
|
||
return content;
|
||
}
|
||
}
|
||
},
|
||
{ field: 'seqNo', title: '排序', align: 'center', valign: 'middle', width: '10%' },
|
||
{
|
||
field: 'agreeFlag', title: '权限', align: 'center', valign: 'middle', width: '10%',
|
||
formatter: function (val, row, index) {
|
||
if (val) {
|
||
return '申请同意后';
|
||
} else {
|
||
return '所有人可进';
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'createTime', title: '创建时间', align: 'center', valign: 'middle', width: '20%', formatter: function (val, row, index) {
|
||
if (val) {
|
||
var date = new Date(val);
|
||
return date.format('yyyy-MM-dd hh:mm:ss');
|
||
} else {
|
||
return '-';
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'status', title: '状态', align: 'center', valign: 'middle', width: '10%', formatter: function (val, row, index) {
|
||
if (val == 0) {
|
||
return '已删除';
|
||
} else if (val == 1) {
|
||
return '有效';
|
||
} else if (val == 2) {
|
||
return '无效';
|
||
} else {
|
||
return val;
|
||
}
|
||
}
|
||
},
|
||
{ field: 'createBy', title: '创建人', align: 'center', valign: 'middle', width: '20%' },
|
||
{
|
||
field: 'tmp', title: '操作', align: 'center', valign: 'middle', width: '20%', formatter: function (val, row, index) {
|
||
var str = '';
|
||
if (row.status != 0) {
|
||
str += '<button class="btn btn-primary btn-sm opt-edit" data-id="' + row.id + '">编辑</button> '
|
||
str += '<button class="btn btn-danger btn-sm opt-remove" data-id="' + row.id + '">删除</button> ';
|
||
}
|
||
return str;
|
||
}
|
||
}
|
||
],
|
||
cache: false,
|
||
striped: true,
|
||
showRefresh: false,
|
||
pageSize: 10,
|
||
pagination: true,
|
||
pageList: [10, 20, 30, 50],
|
||
sidePagination: 'server',
|
||
queryParamsType: 'undefined',
|
||
queryParams: function queryParams(params) {
|
||
var status = $('#status').val();
|
||
if (null == status || status == '') {
|
||
status = 1;
|
||
}
|
||
var erbanNo = $('#erbanNo').val();
|
||
var createTimeStart = $('#createTimeStart').val();
|
||
var createTimeEnd = $('#createTimeEnd').val();
|
||
var worldNumStart = $('#worldNumStart').val();
|
||
var worldNumEnd = $('#worldNumEnd').val();
|
||
var recommendStatus = $('#recommendStatus').val();
|
||
var typeId = $('#typeId').val();
|
||
var param = {
|
||
pageSize: params.pageSize,
|
||
pageNumber: params.pageNumber,
|
||
status: status,
|
||
erbanNo: erbanNo,
|
||
createTimeStart: createTimeStart,
|
||
createTimeEnd: createTimeEnd,
|
||
worldNumStart: worldNumStart,
|
||
worldNumEnd: worldNumEnd,
|
||
recommendStatus: recommendStatus,
|
||
typeId: typeId
|
||
};
|
||
return param;
|
||
},
|
||
uniqueId: 'id',
|
||
ajax:function(request){ //使用ajax请求
|
||
$.ajax({
|
||
type:"GET",
|
||
url:'/admin/world/list',
|
||
contentType:'application/json;charset=utf-8',
|
||
dataType:'json',
|
||
data: request.data,
|
||
success:function (res) {
|
||
console.log(res);
|
||
request.success({
|
||
"rows": res.rows.map(i=>{
|
||
let name = i.name;
|
||
if (name) {
|
||
if (name.startsWith('{') && name.endsWith('}')) {
|
||
i.name = JSON.parse(i.name);
|
||
} else {
|
||
i.name = {
|
||
zh: i.name,
|
||
ar: i.name,
|
||
en: i.name,
|
||
};
|
||
}
|
||
}
|
||
let description = i.description;
|
||
if (description) {
|
||
if (description.startsWith('{') && description.endsWith('}')) {
|
||
i.description = JSON.parse(i.description);
|
||
} else {
|
||
i.description = {
|
||
zh: i.description,
|
||
ar: i.description,
|
||
en: i.description,
|
||
};
|
||
}
|
||
}
|
||
let notice = i.notice;
|
||
if (notice) {
|
||
if (notice.startsWith('{') && notice.endsWith('}')) {
|
||
i.notice = JSON.parse(i.notice);
|
||
} else {
|
||
i.notice = {
|
||
zh: i.notice,
|
||
ar: i.notice,
|
||
en: i.notice,
|
||
};
|
||
}
|
||
}
|
||
return i;
|
||
}),
|
||
"total": res.total
|
||
});
|
||
},
|
||
error:function(error){
|
||
console.log(error);
|
||
}
|
||
})
|
||
},
|
||
toolbar: '#toolbar',
|
||
// url: '/admin/world/list',
|
||
onLoadSuccess: function () {
|
||
$('[data-toggle="tooltip"]').tooltip();
|
||
$('[data-toggle="popover"]').popover();
|
||
console.log('load success');
|
||
},
|
||
onLoadError: function () {
|
||
console.log('load fail');
|
||
}
|
||
});
|
||
|
||
//点击页面空白处理,关闭popover
|
||
$('body').click(function (event) {
|
||
var target = $(event.target); // 判断自己当前点击的内容
|
||
if (!target.hasClass('popover')
|
||
&& !target.hasClass('pop')
|
||
&& !target.hasClass('popover-content')
|
||
&& !target.hasClass('popover-title')
|
||
&& !target.hasClass('arrow')) {
|
||
$('.pop').popover('hide'); // 当点击body的非弹出框相关的内容的时候,关闭所有popover
|
||
}
|
||
});
|
||
|
||
$.ajax({
|
||
type: 'get',
|
||
url: "/admin/world/type/list",
|
||
data: {
|
||
status: 1,
|
||
pageNumber: 1,
|
||
pageSize: 1000
|
||
},
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (json.total > 0) {
|
||
$('#typeId').empty();
|
||
$('#typeId').append('<option value="">全部</option>');
|
||
var rows = json.rows;
|
||
for (var i = 0; i < rows.length; i++) {
|
||
$('#typeId').append('<option value="' + rows[i].id + '">' + rows[i].typeName + '</option>');
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
// 编辑按钮点击事件
|
||
$('#table').on('click', '.opt-edit', function () {
|
||
clearModal();
|
||
var id = $(this).data('id');
|
||
$.ajax({
|
||
type: "get",
|
||
url: "/admin/world/getById",
|
||
data: { id: id },
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (json && json.code == 200) {
|
||
var data = json.data;
|
||
$('#modal_id').val(data.id);
|
||
//推荐与不推荐
|
||
var val = 0;
|
||
var date = new Date().getTime();
|
||
if (data.startTime != null && data.endTime != null
|
||
&& ((date > data.startTime && date < data.endTime) || date < data.startTime)) {
|
||
val = 1;
|
||
}
|
||
$('input[type="radio"][name="recommend"][value=' + val + ']').prop("checked", true);
|
||
if (val == 1) {
|
||
if (null != data.startTime) {
|
||
$('#modal_startTime').val(new Date(data.startTime).format('yyyy-MM-dd hh:mm:ss'));
|
||
}
|
||
if (null != data.endTime) {
|
||
$('#modal_endTime').val(new Date(data.endTime).format('yyyy-MM-dd hh:mm:ss'));
|
||
}
|
||
}
|
||
let name = data.name;
|
||
if (name.startsWith('{') && name.endsWith('}')) {
|
||
var jsonName = JSON.parse(data.name);
|
||
$("#modal_name").val(jsonName.zh);
|
||
// 阿语名称
|
||
$("#ar_modal_name").val(jsonName.ar);
|
||
// 英语名称
|
||
$("#en_modal_name").val(jsonName.en);
|
||
} else {
|
||
$("#modal_name").val(name);
|
||
// 阿语名称
|
||
$("#ar_modal_name").val(name);
|
||
// 英语名称
|
||
$("#en_modal_name").val(name);
|
||
}
|
||
let description = data.description;
|
||
if (description.startsWith('{') && description.endsWith('}')) {
|
||
var jsonDescription = JSON.parse(data.description);
|
||
$("#modal_description").val(jsonDescription.zh);
|
||
// 阿语描述
|
||
$("#ar_modal_description").val(jsonDescription.ar);
|
||
// 英语描述
|
||
$("#en_modal_description").val(jsonDescription.en);
|
||
} else {
|
||
$("#modal_description").val(description);
|
||
// 阿语描述
|
||
$("#ar_modal_description").val(description);
|
||
// 英语描述
|
||
$("#en_modal_description").val(description);
|
||
}
|
||
let notice = data.notice;
|
||
if (notice.startsWith('{') && notice.endsWith('}')) {
|
||
var jsonNotice = JSON.parse(data.notice);
|
||
console.log(jsonNotice)
|
||
$("#modal_notice").val(jsonNotice.zh);
|
||
// 阿语名称
|
||
$("#ar_modal_notice").val(jsonNotice.ar);
|
||
// 英语名称
|
||
$("#en_modal_notice").val(jsonNotice.en);
|
||
} else {
|
||
$("#modal_notice").val(notice);
|
||
// 阿语名称
|
||
$("#ar_modal_notice").val(notice);
|
||
// 英语名称
|
||
$("#en_modal_notice").val(notice);
|
||
}
|
||
|
||
//分类
|
||
$.ajax({
|
||
type: 'get',
|
||
url: "/admin/world/type/list",
|
||
data: {
|
||
status: 1,
|
||
pageNumber: 1,
|
||
pageSize: 1000
|
||
},
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (json.total > 0) {
|
||
$('#modal_worldTypeId').empty();
|
||
$('#modal_worldTypeId').append('<option value="">请选择...</option>');
|
||
var rows = json.rows;
|
||
for (var i = 0; i < rows.length; i++) {
|
||
if (rows[i].id == data.worldTypeId) {
|
||
$('#modal_worldTypeId').append('<option value="' + rows[i].id + '" selected="selected">' + rows[i].typeName + '</option>');
|
||
} else {
|
||
$('#modal_worldTypeId').append('<option value="' + rows[i].id + '">' + rows[i].typeName + '</option>');
|
||
}
|
||
}
|
||
}
|
||
}
|
||
});
|
||
$('#modal_ownerErbanNo').val(data.ownerErbanNo);
|
||
$('#modal_icon').attr('src', data.icon);
|
||
//标签
|
||
var worldTag = data.worldTag;
|
||
if (null != worldTag) {
|
||
var tags = worldTag.split(",");
|
||
for (var i = 0; i < tags.length; i++) {
|
||
if (tags[i] == null || tags[i] == '') {
|
||
continue;
|
||
}
|
||
$('#modal_worldTag_' + tags[i]).prop("checked", true);
|
||
}
|
||
}
|
||
$('input[type="radio"][name="agreeFlag"][value=' + data.agreeFlag + ']').prop("checked", true);
|
||
$('#modal_seqNo').val(data.seqNo);
|
||
}
|
||
}
|
||
});
|
||
$('#worldModalLabel').text('编辑世界');
|
||
$('#worldModal').modal('show');
|
||
});
|
||
|
||
$("#table").on("click", '.opt-remove', function () {
|
||
var id = $(this).attr("data-id");
|
||
if (id == 'undefined') {
|
||
$("#tipMsg").text("id参数有误");
|
||
$("#tipModal").modal('show');
|
||
return;
|
||
}
|
||
if (confirm("你确认删除该记录吗? \r\n 删除后再也不能找回,请谨慎操作!")) {
|
||
$.ajax({
|
||
type: 'post',
|
||
url: "/admin/world/delete",
|
||
data: { id: id },
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (json.code == 200) {
|
||
$("#tipMsg").text("删除成功");
|
||
$("#tipModal").modal('show');
|
||
TableHelper.doRefresh("#table");
|
||
} else {
|
||
$("#tipMsg").text(json.message);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
}
|
||
});
|
||
}
|
||
});
|
||
|
||
// 添加事件
|
||
$('#add').on('click', function () {
|
||
clearModal();
|
||
$('#worldModalLabel').text('新增世界');
|
||
$.ajax({
|
||
type: 'get',
|
||
url: "/admin/world/type/list",
|
||
data: {
|
||
status: 1,
|
||
pageNumber: 1,
|
||
pageSize: 1000
|
||
},
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (json.total > 0) {
|
||
$('#modal_worldTypeId').empty();
|
||
$('#modal_worldTypeId').append('<option value="">请选择...</option>');
|
||
var rows = json.rows;
|
||
for (var i = 0; i < rows.length; i++) {
|
||
$('#modal_worldTypeId').append('<option value="' + rows[i].id + '">' + rows[i].typeName + '</option>');
|
||
}
|
||
}
|
||
}
|
||
});
|
||
$('#worldModal').modal('show');
|
||
});
|
||
|
||
// 保存
|
||
$('#save').on('click', function () {
|
||
if ($('#addForm').validationEngine('validate')) {
|
||
var param = {};
|
||
param.id = $('#modal_id').val();
|
||
//图片
|
||
var icon = $('#modal_icon').attr('src');
|
||
if (icon == null || icon.trim() == '') {
|
||
$('#tipMsg').text('失败,头像不能为空');
|
||
$('#tipModal').modal('show');
|
||
return;
|
||
}
|
||
param.icon = icon;
|
||
//权限
|
||
var agreeFlag = $("input[name='agreeFlag']:checked").val();
|
||
if (agreeFlag == null || agreeFlag.trim() == '') {
|
||
$('#tipMsg').text('失败,权限未设置');
|
||
$('#tipModal').modal('show');
|
||
return;
|
||
}
|
||
param.agreeFlag = agreeFlag;
|
||
//是否推荐
|
||
var recommend = $("input[type='radio'][name='recommend']:checked").val();
|
||
if (recommend == null || recommend.trim() == '') {
|
||
$('#tipMsg').text('失败,推荐状态未设置');
|
||
$('#tipModal').modal('show');
|
||
return;
|
||
}
|
||
if (recommend == 1) {
|
||
var startTime = $('#modal_startTime').val();
|
||
var endTime = $('#modal_endTime').val();
|
||
if (startTime == '') {
|
||
$('#tipMsg').text('失败,推荐开始时间不能为空');
|
||
$('#tipModal').modal('show');
|
||
return;
|
||
}
|
||
if (endTime == '') {
|
||
$('#tipMsg').text('失败,推荐结束时间不能为空');
|
||
$('#tipModal').modal('show');
|
||
return;
|
||
}
|
||
if (startTime != '' && endTime != '' && startTime > endTime) {
|
||
$('#tipMsg').text('失败,推荐开始时间不能大于推荐结束时间');
|
||
$('#tipModal').modal('show');
|
||
return;
|
||
}
|
||
param.startTime = startTime;
|
||
param.endTime = endTime;
|
||
}
|
||
param.recommend = recommend;
|
||
param.id = $('#modal_id').val();
|
||
|
||
var name = $("#modal_name").val();
|
||
// 阿语名称
|
||
var ar_name = $("#ar_modal_name").val();
|
||
// 英语名称
|
||
var en_name = $("#en_modal_name").val();
|
||
// 国际化字段
|
||
var jsonName = {"zh":name,"ar":ar_name,"en":en_name}
|
||
const nameValue = JSON.stringify(jsonName);
|
||
param.name=nameValue;
|
||
|
||
var description = $("#modal_description").val();
|
||
// 阿语描述
|
||
var ar_description = $("#ar_modal_description").val();
|
||
// 英语描述
|
||
var en_description = $("#en_modal_description").val();
|
||
// 国际化描述
|
||
var jsonDescription = {"zh":description,"ar":ar_description,"en":en_description}
|
||
const descriptionValue = JSON.stringify(jsonDescription);
|
||
param.description=descriptionValue;
|
||
|
||
var notice = $("#modal_notice").val();
|
||
// 阿语描述
|
||
var ar_notice = $("#ar_modal_notice").val();
|
||
// 英语描述
|
||
var en_notice = $("#en_modal_notice").val();
|
||
// 国际化描述
|
||
var jsonNotice = {"zh":notice,"ar":ar_notice,"en":en_notice}
|
||
const noticeValue = JSON.stringify(jsonNotice);
|
||
param.notice=noticeValue;
|
||
param.worldTypeId = $('#modal_worldTypeId').val();
|
||
param.ownerErbanNo = $('#modal_ownerErbanNo').val();
|
||
//标签
|
||
var worldTag = [];
|
||
$("#addForm").find('input[name="worldTag"]:checked').each(function () {
|
||
worldTag.push($(this).val());
|
||
});
|
||
param.worldTag = "," + worldTag.join(",") + ",";
|
||
//排序值
|
||
var seqNo = $('#modal_seqNo').val();
|
||
if (seqNo.trim() == '') {
|
||
seqNo = 100;
|
||
}
|
||
param.seqNo = seqNo;
|
||
$.ajax({
|
||
type: 'post',
|
||
url: '/admin/world/save',
|
||
data: param,
|
||
dataType: 'json',
|
||
success: function (res) {
|
||
if (res.code == 200) {
|
||
$('#worldModal').modal('hide');
|
||
$('#tipMsg').text('保存成功');
|
||
$('#tipModal').modal('show');
|
||
TableHelper.doRefresh('#table')
|
||
} else {
|
||
$('#tipMsg').text('保存失败,错误码:' + res.message);
|
||
$('#tipModal').modal('show');
|
||
}
|
||
}
|
||
})
|
||
}
|
||
});
|
||
|
||
$("#search").on('click', function () {
|
||
TableHelper.doRefresh('#table');
|
||
});
|
||
|
||
$('#modal_startTime').datetimepicker({
|
||
format: 'yyyy-mm-dd hh:ii:00',
|
||
autoclose: true
|
||
});
|
||
|
||
$('#modal_endTime').datetimepicker({
|
||
format: 'yyyy-mm-dd hh:ii:00',
|
||
autoclose: true
|
||
});
|
||
|
||
$('#createTimeStart').datetimepicker({
|
||
format: 'yyyy-mm-dd hh:ii:00',
|
||
autoclose: true
|
||
});
|
||
|
||
$('#createTimeEnd').datetimepicker({
|
||
format: 'yyyy-mm-dd hh:ii:00',
|
||
autoclose: true
|
||
});
|
||
|
||
// 上传图片
|
||
$('#uploadBtn').on('click', function () {
|
||
if ($('#uploadFile').val() == '') {
|
||
$('#tipMsg').text('上传图片为空');
|
||
$('#tipModal').modal('show');
|
||
return;
|
||
}
|
||
|
||
var options = {
|
||
type: 'post',
|
||
url: '/admin/upload/img',
|
||
dataType: 'json',
|
||
success: function (res) {
|
||
if (res.path) {
|
||
$('#modal_icon').attr('src', res.path);
|
||
} else {
|
||
$('#tipMsg').text(res.msg);
|
||
$('#tipModal').modal('show');
|
||
}
|
||
}
|
||
}
|
||
$('#addForm').ajaxSubmit(options);
|
||
});
|
||
|
||
function clearModal() {
|
||
$('#addForm')[0].reset();
|
||
$('#addForm').validationEngine('hideAll');
|
||
$('#modal_id').val('');
|
||
$('#modal_icon').attr('src', '');
|
||
}
|
||
});
|
||
}
|
||
},
|
||
|
||
};
|
||
</script>
|
||
|
||
<style scoped></style> |