Blame view

src/views/system/menus/index.vue 6.95 KB
xiaomiao committed
1 2 3
<template>
  <div class="timedTask from-clues">
    <div class="from-clues-header">
xiaomiao committed
4
      <el-form ref="ruleForm" :model="form" label-width="100px">
xiaomiao committed
5
        <el-form-item>
6 7
          <Breadcrumb />
        </el-form-item>
xiaomiao committed
8 9 10
        <el-row class="mb-5">
          <el-col :span="2" class="btnColRight">
            <btn nativeType="cx" @click="handleAdd()">新增菜单</btn>
xiaomiao committed
11 12 13 14 15
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="from-clues-content">
xiaomiao committed
16
      <lb-table
xiaomiao committed
17
        :pagination="false"
xiaomiao committed
18
        :column="tableData.columns"
xiaomiao committed
19
        :data="tablelistData"
xiaomiao committed
20 21
        row-key="id"
        default-expand-all
xiaomiao committed
22
        :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
xiaomiao committed
23 24
      </lb-table>
    </div>
xiaomiao committed
25 26 27
    <edit-dialog ref="dialogForm"
      :product-id="productId"
      :resource-category-id="resourceCategoryId"
xiaomiao committed
28
      @ok="reloadTableData" />
xiaomiao committed
29
    <!-- <authorizationdiglog ref="rolesForm" /> -->
xiaomiao committed
30 31 32
  </div>
</template>
<script>
xiaomiao committed
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
  // 定时任务
  import data from "./data";
  import { deleteAction, getAction, api } from "@/api/manageApi";
  import EditDialog from "./edit-dialog.vue";
  // import authorizationdiglog from "./authorizationdiglog.vue";
  export default {
    name: "menus",
    components: {
      EditDialog,
      // authorizationdiglog,
    },
    data () {
      return {
        tablelistData: [],
        resourceCategoryId: "",
        taskData: null,
        form: {
          job_name: "",
          currentPage: 1,
        },
        title: "",
        queryParam: {},
        selectType: "0",
        queryName: "",
        organizationId: "", // 组织机构ID
        departmentId: "", // 部门ID
        departmentList: [], // 部门列表
        levelList: [], // 职务级别
        sexList: [],
xiaomiao committed
62

xiaomiao committed
63 64 65
        selectionList: [],
        tableData: {
          columns: [].concat(data.columns()).concat([
xiaomiao committed
66
            {
xiaomiao committed
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
              label: "操作",
              width: 380,
              render: (h, scope) => {
                return (
                  <div>
                    <el-button
                      type="text"
                      size="mini"
                      icon="el-icon-edit"
                      onClick={() => {
                        this.handleEdit(scope.row);
                      }}
                    >
                      修改
                    </el-button>

                    <el-button
                      type="text"
                      size="mini"
                      icon="el-icon-delete"
                      style="color:#F56C6C"
                      onClick={() => {
                        this.handleDelete(scope.row.id, scope.row.name);
                      }}
                    >
                      删除
                    </el-button>
                  </div>
                );
              },
xiaomiao committed
97
            },
xiaomiao committed
98 99
          ]),
          data: [],
xiaomiao committed
100
        },
xiaomiao committed
101 102 103 104 105 106 107 108
        pageData: {
          total: 5,
          pageSize: 15,
          current: 1,
        },
        tableUrl: api.menus, // 菜单接口地址
        meumurlid: api.subsystem,// 项目id接口地址
        productId: ""//项目id
xiaomiao committed
109 110
      };
    },
xiaomiao committed
111 112
    created () {
      this.getTableList();
xiaomiao committed
113
    },
xiaomiao committed
114 115 116
    methods: {
      // 加载表格数据
      getTableList () {
xiaomiao committed
117

xiaomiao committed
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
        const queryOptionsid = {
          conditionGroup: {
            queryRelation: "AND",
            conditions: [
              {
                property: "code",
                value: "BDCJGPT",
                operator: "EQ",
              },
            ],
          },
        };
        const params = {
          queryOptions: queryOptionsid,
        };
        // 获取系统id
        getAction(this.meumurlid, params)
          .then((res) => {
            this.productId = res.content[0].id;
            let queryOptions = {
              conditionGroup: {
                conditions: [
                  {
                    property: "productId",
                    value: this.productId,
                    operator: "EQ",
                  },
                ],
                queryRelation: "AND",
              },
              orderBys: [{ property: "sort", direction: "desc" }],
            };
            if (!this.tableUrl) {
              console.log("请设置tableUrl属性为接口地址!");
              return;
            }
            if (this.queryOptions !== "") {
              this.queryParam.queryOptions = JSON.stringify(queryOptions);
            }
            // 查询系统菜单
            getAction(this.tableUrl, this.queryParam)
              .then((res) => {
                if (res.status === 1) {
                  this.loading = false;
                  this.tablelistData = res.content;
                } else {
                  this.$message.error({ message: res.message, showClose: true });
                  this.loading = false;
                }
              })
              .catch((error) => {
                console.log("er", error);
                this.loading = false;
              });
          })
          .catch((error) => {
            console.log("er", error);
          });
      },
      // 新增菜单
      handleAdd () {
        this.$refs.dialogForm.add();
        this.$refs.dialogForm.title = "添加";
      },

      // 修改
      handleEdit (record) {
        this.$refs.dialogForm.edit(record);
        this.$refs.dialogForm.title = "修改";
      },
      // 删除
      handleDelete (id, content) {
        this.$confirm(
          `<div  class="customer-message-wrapper">
xiaomiao committed
192 193 194 195 196 197 198
              <h5 class="title">您确认要执行该操作用于以下信息:</h5>
              <p class="content" aria-controls="${content}">${content}
              </p>
               <p class="result">执行后,数据将
                 <span >无法恢复</span>
                </p>
        </div>`,
xiaomiao committed
199 200 201 202 203 204 205
          '执行确认',
          {
            dangerouslyUseHTMLString: true,
            customClass: 'customer-delete',
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
xiaomiao committed
206
          }
xiaomiao committed
207 208 209 210 211 212 213 214
        )
          .then(() => {
            if (!this.tableUrl) {
              this.$message.error({
                message: '请设置tableUrl属性为接口地址!',
                showClose: true
              })
              return
xiaomiao committed
215
            }
xiaomiao committed
216 217 218 219 220 221 222 223 224
            const url = this.tableUrl + '/' + id
            deleteAction(url).then(res => {
              if (res.status === 1) {
                this.$message.success({ message: res.message, showClose: true })
                this.reloadTableData()
              } else {
                this.$message.error({ message: res.message, showClose: true })
              }
            })
xiaomiao committed
225
          })
xiaomiao committed
226 227 228 229 230 231
          .catch(() => { })
      },
      // 新增、编辑回显
      reloadTableData () {
        this.getTableList()
      },
xiaomiao committed
232
    },
xiaomiao committed
233
  };
xiaomiao committed
234 235
</script>
<style scoped lang="scss">
xiaomiao committed
236 237 238 239 240 241 242 243
  @import "~@/styles/mixin.scss";
  @import "~@/styles/public.scss";
  .btnColRight {
    margin-top: 20px;
  }
  /deep/.el-table__expand-icon {
    color: #fff;
  }
xiaomiao committed
244
</style>