浏览代码

账户配置 校验 添加

jiayufei 4 年之前
父节点
当前提交
6cec6738d3
共有 1 个文件被更改,包括 90 次插入22 次删除
  1. 90 22
      src/views/modules/account-config/components/configuration-modal.vue

+ 90 - 22
src/views/modules/account-config/components/configuration-modal.vue

@@ -15,11 +15,11 @@
                         <acount-search :disabled="modalTitle === 'edit'" class="acount-search-class" :appId.sync="configForm.accountId" :multiple="false" request="1,3"></acount-search>
                     </a-form-model-item>
                     <a-form-model-item label="dp链接范围" class="dp-link-start" prop="dpLinkStartIndex">
-                        <a-input-number class="common-input" placeholder="请输入" :disabled="modalTitle === 'edit'" v-model="configForm.dpLinkStartIndex" :min="1"/>
+                        <a-input-number class="common-input" placeholder="请输入" :disabled="modalTitle === 'edit'" v-model="configForm.dpLinkStartIndex" :min="0"/>
                         <span>~</span>
                     </a-form-model-item>
                     <a-form-model-item label="" class="dp-link-end" prop="dpLinkEndIndex">
-                        <a-input-number class="common-input" placeholder="请输入" :disabled="modalTitle === 'edit'" v-model="configForm.dpLinkEndIndex" :min="configForm.dpLinkStartIndex"/>
+                        <a-input-number class="common-input" placeholder="请输入" :disabled="modalTitle === 'edit'" v-model="configForm.dpLinkEndIndex" :min="getEndIndex"/>
                     </a-form-model-item>
                     <a-form-model-item label="预算方式">
                         <a-radio-group v-model="configForm.accountBudgetMode" button-style="solid" @change="handleAccountMode">
@@ -103,7 +103,7 @@
                 </div>
                 <div class="separate-module-con">
                     <p class="rock-title">优化目标</p>
-                    <a-form-model-item label="转化跟踪方式" prop="adConvertType">
+                    <a-form-model-item label="转化跟踪方式" :prop="configForm.launchTarget === 'OCPM' ? 'adConvertType' : ''">
                         <a-select class="common-input-long" :disabled="modalTitle === 'edit'" v-model="configForm.adConvertType" placeholder="请选择" @change="handleConvertTypeChange">
                             <a-select-option value="AD_CONVERT_SOURCE_TYPE_APP_DOWNLOAD">应用下载API</a-select-option>
                             <a-select-option value="AD_CONVERT_SOURCE_TYPE_SDK">应用下载SDK</a-select-option>
@@ -111,7 +111,7 @@
                             <a-select-option value="AD_CONVERT_SOURCE_TYPE_NORMAL_APP_DOWNLOAD">普通应用下载</a-select-option>
                         </a-select>
                     </a-form-model-item>
-                    <a-form-model-item label="优化目标" prop="adConvertId">
+                    <a-form-model-item label="优化目标" :prop="configForm.launchTarget === 'OCPM' ? 'adConvertId' : ''">
                         <a-select class="common-input-long" :disabled="modalTitle === 'edit'" v-model="configForm.adConvertId" placeholder="请选择" @change="handleConvertChange">
                             <a-select-option
                                 v-for="(item, index) in optimizationOption"
@@ -202,14 +202,15 @@
                             <a-radio-button value="PC" :disabled="!!configForm.adDownloadUrl">PC</a-radio-button>
                         </a-radio-group>
                     </a-form-model-item>
+                    <!-- adAndroidOsv  adAndroidVersion -->
                     <a-form-model-item v-if="configForm.adDownloadUrl" label="安卓版本">
-                        <a-radio-group v-model="configForm.adAndroidOsv" button-style="solid">
+                        <a-radio-group v-model="configForm.adAndroidVersion" button-style="solid" @change="handleAndroidVersion">
                             <a-radio-button value="NONE">不限</a-radio-button>
                             <a-radio-button value="a">自定义</a-radio-button>
                         </a-radio-group>
                     </a-form-model-item>
                     <div class="adver-position-radio">
-                        <div v-if="configForm.adAndroidOsv === 'a'" class="position-radio-change">
+                        <div v-if="configForm.adDownloadUrl && configForm.adAndroidVersion === 'a'" class="position-radio-change">
                             <p>安卓版本</p>
                             <a-radio-group v-model="configForm.androidChangeValue">
                                 <a-radio :style="radioStyle" value="8.0">Andriod 8.0以上</a-radio>
@@ -300,7 +301,7 @@
                             <a-radio-button value="PRICING_OCPM" :disabled="modalTitle === 'edit'">按展示付费(oCPM)</a-radio-button>
                         </a-radio-group>
                     </a-form-model-item>
-                    <a-form-model-item label="目标转化出价" prop="adCpaBid">
+                    <a-form-model-item label="目标转化出价" :prop="configForm.launchTarget === 'OCPM' ? 'adCpaBid' : ''">
                         <a-input-number class="common-input" v-model="configForm.adCpaBid" :min="0.1" :max="configForm.adBudget" :step="0.01"/> 元
                     </a-form-model-item>
                 </div>
@@ -365,7 +366,7 @@
                             :prop="'defaultFormList.' + index + '.value'"
                             :rules="[
                                 {required: true, message: '请输入', trigger: 'blur'},
-                                {min: 1, max: 10, message: '长度位6-9字符', trigger: 'blur'}
+                                {min: 6, max: 9, message: '长度为6-9字符', trigger: 'blur'}
                             ]"
                         >
                             <a-input class="common-input-long" v-model="item.value" placeholder="请输入" allow-clear/>
@@ -383,7 +384,8 @@
                             <a-input class="common-input-long" placeholder="请输入" v-model="configForm.creativeCallToAction" allow-clear/>
                         </a-form-model-item>
                     </div>
-                    <a-form-model-item label="来源" prop="creativeSource">
+                    <!-- configForm.campaignLandingType creativeSource -->
+                    <a-form-model-item label="来源" :prop="getSource">
                         <a-input class="common-input-long" placeholder="请输入来源" v-model="configForm.creativeSource" allow-clear/>
                     </a-form-model-item>
                 </div>
@@ -589,9 +591,9 @@ export default {
                 adPlatform: 'NONE', // 定向-平台
                 adAc: 'NONE', // 定向-网络
                 adHideIfExists: '0', // 定向-已安装用户
-                adHideIfConverted: 'AD', // 定向-已转化用户
+                adHideIfConverted: 'NO_EXCLUDE', // 定向-已转化用户
                 adAutoExtendEnabled: '0', // 定向-智能播放
-                adAndroidOsv: 'NONE', // 定向-安卓版本
+                adAndroidVersion: 'NONE', // 定向-安卓版本
                 androidChangeValue: '', // 安卓版本-自定义
                 adSmartBidType: 'SMART_BID_CUSTOM', // 投放场景
                 adBudget: 0, // 预算
@@ -616,6 +618,14 @@ export default {
         };
     },
     computed: {
+        getEndIndex() {
+            return Number(this.configForm.dpLinkStartIndex);
+        },
+        getSource() {
+            if (this.configForm.campaignLandingType !== 'APP' || (this.configForm.campaignLandingType === 'APP' && this.configForm.adDownloadType === 'EXTERNAL_URL')) {
+                return 'creativeSource';
+            }
+        },
         NewAountId() {
             return this.configForm.accountId;
         },
@@ -685,6 +695,27 @@ export default {
     methods: {
         ...mapGetters(['nickname', 'avatar', 'userInfo']),
         moment,
+        handleGetPackage() {
+            const params = {
+                urlPath: this.configForm.adDownloadUrl,
+                downloadType: 'android'
+            };
+            getAction(urlAcount + '/bytedance-api/advertiser/aiBytedanceAdvertiserStrategy/getPackageNameByUrl', params).then(result => {
+                if (result.code === 0) {
+                    this.configForm.adPackage = result.result.package || '';
+                }
+                else {
+                    this.$message.error(result.message);
+                }
+            }).catch(error => {
+                console.log(error, 'eeee');
+            });
+        },
+        handleAndroidVersion(e) {
+            if (e.target.value === 'NONE') {
+                this.configForm.androidChangeValue = '';
+            }
+        },
         handleAdScheduleType(e) {
             if (e.target.value === 'SCHEDULE_FROM_NOW') {
                 this.configForm.launchDateRange = [];
@@ -713,6 +744,7 @@ export default {
             }
         },
         handleAdDownLoadType(e) {
+            this.optimizationOption = [];
             if (e.target.value === 'DOWNLOAD_URL') {
                 this.configForm.adExternalUrl = '';
                 this.configForm.adOpenUrl = '';
@@ -776,7 +808,6 @@ export default {
                     this.configForm.adRetargetingTagsInclude = detailData.adRetargetingTagsInclude;
                     this.configForm.adSuperiorPopularityType = detailData.adSuperiorPopularityType;
                     this.configForm.adPlatform = detailData.adPlatform;
-                    this.configForm.adAndroidOsv = detailData.adAndroidOsv;
                     this.configForm.adAc = detailData.adAc;
                     this.configForm.adHideIfExists = String(detailData.adHideIfExists);
                     this.configForm.adHideIfConverted = detailData.adHideIfConverted;
@@ -800,7 +831,15 @@ export default {
                     this.configForm.creativeThirdIndustryIds[1] = detailData.creativeThirdIndustryId.substr(0, 6);
                     this.configForm.creativeThirdIndustryIds[2] = detailData.creativeThirdIndustryId;
                     this.imageUrl = detailData.imageUrl;
+                    this.urlResult = detailData.imageUrl;
                     this.md5Result = detailData.creativeProductImageCode;
+                    if (detailData.adAndroidOsv !== 'NONE') {
+                        this.configForm.adAndroidVersion = 'a';
+                        this.configForm.androidChangeValue = detailData.adAndroidOsv;
+                    }
+                    else {
+                        this.configForm.adAndroidVersion = 'NONE';
+                    }
                     if (detailData.productSellingPoints) {
                         let productPointsList = [];
                         const randomNum = new Date().getTime() + Math.ceil(Math.random() * 1000);
@@ -833,16 +872,29 @@ export default {
                     if (detailData.adKeywords) {
                         this.creativeTag = detailData.adKeywords;
                     }
-                    const paramsData = {
-                        advancedCreativeType: 'ATTACHED_CREATIVE_NONE',
-                        advertiserId: this.configForm.accountId,
-                        appType: 'APP_ANDROID',
-                        deliveryRange: 'DEFAULT',
-                        externalUrl: this.configForm.adExternalUrl,
-                        landingType: this.configForm.campaignLandingType,
-                        packageName: this.configForm.adPackage,
-                        promotionContent: this.configForm.adDownloadType
-                    };
+                    let paramsData = {};
+                    if (this.configForm.adDownloadType === 'DOWNLOAD_URL') {
+                        paramsData = {
+                            advancedCreativeType: 'ATTACHED_CREATIVE_NONE',
+                            advertiserId: this.configForm.accountId,
+                            appType: 'APP_ANDROID',
+                            deliveryRange: 'DEFAULT',
+                            externalUrl: this.configForm.adExternalUrl,
+                            landingType: this.configForm.campaignLandingType,
+                            packageName: this.configForm.adPackage,
+                            promotionContent: this.configForm.adDownloadType
+                        };
+                    }
+                    else if (this.configForm.adDownloadType === 'EXTERNAL_URL') {
+                        paramsData = {
+                            advancedCreativeType: 'ATTACHED_CREATIVE_NONE',
+                            advertiserId: this.configForm.accountId,
+                            deliveryRange: 'DEFAULT',
+                            externalUrl: this.configForm.adExternalUrl,
+                            landingType: this.configForm.campaignLandingType,
+                            promotionContent: this.configForm.adDownloadType
+                        };
+                    }
                     postAction(urlAcount + '/bytedance-api/advertiser/aiBytedanceAdvertiserStrategy/getToolConvert', paramsData).then(result => {
                         if (result.code === 0) {
                             const updateResult = result.result.filter(item => item.external_actions.length > 0);
@@ -954,6 +1006,7 @@ export default {
         },
         handleDownloadLink(e) {
             this.configForm.adPlatform = e.target.value ? 'ANDROID' : 'NONE';
+            this.handleGetPackage();
         },
         handleDeleteImg() {
             this.imageUrl = '';
@@ -1075,6 +1128,18 @@ export default {
         },
         handleRelaxSure() {
             let paramsFormData = this.configForm;
+            if (!this.urlResult) {
+                this.$message.error('请上传图片');
+                return;
+            }
+            if (!this.configForm.defaultFormList.length) {
+                this.$message.error('请添加卖点');
+                return;
+            }
+            if (!this.creativeTag.length) {
+                this.$message.error('请添加标签');
+                return;
+            }
             if (paramsFormData.adverPosition === 'a') {
                 paramsFormData.creativeSmartInventory = 0;
             }
@@ -1104,6 +1169,9 @@ export default {
             else if (paramsFormData.launchTimeInterval === 'a') {
                 paramsFormData.adScheduleTime = paramsFormData.scheduleTimeData;
             }
+            if (paramsFormData.adAndroidVersion = 'a') {
+                paramsFormData.adAndroidOsv = paramsFormData.androidChangeValue;
+            }
             paramsFormData.productSellingPoints = this.configForm.defaultFormList && this.configForm.defaultFormList.map(item => item.value);
             paramsFormData.creativeThirdIndustryId = paramsFormData.creativeThirdIndustryIds[2];
             paramsFormData.creativeProductImageCode = this.md5Result;