index.vue 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132
  1. <template>
  2. <div>
  3. <el-card>
  4. <div style="padding-left: 5px">
  5. <!-- 广告活动 -->
  6. <div style="font-size: 20px; font-weight: bold">广告活动</div>
  7. <hr />
  8. <br />
  9. <el-form
  10. :label-position="labelPosition"
  11. ref="ruleFormRef"
  12. :model="ruleForm"
  13. :rules="rules"
  14. label-width="120px"
  15. class="demo-ruleForm"
  16. :size="formSize"
  17. status-icon>
  18. <el-form-item label="广告活动名称" prop="name" style="width: 350px">
  19. <el-input v-model="ruleForm.name" />
  20. </el-form-item>
  21. <el-form-item label="广告组合" prop="adMix">
  22. <el-select v-model="ruleForm.adMix" placeholder="请选择">
  23. <el-option label="Zone one" value="shanghai" />
  24. <el-option label="Zone two" value="beijing" />
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item prop="date1" label="开始日期" style="width: 350px">
  28. <el-date-picker v-model="ruleForm.date1" type="date" label="开始日期" placeholder="开始日期" style="width: 100%" />
  29. </el-form-item>
  30. <el-form-item prop="date2" label="结束日期" style="width: 350px">
  31. <el-date-picker v-model="ruleForm.date2" label="结束日期" placeholder="结束日期" style="width: 100%" />
  32. </el-form-item>
  33. <el-form-item prop="budget" label="每日预算" style="width: 350px">
  34. <el-input v-model="ruleForm.budget" maxlength="7" oninput="value=value.indexOf('.') > -1?value.slice(0, value.indexOf('.') + 3):value" />
  35. </el-form-item>
  36. <el-form-item label="投放类型" prop="type" class="column-item">
  37. <el-radio-group v-model="ruleForm.type" @click="changeType">
  38. <div>
  39. <el-radio label="auto">自动</el-radio>
  40. <div class="radio-description">定向与您推广商品相似的关键词和商品</div>
  41. </div>
  42. <div>
  43. <el-radio label="manual">手动</el-radio>
  44. <div class="radio-description">选择关键词或商品以定向购物者搜索并设置自定义出价</div>
  45. </div>
  46. </el-radio-group>
  47. </el-form-item>
  48. <el-form-item label="竞价策略" prop="bidStrategy" class="column-item column-margin-bottom">
  49. <el-radio-group v-model="ruleForm.bidStrategy">
  50. <div>
  51. <el-radio label="dynamicBid_Low" border>
  52. 动态竞价-仅降低
  53. <div class="radio-description-2">当您的广告不太可能带来销售时,我们将实时降低您的竞价</div>
  54. </el-radio>
  55. </div>
  56. <div>
  57. <el-radio label="dynamicBid_HighAndLow" border>
  58. 动态竞价-提高和降低
  59. <div class="radio-description-2">
  60. 当您的广告很有可能带来销售时,我们将实时提高您的竞价(最高可达 100%),并在您的广告不太可能带来销售时降低您的竞价
  61. </div>
  62. </el-radio>
  63. </div>
  64. <el-radio label="staticBid" border>
  65. 固定竞价
  66. <div class="radio-description-2">我们将使用您的确切竞价和您设置的任何手动调整,而不会根据售出可能性对您的竞价进行更改</div>
  67. </el-radio>
  68. </el-radio-group>
  69. </el-form-item>
  70. <el-form-item label="按展示位置调整出价" prop="placeBid">
  71. <p style="color: #8e9196">除了出价策略外,您还可以将出价提高多达900%</p>
  72. <div class="gap-items">
  73. <div class="gap-item">搜索结果顶部(首页)</div>
  74. <el-input v-model="ruleForm.placeBid" class="gap-item">
  75. <template #append>%</template>
  76. </el-input>
  77. </div>
  78. <div class="gap-items">
  79. <div class="gap-item">商品首页</div>
  80. <el-input v-model="ruleForm.firstPage" class="gap-item">
  81. <template #append>%</template>
  82. </el-input>
  83. </div>
  84. <div class="gap-items">
  85. <div class="gap-item">搜索结果的其余位置</div>
  86. <el-input v-model="ruleForm.other" class="gap-item">
  87. <template #append>%</template>
  88. </el-input>
  89. </div>
  90. </el-form-item>
  91. <!-- 广告组 -->
  92. <div style="font-size: 20px; font-weight: bold; margin-top: 30px">广告组</div>
  93. <hr />
  94. <el-form-item label="广告组名称" prop="adGroupName" style="width: 350px; margin-top: 20px">
  95. <el-input v-model="ruleForm.adGroupName" />
  96. </el-form-item>
  97. <!-- 广告组商品表格 -->
  98. <el-form-item label="商品" prop="commodity" style="width: 100%; margin-top: 20px">
  99. <div style="width: 100%; height: 620px; display: flex; border: 1px solid #c2c7cf; border-radius: 6px">
  100. <div style="width: 50%; border-right: 1px solid #c2c7cf">
  101. <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleGoodsTabs">
  102. <el-tab-pane label="搜索" name="first">
  103. <div style="margin-bottom: 10px">
  104. <el-input v-model="searchInp" placeholder="Please input" class="input-with-select" @change="inpChange" clearable>
  105. <template #prepend>
  106. <el-select v-model="select" style="width: 100px" @change="selChange">
  107. <el-option label="名称" value="name" />
  108. <el-option label="ASIN" value="asin" />
  109. <el-option label="SKU" value="sku" />
  110. </el-select>
  111. </template>
  112. <template #append>
  113. <el-select v-model="select2" style="width: 100px">
  114. <el-option label="最新优先" value="latest" />
  115. <el-option label="最早优先" value="earliest" />
  116. <el-option label="优选广告" value="optimal" />
  117. </el-select>
  118. </template>
  119. </el-input>
  120. </div>
  121. <el-table
  122. height="490"
  123. style="width: 100%"
  124. v-loading="loading"
  125. :data="fullTableData"
  126. :header-cell-style="headerCellStyle"
  127. @selection-change="handleSelectionChange">
  128. <el-table-column type="selection" width="50" />
  129. <el-table-column prop="asin" label="商品">
  130. <template #default="scope">
  131. <div style="display: flex; align-items: center">
  132. <div style="margin-right: 8px; line-height: normal">
  133. <el-image class="img-box" :src="scope.row.image_link" />
  134. </div>
  135. <div>
  136. <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top">
  137. <div class="single-line">{{ scope.row.title ? scope.row.title : '--' }}</div>
  138. </el-tooltip>
  139. <div class="data-color">
  140. <span style="font-weight: 500; color: rgb(30, 33, 41)">${{ scope.row.price ? scope.row.price : '--' }}</span>
  141. <span style="margin: 0 5px; color: #cacdd4">|</span>
  142. <span style="color: #6d7784">{{ scope.row.quantity }}</span>
  143. </div>
  144. <span>
  145. ASIN: <span class="data-color" style="margin-right: 8px">{{ scope.row.asin ? scope.row.asin : '--' }}</span>
  146. </span>
  147. <span>
  148. SKU: <span class="data-color">{{ scope.row.sku ? scope.row.sku : '--' }}</span>
  149. </span>
  150. </div>
  151. </div>
  152. </template>
  153. </el-table-column>
  154. <el-table-column prop="name" label="Name" width="120" align="right">
  155. <template #header>
  156. <el-button type="primary" size="normal" link @click="handleGoodsAdd">添加已选中</el-button>
  157. </template>
  158. <template #default="scope">
  159. <el-button type="primary" size="small" @click="addSingleGoods(scope)" text>添加</el-button>
  160. </template>
  161. </el-table-column>
  162. </el-table>
  163. <el-pagination
  164. @current-change="handleCurrentChange"
  165. @size-change="handleSizeChange"
  166. :current-page="currentPage"
  167. :page-size="pageSize"
  168. :total="totalItems"
  169. layout="prev, pager, next" />
  170. </el-tab-pane>
  171. <el-tab-pane label="输入" name="second">
  172. <el-input
  173. style="padding: 10px;"
  174. v-model="textarea"
  175. :rows="20"
  176. type="textarea"
  177. placeholder="请输入ASIN,多个ASIN使用逗号、空格或换行符分隔。"
  178. maxlength="11000" />
  179. <div style="display: flex; flex-direction: row-reverse; margin-top: 10px">
  180. <el-button v-for="button in buttons" :key="button.text" :type="button.type" link>{{ button.text }}</el-button>
  181. </div>
  182. <!-- <el-row :gutter="12" style="margin-top: 50px">
  183. <el-col :span="12">
  184. <el-card class="card-box" shadow="never" style="border: none; background-color: #e3f0de; height: 50px">
  185. <div style="line-height: 15px">成功添加:</div>
  186. <div style="line-height: 15px">
  187. <el-icon style="color: #8fc47d; font-size: 25px"><SuccessFilled /></el-icon>
  188. </div>
  189. </el-card>
  190. </el-col>
  191. <el-col :span="12">
  192. <el-card class="card-box" shadow="never" style="border: none; background-color: #fbe6e3; height: 50px">
  193. <div style="line-height: 15px">未成功添加:</div>
  194. <div style="line-height: 15px">
  195. <el-icon style="color: #e3918d; font-size: 25px"><CircleCloseFilled /></el-icon>
  196. </div>
  197. </el-card>
  198. </el-col>
  199. </el-row> -->
  200. </el-tab-pane>
  201. </el-tabs>
  202. </div>
  203. <div style="width: 50%">
  204. <el-card class="box-card" shadow="never">
  205. <template #header>
  206. <div class="card-header">
  207. <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ addedData.length }}</span>
  208. <el-button class="button" text bg @click="delAllGoods">全部删除</el-button>
  209. </div>
  210. </template>
  211. <!-- <div v-for="o in 4" :key="o" class="text item">{{ 'List item ' + o }}</div> -->
  212. <div class="card-body"></div>
  213. <!-- <template #footer>Footer content</template> -->
  214. </el-card>
  215. <div style="padding: 0 10px 0 10px; margin-top: -12px">
  216. <el-table
  217. :data="addedData"
  218. height="520"
  219. style="width: 100%"
  220. :header-cell-style="headerCellStyle"
  221. @selection-change="handleAddedGoodsChange">
  222. <el-table-column type="selection" width="50" />
  223. <el-table-column prop="asin" label="ASIN">
  224. <template #default="scope">
  225. <div style="display: flex; align-items: center">
  226. <div style="margin-right: 8px; line-height: normal">
  227. <el-image class="img-box" :src="scope.row.image_link" />
  228. </div>
  229. <div>
  230. <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top">
  231. <div class="single-line">{{ scope.row.title ? scope.row.title : '--' }}</div>
  232. </el-tooltip>
  233. <div class="data-color">
  234. <span style="font-weight: 500; color: rgb(30, 33, 41)">${{ scope.row.price ? scope.row.price : '--' }}</span>
  235. <span style="margin: 0 5px; color: #cacdd4">|</span>
  236. <span style="color: #6d7784">{{ scope.row.quantity }}</span>
  237. </div>
  238. <span
  239. >ASIN:
  240. <span class="data-color" style="margin-right: 8px">{{ scope.row.asin ? scope.row.asin : '--' }}</span>
  241. </span>
  242. <span
  243. >SKU:
  244. <span class="data-color">{{ scope.row.sku ? scope.row.sku : '--' }}</span>
  245. </span>
  246. </div>
  247. </div>
  248. </template>
  249. </el-table-column>
  250. <el-table-column prop="name" label="Name" width="120" align="right">
  251. <template #header>
  252. <el-button type="primary" size="normal" link @click="delSelectedGoods">删除已选中</el-button>
  253. </template>
  254. <template #default="scope">
  255. <el-button type="primary" size="small" @click="delSingleGoods(scope)" text>删除</el-button>
  256. </template>
  257. </el-table-column>
  258. </el-table>
  259. </div>
  260. </div>
  261. </div>
  262. </el-form-item>
  263. <!-- 自动定向 -->
  264. <div class="column-item">
  265. <p style="color: #606266; font-weight: 450"><span style="color: #e47470">*</span> 自动定向</p>
  266. <el-radio-group v-model="ruleForm.autoRedirect" @change="changeBid">
  267. <div style="display: flex">
  268. <el-radio label="defaultBid">设置默认出价</el-radio>
  269. <el-form-item prop="defaultBidInp">
  270. <el-input v-model="ruleForm.defaultBidInp" label="ruleForm.defaultBidInp" style="width: 200px">
  271. <template #prepend>$</template>
  272. </el-input>
  273. </el-form-item>
  274. </div>
  275. <div>
  276. <el-radio label="targetBid">按目标组设置出价</el-radio>
  277. </div>
  278. </el-radio-group>
  279. </div>
  280. <!-- 自动定向---按目标组设置出价 -->
  281. <el-card v-if="showCard" class="box-card">
  282. <div>
  283. <div style="color: #8e9095">
  284. <span>目标群体</span>
  285. <span class="suggested-bid-item">建议竞价</span>
  286. <span>竞价</span>
  287. </div>
  288. <div style="display: flex">
  289. <el-switch v-model="ruleForm.closeMatch" size="small" active-text="紧密匹配" />
  290. <span class="suggested-bid-item">--</span>
  291. <el-form-item prop="closeMatchInp">
  292. <el-input :disabled="!ruleForm.closeMatch" v-model="ruleForm.closeMatchInp" placeholder="Please input" class="bid-input">
  293. <template #prepend>$</template>
  294. </el-input>
  295. </el-form-item>
  296. </div>
  297. <div>
  298. <div style="display: flex">
  299. <el-switch v-model="ruleForm.broadMatch" size="small" active-text="广泛匹配" />
  300. <span class="suggested-bid-item">--</span>
  301. <el-form-item prop="broadMatchInp">
  302. <el-input :disabled="!ruleForm.broadMatch" v-model="ruleForm.broadMatchInp" placeholder="Please input" class="bid-input">
  303. <template #prepend>$</template>
  304. </el-input>
  305. </el-form-item>
  306. </div>
  307. </div>
  308. <div>
  309. <div style="display: flex">
  310. <el-switch v-model="ruleForm.similarProducts" size="small" active-text="同类商品" />
  311. <span class="suggested-bid-item">--</span>
  312. <el-form-item prop="similarProductsInp">
  313. <el-input
  314. :disabled="!ruleForm.similarProducts"
  315. v-model="ruleForm.similarProductsInp"
  316. placeholder="Please input"
  317. class="bid-input">
  318. <template #prepend>$</template>
  319. </el-input>
  320. </el-form-item>
  321. </div>
  322. </div>
  323. <div>
  324. <div style="display: flex">
  325. <el-switch v-model="ruleForm.relatedProducts" size="small" active-text="关联商品" />
  326. <span class="suggested-bid-item">--</span>
  327. <el-form-item prop="relatedProductsInp">
  328. <el-input
  329. :disabled="!ruleForm.relatedProducts"
  330. v-model="ruleForm.relatedProductsInp"
  331. placeholder="Please input"
  332. class="bid-input">
  333. <template #prepend>$</template>
  334. </el-input>
  335. </el-form-item>
  336. </div>
  337. </div>
  338. </div>
  339. </el-card>
  340. <el-form-item label="手动" v-if="ruleForm.type === 'manual'">
  341. <el-card>1233</el-card>
  342. </el-form-item>
  343. <div style="font-size: 20px; font-weight: bold; margin-top: 30px">否定词</div>
  344. <hr />
  345. <!-- 否定词表格 -->
  346. <el-form-item prop="matchType" style="width: 100%; margin-top: 20px">
  347. <div style="width: 100%; height: 520px; display: flex; border: 1px solid #c2c7cf; border-radius: 6px">
  348. <div style="width: 50%; border-right: 1px solid #c2c7cf">
  349. <div style="margin: 10px 0">
  350. <span style="margin-left: 25px; color: #e47470">*</span>
  351. <span style="color: #666666; margin-right: 10px">匹配类型: </span>
  352. <el-checkbox v-model="ruleForm.phraseNegation" label="词组否定" />
  353. <el-checkbox v-model="ruleForm.preciseNegation" label="精确否定" />
  354. </div>
  355. <el-input
  356. v-model="ruleForm.negativeTextarea"
  357. :rows="17"
  358. type="textarea"
  359. placeholder="请输入关键词,多个关键词使用逗号或者换行符分隔。(最多添加1000个关键词)"
  360. maxlength="11000"
  361. style="padding: 0 20px" />
  362. <div style="display: flex; flex-direction: row-reverse; margin-top: 10px">
  363. <el-button style="margin-right: 18px" type="primary" text bg @click="addNegative">添加</el-button>
  364. </div>
  365. </div>
  366. <div style="width: 50%">
  367. <el-card class="box-card" shadow="never">
  368. <template #header>
  369. <div class="card-header">
  370. <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ addedData.length }}</span>
  371. <el-button class="button" text bg @click="delAllNegative">全部删除</el-button>
  372. </div>
  373. </template>
  374. <div class="card-body">
  375. <el-table :data="tableData" style="width: 100%" :header-row-style="changeNegTableHeader">
  376. <el-table-column prop="negativeWords" label="否定词" width="auto" />
  377. <el-table-column prop="operate" label="操作" width="60" align="right">
  378. <template #default="scope">
  379. <el-button type="primary" size="small" @click="delSingleNegative(scope)" text>删除</el-button>
  380. </template>
  381. </el-table-column>
  382. </el-table>
  383. </div>
  384. </el-card>
  385. <div style="padding: 0 10px 0 10px; margin-top: -12px"></div>
  386. </div>
  387. </div>
  388. </el-form-item>
  389. <div style="font-size: 20px; font-weight: bold; margin-top: 30px">否定商品</div>
  390. <hr />
  391. <!-- 否定商品表格 -->
  392. <el-form-item prop="matchType" style="width: 100%; margin-top: 20px">
  393. <div style="width: 100%; height: 520px; display: flex; border: 1px solid #c2c7cf; border-radius: 6px">
  394. <div style="width: 50%; border-right: 1px solid #c2c7cf">
  395. <el-tabs v-model="negativeTabs" class="demo-tabs" @tab-click="handleNegGoodsTabs">
  396. <el-tab-pane label="搜索" name="first">
  397. <div style="margin-bottom: 10px">
  398. <el-input placeholder="按ASIN搜索" v-model="negativeInput" @change="searchNegativeGoods" clearable />
  399. </div>
  400. <el-table
  401. height="415"
  402. style="width: 100%"
  403. v-loading="loading"
  404. :data="negativeTableData"
  405. :header-cell-style="headerCellStyle"
  406. :show-header="false">
  407. <el-table-column prop="asin" label="商品">
  408. <template #default="scope">
  409. <div style="display: flex; align-items: center">
  410. <div style="margin-right: 8px; line-height: normal">
  411. <el-image class="img-box" :src="scope.row.image_link" />
  412. </div>
  413. <div>
  414. <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top">
  415. <div class="single-line">{{ scope.row.title ? scope.row.title : '--' }}</div>
  416. </el-tooltip>
  417. <span>
  418. ASIN: <span class="data-color" style="margin-right: 8px">{{ scope.row.asin ? scope.row.asin : '--' }}</span>
  419. </span>
  420. </div>
  421. </div>
  422. </template>
  423. </el-table-column>
  424. <el-table-column prop="name" label="Name" width="120" align="right">
  425. <template #header> </template>
  426. <template #default="scope">
  427. <el-button type="primary" size="small" @click="addSingleNegativeGoods(scope)" text>添加</el-button>
  428. </template>
  429. </el-table-column>
  430. </el-table>
  431. </el-tab-pane>
  432. <el-tab-pane label="输入" name="second">
  433. <el-input
  434. v-model="ruleForm.negativeGoodsTextarea"
  435. :rows="17"
  436. type="textarea"
  437. placeholder="请输入关键词,多个关键词使用逗号或者换行符分隔。(最多添加1000个关键词)"
  438. maxlength="11000"
  439. style="padding: 10px 10px" />
  440. <div style="display: flex; flex-direction: row-reverse; margin-top: 10px">
  441. <el-button style="margin-right: 10px" type="primary" text bg @click="addNegativeGoods">添加</el-button>
  442. </div>
  443. </el-tab-pane>
  444. </el-tabs>
  445. </div>
  446. <div style="width: 50%">
  447. <el-card class="box-card" shadow="never">
  448. <template #header>
  449. <div class="card-header">
  450. <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ addedNegetiveTableData.length }}</span>
  451. <el-button class="button" text bg @click="delAllNegativeGoods">全部删除</el-button>
  452. </div>
  453. </template>
  454. <div class="card-body"></div>
  455. </el-card>
  456. <div style="padding: 0 10px 0 10px; margin-top: -12px">
  457. <el-table
  458. :data="addedNegetiveTableData"
  459. height="415"
  460. style="width: 100%"
  461. :header-cell-style="headerCellStyle"
  462. @selection-change="handleAddedNegGoods">
  463. <el-table-column prop="asin" label="商品">
  464. <template #default="scope">
  465. <div style="display: flex; align-items: center">
  466. <div style="margin-right: 8px; line-height: normal">
  467. <el-image class="img-box" :src="scope.row.image_link" />
  468. </div>
  469. <div>
  470. <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top">
  471. <div class="single-line">{{ scope.row.title ? scope.row.title : '--' }}</div>
  472. </el-tooltip>
  473. <span
  474. >ASIN:
  475. <span class="data-color" style="margin-right: 8px">{{ scope.row.asin ? scope.row.asin : '--' }}</span>
  476. </span>
  477. </div>
  478. </div>
  479. </template>
  480. </el-table-column>
  481. <el-table-column label="操作" width="120" align="right">
  482. <template #default="scope">
  483. <el-button type="primary" size="small" @click="delSingleNegativeGoods(scope)" text>删除</el-button>
  484. </template>
  485. </el-table-column>
  486. </el-table>
  487. </div>
  488. </div>
  489. </div>
  490. </el-form-item>
  491. <br />
  492. <el-form-item>
  493. <el-button type="negativeGoods" @click="submitForm(ruleFormRef)">Create</el-button>
  494. <el-button @click="resetForm(ruleFormRef)">Reset</el-button>
  495. </el-form-item>
  496. </el-form>
  497. </div>
  498. </el-card>
  499. </div>
  500. </template>
  501. <script lang="ts" setup>
  502. import { onMounted, reactive, ref, computed, watch } from 'vue'
  503. import { useRoute } from 'vue-router'
  504. import type { FormInstance, FormRules, TabsPaneContext } from 'element-plus'
  505. import { useShopInfo } from '/@/stores/shopInfo'
  506. import { usePublicData } from '/@/stores/publicData'
  507. import { storeToRefs } from 'pinia'
  508. import { useRouter } from 'vue-router'
  509. import { request } from '/@/utils/service'
  510. const negativeTableData = ref([])
  511. const addedNegetiveTableData = ref([])
  512. const router = useRouter()
  513. const route = useRoute()
  514. const shopInfo = useShopInfo()
  515. const { profile } = storeToRefs(shopInfo)
  516. const loading = ref(true)
  517. const fullTableData = ref([]) // 表格数据
  518. let addedData = ref([]) // 已添加的商品数据
  519. let selections = [] // 添加选中的项
  520. let addedSels = [] // 删除选中的项
  521. const currentPage = ref() // 当前页
  522. const pageSize = ref(20) // 每页显示条目数
  523. const totalItems = ref() // 数据总量
  524. const showCard = ref(false)
  525. const activeName = ref('first')
  526. const negativeTabs = ref('first')
  527. const searchInp = ref('')
  528. const select = ref('name')
  529. const select2 = ref('latest')
  530. const textarea = ref('')
  531. const buttons = [{ type: 'primary', text: '添加' }] as const
  532. const negativeInput = ref('')
  533. // 表单相关数据
  534. const formSize = ref('default')
  535. const labelPosition = ref('top')
  536. const ruleFormRef = ref<FormInstance>()
  537. interface RuleForm {
  538. name: string
  539. adMix: string
  540. count: string
  541. date1: string
  542. date2: string
  543. budget: string
  544. delivery: boolean
  545. type: string
  546. bidStrategy: string
  547. placeBid: string
  548. firstPage: string
  549. other: string
  550. adGroupName: string
  551. autoRedirect: string
  552. defaultBidInp: string
  553. closeMatch: boolean
  554. broadMatch: boolean
  555. similarProducts: boolean
  556. relatedProducts: boolean
  557. closeMatchInp: string
  558. broadMatchInp: string
  559. similarProductsInp: string
  560. relatedProductsInp: string
  561. phraseNegation: boolean
  562. preciseNegation: boolean
  563. negativeTextarea: string
  564. negativeGoodsTextarea: string
  565. }
  566. const ruleForm = reactive<RuleForm>({
  567. name: 'Hello',
  568. adMix: '',
  569. count: '',
  570. date1: '',
  571. date2: '',
  572. budget: '',
  573. delivery: false,
  574. type: 'auto',
  575. bidStrategy: 'dynamicBid_Low',
  576. placeBid: '',
  577. firstPage: '',
  578. other: '',
  579. adGroupName: '',
  580. autoRedirect: 'defaultBid',
  581. defaultBidInp: '',
  582. closeMatch: true,
  583. broadMatch: true,
  584. similarProducts: true,
  585. relatedProducts: true,
  586. closeMatchInp: '666',
  587. broadMatchInp: '666',
  588. similarProductsInp: '666',
  589. relatedProductsInp: '666',
  590. phraseNegation: true,
  591. preciseNegation: true,
  592. negativeTextarea: '',
  593. negativeGoodsTextarea: '',
  594. })
  595. const rules = computed(() => ({
  596. name: [{ required: true, message: 'Please input Activity name', trigger: 'blur' }],
  597. adMix: [{ required: false, message: 'Please select Activity zone', trigger: 'change' }],
  598. count: [{ required: true, message: 'Please select Activity count', trigger: 'change' }],
  599. date1: [{ required: true, type: 'date', message: 'Please pick a date', trigger: 'change' }],
  600. date2: [{ required: false, type: 'date', message: 'Please pick a time', trigger: 'change' }],
  601. budget: [
  602. { required: true, message: '请输入预算', trigger: 'blur' },
  603. { pattern: /^(?:[1-9]\d{0,5}|1000000)(?:\.\d{1,2})?$/, message: '预算必须是1到1000000之间的数字,小数点后最多两位', trigger: 'blur' },
  604. ],
  605. type: [{ required: false, trigger: 'change' }],
  606. bidStrategy: [{ required: true, message: 'Please select activity resource', trigger: 'change' }],
  607. placeBid: [{ required: false, pattern: /^[0-9]{1,3}$/, message: '必须是0~900之间的整数百分比', trigger: 'change' }],
  608. firstPage: [{ required: false, pattern: /^[0-9]{1,3}$/, message: '必须是0~900之间的整数百分比', trigger: 'change' }],
  609. other: [{ required: false, pattern: /^[0-9]{1,3}$/, message: '必须是0~900之间的整数百分比', trigger: 'change' }],
  610. adGroupName: [{ required: true, message: 'Please input Activity name', trigger: 'blur' }],
  611. autoRedirect: [{ required: true, trigger: 'change' }],
  612. defaultBidInp: getValidationRules('defaultBidInp'),
  613. relatedProductsInp: getValidationRules('relatedProductsInp'),
  614. similarProductsInp: getValidationRules('similarProductsInp'),
  615. broadMatchInp: getValidationRules('broadMatchInp'),
  616. closeMatchInp: getValidationRules('closeMatchInp'),
  617. }))
  618. //------------------------------------------------------------------------------方法------------------------------------------------------------------------------
  619. // 当单选按钮变化时更新showCard状态
  620. function changeBid() {
  621. console.log(ruleForm.autoRedirect)
  622. showCard.value = ruleForm.autoRedirect === 'targetBid'
  623. }
  624. // 切换投放类型
  625. function changeType() {}
  626. // 处理分页器当前页变化
  627. function handleCurrentChange(newPage) {
  628. currentPage.value = newPage
  629. loading.value = true
  630. setTableData()
  631. }
  632. // 处理分页器每页显示条目数变化
  633. function handleSizeChange(newSize) {
  634. pageSize.value = newSize
  635. currentPage.value = 1 // 重置到第一页
  636. }
  637. // ---------------------广告组商品表格模块---------------------
  638. function setTableData(asin = '', sku = '') {
  639. return request({
  640. url: '/api/sellers/listings/',
  641. method: 'GET',
  642. params: {
  643. page: currentPage.value,
  644. limit: pageSize.value,
  645. profile_id: profile.value.profile_id,
  646. asin,
  647. sku,
  648. },
  649. })
  650. .then((resp) => {
  651. fullTableData.value = resp.data
  652. totalItems.value = resp.total
  653. currentPage.value = resp.page
  654. loading.value = false
  655. })
  656. .catch((error) => {
  657. console.error('Error fetching data:', error)
  658. loading.value = false
  659. })
  660. }
  661. function addSingleGoods(scope) {
  662. console.log('scope', scope.row)
  663. const isAlreadyAdded = addedData.value.some((item) => item.sku === scope.row.sku)
  664. if (!isAlreadyAdded) {
  665. addedData.value.push(scope.row)
  666. } else {
  667. console.log('Item is already added.')
  668. }
  669. }
  670. function delSingleGoods(scope) {
  671. const index = addedData.value.findIndex((item) => item.sku === scope.row.sku)
  672. if (index !== -1) {
  673. addedData.value.splice(index, 1)
  674. console.log('Item removed successfully.')
  675. } else {
  676. console.log('Item not found.')
  677. }
  678. }
  679. function delAllGoods() {
  680. addedData.value = []
  681. // addedData.value.splice(0, addedData.value.length)
  682. }
  683. // 删除第二个table中已经选中的项
  684. function delSelectedGoods() {
  685. addedData.value = addedData.value.filter((item) => !addedSels.includes(item))
  686. addedSels = []
  687. }
  688. function inpChange(e) {
  689. const value = e
  690. if (select.value === 'asin') {
  691. loading.value = true
  692. setTableData(value)
  693. } else if (select.value === 'sku') {
  694. loading.value = true
  695. setTableData('', value)
  696. }
  697. }
  698. function selChange(e) {
  699. console.log('e', e)
  700. const value = e
  701. if (select.value === 'asin' && searchInp.value) {
  702. loading.value = true
  703. setTableData(value)
  704. } else if (select.value === 'sku' && searchInp.value) {
  705. loading.value = true
  706. setTableData('', value)
  707. }
  708. }
  709. // 点击表格选项触发事件
  710. function handleSelectionChange(selection) {
  711. selections = selection
  712. }
  713. // 获取addedTable中已选中的项
  714. function handleAddedGoodsChange(selection) {
  715. addedSels = selection
  716. }
  717. // 添加已选中的项
  718. function handleGoodsAdd() {
  719. // 过滤掉已经存在于addedData.value中的项
  720. const newSelections = selections.filter(
  721. (sel) => !addedData.value.some((added) => added.sku === sel.sku) // 使用sku作为唯一标识
  722. )
  723. // 如果有新的不重复项,加入到addedData.value中
  724. if (newSelections.length > 0) {
  725. addedData.value.push(...newSelections)
  726. }
  727. }
  728. // 点击Tab
  729. const handleGoodsTabs = (tab: TabsPaneContext, event: Event) => {
  730. console.log(tab, event)
  731. }
  732. // ---------------------否定词模块---------------------
  733. function addNegative() {
  734. // 删除 negativeTextarea 前后的空格
  735. const trimmedText = ruleForm.negativeTextarea.trim()
  736. // 使用逗号和换行符分割文本
  737. const items = trimmedText.split(/,|\n/)
  738. // 遍历分割后的每个项目
  739. items.forEach((item) => {
  740. const trimmedItem = item.trim() // 删除每个项目前后的空格
  741. if (trimmedItem) {
  742. // 如果两者都是 true,则为每个创建两个条目
  743. if (ruleForm.phraseNegation && ruleForm.preciseNegation) {
  744. negativeList.push({ negativeWords: '词组: ' + trimmedItem })
  745. negativeList.push({ negativeWords: '精确: ' + trimmedItem })
  746. } else if (ruleForm.phraseNegation) {
  747. negativeList.push({ negativeWords: '词组: ' + trimmedItem })
  748. } else if (ruleForm.preciseNegation) {
  749. negativeList.push({ negativeWords: '精确: ' + trimmedItem })
  750. }
  751. } else {
  752. console.log('有空项目,未被添加到列表中')
  753. }
  754. })
  755. // 清空输入框
  756. ruleForm.negativeTextarea = ''
  757. console.log(negativeList)
  758. }
  759. function delAllNegative() {
  760. // negativeList.splice(0, negativeList.length)
  761. negativeList.length = 0
  762. }
  763. function delSingleNegative(scope) {
  764. const index = negativeList.findIndex((item) => item.negativeWords === scope.row.negativeWords)
  765. if (negativeList.length) {
  766. negativeList.splice(index, 1)
  767. console.log(`已删除索引为 ${index} 的条目`)
  768. } else {
  769. console.log('无效的索引,无法删除条目')
  770. }
  771. }
  772. // ---------------------否定商品模块---------------------
  773. let negativeList = reactive([])
  774. const tableData = negativeList
  775. let inputAddedNegGoods = ref([])
  776. function setNegativeTableData(asin = '',) {
  777. return request({
  778. url: '/api/sellers/listings/',
  779. method: 'GET',
  780. params: {
  781. page: currentPage.value,
  782. limit: pageSize.value,
  783. profile_id: profile.value.profile_id,
  784. asin,
  785. },
  786. })
  787. .then((resp) => {
  788. negativeTableData.value = resp.data
  789. inputAddedNegGoods.value = resp.data
  790. loading.value = false
  791. })
  792. .catch((error) => {
  793. console.error('Error fetching data:', error)
  794. loading.value = false
  795. })
  796. }
  797. // 输入tab的textarea
  798. function addNegativeGoods() {
  799. console.log('ruleForm.negativeGoodsTextarea', ruleForm.negativeGoodsTextarea)
  800. loading.value = true
  801. setNegativeTableData(ruleForm.negativeGoodsTextarea)
  802. .then(() => {
  803. addedNegetiveTableData.value = [...addedNegetiveTableData.value, ...inputAddedNegGoods.value]
  804. })
  805. .catch((error) => {
  806. console.error('Error fetching data:', error)
  807. })
  808. .finally(() => {
  809. loading.value = false
  810. })
  811. }
  812. function addSingleNegativeGoods(scope) {
  813. console.log('scope', scope.row)
  814. const isAlreadyAdded = addedNegetiveTableData.value.some((item) => item.sku === scope.row.sku)
  815. if (!isAlreadyAdded) {
  816. addedNegetiveTableData.value.push(scope.row)
  817. } else {
  818. console.log('Item is already added.')
  819. }
  820. }
  821. function delAllNegativeGoods() {
  822. addedNegetiveTableData.value = []
  823. }
  824. function delSingleNegativeGoods(scope) {
  825. const index = addedNegetiveTableData.value.findIndex((item) => item.sku === scope.row.sku)
  826. if (index !== -1) {
  827. addedNegetiveTableData.value.splice(index, 1)
  828. console.log('Item removed successfully.')
  829. } else {
  830. console.log('Item not found.')
  831. }
  832. }
  833. function searchNegativeGoods(e) {
  834. console.log(e)
  835. if (e === '') {
  836. negativeTableData.value = []
  837. } else {
  838. setNegativeTableData(e)
  839. }
  840. }
  841. function handleAddedNegGoods(selection) {
  842. addedSels = selection
  843. }
  844. function handleNegGoodsTabs(tab: TabsPaneContext, event: Event) {
  845. // console.log(tab, event)
  846. }
  847. // ---------------------自定义校验模块---------------------
  848. function checkBid(value, callback, bidField) {
  849. const bid = parseFloat(value)
  850. const budget = parseFloat(ruleForm.budget)
  851. // 检查值是否为最多两位小数的普通数字格式
  852. const isNormalNumberWithTwoDecimals = /^-?\d+(\.\d{1,2})?$/.test(value)
  853. if (!isNormalNumberWithTwoDecimals) {
  854. callback(new Error('请输入数字值(最多两位小数)'))
  855. } else if (isNaN(bid)) {
  856. callback(new Error('请输入有效的数字'))
  857. } else if (bid < 0.02 || bid > 1000) {
  858. callback(new Error('值必须在0.02到1000之间'))
  859. } else if (bid >= budget) {
  860. callback(new Error('出价必须小于预算'))
  861. } else {
  862. callback()
  863. }
  864. }
  865. function getValidationRules(fieldName) {
  866. // 默认校验规则
  867. const commonRules = [
  868. { required: true, message: '此项为必填项', trigger: 'blur' },
  869. { validator: (rule, value, callback) => checkBid(value, callback, fieldName), trigger: 'blur' },
  870. ]
  871. // 根据不同字段和状态返回特定的校验规则
  872. switch (fieldName) {
  873. case 'defaultBidInp':
  874. if (ruleForm.autoRedirect === 'defaultBid') {
  875. return commonRules
  876. }
  877. break
  878. case 'similarProductsInp':
  879. if (ruleForm.autoRedirect === 'targetBid' && ruleForm.similarProducts) {
  880. return commonRules
  881. } else if (ruleForm.similarProducts == false) {
  882. ruleFormRef.value?.clearValidate(fieldName)
  883. }
  884. break
  885. case 'relatedProductsInp':
  886. if (ruleForm.autoRedirect === 'targetBid' && ruleForm.relatedProducts) {
  887. return commonRules
  888. } else if (ruleForm.relatedProducts == false) {
  889. ruleFormRef.value?.clearValidate(fieldName)
  890. }
  891. break
  892. case 'broadMatchInp':
  893. if (ruleForm.autoRedirect === 'targetBid' && ruleForm.broadMatch) {
  894. return commonRules
  895. } else if (ruleForm.broadMatch == false) {
  896. ruleFormRef.value?.clearValidate(fieldName)
  897. }
  898. break
  899. case 'closeMatchInp':
  900. // 仅当autoRedirect为'targetBid'且closeMatch开启时校验closeMatchInp
  901. if (ruleForm.autoRedirect === 'targetBid' && ruleForm.closeMatch) {
  902. return commonRules
  903. } else if (ruleForm.closeMatch == false) {
  904. ruleFormRef.value?.clearValidate(fieldName)
  905. }
  906. break
  907. default:
  908. return []
  909. }
  910. // 如果不满足上述条件,则无需校验
  911. return []
  912. }
  913. watch(
  914. [() => ruleForm.autoRedirect, () => ruleForm.closeMatch, () => ruleForm.broadMatch, () => ruleForm.similarProducts, () => ruleForm.relatedProducts],
  915. () => {
  916. // 定义需要更新校验规则的字段
  917. const fields = ['defaultBidInp', 'closeMatchInp', 'broadMatchInp', 'similarProductsInp', 'relatedProductsInp']
  918. fields.forEach((field) => {
  919. rules.value[field] = getValidationRules(field)
  920. })
  921. }
  922. )
  923. // 表单提交
  924. async function submitForm(formEl: FormInstance | undefined) {
  925. if (!formEl) return
  926. await formEl.validate((valid, fields) => {
  927. if (valid) {
  928. console.log('submit!')
  929. } else {
  930. console.log('error submit!', fields)
  931. }
  932. })
  933. }
  934. function resetForm(formEl: FormInstance | undefined) {
  935. if (!formEl) return
  936. formEl.resetFields()
  937. }
  938. // 修改表头样式
  939. const headerCellStyle = (args) => {
  940. if (args.rowIndex === 0) {
  941. return {
  942. backgroundColor: 'rgba(245, 245, 245, 0.9)',
  943. }
  944. }
  945. }
  946. function changeNegTableHeader(args) {
  947. if (args.rowIndex === 0) {
  948. return {
  949. color: '#505968',
  950. }
  951. }
  952. }
  953. onMounted(() => {
  954. setTableData()
  955. // const myTest = route.query
  956. // console.log('myTest', myTest)
  957. })
  958. defineOptions({
  959. name: 'SpCreateCampaigns',
  960. })
  961. </script>
  962. <style lang="scss" scoped>
  963. ::v-deep(.el-form--default.el-form--label-top .el-form-item .el-form-item__label) {
  964. font-weight: 500;
  965. }
  966. .column-item .el-radio-group {
  967. display: inline-flex;
  968. font-size: 0;
  969. flex-direction: column;
  970. align-items: flex-start;
  971. }
  972. .radio-description {
  973. font-size: 12px;
  974. color: #666;
  975. margin-top: -18px;
  976. margin-left: 22px;
  977. }
  978. .radio-description-2 {
  979. font-size: 12px;
  980. color: #666;
  981. margin-top: -10px;
  982. }
  983. .column-margin-bottom label.el-radio.is-bordered {
  984. margin-bottom: 10px;
  985. padding: 35px;
  986. }
  987. ::v-deep(.column-margin-bottom label.el-radio.is-bordered span.el-radio__inner) {
  988. margin-top: -18px;
  989. margin-left: -15px;
  990. }
  991. .gap-items {
  992. display: flex;
  993. justify-content: flex-start;
  994. width: 100%;
  995. margin-bottom: 20px;
  996. }
  997. .gap-item {
  998. width: 200px;
  999. margin-left: 30px;
  1000. color: #0b0d0d;
  1001. }
  1002. .demo-tabs > .el-tabs__content {
  1003. padding: 52px;
  1004. color: #6b778c;
  1005. font-size: 32px;
  1006. font-weight: 600;
  1007. }
  1008. /* 广告组商品Tab栏 */
  1009. ::v-deep(.el-tabs__nav-scroll) {
  1010. overflow: hidden;
  1011. margin-left: 20px;
  1012. }
  1013. ::v-deep(.el-tabs__nav-wrap::after) {
  1014. height: 2px !important;
  1015. }
  1016. ::v-deep(.el-table__inner-wrapper::before) {
  1017. background-color: white;
  1018. }
  1019. // 表格内容边距
  1020. div {
  1021. & #pane-first,
  1022. & #pane-second {
  1023. margin: 10px;
  1024. }
  1025. }
  1026. // 输入底部样式
  1027. ::v-deep(.card-box .el-card__body) {
  1028. display: flex;
  1029. align-items: center;
  1030. justify-content: space-between;
  1031. padding: 12px;
  1032. }
  1033. .card-header {
  1034. display: flex;
  1035. justify-content: space-between;
  1036. align-items: center;
  1037. }
  1038. .box-card {
  1039. width: 100%;
  1040. // margin: 10px 0 10px 10px;
  1041. margin-right: 10px;
  1042. border: none;
  1043. }
  1044. .single-line {
  1045. color: rgb(30, 33, 41);
  1046. overflow: hidden;
  1047. display: -webkit-box;
  1048. -webkit-box-orient: vertical;
  1049. -webkit-line-clamp: 1;
  1050. white-space: pre-wrap;
  1051. word-break: break-word;
  1052. }
  1053. .data-color {
  1054. color: rgb(30, 33, 41);
  1055. }
  1056. .img-box {
  1057. width: 60px;
  1058. height: 60px;
  1059. margin-top: 5px;
  1060. border: 1px solid rgb(194, 199, 207);
  1061. border-radius: 4px;
  1062. }
  1063. .target-group-item {
  1064. margin-top: 15px;
  1065. }
  1066. .suggested-bid-item {
  1067. margin-left: 230px;
  1068. margin-right: 60px;
  1069. }
  1070. .bid-input {
  1071. width: 200px;
  1072. margin-left: 15px;
  1073. }
  1074. </style>