|
@@ -0,0 +1,161 @@
|
|
|
+jqMultipleShow("click", ".navList", ".tab", ".con");
|
|
|
+var Brandgoods =new Vue({
|
|
|
+ el:'#Brandgoods',
|
|
|
+ data:{
|
|
|
+ params:{
|
|
|
+ userID: '',
|
|
|
+ pageNum :1,
|
|
|
+ pageSize:10,
|
|
|
+ name:'',
|
|
|
+ status:''
|
|
|
+ },
|
|
|
+ brandobj:{
|
|
|
+ userID:'',
|
|
|
+ name:'',
|
|
|
+ logo:'',
|
|
|
+ description:''
|
|
|
+ },
|
|
|
+ title:'',
|
|
|
+ formData:new FormData(),
|
|
|
+ brandlist:[],
|
|
|
+ pageInput: '1',
|
|
|
+ listRecord: 0,
|
|
|
+ bgflag:false,
|
|
|
+ logoShow:false,
|
|
|
+ iconflag:true
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ pageTotal: function () {
|
|
|
+ var total = Math.ceil(this.listRecord / this.params.pageSize);
|
|
|
+ return total > 0 ? total : 1;
|
|
|
+ },
|
|
|
+ showPageBtn: function () {
|
|
|
+ var total = Math.ceil(this.listRecord / this.params.pageSize);
|
|
|
+ total = total > 0 ? total : 1;
|
|
|
+ var index = this.params.pageNum, arr = [];
|
|
|
+ if (total <= 6) {
|
|
|
+ for (var i = 1; i <= total; i++) {
|
|
|
+ arr.push(i);
|
|
|
+ }
|
|
|
+ return arr;
|
|
|
+ }
|
|
|
+ if (index <= 3) return [1, 2, 3, 4, 5, 0, total];
|
|
|
+ if (index >= total - 2) return [1, 0, total - 4, total - 3, total - 2, total - 1, total];
|
|
|
+ return [1, 0, index - 2, index - 1, index, index + 1, index + 2, 0, total];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods:{
|
|
|
+ toPagination: function (pageNum) {
|
|
|
+ if (pageNum <= this.pageTotal) {
|
|
|
+ this.params.pageNum = pageNum;
|
|
|
+ this.BrandList(this.params);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ checkNum: function () {
|
|
|
+ if (this.pageInput > this.pageTotal) {
|
|
|
+ this.pageInput = this.pageTotal;
|
|
|
+ } else if (this.pageInput < 1) {
|
|
|
+ this.pageInput = 1;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ BrandList:function () {
|
|
|
+ var _this = this;
|
|
|
+ SupplierApi.brandList(_this.params,function (res) {
|
|
|
+ if(res.code==0){
|
|
|
+ if(res.data.results && res.data.results.length>0){
|
|
|
+ _this.brandlist=res.data.results;
|
|
|
+ console.log(_this.brandlist)
|
|
|
+ _this.listRecord = res.data.totalRecord;
|
|
|
+ }else{
|
|
|
+ _this.results = res.data.results;
|
|
|
+ _this.listRecord = res.data.totalRecord;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getstatus:function () { //状态
|
|
|
+ var _this = this;
|
|
|
+ _this.params.status=event.target.value;
|
|
|
+ },
|
|
|
+ queryBrand:function () { //查询
|
|
|
+ var _this = this;
|
|
|
+ _this.BrandList()
|
|
|
+ },
|
|
|
+ newBrand:function(){
|
|
|
+ var _this = this;
|
|
|
+ _this.bgflag = true;
|
|
|
+ _this.title = '添加新品牌'
|
|
|
+ },
|
|
|
+ submit:function(){ //确认提交新品牌
|
|
|
+ var _this = this;
|
|
|
+ console.log(_this.brandobj)
|
|
|
+ if(_this.brandobj.name ==''){
|
|
|
+ CAIMEI.dialog('请输入品牌名称')
|
|
|
+ }else {
|
|
|
+ SupplierApi.addBrand(_this.brandobj,function (res) {
|
|
|
+ if (res.code==0){
|
|
|
+ CAIMEI.Alert('提交成功,我们将会在1-2个工作日内审核','确定',true,function () {
|
|
|
+ location.reload()
|
|
|
+ });
|
|
|
+ _this.closebg();
|
|
|
+ } else if(res.code == -1){
|
|
|
+ var errmsg = res.msg;
|
|
|
+ if(errmsg.indexOf('请先登录') > -1) {
|
|
|
+ CAIMEI.dialog('请先登录');
|
|
|
+ } else if (errmsg.indexOf('已存在') > -1) {
|
|
|
+ CAIMEI.dialog('有相同品牌存在,无需重复提交,详情请致电0755-22907771');
|
|
|
+ } else {
|
|
|
+ CAIMEI.dialog('网络错误,请稍后再试');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ editBrand:function(item){
|
|
|
+ var _this = this;
|
|
|
+ _this.bgflag = true;
|
|
|
+ _this.title = '编辑新品牌';
|
|
|
+ _this.brandobj.name = item.name;
|
|
|
+ _this.brandobj.description=item.description;
|
|
|
+ if(item.logo !=''&& item.logo!=null){
|
|
|
+ _this.brandobj.logo=item.logo;
|
|
|
+ _this.logoShow = true;
|
|
|
+ _this.iconflag = false;
|
|
|
+ }else {
|
|
|
+ _this.logoShow = false;
|
|
|
+ _this.iconflag = true;
|
|
|
+ }
|
|
|
+ _this.brandobj.id=item.id;
|
|
|
+ },
|
|
|
+ closebg:function () {
|
|
|
+ var _this = this;
|
|
|
+ _this.bgflag = false;
|
|
|
+ _this.brandobj.name='';
|
|
|
+ _this.brandobj.description='';
|
|
|
+ _this.brandobj.logo='';
|
|
|
+ _this.logoShow = false;
|
|
|
+ _this.iconflag = true;
|
|
|
+
|
|
|
+ },
|
|
|
+ uploadlogo:function () { //上传品牌图片
|
|
|
+ var _this = this;
|
|
|
+ var inputDOM = _this.$refs.goodslogo;
|
|
|
+ var file = inputDOM.files;
|
|
|
+ _this.formData.append('file', file[0]);
|
|
|
+ SupplierApi.uploadimg(_this.formData,function(response){
|
|
|
+ _this.brandobj.logo = response.data;
|
|
|
+ _this.logoShow = true;
|
|
|
+ _this.iconflag = false;
|
|
|
+ event.target.value = '';
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted:function () {
|
|
|
+ var _self = this;
|
|
|
+ if(globalUserData){
|
|
|
+ _self.params.userID = globalUserData.userId;
|
|
|
+ _self.brandobj.userID = globalUserData.userId;
|
|
|
+ }
|
|
|
+ _self.BrandList()
|
|
|
+ }
|
|
|
+})
|