pathList.vue 6.15 KB
<template>
  <div>
    <div class="scrm-sub-client-container">
      <div class="pageContent">
        <GLCombiForm ref="combiForm" :formObj="searchForm" :formData="clientManageFormList" @handleOk="searchTable" @handleRest="resetTable"></GLCombiForm>
        <PathFlowChart :chartNodes="chartNodes" :chartLinks="chartLinks" />
      </div>
    </div>
  </div>
</template>

<script>
import PathFlowChart from './components/PathFlowChart'
import { nodes, links, weeklyData } from './components/chartData'

const EVENT_OPTIONS = [
  // App相关
  { label: 'App激活', value: 'App激活' },
  { label: 'App浏览页面', value: 'App浏览页面' },
  { label: 'App元素点击', value: 'App元素点击' },
  { label: 'App推送点击', value: 'App推送点击' },
  // Web/小程序/微信
  { label: 'web浏览页面', value: 'web浏览页面' },
  { label: '小程序首次启动', value: '小程序首次启动' },
  { label: '小程序浏览页面', value: '小程序浏览页面' },
  { label: '微信端内活跃', value: '微信端内活跃' },
  // 通用行为
  { label: '搜索', value: '搜索' },
  { label: '签到', value: '签到' },
  { label: '所有支付', value: '所有支付' }
]

export default {
  name: 'pathList',
  components: {
    PathFlowChart
  },
  data() {
    return {
      chartNodes: [],
      chartLinks: [],
      searchForm: {
        addWay: [],
        customerName: '',
        purchaseCar: ''
      },
      clientManageFormList: [
        // {
        //   type: 'input',
        //   inputType: 'text',
        //   name: 'customerName',
        //   label: '客户名称',
        //   placeholder: '请输入客户名称'
        // },
        // {
        //   type: 'select',
        //   name: 'addWay',
        //   label: '事件选择',
        //   multiple: true,
        //   collapseTags: true,
        //   optionLabel: 'label',
        //   optionId: 'value',
        //   placeholder: '请选择事件',
        //   optionList: EVENT_OPTIONS
        // },
        {
          type: 'datePicker',
          name: 'purchaseCar',
          label: '时间选择',
          valueFormat: 'yyyy-MM-dd',
          dateType: 'week',
          attrs: {
            format: 'yyyy 第 WW 周'
          },
          customPickerOptions: {
            disabledDate(time) {
              return time.getTime() > Date.now() || time.getTime() < new Date('2017-12-31').getTime()
            }
          }
        }
      ]
    }
  },
  created() {
    this.chartNodes = nodes
    this.chartLinks = links
  },
  methods: {
    //搜索表格
    searchTable() {
      // Check if filters are effectively empty
      const isAddWayEmpty = !this.searchForm.addWay || this.searchForm.addWay.length === 0
      const isDateEmpty = !this.searchForm.purchaseCar

      if (isAddWayEmpty && isDateEmpty) {
        // Show current data source
        this.chartNodes = nodes
        this.chartLinks = links
      } else if (!isDateEmpty) {
        // Try to find weekly data
        // searchForm.purchaseCar is 'yyyy-MM-dd'
        // We use fuzzy matching because the picker might return Sunday/Monday, and our keys are Mondays.
        const selectedTime = new Date(this.searchForm.purchaseCar).getTime()
        const matchedKey = Object.keys(weeklyData).find(key => {
          const keyTime = new Date(key).getTime()
          const diff = Math.abs(keyTime - selectedTime)
          // Match if within 3.5 days (covers same week alignment issues)
          return diff <= 3.5 * 24 * 60 * 60 * 1000
        })

        const data = matchedKey ? weeklyData[matchedKey] : null
        
        if (data) {
          this.chartNodes = data.nodes
          this.chartLinks = data.links
        } else {
          // No data for this week
          this.chartNodes = []
          this.chartLinks = []
        }
      } else {
        // Other filters (like addWay) but no date
        this.chartNodes = []
        this.chartLinks = []
      }
      // this.$refs.clientManage.refreshTable() 
    },
    //重置表格
    resetTable() {
      this.searchForm = {
        addWay: [],
        customerName: '',
        purchaseCar: ''
      }
      // Reset to original data
      this.chartNodes = nodes
      this.chartLinks = links
      
      // this.$refs.clientManage.refreshTable()
    },

  },
  mounted() {}
}
</script>

<style lang="scss" scoped>
@import '@/styles/variables.scss';
@import '@/styles/resetelement.scss';
// /deep/.el-table .el-table__header tr th{
//   line-height: 30px;
// }
.expandImg {
  display: flex;
  // justify-content: center;
  .smallFontSize {
    margin-left: 2px;
    height: 20px;
    font-size: 12px;
    letter-spacing: 0;
    line-height: 20px;
    font-weight: 400;
  }
  .imgEll {
    margin-left: 6.5px;
    cursor: pointer;
    // margin-bottom:3px;
  }
}
.pure-green-text {
  color: #61cc43;
}
.pure-yello-text {
  color: #fb8f28;
}
.scrm-sub-client-container {
  .pageTitle {
    margin-bottom: 20px;
    position: relative;
    height: 20px;
    font-size: 20px;
    font-weight: 700;
    color: #333333;
    line-height: 20px;
    letter-spacing: 1px;
  }
  .pageContent {
    .leadList {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 8px;
      div {
        text-align: center;
        span:nth-child(1) {
          font-weight: 600;
          font-size: 16px;
        }
      }
      /deep/ .el-button {
        color: #08C489;
        border: 1px solid #08C489;
      }
    }
    padding: 20px 20px 30px;
    background-color: #fff;
    .el-button + .el-button {
      margin-left: 10px;
    }
    .searchTop {
      // margin-bottom: 20px;
    }
    .glsx-table {
      // /deep/ .el-table__fixed {
      //   height: 100% !important; //设置高优先,以覆盖内联样式
      // }
      /deep/ .el-table__fixed,
      /deep/ .el-table__fixed-right {
        height: 100% !important; //设置高优先,以覆盖内联样式
      }
    }

    .entmicro {
      display: flex;
      i {
        color: #75acff;
        margin-right: 3px;
        font-size: 14px;
      }
      // }
    }

    .el-tag {
      // margin-right: 10px;
      max-width: 110px;
      cursor: pointer;
      background-color: #fff !important;
    }
  }
}
</style>