quanwei
2 days ago 04102f7237efefa744090ed7c25f7b5d0807b679
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<template>
  <!--
          作者:luoyiming
          时间:2019-10-24
          描述:插件首页
      -->
  <div class="plus-container">
    <!--插件首页-->
    <div class="common-level-rail">
      <!-- <el-button size="small" type="primary" icon="el-icon-plus" @click="addType">添加类别</el-button> -->
    </div>
 
    <div v-for="(item, index) in tableData" :key="index" class="mb16">
      <div class="common-form d-s-c">
        <span>{{item.name}}</span>
        <!-- <a href="javascript:void(0);" class="close-btn ml10 d-c-c" @click="deleteClick(item)">
          <i class="el-icon-error f20"></i>
        </a> -->
      </div>
      <div class="plus-list">
        <div class="item" v-for="(child, num) in item.children" :key="num">
          <div class="item-box pr">
            <a href="javascript:void(0);" class="close-btn" @click="deleteClick(child)">
              <i class="el-icon-error f20"></i>
            </a>
            <a>
              <span class="iconfont icon icon-tubiaozhizuomoban-"></span>
              <div class="ml10">
                <h3>{{child.name}}</h3>
                <p>{{child.remark}}</p>
              </div>
            </a>
          </div>
        </div>
        <div class="item">
          <div class="d-s-c mt10">
            <div class="add-item-box d-c-c" @click="addClick(item)"><i class="el-icon-plus"></i></div>
            <div class="ml10">
              <p class="f14 gray9">添加插件到此类别下</p>
            </div>
          </div>
        </div>
      </div>
    </div>
 
    <!--类别-->
    <Type v-if="open_type" :open_type="open_type" @closeDialog="closeDialogFunc($event, 'type')"></Type>
 
    <!--添加-->
    <Add v-if="open_add" :open_add="open_add" :curModel="curModel" @closeDialog="closeDialogFunc($event, 'add')"></Add>
 
    <!--编辑-->
    <Edit v-if="open_edit" :open_edit="open_edit" :curModel="curModel" @closeDialog="closeDialogFunc($event, 'edit')"></Edit>
  </div>
</template>
 
<script>
import PlugsApi from '@/api/plugs.js';
import Edit from './dialog/Edit.vue';
import Add from './dialog/Add';
import Type from './dialog/Type';
import { deepClone } from '@/utils/base.js';
export default {
  components: {
    /*编辑组件*/
    Edit: Edit,
    Add: Add,
    Type
  },
  data() {
    return {
      /*是否正在加载*/
      loading: true,
      /*表格数据*/
      tableData: [],
      /*总条数*/
      totalDataNumber: 0,
      /*是否打开添加弹窗*/
      open_add: false,
      /*是否打开编辑弹窗*/
      open_edit: false,
      /*是否打开类别弹窗*/
      open_type: false,
      /*当前编辑的对象*/
      curModel: {}
    };
  },
  created() {
    /*获取列表*/
    this.getData();
  },
  methods: {
 
    /*获取列表*/
    getData() {
      let self = this;
      let Params = {};
      PlugsApi.plugslist(Params, true)
        .then(res => {
          self.loading = false;
          self.tableData = res.data.accessList;
          self.totalDataNumber = res.data.list.total;
        })
        .catch(error => {
          self.loading = false;
        });
    },
 
    /*添加插件类别*/
    addType(){
      this.open_type=true;
      //this.tableData.push({plus_name:'新类别'});
    },
 
    /*启用插件*/
    statusChange: function(checked, row) {
      let self = this;
      self.loading = true;
      PlugsApi.updatePlugsStatus(
        {
          plus_id: row.plus_id
        },
        true
      )
        .then(data => {
          self.loading = false;
          row.status = checked;
        })
        .catch(error => {
          self.loading = false;
          row.status = !checked;
        });
    },
 
    /*推荐插件*/
    recomChange: function(checked, row) {
      let self = this;
      self.loading = true;
      PlugsApi.updatePlugsRecom(
        {
          plus_id: row.plus_id
        },
        true
      )
        .then(data => {
          self.loading = false;
          row.is_recom = checked;
          console.log(row);
        })
        .catch(error => {
          self.loading = false;
          row.is_recom = !checked;
        });
    },
 
    /*打开添加*/
    addClick(e) {
      this.curModel=e;
      this.open_add = true;
    },
 
    /*打开编辑*/
    editClick(item) {
      // this.userModel = item;
      this.userModel = deepClone(item);
      this.open_edit = true;
    },
 
    closeDialogFunc(e, f) {
      if (f == 'type') {
        this.open_type = e.openDialog;
        if (e.type == 'success') {
          this.tableData.push({plus_name:'新类别'});
        }
      }
      if (f == 'add') {
        this.open_add = e.openDialog;
        if (e.type == 'success') {
          this.getData();
        }
      }
      if (f == 'edit') {
        this.open_edit = e.openDialog;
        if (e.type == 'success') {
          this.getData();
        }
      }
    },
    /*删除插件*/
    deleteClick(row) {
      let self = this;
      self
        .$confirm('删除后不可恢复,确认删除该记录吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
        .then(() => {
          self.loading = true;
          PlugsApi.deleteplugs(
            {
              plus_id: row.access_id
            },
            true
          )
            .then(data => {
              if (data.code == 1) {
                self.loading = false;
                self.$message({
                  message: data.msg,
                  type: 'success'
                });
                self.getData();
              }
            })
            .catch(error => {
              self.loading = false;
            });
        })
        .catch(() => {});
    }
  }
};
</script>
 
<style>
.plus-container {
  min-height: 400px;
}
.plus-container .common-form .close-btn{ color: #CCCCCC;}
.plus-list {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
}
.plus-list .item {
  width: 25%;
}
.plus-list .item .item-box {
  margin: 0 10px 20px;
  border:1px solid #FFFFFF;
}
.plus-list .item .item-box .close-btn{ position: absolute; padding-left: 0; width: 20px; height: 20px; top: 20px; right: 4px; color: #ff0000; display: none;}
.plus-list .item .item-box:hover{ border-radius: 8px; border:1px dashed #CCCCCC;}
.plus-list .item .item-box:hover .close-btn{display: block;}
.plus-list .item .add-item-box {
  width: 40px;
  height: 40px;
  margin-left: 20px;
  border-radius: 8px;
  border: 1px solid #186eeb;
}
.plus-list .item a {
  display: flex;
  height: 60px;
  padding-left: 10px;
  justify-content: flex-start;
  align-items: center;
}
.plus-list .item a h3 {
  font-weight: normal;
  color: #333333;
}
.plus-list .item a:hover h3 {
  color: #3a8ee6;
}
.plus-list .item a p {
  font-size: 12px;
  color: #999999;
}
.plus-list .item .item-box .iconfont {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  line-height: 40px;
  background: #3a8ee6;
}
.plus-list .item a .iconfont.icon {
  font-size: 22px;
  color: #ffffff;
}
</style>