jiayufei преди 4 години
родител
ревизия
2e7080144d
променени са 2 файла, в които са добавени 108 реда и са изтрити 89 реда
  1. 11 1
      src/api/manage.js
  2. 97 88
      src/views/modules/copy-library/copy-library.vue

+ 11 - 1
src/api/manage.js

@@ -20,7 +20,17 @@ export function postNoCacheAction(url, parameter) {
     }
   })
 }
-
+//post---文件
+export function postFileAction(url,parameter) {
+  return axios({
+    headers: {
+      'Content-Type': 'multipart/form-data'
+    },
+    url: url,
+    method:'post' ,
+    data: parameter
+  })
+}
 //post
 export function postAction(url,parameter) {
   return axios({

+ 97 - 88
src/views/modules/copy-library/copy-library.vue

@@ -149,11 +149,11 @@
                         <div class="only-title-mater">
                             <a-upload
                                 name="file"
+                                action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
                                 :file-list="fileList"
-                                :before-upload="beforeUpload"
                                 @change="handleChange"
                             >
-                                <a-button><a-icon type="upload" />文件上传</a-button>
+                                <a-button><a-icon type="upload"/>文件上传</a-button>
                             </a-upload>
                         </div>
                     </div>
@@ -252,7 +252,7 @@
                     <div></div>
                     <div> 
                         当前选择数量 {{ viedoCheckValue.length }}/{{ materTotalAll }}
-                        <a-button type="primary" class="refush-btn-mat">刷新素材</a-button>
+                        <a-button type="primary" class="refush-btn-mat" @click="handleRefreshMaster">刷新素材</a-button>
                     </div>
                 </div>
                 <a-row class="viedo-serach-class" :gutter="24">
@@ -322,7 +322,7 @@
 <script>
 import AcountSearch from '@/views/modules/Statistics/components/Treeselect.vue';
 
-import {getAction, putAction, deleteAction} from '@/api/manage';
+import {getAction, postFileAction, postAction} from '@/api/manage';
 import {fileCheck, fileEdit, fileEditAll, fileInsertV2, fileEditUpdate, fileEditUpdateBatch} from '@/api/actor';
 import {mapGetters} from 'vuex';
 import {urlAcount} from './copy-library-server.js';
@@ -613,6 +613,12 @@ export default {
     },
     methods: {
         ...mapGetters(['nickname', 'avatar', 'userInfo']),
+        handleRefreshMaster() {
+            this.projectModelValue = '';
+            this.masterTimes = [];
+            this.viedoCheckValue = [];
+            this.hendleMaterialInfo();
+        },
         handleAllChecked() {
             this.viedoCheckValue = this.viedoDefaultList.map(item => item.id);
         },
@@ -635,6 +641,7 @@ export default {
         },
         hendleMaterialInfo() {
             const paramsData = {
+                peojectId: this.projectModelValue,
                 startDate: this.masterTimes[0],
                 endDate: this.masterTimes[1],
                 pageNo: this.masterPag.page,
@@ -717,66 +724,10 @@ export default {
             });
         },
         handleChange(info) {
-            console.log(info, 'info---info');
             this.fileList = info.fileList;
         },
-        beforeUpload(file) {
-            this.cosUpload(file);
-        },
-        cosUpload(file) {
-            let that = this;
-            let date = new Date();
-            let y = date.getFullYear();
-            let MM = date.getMonth() + 1;
-            MM = MM < 10 ? '0' + MM : MM;
-            let d = date.getDate();
-            d = d < 10 ? '0' + d : d;
-            let timeElse = new Date().getTime();
-            let arr = file.name.split('.');
-            let str = '';
-            for (let i = 0; i < arr.length; i++) {
-                if (i === arr.length - 1) {
-                }
-                else {
-                    if (i === arr.length - 2) {
-                        str += arr[i];
-                    }
-                    else {
-                        str += arr[i] + '.';
-                    }
-                }
-            }
-            cos.putObject(
-                {
-                    Bucket: 'media-1301855440',
-                    Region: 'ap-chongqing',
-                    // 存储桶所在地域,必须字段
-                    Key: that.uploadType + '/' + y + '-' + MM + '-' + d + '/' + str + '-' + timeElse + '.' + arr[arr.length - 1],
-                    StorageClass: 'STANDARD',
-                    Body: file // 上传文件对象
-                },
-                function (err, data) {
-                    if (err) {
-                        that.$message.error('上传失败!!!' + err);
-                        return;
-                    }
-                    that.loadingElse = false;
-                    that.fileList.push({
-                        uid: file.name,
-                        name: file.name,
-                        status: 'done',
-                        url: '//' + data.Location
-                    });
-                    if (that.fileList.length > 1) {
-                        that.fileList = that.fileList.slice(-1);
-                    }
-                    console.log(that.fileList, '----------');
-                    // that.handleMd5(file);
-                }
-            );
-        },
         handleSearchMaster() {
-            console.log(this.masterTimes, '素材的搜索条件');
+            this.hendleMaterialInfo();
         },
         handleSelectTimeChange(date, dateString) {
             this.masterTimes = dateString;
@@ -802,17 +753,40 @@ export default {
         },
         // 选择素材的确认按钮
         handleOkShow() {
-           const defaultList = this.viedoDefaultList;
-           const defaultCheckValue = this.viedoCheckValue;
-           this.modalSelectMaterial = defaultList.filter(item => {
-               if (defaultCheckValue.includes(item.id)) {
-                   return item;
-               }
-           });
-           this.handleCancelAll();
+            const defaultList = this.viedoDefaultList;
+            const defaultCheckValue = this.viedoCheckValue;
+            this.modalSelectMaterial = defaultList.filter(item => {
+                if (defaultCheckValue.includes(item.id)) {
+                    return item;
+                }
+            });
+            this.handleCancelAll();
         },
         handleFormLayoutChange(e) {
-            this.copywrittypeName = e.target.value;
+            const defaultValue = e.target.value;
+            this.copywrittypeName = defaultValue;
+            if (defaultValue === 'horizontal') {
+                this.modalSelectMaterial = [];
+                this.defaultFormList = [];
+                this.$nextTick(() => {
+                    for (let i = 0; i < 3; i++) {
+                        const randomNum = new Date().getTime() + Math.ceil(Math.random() * 1000);
+                        this.defaultFormList.push({
+                            id: randomNum,
+                            name: 'username' + randomNum,
+                            value: '',
+                            lenSize: 0,
+                            tabStatus: 'alone',
+                            defaultTagsList: this.adNameTags,
+                            updateTagsList: this.adNameTags.slice(0, 4)
+                        });
+                    }
+                });
+            }
+            else if (defaultValue === 'vertical') {
+                this.advertisingAccount = '';
+                this.fileList = [];
+            }
         },
         handleFormInputChang(e, field, formId) {
             const changeFiled = [];
@@ -973,7 +947,29 @@ export default {
                 });
             }
         },
-        handleCauseSure() {
+        handleUploadWxecl() {
+            let paramsData = new FormData()
+            paramsData.append('accountId', this.advertisingAccount);
+            paramsData.append('excelFile', this.fileList[0].originFileObj);
+            postFileAction(urlAcount + '/bytedance-api/advertiser/bytedanceGeneralCopywriter/loadExcel', paramsData, {
+                headers: {
+                    'Content-Type': 'multipart/form-data'
+                }
+            }).then(result => {
+                if (result.code === 0) {
+                    this.$message.success(result.message);
+                    this.controlTypeModel = '1';
+                    this.handleCauseCancel();
+                    this.handleGetCurrencyList();
+                }
+                else {
+                    this.$message.error(result.message);
+                }
+            }).catch(error => {
+                console.log(error, 'eeee');
+            });
+        },
+        handleVerticalAdd() {
             if (this.defaultFormList && this.defaultFormList.length < 3) {
                 this.$message.error('请至少输入3条标题');
                 return;
@@ -981,33 +977,46 @@ export default {
             let changeSlogan = this.defaultFormList;
             changeSlogan.forEach(item => {
                 item.title = item.value;
-                item.creative_word_ids = [];
+                item.creative_word_ids = item.wordPackId;
             });
-            // let params = {
-            //     id: this.currentPageOnlyList.id,
-            //     auditorId: this.userInfo().id,
-            //     status: 1,
-            //     slogans: changeSlogan
-            // };
+            let paramsData = {
+                materialIds: this.modalSelectMaterial.map(item => item.id),
+                userId: this.userInfo().id,
+                slogans: changeSlogan
+            };
             this.examinForm.validateFields(err => {
                 if (!err) {
-                    // fileEditUpdate(params).then(res => {
-                    //     if (res.code === 200) {
-                    //         this.refuseReason = '';
-                    //         this.causeVisible = false;
-                    //         this.defaultFormList = [];
-                    //         this.$message.success('审核成功');
-                    //         this.loadData();
-                    //     }
-                        
-                    // });
+                    postAction(urlAcount + '/bytedance-api/ctop/bytedanceVideoSlogenInfo/addList', paramsData).then(result => {
+                        if (result.code === 0) {
+                            this.$message.success(result.message);
+                            this.controlTypeModel = '1';
+                            this.handleCauseCancel();
+                            this.handleGetCurrencyList();
+                        }
+                        else {
+                            this.$message.error(result.message);
+                        }
+                    }).catch(error => {
+                        console.log(error, 'eeee');
+                    });
                 }
             });
         },
+        handleCauseSure() {
+            if (this.copywrittypeName === 'horizontal') {
+                this.handleUploadWxecl();
+            }
+            else if (this.copywrittypeName === 'vertical') {
+                this.handleVerticalAdd();
+            }
+        },
         handleCauseCancel() {
             this.copywrittypeName = 'horizontal';
+            this.advertisingAccount = '';
+            this.fileList = [];
             this.causeVisible = false;
             this.defaultFormList = [];
+            this.modalSelectMaterial = [];
         },
         handleGetCreativeWord() {
             getAction('/ctop/ByteDanceCreativeWordPackage/list').then(result => {