Authored by 马力

Merge branch 'dev_材质管理迁移' into grey

... ... @@ -181,6 +181,10 @@ module.exports={
title:'商品管理【ajax查询所有品类】',
url:"/product/queryAllMaxSortList"
},
selectAllMaxSort: {
title: '查询一级物理类目列表',
url: '/product/selectAllMaxSort'
},
queryProductSortList:{
title:'商品管理【根据ID ajax查询子品类列表】',
url: '/product/queryProductSortList',
... ...
module.exports = function (app) {
// 首页
app.get('/goods/material/index', "product.productMaterial.Index", "select_selectAllMaxSort", function(rs) {
this.$extend = {
moduleName: "产品管理",
pageName: "产品材质管理",
maxSortIds: rs.data
}
return rs.data;
});
// 查询列表
app.post('/product/material/list', 'productMaterial_getMaterialList');
// 编辑
app.get('/goods/material/edit/:materialId', 'product.productMaterial.Edit', ['productMaterial_getMaterialDetail', 'select_selectAllMaxSort'],
function(materialrs, sortrs) {
this.$extend = {
moduleName: "产品管理",
pageName: "产品材质编辑",
material: materialrs.data,
maxSortIds: sortrs.data,
title: '编辑材质信息',
action: '/product/material/update'
}
});
// 新增
app.get('/goods/material/add', 'product.productMaterial.Edit', 'select_selectAllMaxSort', function(rs) {
this.$extend = {
moduleName: "产品管理",
pageName: "产品材质创建",
maxSortIds: rs.data,
material: {id: 0},
title: '新增材质信息',
action: '/product/material/add'
}
});
// 新增
app.post('/product/material/add', 'productMaterial_addMaterial');
// 更新
app.post('/product/material/update', 'productMaterial_updateMaterial');
// 删除
app.post('/product/material/delete', 'productMaterial_deleteMaterial');
app.post('/product/material/getBindProductInfo', 'productMaterial_getBindProductInfo');
// 查看绑定该材质的商品列表
app.get('/goods/material/bindinfo/:materialId', 'product.productMaterial.Bind', function(req, res) {
this.$extend = {
moduleName: "产品管理",
pageName: "产品材质绑定信息"
}
});
}
\ No newline at end of file
... ...
/**
* 材质管理
*/
module.exports={
namespace:"productMaterial",
apis:{
getMaterialList: {
title: "查询材质列表",
url: '/product/material/queryMaterialList',
params: [
{name: "maxSortId",type: "Number"},
{name: "page", type: "Number"},
{name: "size", type: "Number"}
]
},
getMaterialDetail: {
title: "查询材质详情",
url: '/product/material/queryMaterialDetail',
params: [
{name: "materialId", type: "Number"}
]
},
addMaterial: {
title: "新增材质",
url: '/product/material/addMaterial',
params: [
{name: "id", type: "Number", default:0},
{name: "maxSortId", type: "Number"},
{name: "caption", type: "String"},
{name: "encaption", type: "String"},
{name: "imageUrl", type: "String"},
{name: "remark", type: "String"}
]
},
updateMaterial: {
title: "更新材质",
url: '/product/material/updateMaterial',
params: [
{name: "id", type: "Number"},
{name: "maxSortId", type: "Number"},
{name: "caption", type: "String"},
{name: "encaption", type: "String"},
{name: "imageUrl", type: "String"},
{name: "remark", type: "String"}
]
},
deleteMaterial: {
title: "删除材质",
url: '/product/material/deleteMaterial',
params: [
{name: "materialId", type: "Number"}
]
},
getBindProductInfo: {
title: "查看材质绑定信息",
url: '/product/material/getBindProductInfo',
params: [
{name: "materialId", type: "Number"}
]
}
}
}
\ No newline at end of file
... ...
<%include '../../../common/views/__ui/header'%>
<%include '../../../common/views/__partail/ListHeader'%>
<div class="contentpanel">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">商品绑定材质信息</h3>
</div>
<div class="panel-body">
<div class="form-group">
<textarea id="product-skn-list" cols="30" rows="10" class="form-control" readonly></textarea>
</div>
</div>
</div>
</div>
<%include '../../../common/views/__ui/footer'%>
\ No newline at end of file
... ...
<%include '../../../common/views/__ui/header'%>
<%include '../../../common/views/__partail/ListHeader'%>
<form id="materialForm" role="form" class="form-horizontal form-bordered" method="post" action="<%action%>">
<input type="hidden" id="id" value="<%material.id%>">
<div class="contentpanel">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><%title%></h3>
</div>
<div class="panel-body">
<div class="row">
<div class="form-group">
<div class="col-sm-1 control-label">
<label>分类: </label>
</div>
<div class="col-sm-9">
<select name="productSortSelect" id="maxSortId" value="<%material.maxSortId%>" class="form-control" required></select>
</div>
</div>
<div class="form-group">
<div class="col-sm-1 control-label">
<label>材质名称: </label>
</div>
<div class="col-sm-9">
<input form="materialForm" type="text" id="caption" value="<%material.caption%>" class="form-control" maxlength="20" required>
</div>
</div>
<div class="form-group">
<div class="col-sm-1 control-label">
<label>英文名称: </label>
</div>
<div class="col-sm-9">
<input form="materialForm" type="text" id="encaption" value="<%material.encaption%>" class="form-control" maxlength="100" required>
</div>
</div>
<div class="form-group">
<div class="col-sm-1 control-label">
<label>图片: </label>
</div>
<div class="col-sm-9">
<input type="file" name="materialPic" value="<%material.imageUrl%>" id="imageUrl" required>
</div>
</div>
<div class="form-group">
<div class="col-sm-1 control-label">
<label>备注: </label>
</div>
<div class="col-sm-9">
<textarea form="materialForm" name="materialRemark" id="remark" rows="6" maxlength="474" class="form-control" required><%material.remark%></textarea>
</div>
</div>
<div style="text-align: center;">
<a href="javascript:;" class="btn btn-success submit-btn">提交</a>
<a href="/goods/material/index" class="btn btn-danger cancel-btn">取消</a>
</div>
</div>
</div>
</div>
</div>
</form>
<!-- 一级商品分类列表 -->
<script type="text/template" id="max-sort-template">
<option value="">请选择分类</option>
<%each maxSortIds as sort index%>
<option value="<%sort.id%>"><%sort.sortName%></option>
<%/each%>
</script>
<%include '../../../common/views/__ui/footer'%>
\ No newline at end of file
... ...
<%include '../../../common/views/__ui/header'%>
<%include '../../../common/views/__partail/ListHeader'%>
<div class="contentpanel">
<div class="panel panel-default">
<div class="panel-body" style="padding-bottom: 0;">
<a href="/goods/material/add" class="btn btn-success"><i class="fa fa-plus"></i> 添加材质</a>
</div>
<div class="panel-body">
<div class="row">
<div class="panel-col2">
<select id="max-sort-select" name="max-sort-select" class="form-control">
</select>
</div>
<div class="panel-col2">
<a href="javascript:;" id="filter-btn" class="btn btn-info">筛选</a>
<a href="" class="btn btn-info">全部</a>
</div>
</div>
</div>
</div>
<div class="panel">
<div class="panel-body nopadding">
<div class="dataTables_wrapper no-footer" id="basicTable"></div>
</div>
</div>
</div>
<!-- 一级商品分类列表 -->
<script type="text/template" id="max-sort-template">
<option value="">请选择分类</option>
<%each maxSortIds as sort index%>
<option value="<%sort.id%>"><%sort.sortName%></option>
<%/each%>
</script>
<%include '../../../common/views/__ui/footer'%>
\ No newline at end of file
... ...
var $ = require('jquery'),
common=require('../../../common/common');
var getMaterialIdFromUrl = function() {
var url = location.href + '';
var index = url.lastIndexOf('/');
var materialId = url.substring(index + 1);
return +materialId;
}
$(document).ready(function() {
var materialId = getMaterialIdFromUrl();
common.util.__ajax({
url: '/product/material/getBindProductInfo',
data: {
materialId: materialId
},
aysnc: false
}, function(res) {
if(res && res.code == 200) {
$('#product-skn-list').text(JSON.stringify(res.data));
}
}, true);
});
... ...
var $ = require('jquery'),
common=require('../../../common/common');
// 设置 物理类目 下拉框
$('#maxSortId').html(common.util.__template($('#max-sort-template').html()));
var e = new common.edit("#materialForm", {bucket: "material"});
e.init();
// 提交
$(document).on('click', '.submit-btn', function() {
e.submit($("#materialForm").attr("action"),function(option) {
console.log(option.data);
option.success=function(res) {
if(res.code == 200) {
e.$tip('提交成功',function(){
history.go(-1);
},'growl-success');
} else {
e.$tip(res.message);
}
return false;
},
option.error=function(res){
e.$tip("提交失败");
}
});
});
\ No newline at end of file
... ...
var $ = require('jquery'),
common=require('../../../common/common');
// 设置 物理类目 下拉框
$('#max-sort-select').html(common.util.__template($('#max-sort-template').html()));
// 取全局属性中的 物理类目列表
var maxSortIds = window.ViewModel || {};
var g = new common.grid({
el: '#basicTable',
parms: function() {
return {
maxSortId: common.util.__input('max-sort-select')
};
},
columns: [
{display: "ID", name: "id"},
{display: "分类", render: function(item) {
var sortName = '';
$.each(maxSortIds, function(_, sort) {
if(+item.maxSortId == +sort.id) {
sortName = sort.sortName;
return true;
}
});
return sortName;
}},
{display: "材质名称", name: "caption"},
{display: "英文名称", name: "encaption"},
{display: "图片", render: function(item) {
var htmlArr = [];
htmlArr.push('<div>');
htmlArr.push('<img src="' + item.imageUrl + '?imageView2/2/w/120/h/60">');
htmlArr.push('</div>');
return htmlArr.join('');
}},
{display: "备注", width: '50%', render: function(item) {
return "<p style='word-break:break-all;'>" + item.remark + "</p>";
}},
{display: "操作", render: function(item) {
var htmlArr = [];
htmlArr.push("<div>");
htmlArr.push('<a href="/goods/material/edit/' + item.id + '" class="btn btn-primary btn-xs">编辑</a>');
htmlArr.push('<a href="javascript:;" class="btn btn-danger del-btn btn-xs" data-id="' + item.id + '">删除</a>');
htmlArr.push('<a href="/goods/material/bindinfo/' + item.id + '" target="_blank" class="btn btn-info btn-xs">查看绑定</a>');
htmlArr.push('</div>');
return htmlArr.join('');
}}
]
});
g.init('/product/material/list');
// 筛选
$(document).on('click', '#filter-btn', function() {
g.reload(1);
});
// 删除
$(document).on('click', '.del-btn', function() {
var id = $(this).data('id');
common.dialog.confirm("温馨提示", "你确定要删除吗?", function() {
common.util.__ajax({
url: '/product/material/delete',
data: {
materialId: id
},
aysnc: false
}, function(res) {
if(res && res.code == 200) {
g.reload();
}
});
});
});
\ No newline at end of file
... ...