Sfoglia il codice sorgente

RING:建计划流程

ringcode 3 anni fa
parent
commit
08afb0060c

+ 22 - 3
src/api/index.ts

@@ -967,9 +967,10 @@ export const getAdCampaigns = (
     advertiser_id: string | number,
     campaign_name?: string,
     page: string | number,
+    pageSize: 200
   }
 ): any => {
-  return axios("/ad/adCampaigns", { params: query });
+  return axios("/ad/advertiser/campaigns", { params: query });
 };
 // 创建广告组
 /* 创建广告组
@@ -995,6 +996,7 @@ export const getPackage = (
   query: {
     advertiser_id: string | number,
     page: string | number,
+    page_size: string | number,
   }
 ): any => {
   return axios("/ad/package/get", { params: query });
@@ -1011,7 +1013,7 @@ export const createPlan = (data: {
   name: string;
   ad_data: object;
 }) => {
-  return axios.post("/ad/campaign/create", data);
+  return axios.post("/ad/create", data);
 };
 
 /**
@@ -1050,7 +1052,24 @@ export const getMediaPackage = (
   query: {
     advertiser_id: any,
     page: string | number,
+    page_size: string | number,
   }
 ): any => {
-  return axios("/ad/create/templates", { params: query });
+  return axios("/ad/flow/package/get", { params: query });
+};
+
+/**
+ * 创建自定义创意
+ * @param
+ */
+export const createCustomCreative = (
+  data: {
+    task_id?: string | number,
+    advertiser_id: string | number,
+    ad_id: string | number,
+    creative_list: any,
+    ad_data: any,
+  }
+): any => {
+  return axios.post("/ad/customCreative/create", data);
 };

+ 1 - 1
src/views/put/component/check-box.vue

@@ -190,10 +190,10 @@ export default CheckBox;
   .selected-box {
     width: 200px;
     margin-left: 20px;
-
     .selected {
       height: 176px;
       overflow: auto;
+    overflow-x: hidden;
       padding: 0 10px;
       p {
         background: rgb(240, 240, 240);

+ 62 - 11
src/views/put/component/creativity-content.vue

@@ -347,20 +347,25 @@ const creativityContent = defineComponent({
         imageType2: 0, // 大图横图
         imageType3: 0, // 小图
       }, // 素材类型计数
-      panes: [
-        // { title: "Tab 1", content: "Content of Tab 1", key: "1" },
-        // { title: "Tab 2", content: "Content of Tab 2", key: "2" },
-        // {
-        //   title: "Tab 3",
-        //   content: "Content of Tab 3",
-        //   key: "3",
-        //   closable: false,
-        // },
-      ],
+      panes: [],
       activeKey: 1,
+      videoModeList: [
+        "CREATIVE_IMAGE_MODE_VIDEO_VERTICAL",
+        "CREATIVE_IMAGE_MODE_VIDEO",
+      ], // 视频类型
+      imageModeList: [
+        "CREATIVE_IMAGE_MODE_LARGE_VERTICAL",
+        "CREATIVE_IMAGE_MODE_LARGE",
+        "CREATIVE_IMAGE_MODE_SMALL",
+      ], // 视频类型
     });
     watch(props.type, (newVal, oldVal) => {
-      if (newVal.creative_material_mode !== oldVal.creative_material_mode) {
+      console.log("ccc", newVal, oldVal);
+      // return
+      let old_type =
+        state.contentType === "CUSTOM" ? "CUSTOM" : "STATIC_ASSEMBLE";
+      if (newVal.creative_material_mode !== old_type) {
+        console.log("cccvvv");
         state.contentType =
           newVal.creative_material_mode === "CUSTOM" ? "CUSTOM" : "PROGRAM";
         state.creatives = [];
@@ -536,6 +541,38 @@ const creativityContent = defineComponent({
         return message.error("请先选择素材");
       }
     },
+    // 向父组件传递数据
+    backData() {
+      let data = JSON.parse(JSON.stringify(this.creatives));
+      let data_list: any = [];
+      // 程序化创意
+      if (this.contentType === "PROGRAM") {
+      } else {
+        // 自定义创意
+        // 组建新对象数组
+        if (data.length > 0) {
+          data.forEach((item: any) => {
+            let list_item: any = {
+              image_mode: item.image_mode, // 素材类型
+              title_material: { title: item.title }, // 标题
+              image_materials: [{ image_info: { image_id: item.image_id } }], // 图片素材时上传 数组长度1
+              video_material: {
+                image_info: { image_id: item.image_id },
+                video_info: { video_id: item.video_id },
+              }, // 视频素材时上传
+            };
+            if (this.imageModeList.includes(item.image_mode)) {
+              // 图片素材 删除视频
+              delete list_item.video_material;
+            } else {
+              delete list_item.image_materials;
+            }
+            data_list.push(list_item);
+          });
+        }
+      }
+      return data_list;
+    },
   },
 });
 // 要传的
@@ -554,6 +591,20 @@ const creativityContent = defineComponent({
 // 竖版视频 CREATIVE_IMAGE_MODE_VIDEO_VERTICAL 横板视频 CREATIVE_IMAGE_MODE_VIDEO
 // 传之前遍历删除imagr_url\video_url\video_cover\image_cover\delete_cover
 
+// 更新
+// 自定义创意
+creative_list: [
+  {
+    image_mode: "", // 素材类型
+    title_material: { title: "" }, // 标题
+    image_materials: [{ image_info: { image_id: 0 } }], // 图片素材时上传 数组长度1
+    video_material: {
+      image_info: { image_id: 0 },
+      video_info: { video_id: 0 },
+    }, // 视频素材时上传
+  },
+];
+
 export default creativityContent;
 </script>
 <style lang="scss" scoped>

+ 9 - 1
src/views/put/component/direction-exclusion.vue

@@ -18,6 +18,7 @@
         <h3 :style="type === 'crowd' ? 'width: 70px' : 'width: 90px'">操作</h3>
       </div>
       <div class="list">
+        <a-empty v-show="list.length == 0"></a-empty>
         <!-- 人群定向循环列表 -->
         <p v-for="item in list" :key="item.id">
           <span
@@ -181,11 +182,18 @@ const DirectionExclusion = defineComponent({
   },
   methods: {
     async getList() {
+      this.list = [];
       let { data } = await getMediaPackage({
         advertiser_id: this.$route.query.advertiser_id,
-        page: 999,
+        page: 1,
+        page_size: 99,
       });
       console.log("定向包数据", data);
+      if (data.list.length > 0) {
+        data.list.forEach((item: any) => {
+          this.list.push({ name: item.name, id: item.flow_package_id });
+        });
+      }
     },
     // 添加定向
     addDirection(val: any) {

+ 48 - 9
src/views/put/plan-create/creativity-add.vue

@@ -10,7 +10,10 @@
           </a-radio-group>
         </a-form-item>
         <a-form-item label="创意内容">
-          <creativity-content :type="creativityAdd"></creativity-content>
+          <creativity-content
+            :type="creativityAdd"
+            ref="materialCom"
+          ></creativity-content>
         </a-form-item>
         <a-form-item
           label="创意标题"
@@ -48,7 +51,7 @@
           </p>
         </a-form-item>
         <a-form-item label="推广卡片">
-          <push-card></push-card>
+          <push-card ref="cardCom"></push-card>
         </a-form-item>
         <a-form-item label="来源">
           <a-input
@@ -113,7 +116,7 @@
               <h3>
                 已添加<span>({{ creativityAdd.ad_keywords.length }}/20)</span>
               </h3>
-              <a-button type="link" @click="creativityAdd.ad_keywords=[]"
+              <a-button type="link" @click="creativityAdd.ad_keywords = []"
                 >全部清空</a-button
               >
             </div>
@@ -139,7 +142,7 @@
 
 <script lang="ts">
 import { defineComponent, reactive, toRefs, ref } from "vue";
-import {} from "@/api";
+import { createCustomCreative } from "@/api";
 import Bus from "@/utils/bus";
 import { message } from "ant-design-vue";
 import creativityContent from "../component/creativity-content.vue";
@@ -148,6 +151,8 @@ import PushCard from "../component/push-card.vue";
 const CreativityAdd = defineComponent({
   components: { creativityContent, PushCard },
   setup() {
+    const materialCom: any = ref(null);
+    const cardCom: any = ref(null);
     const state = reactive({
       label: "", // 创意标签输入框
       kind: ref<any[]>([]), // 创意分类
@@ -171,13 +176,20 @@ const CreativityAdd = defineComponent({
       },
       creativityClassify: {},
     });
-    return { ...toRefs(state), labelCol: { span: 3 }, wrapperCol: { span: 8 } };
+    return {
+      ...toRefs(state),
+      labelCol: { span: 3 },
+      wrapperCol: { span: 8 },
+      materialCom,
+      cardCom,
+    };
   },
   mounted() {
     this.getClassify();
     Bus.$on("stepFourCheck", (val?: any) => {
       console.log("Step4Check");
-      Bus.$emit("stepFourBack");
+      // Bus.$emit("stepFourBack");
+      this.beforeCommit();
     });
   },
   methods: {
@@ -187,10 +199,37 @@ const CreativityAdd = defineComponent({
     },
     // 提交前数据处理
     beforeCommit() {
-      let data: any = { ...this.creativityAdd };
+      let data: any = {};
+      // 一、从素材组件和卡片组件获取数据
+      if (this.creativityAdd.creative_material_mode === "CUSTOM") {
+        // 自定义创意
+        data.creative_list = this.materialCom.backData();
+      }
+      // 二、数据处理
       // 1.创意方式,当值为"STATIC_ASSEMBLE"表示程序化创意,其他情况不传字段
-      if (data.creative_material_mode === "CUSTOM")
-        delete data.creative_material_mode;
+      // if (data.creative_material_mode === "CUSTOM")
+      //   delete data.creative_material_mode;
+      // 2.添加ad_data
+      data.ad_data = {
+        third_industry_id: this.creativityAdd.third_industry_id,
+        ad_keywords: this.creativityAdd.ad_keywords,
+        source: this.creativityAdd.source,
+        creative_auto_generate_switch: this.creativityAdd
+          .creative_auto_generate_switch
+          ? 1
+          : 0,
+        is_comment_disable: this.creativityAdd.is_comment_disable ? 0 : 1,
+        ad_download_status: this.creativityAdd.ad_download_status ? 0 : 1,
+        creative_display_mode: this.creativityAdd.creative_display_mode,
+      };
+      data.advertiser_id = 0;
+      data.ad_id = 0;
+      this.creatCreativity(data);
+    },
+    // 走创建接口
+    async creatCreativity(val: any) {
+      // this.creativityAdd.creative_material_mode === "CUSTOM"
+      let { data } = await createCustomCreative(val);
     },
     // 渲染前数据处理
     beforeBackshow(creativityOrigin: any) {

+ 26 - 11
src/views/put/plan-create/group-select.vue

@@ -70,16 +70,24 @@
           <div class="table-title"><h3>广告组名称</h3></div>
           <div class="list-box">
             <a-radio-group v-model:value="form.campaign_id">
-              <a-radio :style="radioStyle" :value="1"
+              <!-- <a-radio :style="radioStyle" :value="1"
                 >广告组1 <span class="desc">测试广告组</span></a-radio
-              >
+              > -->
               <a-radio
                 :style="radioStyle"
-                v-for="(item, index) in []"
-                :key="index"
-              ></a-radio>
+                v-for="item in groupList"
+                :key="item.campaign_id"
+                :value="item.campaign_id"
+                >{{ item.campaign_name }}
+                <span class="desc" v-show="item.landing_type === 'LINK'"
+                  >销售线索搜集</span
+                >
+                <span class="desc" v-show="item.landing_type === 'APP'"
+                  >应用推广</span
+                ></a-radio
+              >
             </a-radio-group>
-            <a-empty></a-empty>
+            <a-empty v-show="groupList.length === 0"></a-empty>
           </div>
         </div>
       </div>
@@ -121,7 +129,7 @@ const GroupSelect = defineComponent({
       display: "block",
       height: "40px",
       lineHeight: "40px",
-      width: "580px",
+      width: "560px",
       padding: "0 10px",
       borderBottom: "1px solid rgb(230, 230, 230)",
     });
@@ -237,6 +245,7 @@ const GroupSelect = defineComponent({
     // 搜索广告组名称
     onSearch() {
       console.log("搜索广告组", this.groupNameSearch);
+      this.getGroups();
     },
     // step2创建广告组页面校验
     check() {
@@ -261,7 +270,7 @@ const GroupSelect = defineComponent({
             // 请求创建广告主接口
             let param: any = {
               ...this.form,
-              advertiser_id: this.$route.query.account_id,
+              advertiser_id: Number(this.$route.query.advertiser_id),
             };
             delete param.build_mode;
             delete param.campaign_id;
@@ -301,11 +310,17 @@ const GroupSelect = defineComponent({
       return data;
     },
     async getGroups() {
-      let { data } = await getAdCampaigns({
+      let param: any = {
         advertiser_id: String(this.$route.query.advertiser_id),
-        page: 999,
-      });
+        page: 1,
+        pageSize: 200,
+      };
+      if (this.groupNameSearch) {
+        param.campaign_name = this.groupNameSearch;
+      }
+      let { data } = await getAdCampaigns(param);
       console.log("获取广告组", data);
+      this.groupList = data.list;
     },
     // 生成广告组名称
     makeGroupName() {

+ 227 - 37
src/views/put/plan-create/plan-edit.vue

@@ -7,19 +7,23 @@
         <a-form-item label="转化跟踪方式">
           <a-select placeholder="请选择">
             <a-select-option value="XIANSUOTONG">线索通</a-select-option>
-            <a-select-option value="XIANSUOTONG_API">线索API</a-select-option>
+            <a-select-option value="XIANSUOTONG_API">线索API</a-select-option>
           </a-select>
         </a-form-item>
         <a-form-item label="优化目标">
           <a-select placeholder="请选择">
-            <a-select-option value="shanghai">Zone one</a-select-option>
-            <a-select-option value="beijing">Zone two</a-select-option>
+            <a-select-option
+              v-for="(item, index) in []"
+              :key="index"
+            ></a-select-option>
           </a-select>
         </a-form-item>
         <a-form-item label="落地页">
           <a-select placeholder="请选择" v-model:value="plan.external_url">
-            <a-select-option value="shanghai">Zone one</a-select-option>
-            <a-select-option value="beijing">Zone two</a-select-option>
+            <a-select-option
+              v-for="(item, index) in []"
+              :key="index"
+            ></a-select-option>
           </a-select>
         </a-form-item>
         <a-form-item label="直达链接内容">
@@ -91,7 +95,10 @@
         style="margin-bottom: 20px"
       >
         <a-form-item label="定向方式">
-          <a-radio-group v-model:value="userTarget.directType">
+          <a-radio-group
+            v-model:value="userTarget.directType"
+            @change="getPackageList"
+          >
             <a-radio value="BUILD">新建定向</a-radio>
             <a-radio value="SELECT">选择已有定向包</a-radio>
           </a-radio-group>
@@ -102,9 +109,11 @@
         >
           <a-select placeholder="请选择">
             <a-select-option
-              v-for="(item, index) in []"
+              v-for="(item, index) in directList"
               :key="index"
-            ></a-select-option>
+              :value="item.audience_package_id"
+              >{{ item.name }}</a-select-option
+            >
           </a-select>
         </a-form-item>
       </a-form>
@@ -160,7 +169,7 @@
         </a-form-item>
         <!-- 媒体定向 -->
         <a-form-item label="媒体定向">
-          <a-radio-group v-model:value="userTarget.mediaTarget">
+          <a-radio-group v-model:value="plan.superior_popularity_type">
             <a-radio-button value="NONE">不限</a-radio-button>
             <a-radio-button value="1" disabled>游戏优质媒体</a-radio-button>
             <a-radio-button value="CUSTOM">自定义</a-radio-button>
@@ -169,7 +178,7 @@
           <direction-exclusion
             ref="mediaCom"
             :compType="'media'"
-            v-if="userTarget.mediaTarget === 'CUSTOM'"
+            v-if="plan.superior_popularity_type === 'CUSTOM'"
           ></direction-exclusion>
         </a-form-item>
         <a-form-item label="平台">
@@ -376,15 +385,66 @@
       <h1>预算与出价</h1>
       <a-form :label-col="labelCol" :wrapper-col="wrapperCol">
         <a-form-item label="投放场景">
-          <a-radio-group v-model:value="plan.smart_bid_type">
+          <a-radio-group
+            v-model:value="plan.smart_bid_type"
+            @change="itemChange('smart_bid_type')"
+          >
             <a-radio value="SMART_BID_CUSTOM">常规投放</a-radio>
             <a-radio value="SMART_BID_CONSERVATIVE">放量投放</a-radio>
           </a-radio-group>
-          <span style="font-size: 13px; color: gray"
+          <span
+            style="font-size: 13px; color: gray"
+            v-show="plan.smart_bid_type === 'SMART_BID_CUSTOM'"
             >控制成本,尽量消耗完预算</span
           >
+          <span
+            style="font-size: 13px; color: gray"
+            v-show="plan.smart_bid_type === 'SMART_BID_CONSERVATIVE'"
+            >接受成本上浮,尽量消耗更多预算</span
+          >
+          <a-checkbox
+            v-if="plan.smart_bid_type === 'SMART_BID_CONSERVATIVE'"
+            v-model:checked="plan.adjust_cpa"
+            >通过学习期后,尝试优化转化成本</a-checkbox
+          >
+        </a-form-item>
+        <a-form-item
+          label="日预算"
+          v-if="plan.smart_bid_type === 'SMART_BID_CONSERVATIVE'"
+        >
+          <a-input
+            addon-after="元"
+            v-model:value="plan.budget"
+            style="width: 140px"
+            type="number"
+          />
+        </a-form-item>
+        <a-form-item
+          label="预算"
+          v-if="plan.smart_bid_type === 'SMART_BID_CUSTOM'"
+        >
+          <a-input
+            addon-after="元"
+            v-model:value="plan.budget"
+            style="width: 220px"
+            type="number"
+          >
+            <template #addonBefore>
+              <a-select v-model:value="plan.budget_mode" style="width: 90px">
+                <a-select-option value="BUDGET_MODE_DAY"
+                  >日预算</a-select-option
+                >
+                <a-select-option value="BUDGET_MODE_TOTAL"
+                  >总预算</a-select-option
+                >
+              </a-select>
+            </template></a-input
+          >
         </a-form-item>
-        <a-form-item label="竞价策略">
+        <a-form-item
+          label="竞价策略"
+          v-if="plan.smart_bid_type === 'SMART_BID_CUSTOM'"
+        >
           <a-radio-group v-model:value="plan.flow_control_mode">
             <a-radio value="FLOW_CONTROL_MODE_FAST">优先跑量</a-radio>
             <a-radio value="FLOW_CONTROL_MODE_SMOOTH">均衡投放</a-radio>
@@ -397,6 +457,11 @@
             <a-radio value="SCHEDULE_FROM_NOW">从今天起长期投放</a-radio>
             <a-radio value="SCHEDULE_START_END">设置开始和结束时间</a-radio>
           </a-radio-group>
+          <a-range-picker
+            v-if="plan.schedule_type === 'SCHEDULE_START_END'"
+            v-model:value="range"
+            :allowClear="false"
+          />
         </a-form-item>
         <a-form-item label="投放时段">
           <a-radio-group v-model:value="userTarget.timeDuration">
@@ -412,11 +477,16 @@
         <!-- 投放时段 -->
         <a-form-item label="付费方式">
           <a-radio-group v-model:value="plan.pricing">
-            <a-radio value="PRICING_OCPM">按展示付费(oCPM)</a-radio>
+            <a-radio value="PRICING_CPM">按展示付费(oCPM)</a-radio>
           </a-radio-group>
         </a-form-item>
         <a-form-item label="目标转化出价">
-          <a-input style="width: 100px" type="number" suffix="元" />
+          <a-input
+            style="width: 100px"
+            type="number"
+            suffix="元"
+            v-model:value="plan.cpa_bid"
+          />
           <span style="font-size: 13px; color: gray">出价不能大于预算</span>
         </a-form-item>
       </a-form>
@@ -427,27 +497,30 @@
       <h1>第三方检测链</h1>
       <a-form :label-col="labelCol" :wrapper-col="wrapperCol">
         <a-form-item label="展示">
-          <a-input placeholder="选填" v-model:value="plan.track_url" />
+          <a-input placeholder="选填" v-model:value="plan.track_url[0]" />
         </a-form-item>
         <a-form-item label="有效触点">
-          <a-input placeholder="选填" v-model:value="plan.action_track_url" />
+          <a-input
+            placeholder="选填"
+            v-model:value="plan.action_track_url[0]"
+          />
         </a-form-item>
         <a-form-item label="视频播放">
           <a-input
             placeholder="选填"
-            v-model:value="plan.video_play_track_url"
+            v-model:value="plan.video_play_track_url[0]"
           />
         </a-form-item>
         <a-form-item label="视频播完">
           <a-input
             placeholder="选填"
-            v-model:value="plan.video_play_done_track_url"
+            v-model:value="plan.video_play_done_track_url[0]"
           />
         </a-form-item>
         <a-form-item label="视频有效播放">
           <a-input
             placeholder="选填"
-            v-model:value="plan.video_play_effective_track_url"
+            v-model:value="plan.video_play_effective_track_url[0]"
           />
         </a-form-item>
       </a-form>
@@ -470,8 +543,10 @@
 
 <script lang="ts">
 import { defineComponent, reactive, toRefs, ref } from "vue";
-import { createPlan } from "@/api";
+import { createPlan, getPackage } from "@/api";
 import Bus from "@/utils/bus";
+import { Moment } from "moment";
+import moment from "moment";
 import TimeSchedule from "../component/time-schedule.vue";
 import Location from "../component/location-auto-release.vue";
 import DirectionExclusion from "../component/direction-exclusion.vue";
@@ -510,7 +585,7 @@ const PlanEdit = defineComponent({
       },
       plan: {
         // part1 优化目标----------------------------------------------------
-        convert_type: "转化跟踪方式", // 转化跟踪方式
+        convert_type: "", // 转化跟踪方式
         external_url: undefined, // 落地页
         open_url: "", // 直达链接内容
         // part2 投放位置----------------------------------------------------
@@ -526,7 +601,7 @@ const PlanEdit = defineComponent({
         retargeting_tags_include: ref<any[]>([]), // 定向人群
         retargeting_tags_exclude: ref<any[]>([]), //排除人群
         interest_action_mode: "UNLIMITED", // 行为兴趣
-        superior_popularity_type: "", // 媒体定向类型 、、 选择自定义媒体包时本字段不传
+        superior_popularity_type: "NONE", // 媒体定向类型 、、 选择自定义媒体包时本字段不传
         flow_package: ref<any[]>([]), // 定向流量包
         exclude_flow_package: ref<any[]>([]), // 排除流量包
         platform: ref<any[]>(["NONE"]), // 平台-字符串数组
@@ -545,30 +620,34 @@ const PlanEdit = defineComponent({
         auto_extend_targets: ref<any[]>([]), // 可开放定向
         // part4 预算与出价---------------------------------------
         smart_bid_type: "SMART_BID_CUSTOM", // 投放场景
+        adjust_cpa: false, // 优化转化成本 0-false 1-true // 投放场景为常规投放时不传
         flow_control_mode: "FLOW_CONTROL_MODE_FAST", // 竞价策略
-        budget_mode: "", // 预算类型
+        budget_mode: "BUDGET_MODE_DAY", // 预算类型 日预算-BUDGET_MODE_DAY 总预算-BUDGET_MODE_TOTAL // 投放场景为放量投放时 固定为日预算
         budget: 0, // 预算
         schedule_type: "SCHEDULE_FROM_NOW", // 投放时间类型
         start_time: "", // 投放开始时间
         end_time: "", // 投放结束时间
         schedule_time: "", // 投放时段
-        pricing: "PRICING_OCPM", // 付费方式
+        pricing: "PRICING_CPM", // 付费方式
         cpa_bid: "", // 目标转化出价
         // part5 第三方检测---------------------------------------
-        track_url: "", // 展示
-        action_track_url: "", // 有效触点
-        video_play_track_url: "", // 视频播放
-        video_play_done_track_url: "", // 视频播完
-        video_play_effective_track_url: "", // 有效播放
+        track_url: ref<any[]>([]), // 展示
+        action_track_url: ref<any[]>([]), // 有效触点
+        video_play_track_url: ref<any[]>([]), // 视频播放
+        video_play_done_track_url: ref<any[]>([]), // 视频播完
+        video_play_effective_track_url: ref<any[]>([]), // 有效播放
         // part6 计划名称---------------------------------------
         name: "", // 计划名称
         number: 1, // 创建数量
       },
+      range: ref<Moment[]>([]), // 投放时间选择
       phonePriceMarks: PriceSlider, //手机价格区间
       optionsList: {
         mediaList: LaunchMedia, // 投放媒体
         sceneList: LaunchScene, // 投放场景
       },
+      advertiser_id: 0,
+      directList: ref<any[]>([]),
     });
     return {
       ...toRefs(state),
@@ -585,11 +664,13 @@ const PlanEdit = defineComponent({
     };
   },
   mounted() {
+    this.advertiser_id = Number(this.$route.query.advertiser_id);
+    let time = this.getNowFormatDate();
+    this.plan.name = `${this.plan.pricing}_${time}`;
     Bus.$on("stepThreeCheck", (val?: any) => {
       console.log("Step3Check");
-      // Bus.$emit("stepThreeBack");
-      // console.log("接口");
-      this.beforeCommit();
+      Bus.$emit("stepThreeBack");
+      // this.beforeCommit();
     });
   },
   methods: {
@@ -634,7 +715,7 @@ const PlanEdit = defineComponent({
         ? "HAS_OPEN"
         : "DISABLED";
       // 2.用户定向选择已有定向包时处理
-      // 3.缺省代表不限的字段 ['NONE'] => [], 平台、设备类型、运营商carrier、新用户activate_type
+      // 3.缺省代表不限的字段 ['NONE'] => [], 平台、设备类型、运营商carrier、新用户activate_type、(年龄age)、ac(unknown)
       //   3.1平台
       if (data.platform[0] === "NONE") delete data.platform;
       //   3.2设备类型device_type
@@ -643,6 +724,10 @@ const PlanEdit = defineComponent({
       if (data.carrier[0] === "NONE") delete data.carrier;
       //   3.4新用户activate_type
       if (data.activate_type[0] === "NONE") delete data.activate_type;
+      //   3.5年龄 age
+      if (data.age[0] === "NONE") delete data.age;
+      //   3.6 ac
+      if (data.ac[0] === "unknown") delete data.ac;
       // 4.当过滤已转化用户不是CUSTOMER 时 删除过滤时间
       if (data.hide_if_converted !== "CUSTOMER")
         delete data.converted_time_duration;
@@ -665,10 +750,36 @@ const PlanEdit = defineComponent({
       // 12.删除plan.name plan.number
       delete data.name;
       delete data.number;
-
+      // 13.投放场景为常规投放时 删除优化转化成本 adjust_cpa 否则删除竞价策略
+      if (data.smart_bid_type === "SMART_BID_CUSTOM") {
+        delete data.adjust_cpa;
+      } else {
+        data.adjust_cpa = this.numAndBool(data.adjust_cpa);
+        delete data.flow_control_mode;
+      }
+      // 14.当投放时间为指定时间时 range=>start_time\end_time 否则删除
+      if (data.schedule_type === "SCHEDULE_START_END") {
+        data.start_time = moment(this.range[0]).format("YYYY-MM-DD");
+        data.end_time = moment(this.range[1]).format("YYYY-MM-DD");
+      } else {
+        delete data.start_time;
+        delete data.end_time;
+      }
+      // 15.投放人群为不限时 删除 retargeting_tags_include 、 retargeting_tags_exclude
+      if (this.userTarget.crowdType === "NONE") {
+        delete data.retargeting_tags_include;
+        delete data.retargeting_tags_exclude;
+      }
+      // 15.媒体定向为不限时 删除 flow_package 、 exclude_flow_package
+      if (this.plan.superior_popularity_type === "NONE") {
+        delete data.flow_package;
+        delete data.exclude_flow_package;
+      } else {
+        delete data.superior_popularity_type;
+      }
       // 调用接口
       console.log("data", data);
-      return;
+      // return;
       this.savePlan(data);
     },
     // 保存数据
@@ -684,7 +795,13 @@ const PlanEdit = defineComponent({
         ad_data: { ...plan_data },
       };
       console.log("新建计划数据", param);
-      let { data } = await createPlan(param);
+      try {
+        let { data } = await createPlan(param);
+        console.log("请求成功");
+        Bus.$emit("stepThreeBack");
+      } catch (err) {
+        console.log("请求失败", err.msg);
+      }
     },
     // 回显之前处理数据
     beforeBackShow(planOrigin: any) {
@@ -728,6 +845,27 @@ const PlanEdit = defineComponent({
       this.userTarget.timeDuration = planOrigin.schedule_time
         ? "CUSTOM"
         : "NONE";
+      // 11.投放场景不是常规投放时 优化成本bool转num
+      if (planOrigin.smart_bid_type !== "SMART_BID_CUSTOM")
+        planOrigin.adjust_cpa = this.numAndBool(planOrigin.adjust_cpa);
+      // 12.如果返回数据里有start_time/end_time 将这两个值赋值给range
+      if (planOrigin.hasOwnProperty("")) {
+        this.range = [
+          moment(planOrigin.start_time, "YYYY-MM-DD"),
+          moment(planOrigin.end_time, "YYYY-MM-DD"),
+        ];
+      }
+    },
+    // 获取已有定向包
+    async getPackageList() {
+      let param = {
+        advertiser_id: this.advertiser_id,
+        page: 1,
+        page_size: 100,
+      };
+      let { data } = await getPackage(param);
+      console.log("定向包数据", data);
+      this.directList = data.audience_packages;
     },
     // 多选框互斥
     checkboxChange(val: any, type: any) {
@@ -815,6 +953,17 @@ const PlanEdit = defineComponent({
         });
       }
     },
+    // 选项改变时联动
+    itemChange(type: any) {
+      // 投放场景为放量投放 预算类型固定为日预算 清空预算
+      if (
+        type === "smart_bid_type" &&
+        this.plan.smart_bid_type === "SMART_BID_CONSERVATIVE"
+      ) {
+        this.plan.budget_mode = "BUDGET_MODE_DAY";
+        this.plan.budget = 0;
+      }
+    },
     // 用户定向保存为定向包
     saveDirectPackage() {
       console.log("保存定向包");
@@ -826,6 +975,47 @@ const PlanEdit = defineComponent({
       if (val === true) return 1;
       if (val === false) return 0;
     },
+    // 工具函数 获取当前时间
+    getNowFormatDate() {
+      var date = new Date();
+      var seperator1 = "-";
+      var seperator2 = ":";
+      var month: any = date.getMonth() + 1;
+      var strDate: any = date.getDate();
+      var strHours: any = date.getHours();
+      var strMinutes: any = date.getMinutes();
+      var strSeconds: any = date.getSeconds();
+      if (month >= 1 && month <= 9) {
+        month = "0" + month;
+      }
+      if (strDate >= 0 && strDate <= 9) {
+        strDate = "0" + strDate;
+      }
+      if (strHours >= 0 && strHours <= 9) {
+        strHours = "0" + strHours;
+      }
+      if (strMinutes >= 0 && strMinutes <= 9) {
+        strMinutes = "0" + strMinutes;
+      }
+      if (strSeconds >= 0 && strSeconds <= 9) {
+        strSeconds = "0" + strSeconds;
+      }
+      var currentdate =
+        date.getFullYear() +
+        seperator1 +
+        month +
+        seperator1 +
+        strDate +
+        " " +
+        strHours +
+        seperator2 +
+        strMinutes +
+        seperator2 +
+        strSeconds;
+      currentdate = currentdate.replace(/-/g, "_").replace(/ /g, "_");
+      currentdate = currentdate.slice(5, 19);
+      return currentdate;
+    },
     // 互斥项切换-工具函数
     checkboxCheck(val: string) {
       // if (this.plan[val].indexOf("NONE") == 0 && this.plan[val].length > 1) {