target-rule.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <script lang="ts" setup>
  2. /**
  3. * @Name: target-rule
  4. * @Description: 自动化-定向规则
  5. * @Author: Cheney
  6. */
  7. import { ref } from 'vue';
  8. import TargetSelect from '../target-select.vue';
  9. import SelectTmpl from './select-tmpl.vue';
  10. import FreqSetting from '../freq-setting.vue';
  11. import { userFormData } from './common';
  12. import TargetRuleSetting from '../target-rule-setting.vue';
  13. interface Props {
  14. data: {
  15. campaignId: string;
  16. campaignType: string;
  17. profileId: string;
  18. ruleType: number;
  19. };
  20. RuleStatusButton?: { [key: string]: any };
  21. }
  22. const props = defineProps<Props>();
  23. const emits = defineEmits(['refresh']);
  24. const formRef = ref();
  25. const ruleSettingRef = ref();
  26. const { formData, submitFormData } = userFormData(props);
  27. const submitForm = async () => {
  28. const valid2 = await ruleSettingRef.value.validateForm();
  29. formRef.value.validate(async (valid: boolean) => {
  30. if (valid && valid2) {
  31. await submitFormData();
  32. emits('refresh');
  33. } else {
  34. console.log('验证失败:', [valid, valid2]);
  35. }
  36. });
  37. };
  38. function cancel() {
  39. emits('refresh');
  40. }
  41. </script>
  42. <template>
  43. <div class="mx-5">
  44. <div class="asj-h2">定向规则</div>
  45. <SelectTmpl :data="formData" />
  46. <el-card class="mt-3">
  47. <el-form class="custom-card" :model="formData" label-position="top" ref="formRef">
  48. <el-form-item>
  49. <!--<template #label>
  50. <span class="custom-title-icon"></span>
  51. <span class="asj-h3">生效对象</span>
  52. </template>-->
  53. <FreqSetting :rule="formData.rule" :disabled="formData.useTmpl" />
  54. <el-divider />
  55. <TargetSelect
  56. mode="auto"
  57. :data="formData.rule"
  58. :useTmpl="formData.useTmpl"
  59. :campaign-id="data.campaignId"></TargetSelect>
  60. </el-form-item>
  61. </el-form>
  62. </el-card>
  63. <el-card class="mt-3">
  64. <TargetRuleSetting :rule="formData.rule" ref="ruleSettingRef" :disabled="formData.useTmpl" />
  65. </el-card>
  66. <div class="auto-page-foot">
  67. <el-button style="width: 200px" @click="cancel">取消</el-button>
  68. <el-button style="width: 200px" type="primary" @click="submitForm">提交</el-button>
  69. </div>
  70. </div>
  71. </template>
  72. <style lang="scss" scoped>
  73. :deep(.custom-card .el-form-item__content) {
  74. display: block;
  75. }
  76. </style>