shop_vue/src/views/plus/operations/auth/role/add.vue
@@ -30,7 +30,7 @@
</template>
<script>
import PlusApi from '@/api/plus/region.js';
import PlusApi from '@/api/plus/operations.js';
export default {
  data() {
@@ -80,7 +80,7 @@
      self.$refs.form.validate(valid => {
        if (valid) {
          self.loading = true;
          PlusApi.regionRoleAdd({
          PlusApi.operationsRoleAdd({
            params: JSON.stringify(form)
          }, true)
            .then(data => {
@@ -89,7 +89,7 @@
                message: '添加成功',
                type: 'success'
              });
              self.$router.push('/plus/region/auth/role/index');
              self.$router.push('/plus/operations/auth/role/index');
            })
            .catch(error => {
              self.loading = false;
@@ -101,7 +101,7 @@
    /*获取数据*/
    getData() {
      let self = this;
      PlusApi.regionRoleAddInfo()
      PlusApi.operationsRoleAddInfo()
        .then(data => {
          self.data = data.data.menu;
          self.treeData = self.buildTree(self.data); // 构建树形结构
@@ -118,18 +118,18 @@
      if (!data || !Array.isArray(data)) {
        return [];
      }
      // 创建映射表
      const map = {};
      const roots = [];
      // 首先创建映射
      for (let i = 0; i < data.length; i++) {
        map[data[i].access_id] = i;
        // 初始化children数组
        data[i].children = [];
      }
      // 然后建立父子关系
      for (let i = 0; i < data.length; i++) {
        const node = data[i];
@@ -148,7 +148,7 @@
          }
        }
      }
      return roots;
    },
@@ -176,4 +176,4 @@
.img {
  margin-top: 10px;
}
</style>
</style>