Files
peko-admin-web/src/views/infocard/InfocardManageView.vue

988 lines
33 KiB
Vue
Raw Normal View History

2023-09-23 22:03:02 +08:00
<template>
2024-11-11 18:28:39 +08:00
<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>
2025-07-15 11:31:45 +08:00
<div id="toolbar"
style="height: auto">
<form id="searchForm"
class=""
action=""
method="post"
target="_blank">
2024-11-11 18:28:39 +08:00
<div class="col-sm-12">
2025-07-15 11:31:45 +08:00
<label for="type"
class="col-sm-1 control-label">资料卡类型:</label>
2024-11-11 18:28:39 +08:00
<div class="col-sm-2">
2025-07-15 11:31:45 +08:00
<select name="type"
id="type"
data-btn-class="btn-warning"
class="form-control">
<option value=""
selected="selected">全部</option>
2024-11-11 18:28:39 +08:00
<option value="1">普通</option>
<option value="2">贵族</option>
</select>
</div>
2023-09-23 22:03:02 +08:00
2025-07-15 11:31:45 +08:00
<label for="id"
class="col-sm-1 control-label">资料卡id:</label>
2024-11-11 18:28:39 +08:00
<div class="col-sm-2">
2025-07-15 11:31:45 +08:00
<input type="text"
class="form-control"
name="id"
id="id" />
2024-11-11 18:28:39 +08:00
</div>
2023-09-23 22:03:02 +08:00
2025-07-15 11:31:45 +08:00
<label for="name"
class="col-sm-1 control-label">资料卡名称:</label>
2024-11-11 18:28:39 +08:00
<div class="col-sm-2">
2025-07-15 11:31:45 +08:00
<input type="text"
class="form-control"
name="name"
id="name" />
2024-11-11 18:28:39 +08:00
</div>
2023-09-23 22:03:02 +08:00
2025-07-15 11:31:45 +08:00
<label for="partitionId"
class="col-sm-1 control-label">地区:</label>
2024-11-11 18:28:39 +08:00
<div class="col-sm-2">
2025-07-15 11:31:45 +08:00
<select name="partitionId"
id="partitionId"
class="form-control"></select>
2024-11-11 18:28:39 +08:00
</div>
2023-09-23 22:03:02 +08:00
</div>
2024-11-11 18:28:39 +08:00
</form>
<div class="col-sm-12">
2025-07-15 11:31:45 +08:00
<button id="btnSearch"
class="btn btn-default">
2024-11-11 18:28:39 +08:00
<i class="glyphicon glyphicon-search"></i>查询
</button>
2025-07-15 11:31:45 +08:00
<button id="btnAdd"
class="btn btn-default">
2024-11-11 18:28:39 +08:00
<i class="glyphicon glyphicon-plus"></i>新增
</button>
</div>
2023-09-23 22:03:02 +08:00
</div>
2024-11-11 18:28:39 +08:00
</div>
<!-- .content -->
<div id="table"></div>
</div>
</section>
2023-09-23 22:03:02 +08:00
2025-07-15 11:31:45 +08:00
<div class="modal fade"
id="addModal"
tabindex="-1"
role="dialog"
aria-labelledby="modalLabel">
<div class="modal-dialog"
role="document">
<div class="modal-content"
style="width: 500px">
2024-11-11 18:28:39 +08:00
<div class="modal-header">
2025-07-15 11:31:45 +08:00
<button type="button"
class="close"
data-dismiss="modal"
aria-label="Close">
2024-11-11 18:28:39 +08:00
<span aria-hidden="true">&times;</span>
</button>
2025-07-15 11:31:45 +08:00
<h4 class="modal-title"
id="modalLabel">新增资料卡</h4>
2024-11-11 18:28:39 +08:00
</div>
<div class="modal-body">
2025-07-15 11:31:45 +08:00
<form class="form-horizontal"
id="addForm">
<input type="hidden"
name="id"
id="modal_id" />
2024-11-11 18:28:39 +08:00
<div class="form-group">
2025-07-15 11:31:45 +08:00
<label for="partitionFlag"
class="col-sm-4 control-label">选择分区</label>
2024-11-11 18:28:39 +08:00
<div class="col-sm-6">
2025-07-15 11:31:45 +08:00
<input type="checkbox"
name="partitionFlag"
value="1" />英语区<br />
<input type="checkbox"
name="partitionFlag"
value="2" />阿拉伯语区<br />
<input type="checkbox"
name="partitionFlag"
value="4" />华语区<br />
<input type="checkbox"
name="partitionFlag"
value="8" />土耳其<br />
<input type="checkbox"
name="partitionFlag"
value="16" />英语2区<br />
2024-11-11 18:28:39 +08:00
</div>
</div>
<div class="form-group">
2025-07-15 11:31:45 +08:00
<label for="modal_type"
class="col-sm-4 control-label">装扮类型:</label>
2024-11-11 18:28:39 +08:00
<div class="col-sm-6">
2025-07-15 11:31:45 +08:00
<select name="type"
id="modal_type"
data-btn-class="btn-warning"
class="form-control">
2024-11-11 18:28:39 +08:00
<option value="1">普通装扮</option>
<option value="2">贵族装扮</option>
</select>
</div>
</div>
<div class="form-group">
2025-07-15 11:31:45 +08:00
<label for="modal_name"
class="col-sm-4 control-label">装扮名称:</label>
2024-11-11 18:28:39 +08:00
<div class="col-sm-6">
2025-07-15 11:31:45 +08:00
<input type="text"
class="form-control validate[required]"
name="name"
id="modal_name"
placeholder="请输入资料卡名称" />
2024-11-11 18:28:39 +08:00
</div>
</div>
<div class="form-group">
2025-07-15 11:31:45 +08:00
<label for="en_modal_name"
class="col-sm-4 control-label">英语装扮名称:</label>
2024-11-11 18:28:39 +08:00
<div class="col-sm-6">
2025-07-15 11:31:45 +08:00
<input type="text"
class="form-control validate[required]"
name="name"
id="en_modal_name"
placeholder="请输入资料卡名称" />
2024-11-11 18:28:39 +08:00
</div>
</div>
<div class="form-group">
2025-07-15 11:31:45 +08:00
<label for="ar_modal_name"
class="col-sm-4 control-label">阿语装扮名称:</label>
2024-11-11 18:28:39 +08:00
<div class="col-sm-6">
2025-07-15 11:31:45 +08:00
<input type="text"
class="form-control validate[required]"
name="name"
id="ar_modal_name"
placeholder="请输入资料卡名称" />
2024-11-11 18:28:39 +08:00
</div>
</div>
<div class="form-group">
2025-07-15 11:31:45 +08:00
<label for="tr_modal_name"
class="col-sm-4 control-label">土耳其装扮名称:</label>
2024-11-11 18:28:39 +08:00
<div class="col-sm-6">
2025-07-15 11:31:45 +08:00
<input type="text"
class="form-control validate[required]"
name="name"
id="tr_modal_name"
placeholder="请输入资料卡名称" />
2024-11-11 18:28:39 +08:00
</div>
</div>
2025-07-15 11:31:45 +08:00
<div class="form-group">
<label for="pt_modal_name"
class="col-sm-4 control-label">葡萄牙语装扮名称:</label>
<div class="col-sm-6">
<input type="text"
class="form-control validate[required]"
name="name"
id="pt_modal_name"
placeholder="请输入资料卡名称" />
</div>
</div>
<form class="form-horizontal"
id="addForm1">
2024-11-26 15:46:51 +08:00
<div class="form-group">
<label class="col-sm-4 control-label">图片:</label>
<div class="col-sm-6">
2025-07-15 11:31:45 +08:00
<img src=""
id="addIconPicUrl"
style="height: 44px"
alt="" />
<input type="file"
id="addUploadIconPic"
name="uploadFile"
accept="image/gif,image/jpeg,image/jpg,image/png,image/svg,.mp4" />
<button class="btn btn-success"
type="button"
id="uploadBtn">
2024-11-26 15:46:51 +08:00
上传
</button>
2025-07-15 11:31:45 +08:00
<input type="hidden"
id="pic"
name="pic"
class="form-control" />
<a href="javascript:void(0)"
id="removeIconPic">清除</a>
2024-11-26 15:46:51 +08:00
</div>
2024-11-11 18:28:39 +08:00
</div>
2024-11-26 15:46:51 +08:00
</form>
<div class="form-group">
2025-07-15 11:31:45 +08:00
<label for="effectType"
class="col-sm-4 control-label">装扮动效图片类型:</label>
<div class="col-sm-6">
2025-07-15 11:31:45 +08:00
<select name="effectType"
id="effectType"
data-btn-class="btn-warning"
class="form-control">
<option value="0">图片</option>
<option value="1">MP4</option>
</select>
</div>
</div>
2025-07-15 11:31:45 +08:00
<form class="form-horizontal"
id="addForm2">
2024-11-26 15:46:51 +08:00
<div class="form-group">
<label class="col-sm-4 control-label">装扮动效图片:</label>
<div class="col-sm-6">
2025-07-15 11:31:45 +08:00
<img src=""
id="addIconPicUrl2"
style="height: 44px"
alt="" />
<input type="file"
id="addEffect"
name="uploadFile"
accept="image/gif,image/jpeg,image/jpg,image/png,image/svg,.mp4" />
<button class="btn btn-success"
type="button"
id="uploadBtn2">
2024-11-26 15:46:51 +08:00
上传
</button>
2025-07-15 11:31:45 +08:00
<input type="hidden"
id="effect"
name="effect"
class="form-control" />
<a href="javascript:void(0)"
id="removeIconPic2">清除</a>
2024-11-26 15:46:51 +08:00
</div>
</div>
2024-11-26 15:46:51 +08:00
</form>
2024-11-11 18:28:39 +08:00
<div class="form-group">
2025-07-15 11:31:45 +08:00
<label for="status"
class="col-sm-4 control-label">装扮状态:</label>
2024-11-11 18:28:39 +08:00
<div class="col-sm-6">
2025-07-15 11:31:45 +08:00
<select name="status"
id="status"
data-btn-class="btn-warning"
class="form-control">
2024-11-11 18:28:39 +08:00
<option value="1">有效</option>
<option value="2">无效</option>
</select>
</div>
</div>
</form>
</div>
<div class="modal-footer">
2025-07-15 11:31:45 +08:00
<button type="button"
class="btn btn-default"
data-dismiss="modal">
2024-11-11 18:28:39 +08:00
关闭
</button>
2025-07-15 11:31:45 +08:00
<button type="button"
class="btn btn-primary"
id="button-save">
2024-11-11 18:28:39 +08:00
保存
</button>
2023-09-23 22:03:02 +08:00
</div>
2024-11-11 18:28:39 +08:00
</div>
2023-09-23 22:03:02 +08:00
</div>
2024-11-11 18:28:39 +08:00
</div>
2023-09-23 22:03:02 +08:00
2024-11-11 18:28:39 +08:00
<!-- 为用户赠送铭牌弹窗 -->
2025-07-15 11:31:45 +08:00
<div class="modal fade"
id="sendModal"
tabindex="-1"
role="dialog"
aria-labelledby="modalLabel">
<div class="modal-dialog"
role="document">
2024-11-11 18:28:39 +08:00
<div class="modal-content">
<div class="modal-header">
2025-07-15 11:31:45 +08:00
<button type="button"
class="close"
data-dismiss="modal"
aria-label="Close">
2024-11-11 18:28:39 +08:00
<span aria-hidden="true">x</span>
</button>
2025-07-15 11:31:45 +08:00
<h4 class="modal-title"
id="modalSendLabel">赠送装扮</h4>
2024-11-11 18:28:39 +08:00
</div>
<div class="modal-body">
2025-07-15 11:31:45 +08:00
<form class="form-horizontal"
id="sendForm">
<input type="hidden"
name="id"
id="sendId" />
2024-11-11 18:28:39 +08:00
<div class="form-group">
2025-07-15 11:31:45 +08:00
<label for="sendErbanNo"
class="col-sm-3 control-label">ID</label>
2024-11-11 18:28:39 +08:00
<div class="col-sm-9">
2025-07-15 11:31:45 +08:00
<textarea name="erbanNos"
id="sendErbanNo"
class="form-control validate[required]"
placeholder="多个ID使用,分隔一次性不得超过100个"></textarea>
2024-11-11 18:28:39 +08:00
</div>
2023-09-23 22:03:02 +08:00
</div>
2024-11-11 18:28:39 +08:00
<div class="form-group">
2025-07-15 11:31:45 +08:00
<label for="sendDays"
class="col-sm-3 control-label">赠送天数</label>
2024-11-11 18:28:39 +08:00
<div class="col-sm-9">
2025-07-15 11:31:45 +08:00
<input type="text"
name="days"
id="sendDays"
class="form-control validate[required]" />
2024-11-11 18:28:39 +08:00
</div>
</div>
<div class="form-group">
2025-07-15 11:31:45 +08:00
<label for="sendDesc"
class="col-sm-3 control-label">备注</label>
2024-11-11 18:28:39 +08:00
<div class="col-sm-9">
2025-07-15 11:31:45 +08:00
<input type="text"
name="remake"
id="sendDesc"
class="form-control validate[required]" />
2024-11-11 18:28:39 +08:00
</div>
</div>
</form>
2023-09-23 22:03:02 +08:00
</div>
2024-11-11 18:28:39 +08:00
<div class="modal-footer">
2025-07-15 11:31:45 +08:00
<button type="button"
class="btn btn-default"
data-dismiss="modal">
2024-11-11 18:28:39 +08:00
关闭
</button>
2025-07-15 11:31:45 +08:00
<button type="button"
class="btn btn-primary"
id="send">提交</button>
2024-11-11 18:28:39 +08:00
</div>
</div>
2023-09-23 22:03:02 +08:00
</div>
2024-11-11 18:28:39 +08:00
</div>
2023-09-23 22:03:02 +08:00
</template>
<script>
2024-11-11 18:28:39 +08:00
import TableHelper from "@/utils/bootstrap-table-helper";
import { getPartitionInfoList } from "@/api/partition/partitionInfo";
import { buildSelectOption } from "@/utils/system-helper";
2023-09-23 22:03:02 +08:00
export default {
2024-11-11 18:28:39 +08:00
name: "InfocardManageView",
2025-07-15 11:31:45 +08:00
setup () {
2024-11-11 18:28:39 +08:00
return {};
},
2025-07-15 11:31:45 +08:00
created () {
2024-11-11 18:28:39 +08:00
this.$nextTick(function () {
this.initPartition();
this.initData();
});
},
methods: {
2025-07-15 11:31:45 +08:00
initData () {
2024-11-11 18:28:39 +08:00
$(function () {
$("#table").bootstrapTable("destroy");
$("#table").bootstrapTable({
columns: [
{ field: "id", title: "装扮id", align: "middle", width: "5%" },
{
field: "partitionFlag",
title: "地区",
align: "center",
width: "10%",
formatter: function (val, row, index) {
let value = "";
if ((val & 1) != 0) {
value += "英语区<br>";
}
if ((val & 2) != 0) {
value += "阿拉伯语区<br>";
}
if ((val & 4) != 0) {
value += "华语区<br>";
}
if ((val & 8) != 0) {
value += "土耳其区<br>";
}
if ((val & 16) != 0) {
value += "英语2区<br>";
}
2024-11-11 18:28:39 +08:00
return value;
},
},
{
field: "name.zh",
title: "装扮名称",
align: "middle",
width: "5%",
},
{
field: "name.ar",
title: "阿语装扮名称",
align: "middle",
width: "5%",
},
{
field: "name.en",
title: "英语装扮名称",
align: "middle",
width: "5%",
},
{
field: "name.tr",
title: "土耳其装扮名称",
align: "middle",
width: "5%",
},
2025-07-15 11:31:45 +08:00
{
field: "name.pt",
title: "葡萄牙语装扮名称",
align: "middle",
width: "5%",
},
2024-11-11 18:28:39 +08:00
{
field: "pic",
title: "装扮图片",
align: "middle",
valign: "middle",
width: "5%",
formatter: function (val, row, index) {
if (val) {
return (
"<img style='max-width: 200px;max-height: 200px' src='" +
val +
"'>"
);
} else {
return "-";
}
},
},
{
field: "effect",
title: "装扮动效图片",
align: "middle",
valign: "middle",
width: "5%",
formatter: function (val, row, index) {
if (val) {
return (
"<img style='max-width: 200px;max-height: 200px' src='" +
val +
"'>"
);
} else {
return "-";
}
},
},
2024-11-11 18:28:39 +08:00
{
field: "type",
title: "装扮类型",
align: "middle",
width: "5%",
formatter: function (val) {
if (val === 1) {
return "普通装扮";
} else if (val === 2) {
return "贵族装扮";
} else {
return "-";
}
},
},
{
field: "status",
title: "状态",
align: "middle",
width: "5%",
formatter: function (val) {
if (val === 1) {
return "有效";
} else if (val === 2) {
return "无效";
} else {
return "-";
}
},
},
{
field: "effectType",
title: "装扮动效图片类型",
align: "middle",
width: "5%",
formatter: function (val) {
if (val === 0) {
return "图片";
} else if (val === 1) {
2024-12-03 18:09:16 +08:00
return "MP4";
} else {
return "-";
}
},
},
2024-11-11 18:28:39 +08:00
{
field: "createTime",
title: "添加时间",
align: "middle",
width: "5%",
valign: "middle",
formatter: function (val, row, index) {
if (val) {
var date = new Date(val);
return date.format("yyyy-MM-dd hh:mm:00");
} else {
return "-";
}
},
},
{
field: "id",
title: "操作",
align: "middle",
width: "5%",
formatter: function (val, row, index) {
let isSendDisabled = false;
if (row.type === 2) {
isSendDisabled = true;
}
return (
'<button id="btnEdit" name="btnEdit" class="btn btn-sm btn-success opt-edit" data-id=' +
val +
">" +
'<i class="glyphicon glyphicon-edit"></i> 编辑</button>&nbsp;&nbsp;' +
'<button id="btnSend" name="btnSend" class="btn btn-sm btn-success opt-send" data-id=' +
val +
" " +
`${isSendDisabled ? " disabled " : ""}` +
">" +
'<i class="glyphicon glyphicon-edit"></i> 赠送</button>&nbsp;&nbsp;'
);
},
},
],
cache: false,
striped: true,
showRefresh: false,
2025-07-15 11:31:45 +08:00
pageSize: 20,
2024-11-11 18:28:39 +08:00
pagination: true,
2025-07-15 11:31:45 +08:00
pageList: [20, 50],
2024-11-11 18:28:39 +08:00
search: false,
sidePagination: "server", //表示服务端请求
queryParamsType: "-",
uniqueId: "id",
2025-07-15 11:31:45 +08:00
queryParams: function queryParams (params) {
2024-11-11 18:28:39 +08:00
//设置查询参数
var param = {
page: params.pageNumber,
pageSize: params.pageSize,
type: $("#type").val(),
name: $("#name").val(),
id: $("#id").val(),
partitionId: $("#partitionId").val(),
};
return param;
},
ajax: function (request) {
//使用ajax请求
$.ajax({
type: "GET",
url: "/admin/infocard/listByPage",
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 value = i.name;
if (value.startsWith("{") && value.endsWith("}")) {
i.name = JSON.parse(value);
2024-04-10 19:17:45 +08:00
} else {
2024-11-11 18:28:39 +08:00
i.name = {
zh: value,
ar: value,
en: value,
2025-07-15 11:31:45 +08:00
tr: value,
pt: value,
2024-11-11 18:28:39 +08:00
};
2024-04-10 19:17:45 +08:00
}
2024-11-11 18:28:39 +08:00
return i;
}),
total: res.total,
2023-09-23 22:03:02 +08:00
});
2024-11-11 18:28:39 +08:00
},
error: function (error) {
console.log(error);
},
});
},
toolbar: "#toolbar",
// url: '/admin/infocard/listByPage',
onLoadSuccess: function () {
//加载成功时执行
console.log("load success");
},
onLoadError: function () {
//加载失败时执行
console.log("load fail");
},
});
2023-09-23 22:03:02 +08:00
2024-11-11 18:28:39 +08:00
// 查询刷新
$("#btnSearch").on("click", function () {
TableHelper.doRefresh("#table");
});
2023-09-23 22:03:02 +08:00
2024-11-11 18:28:39 +08:00
// 编辑
$("#table").on("click", "#btnEdit", function () {
var id = $(this).attr("data-id");
var row = $("#table").bootstrapTable("getRowByUniqueId", id);
// 赋值
$("#addForm #modal_id").val(row.id);
$("#addForm #modal_type").val(row.type);
let name = row.name;
if (
name &&
Object.prototype.hasOwnProperty.call(name, "zh") &&
Object.prototype.hasOwnProperty.call(name, "ar") &&
2025-07-15 11:31:45 +08:00
Object.prototype.hasOwnProperty.call(name, "en") &&
Object.prototype.hasOwnProperty.call(name, "tr") &&
Object.prototype.hasOwnProperty.call(name, "pt")
2024-11-11 18:28:39 +08:00
) {
$("#addForm #modal_name").val(row.name.zh);
// 阿语
$("#addForm #ar_modal_name").val(row.name.ar);
// 英语
$("#addForm #en_modal_name").val(row.name.en);
// 土耳其
$("#addForm #tr_modal_name").val(row.name.tr);
2025-07-15 11:31:45 +08:00
$("#addForm #pt_modal_name").val(row.name.pt);
2024-11-11 18:28:39 +08:00
} else {
$("#addForm #modal_name").val(name);
// 阿语
$("#addForm #ar_modal_name").val(name);
// 英语
$("#addForm #en_modal_name").val(name);
// 土耳其
$("#addForm #tr_modal_name").val(name);
2025-07-15 11:31:45 +08:00
$("#addForm #pt_modal_name").val(name);
2024-11-11 18:28:39 +08:00
}
$("#addIconPicUrl").attr("src", row.pic);
$("#addIconPicUrl2").attr("src", row.effect);
2024-11-11 18:28:39 +08:00
$("#addForm #pic").val(row.pic);
$("#addForm #effect").val(row.effect);
2024-11-11 18:28:39 +08:00
$("#addForm #status").val(row.status);
$("#addForm #effectType").val(row.effectType);
2024-11-11 18:28:39 +08:00
//分区
let partitionFlag = row.partitionFlag;
if ((partitionFlag & 1) != 0) {
$("input:checkbox[name='partitionFlag']")[0].checked = true;
} else {
$("input:checkbox[name='partitionFlag']")[0].checked = false;
}
if ((partitionFlag & 2) != 0) {
$("input:checkbox[name='partitionFlag']")[1].checked = true;
} else {
$("input:checkbox[name='partitionFlag']")[1].checked = false;
}
if ((partitionFlag & 4) != 0) {
$("input:checkbox[name='partitionFlag']")[2].checked = true;
} else {
$("input:checkbox[name='partitionFlag']")[2].checked = false;
}
if ((partitionFlag & 8) != 0) {
$("input:checkbox[name='partitionFlag']")[3].checked = true;
} else {
$("input:checkbox[name='partitionFlag']")[3].checked = false;
}
if ((partitionFlag & 16) != 0) {
$("input:checkbox[name='partitionFlag']")[4].checked = true;
} else {
$("input:checkbox[name='partitionFlag']")[4].checked = false;
2025-07-15 11:31:45 +08:00
}
2024-11-11 18:28:39 +08:00
$("#addModal").modal("show");
});
2023-09-23 22:03:02 +08:00
2024-11-11 18:28:39 +08:00
$("#uploadBtn").on("click", function () {
var options = {
type: "post",
url: "/admin/upload/img",
dataType: "json",
success: function (json) {
if (json.path) {
$("#pic").val(json.path);
$("#addIconPicUrl").attr("src", json.path);
} else {
$("#tipMsg").text(json.msg);
$("#tipModal").modal("show");
}
},
};
2024-11-26 15:46:51 +08:00
$("#addForm1").ajaxSubmit(options);
2024-11-11 18:28:39 +08:00
});
$("#uploadBtn2").on("click", function () {
var options = {
type: "post",
url: "/admin/upload/img",
dataType: "json",
success: function (json) {
if (json.path) {
$("#effect").val(json.path);
$("#addIconPicUrl2").attr("src", json.path);
} else {
$("#tipMsg").text(json.msg);
$("#tipModal").modal("show");
}
},
};
2024-11-26 15:46:51 +08:00
$("#addForm2").ajaxSubmit(options);
});
2023-09-23 22:03:02 +08:00
2024-11-11 18:28:39 +08:00
$("#removeIconPic").on("click", function () {
$("#addIconPicUrl").attr("src", "");
$("#addUploadIconPic").val("");
$("#iconPic").val("");
});
$("#removeIconPic2").on("click", function () {
$("#addIconPicUrl2").attr("src", "");
$("#addEffect").val("");
$("#effect").val("");
$("#iconPic").val("");
});
2023-09-23 22:03:02 +08:00
2024-11-11 18:28:39 +08:00
//打开新增页面
$("#btnAdd").on("click", function () {
cleanModal();
$("#addModal").modal("show");
});
2024-04-09 19:05:17 +08:00
2024-11-11 18:28:39 +08:00
//保存
$("#button-save").on("click", function () {
var pic = $("#pic").val();
var effect = $("#effect").val();
2024-11-11 18:28:39 +08:00
var name = $("#modal_name").val();
var arName = $("#ar_modal_name").val();
var enName = $("#en_modal_name").val();
var trName = $("#tr_modal_name").val();
2025-07-15 11:31:45 +08:00
var ptName = $("#pt_modal_name").val();
2024-11-11 18:28:39 +08:00
//做下数据校验
if (isEmpty(name)) {
$("#tipMsg").text("装扮名字不能为空");
$("#tipModal").modal("show");
return;
}
if (isEmpty(arName)) {
$("#tipMsg").text("阿语装扮名字不能为空");
$("#tipModal").modal("show");
return;
}
if (isEmpty(enName)) {
$("#tipMsg").text("英语装扮名字不能为空");
$("#tipModal").modal("show");
return;
}
if (isEmpty(trName)) {
$("#tipMsg").text("土耳其装扮名字不能为空");
$("#tipModal").modal("show");
return;
}
2025-07-15 11:31:45 +08:00
if (isEmpty(ptName)) {
$("#tipMsg").text("葡萄牙装扮名字不能为空");
$("#tipModal").modal("show");
return;
}
2024-11-11 18:28:39 +08:00
if (isEmpty(pic)) {
$("#tipMsg").text("图片不能为空");
$("#tipModal").modal("show");
return;
}
if ($("#addForm").validationEngine("validate")) {
console.log('$("#addForm").serialize()', $("#addForm").serialize());
// 获取序列化字符串并转换为对象
let formData = $("#addForm")
.serializeArray()
.reduce(function (obj, item) {
obj[item.name] = item.value;
return obj;
}, {});
2023-09-23 22:03:02 +08:00
2024-11-11 18:28:39 +08:00
// 国际化字段
2025-07-15 11:31:45 +08:00
var jsonName = { zh: name, ar: arName, en: enName, tr: trName, pt: ptName };
2024-11-11 18:28:39 +08:00
const nameValue = JSON.stringify(jsonName);
// 修改属性值
formData.name = nameValue; // 将giftName修改为"newGiftName"
//分区
const partitionFlagArray = $(
"input:checkbox[name='partitionFlag']:checked"
).serializeArray();
let partitionFlag = 0;
for (let i = 0, len = partitionFlagArray.length; i < len; i++) {
console.log(partitionFlagArray[i]);
partitionFlag |= partitionFlagArray[i].value;
}
formData.partitionFlag = partitionFlag;
// 将修改后的对象转换回序列化字符串
2024-11-26 15:46:51 +08:00
formData.pic = $('#addIconPicUrl').attr('src');
formData.effect = $('#addIconPicUrl2').attr('src');
2025-07-15 11:31:45 +08:00
console.log(formData, 2222222222222);
2024-11-11 18:28:39 +08:00
let newSerializeStr = $.param(formData);
$.ajax({
type: "post",
url: "/admin/infocard/saveOrUpdate",
data: newSerializeStr,
dataType: "json",
success: function (json) {
if (json.code === 200) {
$("#tipMsg").text("保存成功");
$("#tipModal").modal("show");
setTimeout(function () {
TableHelper.doRefresh("#table");
$("#addModal").modal("hide");
}, 1000);
} else {
$("#tipMsg").text("保存失败,错误信息:" + json.message);
$("#tipModal").modal("show");
}
},
});
}
});
2023-09-23 22:03:02 +08:00
2024-11-11 18:28:39 +08:00
//打开赠送弹窗
$("#table").on("click", ".opt-send", function () {
//清除数据
$("#sendModal").find("input").val("");
$("#sendModal").find("textarea").val("");
//设置数据
var id = $(this).attr("data-id");
$("#sendId").val(id);
$("#sendModal").modal("show");
});
2023-09-23 22:03:02 +08:00
2024-11-11 18:28:39 +08:00
//同步用户铭牌
$("#table").on("click", ".opt-sync", function () {
//设置数据
var id = $(this).attr("data-id");
$.ajax({
type: "get",
url: "/admin/nameplate/sync",
data: {
id: id,
},
dataType: "json",
success: function (json) {
if (json.code == 200) {
$("#tipMsg").text("同步成功");
$("#tipModal").modal("show");
} else {
$("#tipMsg").text("同步失败");
$("#tipModal").modal("show");
}
},
});
});
2023-09-23 22:03:02 +08:00
2024-11-11 18:28:39 +08:00
//赠送
$("#send").click(function () {
// debugger;
var erbanNo = $("#sendErbanNo").val().trim(); //去掉首尾的空格和换行符
if (!(erbanNo.length > 0)) {
$("#tipMsg").text("请输入ID");
$("#tipModal").modal("show");
return;
}
if (erbanNo.length > 100) {
$("#tipMsg").text("单次赠送用户不得超过100");
$("#tipModal").modal("show");
return;
}
2023-09-23 22:03:02 +08:00
2024-11-11 18:28:39 +08:00
if (!$("#sendDays").val()) {
$("#tipMsg").text("请输入天数");
$("#tipModal").modal("show");
return;
}
var sendDays = $("#sendDays").val();
var sendDesc = $("#sendDesc").val();
var sendId = $("#sendId").val();
$("#tipMsg").text("赠送中,请稍后...");
$("#tipModal").modal("show");
if ($("#sendForm").validationEngine("validate")) {
$.ajax({
type: "get",
url: "/admin/infocard/send",
data: {
erbanNos: erbanNo,
days: sendDays,
cardId: sendId,
remark: sendDesc,
},
dataType: "json",
success: function (json) {
if (json.code === 200) {
$("#sendModal").modal("hide");
$("#tipMsg").text(json.message);
TableHelper.doRefresh("#table");
}
},
2024-04-10 19:17:45 +08:00
});
2024-11-11 18:28:39 +08:00
}
});
});
},
2025-07-15 11:31:45 +08:00
initPartition () {
2024-11-11 18:28:39 +08:00
getPartitionInfoList().then((res) => {
let data = res.data;
buildSelectOption(
"#partitionId",
null,
[
{
value: "",
text: "全部",
},
].concat(
data.map((v) => {
return {
value: v.id,
text: v.desc,
};
})
)
);
});
},
},
2023-09-23 22:03:02 +08:00
};
2025-07-15 11:31:45 +08:00
function cleanModal () {
2024-11-11 18:28:39 +08:00
$("#id").val("");
$("#addIconPicUrl").attr("src", "");
$("#addIconPicUrl2").attr("src", "");
2024-11-11 18:28:39 +08:00
$("#addUploadIconPic").val("");
$("#addEffect").val("");
$("#effect").val("");
2024-11-11 18:28:39 +08:00
$("#pic").val("");
$("#effect").val("");
2024-11-11 18:28:39 +08:00
$("#status").val("");
$("#effectType").val("");
2024-11-11 18:28:39 +08:00
$("#modal_type").val("");
$("#modal_name").val("");
$('input[name="partitionFlag"]').each(function () {
$(this).checked = false;
});
2023-09-23 22:03:02 +08:00
}
//判断空值
2025-07-15 11:31:45 +08:00
function isEmpty (data) {
2024-11-11 18:28:39 +08:00
if (data == null || data == undefined || data == "") {
return true;
}
return false;
2023-09-23 22:03:02 +08:00
}
</script>
<style scoped>
.fixed-table-body {
2024-11-11 18:28:39 +08:00
height: auto !important;
2023-09-23 22:03:02 +08:00
}
.pull-left {
2024-11-11 18:28:39 +08:00
width: 100% !important;
}
</style>