index.vue 13.1 KB
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 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 62 63 64 65 66 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 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 224 225 226 227 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 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 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 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446
<template>
  <div class="main-container">
    <div class="top">
      <el-button type="primary" @click="addMaterial(1)" :size="size">
        <i class="el-icon-plus"></i>
        创建营销素材
      </el-button>
      <span>功能介绍<i class="el-icon-arrow-right"></i></span>
    </div>
    <div class="container">
      <div class="search-form">
        <glsx-combi-form ref="materialFormRef1" :isEdit="isEdit" :formObj="searchForm" :formData="materialFormData1" :inline="true">
        </glsx-combi-form>
        <glsx-combi-form ref="materialFormRef2" :isEdit="isEdit" :formObj="searchForm" :formData="materialFormData2" :inline="true">
          <span slot="footer" slot-scope="scope" class="select-pro">
            <el-button type="primary" :size="size" @click="handleSearch(scope)">查询</el-button>
            <el-button type="default" :size="size" @click="handleReset(scope)">重置</el-button>
          </span>
        </glsx-combi-form>
      </div>
      <div class="tabelList">
        <el-row>
          <el-col :span="5">
            <div class="left">
              <el-button class="add-group" type="primary" icon="el-icon-plus" :size="size" @click="handleAddGroup(1)">创建素材组</el-button>
              <div class="all-group">全部素材组  ({{ groupCounter.length }})</div>
              <ul>
                <!-- <li class="all-group">全部素材组({{ groupCounter.length }})</li> -->
                <li>
                  新车素材组(默认)
                  <el-popover placement="right" width="20" trigger="hover">
                    <el-button-group>
                      <el-button type="text" @click="handleStick">置顶</el-button>
                      <el-button type="text" @click="handleAddGroup(2)">修改</el-button>
                      <el-button type="text" @click="handleDeleteGroup">删除</el-button>
                    </el-button-group>
                    <i slot="reference" class="el-icon-more"></i>
                  </el-popover>
                </li>
                <li v-for="(item, index) in groupCounter" :key="index">
                  {{ item.groupName }}
                  <el-popover placement="left" width="400" trigger="hover">
                    <el-button-group>
                      <el-button type="text" @click="handleStick">置顶</el-button>
                      <el-button type="text" @click="handleAddGroup(2)">修改</el-button>
                      <el-button type="text" @click="handleDeleteGroup">删除</el-button>
                    </el-button-group>
                    <i slot="reference" class="el-icon-s-tools"></i>
                  </el-popover>
                </li>
              </ul>
            </div>
          </el-col>
          <el-col :span="19">
            <div class="right">
              <div class="groupTitle">新车素材组 (共{{ materialTableData.length }}条数据)</div>
              <GLTable ref="materialRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm" :tableParams="tableParams" :tableData="materialTableData" :pageConf="pageConf" :tableTotal="tableTotal" @sortChange="sortChange">
                <!-- 素材内容 -->
                <div slot="materialContent">
                  <!-- 素材内容为自定义文本 -->
                  <div v-if="materialTableData.materialType === '图文'">
                    <div>素材标题</div>
                    <div>放置图片</div>
                  </div>
                  <!-- 素材内容为PDF -->
                  <div v-if="materialTableData.materialType === 'PDF'">
                    <div>素材标题</div>
                    <div>PDF图片 pdf文件名.pdf</div>
                  </div>
                  <!-- 素材内容链接 -->
                  <div v-if="materialTableData.materialType === '自定义链接'">
                    <div>素材标题</div>
                    <div>
                      <div>图片</div>
                      <div>链接</div>
                    </div>
                  </div>
                </div>
                <!-- 状态 -->
                <div slot="status"></div>
                <span slot="auth-button" slot-scope="scope">
                  <el-button type="text" @click="handleDetail(scope.scope)">详情</el-button>
                  <el-button type="text" @click="addMaterial(2, scope.scope)">编辑</el-button>
                  <el-button type="text">更多</el-button>
                  <!-- <el-button type="text" @click="handleForbid(scope)">禁用</el-button> -->
                  <!-- <el-button type="text" @click="handleDelete(scope)">删除</el-button> -->
                </span>
              </GLTable>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
    <AddMaterialGroupDia ref="addMaterialGroup" :dialogVisible="materialGroupDialog" @addMaterialGroup="addGroup"></AddMaterialGroupDia>
  </div>
</template>

<script>
import url from '@/assets/empty.png'
import AddMaterialGroupDia from '@/views/material/components/addMaterialGroupDia'
export default {
  name: 'materialList',
  components: {
    AddMaterialGroupDia
  },
  data() {
    return {
      url,
      searchForm: {
        applicationType: '',
        materialType: '',
        status: '',
        materialName: ''
      },
      materialTableData: [
        {
          id: 123,
          materialContent: '内容',
          status: '正常',
          materialType: '类型',
          sendTimes: 5,
          readPer: 100,
          effect_readPer: 50,
          updateTime: '2016-12-03 22:09:36'
        },
        {
          id: 124,
          materialContent: '内容',
          status: '正常',
          materialType: '类型',
          sendTimes: 6,
          readPer: 100,
          effect_readPer: 50,
          updateTime: '2016-12-03 22:09:36'
        },
        {
          id: 125,
          materialContent: '内容',
          status: '正常',
          materialType: '类型',
          sendTimes: 5,
          readPer: 112,
          effect_readPer: 50,
          updateTime: '2016-12-03 22:09:36'
        },
        {
          id: 126,
          materialContent: '内容',
          status: '正常',
          materialType: '类型',
          sendTimes: 5,
          readPer: 30,
          effect_readPer: 50,
          updateTime: '2016-12-03 22:09:36'
        }
      ],
      materialGroupDialog: false,
      // 素材组
      groupCounter: [],
      materialFormData1: [
        {
          label: '业务类型:',
          name: 'applicationType',
          type: 'select',
          placeholder: '全部'
        },
        {
          label: '素材类型:',
          name: 'materialType',
          type: 'select',
          placeholder: '全部类型'
        },
        {
          label: '状态:',
          name: 'status',
          type: 'select',
          placeholder: '全部(不包括删除)'
        }
      ],
      materialFormData2: [
        {
          label: '素材名称:',
          name: 'materialName',
          type: 'input',
          placeholder: '输入素材关键字'
        }
      ],
      tableParams: {
        listName: 'list',
        tableOption: true,
        tableColumns: [
          {
            label: '素材内容',
            prop: 'materialContent',
            addHtml: 'materialContent'
          },
          {
            label: '状态',
            prop: 'status'
            // addHtml: 'status'
          },
          {
            label: '类型',
            prop: 'materialType'
          },
          {
            label: '发送次数',
            prop: 'sendTimes',
            sortable: true
          },
          {
            label: '阅读人数',
            prop: 'readPer',
            sortable: true
          },
          {
            label: '有效阅读人数',
            prop: 'effect_readPer',
            sortable: true,
            width: '160px'
          },
          {
            label: '更新时间',
            prop: 'updateTime',
            sortable: true
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
      tableTotal: 4
    }
  },
  methods: {
    // 搜索
    handleSearch() {
      this.$refs.materialRef.refreshTable()
    },
    // 重置
    handleReset() {
      this.searchForm = {
        applicationType: '',
        materialType: '',
        status: '',
        materialName: ''
      }
      this.handleSearch()
    },
    // 素材详情
    handleDetail(scope) {
      console.log(scope.id)
      // this.$router.push('/material/materialDetail/' + scope.id)
      this.$router.push({
        path: '/material/materialDetail',
        query: scope.id
      })
    },
    // 素材禁用
    handleForbid() {
      this.$confirm('禁用素材,所有已经发送给客户的素材链接均会失效,是否继续禁用?', '提示', {
        distinguishCancelAndClose: true,
        confirmButtonText: '确定禁用',
        cancelButtonText: '取消'
      })
        .then(() => {
          this.$message({
            type: 'info',
            message: '禁用成功'
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消禁用'
          })
        })
    },
    // 素材删除
    handleDelete() {
      this.$confirm('删除素材,所有已经发送给客户的素材链接均会失效,是否继续删除?', '提示', {
        distinguishCancelAndClose: true,
        confirmButtonText: '确定删除',
        cancelButtonText: '取消'
      })
        .then(() => {
          this.$message({
            type: 'info',
            message: '删除成功'
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    // 打开1-新增, 2-编辑 素材组弹框
    handleAddGroup(addOrEdit, value) {
      console.log(addOrEdit, value)
      this.materialGroupDialog = true
      this.$refs.addMaterialGroup.init(addOrEdit)
    },
    // 新增或编辑素材组
    addGroup(value) {
      this.groupCounter.push(value)
      console.log(this.groupCounter, '-----')
    },
    // 素材组置顶
    handleStick() {},
    // 素材组删除
    handleDeleteGroup() {},
    // 1-新增素材,2-编辑素材
    addMaterial(addOrEdit, scope) {
      console.log(addOrEdit, scope)
      var params = {
        addOrEdit: addOrEdit,
        $title: encodeURI(addOrEdit == 1 ? '创建营销素材' : '编辑营销素材')
      }
      addOrEdit != 1 && (params.id = scope.id)
      this.$router.push({
        path: '/material/addMaterial',
        query: params
      })
    },
    // 排序
    sortChange(sort) {
      console.log(sort)
      // 获取字段名称和排序类型
      var fieldName = sort.prop
      var sortingType = sort.order
      //如果字段名称为“创建时间”,将“创建时间”转换为时间戳,才能进行大小比较
      // if(fieldName=="createTime"){
      //   this.tableData2.map(item => {
      //     item.createTime = this.$moment(item.createTime).valueOf()
      // })

      // 次数排序
      if (sort.column.label === '发送次数') {
        this.handleSort(sortingType, fieldName)
      }

      // 阅读人数排序
      if (sort.column.label === '阅读人数') {
        this.handleSort(sortingType, fieldName)
      }

      // 有效阅读人数排序
      if (sort.column.label === '有效阅读人数') {
       this.handleSort(sortingType, fieldName)
      }
    },
    // 排序规则
    handleSort(sortingType, fieldName) {
      //按照降序排序
        if (sortingType == 'descending') {
          this.materialTableData = this.materialTableData.sort((a, b) => b[fieldName] - a[fieldName])
        }
        //按照升序排序
        else {
          this.materialTableData = this.materialTableData.sort((a, b) => a[fieldName] - b[fieldName])
        }
    }
  }
}
</script>

<style lang="scss" scoped>
.search-form,
.left,
.right {
  background-color: #fff;
}
.main-container {
  height: 100%;
  .top {
    span {
      margin-left: 16px;
      font-size: 16px;
      color: #5850FF;
    }
  }
}
ul {
  li {
    list-style: none;
  }
}
.group-frame {
  width: 72px;
  height: 106px;
  background: #FFFFFF;
  ul {
    margin: 0 8px;
    padding-top: 1px;
    text-align: center;
    li {
      margin: 15px 0;
    }
  }
}
.container {
  margin-top: 10px;
  height: 100%;
  .search-form {
    padding: 20px 68px 0 68px;
  }
  .tabelList {
    margin-top: 10px;
    height: 100%;
    .left {
      height: 100%;
      position: relative;
      border-right: 1px solid #E8E8EA;
      .add-group {
        margin: 20px 0 16px 16px;
      }
      .all-group {
          font-size: 16px;
          font-weight: 600;
          margin: 0 0 19px 16px;
        }
      ul {
        li {
          margin: 0 0 22px 18px;
          position: relative;
          i {
            font-size: 16px;
            position: absolute;
            right: 16px;
            transform:rotate(90deg);
          }
        }
      }
    }
    .right {
      .groupTitle {
        padding: 20px 0 16px 19px;
        font-weight: 600;
      }
      .glsx-table {
        margin: 0 20px;
      }
    }
  }
}
</style>>