Newer
Older
urbanLifeline_YanAn / src / views / OutgoingCall / dataStatistics.vue
@zhangqy zhangqy on 3 Oct 4 KB first commit
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="110px">
      <el-form-item label="">
        <el-radio-group v-model="queryParams.radioType" @change="changeSele">
          <el-radio-button label="1">按天统计</el-radio-button>
          <el-radio-button label="2">按手机统计</el-radio-button>
          <el-radio-button label="3">按模板统计</el-radio-button>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="" prop="startTime">
        <el-date-picker @change="changeSele"
          v-model="queryParams.time"
          type="datetimerange"
          :shortcuts="shortcuts"
          :clearable="false"
          range-separator="至"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
        />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="unitVoiceRecordList">
      <el-table-column type="index" width="55" align="center" prop="序号" />
      <el-table-column v-if="queryParams.radioType=='2'"  label="手机号" align="center" prop="mobile" />
      <el-table-column v-if="queryParams.radioType=='1'" label="当前天" align="center" prop="startDate" />
      <el-table-column v-if="queryParams.radioType=='3'" label="模板名" align="center" prop="robotName" />
      <!-- <el-table-column label="时间" align="center" prop="startDate" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.startDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <el-table-column label="总数" align="center" prop="totalCount" />
      <el-table-column label="成功数" align="center" prop="yesCount" />
      <el-table-column label="失败数" align="center" prop="noCount" />
      <el-table-column label="总通话时间(秒)" align="center" prop="sumTime" />
      <el-table-column label="平均时间(秒)" align="center" prop="avgTime" />
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script setup name="UnitVoiceRecord">
import { unitVoiceDataDayCount, unitVoiceDataMobileCount, unitVoiceDataTemplateCount } from '@/api/OutgoingCall/dataStatistics';
import { onMounted } from 'vue';

const { proxy } = getCurrentInstance();

const unitVoiceRecordList = ref([]);

const loading = ref(true);
const showSearch = ref(true);

const shortcuts = [
  {
    text: '最近一周',
    value: () => {
      const end = new Date();
      const start = new Date();
      start.setDate(start.getDate() - 7);
      return [start, end];
    },
  },
  {
    text: '最近一个月',
    value: () => {
      const end = new Date();
      const start = new Date();
      start.setMonth(start.getMonth() - 1);
      return [start, end];
    },
  },
  {
    text: '最近三个月',
    value: () => {
      const end = new Date();
      const start = new Date();
      start.setMonth(start.getMonth() - 3);
      return [start, end];
    },
  },
];

const total = ref(0);

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    time: [],
    radioType: '1',
  },
  rules: {
    // dataId: [{ required: true, message: "记录id‘不能为空", trigger: "blur" }
    // ],
  },
});

const { queryParams, form, rules } = toRefs(data);

/** 查询语音外呼-呼叫记录内容列表 */
function getList() {
  console.log('queryParams', queryParams.value);
  loading.value = true;
  let data=queryParams.value
  let url =data.radioType=='1'?unitVoiceDataDayCount:data.radioType=='2'?unitVoiceDataMobileCount:unitVoiceDataTemplateCount;
  let params={
    pageNum:data.pageNum,
    pageSize:data.pageSize,
    startTime:data.time?.length>0?proxy.moment(data.time[0]).format('YYYY-MM-DD HH:mm:ss'):'',
    endTime:data.time?.length>0?proxy.moment(data.time[1]).format('YYYY-MM-DD HH:mm:ss'):'',
  }
  console.log(data.time[0]);
  url(params).then(response => {
    unitVoiceRecordList.value = response.data;
    total.value = response.total;
    loading.value = false;
  });
}

// 表单重置
function reset() {
  form.value = {};
  proxy.resetForm('unitVoiceRecordRef');
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  searchDefault();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm('queryRef');
  handleQuery();
}
function searchDefault() {
  const end = new Date();
  const start = new Date();
  start.setDate(start.getDate() - 7);
  queryParams.value.time = [start, end];
  queryParams.value.radioType = '1';
  getList();
}

function changeSele() {
  getList();

}
onMounted(() => {
  searchDefault();
});
</script>