1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180 |
- <template>
- <div class="mainBox">
- <div class="layerBox">
- <tableTitle :name="tableDivTitle" />
- <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="170px" class="demo-ruleForm">
- <div class="dialogText">
- <el-form-item label="通栏名称:" prop="sectorName">
- <el-input v-model="ruleForm.sectorName" placeholder="输入通栏名称"></el-input>
- </el-form-item>
- <el-form-item label="通栏编号:" prop="sectorId">
- <el-input v-model="ruleForm.sectorId" placeholder="输入通栏编号"></el-input>
- </el-form-item>
- <el-form-item label="所属皮肤:" prop="templateStyle">
- <el-select v-model="ruleForm.templateStyle" placeholder="请选择所属皮肤">
- <el-option v-for="item in template_options" :key="item.template_id"
- :label="item.template_name" :value="item.template_id">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="皮肤id:" prop="templateStyle">
- <el-input v-model="ruleForm.templateStyle" placeholder="所属皮肤id"
- disabled></el-input>
- </el-form-item>
- <el-form-item label="通栏关键词:" prop="sectorKeyword" class="custom-align-right">
- <template #label>
- <span class="askBox">
- 通栏关键词:
- <el-tooltip class="item" effect="dark" content="皮肤关键词,如:黑色、卡通、英雄。" placement="top">
- <i class="el-icon-question"></i>
- </el-tooltip>
- </span>
- </template>
- <tagInput :initialTags="tags" @tags-updated="updateTags"></tagInput>
- </el-form-item>
-
- <el-form-item label="通栏类别:" prop="sectorType">
- <el-select v-model="ruleForm.sectorType" placeholder="请选择通栏类别" :disabled="this.dialogName === '编辑'">
- <!-- 通栏分类:1:资讯类:2:通栏广告类;3:混合类;4:搜索框类;5:导航类;6:头条类;7:轮播图类; -->
- <el-option v-for="item in this.typeList" :label="item.label" :value="item.value" :key="item.value">{{item.label}}</el-option>
- </el-select>
- </el-form-item>
-
- <el-form-item label="页面类型:" prop="pageType">
- <el-checkbox-group v-model="ruleForm.pageType" @change="changeCheckbox"
- :disabled="this.dialogName === '编辑'">
- <el-checkbox v-for="(item, index) in checkList" :key="index" :label="item.value">{{item.label}}</el-checkbox>
- </el-checkbox-group>
- </el-form-item>
-
-
- <el-form-item label="通栏缩略图:" prop="image" :label-width="formLabelWidth"
- :class="['custom-form-item']" class="custom-align-right">
- <div class="uploaderBox">
- <!--图片上传组件 start ------------------------------------------------------------>
- <div class="avatar-upload-container" @mouseenter="hovering = true"
- @mouseleave="hovering = false">
- <!-- 上传组件 -->
- <el-upload class="avatar-uploader" action="#" :show-file-list="false"
- :before-upload="beforeAvatarUpload">
- <!-- 预览图片 -->
- <img v-if="this.logoUrl" :src="this.logoUrl" class="avatar">
- <!-- 上传图标 -->
- <div v-else class="chooseImgDiv">
- <div>
- <img src="@/assets/public/upload/noImage.png">
- <div>选择图片</div>
- </div>
- </div>
- <input type="hidden" name="logo" v-model="ruleForm.image">
- </el-upload>
- <!-- 删除按钮,当鼠标悬浮时显示 -->
- <div v-if="hovering && logoUrl" class="delete-button" @click="handleDelete">
- <i class="el-icon-delete"></i>
- </div>
- </div>
- <!--图片上传组件 end ------------------------------------------------------------>
- </div>
- </el-form-item>
- <el-form-item label="组件数量:" prop="component_num">
- <el-input v-model.number="ruleForm.component_num" id="component_num" placeholder="输入组件数量" type="number"
- min="1" @change="getPlaceList(ruleForm.component_num)">
- </el-input>
- </el-form-item>
- <el-form-item label="通栏模版类型:" prop="sectorPlace">
- <el-select v-model="ruleForm.sectorPlace" placeholder="请选择通栏模版类型" @change="changeStyleSort">
- <el-option v-for="item in sectorPlace_options" :key="item.sector_type" :label="item.name+'('+item.width+'*'+item.height+')'" :value="item.sector_type">{{item.name+'('+item.width+'*'+item.height+')'}}
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="尺寸:" prop="sizeList" v-if="this.ruleForm.sectorPlace != ''">
- <p style="margin-top: 0px;">{{ruleForm.sizeList}}</p>
- </el-form-item>
- <el-form-item label="通栏版式预览图:" prop="sector_img" v-if="this.ruleForm.sectorPlace != ''">
- <img :src="ruleForm.sector_img" alt="" width="300px" height="150px">
- </el-form-item>
- <div class="boxes-container" v-if="this.ruleForm.sizeList != '' && this.ruleForm.sectorPlace">
- <el-row class="layout-3" >
- <el-row v-if="checkPlace" style="width: 100%;height: 100%;">
- <el-col v-for="(col,index) in JSON.parse(checkPlace.map)" :key="index" :style="{width:col.col_data.col_width,height:'100%',marginRight:'1.2%'}">
- <el-row class="box" v-for="(row,rowIndex) in col.col_data.row_data" :key="rowIndex" :style="{height:row.row_height,width:'100%',marginBottom:'2.35%'}">
- {{ component_option.find(item => item.sort_id == row.component_sort) ? `位置${component_option.find(item => item.sort_id == row.component_sort).sort_id}
- (${component_option.find(item => item.sort_id == row.component_sort).width}*${component_option.find(item => item.sort_id == row.component_sort).height})` : '' }}
- </el-row>
- </el-col>
- </el-row>
- </el-row>
- </div>
- <div v-for="(item, index) in component_option" :key="index" class="componentChoose">
- <el-form-item :label="item.name+':'" :prop="`${index}`" class="componentOptions">
- <el-select v-model="ruleForm.component_code[index]" multiple clearable placeholder="请选择组件" class="componentOption_one">
- <el-option v-for="(compItem,comIndex) in item.component" :key="compItem.component_type" :label="compItem.component_name" :value="compItem.component_type">
- {{ compItem.component_name }}
- </el-option>
- </el-select>
- </el-form-item>
- </div>
- </div>
- <div class="dialogBtn">
- <el-button type="info" @click="cancelForm">取消</el-button>
- <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
- </div>
- </el-form>
- </div>
- </div>
- </template>
- <script>
- //表格标题
- import tableTitle from './components/tableTitle.vue';
- import tagInput from '../../components/InputTag/index.vue';
- //引入公用样式
- import '@/styles/global.less';
- // import { getSectorList, addSector, delSector, updateSector, getSectorInfo } from '@/api/plate'
- // import { getTemplateClass } from '@/api/style'
- export default {
- components: {
- tableTitle,//表格标题-
- tagInput
- },
- data() {
- const validateEmpty = (rule, value, callback) => {
- if (value.length == 0) {
- callback(new Error('该项不能为空!'))
- } else {
- callback()
- }
- }
- const validateArray = (rule, value, callback) => {
- if (value.length == 0) {
- callback(new Error('该项不能为空!'))
- } else {
- callback()
- }
- }
- return {
- // 0.0画布及多选组件输入框相关----------start
- component : true, //验证组件是否有空数组
- name: '编辑', //备份dialogName来判断是否执行添加和编辑的异步
- tableData: [{}], // 添加空数据使表格正常显示
- // 初始化时设置默认值为 1,确保有初始布局
- component_num: 1,
- activeBoxes: [false], // 初始化激活状态数组
- selectedComponents: { 0: [] }, // 初始化组件选择对象
- // 0.0画布及多选组件输入框相关----------end
- //1.1 初始化信息
- tableDivTitle: "通栏列表", //列表标题
- dialogTableVisible: false, //编辑弹框
- dialogName: '编辑', //编辑弹窗名称
- plateLoading: true, //表格内容加载中
- tableData: [],//表格数据
- class_options: [],//风格下拉列表
- template_options: [],//皮肤下拉列表
- // componen_code: [],//组件版式及组件下拉列表
- sectorPlace_options: [],//通栏模版类型下拉列表
- component_option: [],
- tags: [],//标签数据
- templateStyle: '',//风格
- plateName: '',
- pageType: '',//页面类型
- value: '',
- checkList: [
- {
- value: 1,
- label: '首页',
- },
- {
- value: 2,
- label: '分类页',
- },
- {
- value: 3,
- label: '列表页',
- },
- {
- value: 4,
- label: '详情页',
- },
- {
- value: 5,
- label: '搜索页',
- },
- {
- value: 6,
- label: '单页(列表)',
- },
- {
- value: 7,
- label: '单页(详情)',
- },
- ],
- typeList: [
- {
- value: 1,
- label: '资讯类',
- },
- {
- value: 2,
- label: '广告类',
- },
- {
- value: 3,
- label: '混合类',
- },
- {
- value: 4,
- label: '搜索框类',
- },
- {
- value: 5,
- label: '导航类',
- },
- {
- value: 6,
- label: '头条类',
- },
- {
- value: 7,
- label: '轮播图类',
- },
- {
- value: 8,
- label: '静态资源类',
- },
- {
- value: 9,
- label: '底部导航(列表)类',
- },
- {
- value: 10,
- label: '底部导航(详情)类',
- },
- ],
- //活动id
- activeid: "",
- newArr: [],
- // 1.3 分页相关
- page: 1,
- pageSize: 10,
- total: 0,
- formLabelWidth: '', //广告示例图相关
- //1.4 弹框相关数据
- ruleForm: {
- sectorName: '', //通栏名称
- sectorPlace: null, //通栏模版类型
- component_num: null, //组件数量
- sectorId: null, //通栏编号id
- templateStyle: '', //所属皮肤
- pageType: '', //页面类型
- sizeList: '', //尺寸
- sectorType: null, //通栏类别
- pageType: [], //页面类型
- sectorKeyword: '', //通栏关键词
- image: '', //通栏展示图
- sector_img:'', //通栏版式预览图
- component_code: [], //所选择位置的组件
- sector_width:'',
- sector_height:'',
- },
- rules: {
- sectorName: [{ required: true, trigger: 'blur', validator: validateEmpty }],
- component_num: [{ required: true, trigger: 'blur', validator: validateEmpty }],
- sectorId: [{ required: true, trigger: 'blur', validator: validateEmpty }],
- templateStyle: [{ required: true, trigger: 'blur', validator: validateEmpty }], //关联皮肤名称
- sectorType: [{ required: true, trigger: 'blur', validator: validateEmpty }],
- // pageType: [{ required: true, trigger: 'blur', validator: validateArray }],
- image: [{ required: true, trigger: 'blur', validator: validateEmpty }],
- sectorPlace: [{ required: true, trigger: 'blur', validator: validateEmpty }],
- // sectorPlace: [{ required: true, trigger: 'blur', validator: validateEmpty }],
- component_code: [{ required: true, trigger: 'blur', validator: validateArray }],
- },
- logoUrl: '',
- hovering: false, // 鼠标悬浮状态 悬浮时显示删除
- }
- },
- computed: {
- // 计算激活的方块索引
- activeBoxIndices() {
- return this.activeBoxes
- .map((active, index) => active ? index : null)
- .filter(index => index !== null);
-
- },
- checkPlace(){
- // 检查 sectorPlace_options 是否为数组,避免调用 find 方法时报错
- if (Array.isArray(this.sectorPlace_options)) {
- return this.sectorPlace_options.find(item => item.sector_type == this.ruleForm.sectorPlace);
- }
- return null;
- }
- },
- methods: {
- //1.列表和分页相关 start ------------------------------------------------------------>
- //1.1 开始请求列表信息方法
- // 获取版式列表
- getPlaceList(sectorType) {
- this.component_option = []
- this.ruleForm.component_code = []
- this.ruleForm.sectorPlace = ''
- let data = {
- component_num : this.ruleForm.component_num,
- type_id: 1,
- }
- this.$store.dispatch('plate/getAllSectorPlace',data).then(res => {
- this.sectorPlace_options = res.data
- }).catch(() => {
- this.$message({
- type: 'error',
- message: '网络错误,请重试!'
- });
- })
- // console.log("回显-22222",this.sectorPlace_options);
- },
- //获取风格列表
- getStyleList() {
- this.$store.dispatch('genre/getTemplateClass').then(res => {
- this.class_options = res.data
- // console.log(res.data);
- }).catch(() => {
- this.$message({
- type: 'error',
- message: '网络错误,请重试!'
- });
- })
- },
- //获取皮肤列表
- getSkinList() {
- let data = [];
- this.$store.dispatch('plate/getAllTemplate').then(res => {
- this.template_options = res.data
- console.log(res.data);
- }).catch(() => {
- this.$message({
- type: 'error',
- message: '网络错误,请重试!'
- });
- })
- },
- // //1.3 多选按钮发生变化
- changeCheckbox(val) {
- console.log(val)
- this.newArr = []
- val.forEach(item => {
- if (typeof item !== 'object' || !item.hasOwnProperty('__ob__')) {
- this.newArr.push(item)
- }
- });
- this.pageType = JSON.stringify(this.newArr)
- // console.log(this.pageType);
- },
- // 通栏版式发生变化
- changeStyleSort(val) {
- let num = 0;
- this.component_option = []
- this.activeBoxes = []
- this.selectedComponents = {}
- this.ruleForm.component_code = []
- if ( this.sectorPlace_options && Array.isArray(this.sectorPlace_options)) {
- this.sectorPlace_options.forEach(item => {
- if(item.sector_type == val){
- this.ruleForm.sizeList = item.width + ' * ' + item.height
- this.ruleForm.sector_img = item.sector_img
- this.ruleForm.size_id = item.size_id
- this.ruleForm.sector_width = item.width
- this.ruleForm.sector_height = item.height
- this.ruleForm.component_num = item.component_num;
- }
- })
- }
- let data = {
- sector_type : this.ruleForm.sectorPlace,
- type_id: 2,
- }
- this.$store.dispatch('plate/getAllSectorPlace',data).then(res => {
- this.component_option = res.data
- if(this.component_option && Array.isArray(this.component_option)){
- this.component_option.forEach(item => {
- item.name = '位置'+item.sort_id+'('+item.width+'*'+item.height+')'
- })
- }
- }).catch(() => {
- this.$message({
- type: 'error',
- message: '网络错误,请重试!'
- });
- })
- },
-
- getStyleSort(val) {
- console.log('this.ruleForm.sectorPlace2222', this.ruleForm.sectorPlace);
- console.log('val', val);
- let data = {
- sector_type : this.ruleForm.sectorPlace,
- type_id: 2,
- }
- this.$store.dispatch('plate/getAllSectorPlace',data).then(res => {
- this.component_option = res.data
- this.component_option.forEach(item => {
- item.name = '位置'+item.sort_id+'('+item.width+'*'+item.height+')';
- })
- }).catch(() => {
- this.$message({
- type: 'error',
- message: '网络错误,请重试!'
- });
- })
- },
-
-
-
- //列表和分页相关 end ------------------------------------------------------------>
- // 验证关联组件(每一个位置必须至少有一个组件)
-
- checkComponent() {
- this.component = true
- if (this.ruleForm.component_code && Array.isArray(this.ruleForm.component_code)) {
- const component = '';
- this.ruleForm.component_code.forEach(component => {
- if (component.length == 0) {
- this.component = false,
-
- console.log('component', component);
- this.$message({
- message: '请关联组件!',
- type: 'error'
- })
- }
- });
-
- // return this.component;
- }
- return true;
- },
- //1.9 编辑
- goEdit(id, val) {
- // console.log(id)
- let data = {
- id: this.$route.query.id
- };
-
- this.$store.dispatch('plate/getSectorInfo', data).then(res => {
- console.log('res回显', this.typeList)
- this.ruleForm.sectorName = res.data.sector_name //通栏名称
- this.ruleForm.sectorId = res.data.sector_id //通栏编号id
- this.ruleForm.templateStyle = res.data.template_id //关联皮肤名称
- this.ruleForm.component_num = res.data.component_num //组件数量
- this.ruleForm.sizeList = res.data.sector_width + ' * ' + res.data.sector_height //通栏尺寸
- this.ruleForm.sectorType = parseInt(res.data.place_type) //通栏类别
-
- this.ruleForm.pageType = JSON.parse(res.data.page_type) // 通栏页面类型,根据符号|划分字符串为数组
- this.tags = JSON.parse(res.data.sector_keyword)
-
- this.ruleForm.plateCode = res.data.sector_code //通栏代码
- this.ruleForm.sectorKeyword = this.tags //通栏关键词
- this.ruleForm.image = res.data.sector_img //通栏展示图
- this.logoUrl = res.data.sector_img
- this.ruleForm.sector_img = res.data.place.sector_img
- this.sectorPlace_options = this.getPlaceList(res.data.component_num)
- this.ruleForm.sectorPlace = parseInt(res.data.place_type)
- this.getStyleSort(res.data.sectorPlace)
- // this.ruleForm.size_id = res.data.size_id;
- this.ruleForm.sector_width = res.data.sector_width
- this.ruleForm.sector_height = res.data.sector_height
- this.ruleForm.component_code = JSON.parse(res.data.component_code)
- console.log('回显表单', this.ruleForm)
- console.log('回显表单', this.tags)
- }).catch(() => {
- this.$message({
- type: 'error',
- message: '网络错误,请重试!'
- });
- })
- },
- //1.7 添加
- addPlate() {
- this.dialogTableVisible = true
- this.dialogName = "添加"
- this.name = "添加"
- this.name = this.dialogName
- //添加时清空回显回来的数据
- this.ruleForm.sectorName = '' //通栏名称
- this.ruleForm.sectorId = null //通栏编号id
- this.ruleForm.templateStyle = '' //关联皮肤名称
- this.ruleForm.sizeList = '' //通栏尺寸
- this.ruleForm.sectorType = null //通栏类别
- this.ruleForm.pageType = [] //通栏页面类型
- this.ruleForm.plateCode = '' //通栏代码
- this.ruleForm.sectorKeyword = '' //通栏关键词
- this.ruleForm.component_num = null //组件数量
- this.ruleForm.image = '' //通栏展示图
- this.ruleForm.sector_img = '' //通栏展示图
- // this.ruleForm.size_id = '' //通栏尺寸
- this.ruleForm.sectorPlace = '' //通栏版式编号
- this.logoUrl = ''
- this.ruleForm.image = ''
- this.tags = []
- this.ruleForm.component_code = []
- this.component_option = []
- this.ruleForm.sector_width = ''
- this.ruleForm.sector_height = ''
- // this.getPlaceList();
- this.selectedComponents = []
- this.activeBoxes = []
- },
- // 弹出层相关方法
- // 提交表单
- submitForm(formName) {
- console.log('this.ruleForm', this.dialogName)
- // this.name = this.dialogName
-
- console.log('this.ruleForm111', this.dialogName)
- console.log('this.ruleForm222', this.name)
- this.checkComponent()
- console.log('this.component', this.component)
- if (!this.component) {
- this.dialogName = ""
- return
- }else{
- this.dialogName = this.name
- }
- console.log('this.ruleForm121', this.dialogName)
- console.log('this.ruleForm242', this.name)
- if (this.dialogName == "添加") {
- const data = {
- sector_name: this.ruleForm.sectorName, //通栏名称
- sector_id: this.ruleForm.sectorId, //通栏编号
- template_id: this.ruleForm.templateStyle, //所属皮肤
- // size_id: this.ruleForm.size_id, //通栏尺寸
- sector_type: this.ruleForm.sectorType, //通栏类别
- sector_code: this.ruleForm.plateCode, //通栏代码
- page_type: this.ruleForm.pageType, //页面类型
- component_num: this.ruleForm.component_num, //组件数量
- sector_keyword: JSON.stringify(this.ruleForm.sectorKeyword), //通栏关键词
- sector_img: this.logoUrl, //通栏展示图
- place_type: this.ruleForm.sectorPlace, //通栏版式id
- component_code: JSON.stringify(this.ruleForm.component_code), //通栏所选组件
- sector_width: this.ruleForm.sector_width, //通栏宽度
- sector_height: this.ruleForm.sector_height, //通栏高度
- }
- console.log('添加表单--------data', data);
- this.$store.dispatch('plate/addSector',data).then(data => {
- if (data.code == 200) {
- this.$message({
- message: '添加成功',
- type: 'success'
- })
- this.$router.push({
- path: '/plate',
- });
- }else{
- this.$message({
- message: data.message,
- type: 'error'
- })
- }
- })
-
- }
- if (this.dialogName == "编辑") {
- const data = {
- id: this.$route.query.id,
- sector_name: this.ruleForm.sectorName, //通栏名称
- sector_id: this.ruleForm.sectorId, //通栏编号
- template_id: this.ruleForm.templateStyle, //所属皮肤
- // size_id: this.ruleForm.size_id, //通栏尺寸
- sector_type: this.ruleForm.sectorType, //通栏类别
- sector_code: this.ruleForm.plateCode, //通栏代码
- page_type: this.ruleForm.pageType, //页面类型
- component_num: this.ruleForm.component_num, //组件数量
- sector_keyword: JSON.stringify(this.ruleForm.sectorKeyword), //通栏关键词
- sector_img: this.ruleForm.image, //通栏展示图
- place_type: this.ruleForm.sectorPlace, //通栏版式id
- component_code: JSON.stringify(this.ruleForm.component_code), //通栏所选组件
- sector_width: this.ruleForm.sector_width, //通栏宽度
- sector_height: this.ruleForm.sector_height, //通栏高度
- }
- console.log('编辑表单---data', data);
- this.$store.dispatch('plate/updateSector', data).then(data => {
- if (data.code == 200) {
- this.$message({
- message: '编辑成功',
- type: 'success'
- })
- this.$router.push({
- path: '/plate',
- });
- }else{
- this.$message({
- message: data.message,
- type: 'error'
- })
- }
- })
- }
- },
- //取消添加或编辑
- cancelForm() {
- this.$router.push({
- path: '/plate',
- });
- },
- // 验证输入的数量
- validateCount() {
- // 确保是数字且在1-3范围内(因为输入框min为1,移除小于0的判断)
- let count = parseInt(this.component_num, 10);
- if (isNaN(count)) count = 1;
- if (count > 3) count = 3;
- this.component_num = count;
-
- // 初始化激活状态数组
- this.activeBoxes = Array(count).fill(false);
-
- // 初始化组件选择对象
- this.selectedComponents = {};
- for (let i = 0; i < count; i++) {
- this.selectedComponents[i] = [];
- }
- },
- // 切换方块激活状态
- toggleBox(index) {
- this.$set(this.activeBoxes,index, this.component_option[index])
- // this.activeBoxes[index] = this.component_option[index];
-
- // console.log('this.activeBoxes', this.activeBoxes);
- // console.log('this.selectedComponents', this.component_option);
- },
- //3.6 上传图片操作
- beforeAvatarUpload(file) {
- const isJPG = file.type === 'image/jpeg';
- const isPNG = file.type === 'image/png';
- const isLt2M = file.size / 1024 / 1024 < 2;
- if (!isJPG && !isPNG) {
- this.$message.error('上传图片只能是 JPG 或 PNG 格式!');
- return false;
- }
- if (!isLt2M) {
- this.$message.error('上传图片大小不能超过 2MB!');
- return false;
- }
- const formData = new FormData();
- formData.append('file', file);
- this.$store.dispatch('pool/uploadFile', formData).then(res => {
- this.logoUrl = res.data.imgUrl;//显示缩略图
- this.ruleForm.image = res.data.imgUrl;//提供表单地址
- console.log(res.data.imgUrl)
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '网络错误,请重试!'
- });
- })
- // 阻止默认的上传行为
- return false;
- },
- handleDelete() {
- // 删除图片
- this.logoUrl = ''; // 清空图片 URL
- },
- // 关键词标签
- updateTags(newTags) {
- // this.foem.seo_keywords = newTags;
-
- this.tags = newTags;
- this.ruleForm.sectorKeyword = newTags;
- },
-
- },
- mounted() {
- if(this.$route.query.id && this.$route.query.id != 0) {
- this.dialogName = '编辑',
- this.goEdit()
- }else{
- this.dialogName = '添加',
- this.addPlate()
- }
- // this.getData()
- this.getStyleList()
- this.getSkinList()
- },
- watch:{
- // 监听数量变化,重新初始化
- component_num(newVal) {
- this.validateCount();
- },
- 'ruleForm.component_num':{
- handler(oldVal,newVal){
- console.log('监听val',oldVal);
- console.log('监听newval',newVal);
- // 清空组件代码数组
- // handler(oldval){
- // 清空组件代码数组
- if (!(this.newVal !== null && this.dialogName == '编辑')) {
- this.component_option = [];
- this.ruleForm.component_code = [];
- this.ruleForm.sectorPlace = '';
- }
-
- },
- deep: true
- }
- }
-
- }
- </script>
- <style scoped lang="less">
- input[aria-hidden=true] {
- display: none !important;
- }
- // 提示信息
- .tips {
- margin: 30px;
- background-color: #e9ecf9;
- border-radius: 11px;
- .tipsIcon {
- margin: 10px 15px;
- display: inline-block;
- width: 24px;
- height: 24px;
- background: url("../../assets/advertise/Info Circle.png") no-repeat;
- vertical-align: middle;
- }
- .tipsText {
- font-size: 14px;
- color: #666666;
- }
- }
- // 头部
- .title {
- margin: 30px 30px 20px 30px;
- padding: 30px 30px 40px 30px;
- background-color: #fff;
- border-radius: 20px 20px 20px 20px;
- border: 1px solid #E9EDF7;
- .left {
- float: left;
- }
- .right {
- float: right;
- }
- .searchBox {
- ::v-deep .el-input {
- position: relative;
- font-size: 14px;
- display: inline-block;
- width: 80%;
- }
- .searchTitle {
- padding-bottom: 10px;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 14px;
- color: #999999;
- line-height: 16px;
- }
- .el-select {
- width: 100%;
- display: inline-block;
- position: relative;
- }
- }
- .btnList {
- float: right;
- padding-top: 28px;
- button {
- height: 38px;
- border: none;
- border-radius: 8px;
- padding: 0 30px;
- }
- .search {
- background-color: #5570f1;
- color: #fff;
- margin-right: 20px;
- }
- .reset {
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 16px;
- color: #333333;
- background: #F5F7FB;
- border-radius: 8px 8px 8px 8px;
- border: 1px solid rgba(85, 112, 241, 0.11);
- }
- }
- }
- .layerBox {
- padding: 30px 20px;
- position: relative;
- .btn {
- position: absolute;
- top: 30px;
- right: 20px;
- height: 38px;
- color: #fff;
- background-color: #5570f1;
- border: none;
- border-radius: 8px;
- padding: 8px 28px 9px;
- box-sizing: border-box;
- }
- .listBtnBox {
- justify-content: left;
- }
- .listDeleteBtn,
- .listEditBtn {
- margin-left: 0px;
- padding-left: 0px;
- margin-right: 20px;
- width: 76px;
- height: 36px;
- line-height: 36px;
- }
- ::v-deep .el-form-item {
- margin-bottom: 50px;
- }
- ::v-deep .el-select {
- width: 100%;
- }
- ::v-deep .el-input--medium,
- ::v-deep .el-form-item__label {
- line-height: 36px;
- font-size: 16px;
- }
- }
- /* 方块容器样式 */
- .boxes-container {
- margin-left: 170px;
- width:700px;
- height: 350px;
- margin-bottom: 25px;
- border: 1px dashed #d1d5db;
- border-radius: 6px;
- overflow: hidden;
- }
- /* 通用方块样式 */
- .box {
- display: flex;
- align-items: center;
- justify-content: center;
- color: white;
- font-weight: 600;
- cursor: pointer;
- transition: all 0.2s ease;
- }
- .box:hover {
- filter: brightness(1.1);
- }
- .box.active {
- background-color: #1e40af;
- box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
- }
- /* 数量=3的布局 */
- .layout-3 {
- display: flex;
- height: 100%; /* 固定高度确保左右等高 */
- gap: 10px;
- padding: 10px;
- }
- .layout-3-left {
- flex: 1.5;
- display: flex;
- flex-direction: column;
- gap: 10px;
- height: 100%;
- }
- .layout-3-right {
- flex: 1;
- height: 100%;
- }
- .layout-3-left .box {
- height: 50%; /* 左侧两个方块各占一半高度 */
- }
- .layout-3 .box {
- background-color: #3b82f6;
- border-radius: 6px;
- height: 100%;
- }
- .layout-3-1 .box{
- background-color: #3b82f6;
- border-radius: 6px;
- height: 100%;
- }
- .layout-3-1-left {
- flex: 3;
- height: 100%;
- }
- .layout-3-1-right {
- flex: 1;
- display: flex;
- flex-direction: column;
- gap: 10px;
- height: 100%;
- }
- .layout-3-1-right .box {
- height: 50%; /* 左侧两个方块各占一半高度 */
- }
- .layout-3-1-left .box {
- height: 100%; /* 左侧两个方块各占一半高度 */
- }
- .layout-3-1{
- display: flex;
- height: 100%; /* 固定高度确保左右等高 */
- gap: 10px;
- padding: 10px;
- }
- /* 数量=2的布局 */
- .layout-2 {
- display: flex;
- height: 100%;
- gap: 10px;
- padding: 10px;
- }
- .layout-2-left {
- flex: 5; /* 30%宽度 */
- height: 100%;
- }
- .layout-2-right {
- flex: 5; /* 70%宽度 */
- height: 100%;
- }
- .layout-2 .box {
- background-color: #3b82f6;
- border-radius: 6px;
- height: 100%;
- width: 100%;
- }
- /* 数量=1的布局 */
- .layout-1 {
- height: 100%;
- padding: 10px;
- }
- .layout-1 .box {
- background-color: #3b82f6;
- border-radius: 6px;
- height: 100%;
- width: 100%;
- }
- /* 输入框区域样式 */
- .input-fields {
- display: flex;
- flex-direction: column;
- gap: 15px;
- margin-top: 20px;
- }
- .field-item {
- display: flex;
- align-items: center;
- gap: 15px;
- padding: 12px;
- background-color: #f9fafb;
- border-radius: 6px;
- }
- .field-label {
- width: 120px;
- font-weight: 600;
- color: #374151;
- }
- .size-select {
- flex: 1;
- padding: 8px;
- border: 1px solid #d1d5db;
- border-radius: 4px;
- height: 100px;
- background-color: white;
- }
- .size-select option {
- padding: 4px 0;
- }
- // 弹出层内容
- .dialogText {
- margin: 0 7px 0 3px;
- padding-bottom: 1px;
- padding: 30px 60px 1px 20px;
- background-color: #f5f7fb;
- .adImage {
- width: 140px;
- height: 140px;
- line-height: 210px;
- border-radius: 12px;
- border: 1px solid rgba(85, 112, 241, 0.11);
- img {
- width: 140px;
- height: 80px;
- }
- }
- ::v-deep .avatar {
- width: 140px;
- height: auto;
- }
- .price {
- ::v-deep .el-input {
- width: 29%;
- }
- }
- .example {
- font-family: Microsoft YaHei;
- color: #5570F1;
- }
- .el_btnList {
- margin-right: 15px;
- margin-top: 20px;
- }
- //日期时间选择器的宽
- ::v-deep .el-date-editor.el-input {
- width: 48%;
- }
- ::v-deep .el-button+.el-button {
- margin-left: 0px;
- }
- ::v-deep .el-select {
- width: 100%;
- }
- ::v-deep .el-form-item {
- margin-bottom: 50px;
- }
- }
- // 弹出层按钮
- .dialogBtn {
- text-align: center;
- margin: 50px auto 20px;
- clear: both;
- button {
- width: 184px;
- padding: 16px;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 20px;
- border: none;
- border-radius: 12px 12px 12px 12px;
- }
- // 取消
- .cancel {
- color: #333333;
- background-color: #f5f7fb;
- border: 2px solid rgba(85, 112, 241, 0.11);
- }
- // 提交
- .submit {
- color: #fff;
- background-color: #5570F1;
- margin-left: 40px;
- }
- }
- //审核弹出框
- .radioGroup {
- ::v-deep .el-form-item {
- margin-top: 40px;
- margin-bottom: 0;
- }
- }
- .graph {
- background-color: #f5f7fb;
- padding: 60px 100px;
- overflow: hidden;
- li {
- float: left;
- }
- >li:first-child {
- margin-right: 100px;
- }
- }
- .dialog-footer {
- margin: 0 auto;
- }
- .rowMargin {
- margin-top: 20px;
- }
- .componentChoose{
- background-color: #f5f7fb;
- overflow: hidden;
- }
- .componentOptions{
- float: left;
- margin-right: 30px;
- width: 100%;
- }
- .componentOption_one{
- width: 100%;
- }
- </style>
|