| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609 |
- <template>
- <headerBar
- title="设置"
- />
- <div class="container">
- <nav class="settings-nav">
- <div class="nav-item" :class="{'active': activeIndex === 0}" @click="activeIndex = 0">
- <img src="@/assets/images/setting/icon1.png" class="nav-icon" v-if="activeIndex !== 0"/>
- <img src="@/assets/images/setting/icon1a.png" class="nav-icon" v-else/>
- <span>基础配置</span>
- </div>
- <div class="nav-item" :class="{'active': activeIndex === 2}" @click="activeIndex = 2">
- <img src="@/assets/images/setting/icon3.png" class="nav-icon" v-if="activeIndex !== 2"/>
- <img src="@/assets/images/setting/icon3a.png" class="nav-icon" v-else/>
- <span>其他设置</span>
- </div>
- <div class="nav-item" v-if="configInfoStore.appModel === 1" :class="{'active': activeIndex === 4}" @click="activeIndex = 4">
- <img src="@/assets/images/setting/icon4.png" class="nav-icon" v-if="activeIndex !== 4"/>
- <img src="@/assets/images/setting/icon4a.png" class="nav-icon" v-else/>
- <span>左右脚程序设置</span>
- </div>
- </nav>
- <div class="form-container">
- <!--基础配置-->
- <div class="selectBox" v-if="activeIndex === 0">
- <div class="form-item">
- <label>主图尺寸:</label>
- <div class="select-wrapper">
- <el-select multiple
- collapse-tags
- multiple-limit="3"
- v-model="formData.basic_configs.main_image_size" placeholder="请选择">
- <el-option v-for="item in mainImageSizeList" :key="item.value" :label="item.label" :value="item.value"></el-option>
- </el-select>
- </div>
- </div>
- <div class="form-item">
- <label>图片输出格式:</label>
- <div class="select-wrapper">
- <el-select v-model="formData.basic_configs.image_out_format" placeholder="请选择">
- <el-option v-for="item in imageFormatList" :key="item.value" :label="item.label" :value="item.value"></el-option>
- </el-select>
- </div>
- </div>
- <div class="form-item">
- <label>图片锐化:</label>
- <div class="select-wrapper">
- <el-select v-model="formData.basic_configs.image_sharpening" placeholder="请选择">
- <el-option v-for="item in imageSharpeningList" :key="item.value" :label="item.label" :value="item.value"></el-option>
- </el-select>
- </div>
- </div>
- </div>
- <!--基础配置-->
- <!--其他设置-->
- <template v-if="activeIndex === 2">
- <div class="selectBox" style="padding-top: 0px" >
- <div class="form-item">
- <label>产品类型:</label>
- <div class="select-wrapper">
- <el-select v-model="formData.other_configs.product_type" placeholder="请选择">
- <el-option v-for="item in productTypeList" :key="item.value" :label="item.label" :value="item.value"></el-option>
- </el-select>
- </div>
- </div>
- <div class="form-item">
- <label>默认抠图模式:</label>
- <div class="select-wrapper">
- <el-select v-model="formData.other_configs.cutout_mode" placeholder="请选择">
- <el-option v-for="item in defaultCutoutModeList" :key="item.value" :label="item.label" :value="item.value"></el-option>
- </el-select>
- </div>
- </div>
- <div class="form-item">
- <label>设备运动速度:</label>
- <div class="select-wrapper">
- <el-select v-model="formData.other_configs.device_speed" placeholder="请选择">
- <el-option v-for="item in deviceSpeedList" :key="item.value" :label="item.label" :value="item.value"></el-option>
- </el-select>
- </div>
- </div>
- <!-- <div class="form-item">
- <label>运行模式:</label>
- <div class="select-wrapper">
- <el-select v-model="formData.other_configs.running_mode" placeholder="请选择">
- <el-option v-for="item in runModeList" :key="item.value" :label="item.label" :value="item.value"></el-option>
- </el-select>
- </div>
- </div>-->
- </div>
- <other-config/>
- </template>
- <!--其他设置-->
- <div class="selectBox" style="padding-top: 0px;padding-left: 0;" v-if="activeIndex === 4">
- <actionConfig/>
- </div>
- </div>
- <div class="text-center mt-8">
- <button class="bg-gradient-to-r from-primary" @click="saveSetting(activeIndex)" v-if="activeIndex !== 4">
- 保存
- </button>
- </div>
- </div>
- </template>
- <script setup>
- /**
- * Vue组件逻辑部分,包含与设备配置相关的功能。
- * 主要功能包括:表单数据管理、设备配置列表获取、新增/编辑/删除步骤、保存配置等。
- */
- // 引入Vue相关功能和第三方库
- import { ref, reactive } from 'vue';
- import { useRoute, useRouter } from 'vue-router';
- import { onMounted, watch } from 'vue';
- import socket from "@/stores/modules/socket";
- import headerBar from '@/components/header-bar/index.vue';
- import client from "@/stores/modules/client";
- import icpList from '@/utils/ipc';
- const clientStore = client();
- import { ElMessage, ElMessageBox } from 'element-plus';
- import { digiCamControlWEB } from '@/utils/appconfig'
- import { useCheckInfo } from '@/composables/userCheck';
- import { preview } from '@planckdev/element-plus/utils'
- import actionConfig from './components/action_config.vue'
- import otherConfig from './components/otherConfig'
- useCheckInfo();
- // 路由和状态管理初始化
- const route = useRoute();
- const router = useRouter();
- // 定义响应式变量
- const folderPath = ref(''); // 文件夹路径
- const activeIndex = ref(0); // 当前激活的索引
- const socketStore = socket(); // WebSocket状态管理实例
- import configInfo from '@/stores/modules/config';
- const configInfoStore = configInfo();
- /**
- * 表单数据对象,用于存储设备配置信息。
- */
- const formData = reactive({
- //基础配置
- basic_configs:{
- "main_image_size": [],//主图尺寸
- "image_out_format": "",//图片输出格式
- "image_sharpening": "" //图片锐化
- },
- //拍照配置
- take_photo_configs:{
- "repart_take_photo_warning": false,//重复拍摄警告
- "single_photo_warning": "",//单次张数警告
- "total_photo_warning": "",//累计拍照警告
- "camera_delay": ""//拍照停留
- },
- other_configs:{
- "product_type": "",//产品类型
- "cutout_mode": "",//默认抠图模式
- "device_speed": "",//设备运动速度
- "running_mode": "" //运行模式
- },
- captureOneFolder: '', // Capture One文件夹路径
- mainImageSize: '', // 主图尺寸
- imageFormat: '', // 图片格式
- imageSharpening: '', // 图片锐化
- repeatWarning: '', // 重复警告
- singleWarning: '', // 单次警告
- totalWarning: '', // 总警告
- focusTime: '', // 对焦时间
- photoTime: '', // 拍照时间
- productType: '', // 产品类型
- defaultCutoutMode: '', // 默认抠图模式
- deviceSpeed: '', // 设备速度
- runMode: '', // 运行模式
- receiver: '', // 接收器类型
- left: '', // 左脚配置
- right: '', // 右脚配置
- up: '', // 上移配置
- down: '', // 下移配置
- });
- // 配置选项列表
- const mainImageSizeList = ref([
- { label: '320*320', value: 320 },
- { label: '512*512', value: 512 },
- { label: '768*768', value: 768 },
- { label: '800*800', value: 800 },
- { label: '1024*1024', value: 1024 },
- { label: '1200*1200', value: 1200 },
- { label: '1400*1400', value: 1400 },
- { label: '1600*1600', value: 1600 },
- ]);
- const imageFormatList = ref([
- { label: 'jpg', value: 'jpg' },
- { label: 'png', value: 'png' },
- { label: 'jpeg', value: 'jpeg' },
- { label: 'webp', value: 'webp' },
- { label: 'avif', value: 'avif' },
- ]);
- const imageSharpeningList = ref([
- { label: '0', value: '0' },
- { label: '1', value: '1' },
- { label: '2', value: '2' },
- { label: '3', value: '3' },
- ]);
- const repeatWarningList = ref([
- { label: '关闭', value: false },
- { label: '开启', value: true },
- ]);
- const singleWarningList = ref([
- { label: '11', value: '11' },
- { label: '12', value: '12' },
- { label: '13', value: '13' },
- ]);
- const totalWarningList = ref([
- { label: '1.0', value: '1.0' },
- { label: '1.5', value: '1.5' },
- { label: '2.0', value: '2.0' },
- ]);
- const productTypeList = ref([
- { label: '鞋类', value: '鞋类' },
- { label: '服装', value: '服装' },
- { label: '箱包', value: '箱包' },
- ]);
- const defaultCutoutModeList = ref([
- { label: '普通抠图', value: '普通抠图' },
- { label: '精细化抠图', value: '精细化抠图' },
- ]);
- const deviceSpeedList = ref([
- { label: '一档', value: '1' },
- { label: '二档', value: '2' },
- { label: '三档', value: '3' },
- ]);
- /*
- const runModeList = ref([
- { label: '普通模式', value: '普通模式' },
- { label: '待用户确认模式', value: '待用户确认模式' }
- ]);
- const receiverList = ref([
- { label: '蓝牙', value: '1' },
- { label: '2.4G', value: '2' },
- { label: '5.8G', value: '3' },
- ]);
- const leftList = ref([
- { label: '左脚', value: '1' },
- { label: '右脚', value: '2' },
- { label: '左右脚', value: '3' },
- ]);
- const rightList = ref([
- { label: '左脚', value: '1' },
- { label: '右脚', value: '2' },
- { label: '左右脚', value: '3' },
- ]);
- const upList = ref([
- { label: '上移', value: '1' },
- { label: '下移', value: '2' },
- { label: '左右移', value: '3' },
- ]);
- const downList = ref([
- { label: '上移', value: '1' },
- { label: '下移', value: '2' },
- { label: '左右移', value: '3' },
- ]);
- */
- const indexKey ={
- 0:"basic_configs",
- 1:"take_photo_configs",
- 2:"other_configs",
- }
- /**
- * 监听路由参数变化,更新activeIndex和activeTab。
- */
- watch(() => route.query.type, async (newType,oldType) => {
- if(['0','1','2'].includes(oldType)){
- await saveSetting(oldType)
- }
- const typeValue = parseInt(newType) || 0;
- if(typeValue === 4) return;
- switch (typeValue) {
- default:
- clientStore.ipc.removeAllListeners(icpList.setting.getSysConfig);
- clientStore.ipc.send(icpList.setting.getSysConfig,{
- key: indexKey[typeValue]
- });
- clientStore.ipc.on(icpList.setting.getSysConfig, (event, result) => {
- if(result.code == 0 && result.data){
- formData[indexKey[typeValue]] = result.data
- }
- console.log('icpList.setting.getSysConfig')
- console.log(result)
- clientStore.ipc.removeAllListeners(icpList.setting.getSysConfig);
- });
- break;
- }
- }, { immediate: true });
- /**
- * 监听activeIndex变化,更新URL中的查询参数。
- */
- watch(() => activeIndex.value, (newIndex) => {
- router.push({
- query: {
- ...route.query,
- type: newIndex.toString()
- }
- });
- });
- /**
- * 组件挂载时初始化activeIndex。
- */
- onMounted(() => {
- if (route.query.type) {
- const typeValue = parseInt(route.query.type);
- if (!isNaN(typeValue) && typeValue >= 0 && typeValue <= 3) {
- activeIndex.value = typeValue;
- }
- }
- });
- /**
- * 保存当前表单配置。
- */
- const saveSetting = async (index) => {
- if(index === 0){
- if(formData.basic_configs.main_image_size.length === 0){
- ElMessage.error('请选择主图尺寸!');
- return;
- }
- }
- await new Promise((resolve, reject) => {
- clientStore.ipc.removeAllListeners(icpList.setting.updateSysConfigs);
- clientStore.ipc.send(icpList.setting.updateSysConfigs,{
- key: indexKey[index],
- value:JSON.stringify({
- ...formData[indexKey[index]]
- })
- });
- clientStore.ipc.on(icpList.setting.updateSysConfigs, async (event, result) => {
- clientStore.ipc.removeAllListeners(icpList.setting.updateSysConfigs);
- if(result.code === 0 && result.msg){
- resolve(result)
- }
- });
- });
- };
- </script>
- <style lang="scss">
- .el-image-viewer__wrapper{
- z-index: 9999 !important;
- }
- </style>
- <style lang="scss" scoped>
- body {
- background: #EAECED;
- }
- .container {
- margin: 0 auto;
- min-height: calc(100vh - 30px);
- background: #EAECED;
- display: flex;
- flex-direction: column;
- justify-content: flex-start;
- }
- .settings-nav {
- display: flex;
- justify-content: center;
- gap: 40px;
- padding: 30px 0;
- background: #EDEFF0;
- border-bottom: 1px solid rgba(0,0,0,0.1);
- }
- .nav-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- cursor: pointer;
- color: #666;
- transition: all 0.3s;
- width: 100px;
- justify-content: center;
- height: 70px;
- font-size: 14px;
- }
- .nav-item.active {
- background: #DFE2E3;
- border-radius: 10px;
- color: #2957FF;
- }
- .nav-item i {
- font-size: 24px;
- margin-bottom: 8px;
- width: 40px;
- height: 40px;
- display: flex;
- justify-content: center;
- align-items: center;
- background: #fff;
- border-radius: 8px;
- }
- .form-container {
- border-radius: 12px;
- padding: 30px;
- padding-top: 10px;
- width: 800px;
- margin: 0 auto;
- height: 306px;
- }
- .form-item {
- margin-bottom: 24px;
- display: flex;
- align-items: center;
- }
- .form-item label {
- display: block;
- min-width: 98px;
- text-align: right;
- font-size: 14px;
- color: #1A1A1A;
- }
- .input-group {
- display: flex;
- gap: 12px;
- }
- .input-group input {
- flex: 1;
- border: 1px solid #e5e7eb;
- border-radius: 4px;
- padding: 8px 12px;
- font-size: 14px;
- }
- .select-wrapper {
- position: relative;
- width: 200px;
- :deep(.el-input__inner){
- border-radius: 6px;
- }
- }
- .error-text {
- color: #dc2626;
- font-size: 12px;
- margin-top: 4px;
- }
- .from-primary{
- width: 150px;
- height: 40px;
- color: #FFFFFF;
- background: linear-gradient( 135deg, #2FB0FF 0%, #B863FB 100%);
- }
- .nav-icon{
- width: 32px;
- height: 32px;
- }
- .captureBox{
- border-bottom: 1px solid rgba(0,0,0,0.1);
- }
- .selectBox{
- padding-top: 30px;
- padding-left: 100px;
- border-bottom: 1px solid rgba(0,0,0,0.1);
- :deep(.el-tabs__header){
- padding-left: 0;
- }
- :deep(.el-tabs--card>.el-tabs__header){
- border-bottom: 1px solid #CCCCCC;
- }
- :deep(.el-tabs__item){
- height: 30px;
- line-height: 30px;
- }
- :deep(.el-tabs__nav-wrap){
- margin-bottom: 0;
- }
- :deep(.el-tabs__item.is-active){
- color: #333;
- font-weight: bold;
- background: #fff;
- }
- }
- .select-btn{
- display: flex;
- align-items: center;
- flex-shrink: 0;
- width: 120px;
- height: 30px;
- background: #DFE2E3;
- border-radius: 6px;
- justify-content: center;
- font-size: 14px;
- color: #2957FF;
- gap: 5px;
- img{
- width: 16px;
- height: 16px;
- }
- }
- .mt-8{
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 30px 0;
- height: 100px;
- }
- .config-type{
- font-size: 14px;
- color: #333333;
- display: flex;
- align-items: center;
- justify-content: flex-start;
- padding: 10px 0;
- .el-checkbox{
- margin-left: 10px;
- }
- }
- .editForm{
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: 0;
- .flex-row{
- display: flex;
- align-items: center;
- :deep(.el-radio){
- margin-right: 6px !important;
- }
- :deep(.el-radio__label){
- padding-left: 4px;
- }
- }
- :deep(.el-form-item) {
- margin-bottom: 0;
- .el-form-item__label {
- width: 120px !important;
- padding-right: 0 !important;
- background: #FBFCFF;
- border: 1px solid #EEEEEE;
- height: 41px;
- line-height: 41px;
- padding-left: 5px;
- text-align: left;
- }
- .el-form-item__content {
- width: 190px;
- position: relative;
- height: 41px;
- background: #FFFFFF;
- padding-left: 7px;
- border: 1px solid #EEEEEE;
- .el-input__wrapper {
- box-shadow: none;
- }
- .error-msg{
- display: none;
- position: absolute;
- top: 41px;
- top: 28px;
- left: 8px;
- z-index: 22;
- color: #dc2626;
- font-size: 12px;
- }
- &:hover{
- .error-msg{
- display: block;
- }
- }
- // 确保number类型输入框的上下箭头始终显示
- input[type="number"]::-webkit-inner-spin-button,
- input[type="number"]::-webkit-outer-spin-button {
- opacity: 1;
- height: 28px;
- position: absolute;
- top: 2px;
- right: 2px;
- cursor: pointer;
- }
- input[type="number"] {
- -moz-appearance: number-input; /* Firefox */
- }
- }
- }
- }
- </style>
|