ソースを参照

文案库 修改新增逻辑

jiayufei 4 年 前
コミット
adf8f845ec

+ 3 - 0
src/views/modules/copy-library/copy-library.less

@@ -107,6 +107,9 @@
 }
 /deep/ .select-matermal-modal {
     width: 1000px !important;
+    .common-input-long {
+        width: 280px;
+    }
     .pagin-table-class {
         display: flex;
         justify-content: flex-end;

+ 118 - 100
src/views/modules/copy-library/copy-library.vue

@@ -257,6 +257,25 @@
                 </div>
                 <a-row class="viedo-serach-class" :gutter="24">
                     <a-col :span="9">
+                        <a-form-item label="项目" :labelCol="labelCol" :wrapperCol="wrapperCol">
+                            <a-select
+                                class="common-input-long"
+                                show-search
+                                v-model="projectModelValue"
+                                placeholder="请选择"
+                                :filter-option="filterOption"
+                            >
+                                <a-select-option
+                                    v-for="(item, index) in optimizationOption"
+                                    :key="index"
+                                    :value="item.projectId"
+                                >
+                                    {{ item.projectName }}
+                                </a-select-option>
+                            </a-select>
+                        </a-form-item>
+                    </a-col>
+                    <a-col :span="9">
                         <a-form-item label="日期选择" :labelCol="modalCol" :wrapperCol="modalWrapper">
                             <a-range-picker
                                 v-model="masterTimes"
@@ -265,13 +284,8 @@
                             />
                         </a-form-item>
                     </a-col>
-                    <!-- <a-col :span="9">
-                        <a-form-item label="唯一标识" :labelCol="modalCol" :wrapperCol="modalWrapper">
-                            <a-input v-model="onlyIdentification" placeholder="请输入唯一标识,多个以,隔开"/>
-                        </a-form-item>
-                    </a-col> -->
                     <a-col :span="4">
-                        <a-button style="position: relative;top: 4px;">全选</a-button>
+                        <a-button style="position: relative;top: 4px;" @click="handleAllChecked">全选</a-button>
                         <a-button type="primary" style="position: relative;top: 4px;margin-left:5px" @click="handleSearchMaster">搜索</a-button>
                     </a-col>
                 </a-row>
@@ -326,6 +340,7 @@ export default {
     },
     data() {
         return {
+            projectModelValue: '',
             optimizationOption: [], // 账户option
             controlTypeModel: '1',
             fileList: [],
@@ -410,36 +425,41 @@ export default {
                 {
                     title: '相关创意',
                     align: 'center',
-                    dataIndex: 'creativeCount'
+                    width: 150,
+                    dataIndex: 'count'
                 },
                 {
                     title: '花费(元)',
                     align: 'center',
-                    dataIndex: 'sumCost',
-                    sorter: (a, b) => a.sumCost - b.sumCost
+                    width: 150,
+                    dataIndex: 'cost',
+                    sorter: (a, b) => a.cost - b.cost
                 },
                 {
                     title: '展示数',
-                    dataIndex: 'sumShowMaterial',
+                    dataIndex: 'showNum',
+                    width: 150,
                     align: 'center',
-                    sorter: (a, b) => a.sumShowMaterial - b.sumShowMaterial
+                    sorter: (a, b) => a.showNum - b.showNum
                 },
                 {
                     title: '平均千次展现费用',
                     dataIndex: 'costPerThousandShow',
                     align: 'center',
+                    width: 200,
                     sorter: (a, b) => a.costPerThousandShow - b.costPerThousandShow
                 },
                 {
                     title: '点击数',
-                    dataIndex: 'sumClick',
-                    width: 180,
+                    dataIndex: 'click',
+                    width: 150,
                     align: 'center',
-                    sorter: (a, b) => a.sumClick - b.sumClick
+                    sorter: (a, b) => a.click - b.click
                 },
                 {
                     title: '平均点击单价',
                     dataIndex: 'costPerClick',
+                    width: 150,
                     align: 'center',
                     sorter: (a, b) => a.costPerClick - b.costPerClick
                 },
@@ -452,10 +472,10 @@ export default {
                 },
                 {
                     title: '转化数',
-                    dataIndex: 'sumConvertMaterial',
+                    dataIndex: 'convertNum',
                     align: 'center',
                     width: 150,
-                    sorter: (a, b) => a.sumConvertMaterial - b.sumConvertMaterial
+                    sorter: (a, b) => a.convertNum - b.convertNum
                 },
                 {
                     title: '转化率',
@@ -482,17 +502,20 @@ export default {
                 {
                     title: '相关创意',
                     align: 'center',
+                    width: 150,
                     dataIndex: 'count'
                 },
                 {
                     title: '花费(元)',
                     align: 'center',
+                    width: 150,
                     dataIndex: 'cost',
                     sorter: (a, b) => a.cost - b.cost
                 },
                 {
                     title: '展示数',
                     dataIndex: 'showNum',
+                    width: 150,
                     align: 'center',
                     sorter: (a, b) => a.showNum - b.showNum
                 },
@@ -500,18 +523,20 @@ export default {
                     title: '平均千次展现费用',
                     dataIndex: 'costPerThousandShow',
                     align: 'center',
+                    width: 200,
                     sorter: (a, b) => a.costPerThousandShow - b.costPerThousandShow
                 },
                 {
                     title: '点击数',
                     dataIndex: 'click',
-                    width: 180,
+                    width: 150,
                     align: 'center',
                     sorter: (a, b) => a.click - b.click
                 },
                 {
                     title: '平均点击单价',
                     dataIndex: 'costPerClick',
+                    width: 150,
                     align: 'center',
                     sorter: (a, b) => a.costPerClick - b.costPerClick
                 },
@@ -557,8 +582,7 @@ export default {
             defaultFormList: [],
             titleFiledResult: 0,
             examinForm: this.$form.createForm(this),
-            masterTimes: [], // 选择素材的时间选择
-            onlyIdentification: '' // 唯一标识
+            masterTimes: [] // 选择素材的时间选择
         };
     },
     watch: {
@@ -589,6 +613,9 @@ export default {
     },
     methods: {
         ...mapGetters(['nickname', 'avatar', 'userInfo']),
+        handleAllChecked() {
+            this.viedoCheckValue = this.viedoDefaultList.map(item => item.id);
+        },
         filterOption(input, option) {
             return (
                 option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
@@ -748,34 +775,8 @@ export default {
                 }
             );
         },
-        // handleMd5(file) {
-        //     let bmf = new BMF();
-        //     let that = this;
-        //     return new Promise(function (resolve, reject) {
-        //         bmf.md5(file, (err, md5) => {
-        //             getAction('kuaishouPopulationPackage/checkPopulationPackage', {signature: md5}).then(result => {
-        //                 if (result.code === 200) {
-        //                     that.personNameDisabled = false;
-        //                     that.personResourceDisabled = false;
-        //                     resolve();
-        //                 }
-        //                 else if (result.code === 201) {
-        //                     that.$message.error(result.message);
-        //                     that.personForm.name = result.result.orientationName;
-        //                     that.personForm.resource = result.result.type;
-        //                     that.personNameDisabled = true;
-        //                     that.personResourceDisabled = true;
-        //                     reject();
-        //                 }
-        //             }).catch(error => {
-        //                 console.log(error, 'eeee');
-        //                 reject();
-        //             });
-        //         });
-        //     });
-        // },
         handleSearchMaster() {
-            console.log(this.masterTimes, this.onlyIdentification, '素材的搜索条件');
+            console.log(this.masterTimes, '素材的搜索条件');
         },
         handleSelectTimeChange(date, dateString) {
             this.masterTimes = dateString;
@@ -797,7 +798,6 @@ export default {
         handleCancelAll() {
             this.masterTimes = [];
             this.viedoCheckValue = [];
-            this.onlyIdentification = '';
             this.visibleMatemal = false;
         },
         // 选择素材的确认按钮
@@ -827,32 +827,36 @@ export default {
                 }
             });
             this.$nextTick(() => {
+                const dynamicWordPackIds = [];
                 let finallyLenList = this.handleJudgeExec(this.examinForm.getFieldsValue()[field]);
+                let updateFinallyResult = this.adNameTags.filter(item => finallyLenList.includes(item.name)).map(val => val.name);
                 const inputDefaultLen = this.defaultFormList.filter(item => item.id === formId)[0].value.length;
-                let tagsLen = finallyLenList.length * 4;
+                let tagsLen = updateFinallyResult.length * 2;
                 let tagsSureLen = 0;
                 let resultSelectSize = 0;
                 this.adNameTags.forEach(item => {
-                    finallyLenList.forEach(val => {
+                    updateFinallyResult.forEach(val => {
                         if (item.name === val) {
                             tagsSureLen += item.maxWordLen;
+                            dynamicWordPackIds.push(item.creativeWordId);
                         }
                     });
                 });
-                finallyLenList.forEach(item => {
+                updateFinallyResult.forEach(item => {
                     tagsLen += item.length;
                 });
                 resultSelectSize = inputDefaultLen - tagsLen + tagsSureLen;
                 this.defaultFormList.forEach(item => {
                     if (item.id === formId) {
                         item.lenSize = resultSelectSize;
+                        item.wordPackId = dynamicWordPackIds;
                     }
                 });
                 this.titleFiledResult = changeFiled;
             });
         },
         handleJudgeExec(item) {
-            let re = /\{\{(.+?)\}\}/g;
+            let re = /\{(.+?)\}/g;
             let array = [];
             let temp;
             while ((temp = re.exec(item))) {
@@ -866,36 +870,42 @@ export default {
             let startPos = node.selectionStart; // input 第0个字符到选中的字符
             let endPos = node.selectionEnd; // 选中的字符到最后的字符
             let txt = node.value;
-            let finallyLenList = this.handleJudgeExec(txt);
-            if (finallyLenList.length >= 2) {
-                this.$message.error('最多选择两个词包');
-                return;
-            }
-            if (startPos === 0 || endPos === 0) {
-                txt += '{{' + item + '}}';
-                this.examinForm.setFieldsValue({[field]: txt});
-            }
-            else {
-                this.examinForm.setFieldsValue({[field]: txt.substring(0, startPos) + '{{' + item + '}}' + txt.substring(endPos)});
-                node.selectionStart = startPos + item.length + 6;
-                node.selectionEnd = startPos + item.length + 6;
-            }
-            node.focus();
-            node.blur();
             this.$nextTick(() => {
-                let finallyLenList = this.handleJudgeExec(this.examinForm.getFieldsValue()[field]);
+                let finallyLenList = this.handleJudgeExec(txt);
+                let updateFinallyResult = this.adNameTags.filter(item => finallyLenList.includes(item.name)).map(val => val.name);
+                if (updateFinallyResult.length >= 2) {
+                    this.$message.error('最多选择两个词包');
+                    return;
+                }
+                if (startPos === 0 || endPos === 0) {
+                    txt += '{' + item + '}';
+                    this.examinForm.setFieldsValue({[field]: txt});
+                }
+                else {
+                    this.examinForm.setFieldsValue({[field]: txt.substring(0, startPos) + '{' + item + '}' + txt.substring(endPos)});
+                    node.selectionStart = startPos + item.length + 6;
+                    node.selectionEnd = startPos + item.length + 6;
+                }
+                node.focus();
+                node.blur();
+            });
+            this.$nextTick(() => {
+                const dynamicWordPackIds = [];
+                let changeData = this.handleJudgeExec(this.examinForm.getFieldsValue()[field]);
+                let updateChangeData = this.adNameTags.filter(item => changeData.includes(item.name)).map(val => val.name);
                 const inputDefaultLen = this.examinForm.getFieldsValue()[field].length;
-                let tagsLen = finallyLenList.length * 4;
+                let tagsLen = updateChangeData.length * 2;
                 let tagsSureLen = 0;
                 let resultSelectSize = 0;
                 this.adNameTags.forEach(item => {
-                    finallyLenList.forEach(val => {
+                    updateChangeData.forEach(val => {
                         if (item.name === val) {
                             tagsSureLen += item.maxWordLen;
+                            dynamicWordPackIds.push(item.creativeWordId);
                         }
                     });
                 });
-                finallyLenList.forEach(item => {
+                updateChangeData.forEach(item => {
                     tagsLen += item.length;
                 });
                 resultSelectSize = inputDefaultLen - tagsLen + tagsSureLen;
@@ -903,41 +913,49 @@ export default {
                     if (item.id === formId) {
                         item.lenSize = resultSelectSize;
                         item.value = this.examinForm.getFieldsValue()[field];
+                        item.wordPackId = dynamicWordPackIds;
                     }
                 });
             });
         },
         validatePass(rule, value, callback) {
-            let finallyLenList = this.handleJudgeExec(value);
-            let resultSelectSize = 0;
-            if (finallyLenList.length) {
-                const inputDefaultLen = value.length;
-                let tagsLen = finallyLenList.length * 4;
-                let tagsSureLen = 0;
-                this.adNameTags.forEach(item => {
-                    finallyLenList.forEach(val => {
-                        if (item.name === val) {
-                            tagsSureLen += item.maxWordLen;
-                        }
+            this.$nextTick(() => {
+                let finallyLenList = this.handleJudgeExec(value);
+                let updateFinallyResult = this.adNameTags.filter(item => finallyLenList.includes(item.name)).map(val => val.name);
+                let resultSelectSize = 0;
+                if (updateFinallyResult.length) {
+                    const inputDefaultLen = value.length;
+                    let tagsLen = updateFinallyResult.length * 2;
+                    let tagsSureLen = 0;
+                    this.adNameTags.forEach(item => {
+                        updateFinallyResult.forEach(val => {
+                            if (item.name === val) {
+                                tagsSureLen += item.maxWordLen;
+                            }
+                        });
                     });
-                });
-                finallyLenList.forEach(item => {
-                    tagsLen += item.length;
-                });
-                resultSelectSize = inputDefaultLen - tagsLen + tagsSureLen;
-            }
-            else {
-                resultSelectSize = value.length;
-            }
-            if (resultSelectSize === 0) {
-                callback(new Error('请输入, 创意标题5-30个字'));
-            }
-            else if (resultSelectSize > 30 || resultSelectSize < 5) {
-                callback(new Error('创意标题5-30个字'));
-            }
-            else {
-                callback();
-            }
+                    updateFinallyResult.forEach(item => {
+                        tagsLen += item.length;
+                    });
+                    resultSelectSize = inputDefaultLen - tagsLen + tagsSureLen;
+                }
+                else {
+                    resultSelectSize = value.length;
+                }
+                // {地点}{日3期}{运8营商}{考3{区县}试}{节11555日}
+                if (resultSelectSize === 0) {
+                    callback(new Error('请输入'));
+                }
+                else if (resultSelectSize > 30 || resultSelectSize < 5) {
+                    callback(new Error('创意标题5-30个字'));
+                }
+                else if (updateFinallyResult.length > 2) {
+                    callback(new Error('最多选择两个词包'));
+                }
+                else {
+                    callback();
+                }
+            });
         },
         handleMoreTagsShow(val, type) {
             if (type === 'more') {