Browse Source

文案库页面开发管理

jiayufei 4 years ago
parent
commit
f22bb8c927
1 changed files with 143 additions and 39 deletions
  1. 143 39
      src/views/modules/copy-library/copy-library.vue

+ 143 - 39
src/views/modules/copy-library/copy-library.vue

@@ -94,6 +94,21 @@
                         </div>
                     </div>
                 </div>
+                <div v-if="copywrittypeName === 'horizontal'" class="acount-title">
+                    <div class="acount-title-left">文件上传</div>
+                    <div class="acount-title-right">
+                        <div class="only-title-mater">
+                            <a-upload
+                                name="file"
+                                :file-list="fileList"
+                                :before-upload="beforeUpload"
+                                @change="handleChange"
+                            >
+                                <a-button><a-icon type="upload" />文件上传</a-button>
+                            </a-upload>
+                        </div>
+                    </div>
+                </div>
                 <div v-if="copywrittypeName === 'vertical'" class="acount-title">
                     <div class="acount-title-left">选择素材</div>
                     <div class="acount-title-right">
@@ -187,24 +202,28 @@
                 <div class="viedo-header-class">
                     <div></div>
                     <div> 
-                        当前选择数量 1/{{ materTotalAll }}
+                        当前选择数量 {{ viedoCheckValue.length }}/{{ materTotalAll }}
                         <a-button type="primary" class="refush-btn-mat">刷新素材</a-button>
                     </div>
                 </div>
                 <a-row class="viedo-serach-class" :gutter="24">
                     <a-col :span="9">
                         <a-form-item label="日期选择" :labelCol="modalCol" :wrapperCol="modalWrapper">
-                            <a-range-picker name="buildTime"/>
+                            <a-range-picker
+                                v-model="masterTimes"
+                                format="YYYY-MM-DD"
+                                @change="handleSelectTimeChange"
+                            />
                         </a-form-item>
                     </a-col>
                     <a-col :span="9">
                         <a-form-item label="唯一标识" :labelCol="modalCol" :wrapperCol="modalWrapper">
-                            <a-input placeholder="请输入唯一标识,多个以,隔开"/>
+                            <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 type="primary" style="position: relative;top: 4px;margin-left:5px">搜索</a-button>
+                        <a-button type="primary" style="position: relative;top: 4px;margin-left:5px" @click="handleSearchMaster">搜索</a-button>
                     </a-col>
                 </a-row>
                 <div class="viedo-content-class">
@@ -243,6 +262,12 @@ import {fileCheck, fileEdit, fileEditAll, fileInsertV2, fileEditUpdate, fileEdit
 import {mapGetters} from 'vuex';
 import {urlAcount} from './account-config-server.js';
 
+let COS = require('cos-js-sdk-v5');
+let cos = new COS({
+    SecretId: 'AKIDE6IpMi8fJQRCg1iuWzFajjRs43kbbets',
+    SecretKey: 'tXzuwMfplTTK3c9GFUyETilasvQfePu9'
+});
+
 export default {
     name: 'copy-library',
     components: {
@@ -250,53 +275,43 @@ export default {
     },
     data() {
         return {
-            modalSelectMaterial: [
-                {
-                    name: '北京市去',
-                    id: 1,
-                    statDate: '2019-08-08'
-                },
-                {
-                    name: '素材视频',
-                    id: 2,
-                    statDate: '2019-08-08'
-                },
-            ],
+            fileList: [],
+            modalSelectMaterial: [],
             materTotalAll: 0,
             viedoCheckValue: [],
             viedoDefaultList: [
                 {
-                    name: '1123',
+                    name: '北京市',
                     id: 1,
                     statDate: '2019-08-08'
                 },
                 {
-                    name: '1123',
+                    name: '上海市',
                     id: 2,
                     statDate: '2019-08-08'
                 },
                 {
-                    name: '1123',
+                    name: '天津市',
                     id: 3,
                     statDate: '2019-08-08'
                 },
                 {
-                    name: '1123',
+                    name: '武汉市',
                     id: 4,
                     statDate: '2019-08-08'
                 },
                 {
-                    name: '1123',
+                    name: '贵州市',
                     id: 5,
                     statDate: '2019-08-08'
                 },
                 {
-                    name: '1123',
+                    name: '太原市',
                     id: 6,
                     statDate: '2019-08-08'
                 },
                 {
-                    name: '1123',
+                    name: '大同市',
                     id: 7,
                     statDate: '2019-08-08'
                 }
@@ -409,7 +424,9 @@ export default {
             },
             defaultFormList: [],
             titleFiledResult: 0,
-            examinForm: this.$form.createForm(this)
+            examinForm: this.$form.createForm(this),
+            masterTimes: [], // 选择素材的时间选择
+            onlyIdentification: '' // 唯一标识
         };
     },
     watch: {
@@ -438,6 +455,97 @@ export default {
     },
     methods: {
         ...mapGetters(['nickname', 'avatar', 'userInfo']),
+        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);
+                }
+            );
+        },
+        // 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, '素材的搜索条件');
+        },
+        handleSelectTimeChange(date, dateString) {
+            this.masterTimes = dateString;
+        },
         handleDelAlone(data) {
             this.modalSelectMaterial = this.modalSelectMaterial.filter(item => item.id !== data.id);
         },
@@ -448,29 +556,25 @@ export default {
             };
         },
         handleSelectMaterial() {
-            console.log('选择素材');
             this.visibleMatemal = true;
         },
         // 选择素材的取消按钮
         handleCancelAll() {
-            // this.checkVideoAll = []
-            // this.checkVideoWei = []
+            this.masterTimes = [];
+            this.viedoCheckValue = [];
+            this.onlyIdentification = '';
             this.visibleMatemal = false;
-            this.md5Str = '';
         },
         // 选择素材的确认按钮
         handleOkShow() {
-            // this.checkVideoAll = [...new Set(this.checkVideoAll)]
-            // var data = tqFun(this.checkVideoAll).concat(tqFun(this.checkVideoWai))
-            // this.checkVideo = data
-            // // console.log(this.checkVideoAll, this.checkVideo)
-            // for (let i = 0; i < this.checkVideo.length; i++) {
-            //     this.setVideUrl(this.checkVideo[i])
-            //     if (i == this.checkVideo.length - 1) {
-            //     this.showVideo = true
-            //     this.visibleMatemal = false
-            //     }
-            // }
+           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;