<template>
 
  <div>
  
 

    <!-- 卡片视图区域 -->
    <el-card class="box-card">
      <div class="search-bx1">
          <el-input v-model="searchData.roleName" placeholder="角色"  style="width: 220px;" class="g-mr20" clearable />
      
          <el-button type="primary"   @click="form_search">搜索</el-button>
          <el-button type="primary"   v-if="isButtonEdit"   @click="form_add">添加角色</el-button>
      </div>


      <!-- 表格 -->
      <el-table   key="0"  :data="tableList"  v-loading="tableLoading" element-loading-text="给我一点时间"  stripe border fit>
        <el-table-column label="序号"  width="50px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.id }}</span>
          </template>
        </el-table-column>
        <el-table-column label="角色" min-width="150px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.name }}</span>
          </template>
        </el-table-column>
        <el-table-column label="更新时间" min-width="150px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.created_at_format }}</span>
          </template>
        </el-table-column>
        <el-table-column label="更新用户" min-width="150px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.created_at_format }}</span>
          </template>
        </el-table-column>
        
    
 
        <!-- <el-table-column  label="状态"  min-width="100px" align="center">
          <template slot-scope="scope">
            <el-switch v-model="scope.row.mg_state" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0"   />
          </template>
        </el-table-column> -->
        <el-table-column label="操作" align="center" width="400" class-name="small-padding fixed-width" fixed="right">
          <template slot-scope="scope">
            <!-- 修改按钮 -->
            <el-button    v-if="isButtonEdit"  type="primary" size="mini" icon="el-icon-edit" @click="form_edit(scope.row)">修改</el-button>
            <!-- 删除按钮 -->
            <el-button   v-if="isButtonEdit"  type="danger" size="mini" icon="el-icon-delete" @click="form_delete(scope.row)">删除</el-button>
            <!-- 分配角色 -->
            <el-button  v-if="isButtonEdit"   type="warning" size="mini" icon="el-icon-setting" @click="form_set(scope.row)">页面权限</el-button>

            <!-- <el-button  type="warning" size="mini" icon="el-icon-setting" @click="form_set2(scope.row)">数据权限</el-button> -->


          </template>
        </el-table-column>
      </el-table>

      <!-- 分页区域 -->
      <el-pagination  @size-change="change_size_page"  @current-change="change_current_page"  :current-page="searchData.pageNum" :page-sizes="[1,5,10,20,30,50]"  :page-size="searchData.pageSize" layout="total, prev, pager, next" :total="searchData.total"/>
    </el-card>


    <!-- 弹窗 新增or修改 -->
    <el-dialog  :title="addFormTxt[addFormStatus]" :visible.sync="addFormShow" @close="add_dialog_close" width="50%">
      <div class="">
        <el-form  ref="addFormRef"  :rules="addFormRules"  :model="addForm"  label-position="right" label-width="70px"  style="width:50%;margin:0 auto 50px">
            <el-form-item label="角色名" prop="name">
                <el-input   v-model="addForm.name"  ></el-input>  
            </el-form-item>
 
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="addFormStatus==='create'?add_dialog_save():edit_dialog_save()">确认</el-button>
          <el-button @click="addFormShow = false">关闭</el-button>
        </div>
      </div>
    </el-dialog>


     
    <!-- 弹窗 分配 -->
    <el-dialog  title="分配权限" :visible.sync="setFormShow" @close="set_dialog_close" width="50%">
      <div class="">
        <el-form  ref="setFormRef"    :model="setForm"  label-position="right" label-width="70px"  style="width:50%;margin:0 auto 50px">
           
           <!-- 树形控件  -->
         <el-tree  ref="tree" :data="rightlist" :props="treeProps" show-checkbox   node-key="id"  default-expand-all :default-checked-keys="checkedIdArr" check-strictly   @check-change="change_check"> </el-tree>
     
            
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="set_dialog_save()">确认</el-button>
          <el-button @click="setFormShow = false">关闭</el-button>
        </div>
      </div>
    </el-dialog>

    <el-dialog  title="数据权限" :visible.sync="setFormShow2" @close="set_dialog_close2" width="50%">
      <div class="">
        <el-form  ref="setFormRef2"    :model="setForm2"  label-position="right" label-width="70px"  style="width:50%;margin:0 auto 50px">
           
          <el-form-item label="数据权限" prop="datarole">
            <el-radio-group v-model="setForm2.datarole">
              <el-radio :label="1">全部数据</el-radio>
              <el-radio :label="0">牧场数据</el-radio>
         
            </el-radio-group>
          </el-form-item>
    
            
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="set_dialog_save2()">确认</el-button>
          <el-button @click="setFormShow2 = false">关闭</el-button>
        </div>
      </div>
    </el-dialog>

 
  </div>


</template> 

<script>
import { ajaxDataGet, ajaxDataPost, ajaxDataPut, ajaxDataDelete, checkButtons} from '@/api/common'
import { parseTime, json2excel } from '@/utils/index.js'
export default {
  data() {

    
    
    return {


      
      //接口 - 获取 - 表格
      url_get_table:'/api/v1/system/role/list',
      //接口 - 新增 - 表格
      url_add_table:'/api/v1/system/role/add',  
      //接口 - 修改 - 表格
      url_edit_table:'/api/v1/system/role/edit', 
      //接口 - 删除 - 表格
      url_delete_table:'/api/v1/system/role', 
      
      isButtonEdit:false,

      //获取 - 表格数据 - 参数
      searchData:{
        name: "",
        min_updated_time: "",
        max_updated_time: "",
        page: 1,  //页码
        page_size: 10,   //每页数量
        total:0,  //总页数
       
 
      },

      tableLoading: false,
      //表格内容
      tableList:[
         {id:1,roleName:'111'}
      ],


    

 


      addFormShow:false,
      addFormStatus: '',
      addFormTxt: {  edit: '修改用户',  create: '新增用户' },
      addForm:{
        name:'',remark:'' 
      },

      addFormRules:{
        name: [
          { required: true, message: '用户名必填', trigger: 'blur' },
          
        ],
        // password: [
        //   { required: true, message: '密码必填', trigger: 'blur' },
        //   { min: 3, max: 15, message: '长度3-15个字符之间', trigger: 'blur' },
        // ],
        // email: [
        //   { required: true, message: '邮箱必填', trigger: 'blur' },
        //   { validator: checkEmail, trigger: 'blur' },
        // ],
        // mobile: [
        //   { required: true, message: '手机号必填', trigger: 'blur' },
        //   { validator: checkMobile, trigger: 'blur' },
        // ],

      },


      setFormShow:false,
      setForm:{
          username:'',password:'',email:'',mobile:'',roleList:[2,3]
      },
      
      rightlistAll:[],
       
      //权限数据
      rightlist: [
        // { "menuName": "数据统计", "parentId": 0,  "sort": 1,  "path": null, "menuId": 1, "type":1,
        //     "children": [
        //         {"menuName": "饲喂过程", "parentId": 1, "sort": 1, "path": 'FeedProcess', "menuId": 10 ,"type":2},
        //         {"menuName": "增重趋势", "parentId": 1, "sort": 2,"path":  'WeightTrend',"menuId": 11 ,"type":2},
        //         {"menuName": "配方效果",  "parentId": 1,"sort": 3, "path": 'FormulaEffect', "menuId": 12,"type":2},
        //         {"menuName": "成长达标率","parentId": 1,"sort": 4,"path": 'GrowthRate',"menuId": 13,"type":2},
        //         {"menuName": "饲料成本","parentId": 1,"sort": 5,"path": 'FeedCost',"menuId": 14,"type":2},
        //         {"menuName": "疾病情况","parentId": 1,"sort": 6,"path": 'DiseaseSituation',"menuId": 15},
        //         {"menuName": "存活率","parentId": 1,"sort": 7,"path": 'SurvivalRate',"menuId": 16},
        //     ]
        // },
        // { "menuName": "牛只管理","parentId": 0,"sort": 2,"path": null,"menuId": 2, "type":1,
        //     "children": [
        //         {"menuName": "称量记录","parentId": 2,"sort": 1,"path": 'WeightRecord',"menuId": 20,"type":2,
        //          "children": [
        //               {"menuName": "称量记录编辑","parentId": 20,"sort": 1, "path": null,"menuId": 201,"type":3},
        //           ]
        //         },
        //         {"menuName": "牛只信息","parentId": 2,"sort": 2,"path": 'CowInfo',"menuId": 21,"type":2,
        //          "children": [
        //               {"menuName": "牛只信息编辑","parentId": 21,"sort": 1, "path": null,"menuId": 211,"type":3},
        //           ]
        //         },
        //         {"menuName": "事件记录","parentId": 2,"sort": 3,"path": 'EventRecord',"menuId": 22,"type":2,
        //          "children": [
        //               {"menuName": "事件记录编辑","parentId": 22,"sort": 1, "path": null,"menuId": 221,"type":3},
        //           ]
        //         }
        //     ]
        // },
        // {"menuName": "栏舍管理","parentId": 0,"sort": 3,"path": null,"menuId": 3, "type":1,
        //     "children": [
        //         {"menuName": "牛只栏舍","parentId": 3,"sort": 1, "path": 'CowCowShed',"menuId": 30,"type":2,
        //          "children": [
        //               {"menuName": "牛只栏舍编辑","parentId": 30,"sort": 1, "path": null,"menuId": 301,"type":3},
        //           ]
        //         },
        //         {"menuName": "栏舍分组","parentId": 3,"sort": 2,"path": 'CowShedGroup',"menuId": 31,"type":2,
        //          "children": [
        //               {"menuName": "栏舍分组编辑","parentId": 31,"sort": 1, "path": null,"menuId": 311,"type":3},
        //           ]
        //         }
        //     ]
        // },
        // {"menuName": "配方计划","parentId": 0,"sort": 4,"path": null,"menuId": 4, "type":1,
        //     "children": [
        //         {"menuName": "饲喂计划","parentId": 4,"sort": 1, "path": 'FeedPlan',"menuId": 40,"type":2,
        //          "children": [
        //               {"menuName": "饲喂计划编辑","parentId": 40,"sort": 1, "path": null,"menuId": 401,"type":3},
        //           ]
        //         },
        //         {"menuName": "配方模板", "parentId": 4,"sort": 2, "path": 'FormulaTemplate',"menuId": 41,"type":2,
        //          "children": [
        //               {"menuName": "配方模板编辑","parentId": 41,"sort": 1, "path": null,"menuId": 411,"type":3},
        //           ]
        //         } 
        //     ]
        // },
        // {"menuName": "工单管理","parentId": 0,"sort": 5,"path": null,"menuId": 5, "type":1,
        //     "children": [
        //         {"menuName": "工单任务(分派)","parentId": 5,"sort": 1, "path": 'WorkTaskAssign',"menuId": 50,"type":2,
        //          "children": [
        //               {"menuName": "工单任务(分派)编辑","parentId": 50,"sort": 1, "path": null,"menuId": 501,"type":3},
        //           ]
        //         },
        //         {"menuName": "工单任务(执行)", "parentId": 5,"sort": 2, "path": 'WorkTaskImplement',"menuId": 51,"type":2,
        //          "children": [
        //               {"menuName": "工单任务(执行)编辑","parentId": 51,"sort": 1, "path": null,"menuId": 511,"type":3},
        //           ]} 
        //     ]
        // },
        // {"menuName": "基础设置","parentId": 0,"sort": 6,"path": null,"menuId": 6, "type":1,
        //     "children": [
        //         {"menuName": "犊牛类型","parentId": 6,"sort": 1, "path": 'CalfType',"menuId": 60,"type":2,
        //          "children": [
        //               {"menuName": "犊牛类型编辑","parentId": 60,"sort": 1, "path": null,"menuId": 601,"type":3},
        //           ]
        //         },
        //         {"menuName": "工单类型", "parentId": 6,"sort": 2, "path": 'WorkOrderType',"menuId": 61,"type":2,
        //          "children": [
        //               {"menuName": "工单类型编辑","parentId": 61,"sort": 1, "path": null,"menuId": 611,"type":3},
        //           ]},
        //         {"menuName": "饲喂车管理", "parentId": 6,"sort": 3, "path": 'FeedCarManagement',"menuId": 62,"type":2,
        //          "children": [
        //               {"menuName": "饲喂车管理编辑","parentId": 62,"sort": 1, "path": null,"menuId": 621,"type":3},
        //           ]},
        //         {"menuName": "疾病管理", "parentId": 6,"sort": 4, "path": 'DiseaseType',"menuId": 63,"type":2,
        //          "children": [
        //               {"menuName": "疾病管理编辑","parentId": 63,"sort": 1, "path": null,"menuId": 631,"type":3},
        //           ]},
        //         {"menuName": "预设饲喂模板", "parentId": 6,"sort": 5, "path": 'FeedTemplate',"menuId": 64,"type":2,
        //          "children": [
        //               {"menuName": "预设饲喂模板编辑","parentId": 64,"sort": 1, "path": null,"menuId": 641,"type":3},
        //           ]},
        //         {"menuName": "默认标准参数", "parentId": 6,"sort": 6, "path": 'DefaultPara',"menuId": 65,"type":2,
        //          "children": [
        //               {"menuName": "默认标准参数编辑","parentId": 65,"sort": 1, "path": null,"menuId": 651,"type":3},
        //           ]},
        //         {"menuName": "饲喂成本设置", "parentId": 6,"sort": 7, "path": 'FeedCost',"menuId": 66,"type":2,
        //          "children": [
        //               {"menuName": "饲喂成本设置编辑","parentId": 66,"sort": 1, "path": null,"menuId": 661,"type":3},
        //           ]
        //         },
           
        //     ]
        // },
        // {"menuName": "系统管理","parentId": 0,"sort": 7,"path": null,"menuId": 7, "type":1,
        //     "children": [
        //         {"menuName": "用户管理","parentId": 7,"sort": 1, "path": 'User',"menuId": 70,"type":2,
        //          "children": [
        //               {"menuName": "用户管理编辑","parentId": 70,"sort": 1, "path": null,"menuId": 701,"type":3},
        //           ]
        //         },
        //         {"menuName": "角色管理", "parentId": 7,"sort": 2, "path": 'Role',"menuId": 71,"type":2,
        //          "children": [
        //               {"menuName": "用户管理编辑","parentId": 71,"sort": 1, "path": null,"menuId": 711,"type":3},
        //           ]
        //         },
               
           
        //     ]
        // },


        
       
    ],
      
      
     

      //树形控件的属性绑定对象
      treeProps:{
        label:'name',children:'children'
      },

      //树形默认选中的值
      checkedIdArr:[],

      setFormShow2:false,
      setForm2:{
        datarole:0 
      },  
       
    }
  },
  created(){

  

      //表格 - 初始化 
      this.get_table_data()
       //下拉框
      this.get_select_list1()


       

      //  console.log("this.$store.state.buttonsList==============",this.$store.state.buttonsList)
 

       const isButtonEdit = checkButtons(this.$store.state.buttonsList, "角色管理编辑")
       this.isButtonEdit = isButtonEdit
       console.log('this.isButtonEdit==========',this.isButtonEdit)


        
  },
  
  methods:{

 
    get_select_list1(){
      var me = this
      ajaxDataPost('/api/v1/system/menu/list', {"name":""}).then(e => {
        console.log("树形下拉框1：",e)

 
          if(e.data.list == null || e.data.list  == undefined ||e.data.list.length == 0   ){
            me.rightlist = []
            me.rightlistAll = []

          } else {
            var rightlistAll = []
            me.rightlist = e.data.list 
            me.rightlist.forEach(function(item){
              if(item.children.length !== 0){

                rightlistAll.push(item)
                item.children.forEach(function(items){
                  if(items.children.length !== 0){
                    rightlistAll.push(items)
                    items.children.forEach(function(itemss){
                      rightlistAll.push(itemss)
                    })
                  }
                })
                 
              } else {
                rightlistAll.push(item)
              }

            })
          }
          console.log('rightlistAll',rightlistAll)
          me.rightlistAll = rightlistAll
          

         
         
  
        })
    },


    form_search(){
      var me = this
      console.log('请求表格列表ssearchData',me.searchData)
      this.get_table_data()

    },

    //获取 表格
    get_table_data() {
 
      var me = this

      me.tableLoading = true
      console.log("searchData======>", me.searchData)
        var send_url = me.url_get_table + '?page=' + me.searchData.page +  '&page_size=' + me.searchData.page_size

        ajaxDataPost(send_url,  me.searchData).then(e => {
          console.log("表格请求结果：",e)
            //打印请求成功结果
            if(e.code == 200 ){
              me.tableList = e.data.list
              me.searchData.total = e.data.total;	// 总数
              me.searchData.page = e.data.page;	//页码
              me.searchData.page_size = e.data.page_size;	//每页数量
            
            } else {
              me.$message({ type: 'error', message: '请求表格列表失败！' + e.msg, duration: 2000 })
            }
            

            setTimeout(() => {
              me.tableLoading = false
            }, 100)

          })

        
    },


    //监听 pagesize 改变的事件
    change_size_page(item){
      console.log(item)
 
    },

    //监听 pagenum 改变的事件
    change_current_page(item){
      console.log(item)
       this.searchData.pageNum = item
       this.get_table_data()
    },


    form_add() {
    
      this.reset_form()
      this.addFormStatus = 'create'
      this.addFormShow = true
      this.$nextTick(() => {
        this.$refs['addFormRef'].clearValidate()
      })
    },
    //清空弹窗表单信息
    reset_form(){
      this.addForm.name = ''
    },

    //编辑
    form_edit(row) {
      console.log('行内容row=========', row)
      //编辑行内容赋值
      this.addForm = Object.assign({}, row)  
      this.addFormStatus = 'edit'
      this.addFormShow = true
      this.$nextTick(() => {
        this.$refs['addFormRef'].clearValidate()
      })
    },


    //新增关闭
    add_dialog_close(){
       //内容重置
       this.$refs['addFormRef'].resetFields()
    },

    //新增 保存
    add_dialog_save() {
      var me = this
      this.$refs['addFormRef'].validate(valid => {
        //验证成功
        if (valid) {
          //发起请求
          var send_data = {
              "name": me.addForm.name,
          }
          console.log("弹窗参数：", send_data)

          //关闭弹窗
          // me.addFormShow = false
         //加载 - 发送新增保存
           ajaxDataPost(me.url_add_table, send_data).then(e => {
                console.log("新增结果：",e)
                //打印请求成功结果
                if(e.code == 200  ){
                  me.$message({ type: 'success', message: '新增成功！'  , duration: 2000 })
                  //关闭弹窗
                  me.addFormShow = false
                  me.get_table_data()
                } else {
                  me.$message({ type: 'error', message: '新增失败！' + e.msg, duration: 2000 })
                }
            })
         
        }
      })
    },
    //编辑 保存
    edit_dialog_save(){
      var me = this
      this.$refs['addFormRef'].validate(valid => {
        //验证成功
        if (valid) {
          //发起请求
          var send_data = {
              "name": me.addForm.name,
              "id": me.addForm.id,
          }
          console.log("弹窗参数：", send_data)

          //关闭弹窗
          // me.addFormShow = false
         //加载 - 发送新增保存
         ajaxDataPost(me.url_edit_table, send_data).then(e => {
                console.log("编辑结果：",e)
                //打印请求成功结果
                if(e.code == 200  ){
                  me.$message({ type: 'success', message: '编辑成功！'  , duration: 2000 })
                  //关闭弹窗
                  me.addFormShow = false
                  me.get_table_data()
                } else {
                  me.$message({ type: 'error', message: '编辑失败！' + e.msg, duration: 2000 })
                }
            })
         
        }
      })
    },

 

    form_delete(row) {
      var me = this

       me.$confirm('是否删除此条内容?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
            console.log("删除的ID参数：", row.id)
            //加载 - 发送新增保存
            ajaxDataDelete(me.url_delete_table + '/' +row.id, {}).then(e => {
                console.log("编辑结果：",e)
                //打印请求成功结果
                if(e.code == 200  ){
                  me.$message({ type: 'success',  message: '删除成功!'  });
                  me.get_table_data()
                } else {
                  me.$message({ type: 'error', message: '删除失败！' + e.msg, duration: 2000 })
                }
            })

        
 
          
        }).catch(() => {
          me.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });


       
    },


    
    form_set(row) {


      
      console.log('row', row)
      this.setForm = Object.assign({}, row) 

      
      
      
      this.$nextTick(() => {
        this.$refs['setFormRef'].clearValidate()

        this.checkedIdArr = row.menu_ids
      })

      this.setFormShow = true
    },



    //监听关闭对话框
    set_dialog_close(){
       //内容重置
       this.$refs['setFormRef'].resetFields()
       this.checkedIdArr = []
       //清空树
       this.$refs.tree.setCheckedKeys([]);
       this.setFormShow2 = false
    },






 




    
    change_check() {
      var me =  this
 
      // me.$nextTick(() => {
      //   const arr = []
      //   me.rightlist.forEach(item => {
      //     if (!me.$refs.tree.getNode(item.menuId).childNodes || !me.$refs.tree.getNode(item.menuId).childNodes.length) {
      //       arr.push(item.menuId)
      //     }
      //   })
      //   console.log (arr)
      //   me.$refs.tree.setCheckedKeys(arr)
      // })
 
      
      var checkedKeys = this.$refs.tree.getCheckedKeys() // 所有被选中的节点的 key 所组成的数组数据
      console.log(checkedKeys)
      this.checkedIdArr = checkedKeys


      console.log("选中的ID  checkedIdArr",me.checkedIdArr)
    },

    set_dialog_save() {
      var me = this
      console.log(me.setForm)
    
      console.log("选中的ID  checkedIdArr",me.checkedIdArr)


      console.log(" rightlistAll",me.rightlistAll)
     


      var isParent = false 
      me.rightlistAll.forEach(function(item){


         me.checkedIdArr.forEach(function(items){
           if(items == item.id ){
              var parent_id = item.parent_id
              var name = item.name
              console.log('item.parent_id',item.parent_id)
              if(parent_id !== 0){
                var isParentCheck = me.checkedIdArr.indexOf(parent_id)
                if(isParentCheck == -1){
                  console.log('父级没勾上',name)
           
                  isParent = true
                  return false
                   
                }
              }
              

           
           }
         })
      })

      

      if(isParent){
        me.$message({ type: 'error', message:   '请勾选已选择菜单或按钮的父级权限！'  , duration: 2000 })
        return false
      }
 

      
 

      this.$refs['setFormRef'].validate(valid => {
        //验证成功
        if (valid) {

          console.log(me.addForm )
          //发起请求

          var send_data = {
            "role_id": me.setForm.id,
            "menu_ids":me.checkedIdArr
 
          }
          console.log("弹窗参数：", send_data)


          

          //关闭弹窗
          // me.addFormShow = false
         //加载 - 发送编辑保存
         ajaxDataPost('/api/v1/system/role/menu_ids', send_data).then(e => {
          console.log("编辑结果：",e)
            //打印请求成功结果
            if(e.code == 200  ){
                  me.$message({ type: 'success', message: '新增成功！'  , duration: 2000 })
                  //关闭弹窗
                  me.setFormShow = false
                  me.get_table_data()
                  me.checkedIdArr = []
                } else {
                  me.$message({ type: 'error', message: '新增失败！' + e.msg, duration: 2000 })
                }
          })
          
          
        }
      })


    },


    form_set2(row) {


            
      console.log('row', row)
      this.setForm2 = Object.assign({}, row) 

    
      this.setFormShow2 = true
      this.$nextTick(() => {
        this.$refs['setFormRef2'].clearValidate()
      })
    },



    //监听关闭对话框
    set_dialog_close2(){
      //内容重置
      this.$refs['setFormRef2'].resetFields()
 
    },

    set_dialog_save2() {
      var me = this
      console.log(me.setForm2)
    
    

      this.$refs['setFormRef2'].validate(valid => {
        //验证成功
        if (valid) {

          console.log(me.setForm2 )
          //发起请求

          var send_data = {
            "roleId": me.setForm2.roleId,
            "datarole": me.setForm2.datarole
 
          }
          console.log("弹窗参数：", send_data)

          //关闭弹窗
          // me.addFormShow = false
         //加载 - 发送编辑保存
         ajaxDataPost('/role/data/update', send_data).then(e => {
          console.log("编辑结果：",e)
            //打印请求成功结果
            if(e.msg == "success"  ){
              me.$message({ type: 'success', message: '编辑成功！'  , duration: 2000 })
              //关闭弹窗
              me.setFormShow2 = false
              me.get_table_data()
            } else {
              me.$message({ type: 'error', message: '编辑失败！' + e.msg, duration: 2000 })
            }
          })
          
          
        }
      })


    },


  }
}
</script>
<!-- 加了scoped，则是仅在此组件里生效 -->
<style scoped> 
</style>
