123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458 |
- <template>
- <div>
- <el-card>
- <div style="padding-left: 5px">
- <!-- 广告活动 -->
- <div style="font-size: 20px; font-weight: bold">广告活动</div>
- <hr />
- <br />
- <el-form
- :label-position="labelPosition"
- ref="ruleFormRef"
- :model="ruleForm"
- :rules="rules"
- label-width="120px"
- class="demo-ruleForm"
- :size="formSize"
- status-icon>
- <el-form-item label="广告活动名称" prop="name" style="width: 350px">
- <el-input v-model="ruleForm.name" />
- </el-form-item>
- <el-form-item label="广告组合" prop="adMix">
- <el-select v-model="ruleForm.adMix" placeholder="请选择">
- <el-option label="Zone one" value="shanghai" />
- <el-option label="Zone two" value="beijing" />
- </el-select>
- </el-form-item>
- <el-form-item prop="date1" label="开始日期" style="width: 350px">
- <el-date-picker v-model="ruleForm.date1" type="date" label="开始日期" placeholder="开始日期" style="width: 100%" />
- </el-form-item>
- <el-form-item prop="date2" label="结束日期" style="width: 350px">
- <el-date-picker v-model="ruleForm.date2" label="结束日期" placeholder="结束日期" style="width: 100%" />
- </el-form-item>
- <el-form-item prop="budget" label="每日预算" style="width: 350px">
- <el-input v-model="ruleForm.budget" maxlength="7" oninput="value=value.indexOf('.') > -1?value.slice(0, value.indexOf('.') + 3):value" />
- </el-form-item>
- <el-form-item label="投放类型" prop="type" class="column-item">
- <el-radio-group v-model="ruleForm.type" @click="changeType">
- <div>
- <el-radio label="auto">自动</el-radio>
- <div class="radio-description">定向与您推广商品相似的关键词和商品</div>
- </div>
- <div>
- <el-radio label="manual">手动</el-radio>
- <div class="radio-description">选择关键词或商品以定向购物者搜索并设置自定义出价</div>
- </div>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="竞价策略" prop="bidStrategy" class="column-item column-margin-bottom">
- <el-radio-group v-model="ruleForm.bidStrategy">
- <div>
- <el-radio label="dynamicBid_Low" border>
- 动态竞价-仅降低
- <div class="radio-description-2">当您的广告不太可能带来销售时,我们将实时降低您的竞价</div>
- </el-radio>
- </div>
- <div>
- <el-radio label="dynamicBid_HighAndLow" border>
- 动态竞价-提高和降低
- <div class="radio-description-2">
- 当您的广告很有可能带来销售时,我们将实时提高您的竞价(最高可达 100%),并在您的广告不太可能带来销售时降低您的竞价
- </div>
- </el-radio>
- </div>
- <el-radio label="staticBid" border>
- 固定竞价
- <div class="radio-description-2">我们将使用您的确切竞价和您设置的任何手动调整,而不会根据售出可能性对您的竞价进行更改</div>
- </el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="按展示位置调整出价" prop="placeBid">
- <p style="color: #8e9196">除了出价策略外,您还可以将出价提高多达900%</p>
- <div class="gap-items">
- <div class="gap-item">搜索结果顶部(首页)</div>
- <el-input v-model="ruleForm.placeBid" class="gap-item">
- <template #append>%</template>
- </el-input>
- </div>
- <div class="gap-items">
- <div class="gap-item">商品首页</div>
- <el-input v-model="ruleForm.firstPage" class="gap-item">
- <template #append>%</template>
- </el-input>
- </div>
- <div class="gap-items">
- <div class="gap-item">搜索结果的其余位置</div>
- <el-input v-model="ruleForm.other" class="gap-item">
- <template #append>%</template>
- </el-input>
- </div>
- </el-form-item>
- <!-- 广告组 -->
- <div style="font-size: 20px; font-weight: bold; margin-top: 30px">广告组</div>
- <hr />
- <el-form-item label="广告组名称" prop="adGroupName" style="width: 350px; margin-top: 20px">
- <el-input v-model="ruleForm.adGroupName" />
- </el-form-item>
- <!-- 广告组商品表格 -->
- <el-form-item label="商品" prop="commodity" style="width: 100%; margin-top: 20px">
- <div style="width: 100%; height: 620px; display: flex; border: 1px solid #c2c7cf; border-radius: 6px">
- <div style="width: 50%; border-right: 1px solid #c2c7cf">
- <el-tabs v-model="activeName" class="demo-tabs">
- <el-tab-pane label="搜索" name="first">
- <div style="margin-bottom: 10px">
- <el-input v-model="searchInp" placeholder="Please input" class="input-with-select" @change="inpChange" clearable>
- <template #prepend>
- <el-select v-model="select" style="width: 100px" @change="selChange">
- <el-option label="名称" value="name" />
- <el-option label="ASIN" value="asin" />
- <el-option label="SKU" value="sku" />
- </el-select>
- </template>
- <template #append>
- <el-select v-model="select2" style="width: 100px">
- <el-option label="最新优先" value="latest" />
- <el-option label="最早优先" value="earliest" />
- <el-option label="优选广告" value="optimal" />
- </el-select>
- </template>
- </el-input>
- </div>
- <el-table
- height="490"
- style="width: 100%"
- v-loading="loading"
- :data="fullTableData"
- :header-cell-style="headerCellStyle"
- @selection-change="handleSelectionChange">
- <el-table-column type="selection" width="50" />
- <el-table-column prop="asin" label="商品">
- <template #default="scope">
- <div style="display: flex; align-items: center">
- <div style="margin-right: 8px; line-height: normal">
- <el-image class="img-box" :src="scope.row.image_link" />
- </div>
- <div>
- <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top">
- <div class="single-line">{{ scope.row.title ? scope.row.title : '--' }}</div>
- </el-tooltip>
- <div class="data-color">
- <span style="font-weight: 500; color: rgb(30, 33, 41)">${{ scope.row.price ? scope.row.price : '--' }}</span>
- <span style="margin: 0 5px; color: #cacdd4">|</span>
- <span style="color: #6d7784">{{ scope.row.quantity }}</span>
- </div>
- <span>
- ASIN: <span class="data-color" style="margin-right: 8px">{{ scope.row.asin ? scope.row.asin : '--' }}</span>
- </span>
- <span>
- SKU: <span class="data-color">{{ scope.row.sku ? scope.row.sku : '--' }}</span>
- </span>
- </div>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="name" label="Name" width="120" align="right">
- <template #header>
- <el-button type="primary" size="normal" link @click="handleGoodsAdd">添加已选中</el-button>
- </template>
- <template #default="scope">
- <el-button type="primary" size="small" @click="addSingleGoods(scope)" text>添加</el-button>
- </template>
- </el-table-column>
- </el-table>
- <el-pagination
- @current-change="handleCurrentChange"
- @size-change="handleSizeChange"
- :current-page="currentPage"
- :page-size="pageSize"
- :total="totalItems"
- layout="prev, pager, next" />
- </el-tab-pane>
- <el-tab-pane label="输入" name="second">
- <el-input
- style="padding: 10px"
- v-model="goodsTextarea"
- :rows="20"
- type="textarea"
- placeholder="请输入ASIN,多个ASIN使用逗号、空格或换行符分隔。(未完成)"
- maxlength="11000" />
- <div style="display: flex; flex-direction: row-reverse; margin-top: 10px">
- <el-button v-for="button in buttons" :key="button.text" :type="button.type" link @click="addGods">{{ button.text }}</el-button>
- </div>
- <!-- <el-row :gutter="12" style="margin-top: 50px">
- <el-col :span="12">
- <el-card class="card-box" shadow="never" style="border: none; background-color: #e3f0de; height: 50px">
- <div style="line-height: 15px">成功添加:</div>
- <div style="line-height: 15px">
- <el-icon style="color: #8fc47d; font-size: 25px"><SuccessFilled /></el-icon>
- </div>
- </el-card>
- </el-col>
- <el-col :span="12">
- <el-card class="card-box" shadow="never" style="border: none; background-color: #fbe6e3; height: 50px">
- <div style="line-height: 15px">未成功添加:</div>
- <div style="line-height: 15px">
- <el-icon style="color: #e3918d; font-size: 25px"><CircleCloseFilled /></el-icon>
- </div>
- </el-card>
- </el-col>
- </el-row> -->
- </el-tab-pane>
- </el-tabs>
- </div>
- <div style="width: 50%">
- <el-card class="box-card" shadow="never">
- <template #header>
- <div class="card-header">
- <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ addedData.length }}</span>
- <el-button class="button" text bg @click="delAllGoods">全部删除</el-button>
- </div>
- </template>
- <!-- <div v-for="o in 4" :key="o" class="text item">{{ 'List item ' + o }}</div> -->
- <div class="card-body"></div>
- <!-- <template #footer>Footer content</template> -->
- </el-card>
- <div style="padding: 0 10px 0 10px; margin-top: -12px">
- <el-table
- :data="addedData"
- height="520"
- style="width: 100%"
- :header-cell-style="headerCellStyle"
- @selection-change="handleAddedGoodsChange">
- <el-table-column type="selection" width="50" />
- <el-table-column prop="asin" label="ASIN">
- <template #default="scope">
- <div style="display: flex; align-items: center">
- <div style="margin-right: 8px; line-height: normal">
- <el-image class="img-box" :src="scope.row.image_link" />
- </div>
- <div>
- <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top">
- <div class="single-line">{{ scope.row.title ? scope.row.title : '--' }}</div>
- </el-tooltip>
- <div class="data-color">
- <span style="font-weight: 500; color: rgb(30, 33, 41)">${{ scope.row.price ? scope.row.price : '--' }}</span>
- <span style="margin: 0 5px; color: #cacdd4">|</span>
- <span style="color: #6d7784">{{ scope.row.quantity }}</span>
- </div>
- <span
- >ASIN:
- <span class="data-color" style="margin-right: 8px">{{ scope.row.asin ? scope.row.asin : '--' }}</span>
- </span>
- <span
- >SKU:
- <span class="data-color">{{ scope.row.sku ? scope.row.sku : '--' }}</span>
- </span>
- </div>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="name" label="Name" width="120" align="right">
- <template #header>
- <el-button type="primary" size="normal" link @click="delSelectedGoods">删除已选中</el-button>
- </template>
- <template #default="scope">
- <el-button type="primary" size="small" @click="delSingleGoods(scope)" text>删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- </div>
- </el-form-item>
- <!-- 自动定向 -->
- <div class="column-item" v-if="ruleForm.type == 'auto'">
- <p style="color: #606266; font-weight: 450"><span style="color: #e47470">*</span> 自动定向</p>
- <el-radio-group v-model="ruleForm.autoRedirect" @change="changeBid">
- <div style="display: flex">
- <el-radio label="defaultBid">设置默认出价</el-radio>
- <el-form-item prop="defaultBidInp">
- <el-input v-model="ruleForm.defaultBidInp" label="ruleForm.defaultBidInp" style="width: 200px">
- <template #prepend>$</template>
- </el-input>
- </el-form-item>
- </div>
- <div>
- <el-radio label="targetBid">按目标组设置出价</el-radio>
- </div>
- </el-radio-group>
- </div>
- <!-- 自动定向---按目标组设置出价 -->
- <el-card v-if="showCard && ruleForm.type == 'auto'" class="box-card">
- <div>
- <div style="color: #8e9095">
- <span>目标群体</span>
- <span class="suggested-bid-item">建议竞价</span>
- <span>竞价</span>
- </div>
- <div style="display: flex">
- <el-switch v-model="ruleForm.closeMatch" size="small" active-text="紧密匹配" />
- <span class="suggested-bid-item">--</span>
- <el-form-item prop="closeMatchInp">
- <el-input :disabled="!ruleForm.closeMatch" v-model="ruleForm.closeMatchInp" placeholder="Please input" class="bid-input">
- <template #prepend>$</template>
- </el-input>
- </el-form-item>
- </div>
- <div>
- <div style="display: flex">
- <el-switch v-model="ruleForm.broadMatch" size="small" active-text="广泛匹配" />
- <span class="suggested-bid-item">--</span>
- <el-form-item prop="broadMatchInp">
- <el-input :disabled="!ruleForm.broadMatch" v-model="ruleForm.broadMatchInp" placeholder="Please input" class="bid-input">
- <template #prepend>$</template>
- </el-input>
- </el-form-item>
- </div>
- </div>
- <div>
- <div style="display: flex">
- <el-switch v-model="ruleForm.similarProducts" size="small" active-text="同类商品" />
- <span class="suggested-bid-item">--</span>
- <el-form-item prop="similarProductsInp">
- <el-input
- :disabled="!ruleForm.similarProducts"
- v-model="ruleForm.similarProductsInp"
- placeholder="Please input"
- class="bid-input">
- <template #prepend>$</template>
- </el-input>
- </el-form-item>
- </div>
- </div>
- <div>
- <div style="display: flex">
- <el-switch v-model="ruleForm.relatedProducts" size="small" active-text="关联商品" />
- <span class="suggested-bid-item">--</span>
- <el-form-item prop="relatedProductsInp">
- <el-input
- :disabled="!ruleForm.relatedProducts"
- v-model="ruleForm.relatedProductsInp"
- placeholder="Please input"
- class="bid-input">
- <template #prepend>$</template>
- </el-input>
- </el-form-item>
- </div>
- </div>
- </div>
- </el-card>
- <!-- 投放类型 -->
- <div class="column-item" v-if="ruleForm.type == 'manual'">
- <p style="color: #606266; font-weight: 450"><span style="color: #e47470">*</span> 投放类型</p>
- <el-radio-group v-model="ruleForm.targetType" @change="changeTargetType">
- <div style="display: flex">
- <el-radio label="keyWords" style="align-items: flex-start; margin-top: 5px">
- <div style="margin-top: -4px">关键词投放</div>
- <div>选择关键词以帮助您的商品出现在购物者搜索中</div>
- </el-radio>
- </div>
- <div>
- <el-radio label="Goods" style="align-items: flex-start; margin-top: 20px">
- <div style="margin-top: -4px">商品投放</div>
- <div>选择关键词以帮助您的商品出现在购物者搜索中</div>
- </el-radio>
- </div>
- </el-radio-group>
- </div>
- <!-- 关键词定向 -->
- <div style="font-size: 20px; font-weight: bold; margin-top: 30px" v-if="ruleForm.targetType == 'keyWords' && ruleForm.type == 'manual'">
- 关键词定向
- </div>
- <hr v-if="ruleForm.targetType == 'keyWords' && ruleForm.type == 'manual'" />
- <el-form-item style="width: 100%; margin-top: 20px" v-if="ruleForm.targetType == 'keyWords' && ruleForm.type == 'manual'">
- <div style="width: 100%; height: 520px; display: flex; border: 1px solid #c2c7cf; border-radius: 6px">
- <div style="width: 50%; border-right: 1px solid #c2c7cf">
- <el-tabs v-model="keyWordsTabs" class="demo-tabs" @tab-click="handleGoodsTabs">
- <div style="margin: 8px">
- <p style="margin-left: 8px; margin-bottom: -8px; font-weight: 500; color: #616266">竞价:</p>
- <div style="display: flex; align-items: center">
- <el-select v-model="bidType" class="m-2" placeholder="Select" style="width: 450px">
- <el-option v-for="item in bidTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- <el-input v-model="bidInput" placeholder="Please input">
- <template #prepend>$</template>
- </el-input>
- </div>
- <div style="display: flex">
- <span style="margin: 0 10px 0 8px; font-weight: 500; color: #616266">匹配类型: </span>
- <el-checkbox v-model="widelyType" label="广泛" />
- <el-checkbox v-model="phraseType" label="词组" />
- <el-checkbox v-model="exactType" label="精确" />
- </div>
- </div>
- <el-tab-pane label="建议" name="first">
- <el-table
- height="345"
- style="width: 100%; padding-left: 5px"
- v-loading="loading"
- :data="keyWordsTableData"
- :header-cell-style="headerCellStyle"
- :header-row-style="changeKeyWordsTableHeader">
- <el-table-column prop="asin" label="关键词"> </el-table-column>
- <el-table-column prop="name" label="匹配类型"> </el-table-column>
- <el-table-column prop="name" label="建议出价" width="120"> </el-table-column>
- </el-table>
- </el-tab-pane>
- <el-tab-pane label="输入" name="second">
- <el-input v-model="keyWordsTextarea" :rows="10" type="textarea" placeholder="未完成" style="padding-left: 5px" />
- <el-button type="primary" size="small" text bg @click="addKeyWords">添加</el-button>
- </el-tab-pane>
- </el-tabs>
- </div>
- <div style="width: 50%">
- <el-card class="box-card" shadow="never">
- <template #header>
- <div class="card-header">
- <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ addedData.length }}</span>
- <el-button class="button" text bg @click="delAllKeyWords">全部删除</el-button>
- </div>
- </template>
- <div class="card-body">
- <el-table
- :data="addedKeyWordsTableData"
- style="width: 100%"
- :header-row-style="changeKeyWordsTableHeader"
- :header-cell-style="headerCellStyle">
- <el-table-column prop="keyword" label="关键词" width="auto" />
- <el-table-column prop="bid" label="出价" />
- <el-table-column prop="suggestBid" label="建议出价" />
- <el-table-column prop="operate" label="操作" width="60" align="right" />
- </el-table>
- </div>
- </el-card>
- <div style="padding: 0 10px 0 10px; margin-top: -12px"></div>
- </div>
- </div>
- </el-form-item>
- <div
- style="font-size: 20px; font-weight: bold; margin-top: 30px"
- v-if="ruleForm.type === 'auto' || (ruleForm.targetType === 'keyWords' && ruleForm.type === 'manual')">
- 否定词
- </div>
- <hr v-if="ruleForm.type === 'auto' || (ruleForm.targetType === 'keyWords' && ruleForm.type === 'manual')" />
- <!-- 否定词表格 -->
- <el-form-item
- style="width: 100%; margin-top: 20px"
- v-if="ruleForm.type === 'auto' || (ruleForm.targetType === 'keyWords' && ruleForm.type === 'manual')">
- <div style="width: 100%; height: 520px; display: flex; border: 1px solid #c2c7cf; border-radius: 6px">
- <div style="width: 50%; border-right: 1px solid #c2c7cf">
- <div style="margin: 10px 0">
- <span style="margin-left: 25px; color: #e47470">*</span>
- <span style="color: #666666; margin-right: 10px">匹配类型: </span>
- <el-checkbox v-model="ruleForm.phraseNegation" label="词组否定" />
- <el-checkbox v-model="ruleForm.preciseNegation" label="精确否定" />
- </div>
- <el-input
- v-model="ruleForm.negativeTextarea"
- :rows="17"
- type="textarea"
- placeholder="请输入关键词,多个关键词使用逗号或者换行符分隔。(最多添加1000个关键词)"
- maxlength="11000"
- style="padding: 0 20px" />
- <div style="display: flex; flex-direction: row-reverse; margin-top: 10px">
- <el-button style="margin-right: 18px" type="primary" text bg @click="addNegative">添加</el-button>
- </div>
- </div>
- <div style="width: 50%">
- <el-card class="box-card" shadow="never">
- <template #header>
- <div class="card-header">
- <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ addedData.length }}</span>
- <el-button class="button" text bg @click="delAllNegative">全部删除</el-button>
- </div>
- </template>
- <div class="card-body">
- <el-table :data="tableData" style="width: 100%" :header-row-style="changeNegTableHeader">
- <el-table-column prop="negativeWords" label="否定词" width="auto" />
- <el-table-column prop="operate" label="操作" width="60" align="right">
- <template #default="scope">
- <el-button type="primary" size="small" @click="delSingleNegative(scope)" text>删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </el-card>
- <div style="padding: 0 10px 0 10px; margin-top: -12px"></div>
- </div>
- </div>
- </el-form-item>
- <!-- 商品定向 -->
- <div style="font-size: 20px; font-weight: bold; margin-top: 30px" v-if="ruleForm.targetType == 'Goods'">商品定向</div>
- <hr v-if="ruleForm.targetType == 'Goods'" />
- <el-form-item style="width: 100%; margin-top: 20px" v-if="ruleForm.targetType == 'Goods'">
- <div style="width: 100%; height: 520px; display: flex; border: 1px solid #c2c7cf; border-radius: 6px" v-loading="productOrientationLoading">
- <div style="width: 50%; border-right: 1px solid #c2c7cf">
- <el-tabs type="border-card" stretch class="goods-orientation-tabs" style="border-bottom-left-radius: 6px;">
- <el-tab-pane label="品类" style="border-top-left-radius: 6px;">
- <div style="display: flex; align-items: center">
- <span style="width: 40px">竞价:</span>
- <el-select v-model="categoryBiddingType" class="m-2" placeholder="Select">
- <el-option v-for="item in categoryBiddingTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- <el-input v-model="categoryBidInput" placeholder="Please input" style="width: 200px">
- <template #prepend>$</template>
- </el-input>
- </div>
- <el-tabs v-model="categoryTabs" class="category-tabs">
- <el-tab-pane label="建议" name="first">
- <el-table :data="proposalTableData" style="width: 100%" height="342">
- <el-table-column prop="proposal" label="建议" width="520">
- <template #header>
- 0建议
- </template>
- </el-table-column>
- <el-table-column prop="address" label="Address">
- <template #header>
- <el-button type="primary" size="normal" link @click="handleGoodsAdd">全部添加</el-button>
- </template>
- <template #default="scope">
- <el-button type="primary" size="small" @click="addSingleGoods(scope)" text>添加</el-button>
- </template>
- </el-table-column>
- </el-table>
- </el-tab-pane>
- <el-tab-pane label="搜索" name="second">
- <el-input placeholder="请输入关键词过滤" />
- <el-table :data="searchClassifyTableData" style="width: 100%" height="309">
- <el-table-column prop="categorie_name" label="亚马逊分类">
-
- </el-table-column>
-
- </el-table>
- </el-tab-pane>
- </el-tabs>
- </el-tab-pane>
- <el-tab-pane label="单个商品">
- <div style="display: flex; align-items: center">
- <span style="width: 40px">竞价:</span>
- <el-select v-model="categoryBiddingType" class="m-2" placeholder="Select">
- <el-option v-for="item in categoryBiddingTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- <el-input v-model="categoryBidInput" placeholder="Please input" style="width: 200px">
- <template #prepend>$</template>
- </el-input>
- <div style="margin-left: 20px">
- <span style="margin-right: 10px">类型:</span>
- <el-checkbox v-model="expand" label="拓展" />
- <el-checkbox v-model="accurate" label="精准" />
- </div>
- </div>
- <el-tabs v-model="singleGoodsTabs" class="category-tabs">
- <el-tab-pane label="建议" name="first">
- <el-table :data="proposalTableData" style="width: 100%" height="342">
- <el-table-column prop="proposal" label="商品" width="520" />
- <el-table-column prop="address" label="类型" />
- <el-table-column prop="operational" label="操作" />
- </el-table>
- </el-tab-pane>
- <el-tab-pane label="搜索" name="second">
- <el-input placeholder="按ASIN搜索"></el-input>
- <el-table :data="proposalTableData" style="width: 100%" height="342">
- <el-table-column prop="proposal" label="商品" width="520" />
- <el-table-column prop="address" label="类型" />
- <el-table-column prop="operational" label="操作" />
- </el-table>
- </el-tab-pane>
- <!-- TODO: 商品定向TextArea -->
- <el-tab-pane label="输入" name="third">待完成</el-tab-pane>
- </el-tabs>
- </el-tab-pane>
- </el-tabs>
- </div>
- <div style="width: 50%">
- <el-card class="box-card" shadow="never">
- <template #header>
- <div class="card-header">
- <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ addedData.length }}</span>
- <el-button class="button" text bg @click="delAllKeyWords">全部删除</el-button>
- </div>
- </template>
- <div class="card-body">
- <el-table
- :data="addedKeyWordsTableData"
- style="width: 100%"
- :header-row-style="changeKeyWordsTableHeader"
- :header-cell-style="headerCellStyle">
- <el-table-column prop="keyword" label="关键词" width="auto" />
- <el-table-column prop="bid" label="出价" />
- <el-table-column prop="suggestBid" label="建议出价" />
- <el-table-column prop="operate" label="操作" width="60" align="right" />
- </el-table>
- </div>
- </el-card>
- <div style="padding: 0 10px 0 10px; margin-top: -12px"></div>
- </div>
- </div>
- </el-form-item>
- <div
- style="font-size: 20px; font-weight: bold; margin-top: 30px"
- v-if="ruleForm.type == 'auto' || (ruleForm.targetType == 'Goods' && ruleForm.type === 'manual')">
- 否定商品
- </div>
- <hr v-if="ruleForm.type == 'auto' || (ruleForm.targetType == 'Goods' && ruleForm.type === 'manual')" />
- <!-- 否定商品表格 -->
- <el-form-item
- prop="matchType"
- style="width: 100%; margin-top: 20px"
- v-if="ruleForm.type == 'auto' || (ruleForm.targetType == 'Goods' && ruleForm.type === 'manual')">
- <div style="width: 100%; height: 520px; display: flex; border: 1px solid #c2c7cf; border-radius: 6px">
- <div style="width: 50%; border-right: 1px solid #c2c7cf">
- <el-tabs v-model="negativeTabs" class="demo-tabs" @tab-click="handleNegGoodsTabs">
- <el-tab-pane label="搜索" name="first">
- <div style="margin-bottom: 10px">
- <el-input placeholder="按ASIN搜索" v-model="negativeInput" @change="searchNegativeGoods" clearable />
- </div>
- <el-table
- height="415"
- style="width: 100%"
- v-loading="loading"
- :data="negativeTableData"
- :header-cell-style="headerCellStyle"
- :show-header="false">
- <el-table-column prop="asin" label="商品">
- <template #default="scope">
- <div style="display: flex; align-items: center">
- <div style="margin-right: 8px; line-height: normal">
- <el-image class="img-box" :src="scope.row.image_link" />
- </div>
- <div>
- <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top">
- <div class="single-line">{{ scope.row.title ? scope.row.title : '--' }}</div>
- </el-tooltip>
- <span>
- ASIN: <span class="data-color" style="margin-right: 8px">{{ scope.row.asin ? scope.row.asin : '--' }}</span>
- </span>
- </div>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="name" label="Name" width="120" align="right">
- <template #header> </template>
- <template #default="scope">
- <el-button type="primary" size="small" @click="addSingleNegativeGoods(scope)" text>添加</el-button>
- </template>
- </el-table-column>
- </el-table>
- </el-tab-pane>
- <el-tab-pane label="输入" name="second">
- <el-input
- v-model="ruleForm.negativeGoodsTextarea"
- :rows="17"
- type="textarea"
- placeholder="未完成"
- maxlength="11000"
- style="padding: 10px 10px" />
- <div style="display: flex; flex-direction: row-reverse; margin-top: 10px">
- <el-button style="margin-right: 10px" type="primary" text bg @click="addNegativeGoods">添加</el-button>
- </div>
- </el-tab-pane>
- </el-tabs>
- </div>
- <div style="width: 50%">
- <el-card class="box-card" shadow="never">
- <template #header>
- <div class="card-header">
- <span style="font-weight: 550; font-size: 15px; color: #1f2128">已添加: {{ addedNegetiveTableData.length }}</span>
- <el-button class="button" text bg @click="delAllNegativeGoods">全部删除</el-button>
- </div>
- </template>
- <div class="card-body"></div>
- </el-card>
- <div style="padding: 0 10px 0 10px; margin-top: -12px">
- <el-table
- :data="addedNegetiveTableData"
- height="415"
- style="width: 100%"
- :header-cell-style="headerCellStyle"
- @selection-change="handleAddedNegGoods">
- <el-table-column prop="asin" label="商品">
- <template #default="scope">
- <div style="display: flex; align-items: center">
- <div style="margin-right: 8px; line-height: normal">
- <el-image class="img-box" :src="scope.row.image_link" />
- </div>
- <div>
- <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top">
- <div class="single-line">{{ scope.row.title ? scope.row.title : '--' }}</div>
- </el-tooltip>
- <span
- >ASIN:
- <span class="data-color" style="margin-right: 8px">{{ scope.row.asin ? scope.row.asin : '--' }}</span>
- </span>
- </div>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="120" align="right">
- <template #default="scope">
- <el-button type="primary" size="small" @click="delSingleNegativeGoods(scope)" text>删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- </div>
- </el-form-item>
- <br />
- <el-form-item>
- <el-button type="negativeGoods" @click="submitForm(ruleFormRef)">Create</el-button>
- <el-button @click="resetForm(ruleFormRef)">Reset</el-button>
- </el-form-item>
- </el-form>
- </div>
- </el-card>
- </div>
- </template>
- <script lang="ts" setup>
- import { onMounted, reactive, ref, computed, watch } from 'vue'
- import { useRoute } from 'vue-router'
- import type { FormInstance, FormRules, TabsPaneContext } from 'element-plus'
- import { useShopInfo } from '/@/stores/shopInfo'
- import { usePublicData } from '/@/stores/publicData'
- import { storeToRefs } from 'pinia'
- import { useRouter } from 'vue-router'
- import { request } from '/@/utils/service'
- const negativeTableData = ref([])
- const addedNegetiveTableData = ref([])
- const router = useRouter()
- const route = useRoute()
- const shopInfo = useShopInfo()
- const { profile } = storeToRefs(shopInfo)
- const loading = ref(true)
- const fullTableData = ref([]) // 表格数据
- let addedData = ref([]) // 已添加的商品数据
- let selections = [] // 添加选中的项
- let addedSels = [] // 删除选中的项
- const currentPage = ref() // 当前页
- const pageSize = ref(20) // 每页显示条目数
- const totalItems = ref() // 数据总量
- const showCard = ref(false)
- const activeName = ref('first')
- const negativeTabs = ref('first')
- const keyWordsTabs = ref('first')
- const productOrientationTabs = ref('first')
- const categoryTabs = ref('first')
- const singleGoodsTabs = ref('first')
- const searchInp = ref('')
- const select = ref('name')
- const select2 = ref('latest')
- const buttons = [{ type: 'primary', text: '添加' }] as const
- const negativeInput = ref('')
- let widelyType = ref(true)
- let phraseType = ref(true)
- let exactType = ref(true)
- // 表单相关数据
- const formSize = ref('default')
- const labelPosition = ref('top')
- const ruleFormRef = ref<FormInstance>()
- interface RuleForm {
- name: string
- adMix: string
- count: string
- date1: string
- date2: string
- budget: string
- delivery: boolean
- type: string
- bidStrategy: string
- placeBid: string
- firstPage: string
- other: string
- adGroupName: string
- autoRedirect: string
- defaultBidInp: string
- closeMatch: boolean
- broadMatch: boolean
- similarProducts: boolean
- relatedProducts: boolean
- closeMatchInp: string
- broadMatchInp: string
- similarProductsInp: string
- relatedProductsInp: string
- phraseNegation: boolean
- preciseNegation: boolean
- negativeTextarea: string
- negativeGoodsTextarea: string
- targetType: string
- }
- const ruleForm = reactive<RuleForm>({
- name: 'Hello',
- adMix: '',
- count: '',
- date1: '',
- date2: '',
- budget: '',
- delivery: false,
- type: 'auto',
- bidStrategy: 'dynamicBid_Low',
- placeBid: '',
- firstPage: '',
- other: '',
- adGroupName: '',
- autoRedirect: 'defaultBid',
- defaultBidInp: '',
- closeMatch: true,
- broadMatch: true,
- similarProducts: true,
- relatedProducts: true,
- closeMatchInp: '666',
- broadMatchInp: '666',
- similarProductsInp: '666',
- relatedProductsInp: '666',
- phraseNegation: true,
- preciseNegation: true,
- negativeTextarea: '',
- negativeGoodsTextarea: '',
- targetType: 'keyWords',
- })
- const rules = computed(() => ({
- name: [{ required: true, message: 'Please input Activity name', trigger: 'blur' }],
- adMix: [{ required: false, message: 'Please select Activity zone', trigger: 'change' }],
- count: [{ required: true, message: 'Please select Activity count', trigger: 'change' }],
- date1: [{ required: true, type: 'date', message: 'Please pick a date', trigger: 'change' }],
- date2: [{ required: false, type: 'date', message: 'Please pick a time', trigger: 'change' }],
- budget: [
- { required: true, message: '请输入预算', trigger: 'blur' },
- { pattern: /^(?:[1-9]\d{0,5}|1000000)(?:\.\d{1,2})?$/, message: '预算必须是1到1000000之间的数字,小数点后最多两位', trigger: 'blur' },
- ],
- type: [{ required: false, trigger: 'change' }],
- bidStrategy: [{ required: true, message: 'Please select activity resource', trigger: 'change' }],
- placeBid: [{ required: false, pattern: /^[0-9]{1,3}$/, message: '必须是0~900之间的整数百分比', trigger: 'change' }],
- firstPage: [{ required: false, pattern: /^[0-9]{1,3}$/, message: '必须是0~900之间的整数百分比', trigger: 'change' }],
- other: [{ required: false, pattern: /^[0-9]{1,3}$/, message: '必须是0~900之间的整数百分比', trigger: 'change' }],
- adGroupName: [{ required: true, message: 'Please input Activity name', trigger: 'blur' }],
- autoRedirect: [{ required: true, trigger: 'change' }],
- defaultBidInp: getValidationRules('defaultBidInp'),
- relatedProductsInp: getValidationRules('relatedProductsInp'),
- similarProductsInp: getValidationRules('similarProductsInp'),
- broadMatchInp: getValidationRules('broadMatchInp'),
- closeMatchInp: getValidationRules('closeMatchInp'),
- }))
- //------------------------------------------------------------------------------方法------------------------------------------------------------------------------
- // 当单选按钮变化时更新showCard状态
- function changeBid() {
- console.log(ruleForm.autoRedirect)
- showCard.value = ruleForm.autoRedirect === 'targetBid'
- }
- // 切换投放类型
- function changeType() {}
- // 处理分页器当前页变化
- function handleCurrentChange(newPage) {
- currentPage.value = newPage
- loading.value = true
- setTableData()
- }
- // 处理分页器每页显示条目数变化
- function handleSizeChange(newSize) {
- pageSize.value = newSize
- currentPage.value = 1 // 重置到第一页
- }
- // ------------------------------------------投放类型模块------------------------------------------
- async function changeTargetType() {
- console.log(ruleForm.targetType)
- showCard.value = ruleForm.targetType === 'keyWords'
- if(ruleForm.targetType === 'Goods') {
- productOrientationLoading.value = true
- await setProductOrientationData()
- }
- }
- // ------------------------------------------商品定向模块------------------------------------------
- const categoryBiddingType = ref('customBid')
- const categoryBiddingTypeOptions = [
- {
- value: 'defaultBid',
- label: '默认竞价',
- },
- {
- value: 'customBid',
- label: '自定义竞价',
- },
- ]
- const categoryBidInput = ref('0.75')
- const expand = ref(true)
- const accurate = ref(false)
- const proposalTableData = ref([])
- const searchClassifyTableData = ref([])
- const productOrientationLoading = ref(false)
- async function setProductOrientationData() {
- try {
- const resp = await request({
- url: '/api/ad_manage/targetable/categories/',
- method: 'GET',
- params: {
- profile_id: profile.value.profile_id,
- },
- })
- searchClassifyTableData.value = resp.data
- console.log('searchClassifyTableData', searchClassifyTableData.value)
- productOrientationLoading.value = false
- } catch (error) {
- console.error("请求失败:", error)
- }
- }
- // ------------------------------------------关键词定向模块------------------------------------------
- const bidType = ref('customBid')
- const bidTypeOptions = [
- // 竞价select下拉选项
- {
- value: 'suggestBid',
- label: '建议出价',
- },
- {
- value: 'customBid',
- label: '自定义出价',
- },
- {
- value: 'defaultBid',
- label: '默认出价',
- },
- ]
- const bidInput = ref('0.75')
- const keyWordsTableData = ref([]) // 关键词定向左侧表格数据
- const addedKeyWordsTableData = ref([]) // 关键词定向右侧表格数据
- const keyWordsTextarea = ref('')
- function delAllKeyWords() {
- // 删除已经添加的关键词
- addedKeyWordsTableData.value = []
- }
- function addKeyWords() {
- // 添加关键词
- if (keyWordsTextarea.value) {
- addedKeyWordsTableData.value.push({
- keyWords: keyWordsTextarea.value,
- })
- keyWordsTextarea.value = ''
- }
- }
- // ------------------------------------------广告组商品表格模块------------------------------------------
- const goodsTextarea = ref('')
- function setTableData(asin = '', sku = '') {
- return request({
- url: '/api/sellers/listings/',
- method: 'GET',
- params: {
- page: currentPage.value,
- limit: pageSize.value,
- profile_id: profile.value.profile_id,
- asin,
- sku,
- },
- })
- .then((resp) => {
- fullTableData.value = resp.data
- totalItems.value = resp.total
- currentPage.value = resp.page
- loading.value = false
- })
- .catch((error) => {
- console.error('Error fetching data:', error)
- loading.value = false
- })
- }
- function addSingleGoods(scope) {
- console.log('scope', scope.row)
- const isAlreadyAdded = addedData.value.some((item) => item.sku === scope.row.sku)
- if (!isAlreadyAdded) {
- addedData.value.push(scope.row)
- } else {
- console.log('Item is already added.')
- }
- }
- function addGods() {
- const inputData = goodsTextarea.value
- const asins = inputData.split(/[\n,]+/)
- asins.forEach((asin) => {
- if (asin.trim()) {
- setTableData(asin.trim())
- .then((response) => {
- // 假设你的数据是在 response.data 中
- console.log(`Data for ASIN ${asin}:`, response) // 更新这里来正确地访问数据
- })
- .catch((error) => {
- console.error(`Error fetching data for ASIN ${asin}:`, error)
- })
- }
- })
- }
- function delSingleGoods(scope) {
- const index = addedData.value.findIndex((item) => item.sku === scope.row.sku)
- if (index !== -1) {
- addedData.value.splice(index, 1)
- console.log('Item removed successfully.')
- } else {
- console.log('Item not found.')
- }
- }
- function delAllGoods() {
- addedData.value = []
- // addedData.value.splice(0, addedData.value.length)
- }
- // 删除第二个table中已经选中的项
- function delSelectedGoods() {
- addedData.value = addedData.value.filter((item) => !addedSels.includes(item))
- addedSels = []
- }
- function inpChange(e) {
- const value = e
- if (select.value === 'asin') {
- loading.value = true
- setTableData(value)
- } else if (select.value === 'sku') {
- loading.value = true
- setTableData('', value)
- }
- }
- function selChange(e) {
- console.log('e', e)
- const value = e
- if (select.value === 'asin' && searchInp.value) {
- loading.value = true
- setTableData(value)
- } else if (select.value === 'sku' && searchInp.value) {
- loading.value = true
- setTableData('', value)
- }
- }
- // 点击表格选项触发事件
- function handleSelectionChange(selection) {
- selections = selection
- }
- // 获取addedTable中已选中的项
- function handleAddedGoodsChange(selection) {
- addedSels = selection
- }
- // 添加已选中的项
- function handleGoodsAdd() {
- // 过滤掉已经存在于addedData.value中的项
- const newSelections = selections.filter(
- (sel) => !addedData.value.some((added) => added.sku === sel.sku) // 使用sku作为唯一标识
- )
- // 如果有新的不重复项,加入到addedData.value中
- if (newSelections.length > 0) {
- addedData.value.push(...newSelections)
- }
- }
- // 点击Tab
- const handleGoodsTabs = (tab: TabsPaneContext, event: Event) => {
- console.log(tab, event)
- }
- // ------------------------------------------否定词模块------------------------------------------
- function addNegative() {
- // 删除 negativeTextarea 前后的空格
- const trimmedText = ruleForm.negativeTextarea.trim()
- // 使用逗号和换行符分割文本
- const items = trimmedText.split(/,|\n/)
- // 遍历分割后的每个项目
- items.forEach((item) => {
- const trimmedItem = item.trim() // 删除每个项目前后的空格
- if (trimmedItem) {
- // 如果两者都是 true,则为每个创建两个条目
- if (ruleForm.phraseNegation && ruleForm.preciseNegation) {
- negativeList.push({ negativeWords: '词组: ' + trimmedItem })
- negativeList.push({ negativeWords: '精确: ' + trimmedItem })
- } else if (ruleForm.phraseNegation) {
- negativeList.push({ negativeWords: '词组: ' + trimmedItem })
- } else if (ruleForm.preciseNegation) {
- negativeList.push({ negativeWords: '精确: ' + trimmedItem })
- }
- } else {
- console.log('有空项目,未被添加到列表中')
- }
- })
- // 清空输入框
- ruleForm.negativeTextarea = ''
- console.log(negativeList)
- }
- function delAllNegative() {
- // negativeList.splice(0, negativeList.length)
- negativeList.length = 0
- }
- function delSingleNegative(scope) {
- const index = negativeList.findIndex((item) => item.negativeWords === scope.row.negativeWords)
- if (negativeList.length) {
- negativeList.splice(index, 1)
- console.log(`已删除索引为 ${index} 的条目`)
- } else {
- console.log('无效的索引,无法删除条目')
- }
- }
- // ------------------------------------------否定商品模块------------------------------------------
- let negativeList = reactive([])
- const tableData = negativeList
- let inputAddedNegGoods = ref([])
- function setNegativeTableData(asin = '') {
- return request({
- url: '/api/sellers/listings/',
- method: 'GET',
- params: {
- page: currentPage.value,
- limit: pageSize.value,
- profile_id: profile.value.profile_id,
- asin,
- },
- })
- .then((resp) => {
- negativeTableData.value = resp.data
- inputAddedNegGoods.value = resp.data
- loading.value = false
- })
- .catch((error) => {
- console.error('Error fetching data:', error)
- loading.value = false
- })
- }
- // 输入tab的textarea
- function addNegativeGoods() {
- console.log('ruleForm.negativeGoodsTextarea', ruleForm.negativeGoodsTextarea)
- loading.value = true
- setNegativeTableData(ruleForm.negativeGoodsTextarea)
- .then(() => {
- addedNegetiveTableData.value = [...addedNegetiveTableData.value, ...inputAddedNegGoods.value]
- })
- .catch((error) => {
- console.error('Error fetching data:', error)
- })
- .finally(() => {
- loading.value = false
- })
- }
- function addSingleNegativeGoods(scope) {
- console.log('scope', scope.row)
- const isAlreadyAdded = addedNegetiveTableData.value.some((item) => item.sku === scope.row.sku)
- if (!isAlreadyAdded) {
- addedNegetiveTableData.value.push(scope.row)
- } else {
- console.log('Item is already added.')
- }
- }
- function delAllNegativeGoods() {
- addedNegetiveTableData.value = []
- }
- function delSingleNegativeGoods(scope) {
- const index = addedNegetiveTableData.value.findIndex((item) => item.sku === scope.row.sku)
- if (index !== -1) {
- addedNegetiveTableData.value.splice(index, 1)
- console.log('Item removed successfully.')
- } else {
- console.log('Item not found.')
- }
- }
- function searchNegativeGoods(e) {
- console.log(e)
- if (e === '') {
- negativeTableData.value = []
- } else {
- setNegativeTableData(e)
- }
- }
- function handleAddedNegGoods(selection) {
- addedSels = selection
- }
- function handleNegGoodsTabs(tab: TabsPaneContext, event: Event) {
- // console.log(tab, event)
- }
- // ------------------------------------------自定义校验模块------------------------------------------
- function checkBid(value, callback, bidField) {
- const bid = parseFloat(value)
- const budget = parseFloat(ruleForm.budget)
- // 检查值是否为最多两位小数的普通数字格式
- const isNormalNumberWithTwoDecimals = /^-?\d+(\.\d{1,2})?$/.test(value)
- if (!isNormalNumberWithTwoDecimals) {
- callback(new Error('请输入数字值(最多两位小数)'))
- } else if (isNaN(bid)) {
- callback(new Error('请输入有效的数字'))
- } else if (bid < 0.02 || bid > 1000) {
- callback(new Error('值必须在0.02到1000之间'))
- } else if (bid >= budget) {
- callback(new Error('出价必须小于预算'))
- } else {
- callback()
- }
- }
- // 自定义校验规则---自动定价和按目标设置出价模块
- function getValidationRules(fieldName) {
- // 默认校验规则
- const commonRules = [
- { required: true, message: '此项为必填项', trigger: 'blur' },
- { validator: (rule, value, callback) => checkBid(value, callback, fieldName), trigger: 'blur' },
- ]
- // 根据不同字段和状态返回特定的校验规则
- switch (fieldName) {
- case 'defaultBidInp':
- if (ruleForm.autoRedirect === 'defaultBid') {
- return commonRules
- }
- break
- case 'similarProductsInp':
- if (ruleForm.autoRedirect === 'targetBid' && ruleForm.similarProducts) {
- return commonRules
- } else if (ruleForm.similarProducts == false) {
- ruleFormRef.value?.clearValidate(fieldName)
- }
- break
- case 'relatedProductsInp':
- if (ruleForm.autoRedirect === 'targetBid' && ruleForm.relatedProducts) {
- return commonRules
- } else if (ruleForm.relatedProducts == false) {
- ruleFormRef.value?.clearValidate(fieldName)
- }
- break
- case 'broadMatchInp':
- if (ruleForm.autoRedirect === 'targetBid' && ruleForm.broadMatch) {
- return commonRules
- } else if (ruleForm.broadMatch == false) {
- ruleFormRef.value?.clearValidate(fieldName)
- }
- break
- case 'closeMatchInp':
- // 仅当autoRedirect为'targetBid'且closeMatch开启时校验closeMatchInp
- if (ruleForm.autoRedirect === 'targetBid' && ruleForm.closeMatch) {
- return commonRules
- } else if (ruleForm.closeMatch == false) {
- ruleFormRef.value?.clearValidate(fieldName)
- }
- break
- default:
- return []
- }
- // 如果不满足上述条件,则无需校验
- return []
- }
- // 监听表单字段变化,根据不同字段和状态返回特定的校验规则
- watch(
- [() => ruleForm.autoRedirect, () => ruleForm.closeMatch, () => ruleForm.broadMatch, () => ruleForm.similarProducts, () => ruleForm.relatedProducts],
- () => {
- // 定义需要更新校验规则的字段
- const fields = ['defaultBidInp', 'closeMatchInp', 'broadMatchInp', 'similarProductsInp', 'relatedProductsInp']
- fields.forEach((field) => {
- rules.value[field] = getValidationRules(field)
- })
- }
- )
- // 表单提交
- async function submitForm(formEl: FormInstance | undefined) {
- if (!formEl) return
- await formEl.validate((valid, fields) => {
- if (valid) {
- console.log('submit!')
- } else {
- console.log('error submit!', fields)
- }
- })
- }
- function resetForm(formEl: FormInstance | undefined) {
- if (!formEl) return
- formEl.resetFields()
- }
- // 修改表头样式
- const headerCellStyle = (args) => {
- if (args.rowIndex === 0) {
- return {
- backgroundColor: 'rgba(245, 245, 245, 0.9)',
- }
- }
- }
- function changeNegTableHeader(args) {
- if (args.rowIndex === 0) {
- return {
- color: '#505968',
- }
- }
- }
- function changeKeyWordsTableHeader(args) {
- if (args.rowIndex === 0) {
- return {
- color: '#505968',
- backgroundColor: 'rgba(245, 245, 245, 0.9)',
- }
- }
- }
- onMounted(() => {
- setTableData()
- // const myTest = route.query
- // console.log('myTest', myTest)
- })
- defineOptions({
- name: 'SpCreateCampaigns',
- })
- </script>
- <style lang="scss" scoped>
- ::v-deep(.el-form--default.el-form--label-top .el-form-item .el-form-item__label) {
- font-weight: 500;
- }
- .column-item .el-radio-group {
- display: inline-flex;
- font-size: 0;
- flex-direction: column;
- align-items: flex-start;
- }
- .radio-description {
- font-size: 12px;
- color: #666;
- margin-top: -18px;
- margin-left: 22px;
- }
- .radio-description-2 {
- font-size: 12px;
- color: #666;
- margin-top: -10px;
- }
- .column-margin-bottom label.el-radio.is-bordered {
- margin-bottom: 10px;
- padding: 35px;
- }
- ::v-deep(.column-margin-bottom label.el-radio.is-bordered span.el-radio__inner) {
- margin-top: -18px;
- margin-left: -15px;
- }
- .gap-items {
- display: flex;
- justify-content: flex-start;
- width: 100%;
- margin-bottom: 20px;
- }
- .gap-item {
- width: 200px;
- margin-left: 30px;
- color: #0b0d0d;
- }
- .demo-tabs > .el-tabs__content {
- padding: 52px;
- color: #6b778c;
- font-size: 32px;
- font-weight: 600;
- }
- /* 广告组商品Tab栏 */
- ::v-deep(.el-tabs__nav-scroll) {
- overflow: hidden;
- margin-left: 20px;
- }
- ::v-deep(.el-tabs__nav-wrap::after) {
- height: 2px !important;
- }
- ::v-deep(.el-table__inner-wrapper::before) {
- background-color: white;
- }
- // 表格内容边距
- div {
- & #pane-first,
- & #pane-second {
- margin: 10px;
- }
- }
- // 输入底部样式
- ::v-deep(.card-box .el-card__body) {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 12px;
- }
- .card-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .box-card {
- width: 100%;
- // margin: 10px 0 10px 10px;
- margin-right: 10px;
- border: none;
- }
- .single-line {
- color: rgb(30, 33, 41);
- overflow: hidden;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 1;
- white-space: pre-wrap;
- word-break: break-word;
- }
- .data-color {
- color: rgb(30, 33, 41);
- }
- .img-box {
- width: 60px;
- height: 60px;
- margin-top: 5px;
- border: 1px solid rgb(194, 199, 207);
- border-radius: 4px;
- }
- .target-group-item {
- margin-top: 15px;
- }
- .suggested-bid-item {
- margin-left: 230px;
- margin-right: 60px;
- }
- .bid-input {
- width: 200px;
- margin-left: 15px;
- }
- ::v-deep(.goods-orientation-tabs .el-tabs__nav-scroll) {
- margin-left: -20px !important;
- }
- ::v-deep(.category-tabs .el-tabs__nav) {
- margin-left: 20px;
- }
- </style>
|