UNPKG

4.51 kBPlain TextView Raw
1<template>
2 <div style="padding: 0px 100px;" class="flex">
3 <div class="btn-group auto" style="margin-bottom: 30px">
4 <button type="button" class="button_clear button_spacing" style="width: 70px" @click="removeData(ids)">批量删除</button>
5 <button type="button" class="button_new button_spacing" style="width: 70px" @click="add('add-function')">添加功能</button>
6 <button type="button" class="button_search button_spacing" style="width:100px" @click='$goto("adjust-fun-pos", {data: data})'>调整功能位置</button>
7 </div>
8 <div class="datapanel">
9 <h3 class="txtline">&nbsp;&nbsp;【{{data.name}}】功能管理</h3>
10 <data-grid class="list_area table_sy" partial='list' v-ref:grid :model="model">
11 <template partial='head'>
12 <tr>
13 <th>全选
14 <input type="checkbox" class="all-checked" v-model="checked" @click="$parent.$parent.isAll(checked)">
15 </th>
16 <th></th>
17 <th>资源名称</th>
18 <th>修改</th>
19 <th>删除</th>
20 </tr>
21 </template>
22 <template partial='body'>
23 <tr>
24 <td style="text-align: center;">
25 <input type="checkbox" v-model="$parent.$parent.ids" :value="row">
26 </td>
27 <td style="text-align: center;"><img :src="$parent.$parent.imgsrc(row.f_icon)" alt=""></td>
28 <td style="text-align: center;">{{row.name}}</td>
29 <td style="text-align: center;"><img height="15" width="15" src="../../../static/ldaplefticon/修改.png" @click="$parent.$parent.add('add-function', row)"></img></td>
30 <td style="text-align: center;"><img height="15" width="15" src="../../../static/ldaplefticon/删除.png" @click="$parent.$parent.removeData([row])"></img></td>
31 </tr>
32 </template>
33 </data-grid>
34 </div>
35 </div>
36</template>
37
38<script>
39import co from 'co'
40import * as Util from '../Util'
41
42let gen = function * (self) {
43 //self.model = yield self.$post('rs/search', {source: `tool.getChildren($${self.data.id}$)`, userid: self.userid},{resolveMsg: null, rejectMsg: null})
44 self.model = yield self.$http.post('rs/search',{source: `tool.getChildren($${self.data.id}$).where(true)`, userid: self.userid})
45 // console.log(self.model)
46}
47let deleteData = function * (self,data) {
48 //yield self.$post('rs/data/delete', {data: data},{resolveMsg:null, rejectMsg:null})
49 let msg = yield self.$http.post('rs/data/delete',{data : data})
50 yield self.$showMessage(msg.bodyText)
51 self.ids = []
52 self.flush()
53 self.refresh()
54}
55export default {
56 title: '功能模块',
57 props: ['data', 'userid'],
58 ready() {
59 this.$parent.setTitle(this.data.name)
60 this.refresh()
61 },
62 data () {
63 return {
64 ids: [], // 处理全选和部分选择使用
65 model: ''
66 }
67 },
68 methods: {
69 flush(){
70 this.$parent.$parent.$parent.$parent.flush()
71 },
72 // 刷新数据
73 refresh () {
74 let g = gen(this)
75 co(g)
76 },
77 add(name, row) {
78 // console.log(name)
79 let parent = this.data
80 let del = delete parent.children
81 this.$goto(name, {parent: parent, data: row}, 'self', this.isRefresh)
82 },
83 isAll (checked) {
84 this.ids = []
85 if (!checked) {
86 this.model.data.forEach((row) => {
87 this.ids.push(row)
88 })
89 }
90 },
91 imgsrc (name) {
92 return Util.getImgsrc(name)
93 },
94 removeData (data) {
95 var removeName = ''
96 data.forEach((item) => {
97 removeName = removeName + item.name + ';'
98 })
99 if(data.length>0){
100 this.$showMessage('确定要删除【'+removeName+'】', ['confirm', 'cancel']).then((res) => {
101 if (res === 'confirm') {
102 let d = deleteData(this,data)
103 co(d)
104 }
105 })
106 } else {
107 this.$showMessage('请选择删除项!')
108 }
109 },
110 isRefresh (param) {
111 if (param === 'refresh') {
112 this.refresh()
113 }
114 }
115 // modify(row) {
116 // this.$goto("modify-function", {parentname: this.datas.name, parentid: this.datas.id, row: row})
117 // }
118 }
119}
120</script>
121<style>
122 .all-checked {
123 vertical-align: text-top;
124 margin-left: 10px !important;
125 }
126 td > .glyphicon {
127 cursor: pointer;
128 }
129 th > input[type="checkbox"], td > input[type="checkbox"] {
130 cursor: pointer;
131 }
132</style>