3 Star 0 Fork 0

moon/miduoduo-admin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
goods_group.html 10.20 KB
一键复制 编辑 原始数据 按行查看 历史
cheetahlou 提交于 2017-11-21 19:19 . fix
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>商品分组管理</title>
<!--树style设置-->
<style>
html {
margin: 0;
padding: 0;
font-size: 62.5%;
}
body {
max-width: 800px;
min-width: 300px;
margin: 0 auto;
padding: 20px 10px;
font-size: 14px;
font-size: 1.4em;
}
h1 {
font-size: 1.8em;
}
.demo {
max-width: 400px;
overflow: auto;
border: 1px solid silver;
min-height: 100px;
}
</style>
<meta name="keywords" content="">
<meta name="description" content="">
<!--<link rel="shortcut icon" href="favicon.ico">-->
<link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<link href="css/plugins/webuploader/webuploader.css" rel="stylesheet" type="text/css">
<link href="css/demo/webuploader-demo.css" rel="stylesheet" type="text/css">
<link href="css/plugins/fileinput/fileinput.css" rel="stylesheet" type="text/css"/>
<link href="css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
<link href="css/plugins/switchery/switchery.css" rel="stylesheet">
<link href="css/style.css?v=4.1.0" rel="stylesheet">
<!--jsTree-->
<link href="css/plugins/jsTree/style.min.css" rel="stylesheet" type="text/css">
<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>
<script src="js/core.js"></script>
<!-- jQuery Validation plugin javascript-->
<script src="js/plugins/validate/jquery.validate.min.js"></script>
<script src="js/plugins/validate/messages_zh.min.js"></script>
<!-- fileinput -->
<script src="js/plugins/fileinput/fileinput.js"></script>
<script src="js/plugins/fileinput/fileinput_locale_zh.js"></script>
<!-- 日期layerDate plugin javascript -->
<!-- <script src="js/plugins/layer/laydate/laydate.js"></script>
<script src="js/demo/laydate-demo.js"></script>-->
<!-- summernote -->
<script src="js/plugins/summernote/summernote.min.js"></script>
<script src="js/plugins/summernote/summernote-zh-CN.js"></script>
<script src="js/demo/summernote-demo.js"></script>
<!--jsTree-->
<script src="js/plugins/jsTree/jstree.js"></script>
<script src="js/plugins/jsTree/jstree.min.js"></script>
</head>
<body>
<h1>商品分组管理</h1>
<div id="title_div" class="form-group">
<label class="col-sm-3 control-label">分组产品线</label>
<div class="col-sm-8">
<select id="cateType" name="cateType" style="height:31px;border-radius: 3px;border: solid 1px #ddd;">
<option value="0">蜜哆哆</option>
<option value="1">蜜雅阁</option>
<option value="2">品牌馆</option>
</select>
</div>
</div>
<div>
<button type="button" class="btn btn-success btn-sm" onclick="lv1_create();"><i
class="glyphicon glyphicon-asterisk"></i>新建商品分组
</button>
<button id="btn_refresh_tree" type="button" class="btn btn-warning btn-sm"><i
class="glyphicon glyphicon-refresh"></i> 刷新
</button>
<!-- 搜索框 -->
<div class="search_input">
<input type="text" id="search_ay" placeholder="输入关键词自动搜索"/>
<button id="btn_search">搜索</button>
</div>
</div>
<div id="jstree_demo" class="demo"></div>
<div>
<label style="font-size: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前选择的商品分组为:<span
id="curCatePath" style="color:#07d;">未选择分组</span></label>
<div>
<div id="title_div" class="form-group">
<label class="col-sm-3 control-label" style="margin-bottom: 10px">分组描述:</label>
<div class="col-sm-8" style="margin-bottom: 10px">
<input id="subtitle" name="subtitle" type="text"
class="form-control">
</div>
</div>
<div id="previous_picture_div" class="form-group" style="display: none;">
<label class="col-sm-3 control-label">原分组图:</label>
<div class="col-sm-8">
<span id="pictureUrl" name="pictureUrl"
class="footable-sort-indicator"></span>
</div>
</div>
<div id="jiu_picture_div" class="form-group" style="display: none;">
<label class="col-sm-3 control-label">旧banner图(将更新到服务器):</label>
<div class="col-sm-8">
<span id="oldpic" name="oldpic"
class="footable-sort-indicator"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">修改/添加分组banner图(一张):</label>
<div class="col-sm-8" style="margin-bottom: 10px">
<div class="page-container">
<input type="file" id="fileupload2" name="file">
</div>
</div>
<span style="display: none;" id="uploadSuccessImg"></span>
</div>
</div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-3" style="margin: 10% auto 10% 25%;">
<button class="btn btn-primary" type="button" onclick="onSave()">保存</button>
<!--<button class="btn btn-primary" type="button" onclick="test()">测试</button>-->
</div>
</div>
</div>
<script>
$(function () {
//分组图片初始化
initGroupFileInput("fileupload2", urlcore + "/api/attachment/upload", "#oldpic");
// 分组图片地址
});
//保存或修改
function onSave() {
//分组描述
var subtitle = $("#subtitle").val();
//分组id
var classifyId = getClassifyId();
if (classifyId == "" || classifyId == undefined || classifyId == "#") {
alert("请先选择商品分组!");
return;
}
//分组图片
var pictureUrl = "";
$("#oldpic img").each(function (index, item) {
if(index==0)
pictureUrl += $(this).attr("src");
});
if(pictureUrl==""){
alert("请先选择图片");
return;
}
var postdata = "{";
postdata += '"id":"' + classifyId + '"';
postdata += ',"subtitle":"' + subtitle + '"';
postdata += ',"pictureUrl":"' + pictureUrl + '"';
postdata += "}";
//添加或修改分组图片和描述
$.ajax({
type: "POST",
url: urlcore + "/api/indexGroup/update",
dataType: "json",
contentType: "application/json;charset=UTF-8",
data: postdata,
success: function (data) {
//刷新树或更改产品线后初始化基本信息
initGroupDetail();
alert("修改分组信息成功");
var picSrc = data.data.pictureUrl;
//显示更新后的图片
showPicAfterSave(picSrc);
//刷新fileinput插件
$("#fileupload2").fileinput("refresh");
},
error: function () {
alert("修改分组信息失败!");
}
});
}
//显示更新后的图片,并插入或更新tree中node的original中的pictureUrl
function showPicAfterSave(picSrc) {
var instance = $('#jstree_demo').jstree(true);
//获取当前node
var curNode=instance.get_node(getClassifyId());
//更新node中original的图片信息,使切换的时候还能显示
curNode.original.picture_url=picSrc;
console.log("select zz node:",curNode);
//显示更新后的图片
$('#previous_picture_div').css("display", "block");
var imgStr1 = "";
//多图数组
picSrc = picSrc.split(",");
$.each(picSrc, function (index, value) {
if (value != "") {
imgStr1 +=
'<div style="position:relative;width:180px;height:auto;float:left;" display="block">' +
' <img style="padding: 5px 5px 5px 5px;" width="auto" height="150px" src="' + value + '">' +
'</div>';
}
});
$('#pictureUrl').html(imgStr1);
}
function test() {
var pictureUrl = "";
$("#oldpic img").each(function (index, item) {
if (index == 0) {
pictureUrl = $(this).attr("src");
}
});
console.log(pictureUrl);
}
//获取分组树当前选中分组
function getClassifyId() {
var instance = $('#jstree_demo').jstree(true);
classifyId = instance.get_selected()[0]
return classifyId;
}
function demo_rename(cateType) {
var postdata = "{";
postdata += '"title":"' + "新分组" + '"';
postdata += '"cateType":"' + cateType + '"';
// postdata += ',"parentID":' + parseInt(data.rslt.parent.attr("id").replace("li_", ""));
postdata += "}";
$.ajax({
type: "post",
url: urlcore + "/api/classify/addClassify",
contentType: "application/json;charset=utf-8",
data: postdata,
success: function (data1) {
var id = parseInt(data1.data.id);
// $(data.rslt.obj).attr("id", "li_" + data1.d);
var instance = $('#jstree_demo').jstree(true);
instance.deselect_all();
instance.select_node(id);
instance.edit(id, "");
},
error: function () {
alert("创建新分组失败");
}
});
};
function demo_delete() {
var instance = $('#jstree_demo').jstree(true);
//var cur = instance.get_selected();
instance.create_node('#', {
"text": "Child 2",
"type": "root"
});
};
</script>
<!-- 自定义js -->
<script src="js/goods_group.js"></script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yun_token/miduoduo-admin.git
[email protected]:yun_token/miduoduo-admin.git
yun_token
miduoduo-admin
miduoduo-admin
master

搜索帮助