diff --git a/dbscript/update_credit.sql b/dbscript/update_credit.sql index b3eda0c7..5b97a8a1 100644 --- a/dbscript/update_credit.sql +++ b/dbscript/update_credit.sql @@ -26,6 +26,7 @@ CREATE TABLE `sa_goods_category` ( `name` varchar(50) DEFAULT NULL COMMENT '分类别名', `icon` varchar(100) DEFAULT NULL COMMENT '图标', `image` varchar(100) DEFAULT NULL COMMENT '大图', + `props` TEXT COMMENT '绑定属性', `sort` int(11) DEFAULT NULL COMMENT '排序', `keywords` varchar(255) DEFAULT NULL COMMENT '分类关键词', `description` varchar(255) DEFAULT NULL COMMENT '分类描述', diff --git a/src/application/admin/view/credit/category/edit.tpl b/src/application/admin/view/credit/category/edit.tpl index 2c495ad2..b6153dab 100644 --- a/src/application/admin/view/credit/category/edit.tpl +++ b/src/application/admin/view/credit/category/edit.tpl @@ -90,6 +90,13 @@ {/if} +
+ +
+ +
+
diff --git a/src/application/admin/view/credit/goods/edit.tpl b/src/application/admin/view/credit/goods/edit.tpl index 7bd33e60..3137f362 100644 --- a/src/application/admin/view/credit/goods/edit.tpl +++ b/src/application/admin/view/credit/goods/edit.tpl @@ -37,7 +37,8 @@
商品分类
@@ -203,15 +204,6 @@ zIndex: 100 }); jQuery(function ($) { - - $('.addpropbtn').click(function (e) { - $('.prop-groups').append('
\n' + - ' \n' + - ' \n' + - ' \n' + - '
'); - }); - $('.taginput').each(function () { $(this).tags('spec_data[' + $(this).data('spec_id') + '][data][]', resetSkus); }); @@ -221,6 +213,49 @@ self.parents('.input-group').remove(); }) }); + function addProp(key, value) { + $('.prop-groups').append('
\n' + + ' \n' + + ' \n' + + ' \n' + + '
'); + } + $('.addpropbtn').click(function (e) { + addProp(); + }); + + function changeCategory(select, force) { + var option = $(select).find('option:selected'); + var curProps = []; + var cid = $(option).val(); + + var props = $(option).data('props') || []; + $('.prop-groups .input-group').each(function () { + var input = $(this).find('input'); + var prop = input.val().trim(); + if (input.eq(1).val().trim() === '') { + if (props.indexOf(prop) < 0) { + $(this).remove(); + } else { + curProps.push(prop); + } + } else { + curProps.push(prop); + } + }); + for (var i = 0; i < props.length; i++) { + if (curProps.indexOf(props[i]) < 0) { + addProp(props[i]); + } + } + } + + $('#goods-cate').change(function (e) { + changeCategory(this); + }); + if ('add' === "{$goods['id']?'':'add'}") { + changeCategory($('#goods-cate'), true); + } });