index.vue 14.7 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 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512
<template>
  <div class="store-wrap">
    <div class="container">
      <GLCombiForm ref="showSearch" :rowNumber="1" :formObj="tableSearchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
      <div class="store-head">
        <div class="info">门店管理列表</div>
        <el-button type="primary" size="small" @click="handleAdd">新建</el-button>
      </div>
      <GLTable ref="storeRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm" :tableParams="tableParams" :beforeSearchFn="beforeSearchFn" :pageConf="pageConf" @setTableFinishFun="setTableFinishFun">
        <div slot="activityImg" class="table-image" slot-scope="scope">
          <el-popover placement="top" width="160" trigger="hover" popper-class="table-popover-block">
            <img class="table-popover-img" :src="scope.scope.activityImg" />
          </el-popover>
        </div>
        <template slot="activityLink" slot-scope="scope">
          <span class="relink">{{ scope.scope.activityName }}</span>
        </template>
        <template slot="moveCarCodeCount" slot-scope="scope">
          <span class="moveCarCodeCount" @click="opneMoveMessage(scope.scope)">{{ scope.scope.moveCarCodeCount }}</span>
        </template>
        <template slot="switch" slot-scope="scope">
          <el-switch v-model="scope.scope.isOpen" @change="updateState(scope.scope)"></el-switch>
        </template>
        <div class="table-btns" slot="auth-button" slot-scope="scope">
          <!-- <el-button type="text" @click="handlePreview(scope.scope)">预览</el-button> -->
          <el-button type="text" @click="handleEdit(scope.scope)">编辑</el-button>
          <el-button type="text" @click="handleShare(scope.scope)">分享</el-button>
        </div>
      </GLTable>
      <div v-show="false">
        <div class="nodata-panel">
          暂无数据,
          <a @click="handleAdd()">立即创建</a>
        </div>
      </div>
    </div>
    <!-- 预览 -->
    <GLDialog :mode="mode" title="预览" :visible.sync="previewVisible" :hasFooter="hasFooter">
      <div class="preview-wrap">
        <div class="content">
          <div class="title">XX频道-频道显示</div>
          <div class="content-left-img">
            <img src="https://scrm.test.glsx.com.cn/group1/M00/03/89/wKgD3mOpdwGAYz3oAADubdbqeKs402.png" />
          </div>
          <div class="contet-bottom-info">
            <div class="info-title word-hide">广汇凯威行年中直播购物节广汇凯威行年中直播购物节</div>
            <div class="flex mgt15">
              <img class="profile" src="https://scrm.test.glsx.com.cn/group1/M00/03/89/wKgD3mOpdwGAYz3oAADubdbqeKs402.png" />
              <div class="anchor">主播:小艺、小明</div>
            </div>
            <div class="qr-code">
              <img src="http://qcimg01.glsx.com.cn:7060/group1/M00/03/8B/wKgD3mOql2KAFOSKAAFR2Yt613E480.png" />
            </div>
          </div>
        </div>
        <div class="content">
          <div class="title">XX频道-频道显示</div>
          <div style="display: flex">
            <img class="head" src="https://scrm.test.glsx.com.cn/group1/M00/03/89/wKgD3mOpdwGAYz3oAADubdbqeKs402.png" />
            <div class="content-right-info">
              <div class="advertise-title">新车频道推广</div>
              <img class="advertise-pic" src="https://scrm.test.glsx.com.cn/group1/M00/03/89/wKgD3mOpdwGAYz3oAADubdbqeKs402.png" />
              <div class="line"></div>
              <div class="flex">
                <img class="procedure-logo" src="@/assets/channel/procedure-logo.png" />
                <div class="procedure">小程序</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </GLDialog>
    <!-- 分享 -->
    <GLDialog class="share-dialog" :mode="mode" title="分享" :visible.sync="shareVisible" :hasFooter="hasFooter">
      <GLTabs v-model="activeName" :tabPaneList="tabPaneList" @tab-click="handleClick"></GLTabs>
      <div class="preview-wrap">
        <div class="share-content">
          <div>
            <div class="share-title">频道分享海报</div>
            <el-button type="primary" @click="handleSaveImg(shareData.posterUrl)">保存图片</el-button>
          </div>
          <div class="poster">
            <img :src="shareData.posterUrl" />
          </div>
        </div>
        <div class="share-content">
          <div>
            <div class="share-title">小程序码</div>
            <el-button type="primary" @click="handleSaveImg(shareData.qrCodeUrl, '小程序码')">保存图片</el-button>
          </div>
          <div class="qr-code">
            <img :src="shareData.qrCodeUrl" />
          </div>
        </div>
      </div>
      <div class="share-footer">
        <div class="share-title">小程序页面路径</div>
        <div class="share-path">{{ shareData.urlLink }}</div>
        <el-button class="share-btn" type="primary" @click="handleSaveTxt(shareData.urlLink)">复制链接</el-button>
      </div>
    </GLDialog>
  </div>
</template>

<script>
import url from '@/assets/empty.png'
import * as dayjs from 'dayjs'
import { mapMutations } from 'vuex'
export default {
  name: 'App',
  data() {
    return {
      tableSearchForm: {
        merchantName: '',
        createDate: []
      },
      shareMerchantId: '',
      tabPaneList: [],
      activeName: '',
      searchForm: {},
      url: url,
      mode: 'mid',
      hasFooter: false,
      previewVisible: false, //预览
      shareVisible: false, //分享
      shareData: {},
      searchFormData: [
        {
          label: '门店名称',
          name: 'merchantName',
          type: 'input'
        },
        {
          label: '创建日期',
          name: 'createDate',
          type: 'datePicker',
          isClear: true,
          customPickerOptions: {
            disabledDate(date) {
              const yesterday = new Date(new Date().setDate(new Date().getDate()))
              if (date > yesterday) {
                return true
              }
              return false
            }
          }
        }
      ],
      getListApi: this.$apis.store.getMerchantListApi,
      tableParams: {
        listName: 'list',
        // tableOption: true,
        tableColumns: [
          {
            label: '门店名称',
            prop: 'merchantName',
            width: '250',
            line:1
          },
          {
            label: '频道个数',
            prop: 'channelCount ',
            // width: '120',
            formatter: cellValue => {
              return cellValue.channelCount || '-'
            }
          },
          {
            label: '创建日期',
            prop: 'createdDate',
            // width: '180',
            formatter: cellValue => {
              return dayjs(cellValue.createdDate).format('YYYY-MM-DD HH:mm:ss')
            }
          },
          {
            label: '更新日期',
            prop: 'updatedDate',
            // width: '180',
            formatter: cellValue => {
              return dayjs(cellValue.updatedDate).format('YYYY-MM-DD HH:mm:ss')
            }
          },
          {
            label: '操作人',
            prop: 'updatedBy'
          },
          {
            label: '操作',
            addHtml: 'auth-button',
            fixed: 'right',
            width: 150
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' }
    }
  },
  created() {
  },
  mounted() {},
  methods: {
      ...mapMutations({
      SET_CHANNEL_TYPE: 'channel/SET_CHANNEL_TYPE'
    }),
    getParams() {
      var params = JSON.parse(JSON.stringify(this.tableSearchForm))
      if (this.tableSearchForm.createDate.length) {
        params.beginDate = new Date(this.tableSearchForm.createDate[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
        params.endDate = new Date(this.tableSearchForm.createDate[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
      }

      return params
    },
    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchForm = this.getParams()
        delete this.searchForm.createDate
        resolve()
      })
    },
    //保存图片
    handleSaveImg(url, downloadTxt = '海报') {
      var alink = document.createElement('a')
      alink.href = url
      alink.setAttribute('target', '_blank')
      alink.download = downloadTxt
      alink.click()
      alink.remove()
    },
    getChannelList() {
      this.$apis.store
      .getconfigMerchant({
        pageSize: 100,
        pageNum: 1,
        merchantId: this.shareMerchantId
      })
      .then(res => {
        if(res?.length){
          let tabPaneList = [] 
          res.forEach(item => { 
            tabPaneList.push({label: item.channelName,name: item.channelType,merchantChannelId: item.id})
          })
          this.tabPaneList = tabPaneList
          this.activeName = tabPaneList[0].name
          this.getShareData()
        }
      })
    },
    handleClick(){
      this.getShareData()
    },
    //分享
    handleShare(val) {
      this.shareMerchantId = val.merchantId
      this.getChannelList()
      this.shareVisible = true
    },
    getShareData(){
      this.$apis.store.getMerchantShare({ merchantId: this.shareMerchantId, channelType: this.activeName }).then(res => {
        this.shareData = res
      })
    },
    //预览
    handlePreview() {
      this.previewVisible = true
    },
    //复制
    handleSaveTxt(txt) {
      this.$message({
        message: '复制成功',
        type: 'success',
        customClass: 'message-Z-zinde'
      })
      const input = document.createElement('input')
      document.body.appendChild(input)
      input.setAttribute('value', txt)
      input.select()
      document.execCommand('Copy')
      document.body.removeChild(input)
    },
    handleAdd(scope) {
      this.$router.push('/store/add')
    },
    handleSearch() {
      this.$refs.storeRef.refreshTable()
    },
    handleReset() {
      this.tableSearchForm = {
        merchantName: '',
        createDate: []
      }
      this.searchForm = {}
      this.handleSearch()
    },
    setTableFinishFun() {
      if (this.$refs.storeRef.data.length) {
        this.$refs.storeRef.tableHeightValues = ''
      } else {
        const tableSearchArr = Object.values(this.searchForm).find(item => item)
        let cloneNode,
          nodata = document.querySelector('.nodata-panel')
        this.$nextTick(() => {
          if (tableSearchArr) {
            nodata.setAttribute('style', 'display:none')
            cloneNode = '暂无数据'
            document.querySelector('.noDataText').innerHTML = ''
            document.querySelector('.noDataText').append(nodata)
          } else {
            nodata.setAttribute('style', 'display:block')
            document.querySelector('.noDataText').innerHTML = ''
            cloneNode = nodata
          }
          document.querySelector('.noDataText').append(cloneNode)
          this.$refs.storeRef.setTableHeightFun()
        })
      }
    },
    handleEdit(val) {
        this.SET_CHANNEL_TYPE({ channelType: '' })
      this.$router.push({
        path: `/store/edit?merchantId=${val.merchantId}`
      })
    }
  }
}
</script>

<style scoped lang="scss">
.store-wrap {
  .store-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 0 18px 0;
    .info {
      font-weight: 600;
      font-size: 16px;
      color: #333333;
    }
  }
  .nodata-panel {
    a {
      cursor: pointer;
      color: #5850ff;
    }
  }
  .preview-wrap {
    display: flex;
    justify-content: space-between;
    .content {
      width: 335px;
      height: 388px;
      background: #f8f8f8;
      border-radius: 2px;
      padding: 20px;
      box-sizing: border-box;
      .title {
        font-weight: 600;
        font-size: 14px;
        color: #333333;
        margin-bottom: 10px;
      }
      .content-left-img {
        width: 200px;
        height: 200px;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .contet-bottom-info {
        width: 200px;
        height: 118.42px;
        background: #ffffff;
        padding: 7.89px;
        box-sizing: border-box;
        .info-title {
          font-weight: 600;
          font-size: 13.16px;
          color: #333333;
          width: 180px;
        }
        .profile {
          width: 19.74px;
          height: 19.74px;
          border-radius: 50%;
          margin-right: 7.9px;
        }
        .anchor {
          font-weight: 500;
          font-size: 11.84px;
          color: #999999;
        }
        .qr-code {
          width: 51.32px;
          height: 51.32px;
          margin-left: 130px;
          img {
            width: 100%;
            height: 100%;
          }
        }
      }
      .head {
        width: 26px;
        height: 26px;
        border-radius: 2px;
        margin-right: 3px;
      }
      .content-right-info {
        width: 176px;
        height: 184px;
        background: #ffffff;
        padding: 6px 6px 5px 10px;
        .advertise-title {
          font-weight: 400;
          font-size: 12px;
          color: #333333;
          margin-left: 3px;
          margin-bottom: 6px;
        }
        .advertise-pic {
          width: 160px;
          height: 127px;
        }
        .line {
          width: 160px;
          height: 0.5px;
          background: #ededed;
          margin: 8px auto 4.5px auto;
        }
        .procedure {
          font-weight: 400;
          font-size: 8px;
          color: #666666;
        }
        .procedure-logo {
          width: 10px;
          height: 10px;
        }
      }
    }
  }

  .share-dialog{
    .preview-wrap{
      margin-top: 10px;
    }
    /deep/ .el-dialog__body{
      padding-top: 0;
    }
  }
  .share-content {
    width: 335px;
    height: 328px;
    background: #f8f8f8;
    border-radius: 2px;
    display: flex;
    justify-content: space-between;
    padding: 20px;
    box-sizing: border-box;
    .share-title {
      font-weight: 600;
      font-size: 14px;
      color: #333333;
      margin-bottom: 50px;
    }
    .qr-code {
      width: 120px;
      height: 120px;
      img {
        width: 100%;
        height: 100%;
      }
    }
    .poster {
      width: 152px;
      height: 242px;
      img {
        width: 100%;
        height: 100%;
      }
    }
  }
  .share-footer {
    width: 680px;
    height: 90px;
    background: #f8f8f8;
    border-radius: 2px;
    margin-top: 10px;
    padding: 10px 20px;
    box-sizing: border-box;
    .share-path {
      font-weight: 600;
      font-size: 14px;
      color: #999999;
    }
    .share-title {
      font-weight: 600;
      font-size: 14px;
      color: #333333;
      margin-bottom: 10px;
    }
    .share-btn{
      position: absolute;
      right:40px;
      bottom: 30px;
    }
  }
}
</style>