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
<template>
  <!--
        作者:luoyiming
        时间:2019-10-25
        描述:插件-添加
    -->
  <el-dialog title="添加插件" :visible.sync="dialogVisible" @close='dialogFormVisible' :close-on-click-modal="false"
    :close-on-press-escape="false">
      <el-table size="small" :data="categoryList" border style="width: 100%" v-loading="loading">
        <el-table-column prop="name" label="名称"></el-table-column>
        <el-table-column prop="name" label="操作" width="80">
          <template slot-scope="scope">
            <el-button @click="addClick(scope.row)" size="small">添加</el-button>
           </template>
        </el-table-column>
      </el-table>
    <!-- <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible">取 消</el-button>
      <el-button type="primary" @click="addClick()" :loading="loading">确 定</el-button>
    </div> -->
  </el-dialog>
</template>
 
<script>
  import PlugsApi from '@/api/plugs.js';
  export default {
    data() {
      return {
        form: {
          status: 0,
          srot: 1,
          plus_name: '',
          desc: '',
          ico: '',
          url: 'index/index',
          sort: 1,
 
        },
        categoryList: [],
        srot: '1',
        radio: '1',
        /*左边长度*/
        formLabelWidth: '120px',
        /*是否显示*/
        dialogVisible: false,
        /*是否正在加载*/
        loading: true,
      };
    },
    props: {
      open_add:Boolean,
      curModel:Object
    },
    created() {
      this.dialogVisible = this.open_add;
      /*获取插件列表*/
      this.getCategoryList();
    },
    methods: {
 
      /*获取插件*/
      getCategoryList() {
        let self = this;
        let Params = {
          plus_category_id:self.curModel.plus_category_id
        };
        PlugsApi.getplugs(Params, true)
          .then(data => {
            self.loading = false;
            self.categoryList = data.data.accessList;
          })
          .catch(error => {
            self.loading = false;
          });
      },
 
      /*添加插件*/
      addClick(e) {
        let self = this;
        let params = {
          access_id:e.access_id,
          plus_category_id:self.curModel.plus_category_id
        };
        PlugsApi.addplugs(params, true).then(res => {
            self.loading = false;
            if (res.code == 1) {
              self.$message({
                message: '恭喜你,添加成功',
                type: 'success'
              });
              self.dialogFormVisible(true);
            } else {
                self.loading = false;
              self.$message.error('错了哦,这是一条错误消息');
            }
          })
          .catch(error => {
              self.loading = false;
          });
      },
 
      /*关闭弹窗*/
      dialogFormVisible(e) {
        if (e) {
          this.$emit('closeDialog', {
            type: 'success',
            openDialog: false
          })
        } else {
          this.$emit('closeDialog', {
            type: 'error',
            openDialog: false
          })
        }
      }
 
    }
  };
</script>
 
<style></style>