瀏覽代碼

人群包管理 上传 新增 MD5校验

jiayufei 4 年之前
父節點
當前提交
1cb9fa4408

+ 4 - 3
src/views/modules/crowd-control/components/tree-select/tree-select.less

@@ -10,13 +10,14 @@
         .class-left-header {
             height: 50px;
             line-height: 50px;
-            background-color: #ccc;
+            background-color: #f9fafd;
+            border-bottom: 1px solid #eee;
             text-indent: 10px;
         }
         .select-class-left {
             width: 60%;
             height: 400px;
-            border: 1px solid #ccc;
+            border: 1px solid #eee;
             .class-left-content {
                 overflow-y: auto;
                 height: 340px;
@@ -29,7 +30,7 @@
         .select-class-right {
             width: 35%;
             height: 400px;
-            border: 1px solid #ccc;
+            border: 1px solid #eee;
             .class-left-content {
                 padding: 0 10px;
                 height: 348px;

+ 40 - 8
src/views/modules/crowd-control/components/tree-select/tree-select.vue

@@ -126,14 +126,21 @@ export default {
             }
             this.applyTypeOption = defaultTypeOption;
             this.selectRightData = new Set(defaultTypeOption);
-            for(let i = keysLen - 1; i >= 0; i--) {
-                if(defaultCheckKey[i] === list.key) {
-                    defaultCheckKey.splice(i, 1);
-                }
-            }
             const txt = this.handleDelFindId(this.treeData, list.key);
             const lastIndex = defaultCheckKey.findIndex(item => item === txt);
-            defaultCheckKey.splice(lastIndex, 1);
+            let value = null;
+            if (lastIndex > -1) {
+                value = defaultCheckKey.findIndex(item => item === txt);
+                for(let i = keysLen - 1; i >= 0; i--) {
+                    if(defaultCheckKey[i] === list.key) {
+                        defaultCheckKey.splice(i, 1);
+                    }
+                }
+            }
+            else {
+                value = defaultCheckKey.findIndex(item => item === list.key);
+            }
+            defaultCheckKey.splice(value, 1);
             this.checkedKeys = defaultCheckKey;
         },
         onChange(e) {
@@ -203,10 +210,31 @@ export default {
             this.expandedKeys = expandedKeys;
             this.autoExpandParent = false;
         },
+        // 去重的方法
+        Es6duplicate(arr, type) {
+            if (!arr.length){
+                return arr;
+            }
+            else {
+                if (type) {
+                    let obj = {};
+                    let newArr = arr.reduce((cur, next) => {
+                        obj[next.key] ? '' : obj[next.key] = true && cur.push(next);
+                        return cur;
+                    }, []);
+                    return newArr;
+                }
+                else {
+                    return Array.from(new Set(arr));
+                }
+            }
+        },
         onCheck(checkedKeys) {
+            this.checkedKeys = checkedKeys;
             this.nodes(this.treeData, checkedKeys);
-            this.applyTypeOption = [...this.selectRightData];
-            const changeSelectData = [...this.selectRightData].map(item => item.key);
+            this.applyTypeOption = this.Es6duplicate([...this.selectRightData], 'key');
+            const changeSelectData = this.applyTypeOption.map(item => item.key);
+            this.checkedKeys = changeSelectData;
             if (this.applyTypeOption.length > 100) {
                 const lastOptionKey = this.applyTypeOption[99].key;
                 const lastIndex = changeSelectData.findIndex(item => item === lastOptionKey);
@@ -216,6 +244,10 @@ export default {
             this.$emit('applyType', this.applyTypeOption);
         },
         nodes(data, checkedKeys) {
+            if (!checkedKeys.length) {
+                this.selectRightData = new Set();
+                return;
+            }
             data.forEach(item => {
                 if (item.children) {
                     this.nodes(item.children, checkedKeys);

+ 10 - 5
src/views/modules/crowd-control/crowd-control-service.js

@@ -7,22 +7,27 @@ class AppMarketService {
     constructor() {}
 
     // 相关账户的table列表
-    setAcountColumns() {
+    setAcountColumns(data) {
         return [
             {
-                title: '项目名称',
+                title: '账户名称',
                 dataIndex: 'accountName',
-                width: '35%'
+                width: '30%'
             },
             {
-                title: '所属项目',
+                title: '所属账户',
                 dataIndex: 'projectName',
-                width: '35%'
+                width: '30%'
             },
             {
                 title: '人群包数量',
                 dataIndex: 'count',
                 width: '20%'
+            },
+            {
+                title: '状态',
+                dataIndex: 'statusStr',
+                width: '20%'
             }
         ]
     }

+ 54 - 15
src/views/modules/crowd-control/crowd-control.vue

@@ -58,7 +58,7 @@
                 :pagination="false"
             >
                 <span slot="action" slot-scope="text, record">
-                    <a @click="handleEdit(record)">推送</a>
+                    <a @click="handleEdit(record)" :disabled="record.status !== 4">推送</a>
                     <a-divider type="vertical" />
                     <a @click="handleDelete(record)">删除</a>
                 </span>
@@ -101,7 +101,7 @@
                     :wrapper-col="wrapperCol"
                 >
                     <a-form-model-item label="匹配类型" prop="resource">
-                        <a-radio-group v-model="personForm.resource">
+                        <a-radio-group v-model="personForm.resource" :disabled="personResourceDisabled">
                             <a-radio v-for="item in mateTypeTasks" :key="item.label" :value="item.label">{{ item.value }}</a-radio>
                         </a-radio-group>
                     </a-form-model-item>
@@ -109,6 +109,7 @@
                         <a-input
                             v-model="personForm.name"
                             placeholder="请输入人群包名称"
+                            :disabled="personNameDisabled"
                         />
                     </a-form-model-item>
                     <a-form-model-item label="选择账户">
@@ -157,7 +158,7 @@
             </div>
         </a-modal>
         <a-modal
-            title="相关项目"
+            title="失败原因"
             v-if="causeVisible"
             :visible="causeVisible"
             :confirm-loading="causeConfirmLoading"
@@ -178,7 +179,7 @@
             </div>
         </a-modal>   
         <a-modal
-            title="相关项目"
+            :title="relaxStatus === 'dep' ? '相关项目' : '相关账户'"
             v-if="relaxVisible"
             :visible="relaxVisible"
             :confirm-loading="relaxConfirmLoading"
@@ -211,6 +212,7 @@ import TreeSelect from './components/tree-select/tree-select';
 import {getAction, postAction} from '@/api/manage';
 import AcountSearch from '@/views/modules/Statistics/components/Treeselect.vue';
 import AppMarketService from './crowd-control-service';
+import BMF from 'browser-md5-file';
 
 let COS = require('cos-js-sdk-v5');
 let cos = new COS({
@@ -226,6 +228,8 @@ export default {
     data() {
         let that = this;
         return {
+            personResourceDisabled: false,
+            personNameDisabled: false,
             totalAllCause: 0,
             acountId: undefined, // 搜索的账户ID
             uploadAcountIds: '',
@@ -388,6 +392,7 @@ export default {
                 onOk() {
                     getAction('/kuaishouCrowdPack/delete', {id: data.id}).then(result => {
                         if (result.code === 200) {
+                            this.$message.success('删除成功');
                             this.handleGetTableList({});
                         }
                         else {
@@ -490,19 +495,35 @@ export default {
             this.pushVisible = false;
         },
         beforeUpload(file) {
-            const isZip = file.type.includes('zip') || file.type.includes('text');
-            const fileOvesize = file.size > (1024 * 1024 * 1024);
-            if (!isZip) {
-                this.fileList = [];
-                this.$message.error('只能上传zip格式的文件或者txt文件');
-                return false;
-            }
-            if (fileOvesize) {
-                this.$message.error('文件大小不能超过1G');
-                return;
-            }
             this.cosUpload(file);
         },
+        handleMd5(file) {
+            let bmf = new BMF();
+            let that = this;
+            return new Promise(function (resolve, reject) {
+                bmf.md5(file, (err, md5) => {
+                    getAction('/kuaishouCrowdPack/checkCrowdPackage', {signature: md5}).then(result => {
+                        if (result.code === 200) {
+                            that.$message.warning('人群包不存在,允许输入人群包名');
+                            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();
+                    });
+                })
+            })
+        },
         handleChange(info) {
             this.fileList = info.fileList;
         },
@@ -553,6 +574,17 @@ export default {
                     if (that.fileList.length > 1) {
                         that.fileList = that.fileList.slice(-1);
                     }
+                    const isZip = file.type.includes('zip') || file.type.includes('text');
+                    const fileOvesize = file.size > (1024 * 1024 * 1024);
+                    if (!isZip) {
+                        that.$message.error('只能上传zip格式的文件或者txt文件');
+                        return;
+                    }
+                    if (fileOvesize) {
+                        that.$message.error('文件大小不能超过1G');
+                        return;
+                    }
+                    that.handleMd5(file);
                 }
             );
         },
@@ -597,7 +629,11 @@ export default {
             postAction('/kuaishouCrowdPack/uploadCrowdPack', paramsData).then(result => {
                 if (result.code === 200) {
                     this.personVisible = false;
+                    this.personResourceDisabled = false;
+                    this.personNameDisabled = false;
+                    this.$message.error('上传成功');
                     this.handleGetTableList({});
+                    this.fileList = [];
                 }
                 else {
                     this.$message.error(result.message);
@@ -608,8 +644,11 @@ export default {
         },
         handleCancel() {
             this.personVisible = false;
+            this.personResourceDisabled = false;
+            this.personNameDisabled = false;
             this.$refs.ruleForm.resetFields();
             this.uploadAcountIds = '';
+            this.fileList = [];
         }
     }
 };

+ 1 - 1
src/views/modules/stockWatch/modules/keep-person/keep-person.vue

@@ -9,7 +9,7 @@
                         <span>今日消耗:</span>
                         <span>1000000</span>
                         <span class="left-title-radio"><img class="title-radio-img" src="@/assets/up.png" alt="">10.765%</span>
-                        <!-- TODO 这个是下降的样式,后续优化 -->
+                        <!-- TODO 这个是下降的样式,后续优化  -->
                         <!-- <span class="left-title-radio-down"><img class="title-radio-img" src="@/assets/down.png" alt="">10.765%</span> -->
                     </div>
                 </div>