1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| Vue.component("grid-s",{ template:"#grid-tpl", props:["list","colums","searchQuery"], data:function(){ return { mode:0, item:{}, title:"", index:0 } }, methods:{ openNewItemDialog:function(title){ this.title=title; this.mode=1; this.item={}; this.$broadcast('showDialog', true); }, createItem:function(){ this.list.push(this.item); this.$broadcast('showDialog', false); wilddog.set(item); this.item = {}; }, delItem:function(index){ this.list.splice(index,1); }, modifyItem:function(){ for (var j in this.item) { this.list[this.index][j] = this.item[j] } this.$broadcast('showDialog', false); this.item = {}; }, openModifyItemDialog:function(item,index){ this.title="Edit "+item.title; this.mode=2; this.item=_.cloneDeep(item); this.index=index; this.$broadcast('showDialog', true); }
}, components:{ "dialog-s":{ template:"#dialog-tpl", props:["mode","title","fields","item","index"], data:function(){ return { show:false } }, methods:{ close:function(){ this.show=false; }, save:function(){ if(this.mode==1){ this.$dispatch('create-item'); } else{ this.$dispatch('modify-item'); } } }, events:{ 'showDialog': function(show) { this.show = show; } } } } }); var demo=new Vue({ el:"#app", data:{ searchQuery:'', colums:[{title:"title"},{title:"sku"},{title:"price"}], list:[{ title:"sony", sku:"23232323A", price:5000 },{ title:"Apple", sku:"45454545A", price:6000 }] } });
|