ClickRecord.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <base-form slot="content" ref="ruleForm" :data="searchData">
  3. <div slot="footer">
  4. <el-button :loading="listLoading" icon="el-icon-search" class="xl-form-btn bgc1" @click="searchHandle">查询</el-button>
  5. <el-button :loading="listLoading" icon="el-icon-document" class="xl-form-btn bgc2" @click="toExportExcel">导出</el-button>
  6. </div>
  7. </base-form>
  8. </template>
  9. <script>
  10. export default {
  11. props: {
  12. listLoading: Boolean
  13. },
  14. inject: ['parentData'],
  15. mixins,
  16. data() {
  17. return {
  18. searchData: []
  19. }
  20. },
  21. mounted () {
  22. this.getDef()
  23. },
  24. methods: {
  25. subwayLineChange (val) {
  26. this.getDef('change')
  27. },
  28. getDef (str) {
  29. let params = { ...this.$refs.ruleForm.baseForm }
  30. this.searchData = [
  31. { label: '咨询客户', key: 'nickname' },
  32. { label: '置业经理', key: 'sale_id', type: 'selectRemote',
  33. remoteParams: { skey: 'sale_name', api: `user.admsaleuserlist?page_size=999`, opKey: 'sale_name', opVal: 'id' }
  34. },
  35. { label: '点击类型', key: 'click_type', type: 'select', options: this.$dictData.contact_click_type},
  36. { label: '目标类型', key: 'target_type', type: 'select', options: this.$dictData.contact_target_type},
  37. { label: '点击时间', label2: '开始时间', label3: '结束时间', key: 'startEndTime', type: 'datePicker', rules: 1},
  38. ]
  39. this.setDefaultValue(params, 'searchData')
  40. },
  41. toExportExcel () {
  42. const oldform = this.$refs.ruleForm.baseForm
  43. const newForm = { ...oldform }
  44. if (newForm.startEndTime) {
  45. newForm.start_at = newForm.startEndTime[0]
  46. newForm.end_at = newForm.startEndTime[1]
  47. delete newForm.startEndTime
  48. } else {
  49. this.$msgw('请选择导出的时间范围')
  50. return
  51. }
  52. const token = window.sessionStorage.getItem('fp_token')
  53. window.open(`https://api.honglouplus.com/adm/contact/click/export?token=${encodeURIComponent(token)}&target_type=${newForm.target_type}&start_at=${newForm.start_at}&end_at=${newForm.end_at}&sale_id=${newForm.sale_id}`)
  54. },
  55. searchHandle() {
  56. const oldform = this.$refs.ruleForm.baseForm
  57. const newForm = { ...oldform }
  58. if (newForm.startEndTime) {
  59. newForm.start_at = newForm.startEndTime[0]
  60. newForm.end_at = newForm.startEndTime[1]
  61. }
  62. delete newForm.startEndTime
  63. this.$emit('change', newForm)
  64. }
  65. }
  66. }
  67. </script>