Browse Source

提交一波

xia 4 years ago
parent
commit
ad50d6371c

+ 1 - 1
.env.development

@@ -1,6 +1,6 @@
 NODE_ENV = development
 VUE_APP_BASE_URL = '/'
 VUE_APP_PUB_URL = '/'
-PROXY_API_URL = 'https://t-promoter.58duke.com/'
+PROXY_API_URL = 'https://promoter.58duke.com/'
 
 MAIN_API_URL = 'https://t-promoter.58duke.com/'

+ 1 - 0
src/hooks/usePagination.ts

@@ -27,6 +27,7 @@ const usePagination = () => {
       tablePageOptions.pageSize = meta.value.per_page;
       tablePageOptions.total = meta.value.total;
       loading.value = false;
+      console.log(tablePageOptions)
     }
   );
 

+ 5 - 1
src/store/modules/app/_type.ts

@@ -15,6 +15,7 @@ type State = {
   officials: SelectOptions<number>;
   platforms: SelectOptions<string>;
   collapsed:boolean;
+  selectTime:any[];
 };
 
 // mutation 定义
@@ -24,7 +25,8 @@ enum MutationType {
   setUser = "setUser",
   setOfficial = "setOfficial",
   setPlatforms = "setPlatforms",
-  setCollapsed = 'setCollapsed'
+  setCollapsed = 'setCollapsed',
+  setSelectTime = 'setSelectTime'
 }
 
 type Mutations<S = State> = {
@@ -34,6 +36,7 @@ type Mutations<S = State> = {
   [MutationType.setOfficial](state: S, officials: SelectOptions<number>): void;
   [MutationType.setPlatforms](state: S, platforms: SelectOptions<string>): void;
   [MutationType.setCollapsed](state: S, platforms: boolean): void;
+  [MutationType.setSelectTime](state: S, platforms: any[]): void;
 };
 
 // action 定义
@@ -67,6 +70,7 @@ type Getters = {
   officials(state: State): SelectOptions<number>;
   platforms(state: State): SelectOptions<string>;
   collapsed(state: State): boolean;
+  selectTime(state: State): any[];
 };
 
 export { State, Mutations, MutationType, Actions, ActionType, Getters };

+ 1 - 0
src/store/modules/app/getters.ts

@@ -10,6 +10,7 @@ const getters: GetterTree<State, RootState> & Getters = {
   officials: (state) => state.officials,
   platforms: (state) => state.platforms,
   collapsed: (state) => state.collapsed,
+  selectTime: (state) => state.selectTime,
 };
 
 export default getters;

+ 3 - 0
src/store/modules/app/mutations.ts

@@ -12,6 +12,9 @@ const mutations: MutationTree<State> & Mutations = {
   [MutationType.setRoutes](state, routes) {
     state.routes = routes;
   },
+  [MutationType.setSelectTime](state, time) {
+    state.selectTime = time;
+  },
   [MutationType.setUser](state, user) {
     state.user = user;
     state.store.setItem("user", JSON.stringify(user));

+ 1 - 0
src/store/modules/app/state.ts

@@ -22,6 +22,7 @@ const state: State = {
   user: store.getItem("user")?.parse<IUser>() ?? {},
   officials: [],
   platforms: [],
+  selectTime:[],
   collapsed:
     store.getItem("collapsed") && store.getItem("collapsed") === "true"
       ? true

+ 13 - 12
src/views/_pageOptions/table-put.ts

@@ -1,11 +1,12 @@
 interface colunm {
-  title:string;
-  dataIndex:string;
-  width?:number;
-  slots?:any;
-  sorter?:any;
-  children?:Array<colunm>;
-  ellipsis?: boolean,
+  title: string;
+  dataIndex: string;
+  width?: number;
+  slots?: any;
+  sorter?: any;
+  children?: Array<colunm>;
+  ellipsis?: boolean;
+  sortDirections?: (string | false)[];
 }
 export const TableColumnOfPutBooks = [
   {
@@ -53,7 +54,7 @@ export const TableColumnOfPutAdAccount = [
     title: "广告主名称",
     dataIndex: "advertiser_name",
     key: "advertiser_name",
-    width:200,
+    width: 200,
     ellipsis: true,
   },
   {
@@ -90,7 +91,7 @@ export const TableColumnOfPutAdAccount = [
     key: "operator",
     slots: { customRender: "operator" },
     width: 100,
-  }
+  },
 ];
 
 export const TableColumnOfPutData = [
@@ -635,7 +636,7 @@ export const MatchList = [
   },
 ];
 
-export const AdgroupCloumn:Array<colunm> = [
+export const AdgroupCloumn: Array<colunm> = [
   {
     title: "",
     dataIndex: "check",
@@ -706,7 +707,7 @@ export const AdgroupCloumn:Array<colunm> = [
   },
 ];
 
-export const AdCoundCloumn:Array<colunm>= [
+export const AdCoundCloumn: Array<colunm> = [
   {
     title: "账户信息",
     dataIndex: "campaign_name",
@@ -777,5 +778,5 @@ export const AdCoundCloumn:Array<colunm>= [
     slots: {
       customRender: "operte",
     },
-  }
+  },
 ];

+ 4 - 0
src/views/_pageOptions/table_financial.ts

@@ -26,6 +26,8 @@ export const TableColumnOfFinancial = [
   {
     title: "总支出",
     dataIndex: "cost",
+    sorter:true,
+    sortDirections: ['descend', 'ascend',false],
   },
   {
     title: "现金支出",
@@ -54,6 +56,8 @@ export const TableColumnOfFinancial = [
   {
     title: "日终结余",
     dataIndex: "balance",
+    sorter:true,
+    sortDirections: ['descend', 'ascend',false],
   },
   
 ];

+ 57 - 23
src/views/financial/index.vue

@@ -16,23 +16,22 @@
       </template>
     </tool-bar>
 
-        <a-table
-          :columns="columns"
-          :data-source="list"
-          :scroll="{ x: 1500, y: 600 }"
-          @change="handleTableChange"
-          bordered
-        >
-          <template #advertiser="{ text, record }">
-            <p>账户名:{{ record.advertiser_name }}</p>
-            <p>账户ID:{{ record.advertiser_id }}</p>
-          </template>
-          <template #agent="{ text, record }">
-            <p>代理商名:{{ record.agent_name }}</p>
-            <p>代理商Id:{{ record.agent_id }}</p>
-          </template>
-        </a-table>
-
+    <a-table
+      :columns="columns"
+      :data-source="list"
+      :scroll="{ x: 1500, y: 600 }"
+      @change="handleTableChange"
+      bordered
+    >
+      <template #advertiser="{ text, record }">
+        <p>账户名:{{ record.advertiser_name }}</p>
+        <p>账户ID:{{ record.advertiser_id }}</p>
+      </template>
+      <template #agent="{ text, record }">
+        <p>代理商名:{{ record.agent_name }}</p>
+        <p>代理商Id:{{ record.agent_id }}</p>
+      </template>
+    </a-table>
   </div>
 </template>
 
@@ -67,6 +66,8 @@ const Finance = defineComponent({
       inConfirm: false,
       list: ref<FinanceData[]>([]),
       rangePick: picker,
+      cost_order: 0,
+      balance_order: 0,
       pickered: [moment().subtract(30, "d"), moment()],
       columns: TableColumnOfFinancial,
     });
@@ -81,11 +82,19 @@ const Finance = defineComponent({
         let [begin_dates, end_dates] = state.pickered;
         let start_ymd = moment(begin_dates).format("YYYY-MM-DD");
         let end_ymd = moment(end_dates).format("YYYY-MM-DD");
-        const { data } = await getFinanceList({
-          start_ymd,
-          end_ymd,
-          page: query?.current ?? 1,
-        });
+        const { data } = await getFinanceList(
+          Object.assign(
+            {
+              cost_order: state.cost_order,
+              balance_order: state.balance_order,
+            },
+            {
+              start_ymd,
+              end_ymd,
+              page: query?.current ?? 1,
+            }
+          )
+        );
         state.list = data.list as Array<FinanceData>;
         meta.value = data.meta;
       } catch (error) {
@@ -95,7 +104,32 @@ const Finance = defineComponent({
       }
     };
 
-    const handleTableChange = (pagination: PageOptions) => {
+    const setSateSwitch = (val: string, name: string) => {
+      state.cost_order = 0;
+      state.balance_order = 0;
+      switch (val) {
+        case "ascend":
+          (state as any)[name] = 2;
+          break;
+        case "descend":
+          (state as any)[name] = 1;
+          break;
+        default:
+          (state as any)[name] = 0;
+      }
+    };
+
+    const handleTableChange = (
+      pagination: PageOptions,
+      filters: any,
+      sorter: any
+    ) => {
+      if (sorter.columnKey == "cost") {
+        setSateSwitch(sorter.order, "cost_order");
+      }
+      if (sorter.columnKey == "balance") {
+        setSateSwitch(sorter.order, "balance_order");
+      }
       const { current, pageSize, total } = pagination;
       getData({ current: current });
     };

+ 57 - 16
src/views/put/ad-countdata.vue

@@ -12,6 +12,7 @@
           v-model:value="pickered"
           :ranges="rangePick"
           format="YYYY/MM/DD"
+          @change="changeTime"
         />
       </template>
     </tool-bar>
@@ -63,18 +64,26 @@
   </div>
 </template>
 <script lang="ts">
-import { defineComponent, reactive, toRefs, ref, onMounted } from "vue";
+import {
+  defineComponent,
+  reactive,
+  toRefs,
+  ref,
+  onMounted,
+  computed,
+} from "vue";
 import { picker } from "@/helper/config/range";
 import ToolBar from "@/components/tool-bar/index.vue";
 import moment from "moment";
 import useApp from "@/hooks/useApp";
+import { MutationType } from "@/store/modules/app/_type";
 import { AdCoundCloumn } from "../_pageOptions/table-put";
 import {
   getAdgroupData,
   setGroupStatus,
   setGroupDay,
   ALLAcountGroupData,
-  setBackMinimum
+  setBackMinimum,
 } from "@/api";
 import usePagination from "@/hooks/usePagination";
 import EditableCell from "@/components/edit-cell/index.vue";
@@ -87,18 +96,29 @@ const Adgroup = defineComponent({
   },
   setup() {
     let { loading, meta, tablePageOptions } = usePagination();
-    const { router } = useApp();
+    const { router, store } = useApp();
+
+    console.log(moment(store.getters.selectTime[0]));
     const state = reactive({
       inSearching: false,
       open: false,
       inConfirm: false,
       list: ref<AdgroupList[]>([]),
       rangePick: picker,
-      pickered: [moment().subtract(30, "d"), moment()],
+      pickered: computed(() =>
+        store.getters.selectTime.length > 0
+          ? [
+              moment(store.getters.selectTime[0]),
+              moment(store.getters.selectTime[1]),
+            ]
+          : [moment().subtract(30, "d"), moment()]
+      ),
       columns: ref<any[]>([]),
       fields: {},
       tableLoading: false,
       cost_order: 0,
+      convert_order: 0,
+      convert_cost_order: 0,
       balance_order: 0,
       showTable: false,
       scrollY: 600,
@@ -132,24 +152,30 @@ const Adgroup = defineComponent({
             account_id: query?.account_id,
             page: query?.current ?? 1,
           },
-          state.cost_order ? { cost_order: state.cost_order } : {},
-          state.balance_order ? { balance_order: state.balance_order } : {}
+          {
+            cost_order: state.cost_order,
+            convert_order: state.convert_order,
+            convert_cost_order: state.convert_cost_order,
+            balance_order: state.balance_order,
+          }
         );
         const { data } = await getAdgroupData(datas);
         const { data: totals } = await ALLAcountGroupData(datas);
-
+        let sortList = ["cost", "convert", "convert_cost", "balance"];
         let mainCloumn = AdCoundCloumn.map((r) => {
-          if (r.dataIndex != "firle" && r.dataIndex !== "campaign_name" && r.dataIndex!=='back_min_price') {
+          if (
+            r.dataIndex != "firle" &&
+            r.dataIndex !== "campaign_name" &&
+            r.dataIndex !== "back_min_price"
+          ) {
             r.children = [
               {
                 title: totals[r.dataIndex],
                 dataIndex: r.dataIndex,
                 width: r.width,
                 ellipsis: true,
-                sorter:
-                  r.dataIndex === "cost" || r.dataIndex === "balance"
-                    ? true
-                    : false,
+                sorter: sortList.includes(r.dataIndex) ? true : false,
+                sortDirections: ["descend", "ascend", false],
               },
             ];
           }
@@ -166,6 +192,10 @@ const Adgroup = defineComponent({
       }
     };
     const setSateSwitch = (val: string, name: string) => {
+      state.cost_order = 0;
+      state.convert_order = 0;
+      state.convert_cost_order = 0;
+      state.balance_order = 0;
       switch (val) {
         case "ascend":
           (state as any)[name] = 2;
@@ -189,6 +219,12 @@ const Adgroup = defineComponent({
       if (sorter.columnKey == "balance") {
         setSateSwitch(sorter.order, "balance_order");
       }
+      if(sorter.columnKey == "convert"){
+        setSateSwitch(sorter.order, "convert_order");
+      }
+      if(sorter.columnKey == "convert_cost"){
+        setSateSwitch(sorter.order, "convert_cost_order");
+      }
       const { current, pageSize, total } = pagination;
       let data = Object.assign({ current, ...state.fields });
       getData(data);
@@ -196,6 +232,10 @@ const Adgroup = defineComponent({
     const goAdlgroup = (id: string) => {
       router.push({ path: "/put/datas/group", query: { advertiser_id: id } });
     };
+    const changeTime = (monent: any, string: string[]) => {
+      console.log(string);
+      store.commit(MutationType.setSelectTime, string);
+    };
     onMounted(getData);
     return {
       ...toRefs(state),
@@ -204,6 +244,7 @@ const Adgroup = defineComponent({
       onSearch,
       handleTableChange,
       goAdlgroup,
+      changeTime,
     };
   },
   mounted() {
@@ -228,11 +269,11 @@ const Adgroup = defineComponent({
       } else {
         let data = {
           advertiser_id: record.advertiser_id,
-          back_min_price: value
-        }
-        setBackMinimum(data).then(res=>{
+          back_min_price: value,
+        };
+        setBackMinimum(data).then((res) => {
           this.$message.success("修改成功!");
-        })
+        });
       }
     },
   },

+ 42 - 12
src/views/put/ad-group.vue

@@ -2,7 +2,7 @@
   <div class="page-wrap page-wrap-put-books">
     <tool-bar
       :text="['advertiser_id', 'campaign_id']"
-      :label="['账户名称/ID', '广告组名称/ID']"
+      :label="['广告主名称/ID', '广告组名称/ID']"
       :defaultVal="defaultToolvalue"
       v-model:loading="inSearching"
       @confirm="onSearch"
@@ -13,6 +13,7 @@
           v-model:value="pickered"
           :ranges="rangePick"
           format="YYYY/MM/DD"
+          @change="changeTime"
         />
       </template>
     </tool-bar>
@@ -43,7 +44,14 @@
   </div>
 </template>
 <script lang="ts">
-import { defineComponent, reactive, toRefs, ref, onMounted } from "vue";
+import {
+  defineComponent,
+  reactive,
+  toRefs,
+  ref,
+  onMounted,
+  computed,
+} from "vue";
 import { picker } from "@/helper/config/range";
 import ToolBar from "@/components/tool-bar/index.vue";
 import moment from "moment";
@@ -51,7 +59,7 @@ import { AdgroupCloumn } from "../_pageOptions/table-put";
 import useApp from "@/hooks/useApp";
 import { getAdgroupList, setGroupStatus, ALLadGroupData } from "@/api";
 import usePagination from "@/hooks/usePagination";
-
+import { MutationType } from "@/store/modules/app/_type";
 import { AdGroupData, PageOptions, GroupDatas } from "@/types/api";
 
 const Adgroup = defineComponent({
@@ -60,7 +68,7 @@ const Adgroup = defineComponent({
   },
   setup() {
     let { loading, meta, tablePageOptions } = usePagination();
-    const { router, route } = useApp();
+    const { router, route, store } = useApp();
 
     const state = reactive({
       inSearching: false,
@@ -69,12 +77,18 @@ const Adgroup = defineComponent({
       list: ref<any[]>([]),
       rangePick: picker,
       cost_order: 0,
+      convert_order:0,
+      convert_cost_order:0,
       showTable: false,
       scrollY: 600,
-      pickered: [moment().subtract(30, "d"), moment()],
+      pickered: computed(() =>
+        store.getters.selectTime.length > 0
+          ? [moment(store.getters.selectTime[0]),moment(store.getters.selectTime[1])]
+          : [moment().subtract(30, "d"), moment()]
+      ),
       columns: ref<any[]>([]),
       fields: {},
-      tableLoading:false,
+      tableLoading: false,
       defaultToolvalue: {},
     });
     if (route.query && route.query.advertiser_id) {
@@ -115,7 +129,7 @@ const Adgroup = defineComponent({
             campaign_id: query?.campaign_id,
             page: query?.current ?? 1,
           },
-          state.cost_order ? { cost_order: state.cost_order } : {}
+          { cost_order: state.cost_order,convert_order:state.convert_order, convert_cost_order:state.convert_cost_order }
         );
         const { data } = await getAdgroupList(datas);
         const { data: totals } = await ALLadGroupData(datas);
@@ -125,7 +139,7 @@ const Adgroup = defineComponent({
           item.is_enable = !!item.is_enable;
           return item;
         });
-
+      let sortList = ['cost','convert','convert_cost']
         let mainCloumn = AdgroupCloumn.map((r) => {
           if (r.dataIndex != "check" && r.dataIndex !== "campaign_name") {
             r.children = [
@@ -133,7 +147,8 @@ const Adgroup = defineComponent({
                 title: totals[r.dataIndex],
                 dataIndex: r.dataIndex,
                 width: r.width,
-                sorter: r.dataIndex == "cost" ? true : false,
+                sorter: sortList.includes(r.dataIndex) ? true : false,
+                sortDirections: ['descend', 'ascend',false],
                 ellipsis: true,
               },
             ];
@@ -153,6 +168,9 @@ const Adgroup = defineComponent({
     };
 
     const setSateSwitch = (val: string, name: string) => {
+      state.cost_order = 0;
+      state.convert_order = 0;
+      state.convert_cost_order = 0;
       switch (val) {
         case "ascend":
           (state as any)[name] = 2;
@@ -170,10 +188,15 @@ const Adgroup = defineComponent({
       filters: any,
       sorter: any
     ) => {
-      console.log(sorter)
       if (sorter.columnKey == "cost") {
         setSateSwitch(sorter.order, "cost_order");
       }
+      if(sorter.columnKey == "convert"){
+        setSateSwitch(sorter.order, "convert_order");
+      }
+      if(sorter.columnKey == "convert_cost"){
+        setSateSwitch(sorter.order, "convert_cost_order");
+      }
       const { current, pageSize, total } = pagination;
       let data = Object.assign({ current, ...state.fields });
       getData(data);
@@ -187,7 +210,7 @@ const Adgroup = defineComponent({
     });
     const goAdlgroup = (id: string, campaign_id: string) => {
       let begin_date, end_date;
-      if(state.pickered){
+      if (state.pickered) {
         let [begin_dates, end_dates] = state.pickered;
         if (begin_dates && end_dates) {
           begin_date = moment(begin_dates).format("YYYY-MM-DD");
@@ -196,9 +219,15 @@ const Adgroup = defineComponent({
       }
       router.push({
         path: "/put/datas/ad-plan",
-        query: { campaign_id,begin_date,end_date },
+        query: { campaign_id, begin_date, end_date },
       });
     };
+
+    const changeTime = (monent: any, string: string[]) => {
+      console.log(string)
+      store.commit(MutationType.setSelectTime, string);
+    };
+
     return {
       ...toRefs(state),
       loading,
@@ -206,6 +235,7 @@ const Adgroup = defineComponent({
       onSearch,
       handleTableChange,
       goAdlgroup,
+      changeTime,
     };
   },
   mounted() {

+ 11 - 4
src/views/put/put-ad-plan.vue

@@ -267,7 +267,7 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, reactive, toRefs, ref, unref, onMounted } from "vue";
+import { defineComponent, reactive, toRefs, ref, unref, onMounted,computed } from "vue";
 import moment,{ Moment } from "moment";
 import ToolBar from "@/components/tool-bar/index.vue";
 import PutData from "@/views/put/put-log.vue";
@@ -279,6 +279,8 @@ import EditableCell from "@/components/edit-cell/index.vue";
 import usePagination from "@/hooks/usePagination";
 import { picker } from "@/helper/config/range";
 import { InfoCircleOutlined } from "@ant-design/icons-vue";
+import { MutationType } from "@/store/modules/app/_type";
+
 import {
   TableColumnOfPutAdPlan,
   ALLCloumnList,
@@ -312,7 +314,7 @@ const PutAdPlan = defineComponent({
 
   setup() {
     let { loading, meta, tablePageOptions } = usePagination();
-    const { router, route } = useApp();
+    const { router, route,store } = useApp();
 
     let list: any[] = [],
       opList: any[] = [],
@@ -342,7 +344,11 @@ const PutAdPlan = defineComponent({
         ad_lid: 0,
         back_platform: "",
       },
-      pickerFilter: [moment(), moment()],
+      pickerFilter: computed(() =>
+        store.getters.selectTime.length > 0
+          ? [moment(store.getters.selectTime[0]),moment(store.getters.selectTime[1])]
+          : [moment(), moment()]
+      ),
       tablePageOptions,
       columns: list,
       temData: {},
@@ -422,7 +428,8 @@ const PutAdPlan = defineComponent({
       }
     };
 
-    const switchDate = (date: any, dateString: string) => {
+    const switchDate = (date: any, dateString:any[]) => {
+      store.commit(MutationType.setSelectTime, dateString);
       onSearch(state.fields);
     };
 

+ 16 - 4
src/views/put/put-data.vue

@@ -13,6 +13,7 @@
           :ranges="rangePick"
           format="YYYY/MM/DD"
           v-model:value="pickered"
+          @change="changeTime"
         />
       </template>
     </tool-bar>
@@ -35,6 +36,7 @@
     <a-table
       :columns="columns"
       :data-source="list"
+      :pagination="tablePageOptions"
       :scroll="{ x: 1200, y: 600 }"
       @change="handleTableChange"
       bordered
@@ -47,7 +49,7 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, reactive, toRefs, ref, onMounted } from "vue";
+import { computed,defineComponent, reactive, toRefs, ref, onMounted } from "vue";
 import { picker } from "@/helper/config/range";
 import ToolBar from "@/components/tool-bar/index.vue";
 import moment from "moment";
@@ -56,7 +58,7 @@ import {
   TableColumnOfPutData,
   TableColumnOfMoreStat,
 } from "../_pageOptions/table-put";
-
+import { MutationType } from "@/store/modules/app/_type";
 import {
   getDeliveryStatList,
   getDeliveryMoreStatList,
@@ -72,15 +74,20 @@ const PutData = defineComponent({
     ToolBar,
   },
   setup() {
-    const { router, route } = useApp();
+    const { router, route,store } = useApp();
     let { loading, meta, tablePageOptions } = usePagination();
     let listed: any = [];
     const state = reactive({
       list: ref<any>([]),
       fields: {},
       drawerlist: ref<moreStatPlanItem[]>([]),
-      pickered: [moment().subtract(30, "d"), moment()],
+      pickered: computed(() =>
+        store.getters.selectTime.length > 0
+          ? [moment(store.getters.selectTime[0]),moment(store.getters.selectTime[1])]
+          : [moment().subtract(30, "d"), moment()]
+      ),
       columns: listed,
+      tablePageOptions,
       pickerFilter: [],
       drawercolumns: TableColumnOfMoreStat,
       inSearching: false,
@@ -171,6 +178,10 @@ const PutData = defineComponent({
       });
       getList(data);
     };
+    const changeTime = (monent:any,string:string[]) => {
+        store.commit(MutationType.setSelectTime, string);
+    }
+
     onMounted(() => {
       getCloums();
       getList({
@@ -185,6 +196,7 @@ const PutData = defineComponent({
       meta,
       handleTableChange,
       changeNumber,
+      changeTime,
     };
   },
   methods: {