index.vue 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910
  1. <template>
  2. <div>
  3. <el-card>
  4. <div style="padding-left: 5px">
  5. <!-- 广告活动 -->
  6. <el-form
  7. :label-position="labelPosition"
  8. ref="campaignFormRef"
  9. :model="campaignRuleForm"
  10. :rules="campaignRules"
  11. label-width="120px"
  12. class="demo-ruleForm"
  13. :size="formSize"
  14. status-icon>
  15. <el-card shadow="never" body-style="padding-bottom: 0 !important;" v-loading="campaignLoading">
  16. <div style="font-size: 24px; font-weight: bold;">广告活动</div>
  17. <hr>
  18. <br>
  19. <el-form-item label="广告活动名称" prop="name" style="width: 350px">
  20. <el-input v-model="campaignRuleForm.name" />
  21. </el-form-item>
  22. <el-form-item label="广告组合" prop="adMix">
  23. <el-select v-model="campaignRuleForm.adMix" placeholder="请选择">
  24. <el-option label="Zone one" value="shanghai" />
  25. <el-option label="Zone two" value="beijing" />
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item prop="startDate" label="开始日期" style="width: 350px">
  29. <el-date-picker
  30. v-model="campaignRuleForm.startDate"
  31. type="date"
  32. format="YYYY-MM-DD"
  33. value-format="YYYY-MM-DD"
  34. label="开始日期"
  35. placeholder="开始日期"
  36. style="width: 100%"/>
  37. </el-form-item>
  38. <el-form-item prop="date2" label="结束日期" style="width: 350px">
  39. <el-date-picker
  40. v-model="campaignRuleForm.date2"
  41. type="date"
  42. format="YYYY-MM-DD"
  43. value-format="YYYY-MM-DD"
  44. label="结束日期"
  45. placeholder="结束日期"
  46. style="width: 100%"/>
  47. </el-form-item>
  48. <el-form-item prop="budget" label="每日预算" style="width: 350px">
  49. <el-input v-model="campaignRuleForm.budget" maxlength="7" oninput="value=value.indexOf('.') > -1?value.slice(0, value.indexOf('.') + 3):value" />
  50. </el-form-item>
  51. <el-form-item label="投放类型" prop="type" class="column-item">
  52. <el-radio-group v-model="campaignRuleForm.type" @click="changeType">
  53. <div>
  54. <el-radio label="AUTO">自动</el-radio>
  55. <div class="radio-description">定向与您推广商品相似的关键词和商品</div>
  56. </div>
  57. <div>
  58. <el-radio label="MANUAL">手动</el-radio>
  59. <div class="radio-description">选择关键词或商品以定向购物者搜索并设置自定义出价</div>
  60. </div>
  61. </el-radio-group>
  62. </el-form-item>
  63. <el-form-item label="竞价策略" prop="bidStrategy" class="column-item column-margin-bottom">
  64. <el-radio-group v-model="campaignRuleForm.bidStrategy">
  65. <div>
  66. <el-radio label="LEGACY_FOR_SALES" border>
  67. 动态竞价-仅降低
  68. <div class="radio-description-2">当您的广告不太可能带来销售时,我们将实时降低您的竞价</div>
  69. </el-radio>
  70. </div>
  71. <div>
  72. <el-radio label="AUTO_FOR_SALES" border>
  73. 动态竞价-提高和降低
  74. <div class="radio-description-2">
  75. 当您的广告很有可能带来销售时,我们将实时提高您的竞价(最高可达 100%),并在您的广告不太可能带来销售时降低您的竞价
  76. </div>
  77. </el-radio>
  78. </div>
  79. <el-radio label="MANUAL" border>
  80. 固定竞价
  81. <div class="radio-description-2">我们将使用您的确切竞价和您设置的任何手动调整,而不会根据售出可能性对您的竞价进行更改</div>
  82. </el-radio>
  83. </el-radio-group>
  84. </el-form-item>
  85. <el-form-item label="按展示位置调整出价" prop="placeBid">
  86. <p style="color: #8e9196">除了出价策略外,您还可以将出价提高多达900%</p>
  87. <div class="gap-items">
  88. <div class="gap-item">搜索结果顶部(首页)</div>
  89. <el-input v-model="campaignRuleForm.placeBid" class="gap-item">
  90. <template #append>%</template>
  91. </el-input>
  92. </div>
  93. <div class="gap-items">
  94. <div class="gap-item">商品首页</div>
  95. <el-input v-model="campaignRuleForm.firstPage" class="gap-item">
  96. <template #append>%</template>
  97. </el-input>
  98. </div>
  99. <div class="gap-items" style="margin-bottom: 0">
  100. <div class="gap-item">搜索结果的其余位置</div>
  101. <el-input v-model="campaignRuleForm.other" class="gap-item">
  102. <template #append>%</template>
  103. </el-input>
  104. </div>
  105. </el-form-item>
  106. <el-form-item style="margin-left: 48%;">
  107. <el-button type="primary" plain @click="submitCampaignForm(campaignFormRef)">保存</el-button>
  108. </el-form-item>
  109. </el-card>
  110. <br>
  111. <!-- 广告组 -->
  112. <el-card shadow="never" body-style="padding-bottom: 0 !important;">
  113. <div style="font-size: 20px; font-weight: bold;">广告组</div>
  114. <hr>
  115. <br>
  116. <el-form ref="adGroupRuleFormRef" :model="adGroupRuleForm" :rules="adGroupRules">
  117. <el-form-item required label="广告组名称" prop="adGroupName" style="width: 350px; margin-top: 20px">
  118. <el-input v-model="adGroupRuleForm.adGroupName" />
  119. </el-form-item>
  120. <el-form-item required label="默认竞价" prop="defaultBidInp">
  121. <el-input v-model="adGroupRuleForm.defaultBidInp" style="width: 200px">
  122. <template #prepend>$</template>
  123. </el-input>
  124. </el-form-item>
  125. <el-form-item style="margin-left: 48%;">
  126. <el-button type="primary" plain @click="submitGroupsForm(adGroupRuleFormRef)" :disabled="campaignSave">保存</el-button>
  127. </el-form-item>
  128. </el-form>
  129. </el-card>
  130. <!-- 商品表格 -->
  131. <div style=" margin-top:20px; font-size: 24px; font-weight: bold;">商品</div>
  132. <hr>
  133. <br>
  134. <el-form-item prop="commodity" style="width: 100%;">
  135. <div style="width: 100%; height: 620px; display: flex; border: 1px solid #e5e7ec; border-radius: 6px">
  136. <div style="width: 50%; border-right: 1px solid #e5e7ec">
  137. <el-tabs v-model="activeName" class="demo-tabs">
  138. <el-tab-pane label="搜索" name="first">
  139. <div style="margin-bottom: 10px">
  140. <el-input v-model="searchInp" placeholder="Please input" class="input-with-select" @change="inpChange" clearable>
  141. <template #prepend>
  142. <el-select v-model="select" style="width: 100px" @change="selChange">
  143. <el-option label="名称" value="name" />
  144. <el-option label="ASIN" value="asin" />
  145. <el-option label="SKU" value="sku" />
  146. </el-select>
  147. </template>
  148. <template #append>
  149. <el-select v-model="select2" style="width: 100px">
  150. <el-option label="最新优先" value="latest" />
  151. <el-option label="最早优先" value="earliest" />
  152. <el-option label="优选广告" value="optimal" />
  153. </el-select>
  154. </template>
  155. </el-input>
  156. </div>
  157. <el-table
  158. height="490"
  159. style="width: 100%"
  160. v-loading="loading"
  161. :data="fullTableData"
  162. :header-cell-style="headerCellStyle"
  163. @selection-change="handleSelectionChange">
  164. <el-table-column type="selection" width="50" />
  165. <el-table-column prop="asin" label="商品">
  166. <template #default="scope">
  167. <div style="display: flex; align-items: center">
  168. <div style="margin-right: 8px; line-height: normal">
  169. <el-image class="img-box" :src="scope.row.image_link" />
  170. </div>
  171. <div>
  172. <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top">
  173. <div class="single-line">{{ scope.row.title ? scope.row.title : '--' }}</div>
  174. </el-tooltip>
  175. <div class="data-color">
  176. <span style="font-weight: 500; color: rgb(30, 33, 41)">${{ scope.row.price ? scope.row.price : '--' }}</span>
  177. <span style="margin: 0 5px; color: #cacdd4">|</span>
  178. <span style="color: #6d7784">{{ scope.row.quantity }}</span>
  179. </div>
  180. <span>
  181. ASIN: <span class="data-color" style="margin-right: 8px">{{ scope.row.asin ? scope.row.asin : '--' }}</span>
  182. </span>
  183. <span>
  184. SKU: <span class="data-color">{{ scope.row.sku ? scope.row.sku : '--' }}</span>
  185. </span>
  186. </div>
  187. </div>
  188. </template>
  189. </el-table-column>
  190. <el-table-column prop="name" label="Name" width="120" align="right">
  191. <template #header>
  192. <el-button type="primary" size="normal" link @click="handleGoodsAdd">添加已选中</el-button>
  193. </template>
  194. <template #default="scope">
  195. <el-button type="primary" size="small" @click="addSingleGoods(scope)" text>添加</el-button>
  196. </template>
  197. </el-table-column>
  198. </el-table>
  199. <el-pagination
  200. @current-change="handleCurrentChange"
  201. @size-change="handleSizeChange"
  202. :current-page="currentPage"
  203. :page-size="pageSize"
  204. :total="totalItems"
  205. layout="prev, pager, next" />
  206. </el-tab-pane>
  207. <el-tab-pane label="输入" name="second">
  208. <el-input
  209. style="padding: 10px"
  210. v-model="goodsTextarea"
  211. :rows="20"
  212. type="textarea"
  213. placeholder="请输入ASIN,多个ASIN使用逗号、空格或换行符分隔。(未完成)"
  214. maxlength="11000" />
  215. <div style="display: flex; flex-direction: row-reverse; margin-top: 10px">
  216. <el-button v-for="button in buttons" :key="button.text" :type="button.type" link @click="addGods">{{ button.text }}</el-button>
  217. </div>
  218. <!-- <el-row :gutter="12" style="margin-top: 50px">
  219. <el-col :span="12">
  220. <el-card class="card-box" shadow="never" style="border: none; background-color: #e3f0de; height: 50px">
  221. <div style="line-height: 15px">成功添加:</div>
  222. <div style="line-height: 15px">
  223. <el-icon style="color: #8fc47d; font-size: 25px"><SuccessFilled /></el-icon>
  224. </div>
  225. </el-card>
  226. </el-col>
  227. <el-col :span="12">
  228. <el-card class="card-box" shadow="never" style="border: none; background-color: #fbe6e3; height: 50px">
  229. <div style="line-height: 15px">未成功添加:</div>
  230. <div style="line-height: 15px">
  231. <el-icon style="color: #e3918d; font-size: 25px"><CircleCloseFilled /></el-icon>
  232. </div>
  233. </el-card>
  234. </el-col>
  235. </el-row> -->
  236. </el-tab-pane>
  237. </el-tabs>
  238. </div>
  239. <div style="width: 50%">
  240. <el-card class="box-card" shadow="never" style="border: 0">
  241. <template #header>
  242. <div class="card-header">
  243. <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ addedData.length }}</span>
  244. <el-button class="button" text bg @click="delAllGoods">全部删除</el-button>
  245. </div>
  246. </template>
  247. <!-- <div v-for="o in 4" :key="o" class="text item">{{ 'List item ' + o }}</div> -->
  248. <div class="card-body"></div>
  249. <!-- <template #footer>Footer content</template> -->
  250. </el-card>
  251. <div style="padding: 0 10px 0 10px; margin-top: -12px">
  252. <el-table
  253. :data="addedData"
  254. height="520"
  255. style="width: 100%"
  256. :header-cell-style="headerCellStyle"
  257. @selection-change="handleAddedGoodsChange">
  258. <el-table-column type="selection" width="50" />
  259. <el-table-column prop="asin" label="ASIN">
  260. <template #default="scope">
  261. <div style="display: flex; align-items: center">
  262. <div style="margin-right: 8px; line-height: normal">
  263. <el-image class="img-box" :src="scope.row.image_link" />
  264. </div>
  265. <div>
  266. <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top">
  267. <div class="single-line">{{ scope.row.title ? scope.row.title : '--' }}</div>
  268. </el-tooltip>
  269. <div class="data-color">
  270. <span style="font-weight: 500; color: rgb(30, 33, 41)">${{ scope.row.price ? scope.row.price : '--' }}</span>
  271. <span style="margin: 0 5px; color: #cacdd4">|</span>
  272. <span style="color: #6d7784">{{ scope.row.quantity }}</span>
  273. </div>
  274. <span
  275. >ASIN:
  276. <span class="data-color" style="margin-right: 8px">{{ scope.row.asin ? scope.row.asin : '--' }}</span>
  277. </span>
  278. <span
  279. >SKU:
  280. <span class="data-color">{{ scope.row.sku ? scope.row.sku : '--' }}</span>
  281. </span>
  282. </div>
  283. </div>
  284. </template>
  285. </el-table-column>
  286. <el-table-column prop="name" label="Name" width="120" align="right">
  287. <template #header>
  288. <el-button type="primary" size="normal" link @click="delSelectedGoods">删除已选中</el-button>
  289. </template>
  290. <template #default="scope">
  291. <el-button type="primary" size="small" @click="delSingleGoods(scope)" text>删除</el-button>
  292. </template>
  293. </el-table-column>
  294. </el-table>
  295. </div>
  296. </div>
  297. </div>
  298. </el-form-item>
  299. <!-- 按目标组设置出价 -->
  300. <div class="column-item" v-if="campaignRuleForm.type == 'AUTO'">
  301. <div style=" margin-top:20px; font-size: 24px; font-weight: bold;">按目标组设置出价</div>
  302. <hr>
  303. <br>
  304. <el-card shadow="never" v-if="campaignRuleForm.type == 'AUTO'" class="box-card">
  305. <div>
  306. <div style="color: #8e9095">
  307. <span>目标群体</span>
  308. <span class="suggested-bid-item">建议竞价</span>
  309. <span>竞价</span>
  310. </div>
  311. <div style="display: flex">
  312. <el-switch v-model="ruleForm.closeMatch" size="small" active-text="紧密匹配" />
  313. <span class="suggested-bid-item">--</span>
  314. <el-form-item prop="closeMatchInp">
  315. <el-input :disabled="!ruleForm.closeMatch" v-model="ruleForm.closeMatchInp" placeholder="Please input" class="bid-input">
  316. <template #prepend>$</template>
  317. </el-input>
  318. </el-form-item>
  319. </div>
  320. <div>
  321. <div style="display: flex">
  322. <el-switch v-model="ruleForm.broadMatch" size="small" active-text="广泛匹配" />
  323. <span class="suggested-bid-item">--</span>
  324. <el-form-item prop="broadMatchInp">
  325. <el-input :disabled="!ruleForm.broadMatch" v-model="ruleForm.broadMatchInp" placeholder="Please input" class="bid-input">
  326. <template #prepend>$</template>
  327. </el-input>
  328. </el-form-item>
  329. </div>
  330. </div>
  331. <div>
  332. <div style="display: flex">
  333. <el-switch v-model="ruleForm.similarProducts" size="small" active-text="同类商品" />
  334. <span class="suggested-bid-item">--</span>
  335. <el-form-item prop="similarProductsInp">
  336. <el-input
  337. :disabled="!ruleForm.similarProducts"
  338. v-model="ruleForm.similarProductsInp"
  339. placeholder="Please input"
  340. class="bid-input">
  341. <template #prepend>$</template>
  342. </el-input>
  343. </el-form-item>
  344. </div>
  345. </div>
  346. <div>
  347. <div style="display: flex">
  348. <el-switch v-model="ruleForm.relatedProducts" size="small" active-text="关联商品" />
  349. <span class="suggested-bid-item">--</span>
  350. <el-form-item prop="relatedProductsInp">
  351. <el-input
  352. :disabled="!ruleForm.relatedProducts"
  353. v-model="ruleForm.relatedProductsInp"
  354. placeholder="Please input"
  355. class="bid-input">
  356. <template #prepend>$</template>
  357. </el-input>
  358. </el-form-item>
  359. </div>
  360. </div>
  361. </div>
  362. </el-card>
  363. </div>
  364. <!-- 投放类型 -->
  365. <div class="column-item" v-if="campaignRuleForm.type == 'MANUAL'">
  366. <p style="color: #606266; font-weight: 450"><span style="color: #e47470">*</span> 投放类型</p>
  367. <el-radio-group v-model="ruleForm.targetType" @change="changeTargetType">
  368. <div style="display: flex">
  369. <el-radio label="keyWords" style="align-items: flex-start; margin-top: 5px">
  370. <div style="margin-top: -4px">关键词投放</div>
  371. <div>选择关键词以帮助您的商品出现在购物者搜索中</div>
  372. </el-radio>
  373. </div>
  374. <div>
  375. <el-radio label="Goods" style="align-items: flex-start; margin-top: 20px">
  376. <div style="margin-top: -4px">商品投放</div>
  377. <div>选择特定的商品, 分类, 品牌或者其他商品功能来定向您的广告</div>
  378. </el-radio>
  379. </div>
  380. </el-radio-group>
  381. </div>
  382. <!-- 关键词定向 -->
  383. <div style="font-size: 20px; font-weight: bold; margin-top: 30px" v-if="ruleForm.targetType == 'keyWords' && campaignRuleForm.type == 'MANUAL'">
  384. 关键词定向
  385. </div>
  386. <hr v-if="ruleForm.targetType == 'keyWords' && campaignRuleForm.type == 'MANUAL'" />
  387. <el-form-item style="width: 100%; margin-top: 20px" v-if="ruleForm.targetType == 'keyWords' && campaignRuleForm.type == 'MANUAL'">
  388. <div style="width: 100%; height: 520px; display: flex; border: 1px solid #c2c7cf; border-radius: 6px">
  389. <div style="width: 50%; border-right: 1px solid #c2c7cf">
  390. <el-tabs v-model="keyWordsTabs" class="demo-tabs" @tab-click="handleGoodsTabs">
  391. <div style="margin: 8px">
  392. <p style="margin-left: 8px; margin-bottom: -8px; font-weight: 500; color: #616266">竞价:</p>
  393. <div style="display: flex; align-items: center">
  394. <el-select v-model="bidType" class="m-2" placeholder="Select" style="width: 450px">
  395. <el-option v-for="item in bidTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
  396. </el-select>
  397. <el-input v-model="bidInput" placeholder="Please input">
  398. <template #prepend>$</template>
  399. </el-input>
  400. </div>
  401. <div style="display: flex">
  402. <span style="margin: 0 10px 0 8px; font-weight: 500; color: #616266">匹配类型: </span>
  403. <el-checkbox v-model="widelyType" label="广泛" />
  404. <el-checkbox v-model="phraseType" label="词组" />
  405. <el-checkbox v-model="exactType" label="精确" />
  406. </div>
  407. </div>
  408. <el-tab-pane label="建议" name="first">
  409. <el-table
  410. height="345"
  411. style="width: 100%; padding-left: 5px"
  412. v-loading="loading"
  413. :data="keyWordsTableData"
  414. :header-cell-style="headerCellStyle"
  415. :header-row-style="changeKeyWordsTableHeader">
  416. <el-table-column prop="asin" label="关键词"> </el-table-column>
  417. <el-table-column prop="name" label="匹配类型"> </el-table-column>
  418. <el-table-column prop="name" label="建议出价" width="120"> </el-table-column>
  419. </el-table>
  420. </el-tab-pane>
  421. <el-tab-pane label="输入" name="second">
  422. <el-input v-model="keyWordsTextarea" :rows="10" type="textarea" placeholder="未完成" style="padding-left: 5px" />
  423. <el-button type="primary" size="small" text bg @click="addKeyWords">添加</el-button>
  424. </el-tab-pane>
  425. </el-tabs>
  426. </div>
  427. <div style="width: 50%">
  428. <el-card class="box-card" shadow="never">
  429. <template #header>
  430. <div class="card-header">
  431. <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ addedData.length }}</span>
  432. <el-button class="button" text bg @click="delAllKeyWords">全部删除</el-button>
  433. </div>
  434. </template>
  435. <div class="card-body">
  436. <el-table
  437. :data="addedKeyWordsTableData"
  438. style="width: 100%"
  439. :header-row-style="changeKeyWordsTableHeader"
  440. :header-cell-style="headerCellStyle">
  441. <el-table-column prop="keyword" label="关键词" width="auto" />
  442. <el-table-column prop="bid" label="出价" />
  443. <el-table-column prop="suggestBid" label="建议出价" />
  444. <el-table-column prop="operate" label="操作" width="60" align="right" />
  445. </el-table>
  446. </div>
  447. </el-card>
  448. <div style="padding: 0 10px 0 10px; margin-top: -12px"></div>
  449. </div>
  450. </div>
  451. </el-form-item>
  452. <div
  453. style="font-size: 20px; font-weight: bold; margin-top: 30px"
  454. v-if="campaignRuleForm.type === 'AUTO' || (ruleForm.targetType === 'keyWords' && campaignRuleForm.type === 'MANUAL')">
  455. 否定词
  456. </div>
  457. <hr v-if="campaignRuleForm.type === 'AUTO' || (ruleForm.targetType === 'keyWords' && campaignRuleForm.type === 'MANUAL')" />
  458. <!-- 否定词表格 -->
  459. <el-form-item
  460. style="width: 100%; margin-top: 20px"
  461. v-if="campaignRuleForm.type === 'AUTO' || (ruleForm.targetType === 'keyWords' && campaignRuleForm.type === 'MANUAL')">
  462. <div style="width: 100%; height: 520px; display: flex; border: 1px solid #e5e7ec; border-radius: 6px">
  463. <div style="width: 50%; border-right: 1px solid #e5e7ec">
  464. <div style="margin: 10px 0">
  465. <span style="margin-left: 25px; color: #e47470">*</span>
  466. <span style="color: #666666; margin-right: 10px">匹配类型: </span>
  467. <el-checkbox v-model="ruleForm.phraseNegation" label="词组否定" />
  468. <el-checkbox v-model="ruleForm.preciseNegation" label="精确否定" />
  469. </div>
  470. <el-input
  471. v-model="ruleForm.negativeTextarea"
  472. :rows="17"
  473. type="textarea"
  474. placeholder="请输入关键词,多个关键词使用逗号或者换行符分隔。(最多添加1000个关键词)"
  475. maxlength="11000"
  476. style="padding: 0 20px" />
  477. <div style="display: flex; flex-direction: row-reverse; margin-top: 10px">
  478. <el-button style="margin-right: 18px" type="primary" text bg @click="addNegative">添加</el-button>
  479. </div>
  480. </div>
  481. <div style="width: 50%">
  482. <el-card class="box-card" shadow="never" style="border: none">
  483. <template #header>
  484. <div class="card-header">
  485. <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ addedData.length }}</span>
  486. <el-button class="button" text bg @click="delAllNegative">全部删除</el-button>
  487. </div>
  488. </template>
  489. <div class="card-body">
  490. <el-table :data="tableData" style="width: 100%" :header-row-style="changeNegTableHeader">
  491. <el-table-column prop="negativeWords" label="否定词" width="auto" />
  492. <el-table-column prop="operate" label="操作" width="60" align="right">
  493. <template #default="scope">
  494. <el-button type="primary" size="small" @click="delSingleNegative(scope)" text>删除</el-button>
  495. </template>
  496. </el-table-column>
  497. </el-table>
  498. </div>
  499. </el-card>
  500. <div style="padding: 0 10px 0 10px; margin-top: -12px"></div>
  501. </div>
  502. </div>
  503. </el-form-item>
  504. <!-- 商品定向 -->
  505. <div style="font-size: 20px; font-weight: bold; margin-top: 30px" v-if="ruleForm.targetType == 'Goods'">商品定向</div>
  506. <hr v-if="ruleForm.targetType == 'Goods'" />
  507. <el-form-item style="width: 100%; margin-top: 20px" v-if="ruleForm.targetType == 'Goods'">
  508. <div
  509. style="width: 100%; height: 520px; display: flex; border: 1px solid #c2c7cf; border-radius: 6px"
  510. v-loading="productOrientationLoading">
  511. <div style="width: 50%; border-right: 1px solid #c2c7cf">
  512. <el-tabs
  513. type="border-card"
  514. stretch
  515. class="goods-orientation-tabs"
  516. style="border: 0; border-right: 0; border-bottom-left-radius: 6px; border-top-left-radius: 5px; overflow: hidden">
  517. <el-tab-pane label="品类" style="border-top-left-radius: 6px">
  518. <div style="display: flex; align-items: center">
  519. <span style="width: 40px">竞价:</span>
  520. <el-select v-model="categoryBiddingType" class="m-2" placeholder="Select">
  521. <el-option v-for="item in categoryBiddingTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
  522. </el-select>
  523. <el-input v-model="categoryBidInput" placeholder="Please input" style="width: 200px">
  524. <template #prepend>$</template>
  525. </el-input>
  526. </div>
  527. <el-tabs v-model="categoryTabs" class="category-tabs">
  528. <el-tab-pane label="建议" name="first">
  529. <el-table :data="proposalTableData" style="width: 100%" height="342">
  530. <el-table-column prop="proposal" label="建议" width="520">
  531. <template #header> 0建议 </template>
  532. </el-table-column>
  533. <el-table-column prop="address" label="Address">
  534. <template #header>
  535. <el-button type="primary" size="normal" link @click="handleGoodsAdd">全部添加</el-button>
  536. </template>
  537. <template #default="scope">
  538. <el-button type="primary" size="small" @click="addSingleGoods(scope)" text>添加</el-button>
  539. </template>
  540. </el-table-column>
  541. </el-table>
  542. </el-tab-pane>
  543. <el-tab-pane label="搜索" name="second">
  544. <el-input placeholder="请输入关键词过滤" />
  545. <el-scrollbar height="309px">
  546. <el-tree :data="searchClassifyTableData" :props="defaultProps">
  547. <template #default="{ node, data }">
  548. <span class="custom-tree-node">
  549. <span style="width: 75%">{{ node.label }}</span>
  550. <span style="color: rgb(50, 108, 216)" v-if="data.ta == true">
  551. <a @click="refine(data)"> 细化 </a>
  552. <a style="margin-left: 8px" @click="orientate(node, data)"> 定向 </a>
  553. </span>
  554. </span>
  555. </template>
  556. </el-tree>
  557. </el-scrollbar>
  558. <el-dialog v-model="visible" :title="`细化分类: ${dialogTitle}`" @close="dialogClose" destroy-on-close>
  559. <div style="display: flex; justify-content: space-between">
  560. <span>根据特定品牌、价格范围、星级和Prime配送资格,细化分类</span>
  561. <span>
  562. <el-checkbox v-model="dialogForm.isCount" label="显示商品数量" @change="isCountChanged" />
  563. </span>
  564. </div>
  565. <el-form :model="dialogForm" :rules="dialogRules" ref="dialogFormRef" style="margin-top: 20px">
  566. <el-form-item style="padding-left: 140px">
  567. <span style="margin-right: 10px; color: #616266; font-weight: 500">品牌</span>
  568. <el-select v-model="dialogForm.dialogselectValue" placeholder="请选择" v-loading="dialogSelectLoading">
  569. <el-option v-for="item in dialogForm.dialogOptions" :key="item.value" :label="item.label" :value="item.value" />
  570. </el-select>
  571. </el-form-item>
  572. <el-form-item prop="prices" style="padding-left: 112px; margin-top: 10px">
  573. <span style="margin-right: 10px; color: #616266; font-weight: 500">价格范围</span>
  574. <el-input-number v-model="dialogForm.prices.lowest" :min="1" :controls="false" placeholder="无最低商品价格" />
  575. --
  576. <el-input-number v-model="dialogForm.prices.highest" :min="1" :controls="false" placeholder="无最高商品价格" />
  577. </el-form-item>
  578. <el-form-item prop="starRating" style="padding-left: 85px; margin-top: 10px">
  579. <span style="margin-right: 15px; color: #616266; font-weight: 500">查看星级评定</span>
  580. <el-slider v-model="dialogForm.starRating" range show-stops :max="5" :marks="marks" style="width: 70%" />
  581. </el-form-item>
  582. <el-form-item prop="delivery" style="padding-left: 140px; margin-top: 30px">
  583. <span style="margin-right: 10px; color: #616266; font-weight: 500">配送</span>
  584. <el-radio-group v-model="dialogForm.delivery">
  585. <el-radio label="all" style="font-weight: 400">具备</el-radio>
  586. <el-radio label="eligible" style="font-weight: 400">具备Prime资格</el-radio>
  587. <el-radio label="diseligible" style="font-weight: 400">不具备Prime资格</el-radio>
  588. </el-radio-group>
  589. </el-form-item>
  590. </el-form>
  591. <template #footer>
  592. <div style="display: flex; justify-content: space-between">
  593. <span v-loading="countLoadig"
  594. >定位到的商品数量:
  595. <span v-if="dialogForm.isCount == true">{{ commodityCount[0]?.min }} - {{ commodityCount[0]?.max }}</span></span
  596. >
  597. <span class="dialog-footer">
  598. <el-button @click="visible = false">取消</el-button>
  599. <el-button type="primary" @click="dialogFormSubmit">确定</el-button>
  600. </span>
  601. </div>
  602. </template>
  603. </el-dialog>
  604. </el-tab-pane>
  605. </el-tabs>
  606. </el-tab-pane>
  607. <el-tab-pane label="单个商品">
  608. <div style="display: flex; align-items: center">
  609. <span style="width: 40px">竞价:</span>
  610. <el-select class="m-2" v-model="singleGoodsBidSelect" @change="singleGoodsBidSelectChanged">
  611. <el-option v-for="item in singleGoodsBidTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
  612. </el-select>
  613. <el-input
  614. v-model="singleGoodsBidInput"
  615. :disabled="singleGoodsBidSelect == 'defaultBid'"
  616. placeholder="Please input"
  617. style="width: 200px">
  618. <template #prepend>$</template>
  619. </el-input>
  620. <div style="margin-left: 20px">
  621. <span style="margin-right: 10px">类型:</span>
  622. <el-checkbox v-model="expand" label="扩展" />
  623. <el-checkbox v-model="accurate" label="精准" />
  624. </div>
  625. </div>
  626. <el-tabs v-model="singleGoodsTabs" class="category-tabs">
  627. <el-tab-pane label="建议" name="first">
  628. <el-table :data="proposalTableData" style="width: 100%" height="342">
  629. <el-table-column prop="proposal" label="商品" width="520" />
  630. <el-table-column prop="address" label="类型" />
  631. <el-table-column prop="operational" label="操作" />
  632. </el-table>
  633. </el-tab-pane>
  634. <el-tab-pane label="搜索" name="second">
  635. <el-input placeholder="按ASIN搜索"></el-input>
  636. <el-table :data="proposalTableData" style="width: 100%" height="309">
  637. <el-table-column prop="proposal" label="商品" width="520" />
  638. <el-table-column prop="address" label="类型" />
  639. <el-table-column prop="operational" label="操作" />
  640. </el-table>
  641. </el-tab-pane>
  642. <!-- TODO: 商品定向TextArea -->
  643. <el-tab-pane label="输入" name="third">待完成</el-tab-pane>
  644. </el-tabs>
  645. </el-tab-pane>
  646. </el-tabs>
  647. </div>
  648. <div style="width: 50%">
  649. <el-card class="box-card" shadow="never">
  650. <template #header>
  651. <div class="card-header">
  652. <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ productOrientationTableData.length }}</span>
  653. <el-button class="button" text bg @click="delAllCna">全部删除</el-button>
  654. </div>
  655. </template>
  656. <div class="card-body">
  657. <el-table
  658. :data="productOrientationTableData"
  659. style="width: 100%"
  660. :header-row-style="changeKeyWordsTableHeader"
  661. :header-cell-style="headerCellStyle">
  662. <el-table-column prop="cna" label="分类 & 商品" width="300">
  663. <template #default="scope"> 分类: {{ scope.row.cna }} </template>
  664. </el-table-column>
  665. <el-table-column prop="type" label="类型">
  666. <template #default="scope">
  667. {{ scope.row.type ? 'scope.row.type' : '--' }}
  668. </template>
  669. </el-table-column>
  670. <el-table-column prop="bid" label="竞价">
  671. <template #default="scope">
  672. <el-input-number v-model="scope.row.bid" :min="0" :max="1000000" :controls="false" size="small" />
  673. </template>
  674. </el-table-column>
  675. <el-table-column prop="operate" label="操作" width="60" align="right">
  676. <template #default="scope">
  677. <el-button text size="small" @click="delCna(scope.$index)">删除</el-button>
  678. </template>
  679. </el-table-column>
  680. </el-table>
  681. </div>
  682. </el-card>
  683. <div style="padding: 0 10px 0 10px; margin-top: -12px"></div>
  684. </div>
  685. </div>
  686. </el-form-item>
  687. <div
  688. style="font-size: 20px; font-weight: bold; margin-top: 30px"
  689. v-if="campaignRuleForm.type == 'AUTO' || (ruleForm.targetType == 'Goods' && campaignRuleForm.type === 'manual')">
  690. 否定商品
  691. </div>
  692. <hr v-if="campaignRuleForm.type == 'AUTO' || (ruleForm.targetType == 'Goods' && campaignRuleForm.type === 'MANUAL')" />
  693. <!-- 否定商品表格 -->
  694. <el-form-item
  695. prop="matchType"
  696. style="width: 100%; margin-top: 20px"
  697. v-if="campaignRuleForm.type == 'AUTO' || (ruleForm.targetType == 'Goods' && campaignRuleForm.type === 'MANUAL')">
  698. <div style="width: 100%; height: 520px; display: flex; border: 1px solid #e5e7ec; border-radius: 6px">
  699. <div style="width: 50%; border-right: 1px solid #e5e7ec">
  700. <el-tabs v-model="negativeTabs" class="demo-tabs" @tab-click="handleNegGoodsTabs">
  701. <el-tab-pane label="搜索" name="first">
  702. <div style="margin-bottom: 10px">
  703. <el-input placeholder="按ASIN搜索" v-model="negativeInput" @change="searchNegativeGoods" clearable />
  704. </div>
  705. <el-table
  706. height="415"
  707. style="width: 100%"
  708. v-loading="loading"
  709. :data="negativeTableData"
  710. :header-cell-style="headerCellStyle"
  711. :show-header="false">
  712. <el-table-column prop="asin" label="商品">
  713. <template #default="scope">
  714. <div style="display: flex; align-items: center">
  715. <div style="margin-right: 8px; line-height: normal">
  716. <el-image class="img-box" :src="scope.row.image_link" />
  717. </div>
  718. <div>
  719. <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top">
  720. <div class="single-line">{{ scope.row.title ? scope.row.title : '--' }}</div>
  721. </el-tooltip>
  722. <span>
  723. ASIN: <span class="data-color" style="margin-right: 8px">{{ scope.row.asin ? scope.row.asin : '--' }}</span>
  724. </span>
  725. </div>
  726. </div>
  727. </template>
  728. </el-table-column>
  729. <el-table-column prop="name" label="Name" width="120" align="right">
  730. <template #header> </template>
  731. <template #default="scope">
  732. <el-button type="primary" size="small" @click="addSingleNegativeGoods(scope)" text>添加</el-button>
  733. </template>
  734. </el-table-column>
  735. </el-table>
  736. </el-tab-pane>
  737. <el-tab-pane label="输入" name="second">
  738. <el-input
  739. v-model="ruleForm.negativeGoodsTextarea"
  740. :rows="17"
  741. type="textarea"
  742. placeholder="未完成"
  743. maxlength="11000"
  744. style="padding: 10px 10px" />
  745. <div style="display: flex; flex-direction: row-reverse; margin-top: 10px">
  746. <el-button style="margin-right: 10px" type="primary" text bg @click="addNegativeGoods">添加</el-button>
  747. </div>
  748. </el-tab-pane>
  749. </el-tabs>
  750. </div>
  751. <div style="width: 50%">
  752. <el-card class="box-card" shadow="never" style="border: none">
  753. <template #header>
  754. <div class="card-header">
  755. <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ addedNegetiveTableData.length }}</span>
  756. <el-button class="button" text bg @click="delAllNegativeGoods">全部删除</el-button>
  757. </div>
  758. </template>
  759. <div class="card-body"></div>
  760. </el-card>
  761. <div style="padding: 0 10px 0 10px; margin-top: -12px">
  762. <el-table
  763. :data="addedNegetiveTableData"
  764. height="415"
  765. style="width: 100%"
  766. :header-cell-style="headerCellStyle"
  767. @selection-change="handleAddedNegGoods">
  768. <el-table-column prop="asin" label="商品">
  769. <template #default="scope">
  770. <div style="display: flex; align-items: center">
  771. <div style="margin-right: 8px; line-height: normal">
  772. <el-image class="img-box" :src="scope.row.image_link" />
  773. </div>
  774. <div>
  775. <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top">
  776. <div class="single-line">{{ scope.row.title ? scope.row.title : '--' }}</div>
  777. </el-tooltip>
  778. <span
  779. >ASIN:
  780. <span class="data-color" style="margin-right: 8px">{{ scope.row.asin ? scope.row.asin : '--' }}</span>
  781. </span>
  782. </div>
  783. </div>
  784. </template>
  785. </el-table-column>
  786. <el-table-column label="操作" width="120" align="right">
  787. <template #default="scope">
  788. <el-button type="primary" size="small" @click="delSingleNegativeGoods(scope)" text>删除</el-button>
  789. </template>
  790. </el-table-column>
  791. </el-table>
  792. </div>
  793. </div>
  794. </div>
  795. </el-form-item>
  796. <br />
  797. <el-form-item>
  798. <el-button size="large" @click="resetForm(ruleFormRef)">取消</el-button>
  799. <el-button size="large" type="primary" plain @click="submitForm(ruleFormRef)">保存</el-button>
  800. </el-form-item>
  801. </el-form>
  802. </div>
  803. </el-card>
  804. </div>
  805. </template>
  806. <script lang="ts" setup>
  807. import { onMounted, reactive, ref, computed, watch } from 'vue'
  808. import type { CSSProperties } from 'vue'
  809. import { useRoute } from 'vue-router'
  810. import type { FormInstance, FormRules, TabsPaneContext } from 'element-plus'
  811. import { ElMessage } from 'element-plus'
  812. import { useShopInfo } from '/@/stores/shopInfo'
  813. import { usePublicData } from '/@/stores/publicData'
  814. import { storeToRefs } from 'pinia'
  815. import { useRouter } from 'vue-router'
  816. import { request } from '/@/utils/service'
  817. import { number } from 'echarts'
  818. const negativeTableData = ref([])
  819. const addedNegetiveTableData = ref([])
  820. const router = useRouter()
  821. const route = useRoute()
  822. const shopInfo = useShopInfo()
  823. const { profile } = storeToRefs(shopInfo)
  824. const loading = ref(true)
  825. const fullTableData = ref([]) // 表格数据
  826. let addedData = ref([]) // 已添加的商品数据
  827. let selections = [] // 添加选中的项
  828. let addedSels = [] // 删除选中的项
  829. const currentPage = ref() // 当前页
  830. const pageSize = ref(20) // 每页显示条目数
  831. const totalItems = ref() // 数据总量
  832. const showCard = ref(false)
  833. const activeName = ref('first')
  834. const negativeTabs = ref('first')
  835. const keyWordsTabs = ref('first')
  836. const productOrientationTabs = ref('first')
  837. const categoryTabs = ref('first')
  838. const singleGoodsTabs = ref('first')
  839. const searchInp = ref('')
  840. const select = ref('name')
  841. const select2 = ref('latest')
  842. const buttons = [{ type: 'primary', text: '添加' }] as const
  843. const negativeInput = ref('')
  844. let widelyType = ref(true)
  845. let phraseType = ref(true)
  846. let exactType = ref(true)
  847. // 表单相关数据
  848. const campaignLoading = ref(false)
  849. const formSize = ref('default')
  850. const labelPosition = ref('top')
  851. const campaignFormRef = ref<FormInstance>()
  852. interface CampaignForm {
  853. name: string
  854. adMix: string
  855. count: string
  856. startDate: string
  857. date2: string
  858. budget: string
  859. delivery: boolean
  860. type: string
  861. bidStrategy: string
  862. placeBid: string
  863. firstPage: string
  864. other: string
  865. }
  866. const campaignRuleForm = reactive<CampaignForm>({
  867. name: 'aitest02campaign_wxc',
  868. adMix: '',
  869. count: '',
  870. startDate: '',
  871. date2: '',
  872. budget: '',
  873. delivery: false,
  874. type: 'AUTO',
  875. bidStrategy: 'LEGACY_FOR_SALES',
  876. placeBid: '',
  877. firstPage: '',
  878. other: ''
  879. })
  880. const campaignRules = computed(() => ({
  881. name: [{ required: true, message: 'Please input Activity name', trigger: 'blur' }],
  882. adMix: [{ required: false, message: 'Please select Activity zone', trigger: 'change' }],
  883. count: [{ required: true, message: 'Please select Activity count', trigger: 'change' }],
  884. startDate: [{ required: true, type: 'date', message: 'Please pick a date', trigger: 'change' }],
  885. date2: [{ required: false, type: 'date', message: 'Please pick a time', trigger: 'change' }],
  886. budget: [
  887. { required: true, message: '请输入预算', trigger: 'blur' },
  888. { pattern: /^(?:[1-9]\d{0,5}|1000000)(?:\.\d{1,2})?$/, message: '预算必须是1到1000000之间的数字,小数点后最多两位', trigger: 'blur' },
  889. ],
  890. type: [{ required: false, trigger: 'change' }],
  891. bidStrategy: [{ required: true, message: 'Please select activity resource', trigger: 'change' }],
  892. placeBid: [{ required: false, pattern: /^[0-9]{1,3}$/, message: '必须是0~900之间的整数百分比', trigger: 'change' }],
  893. firstPage: [{ required: false, pattern: /^[0-9]{1,3}$/, message: '必须是0~900之间的整数百分比', trigger: 'change' }],
  894. other: [{ required: false, pattern: /^[0-9]{1,3}$/, message: '必须是0~900之间的整数百分比', trigger: 'change' }],
  895. }))
  896. const adGroupRuleFormRef = ref<FormInstance>()
  897. interface AdGroupForm {
  898. adGroupName: string
  899. defaultBidInp: string
  900. }
  901. const adGroupRuleForm = reactive<AdGroupForm>({
  902. adGroupName: '',
  903. defaultBidInp: '',
  904. })
  905. const adGroupRules = computed(() => ({
  906. adGroupName: [{ required: true, message: '请输入广告组名称', trigger: 'blur' }],
  907. defaultBidInp: [
  908. { required: true, message: '请输入默认出价', trigger: 'blur' },
  909. { validator: validateDefaultBidInp, trigger: 'blur' },
  910. ],
  911. }))
  912. function validateDefaultBidInp(rule, value, callback) {
  913. if (value === '') {
  914. callback(new Error('请输入默认出价'))
  915. } else if (!/^(0\.0[2-9]|0\.[1-9]\d|1?\d{1,2}(\.\d{1,2})?|1000(\.0{1,2})?)$/.test(value)) {
  916. callback(new Error('最小不低于0.02,最大不超过1000,并且只能有两位小数'))
  917. } else {
  918. const numericValue = parseFloat(value)
  919. const numericBudget = parseFloat(campaignRuleForm.budget)
  920. if (numericValue > numericBudget) {
  921. callback(new Error('默认出价不能大于当前预算'))
  922. } else {
  923. callback()
  924. }
  925. }
  926. }
  927. const ruleFormRef = ref<FormInstance>()
  928. interface RuleForm {
  929. autoRedirect: string
  930. closeMatch: boolean
  931. broadMatch: boolean
  932. similarProducts: boolean
  933. relatedProducts: boolean
  934. closeMatchInp: string
  935. broadMatchInp: string
  936. similarProductsInp: string
  937. relatedProductsInp: string
  938. phraseNegation: boolean
  939. preciseNegation: boolean
  940. negativeTextarea: string
  941. negativeGoodsTextarea: string
  942. targetType: string
  943. }
  944. const ruleForm = reactive<RuleForm>({
  945. autoRedirect: 'defaultBid',
  946. closeMatch: true,
  947. broadMatch: true,
  948. similarProducts: true,
  949. relatedProducts: true,
  950. closeMatchInp: '666',
  951. broadMatchInp: '666',
  952. similarProductsInp: '666',
  953. relatedProductsInp: '666',
  954. phraseNegation: true,
  955. preciseNegation: true,
  956. negativeTextarea: '',
  957. negativeGoodsTextarea: '',
  958. targetType: 'keyWords',
  959. })
  960. const rules = computed(() => ({
  961. autoRedirect: [{ required: true, trigger: 'change' }],
  962. relatedProductsInp: getValidationRules('relatedProductsInp'),
  963. similarProductsInp: getValidationRules('similarProductsInp'),
  964. broadMatchInp: getValidationRules('broadMatchInp'),
  965. closeMatchInp: getValidationRules('closeMatchInp'),
  966. }))
  967. //------------------------------------------------------------------------------方法------------------------------------------------------------------------------
  968. // 当单选按钮变化时更新showCard状态
  969. function changeBid() {
  970. console.log(ruleForm.autoRedirect)
  971. showCard.value = ruleForm.autoRedirect === 'targetBid'
  972. }
  973. // 切换投放类型
  974. function changeType() {}
  975. // 处理分页器当前页变化
  976. function handleCurrentChange(newPage) {
  977. currentPage.value = newPage
  978. loading.value = true
  979. setTableData()
  980. }
  981. // 处理分页器每页显示条目数变化
  982. function handleSizeChange(newSize) {
  983. pageSize.value = newSize
  984. currentPage.value = 1 // 重置到第一页
  985. }
  986. // ------------------------------------------投放类型模块------------------------------------------
  987. async function changeTargetType() {
  988. // console.log(ruleForm.targetType)
  989. showCard.value = ruleForm.targetType === 'keyWords'
  990. if (ruleForm.targetType === 'Goods') {
  991. productOrientationLoading.value = true
  992. await setProductOrientationData()
  993. }
  994. }
  995. // ------------------------------------------商品定向模块------------------------------------------
  996. const categoryBiddingType = ref('customBid')
  997. const categoryBiddingTypeOptions = [
  998. {
  999. value: 'defaultBid',
  1000. label: '默认竞价',
  1001. },
  1002. {
  1003. value: 'customBid',
  1004. label: '自定义竞价',
  1005. },
  1006. ]
  1007. const categoryBidInput = ref('0.75')
  1008. const singleGoodsBidSelect = ref('customBid')
  1009. const singleGoodsBidTypeOptions = [
  1010. {
  1011. value: 'defaultBid',
  1012. label: '默认竞价',
  1013. },
  1014. {
  1015. value: 'customBid',
  1016. label: '自定义竞价',
  1017. },
  1018. ]
  1019. const singleGoodsBidInput = ref('0.75')
  1020. const expand = ref(true)
  1021. const accurate = ref(false)
  1022. const proposalTableData = ref([])
  1023. const searchClassifyTableData = ref([])
  1024. const productOrientationLoading = ref(false)
  1025. const dialogSelectLoading = ref(false)
  1026. const defaultProps = {
  1027. children: 'ch',
  1028. label: 'cna',
  1029. }
  1030. const countLoadig = ref(false)
  1031. const visible = ref(false)
  1032. let dialogTitle = ref('')
  1033. let categoryId = ref('')
  1034. const dialogselectValue = ref('')
  1035. let dialogOptions: any = ref([])
  1036. const dialogForm: any = reactive({
  1037. prices: {
  1038. lowest: undefined,
  1039. highest: undefined,
  1040. },
  1041. starRating: [0, 5],
  1042. dialogselectValue: [],
  1043. delivery: 'all',
  1044. isCount: false,
  1045. })
  1046. const dialogFormRef = ref()
  1047. const dialogRules = reactive({
  1048. prices: [{ validator: validatePrices, trigger: 'blur' }],
  1049. })
  1050. interface Mark {
  1051. style: CSSProperties
  1052. label: string
  1053. }
  1054. type Marks = Record<number, Mark | string>
  1055. const marks = reactive<Marks>({
  1056. 0: '0',
  1057. 1: '1',
  1058. 2: '2',
  1059. 3: '3',
  1060. 4: '4',
  1061. 5: '5',
  1062. })
  1063. let commodityCount = ref([])
  1064. let currentDialogIndex = ref(0)
  1065. let productOrientationTableData = ref([])
  1066. async function validatePrices(rule, value) {
  1067. if (value.highest !== '' && value.lowest !== '' && value.highest <= value.lowest) {
  1068. return Promise.reject('最高价格必须大于最低价格')
  1069. }
  1070. return Promise.resolve()
  1071. }
  1072. function dialogFormSubmit() {
  1073. dialogFormRef.value.validate((valid) => {
  1074. if (valid) {
  1075. console.log('表单提交')
  1076. visible.value = false
  1077. } else {
  1078. console.log('验证失败')
  1079. }
  1080. })
  1081. }
  1082. async function setProductOrientationData() {
  1083. try {
  1084. const resp = await request({
  1085. url: '/api/ad_manage/targetable/categories/',
  1086. method: 'GET',
  1087. params: {
  1088. profile_id: profile.value.profile_id,
  1089. },
  1090. })
  1091. searchClassifyTableData.value = resp.data
  1092. productOrientationLoading.value = false
  1093. } catch (error) {
  1094. console.error('请求失败:', error)
  1095. }
  1096. }
  1097. async function setDialogOption() {
  1098. try {
  1099. const resp = await request({
  1100. url: '/api/ad_manage/categories/brands/',
  1101. method: 'GET',
  1102. params: {
  1103. profile_id: profile.value.profile_id,
  1104. category_id: categoryId.value,
  1105. },
  1106. })
  1107. const options = resp.data
  1108. dialogForm.dialogOptions = options.brands.map((brand) => {
  1109. return {
  1110. label: brand.name,
  1111. value: brand.id,
  1112. }
  1113. })
  1114. dialogSelectLoading.value = false
  1115. } catch (error) {
  1116. console.error('请求失败:', error)
  1117. }
  1118. }
  1119. async function getCount(instanceId) {
  1120. try {
  1121. const resp = await request({
  1122. url: '/api/ad_manage/products/count/',
  1123. method: 'POST',
  1124. data: {
  1125. profile_id: profile.value.profile_id,
  1126. category_id: categoryId.value,
  1127. },
  1128. })
  1129. if (instanceId === currentDialogIndex.value) {
  1130. commodityCount.value = resp.data.AsinCounts
  1131. }
  1132. } catch (error) {
  1133. console.error('请求失败:', error)
  1134. } finally {
  1135. if (instanceId === currentDialogIndex.value) {
  1136. countLoadig.value = false
  1137. }
  1138. }
  1139. }
  1140. function dialogClose() {
  1141. currentDialogIndex.value++
  1142. resetDialogForm()
  1143. dialogForm.isCount = false
  1144. commodityCount.value = []
  1145. countLoadig.value = false
  1146. }
  1147. function resetDialogForm() {
  1148. dialogForm.prices.lowest = undefined
  1149. dialogForm.prices.highest = undefined
  1150. dialogForm.starRating = [0, 5]
  1151. dialogForm.dialogselectValue = []
  1152. dialogForm.delivery = 'all'
  1153. dialogForm.isCount = false
  1154. }
  1155. function isCountChanged() {
  1156. if (dialogForm.isCount) {
  1157. const instanceId = currentDialogIndex.value
  1158. countLoadig.value = true
  1159. getCount(instanceId)
  1160. } else {
  1161. countLoadig.value = false
  1162. commodityCount.value = []
  1163. }
  1164. }
  1165. function delCna(index) {
  1166. productOrientationTableData.value.splice(index, 1)
  1167. }
  1168. function delAllCna() {
  1169. productOrientationTableData.value = []
  1170. }
  1171. function singleGoodsBidSelectChanged() {
  1172. if (singleGoodsBidSelect.value === 'defaultBid') {
  1173. singleGoodsBidInput.value = ''
  1174. }
  1175. }
  1176. function refine(data) {
  1177. console.log('🚀 ~ refine ~ data-->>', data)
  1178. commodityCount.value = []
  1179. dialogTitle.value = data.cna
  1180. categoryId.value = data.cid
  1181. visible.value = true
  1182. dialogSelectLoading.value = true
  1183. setDialogOption()
  1184. }
  1185. function orientate(node, data) {
  1186. console.log('🚀 ~ orientate ~ data-->>', data)
  1187. const exists = productOrientationTableData.value.some((item) => item.cid === data.cid)
  1188. if (!exists) {
  1189. productOrientationTableData.value.push(data)
  1190. }
  1191. }
  1192. // ------------------------------------------关键词定向模块------------------------------------------
  1193. const bidType = ref('customBid')
  1194. const bidTypeOptions = [
  1195. // 竞价select下拉选项
  1196. {
  1197. value: 'suggestBid',
  1198. label: '建议出价',
  1199. },
  1200. {
  1201. value: 'customBid',
  1202. label: '自定义出价',
  1203. },
  1204. {
  1205. value: 'defaultBid',
  1206. label: '默认出价',
  1207. },
  1208. ]
  1209. const bidInput = ref('0.75')
  1210. const keyWordsTableData = ref([]) // 关键词定向左侧表格数据
  1211. const addedKeyWordsTableData = ref([]) // 关键词定向右侧表格数据
  1212. const keyWordsTextarea = ref('')
  1213. function delAllKeyWords() {
  1214. // 删除已经添加的关键词
  1215. addedKeyWordsTableData.value = []
  1216. }
  1217. function addKeyWords() {
  1218. // 添加关键词
  1219. if (keyWordsTextarea.value) {
  1220. addedKeyWordsTableData.value.push({
  1221. keyWords: keyWordsTextarea.value,
  1222. })
  1223. keyWordsTextarea.value = ''
  1224. }
  1225. }
  1226. // ------------------------------------------广告组商品表格模块------------------------------------------
  1227. const goodsTextarea = ref('')
  1228. function setTableData(asin = '', sku = '') {
  1229. return request({
  1230. url: '/api/sellers/listings/',
  1231. method: 'GET',
  1232. params: {
  1233. page: currentPage.value,
  1234. limit: pageSize.value,
  1235. profile_id: profile.value.profile_id,
  1236. asin,
  1237. sku,
  1238. },
  1239. })
  1240. .then((resp) => {
  1241. fullTableData.value = resp.data
  1242. totalItems.value = resp.total
  1243. currentPage.value = resp.page
  1244. loading.value = false
  1245. })
  1246. .catch((error) => {
  1247. console.error('Error fetching data:', error)
  1248. loading.value = false
  1249. })
  1250. }
  1251. function addSingleGoods(scope) {
  1252. console.log('scope', scope.row)
  1253. const isAlreadyAdded = addedData.value.some((item) => item.sku === scope.row.sku)
  1254. if (!isAlreadyAdded) {
  1255. addedData.value.push(scope.row)
  1256. } else {
  1257. console.log('Item is already added.')
  1258. }
  1259. }
  1260. function addGods() {
  1261. const inputData = goodsTextarea.value
  1262. const asins = inputData.split(/[\n,]+/)
  1263. asins.forEach((asin) => {
  1264. if (asin.trim()) {
  1265. setTableData(asin.trim())
  1266. .then((response) => {
  1267. // 假设你的数据是在 response.data 中
  1268. console.log(`Data for ASIN ${asin}:`, response) // 更新这里来正确地访问数据
  1269. })
  1270. .catch((error) => {
  1271. console.error(`Error fetching data for ASIN ${asin}:`, error)
  1272. })
  1273. }
  1274. })
  1275. }
  1276. function delSingleGoods(scope) {
  1277. const index = addedData.value.findIndex((item) => item.sku === scope.row.sku)
  1278. if (index !== -1) {
  1279. addedData.value.splice(index, 1)
  1280. console.log('Item removed successfully.')
  1281. } else {
  1282. console.log('Item not found.')
  1283. }
  1284. }
  1285. function delAllGoods() {
  1286. addedData.value = []
  1287. // addedData.value.splice(0, addedData.value.length)
  1288. }
  1289. // 删除第二个table中已经选中的项
  1290. function delSelectedGoods() {
  1291. addedData.value = addedData.value.filter((item) => !addedSels.includes(item))
  1292. addedSels = []
  1293. }
  1294. function inpChange(e) {
  1295. const value = e
  1296. if (select.value === 'asin') {
  1297. loading.value = true
  1298. setTableData(value)
  1299. } else if (select.value === 'sku') {
  1300. loading.value = true
  1301. setTableData('', value)
  1302. }
  1303. }
  1304. function selChange(e) {
  1305. console.log('e', e)
  1306. const value = e
  1307. if (select.value === 'asin' && searchInp.value) {
  1308. loading.value = true
  1309. setTableData(value)
  1310. } else if (select.value === 'sku' && searchInp.value) {
  1311. loading.value = true
  1312. setTableData('', value)
  1313. }
  1314. }
  1315. // 点击表格选项触发事件
  1316. function handleSelectionChange(selection) {
  1317. selections = selection
  1318. }
  1319. // 获取addedTable中已选中的项
  1320. function handleAddedGoodsChange(selection) {
  1321. addedSels = selection
  1322. }
  1323. // 添加已选中的项
  1324. function handleGoodsAdd() {
  1325. // 过滤掉已经存在于addedData.value中的项
  1326. const newSelections = selections.filter(
  1327. (sel) => !addedData.value.some((added) => added.sku === sel.sku) // 使用sku作为唯一标识
  1328. )
  1329. // 如果有新的不重复项,加入到addedData.value中
  1330. if (newSelections.length > 0) {
  1331. addedData.value.push(...newSelections)
  1332. }
  1333. }
  1334. // 点击Tab
  1335. const handleGoodsTabs = (tab: TabsPaneContext, event: Event) => {
  1336. console.log(tab, event)
  1337. }
  1338. // ------------------------------------------否定词模块------------------------------------------
  1339. function addNegative() {
  1340. // 删除 negativeTextarea 前后的空格
  1341. const trimmedText = ruleForm.negativeTextarea.trim()
  1342. // 使用逗号和换行符分割文本
  1343. const items = trimmedText.split(/,|\n/)
  1344. // 遍历分割后的每个项目
  1345. items.forEach((item) => {
  1346. const trimmedItem = item.trim() // 删除每个项目前后的空格
  1347. if (trimmedItem) {
  1348. // 如果两者都是 true,则为每个创建两个条目
  1349. if (ruleForm.phraseNegation && ruleForm.preciseNegation) {
  1350. negativeList.push({ negativeWords: '词组: ' + trimmedItem })
  1351. negativeList.push({ negativeWords: '精确: ' + trimmedItem })
  1352. } else if (ruleForm.phraseNegation) {
  1353. negativeList.push({ negativeWords: '词组: ' + trimmedItem })
  1354. } else if (ruleForm.preciseNegation) {
  1355. negativeList.push({ negativeWords: '精确: ' + trimmedItem })
  1356. }
  1357. } else {
  1358. console.log('有空项目,未被添加到列表中')
  1359. }
  1360. })
  1361. // 清空输入框
  1362. ruleForm.negativeTextarea = ''
  1363. console.log(negativeList)
  1364. }
  1365. function delAllNegative() {
  1366. // negativeList.splice(0, negativeList.length)
  1367. negativeList.length = 0
  1368. }
  1369. function delSingleNegative(scope) {
  1370. const index = negativeList.findIndex((item) => item.negativeWords === scope.row.negativeWords)
  1371. if (negativeList.length) {
  1372. negativeList.splice(index, 1)
  1373. console.log(`已删除索引为 ${index} 的条目`)
  1374. } else {
  1375. console.log('无效的索引,无法删除条目')
  1376. }
  1377. }
  1378. // ------------------------------------------否定商品模块------------------------------------------
  1379. let negativeList = reactive([])
  1380. const tableData = negativeList
  1381. let inputAddedNegGoods = ref([])
  1382. function setNegativeTableData(asin = '') {
  1383. return request({
  1384. url: '/api/sellers/listings/',
  1385. method: 'GET',
  1386. params: {
  1387. page: currentPage.value,
  1388. limit: pageSize.value,
  1389. profile_id: profile.value.profile_id,
  1390. asin,
  1391. },
  1392. })
  1393. .then((resp) => {
  1394. negativeTableData.value = resp.data
  1395. inputAddedNegGoods.value = resp.data
  1396. loading.value = false
  1397. })
  1398. .catch((error) => {
  1399. console.error('Error fetching data:', error)
  1400. loading.value = false
  1401. })
  1402. }
  1403. // 输入tab的textarea
  1404. function addNegativeGoods() {
  1405. console.log('ruleForm.negativeGoodsTextarea', ruleForm.negativeGoodsTextarea)
  1406. loading.value = true
  1407. setNegativeTableData(ruleForm.negativeGoodsTextarea)
  1408. .then(() => {
  1409. addedNegetiveTableData.value = [...addedNegetiveTableData.value, ...inputAddedNegGoods.value]
  1410. })
  1411. .catch((error) => {
  1412. console.error('Error fetching data:', error)
  1413. })
  1414. .finally(() => {
  1415. loading.value = false
  1416. })
  1417. }
  1418. function addSingleNegativeGoods(scope) {
  1419. console.log('scope', scope.row)
  1420. const isAlreadyAdded = addedNegetiveTableData.value.some((item) => item.sku === scope.row.sku)
  1421. if (!isAlreadyAdded) {
  1422. addedNegetiveTableData.value.push(scope.row)
  1423. } else {
  1424. console.log('Item is already added.')
  1425. }
  1426. }
  1427. function delAllNegativeGoods() {
  1428. addedNegetiveTableData.value = []
  1429. }
  1430. function delSingleNegativeGoods(scope) {
  1431. const index = addedNegetiveTableData.value.findIndex((item) => item.sku === scope.row.sku)
  1432. if (index !== -1) {
  1433. addedNegetiveTableData.value.splice(index, 1)
  1434. console.log('Item removed successfully.')
  1435. } else {
  1436. console.log('Item not found.')
  1437. }
  1438. }
  1439. function searchNegativeGoods(e) {
  1440. console.log(e)
  1441. if (e === '') {
  1442. negativeTableData.value = []
  1443. } else {
  1444. setNegativeTableData(e)
  1445. }
  1446. }
  1447. function handleAddedNegGoods(selection) {
  1448. addedSels = selection
  1449. }
  1450. function handleNegGoodsTabs(tab: TabsPaneContext, event: Event) {
  1451. // console.log(tab, event)
  1452. }
  1453. // ------------------------------------------自定义校验模块------------------------------------------
  1454. function checkBid(value, callback, bidField) {
  1455. const bid = parseFloat(value)
  1456. const budget = parseFloat(campaignRuleForm.budget)
  1457. // 检查值是否为最多两位小数的普通数字格式
  1458. const isNormalNumberWithTwoDecimals = /^-?\d+(\.\d{1,2})?$/.test(value)
  1459. if (!isNormalNumberWithTwoDecimals) {
  1460. callback(new Error('请输入数字值(最多两位小数)'))
  1461. } else if (isNaN(bid)) {
  1462. callback(new Error('请输入有效的数字'))
  1463. } else if (bid < 0.02 || bid > 1000) {
  1464. callback(new Error('值必须在0.02到1000之间'))
  1465. } else if (bid >= budget) {
  1466. callback(new Error('出价必须小于预算'))
  1467. } else {
  1468. callback()
  1469. }
  1470. }
  1471. // 自定义校验规则---自动定价和按目标设置出价模块
  1472. function getValidationRules(fieldName) {
  1473. // 默认校验规则
  1474. const commonRules = [
  1475. { required: true, message: '此项为必填项', trigger: 'blur' },
  1476. { validator: (rule, value, callback) => checkBid(value, callback, fieldName), trigger: 'blur' },
  1477. ]
  1478. // 根据不同字段和状态返回特定的校验规则
  1479. switch (fieldName) {
  1480. case 'defaultBidInp':
  1481. if (ruleForm.autoRedirect === 'defaultBid') {
  1482. return commonRules
  1483. }
  1484. break
  1485. case 'similarProductsInp':
  1486. if (ruleForm.autoRedirect === 'targetBid' && ruleForm.similarProducts) {
  1487. return commonRules
  1488. } else if (ruleForm.similarProducts == false) {
  1489. ruleFormRef.value?.clearValidate(fieldName)
  1490. }
  1491. break
  1492. case 'relatedProductsInp':
  1493. if (ruleForm.autoRedirect === 'targetBid' && ruleForm.relatedProducts) {
  1494. return commonRules
  1495. } else if (ruleForm.relatedProducts == false) {
  1496. ruleFormRef.value?.clearValidate(fieldName)
  1497. }
  1498. break
  1499. case 'broadMatchInp':
  1500. if (ruleForm.autoRedirect === 'targetBid' && ruleForm.broadMatch) {
  1501. return commonRules
  1502. } else if (ruleForm.broadMatch == false) {
  1503. ruleFormRef.value?.clearValidate(fieldName)
  1504. }
  1505. break
  1506. case 'closeMatchInp':
  1507. // 仅当autoRedirect为'targetBid'且closeMatch开启时校验closeMatchInp
  1508. if (ruleForm.autoRedirect === 'targetBid' && ruleForm.closeMatch) {
  1509. return commonRules
  1510. } else if (ruleForm.closeMatch == false) {
  1511. ruleFormRef.value?.clearValidate(fieldName)
  1512. }
  1513. break
  1514. default:
  1515. return []
  1516. }
  1517. // 如果不满足上述条件,则无需校验
  1518. return []
  1519. }
  1520. // 监听表单字段变化,根据不同字段和状态返回特定的校验规则
  1521. watch(
  1522. [() => ruleForm.autoRedirect, () => ruleForm.closeMatch, () => ruleForm.broadMatch, () => ruleForm.similarProducts, () => ruleForm.relatedProducts],
  1523. () => {
  1524. // 定义需要更新校验规则的字段
  1525. const fields = ['defaultBidInp', 'closeMatchInp', 'broadMatchInp', 'similarProductsInp', 'relatedProductsInp']
  1526. fields.forEach((field) => {
  1527. rules.value[field] = getValidationRules(field)
  1528. })
  1529. }
  1530. )
  1531. // ------------------------------------------表单提交------------------------------------------
  1532. async function submitForm(formEl: FormInstance | undefined) {
  1533. if (!formEl) return
  1534. await formEl.validate((valid, fields) => {
  1535. if (valid) {
  1536. console.log('submit!')
  1537. createCampaigns()
  1538. } else {
  1539. console.log('error submit!', fields)
  1540. }
  1541. })
  1542. }
  1543. function resetForm(formEl: FormInstance | undefined) {
  1544. if (!formEl) return
  1545. formEl.resetFields()
  1546. }
  1547. let respCampaignId = ref('')
  1548. let campaignSave = ref(true)
  1549. async function createCampaigns() {
  1550. try {
  1551. // 必需字段列表
  1552. const requiredFields = [
  1553. { key: 'profile_id', value: profile.value.profile_id },
  1554. { key: 'name', value: campaignRuleForm.name },
  1555. { key: 'startDate', value: campaignRuleForm.startDate },
  1556. { key: 'targetingType', value: campaignRuleForm.type },
  1557. { key: 'strategy', value: campaignRuleForm.bidStrategy },
  1558. { key: 'budget', value: campaignRuleForm.budget },
  1559. ]
  1560. // 检查每个必需字段
  1561. requiredFields.forEach((field) => {
  1562. if (!field.value) {
  1563. throw new Error(`缺少必需的字段: ${field.key}`)
  1564. }
  1565. })
  1566. // 构建请求数据
  1567. const requestData = {
  1568. profile_id: profile.value.profile_id,
  1569. name: campaignRuleForm.name,
  1570. startDate: campaignRuleForm.startDate,
  1571. budget: campaignRuleForm.budget,
  1572. targetingType: campaignRuleForm.type,
  1573. strategy: campaignRuleForm.bidStrategy,
  1574. state: 'PAUSED',
  1575. // 可选字段
  1576. endDate: campaignRuleForm.date2,
  1577. t_percentage: campaignRuleForm.placeBid,
  1578. p_percentage: campaignRuleForm.firstPage,
  1579. r_percentage: campaignRuleForm.other,
  1580. }
  1581. // 过滤掉 undefined 或空的可选字段
  1582. const filteredRequestData = Object.fromEntries(Object.entries(requestData).filter(([_, v]) => v != null))
  1583. const resp = await request({
  1584. url: '/api/ad_manage/spcampaigns/create/',
  1585. method: 'POST',
  1586. data: filteredRequestData,
  1587. })
  1588. console.log('🚀 ~ createCampaigns ~ resp-->>', resp)
  1589. respCampaignId.value = resp.data.campaignId
  1590. if (respCampaignId.value) {
  1591. campaignSave.value = false
  1592. campaignLoading.value = false
  1593. } else {
  1594. campaignLoading.value = false
  1595. ElMessage.error('广告活动创建失败!')
  1596. }
  1597. } catch (error) {
  1598. console.error('请求失败:', error)
  1599. }
  1600. }
  1601. async function submitCampaignForm(formEl: FormInstance | undefined) {
  1602. if (!formEl) return
  1603. await formEl.validate((valid, fields) => {
  1604. if (valid) {
  1605. console.log('submit!')
  1606. campaignLoading.value = true
  1607. createCampaigns()
  1608. } else {
  1609. console.log('error submit!', fields)
  1610. }
  1611. })
  1612. }
  1613. async function createGroups() {
  1614. try {
  1615. // 构建请求数据
  1616. const requestData = {
  1617. profile_id: profile.value.profile_id,
  1618. campaignId: respCampaignId,
  1619. name: adGroupRuleForm.adGroupName,
  1620. defaultBid: adGroupRuleForm.defaultBidInp,
  1621. state: 'PAUSED',
  1622. }
  1623. // 过滤掉 undefined 或空的可选字段
  1624. const filteredRequestData = Object.fromEntries(Object.entries(requestData).filter(([_, v]) => v != null))
  1625. const resp = await request({
  1626. url: '/api/ad_manage/spgroups/create/',
  1627. method: 'POST',
  1628. data: filteredRequestData,
  1629. })
  1630. console.log('🚀 ~ createCampaigns ~ resp-->>', resp)
  1631. } catch (error) {
  1632. console.error('请求失败:', error)
  1633. }
  1634. }
  1635. async function submitGroupsForm(formEl: FormInstance | undefined) {
  1636. if (!formEl) return
  1637. await formEl.validate((valid, fields) => {
  1638. if (valid) {
  1639. console.log('submit!')
  1640. createGroups()
  1641. } else {
  1642. console.log('error submit!', fields)
  1643. }
  1644. })
  1645. }
  1646. // 修改表头样式
  1647. const headerCellStyle = (args) => {
  1648. if (args.rowIndex === 0) {
  1649. return {
  1650. backgroundColor: 'rgba(245, 245, 245, 0.9)',
  1651. }
  1652. }
  1653. }
  1654. function changeNegTableHeader(args) {
  1655. if (args.rowIndex === 0) {
  1656. return {
  1657. color: '#505968',
  1658. }
  1659. }
  1660. }
  1661. function changeKeyWordsTableHeader(args) {
  1662. if (args.rowIndex === 0) {
  1663. return {
  1664. color: '#505968',
  1665. backgroundColor: 'rgba(245, 245, 245, 0.9)',
  1666. }
  1667. }
  1668. }
  1669. onMounted(() => {
  1670. setTableData()
  1671. // const myTest = route.query
  1672. // console.log('myTest', myTest)
  1673. })
  1674. defineOptions({
  1675. name: 'SpCreateCampaigns',
  1676. })
  1677. </script>
  1678. <style lang="scss" scoped>
  1679. ::v-deep(.el-form--default.el-form--label-top .el-form-item .el-form-item__label) {
  1680. font-weight: 500;
  1681. }
  1682. .column-item .el-radio-group {
  1683. display: inline-flex;
  1684. font-size: 0;
  1685. flex-direction: column;
  1686. align-items: flex-start;
  1687. }
  1688. .radio-description {
  1689. font-size: 12px;
  1690. color: #666;
  1691. margin-top: -18px;
  1692. margin-left: 22px;
  1693. }
  1694. .radio-description-2 {
  1695. font-size: 12px;
  1696. color: #666;
  1697. margin-top: -10px;
  1698. }
  1699. .column-margin-bottom label.el-radio.is-bordered {
  1700. margin-bottom: 10px;
  1701. padding: 35px;
  1702. }
  1703. ::v-deep(.column-margin-bottom label.el-radio.is-bordered span.el-radio__inner) {
  1704. margin-top: -18px;
  1705. margin-left: -15px;
  1706. }
  1707. .gap-items {
  1708. display: flex;
  1709. justify-content: flex-start;
  1710. width: 100%;
  1711. margin-bottom: 20px;
  1712. }
  1713. .gap-item {
  1714. width: 200px;
  1715. margin-left: 30px;
  1716. color: #0b0d0d;
  1717. }
  1718. .demo-tabs > .el-tabs__content {
  1719. padding: 52px;
  1720. color: #6b778c;
  1721. font-size: 32px;
  1722. font-weight: 600;
  1723. }
  1724. /* 广告组商品Tab栏 */
  1725. ::v-deep(.el-tabs__nav-scroll) {
  1726. overflow: hidden;
  1727. margin-left: 20px;
  1728. }
  1729. ::v-deep(.el-tabs__nav-wrap::after) {
  1730. height: 2px !important;
  1731. }
  1732. ::v-deep(.el-table__inner-wrapper::before) {
  1733. background-color: white;
  1734. }
  1735. // 表格内容边距
  1736. div {
  1737. & #pane-first,
  1738. & #pane-second {
  1739. margin: 10px;
  1740. }
  1741. }
  1742. // 输入底部样式
  1743. ::v-deep(.card-box .el-card__body) {
  1744. display: flex;
  1745. align-items: center;
  1746. justify-content: space-between;
  1747. padding: 12px;
  1748. }
  1749. .card-header {
  1750. display: flex;
  1751. justify-content: space-between;
  1752. align-items: center;
  1753. }
  1754. .box-card {
  1755. width: 100%;
  1756. // margin: 10px 0 10px 10px;
  1757. margin-right: 10px;
  1758. }
  1759. .single-line {
  1760. color: rgb(30, 33, 41);
  1761. overflow: hidden;
  1762. display: -webkit-box;
  1763. -webkit-box-orient: vertical;
  1764. -webkit-line-clamp: 1;
  1765. white-space: pre-wrap;
  1766. word-break: break-word;
  1767. }
  1768. .data-color {
  1769. color: rgb(30, 33, 41);
  1770. }
  1771. .img-box {
  1772. width: 60px;
  1773. height: 60px;
  1774. margin-top: 5px;
  1775. border: 1px solid rgb(194, 199, 207);
  1776. border-radius: 4px;
  1777. }
  1778. .target-group-item {
  1779. margin-top: 15px;
  1780. }
  1781. .suggested-bid-item {
  1782. margin-left: 230px;
  1783. margin-right: 60px;
  1784. }
  1785. .bid-input {
  1786. width: 200px;
  1787. margin-left: 15px;
  1788. }
  1789. ::v-deep(.goods-orientation-tabs .el-tabs__nav-scroll) {
  1790. margin-left: -20px !important;
  1791. }
  1792. ::v-deep(.category-tabs .el-tabs__nav) {
  1793. margin-left: 20px;
  1794. }
  1795. ::v-deep(.goods-orientation-tabs #tab-1) {
  1796. /* 商品定向Tab栏 */
  1797. border-right: 0;
  1798. }
  1799. .custom-tree-node {
  1800. /* el-tree自定义样式 */
  1801. flex: 1;
  1802. display: flex;
  1803. align-items: center;
  1804. justify-content: space-between;
  1805. font-size: 14px;
  1806. padding-right: 8px;
  1807. }
  1808. .dialog-head {
  1809. /* 弹窗样式 */
  1810. display: flex;
  1811. flex-direction: row;
  1812. justify-content: space-between;
  1813. }
  1814. </style>