organ.vue 8.46 KB
Newer Older
xulili's avatar
xulili committed
1
<template>
xulili's avatar
xulili committed
2 3 4 5 6 7 8 9
  <div class="oran-wrapper height100">
    <div class="org-tree-container">
      <div class="org-tree-box">
        <div class="org-tree-box-header">组织结构</div>
        <div class="org-tree-box-content">
          <div class="tree-search party-form">
            <el-input
              placeholder="请输入组织结构名称"
xulili's avatar
xulili committed
10
              v-model="name"
xulili's avatar
xulili committed
11
            >
xulili's avatar
xulili committed
12 13 14 15 16
             <i
              slot="suffix" 
              class="el-input__icon el-icon-search"
              @click="getOrgTree()">
              </i>
xulili's avatar
xulili committed
17 18 19
            </el-input>
            <div class="f0">
              <el-tooltip content="新建" placement="top">
xulili's avatar
xulili committed
20
                <i class="icon-add party-icon-20"  @click="handleAdd('add')"/>
xulili's avatar
xulili committed
21 22
              </el-tooltip>
              <el-tooltip content="导入" placement="top">
xulili's avatar
xulili committed
23
                <i class="icon-import party-icon-20"  @click="handleImport('import')"/>
xulili's avatar
xulili committed
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
              </el-tooltip>
            </div>
          </div>
          <div class="tree-content">
            <el-tree
              class="org-tree"
              :data="data"
              :props="defaultProps"
              @node-click="handleNodeClick"
            >
              <div
                class="custom-tree-node"
                slot-scope="{ node, data }"
                :class="'tree-node-level' + data.level"
              >
                <i class="icon-org" v-if="data.level === 1"></i>
                <span>{{ node.label }}</span>
              </div>
            </el-tree>
          </div>
        </div>
      </div>
    </div>
    <div class="org-detail">
      <div class="org-detail-panel-box">
xulili's avatar
xulili committed
49
        <span class="title">{{ currentInfo.name }}</span>
xulili's avatar
xulili committed
50
        <div class="icon-group">
xulili's avatar
xulili committed
51 52
          <i class="icon-edit party-icon-24" @click="handleEdit()"> </i>
          <i class="icon-del party-icon-24" @click="handleDel()"> </i>
xulili's avatar
xulili committed
53 54 55 56 57 58 59 60 61 62 63
        </div>
      </div>
      <div class="org-detail-panel-box-content">
        <div class="page-tip">
          <p class="page-tip-title">页面说明:</p>
          <p class="page-tip-des">
            点击相应的机构名称,可查看该机构的详细信息。可新增机构、删除机构及批量导入机构信息。新增机构中“*”为必填项
          </p>
        </div>
        <el-form label-position="top" :inline="true">
          <el-form-item label="上级机构" class="w50">
xulili's avatar
xulili committed
64
            <span></span>
xulili's avatar
xulili committed
65 66
          </el-form-item>
          <el-form-item label="下级机构" class="w50">
xulili's avatar
xulili committed
67 68 69
            <span>
             
            </span>
xulili's avatar
xulili committed
70 71
          </el-form-item>
          <el-form-item label="地理位置" class="w100">
xulili's avatar
xulili committed
72 73 74
            <span>
              {{currentInfo.remarks}}
            </span>
xulili's avatar
xulili committed
75 76 77
          </el-form-item>
          <el-form-item label="备注信息" class="w100">
            <span>
xulili's avatar
xulili committed
78
                {{currentInfo.remarks}}
xulili's avatar
xulili committed
79 80 81 82
            </span>
          </el-form-item>
        </el-form>
      </div>
xulili's avatar
xulili committed
83 84 85 86 87 88 89
      <org-add 
        ref="orgAdd" 
        :parentId="currentInfo.id" 
        :level="currentInfo.level"
        @success="getOrgTree()"
      /> 
      <org-edit ref="orgEdit" :currentInfo="currentInfo"/> 
xulili's avatar
xulili committed
90
    </div>
xulili's avatar
xulili committed
91 92 93
  </div>
</template>
<script>
xulili's avatar
xulili committed
94 95 96 97
import {orgAdd, orgEdit} from './orgDialog'
export default {
  data() {
    return {
xulili's avatar
xulili committed
98 99
      name: "",
      data: [],
xulili's avatar
xulili committed
100 101 102 103
      defaultProps: {
        children: "children",
        label: "name",
      },
xulili's avatar
xulili committed
104 105
      currentId:'',
      currentInfo:{},
xulili's avatar
xulili committed
106 107 108
    };
  },
  components:{orgAdd,orgEdit},
xulili's avatar
xulili committed
109 110 111
  mounted(){
    this.getOrgTree()
  },
xulili's avatar
xulili committed
112 113
  methods: {
    handleNodeClick(data) {
xulili's avatar
xulili committed
114 115
      this.currentId = data.id
      this.getInfoById()
xulili's avatar
xulili committed
116
    },
xulili's avatar
xulili committed
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
    // 获取机构数详情
    getInfoById(){
      this.$https({
         method: "get",
         url: "organ/getById",
         authType: this.backToken,
      },{id:this.currentId}).then(res=>{
        if(res.status == 200){
          if(res.data.resultCode == 200){
            if(res.data.data){
                this.currentInfo = res.data.data
            }else{
               this.currentInfo = {}
            }
          }else{
            this.currentInfo = {}
          }
        }else{
          this.currentInfo = {}
        }
      }).catch(err=>{
         console.log(res)
      })
    },
    // 获取机构树
    getOrgTree(){
      this.$https({
        method: "get",
        url: "organ/getTree",
        authType: this.backToken,
      },{name:this.name}).then(res=>{
        if(res.status == 200){
          if(res.data.resultCode == 200){
             this.data = res.data.data
          }else{
            this.data = []
          }
        }else{
          this.data = []
        }
      }).catch(err=>{
        console.log(res)
      })
    },
    // 新增或者导入 之前判断是否选择父级
    handleOperate(type){
      if(JSON.stringify(this.currentInfo) === "{}"){
        this.currentId.level = 1
        this.currentInfo.id = '0'
      }
      if(type === 'add'){
        this.handleAdd()
      }
      if(type === 'import'){
         this.handleImport()
      }
    },
    // 新增
    handleAdd(){
      this.$refs.orgAdd.dialogVisible = true
    },
    //导入
    handleImport(){

    },
    handleEdit(){


    },
    // 删除
    handleDel(){
       this.$confirm('此操作将永久删除, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.delAction()
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
    },
    delAction(){
       this.$https({
         method: `delete?id=${this.currentId}`,
         url: "organ/delete",
         authType: this.backToken,
      }).then(res=>{
        if(res.status == 200){
          if(res.data.resultCode == 200){
            this.$message({
              type:'success',
              message:res.data.message
            })
            this.getOrgTree()
          }else{
            this.$message.error(res.data.message)
          }
        }else{
          this.$message.error(res.data)
        }
      }).catch(err=>{
         console.log(err)
      })
    }
xulili's avatar
xulili committed
224 225
  },
};
xulili's avatar
xulili committed
226 227
</script>
<style lang="less" scoped>
xulili's avatar
xulili committed
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
.oran-wrapper {
  display: flex;
  .org-tree-container {
    width: 420px;
    padding-right: 20px;
    height: 100%;
    .org-tree-box {
      height: 100%;
      background: @party-white;
      border: 1px solid @party-white;
      box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.1);
      border-radius: 8px;
      overflow: hidden;
      .org-tree-box-header {
        height: 56px;
        line-height: 56px;
        background-color: @party-red;
        text-align: center;
        font-size: 16px;
        color: @party-white;
      }
      /deep/ .tree-search {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-bottom: 10px;
        .el-input__icon {
          width: 40px;
          font-size: 20px;
          color: @party-btn-color;
        }
        .icon-import {
          margin-left: 10px;
        }
      }
      .org-tree-box-content {
        padding: 20px;
xulili's avatar
xulili committed
265 266 267 268 269
        height: calc(100% - 56px);
        .tree-content{
          height: calc(100% - 60px);
          overflow-y: auto;
        }
xulili's avatar
xulili committed
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
      }
    }
  }
  .org-detail {
    width: calc(100% - 420px);
    height: 100%;
    background: @party-white;
    border: 1px solid @party-white;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
    .org-detail-panel-box {
      height: 64px;
      border-bottom: 1px solid @party-border-color;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 24px;
      .title{
         font-size: 20px;
         font-weight: bold;
         color: @font-color;
      }
      .icon-del {
        margin-left: 30px;
      }
    }
    .org-detail-panel-box-content {
      height: calc(100% - 64px);
      padding: 20px;
      overflow-y: scroll;
      .page-tip {
        width: 648px;
        height: 72px;
        background: @party-bg-gray;
        border-radius: 8px;
        color: @font-color;
        display: flex;
        padding: 16px 20px;
        margin: 0 auto 40px;
        .page-tip-title {
          width: 100px;
          font-weight: bold;
        }
      }
      .el-form {
        width: 648px;
        margin: 0 auto;
        .w50 { width: calc(50% - 15px); }
        .w100 { width: 100%;}
        .el-form-item__content{
          span{
            color: @font-color;
            font-weight: bold;
          }
        }
      }
    }
  }
xulili's avatar
xulili committed
329
}
xulili's avatar
xulili committed
330
</style>