creativity-add.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <div class="creativity-add">
  3. <div class="part-box">
  4. <h3 class="title">添加创意</h3>
  5. <a-form :label-col="labelCol" :wrapper-col="wrapperCol">
  6. <a-form-item label="创意方式">
  7. <a-radio-group v-model:value="creativityAdd.creative_material_mode">
  8. <a-radio value="STATIC_ASSEMBLE">程序化创意</a-radio>
  9. <a-radio value="CUSTOM">自定义创意</a-radio>
  10. </a-radio-group>
  11. </a-form-item>
  12. <a-form-item label="创意内容">
  13. <creativity-content :type="creativityAdd"></creativity-content>
  14. </a-form-item>
  15. </a-form>
  16. </div>
  17. <div class="part-box">
  18. <h3 class="title">创意分类</h3>
  19. </div>
  20. </div>
  21. </template>
  22. <script lang="ts">
  23. import { defineComponent, reactive, toRefs, ref } from "vue";
  24. import {} from "@/api";
  25. import Bus from "@/utils/bus";
  26. import { message } from "ant-design-vue";
  27. import creativityContent from "../component/creativity-content.vue";
  28. const CreativityAdd = defineComponent({
  29. components: { creativityContent },
  30. setup() {
  31. const state = reactive({
  32. creativityAdd: {
  33. creative_material_mode: "STATIC_ASSEMBLE", // 创意方式,当值为"STATIC_ASSEMBLE"表示程序化创意,其他情况不传字段
  34. creatives: ref<any[]>([]), //自定义素材信息, 最多支持10个创意。首选投放位置和创意类型决定素材规格。当为程序化创意时,该字段不填数据,值为[]
  35. title_list: [
  36. {
  37. title: "", // 标题
  38. },
  39. ], // 程序化创意时传 自定义不传
  40. },
  41. creativityClassify: {},
  42. });
  43. return { ...toRefs(state), labelCol: { span: 3 }, wrapperCol: { span: 8 } };
  44. },
  45. mounted() {
  46. Bus.$on("stepFourCheck", (val?: any) => {
  47. console.log("Step4Check");
  48. Bus.$emit("stepFourBack");
  49. });
  50. },
  51. methods: {
  52. // 提交前数据处理
  53. beforeCommit() {
  54. let data: any = { ...this.creativityAdd };
  55. // 1.创意方式,当值为"STATIC_ASSEMBLE"表示程序化创意,其他情况不传字段
  56. if (data.creative_material_mode === "CUSTOM")
  57. delete data.creative_material_mode;
  58. },
  59. // 渲染前数据处理
  60. beforeBackshow(creativityOrigin: any) {
  61. // 1.创意方式页面
  62. if (!creativityOrigin.creative_material_mode)
  63. creativityOrigin.creative_material_mode = "CUSTOM";
  64. },
  65. },
  66. beforeUnmount() {
  67. Bus.$off("stepFourCheck");
  68. },
  69. });
  70. export default CreativityAdd;
  71. </script>
  72. <style lang="scss" scoped>
  73. .creativity-add {
  74. .title {
  75. line-height: 30px;
  76. font-weight: bold;
  77. padding-left: 10px;
  78. }
  79. }
  80. </style>