Browse Source

提交各种修改

xia 4 năm trước cách đây
mục cha
commit
6f0c32ae51

+ 13 - 1
src/api/index.ts

@@ -14,6 +14,7 @@ import {
   ADPlanItem,
   deliveryPlanItem,
   IPlatform,
+  adPlanLog
 } from "@/types/api";
 
 /**
@@ -215,5 +216,16 @@ export const statusChange = (data: {
   return axios.post("/ad/updateAdStatus", data);
 };
 
-
+/* 获取操作日志
+ * @param null
+ */
+export const opertaroLog = (
+  query: Partial<{
+    begin_time: string;
+    end_time: string;
+    page: number;
+  }> = { page: 1 }
+): AxiosPromise<IList<adPlanLog>> => {
+  return axios("/ad/adOptLogs", { params: query });
+};
 

+ 47 - 17
src/components/edit-cell/index.vue

@@ -1,42 +1,72 @@
 <template>
   <div class="editable-cell">
-        <div v-if="editable" class="editable-cell-input-wrapper">
-          <a-input v-model:value="value" @pressEnter="check" />
-          <check-outlined class="editable-cell-icon-check" @click="check" />
-        </div>
-        <div v-else class="editable-cell-text-wrapper">
-          {{value || ' '}}
-          <edit-outlined class="editable-cell-icon" @click="edit" />
-        </div>
+    <div v-if="editable" class="editable-cell-input-wrapper">
+      <a-input v-model:value="value" @pressEnter="check" />
+      <check-outlined class="editable-cell-icon-check" @click="check" />
     </div>
+    <div v-else class="editable-cell-text-wrapper">
+      {{ value || " " }}
+      <edit-outlined class="editable-cell-icon" @click="edit" />
+    </div>
+  </div>
 </template>
 
 <script lang="ts">
-import { CheckOutlined, EditOutlined } from '@ant-design/icons-vue';
-import { defineComponent, PropType, ref, watch, watchEffect } from "vue";
-const EditableCell  = defineComponent({
+import {
+  CheckOutlined,
+  EditOutlined,
+  ExclamationCircleOutlined,
+} from "@ant-design/icons-vue";
+import { Modal } from "ant-design-vue";
+import {
+  defineComponent,
+  PropType,
+  ref,
+  watch,
+  watchEffect,
+  createVNode,
+} from "vue";
+const EditableCell = defineComponent({
   props: {
-    text:  Number,
+    text: Number,
     onChange: Function,
+    title: String,
   },
   components: {
     CheckOutlined,
     EditOutlined,
+    ExclamationCircleOutlined,
   },
   data() {
     return {
       value: this.text,
       editable: false,
+      titles: this.title,
+      preValue: this.text,
     };
   },
   methods: {
-    handleChange(e:any) {
+    handleChange(e: any) {
       const value = e.target.value;
       this.value = value;
     },
     check() {
-      this.editable = false;
-      this.$emit('change', this.value);
+      let _self = this;
+      Modal.confirm({
+        title: `修改${this.titles}`,
+        icon: createVNode(ExclamationCircleOutlined),
+        content: `是否确认修改${_self.titles}为${_self.value}`,
+        onOk() {
+          _self.preValue = _self.value;
+          _self.editable = false;
+          _self.$emit("change", _self.value);
+        },
+        onCancel() {
+          _self.editable = false;
+          _self.value = _self.preValue;
+          _self.$message.success("你取消了修改");
+        },
+      });
     },
     edit() {
       this.editable = true;
@@ -44,7 +74,7 @@ const EditableCell  = defineComponent({
   },
 });
 
-export default EditableCell ;
+export default EditableCell;
 </script>
 <style lang="scss">
 .editable-cell {
@@ -87,4 +117,4 @@ export default EditableCell ;
 .editable-cell:hover .editable-cell-icon {
   display: inline-block;
 }
-</style>
+</style>

+ 11 - 1
src/router/async.ts

@@ -45,6 +45,16 @@ const PutData: RouteConfig = {
   component: () => import("@/views/put/put-data.vue"),
 };
 
+
+const PutLog: RouteConfig = {
+  name: "PutLog",
+  path: "log",
+  meta: {
+    title: "操作日志",
+  },
+  component: () => import("@/views/put/put-log.vue"),
+};
+
 const PutDataMore: RouteConfig = {
   name: "PutDataMore",
   path: "datamore",
@@ -62,7 +72,7 @@ export const PutManager: RouteConfig = {
   meta: {
     title: "投放管理",
   },
-  children: [PutBook, PutAdAccount, PutAdPlan, PutData, PutDataMore],
+  children: [PutBook, PutAdAccount, PutAdPlan, PutData, PutDataMore, PutLog],
   component: () => import("@/views/put/index.vue"),
 };
 

+ 11 - 0
src/types/api.d.ts

@@ -261,3 +261,14 @@ export interface IPlatform {
   desc: string;
   name: string;
 }
+
+export interface adPlanLog {
+  advertiser_id: string;
+  object_id: string;
+  object_type: string;
+  object_name: string;
+  content_log: any;
+  operator: string;
+  create_time: string;
+  opt_ip: string;
+}

+ 46 - 4
src/views/_pageOptions/table-put.ts

@@ -137,6 +137,48 @@ export const TableColumnOfPutData = [
   },
 ];
 
+export const TableColumnOfPutLog = [
+  {
+    title: "操作时间",
+    key: "create_time",
+    dataIndex: "create_time",
+    width: 200,
+  },
+  {
+    title: "计划id",
+    key: "object_id",
+    dataIndex: "object_id",
+    width: 200,
+  },
+  {
+    title: "类型",
+    key: "object_type",
+    dataIndex: "object_type",
+    width: 200,
+  },
+  {
+    title: "操作者",
+    key: "operator",
+    dataIndex: "operator",
+    width: 200,
+  },
+  {
+    title: "操作ip",
+    key: "opt_ip",
+    dataIndex: "opt_ip",
+    width: 200,
+  },
+  {
+    title: "日志",
+    key: "content_log",
+    width: 200,
+    slots: { customRender: "log" },
+  }
+]
+
+
+
+
 export const TableColumnOfMoreStat = [
   {
     fixed: "left",
@@ -287,7 +329,7 @@ export const TableColumnOfPutAdPlan = [
     fixed: "left",
     title: "",
     dataIndex: "check",
-    width: 120,
+    width: 100,
     slots:{
       customRender: 'switch'
     }
@@ -296,19 +338,19 @@ export const TableColumnOfPutAdPlan = [
     fixed: "left",
     title: "账户名",
     dataIndex: "account_name",
-    width: 120,
+    width: 100,
   },
   {
     fixed: "left",
     title: "邮箱",
     dataIndex: "email",
-    width: 150,
+    width: 100,
   },
   {
     fixed: "left",
     title: "广告名",
     dataIndex: "ad_name",
-    width: 150,
+    width: 100,
   },
 ];
 

+ 26 - 12
src/views/put/put-ad-plan.vue

@@ -34,7 +34,10 @@
       :scroll="{ x: 1500 }"
     >
       <template #switch="{ text, record }">
-        <a-switch v-model:checked="record.enable" @change="switchMethod(record)" />
+        <a-switch
+          v-model:checked="record.enable"
+          @change="switchMethod(record)"
+        />
       </template>
       <template #external_url="{ text, record }">
         <p @click="onGo(record)"><a>前往落地页链接</a></p>
@@ -43,6 +46,7 @@
       <template #cpa_bid="{ text, record }">
         <editable-cell
           :text="text"
+          title="预算"
           @change="(val) => onCellChange(record, 'cpa_bid', val)"
         />
       </template>
@@ -50,6 +54,7 @@
       <template #budget="{ text, record }">
         <editable-cell
           :text="text"
+          title="出价"
           @change="(val) => onCellChange(record, 'budget', val)"
         />
       </template>
@@ -73,7 +78,7 @@ import {
   getCustomColumn,
   adChangeMoney,
   adChangeCrem,
-  statusChange
+  statusChange,
 } from "@/api";
 
 import { ADPlanItem, PageOptions } from "@/types/api";
@@ -85,6 +90,7 @@ const PutAdPlan = defineComponent({
   },
   setup() {
     let { loading, meta, tablePageOptions } = usePagination();
+    let list: any[] = [];
     const state = reactive({
       platform: "platform1",
       list: ref<ADPlanItem[]>([]),
@@ -92,7 +98,8 @@ const PutAdPlan = defineComponent({
       loading,
       picker: [],
       tablePageOptions,
-      columns: TableColumnOfPutAdPlan,
+      columns: list,
+      defaultColumns: TableColumnOfPutAdPlan,
     });
 
     const onSearch = async (fields: Record<string, string>) => {
@@ -143,6 +150,7 @@ const PutAdPlan = defineComponent({
         } = {
           title: item.desc,
           dataIndex: item.name,
+          width: 150
         };
         if (item.name == "external_url") {
           lolumnItem.slots = { customRender: "external_url" };
@@ -153,6 +161,8 @@ const PutAdPlan = defineComponent({
 
         columns.push(lolumnItem);
       });
+      state.columns = [];
+      state.columns.push(...state.defaultColumns);
       state.columns.push(...columns);
     });
 
@@ -167,6 +177,7 @@ const PutAdPlan = defineComponent({
         meta.value = res.data.meta;
       });
     };
+
     return { ...toRefs(state), handleTableChange, onSearch };
   },
   methods: {
@@ -180,29 +191,32 @@ const PutAdPlan = defineComponent({
       if (dataIndex == "cpa_bid") {
         adChangeCrem({ ad_id, bid: value })
           .then((res) => {
-            location.reload();
+            this.$message.success("修改成功!");
           })
           .catch((e) => {
-            location.reload();
+            //location.reload();
           });
       }
       if (dataIndex == "budget") {
         adChangeMoney({ ad_id, budget: value })
           .then((res) => {
-            location.reload();
+            this.$message.success("修改成功!");
           })
           .catch((e) => {
-            location.reload();
+            //location.reload();
           });
       }
     },
-    switchMethod(record:any){
+    switchMethod(record: any) {
       console.log(record);
       let ad_id = record.ad_id;
-      statusChange({ ad_id, status: record.enable?'enable':'disable' }).then(res=>{
-        this.$message.error('修改广告状态成功!');
-      })
-    }
+      statusChange({
+        ad_id,
+        status: record.enable ? "disable" : "enable",
+      }).then((res) => {
+        this.$message.success("修改广告状态成功!");
+      });
+    },
   },
 });
 

+ 91 - 0
src/views/put/put-log.vue

@@ -0,0 +1,91 @@
+<template>
+  <div class="page-wrap page-wrap-put-books">
+    <tool-bar :text="[]" :label="[]"  @confirm="onSearch" v-model:loading="inSearching">
+      <template #picker>
+        <p class="label">日期</p>
+        <a-range-picker
+          v-model:value="picker"
+          :ranges="{
+            本周: [moment(), moment().endOf('week')],
+            本月: [moment(), moment().endOf('month')],
+          }"
+          format="YYYY/MM/DD"
+        />
+      </template>
+    </tool-bar>
+    <a-table :columns="columns" :data-source="list" rowKey="id">
+      <template #log="{ text, record }">
+        <p v-for="(log, index) in record.content_log" :key="log">
+          <span style="line-height: 200%">{{ log }}</span>
+        </p>
+      </template>
+    </a-table>
+  </div>
+</template>
+
+<script lang="ts">
+import { defineComponent, reactive, toRefs, ref } from "vue";
+
+import ToolBar from "@/components/tool-bar/index.vue";
+import moment from "moment";
+import { TableColumnOfPutLog } from "../_pageOptions/table-put";
+
+import { opertaroLog } from "@/api";
+import usePagination from "@/hooks/usePagination";
+
+import { adPlanLog, PageOptions } from "@/types/api";
+import useApp from "@/hooks/useApp";
+
+const PutData = defineComponent({
+  components: {
+    ToolBar,
+  },
+  setup() {
+    const { router } = useApp();
+    let { loading, meta, tablePageOptions } = usePagination();
+    const state = reactive({
+      list: ref<adPlanLog[]>([]),
+      columns: TableColumnOfPutLog,
+      picker: [],
+      inSearching: false,
+    });
+    const onSearch = async (fields: Record<string, string>) => {
+      try {
+        const { picker } = state;
+        let [begin_dates, end_dates] = picker;
+        let begin_time = moment(begin_dates).format("YYYY-MM-DD");
+        let end_time = moment(end_dates).format("YYYY-MM-DD");
+        const { data } = await opertaroLog({begin_time,end_time,page: 1});
+        state.list = data.list;
+        meta.value = data.meta;
+      } catch (e) {
+        console.log(e);
+      } finally {
+        console.log(state.inSearching);
+        state.inSearching = false;
+      }
+    };
+    opertaroLog().then((res) => {
+      state.list = res.data.list;
+      console.log(state.list);
+    });
+    const handleTableChange = (pagination: PageOptions) => {
+      const { current, pageSize, total } = pagination;
+      opertaroLog({ page: current }).then((res) => {
+        state.list = res.data.list;
+        meta.value = res.data.meta;
+      });
+    };
+    const more = (data: any) => {
+      console.log(data.date);
+      router.push({ path: "/put/datamore" });
+    };
+    return { ...toRefs(state), onSearch, handleTableChange, meta, more };
+  },
+  methods: {
+    moment,
+  },
+});
+
+export default PutData;
+</script>