| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744 |
- <template>
- <headerBar title="主图与详情生成" :menu="[
- {
- type: 'setting'
- }
- ]" />
- <div class="detail-container">
- <div>
- <!-- 主图LOGO部分 -->
- <div class="logo-section flex left top">
- <div class="section-title">
- <img src="@/assets/images/Photography/zhuangshi.png" style="width: 32px; height: 32px;" />
- 主图LOGO:
- </div>
- <upload :value="form.logo_path" @input="onInput"></upload>
- </div>
- <el-divider />
- <!-- 图片抠图与货号图生成 -->
- <div class="section">
- <div class="section-title">
- <img src="@/assets/images/Photography/zhuangshi.png" style="width: 32px; height: 32px;" />
- 图片抠图与货号图生成
- </div>
- <div class="section-content">
- <div v-if="showTips" class="instruction-out flex top left">
- <img style="fill: #000" src="@/assets/images/xinxi.svg" />
- <ol class="instruction-list">
- <li>请在下方确认图片拍摄过程中的顺序,确保所有拍摄的图片的顺序一致。</li>
- <li>使用中英文语号分隔。</li>
- <li>图片的名称不能随意修改,否则无法正常生成详情页。</li>
- <li>现有图片名称有:俯视、侧视、后视、鞋底、内里</li>
- </ol>
- <el-icon @click="showTips = false" class="close-icon">
- <Close />
- </el-icon>
- </div>
- <!-- 货号文件夹 -->
- <!-- <div class="form-item">
- <div class="label">货号文件夹:</div>
- <div class="folder-warp">
- <div class="folder-input">
- <el-input style="width: 60%;" v-model="folderPath" type="textarea" :rows="2" readonly
- placeholder="请选择货号文件夹" />
- <el-button class="check-button" type="primary" @click="selectFolder">
- <img src="@/assets/images/Photography/wenjian.png" style="width: 14px; " />
- 选择目标文件夹</el-button>
- </div>
- <div class="hint">
- <el-icon>
- <Warning />
- </el-icon> <text>选择货号的上级文件夹</text>
- </div>
- </div>
- </div>
- -->
- </div>
- </div>
- <el-divider />
- <!-- 选择详情模板部分 -->
- <div class="template-section ">
- <div class="flex between">
- <div class="section-title">
- <img src="@/assets/images/Photography/zhuangshi.png" style="width: 32px; height: 32px;" />
- 选择详情模版
- </div>
- <div class="template-pagination">
- <el-pagination background layout="prev, pager, next" v-model:current-page="queryParams.current"
- v-model:page-size.sync="queryParams.size" :total="totalPage" @current-change="onCurrentChange"
- @size-change="onSizeChange" />
- </div>
- </div>
- <div class="template-list">
- <div v-for="(template, index) in visibleTemplates" :key="index" class="template-item"
- @click="form.selectTemplate = template">
- <el-image :src="template.template_cover_image" fit="contain" class="cur-p"
- style="width: 100%; display: block;" />
- <div class="select-warp" :class="form.selectTemplate.id == template.id ? 'active' : ''">
- <el-icon color="#FFFFFF">
- <Select />
- </el-icon>
- </div>
- <div class="template-info">
- <span class="mar-left-10 chaochu_1">{{ template.template_name }}</span>
- <div class="template-view" @click="viewTemplate(template)">查看</div>
- </div>
- </div>
- </div>
- </div>
- <el-divider />
- <!-- 详情高级配置 -->
- <div class="section">
- <div class="section-title">
- <img src="@/assets/images/Photography/zhuangshi.png" style="width: 32px; height: 32px;" />
- 详情高级配置
- </div>
- <div class="section-content">
- <!-- 图片顺序 -->
- <div class="form-item">
- <div class="label">图片顺序:</div>
- <el-input v-model="imageOrder" placeholder="请输入图片顺序" class="specific-page-input">
- <template #append>
- <el-button class="explain-btn" link type="primary">说明</el-button>
- </template>
- </el-input>
- </div>
- <!-- 同款检验 -->
- <!-- <div class="form-item">
- <div class="label">同款检验:</div>
- <el-checkbox v-model="checkSimilar">同款下货号必须齐全</el-checkbox>
- </div>
- -->
- <!-- 可指定页面独修改 -->
- <!-- <div class="form-item">
- <div class="label">可指定页面独修改:</div>
- <el-input v-model="specificPage" placeholder="请输入入需要单独修改的页面,示例:4:1 (需修改模版的编号:第一张)"
- class="specific-page-input">
- <template #append>
- <el-button class="explain-btn" link type="primary">说明</el-button>
- </template>
- </el-input>
- </div>
- -->
- </div>
- </div>
- <el-divider />
- <!-- 详情资料准备部分 -->
- <div class="data-prep-section">
- <div class="flex-item left">
- <div class="section-title">
- <img src="@/assets/images/Photography/zhuangshi.png" style="width: 32px; height: 32px;" />
- 详情资料准备 (2选1)
-
- <el-button v-if="form.dataType == '1'" type="text" class="mar-left-10 fs-16" @click="downloadExcel">下载商品基础资料模版</el-button>
- </div>
- </div>
- <div class="flex-item left">
- <el-radio-group v-model="form.dataType" class="ml-4">
- <el-radio label="1" size="large">EXCEL文件选择</el-radio>
- <el-radio label="2" size="large">系统对接(和业务员联系)</el-radio>
- </el-radio-group>
- </div>
- <div v-if="form.dataType == '1'" class="excel-upload">
- <div class="flex bottom between">
- <div style="max-width: 160px;" class="mar-left-20">商品基础资料EXCEL文件选择:</div>
- <div class="flex bottom mar-left-20" style="flex-grow: 1;">
- <el-input type="textarea" v-model="form.excel_path" />
- </div>
- <el-button class="select-button button--primary1 mar-left-20" type="primary" @click="selectExcel">
- <img src="@/assets/images/Photography/wenjian.png" style="width: 16px; margin-right: 4px;" />
- 选择</el-button>
- </div>
- </div>
- </div>
- </div>
- <!-- 底部按钮 -->
- <div class="footer">
- <!-- <el-button class="button--primary1 footer-button" type="primary" @click="saveConfig">保存配置</el-button> -->
- <!-- <el-button class="button--primary1 footer-button" type="primary" @click="startProcess">开始处理</el-button> -->
- <el-button class="button--primary1 footer-button" type="primary" @click="generate">开始生成</el-button>
- </div>
- </div>
- <loading-dialog v-model="loadingDialogVisible" :progress="progress" :message="message"
- :disabled-button="disabledButton" @button-click="handleComplete">
- <template v-if="partErrList && partErrList.length > 0" #errList>
- <div v-for="(item, idx) in partErrList" :key="idx">
- <span>{{ item.goods_art_no }}</span>:<span>{{ item.info }}</span>
- </div>
- </template>
- </loading-dialog>
- <el-dialog v-model="dialogVisible">
- <img style="width: 100%;" :src="dialogImageUrl" alt="Preview Image" />
- </el-dialog>
- </template>
- <script lang="ts" setup>
- import { getCompanyTemplatesApi } from '@/apis/other'
- import tokenInfo from '@/stores/modules/token';
- import useUserInfo from "@/stores/modules/user";
- import { useRoute, useRouter } from 'vue-router'
- import { ElMessage, ElMessageBox } from 'element-plus'
- import headerBar from '@/components/header-bar/index.vue'
- import { ref, computed, reactive, onMounted } from 'vue';
- import { Select } from '@element-plus/icons-vue'
- import upload from '@/components/upload'
- import client from "@/stores/modules/client";
- import icpList from '@/utils/ipc'
- const clientStore = client();
- import { getRouterUrl } from '@/utils/appfun'
- import { Close, Warning } from '@element-plus/icons-vue'
- import LoadingDialog from '@/views/Photography/components/LoadingDialog.vue'
- import { useCheckInfo } from '@/composables/userCheck';
- useCheckInfo();
- const showTips = ref(true)
- const folderPath = ref('') //货号文件夹
- // const reportMode = ref('normal') // 抠图模式
- const imageOrder = ref('俯视、侧视、后跟、鞋底、内里、组合、组合2、组合3') // 图片顺序
- const checkSimilar = ref(false) // 同款检验
- const specificPage = ref('') // 可指定页面独修改
- // 路由和状态管理初始化
- const route = useRoute();
- const router = useRouter();
- // 完成目录
- const completeDirectory = ref('')
- const loadingDialogVisible = ref(false)
- const progress = ref(0)
- const message = ref('正在为您处理,请稍后')
- const disabledButton = ref(true)
- let templates = ref([])
- let goods_art_nos = ref([])
- let partErrList = ref([])
- const excel_template_url = ref('')
- // 定义一个定时器变量
- const INTERVAL = ref<number | NodeJS.Timeout | null>(null);
- // 状态变量
- const totalPage = ref(0);
- const itemsPerPage = 4; // 每页显示的模板数量
- const dialogVisible = ref(false);
- const dialogImageUrl = ref('');
- const queryParams = reactive({ // 分页查询参数
- size: 1,
- current: 1,
- })
- const form = reactive({
- selectTemplate: {}, //选中的模板
- dataType: '1', // 1: 选择excel文件 2: 系统对接
- logo_path: '', // 主图LOGO
- excel_path: '', // 商品基础资料EXCEL文件选择
- })
- onMounted(() => {
- const goods_art_data = route.query.goods_art_nos
- goods_art_nos.value = Array.isArray(goods_art_data) ? goods_art_data : [goods_art_data]
- getCompanyTemplates()
- })
- // 计算属性,获取当前页可见的模板
- const visibleTemplates = computed(() => {
- const startIndex = (queryParams.current - 1) * itemsPerPage;
- const data = templates.value.slice(startIndex, startIndex + itemsPerPage);
- return data
- });
- // 查看模板详情
- const viewTemplate = (template) => {
- // 展示大图
- dialogVisible.value = true
- dialogImageUrl.value = template.template_preview_image
- };
- // 获取模版列表
- const getCompanyTemplates = async () => {
- const { data } = await getCompanyTemplatesApi()
- templates.value = data.list
- // 默认选中第一个模板
- if (templates.value.length > 0) {
- form.selectTemplate = templates.value[0]
- }
- excel_template_url.value = data.excel_template_url
- // 计算总页数
- totalPage.value = Math.ceil(templates.value.length / itemsPerPage);
- }
- const downloadExcel = () => {
- const a = document.createElement('a')
- a.href = excel_template_url.value,
- a.download = '商品基础资料模版'
- document.body.appendChild(a)
- a.click()
- setTimeout(() => {
- document.body.removeChild(a);
- }, 1000);
- }
- const onCurrentChange = (page) => {
- queryParams.current = page;
- };
- const onSizeChange = (data) => {
- };
- // 开始生成操作
- const generate = async function () {
- const tokenInfoStore = tokenInfo();
- const token = tokenInfoStore.getToken; // 使用 getToken() 获取 token
- let temp_list = []
- templates.value.map(item => {
- temp_list.push({
- template_id: item.template_id,
- template_local_classes: item.template_local_classes,
- })
- })
- const params = {
- goods_art_no: JSON.parse(JSON.stringify(goods_art_nos.value)),
- logo_path: form.logo_path || '',
- temp_name: form.selectTemplate.template_id || '',
- excel_path: form.dataType == '1' ? form.excel_path : '',
- template_image_order: form.selectTemplate.template_image_order,
- temp_list,
- token,
- }
- // 开启进度弹窗
- progress.value = 0
- openLoadingDialog(20)
- console.log("params", "color:#3f7cff", params);
- clientStore.ipc.removeAllListeners(icpList.generate.generatePhotoDetail);
- clientStore.ipc.send(icpList.generate.generatePhotoDetail, params);
- clientStore.ipc.on(icpList.generate.generatePhotoDetail, (event, result) => {
- console.log('result', result)
- partErrList.value = []
- clientStore.ipc.removeAllListeners(icpList.generate.generatePhotoDetail);
- clearInterval(INTERVAL.value)
- if (result.code === 0) {
- const { output_folder, list } = result.data
- const allSuccess = list.every(item => item.success);
- const allFailure = list.every(item => !item.success);
- if (allSuccess) {
- console.log("全部成功")
- handleSuccess(output_folder, '全部生成成功')
- } else if (allFailure) {
- console.log("全部失败");
- handleFailure(list)
- } else {
- console.log("部分成功,部分失败");
- handlePartSuccess(output_folder, list)
- }
- } else {
- console.log('code全部生成失败')
- handleFail(result.msg)
- }
- //生成失败 (接口请求失败)
- function handleFail(errorMsg: string) {
- loadingDialogVisible.value = false
- disabledButton.value = false
- if (errorMsg) {
- ElMessage.error(errorMsg)
- }
- }
- // 全部生成成功
- function handleSuccess(href, loadingMsg) {
- completeDirectory.value = href
- progress.value = 100
- disabledButton.value = false
- message.value = loadingMsg
- }
- // 部分成功
- function handlePartSuccess(output_folder: string, partSuccessList) {
- let errorList = []
- partSuccessList.map(item => {
- if (!item.success) {
- errorList.push(item)
- }
- })
- partErrList.value = errorList
- handleSuccess(output_folder, '部分货号生成失败')
- }
- // 全部生成失败
- function handleFailure(partSuccessList) {
- let errorList = []
- partSuccessList.map(item => {
- if (!item.success) {
- errorList.push(item)
- }
- })
- partErrList.value = errorList
- completeDirectory.value = ''
- progress.value = 100
- disabledButton.value = true
- message.value = '全部货号生成失败'
- }
- });
- }
- const openLoadingDialog = (timer: number) => {
- loadingDialogVisible.value = true
- disabledButton.value = true
- // 根据传入的秒数计算每次增加的进度值
- const step = 100 / timer
- INTERVAL.value = setInterval(() => {
- if (progress.value < 100) {
- progress.value = Math.round(progress.value + step)
- }
- }, 1000)
- }
- const onInput = (value) => {
- form.logo_path = value
- }
- function selectExcel() {
- clientStore.ipc.removeAllListeners(icpList.utils.openFile);
- clientStore.ipc.send(icpList.utils.openFile, {
- filters: [
- { name: '支持xls,xlsx', extensions: ['xlsx', 'xls'] }
- ],
- title: "选择基础文件资料"
- });
- clientStore.ipc.on(icpList.utils.openFile, async (event, result) => {
- form.excel_path = result
- clientStore.ipc.removeAllListeners(icpList.utils.openFile);
- })
- }
- const Router = useRouter()
- //打开主图详情
- function openPhotographySeniorDetail() {
- const { href } = Router.resolve({
- name: 'PhotographySeniorDetail'
- })
- clientStore.ipc.removeAllListeners(icpList.utils.openMain);
- let params = {
- title: '详情高级配置',
- width: 1000,
- height: 630,
- frame: true,
- id: "PhotographySeniorDetail",
- url: getRouterUrl(href)
- }
- clientStore.ipc.send(icpList.utils.openMain, params);
- }
- const handleComplete = () => {
- loadingDialogVisible.value = false
- // 这里可以添加打开目录的逻辑
- clientStore.ipc.removeAllListeners(icpList.utils.shellFun);
- let params = {
- action: 'openPath',
- params: completeDirectory.value?.replaceAll('/', '\\')
- }
- clientStore.ipc.send(icpList.utils.shellFun, params);
- }
- const selectFolder = () => {
- clientStore.ipc.removeAllListeners(icpList.utils.openDirectory);
- clientStore.ipc.send(icpList.utils.openDirectory);
- clientStore.ipc.on(icpList.utils.openDirectory, async (event, result) => {
- folderPath.value = result
- clientStore.ipc.removeAllListeners(icpList.utils.openDirectory);
- })
- }
- </script>
- <style lang="scss" scoped>
- .detail-container {
- background-color: #EAECED;
- width: 100%;
- min-width: 600px;
- padding: 20px;
- overflow: hidden;
- }
- .logo-section,
- .template-section,
- .data-prep-section {
- margin-bottom: 20px;
- }
- .logo-upload {
- border: 1px dashed #ccc;
- border-radius: 5px;
- padding: 50px 0;
- text-align: center;
- cursor: pointer;
- }
- .template-pagination button {
- margin-right: 5px;
- }
- .template-pagination span {
- display: inline-block;
- width: 20px;
- height: 20px;
- line-height: 20px;
- text-align: center;
- border: 1px solid #ccc;
- border-radius: 5px;
- margin-right: 5px;
- cursor: pointer;
- }
- .template-list {
- display: flex;
- flex-wrap: wrap;
- gap: 20px;
- margin-top: 10px;
- .template-item {
- width: calc(25% - 18px);
- border: 1px solid #ccc;
- border-radius: 10px;
- cursor: pointer;
- background: #f0f0f0;
- position: relative;
- overflow: hidden;
- .template-info {
- position: absolute;
- bottom: 0;
- left: 0;
- background: rgba($color: #000000, $alpha: .3);
- width: 100%;
- height: 36px;
- line-height: 36px;
- color: #eee;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .template-view {
- background: #DFE2E3;
- color: #3366FF;
- height: 30px;
- line-height: 30px;
- padding: 0 10px;
- border-radius: 4px;
- margin-right: 10px;
- font-size: 14px;
- }
- }
- }
- }
- .excel-upload {
- width: 100%;
- background: #F7F7F7;
- padding: 20px 0;
- }
- .generate-button {
- padding: 10px 20px;
- color: white;
- border: none;
- border-radius: 5px;
- cursor: pointer;
- }
- .select-button {
- background: #DFE2E3 !important;
- color: #3366FF !important;
- height: 30px;
- line-height: 30px;
- padding: 0 10px;
- border-radius: 4px;
- margin-right: 10px;
- font-size: 14px;
- font-weight: 550;
- }
- .select-warp {
- width: 18px;
- height: 18px;
- border-radius: 4px;
- background-color: #fff;
- position: absolute;
- top: 10px;
- left: 10px;
- &.active {
- background-color: #1677FF;
- }
- }
- .section-title {
- display: flex;
- align-items: center;
- gap: 8px;
- font-weight: bold;
- margin-bottom: 16px;
- color: #474747;
- }
- .section {
- margin-bottom: 24px;
- .section-title {
- display: flex;
- align-items: center;
- gap: 8px;
- font-weight: bold;
- margin-bottom: 16px;
- color: #474747;
- }
- .section-content {
- padding-left: 16px;
- }
- }
- .instruction-out {
- background: #EAF3FF;
- border-radius: 4px;
- border: 1px solid #CBE1FF;
- padding: 10px 20px;
- width: 80%;
- position: relative;
- .instruction-list {
- margin: 0px 0 0 10px;
- padding-left: 20px;
- padding-right: 40px;
- width: 100%;
- li {
- margin-bottom: 4px;
- text-align: left;
- font-size: 14px;
- }
- }
- .close-icon {
- position: absolute;
- top: 12px;
- right: 19px;
- }
- }
- .form-item {
- margin: 16px 0;
- display: flex;
- .label {
- min-width: 120px;
- margin-right: 12px;
- }
- .folder-warp {
- width: 100%;
- display: flex;
- flex-direction: column;
- .folder-input {
- flex: 1;
- display: flex;
- align-items: center;
- .check-button {
- background: #DFE2E3;
- border-radius: 6px;
- padding: 6px 12px;
- color: #2957FF;
- margin-left: 20px;
- }
- }
- }
- .hint {
- text-align: left;
- color: #999;
- margin-top: 6px;
- font-size: 14px;
- color: #FF4C00;
- font-style: normal;
- }
- .specific-page-input {
- flex: 1;
- }
- }
- .image-order {
- flex: 1;
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .footer {
- display: flex;
- justify-content: center;
- margin-top: 24px;
- .footer-button {
- padding: 10px 20px;
- }
- }
- .explain-btn {
- padding-left: 20px;
- padding-right: 20px;
- color: #2957FF !important;
- }
- </style>
|