|
@@ -17,7 +17,7 @@
|
|
<el-form-item label="广告名称" prop="name">
|
|
<el-form-item label="广告名称" prop="name">
|
|
<el-input v-model="ruleForm.name" style="width: 50%" />
|
|
<el-input v-model="ruleForm.name" style="width: 50%" />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <div style="display: flex; border: 1px solid #dddfe6; padding: 0 0 0 5px; margin-bottom: 20px">
|
|
|
|
|
|
+ <div style="display: flex; border: 1px solid #dddfe6; padding: 0 0 0 5px; margin-bottom: 20px" v-loading="createLoading">
|
|
<div style="width: 50%; padding-left: 5px; border-right: 1px solid #dddfe6">
|
|
<div style="width: 50%; padding-left: 5px; border-right: 1px solid #dddfe6">
|
|
<el-scrollbar height="700px">
|
|
<el-scrollbar height="700px">
|
|
<el-collapse v-model="activeNames" @change="handleChange" style="border-top: none; border-bottom: none">
|
|
<el-collapse v-model="activeNames" @change="handleChange" style="border-top: none; border-bottom: none">
|
|
@@ -31,6 +31,7 @@
|
|
v-model:file-list="fileList"
|
|
v-model:file-list="fileList"
|
|
:on-change="changeFile"
|
|
:on-change="changeFile"
|
|
v-loading="upLoading"
|
|
v-loading="upLoading"
|
|
|
|
+ :on-remove="handleRemove"
|
|
action="#"
|
|
action="#"
|
|
accept=".png, .jpg"
|
|
accept=".png, .jpg"
|
|
:limit="1"
|
|
:limit="1"
|
|
@@ -82,7 +83,16 @@
|
|
</el-collapse-item>
|
|
</el-collapse-item>
|
|
<el-collapse-item name="2" style="padding-right: 10px">
|
|
<el-collapse-item name="2" style="padding-right: 10px">
|
|
<template #title>自定义图片(可选)</template>
|
|
<template #title>自定义图片(可选)</template>
|
|
- <el-upload v-model:file-list="fileList" action="#" accept=".png, .jpg" :limit="1" list-type="picture-card" :auto-upload="false">
|
|
|
|
|
|
+ <el-upload
|
|
|
|
+ v-model:file-list="customFileList"
|
|
|
|
+ :on-change="changeCustomFile"
|
|
|
|
+ :on-remove="handleCustomRemove"
|
|
|
|
+ v-loading="customUpLoading"
|
|
|
|
+ action="#"
|
|
|
|
+ accept=".png, .jpg"
|
|
|
|
+ :limit="1"
|
|
|
|
+ list-type="picture-card"
|
|
|
|
+ :auto-upload="false">
|
|
<el-icon><Plus /></el-icon>
|
|
<el-icon><Plus /></el-icon>
|
|
<template #file="{ file }">
|
|
<template #file="{ file }">
|
|
<div>
|
|
<div>
|
|
@@ -153,8 +163,13 @@
|
|
</el-scrollbar>
|
|
</el-scrollbar>
|
|
</div>
|
|
</div>
|
|
<div style="width: 50%; padding: 0 10px; position: relative">
|
|
<div style="width: 50%; padding: 0 10px; position: relative">
|
|
- <el-button type="primary" plain @click="clickSave" :disabled="fileList.length == 0" style="position: absolute; top: 92%; left: 46%"
|
|
|
|
- >保存</el-button
|
|
|
|
|
|
+ <el-button
|
|
|
|
+ type="primary"
|
|
|
|
+ plain
|
|
|
|
+ @click="submitForm(ruleFormRef)"
|
|
|
|
+ :disabled="!fileList.length"
|
|
|
|
+ style="position: absolute; top: 92%; left: 46%">
|
|
|
|
+ 保存</el-button
|
|
>
|
|
>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -267,16 +282,13 @@ import type { FormInstance, FormRules, UploadProps, UploadUserFile } from 'eleme
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
import { Plus, Picture, Search, Delete, Download, ZoomIn } from '@element-plus/icons-vue'
|
|
import { Plus, Picture, Search, Delete, Download, ZoomIn } from '@element-plus/icons-vue'
|
|
import type { UploadFile } from 'element-plus'
|
|
import type { UploadFile } from 'element-plus'
|
|
-import { getAssets, getLifeStyleAssets, getPageAsins, getCommodityCard, uploadFile, checkAsset } from '../api/index'
|
|
|
|
|
|
+import { getAssets, getLifeStyleAssets, getPageAsins, getCommodityCard, uploadFile, checkAsset, postProductset } from '../api/index'
|
|
import emitter from '/@/utils/emitter'
|
|
import emitter from '/@/utils/emitter'
|
|
import { storeToRefs } from 'pinia'
|
|
import { storeToRefs } from 'pinia'
|
|
import { useShopInfo } from '/@/stores/shopInfo'
|
|
import { useShopInfo } from '/@/stores/shopInfo'
|
|
import axios from 'axios'
|
|
import axios from 'axios'
|
|
|
|
|
|
-// async function uploadFile(formData) {
|
|
|
|
-// return axios.post('http://192.168.1.225/api/ad_manage/assets/upload/', formData)
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
|
|
+const respAdGroupId = inject<Ref>('respAdGroupId')
|
|
const shopInfo = useShopInfo()
|
|
const shopInfo = useShopInfo()
|
|
const { profile } = storeToRefs(shopInfo)
|
|
const { profile } = storeToRefs(shopInfo)
|
|
|
|
|
|
@@ -304,6 +316,7 @@ const submitForm = async (formEl: FormInstance | undefined) => {
|
|
await formEl.validate((valid, fields) => {
|
|
await formEl.validate((valid, fields) => {
|
|
if (valid) {
|
|
if (valid) {
|
|
console.log('submit!')
|
|
console.log('submit!')
|
|
|
|
+ createCreativity()
|
|
} else {
|
|
} else {
|
|
console.log('error submit!', fields)
|
|
console.log('error submit!', fields)
|
|
}
|
|
}
|
|
@@ -355,12 +368,69 @@ function handleRemove(file: UploadFile) {
|
|
fileList.value = []
|
|
fileList.value = []
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+function handleCustomRemove(file: UploadFile) {
|
|
|
|
+ customFileList.value = []
|
|
|
|
+}
|
|
|
|
+
|
|
function handlePictureCardPreview(file: UploadFile) {
|
|
function handlePictureCardPreview(file: UploadFile) {
|
|
handleUpload(file)
|
|
handleUpload(file)
|
|
dialogImageUrl.value = file.url!
|
|
dialogImageUrl.value = file.url!
|
|
dialogVisible.value = true
|
|
dialogVisible.value = true
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 自定义文件上传
|
|
|
|
+const customFileList = ref([])
|
|
|
|
+const customUpLoading = ref(false)
|
|
|
|
+let customImageAssetId = ''
|
|
|
|
+
|
|
|
|
+function changeCustomFile(file: UploadFile) {
|
|
|
|
+ handleCustomUpload(file)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+async function handleCustomUpload(file: UploadFile) {
|
|
|
|
+ const formData = new FormData()
|
|
|
|
+ formData.append('file', file.raw)
|
|
|
|
+ formData.append('profile_id', profile.value.profile_id)
|
|
|
|
+ formData.append('brandEntityId', brandEntityId.value)
|
|
|
|
+ formData.append('assetType', 'IMAGE')
|
|
|
|
+ formData.append('assetSubTypeList', JSON.stringify(['LOGO']))
|
|
|
|
+ upLoading.value = true
|
|
|
|
+ try {
|
|
|
|
+ const response = await uploadFile(formData)
|
|
|
|
+ const fileName = response.data.file_name
|
|
|
|
+ const obj = {
|
|
|
|
+ profile_id: profile.value.profile_id,
|
|
|
|
+ file_name: fileName,
|
|
|
|
+ }
|
|
|
|
+ const resp = await checkAsset(obj)
|
|
|
|
+ customImageAssetId = resp.data.assetId
|
|
|
|
+ const { width, height } = resp.data.fileMetadata
|
|
|
|
+ customImageCrop = {
|
|
|
|
+ width,
|
|
|
|
+ height,
|
|
|
|
+ top: 0,
|
|
|
|
+ left: 0,
|
|
|
|
+ }
|
|
|
|
+ if (resp.data.checkresult == 'success') {
|
|
|
|
+ ElMessage({ message: '上传成功', type: 'success' })
|
|
|
|
+ } else {
|
|
|
|
+ ElMessage.error('上传失败')
|
|
|
|
+ }
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error('上传失败:', error)
|
|
|
|
+ } finally {
|
|
|
|
+ upLoading.value = false
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const createLoading = ref(false)
|
|
|
|
+const casins = ref('')
|
|
|
|
+let brandLogoCrop = {}
|
|
|
|
+let customImageCrop = {}
|
|
|
|
+let url = ''
|
|
|
|
+let brandName = ''
|
|
|
|
+let brandLogoAssetID = ''
|
|
|
|
+
|
|
function changeFile(file: UploadFile) {
|
|
function changeFile(file: UploadFile) {
|
|
handleUpload(file)
|
|
handleUpload(file)
|
|
}
|
|
}
|
|
@@ -381,6 +451,14 @@ async function handleUpload(file: UploadFile) {
|
|
file_name: fileName,
|
|
file_name: fileName,
|
|
}
|
|
}
|
|
const resp = await checkAsset(obj)
|
|
const resp = await checkAsset(obj)
|
|
|
|
+ brandLogoAssetID = resp.data.assetId
|
|
|
|
+ const { width, height } = resp.data.fileMetadata
|
|
|
|
+ brandLogoCrop = {
|
|
|
|
+ width,
|
|
|
|
+ height,
|
|
|
|
+ top: 0,
|
|
|
|
+ left: 0,
|
|
|
|
+ }
|
|
if (resp.data.checkresult == 'success') {
|
|
if (resp.data.checkresult == 'success') {
|
|
ElMessage({ message: '上传成功', type: 'success' })
|
|
ElMessage({ message: '上传成功', type: 'success' })
|
|
} else {
|
|
} else {
|
|
@@ -393,6 +471,37 @@ async function handleUpload(file: UploadFile) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+async function createCreativity() {
|
|
|
|
+ createLoading.value = true
|
|
|
|
+ try {
|
|
|
|
+ const obj = {
|
|
|
|
+ profile_id: profile.value.profile_id,
|
|
|
|
+ casins: casins.value,
|
|
|
|
+ lasins: [],
|
|
|
|
+ url: url,
|
|
|
|
+ name: ruleForm.name,
|
|
|
|
+ state: 'PAUSED',
|
|
|
|
+ adGroupId: respAdGroupId.value,
|
|
|
|
+ brandName: brandName,
|
|
|
|
+ brandLogoCrop: brandLogoCrop,
|
|
|
|
+ brandLogoAssetID: brandLogoAssetID,
|
|
|
|
+ customImageCrop: customImageCrop,
|
|
|
|
+ customImageAssetId: customImageAssetId,
|
|
|
|
+ headline: ruleForm.title,
|
|
|
|
+ }
|
|
|
|
+ const response = await postProductset(obj)
|
|
|
|
+ if (response.data.creative_state == 'success') {
|
|
|
|
+ ElMessage({ message: '创建成功', type: 'success' })
|
|
|
|
+ } else {
|
|
|
|
+ ElMessage.error('上传失败')
|
|
|
|
+ }
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error('error:', error)
|
|
|
|
+ } finally {
|
|
|
|
+ createLoading.value = false
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
// 选择卡片功能
|
|
// 选择卡片功能
|
|
function selectCard(item) {
|
|
function selectCard(item) {
|
|
if (isSelected(item.id)) {
|
|
if (isSelected(item.id)) {
|
|
@@ -417,14 +526,10 @@ function handleConfirmSelection() {
|
|
url: selectedImageUrl.value,
|
|
url: selectedImageUrl.value,
|
|
// 根据需要添加更多属性
|
|
// 根据需要添加更多属性
|
|
}
|
|
}
|
|
-
|
|
|
|
- // 将新的文件对象添加到 fileList 中
|
|
|
|
- fileList.value.push(newFile)
|
|
|
|
|
|
+ fileList.value.push(newFile) // 将新的文件对象添加到 fileList 中
|
|
}
|
|
}
|
|
|
|
|
|
- // 清空选中卡片
|
|
|
|
- selectedCards.value = []
|
|
|
|
- // 关闭对话框
|
|
|
|
|
|
+ selectedCards.value = [] // 清空选中卡片
|
|
centerDialogVisible.value = false
|
|
centerDialogVisible.value = false
|
|
}
|
|
}
|
|
|
|
|
|
@@ -439,8 +544,6 @@ async function getAssetsData() {
|
|
assetSubType: 'LOGO',
|
|
assetSubType: 'LOGO',
|
|
}
|
|
}
|
|
const response = await getAssets(query)
|
|
const response = await getAssets(query)
|
|
- console.log('🚀 ~ getAssetsData ~ response-->>', response)
|
|
|
|
-
|
|
|
|
cards.splice(0, cards.length)
|
|
cards.splice(0, cards.length)
|
|
|
|
|
|
response.data.forEach((asset) => {
|
|
response.data.forEach((asset) => {
|
|
@@ -511,7 +614,6 @@ async function getCommodityCollapseData() {
|
|
}
|
|
}
|
|
const response = await getPageAsins(query)
|
|
const response = await getPageAsins(query)
|
|
asinList.value = response.data.asinList
|
|
asinList.value = response.data.asinList
|
|
- console.log('asinList', asinList.value)
|
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
console.log('error:', error)
|
|
console.log('error:', error)
|
|
} finally {
|
|
} finally {
|
|
@@ -519,10 +621,6 @@ async function getCommodityCollapseData() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-function clickSave() {
|
|
|
|
- console.log(123, fileList.value)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
let lastQueriedAsins = []
|
|
let lastQueriedAsins = []
|
|
const commodityCard = ref([])
|
|
const commodityCard = ref([])
|
|
async function getCommodityCardData() {
|
|
async function getCommodityCardData() {
|
|
@@ -637,18 +735,32 @@ const flattenedReplaceableCommodity = computed(() => {
|
|
return replaceableCommodity.value.flat()
|
|
return replaceableCommodity.value.flat()
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+watch(
|
|
|
|
+ flattenedCommodityCard,
|
|
|
|
+ (newValue: any) => {
|
|
|
|
+ casins.value = newValue.map((item) => item.asin)
|
|
|
|
+ },
|
|
|
|
+ { deep: true }
|
|
|
|
+)
|
|
|
|
+
|
|
const brandEntityId = ref('')
|
|
const brandEntityId = ref('')
|
|
|
|
+
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
emitter.on('send-brandEntityId', (value: any) => {
|
|
emitter.on('send-brandEntityId', (value: any) => {
|
|
- // console.log('接收到', value.brandEntityId[0].brandEntityId)
|
|
|
|
brandEntityId.value = value.brandEntityId[0].brandEntityId
|
|
brandEntityId.value = value.brandEntityId[0].brandEntityId
|
|
})
|
|
})
|
|
|
|
+ emitter.on('page', (value: any) => {
|
|
|
|
+ url = value
|
|
|
|
+ })
|
|
|
|
+ emitter.on('video-shop', (value: any) => {
|
|
|
|
+ brandName = value.brandRegistryName
|
|
|
|
+ })
|
|
})
|
|
})
|
|
|
|
|
|
// 接收数据端在组建卸载时解绑事件
|
|
// 接收数据端在组建卸载时解绑事件
|
|
onUnmounted(() => {
|
|
onUnmounted(() => {
|
|
emitter.off('send-brandEntityId')
|
|
emitter.off('send-brandEntityId')
|
|
- emitter.off('test')
|
|
|
|
|
|
+ emitter.off('page')
|
|
})
|
|
})
|
|
</script>
|
|
</script>
|
|
|
|
|