Browse Source

bug修复

Szx 3 năm trước cách đây
mục cha
commit
dae61c27c2
3 tập tin đã thay đổi với 250 bổ sung192 xóa
  1. 237 187
      src/views/data/performance-detail.vue
  2. 9 4
      src/views/data/performance.vue
  3. 4 1
      src/views/put/ad-group.vue

+ 237 - 187
src/views/data/performance-detail.vue

@@ -112,7 +112,7 @@ import { Moment } from "moment";
 import moment from "moment";
 import { TableColumnOfStuffDetail } from "../_pageOptions/table_data";
 
-import { ColumnProps } from 'ant-design-vue/es/table/interface';
+import { ColumnProps } from "ant-design-vue/es/table/interface";
 
 //getPromotionList
 import {
@@ -120,13 +120,12 @@ import {
   getStuffPerformanceSum,
   getStuffPerformanceChart,
 } from "@/api";
-import { message } from "ant-design-vue";
 const PerformanceDetial = defineComponent({
   components: {},
   setup() {
     let { meta, tablePageOptions } = usePagination();
     const value = ref<Moment[]>([]);
-    const mode2 = ref<string[]>(['month', 'month']);
+    const mode2 = ref<string[]>(["month", "month"]);
     const state = reactive({
       search: {
         uid: 0,
@@ -148,39 +147,48 @@ const PerformanceDetial = defineComponent({
       uname: "",
       chartFlag: true,
     });
-    const columns: ColumnProps[] = []
+    const columns: ColumnProps[] = [];
     return {
       ...toRefs(state),
       tablePageOptions,
       meta,
       columns,
       value,
-      mode2
+      mode2,
     };
   },
   mounted() {
-    this.columnsInit()
+    this.columnsInit();
     this.search.uid = Number(this.$route.query.uid);
     this.uname = String(this.$route.query.uname);
-    // this.getList({ current: 1 });
-    this.getSum();
-    this.onTypeChange("day");
+    this.search.date_arr[0] = String(this.$route.query.start_time);
+    this.search.date_arr[1] = String(this.$route.query.end_time);
 
-    console.log("ccc", this.$route.query.uid);
+    console.log(this.value, "value");
+    this.search.type = String(this.$route.query.type);
+    this.getSum();
+    this.onTypeChange(this.search.type);
   },
   methods: {
     handlePanelChange2(val: Moment[], mode: string[]) {
       this.value = val;
-      if(this.search.type === 'month') {
-        this.search.date_arr = [moment(val[0]).format('YYYY-MM'),moment(val[1]).format('YYYY-MM')]
+      console.log(this.value);
+      if (this.search.type === "month") {
+        this.search.date_arr = [
+          moment(val[0]).format("YYYY-MM"),
+          moment(val[1]).format("YYYY-MM"),
+        ];
       } else {
-        this.search.date_arr = [moment(val[0]).format('YYYY-MM-DD'),moment(val[1]).format('YYYY-MM-DD')]
+        this.search.date_arr = [
+          moment(val[0]).format("YYYY-MM-DD"),
+          moment(val[1]).format("YYYY-MM-DD"),
+        ];
       }
-      this.getList()
+      this.getList();
     },
     handleChange(val: Moment[]) {
       this.value = val;
-      this.handlePanelChange2(val,this.mode2)
+      this.handlePanelChange2(val, this.mode2);
     },
     // 获取推广链接数据
     async getList(page?: any, filter?: any, sorter?: any) {
@@ -191,20 +199,20 @@ const PerformanceDetial = defineComponent({
         end_date: this.search.date_arr ? this.search.date_arr[1] : "",
         ...this.search,
       };
-      if(sorter) {
-        if(sorter.order === 'descend') param.back_amount_order = 2
-        if(sorter.order === "ascend") param.back_amount_order = 1
+      if (sorter) {
+        if (sorter.order === "descend") param.back_amount_order = 2;
+        if (sorter.order === "ascend") param.back_amount_order = 1;
       }
       delete param.date_arr;
-      if(!param.value)  param.value = '1,2,3,4,5,9'
-      console.log("请求参数", param);
+      if (!param.value) param.value = "1,2,3,4,5,9";
+      // console.log("请求参数", param);
       let { data } = await getStuffPerformance({
         page: page ? page.current : 1,
         ...param,
       });
       let chartData = await getStuffPerformanceChart(param);
-      console.log("请求结果", data);
-      console.log("CHART结果", chartData.data);
+      // console.log("请求结果", data);
+      // console.log("CHART结果", chartData.data);
       this.loading = false;
       this.$nextTick(() => {
         this.renderChart(chartData.data);
@@ -212,7 +220,7 @@ const PerformanceDetial = defineComponent({
       this.list = data.list;
       this.meta = data.meta;
       this.customColumns();
-      this.getSum()
+      this.getSum();
     },
     // 获取绩总览
     async getSum() {
@@ -221,7 +229,7 @@ const PerformanceDetial = defineComponent({
         end_date: this.search.date_arr ? this.search.date_arr[1] : "",
         uid: this.$route.query.uid,
       });
-      console.log("总览", data);
+      // console.log("总览", data);
       this.sum.back_amount = data.back_amount; // 回本
       this.sum.cash_withdrawal_amount = data.cash_withdrawal_amount; // 体现合计
       this.sum.cost_amount = data.cost_amount; // 成本合计
@@ -229,31 +237,47 @@ const PerformanceDetial = defineComponent({
     },
     // 月、日查询类型改变
     onTypeChange(val: string) {
-      var date = new Date((new Date).getTime()-24*60*60*1000);
+      var date = new Date(new Date().getTime() - 24 * 60 * 60 * 1000);
       console.log(val);
       if (val === "month") {
         this.search.value = 3;
         var list = this.getDateRange(date, 30, true);
-        console.log(list[0].substring(0, 7));
-        this.search.date_arr = [
-          list[0].substring(0, 7),
-          list[1].substring(0, 7),
-        ];
-        this.mode2 = ['month','month']
-        this.value= [moment(this.search.date_arr[0],'YYYY-MM'),moment(this.search.date_arr[1],'YYYY-MM')]
+        this.mode2 = ["month", "month"];
+        if (this.$route.query.start_time && this.$route.query.end_time) {
+          this.value[0] = moment(this.search.date_arr[0], "YYYY-MM");
+          this.value[1] = moment(this.search.date_arr[1], "YYYY-MM");
+        } else {
+          this.search.date_arr = [
+            list[0].substring(0, 7),
+            list[1].substring(0, 7),
+          ];
+          this.value = [
+            moment(this.search.date_arr[0], "YYYY-MM"),
+            moment(this.search.date_arr[1], "YYYY-MM"),
+          ];
+        }
       } else {
         this.search.value = "";
-        var list = this.getDateRange(date, 30, true);
-        this.search.date_arr = list;
-        this.mode2 = ['date','date']
-        this.value= [moment(this.search.date_arr[0],'YYYY-MM-DD'),moment(this.search.date_arr[1],'YYYY-MM-DD')]
+
+        this.mode2 = ["date", "date"];
+        if (this.$route.query.start_time && this.$route.query.end_time) {
+          this.value[0] = moment(this.search.date_arr[0], "YYYY-MM-DD");
+          this.value[1] = moment(this.search.date_arr[1], "YYYY-MM-DD");
+        } else {
+          var list = this.getDateRange(date, 30, true);
+          this.search.date_arr = list;
+          this.value = [
+            moment(this.search.date_arr[0], "YYYY-MM-DD"),
+            moment(this.search.date_arr[1], "YYYY-MM-DD"),
+          ];
+        }
       }
       this.getList();
     },
     // 渲染图表
     renderChart(data: any) {
       console.log("CHART DATA:", data);
-        this.chartFlag = data.length === 0 ? false : true
+      this.chartFlag = data.length === 0 ? false : true;
       const linePlot = new Line("chart-container", {
         data,
         xField: "date",
@@ -314,162 +338,188 @@ const PerformanceDetial = defineComponent({
     },
     // columns初始化
     columnsInit() {
-      this.columns = [{
-        title: '日期',
-        dataIndex: 'date',
-        fixed: 'left',
-        width: 150,
-      },
-      {
-        title: '成本合计(元)',
-        dataIndex: 'cost_amount',
-        width: 120
-      },
-      {
-        title: '回本(元)',
-        dataIndex: 'back_amount',
-        sorter: (a: any, b: any) => a.back_amount - b.back_amount,
-        width: 120
-      },
-      {
-        title: '回本率(%)',
-        dataIndex: 'back_rate',
-        width: 120
-      },
-      {
-        title: '提现合计(元)',
-        dataIndex: 'cash_withdrawal_amount',
-        width: 150
-      },
-      //
-      {
-        title: '用户充值(元)',
-        dataIndex: 'user_charge_amount_sum',
-        width: 120
-      },]
+      this.columns = [
+        {
+          title: "日期",
+          dataIndex: "date",
+          fixed: "left",
+          width: 150,
+        },
+        {
+          title: "成本合计(元)",
+          dataIndex: "cost_amount",
+          width: 120,
+        },
+        {
+          title: "回本(元)",
+          dataIndex: "back_amount",
+          sorter: (a: any, b: any) => a.back_amount - b.back_amount,
+          width: 120,
+        },
+        {
+          title: "回本率(%)",
+          dataIndex: "back_rate",
+          width: 120,
+        },
+        {
+          title: "提现合计(元)",
+          dataIndex: "cash_withdrawal_amount",
+          width: 150,
+        },
+        //
+        {
+          title: "用户充值(元)",
+          dataIndex: "user_charge_amount_sum",
+          width: 120,
+        },
+      ];
     },
     // 搜索条件修改后 处理columns
     customColumns() {
-      this.columnsInit()
-      let withdrawalIndex = 0, chargeIndex = 0;
-      this.columns.forEach((item,index)=> {
-        if(item.dataIndex === 'cash_withdrawal_amount') withdrawalIndex = index
-        if(item.dataIndex === 'user_charge_amount_sum') chargeIndex = index+2
-      })
+      this.columnsInit();
+      let withdrawalIndex = 0,
+        chargeIndex = 0;
+      this.columns.forEach((item, index) => {
+        if (item.dataIndex === "cash_withdrawal_amount")
+          withdrawalIndex = index;
+        if (item.dataIndex === "user_charge_amount_sum")
+          chargeIndex = index + 2;
+      });
       // 选择按月查询 1.自然日从0加起-默认展示M+0、M+1、M+2 \ 2.24小时-从1加起-默认展示M+0、M+1
-      if(this.search.type === 'month') { //  按月查询
-          if(!this.search.value) {// 默认 未输入自定义月数
-            for(let i = 0; i< 3; i++) {
-              this.columns.splice(withdrawalIndex+(i+1), 0,{
-                title: '提现(元)M+'+ i,
-                dataIndex: 'cash_withdrawal',
-                width: 150,
-                customRender: ({ text, record }) => {
-                  return (<div style="color:gray;font-size:13px">
-                            <p style="color:black;font-size:14px">{ text[i].amount }</p>
-                            <p>累计提现: { text[i].accruing_amount }</p>
-                            <p>回本率: { text[i].back_rate }</p>
-                          </div>)
-                },
-              })
-              this.columns.splice(chargeIndex+(i*2), 0,{
-                title: '用户充值(元)M+'+ i,
-                dataIndex: 'user_charge',
-                width: 150,
-                customRender: ({ text, record }) => {
-                  return (<div style="color:gray;font-size:13px">
-                            <p style="color:black;font-size:14px">{ text[i].amount }</p>
-                            <p>累计充值: { text[i].accruing_amount }</p>
-                            <p>回本率: { text[i].back_rate }</p>
-                          </div>)
-                },
-              })
-            }
-          } else { // 自定义月数
-            for(let i = 0; i< this.search.value; i++) {
-                this.columns.splice(withdrawalIndex+(i+1), 0,{
-                  title: '提现(元)M+'+ i,
-                  dataIndex: 'cash_withdrawal',
-                  width: 150,
-                  customRender: ({ text, record }) => {
-                    return (<div style="color:gray;font-size:13px">
-                              <p style="color:black;font-size:14px">{ text[i].amount }</p>
-                              <p>累计提现: { text[i].accruing_amount }</p>
-                              <p>回本率: { text[i].back_rate }</p>
-                            </div>)
-                  },
-                })
-                this.columns.splice(chargeIndex+(i*2), 0,{
-                  title: '用户充值(元)M+'+ i,
-                  dataIndex: 'user_charge',
-                  width: 150,
-                  customRender: ({ text, record }) => {
-                    return (<div style="color:gray;font-size:13px">
-                              <p style="color:black;font-size:14px">{ text[i].amount }</p>
-                              <p>累计充值: { text[i].accruing_amount }</p>
-                              <p>回本率: { text[i].back_rate }</p>
-                            </div>)
-                  },
-                })
-            }
+      if (this.search.type === "month") {
+        //  按月查询
+        if (!this.search.value) {
+          // 默认 未输入自定义月数
+          for (let i = 0; i < 3; i++) {
+            this.columns.splice(withdrawalIndex + (i + 1), 0, {
+              title: "提现(元)M+" + i,
+              dataIndex: "cash_withdrawal",
+              width: 150,
+              customRender: ({ text, record }) => {
+                return (
+                  <div style="color:gray;font-size:13px">
+                    <p style="color:black;font-size:14px">{text[i].amount}</p>
+                    <p>累计提现: {text[i].accruing_amount}</p>
+                    <p>回本率: {text[i].back_rate}</p>
+                  </div>
+                );
+              },
+            });
+            this.columns.splice(chargeIndex + i * 2, 0, {
+              title: "用户充值(元)M+" + i,
+              dataIndex: "user_charge",
+              width: 150,
+              customRender: ({ text, record }) => {
+                return (
+                  <div style="color:gray;font-size:13px">
+                    <p style="color:black;font-size:14px">{text[i].amount}</p>
+                    <p>累计充值: {text[i].accruing_amount}</p>
+                    <p>回本率: {text[i].back_rate}</p>
+                  </div>
+                );
+              },
+            });
+          }
+        } else {
+          // 自定义月数
+          for (let i = 0; i < this.search.value; i++) {
+            this.columns.splice(withdrawalIndex + (i + 1), 0, {
+              title: "提现(元)M+" + i,
+              dataIndex: "cash_withdrawal",
+              width: 150,
+              customRender: ({ text, record }) => {
+                return (
+                  <div style="color:gray;font-size:13px">
+                    <p style="color:black;font-size:14px">{text[i].amount}</p>
+                    <p>累计提现: {text[i].accruing_amount}</p>
+                    <p>回本率: {text[i].back_rate}</p>
+                  </div>
+                );
+              },
+            });
+            this.columns.splice(chargeIndex + i * 2, 0, {
+              title: "用户充值(元)M+" + i,
+              dataIndex: "user_charge",
+              width: 150,
+              customRender: ({ text, record }) => {
+                return (
+                  <div style="color:gray;font-size:13px">
+                    <p style="color:black;font-size:14px">{text[i].amount}</p>
+                    <p>累计充值: {text[i].accruing_amount}</p>
+                    <p>回本率: {text[i].back_rate}</p>
+                  </div>
+                );
+              },
+            });
+          }
+        }
+      } else {
+        // 选择按日查询 1.自然日从0加起-默认展示T+0、T+2、T+6、T+14、T+29 \ 2.24小时-从1加起-默认展示T+0、T+2、T+6、T+14、T+29
+        if (!this.search.value) {
+          // 默认 未输入自定义月数
+          for (let i = 0; i < 5; i++) {
+            this.columns.splice(withdrawalIndex + (i + 1), 0, {
+              title: "提现(元)T+" + [0, 2, 6, 14, 29][i],
+              dataIndex: "cash_withdrawal",
+              width: 150,
+              customRender: ({ text, record }) => {
+                return (
+                  <div style="color:gray;font-size:13px">
+                    <p style="color:black;font-size:14px">{text[i].amount}</p>
+                    <p>累计提现: {text[i].accruing_amount}</p>
+                    <p>回本率: {text[i].back_rate}</p>
+                  </div>
+                );
+              },
+            });
+            this.columns.splice(chargeIndex + i * 2, 0, {
+              title: "用户充值(元)T+" + [0, 2, 6, 14, 29][i],
+              dataIndex: "user_charge",
+              width: 150,
+              customRender: ({ text, record }) => {
+                return (
+                  <div style="color:gray;font-size:13px">
+                    <p style="color:black;font-size:14px">{text[i].amount}</p>
+                    <p>累计充值: {text[i].accruing_amount}</p>
+                    <p>回本率: {text[i].back_rate}</p>
+                  </div>
+                );
+              },
+            });
           }
-        
-      } else { // 选择按日查询 1.自然日从0加起-默认展示T+0、T+2、T+6、T+14、T+29 \ 2.24小时-从1加起-默认展示T+0、T+2、T+6、T+14、T+29
-          if(!this.search.value) {// 默认 未输入自定义月数
-            for(let i = 0; i< 5; i++) {
-              this.columns.splice(withdrawalIndex+(i+1), 0,{
-                title: '提现(元)T+'+ [0,2,6,14,29][i],
-                dataIndex: 'cash_withdrawal',
-                width: 150,
-                customRender: ({ text, record }) => {
-                  return (<div style="color:gray;font-size:13px">
-                            <p style="color:black;font-size:14px">{ text[i].amount }</p>
-                            <p>累计提现: { text[i].accruing_amount }</p>
-                            <p>回本率: { text[i].back_rate }</p>
-                          </div>)
-                },
-              })
-              this.columns.splice(chargeIndex+(i*2), 0,{
-                title: '用户充值(元)T+'+ [0,2,6,14,29][i],
-                dataIndex: 'user_charge',
-                width: 150,
-                customRender: ({ text, record }) => {
-                  return (<div style="color:gray;font-size:13px">
-                            <p style="color:black;font-size:14px">{ text[i].amount }</p>
-                            <p>累计充值: { text[i].accruing_amount }</p>
-                            <p>回本率: { text[i].back_rate }</p>
-                          </div>)
-                },
-              })
-            }
-          } else { // 自定义月数
-            for(let i = 0; i< this.search.value; i++) {
-                this.columns.splice(withdrawalIndex+(i+1), 0,{
-                  title: '提现(元)T+'+ i,
-                  dataIndex: 'cash_withdrawal',
-                  width: 150,
-                  customRender: ({ text, record }) => {
-                    return (<div style="color:gray;font-size:13px">
-                              <p style="color:black;font-size:14px">{ text[i].amount }</p>
-                              <p>累计提现: { text[i].accruing_amount }</p>
-                              <p>回本率: { text[i].back_rate }</p>
-                            </div>)
-                  },
-                })
-                this.columns.splice(chargeIndex+(i*2), 0,{
-                  title: '用户充值(元)T+'+ i,
-                  dataIndex: 'user_charge',
-                  width: 150,
-                  customRender: ({ text, record }) => {
-                    return (<div style="color:gray;font-size:13px">
-                              <p style="color:black;font-size:14px">{ text[i].amount }</p>
-                              <p>累计充值: { text[i].accruing_amount }</p>
-                              <p>回本率: { text[i].back_rate }</p>
-                            </div>)
-                  },
-                })
-            }
+        } else {
+          // 自定义月数
+          for (let i = 0; i < this.search.value; i++) {
+            this.columns.splice(withdrawalIndex + (i + 1), 0, {
+              title: "提现(元)T+" + i,
+              dataIndex: "cash_withdrawal",
+              width: 150,
+              customRender: ({ text, record }) => {
+                return (
+                  <div style="color:gray;font-size:13px">
+                    <p style="color:black;font-size:14px">{text[i].amount}</p>
+                    <p>累计提现: {text[i].accruing_amount}</p>
+                    <p>回本率: {text[i].back_rate}</p>
+                  </div>
+                );
+              },
+            });
+            this.columns.splice(chargeIndex + i * 2, 0, {
+              title: "用户充值(元)T+" + i,
+              dataIndex: "user_charge",
+              width: 150,
+              customRender: ({ text, record }) => {
+                return (
+                  <div style="color:gray;font-size:13px">
+                    <p style="color:black;font-size:14px">{text[i].amount}</p>
+                    <p>累计充值: {text[i].accruing_amount}</p>
+                    <p>回本率: {text[i].back_rate}</p>
+                  </div>
+                );
+              },
+            });
           }
+        }
       }
     },
   },

+ 9 - 4
src/views/data/performance.vue

@@ -124,6 +124,9 @@ const Performance = defineComponent({
   },
   methods: {
     handlePanelChange2(val: Moment[], mode: string[]) {
+
+
+      console.log(val,'monthvalue')
       this.value = val;
       if(this.search.type === 'month') {
         this.search.date_arr = [moment(val[0]).format('YYYY-MM'),moment(val[1]).format('YYYY-MM')]
@@ -150,9 +153,9 @@ const Performance = defineComponent({
         width:120
       },
       {
-        title: '回本(元)',
-        dataIndex: 'back_amount',
-        sorter: (a: any, b: any) => a.back_amount - b.back_amount,
+        title: '回本率(%)',
+        dataIndex: 'back_rate',
+        sorter: (a: any, b: any) => `${(a.back_amount - b.back_amount)}`,
         width:120
       },
       {
@@ -385,8 +388,10 @@ const Performance = defineComponent({
     // 查看详情
     toDetial(item: any) {
       console.log("查看详情", item);
+      console.log(this.value,'value')
+      console.log(this.search.date_arr,'attr_date')
       this.$router.push(
-        `/data/performanceDetail?uid=${item.uid}&uname=${item.uname}`
+        `/data/performanceDetail?uid=${item.uid}&uname=${item.uname}&start_time=${this.search.date_arr[0]}&end_time=${this.search.date_arr[1]}&type=${this.search.type}`
       );
     },
   },

+ 4 - 1
src/views/put/ad-group.vue

@@ -297,6 +297,7 @@ const Adgroup = defineComponent({
       filters: any,
       sorter: any
     ) => {
+      console.log(1)
       console.log(toolbarref.value);
       if (sorter.columnKey == "cost") {
         setSateSwitch(sorter.order, "cost_order");
@@ -310,7 +311,9 @@ const Adgroup = defineComponent({
       const { current, pageSize, total } = pagination;
       let fields = toolbarref.value.returnFields();
       const { advertiser_id, campaign_id } = fields;
-      let data = Object.assign({ current,advertiser_id,campaign_id, ...state.defaultToolvalue });
+      //加入筛选条件是否启用
+      let is_enable = state.is_enable
+      let data = Object.assign({ current,advertiser_id,campaign_id,is_enable, ...state.defaultToolvalue });
       getData(data);
     };
     const popConfirm = () => {