|  | @@ -12,7 +12,9 @@ import SwitchCampaign from '/@/views/components/auto/auto-campaigns/switch-campa
 | 
											
												
													
														|  |  import TargetRule from '/@/views/components/auto/auto-campaigns/target-rule.vue';
 |  |  import TargetRule from '/@/views/components/auto/auto-campaigns/target-rule.vue';
 | 
											
												
													
														|  |  import SearchTermRule from '/@/views/components/auto/auto-campaigns/search-term.vue';
 |  |  import SearchTermRule from '/@/views/components/auto/auto-campaigns/search-term.vue';
 | 
											
												
													
														|  |  import NegKeywordRule from '/@/views/components/auto/auto-campaigns/neg-keyword.vue';
 |  |  import NegKeywordRule from '/@/views/components/auto/auto-campaigns/neg-keyword.vue';
 | 
											
												
													
														|  | -import * as api from './api';
 |  | 
 | 
											
												
													
														|  | 
 |  | +import { postCampaignStatus } from './api';
 | 
											
												
													
														|  | 
 |  | +import { ElMessage } from 'element-plus';
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  interface Props {
 |  |  interface Props {
 | 
											
												
													
														|  |    campaignId: string;
 |  |    campaignId: string;
 | 
											
										
											
												
													
														|  | @@ -23,34 +25,14 @@ const props = defineProps<Props>();
 | 
											
												
													
														|  |  const campaignType = 'sp';
 |  |  const campaignType = 'sp';
 | 
											
												
													
														|  |  const activeTab = ref(1);
 |  |  const activeTab = ref(1);
 | 
											
												
													
														|  |  const RuleStatusButton = ref({
 |  |  const RuleStatusButton = ref({
 | 
											
												
													
														|  | -  '1': '-',
 |  | 
 | 
											
												
													
														|  | -  '2': '-',
 |  | 
 | 
											
												
													
														|  | -  '3': '-',
 |  | 
 | 
											
												
													
														|  | -  '4': '-',
 |  | 
 | 
											
												
													
														|  | -  '5': '-',
 |  | 
 | 
											
												
													
														|  | -  '6': '-',
 |  | 
 | 
											
												
													
														|  | -});
 |  | 
 | 
											
												
													
														|  | -// const height = ref(800)
 |  | 
 | 
											
												
													
														|  | -// const campaignRuleStatus = ref({
 |  | 
 | 
											
												
													
														|  | -//   campaignId: props.campaignId,
 |  | 
 | 
											
												
													
														|  | -//   campaignType: campaignType,
 |  | 
 | 
											
												
													
														|  | -//   profileId: props.profileId,
 |  | 
 | 
											
												
													
														|  | -//   ruleType: activeTab.value,
 |  | 
 | 
											
												
													
														|  | -//   templateName: '',
 |  | 
 | 
											
												
													
														|  | -//   useTmpl: false,
 |  | 
 | 
											
												
													
														|  | -//   template: null,
 |  | 
 | 
											
												
													
														|  | -//   rule: {
 |  | 
 | 
											
												
													
														|  | -//     type: activeTab.value,
 |  | 
 | 
											
												
													
														|  | -//     campaignType: campaignType,
 |  | 
 | 
											
												
													
														|  | -//     campaignAd: [],
 |  | 
 | 
											
												
													
														|  | -//     action: {},
 |  | 
 | 
											
												
													
														|  | -//     activeModel: '',
 |  | 
 | 
											
												
													
														|  | -//     setTime: '',
 |  | 
 | 
											
												
													
														|  | -//     weekdays: [],
 |  | 
 | 
											
												
													
														|  | -//     conditions: [],
 |  | 
 | 
											
												
													
														|  | -//   },
 |  | 
 | 
											
												
													
														|  | -//   RuleStatusButton: RuleStatusButton,
 |  | 
 | 
											
												
													
														|  | -// })
 |  | 
 | 
											
												
													
														|  | 
 |  | +  '1': 0,
 | 
											
												
													
														|  | 
 |  | +  '2': 0,
 | 
											
												
													
														|  | 
 |  | +  '3': 0,
 | 
											
												
													
														|  | 
 |  | +  '4': 0,
 | 
											
												
													
														|  | 
 |  | +  '5': 0,
 | 
											
												
													
														|  | 
 |  | +  '6': 0,
 | 
											
												
													
														|  | 
 |  | +})
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  const baseData = ref({
 |  |  const baseData = ref({
 | 
											
												
													
														|  |    campaignId: props.campaignId,
 |  |    campaignId: props.campaignId,
 | 
											
												
													
														|  |    campaignType: campaignType,
 |  |    campaignType: campaignType,
 | 
											
										
											
												
													
														|  | @@ -58,22 +40,48 @@ const baseData = ref({
 | 
											
												
													
														|  |    ruleType: activeTab,
 |  |    ruleType: activeTab,
 | 
											
												
													
														|  |  });
 |  |  });
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -onMounted(async () => {
 |  | 
 | 
											
												
													
														|  | -  await initData();
 |  | 
 | 
											
												
													
														|  | -});
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |  async function initData() {
 |  |  async function initData() {
 | 
											
												
													
														|  | -  const resp = await api.getCampaignRuleInfo(baseData.value);
 |  | 
 | 
											
												
													
														|  | -  const info = resp.data[0];
 |  | 
 | 
											
												
													
														|  | -  if (info) {
 |  | 
 | 
											
												
													
														|  | -    for (const i of ['1', '2', '3', '4', '5', '6']) {
 |  | 
 | 
											
												
													
														|  | -      RuleStatusButton.value[i] = info.RuleStatusButton[i];
 |  | 
 | 
											
												
													
														|  | -    }
 |  | 
 | 
											
												
													
														|  | -  }
 |  | 
 | 
											
												
													
														|  | 
 |  | +  // const resp = await api.getCampaignRuleInfo(baseData.value);
 | 
											
												
													
														|  | 
 |  | +  // const info = resp.data[0];
 | 
											
												
													
														|  | 
 |  | +  // if (info) {
 | 
											
												
													
														|  | 
 |  | +  //   for (const i of ['1', '2', '3', '4', '5', '6']) {
 | 
											
												
													
														|  | 
 |  | +  //     RuleStatusButton.value[i] = info.RuleStatusButton[i];
 | 
											
												
													
														|  | 
 |  | +  //   }
 | 
											
												
													
														|  | 
 |  | +  //   console.log('Initialized RuleStatusButton', RuleStatusButton.value); // 添加调试信息
 | 
											
												
													
														|  | 
 |  | +  // }
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  async function changeTab() {
 |  |  async function changeTab() {
 | 
											
												
													
														|  | -  // await initData()
 |  | 
 | 
											
												
													
														|  | 
 |  | +  // await initData();
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +async function changeStatus(newStatus: number, tabIndex: string) {
 | 
											
												
													
														|  | 
 |  | +  const body = {
 | 
											
												
													
														|  | 
 |  | +    ...baseData.value,
 | 
											
												
													
														|  | 
 |  | +    ruleType: Number(tabIndex),
 | 
											
												
													
														|  | 
 |  | +    status: newStatus
 | 
											
												
													
														|  | 
 |  | +  };
 | 
											
												
													
														|  | 
 |  | +  try {
 | 
											
												
													
														|  | 
 |  | +    const response = await postCampaignStatus(body);
 | 
											
												
													
														|  | 
 |  | +    if (response.code === 2000) {
 | 
											
												
													
														|  | 
 |  | +      ElMessage.success('更新状态成功');
 | 
											
												
													
														|  | 
 |  | +      const resp = await getCampaignRuleInfo(baseData.value);
 | 
											
												
													
														|  | 
 |  | +      RuleStatusButton.value = resp.data[0].RuleStatusButton;
 | 
											
												
													
														|  | 
 |  | +    } else if (response.code == 5000) {
 | 
											
												
													
														|  | 
 |  | +      ElMessage.warning(`${ response.data.description }`);
 | 
											
												
													
														|  | 
 |  | +    } else {
 | 
											
												
													
														|  | 
 |  | +      ElMessage.error('状态更新失败');
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +  } catch (error) {
 | 
											
												
													
														|  | 
 |  | +    console.log('error:', error);
 | 
											
												
													
														|  | 
 |  | +  }
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +function updateRuleStatusButton(newValue) {
 | 
											
												
													
														|  | 
 |  | +  if (newValue !== undefined) {
 | 
											
												
													
														|  | 
 |  | +    RuleStatusButton.value = { ...RuleStatusButton.value, ...newValue }
 | 
											
												
													
														|  | 
 |  | +  } else {
 | 
											
												
													
														|  | 
 |  | +    console.error('接收到的 newValue 是 undefined')
 | 
											
												
													
														|  | 
 |  | +  }
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  async function refresh(tab: number) {
 |  |  async function refresh(tab: number) {
 | 
											
										
											
												
													
														|  | @@ -82,64 +90,84 @@ async function refresh(tab: number) {
 | 
											
												
													
														|  |      activeTab.value = tab;
 |  |      activeTab.value = tab;
 | 
											
												
													
														|  |    });
 |  |    });
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +onMounted(async () => {
 | 
											
												
													
														|  | 
 |  | +  // await initData();
 | 
											
												
													
														|  | 
 |  | +});
 | 
											
												
													
														|  |  </script>
 |  |  </script>
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  <template>
 |  |  <template>
 | 
											
												
													
														|  | -  <el-tabs tab-position="left" v-model="activeTab" @tab-change="changeTab">
 |  | 
 | 
											
												
													
														|  | -    <el-tab-pane label="分时调价" :name="1">
 |  | 
 | 
											
												
													
														|  | 
 |  | +  <el-tabs v-model="activeTab" tab-position="left" @tab-change="changeTab">
 | 
											
												
													
														|  | 
 |  | +    <el-tab-pane :name="1" label="分时调价">
 | 
											
												
													
														|  |        <template #label>
 |  |        <template #label>
 | 
											
												
													
														|  |          <div class="tab-label">
 |  |          <div class="tab-label">
 | 
											
												
													
														|  | -          <el-switch size="small" v-model="RuleStatusButton['1']" :disabled="RuleStatusButton['1'] === '-'"></el-switch>
 |  | 
 | 
											
												
													
														|  | 
 |  | +          <el-switch v-model="RuleStatusButton['1']" :active-value="1" :disabled="RuleStatusButton['1'] === '-'"
 | 
											
												
													
														|  | 
 |  | +                     :inactive-value="0" size="small" @change="(val) => changeStatus(val, '1')" @click.stop="">
 | 
											
												
													
														|  | 
 |  | +          </el-switch>
 | 
											
												
													
														|  |            <span>分时调价</span>
 |  |            <span>分时调价</span>
 | 
											
												
													
														|  |          </div>
 |  |          </div>
 | 
											
												
													
														|  |        </template>
 |  |        </template>
 | 
											
												
													
														|  | -      <TimerBid :data="baseData" :RuleStatusButton="RuleStatusButton" @refresh="refresh(1)" v-if="activeTab === 1" />
 |  | 
 | 
											
												
													
														|  | 
 |  | +      <TimerBid v-if="activeTab === 1" :RuleStatusButton="RuleStatusButton" :data="baseData" @refresh="refresh(1)"  @updateRuleStatusButton="updateRuleStatusButton"/>
 | 
											
												
													
														|  |      </el-tab-pane>
 |  |      </el-tab-pane>
 | 
											
												
													
														|  | -    <el-tab-pane label="分时预算" :name="2">
 |  | 
 | 
											
												
													
														|  | 
 |  | +    <el-tab-pane :name="2" label="分时预算">
 | 
											
												
													
														|  |        <template #label>
 |  |        <template #label>
 | 
											
												
													
														|  |          <div class="tab-label">
 |  |          <div class="tab-label">
 | 
											
												
													
														|  | -          <el-switch size="small" v-model="RuleStatusButton['2']" :disabled="RuleStatusButton['2'] === '-'"></el-switch>
 |  | 
 | 
											
												
													
														|  | 
 |  | +          <el-switch v-model="RuleStatusButton['2']" :active-value="1" :disabled="RuleStatusButton['2'] === '-'"
 | 
											
												
													
														|  | 
 |  | +                     :inactive-value="0" size="small" @change="(val) => changeStatus(val, '2')" @click.stop="">
 | 
											
												
													
														|  | 
 |  | +          </el-switch>
 | 
											
												
													
														|  |            <span>分时预算</span>
 |  |            <span>分时预算</span>
 | 
											
												
													
														|  |          </div>
 |  |          </div>
 | 
											
												
													
														|  |        </template>
 |  |        </template>
 | 
											
												
													
														|  | -      <TimerBudget :data="baseData" :RuleStatusButton="RuleStatusButton" @refresh="refresh(2)" v-if="activeTab === 2" />
 |  | 
 | 
											
												
													
														|  | 
 |  | +      <TimerBudget v-if="activeTab === 2" :RuleStatusButton="RuleStatusButton" :data="baseData" @refresh="refresh(2)" />
 | 
											
												
													
														|  |      </el-tab-pane>
 |  |      </el-tab-pane>
 | 
											
												
													
														|  | -    <el-tab-pane label="广告活动" :name="3">
 |  | 
 | 
											
												
													
														|  | 
 |  | +    <el-tab-pane :name="3" label="广告活动">
 | 
											
												
													
														|  |        <template #label>
 |  |        <template #label>
 | 
											
												
													
														|  |          <div class="tab-label">
 |  |          <div class="tab-label">
 | 
											
												
													
														|  | -          <el-switch size="small" v-model="RuleStatusButton['3']" :disabled="RuleStatusButton['3'] === '-'"></el-switch>
 |  | 
 | 
											
												
													
														|  | 
 |  | +          <el-switch v-model="RuleStatusButton['3']" :active-value="1" :disabled="RuleStatusButton['3'] === '-'"
 | 
											
												
													
														|  | 
 |  | +                     :inactive-value="0" size="small" @change="(val) => changeStatus(val, '3')" @click.stop="">
 | 
											
												
													
														|  | 
 |  | +          </el-switch>
 | 
											
												
													
														|  |            <span>广告活动</span>
 |  |            <span>广告活动</span>
 | 
											
												
													
														|  |          </div>
 |  |          </div>
 | 
											
												
													
														|  |        </template>
 |  |        </template>
 | 
											
												
													
														|  | -      <SwitchCampaign :data="baseData" :RuleStatusButton="RuleStatusButton" @refresh="refresh(3)" v-if="activeTab === 3" />
 |  | 
 | 
											
												
													
														|  | 
 |  | +      <SwitchCampaign v-if="activeTab === 3" :RuleStatusButton="RuleStatusButton" :data="baseData"
 | 
											
												
													
														|  | 
 |  | +                      @refresh="refresh(3)" />
 | 
											
												
													
														|  |      </el-tab-pane>
 |  |      </el-tab-pane>
 | 
											
												
													
														|  | -    <el-tab-pane label="定向规则" :name="4">
 |  | 
 | 
											
												
													
														|  | 
 |  | +    <el-tab-pane :name="4" label="定向规则">
 | 
											
												
													
														|  |        <template #label>
 |  |        <template #label>
 | 
											
												
													
														|  |          <div class="tab-label">
 |  |          <div class="tab-label">
 | 
											
												
													
														|  | -          <el-switch size="small" v-model="RuleStatusButton['4']" :disabled="RuleStatusButton['4'] === '-'"></el-switch>
 |  | 
 | 
											
												
													
														|  | 
 |  | +          <el-switch v-model="RuleStatusButton['4']" :active-value="1" :disabled="RuleStatusButton['4'] === '-'"
 | 
											
												
													
														|  | 
 |  | +                     :inactive-value="0" size="small" @change="(val) => changeStatus(val, '4')" @click.stop="">
 | 
											
												
													
														|  | 
 |  | +          </el-switch>
 | 
											
												
													
														|  |            <span>定向规则</span>
 |  |            <span>定向规则</span>
 | 
											
												
													
														|  |          </div>
 |  |          </div>
 | 
											
												
													
														|  |        </template>
 |  |        </template>
 | 
											
												
													
														|  | -      <TargetRule :data="baseData" :RuleStatusButton="RuleStatusButton" @refresh="refresh(4)" v-if="activeTab === 4"></TargetRule>
 |  | 
 | 
											
												
													
														|  | 
 |  | +      <TargetRule v-if="activeTab === 4" :RuleStatusButton="RuleStatusButton" :data="baseData"
 | 
											
												
													
														|  | 
 |  | +                  @refresh="refresh(4)"></TargetRule>
 | 
											
												
													
														|  |      </el-tab-pane>
 |  |      </el-tab-pane>
 | 
											
												
													
														|  | -    <el-tab-pane label="添加搜索词" :name="5">
 |  | 
 | 
											
												
													
														|  | 
 |  | +    <el-tab-pane :name="5" label="添加搜索词">
 | 
											
												
													
														|  |        <template #label>
 |  |        <template #label>
 | 
											
												
													
														|  |          <div class="tab-label">
 |  |          <div class="tab-label">
 | 
											
												
													
														|  | -          <el-switch size="small" v-model="RuleStatusButton['5']" :disabled="RuleStatusButton['5'] === '-'"></el-switch>
 |  | 
 | 
											
												
													
														|  | 
 |  | +          <el-switch v-model="RuleStatusButton['5']" :active-value="1" :disabled="RuleStatusButton['5'] === '-'"
 | 
											
												
													
														|  | 
 |  | +                     :inactive-value="0" size="small" @change="(val) => changeStatus(val, '5')" @click.stop="">
 | 
											
												
													
														|  | 
 |  | +          </el-switch>
 | 
											
												
													
														|  |            <span>添加搜索词</span>
 |  |            <span>添加搜索词</span>
 | 
											
												
													
														|  |          </div>
 |  |          </div>
 | 
											
												
													
														|  |        </template>
 |  |        </template>
 | 
											
												
													
														|  | -      <SearchTermRule :data="baseData" :RuleStatusButton="RuleStatusButton" @refresh="refresh(5)" v-if="activeTab === 5">
 |  | 
 | 
											
												
													
														|  | 
 |  | +      <SearchTermRule v-if="activeTab === 5" :RuleStatusButton="RuleStatusButton" :data="baseData"
 | 
											
												
													
														|  | 
 |  | +                      @refresh="refresh(5)">
 | 
											
												
													
														|  |        </SearchTermRule>
 |  |        </SearchTermRule>
 | 
											
												
													
														|  |      </el-tab-pane>
 |  |      </el-tab-pane>
 | 
											
												
													
														|  | -    <el-tab-pane label="添加否定词" :name="6">
 |  | 
 | 
											
												
													
														|  | 
 |  | +    <el-tab-pane :name="6" label="添加否定词">
 | 
											
												
													
														|  |        <template #label>
 |  |        <template #label>
 | 
											
												
													
														|  |          <div class="tab-label">
 |  |          <div class="tab-label">
 | 
											
												
													
														|  | -          <el-switch size="small" v-model="RuleStatusButton['6']" :disabled="RuleStatusButton['6'] === '-'"></el-switch>
 |  | 
 | 
											
												
													
														|  | 
 |  | +          <el-switch v-model="RuleStatusButton['6']" :active-value="1" :disabled="RuleStatusButton['6'] === '-'"
 | 
											
												
													
														|  | 
 |  | +                     :inactive-value="0" size="small" @change="(val) => changeStatus(val, '6')" @click.stop="">
 | 
											
												
													
														|  | 
 |  | +          </el-switch>
 | 
											
												
													
														|  |            <span>添加否定词</span>
 |  |            <span>添加否定词</span>
 | 
											
												
													
														|  |          </div>
 |  |          </div>
 | 
											
												
													
														|  |        </template>
 |  |        </template>
 | 
											
												
													
														|  | -      <NegKeywordRule :data="baseData" :RuleStatusButton="RuleStatusButton" @refresh="refresh(6)" v-if="activeTab === 6">
 |  | 
 | 
											
												
													
														|  | 
 |  | +      <NegKeywordRule v-if="activeTab === 6" :RuleStatusButton="RuleStatusButton" :data="baseData"
 | 
											
												
													
														|  | 
 |  | +                      @refresh="refresh(6)">
 | 
											
												
													
														|  |        </NegKeywordRule>
 |  |        </NegKeywordRule>
 | 
											
												
													
														|  |      </el-tab-pane>
 |  |      </el-tab-pane>
 | 
											
												
													
														|  |    </el-tabs>
 |  |    </el-tabs>
 | 
											
										
											
												
													
														|  | @@ -152,4 +180,4 @@ async function refresh(tab: number) {
 | 
											
												
													
														|  |    align-items: center;
 |  |    align-items: center;
 | 
											
												
													
														|  |    width: 120px;
 |  |    width: 120px;
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  | -</style>
 |  | 
 | 
											
												
													
														|  | 
 |  | +</style>
 |