321
This commit is contained in:
parent
6780f859cb
commit
066f3dbadc
|
|
@ -1,4 +1,4 @@
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Project: CoreCms
|
* Project: CoreCms
|
||||||
* ProjectName: 核心内容管理系统
|
* ProjectName: 核心内容管理系统
|
||||||
* Web: https://www.corecms.net
|
* Web: https://www.corecms.net
|
||||||
|
|
@ -34,7 +34,7 @@ namespace CoreCms.Net.Repository
|
||||||
_unitOfWork = unitOfWork;
|
_unitOfWork = unitOfWork;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 实现重写增删改查操作==========================================================
|
#region 实现重写增删改查操作==========================================================
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 重写异步插入方法
|
/// 重写异步插入方法
|
||||||
|
|
@ -68,15 +68,22 @@ namespace CoreCms.Net.Repository
|
||||||
var oldModel = await DbClient.Queryable<SQRooms>().In(entity.id).SingleAsync();
|
var oldModel = await DbClient.Queryable<SQRooms>().In(entity.id).SingleAsync();
|
||||||
if (oldModel == null)
|
if (oldModel == null)
|
||||||
{
|
{
|
||||||
jm.msg = "不存在此信息";
|
jm.msg = "不存在此信息";
|
||||||
return jm;
|
return jm;
|
||||||
}
|
}
|
||||||
|
|
||||||
//事物处理过程开始
|
//事物处理过程开始
|
||||||
oldModel.id = entity.id;
|
oldModel.id = entity.id;
|
||||||
oldModel.name = entity.name;
|
oldModel.name = entity.name;
|
||||||
oldModel.price_per_hour = entity.price_per_hour;
|
oldModel.price_per_hour = entity.price_per_hour;
|
||||||
oldModel.capacity = entity.capacity;
|
oldModel.capacity = entity.capacity;
|
||||||
oldModel.status = entity.status;
|
oldModel.status = entity.status;
|
||||||
|
oldModel.amenities = entity.amenities;
|
||||||
|
oldModel.description = entity.description;
|
||||||
|
oldModel.image_detailed_url = entity.image_detailed_url;
|
||||||
|
oldModel.image_url = entity.image_url;
|
||||||
|
oldModel.room_type = entity.room_type;
|
||||||
|
oldModel.sort_order = entity.sort_order;
|
||||||
|
|
||||||
//事物处理过程结束
|
//事物处理过程结束
|
||||||
var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
|
var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
|
||||||
|
|
@ -152,7 +159,7 @@ namespace CoreCms.Net.Repository
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 获取缓存的所有数据==========================================================
|
#region 获取缓存的所有数据==========================================================
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取缓存的所有数据
|
/// 获取缓存的所有数据
|
||||||
|
|
@ -202,29 +209,13 @@ namespace CoreCms.Net.Repository
|
||||||
{
|
{
|
||||||
page = await DbClient.Queryable<SQRooms>()
|
page = await DbClient.Queryable<SQRooms>()
|
||||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||||
.WhereIF(predicate != null, predicate).Select(p => new SQRooms
|
.WhereIF(predicate != null, predicate).Select(p => p).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||||
{
|
|
||||||
id = p.id,
|
|
||||||
name = p.name,
|
|
||||||
price_per_hour = p.price_per_hour,
|
|
||||||
capacity = p.capacity,
|
|
||||||
status = p.status,
|
|
||||||
|
|
||||||
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
page = await DbClient.Queryable<SQRooms>()
|
page = await DbClient.Queryable<SQRooms>()
|
||||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||||
.WhereIF(predicate != null, predicate).Select(p => new SQRooms
|
.WhereIF(predicate != null, predicate).Select(p => p).ToPageListAsync(pageIndex, pageSize, totalCount);
|
||||||
{
|
|
||||||
id = p.id,
|
|
||||||
name = p.name,
|
|
||||||
price_per_hour = p.price_per_hour,
|
|
||||||
capacity = p.capacity,
|
|
||||||
status = p.status,
|
|
||||||
|
|
||||||
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
|
||||||
}
|
}
|
||||||
var list = new PageList<SQRooms>(page, pageIndex, pageSize, totalCount);
|
var list = new PageList<SQRooms>(page, pageIndex, pageSize, totalCount);
|
||||||
return list;
|
return list;
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,8 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||||
"price_per_hour" => p => p.price_per_hour,
|
"price_per_hour" => p => p.price_per_hour,
|
||||||
"capacity" => p => p.capacity,
|
"capacity" => p => p.capacity,
|
||||||
"status" => p => p.status,
|
"status" => p => p.status,
|
||||||
|
"sort_order" => p => p.sort_order,
|
||||||
|
"room_type_name" => p => p.room_type_name,
|
||||||
_ => p => p.id
|
_ => p => p.id
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -129,6 +131,12 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||||
{
|
{
|
||||||
where = where.And(p => p.status == false);
|
where = where.And(p => p.status == false);
|
||||||
}
|
}
|
||||||
|
//房间类型名称 nvarchar
|
||||||
|
var room_type_name = Request.Form["room_type_name"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(room_type_name))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.room_type_name.Contains(room_type_name));
|
||||||
|
}
|
||||||
//获取数据
|
//获取数据
|
||||||
var list = await _SQRoomsServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true);
|
var list = await _SQRoomsServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true);
|
||||||
//返回数据
|
//返回数据
|
||||||
|
|
@ -346,6 +354,36 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||||
cell4.CellStyle = headerStyle;
|
cell4.CellStyle = headerStyle;
|
||||||
mySheet.SetColumnWidth(4, 10 * 256);
|
mySheet.SetColumnWidth(4, 10 * 256);
|
||||||
|
|
||||||
|
var cell5 = headerRow.CreateCell(5);
|
||||||
|
cell5.SetCellValue("房间类型名称");
|
||||||
|
cell5.CellStyle = headerStyle;
|
||||||
|
mySheet.SetColumnWidth(5, 15 * 256);
|
||||||
|
|
||||||
|
var cell6 = headerRow.CreateCell(6);
|
||||||
|
cell6.SetCellValue("房间类型");
|
||||||
|
cell6.CellStyle = headerStyle;
|
||||||
|
mySheet.SetColumnWidth(6, 15 * 256);
|
||||||
|
|
||||||
|
var cell7 = headerRow.CreateCell(7);
|
||||||
|
cell7.SetCellValue("排序权重");
|
||||||
|
cell7.CellStyle = headerStyle;
|
||||||
|
mySheet.SetColumnWidth(7, 12 * 256);
|
||||||
|
|
||||||
|
var cell8 = headerRow.CreateCell(8);
|
||||||
|
cell8.SetCellValue("房间图片");
|
||||||
|
cell8.CellStyle = headerStyle;
|
||||||
|
mySheet.SetColumnWidth(8, 30 * 256);
|
||||||
|
|
||||||
|
var cell9 = headerRow.CreateCell(9);
|
||||||
|
cell9.SetCellValue("房间描述");
|
||||||
|
cell9.CellStyle = headerStyle;
|
||||||
|
mySheet.SetColumnWidth(9, 40 * 256);
|
||||||
|
|
||||||
|
var cell10 = headerRow.CreateCell(10);
|
||||||
|
cell10.SetCellValue("房间设施");
|
||||||
|
cell10.CellStyle = headerStyle;
|
||||||
|
mySheet.SetColumnWidth(10, 30 * 256);
|
||||||
|
|
||||||
headerRow.Height = 30 * 20;
|
headerRow.Height = 30 * 20;
|
||||||
var commonCellStyle = ExcelHelper.GetCommonStyle(book);
|
var commonCellStyle = ExcelHelper.GetCommonStyle(book);
|
||||||
|
|
||||||
|
|
@ -374,6 +412,30 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||||
rowTemp4.SetCellValue(listModel[i].status ? "启用" : "停用");
|
rowTemp4.SetCellValue(listModel[i].status ? "启用" : "停用");
|
||||||
rowTemp4.CellStyle = commonCellStyle;
|
rowTemp4.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
|
var rowTemp5 = rowTemp.CreateCell(5);
|
||||||
|
rowTemp5.SetCellValue(listModel[i].room_type_name ?? "");
|
||||||
|
rowTemp5.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
|
var rowTemp6 = rowTemp.CreateCell(6);
|
||||||
|
rowTemp6.SetCellValue(listModel[i].room_type ?? "");
|
||||||
|
rowTemp6.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
|
var rowTemp7 = rowTemp.CreateCell(7);
|
||||||
|
rowTemp7.SetCellValue(listModel[i].sort_order?.ToString() ?? "0");
|
||||||
|
rowTemp7.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
|
var rowTemp8 = rowTemp.CreateCell(8);
|
||||||
|
rowTemp8.SetCellValue(listModel[i].image_url ?? "");
|
||||||
|
rowTemp8.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
|
var rowTemp9 = rowTemp.CreateCell(9);
|
||||||
|
rowTemp9.SetCellValue(listModel[i].description ?? "");
|
||||||
|
rowTemp9.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
|
var rowTemp10 = rowTemp.CreateCell(10);
|
||||||
|
rowTemp10.SetCellValue(listModel[i].amenities ?? "");
|
||||||
|
rowTemp10.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
}
|
}
|
||||||
// 导出excel
|
// 导出excel
|
||||||
string webRootPath = _webHostEnvironment.WebRootPath;
|
string webRootPath = _webHostEnvironment.WebRootPath;
|
||||||
|
|
@ -446,6 +508,12 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||||
{
|
{
|
||||||
where = where.And(p => p.status == false);
|
where = where.And(p => p.status == false);
|
||||||
}
|
}
|
||||||
|
//房间类型名称 nvarchar
|
||||||
|
var room_type_name = Request.Form["room_type_name"].FirstOrDefault();
|
||||||
|
if (!string.IsNullOrEmpty(room_type_name))
|
||||||
|
{
|
||||||
|
where = where.And(p => p.room_type_name.Contains(room_type_name));
|
||||||
|
}
|
||||||
//获取数据
|
//获取数据
|
||||||
//创建Excel文件的对象
|
//创建Excel文件的对象
|
||||||
var book = new HSSFWorkbook();
|
var book = new HSSFWorkbook();
|
||||||
|
|
@ -482,6 +550,35 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||||
cell4.CellStyle = headerStyle;
|
cell4.CellStyle = headerStyle;
|
||||||
mySheet.SetColumnWidth(4, 10 * 256);
|
mySheet.SetColumnWidth(4, 10 * 256);
|
||||||
|
|
||||||
|
var cell5 = headerRow.CreateCell(5);
|
||||||
|
cell5.SetCellValue("房间类型名称");
|
||||||
|
cell5.CellStyle = headerStyle;
|
||||||
|
mySheet.SetColumnWidth(5, 15 * 256);
|
||||||
|
|
||||||
|
var cell6 = headerRow.CreateCell(6);
|
||||||
|
cell6.SetCellValue("房间类型");
|
||||||
|
cell6.CellStyle = headerStyle;
|
||||||
|
mySheet.SetColumnWidth(6, 15 * 256);
|
||||||
|
|
||||||
|
var cell7 = headerRow.CreateCell(7);
|
||||||
|
cell7.SetCellValue("排序权重");
|
||||||
|
cell7.CellStyle = headerStyle;
|
||||||
|
mySheet.SetColumnWidth(7, 12 * 256);
|
||||||
|
|
||||||
|
var cell8 = headerRow.CreateCell(8);
|
||||||
|
cell8.SetCellValue("房间图片");
|
||||||
|
cell8.CellStyle = headerStyle;
|
||||||
|
mySheet.SetColumnWidth(8, 30 * 256);
|
||||||
|
|
||||||
|
var cell9 = headerRow.CreateCell(9);
|
||||||
|
cell9.SetCellValue("房间描述");
|
||||||
|
cell9.CellStyle = headerStyle;
|
||||||
|
mySheet.SetColumnWidth(9, 40 * 256);
|
||||||
|
|
||||||
|
var cell10 = headerRow.CreateCell(10);
|
||||||
|
cell10.SetCellValue("房间设施");
|
||||||
|
cell10.CellStyle = headerStyle;
|
||||||
|
mySheet.SetColumnWidth(10, 30 * 256);
|
||||||
|
|
||||||
headerRow.Height = 30 * 20;
|
headerRow.Height = 30 * 20;
|
||||||
var commonCellStyle = ExcelHelper.GetCommonStyle(book);
|
var commonCellStyle = ExcelHelper.GetCommonStyle(book);
|
||||||
|
|
@ -491,35 +588,49 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||||
{
|
{
|
||||||
var rowTemp = mySheet.CreateRow(i + 1);
|
var rowTemp = mySheet.CreateRow(i + 1);
|
||||||
|
|
||||||
|
|
||||||
var rowTemp0 = rowTemp.CreateCell(0);
|
var rowTemp0 = rowTemp.CreateCell(0);
|
||||||
rowTemp0.SetCellValue(listModel[i].id.ToString());
|
rowTemp0.SetCellValue(listModel[i].id.ToString());
|
||||||
rowTemp0.CellStyle = commonCellStyle;
|
rowTemp0.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var rowTemp1 = rowTemp.CreateCell(1);
|
var rowTemp1 = rowTemp.CreateCell(1);
|
||||||
rowTemp1.SetCellValue(listModel[i].name.ToString());
|
rowTemp1.SetCellValue(listModel[i].name.ToString());
|
||||||
rowTemp1.CellStyle = commonCellStyle;
|
rowTemp1.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var rowTemp2 = rowTemp.CreateCell(2);
|
var rowTemp2 = rowTemp.CreateCell(2);
|
||||||
rowTemp2.SetCellValue(listModel[i].price_per_hour.ToString());
|
rowTemp2.SetCellValue(listModel[i].price_per_hour.ToString());
|
||||||
rowTemp2.CellStyle = commonCellStyle;
|
rowTemp2.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var rowTemp3 = rowTemp.CreateCell(3);
|
var rowTemp3 = rowTemp.CreateCell(3);
|
||||||
rowTemp3.SetCellValue(listModel[i].capacity.ToString());
|
rowTemp3.SetCellValue(listModel[i].capacity.ToString());
|
||||||
rowTemp3.CellStyle = commonCellStyle;
|
rowTemp3.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var rowTemp4 = rowTemp.CreateCell(4);
|
var rowTemp4 = rowTemp.CreateCell(4);
|
||||||
rowTemp4.SetCellValue(listModel[i].status ? "启用" : "停用");
|
rowTemp4.SetCellValue(listModel[i].status ? "启用" : "停用");
|
||||||
rowTemp4.CellStyle = commonCellStyle;
|
rowTemp4.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
|
var rowTemp5 = rowTemp.CreateCell(5);
|
||||||
|
rowTemp5.SetCellValue(listModel[i].room_type_name ?? "");
|
||||||
|
rowTemp5.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
|
var rowTemp6 = rowTemp.CreateCell(6);
|
||||||
|
rowTemp6.SetCellValue(listModel[i].room_type ?? "");
|
||||||
|
rowTemp6.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
|
var rowTemp7 = rowTemp.CreateCell(7);
|
||||||
|
rowTemp7.SetCellValue(listModel[i].sort_order?.ToString() ?? "0");
|
||||||
|
rowTemp7.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
|
var rowTemp8 = rowTemp.CreateCell(8);
|
||||||
|
rowTemp8.SetCellValue(listModel[i].image_url ?? "");
|
||||||
|
rowTemp8.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
|
var rowTemp9 = rowTemp.CreateCell(9);
|
||||||
|
rowTemp9.SetCellValue(listModel[i].description ?? "");
|
||||||
|
rowTemp9.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
|
var rowTemp10 = rowTemp.CreateCell(10);
|
||||||
|
rowTemp10.SetCellValue(listModel[i].amenities ?? "");
|
||||||
|
rowTemp10.CellStyle = commonCellStyle;
|
||||||
|
|
||||||
}
|
}
|
||||||
// 写入到excel
|
// 写入到excel
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<script type="text/html" template lay-done="layui.data.done(d);">
|
<script type="text/html" template lay-done="layui.data.done(d);">
|
||||||
<div class="layui-form coreshop-form layui-form-pane" lay-filter="LAY-app-SQRooms-createForm" id="LAY-app-SQRooms-createForm">
|
<div style="overflow: auto;height: 100%;width: 100%;">
|
||||||
|
<div class="layui-form coreshop-form layui-form-pane" lay-filter="LAY-app-SQRooms-createForm" id="LAY-app-SQRooms-createForm" style="width: 99%;">
|
||||||
|
|
||||||
<div class="layui-row layui-col-space15">
|
<div class="layui-row layui-col-space15">
|
||||||
|
|
||||||
|
|
@ -38,9 +39,97 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="room_type_name" class="layui-form-label">房间类型名称</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input name="room_type_name" lay-verType="tips" lay-verify="verifyroom_type_name" class="layui-input" placeholder="请输入房间类型名称(如:豪华包间、标准包间)" maxlength="50"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="room_type" class="layui-form-label">房间类型</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input name="room_type" lay-verType="tips" lay-verify="verifyroom_type" class="layui-input" placeholder="请输入房间类型" maxlength="50"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="sort_order" class="layui-form-label">排序权重</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="number" name="sort_order" lay-verType="tips" class="layui-input" placeholder="数字越小越靠前" value="0"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="image_url" class="layui-form-label">房间图片</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input name="image_url" id="image_url" size="15" autocomplete="off" class="layui-input" placeholder="房间图片URL" />
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<div class="layui-upload">
|
||||||
|
<button type="button" class="layui-btn" id="upBtn">上传图片</button>
|
||||||
|
<div class="layui-upload-list">
|
||||||
|
<img class="layui-upload-img" id="viewImgBox" src="" style="max-width: 200px; max-height: 200px;">
|
||||||
|
<p id="viewTextBox"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="image_detailed_url" class="layui-form-label">房间详细图片</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="hidden" name="image_detailed_url" id="image_detailed_url" value="" />
|
||||||
|
<div class="layui-upload">
|
||||||
|
<button type="button" class="layui-btn" id="upBtnDetailedImages">上传图片</button>
|
||||||
|
<div class="layui-upload-list" id="upload-detailed-images-list" style="margin-top: 10px;"></div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-mid layui-word-aux">可上传多张图片,鼠标悬浮图片可删除</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="description" class="layui-form-label">房间描述</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<textarea name="description" lay-verType="tips" lay-verify="verifydescription" class="layui-textarea" placeholder="请输入房间描述" maxlength="500"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="amenities" class="layui-form-label">房间设施</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input name="amenities" lay-verType="tips" class="layui-input" placeholder="多个设施用逗号分隔,如:空调,WiFi,投影仪" />
|
||||||
|
<div class="layui-form-mid layui-word-aux">多个设施用逗号分隔</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -48,31 +137,160 @@
|
||||||
<input type="button" class="layui-btn" lay-submit lay-filter="LAY-app-SQRooms-createForm-submit" id="LAY-app-SQRooms-createForm-submit" value="确认添加">
|
<input type="button" class="layui-btn" lay-submit lay-filter="LAY-app-SQRooms-createForm-submit" id="LAY-app-SQRooms-createForm-submit" value="确认添加">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
var debug = layui.setter.debug;
|
var debug = layui.setter.debug;
|
||||||
layui.data.done = function (d) {
|
layui.data.done = function (d) {
|
||||||
//开启调试情况下获取接口赋值数据
|
//开启调试情况下获取接口赋值数据
|
||||||
if (debug) { console.log(d.params.data); }
|
if (debug) { console.log(d.params.data); }
|
||||||
layui.use(['admin', 'form', 'laydate', 'upload', 'coreHelper', 'cropperImg'],
|
layui.use(['admin', 'form', 'laydate', 'upload', 'coreHelper', 'cropperImg', 'laytpl'],
|
||||||
function () {
|
function () {
|
||||||
var $ = layui.$
|
var $ = layui.$
|
||||||
, form = layui.form
|
, form = layui.form
|
||||||
, admin = layui.admin
|
, admin = layui.admin
|
||||||
, laydate = layui.laydate
|
, laydate = layui.laydate
|
||||||
, upload = layui.upload
|
, upload = layui.upload
|
||||||
, cropperImg = layui.cropperImg
|
, cropperImg = layui.cropperImg
|
||||||
, coreHelper = layui.coreHelper;
|
, laytpl = layui.laytpl
|
||||||
|
, coreHelper = layui.coreHelper;
|
||||||
|
|
||||||
form.verify({
|
// 详细图片数组
|
||||||
verifyname: [/^.{0,100}$/, '房间名称最大只允许输入100位字符'],
|
var detailedImages = [];
|
||||||
});
|
|
||||||
form.val('LAY-app-SQRooms-createForm', {
|
form.verify({
|
||||||
status: 1,
|
verifyname: [/^.{0,100}$/, '房间名称最大只允许输入100位字符'],
|
||||||
capacity: 4
|
verifyroom_type_name: [/^.{0,50}$/, '房间类型名称最大只允许输入50位字符'],
|
||||||
});
|
verifyroom_type: [/^.{0,50}$/, '房间类型最大只允许输入50位字符'],
|
||||||
//重载form
|
verifydescription: [/^.{0,500}$/, '房间描述最大只允许输入500位字符'],
|
||||||
form.render(null, 'LAY-app-SQRooms-createForm');
|
});
|
||||||
})
|
|
||||||
};
|
//房间图片上传
|
||||||
|
$('#upBtn').click(function () {
|
||||||
|
var imgSrc = $('#viewImgBox').attr('src') || layui.setter.noImagePicUrl || '/images/no-image.png';
|
||||||
|
cropperImg.cropImg({
|
||||||
|
aspectRatio: 16 / 9,
|
||||||
|
imgSrc: imgSrc,
|
||||||
|
onCrop: function (data) {
|
||||||
|
var loadIndex = layer.load(2);
|
||||||
|
coreHelper.Post("api/Tools/UploadFilesFByBase64", { base64: data }, function (res) {
|
||||||
|
if (0 === res.code) {
|
||||||
|
$('#viewImgBox').attr('src', res.data.fileUrl);
|
||||||
|
$("#image_url").val(res.data.fileUrl);
|
||||||
|
layer.msg(res.msg);
|
||||||
|
layer.close(loadIndex);
|
||||||
|
} else {
|
||||||
|
layer.close(loadIndex);
|
||||||
|
layer.msg(res.msg, { icon: 2, anim: 6 });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 渲染详细图片列表
|
||||||
|
function renderDetailedImages() {
|
||||||
|
var getTpl = detailed_image_tpl.innerHTML;
|
||||||
|
var view = document.getElementById('upload-detailed-images-list');
|
||||||
|
laytpl(getTpl).render(detailedImages, function (html) {
|
||||||
|
view.innerHTML = html;
|
||||||
|
});
|
||||||
|
// 更新隐藏字段
|
||||||
|
$('#image_detailed_url').val(detailedImages.join(','));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 详细图片上传
|
||||||
|
$('#upBtnDetailedImages').click(function () {
|
||||||
|
cropperImg.cropImg({
|
||||||
|
aspectRatio: 16 / 9,
|
||||||
|
onCrop: function (data) {
|
||||||
|
var loadIndex = layer.load(2);
|
||||||
|
coreHelper.Post("api/Tools/UploadFilesFByBase64", { base64: data }, function (res) {
|
||||||
|
if (0 === res.code) {
|
||||||
|
detailedImages.push(res.data.fileUrl);
|
||||||
|
renderDetailedImages();
|
||||||
|
layer.msg(res.msg);
|
||||||
|
layer.close(loadIndex);
|
||||||
|
} else {
|
||||||
|
layer.close(loadIndex);
|
||||||
|
layer.msg(res.msg, { icon: 2, anim: 6 });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 删除详细图片
|
||||||
|
window.delDetailedImage = function(obj, imageUrl) {
|
||||||
|
var imgDiv = $(obj).closest('.detailed-img-item');
|
||||||
|
imgDiv.remove();
|
||||||
|
var index = detailedImages.indexOf(imageUrl);
|
||||||
|
if (index > -1) {
|
||||||
|
detailedImages.splice(index, 1);
|
||||||
|
}
|
||||||
|
renderDetailedImages();
|
||||||
|
};
|
||||||
|
|
||||||
|
form.val('LAY-app-SQRooms-createForm', {
|
||||||
|
status: 1,
|
||||||
|
capacity: 4,
|
||||||
|
sort_order: 0
|
||||||
|
});
|
||||||
|
//重载form
|
||||||
|
form.render(null, 'LAY-app-SQRooms-createForm');
|
||||||
|
})
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.detailed-img-item {
|
||||||
|
float: left;
|
||||||
|
position: relative;
|
||||||
|
text-align: center;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
padding: 5px;
|
||||||
|
margin-right: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
.detailed-img-item img {
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
object-fit: cover;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.detailed-img-item:hover .detailed-img-delete {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.detailed-img-delete {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
top: 5px;
|
||||||
|
right: 5px;
|
||||||
|
background-color: rgba(255, 255, 255, 0.9);
|
||||||
|
border: 1px solid #ff5722;
|
||||||
|
color: #ff5722;
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 3px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 12px;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
.detailed-img-delete:hover {
|
||||||
|
background-color: #ff5722;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
#upload-detailed-images-list {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<!--详细图片模板-->
|
||||||
|
<script type="text/html" id="detailed_image_tpl">
|
||||||
|
{{# layui.each(d, function(index, item){ }}
|
||||||
|
<div class="detailed-img-item">
|
||||||
|
<img src="{{ item }}" onclick='layui.coreHelper.viewImage("{{ item }}")' />
|
||||||
|
<span class="detailed-img-delete" onclick="delDetailedImage(this, '{{ item }}')">删除</span>
|
||||||
|
</div>
|
||||||
|
{{# }); }}
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<script type="text/html" template lay-done="layui.data.done(d);">
|
<script type="text/html" template lay-done="layui.data.done(d);">
|
||||||
<div class="layui-form coreshop-form layui-form-pane" lay-filter="LAY-app-SQRooms-detailsForm" id="LAY-app-SQRooms-detailsForm">
|
<div style="overflow: auto;height: 100%;width: 100%;">
|
||||||
|
<div class="layui-form coreshop-form layui-form-pane" lay-filter="LAY-app-SQRooms-detailsForm" id="LAY-app-SQRooms-detailsForm" style="width: 99%;">
|
||||||
|
|
||||||
<div class="layui-row layui-col-space15">
|
<div class="layui-row layui-col-space15">
|
||||||
<div class="layui-col-md6">
|
<div class="layui-col-md6">
|
||||||
|
|
@ -41,7 +42,97 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">房间类型名称</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-form-mid">{{ d.params.data.room_type_name || '--' }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">房间类型</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-form-mid">{{ d.params.data.room_type || '--' }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">排序权重</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-form-mid">{{ d.params.data.sort_order || 0 }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">房间描述</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-form-mid" style="word-break: break-all;">{{ d.params.data.description || '--' }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">房间设施</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-form-mid">{{ d.params.data.amenities || '--' }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">房间图片</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
{{# if(d.params.data.image_url){ }}
|
||||||
|
<img src="{{d.params.data.image_url}}" style="max-width: 300px; max-height: 300px; border-radius: 4px;" >
|
||||||
|
{{# } else { }}
|
||||||
|
<div class="layui-form-mid" style="color: #999;">暂无图片</div>
|
||||||
|
{{# } }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">房间详细图片</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
{{# if(d.params.data.image_detailed_url){ }}
|
||||||
|
{{# var imgs = d.params.data.image_detailed_url.split(','); }}
|
||||||
|
{{# layui.each(imgs, function(index, item){ }}
|
||||||
|
{{# if(item.trim()){ }}
|
||||||
|
<img src="{{item.trim()}}" style="max-width: 150px; max-height: 150px; margin-right: 10px; margin-bottom: 10px; border-radius: 4px;" >
|
||||||
|
{{# } }}
|
||||||
|
{{# }); }}
|
||||||
|
{{# } else { }}
|
||||||
|
<div class="layui-form-mid" style="color: #999;">暂无图片</div>
|
||||||
|
{{# } }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
var debug = layui.setter.debug;
|
var debug = layui.setter.debug;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<script type="text/html" template lay-done="layui.data.sendParams(d);">
|
<script type="text/html" template lay-done="layui.data.sendParams(d);">
|
||||||
<div class="layui-form coreshop-form layui-form-pane" lay-filter="LAY-app-SQRooms-editForm" id="LAY-app-SQRooms-editForm">
|
<div style="overflow: auto;height: 100%;width: 100%;">
|
||||||
|
<div class="layui-form coreshop-form layui-form-pane" lay-filter="LAY-app-SQRooms-editForm" id="LAY-app-SQRooms-editForm" style="width: 99%;" >
|
||||||
<input type="hidden" name="id" value="{{d.params.data.id || '' }}" />
|
<input type="hidden" name="id" value="{{d.params.data.id || '' }}" />
|
||||||
|
|
||||||
<div class="layui-row layui-col-space15">
|
<div class="layui-row layui-col-space15">
|
||||||
|
|
@ -42,31 +43,266 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="room_type_name" class="layui-form-label">房间类型名称</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input name="room_type_name" lay-verType="tips" lay-verify="verifyroom_type_name" class="layui-input" placeholder="请输入房间类型名称(如:豪华包间、标准包间)" value="{{d.params.data.room_type_name || '' }}" maxlength="50"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="room_type" class="layui-form-label">房间类型</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input name="room_type" lay-verType="tips" lay-verify="verifyroom_type" class="layui-input" placeholder="请输入房间类型" value="{{d.params.data.room_type || '' }}" maxlength="50"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md6">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="sort_order" class="layui-form-label">排序权重</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="number" name="sort_order" lay-verType="tips" class="layui-input" placeholder="数字越小越靠前" value="{{d.params.data.sort_order || 0}}"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="image_url" class="layui-form-label">房间图片</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input name="image_url" id="image_url" size="15" autocomplete="off" class="layui-input" placeholder="房间图片URL" value="{{d.params.data.image_url || '' }}" />
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<div class="layui-upload">
|
||||||
|
<button type="button" class="layui-btn" id="upBtn">上传图片</button>
|
||||||
|
<div class="layui-upload-list">
|
||||||
|
<img class="layui-upload-img" id="viewImgBox" src="{{d.params.data.image_url || layui.setter.noImagePicUrl || '/images/no-image.png'}}" style="max-width: 200px; max-height: 200px;">
|
||||||
|
<p id="viewTextBox"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="image_detailed_url" class="layui-form-label">房间详细图片</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="hidden" name="image_detailed_url" id="image_detailed_url" value="{{d.params.data.image_detailed_url || '' }}" />
|
||||||
|
<div class="layui-upload">
|
||||||
|
<button type="button" class="layui-btn" id="upBtnDetailedImages">上传图片</button>
|
||||||
|
<div class="layui-upload-list" id="upload-detailed-images-list" style="margin-top: 10px;"></div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-mid layui-word-aux">可上传多张图片,鼠标悬浮图片可删除</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="description" class="layui-form-label">房间描述</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<textarea name="description" lay-verType="tips" lay-verify="verifydescription" class="layui-textarea" placeholder="请输入房间描述" maxlength="500">{{d.params.data.description || '' }}</textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label for="amenities" class="layui-form-label">房间设施</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input name="amenities" lay-verType="tips" class="layui-input" placeholder="多个设施用逗号分隔,如:空调,WiFi,投影仪" value="{{d.params.data.amenities || '' }}" />
|
||||||
|
<div class="layui-form-mid layui-word-aux">多个设施用逗号分隔</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="layui-form-item text-right core-hidden">
|
<div class="layui-form-item text-right core-hidden">
|
||||||
<input type="button" class="layui-btn" lay-submit lay-filter="LAY-app-SQRooms-editForm-submit" id="LAY-app-SQRooms-editForm-submit" value="确认编辑">
|
<input type="button" class="layui-btn" lay-submit lay-filter="LAY-app-SQRooms-editForm-submit" id="LAY-app-SQRooms-editForm-submit" value="确认编辑">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
var debug = layui.setter.debug;
|
var debug = layui.setter.debug;
|
||||||
layui.data.sendParams = function (d) {
|
layui.data.sendParams = function (d) {
|
||||||
//开启调试情况下获取接口赋值数据
|
//开启调试情况下获取接口赋值数据
|
||||||
if (debug) { console.log(d.params.data); }
|
if (debug) { console.log(d.params.data); }
|
||||||
layui.use(['admin', 'form', 'laydate', 'upload', 'coreHelper', 'cropperImg'],
|
layui.use(['admin', 'form', 'laydate', 'upload', 'coreHelper', 'cropperImg', 'laytpl'],
|
||||||
function () {
|
function () {
|
||||||
var $ = layui.$
|
var $ = layui.$
|
||||||
, form = layui.form
|
, form = layui.form
|
||||||
, admin = layui.admin
|
, admin = layui.admin
|
||||||
, laydate = layui.laydate
|
, laydate = layui.laydate
|
||||||
, upload = layui.upload
|
, upload = layui.upload
|
||||||
, cropperImg = layui.cropperImg
|
, cropperImg = layui.cropperImg
|
||||||
, coreHelper = layui.coreHelper;
|
, laytpl = layui.laytpl
|
||||||
|
, coreHelper = layui.coreHelper;
|
||||||
|
|
||||||
form.verify({
|
// 详细图片数组
|
||||||
verifyname: [/^.{0,100}$/,'房间名称最大只允许输入100位字符'],
|
var detailedImages = [];
|
||||||
});
|
|
||||||
//重载form
|
// 初始化详细图片
|
||||||
form.render(null, 'LAY-app-SQRooms-editForm');
|
var detailedImagesStr = d.params.data.image_detailed_url || '';
|
||||||
})
|
if (detailedImagesStr && detailedImagesStr.trim() !== '') {
|
||||||
};
|
detailedImages = detailedImagesStr.split(',').filter(function(url) {
|
||||||
|
return url.trim() !== '';
|
||||||
|
}).map(function(url) {
|
||||||
|
return url.trim();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
form.verify({
|
||||||
|
verifyname: [/^.{0,100}$/, '房间名称最大只允许输入100位字符'],
|
||||||
|
verifyroom_type_name: [/^.{0,50}$/, '房间类型名称最大只允许输入50位字符'],
|
||||||
|
verifyroom_type: [/^.{0,50}$/, '房间类型最大只允许输入50位字符'],
|
||||||
|
verifydescription: [/^.{0,500}$/, '房间描述最大只允许输入500位字符'],
|
||||||
|
});
|
||||||
|
|
||||||
|
//房间图片上传
|
||||||
|
$('#upBtn').click(function () {
|
||||||
|
var currentImgSrc = $('#viewImgBox').attr('src');
|
||||||
|
var imgSrc = currentImgSrc && currentImgSrc !== '' ? currentImgSrc : (layui.setter.noImagePicUrl || '/images/no-image.png');
|
||||||
|
cropperImg.cropImg({
|
||||||
|
aspectRatio: 16 / 9,
|
||||||
|
imgSrc: imgSrc,
|
||||||
|
onCrop: function (data) {
|
||||||
|
var loadIndex = layer.load(2);
|
||||||
|
coreHelper.Post("api/Tools/UploadFilesFByBase64", { base64: data }, function (res) {
|
||||||
|
if (0 === res.code) {
|
||||||
|
$('#viewImgBox').attr('src', res.data.fileUrl);
|
||||||
|
$("#image_url").val(res.data.fileUrl);
|
||||||
|
layer.msg(res.msg);
|
||||||
|
layer.close(loadIndex);
|
||||||
|
} else {
|
||||||
|
layer.close(loadIndex);
|
||||||
|
layer.msg(res.msg, { icon: 2, anim: 6 });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 渲染详细图片列表
|
||||||
|
function renderDetailedImages() {
|
||||||
|
var getTpl = detailed_image_tpl.innerHTML;
|
||||||
|
var view = document.getElementById('upload-detailed-images-list');
|
||||||
|
laytpl(getTpl).render(detailedImages, function (html) {
|
||||||
|
view.innerHTML = html;
|
||||||
|
});
|
||||||
|
// 更新隐藏字段
|
||||||
|
$('#image_detailed_url').val(detailedImages.join(','));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化显示详细图片
|
||||||
|
if (detailedImages.length > 0) {
|
||||||
|
renderDetailedImages();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 详细图片上传
|
||||||
|
$('#upBtnDetailedImages').click(function () {
|
||||||
|
cropperImg.cropImg({
|
||||||
|
aspectRatio: 16 / 9,
|
||||||
|
onCrop: function (data) {
|
||||||
|
var loadIndex = layer.load(2);
|
||||||
|
coreHelper.Post("api/Tools/UploadFilesFByBase64", { base64: data }, function (res) {
|
||||||
|
if (0 === res.code) {
|
||||||
|
detailedImages.push(res.data.fileUrl);
|
||||||
|
renderDetailedImages();
|
||||||
|
layer.msg(res.msg);
|
||||||
|
layer.close(loadIndex);
|
||||||
|
} else {
|
||||||
|
layer.close(loadIndex);
|
||||||
|
layer.msg(res.msg, { icon: 2, anim: 6 });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 删除详细图片
|
||||||
|
window.delDetailedImage = function(obj, imageUrl) {
|
||||||
|
var imgDiv = $(obj).closest('.detailed-img-item');
|
||||||
|
imgDiv.remove();
|
||||||
|
var index = detailedImages.indexOf(imageUrl);
|
||||||
|
if (index > -1) {
|
||||||
|
detailedImages.splice(index, 1);
|
||||||
|
}
|
||||||
|
renderDetailedImages();
|
||||||
|
};
|
||||||
|
|
||||||
|
//重载form
|
||||||
|
form.render(null, 'LAY-app-SQRooms-editForm');
|
||||||
|
})
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.detailed-img-item {
|
||||||
|
float: left;
|
||||||
|
position: relative;
|
||||||
|
text-align: center;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
padding: 5px;
|
||||||
|
margin-right: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
.detailed-img-item img {
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
object-fit: cover;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.detailed-img-item:hover .detailed-img-delete {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.detailed-img-delete {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
top: 5px;
|
||||||
|
right: 5px;
|
||||||
|
background-color: rgba(255, 255, 255, 0.9);
|
||||||
|
border: 1px solid #ff5722;
|
||||||
|
color: #ff5722;
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 3px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 12px;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
.detailed-img-delete:hover {
|
||||||
|
background-color: #ff5722;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
#upload-detailed-images-list {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<!--详细图片模板-->
|
||||||
|
<script type="text/html" id="detailed_image_tpl">
|
||||||
|
{{# layui.each(d, function(index, item){ }}
|
||||||
|
<div class="detailed-img-item">
|
||||||
|
<img src="{{ item }}" onclick='layui.coreHelper.viewImage("{{ item }}")' />
|
||||||
|
<span class="detailed-img-delete" onclick="delDetailedImage(this, '{{ item }}')">删除</span>
|
||||||
|
</div>
|
||||||
|
{{# }); }}
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -45,8 +45,14 @@
|
||||||
<input type="text" name="capacity" placeholder="请输入可容纳人数" class="layui-input">
|
<input type="text" name="capacity" placeholder="请输入可容纳人数" class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
<label class="layui-form-label" for="status">状态</label>
|
<label class="layui-form-label" for="room_type_name">房间类型名称</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="room_type_name" placeholder="请输入房间类型名称" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label" for="status">状态</label>
|
||||||
<div class="layui-input-inline">
|
<div class="layui-input-inline">
|
||||||
<select name="status">
|
<select name="status">
|
||||||
<option value="">请选择</option>
|
<option value="">请选择</option>
|
||||||
|
|
@ -141,8 +147,21 @@
|
||||||
{ type: "checkbox", fixed: "left" },
|
{ type: "checkbox", fixed: "left" },
|
||||||
{ field: 'id', title: '房间ID', width: 60, sort: false },
|
{ field: 'id', title: '房间ID', width: 60, sort: false },
|
||||||
{ field: 'name', title: '房间名称', sort: false, minWidth: 200 },
|
{ field: 'name', title: '房间名称', sort: false, minWidth: 200 },
|
||||||
|
{ field: 'room_type_name', title: '房间类型名称', sort: false, width: 120 },
|
||||||
{ field: 'price_per_hour', title: '价格/小时', sort: false, width: 105 },
|
{ field: 'price_per_hour', title: '价格/小时', sort: false, width: 105 },
|
||||||
{ field: 'capacity', title: '可容纳人数', sort: false, width: 105 },
|
{ field: 'capacity', title: '可容纳人数', sort: false, width: 105 },
|
||||||
|
{ field: 'sort_order', title: '排序权重', sort: true, width: 100 },
|
||||||
|
{
|
||||||
|
field: 'image_url', title: '房间图片', width: 100, sort: false,
|
||||||
|
templet: function (d) {
|
||||||
|
if (d.image_url) {
|
||||||
|
return '<a href="javascript:void(0);" onclick=layui.coreHelper.viewImage("' + d.image_url + '")><image style="max-width:50px;max-height:50px;border-radius:4px;" src="' + d.image_url + '" /></a>';
|
||||||
|
} else {
|
||||||
|
var noImageUrl = layui.setter.noImagePicUrl || '/images/no-image.png';
|
||||||
|
return '<a href="javascript:void(0);" onclick=layui.coreHelper.viewImage("' + noImageUrl + '")><image style="max-width:50px;max-height:50px;border-radius:4px;" src="' + noImageUrl + '" /></a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{ field: 'status', title: '状态', width: 95, templet: '#switch_status', sort: false, unresize: true },
|
{ field: 'status', title: '状态', width: 95, templet: '#switch_status', sort: false, unresize: true },
|
||||||
{ width: 200, align: 'center', title: '预约管理', fixed: 'right', toolbar: '#LAY-app-SQRooms-tableBox-setting' },
|
{ width: 200, align: 'center', title: '预约管理', fixed: 'right', toolbar: '#LAY-app-SQRooms-tableBox-setting' },
|
||||||
{ width: 160, align: 'center', title: '房间管理', fixed: 'right', toolbar: '#LAY-app-SQRooms-tableBox-bar' }
|
{ width: 160, align: 'center', title: '房间管理', fixed: 'right', toolbar: '#LAY-app-SQRooms-tableBox-bar' }
|
||||||
|
|
@ -203,7 +222,7 @@
|
||||||
admin.popup({
|
admin.popup({
|
||||||
shadeClose: false,
|
shadeClose: false,
|
||||||
title: '创建数据',
|
title: '创建数据',
|
||||||
area: ['800px', '300px'],
|
area: ['1200px', '800px'],
|
||||||
id: 'LAY-popup-SQRooms-create',
|
id: 'LAY-popup-SQRooms-create',
|
||||||
success: function (layero, index) {
|
success: function (layero, index) {
|
||||||
view(this.id).render('sq/sqrooms/create', { data: e.data }).done(function () {
|
view(this.id).render('sq/sqrooms/create', { data: e.data }).done(function () {
|
||||||
|
|
@ -248,7 +267,7 @@
|
||||||
admin.popup({
|
admin.popup({
|
||||||
shadeClose: false,
|
shadeClose: false,
|
||||||
title: '编辑数据',
|
title: '编辑数据',
|
||||||
area: ['800px', '300px'],
|
area: ['1200px', '800px'],
|
||||||
id: 'LAY-popup-SQRooms-edit',
|
id: 'LAY-popup-SQRooms-edit',
|
||||||
success: function (layero, index) {
|
success: function (layero, index) {
|
||||||
view(this.id).render('sq/sqrooms/edit', { data: e.data }).done(function () {
|
view(this.id).render('sq/sqrooms/edit', { data: e.data }).done(function () {
|
||||||
|
|
@ -293,7 +312,7 @@
|
||||||
admin.popup({
|
admin.popup({
|
||||||
shadeClose: false,
|
shadeClose: false,
|
||||||
title: '查看详情',
|
title: '查看详情',
|
||||||
area: ['800px', '300px'],
|
area: ['1200px', '800px'],
|
||||||
id: 'LAY-popup-SQRooms-details',
|
id: 'LAY-popup-SQRooms-details',
|
||||||
success: function (layero, index) {
|
success: function (layero, index) {
|
||||||
view(this.id).render('sq/sqrooms/details', { data: e.data }).done(function () {
|
view(this.id).render('sq/sqrooms/details', { data: e.data }).done(function () {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user