index.vue 7.33 KB
Newer Older
乐宝呗666's avatar
乐宝呗666 committed
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
<template>
  <div class="interactive-wrapper height100">
    <el-card class="height100 tree-box">
      <div class="tree-title">组织机构</div>
      <div class="tree-body">
        <el-input
          suffix-icon="el-icon-search"
          placeholder="请输入组织结构名称"
          v-model="filterText"
        ></el-input>
        <div class="tree-content">
          <el-tree
            class="org-tree"
            :data="treeData"
            :props="defaultProps"
            accordion
            :filter-node-method="filterNode"
            @node-click="handleNodeClick"
            ref="tree"
          >
            <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>
    </el-card>
    <el-card class="height100 detail-box" ref="rightBox">
      <div class="content-title">
35
        <div class="title">"{{selectOrgName}}" 展板互动信息汇总</div>
乐宝呗666's avatar
乐宝呗666 committed
36 37
        <div class="page-tip">
          <span class="page-tip-title">页面说明:</span>
乐宝呗666's avatar
乐宝呗666 committed
38
          <span class="page-tips">可查看某个组织机构的互动信息</span>
乐宝呗666's avatar
乐宝呗666 committed
39 40
        </div>
      </div>
乐宝呗666's avatar
乐宝呗666 committed
41
      <div class="scrollBox"  v-show="tableData.length">
乐宝呗666's avatar
乐宝呗666 committed
42 43 44 45 46
        <div
          class="content-item"
          v-for="(item, index) in tableData"
          :key="index"
        >
47 48
          <h5 class="title">{{ item.boardName }}</h5>
          <p>{{ item.content||'暂无内容' }}</p>
乐宝呗666's avatar
乐宝呗666 committed
49
          <div class="img-box" v-if="item.images.length">
乐宝呗666's avatar
乐宝呗666 committed
50 51 52 53
            <a target="_blank" v-for="(j, idx) in item.images" :key="idx" :href="j.url">
              <img  :src="j.cover" alt="" />
            </a>
            <!-- <img v-for="(j, idx) in item.images" :src="j" :key="idx" alt="" /> -->
乐宝呗666's avatar
乐宝呗666 committed
54
          </div>
乐宝呗666's avatar
乐宝呗666 committed
55
          <div class="img-box" v-if="!item.images.length">暂无数据</div>
乐宝呗666's avatar
乐宝呗666 committed
56 57 58 59 60 61
          <div class="author">
            <div>{{ item.username }}</div>
            <div>{{ item.createTime }}</div>
          </div>
        </div>
      </div>
62
      <party-pagination v-show="tableData.length" :page="page" @changePage="handleCurrentChange"/>
乐宝呗666's avatar
乐宝呗666 committed
63 64 65 66
    </el-card>
  </div>
</template>
<script>
67
import { partyPagination} from "@/components/index";
乐宝呗666's avatar
乐宝呗666 committed
68
export default {
69
  components: { partyPagination },
乐宝呗666's avatar
乐宝呗666 committed
70 71 72
  data() {
    return {
      filterText: "",
乐宝呗666's avatar
乐宝呗666 committed
73
      page: {
74 75
        _index: 1,
        _size: 10,
乐宝呗666's avatar
乐宝呗666 committed
76
        total: 0,
乐宝呗666's avatar
乐宝呗666 committed
77 78 79 80 81 82
      },
      treeData: [],
      defaultProps: {
        children: "children",
        label: "name",
      },
83 84
      selectOrgId: "",
      selectOrgName: "",
乐宝呗666's avatar
乐宝呗666 committed
85 86 87 88 89 90 91 92 93 94
      tableData: [],
    };
  },
  watch: {
    filterText(val) {
      this.$refs.tree.filter(val);
    },
  },
  mounted() {
    // 获取全部组织机构数据
乐宝呗666's avatar
乐宝呗666 committed
95 96
    this.getOrgData();
    // this.onSearch()
乐宝呗666's avatar
乐宝呗666 committed
97 98 99 100
  },
  methods: {
    // 查询
    onSearch() {
101
      this.page._index = 1;
乐宝呗666's avatar
乐宝呗666 committed
102
      this.getTableData();
乐宝呗666's avatar
乐宝呗666 committed
103 104 105
    },
    // 获得数据接口
    getTableData() {
乐宝呗666's avatar
乐宝呗666 committed
106 107
      let vm = this;
      vm.tableData = [];
乐宝呗666's avatar
乐宝呗666 committed
108
      let param = {
109 110
        _index: this.page._index,
        _size: this.page._size,
111
        orgId: this.selectOrgId,
乐宝呗666's avatar
乐宝呗666 committed
112 113 114 115 116 117 118 119 120 121 122
      };
      vm.$https(
        {
          url: "interaction/getList",
          method: "post",
          authType: this.backToken,
        },
        vm.$qs.stringify(param)
      )
        .then((res) => {
          if (res.data.resultCode === "200") {
乐宝呗666's avatar
乐宝呗666 committed
123 124 125 126 127 128 129
            let data = res.data.data;
            vm.page.total = data.total;
            vm.tableData = data.records;
            if(!vm.tableData.length){
              this.$message('暂无数据')
              return false
            }
乐宝呗666's avatar
乐宝呗666 committed
130
            vm.tableData.forEach((item) => {
乐宝呗666's avatar
乐宝呗666 committed
131
              item.images = item.images ? item.images.split(",") : [];
乐宝呗666's avatar
乐宝呗666 committed
132
              item.images.forEach((result, index) => {
乐宝呗666's avatar
乐宝呗666 committed
133 134 135
                item.images[index] = {
                  url:result
                }
乐宝呗666's avatar
乐宝呗666 committed
136
                if (/\.(MP4|mp4)/.test(result)) {
乐宝呗666's avatar
乐宝呗666 committed
137
                  item.images[index].cover = require("@/assets/video-icon.png");
乐宝呗666's avatar
乐宝呗666 committed
138
                } else if (/\.(MP3|mp3)/.test(result)) {
乐宝呗666's avatar
乐宝呗666 committed
139 140 141 142 143
                  item.images[index].cover = require("@/assets/audio-icon.png");
                } else if(/\.(jpg|png|jpeg|bmp|gif)/.test(result)) {
                  item.images[index].cover = result;
                } else{
                  item.images[index].cover = require("@/assets/default-img.jpeg");;
乐宝呗666's avatar
乐宝呗666 committed
144
                }
乐宝呗666's avatar
乐宝呗666 committed
145 146 147
              });
            });
            vm.tableData = [...vm.tableData];
乐宝呗666's avatar
乐宝呗666 committed
148
          } else {
乐宝呗666's avatar
乐宝呗666 committed
149
            this.$message.error(res.data.message);
乐宝呗666's avatar
乐宝呗666 committed
150 151 152
          }
        })
        .catch(function (err) {
乐宝呗666's avatar
乐宝呗666 committed
153
          console.log(err);
乐宝呗666's avatar
乐宝呗666 committed
154 155 156 157 158 159 160 161 162 163 164
        });
    },
    // 获取组织机构数据
    getOrgData() {
      this.$https({
        method: "get",
        url: "organ/getTree",
        authType: this.backToken,
      }).then(
        (res) => {
          if (res.data.resultCode === "200") {
乐宝呗666's avatar
乐宝呗666 committed
165
            this.treeData = res.data.data;
乐宝呗666's avatar
乐宝呗666 committed
166
          } else {
乐宝呗666's avatar
乐宝呗666 committed
167
            this.$message.error(res.data.message);
乐宝呗666's avatar
乐宝呗666 committed
168 169 170
          }
        },
        (error) => {
乐宝呗666's avatar
乐宝呗666 committed
171
          console.log(error);
乐宝呗666's avatar
乐宝呗666 committed
172 173 174 175 176 177 178 179 180 181
        }
      );
    },
    // 过滤树结构数据
    filterNode(value, data) {
      if (!value) return true;
      return data.name.indexOf(value) !== -1;
    },
    // 点击节点事件
    handleNodeClick(data) {
182 183
      this.selectOrgId = data.id;
      this.selectOrgName = data.name;
乐宝呗666's avatar
乐宝呗666 committed
184
      this.onSearch();
乐宝呗666's avatar
乐宝呗666 committed
185 186 187
    },
    // 分页
    handleCurrentChange(val) {
188
      this.page._index = val;
乐宝呗666's avatar
乐宝呗666 committed
189
      this.getTableData();
乐宝呗666's avatar
乐宝呗666 committed
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 224 225 226 227 228 229 230
    },
  },
};
</script>
<style lang="less">
.interactive-wrapper {
  display: flex;
  .tree-box {
    width: 420px;
    .tree-body {
      padding: 20px;
      height: calc(100% - 56px);
      .tree-content {
        overflow-y: auto;
        height: calc(100% - 50px);
      }
      .el-input {
        margin-bottom: 10px;
        .el-input__inner {
          background: #f8f8f8;
          border-radius: 22px;
        }
        .el-input__icon {
          font-size: 18px;
          color: #ac9374;
        }
      }
    }
  }
  .detail-box {
    width: calc(100% - 440px);
    margin-left: 20px;
  }
  .scrollBox {
    height: calc(100% - 160px);
    overflow-y: auto;
  }
  .page-tip {
    display: flex;
    font-size: 14px;
    color: #333333;
231
    line-height: 30px;
乐宝呗666's avatar
乐宝呗666 committed
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
    .page-tip-title {
      font-weight: bold;
      padding-right: 10px;
    }
  }

  .el-card__body {
    padding: 0;
    height: 100%;
  }
  .tree-title {
    font-size: 16px;
    color: #fff;
    text-align: center;
    height: 56px;
    line-height: 56px;
    background: #9b1e23;
    border-radius: 8px 8px 0 0;
  }

  .content-title {
    display: flex;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #eee;
    .title {
      font-size: 20px;
      color: #333;
    }
    .page-tips {
262
      width: 220px;
乐宝呗666's avatar
乐宝呗666 committed
263 264 265 266 267 268 269 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
    }
  }
  .content-item {
    font-size: 16px;
    margin: 20px;
    padding: 40px;
    background: #f8f8f8;
    .title {
      padding-bottom: 20px;
    }
    p {
      padding-bottom: 20px;
      border-bottom: 1px solid #bbb;
    }
    .img-box {
      padding: 20px;
      border-bottom: 1px solid #bbb;
      img {
        width: 90px;
        height: 90px;
        margin-right: 20px;
      }
    }
    .author {
      display: flex;
      justify-content: space-between;
      padding-top: 16px;
      font-size: 14px;
    }
  }
}
</style>