index.vue 7.7 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 36
        <div class="title" v-if="selectOrgName">"{{selectOrgName}}" 展板互动信息汇总</div>
        <div class="title" v-if="!selectOrgName">展板互动信息汇总</div>
乐宝呗666's avatar
乐宝呗666 committed
37 38
        <div class="page-tip">
          <span class="page-tip-title">页面说明:</span>
乐宝呗666's avatar
乐宝呗666 committed
39
          <span class="page-tips">可查看某个组织机构的互动信息</span>
乐宝呗666's avatar
乐宝呗666 committed
40 41
        </div>
      </div>
乐宝呗666's avatar
乐宝呗666 committed
42
      <div class="scrollBox"  v-show="tableData.length">
乐宝呗666's avatar
乐宝呗666 committed
43 44 45 46 47
        <div
          class="content-item"
          v-for="(item, index) in tableData"
          :key="index"
        >
48 49
          <h5 class="title">{{ item.boardName }}</h5>
          <p>{{ item.content||'暂无内容' }}</p>
乐宝呗666's avatar
乐宝呗666 committed
50
          <div class="img-box" v-if="item.images.length">
乐宝呗666's avatar
乐宝呗666 committed
51 52 53 54
            <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
55
          </div>
乐宝呗666's avatar
乐宝呗666 committed
56
          <div class="img-box" v-if="!item.images.length">暂无数据</div>
乐宝呗666's avatar
乐宝呗666 committed
57
          <div class="author">
乐宝呗666's avatar
乐宝呗666 committed
58
            <div>{{ item.name }}</div>
乐宝呗666's avatar
乐宝呗666 committed
59 60 61 62
            <div>{{ item.createTime }}</div>
          </div>
        </div>
      </div>
乐宝呗666's avatar
乐宝呗666 committed
63
      <party-pagination style="margin-right:20px;" v-show="tableData.length" :page="page" @changePage="handleCurrentChange"/>
乐宝呗666's avatar
乐宝呗666 committed
64 65 66 67
    </el-card>
  </div>
</template>
<script>
68
import { partyPagination} from "@/components/index";
乐宝呗666's avatar
乐宝呗666 committed
69
export default {
70
  components: { partyPagination },
乐宝呗666's avatar
乐宝呗666 committed
71 72 73
  data() {
    return {
      filterText: "",
乐宝呗666's avatar
乐宝呗666 committed
74
      page: {
75 76
        _index: 1,
        _size: 10,
乐宝呗666's avatar
乐宝呗666 committed
77
        total: 0,
乐宝呗666's avatar
乐宝呗666 committed
78 79 80 81 82 83
      },
      treeData: [],
      defaultProps: {
        children: "children",
        label: "name",
      },
84 85
      selectOrgId: "",
      selectOrgName: "",
乐宝呗666's avatar
乐宝呗666 committed
86 87 88 89 90 91 92 93 94 95
      tableData: [],
    };
  },
  watch: {
    filterText(val) {
      this.$refs.tree.filter(val);
    },
  },
  mounted() {
    // 获取全部组织机构数据
乐宝呗666's avatar
乐宝呗666 committed
96 97
    this.getOrgData();
    // this.onSearch()
乐宝呗666's avatar
乐宝呗666 committed
98 99 100 101
  },
  methods: {
    // 查询
    onSearch() {
102
      this.page._index = 1;
乐宝呗666's avatar
乐宝呗666 committed
103
      this.getTableData();
乐宝呗666's avatar
乐宝呗666 committed
104 105 106
    },
    // 获得数据接口
    getTableData() {
乐宝呗666's avatar
乐宝呗666 committed
107 108
      let vm = this;
      vm.tableData = [];
乐宝呗666's avatar
乐宝呗666 committed
109
      let param = {
110 111
        _index: this.page._index,
        _size: this.page._size,
112
        orgId: this.selectOrgId,
乐宝呗666's avatar
乐宝呗666 committed
113 114 115 116 117 118 119 120 121 122 123
      };
      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
124 125 126 127 128 129 130
            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
131
            vm.tableData.forEach((item) => {
乐宝呗666's avatar
乐宝呗666 committed
132
              item.images = item.images ? item.images.split(",") : [];
乐宝呗666's avatar
乐宝呗666 committed
133
              item.images.forEach((result, index) => {
乐宝呗666's avatar
乐宝呗666 committed
134 135 136
                item.images[index] = {
                  url:result
                }
乐宝呗666's avatar
乐宝呗666 committed
137
                if (/\.(MP4|mp4)/.test(result)) {
乐宝呗666's avatar
乐宝呗666 committed
138
                  item.images[index].cover = require("@/assets/video-icon.png");
乐宝呗666's avatar
乐宝呗666 committed
139
                } else if (/\.(MP3|mp3)/.test(result)) {
乐宝呗666's avatar
乐宝呗666 committed
140 141 142 143 144
                  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
145
                }
乐宝呗666's avatar
乐宝呗666 committed
146 147 148
              });
            });
            vm.tableData = [...vm.tableData];
乐宝呗666's avatar
乐宝呗666 committed
149
          } else {
乐宝呗666's avatar
乐宝呗666 committed
150
            this.$message.error(res.data.message);
乐宝呗666's avatar
乐宝呗666 committed
151 152 153
          }
        })
        .catch(function (err) {
乐宝呗666's avatar
乐宝呗666 committed
154
          console.log(err);
乐宝呗666's avatar
乐宝呗666 committed
155 156 157 158 159 160 161 162 163 164 165
        });
    },
    // 获取组织机构数据
    getOrgData() {
      this.$https({
        method: "get",
        url: "organ/getTree",
        authType: this.backToken,
      }).then(
        (res) => {
          if (res.data.resultCode === "200") {
乐宝呗666's avatar
乐宝呗666 committed
166
            this.treeData = res.data.data;
乐宝呗666's avatar
乐宝呗666 committed
167
          } else {
乐宝呗666's avatar
乐宝呗666 committed
168
            this.$message.error(res.data.message);
乐宝呗666's avatar
乐宝呗666 committed
169 170 171
          }
        },
        (error) => {
乐宝呗666's avatar
乐宝呗666 committed
172
          console.log(error);
乐宝呗666's avatar
乐宝呗666 committed
173 174 175 176 177 178 179 180 181 182
        }
      );
    },
    // 过滤树结构数据
    filterNode(value, data) {
      if (!value) return true;
      return data.name.indexOf(value) !== -1;
    },
    // 点击节点事件
    handleNodeClick(data) {
183 184
      this.selectOrgId = data.id;
      this.selectOrgName = data.name;
乐宝呗666's avatar
乐宝呗666 committed
185
      this.onSearch();
乐宝呗666's avatar
乐宝呗666 committed
186 187 188
    },
    // 分页
    handleCurrentChange(val) {
189
      this.page._index = val;
乐宝呗666's avatar
乐宝呗666 committed
190
      this.getTableData();
乐宝呗666's avatar
乐宝呗666 committed
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
    },
  },
};
</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;
  }
乐宝呗666's avatar
乐宝呗666 committed
224 225 226 227 228 229 230 231 232 233 234
  @media screen and (max-width: 1024px) {
    .tree-box {
        width: 320px;
    }
    .detail-box {
      width: calc(100% - 340px);
    }
    .page-tip {
      display: none !important;
    }
}
乐宝呗666's avatar
乐宝呗666 committed
235 236 237 238 239 240 241 242
  .scrollBox {
    height: calc(100% - 160px);
    overflow-y: auto;
  }
  .page-tip {
    display: flex;
    font-size: 14px;
    color: #333333;
243
    line-height: 30px;
乐宝呗666's avatar
乐宝呗666 committed
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
    .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 {
274
      width: 220px;
乐宝呗666's avatar
乐宝呗666 committed
275 276 277 278 279 280 281 282 283 284 285 286 287
    }
  }
  .content-item {
    font-size: 16px;
    margin: 20px;
    padding: 40px;
    background: #f8f8f8;
    .title {
      padding-bottom: 20px;
    }
    p {
      padding-bottom: 20px;
      border-bottom: 1px solid #bbb;
乐宝呗666's avatar
乐宝呗666 committed
288 289
      white-space: normal;
      word-wrap: break-word;
乐宝呗666's avatar
乐宝呗666 committed
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
    }
    .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>