...
|
...
|
@@ -8,21 +8,8 @@ var $ = require('jquery'); |
|
|
var edit = require('../common/edit');
|
|
|
var dropDown = require('../common/dropDown');
|
|
|
var grid=require('../common/grid');
|
|
|
var baseNum = 1;
|
|
|
|
|
|
// 获取品类属性列表
|
|
|
function getAttrList(id, callback) {
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/product/attr/queryProductAttributeList',
|
|
|
dataType: 'json',
|
|
|
data: {
|
|
|
param: id
|
|
|
}
|
|
|
}).then(function (d) {
|
|
|
|
|
|
callback(d);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 把Y、N转换成是、否
|
|
|
function convertNorY(val) {
|
...
|
...
|
@@ -33,37 +20,79 @@ function convertNorY(val) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
function createTr(id) {
|
|
|
|
|
|
getAttrList(id, function (d) {
|
|
|
function queryAttrList(id) {
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
var tableGird = new grid({
|
|
|
|
|
|
var data = d.data;
|
|
|
var dataLen = data.length;
|
|
|
var i;
|
|
|
var trHtml = '';
|
|
|
el:"#attr-table",
|
|
|
parms:function(){
|
|
|
|
|
|
for (i = 0; i < dataLen; i++) {
|
|
|
return {
|
|
|
categoryId: id * baseNum
|
|
|
};
|
|
|
},
|
|
|
columns:[
|
|
|
{
|
|
|
display: "属性名称",
|
|
|
name: "attributeName"
|
|
|
}, {
|
|
|
display: "属性类型",
|
|
|
name: "attributeValues"
|
|
|
}, {
|
|
|
display: "输入类型",
|
|
|
name: "inputType"
|
|
|
}, {
|
|
|
display: "是否必选",
|
|
|
name:"isMust",
|
|
|
render:function(item){
|
|
|
return convertNorY(item.isMust);
|
|
|
}
|
|
|
}, {
|
|
|
display: "是否可搜索",
|
|
|
name: "isSearch",
|
|
|
render: function(item){
|
|
|
return convertNorY(item.isSearch);
|
|
|
}
|
|
|
}, {
|
|
|
display:"操作",
|
|
|
name:"categoryId",
|
|
|
render:function(items){
|
|
|
|
|
|
trHtml +=
|
|
|
'<tr>' +
|
|
|
'<td>' + data[i].a + '</td>' +
|
|
|
'<td>' + data[i].attributeType + '</td>' +
|
|
|
'<td>' + data[i].inputType + '</td>' +
|
|
|
'<td>' + convertNorY(data[i].isMust) + '</td>' +
|
|
|
'<td>' + convertNorY(data[i].isSearch) + '</td>' +
|
|
|
'<td><a class="btn btn-success btn-xs edit-class-btn">编辑</a></td>' +
|
|
|
'</tr>'
|
|
|
return ('<button attribute-id="' + items.attributeId + '" class="btn btn-success btn-xs edit-class-btn">编辑</button>');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
});
|
|
|
tableGird.init('/product/attr/queryProductAttributeList');
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var $attributeName = $('#attributeName');
|
|
|
var $saleType = $('#saleType');
|
|
|
var $inputType = $('#inputType');
|
|
|
var $isMust = $('#isMust');
|
|
|
var $isSearch = $('#isSearch');
|
|
|
var $maxValueLen = $('#maxValueLen');
|
|
|
var $isAllowAlias = $('#isAllowAlias');
|
|
|
var $orderBy = $('#orderBy');
|
|
|
var $attributeValues = $('#attributeValues');
|
|
|
var $displayPosition = $('#displayPosition');
|
|
|
var $remark = $('#remark');
|
|
|
var $attributeId = $('#attributeId');
|
|
|
|
|
|
function removeAttr() {
|
|
|
$attributeName.val('');
|
|
|
$saleType.val('');
|
|
|
$inputType.val('');
|
|
|
$isMust.val('');
|
|
|
$isSearch.val('');
|
|
|
$maxValueLen.val('');
|
|
|
$isAllowAlias.val('');
|
|
|
$orderBy.val('');
|
|
|
$attributeValues.val('');
|
|
|
$displayPosition.val('');
|
|
|
$remark.val('');
|
|
|
$attributeId.val('');
|
|
|
}
|
|
|
|
|
|
exports.init = function () {
|
|
|
|
...
|
...
|
@@ -90,6 +119,8 @@ exports.init = function () { |
|
|
$('.model-attr-btn').removeAttr('disabled');
|
|
|
|
|
|
$('input#categoryId').val($this.attr('data-val'));
|
|
|
|
|
|
queryAttrList($this.attr('data-val'));
|
|
|
}
|
|
|
|
|
|
} else {
|
...
|
...
|
@@ -147,66 +178,67 @@ exports.init = function () { |
|
|
|
|
|
$('.add-attr-btn').click(function(){
|
|
|
|
|
|
if (!!$('#attributeName').attr('update')) {
|
|
|
$('#add-attr-form').attr('action','/product/attr/update');
|
|
|
}
|
|
|
|
|
|
addAttrVerification.submit($("#add-attr-form").attr("action"), function(option,that) {
|
|
|
option.success=function(res){
|
|
|
console.log('success');
|
|
|
|
|
|
$('#addAttr').modal('toggle')
|
|
|
console.log(res);
|
|
|
|
|
|
$('#addAttr').modal('toggle');
|
|
|
|
|
|
removeAttr();
|
|
|
};
|
|
|
option.error=function(res){
|
|
|
console.log('error');
|
|
|
console.log(res);
|
|
|
}
|
|
|
});
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
//添加产品属性下拉框实例化
|
|
|
new dropDown({
|
|
|
el:'.attr-select'
|
|
|
});
|
|
|
|
|
|
console.log($('input#categoryId').val());
|
|
|
// 编辑产品属性
|
|
|
$(document).on('click', '.edit-class-btn', function () {
|
|
|
|
|
|
var tableGird = new grid({
|
|
|
var $this = $(this);
|
|
|
var attrId = $this.attr('attribute-id');
|
|
|
|
|
|
el:"#attr-table",
|
|
|
parms:function(){
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
dataType: 'json',
|
|
|
url: '/product/attr/getProductAttribute',
|
|
|
data: {
|
|
|
attributeId: attrId*baseNum
|
|
|
}
|
|
|
}).then(function (d) {
|
|
|
var data = d.data.data;
|
|
|
$attributeName.val(data.attributeName).attr('update', 'true');
|
|
|
$saleType.val(data.saleType);
|
|
|
$inputType.val(data.inputType);
|
|
|
$isMust.val(data.isMust);
|
|
|
$isSearch.val(data.isSearch);
|
|
|
$maxValueLen.val(data.maxValueLen);
|
|
|
$isAllowAlias.val(data.isAllowAlias);
|
|
|
$orderBy.val(data.orderBy);
|
|
|
$attributeValues.val(data.attributeValues);
|
|
|
$displayPosition.val(data.displayPosition);
|
|
|
$remark.val(data.remark);
|
|
|
$attributeId.val(attrId);
|
|
|
|
|
|
// 显示dialog
|
|
|
$('#addAttr').modal('toggle');
|
|
|
|
|
|
|
|
|
console.log(d);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
return {
|
|
|
param: 6
|
|
|
};
|
|
|
},
|
|
|
columns:[
|
|
|
{
|
|
|
display: "属性名称",
|
|
|
name: "attributeName"
|
|
|
}, {
|
|
|
display: "属性类型",
|
|
|
name: "attributeType"
|
|
|
}, {
|
|
|
display: "输入类型",
|
|
|
name: "inputType"
|
|
|
}, {
|
|
|
display: "是否必选",
|
|
|
name:"isMust",
|
|
|
render:function(item){
|
|
|
return convertNorY(item.isMust);
|
|
|
}
|
|
|
}, {
|
|
|
display: "是否可搜索",
|
|
|
name: "isSearch",
|
|
|
render: function(item){
|
|
|
return convertNorY(item.isSearch);
|
|
|
}
|
|
|
}, {
|
|
|
display:"操作",
|
|
|
name:"categoryId",
|
|
|
render:function(items){
|
|
|
|
|
|
return ('<button class="btn btn-success btn-xs edit-class-btn">编辑</button>');
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
$('.add-attr-btn-close').click(function () {
|
|
|
|
|
|
removeAttr();
|
|
|
});
|
|
|
tableGird.init('/product/attr/queryProductAttributeList');
|
|
|
|
|
|
}; |
|
|
\ No newline at end of file |
...
|
...
|
|