Merge branch 'dev_材质管理迁移' into grey
Showing
9 changed files
with
384 additions
and
0 deletions
@@ -181,6 +181,10 @@ module.exports={ | @@ -181,6 +181,10 @@ module.exports={ | ||
181 | title:'商品管理【ajax查询所有品类】', | 181 | title:'商品管理【ajax查询所有品类】', |
182 | url:"/product/queryAllMaxSortList" | 182 | url:"/product/queryAllMaxSortList" |
183 | }, | 183 | }, |
184 | + selectAllMaxSort: { | ||
185 | + title: '查询一级物理类目列表', | ||
186 | + url: '/product/selectAllMaxSort' | ||
187 | + }, | ||
184 | queryProductSortList:{ | 188 | queryProductSortList:{ |
185 | title:'商品管理【根据ID ajax查询子品类列表】', | 189 | title:'商品管理【根据ID ajax查询子品类列表】', |
186 | url: '/product/queryProductSortList', | 190 | url: '/product/queryProductSortList', |
1 | +module.exports = function (app) { | ||
2 | + // 首页 | ||
3 | + app.get('/goods/material/index', "product.productMaterial.Index", "select_selectAllMaxSort", function(rs) { | ||
4 | + this.$extend = { | ||
5 | + moduleName: "产品管理", | ||
6 | + pageName: "产品材质管理", | ||
7 | + maxSortIds: rs.data | ||
8 | + } | ||
9 | + | ||
10 | + return rs.data; | ||
11 | + }); | ||
12 | + | ||
13 | + // 查询列表 | ||
14 | + app.post('/product/material/list', 'productMaterial_getMaterialList'); | ||
15 | + | ||
16 | + // 编辑 | ||
17 | + app.get('/goods/material/edit/:materialId', 'product.productMaterial.Edit', ['productMaterial_getMaterialDetail', 'select_selectAllMaxSort'], | ||
18 | + function(materialrs, sortrs) { | ||
19 | + this.$extend = { | ||
20 | + moduleName: "产品管理", | ||
21 | + pageName: "产品材质编辑", | ||
22 | + material: materialrs.data, | ||
23 | + maxSortIds: sortrs.data, | ||
24 | + title: '编辑材质信息', | ||
25 | + action: '/product/material/update' | ||
26 | + } | ||
27 | + }); | ||
28 | + | ||
29 | + // 新增 | ||
30 | + app.get('/goods/material/add', 'product.productMaterial.Edit', 'select_selectAllMaxSort', function(rs) { | ||
31 | + this.$extend = { | ||
32 | + moduleName: "产品管理", | ||
33 | + pageName: "产品材质创建", | ||
34 | + maxSortIds: rs.data, | ||
35 | + material: {id: 0}, | ||
36 | + title: '新增材质信息', | ||
37 | + action: '/product/material/add' | ||
38 | + } | ||
39 | + }); | ||
40 | + | ||
41 | + // 新增 | ||
42 | + app.post('/product/material/add', 'productMaterial_addMaterial'); | ||
43 | + | ||
44 | + // 更新 | ||
45 | + app.post('/product/material/update', 'productMaterial_updateMaterial'); | ||
46 | + | ||
47 | + // 删除 | ||
48 | + app.post('/product/material/delete', 'productMaterial_deleteMaterial'); | ||
49 | + | ||
50 | + app.post('/product/material/getBindProductInfo', 'productMaterial_getBindProductInfo'); | ||
51 | + | ||
52 | + // 查看绑定该材质的商品列表 | ||
53 | + app.get('/goods/material/bindinfo/:materialId', 'product.productMaterial.Bind', function(req, res) { | ||
54 | + this.$extend = { | ||
55 | + moduleName: "产品管理", | ||
56 | + pageName: "产品材质绑定信息" | ||
57 | + } | ||
58 | + }); | ||
59 | +} |
1 | +/** | ||
2 | + * 材质管理 | ||
3 | + */ | ||
4 | +module.exports={ | ||
5 | + namespace:"productMaterial", | ||
6 | + apis:{ | ||
7 | + getMaterialList: { | ||
8 | + title: "查询材质列表", | ||
9 | + url: '/product/material/queryMaterialList', | ||
10 | + params: [ | ||
11 | + {name: "maxSortId",type: "Number"}, | ||
12 | + {name: "page", type: "Number"}, | ||
13 | + {name: "size", type: "Number"} | ||
14 | + ] | ||
15 | + }, | ||
16 | + getMaterialDetail: { | ||
17 | + title: "查询材质详情", | ||
18 | + url: '/product/material/queryMaterialDetail', | ||
19 | + params: [ | ||
20 | + {name: "materialId", type: "Number"} | ||
21 | + ] | ||
22 | + }, | ||
23 | + addMaterial: { | ||
24 | + title: "新增材质", | ||
25 | + url: '/product/material/addMaterial', | ||
26 | + params: [ | ||
27 | + {name: "id", type: "Number", default:0}, | ||
28 | + {name: "maxSortId", type: "Number"}, | ||
29 | + {name: "caption", type: "String"}, | ||
30 | + {name: "encaption", type: "String"}, | ||
31 | + {name: "imageUrl", type: "String"}, | ||
32 | + {name: "remark", type: "String"} | ||
33 | + ] | ||
34 | + }, | ||
35 | + updateMaterial: { | ||
36 | + title: "更新材质", | ||
37 | + url: '/product/material/updateMaterial', | ||
38 | + params: [ | ||
39 | + {name: "id", type: "Number"}, | ||
40 | + {name: "maxSortId", type: "Number"}, | ||
41 | + {name: "caption", type: "String"}, | ||
42 | + {name: "encaption", type: "String"}, | ||
43 | + {name: "imageUrl", type: "String"}, | ||
44 | + {name: "remark", type: "String"} | ||
45 | + ] | ||
46 | + }, | ||
47 | + deleteMaterial: { | ||
48 | + title: "删除材质", | ||
49 | + url: '/product/material/deleteMaterial', | ||
50 | + params: [ | ||
51 | + {name: "materialId", type: "Number"} | ||
52 | + ] | ||
53 | + }, | ||
54 | + getBindProductInfo: { | ||
55 | + title: "查看材质绑定信息", | ||
56 | + url: '/product/material/getBindProductInfo', | ||
57 | + params: [ | ||
58 | + {name: "materialId", type: "Number"} | ||
59 | + ] | ||
60 | + } | ||
61 | + } | ||
62 | +} |
1 | +<%include '../../../common/views/__ui/header'%> | ||
2 | +<%include '../../../common/views/__partail/ListHeader'%> | ||
3 | + | ||
4 | +<div class="contentpanel"> | ||
5 | + <div class="panel panel-default"> | ||
6 | + <div class="panel-heading"> | ||
7 | + <h3 class="panel-title">商品绑定材质信息</h3> | ||
8 | + </div> | ||
9 | + | ||
10 | + <div class="panel-body"> | ||
11 | + <div class="form-group"> | ||
12 | + <textarea id="product-skn-list" cols="30" rows="10" class="form-control" readonly></textarea> | ||
13 | + </div> | ||
14 | + </div> | ||
15 | + </div> | ||
16 | +</div> | ||
17 | + | ||
18 | +<%include '../../../common/views/__ui/footer'%> |
1 | +<%include '../../../common/views/__ui/header'%> | ||
2 | +<%include '../../../common/views/__partail/ListHeader'%> | ||
3 | +<form id="materialForm" role="form" class="form-horizontal form-bordered" method="post" action="<%action%>"> | ||
4 | + <input type="hidden" id="id" value="<%material.id%>"> | ||
5 | + <div class="contentpanel"> | ||
6 | + <div class="panel panel-default"> | ||
7 | + <div class="panel-heading"> | ||
8 | + <h3 class="panel-title"><%title%></h3> | ||
9 | + </div> | ||
10 | + <div class="panel-body"> | ||
11 | + <div class="row"> | ||
12 | + <div class="form-group"> | ||
13 | + <div class="col-sm-1 control-label"> | ||
14 | + <label>分类: </label> | ||
15 | + </div> | ||
16 | + <div class="col-sm-9"> | ||
17 | + <select name="productSortSelect" id="maxSortId" value="<%material.maxSortId%>" class="form-control" required></select> | ||
18 | + </div> | ||
19 | + </div> | ||
20 | + <div class="form-group"> | ||
21 | + <div class="col-sm-1 control-label"> | ||
22 | + <label>材质名称: </label> | ||
23 | + </div> | ||
24 | + <div class="col-sm-9"> | ||
25 | + <input form="materialForm" type="text" id="caption" value="<%material.caption%>" class="form-control" maxlength="20" required> | ||
26 | + </div> | ||
27 | + </div> | ||
28 | + <div class="form-group"> | ||
29 | + <div class="col-sm-1 control-label"> | ||
30 | + <label>英文名称: </label> | ||
31 | + </div> | ||
32 | + <div class="col-sm-9"> | ||
33 | + <input form="materialForm" type="text" id="encaption" value="<%material.encaption%>" class="form-control" maxlength="100" required> | ||
34 | + </div> | ||
35 | + </div> | ||
36 | + <div class="form-group"> | ||
37 | + <div class="col-sm-1 control-label"> | ||
38 | + <label>图片: </label> | ||
39 | + </div> | ||
40 | + <div class="col-sm-9"> | ||
41 | + <input type="file" name="materialPic" value="<%material.imageUrl%>" id="imageUrl" required> | ||
42 | + </div> | ||
43 | + </div> | ||
44 | + <div class="form-group"> | ||
45 | + <div class="col-sm-1 control-label"> | ||
46 | + <label>备注: </label> | ||
47 | + </div> | ||
48 | + <div class="col-sm-9"> | ||
49 | + <textarea form="materialForm" name="materialRemark" id="remark" rows="6" maxlength="474" class="form-control" required><%material.remark%></textarea> | ||
50 | + </div> | ||
51 | + </div> | ||
52 | + <div style="text-align: center;"> | ||
53 | + <a href="javascript:;" class="btn btn-success submit-btn">提交</a> | ||
54 | + <a href="/goods/material/index" class="btn btn-danger cancel-btn">取消</a> | ||
55 | + </div> | ||
56 | + </div> | ||
57 | + </div> | ||
58 | + </div> | ||
59 | + </div> | ||
60 | +</form> | ||
61 | + | ||
62 | +<!-- 一级商品分类列表 --> | ||
63 | +<script type="text/template" id="max-sort-template"> | ||
64 | + <option value="">请选择分类</option> | ||
65 | + <%each maxSortIds as sort index%> | ||
66 | + <option value="<%sort.id%>"><%sort.sortName%></option> | ||
67 | + <%/each%> | ||
68 | +</script> | ||
69 | +<%include '../../../common/views/__ui/footer'%> |
1 | +<%include '../../../common/views/__ui/header'%> | ||
2 | +<%include '../../../common/views/__partail/ListHeader'%> | ||
3 | + | ||
4 | +<div class="contentpanel"> | ||
5 | + <div class="panel panel-default"> | ||
6 | + <div class="panel-body" style="padding-bottom: 0;"> | ||
7 | + <a href="/goods/material/add" class="btn btn-success"><i class="fa fa-plus"></i> 添加材质</a> | ||
8 | + </div> | ||
9 | + | ||
10 | + <div class="panel-body"> | ||
11 | + <div class="row"> | ||
12 | + <div class="panel-col2"> | ||
13 | + <select id="max-sort-select" name="max-sort-select" class="form-control"> | ||
14 | + </select> | ||
15 | + </div> | ||
16 | + <div class="panel-col2"> | ||
17 | + <a href="javascript:;" id="filter-btn" class="btn btn-info">筛选</a> | ||
18 | + <a href="" class="btn btn-info">全部</a> | ||
19 | + </div> | ||
20 | + </div> | ||
21 | + </div> | ||
22 | + </div> | ||
23 | + | ||
24 | + <div class="panel"> | ||
25 | + <div class="panel-body nopadding"> | ||
26 | + <div class="dataTables_wrapper no-footer" id="basicTable"></div> | ||
27 | + </div> | ||
28 | + </div> | ||
29 | +</div> | ||
30 | + | ||
31 | +<!-- 一级商品分类列表 --> | ||
32 | +<script type="text/template" id="max-sort-template"> | ||
33 | + <option value="">请选择分类</option> | ||
34 | + <%each maxSortIds as sort index%> | ||
35 | + <option value="<%sort.id%>"><%sort.sortName%></option> | ||
36 | + <%/each%> | ||
37 | +</script> | ||
38 | + | ||
39 | +<%include '../../../common/views/__ui/footer'%> |
1 | +var $ = require('jquery'), | ||
2 | + common=require('../../../common/common'); | ||
3 | + | ||
4 | +var getMaterialIdFromUrl = function() { | ||
5 | + var url = location.href + ''; | ||
6 | + | ||
7 | + var index = url.lastIndexOf('/'); | ||
8 | + var materialId = url.substring(index + 1); | ||
9 | + return +materialId; | ||
10 | +} | ||
11 | + | ||
12 | +$(document).ready(function() { | ||
13 | + var materialId = getMaterialIdFromUrl(); | ||
14 | + common.util.__ajax({ | ||
15 | + url: '/product/material/getBindProductInfo', | ||
16 | + data: { | ||
17 | + materialId: materialId | ||
18 | + }, | ||
19 | + aysnc: false | ||
20 | + }, function(res) { | ||
21 | + if(res && res.code == 200) { | ||
22 | + $('#product-skn-list').text(JSON.stringify(res.data)); | ||
23 | + } | ||
24 | + }, true); | ||
25 | +}); |
1 | +var $ = require('jquery'), | ||
2 | + common=require('../../../common/common'); | ||
3 | + | ||
4 | +// 设置 物理类目 下拉框 | ||
5 | +$('#maxSortId').html(common.util.__template($('#max-sort-template').html())); | ||
6 | + | ||
7 | +var e = new common.edit("#materialForm", {bucket: "material"}); | ||
8 | + | ||
9 | +e.init(); | ||
10 | + | ||
11 | +// 提交 | ||
12 | +$(document).on('click', '.submit-btn', function() { | ||
13 | + e.submit($("#materialForm").attr("action"),function(option) { | ||
14 | + console.log(option.data); | ||
15 | + option.success=function(res) { | ||
16 | + if(res.code == 200) { | ||
17 | + e.$tip('提交成功',function(){ | ||
18 | + history.go(-1); | ||
19 | + },'growl-success'); | ||
20 | + } else { | ||
21 | + e.$tip(res.message); | ||
22 | + } | ||
23 | + | ||
24 | + return false; | ||
25 | + }, | ||
26 | + option.error=function(res){ | ||
27 | + e.$tip("提交失败"); | ||
28 | + } | ||
29 | + }); | ||
30 | +}); |
1 | +var $ = require('jquery'), | ||
2 | + common=require('../../../common/common'); | ||
3 | + | ||
4 | +// 设置 物理类目 下拉框 | ||
5 | +$('#max-sort-select').html(common.util.__template($('#max-sort-template').html())); | ||
6 | +// 取全局属性中的 物理类目列表 | ||
7 | +var maxSortIds = window.ViewModel || {}; | ||
8 | + | ||
9 | +var g = new common.grid({ | ||
10 | + el: '#basicTable', | ||
11 | + parms: function() { | ||
12 | + return { | ||
13 | + maxSortId: common.util.__input('max-sort-select') | ||
14 | + }; | ||
15 | + }, | ||
16 | + columns: [ | ||
17 | + {display: "ID", name: "id"}, | ||
18 | + {display: "分类", render: function(item) { | ||
19 | + var sortName = ''; | ||
20 | + $.each(maxSortIds, function(_, sort) { | ||
21 | + if(+item.maxSortId == +sort.id) { | ||
22 | + sortName = sort.sortName; | ||
23 | + return true; | ||
24 | + } | ||
25 | + }); | ||
26 | + | ||
27 | + return sortName; | ||
28 | + }}, | ||
29 | + {display: "材质名称", name: "caption"}, | ||
30 | + {display: "英文名称", name: "encaption"}, | ||
31 | + {display: "图片", render: function(item) { | ||
32 | + var htmlArr = []; | ||
33 | + htmlArr.push('<div>'); | ||
34 | + htmlArr.push('<img src="' + item.imageUrl + '?imageView2/2/w/120/h/60">'); | ||
35 | + htmlArr.push('</div>'); | ||
36 | + | ||
37 | + return htmlArr.join(''); | ||
38 | + }}, | ||
39 | + {display: "备注", width: '50%', render: function(item) { | ||
40 | + return "<p style='word-break:break-all;'>" + item.remark + "</p>"; | ||
41 | + }}, | ||
42 | + {display: "操作", render: function(item) { | ||
43 | + var htmlArr = []; | ||
44 | + htmlArr.push("<div>"); | ||
45 | + htmlArr.push('<a href="/goods/material/edit/' + item.id + '" class="btn btn-primary btn-xs">编辑</a>'); | ||
46 | + htmlArr.push('<a href="javascript:;" class="btn btn-danger del-btn btn-xs" data-id="' + item.id + '">删除</a>'); | ||
47 | + htmlArr.push('<a href="/goods/material/bindinfo/' + item.id + '" target="_blank" class="btn btn-info btn-xs">查看绑定</a>'); | ||
48 | + htmlArr.push('</div>'); | ||
49 | + | ||
50 | + return htmlArr.join(''); | ||
51 | + }} | ||
52 | + ] | ||
53 | +}); | ||
54 | + | ||
55 | +g.init('/product/material/list'); | ||
56 | + | ||
57 | +// 筛选 | ||
58 | +$(document).on('click', '#filter-btn', function() { | ||
59 | + g.reload(1); | ||
60 | +}); | ||
61 | + | ||
62 | +// 删除 | ||
63 | +$(document).on('click', '.del-btn', function() { | ||
64 | + var id = $(this).data('id'); | ||
65 | + common.dialog.confirm("温馨提示", "你确定要删除吗?", function() { | ||
66 | + common.util.__ajax({ | ||
67 | + url: '/product/material/delete', | ||
68 | + data: { | ||
69 | + materialId: id | ||
70 | + }, | ||
71 | + aysnc: false | ||
72 | + }, function(res) { | ||
73 | + if(res && res.code == 200) { | ||
74 | + g.reload(); | ||
75 | + } | ||
76 | + }); | ||
77 | + }); | ||
78 | +}); |
-
Please register or login to post a comment