浏览代码

素材认证方法修改

zhuxinbo 5 年之前
父节点
当前提交
d1f8adcc81

+ 19 - 12
src/views/modules/advertiser/UserAllocationList.vue

@@ -61,7 +61,8 @@
     <!--  添加项目成员 -->
     <a-modal title="项目绑定" v-model="visibleAdd" @ok="handleOkAdd" :confirmLoading="confirmLoading">
       <!-- /sys/user/getAllUserList -->
-      <a-select
+      <treeSelect ref="treeSelect" :appId.sync="projectId" :multiple="false" :mediaId="mediaId" style="width:100%" />
+      <!-- <a-select
         v-model="projectId"
         placeholder="请输入项目名称"
         showSearch
@@ -72,7 +73,7 @@
         <a-select-option :value="item.id" v-for="item of options" :key="item.id">
           {{ item.projectName }}
         </a-select-option>
-      </a-select>
+      </a-select> -->
     </a-modal>
   </a-card>
 </template>
@@ -82,11 +83,15 @@ import UserAllocationModal from './modules/UserAllocationModal'
 import { JeecgListMixin } from '@/mixins/JeecgListMixin'
 import { mapGetters } from 'vuex'
 import { httpAction, getAction, deleteAction } from '@/api/manage'
+
+import treeSelect from './modules/Treeselect'
+
 export default {
   name: 'UserAllocationList',
   mixins: [JeecgListMixin],
   components: {
-    UserAllocationModal
+    UserAllocationModal,
+    treeSelect
   },
   data() {
     return {
@@ -157,7 +162,8 @@ export default {
       },
       confirmLoading: false,
       projectId: '',
-      accountId: ''
+      accountId: '',
+      mediaId: ''
     }
   },
   computed: {
@@ -174,14 +180,15 @@ export default {
       console.log(item)
       this.visibleAdd = true
       this.accountId = item.accountId
-      getAction('/ctop/project/getProjectByCompany', { userId: this.userInfo().id, mediaId: item.mediaId }).then(
-        res => {
-          console.log(res)
-          if (res.success) {
-            this.options = res.result
-          }
-        }
-      )
+      this.$refs.treeSelect.getParticipateList(item.mediaId)
+      //   getAction('/ctop/project/getProjectByCompany', { userId: this.userInfo().id, mediaId: item.mediaId }).then(
+      //     res => {
+      //       console.log(res)
+      //       if (res.success) {
+      //         this.options = res.result
+      //       }
+      //     }
+      //   )
     },
     handleOkAdd(e) {
       var params = {}

+ 153 - 0
src/views/modules/advertiser/modules/Treeselect.vue

@@ -0,0 +1,153 @@
+<style lang="scss" scoped>
+.select-project {
+  width: 50%;
+}
+</style>
+<template>
+  <div class="select-project">
+    <treeselect
+      :multiple="multiple"
+      :disable-branch-nodes="!multiple"
+      :options="options"
+      :load-options="loadOptions"
+      placeholder="请选择项目"
+      v-model="value"
+      :value-consists-of="valueConsistsOf"
+      @select="update"
+      @input="emitValue"
+      :limit="2"
+      :limitText="
+        count => {
+          return '隐藏' + count + '条'
+        }
+      "
+      noChildrenText="该广告主下暂无项目"
+      noOptionsText="暂无项目"
+    />
+  </div>
+</template>
+
+<script>
+// import the component
+import Treeselect from '@riophae/vue-treeselect'
+// import the styles
+import '@riophae/vue-treeselect/dist/vue-treeselect.css'
+import { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
+
+import { getAction, postAction } from '@/api/manage'
+import { mapGetters } from 'vuex'
+// We just use `setTimeout()` here to simulate an async operation
+// instead of requesting a real API server for demo purpose.
+
+export default {
+  data: () => ({
+    value: null,
+    valueConsistsOf: 'LEAF_PRIORITY',
+    options: [],
+    mediaId: ''
+  }),
+  props: {
+    multiple: {
+      type: Boolean,
+      default() {
+        return true
+      }
+    },
+    appId: {}
+  },
+  components: { Treeselect },
+  watch: {
+    $route(n, o) {},
+    appId: {
+      handler(n, o) {
+        console.log(n)
+        if (n.length == 0) {
+          if (this.multiple) {
+            this.value = []
+          } else {
+            this.value = ''
+          }
+        }
+      },
+      deep: true
+    }
+  },
+  methods: {
+    ...mapGetters(['nickname', 'avatar', 'userInfo']),
+    update(node, id) {
+      console.log(node, id)
+
+      getAction('/ctop/project/getProjectByAdvertiserAndMediaId', {
+        advertiserId: node.id,
+        mediaId: this.mediaId
+      }).then(res => {
+        console.log(res)
+        if (res.code == 0) {
+          if (res.result.length > 0) {
+            node.children = res.result.map(item => {
+              return {
+                id: item.id,
+                label: item.projectName
+              }
+            })
+          } else {
+          }
+        } else {
+          new Error('Failed to load options: network error.')
+        }
+      })
+    },
+    emitValue() {
+      this.$emit('update:appId', this.value)
+    },
+    getChildren() {},
+    loadOptions({ action, parentNode, callback }) {
+      // Typically, do the AJAX stuff here.
+      // Once the server has responded,
+      // assign children options to the parent node & call the callback.
+      if (action === LOAD_CHILDREN_OPTIONS) {
+        getAction('/ctop/project/getProjectByAdvertiserAndMediaId', {
+          advertiserId: parentNode.id,
+          mediaId: this.mediaId
+        }).then(res => {
+          console.log(res)
+          if (res.code == 0) {
+            if (res.result.length > 0) {
+              parentNode.children = res.result.map(item => {
+                return {
+                  id: item.id,
+                  label: item.projectName
+                }
+              })
+              callback()
+            } else {
+              parentNode.children = []
+              callback()
+            }
+          } else {
+            callback(new Error('Failed to load options: network error.'))
+          }
+        })
+      }
+    },
+    getParticipateList(mediaId) {
+      this.mediaId = mediaId
+      this.value = null
+      getAction('/ctop/advertiser/getAdvertiserByCompany', { userId: this.userInfo().id }).then(res => {
+        console.log(res)
+        if (res.code == 0) {
+          this.options = res.result.map(item => {
+            return {
+              id: item.id,
+              label: item.name,
+              children: null
+            }
+          })
+        }
+      })
+    }
+  },
+
+  mounted() {}
+}
+</script>

+ 11 - 2
src/views/modules/material/materialList.vue

@@ -390,7 +390,13 @@ a {
             </a-select-option>
           </a-select>
         </a-form-item>
-        <a-form-item :label-col="labelCol" :wrapper-col="wrapperCol" label="图片素材上传" class="add-image-material">
+        <a-form-item
+          :label-col="labelCol"
+          :wrapper-col="wrapperCol"
+          label="图片素材上传"
+          class="add-image-material"
+          v-if="getData('projectId')"
+        >
           <upload-to-ali
             style="width:160%"
             v-model="urlList.url"
@@ -1163,7 +1169,7 @@ export default {
             //   that.urlList.name.push(file[0].name)
             //   that.urlList.md5.push(md5)
 
-            fileCheck({ code: md5 }).then(res => {
+            fileCheck({ code: md5, projectId: that.getData('projectId') }).then(res => {
               if (res.code == 0) {
                 that.$message.error('此素材已经上传')
                 reject()
@@ -1176,6 +1182,9 @@ export default {
         }
       })
     },
+    getData(className) {
+      return this.form.getFieldValue(className)
+    },
     fileWater(file) {
       var bmf = new BMF()
       var that = this

+ 8 - 2
src/views/modules/material/videoMaterial.vue

@@ -419,13 +419,16 @@ a {
               { rules: [{ required: true, message: '请选择项目!' }] }
             ]"
             @change="getProjectId"
+            showSearch
+            optionFilterProp="children"
+            :filterOption="filterOption"
           >
             <a-select-option :value="item.projectId" v-for="item of dataElse" :key="item.id">
               {{ item.projectName }}
             </a-select-option>
           </a-select>
         </a-form-item>
-        <a-form-item :label-col="labelCol" :wrapper-col="wrapperCol" label="视频素材上传">
+        <a-form-item :label-col="labelCol" :wrapper-col="wrapperCol" label="视频素材上传" v-if="getData('projectId')">
           <upload-to-ali
             v-model="urlList.url"
             :customDomain="customDomain"
@@ -876,6 +879,9 @@ export default {
     }
   },
   methods: {
+    getData(className) {
+      return this.form.getFieldValue(className)
+    },
     deleteData(id) {
       deleteAction('/ctop/materialInfo/delete', { id: id }).then(res => {
         if (res.success) {
@@ -1250,7 +1256,7 @@ export default {
         bmf.md5(file[0], (err, md5) => {
           that.urlList.name = file[0].name
           that.urlList.md5 = md5
-          fileCheck({ code: md5 }).then(res => {
+          fileCheck({ code: md5, projectId: that.getData('projectId') }).then(res => {
             if (res.code == 0) {
               that.$message.error('此素材已经上传')
               that.repeat = true