|
|
@@ -7,12 +7,27 @@
|
|
|
:mask-closable="false"
|
|
|
:ok-loading="loading"
|
|
|
@cancel="close"
|
|
|
- @before-ok="submit">
|
|
|
+ @before-ok="submit"
|
|
|
+ >
|
|
|
<!-- 表单信息 start -->
|
|
|
- <a-form ref="formRef" :model="formData" :rules="rules" :auto-label-width="true">
|
|
|
- <a-form-item label="推送游戏" field="game_id">
|
|
|
- <a-select v-model="formData.game_id" placeholder="请选择推送游戏" @change="handleGameChange">
|
|
|
- <a-option v-for="item in gamePackageOptions" :key="item.game_id" :value="item.game_id" :label="item.name" />
|
|
|
+ <a-form
|
|
|
+ ref="formRef"
|
|
|
+ :model="formData"
|
|
|
+ :rules="rules"
|
|
|
+ :auto-label-width="true"
|
|
|
+ >
|
|
|
+ <a-form-item label="媒体母包" field="game_id">
|
|
|
+ <a-select
|
|
|
+ v-model="formData.game_id"
|
|
|
+ placeholder="请选择媒体母包"
|
|
|
+ @change="handleGameChange"
|
|
|
+ >
|
|
|
+ <a-option
|
|
|
+ v-for="item in gamePackageOptions"
|
|
|
+ :key="item.game_id"
|
|
|
+ :value="item.game_id"
|
|
|
+ :label="item.name"
|
|
|
+ />
|
|
|
</a-select>
|
|
|
</a-form-item>
|
|
|
|
|
|
@@ -30,7 +45,8 @@
|
|
|
v-for="item in ttAccountOptions"
|
|
|
:key="item.advertiser_id"
|
|
|
:value="item.advertiser_id"
|
|
|
- :label="item.advertiser_name" />
|
|
|
+ :label="item.advertiser_name"
|
|
|
+ />
|
|
|
</a-select>
|
|
|
</a-form-item>
|
|
|
</a-form>
|
|
|
@@ -39,110 +55,112 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, reactive, computed } from 'vue'
|
|
|
-import { Message, Modal } from '@arco-design/web-vue'
|
|
|
-import tool from '@/utils/tool'
|
|
|
-import api from '@/api/system/post'
|
|
|
-import { request } from '@/utils/request'
|
|
|
-import commonApi from '../../api/common'
|
|
|
-import agentSiteApi from '../../api/advert/agentSite'
|
|
|
+import { ref, reactive, computed } from "vue";
|
|
|
+import { Message, Modal } from "@arco-design/web-vue";
|
|
|
+import tool from "@/utils/tool";
|
|
|
+import api from "@/api/system/post";
|
|
|
+import { request } from "@/utils/request";
|
|
|
+import commonApi from "../../api/common";
|
|
|
+import agentSiteApi from "../../api/advert/agentSite";
|
|
|
|
|
|
-const emit = defineEmits(['success'])
|
|
|
+const emit = defineEmits(["success"]);
|
|
|
|
|
|
// 引用定义
|
|
|
-const formRef = ref()
|
|
|
-const mode = ref('')
|
|
|
-const visible = ref(false)
|
|
|
-const loading = ref(false)
|
|
|
-const siteIds = ref()
|
|
|
-const ttAccountOptions = ref([])
|
|
|
-const gamePackageOptions = ref([])
|
|
|
+const formRef = ref();
|
|
|
+const mode = ref("");
|
|
|
+const visible = ref(false);
|
|
|
+const loading = ref(false);
|
|
|
+const siteIds = ref();
|
|
|
+const ttAccountOptions = ref([]);
|
|
|
+const gamePackageOptions = ref([]);
|
|
|
|
|
|
let title = computed(() => {
|
|
|
- return '推送头条分包和转化'
|
|
|
-})
|
|
|
+ return "推送头条分包和转化";
|
|
|
+});
|
|
|
|
|
|
// 表单初始值
|
|
|
const initialFormData = {
|
|
|
- id: '',
|
|
|
- game_id: '',
|
|
|
+ id: "",
|
|
|
+ game_id: "",
|
|
|
fb: true,
|
|
|
zh: true,
|
|
|
- remark: '',
|
|
|
-}
|
|
|
+ remark: "",
|
|
|
+};
|
|
|
|
|
|
// 表单信息
|
|
|
-const formData = reactive({ ...initialFormData })
|
|
|
+const formData = reactive({ ...initialFormData });
|
|
|
|
|
|
// 设置批量数据
|
|
|
const setSiteIds = async (value) => {
|
|
|
- siteIds.value = value
|
|
|
-}
|
|
|
+ siteIds.value = value;
|
|
|
+};
|
|
|
|
|
|
// 验证规则
|
|
|
const rules = {
|
|
|
- game_id: [{ required: true, message: '推送游戏不能为空' }],
|
|
|
- advertiser_id: [{ required: true, message: '头条账号不能为空' }],
|
|
|
-}
|
|
|
+ game_id: [{ required: true, message: "媒体母包不能为空" }],
|
|
|
+ advertiser_id: [{ required: true, message: "头条账号不能为空" }],
|
|
|
+};
|
|
|
|
|
|
// 打开弹框
|
|
|
-const open = async (type = 'ks') => {
|
|
|
- mode.value = type
|
|
|
+const open = async (type = "ks") => {
|
|
|
+ mode.value = type;
|
|
|
// 重置表单数据
|
|
|
- Object.assign(formData, initialFormData)
|
|
|
- formRef.value.clearValidate()
|
|
|
- formRef.value.resetFields()
|
|
|
+ Object.assign(formData, initialFormData);
|
|
|
+ formRef.value.clearValidate();
|
|
|
+ formRef.value.resetFields();
|
|
|
|
|
|
- visible.value = true
|
|
|
- await initPage()
|
|
|
-}
|
|
|
+ visible.value = true;
|
|
|
+ await initPage();
|
|
|
+};
|
|
|
|
|
|
// 初始化页面数据
|
|
|
const initPage = async () => {
|
|
|
- await getGamePackageOptions()
|
|
|
- await getTtAccountOptions()
|
|
|
-}
|
|
|
+ await getGamePackageOptions();
|
|
|
+ await getTtAccountOptions();
|
|
|
+};
|
|
|
|
|
|
// 游戏ID改变
|
|
|
const handleGameChange = (value) => {
|
|
|
- const gameData = gamePackageOptions.value.find((item) => item.game_id === value)
|
|
|
+ const gameData = gamePackageOptions.value.find(
|
|
|
+ (item) => item.game_id === value
|
|
|
+ );
|
|
|
|
|
|
- formData.id = gameData.id
|
|
|
-}
|
|
|
+ formData.id = gameData.id;
|
|
|
+};
|
|
|
|
|
|
// 获取母包列表
|
|
|
const getGamePackageOptions = async () => {
|
|
|
- const res = await commonApi.getPackageOptionsApi({ media_id: 1 })
|
|
|
+ const res = await commonApi.getPackageOptionsApi({ media_id: 1 });
|
|
|
if (res.code === 200) {
|
|
|
- gamePackageOptions.value = res.data
|
|
|
+ gamePackageOptions.value = res.data;
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
// 获取头条账号Options
|
|
|
const getTtAccountOptions = async () => {
|
|
|
- const res = await agentSiteApi.getTtAccountOptionsApi()
|
|
|
+ const res = await agentSiteApi.getTtAccountOptionsApi();
|
|
|
if (res.code === 200) {
|
|
|
- ttAccountOptions.value = res.data
|
|
|
+ ttAccountOptions.value = res.data;
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
// 设置数据
|
|
|
const setFormData = async (data) => {
|
|
|
for (const key in formData) {
|
|
|
if (data[key] != null && data[key] != undefined) {
|
|
|
- formData[key] = data[key]
|
|
|
+ formData[key] = data[key];
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
// 数据保存
|
|
|
const submit = async (done) => {
|
|
|
- const validate = await formRef.value?.validate()
|
|
|
+ const validate = await formRef.value?.validate();
|
|
|
if (!validate) {
|
|
|
- loading.value = true
|
|
|
- let data = { ...formData }
|
|
|
- console.log(data)
|
|
|
- let result = {}
|
|
|
+ loading.value = true;
|
|
|
+ let data = { ...formData };
|
|
|
+ console.log(data);
|
|
|
+ let result = {};
|
|
|
|
|
|
// 推送
|
|
|
result = await agentSiteApi.ttPushNewEventApi({
|
|
|
@@ -152,27 +170,27 @@ const submit = async (done) => {
|
|
|
fb: data.fb,
|
|
|
zh: data.zh,
|
|
|
advertiser_id: data.advertiser_id,
|
|
|
- })
|
|
|
+ });
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
// Message.success("操作成功");
|
|
|
Modal.info({
|
|
|
- title: '推送结果',
|
|
|
+ title: "推送结果",
|
|
|
content: result.data.message,
|
|
|
- })
|
|
|
- emit('success')
|
|
|
- done(true)
|
|
|
+ });
|
|
|
+ emit("success");
|
|
|
+ done(true);
|
|
|
}
|
|
|
// 防止连续点击提交
|
|
|
setTimeout(() => {
|
|
|
- loading.value = false
|
|
|
- }, 500)
|
|
|
+ loading.value = false;
|
|
|
+ }, 500);
|
|
|
}
|
|
|
- done(false)
|
|
|
-}
|
|
|
+ done(false);
|
|
|
+};
|
|
|
|
|
|
// 关闭弹窗
|
|
|
-const close = () => (visible.value = false)
|
|
|
+const close = () => (visible.value = false);
|
|
|
|
|
|
-defineExpose({ open, setFormData, setSiteIds })
|
|
|
+defineExpose({ open, setFormData, setSiteIds });
|
|
|
</script>
|