timer-bid.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <script lang="ts" setup>
  2. import { ref, onMounted, Ref, watch, reactive } from 'vue';
  3. import TimerBidTable from '/@/components/TimerBidTable/index.vue';
  4. import SelectTmpl from './select-tmpl.vue';
  5. import { userFormData } from './common';
  6. import XEUtils from 'xe-utils';
  7. import dayjs from 'dayjs';
  8. interface Props {
  9. data: {
  10. campaignId: string;
  11. campaignType: string;
  12. profileId: string;
  13. ruleType: number;
  14. };
  15. RuleStatusButton?: { [key: string]: any };
  16. }
  17. const props = defineProps<Props>();
  18. const emits = defineEmits(['refresh']);
  19. const formRef = ref();
  20. const { formData, submitFormData } = userFormData(props);
  21. const checkConditions = (rule: any, value: any, callback: any) => {
  22. for (const bidList of formData.value.rule.conditions) {
  23. for (const val of bidList) {
  24. if (val > 0) {
  25. return callback();
  26. }
  27. }
  28. }
  29. callback(new Error('请先设置竞价!'));
  30. };
  31. const submit = async () => {
  32. formRef.value.validate(async (valid: any) => {
  33. if (valid) {
  34. await submitFormData();
  35. emits('refresh');
  36. } else {
  37. console.log('验证失败');
  38. }
  39. });
  40. };
  41. const cancel = async () => {
  42. emits('refresh');
  43. };
  44. const timeRange = ref('Option1');
  45. const schedule = ref('Option1');
  46. const bid = ref('');
  47. const timeRangeOptions = [
  48. {
  49. value: 'Option1',
  50. label: '24小时: 00:00-23:59',
  51. },
  52. {
  53. value: 'Option2',
  54. label: '凌晨: 00:00-06:59',
  55. },
  56. {
  57. value: 'Option3',
  58. label: '上午: 7:00-11:59',
  59. },
  60. {
  61. value: 'Option4',
  62. label: '工作时: 9:00-16:59',
  63. },
  64. {
  65. value: 'Option5',
  66. label: '下午: 12:00-16:59',
  67. },
  68. {
  69. value: 'Option6',
  70. label: '晚上: 17:00-20:59',
  71. },
  72. {
  73. value: 'Option7',
  74. label: '深夜: 21:00-23:59',
  75. },
  76. ];
  77. const scheduleOptions = [
  78. {
  79. value: 'Option1',
  80. label: '每一天',
  81. },
  82. {
  83. value: 'Option2',
  84. label: '仅在工作日',
  85. },
  86. {
  87. value: 'Option3',
  88. label: '仅在周末',
  89. },
  90. ];
  91. const isVisible = ref(true)
  92. function handleClose() {
  93. isVisible.value = false
  94. }
  95. </script>
  96. <template>
  97. <div class="mx-5">
  98. <div class="asj-h2">分时调价</div>
  99. <div class="mt-3.5">
  100. 规则执行时区: PDT
  101. <div>
  102. <el-tag v-if="isVisible" closable @close="handleClose" color="#e7edf4" class="custom-tag">
  103. <template #default>
  104. <div class="tag-content">
  105. <strong>自动化分时规则:</strong>
  106. <p>
  107. 1. 应用分时调价后,如需手动修改竞价,只能在Xmars操作。在亚马逊后台或其他第三方系统进行的调价操作,竞价将会被Xmars当前时段的自动化执行结果覆盖。
  108. </p>
  109. <p>2. 广告活动开启分时调价,规则的修改将在下一个整点生效。</p>
  110. </div>
  111. </template>
  112. </el-tag>
  113. </div>
  114. </div>
  115. <SelectTmpl :data="formData" />
  116. <el-card class="mt-3">
  117. <el-form :model="formData" label-position="top" style="margin-top: 20px" ref="formRef">
  118. <el-form-item prop="rule.conditions" :rules="[{ validator: checkConditions, trigger: 'xxx' }]">
  119. <template #label>
  120. <span class="custom-title-icon"></span>
  121. <span class="asj-h3">设置竞价</span>
  122. </template>
  123. <div class="flex flex-col">
  124. <div class="flex gap-2 my-2">
  125. <el-select v-model="timeRange">
  126. <el-option v-for="item in timeRangeOptions" :key="item.value" :label="item.label" :value="item.value" />
  127. </el-select>
  128. <el-select v-model="schedule">
  129. <el-option v-for="item in scheduleOptions" :key="item.value" :label="item.label" :value="item.value" />
  130. </el-select>
  131. <el-input v-model="bid" style="width: 150px" placeholder="1.0"></el-input>
  132. <el-button link class="active-btn" style="color: #3c58af">应用</el-button>
  133. </div>
  134. <TimerBidTable
  135. :data="formData.rule.conditions"
  136. @click="formRef.clearValidate('rule.conditions')"
  137. :disabled="formData.useTmpl" />
  138. </div>
  139. </el-form-item>
  140. </el-form>
  141. </el-card>
  142. <div class="auto-page-foot">
  143. <el-button style="width: 200px" @click="cancel">取消</el-button>
  144. <el-button style="width: 200px" type="primary" @click="submit">提交</el-button>
  145. </div>
  146. </div>
  147. </template>
  148. <style scoped>
  149. .active-btn:hover {
  150. color: #7a9ce4 !important; /* 如果需要改变字体颜色 */
  151. transition: all 0.3s; /* 添加过渡效果 */
  152. }
  153. .custom-title-icon {
  154. padding-right: 10px;
  155. }
  156. .custom-title-icon:before {
  157. content: '';
  158. width: 4px;
  159. height: 15px;
  160. background: #3569d6;
  161. position: absolute;
  162. transform: translateY(25%);
  163. }
  164. .custom-tag {
  165. height: auto;
  166. padding: 8px 8px 8px 16px;
  167. color: #505968;
  168. border-color: #abbbd8;
  169. align-items: flex-start !important;
  170. white-space: normal;
  171. line-height: 1.5;
  172. }
  173. .tag-content {
  174. display: block;
  175. max-width: 100%;
  176. }
  177. </style>