|
@@ -7,7 +7,6 @@ $(function () {
|
|
|
{label: '商品名称', name: 'name', index: 'name', width: 160},
|
|
|
{label: '商品分类', name: 'categoryName', index: 'category_id', width: 80},
|
|
|
{label: '店铺名称', name: 'brandName', index: 'brand_id', width: 120},
|
|
|
-
|
|
|
{
|
|
|
label: '录入日期', name: 'addTime', index: 'add_time', width: 80, formatter: function (value) {
|
|
|
return transDate(value, 'yyyy-MM-dd');
|
|
@@ -62,10 +61,67 @@ var setting = {
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
+var guigeDetailHeader = [
|
|
|
+ {
|
|
|
+ name:'库存',
|
|
|
+ id:'goodsNumber'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name:'规格编码',
|
|
|
+ id:'goodsSn'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name:'市场价',
|
|
|
+ id:'marketPrice'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name:'销售价',
|
|
|
+ id:'retailPrice'
|
|
|
+ },
|
|
|
+
|
|
|
+]
|
|
|
+
|
|
|
+var val1 = [
|
|
|
+ {
|
|
|
+ val:'20码',
|
|
|
+ id:'20m'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ val:'30码',
|
|
|
+ id:'30m'
|
|
|
+ }
|
|
|
+]
|
|
|
+
|
|
|
+var val2 = [
|
|
|
+ {
|
|
|
+ val:'10寸',
|
|
|
+ id:'10c'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ val:'20寸',
|
|
|
+ id:'20c'
|
|
|
+ },
|
|
|
+]
|
|
|
+
|
|
|
+var val3 = [
|
|
|
+ {
|
|
|
+ val:'毛坯房',
|
|
|
+ id:'mp'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ val:'精装房',
|
|
|
+ id:'jz'
|
|
|
+ }
|
|
|
+]
|
|
|
+
|
|
|
+var isFrist = true
|
|
|
+
|
|
|
+
|
|
|
var vm = new Vue({
|
|
|
el: '#rrapp',
|
|
|
- data(){
|
|
|
- const validateBrandIdCheck = (rule, value, callback) => {
|
|
|
+ data: function () {
|
|
|
+ const validateBrandIdCheck =function (rule, value, callback) {
|
|
|
if (value === '' || !value) {
|
|
|
callback(new Error('店铺不能为空'));
|
|
|
}else {
|
|
@@ -73,7 +129,12 @@ var vm = new Vue({
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- const validateCategoryNameCheck = (rule, value, callback) => {
|
|
|
+
|
|
|
+ const validateCategoryNameCheck =function (rule, value, callback) {
|
|
|
+ if (isFrist) {
|
|
|
+ isFrist = false
|
|
|
+ return
|
|
|
+ }
|
|
|
if (value === '' || !value || value==='一级分类') {
|
|
|
callback(new Error('请选择商品类型'));
|
|
|
} else {
|
|
@@ -81,6 +142,8 @@ var vm = new Vue({
|
|
|
}
|
|
|
};
|
|
|
return {
|
|
|
+ ggheader:guigeDetailHeader,
|
|
|
+ ggContent:'',
|
|
|
showList: true,
|
|
|
title: null,
|
|
|
uploadList: [],
|
|
@@ -99,7 +162,7 @@ var vm = new Vue({
|
|
|
},
|
|
|
ruleValidate: {
|
|
|
categoryName: [
|
|
|
- {required: true, validator: validateCategoryNameCheck, trigger: 'blur'}
|
|
|
+ {required: true, validator: validateCategoryNameCheck, trigger: 'change'}
|
|
|
],
|
|
|
goodsSn: [
|
|
|
{required: true, message: '商品序列号不能为空', trigger: 'blur'}
|
|
@@ -123,13 +186,226 @@ var vm = new Vue({
|
|
|
},
|
|
|
brands: [],//品牌
|
|
|
macros: [],//商品单位
|
|
|
- attributeCategories: []//属性类别
|
|
|
+ attributeCategories: [],//属性类别
|
|
|
+ specifications: [],
|
|
|
+ ggname:[],
|
|
|
+ guigeArr:[{
|
|
|
+ name:'',
|
|
|
+ val:[
|
|
|
+ {
|
|
|
+ name:'',
|
|
|
+ picUrl:''
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }],
|
|
|
+ currenIdx:'',
|
|
|
+ currenI:'',
|
|
|
+ inputArr:[],
|
|
|
+ goodsSpecificationList:[]
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ getInputArr:function(){
|
|
|
+ let uuidLink = []
|
|
|
+ var arr = []
|
|
|
+ this.ggContent.forEach(function (item){
|
|
|
+ uuidLink = []
|
|
|
+ uuidLink.push(item.uuid)
|
|
|
+ if (item.subItems) {
|
|
|
+ item.subItems.forEach(function(sub){
|
|
|
+ uuidLink.push(sub.uuid)
|
|
|
+ if (sub.subItems) {
|
|
|
+ sub.subItems.forEach(function(last){
|
|
|
+ uuidLink.push(last.uuid)
|
|
|
+ if (!last.subItems) {
|
|
|
+ arr.push(Object.assign({},{
|
|
|
+ uuidLink:uuidLink.join('_')
|
|
|
+ },last.inputVal))
|
|
|
+ uuidLink.pop()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ arr.push(Object.assign({},{
|
|
|
+ uuidLink:uuidLink.join('_')
|
|
|
+ },sub.inputVal))
|
|
|
+ uuidLink.pop()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ arr.push(Object.assign({},{
|
|
|
+ uuidLink:uuidLink.join('_')
|
|
|
+ },item.inputVal))
|
|
|
+ uuidLink.pop()
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // console.log(this.ggContent)
|
|
|
+
|
|
|
+ this.inputArr = arr
|
|
|
+ },
|
|
|
+ showArrsds:function () {
|
|
|
+ // console.log(this.inputArr)
|
|
|
+ // console.log(this.guigeArr)
|
|
|
+ },
|
|
|
+ transToGuigeArr:function (arr) {
|
|
|
+ let temp = []
|
|
|
+ let tepName = arr.map(function (item) {
|
|
|
+ return item.specificationName
|
|
|
+ })
|
|
|
+ tepName = []
|
|
|
+ arr.forEach(function (item) {
|
|
|
+ if (!~tepName.indexOf(item.specificationName)) {
|
|
|
+ tepName.push(item.specificationName)
|
|
|
+ temp.push({
|
|
|
+ name: item.specificationName,
|
|
|
+ val:[
|
|
|
+ {
|
|
|
+ name:item.value,
|
|
|
+ picUrl:item.picUrl,
|
|
|
+ uuid:item.uuid,
|
|
|
+ id:item.id
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ temp.forEach(function (sub) {
|
|
|
+ // console.log(sub)
|
|
|
+ if (sub.name === item.specificationName) {
|
|
|
+ sub.val.push(
|
|
|
+ {
|
|
|
+ name:item.value,
|
|
|
+ picUrl:item.picUrl,
|
|
|
+ uuid:item.uuid,
|
|
|
+ id:item.id
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ this.guigeArr = temp
|
|
|
+ this.showArr()
|
|
|
+ // guigeArr:[{
|
|
|
+ // name:'',
|
|
|
+ // val:[
|
|
|
+ // {
|
|
|
+ // name:'',
|
|
|
+ // picUrl:''
|
|
|
+ // }
|
|
|
+ // ]
|
|
|
+ // }]
|
|
|
+ },
|
|
|
+ showArr:function () {
|
|
|
+ let tmp = []
|
|
|
+ let itm = []
|
|
|
+ let goodsSpecificationList = []
|
|
|
+ this.ggname = []
|
|
|
+ this.guigeArr.forEach(function(item,idx){
|
|
|
+ itm = []
|
|
|
+ item.val.forEach(function(sub,i){
|
|
|
+ let tt= {
|
|
|
+ value:sub.name,
|
|
|
+ picUrl:sub.picUrl||'',
|
|
|
+ uuid:sub.uuid||((idx+1)+'-'+(i+1)),
|
|
|
+ specificationId: item.specificationId,
|
|
|
+ inputVal:{
|
|
|
+ goodsNumber:'',
|
|
|
+ goodsSn:'',
|
|
|
+ retailPrice:'',
|
|
|
+ marketPrice:''
|
|
|
+ }
|
|
|
+ }
|
|
|
+ itm.push(tt)
|
|
|
+ goodsSpecificationList.push(tt)
|
|
|
+ })
|
|
|
+ vm.ggname.push({
|
|
|
+ name:item.name
|
|
|
+ })
|
|
|
+ tmp.push(itm)
|
|
|
+ })
|
|
|
+
|
|
|
+ tmp[0].forEach(function (i1){
|
|
|
+ if (tmp[1]) {
|
|
|
+ i1['subItems'] = tmp[1]
|
|
|
+ i1['subItems'].forEach(function (i2){
|
|
|
+ if (tmp[2]) {
|
|
|
+ i2['subItems'] = tmp[2]
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ this.ggContent = tmp[0]
|
|
|
+ // console.log(this.guigeArr)
|
|
|
+ this.goodsSpecificationList = goodsSpecificationList
|
|
|
+ this.getInputArr()
|
|
|
+ },
|
|
|
+ handleItem: function (idx,sub) {
|
|
|
+ this.$set(this.guigeArr[idx],'name',sub.name)
|
|
|
+ this.$set(this.guigeArr[idx],'picUrl','')
|
|
|
+ this.$set(this.guigeArr[idx],'specificationId',sub.id)
|
|
|
+ this.$set(this.guigeArr[idx],'show',false)
|
|
|
+ },
|
|
|
+
|
|
|
+ handleBigItem:function (item) {
|
|
|
+ this.guigeArr.splice(item,1)
|
|
|
+ },
|
|
|
+ handleCurrentIdx: function (i,idx) {
|
|
|
+ vm.currenIdx = idx
|
|
|
+ vm.currenI = i
|
|
|
+
|
|
|
+ },
|
|
|
+ handleItemPicUrl: function (res, file) {
|
|
|
+ console.log('currenIdx',vm.currenIdx)
|
|
|
+ vm.$set(vm.guigeArr[vm.currenI]['val'][vm.currenIdx],'picUrl',file.response.url)
|
|
|
+ this.guigeArr = vm.guigeArr
|
|
|
+ },
|
|
|
+ onfocus:function (idx) {
|
|
|
+ this.$set(this.guigeArr[idx],'show',true)
|
|
|
+ },
|
|
|
+ onblur:function (idx) {
|
|
|
+ this.$set(this.guigeArr[idx],'show',false)
|
|
|
+ },
|
|
|
+ delguige:function (item,parent) {
|
|
|
+ parent.splice(item,1)
|
|
|
+ },
|
|
|
+ addguige:function (item) {
|
|
|
+ item.val.push({
|
|
|
+ name:'',
|
|
|
+ picUrl:''
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ addGoodsItem:function () {
|
|
|
+ if (this.guigeArr.length<3) {
|
|
|
+ this.guigeArr.push({
|
|
|
+ name:'',
|
|
|
+ val:[
|
|
|
+ {
|
|
|
+ name:'',
|
|
|
+ picUrl:''
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
query: function () {
|
|
|
vm.reload();
|
|
|
},
|
|
|
+ getSpecification: function () {
|
|
|
+ Ajax.request({
|
|
|
+ url: "../specification/queryAll",
|
|
|
+ async: true,
|
|
|
+ successCallback: function (r) {
|
|
|
+ vm.specifications = r.list;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
add: function () {
|
|
|
vm.showList = false;
|
|
|
vm.title = "新增";
|
|
@@ -143,6 +419,9 @@ var vm = new Vue({
|
|
|
isAppExclusive: 0,
|
|
|
isLimited: 0,
|
|
|
isHot: 0,
|
|
|
+ goodsNumber:1,
|
|
|
+ retailPrice:1,
|
|
|
+ marketPrice:1,
|
|
|
categoryName: ''
|
|
|
};
|
|
|
$('#goodsDesc').editable('setHTML', '');
|
|
@@ -150,10 +429,26 @@ var vm = new Vue({
|
|
|
vm.brands = [];
|
|
|
vm.macros = [];
|
|
|
vm.attributeCategories = [];
|
|
|
+ vm.ggname=[]
|
|
|
+ vm.guigeArr=[{
|
|
|
+ name:'',
|
|
|
+ val:[
|
|
|
+ {
|
|
|
+ name:'',
|
|
|
+ picUrl:''
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }]
|
|
|
+ vm.ggContent='',
|
|
|
+ vm.currenIdx=''
|
|
|
+ vm.currenI=''
|
|
|
+ vm.inputArr=[]
|
|
|
+ vm.goodsSpecificationList=[]
|
|
|
// vm.attribute = [];
|
|
|
vm.getBrands();
|
|
|
vm.getMacro();
|
|
|
vm.getAttributeCategories();
|
|
|
+ vm.getSpecification();
|
|
|
// vm.getAttributes('');
|
|
|
},
|
|
|
update: function (event) {
|
|
@@ -215,8 +510,17 @@ var vm = new Vue({
|
|
|
saveOrUpdate: function (event) {
|
|
|
var url = vm.goods.id == null ? "../goods/save" : "../goods/update";
|
|
|
vm.goods.goodsDesc = $('#goodsDesc').editable('getHTML');
|
|
|
+
|
|
|
vm.goods.goodsImgList = vm.uploadList;
|
|
|
|
|
|
+ vm.goods['goodsSpecificationList'] = vm.goodsSpecificationList
|
|
|
+
|
|
|
+ vm.goods['productList'] = vm.inputArr
|
|
|
+
|
|
|
+ vm.goods['guigeArr'] = JSON.stringify(vm.guigeArr)
|
|
|
+
|
|
|
+ vm.goods['ggContent'] = JSON.stringify(vm.ggContent)
|
|
|
+
|
|
|
Ajax.request({
|
|
|
type: "POST",
|
|
|
url: url,
|
|
@@ -323,8 +627,28 @@ var vm = new Vue({
|
|
|
async: true,
|
|
|
successCallback: function (r) {
|
|
|
vm.goods = r.goods;
|
|
|
+ // vm.goodsSpecificationList = r.goods.goodsSpecificationList
|
|
|
+ vm.inputArr = r.goods.productList
|
|
|
+
|
|
|
+ vm.guigeArr = JSON.parse(r.goods.guigeArr)
|
|
|
+ vm.ggContent = JSON.parse(r.goods.ggContent)
|
|
|
+
|
|
|
+
|
|
|
+ vm.ggname = []
|
|
|
+
|
|
|
+ vm.guigeArr.forEach(function (item){
|
|
|
+ vm.ggname.push({
|
|
|
+ name:item.name
|
|
|
+ })
|
|
|
+ })
|
|
|
+ // vm.showArr()
|
|
|
+ // console.log(vm.guigeArr)
|
|
|
+ // console.log(vm.ggContent)
|
|
|
+
|
|
|
$('#goodsDesc').editable('setHTML', vm.goods.goodsDesc);
|
|
|
vm.getCategory();
|
|
|
+ vm.getSpecification();
|
|
|
+ // vm.transToGuigeArr(r.goods.goodsSpecificationList)
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -373,22 +697,22 @@ var vm = new Vue({
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- handleView(name) {
|
|
|
+ handleView:function(name) {
|
|
|
this.imgName = name;
|
|
|
this.visible = true;
|
|
|
},
|
|
|
- handleRemove(file) {
|
|
|
+ handleRemove:function(file) {
|
|
|
// 从 upload 实例删除数据
|
|
|
const fileList = this.uploadList;
|
|
|
this.uploadList.splice(fileList.indexOf(file), 1);
|
|
|
},
|
|
|
- handleSuccess(res, file) {
|
|
|
+ handleSuccess:function(res, file) {
|
|
|
// 因为上传过程为实例,这里模拟添加 url
|
|
|
file.imgUrl = res.url;
|
|
|
file.name = res.url;
|
|
|
vm.uploadList.add(file);
|
|
|
},
|
|
|
- handleBeforeUpload() {
|
|
|
+ handleBeforeUpload:function() {
|
|
|
const check = this.uploadList.length < 5;
|
|
|
if (!check) {
|
|
|
this.$Notice.warning({
|
|
@@ -423,6 +747,10 @@ var vm = new Vue({
|
|
|
handleSuccessListPicUrl: function (res, file) {
|
|
|
vm.goods.listPicUrl = file.response.url;
|
|
|
},
|
|
|
+
|
|
|
+ eyeImageItemPicUrl: function (url) {
|
|
|
+ eyeImage(url);
|
|
|
+ },
|
|
|
eyeImagePicUrl: function () {
|
|
|
var url = vm.goods.primaryPicUrl;
|
|
|
eyeImage(url);
|
|
@@ -435,7 +763,8 @@ var vm = new Vue({
|
|
|
eyeImage($(e.target).attr('src'));
|
|
|
}
|
|
|
},
|
|
|
- mounted() {
|
|
|
+ mounted:function() {
|
|
|
+ // this.transToGuigeArr()
|
|
|
this.uploadList = this.$refs.upload.fileList;
|
|
|
this.getBrands()
|
|
|
}
|