瀏覽代碼

修改bug

yumeng 1 天之前
父節點
當前提交
116a8d6383

+ 23 - 14
src/views/modules/advertiser/AdvertiserList.vue

@@ -12,11 +12,10 @@
                 v-model="allIdUser"
                 placeholder="请选择广告主开户主体名称"
                 @keyup.enter.native="searchQueryOne"
-                @focus="getList"
+                @focus="loadAdvertiserOptions"
                 showSearch
-                optionFilterProp="children"
-                :filterOption="filterOption"
-                @search="getList"
+                :filterOption="false"
+                @search="searchAdvertiserOptions"
               >
                 <a-select-option :value="item.id" v-for="(item, index) of list" :key="index">
                   {{ item.name }}
@@ -432,23 +431,24 @@ export default {
   },
   created() {
     this.queryParam.userId = this.userInfo().id
-    this.getList(null)
+    this.loadAdvertiserOptions()
   },
   methods: {
     filterOption(input, option) {
       return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
     },
-    getList(value) {
-      var params = {}
-      // params.userId = this.userInfo().id
-      params.pageSize = 50
-      params.pageNo = 1
-      params.name = value
-      console.log(params)
+    loadAdvertiserOptions(value = '') {
+      const params = {
+        pageSize: 50,
+        pageNo: 1,
+        userId: this.userInfo().id,
+      }
+      if (value) {
+        params.name = value
+      }
       getAction('/ctop/advertiser/list', params)
         .then((res) => {
           if (res.success) {
-            console.log(res)
             this.list = res.result.records
           } else {
             this.$message.warning(res.message)
@@ -456,6 +456,9 @@ export default {
         })
         .finally(() => {})
     },
+    searchAdvertiserOptions(value) {
+      this.loadAdvertiserOptions(value ? value.trim() : '')
+    },
     handleEditElse(item, type) {
       if (type == 'product') {
         this.$refs.modalFormTwo.edit(item)
@@ -486,7 +489,10 @@ export default {
         this.$refs.modalForm.disableSubmit = false
       } else if (this.active == 'product') {
         if (this.queryParam.advertiserId) {
-          this.$refs.modalFormTwo.add({ advertiserId: this.queryParam.advertiserId })
+          this.$refs.modalFormTwo.add({
+            advertiserId: this.queryParam.advertiserId,
+            advertiserId_dictText: this.advertiserName ? this.advertiserName : undefined,
+          })
         } else {
           this.$refs.modalFormTwo.add()
         }
@@ -495,7 +501,9 @@ export default {
       } else if (this.active == 'project') {
         this.$refs.modalFormThree.add({
           advertiserId: this.queryParam.advertiserId ? this.queryParam.advertiserId : this.advertiserId ? this.advertiserId : undefined,
+          advertiserId_dictText: this.advertiserName ? this.advertiserName : undefined,
           productId: this.queryParam.productId ? this.queryParam.productId : undefined,
+          productId_dictText: this.productName ? this.productName : undefined,
         })
         this.$refs.modalFormThree.title = '新增'
         this.$refs.modalFormThree.disableSubmit = false
@@ -513,6 +521,7 @@ export default {
         this.queryParam.productId = item.id
         this.productName = item.productName
         this.advertiserId = item.advertiserId
+        this.advertiserName = item.advertiserId_dictText
         this.queryParam.projectName = null
         this.callbackTwo('project')
       }

+ 33 - 26
src/views/modules/advertiser/ProjectList.vue

@@ -14,15 +14,16 @@
             <a-form-item label="广告主名称">
               <!-- <a-input placeholder="请输入广告主名称" v-model="queryParam.advertiserName"></a-input> -->
 
-              <a-select
-                optionFilterProp="children"
-                showSearch
-                :filterOption="filterOption"
-                v-model="queryParam.advertiserId"
-                placeholder="请选择广告主名称"
-              >
-                <a-select-option :value="item.id" v-for="(item, index) of list" :key="index">
-                  {{ item.name }}
+              <a-select
+                showSearch
+                :filterOption="false"
+                v-model="queryParam.advertiserId"
+                placeholder="请选择广告主名称"
+                @focus="loadAdvertisers"
+                @search="searchAdvertisers"
+              >
+                <a-select-option :value="item.id" v-for="(item, index) of list" :key="index">
+                  {{ item.name }}
                 </a-select-option>
               </a-select>
             </a-form-item>
@@ -358,22 +359,28 @@ export default {
     },
    
     ...mapGetters(['nickname', 'avatar', 'userInfo']),
-    getList() {
-      var params = {}
-      // params.userId = this.userInfo().id
-      params.pageSize = 1000
-      params.pageNo = 1
-      params.userId = this.userInfo().id
-      getAction('/ctop/advertiser/list', params)
-        .then((res) => {
-          if (res.success) {
-            this.list = res.result.records
+    loadAdvertisers(name = '') {
+      const params = {
+        pageSize: 50,
+        pageNo: 1,
+        userId: this.userInfo().id,
+      }
+      if (name) {
+        params.name = name
+      }
+      getAction('/ctop/advertiser/list', params)
+        .then((res) => {
+          if (res.success) {
+            this.list = res.result.records
           } else {
             this.$message.warning(res.message)
           }
-        })
-        .finally(() => {})
-    },
+        })
+        .finally(() => {})
+    },
+    searchAdvertisers(value) {
+      this.loadAdvertisers(value ? value.trim() : '')
+    },
     // searchQuery(){
     //   this.queryParam.userId = this.userInfo().id;
     //   this.getList();
@@ -403,9 +410,9 @@ export default {
       }
     },
   },
-  mounted() {
-    this.getAllUserList()
-    this.getList()
+  mounted() {
+    this.getAllUserList()
+    this.loadAdvertisers()
     // getAction('/sys/user/getAllUserList', { pageSize: 50, pageNo: 1, userName: '' }).then((res) => {
     //   if (res.success) {
     //     this.options = res.result.list
@@ -416,4 +423,4 @@ export default {
 </script>
 <style scoped>
 @import '~@assets/less/common.less';
-</style>
+</style>

+ 99 - 62
src/views/modules/advertiser/modules/ProjectModal.vue

@@ -45,20 +45,23 @@
                     </a-select>
                 </a-form-item>
 
-                <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="广告主名称">
-                    <a-select @change="handleChange" optionFilterProp="children" showSearch :filterOption="filterOption"
-                              v-decorator="['advertiserId', validatorRules.advertiserId]">
-                        <a-select-option :value="item.id" v-for="(item, index) of list" :key="index">
-                            {{ item.name }}
-                        </a-select-option>
-                    </a-select>
-                </a-form-item>
-                <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="产品名称">
-                    <a-select optionFilterProp="children" showSearch :filterOption="filterOption"
-                              v-decorator="['productId', validatorRules.productId]"
-                              :disabled="getFormFieldValue('advertiserId') == '' || getFormFieldValue('advertiserId') == null">
-                        <a-select-option :value="item.id" v-for="(item, index) of listProduct" :key="index">
-                            {{ item.productName }}
+                <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="广告主名称">
+                    <a-select @change="handleChange" showSearch :filterOption="false"
+                              @search="searchAdvertiser"
+                              @focus="loadAdvertisers"
+                              v-decorator="['advertiserId', validatorRules.advertiserId]">
+                        <a-select-option :value="item.id" v-for="(item, index) of list" :key="index">
+                            {{ item.name }}
+                        </a-select-option>
+                    </a-select>
+                </a-form-item>
+                <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="产品名称">
+                    <a-select showSearch :filterOption="false"
+                              @search="searchProduct"
+                              v-decorator="['productId', validatorRules.productId]"
+                              :disabled="getFormFieldValue('advertiserId') == '' || getFormFieldValue('advertiserId') == null">
+                        <a-select-option :value="item.id" v-for="(item, index) of listProduct" :key="index">
+                            {{ item.productName }}
                         </a-select-option>
                     </a-select>
                 </a-form-item>
@@ -500,15 +503,10 @@ export default {
             // }
             // console.log(`checked = ${e.target.value}`)
             // this.form.resetFields([])
-        },
-        handleChange(value) {
-            console.log(value)
-            getAction('/ctop/product/list', {advertiserId: value, pageSize: 1000}).then((res) => {
-                if (res.success) {
-                    this.listProduct = res.result.records
-                }
-            })
-        },
+        },
+        handleChange(value) {
+            this.loadProducts(value)
+        },
         handleBlur() {
             console.log('blur')
         },
@@ -518,24 +516,61 @@ export default {
         filterOption(input, option) {
             return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
         },
-        getList() {
-            var params = {}
-            params.userId = this.userInfo().id
-            params.pageSize = 1000
-            params.pageNo = 1
-            console.log(params)
-            getAction(this.url.getList, params)
-                .then((res) => {
-                    if (res.success) {
-                        console.log(res)
-                        this.list = res.result.records
-                    } else {
-                        this.$message.warning(res.message)
-                    }
-                })
-                .finally(() => {
-                })
-        },
+        loadAdvertisers(name = '', currentOption = null) {
+            const params = {
+                userId: this.userInfo().id,
+                pageSize: 50,
+                pageNo: 1
+            }
+            if (name) {
+                params.name = name
+            }
+            getAction(this.url.getList, params)
+                .then((res) => {
+                    if (res.success) {
+                        const records = res.result.records || []
+                        if (currentOption && currentOption.id && !records.find(item => item.id === currentOption.id)) {
+                            this.list = [currentOption, ...records]
+                        } else {
+                            this.list = records
+                        }
+                    } else {
+                        this.$message.warning(res.message)
+                    }
+                })
+                .finally(() => {
+                })
+        },
+        searchAdvertiser(value) {
+            this.loadAdvertisers(value ? value.trim() : '')
+        },
+        loadProducts(advertiserId, productName = '', currentOption = null) {
+            if (!advertiserId) {
+                this.listProduct = []
+                return
+            }
+            const params = {
+                advertiserId,
+                pageSize: 50,
+                pageNo: 1
+            }
+            if (productName) {
+                params.productName = productName
+            }
+            getAction('/ctop/product/list', params).then((res) => {
+                if (res.success) {
+                    const records = res.result.records || []
+                    if (currentOption && currentOption.id && !records.find(item => item.id === currentOption.id)) {
+                        this.listProduct = [currentOption, ...records]
+                    } else {
+                        this.listProduct = records
+                    }
+                }
+            })
+        },
+        searchProduct(value) {
+            this.loadProducts(this.getFormFieldValue('advertiserId'), value ? value.trim() : '')
+        },
         getAgentCodeList() {
             // /agent/agentConfig/list
             getAction('/agent/agentConfig/list').then((res) => {
@@ -557,26 +592,28 @@ export default {
                 }
             })
         },
-        add(item) {
-            this.editAll = false
-            this.edit({
-                mediaId: '2',
-                ...item,
-            })
-        },
-        edit(record) {
-            console.log(record);
-            this.getSupplierList()
-            this.getList()
-            this.getOcpxList()
-            if (record.advertiserId) {
-                this.editAll = true
-                getAction('/ctop/product/list', {advertiserId: record.advertiserId, pageSize: 1000}).then((res) => {
-                    if (res.success) {
-                        this.listProduct = res.result.records
-                    }
-                })
-            }
+        add(item = {}) {
+            this.editAll = false
+            this.edit({
+                mediaId: '2',
+                ...item,
+            })
+        },
+        edit(record = {}) {
+            console.log(record);
+            this.getSupplierList()
+            this.loadAdvertisers('', record.advertiserId ? {
+                id: record.advertiserId,
+                name: record.advertiserId_dictText
+            } : null)
+            this.getOcpxList()
+            if (record.advertiserId) {
+                this.editAll = true
+                this.loadProducts(record.advertiserId, '', record.productId ? {
+                    id: record.productId,
+                    productName: record.productId_dictText
+                } : null)
+            }
 
             // var params = { ...record }
             if (record.mediaId == '2' || record.mediaId == '4' || record.mediaId == '6') {
@@ -877,4 +914,4 @@ export default {
 }
 </script>
 
-<style lang="less" scoped></style>
+<style lang="less" scoped></style>

+ 34 - 16
src/views/modules/advertiser/modules/productModal.vue

@@ -4,8 +4,14 @@
     <a-spin :spinning="confirmLoading">
       <a-form :form="form">
         <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="广告主名称">
-          <a-select optionFilterProp="children" showSearch
-            :filterOption="filterOption" v-decorator="['advertiserId', validatorRules.advertiserId]">
+          <a-select
+            showSearch
+            :filterOption="false"
+            @search="searchAdvertiser"
+            @focus="loadAdvertisers"
+            v-decorator="['advertiserId', validatorRules.advertiserId]"
+            placeholder="请选择广告主名称"
+          >
             <a-select-option :value="item.id" v-for="(item, index) of list" :key="index">{{
               item.name
             }}</a-select-option>
@@ -163,24 +169,33 @@
       filterOption(input, option) {
         return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
       },
-      getList() {
-        var params = {}
-        params.userId = this.userInfo().id
-        params.pageSize = 1000
-        params.pageNo = 1
-        console.log(params)
-        getAction(this.url.getList,params)
+      loadAdvertisers(name = '', currentOption = null) {
+        const params = {
+          userId: this.userInfo().id,
+          pageSize: 50,
+          pageNo: 1,
+        }
+        if (name) {
+          params.name = name
+        }
+        getAction(this.url.getList, params)
           .then(res => {
             if (res.success) {
-              console.log(res)
-              this.list = res.result.records
-
+              const records = res.result.records || []
+              if (currentOption && currentOption.id && !records.find(item => item.id === currentOption.id)) {
+                this.list = [currentOption, ...records]
+              } else {
+                this.list = records
+              }
             } else {
               this.$message.warning(res.message)
             }
           })
           .finally(() => {})
       },
+      searchAdvertiser(value) {
+        this.loadAdvertisers(value ? value.trim() : '')
+      },
       getSupplierList() {
         var params = {}
         getAction('/ctop/supplierList/list',{pageNo:1,pageSize:100}).then(res => {
@@ -191,13 +206,16 @@
           }
         })
       },
-      add(item) {
+      add(item = {}) {
         this.addDis = false
         this.edit(item)
       },
-      edit(record) {
+      edit(record = {}) {
         // this.getSupplierList()
-        this.getList()
+        this.loadAdvertisers('', record.advertiserId ? {
+          id: record.advertiserId,
+          name: record.advertiserId_dictText
+        } : null)
         this.supplierList = []
         var params = {
           ...record
@@ -295,4 +313,4 @@
   }
 </script>
 
-<style lang="less" scoped></style>
+<style lang="less" scoped></style>

+ 101 - 61
src/views/modules/advertiser/modules/projectListModal.vue

@@ -35,21 +35,24 @@
                     </a-select>
                 </a-form-item>
 
-                <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="广告主名称">
-                    <a-select @change="handleChange" optionFilterProp="children" showSearch :filterOption="filterOption"
-                              v-decorator="['advertiserId', validatorRules.advertiserId]" placeholder="请选择广告主"
-                              disabled>
-                        <a-select-option :value="item.id" v-for="(item, index) of list" :key="index">
-                            {{ item.name }}
-                        </a-select-option>
+                <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="广告主名称">
+                    <a-select @change="handleChange" showSearch :filterOption="false"
+                              @search="searchAdvertiser"
+                              @focus="loadAdvertisers"
+                              v-decorator="['advertiserId', validatorRules.advertiserId]" placeholder="请选择广告主"
+                              disabled>
+                        <a-select-option :value="item.id" v-for="(item, index) of list" :key="index">
+                            {{ item.name }}
+                        </a-select-option>
                     </a-select>
-                </a-form-item>
-                <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="产品名称">
-                    <a-select optionFilterProp="children" showSearch :filterOption="filterOption"
-                              v-decorator="['productId']"
-                              placeholder="请选择产品" disabled>
-                        <a-select-option :value="item.id" v-for="(item, index) of listProduct" :key="index">
-                            {{ item.productName }}
+                </a-form-item>
+                <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="产品名称">
+                    <a-select showSearch :filterOption="false"
+                              @search="searchProduct"
+                              v-decorator="['productId']"
+                              placeholder="请选择产品" disabled>
+                        <a-select-option :value="item.id" v-for="(item, index) of listProduct" :key="index">
+                            {{ item.productName }}
                         </a-select-option>
                     </a-select>
                 </a-form-item>
@@ -476,16 +479,12 @@ export default {
             }
         },
         ...mapGetters(['nickname', 'avatar', 'userInfo']),
-        onChange(e) {
-            console.log(`checked = ${e.target.value}`)
-        },
-        handleChange(value) {
-            getAction('/ctop/product/list', {advertiserId: value, pageSize: 1000}).then((res) => {
-                if (res.success) {
-                    this.listProduct = res.result.records
-                }
-            })
-        },
+        onChange(e) {
+            console.log(`checked = ${e.target.value}`)
+        },
+        handleChange(value) {
+            this.loadProducts(value)
+        },
         handleBlur() {
         },
         handleFocus() {
@@ -493,22 +492,61 @@ export default {
         filterOption(input, option) {
             return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
         },
-        getList() {
-            var params = {}
-            params.userId = this.userInfo().id
-            params.pageSize = 1000
-            params.pageNo = 1
-            getAction(this.url.getList, params)
-                .then((res) => {
-                    if (res.success) {
-                        this.list = res.result.records
-                    } else {
-                        this.$message.warning(res.message)
-                    }
-                })
-                .finally(() => {
+        loadAdvertisers(name = '', currentOption = null) {
+            const params = {
+                userId: this.userInfo().id,
+                pageSize: 50,
+                pageNo: 1
+            }
+            if (name) {
+                params.name = name
+            }
+            getAction(this.url.getList, params)
+                .then((res) => {
+                    if (res.success) {
+                        const records = res.result.records || []
+                        if (currentOption && currentOption.id && !records.find(item => item.id === currentOption.id)) {
+                            this.list = [currentOption, ...records]
+                        } else {
+                            this.list = records
+                        }
+                    } else {
+                        this.$message.warning(res.message)
+                    }
                 })
-        },
+                .finally(() => {
+                })
+        },
+        searchAdvertiser(value) {
+            this.loadAdvertisers(value ? value.trim() : '')
+        },
+        loadProducts(advertiserId, productName = '', currentOption = null) {
+            if (!advertiserId) {
+                this.listProduct = []
+                return
+            }
+            const params = {
+                advertiserId,
+                pageSize: 50,
+                pageNo: 1
+            }
+            if (productName) {
+                params.productName = productName
+            }
+            getAction('/ctop/product/list', params).then((res) => {
+                if (res.success) {
+                    const records = res.result.records || []
+                    if (currentOption && currentOption.id && !records.find(item => item.id === currentOption.id)) {
+                        this.listProduct = [currentOption, ...records]
+                    } else {
+                        this.listProduct = records
+                    }
+                }
+            })
+        },
+        searchProduct(value) {
+            this.loadProducts(this.getFormFieldValue('advertiserId'), value ? value.trim() : '')
+        },
         getAgentCodeList() {
             // /agent/agentConfig/list
             getAction('/agent/agentConfig/list').then((res) => {
@@ -530,27 +568,29 @@ export default {
                 }
             })
         },
-        add(item) {
-            this.editAll = false
-            this.edit({
-                responsibleId: this.userInfo().id, //用户Id
-                mediaId: '2',
-                ...item,
-            })
-        },
-        edit(record) {
-            console.log(record)
-            this.getSupplierList()
-            this.getList()
-
-            if (record.advertiserId) {
-                this.editAll = true
-                getAction('/ctop/product/list', {advertiserId: record.advertiserId, pageSize: 1000}).then((res) => {
-                    if (res.success) {
-                        this.listProduct = res.result.records
-                    }
-                })
-            }
+        add(item = {}) {
+            this.editAll = false
+            this.edit({
+                responsibleId: this.userInfo().id, //用户Id
+                mediaId: '2',
+                ...item,
+            })
+        },
+        edit(record = {}) {
+            console.log(record)
+            this.getSupplierList()
+            this.loadAdvertisers('', record.advertiserId ? {
+                id: record.advertiserId,
+                name: record.advertiserId_dictText
+            } : null)
+
+            if (record.advertiserId) {
+                this.editAll = true
+                this.loadProducts(record.advertiserId, '', record.productId ? {
+                    id: record.productId,
+                    productName: record.productId_dictText
+                } : null)
+            }
             // else if (this.request == '2,4') {
             //         params.type = 'kuaishou'
             //       }
@@ -871,4 +911,4 @@ export default {
 }
 </script>
 
-<style lang="less" scoped></style>
+<style lang="less" scoped></style>