search-term-add.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <script lang="ts" setup>
  2. /**
  3. * @Name: search-term-add.vue
  4. * @Description: 自动化-添加搜索词
  5. * @Author: Cheney
  6. */
  7. import { ref } from 'vue';
  8. import { Delete, Plus } from '@element-plus/icons-vue';
  9. import CampaignSelect from '/@/views/components/campaign-select/index.vue';
  10. import AdGroupSelect from '/@/views/components/ad-group-select/index.vue';
  11. interface Props {
  12. rule: AutoRule;
  13. disabled?: boolean;
  14. }
  15. const props = defineProps<Props>();
  16. const formRef = ref();
  17. function addCampaignAd() {
  18. props.rule.campaignAd.push({
  19. campaignType: 'sp',
  20. campaignId: '',
  21. adGroupId: '',
  22. });
  23. }
  24. if (props.rule.campaignAd.length === 0) {
  25. addCampaignAd();
  26. }
  27. if (!props.rule.activeModel) {
  28. props.rule.activeModel = 'all';
  29. }
  30. function delCampaignAd(index: number) {
  31. props.rule.campaignAd.splice(index, 1);
  32. }
  33. async function changeCampaignType(info: any) {
  34. info.campaignId = '';
  35. info.adGroupId = '';
  36. }
  37. async function validate() {
  38. let ret = true;
  39. if (!formRef.value) return ret;
  40. await formRef.value.validate(async (valid: boolean) => {
  41. ret = valid;
  42. });
  43. return ret;
  44. }
  45. defineExpose({ validate });
  46. </script>
  47. <template>
  48. <div>
  49. <div class="asj-h3">
  50. <span class="custom-title-icon"></span>
  51. 添加到
  52. </div>
  53. <el-radio-group
  54. style="display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 20px"
  55. v-model="rule.activeModel">
  56. <el-radio label="all">当前广告活动(所有广告组)</el-radio>
  57. <el-radio label="current">当前广告活动(当前广告组)</el-radio>
  58. <el-radio label="specified">指定广告活动的广告组</el-radio>
  59. <div style="margin-left: 23px" v-if="rule.activeModel === 'specified'">
  60. <el-form :inline="true" :model="rule" :disabled="disabled" ref="formRef">
  61. <el-form-item
  62. v-for="(info, index) in rule.campaignAd"
  63. style="margin: 10px auto"
  64. :prop="`campaignAd[${index}].adGroupId`"
  65. :rules="{ required: true, message: '广告组必填' }">
  66. <div style="display: flex; align-items: center; gap: 10px">
  67. <el-select v-model="info.campaignType" style="width: 100px" @change="changeCampaignType(info)">
  68. <el-option label="SP" value="sp"></el-option>
  69. <el-option label="SB" value="sb"></el-option>
  70. <!-- <el-option label="SD" value="sd"></el-option> -->
  71. </el-select>
  72. <CampaignSelect
  73. v-model="info.campaignId"
  74. :query="{ profileId: '3006125408623189', campaignType: info.campaignType }"
  75. @change="info.adGroupId = ''"
  76. width="450px"></CampaignSelect>
  77. <AdGroupSelect
  78. v-model="info.adGroupId"
  79. width="450px"
  80. :query="{ profileId: '3006125408623189', campaignType: info.campaignType, campaignId: info.campaignId }">
  81. </AdGroupSelect>
  82. <el-button
  83. link
  84. :icon="Delete"
  85. type="danger"
  86. @click="delCampaignAd(index)"
  87. v-show="rule.campaignAd.length > 1"></el-button>
  88. </div>
  89. </el-form-item>
  90. </el-form>
  91. <el-button link :icon="Plus" type="primary" @click="addCampaignAd">添加</el-button>
  92. </div>
  93. </el-radio-group>
  94. </div>
  95. </template>
  96. <style scoped>
  97. .custom-title-icon {
  98. padding-right: 10px;
  99. }
  100. .custom-title-icon:before {
  101. content: '';
  102. width: 4px;
  103. height: 15px;
  104. background: #3569d6;
  105. position: absolute;
  106. transform: translateY(25%);
  107. }
  108. </style>