index.vue 8 KB
<!--
 * @Author: yangming yangming@didihu.com.cn
 * @Date: 2023-09-05 17:24:08
 * @LastEditors: yangming yangming@didihu.com.cn
 * @LastEditTime: 2024-01-10 09:14:20
 * @FilePath: \scrm-micro-journey\src\views\journeyConfig\index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="journey-main">
    <div class="bg-fff p20">
      <GLCombiForm ref="formSearch" :formObj="searchForm" :formData="searchFormData" @handleOk="byGroupIdSop" @handleRest="handleReset"></GLCombiForm>
      <div class="journey-body" v-if="journeyList.length">
        <div class="journey-item" v-for="item in journeyList" :key="item.id">
          <div class="journey-item-head flex-column-center ">
            <img src="@/assets/config/icon-1.png" />
            <span>{{ item.instName }}</span>
            <a @click="handleEdit(item)">编辑</a>
            <div :class="{ 'journey-item-status  flex-center': true, 'is-disable': item.instStatus == -1 || item.instStatus == 0 }">
              <i :class="`${getStatusValue(item, 'icon')}`"></i>
              <span>{{ getStatusValue(item, 'label') }}</span>
            </div>
          </div>
          <div class="journey-item-body">
            <div class="journey-process">
              <div class="journey-process-item" v-for="(p, index) in item.journeyItem" :key="index">
                <img src="@/assets/config/icon-next.png" class="journey-status" v-if="index != item.journeyItem.length - 1" />
                <img src="@/assets/config/icon-end.png" class="journey-status" v-else />
                <div class="journey-step__main">
                  <div class="journey-step-icon"></div>
                  <div class="journey-step-desc">{{ p.label }}</div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="empty-panel" v-else>
        <div class="empty-img">
          <img src="@/assets/config/empty.png" />
        </div>
        <div class="empty-txt">
          暂无数据
        </div>
      </div>
    </div>
  </div>
</template>
<script>
const STATUS = [
  { label: '已启用', value: 1, icon: 'el-icon-check' },
  { label: '未启用', value: 0, icon: 'el-icon-close' },
  { label: '已禁用', value: -1, icon: 'el-icon-remove-outline' }
]
export default {
  data() {
    return {
      searchForm: {
        instStatus: [1, 0]
      },
      journeyAllList: [],
      searchFormData: [
        {
          label: '旅程',
          name: 'instId',
          type: 'select',
          optionList: [],
          optionId: 'instId',
          optionLabel: 'instName'
        },
        {
          label: '状态',
          name: 'instStatus',
          type: 'select',
          optionList: STATUS,
          optionId: 'value',
          optionLabel: 'label',
          multiple: true
        }
      ],
      journeyList: []
      // journeyList: [
      //   {
      //     id: 1,
      //     title: '续保客户旅程1',
      //     status: 1,
      //     journeyItem: [
      //       {
      //         label: '待跟进',
      //         process: 1
      //       },
      //       {
      //         label: '有意向',
      //         process: 2
      //       },
      //       {
      //         label: '可报价',
      //         process: 3
      //       },
      //       {
      //         label: '已成交',
      //         process: 4
      //       },
      //       {
      //         label: '战败',
      //         process: 5
      //       }
      //     ]
      //   },
      //   {
      //     id: 2,
      //     title: '续保客户旅程2',
      //     status: 2,
      //     journeyItem: []
      //   },
      //   {
      //     id: 2,
      //     title: '续保客户旅程3',
      //     status: 3,
      //     journeyItem: []
      //   }
      // ]
    }
  },
  mounted() {
    this.byGroupIdSop()
  },
  methods: {
    async byGroupIdSop() {
      const res = await this.$apis.journeyConfig.byGroupIdSop({ groupId: this.$globalState.session.merchantId, pageNumber: 1 })
      this.journeyAllList = res.list || []
      this.journeyAllList.forEach(item => {
        const stages = JSON.parse(item.instParam).stages
        item.journeyItem = []
        let process = 0
        for (let k in stages) {
          process++
          item.journeyItem.push({
            label: stages[k].value,
            process
          })
        }
        this.searchFormData[0].optionList = this.$common.utils.deepClone(this.journeyAllList)
        this.handleSearch()
      })
    },
    //状态值映射
    getStatusValue(val, prop) {
      if (!val || !prop) return
      return STATUS.find(item => item.value == val.instStatus)[prop]
    },
    handleEdit(item) {
      this.$router.push({
        path: '/journeyConfig/config',
        query: {
          title: item.instName,
          instId: item.instId
        }
      })
    },
    async handleSearch() {
      const { instStatus, instId } = this.searchForm
      this.journeyList = this.journeyAllList
      if (instId) {
        this.journeyList = this.journeyList.filter(item => item.instId == instId)
      }
      if (instStatus && instStatus.length) {
        this.journeyList = this.journeyList.filter(item => instStatus.includes(item.instStatus))
      }
    },
    handleReset() {
      this.searchForm = {}
      this.byGroupIdSop()
    }
  }
}
</script>
<style lang="scss" scoped>
.empty-panel {
  font-size: 16px;
  color: #999999;
  text-align: center;
  height: calc(100vh - 290px);
  .empty-img {
    width: 268px;
    height: 88;
    margin: 60px auto 4px;
  }
}
.journey-item {
  border: 1px solid #f0f0fb;
  border-radius: 4px;
  &-head {
    height: 50px;
    padding-left: 16px;
    border-bottom: 1px solid #f0f0fb;
    img {
      width: 30px;
      height: 30px;
    }
    > span {
      font-size: 16px;
      color: #333333;
      margin: 0px 10px;
    }
    a {
      font-size: 14px;
      color: #5850ff;
      cursor: pointer;
    }
    .journey-item-status {
      margin-left: auto;
      width: 84px;
      height: 28px;
      background-image: linear-gradient(108deg, #2cca74 0%, #16ced2 100%);
      border-radius: 2px 0 0 2px;
      color: #ffffff;
      font-size: 14px;
      &.is-disable {
        background-image: linear-gradient(108deg, #acacca 0%, #c9bcd0 100%);
      }
      i {
        margin-right: 4px;
        &.el-icon-remove-outline {
          transform: rotate(180deg);
        }
      }
    }
  }
  &-body {
    padding: 32px;
    display: flex;
    // justify-content: center;
    .journey-process {
      display: flex;
      flex-wrap: nowrap;
      overflow-x: auto;
      &-item {
        position: relative;
        flex: 0 0 195px;
        width: 195px;
        height: 88px;
        &:last-child {
          flex: 0 0 88px;
          width: 88px;
        }
        .journey-status {
          position: absolute;
          height: 88px;
          width: auto;
        }
        .journey-step__main {
          position: absolute;
          width: 88px;
          text-align: center;
          top: 15px;
          margin: auto;
          .journey-step-icon {
            margin: 5px auto;
          }
          .journey-step-desc {
            font-size: 14px;
            color: #333333;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            padding: 0px 6px;
          }
        }
      }
    }
  }
}
.journey-step-icon {
  width: 25px;
  height: 24px;
  background: url('../../assets/config/sop_icon.png');
  background-size: 100% 100%;
}
.step-icon-2 {
  background: url('../../assets/config/icon-sprites.png') -10px -10px;
}
.step-icon-3 {
  background: url('../../assets/config/icon-sprites.png') -55px -10px;
}
.step-icon-4 {
  background: url('../../assets/config/icon-sprites.png') -10px -54px;
}
.step-icon-5 {
  background: url('../../assets/config/icon-sprites.png') -55px -54px;
}
.step-icon-1 {
  background: url('../../assets/config/icon-sprites.png') -54px -142px;
}
</style>