浏览代码

🎈 perf:

优化加载速度; 修复内存泄漏, 表格数据重复添加的问题
WanGxC 1 年之前
父节点
当前提交
c1c1d07f4f

+ 8 - 4
src/views/adManage/sd/campaigns/CreateCampaigns/component/CustomTarget.vue

@@ -108,7 +108,8 @@
           <el-table :data="addedTableData" :header-cell-style="changeTableHeader" height="600" style="width: 100%">
           <el-table :data="addedTableData" :header-cell-style="changeTableHeader" height="600" style="width: 100%">
             <el-table-column prop="date" label="商品">
             <el-table-column prop="date" label="商品">
               <template #default="{ row }">
               <template #default="{ row }">
-                <div v-if="row.cna || row.dialogTitle">浏览再营销</div>
+                <!-- <div>{{ row }}</div> -->
+                <div v-if="row.currentTitle">{{ row.currentTitle }}</div>
                 <div v-if="row.cna || row.dialogTitle">
                 <div v-if="row.cna || row.dialogTitle">
                   分类: <span style="color: black">{{ row.cna ? row.cna : row.dialogTitle }}</span>
                   分类: <span style="color: black">{{ row.cna ? row.cna : row.dialogTitle }}</span>
                 </div>
                 </div>
@@ -289,16 +290,17 @@ const purchasesLookBackOptions = [
 const addedTableData = ref([])
 const addedTableData = ref([])
 
 
 function browseOrientation(data) {
 function browseOrientation(data) {
-  const exists = addedTableData.value.some((item) => item.cid === data.cid)
+  const exists = addedTableData.value.some((item) => item.classificationId === data.cid)
   if (!exists) {
   if (!exists) {
     const dataWithLookback = {
     const dataWithLookback = {
+      currentTitle: '浏览再营销',
       type: 'c',
       type: 'c',
       tactictype: 'views',
       tactictype: 'views',
+      cna: data.cna,
       lookback: viewsLookBack.value,
       lookback: viewsLookBack.value,
       bid: bid.value,
       bid: bid.value,
       classificationId: data.cid
       classificationId: data.cid
     }
     }
-    console.log('dataWithLookback', dataWithLookback)
     addedTableData.value.push(dataWithLookback)
     addedTableData.value.push(dataWithLookback)
   } else {
   } else {
     ElMessage({
     ElMessage({
@@ -314,6 +316,7 @@ function buyOrientation(data) {
     const dataWithLookback = {
     const dataWithLookback = {
       ...data,
       ...data,
       lookback: viewsLookBack.value,
       lookback: viewsLookBack.value,
+      currentTitle: '购买再营销',
     }
     }
     console.log('dataWithLookback', dataWithLookback)
     console.log('dataWithLookback', dataWithLookback)
     addedTableData.value.push(dataWithLookback)
     addedTableData.value.push(dataWithLookback)
@@ -336,8 +339,8 @@ function browseRefine(data) {
   const exists = addedTableData.value.some((item) => item.cid === data.cid)
   const exists = addedTableData.value.some((item) => item.cid === data.cid)
 
 
   if (!exists) {
   if (!exists) {
-    console.log('data', data)
     const tableRow = {
     const tableRow = {
+      currentTitle: '浏览再营销',
       type: 'c',
       type: 'c',
       tactictype: 'views',
       tactictype: 'views',
       lookback: viewsLookBack.value,
       lookback: viewsLookBack.value,
@@ -370,6 +373,7 @@ function buyRefine(data) {
     const deliveryText = deliveryMap[data.delivery]
     const deliveryText = deliveryMap[data.delivery]
 
 
     const tableRow = {
     const tableRow = {
+      currentTitle: '购买再营销',
       type: 'c',
       type: 'c',
       tactictype: 'views',
       tactictype: 'views',
       lookback: viewsLookBack.value,
       lookback: viewsLookBack.value,

+ 2 - 1
src/views/adManage/sd/campaigns/CreateCampaigns/component/PromoteProduct.vue

@@ -377,13 +377,14 @@ function handleSizeChange(newSize) {
   currentPage.value = 1 // 重置到第一页
   currentPage.value = 1 // 重置到第一页
 }
 }
 
 
-const headerCellStyle = (args) => {
+function headerCellStyle(args) {
   if (args.rowIndex === 0) {
   if (args.rowIndex === 0) {
     return {
     return {
       backgroundColor: 'rgba(245, 245, 245, 0.9)',
       backgroundColor: 'rgba(245, 245, 245, 0.9)',
     }
     }
   }
   }
 }
 }
+
 onMounted(() => {
 onMounted(() => {
   setTableData()
   setTableData()
   emitter.on('respAdGroupId', (value: any)=>{
   emitter.on('respAdGroupId', (value: any)=>{

+ 0 - 1
src/views/adManage/sd/campaigns/CreateCampaigns/component/SingleSearch.vue

@@ -58,7 +58,6 @@ async function searchAsin() {
     }
     }
     const response = await getCommodityCard(query)
     const response = await getCommodityCard(query)
     commodityData.value = response.data
     commodityData.value = response.data
-    console.log('commodityData.value', commodityData.value)
   } catch (error) {
   } catch (error) {
     console.log('error:', error)
     console.log('error:', error)
   } finally {
   } finally {

+ 26 - 40
src/views/adManage/sp/campaigns/CreateCampaigns/index.vue

@@ -119,7 +119,7 @@
             <br />
             <br />
             <el-form ref="adGroupRuleFormRef" :model="adGroupRuleForm" :rules="adGroupRules">
             <el-form ref="adGroupRuleFormRef" :model="adGroupRuleForm" :rules="adGroupRules">
               <el-form-item required label="广告组名称" prop="adGroupName" style="width: 350px; margin-top: 20px">
               <el-form-item required label="广告组名称" prop="adGroupName" style="width: 350px; margin-top: 20px">
-                <el-input v-model="adGroupRuleForm.adGroupName"  placeholder="请输入广告组名称"/>
+                <el-input v-model="adGroupRuleForm.adGroupName" placeholder="请输入广告组名称" />
               </el-form-item>
               </el-form-item>
               <el-form-item required label="默认竞价" prop="defaultBidInp">
               <el-form-item required label="默认竞价" prop="defaultBidInp">
                 <el-input v-model="adGroupRuleForm.defaultBidInp" minlength="3" maxlength="4" style="width: 200px">
                 <el-input v-model="adGroupRuleForm.defaultBidInp" minlength="3" maxlength="4" style="width: 200px">
@@ -514,7 +514,7 @@
                   <template #header>
                   <template #header>
                     <div class="card-header">
                     <div class="card-header">
                       <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ addedData.length }}</span>
                       <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ addedData.length }}</span>
-                      <el-button class="button" text bg @click="delAllNegative">全部删除</el-button>
+                      <el-button class="button" text bg :disabled="!tableData.length" @click="delAllNegative">全部删除</el-button>
                     </div>
                     </div>
                   </template>
                   </template>
                   <div class="card-body">
                   <div class="card-body">
@@ -815,13 +815,21 @@
                   <el-tab-pane label="输入" name="second">
                   <el-tab-pane label="输入" name="second">
                     <el-input
                     <el-input
                       v-model="ruleForm.negativeGoodsTextarea"
                       v-model="ruleForm.negativeGoodsTextarea"
+                      :disabled="true"
                       :rows="17"
                       :rows="17"
                       type="textarea"
                       type="textarea"
-                      placeholder="未完成"
                       maxlength="11000"
                       maxlength="11000"
                       style="padding: 10px 10px" />
                       style="padding: 10px 10px" />
                     <div style="display: flex; flex-direction: row-reverse; margin-top: 10px">
                     <div style="display: flex; flex-direction: row-reverse; margin-top: 10px">
-                      <el-button style="margin-right: 10px" type="primary" text bg @click="addNegativeGoods">添加</el-button>
+                      <el-button
+                        style="margin-right: 10px"
+                        type="primary"
+                        text
+                        bg
+                        :disabled="!ruleForm.negativeGoodsTextarea"
+                        @click="addNegativeGoods"
+                        >添加</el-button
+                      >
                     </div>
                     </div>
                   </el-tab-pane>
                   </el-tab-pane>
                 </el-tabs>
                 </el-tabs>
@@ -1049,7 +1057,7 @@ async function createCampaigns() {
 
 
 const adMixOptions = ref([])
 const adMixOptions = ref([])
 async function getAdMix() {
 async function getAdMix() {
-  try { 
+  try {
     const resp = await request({
     const resp = await request({
       url: '/api/ad_manage/portfolios/select_list',
       url: '/api/ad_manage/portfolios/select_list',
       method: 'GET',
       method: 'GET',
@@ -1064,7 +1072,6 @@ async function submitCampaignForm(formEl: FormInstance | undefined) {
   if (!formEl) return
   if (!formEl) return
   await formEl.validate((valid, fields) => {
   await formEl.validate((valid, fields) => {
     if (valid) {
     if (valid) {
-      console.log('submit!')
       campaignLoading.value = true
       campaignLoading.value = true
       createCampaigns()
       createCampaigns()
     } else {
     } else {
@@ -1077,7 +1084,6 @@ async function submitForm(formEl: FormInstance | undefined) {
   if (!formEl) return
   if (!formEl) return
   await formEl.validate((valid, fields) => {
   await formEl.validate((valid, fields) => {
     if (valid) {
     if (valid) {
-      console.log('submit!')
       createCampaigns()
       createCampaigns()
     } else {
     } else {
       console.log('error submit!', fields)
       console.log('error submit!', fields)
@@ -1147,7 +1153,6 @@ async function createGroups() {
       data: filteredRequestData,
       data: filteredRequestData,
     })
     })
     respAdGroupId.value = resp.data.adGroupId
     respAdGroupId.value = resp.data.adGroupId
-    console.log('🚀 ~ createGroups ~ resp-->>', resp)
     adGroupLoading.value = false
     adGroupLoading.value = false
     if (respAdGroupId.value) {
     if (respAdGroupId.value) {
       ElMessage({
       ElMessage({
@@ -1167,7 +1172,6 @@ async function submitGroupsForm(formEl: FormInstance | undefined) {
   await formEl.validate((valid, fields) => {
   await formEl.validate((valid, fields) => {
     if (valid) {
     if (valid) {
       adGroupLoading.value = true
       adGroupLoading.value = true
-      console.log('submit!')
       createGroups()
       createGroups()
     } else {
     } else {
       console.log('error submit!', fields)
       console.log('error submit!', fields)
@@ -1211,7 +1215,10 @@ function addSingleGoods(scope) {
   if (!isAlreadyAdded) {
   if (!isAlreadyAdded) {
     adsTableData.value.push(scope.row)
     adsTableData.value.push(scope.row)
   } else {
   } else {
-    console.log('Item is already added.')
+    ElMessage({
+      message: '已添加',
+      type: 'warning',
+    })
   }
   }
 }
 }
 
 
@@ -1236,7 +1243,6 @@ function delSingleGoods(scope) {
   const index = adsTableData.value.findIndex((item) => item.sku === scope.row.sku)
   const index = adsTableData.value.findIndex((item) => item.sku === scope.row.sku)
   if (index !== -1) {
   if (index !== -1) {
     adsTableData.value.splice(index, 1)
     adsTableData.value.splice(index, 1)
-    console.log('Item removed successfully.')
   } else {
   } else {
     console.log('Item not found.')
     console.log('Item not found.')
   }
   }
@@ -1265,7 +1271,7 @@ function inpChange(e) {
 }
 }
 
 
 function selChange(e) {
 function selChange(e) {
-  console.log('e', e)
+  // console.log('e', e)
   const value = e
   const value = e
   if (select.value === 'asin' && searchInp.value) {
   if (select.value === 'asin' && searchInp.value) {
     loading.value = true
     loading.value = true
@@ -1335,7 +1341,6 @@ async function createAds() {
       method: 'POST',
       method: 'POST',
       data: filteredRequestData,
       data: filteredRequestData,
     })
     })
-    console.log('🚀 ~ createAds ~ resp-->>', resp)
     commodityLoading.value = false
     commodityLoading.value = false
     if (resp.data.success.length > 0) {
     if (resp.data.success.length > 0) {
       adsSave.value = false
       adsSave.value = false
@@ -1458,7 +1463,6 @@ async function createTargetGroup() {
       method: 'POST',
       method: 'POST',
       data: filteredRequestData,
       data: filteredRequestData,
     })
     })
-    console.log('🚀 ~ createTargetGroup ~ resp-->>', resp)
     targetGroupLoading.value = false
     targetGroupLoading.value = false
     if (respAdGroupId.value) {
     if (respAdGroupId.value) {
       ElMessage({
       ElMessage({
@@ -1475,7 +1479,6 @@ async function createTargetGroup() {
 
 
 function submitTargetGroupForm() {
 function submitTargetGroupForm() {
   targetGroupLoading.value = true
   targetGroupLoading.value = true
-  console.log('submit!')
   createTargetGroup()
   createTargetGroup()
 }
 }
 
 
@@ -1510,7 +1513,6 @@ const rules = computed(() => ({
 
 
 // 当单选按钮变化时更新showCard状态
 // 当单选按钮变化时更新showCard状态
 function changeBid() {
 function changeBid() {
-  console.log(ruleForm.autoRedirect)
   showCard.value = ruleForm.autoRedirect === 'targetBid'
   showCard.value = ruleForm.autoRedirect === 'targetBid'
 }
 }
 // 切换投放类型
 // 切换投放类型
@@ -1747,8 +1749,6 @@ function singleGoodsSearchChaneged() {
   setSearchTableData()
   setSearchTableData()
 }
 }
 function addSingleSearch(scope) {
 function addSingleSearch(scope) {
-  console.log('🚀 ~ addSingleSearch ~ scope-->>', scope)
-
   const typesToAdd = []
   const typesToAdd = []
   if (expand.value) {
   if (expand.value) {
     typesToAdd.push('ASIN_EXPANDED_FROM')
     typesToAdd.push('ASIN_EXPANDED_FROM')
@@ -1783,28 +1783,26 @@ function addSingleSearch(scope) {
       }
       }
       productOrientationTableData.value.push(newData)
       productOrientationTableData.value.push(newData)
     } else {
     } else {
-      console.log(`${productType} item is already added.`)
+      ElMessage({
+        message: `${productType} 已添加`,
+        type: 'warning',
+      })
     }
     }
   })
   })
 }
 }
 
 
 let selectedLabels = ref([]) // 选中的label数组
 let selectedLabels = ref([]) // 选中的label数组
 function dialogSelectChange(event) {
 function dialogSelectChange(event) {
-  console.log('🚀 ~ dialogSelectChange ~ event-->>', event)
-
   // 使用 map 来转换每个选中项的 value 为其对应的 label
   // 使用 map 来转换每个选中项的 value 为其对应的 label
   selectedLabels.value = event.map((selectedValue) => {
   selectedLabels.value = event.map((selectedValue) => {
     const selectedOption = dialogForm.dialogOptions.find((option) => option.value === selectedValue)
     const selectedOption = dialogForm.dialogOptions.find((option) => option.value === selectedValue)
     return selectedOption ? selectedOption.label : ''
     return selectedOption ? selectedOption.label : ''
   })
   })
-
-  console.log('🚀 ~ dialogSelectChange ~ selectedLabels-->>', selectedLabels.value)
 }
 }
 
 
 let refineItem = ref([])
 let refineItem = ref([])
 // 细化按钮功能
 // 细化按钮功能
 function refine(data) {
 function refine(data) {
-  console.log('🚀 ~ refine ~ data-->>', data)
   commodityCount.value = []
   commodityCount.value = []
   dialogTitle.value = data.cna
   dialogTitle.value = data.cna
   categoryId.value = data.cid
   categoryId.value = data.cid
@@ -1817,7 +1815,6 @@ function refine(data) {
 function dialogFormSubmit() {
 function dialogFormSubmit() {
   dialogFormRef.value.validate((valid) => {
   dialogFormRef.value.validate((valid) => {
     if (valid) {
     if (valid) {
-      console.log('表单提交')
       visible.value = false
       visible.value = false
       const dialogClassification = dialogTitle.value
       const dialogClassification = dialogTitle.value
       const dialogPrices_low = dialogForm.prices.lowest
       const dialogPrices_low = dialogForm.prices.lowest
@@ -1826,7 +1823,6 @@ function dialogFormSubmit() {
       const ratingLow = dialogStartRating[0]
       const ratingLow = dialogStartRating[0]
       const ratingHigh = dialogStartRating[1]
       const ratingHigh = dialogStartRating[1]
       const dialogDelivery = dialogForm.delivery
       const dialogDelivery = dialogForm.delivery
-      console.log('🚀 ~ dialogFormRef.value.validate ~ dialogDelivery-->>', dialogDelivery)
       const deliveryMap = {
       const deliveryMap = {
         all: '所有',
         all: '所有',
         eligible: '具备Prime资格',
         eligible: '具备Prime资格',
@@ -1860,7 +1856,6 @@ function dialogFormSubmit() {
           delivery: dialogDelivery,
           delivery: dialogDelivery,
           deliveryText: deliveryMap[dialogDelivery],
           deliveryText: deliveryMap[dialogDelivery],
         }
         }
-        console.log('🚀 ~ dialogFormRef.value.validate ~ refineObj-->>', refineObj)
         productOrientationTableData.value.push(refineObj)
         productOrientationTableData.value.push(refineObj)
       })
       })
     } else {
     } else {
@@ -1871,7 +1866,6 @@ function dialogFormSubmit() {
 
 
 // 定向按钮功能
 // 定向按钮功能
 function orientate(node, data) {
 function orientate(node, data) {
-  console.log('🚀 ~ orientate ~ data-->>', data)
   const exists = productOrientationTableData.value.some((item) => item.cid === data.cid)
   const exists = productOrientationTableData.value.some((item) => item.cid === data.cid)
 
 
   let bidValue = null
   let bidValue = null
@@ -1895,19 +1889,16 @@ function orientate(node, data) {
 
 
 let productTargetBidList = ref([])
 let productTargetBidList = ref([])
 async function productTagetSave() {
 async function productTagetSave() {
-  console.log('tableData', productOrientationTableData.value)
   // 检查是否存在 bid 为空的行
   // 检查是否存在 bid 为空的行
   const hasEmptyBid = productOrientationTableData.value.some((row) => row.bid == null || row.bid === '')
   const hasEmptyBid = productOrientationTableData.value.some((row) => row.bid == null || row.bid === '')
   // 直接返回,不继续执行
   // 直接返回,不继续执行
   if (hasEmptyBid) {
   if (hasEmptyBid) {
-    console.log('存在空的 bid,不发送请求')
     ElMessage.error('存在空的 bid,无法创建商品!')
     ElMessage.error('存在空的 bid,无法创建商品!')
     return
     return
   }
   }
   productOrientationTableData.value.forEach((row) => {
   productOrientationTableData.value.forEach((row) => {
     productTargetBidList.value.push(row.bid)
     productTargetBidList.value.push(row.bid)
   })
   })
-  console.log('productTargetBidList', productTargetBidList.value)
   productOrientationLoading.value = true
   productOrientationLoading.value = true
   try {
   try {
     const requestData = {
     const requestData = {
@@ -1924,7 +1915,6 @@ async function productTagetSave() {
       data: filteredRequestData,
       data: filteredRequestData,
     })
     })
 
 
-    console.log('🚀 ~ createTargetGroup ~ resp-->>', resp)
     productOrientationLoading.value = false
     productOrientationLoading.value = false
 
 
     if (respAdGroupId.value) {
     if (respAdGroupId.value) {
@@ -2152,7 +2142,6 @@ function delSingleNegative(scope) {
     // 从 negativeList 删除
     // 从 negativeList 删除
     if (negativeList.length) {
     if (negativeList.length) {
       negativeList.splice(index, 1)
       negativeList.splice(index, 1)
-      console.log(`已删除索引为 ${index} 的条目`)
     } else {
     } else {
       console.log('无效的索引,无法删除条目')
       console.log('无效的索引,无法删除条目')
     }
     }
@@ -2177,7 +2166,6 @@ function delSingleNegative(scope) {
 
 
 async function negativeWordsSave() {
 async function negativeWordsSave() {
   negativeWordsLoading.value = true
   negativeWordsLoading.value = true
-  console.log('negativeList', negativeList)
   try {
   try {
     const requestData = {
     const requestData = {
       profile_id: profile.value.profile_id,
       profile_id: profile.value.profile_id,
@@ -2238,7 +2226,6 @@ function setNegativeTableData(asin = '') {
 
 
 // 输入tab的textarea
 // 输入tab的textarea
 function addNegativeGoods() {
 function addNegativeGoods() {
-  console.log('ruleForm.negativeGoodsTextarea', ruleForm.negativeGoodsTextarea)
   loading.value = true
   loading.value = true
 
 
   setNegativeTableData(ruleForm.negativeGoodsTextarea)
   setNegativeTableData(ruleForm.negativeGoodsTextarea)
@@ -2258,7 +2245,10 @@ function addSingleNegativeGoods(scope) {
   if (!isAlreadyAdded) {
   if (!isAlreadyAdded) {
     addedNegetiveTableData.value.push(scope.row)
     addedNegetiveTableData.value.push(scope.row)
   } else {
   } else {
-    console.log('Item is already added.')
+    ElMessage({
+      message: '已存在',
+      type: 'warning',
+    })
   }
   }
 }
 }
 
 
@@ -2271,14 +2261,12 @@ function delSingleNegativeGoods(scope) {
 
 
   if (index !== -1) {
   if (index !== -1) {
     addedNegetiveTableData.value.splice(index, 1)
     addedNegetiveTableData.value.splice(index, 1)
-    console.log('Item removed successfully.')
   } else {
   } else {
     console.log('Item not found.')
     console.log('Item not found.')
   }
   }
 }
 }
 
 
 function searchNegativeGoods(e) {
 function searchNegativeGoods(e) {
-  console.log(e)
   if (e === '') {
   if (e === '') {
     negativeTableData.value = []
     negativeTableData.value = []
   } else {
   } else {
@@ -2295,10 +2283,8 @@ function handleNegGoodsTabs(tab: TabsPaneContext, event: Event) {
 }
 }
 
 
 async function negativeGoodsSave() {
 async function negativeGoodsSave() {
-  console.log(addedNegetiveTableData.value)
   const asinList = addedNegetiveTableData.value.map((item) => item.asin)
   const asinList = addedNegetiveTableData.value.map((item) => item.asin)
   negativeGoodsLoading.value = true
   negativeGoodsLoading.value = true
-  console.log('addedNegetiveTableData', addedNegetiveTableData.value)
   try {
   try {
     const requestData = {
     const requestData = {
       profile_id: profile.value.profile_id,
       profile_id: profile.value.profile_id,