index.vue 95 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454
  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: 300px">
  49. <el-input
  50. v-model="campaignRuleForm.budget"
  51. maxlength="7"
  52. oninput="value=value.indexOf('.') > -1?value.slice(0, value.indexOf('.') + 3):value">
  53. <template #prepend>$</template>
  54. </el-input>
  55. </el-form-item>
  56. <el-form-item label="投放类型" prop="type" class="column-item">
  57. <el-radio-group v-model="campaignRuleForm.type" @click="changeType">
  58. <div>
  59. <el-radio label="AUTO">自动</el-radio>
  60. <div class="radio-description">定向与您推广商品相似的关键词和商品</div>
  61. </div>
  62. <div>
  63. <el-radio label="MANUAL">手动</el-radio>
  64. <div class="radio-description">选择关键词或商品以定向购物者搜索并设置自定义出价</div>
  65. </div>
  66. </el-radio-group>
  67. </el-form-item>
  68. <el-form-item label="竞价策略" prop="bidStrategy" class="column-item column-margin-bottom">
  69. <el-radio-group v-model="campaignRuleForm.bidStrategy">
  70. <div>
  71. <el-radio label="LEGACY_FOR_SALES" border>
  72. 动态竞价-仅降低
  73. <div class="radio-description-2">当您的广告不太可能带来销售时,我们将实时降低您的竞价</div>
  74. </el-radio>
  75. </div>
  76. <div>
  77. <el-radio label="AUTO_FOR_SALES" border>
  78. 动态竞价-提高和降低
  79. <div class="radio-description-2">
  80. 当您的广告很有可能带来销售时,我们将实时提高您的竞价(最高可达 100%),并在您的广告不太可能带来销售时降低您的竞价
  81. </div>
  82. </el-radio>
  83. </div>
  84. <el-radio label="MANUAL" border>
  85. 固定竞价
  86. <div class="radio-description-2">我们将使用您的确切竞价和您设置的任何手动调整,而不会根据售出可能性对您的竞价进行更改</div>
  87. </el-radio>
  88. </el-radio-group>
  89. </el-form-item>
  90. <el-form-item label="按展示位置调整出价" prop="placeBid">
  91. <p style="color: #8e9196">除了出价策略外,您还可以将出价提高多达900%</p>
  92. <div class="gap-items">
  93. <div class="gap-item">搜索结果顶部(首页)</div>
  94. <el-input v-model="campaignRuleForm.placeBid" class="gap-item">
  95. <template #append>%</template>
  96. </el-input>
  97. </div>
  98. <div class="gap-items">
  99. <div class="gap-item">商品首页</div>
  100. <el-input v-model="campaignRuleForm.firstPage" class="gap-item">
  101. <template #append>%</template>
  102. </el-input>
  103. </div>
  104. <div class="gap-items" style="margin-bottom: 0">
  105. <div class="gap-item">搜索结果的其余位置</div>
  106. <el-input v-model="campaignRuleForm.other" class="gap-item">
  107. <template #append>%</template>
  108. </el-input>
  109. </div>
  110. </el-form-item>
  111. <el-form-item style="margin-left: 48%">
  112. <el-button type="primary" plain @click="submitCampaignForm(campaignFormRef)">保存</el-button>
  113. </el-form-item>
  114. </el-card>
  115. <br />
  116. <!-- 广告组 -->
  117. <el-card shadow="never" body-style="padding-bottom: 0 !important;" v-loading="adGroupLoading">
  118. <div style="font-size: 20px; font-weight: bold">广告组</div>
  119. <hr />
  120. <br />
  121. <el-form ref="adGroupRuleFormRef" :model="adGroupRuleForm" :rules="adGroupRules">
  122. <el-form-item required label="广告组名称" prop="adGroupName" style="width: 350px; margin-top: 20px">
  123. <el-input v-model="adGroupRuleForm.adGroupName" />
  124. </el-form-item>
  125. <el-form-item required label="默认竞价" prop="defaultBidInp">
  126. <el-input v-model="adGroupRuleForm.defaultBidInp" minlength="3" maxlength="4" style="width: 200px">
  127. <template #prepend>$</template>
  128. </el-input>
  129. </el-form-item>
  130. <el-form-item style="margin-left: 48%">
  131. <el-button type="primary" plain @click="submitGroupsForm(adGroupRuleFormRef)" :disabled="adGroupSave">保存</el-button>
  132. </el-form-item>
  133. </el-form>
  134. </el-card>
  135. <!-- 商品表格 -->
  136. <div style="margin-top: 20px; font-size: 24px; font-weight: bold">商品</div>
  137. <hr />
  138. <br />
  139. <el-form-item prop="commodity" style="width: 100%" v-loading="commodityLoading">
  140. <div style="width: 100%; height: 620px; display: flex; border: 1px solid #e5e7ec; border-radius: 6px">
  141. <div style="width: 50%; border-right: 1px solid #e5e7ec">
  142. <el-tabs v-model="activeName" class="demo-tabs">
  143. <el-tab-pane label="搜索" name="first">
  144. <div style="margin-bottom: 10px">
  145. <el-input v-model="searchInp" placeholder="Please input" class="input-with-select" @change="inpChange" clearable>
  146. <template #prepend>
  147. <el-select v-model="select" style="width: 100px" @change="selChange">
  148. <el-option label="名称" value="name" />
  149. <el-option label="ASIN" value="asin" />
  150. <el-option label="SKU" value="sku" />
  151. </el-select>
  152. </template>
  153. <template #append>
  154. <el-select v-model="select2" style="width: 100px">
  155. <el-option label="最新优先" value="latest" />
  156. <el-option label="最早优先" value="earliest" />
  157. <el-option label="优选广告" value="optimal" />
  158. </el-select>
  159. </template>
  160. </el-input>
  161. </div>
  162. <el-table
  163. height="490"
  164. style="width: 100%"
  165. v-loading="loading"
  166. :data="fullTableData"
  167. :header-cell-style="headerCellStyle"
  168. @selection-change="handleSelectionChange">
  169. <el-table-column type="selection" width="50" />
  170. <el-table-column prop="asin" label="商品">
  171. <template #default="scope">
  172. <div style="display: flex; align-items: center">
  173. <div style="margin-right: 8px; line-height: normal">
  174. <el-image class="img-box" :src="scope.row.image_link" />
  175. </div>
  176. <div>
  177. <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top">
  178. <div class="single-line">{{ scope.row.title ? scope.row.title : '--' }}</div>
  179. </el-tooltip>
  180. <div class="data-color">
  181. <span style="font-weight: 500; color: rgb(30, 33, 41)">${{ scope.row.price ? scope.row.price : '--' }}</span>
  182. <span style="margin: 0 5px; color: #cacdd4">|</span>
  183. <span style="color: #6d7784">{{ scope.row.quantity }}</span>
  184. </div>
  185. <span>
  186. ASIN: <span class="data-color" style="margin-right: 8px">{{ scope.row.asin ? scope.row.asin : '--' }}</span>
  187. </span>
  188. <span>
  189. SKU: <span class="data-color">{{ scope.row.sku ? scope.row.sku : '--' }}</span>
  190. </span>
  191. </div>
  192. </div>
  193. </template>
  194. </el-table-column>
  195. <el-table-column prop="name" label="Name" width="120" align="right">
  196. <template #header>
  197. <el-button type="primary" size="normal" link @click="handleGoodsAdd">添加已选中</el-button>
  198. </template>
  199. <template #default="scope">
  200. <el-button type="primary" size="small" @click="addSingleGoods(scope)" text>添加</el-button>
  201. </template>
  202. </el-table-column>
  203. </el-table>
  204. <el-pagination
  205. @current-change="handleCurrentChange"
  206. @size-change="handleSizeChange"
  207. :current-page="currentPage"
  208. :page-size="pageSize"
  209. :total="totalItems"
  210. layout="prev, pager, next" />
  211. </el-tab-pane>
  212. <el-tab-pane label="输入" name="second">
  213. <el-input
  214. style="padding: 10px"
  215. v-model="goodsTextarea"
  216. :rows="20"
  217. type="textarea"
  218. placeholder="请输入ASIN,多个ASIN使用逗号、空格或换行符分隔。(未完成)"
  219. maxlength="11000" />
  220. <div style="display: flex; flex-direction: row-reverse; margin-top: 10px">
  221. <el-button v-for="button in buttons" :key="button.text" :type="button.type" link @click="addGods">{{ button.text }}</el-button>
  222. </div>
  223. </el-tab-pane>
  224. </el-tabs>
  225. </div>
  226. <div style="width: 50%">
  227. <el-card class="box-card" shadow="never" style="border: 0">
  228. <template #header>
  229. <div class="card-header">
  230. <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ adsTableData.length }}</span>
  231. <el-button class="button" text bg @click="delAllGoods">全部删除</el-button>
  232. </div>
  233. </template>
  234. <div class="card-body"></div>
  235. </el-card>
  236. <div style="padding: 0 10px 0 10px; margin-top: -12px">
  237. <el-table
  238. :data="adsTableData"
  239. height="475"
  240. style="width: 100%"
  241. :header-cell-style="headerCellStyle"
  242. @selection-change="handleAddedGoodsChange">
  243. <el-table-column type="selection" width="50" />
  244. <el-table-column prop="asin" label="ASIN">
  245. <template #default="scope">
  246. <div style="display: flex; align-items: center">
  247. <div style="margin-right: 8px; line-height: normal">
  248. <el-image class="img-box" :src="scope.row.image_link" />
  249. </div>
  250. <div>
  251. <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top">
  252. <div class="single-line">{{ scope.row.title ? scope.row.title : '--' }}</div>
  253. </el-tooltip>
  254. <div class="data-color">
  255. <span style="font-weight: 500; color: rgb(30, 33, 41)">${{ scope.row.price ? scope.row.price : '--' }}</span>
  256. <span style="margin: 0 5px; color: #cacdd4">|</span>
  257. <span style="color: #6d7784">{{ scope.row.quantity }}</span>
  258. </div>
  259. <span
  260. >ASIN:
  261. <span class="data-color" style="margin-right: 8px">{{ scope.row.asin ? scope.row.asin : '--' }}</span>
  262. </span>
  263. <span
  264. >SKU:
  265. <span class="data-color">{{ scope.row.sku ? scope.row.sku : '--' }}</span>
  266. </span>
  267. </div>
  268. </div>
  269. </template>
  270. </el-table-column>
  271. <el-table-column prop="name" label="Name" width="120" align="right">
  272. <template #header>
  273. <el-button type="primary" size="normal" link @click="delSelectedGoods">删除已选中</el-button>
  274. </template>
  275. <template #default="scope">
  276. <el-button type="primary" size="small" @click="delSingleGoods(scope)" text>删除</el-button>
  277. </template>
  278. </el-table-column>
  279. </el-table>
  280. </div>
  281. <div style="display: flex; justify-content: space-around; padding-top: 10px">
  282. <el-button type="primary" plain :disabled="adsSave" @click="submitAdsForm">保存</el-button>
  283. </div>
  284. </div>
  285. </div>
  286. </el-form-item>
  287. <!-- 按目标组设置出价 -->
  288. <el-form
  289. :label-position="labelPosition"
  290. ref="targetGroupFormRef"
  291. :model="targetGroupRuleForm"
  292. :rules="targetGroupRules"
  293. label-width="120px"
  294. class="demo-ruleForm"
  295. :size="formSize"
  296. status-icon>
  297. <div class="column-item" v-if="campaignRuleForm.type == 'AUTO'">
  298. <div style="margin-top: 20px; font-size: 24px; font-weight: bold">按目标组设置出价</div>
  299. <hr />
  300. <br />
  301. <el-card shadow="never" v-if="campaignRuleForm.type == 'AUTO'" class="box-card" v-loading="targetGroupLoading">
  302. <div>
  303. <div style="color: #8e9095">
  304. <span>目标群体</span>
  305. <span class="suggested-bid-item">建议竞价</span>
  306. <span>竞价</span>
  307. </div>
  308. <div style="display: flex">
  309. <el-switch v-model="targetGroupRuleForm.closeMatch" size="small" active-text="紧密匹配" @change="closeMatchChange" />
  310. <span class="suggested-bid-item">--</span>
  311. <el-form-item prop="closeMatchInp">
  312. <el-input
  313. :disabled="!targetGroupRuleForm.closeMatch"
  314. v-model="targetGroupRuleForm.closeMatchInp"
  315. minlength="3"
  316. maxlength="4"
  317. class="bid-input">
  318. <template #prepend>$</template>
  319. </el-input>
  320. </el-form-item>
  321. </div>
  322. <div>
  323. <div style="display: flex">
  324. <el-switch v-model="targetGroupRuleForm.broadMatch" size="small" active-text="广泛匹配" @change="broadMatchChange" />
  325. <span class="suggested-bid-item">--</span>
  326. <el-form-item prop="broadMatchInp">
  327. <el-input
  328. :disabled="!targetGroupRuleForm.broadMatch"
  329. v-model="targetGroupRuleForm.broadMatchInp"
  330. minlength="3"
  331. maxlength="4"
  332. class="bid-input">
  333. <template #prepend>$</template>
  334. </el-input>
  335. </el-form-item>
  336. </div>
  337. </div>
  338. <div>
  339. <div style="display: flex">
  340. <el-switch v-model="targetGroupRuleForm.similarProducts" size="small" active-text="同类商品" @change="similarProductsChange" />
  341. <span class="suggested-bid-item">--</span>
  342. <el-form-item prop="similarProductsInp">
  343. <el-input
  344. :disabled="!targetGroupRuleForm.similarProducts"
  345. v-model="targetGroupRuleForm.similarProductsInp"
  346. minlength="3"
  347. maxlength="4"
  348. class="bid-input">
  349. <template #prepend>$</template>
  350. </el-input>
  351. </el-form-item>
  352. </div>
  353. </div>
  354. <div>
  355. <div style="display: flex">
  356. <el-switch v-model="targetGroupRuleForm.relatedProducts" size="small" active-text="关联商品" @change="relatedProductsChange" />
  357. <span class="suggested-bid-item">--</span>
  358. <el-form-item prop="relatedProductsInp">
  359. <el-input
  360. :disabled="!targetGroupRuleForm.relatedProducts"
  361. v-model="targetGroupRuleForm.relatedProductsInp"
  362. minlength="3"
  363. maxlength="4"
  364. class="bid-input">
  365. <template #prepend>$</template>
  366. </el-input>
  367. </el-form-item>
  368. </div>
  369. </div>
  370. </div>
  371. <div style="display: flex; justify-content: space-around">
  372. <el-button type="primary" plain :disabled="targetGroupBidSave" @click="submitTargetGroupForm">保存</el-button>
  373. </div>
  374. </el-card>
  375. </div>
  376. </el-form>
  377. <!-- 投放类型 -->
  378. <div class="column-item" v-if="campaignRuleForm.type == 'MANUAL'">
  379. <p style="color: #606266; font-weight: 450"><span style="color: #e47470">*</span> 投放类型</p>
  380. <el-radio-group v-model="ruleForm.targetType" @change="changeTargetType">
  381. <div style="display: flex">
  382. <el-radio label="keyWords" style="align-items: flex-start; margin-top: 5px">
  383. <div style="margin-top: -4px">关键词投放</div>
  384. <div>选择关键词以帮助您的商品出现在购物者搜索中</div>
  385. </el-radio>
  386. </div>
  387. <div>
  388. <el-radio label="Goods" style="align-items: flex-start; margin-top: 20px">
  389. <div style="margin-top: -4px">商品投放</div>
  390. <div>选择特定的商品, 分类, 品牌或者其他商品功能来定向您的广告</div>
  391. </el-radio>
  392. </div>
  393. </el-radio-group>
  394. </div>
  395. <!-- 关键词定向 -->
  396. <!-- TODO: 未完成 不知道有什么用 -->
  397. <div
  398. style="font-size: 20px; font-weight: bold; margin-top: 30px"
  399. v-if="ruleForm.targetType == 'keyWords' && campaignRuleForm.type == 'MANUAL'">
  400. 关键词定向
  401. </div>
  402. <hr v-if="ruleForm.targetType == 'keyWords' && campaignRuleForm.type == 'MANUAL'" />
  403. <el-form-item style="width: 100%; margin-top: 20px" v-if="ruleForm.targetType == 'keyWords' && campaignRuleForm.type == 'MANUAL'">
  404. <div style="width: 100%; height: 600px; display: flex; border: 1px solid #e5e7eb; border-radius: 6px">
  405. <div style="width: 50%; border-right: 1px solid #e5e7eb">
  406. <el-tabs v-model="keyWordsTabs" class="demo-tabs" @tab-click="handleGoodsTabs">
  407. <div style="margin: 8px">
  408. <p style="margin-left: 8px; margin-bottom: -8px; font-weight: 500; color: #616266">竞价:</p>
  409. <div style="display: flex; align-items: center">
  410. <el-select v-model="bidType" class="m-2" placeholder="Select" style="width: 450px">
  411. <el-option v-for="item in bidTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
  412. </el-select>
  413. <el-input v-model="bidInput" placeholder="Please input">
  414. <template #prepend>$</template>
  415. </el-input>
  416. </div>
  417. <div style="display: flex">
  418. <span style="margin: 0 10px 0 8px; font-weight: 500; color: #616266">匹配类型: </span>
  419. <el-checkbox v-model="widelyType" label="广泛" />
  420. <el-checkbox v-model="phraseType" label="词组" />
  421. <el-checkbox v-model="exactType" label="精确" />
  422. </div>
  423. </div>
  424. <el-tab-pane label="建议" name="first">
  425. <el-table
  426. height="425"
  427. style="width: 100%; padding-left: 5px"
  428. v-loading="loading"
  429. :data="keyWordsTableData"
  430. :header-cell-style="headerCellStyle"
  431. :header-row-style="changeKeyWordsTableHeader">
  432. <el-table-column prop="asin" label="关键词"> </el-table-column>
  433. <el-table-column prop="name" label="匹配类型"> </el-table-column>
  434. <el-table-column prop="name" label="建议出价" width="120"> </el-table-column>
  435. </el-table>
  436. </el-tab-pane>
  437. <el-tab-pane label="输入" name="second">
  438. <el-input v-model="keyWordsTextarea" :rows="10" type="textarea" placeholder="未完成" style="padding-left: 5px" />
  439. <el-button type="primary" size="small" text bg @click="addKeyWords">添加</el-button>
  440. </el-tab-pane>
  441. </el-tabs>
  442. </div>
  443. <div style="width: 50%">
  444. <el-card class="box-card" shadow="never" style="border: none">
  445. <template #header>
  446. <div class="card-header">
  447. <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ addedData.length }}</span>
  448. <el-button class="button" text bg @click="delAllKeyWords">全部删除</el-button>
  449. </div>
  450. </template>
  451. <div class="card-body" body-style="padding-bottom: -20px;">
  452. <el-table
  453. :data="addedKeyWordsTableData"
  454. style="width: 100%; height: 450px"
  455. :header-row-style="changeKeyWordsTableHeader"
  456. :header-cell-style="headerCellStyle">
  457. <el-table-column prop="keyword" label="关键词" width="auto" />
  458. <el-table-column prop="bid" label="出价" />
  459. <el-table-column prop="suggestBid" label="建议出价" />
  460. <el-table-column prop="operate" label="操作" width="60" align="right" />
  461. </el-table>
  462. </div>
  463. </el-card>
  464. <div style="display: flex; justify-content: space-around; padding-top: 0px">
  465. <el-button type="primary" plain>保存</el-button>
  466. </div>
  467. </div>
  468. </div>
  469. </el-form-item>
  470. <div
  471. style="font-size: 20px; font-weight: bold; margin-top: 30px"
  472. v-if="campaignRuleForm.type === 'AUTO' || (ruleForm.targetType === 'keyWords' && campaignRuleForm.type === 'MANUAL')">
  473. 否定词
  474. </div>
  475. <hr v-if="campaignRuleForm.type === 'AUTO' || (ruleForm.targetType === 'keyWords' && campaignRuleForm.type === 'MANUAL')" />
  476. <!-- 否定词表格 -->
  477. <el-form-item
  478. style="width: 100%; margin-top: 20px"
  479. v-if="campaignRuleForm.type === 'AUTO' || (ruleForm.targetType === 'keyWords' && campaignRuleForm.type === 'MANUAL')">
  480. <div style="width: 100%; height: 520px; display: flex; border: 1px solid #e5e7ec; border-radius: 6px" v-loading="negativeWordsLoading">
  481. <div style="width: 50%; border-right: 1px solid #e5e7ec">
  482. <div style="margin: 10px 0">
  483. <span style="margin-left: 25px; color: #e47470">*</span>
  484. <span style="color: #666666; margin-right: 10px">匹配类型: </span>
  485. <el-checkbox v-model="NEGATIVE_PHRASE" label="词组否定" />
  486. <el-checkbox v-model="NEGATIVE_EXACT" label="精确否定" />
  487. </div>
  488. <el-input
  489. v-model="negativeWordsTextarea"
  490. :rows="17"
  491. type="textarea"
  492. placeholder="请输入关键词,多个关键词使用逗号或者换行符分隔。(最多添加1000个关键词)"
  493. maxlength="11000"
  494. style="padding: 0 20px" />
  495. <div style="display: flex; flex-direction: row-reverse; margin-top: 10px">
  496. <el-button style="margin-right: 18px" type="primary" text bg @click="addNegative">添加</el-button>
  497. </div>
  498. </div>
  499. <div style="width: 50%">
  500. <el-card class="box-card" shadow="never" style="border: none">
  501. <template #header>
  502. <div class="card-header">
  503. <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ addedData.length }}</span>
  504. <el-button class="button" text bg @click="delAllNegative">全部删除</el-button>
  505. </div>
  506. </template>
  507. <div class="card-body">
  508. <el-table :data="tableData" style="width: 100%; height: 370px; padding-bottom: 0" :header-row-style="changeNegTableHeader">
  509. <el-table-column prop="negativeWords" label="否定词" width="auto" />
  510. <el-table-column prop="operate" label="操作" width="60" align="right">
  511. <template #default="scope">
  512. <el-button type="primary" size="small" @click="delSingleNegative(scope)" text>删除</el-button>
  513. </template>
  514. </el-table-column>
  515. </el-table>
  516. </div>
  517. </el-card>
  518. <div style="display: flex; justify-content: space-around">
  519. <el-button type="primary" plain @click="negativeWordsSave" :disabled="!negativeList.length">保存</el-button>
  520. </div>
  521. </div>
  522. </div>
  523. </el-form-item>
  524. <!-- 商品定向 -->
  525. <div style="font-size: 20px; font-weight: bold; margin-top: 30px" v-if="ruleForm.targetType == 'Goods'">商品定向</div>
  526. <hr v-if="ruleForm.targetType == 'Goods'" />
  527. <el-form-item style="width: 100%; margin-top: 20px" v-if="ruleForm.targetType == 'Goods'">
  528. <div
  529. style="width: 100%; height: 600px; display: flex; border: 1px solid #e5e7eb; border-radius: 6px"
  530. v-loading="productOrientationLoading">
  531. <div style="width: 50%; border-right: 1px solid #e5e7eb">
  532. <el-tabs
  533. type="border-card"
  534. stretch
  535. class="goods-orientation-tabs"
  536. style="border: 0; border-right: 0; border-bottom-left-radius: 6px; border-top-left-radius: 5px; overflow: hidden">
  537. <el-tab-pane label="品类" style="border-top-left-radius: 6px">
  538. <div style="display: flex; align-items: center">
  539. <span style="width: 40px">竞价:</span>
  540. <el-select v-model="categoryBiddingType" @change="singleGoodsBidSelectChanged" class="m-2" placeholder="Select">
  541. <el-option v-for="item in categoryBiddingTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
  542. </el-select>
  543. <el-input
  544. v-model="singleGoodsBidInput"
  545. :disabled="categoryBiddingType === 'defaultBid'"
  546. style="width: 200px">
  547. <template #prepend>$</template>
  548. </el-input>
  549. </div>
  550. <el-tabs v-model="categoryTabs" class="category-tabs">
  551. <el-tab-pane label="建议" name="first">
  552. <el-table :data="proposalTableData" style="width: 100%" height="422">
  553. <el-table-column prop="proposal" label="建议" width="520">
  554. <template #header> 0建议 </template>
  555. </el-table-column>
  556. <el-table-column prop="address" label="Address">
  557. <template #header>
  558. <el-button type="primary" size="normal" link @click="handleGoodsAdd">全部添加</el-button>
  559. </template>
  560. <template #default="scope">
  561. <el-button type="primary" size="small" @click="addSingleGoods(scope)" text>添加</el-button>
  562. </template>
  563. </el-table-column>
  564. </el-table>
  565. </el-tab-pane>
  566. <el-tab-pane label="搜索" name="second">
  567. <el-input placeholder="请输入关键词过滤" />
  568. <el-scrollbar height="390px">
  569. <el-tree :data="searchClassifyTableData" :props="defaultProps" :expand-on-click-node="false">
  570. <template #default="{ node, data }">
  571. <span class="custom-tree-node">
  572. <span style="width: 75%">{{ node.label }}</span>
  573. <span style="color: rgb(50, 108, 216)" v-if="data.ta == true">
  574. <a @click="refine(data)"> 细化 </a>
  575. <a style="margin-left: 8px" @click="orientate(node, data)"> 定向 </a>
  576. </span>
  577. </span>
  578. </template>
  579. </el-tree>
  580. </el-scrollbar>
  581. <el-dialog v-model="visible" :title="`细化分类: ${dialogTitle}`" @close="dialogClose" destroy-on-close>
  582. <div style="display: flex; justify-content: space-between">
  583. <span>根据特定品牌、价格范围、星级和Prime配送资格,细化分类</span>
  584. <span>
  585. <el-checkbox v-model="dialogForm.isCount" label="显示商品数量" @change="isCountChanged" />
  586. </span>
  587. </div>
  588. <el-form :model="dialogForm" :rules="dialogRules" ref="dialogFormRef" style="margin-top: 20px">
  589. <el-form-item style="padding-left: 140px">
  590. <span style="margin-right: 10px; color: #616266; font-weight: 500">品牌</span>
  591. <el-select
  592. v-model="dialogForm.dialogselectValue"
  593. @change="dialogSelectChange"
  594. multiple
  595. placeholder="请选择"
  596. :loading="dialogSelectLoading"
  597. >
  598. <el-option v-for="item in dialogForm.dialogOptions" :key="item.value" :label="item.label" :value="item.value" />
  599. </el-select>
  600. </el-form-item>
  601. <el-form-item prop="prices" style="padding-left: 112px; margin-top: 10px">
  602. <span style="margin-right: 10px; color: #616266; font-weight: 500">价格范围</span>
  603. <el-input-number v-model="dialogForm.prices.lowest" :min="1" :controls="false" placeholder="无最低商品价格" />
  604. --
  605. <el-input-number v-model="dialogForm.prices.highest" :min="1" :controls="false" placeholder="无最高商品价格" />
  606. </el-form-item>
  607. <el-form-item prop="starRating" style="padding-left: 85px; margin-top: 10px">
  608. <span style="margin-right: 15px; color: #616266; font-weight: 500">查看星级评定</span>
  609. <el-slider v-model="dialogForm.starRating" range show-stops :max="5" :marks="marks" style="width: 70%" />
  610. </el-form-item>
  611. <el-form-item prop="delivery" style="padding-left: 140px; margin-top: 30px">
  612. <span style="margin-right: 10px; color: #616266; font-weight: 500">配送</span>
  613. <el-radio-group v-model="dialogForm.delivery">
  614. <el-radio label="all" style="font-weight: 400">所有</el-radio>
  615. <el-radio label="eligible" style="font-weight: 400">具备Prime资格</el-radio>
  616. <el-radio label="diseligible" style="font-weight: 400">不具备Prime资格</el-radio>
  617. </el-radio-group>
  618. </el-form-item>
  619. </el-form>
  620. <template #footer>
  621. <div style="display: flex; justify-content: space-between">
  622. <span v-loading="countLoadig"
  623. >定位到的商品数量:
  624. <span v-if="dialogForm.isCount == true">{{ commodityCount[0]?.min }} - {{ commodityCount[0]?.max }}</span></span
  625. >
  626. <span class="dialog-footer">
  627. <el-button @click="visible = false">取消</el-button>
  628. <el-button type="primary" @click="dialogFormSubmit">确定</el-button>
  629. </span>
  630. </div>
  631. </template>
  632. </el-dialog>
  633. </el-tab-pane>
  634. </el-tabs>
  635. </el-tab-pane>
  636. <el-tab-pane label="单个商品">
  637. <div style="display: flex; align-items: center">
  638. <span style="width: 40px">竞价:</span>
  639. <el-select class="m-2" v-model="singleGoodsBidSelect" @change="singleGoodsBidSelectChanged">
  640. <el-option v-for="item in singleGoodsBidTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
  641. </el-select>
  642. <el-input
  643. v-model="singleGoodsBidInput"
  644. :disabled="singleGoodsBidSelect == 'defaultBid'"
  645. style="width: 200px">
  646. <template #prepend>$</template>
  647. </el-input>
  648. <div style="margin-left: 20px">
  649. <span style="margin-right: 10px">类型:</span>
  650. <el-checkbox v-model="expand" label="扩展" />
  651. <el-checkbox v-model="accurate" label="精准" />
  652. </div>
  653. </div>
  654. <el-tabs v-model="singleGoodsTabs" class="category-tabs">
  655. <el-tab-pane label="建议" name="first">
  656. <el-table :data="proposalTableData" style="width: 100%" height="342">
  657. <el-table-column prop="proposal" label="商品" width="520" />
  658. <el-table-column prop="address" label="类型" />
  659. <el-table-column prop="operational" label="操作" />
  660. </el-table>
  661. </el-tab-pane>
  662. <el-tab-pane label="搜索" name="second">
  663. <el-input v-model="singleGoodsSearchInp" @change="singleGoodsSearchChaneged" placeholder="按ASIN搜索"></el-input>
  664. <el-table :data="searchTableData" style="width: 100%" height="309">
  665. <el-table-column prop="asin" label="商品" width="520">
  666. <template #default="{ row }">
  667. <div style="display: flex; align-items: center">
  668. <img :src="row.image_link" style="width: 40px; height: 40px; margin-right: 10px" />
  669. <span>{{ row.title }}</span>
  670. </div>
  671. </template>
  672. </el-table-column>
  673. <el-table-column prop="productTypes" label="类型">
  674. <template #default="scope">
  675. <div v-if="expand">扩展</div>
  676. <div v-if="accurate">精准</div>
  677. </template>
  678. </el-table-column>
  679. <el-table-column prop="operational" label="操作">
  680. <template #default="scope">
  681. <el-button class="button" text @click="addSingleSearch(scope)">添加</el-button>
  682. </template>
  683. </el-table-column>
  684. </el-table>
  685. </el-tab-pane>
  686. <!-- TODO: 商品定向TextArea -->
  687. <el-tab-pane label="输入" name="third">待完成</el-tab-pane>
  688. </el-tabs>
  689. </el-tab-pane>
  690. </el-tabs>
  691. </div>
  692. <div style="width: 50%">
  693. <el-card class="box-card" shadow="never" style="border: none">
  694. <template #header>
  695. <div class="card-header">
  696. <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ productOrientationTableData.length }}</span>
  697. <el-button class="button" text bg @click="delAllCna">全部删除</el-button>
  698. </div>
  699. </template>
  700. <div class="card-body">
  701. <el-table
  702. height="460"
  703. :data="productOrientationTableData"
  704. style="width: 100%"
  705. :header-row-style="changeKeyWordsTableHeader"
  706. :header-cell-style="headerCellStyle">
  707. <el-table-column prop="cna" label="分类 & 商品" width="300">
  708. <template #default="scope">
  709. <div v-if="scope.row.cna || scope.row.classification">
  710. 分类: <span style="color: #000000">{{ scope.row.cna ? scope.row.cna : scope.row.classification }}</span>
  711. </div>
  712. <div v-if="scope.row.asin">
  713. {{ scope.row.asin ? scope.row.asin : '--' }}
  714. </div>
  715. <div v-if="scope.row.brand">
  716. 品牌: <span style="color: #000000">{{ scope.row.brand }}</span>
  717. </div>
  718. <div v-if="scope.row.low_price || scope.row.high_price">
  719. 品牌价格:
  720. <span style="color: #000000">
  721. {{ scope.row.low_price ? '$' + scope.row.low_price : '--' }} -
  722. {{ scope.row.high_price ? '$' + scope.row.high_price : '--' }}
  723. </span>
  724. </div>
  725. <div v-if="scope.row.low_rating || scope.row.high_rating">
  726. 评分: <span style="color: #000000">{{ scope.row.low_rating }} - {{ scope.row.high_rating }}</span>
  727. </div>
  728. <div v-if="scope.row.deliveryText">
  729. 配送: <span style="color: #000000">{{ scope.row.deliveryText }}</span>
  730. </div>
  731. </template>
  732. </el-table-column>
  733. <el-table-column prop="type" label="类型">
  734. <template #default="scope">
  735. {{ scope.row.productTypeText ? scope.row.productTypeText : '--' }}
  736. </template>
  737. </el-table-column>
  738. <el-table-column prop="bid" label="竞价">
  739. <template #default="scope">
  740. <el-input-number v-model="scope.row.bid" :min="0.02" :max="1000000" :controls="false" size="small" />
  741. </template>
  742. </el-table-column>
  743. <el-table-column prop="operate" label="操作" width="60" align="right">
  744. <template #default="scope">
  745. <el-button text size="small" @click="delCna(scope.$index)">删除</el-button>
  746. </template>
  747. </el-table-column>
  748. </el-table>
  749. </div>
  750. </el-card>
  751. <div style="display: flex; justify-content: space-around; margin-top: -8px">
  752. <el-button type="primary" plain @click="productTagetSave">保存</el-button>
  753. </div>
  754. </div>
  755. </div>
  756. </el-form-item>
  757. <div
  758. style="font-size: 20px; font-weight: bold; margin-top: 30px"
  759. v-if="campaignRuleForm.type == 'AUTO' || (ruleForm.targetType == 'Goods' && campaignRuleForm.type === 'MANUAL')">
  760. 否定商品
  761. </div>
  762. <hr v-if="campaignRuleForm.type == 'AUTO' || (ruleForm.targetType == 'Goods' && campaignRuleForm.type === 'MANUAL')" />
  763. <el-form-item
  764. prop="matchType"
  765. style="width: 100%; margin-top: 20px"
  766. v-if="campaignRuleForm.type == 'AUTO' || (ruleForm.targetType == 'Goods' && campaignRuleForm.type === 'MANUAL')">
  767. <div style="width: 100%; height: 600px; display: flex; border: 1px solid #e5e7ec; border-radius: 6px" v-loading="negativeGoodsLoading">
  768. <div style="width: 50%; border-right: 1px solid #e5e7ec">
  769. <el-tabs v-model="negativeTabs" class="demo-tabs" @tab-click="handleNegGoodsTabs">
  770. <el-tab-pane label="搜索" name="first">
  771. <div style="margin-bottom: 10px">
  772. <el-input placeholder="按ASIN搜索" v-model="negativeInput" @change="searchNegativeGoods" clearable />
  773. </div>
  774. <el-table
  775. height="495"
  776. style="width: 100%"
  777. v-loading="loading"
  778. :data="negativeTableData"
  779. :header-cell-style="headerCellStyle"
  780. :show-header="false">
  781. <el-table-column prop="asin" label="商品">
  782. <template #default="scope">
  783. <div style="display: flex; align-items: center">
  784. <div style="margin-right: 8px; line-height: normal">
  785. <el-image class="img-box" :src="scope.row.image_link" />
  786. </div>
  787. <div>
  788. <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top">
  789. <div class="single-line">{{ scope.row.title ? scope.row.title : '--' }}</div>
  790. </el-tooltip>
  791. <span>
  792. ASIN: <span class="data-color" style="margin-right: 8px">{{ scope.row.asin ? scope.row.asin : '--' }}</span>
  793. </span>
  794. </div>
  795. </div>
  796. </template>
  797. </el-table-column>
  798. <el-table-column prop="name" label="Name" width="120" align="right">
  799. <template #header> </template>
  800. <template #default="scope">
  801. <el-button type="primary" size="small" @click="addSingleNegativeGoods(scope)" text>添加</el-button>
  802. </template>
  803. </el-table-column>
  804. </el-table>
  805. </el-tab-pane>
  806. <el-tab-pane label="输入" name="second">
  807. <el-input
  808. v-model="ruleForm.negativeGoodsTextarea"
  809. :rows="17"
  810. type="textarea"
  811. placeholder="未完成"
  812. maxlength="11000"
  813. style="padding: 10px 10px" />
  814. <div style="display: flex; flex-direction: row-reverse; margin-top: 10px">
  815. <el-button style="margin-right: 10px" type="primary" text bg @click="addNegativeGoods">添加</el-button>
  816. </div>
  817. </el-tab-pane>
  818. </el-tabs>
  819. </div>
  820. <div style="width: 50%">
  821. <el-card class="box-card" shadow="never" style="border: none">
  822. <template #header>
  823. <div class="card-header">
  824. <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ addedNegetiveTableData.length }}</span>
  825. <el-button class="button" text bg @click="delAllNegativeGoods">全部删除</el-button>
  826. </div>
  827. </template>
  828. <div class="card-body"></div>
  829. </el-card>
  830. <div style="padding: 0 10px 0 10px; margin-top: -30px">
  831. <el-table
  832. :data="addedNegetiveTableData"
  833. height="473"
  834. style="width: 100%"
  835. :header-cell-style="headerCellStyle"
  836. @selection-change="handleAddedNegGoods">
  837. <el-table-column prop="asin" label="商品">
  838. <template #default="scope">
  839. <div style="display: flex; align-items: center">
  840. <div style="margin-right: 8px; line-height: normal">
  841. <el-image class="img-box" :src="scope.row.image_link" />
  842. </div>
  843. <div>
  844. <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top">
  845. <div class="single-line">{{ scope.row.title ? scope.row.title : '--' }}</div>
  846. </el-tooltip>
  847. <span
  848. >ASIN:
  849. <span class="data-color" style="margin-right: 8px">{{ scope.row.asin ? scope.row.asin : '--' }}</span>
  850. </span>
  851. </div>
  852. </div>
  853. </template>
  854. </el-table-column>
  855. <el-table-column label="操作" width="120" align="right">
  856. <template #default="scope">
  857. <el-button type="primary" size="small" @click="delSingleNegativeGoods(scope)" text>删除</el-button>
  858. </template>
  859. </el-table-column>
  860. </el-table>
  861. </div>
  862. <div style="display: flex; justify-content: space-around; padding-top: 10px">
  863. <el-button plain type="primary" @click="negativeGoodsSave" :disabled="!addedNegetiveTableData.length">保存</el-button>
  864. </div>
  865. </div>
  866. </div>
  867. </el-form-item>
  868. <!-- <br />
  869. <el-form-item>
  870. <el-button size="large" @click="resetForm(ruleFormRef)">取消</el-button>
  871. <el-button size="large" type="primary" plain @click="submitForm(ruleFormRef)">保存</el-button>
  872. </el-form-item> -->
  873. </el-form>
  874. </div>
  875. </el-card>
  876. </div>
  877. </template>
  878. <script lang="ts" setup>
  879. import { onMounted, reactive, ref, computed, watch } from 'vue'
  880. import type { CSSProperties } from 'vue'
  881. import { useRoute } from 'vue-router'
  882. import type { FormInstance, FormRules, TabsPaneContext } from 'element-plus'
  883. import { ElMessage } from 'element-plus'
  884. import { useShopInfo } from '/@/stores/shopInfo'
  885. import { usePublicData } from '/@/stores/publicData'
  886. import { storeToRefs } from 'pinia'
  887. import { useRouter } from 'vue-router'
  888. import { request } from '/@/utils/service'
  889. const negativeTableData = ref([])
  890. const addedNegetiveTableData = ref([])
  891. const router = useRouter()
  892. const route = useRoute()
  893. const shopInfo = useShopInfo()
  894. const { profile } = storeToRefs(shopInfo)
  895. const loading = ref(true)
  896. const fullTableData = ref([]) // 表格数据
  897. let addedData = ref([]) // 已添加的商品数据
  898. let adsTableData = ref([])
  899. let selections = [] // 添加选中的项
  900. let addedSels = [] // 删除选中的项
  901. const currentPage = ref() // 当前页
  902. const pageSize = ref(20) // 每页显示条目数
  903. const totalItems = ref() // 数据总量
  904. const showCard = ref(false)
  905. const activeName = ref('first')
  906. const negativeTabs = ref('first')
  907. const keyWordsTabs = ref('first')
  908. const productOrientationTabs = ref('first')
  909. const categoryTabs = ref('first')
  910. const singleGoodsTabs = ref('first')
  911. const searchInp = ref('')
  912. const select = ref('name')
  913. const select2 = ref('latest')
  914. const buttons = [{ type: 'primary', text: '添加' }] as const
  915. const negativeInput = ref('')
  916. let widelyType = ref(true)
  917. let phraseType = ref(true)
  918. let exactType = ref(true)
  919. // 表单相关数据
  920. const campaignLoading = ref(false)
  921. const formSize = ref('default')
  922. const labelPosition = ref('top')
  923. // ------------------------------------------广告活动------------------------------------------
  924. let respCampaignId = ref('')
  925. let adGroupSave = ref(true)
  926. const campaignFormRef = ref<FormInstance>()
  927. interface CampaignForm {
  928. name: string
  929. adMix: string
  930. count: string
  931. startDate: string
  932. date2: string
  933. budget: string
  934. delivery: boolean
  935. type: string
  936. bidStrategy: string
  937. placeBid: string
  938. firstPage: string
  939. other: string
  940. }
  941. const campaignRuleForm = reactive<CampaignForm>({
  942. name: 'aitest02campaign_wxc',
  943. adMix: '',
  944. count: '',
  945. startDate: '',
  946. date2: '',
  947. budget: '',
  948. delivery: false,
  949. type: 'AUTO',
  950. bidStrategy: 'LEGACY_FOR_SALES',
  951. placeBid: '',
  952. firstPage: '',
  953. other: '',
  954. })
  955. const campaignRules = computed(() => ({
  956. name: [{ required: true, message: 'Please input Activity name', trigger: 'blur' }],
  957. adMix: [{ required: false, message: 'Please select Activity zone', trigger: 'change' }],
  958. count: [{ required: true, message: 'Please select Activity count', trigger: 'change' }],
  959. startDate: [{ required: true, type: 'date', message: 'Please pick a date', trigger: 'change' }],
  960. date2: [{ required: false, type: 'date', message: 'Please pick a time', trigger: 'change' }],
  961. budget: [
  962. { required: true, message: '请输入预算', trigger: 'blur' },
  963. { pattern: /^(?:[1-9]\d{0,5}|1000000)(?:\.\d{1,2})?$/, message: '预算必须是1到1000000之间的数字,小数点后最多两位', trigger: 'blur' },
  964. ],
  965. type: [{ required: false, trigger: 'change' }],
  966. bidStrategy: [{ required: true, message: 'Please select activity resource', trigger: 'change' }],
  967. placeBid: [{ required: false, pattern: /^[0-9]{1,3}$/, message: '必须是0~900之间的整数百分比', trigger: 'change' }],
  968. firstPage: [{ required: false, pattern: /^[0-9]{1,3}$/, message: '必须是0~900之间的整数百分比', trigger: 'change' }],
  969. other: [{ required: false, pattern: /^[0-9]{1,3}$/, message: '必须是0~900之间的整数百分比', trigger: 'change' }],
  970. }))
  971. async function createCampaigns() {
  972. try {
  973. // 必需字段列表
  974. const requiredFields = [
  975. { key: 'profile_id', value: profile.value.profile_id },
  976. { key: 'name', value: campaignRuleForm.name },
  977. { key: 'startDate', value: campaignRuleForm.startDate },
  978. { key: 'targetingType', value: campaignRuleForm.type },
  979. { key: 'strategy', value: campaignRuleForm.bidStrategy },
  980. { key: 'budget', value: campaignRuleForm.budget },
  981. ]
  982. // 检查每个必需字段
  983. requiredFields.forEach((field) => {
  984. if (!field.value) {
  985. throw new Error(`缺少必需的字段: ${field.key}`)
  986. }
  987. })
  988. // 构建请求数据
  989. const requestData = {
  990. profile_id: profile.value.profile_id,
  991. name: campaignRuleForm.name,
  992. startDate: campaignRuleForm.startDate,
  993. budget: campaignRuleForm.budget,
  994. targetingType: campaignRuleForm.type,
  995. strategy: campaignRuleForm.bidStrategy,
  996. state: 'PAUSED',
  997. // 可选字段
  998. endDate: campaignRuleForm.date2,
  999. t_percentage: campaignRuleForm.placeBid,
  1000. p_percentage: campaignRuleForm.firstPage,
  1001. r_percentage: campaignRuleForm.other,
  1002. }
  1003. // 过滤掉 undefined 或空的可选字段
  1004. const filteredRequestData = Object.fromEntries(Object.entries(requestData).filter(([_, v]) => v != null))
  1005. const resp = await request({
  1006. url: '/api/ad_manage/spcampaigns/create/',
  1007. method: 'POST',
  1008. data: filteredRequestData,
  1009. })
  1010. console.log('🚀 ~ createCampaigns ~ resp-->>', resp)
  1011. respCampaignId.value = resp.data.campaignId
  1012. if (respCampaignId.value) {
  1013. adGroupSave.value = false
  1014. campaignLoading.value = false
  1015. ElMessage({
  1016. message: '广告活动创建成功',
  1017. type: 'success',
  1018. })
  1019. } else {
  1020. campaignLoading.value = false
  1021. ElMessage.error('广告活动创建失败!')
  1022. }
  1023. } catch (error) {
  1024. console.error('请求失败:', error)
  1025. }
  1026. }
  1027. async function submitCampaignForm(formEl: FormInstance | undefined) {
  1028. if (!formEl) return
  1029. await formEl.validate((valid, fields) => {
  1030. if (valid) {
  1031. console.log('submit!')
  1032. campaignLoading.value = true
  1033. createCampaigns()
  1034. } else {
  1035. console.log('error submit!', fields)
  1036. }
  1037. })
  1038. }
  1039. async function submitForm(formEl: FormInstance | undefined) {
  1040. if (!formEl) return
  1041. await formEl.validate((valid, fields) => {
  1042. if (valid) {
  1043. console.log('submit!')
  1044. createCampaigns()
  1045. } else {
  1046. console.log('error submit!', fields)
  1047. }
  1048. })
  1049. }
  1050. function resetForm(formEl: FormInstance | undefined) {
  1051. if (!formEl) return
  1052. formEl.resetFields()
  1053. }
  1054. // ------------------------------------------------------广告组------------------------------------------------------
  1055. const adGroupRuleFormRef = ref<FormInstance>()
  1056. interface AdGroupForm {
  1057. adGroupName: string
  1058. defaultBidInp: string
  1059. }
  1060. const adGroupRuleForm = reactive<AdGroupForm>({
  1061. adGroupName: '',
  1062. defaultBidInp: '',
  1063. })
  1064. const adGroupRules = computed(() => ({
  1065. adGroupName: [{ required: true, message: '请输入广告组名称', trigger: 'blur' }],
  1066. defaultBidInp: [
  1067. { required: true, message: '请输入默认出价', trigger: 'blur' },
  1068. { validator: validateDefaultBidInp, trigger: 'blur' },
  1069. ],
  1070. }))
  1071. function validateDefaultBidInp(rule, value, callback) {
  1072. // 通用校验方法
  1073. if (value === '') {
  1074. callback(new Error('请输入默认出价'))
  1075. } else if (!/^(0\.0[2-9]|0\.[1-9]\d?|[1-9]\d{0,2}(\.\d{1,2})?|1000(\.0{1,2})?)$/.test(value)) {
  1076. callback(new Error('最小不低于0.02,最大不超过1000'))
  1077. } else {
  1078. const numericValue = parseFloat(value)
  1079. const numericBudget = parseFloat(campaignRuleForm.budget)
  1080. if (numericValue > numericBudget) {
  1081. callback(new Error('默认出价不能大于当前预算'))
  1082. } else {
  1083. callback()
  1084. }
  1085. }
  1086. }
  1087. let respAdGroupId = ref('')
  1088. let adsSave = ref(true)
  1089. async function createGroups() {
  1090. try {
  1091. // 构建请求数据
  1092. const requestData = {
  1093. profile_id: profile.value.profile_id,
  1094. campaignId: respCampaignId.value,
  1095. name: adGroupRuleForm.adGroupName,
  1096. defaultBid: adGroupRuleForm.defaultBidInp,
  1097. state: 'PAUSED',
  1098. }
  1099. // 过滤掉 undefined 或空的可选字段
  1100. const filteredRequestData = Object.fromEntries(Object.entries(requestData).filter(([_, v]) => v != null))
  1101. const resp = await request({
  1102. url: '/api/ad_manage/spgroups/create/',
  1103. method: 'POST',
  1104. data: filteredRequestData,
  1105. })
  1106. respAdGroupId.value = resp.data.adGroupId
  1107. console.log('🚀 ~ createGroups ~ resp-->>', resp)
  1108. adGroupLoading.value = false
  1109. if (respAdGroupId.value) {
  1110. ElMessage({
  1111. message: '广告组创建成功',
  1112. type: 'success',
  1113. })
  1114. } else {
  1115. ElMessage.error('广告组创建失败!')
  1116. }
  1117. } catch (error) {
  1118. console.error('请求失败:', error)
  1119. }
  1120. }
  1121. async function submitGroupsForm(formEl: FormInstance | undefined) {
  1122. if (!formEl) return
  1123. await formEl.validate((valid, fields) => {
  1124. if (valid) {
  1125. adGroupLoading.value = true
  1126. console.log('submit!')
  1127. createGroups()
  1128. } else {
  1129. console.log('error submit!', fields)
  1130. }
  1131. })
  1132. }
  1133. // ------------------------------------------商品------------------------------------------
  1134. const goodsTextarea = ref('')
  1135. const adGroupLoading = ref(false)
  1136. const commodityLoading = ref(false)
  1137. let addedAdsTableItems = ref([])
  1138. function setTableData(asin = '', sku = '') {
  1139. return request({
  1140. url: '/api/sellers/listings/our/',
  1141. method: 'GET',
  1142. params: {
  1143. page: currentPage.value,
  1144. limit: pageSize.value,
  1145. profile_id: profile.value.profile_id,
  1146. asin,
  1147. sku,
  1148. },
  1149. })
  1150. .then((resp) => {
  1151. fullTableData.value = resp.data
  1152. totalItems.value = resp.total
  1153. currentPage.value = resp.page
  1154. loading.value = false
  1155. })
  1156. .catch((error) => {
  1157. console.error('Error fetching data:', error)
  1158. loading.value = false
  1159. })
  1160. }
  1161. function addSingleGoods(scope) {
  1162. // console.log('scope', scope.row)
  1163. const isAlreadyAdded = adsTableData.value.some((item) => item.sku === scope.row.sku)
  1164. if (!isAlreadyAdded) {
  1165. adsTableData.value.push(scope.row)
  1166. } else {
  1167. console.log('Item is already added.')
  1168. }
  1169. }
  1170. function addGods() {
  1171. const inputData = goodsTextarea.value
  1172. const asins = inputData.split(/[\n,]+/)
  1173. asins.forEach((asin) => {
  1174. if (asin.trim()) {
  1175. setTableData(asin.trim())
  1176. .then((response) => {
  1177. console.log(`Data for ASIN ${asin}:`, response) // 更新这里来正确地访问数据
  1178. })
  1179. .catch((error) => {
  1180. console.error(`Error fetching data for ASIN ${asin}:`, error)
  1181. })
  1182. }
  1183. })
  1184. }
  1185. function delSingleGoods(scope) {
  1186. const index = adsTableData.value.findIndex((item) => item.sku === scope.row.sku)
  1187. if (index !== -1) {
  1188. adsTableData.value.splice(index, 1)
  1189. console.log('Item removed successfully.')
  1190. } else {
  1191. console.log('Item not found.')
  1192. }
  1193. }
  1194. function delAllGoods() {
  1195. adsTableData.value = []
  1196. // adsTableData.value.splice(0, adsTableData.value.length)
  1197. }
  1198. // 删除第二个table中已经选中的项
  1199. function delSelectedGoods() {
  1200. adsTableData.value = adsTableData.value.filter((item) => !addedSels.includes(item))
  1201. addedSels = []
  1202. }
  1203. function inpChange(e) {
  1204. const value = e
  1205. if (select.value === 'asin') {
  1206. loading.value = true
  1207. setTableData(value)
  1208. } else if (select.value === 'sku') {
  1209. loading.value = true
  1210. setTableData('', value)
  1211. }
  1212. }
  1213. function selChange(e) {
  1214. console.log('e', e)
  1215. const value = e
  1216. if (select.value === 'asin' && searchInp.value) {
  1217. loading.value = true
  1218. setTableData(value)
  1219. } else if (select.value === 'sku' && searchInp.value) {
  1220. loading.value = true
  1221. setTableData('', value)
  1222. }
  1223. }
  1224. // 点击表格选项触发事件
  1225. function handleSelectionChange(selection) {
  1226. selections = selection
  1227. }
  1228. // 获取addedTable中已选中的项
  1229. function handleAddedGoodsChange(selection) {
  1230. addedSels = selection
  1231. }
  1232. // 添加已选中的项
  1233. function handleGoodsAdd() {
  1234. // 过滤掉已经存在于addedData.value中的项
  1235. const newSelections = selections.filter(
  1236. (sel) => !adsTableData.value.some((added) => added.sku === sel.sku) // 使用sku作为唯一标识
  1237. )
  1238. // 如果有新的不重复项,加入到addedData.value中
  1239. if (newSelections.length > 0) {
  1240. adsTableData.value.push(...newSelections)
  1241. }
  1242. }
  1243. // 点击Tab
  1244. const handleGoodsTabs = (tab: TabsPaneContext, event: Event) => {
  1245. console.log(tab, event)
  1246. }
  1247. function isItemInList(item, list) {
  1248. return list.some((listItem) => listItem.sku === item.sku && listItem.asin === item.asin)
  1249. }
  1250. // 监听商品右侧表格已添加的数据并转化数据格式
  1251. watch(
  1252. adsTableData,
  1253. (newValue, oldValue) => {
  1254. newValue.forEach((item) => {
  1255. if (!isItemInList(item, addedAdsTableItems.value)) {
  1256. addedAdsTableItems.value.push({ sku: item.sku, asin: item.asin })
  1257. }
  1258. })
  1259. if (adsTableData.value.length !== 0) {
  1260. adsSave.value = false
  1261. } else {
  1262. adsSave.value = true
  1263. }
  1264. },
  1265. { deep: true }
  1266. )
  1267. async function createAds() {
  1268. try {
  1269. const requestData = {
  1270. profile_id: profile.value.profile_id,
  1271. campaignId: respCampaignId.value,
  1272. adGroupId: respAdGroupId.value,
  1273. asinsku: addedAdsTableItems.value,
  1274. state: 'PAUSED',
  1275. }
  1276. const filteredRequestData = Object.fromEntries(Object.entries(requestData).filter(([_, v]) => v != null))
  1277. const resp = await request({
  1278. url: '/api/ad_manage/spads/create/',
  1279. method: 'POST',
  1280. data: filteredRequestData,
  1281. })
  1282. console.log('🚀 ~ createAds ~ resp-->>', resp)
  1283. commodityLoading.value = false
  1284. if (resp.data.success.length > 0) {
  1285. adsSave.value = false
  1286. targetGroupBidSave.value = false
  1287. adsTableData.value = []
  1288. ElMessage({
  1289. message: '商品创建成功',
  1290. type: 'success',
  1291. })
  1292. } else {
  1293. ElMessage.error('商品创建失败!')
  1294. }
  1295. } catch (error) {
  1296. console.error('请求失败:', error)
  1297. }
  1298. }
  1299. function submitAdsForm() {
  1300. commodityLoading.value = true
  1301. createAds()
  1302. }
  1303. // ------------------------------------------目标组设置出价------------------------------------------
  1304. let targetGroupBidSave = ref(true)
  1305. let targetGroupLoading = ref(false)
  1306. const targetGroupFormRef = ref<FormInstance>()
  1307. interface TargetGroupForm {
  1308. closeMatch: boolean
  1309. broadMatch: boolean
  1310. similarProducts: boolean
  1311. relatedProducts: boolean
  1312. closeMatchInp: string
  1313. broadMatchInp: string
  1314. similarProductsInp: string
  1315. relatedProductsInp: string
  1316. }
  1317. const targetGroupRuleForm = reactive<TargetGroupForm>({
  1318. closeMatch: true,
  1319. broadMatch: true,
  1320. similarProducts: true,
  1321. relatedProducts: true,
  1322. closeMatchInp: '1',
  1323. broadMatchInp: '1',
  1324. similarProductsInp: '1',
  1325. relatedProductsInp: '1',
  1326. })
  1327. const targetGroupRules = computed(() => ({
  1328. closeMatchInp: [
  1329. { required: true, message: '请输入默认出价', trigger: 'blur' },
  1330. { validator: validateDefaultBidInp, trigger: 'blur' },
  1331. ],
  1332. broadMatchInp: [
  1333. { required: true, message: '请输入默认出价', trigger: 'blur' },
  1334. { validator: validateDefaultBidInp, trigger: 'blur' },
  1335. ],
  1336. similarProductsInp: [
  1337. { required: true, message: '请输入默认出价', trigger: 'blur' },
  1338. { validator: validateDefaultBidInp, trigger: 'blur' },
  1339. ],
  1340. relatedProductsInp: [
  1341. { required: true, message: '请输入默认出价', trigger: 'blur' },
  1342. { validator: validateDefaultBidInp, trigger: 'blur' },
  1343. ],
  1344. }))
  1345. function closeMatchChange() {
  1346. if (targetGroupRuleForm.closeMatch == false) {
  1347. targetGroupRuleForm.closeMatchInp = ''
  1348. targetGroupFormRef.value.clearValidate('closeMatchInp')
  1349. } else {
  1350. targetGroupRuleForm.closeMatchInp = '1'
  1351. // targetGroupFormRef.value.validateField('closeMatchInp')
  1352. }
  1353. }
  1354. function broadMatchChange() {
  1355. if (targetGroupRuleForm.broadMatch == false) {
  1356. targetGroupRuleForm.broadMatchInp = ''
  1357. targetGroupFormRef.value.clearValidate('broadMatchInp')
  1358. } else {
  1359. targetGroupRuleForm.broadMatchInp = '1'
  1360. // targetGroupFormRef.value.validateField('broadMatchInp')
  1361. }
  1362. }
  1363. function similarProductsChange() {
  1364. if (targetGroupRuleForm.similarProducts == false) {
  1365. targetGroupRuleForm.similarProductsInp = ''
  1366. targetGroupFormRef.value.clearValidate('similarProductsInp')
  1367. } else {
  1368. targetGroupRuleForm.similarProductsInp = '1'
  1369. // targetGroupFormRef.value.validateField('similarProductsInp')
  1370. }
  1371. }
  1372. function relatedProductsChange() {
  1373. if (targetGroupRuleForm.relatedProducts == false) {
  1374. targetGroupRuleForm.relatedProductsInp = ''
  1375. targetGroupFormRef.value.clearValidate('relatedProductsInp')
  1376. } else {
  1377. targetGroupRuleForm.relatedProductsInp = '1'
  1378. // targetGroupFormRef.value.validateField('relatedProductsInp')
  1379. }
  1380. }
  1381. async function createTargetGroup() {
  1382. try {
  1383. const requestData = {
  1384. profile_id: profile.value.profile_id,
  1385. adGroupId: respAdGroupId.value,
  1386. QUERY_HIGH_REL_MATCHES: targetGroupRuleForm.closeMatchInp,
  1387. QUERY_BROAD_REL_MATCHES: targetGroupRuleForm.broadMatchInp,
  1388. ASIN_SUBSTITUTE_RELATED: targetGroupRuleForm.similarProductsInp,
  1389. ASIN_ACCESSORY_RELATED: targetGroupRuleForm.relatedProductsInp,
  1390. QUERY_HIGH_REL_MATCHES_state: targetGroupRuleForm.closeMatch,
  1391. QUERY_BROAD_REL_MATCHES_state: targetGroupRuleForm.broadMatch,
  1392. ASIN_SUBSTITUTE_RELATED_state: targetGroupRuleForm.similarProducts,
  1393. ASIN_ACCESSORY_RELATED_state: targetGroupRuleForm.relatedProducts,
  1394. }
  1395. const filteredRequestData = Object.fromEntries(Object.entries(requestData).filter(([_, v]) => v != null))
  1396. const resp = await request({
  1397. url: '/api/ad_manage/sptargets/auto/updata/',
  1398. method: 'POST',
  1399. data: filteredRequestData,
  1400. })
  1401. console.log('🚀 ~ createTargetGroup ~ resp-->>', resp)
  1402. targetGroupLoading.value = false
  1403. if (respAdGroupId.value) {
  1404. ElMessage({
  1405. message: '目标组创建成功',
  1406. type: 'success',
  1407. })
  1408. } else {
  1409. ElMessage.error('目标组创建失败!')
  1410. }
  1411. } catch (error) {
  1412. console.error('请求失败:', error)
  1413. }
  1414. }
  1415. function submitTargetGroupForm() {
  1416. targetGroupLoading.value = true
  1417. console.log('submit!')
  1418. createTargetGroup()
  1419. }
  1420. // ------------------------------------------否定词------------------------------------------
  1421. const ruleFormRef = ref<FormInstance>()
  1422. interface RuleForm {
  1423. autoRedirect: string
  1424. // NEGATIVE_PHRASE: boolean
  1425. // NEGATIVE_EXACT: boolean
  1426. negativeTextarea: string
  1427. negativeGoodsTextarea: string
  1428. targetType: string
  1429. }
  1430. const ruleForm = reactive<RuleForm>({
  1431. autoRedirect: 'defaultBid',
  1432. // NEGATIVE_PHRASE: true,
  1433. // NEGATIVE_EXACT: true,
  1434. negativeTextarea: '',
  1435. negativeGoodsTextarea: '',
  1436. targetType: 'keyWords',
  1437. })
  1438. const rules = computed(() => ({
  1439. autoRedirect: [{ required: true, trigger: 'change' }],
  1440. // relatedProductsInp: getValidationRules('relatedProductsInp'),
  1441. // similarProductsInp: getValidationRules('similarProductsInp'),
  1442. // broadMatchInp: getValidationRules('broadMatchInp'),
  1443. // closeMatchInp: getValidationRules('closeMatchInp'),
  1444. }))
  1445. //------------------------------------------------------------------------------方法------------------------------------------------------------------------------
  1446. // 当单选按钮变化时更新showCard状态
  1447. function changeBid() {
  1448. console.log(ruleForm.autoRedirect)
  1449. showCard.value = ruleForm.autoRedirect === 'targetBid'
  1450. }
  1451. // 切换投放类型
  1452. function changeType() {}
  1453. // 处理分页器当前页变化
  1454. function handleCurrentChange(newPage) {
  1455. currentPage.value = newPage
  1456. loading.value = true
  1457. setTableData()
  1458. }
  1459. // 处理分页器每页显示条目数变化
  1460. function handleSizeChange(newSize) {
  1461. pageSize.value = newSize
  1462. currentPage.value = 1 // 重置到第一页
  1463. }
  1464. // ------------------------------------------投放类型模块------------------------------------------
  1465. async function changeTargetType() {
  1466. // console.log(ruleForm.targetType)
  1467. showCard.value = ruleForm.targetType === 'keyWords'
  1468. if (ruleForm.targetType === 'Goods') {
  1469. productOrientationLoading.value = true
  1470. await setProductOrientationData()
  1471. }
  1472. }
  1473. // ------------------------------------------商品定向模块------------------------------------------
  1474. const categoryBiddingType = ref('customBid')
  1475. const categoryBiddingTypeOptions = [
  1476. {
  1477. value: 'defaultBid',
  1478. label: '默认竞价',
  1479. },
  1480. {
  1481. value: 'customBid',
  1482. label: '自定义竞价',
  1483. },
  1484. ]
  1485. const categoryBidInput = ref('0.75')
  1486. const singleGoodsBidSelect = ref('customBid')
  1487. const singleGoodsBidTypeOptions = [
  1488. {
  1489. value: 'defaultBid',
  1490. label: '默认竞价',
  1491. },
  1492. {
  1493. value: 'customBid',
  1494. label: '自定义竞价',
  1495. },
  1496. ]
  1497. const singleGoodsBidInput = ref('0.75')
  1498. const expand = ref(true)
  1499. const accurate = ref(false)
  1500. const proposalTableData = ref([])
  1501. const searchClassifyTableData = ref([])
  1502. const productOrientationLoading = ref(false)
  1503. const dialogSelectLoading = ref(false)
  1504. const defaultProps = {
  1505. children: 'ch',
  1506. label: 'cna',
  1507. }
  1508. const countLoadig = ref(false)
  1509. const visible = ref(false)
  1510. let dialogTitle = ref('')
  1511. let categoryId = ref('')
  1512. const dialogselectValue = ref('')
  1513. let dialogOptions: any = ref([])
  1514. const dialogForm: any = reactive({
  1515. prices: {
  1516. lowest: undefined,
  1517. highest: undefined,
  1518. },
  1519. starRating: [0, 5],
  1520. dialogselectValue: [],
  1521. delivery: 'all',
  1522. isCount: false,
  1523. })
  1524. const dialogFormRef = ref()
  1525. const dialogRules = reactive({
  1526. prices: [{ validator: validatePrices, trigger: 'blur' }],
  1527. })
  1528. interface Mark {
  1529. style: CSSProperties
  1530. label: string
  1531. }
  1532. type Marks = Record<number, Mark | string>
  1533. const marks = reactive<Marks>({
  1534. 0: '0',
  1535. 1: '1',
  1536. 2: '2',
  1537. 3: '3',
  1538. 4: '4',
  1539. 5: '5',
  1540. })
  1541. let commodityCount = ref([])
  1542. let currentDialogIndex = ref(0)
  1543. let productOrientationTableData = ref([])
  1544. async function validatePrices(rule, value) {
  1545. if (value.highest !== '' && value.lowest !== '' && value.highest <= value.lowest) {
  1546. return Promise.reject('最高价格必须大于最低价格')
  1547. }
  1548. return Promise.resolve()
  1549. }
  1550. async function setProductOrientationData() {
  1551. try {
  1552. const resp = await request({
  1553. url: '/api/ad_manage/targetable/categories/',
  1554. method: 'GET',
  1555. params: {
  1556. profile_id: profile.value.profile_id,
  1557. },
  1558. })
  1559. searchClassifyTableData.value = resp.data
  1560. productOrientationLoading.value = false
  1561. } catch (error) {
  1562. console.error('请求失败:', error)
  1563. }
  1564. }
  1565. async function setDialogOption() {
  1566. try {
  1567. const resp = await request({
  1568. url: '/api/ad_manage/categories/brands/',
  1569. method: 'GET',
  1570. params: {
  1571. profile_id: profile.value.profile_id,
  1572. category_id: categoryId.value,
  1573. },
  1574. })
  1575. const options = resp.data
  1576. dialogForm.dialogOptions = options.brands.map((brand) => {
  1577. return {
  1578. label: brand.name,
  1579. value: brand.id,
  1580. }
  1581. })
  1582. dialogSelectLoading.value = false
  1583. } catch (error) {
  1584. console.error('请求失败:', error)
  1585. }
  1586. }
  1587. async function getCount(instanceId) {
  1588. try {
  1589. const resp = await request({
  1590. url: '/api/ad_manage/products/count/',
  1591. method: 'POST',
  1592. data: {
  1593. profile_id: profile.value.profile_id,
  1594. category_id: categoryId.value,
  1595. },
  1596. })
  1597. if (instanceId === currentDialogIndex.value) {
  1598. commodityCount.value = resp.data.AsinCounts
  1599. }
  1600. } catch (error) {
  1601. console.error('请求失败:', error)
  1602. } finally {
  1603. if (instanceId === currentDialogIndex.value) {
  1604. countLoadig.value = false
  1605. }
  1606. }
  1607. }
  1608. function dialogClose() {
  1609. currentDialogIndex.value++
  1610. resetDialogForm()
  1611. dialogForm.isCount = false
  1612. commodityCount.value = []
  1613. countLoadig.value = false
  1614. }
  1615. function resetDialogForm() {
  1616. dialogForm.prices.lowest = undefined
  1617. dialogForm.prices.highest = undefined
  1618. dialogForm.starRating = [0, 5]
  1619. dialogForm.dialogselectValue = []
  1620. dialogForm.delivery = 'all'
  1621. dialogForm.isCount = false
  1622. }
  1623. function isCountChanged() {
  1624. if (dialogForm.isCount) {
  1625. const instanceId = currentDialogIndex.value
  1626. countLoadig.value = true
  1627. getCount(instanceId)
  1628. } else {
  1629. countLoadig.value = false
  1630. commodityCount.value = []
  1631. }
  1632. }
  1633. function delCna(index) {
  1634. productOrientationTableData.value.splice(index, 1)
  1635. }
  1636. function delAllCna() {
  1637. productOrientationTableData.value = []
  1638. }
  1639. function singleGoodsBidSelectChanged() {
  1640. if (singleGoodsBidSelect.value === 'defaultBid' || categoryBiddingType.value === 'defaultBid') {
  1641. singleGoodsBidInput.value = ''
  1642. }
  1643. }
  1644. let singleGoodsSearchInp = ref('')
  1645. let searchTableData = ref([])
  1646. function setSearchTableData(asin = '', sku = '') {
  1647. return request({
  1648. url: '/api/sellers/listings/our/',
  1649. method: 'GET',
  1650. params: {
  1651. profile_id: profile.value.profile_id,
  1652. asin,
  1653. sku,
  1654. },
  1655. })
  1656. .then((resp) => {
  1657. searchTableData.value = resp.data
  1658. productOrientationLoading.value = false
  1659. })
  1660. .catch((error) => {
  1661. console.error('Error fetching data:', error)
  1662. productOrientationLoading.value = false
  1663. })
  1664. }
  1665. function singleGoodsSearchChaneged() {
  1666. productOrientationLoading.value = true
  1667. setSearchTableData()
  1668. }
  1669. function addSingleSearch(scope) {
  1670. console.log('🚀 ~ addSingleSearch ~ scope-->>', scope);
  1671. const typesToAdd = [];
  1672. if (expand.value) {
  1673. typesToAdd.push('ASIN_EXPANDED_FROM');
  1674. }
  1675. if (accurate.value) {
  1676. typesToAdd.push('ASIN_SAME_AS');
  1677. }
  1678. const productTypeMap = {
  1679. ASIN_EXPANDED_FROM: '扩展',
  1680. ASIN_SAME_AS: '精确',
  1681. };
  1682. typesToAdd.forEach((productType) => {
  1683. const isAlreadyAdded = productOrientationTableData.value.some(item => item.sku === scope.row.sku && item.productType === productType);
  1684. let bidValue = null;
  1685. // 根据 categoryBiddingType.value 的值设置 bidValue
  1686. if (categoryBiddingType.value === 'defaultBid') {
  1687. bidValue = adGroupRuleForm.defaultBidInp;
  1688. } else if (categoryBiddingType.value === 'customBid') {
  1689. bidValue = singleGoodsBidInput.value;
  1690. }
  1691. if (!isAlreadyAdded) {
  1692. const newData = {
  1693. type: 'p',
  1694. asin: scope.row.asin,
  1695. sku: scope.row.sku,
  1696. productType: productType,
  1697. productTypeText: productTypeMap[productType],
  1698. bid: bidValue, // 添加 bid 值
  1699. };
  1700. productOrientationTableData.value.push(newData);
  1701. } else {
  1702. console.log(`${productType} item is already added.`);
  1703. }
  1704. });
  1705. }
  1706. let selectedLabels = ref([]) // 选中的label数组
  1707. function dialogSelectChange(event) {
  1708. console.log('🚀 ~ dialogSelectChange ~ event-->>', event)
  1709. // 使用 map 来转换每个选中项的 value 为其对应的 label
  1710. selectedLabels.value = event.map((selectedValue) => {
  1711. const selectedOption = dialogForm.dialogOptions.find((option) => option.value === selectedValue)
  1712. return selectedOption ? selectedOption.label : ''
  1713. })
  1714. console.log('🚀 ~ dialogSelectChange ~ selectedLabels-->>', selectedLabels.value)
  1715. }
  1716. let refineItem = ref([])
  1717. // 细化按钮功能
  1718. function refine(data) {
  1719. console.log('🚀 ~ refine ~ data-->>', data)
  1720. commodityCount.value = []
  1721. dialogTitle.value = data.cna
  1722. categoryId.value = data.cid
  1723. refineItem.value.push(data)
  1724. visible.value = true
  1725. dialogSelectLoading.value = true
  1726. setDialogOption()
  1727. }
  1728. // 弹框提交功能
  1729. function dialogFormSubmit() {
  1730. dialogFormRef.value.validate((valid) => {
  1731. if (valid) {
  1732. console.log('表单提交')
  1733. visible.value = false
  1734. const dialogClassification = dialogTitle.value
  1735. const dialogPrices_low = dialogForm.prices.lowest
  1736. const dialogPrices_high = dialogForm.prices.highest
  1737. const dialogStartRating = dialogForm.starRating
  1738. const ratingLow = dialogStartRating[0]
  1739. const ratingHigh = dialogStartRating[1]
  1740. const dialogDelivery = dialogForm.delivery
  1741. console.log('🚀 ~ dialogFormRef.value.validate ~ dialogDelivery-->>', dialogDelivery)
  1742. const deliveryMap = {
  1743. all: '所有',
  1744. eligible: '具备Prime资格',
  1745. diseligible: '不具备Prime资格',
  1746. }
  1747. let bidValue = null;
  1748. // 根据 categoryBiddingType.value 的值设置 bidValue
  1749. if (categoryBiddingType.value === 'defaultBid') {
  1750. bidValue = adGroupRuleForm.defaultBidInp;
  1751. } else if (categoryBiddingType.value === 'customBid') {
  1752. bidValue = singleGoodsBidInput.value;
  1753. }
  1754. selectedLabels.value.forEach((brandLabel) => {
  1755. // 查找与当前 brandLabel 相对应的选项
  1756. const selectedOption = dialogForm.dialogOptions.find((option) => option.label === brandLabel)
  1757. // 获取对应的 brandId,如果没有找到则默认为空
  1758. const brandId = selectedOption ? selectedOption.value : ''
  1759. const refineObj = {
  1760. type: 'c',
  1761. classification: dialogClassification,
  1762. classificationId: categoryId.value,
  1763. brand: brandLabel,
  1764. brandId: brandId, // 使用找到的 brandId
  1765. bid: bidValue, // 添加 bid 值
  1766. low_price: dialogPrices_low,
  1767. high_price: dialogPrices_high,
  1768. low_rating: ratingLow,
  1769. high_rating: ratingHigh,
  1770. delivery: dialogDelivery,
  1771. deliveryText: deliveryMap[dialogDelivery],
  1772. }
  1773. console.log('🚀 ~ dialogFormRef.value.validate ~ refineObj-->>', refineObj)
  1774. productOrientationTableData.value.push(refineObj)
  1775. })
  1776. } else {
  1777. console.log('验证失败')
  1778. }
  1779. })
  1780. }
  1781. // 定向按钮功能
  1782. function orientate(node, data) {
  1783. console.log('🚀 ~ orientate ~ data-->>', data);
  1784. const exists = productOrientationTableData.value.some(item => item.cid === data.cid);
  1785. let bidValue = null;
  1786. // 根据 categoryBiddingType.value 的值设置 bidValue
  1787. if (categoryBiddingType.value === 'defaultBid') {
  1788. bidValue = adGroupRuleForm.defaultBidInp;
  1789. } else if (categoryBiddingType.value === 'customBid') {
  1790. bidValue = singleGoodsBidInput.value;
  1791. }
  1792. if (!exists) {
  1793. const newData = {
  1794. type: 'c',
  1795. classification: data.cna,
  1796. classificationId: data.cid,
  1797. bid: bidValue, // 将 bid 值添加到新数据中
  1798. };
  1799. productOrientationTableData.value.push(newData);
  1800. }
  1801. }
  1802. let productTargetBidList = ref([])
  1803. async function productTagetSave() {
  1804. console.log('tableData', productOrientationTableData.value)
  1805. // 检查是否存在 bid 为空的行
  1806. const hasEmptyBid = productOrientationTableData.value.some(row => row.bid == null || row.bid === '')
  1807. // 直接返回,不继续执行
  1808. if (hasEmptyBid) {
  1809. console.log('存在空的 bid,不发送请求')
  1810. ElMessage.error('存在空的 bid,无法创建商品!')
  1811. return
  1812. }
  1813. productOrientationTableData.value.forEach((row) => {
  1814. productTargetBidList.value.push(row.bid)
  1815. })
  1816. console.log('productTargetBidList', productTargetBidList.value)
  1817. productOrientationLoading.value = true
  1818. try {
  1819. const requestData = {
  1820. profile_id: profile.value.profile_id,
  1821. adGroupId: respAdGroupId.value,
  1822. campaignId: respCampaignId.value,
  1823. expressionList: productOrientationTableData.value,
  1824. state: "PAUSED"
  1825. }
  1826. const filteredRequestData = Object.fromEntries(Object.entries(requestData).filter(([_, v]) => v != null))
  1827. const resp = await request({
  1828. url: '/api/ad_manage/sptargets/manual/create/',
  1829. method: 'POST',
  1830. data: filteredRequestData,
  1831. })
  1832. console.log('🚀 ~ createTargetGroup ~ resp-->>', resp)
  1833. productOrientationLoading.value = false
  1834. if (respAdGroupId.value) {
  1835. ElMessage({
  1836. message: '商品创建成功',
  1837. type: 'success',
  1838. })
  1839. } else {
  1840. ElMessage.error('商品创建失败!')
  1841. }
  1842. } catch (error) {
  1843. console.error('请求失败:', error)
  1844. }
  1845. // 清空表格和 bid 列表
  1846. productOrientationTableData.value = []
  1847. productTargetBidList.value = []
  1848. }
  1849. // ------------------------------------------关键词定向模块------------------------------------------
  1850. const bidType = ref('customBid')
  1851. const bidTypeOptions = [
  1852. // 竞价select下拉选项
  1853. {
  1854. value: 'suggestBid',
  1855. label: '建议出价',
  1856. },
  1857. {
  1858. value: 'customBid',
  1859. label: '自定义出价',
  1860. },
  1861. {
  1862. value: 'defaultBid',
  1863. label: '默认出价',
  1864. },
  1865. ]
  1866. const bidInput = ref('0.75')
  1867. const keyWordsTableData = ref([]) // 关键词定向左侧表格数据
  1868. const addedKeyWordsTableData = ref([]) // 关键词定向右侧表格数据
  1869. const keyWordsTextarea = ref('')
  1870. function delAllKeyWords() {
  1871. // 删除已经添加的关键词
  1872. addedKeyWordsTableData.value = []
  1873. }
  1874. function addKeyWords() {
  1875. // 添加关键词
  1876. if (keyWordsTextarea.value) {
  1877. addedKeyWordsTableData.value.push({
  1878. keyWords: keyWordsTextarea.value,
  1879. })
  1880. keyWordsTextarea.value = ''
  1881. }
  1882. }
  1883. // ------------------------------------------否定词模块------------------------------------------
  1884. let negativeWordsLoading = ref(false)
  1885. let negativeList = reactive([])
  1886. let negativeWordsTextarea = ref('')
  1887. let NEGATIVE_PHRASE = ref(true)
  1888. let NEGATIVE_EXACT = ref(true)
  1889. let exactNegativeList = reactive([]) // 用于存储精确否定的数组
  1890. let phraseNegativeList = reactive([]) // 用于存储词组否定的数组
  1891. function addNegative() {
  1892. const trimmedText = negativeWordsTextarea.value.trim()
  1893. const items = trimmedText.split(/,|\n/)
  1894. items.forEach((item) => {
  1895. const trimmedItem = item.trim()
  1896. if (trimmedItem) {
  1897. let phraseEntry = '词组: ' + trimmedItem
  1898. let exactEntry = '精确: ' + trimmedItem
  1899. if (NEGATIVE_PHRASE.value && !negativeList.some((n) => n.negativeWords === phraseEntry)) {
  1900. negativeList.push({ negativeWords: phraseEntry })
  1901. phraseNegativeList.push(trimmedItem) // 添加到词组否定数组
  1902. }
  1903. if (NEGATIVE_EXACT.value && !negativeList.some((n) => n.negativeWords === exactEntry)) {
  1904. negativeList.push({ negativeWords: exactEntry })
  1905. exactNegativeList.push(trimmedItem) // 添加到精确否定数组
  1906. }
  1907. } else {
  1908. console.log('有空项目,未被添加到列表中')
  1909. }
  1910. })
  1911. negativeWordsTextarea.value = ''
  1912. console.log('🚀 ~ exactNegativeList-->>', exactNegativeList)
  1913. console.log('🚀 ~ phraseNegativeList-->>', phraseNegativeList)
  1914. }
  1915. function delAllNegative() {
  1916. // negativeList.splice(0, negativeList.length)
  1917. negativeList.length = 0
  1918. exactNegativeList.length = 0
  1919. phraseNegativeList.length = 0
  1920. }
  1921. function delSingleNegative(scope) {
  1922. const index = negativeList.findIndex((item) => item.negativeWords === scope.row.negativeWords)
  1923. if (index !== -1) {
  1924. // 确定被删除的项是词组还是精确
  1925. const isPhrase = scope.row.negativeWords.startsWith('词组: ')
  1926. const isExact = scope.row.negativeWords.startsWith('精确: ')
  1927. // 从 negativeList 删除
  1928. if (negativeList.length) {
  1929. negativeList.splice(index, 1)
  1930. console.log(`已删除索引为 ${index} 的条目`)
  1931. } else {
  1932. console.log('无效的索引,无法删除条目')
  1933. }
  1934. // 从 exactNegativeList 或 phraseNegativeList 删除
  1935. const trimmedItem = scope.row.negativeWords.substring(4).trim() // 从 '词组: ' 或 '精确: ' 后开始截取
  1936. if (isPhrase) {
  1937. const phraseIndex = phraseNegativeList.findIndex((item) => item === trimmedItem)
  1938. if (phraseIndex !== -1) {
  1939. phraseNegativeList.splice(phraseIndex, 1)
  1940. }
  1941. } else if (isExact) {
  1942. const exactIndex = exactNegativeList.findIndex((item) => item === trimmedItem)
  1943. if (exactIndex !== -1) {
  1944. exactNegativeList.splice(exactIndex, 1)
  1945. }
  1946. }
  1947. } else {
  1948. console.log('无效的索引,无法删除条目')
  1949. }
  1950. }
  1951. async function negativeWordsSave() {
  1952. negativeWordsLoading.value = true
  1953. console.log('negativeList', negativeList)
  1954. try {
  1955. const requestData = {
  1956. profile_id: profile.value.profile_id,
  1957. campaignId: respCampaignId.value,
  1958. adGroupId: respAdGroupId.value,
  1959. state: 'PAUSED',
  1960. EkeywordList: exactNegativeList,
  1961. PkeywordList: phraseNegativeList,
  1962. }
  1963. const filteredRequestData = Object.fromEntries(Object.entries(requestData).filter(([_, v]) => v != null))
  1964. const resp = await request({
  1965. url: '/api/ad_manage/sptargets/add/negative/keywords/',
  1966. method: 'POST',
  1967. data: filteredRequestData,
  1968. })
  1969. console.log('🚀 ~ negativeWordsSave ~ resp-->>', resp)
  1970. negativeWordsLoading.value = false
  1971. if (resp.data.negativeKeyworderror.length !== 0) {
  1972. ElMessage({
  1973. message: '否定词创建成功',
  1974. type: 'success',
  1975. })
  1976. delAllNegative()
  1977. } else {
  1978. ElMessage.error('否定词创建失败!')
  1979. }
  1980. } catch (error) {
  1981. console.error('请求失败:', error)
  1982. }
  1983. }
  1984. // ------------------------------------------否定商品模块------------------------------------------
  1985. let negativeGoodsLoading = ref(false)
  1986. const tableData = negativeList
  1987. let inputAddedNegGoods = ref([])
  1988. function setNegativeTableData(asin = '') {
  1989. negativeGoodsLoading.value = true
  1990. return request({
  1991. url: '/api/sellers/listings/all/',
  1992. method: 'GET',
  1993. params: {
  1994. page: currentPage.value,
  1995. limit: pageSize.value,
  1996. profile_id: profile.value.profile_id,
  1997. asin,
  1998. },
  1999. })
  2000. .then((resp) => {
  2001. negativeTableData.value = resp.data
  2002. inputAddedNegGoods.value = resp.data
  2003. negativeGoodsLoading.value = false
  2004. })
  2005. .catch((error) => {
  2006. console.error('Error fetching data:', error)
  2007. negativeGoodsLoading.value = false
  2008. })
  2009. }
  2010. // 输入tab的textarea
  2011. function addNegativeGoods() {
  2012. console.log('ruleForm.negativeGoodsTextarea', ruleForm.negativeGoodsTextarea)
  2013. loading.value = true
  2014. setNegativeTableData(ruleForm.negativeGoodsTextarea)
  2015. .then(() => {
  2016. addedNegetiveTableData.value = [...addedNegetiveTableData.value, ...inputAddedNegGoods.value]
  2017. })
  2018. .catch((error) => {
  2019. console.error('Error fetching data:', error)
  2020. })
  2021. .finally(() => {
  2022. loading.value = false
  2023. })
  2024. }
  2025. function addSingleNegativeGoods(scope) {
  2026. const isAlreadyAdded = addedNegetiveTableData.value.some((item) => item.asin === scope.row.asin)
  2027. if (!isAlreadyAdded) {
  2028. addedNegetiveTableData.value.push(scope.row)
  2029. } else {
  2030. console.log('Item is already added.')
  2031. }
  2032. }
  2033. function delAllNegativeGoods() {
  2034. addedNegetiveTableData.value = []
  2035. }
  2036. function delSingleNegativeGoods(scope) {
  2037. const index = addedNegetiveTableData.value.findIndex((item) => item.asin === scope.row.asin)
  2038. if (index !== -1) {
  2039. addedNegetiveTableData.value.splice(index, 1)
  2040. console.log('Item removed successfully.')
  2041. } else {
  2042. console.log('Item not found.')
  2043. }
  2044. }
  2045. function searchNegativeGoods(e) {
  2046. console.log(e)
  2047. if (e === '') {
  2048. negativeTableData.value = []
  2049. } else {
  2050. setNegativeTableData(e)
  2051. }
  2052. }
  2053. function handleAddedNegGoods(selection) {
  2054. addedSels = selection
  2055. }
  2056. function handleNegGoodsTabs(tab: TabsPaneContext, event: Event) {
  2057. // console.log(tab, event)
  2058. }
  2059. async function negativeGoodsSave() {
  2060. console.log(addedNegetiveTableData.value)
  2061. const asinList = addedNegetiveTableData.value.map((item) => item.asin)
  2062. console.log('🚀 ~ negativeGoodsSave ~ asinList-->>', asinList)
  2063. negativeGoodsLoading.value = true
  2064. console.log('addedNegetiveTableData', addedNegetiveTableData.value)
  2065. try {
  2066. const requestData = {
  2067. profile_id: profile.value.profile_id,
  2068. campaignId: respCampaignId.value,
  2069. adGroupId: respAdGroupId.value,
  2070. asinList: asinList,
  2071. matchType: 'ASIN_SAME_AS',
  2072. state: 'PAUSED',
  2073. }
  2074. const filteredRequestData = Object.fromEntries(Object.entries(requestData).filter(([_, v]) => v != null))
  2075. const resp = await request({
  2076. url: '/api/ad_manage/sptargets/add/negative/targets/',
  2077. method: 'POST',
  2078. data: filteredRequestData,
  2079. })
  2080. console.log('🚀 ~ negativeWordsSave ~ resp-->>', resp)
  2081. negativeGoodsLoading.value = false
  2082. if (resp.data.success.length !== 0) {
  2083. ElMessage({
  2084. message: '否定商品创建成功',
  2085. type: 'success',
  2086. })
  2087. delAllNegative()
  2088. } else {
  2089. ElMessage.error('否定商品创建失败!')
  2090. }
  2091. } catch (error) {
  2092. console.error('请求失败:', error)
  2093. }
  2094. }
  2095. // ------------------------------------------自定义校验模块------------------------------------------
  2096. function checkBid(value, callback, bidField) {
  2097. const bid = parseFloat(value)
  2098. const budget = parseFloat(campaignRuleForm.budget)
  2099. // 检查值是否为最多两位小数的普通数字格式
  2100. const isNormalNumberWithTwoDecimals = /^-?\d+(\.\d{1,2})?$/.test(value)
  2101. if (!isNormalNumberWithTwoDecimals) {
  2102. callback(new Error('请输入数字值(最多两位小数)'))
  2103. } else if (isNaN(bid)) {
  2104. callback(new Error('请输入有效的数字'))
  2105. } else if (bid < 0.02 || bid > 1000) {
  2106. callback(new Error('值必须在0.02到1000之间'))
  2107. } else if (bid >= budget) {
  2108. callback(new Error('出价必须小于预算'))
  2109. } else {
  2110. callback()
  2111. }
  2112. }
  2113. // 自定义校验规则---自动定价和按目标设置出价模块
  2114. // function getValidationRules(fieldName) {
  2115. // // 默认校验规则
  2116. // const commonRules = [
  2117. // { required: true, message: '此项为必填项', trigger: 'blur' },
  2118. // { validator: (rule, value, callback) => checkBid(value, callback, fieldName), trigger: 'blur' },
  2119. // ]
  2120. // // 根据不同字段和状态返回特定的校验规则
  2121. // switch (fieldName) {
  2122. // case 'defaultBidInp':
  2123. // if (ruleForm.autoRedirect === 'defaultBid') {
  2124. // return commonRules
  2125. // }
  2126. // break
  2127. // case 'similarProductsInp':
  2128. // if (ruleForm.autoRedirect === 'targetBid' && ruleForm.similarProducts) {
  2129. // return commonRules
  2130. // } else if (ruleForm.similarProducts == false) {
  2131. // ruleFormRef.value?.clearValidate(fieldName)
  2132. // }
  2133. // break
  2134. // case 'relatedProductsInp':
  2135. // if (ruleForm.autoRedirect === 'targetBid' && ruleForm.relatedProducts) {
  2136. // return commonRules
  2137. // } else if (ruleForm.relatedProducts == false) {
  2138. // ruleFormRef.value?.clearValidate(fieldName)
  2139. // }
  2140. // break
  2141. // case 'broadMatchInp':
  2142. // if (ruleForm.autoRedirect === 'targetBid' && ruleForm.broadMatch) {
  2143. // return commonRules
  2144. // } else if (ruleForm.broadMatch == false) {
  2145. // ruleFormRef.value?.clearValidate(fieldName)
  2146. // }
  2147. // break
  2148. // case 'closeMatchInp':
  2149. // // 仅当autoRedirect为'targetBid'且closeMatch开启时校验closeMatchInp
  2150. // if (ruleForm.autoRedirect === 'targetBid' && ruleForm.closeMatch) {
  2151. // return commonRules
  2152. // } else if (ruleForm.closeMatch == false) {
  2153. // ruleFormRef.value?.clearValidate(fieldName)
  2154. // }
  2155. // break
  2156. // default:
  2157. // return []
  2158. // }
  2159. // // 如果不满足上述条件,则无需校验
  2160. // return []
  2161. // }
  2162. // 监听表单字段变化,根据不同字段和状态返回特定的校验规则
  2163. // watch(
  2164. // [() => ruleForm.autoRedirect, () => ruleForm.closeMatch, () => ruleForm.broadMatch, () => ruleForm.similarProducts, () => ruleForm.relatedProducts],
  2165. // () => {
  2166. // // 定义需要更新校验规则的字段
  2167. // const fields = ['defaultBidInp', 'closeMatchInp', 'broadMatchInp', 'similarProductsInp', 'relatedProductsInp']
  2168. // fields.forEach((field) => {
  2169. // rules.value[field] = getValidationRules(field)
  2170. // })
  2171. // }
  2172. // )
  2173. // 修改表头样式
  2174. const headerCellStyle = (args) => {
  2175. if (args.rowIndex === 0) {
  2176. return {
  2177. backgroundColor: 'rgba(245, 245, 245, 0.9)',
  2178. }
  2179. }
  2180. }
  2181. function changeNegTableHeader(args) {
  2182. if (args.rowIndex === 0) {
  2183. return {
  2184. color: '#505968',
  2185. }
  2186. }
  2187. }
  2188. function changeKeyWordsTableHeader(args) {
  2189. if (args.rowIndex === 0) {
  2190. return {
  2191. color: '#505968',
  2192. backgroundColor: 'rgba(245, 245, 245, 0.9)',
  2193. }
  2194. }
  2195. }
  2196. onMounted(() => {
  2197. setTableData()
  2198. // const myTest = route.query
  2199. // console.log('myTest', myTest)
  2200. })
  2201. defineOptions({
  2202. name: 'SpCreateCampaigns',
  2203. })
  2204. </script>
  2205. <style lang="scss" scoped>
  2206. ::v-deep(.el-form--default.el-form--label-top .el-form-item .el-form-item__label) {
  2207. font-weight: 500;
  2208. }
  2209. .column-item .el-radio-group {
  2210. display: inline-flex;
  2211. font-size: 0;
  2212. flex-direction: column;
  2213. align-items: flex-start;
  2214. }
  2215. .radio-description {
  2216. font-size: 12px;
  2217. color: #666;
  2218. margin-top: -18px;
  2219. margin-left: 22px;
  2220. }
  2221. .radio-description-2 {
  2222. font-size: 12px;
  2223. color: #666;
  2224. margin-top: -10px;
  2225. }
  2226. .column-margin-bottom label.el-radio.is-bordered {
  2227. margin-bottom: 10px;
  2228. padding: 35px;
  2229. }
  2230. ::v-deep(.column-margin-bottom label.el-radio.is-bordered span.el-radio__inner) {
  2231. margin-top: -18px;
  2232. margin-left: -15px;
  2233. }
  2234. .gap-items {
  2235. display: flex;
  2236. justify-content: flex-start;
  2237. width: 100%;
  2238. margin-bottom: 20px;
  2239. }
  2240. .gap-item {
  2241. width: 200px;
  2242. margin-left: 30px;
  2243. color: #0b0d0d;
  2244. }
  2245. .demo-tabs > .el-tabs__content {
  2246. padding: 52px;
  2247. color: #6b778c;
  2248. font-size: 32px;
  2249. font-weight: 600;
  2250. }
  2251. /* 广告组商品Tab栏 */
  2252. ::v-deep(.el-tabs__nav-scroll) {
  2253. overflow: hidden;
  2254. margin-left: 20px;
  2255. }
  2256. ::v-deep(.el-tabs__nav-wrap::after) {
  2257. height: 2px !important;
  2258. }
  2259. ::v-deep(.el-table__inner-wrapper::before) {
  2260. background-color: white;
  2261. }
  2262. // 表格内容边距
  2263. div {
  2264. & #pane-first,
  2265. & #pane-second {
  2266. margin: 10px;
  2267. }
  2268. }
  2269. // 输入底部样式
  2270. ::v-deep(.card-box .el-card__body) {
  2271. display: flex;
  2272. align-items: center;
  2273. justify-content: space-between;
  2274. padding: 12px;
  2275. }
  2276. .card-header {
  2277. display: flex;
  2278. justify-content: space-between;
  2279. align-items: center;
  2280. }
  2281. .box-card {
  2282. width: 100%;
  2283. // margin: 10px 0 10px 10px;
  2284. margin-right: 10px;
  2285. }
  2286. .single-line {
  2287. color: rgb(30, 33, 41);
  2288. overflow: hidden;
  2289. display: -webkit-box;
  2290. -webkit-box-orient: vertical;
  2291. -webkit-line-clamp: 1;
  2292. white-space: pre-wrap;
  2293. word-break: break-word;
  2294. }
  2295. .data-color {
  2296. color: rgb(30, 33, 41);
  2297. }
  2298. .img-box {
  2299. width: 60px;
  2300. height: 60px;
  2301. margin-top: 5px;
  2302. border: 1px solid rgb(194, 199, 207);
  2303. border-radius: 4px;
  2304. }
  2305. .target-group-item {
  2306. margin-top: 15px;
  2307. }
  2308. .suggested-bid-item {
  2309. margin-left: 230px;
  2310. margin-right: 60px;
  2311. }
  2312. .bid-input {
  2313. width: 200px;
  2314. margin-left: 15px;
  2315. }
  2316. ::v-deep(.goods-orientation-tabs .el-tabs__nav-scroll) {
  2317. margin-left: -20px !important;
  2318. }
  2319. ::v-deep(.category-tabs .el-tabs__nav) {
  2320. margin-left: 20px;
  2321. }
  2322. ::v-deep(.goods-orientation-tabs #tab-1) {
  2323. /* 商品定向Tab栏 */
  2324. border-right: 0;
  2325. }
  2326. .custom-tree-node {
  2327. /* el-tree自定义样式 */
  2328. flex: 1;
  2329. display: flex;
  2330. align-items: center;
  2331. justify-content: space-between;
  2332. font-size: 14px;
  2333. padding-right: 8px;
  2334. }
  2335. .dialog-head {
  2336. /* 弹窗样式 */
  2337. display: flex;
  2338. flex-direction: row;
  2339. justify-content: space-between;
  2340. }
  2341. </style>