plate.vue 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054
  1. <!-- 板块 -->
  2. <template>
  3. <div>
  4. <!-- 头部搜索框部分 -->
  5. <div class="title">
  6. <el-row>
  7. <el-col :span="6" class="left">
  8. <div class="searchBox">
  9. <div class="searchTitle">通栏名称</div>
  10. <el-input v-model="apiData.sector_name" clearable placeholder="请输入通栏名称"></el-input>
  11. </div>
  12. </el-col>
  13. <el-col :span="6" class="left">
  14. <div class="searchBox">
  15. <div class="searchTitle">模板风格</div>
  16. <el-select v-model="apiData.template_class_id" clearable placeholder="请选择模板风格" @change="getSkinList">
  17. <el-option v-for="item in class_options" :key="item.class_id" :label="item.name" :value="item.class_id">
  18. </el-option>
  19. </el-select>
  20. </div>
  21. </el-col>
  22. <el-col :span="6" class="left">
  23. <div class="searchBox">
  24. <div class="searchTitle">所属皮肤</div>
  25. <el-select v-model="apiData.template_id" clearable placeholder="请选择所属皮肤">
  26. <el-option v-for="item in template_options" :key="item.template_id" :label="item.template_name" :value="item.template_id">
  27. </el-option>
  28. </el-select>
  29. </div>
  30. </el-col>
  31. <el-col :span="6" class="right">
  32. <div class="btnList">
  33. <button class="search" @click="goSearch">搜索</button>
  34. <button class="reset" @click="goReset">重置</button>
  35. </div>
  36. </el-col>
  37. </el-row>
  38. <el-row class="rowMargin">
  39. <el-col :span="6" class="left">
  40. <div class="searchBox">
  41. <div class="searchTitle">尺寸</div>
  42. <div class="sizeBox">
  43. <div class="sizeInput"><el-input v-model="apiData.width" clearable placeholder="宽"></el-input> </div>
  44. <div class="sizeInputSymbol">*</div>
  45. <div class="sizeInput"><el-input v-model="apiData.height" clearable placeholder="高"></el-input></div>
  46. </div>
  47. </div>
  48. </el-col>
  49. </el-row>
  50. </div>
  51. <!--表格内容 start------------------------------------------------------------>
  52. <div class="layerBox">
  53. <tableTitle :name="tableDivTitle" />
  54. <button class="btn" @click="addPlate">添加通栏</button>
  55. <el-row>
  56. <template>
  57. <el-table class="my-table" :data="tableData" style="width: 100%" >
  58. <el-table-column fixed prop="sector_id" label="编号" width="90"></el-table-column>
  59. <el-table-column prop="sector_name" label="通栏名称" width=""></el-table-column>
  60. <el-table-column prop="sector_size" label="尺寸" width=""></el-table-column>
  61. <el-table-column prop="template_name" label="所属皮肤" width=""></el-table-column>
  62. <el-table-column prop="class_name" label="所属风格" width=""></el-table-column>
  63. <el-table-column prop="pagetype" label="所属页面" width="230">
  64. </el-table-column>
  65. <el-table-column prop="created_at" label="添加时间" width=""></el-table-column>
  66. <el-table-column prop="updated_at" label="修改时间" width=""></el-table-column>
  67. <el-table-column fixed="right" label="操作" width="200">
  68. <template slot-scope="scope">
  69. <div class="listBtnBox">
  70. <div class="listDeleteBtn" @click="deleteRow(scope.row.id)">
  71. <i class="el-icon-delete"></i>
  72. 删除
  73. </div>
  74. <div class="listEditBtn" @click="goEdit(scope.row.id, scope.row)">
  75. <i class="el-icon-edit-outline"></i>
  76. 编辑
  77. </div>
  78. </div>
  79. </template>
  80. </el-table-column>
  81. </el-table>
  82. </template>
  83. </el-row>
  84. </div>
  85. <!--分页 start------------------------------------------------------------>
  86. <div class="alignBox">
  87. <el-row>
  88. <el-col :span="24">
  89. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
  90. :current-page="page" :page-size="pageSize" layout="total, prev, pager, next, jumper"
  91. :total="total">
  92. </el-pagination>
  93. </el-col>
  94. </el-row>
  95. </div>
  96. <!--分页 end------------------------------------------------------------>
  97. <!--表格内容 end------------------------------------------------------------>
  98. <!-- 弹出框 编辑 start----------------------------------------------------------->
  99. <el-dialog :title="dialogName" :visible.sync="dialogTableVisible" width="50%" top="8vh" :close-on-click-modal="false">
  100. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
  101. <div class="dialogText">
  102. <el-form-item label="通栏名称:" prop="sectorName">
  103. <el-input v-model="ruleForm.sectorName" placeholder="输入通栏名称"></el-input>
  104. </el-form-item>
  105. <el-form-item label="通栏编号:" prop="sectorId">
  106. <el-input v-model.number="ruleForm.sectorId" placeholder="输入通栏编号" type="number" min="1"></el-input>
  107. </el-form-item>
  108. <el-form-item label="组件数量:" prop="component_num">
  109. <el-input v-model.number="ruleForm.component_num" placeholder="输入组件数量" type="number" min="1" @change="getPlaceList(ruleForm.component_num)">
  110. </el-input>
  111. </el-form-item>
  112. <el-form-item label="所属皮肤:" prop="templateStyle">
  113. <el-select v-model="ruleForm.templateStyle" placeholder="请选择所属皮肤"
  114. :disabled="this.dialogName === '编辑'" @change="changeTemplateStyle">
  115. <el-option v-for="item in template_options" :key="item.template_id"
  116. :label="item.template_name" :value="item.template_id">
  117. </el-option>
  118. </el-select>
  119. </el-form-item>
  120. <el-form-item label="皮肤id:" prop="templateStyle">
  121. <el-input v-model="ruleForm.templateStyle" placeholder="所属皮肤id"
  122. disabled></el-input>
  123. </el-form-item>
  124. <el-form-item label="尺寸:" prop="sizeList">
  125. <el-select v-model="ruleForm.sizeList" placeholder="请选择尺寸" @change="changeTemplateStyle">
  126. <el-option v-for="item in size_options" :key="item.id" :label="item.label" :value="item.id">{{item.label}}
  127. </el-option>
  128. </el-select>
  129. </el-form-item>
  130. <el-form-item label="通栏类别:" prop="sectorType">
  131. <el-select v-model="ruleForm.sectorType" placeholder="请选择所属页面" :disabled="this.dialogName === '编辑'">
  132. <!-- 通栏分类:1:资讯类:2:通栏广告类;3:混合类;4:搜索框类;5:导航类;6:头条类;7:轮播图类; -->
  133. <el-option :value="1" label="资讯类">资讯类</el-option>
  134. <el-option :value="2" label="广告类">广告类</el-option>
  135. <el-option :value="3" label="混合类">混合类</el-option>
  136. <el-option :value="4" label="搜索框类">搜索框类</el-option>
  137. <el-option :value="5" label="导航类">导航类</el-option>
  138. <el-option :value="6" label="通栏类">头条类</el-option>
  139. <el-option :value="7" label="通栏类">轮播图类</el-option>
  140. </el-select>
  141. </el-form-item>
  142. <el-form-item label="页面类型:" prop="pageType">
  143. <el-checkbox-group v-model="ruleForm.pageType" @change="changeCheckbox"
  144. :disabled="this.dialogName === '编辑'">
  145. <el-checkbox v-for="(item, index) in checkList" :key="index" :label="item.value">{{item.label}}</el-checkbox>
  146. </el-checkbox-group>
  147. </el-form-item>
  148. <el-form-item label="通栏模版类型:" prop="sectorPlace">
  149. <el-select v-model="ruleForm.sectorPlace" placeholder="请选择通栏模版类型" @change="changeTemplateStyle">
  150. <el-option v-for="item in sectorPlace_options" :key="item.type" :label="item.component_img" :value="item.type">{{item.component_img}}
  151. </el-option>
  152. </el-select>
  153. </el-form-item>
  154. <el-form-item label="通栏关键词:" prop="sectorKeyword" class="custom-align-right">
  155. <template #label>
  156. <span class="askBox">
  157. 通栏关键词:
  158. <el-tooltip class="item" effect="dark" content="皮肤关键词,如:黑色、卡通、英雄。" placement="top">
  159. <i class="el-icon-question"></i>
  160. </el-tooltip>
  161. </span>
  162. </template>
  163. <tagInput :initialTags="tags" @tags-updated="updateTags"></tagInput>
  164. </el-form-item>
  165. <el-form-item label="通栏缩略图:" prop="image" :label-width="formLabelWidth"
  166. :class="['custom-form-item']" class="custom-align-right">
  167. <div class="uploaderBox">
  168. <!--图片上传组件 start ------------------------------------------------------------>
  169. <div class="avatar-upload-container" @mouseenter="hovering = true"
  170. @mouseleave="hovering = false">
  171. <!-- 上传组件 -->
  172. <el-upload class="avatar-uploader" action="#" :show-file-list="false"
  173. :before-upload="beforeAvatarUpload">
  174. <!-- 预览图片 -->
  175. <img v-if="this.logoUrl" :src="this.logoUrl" class="avatar">
  176. <!-- 上传图标 -->
  177. <div v-else class="chooseImgDiv">
  178. <div>
  179. <img src="@/assets/public/upload/noImage.png">
  180. <div>选择图片</div>
  181. </div>
  182. </div>
  183. <input type="hidden" name="logo" v-model="ruleForm.image">
  184. </el-upload>
  185. <!-- 删除按钮,当鼠标悬浮时显示 -->
  186. <div v-if="hovering && logoUrl" class="delete-button" @click="handleDelete">
  187. <i class="el-icon-delete"></i>
  188. </div>
  189. </div>
  190. <!--图片上传组件 end ------------------------------------------------------------>
  191. </div>
  192. </el-form-item>
  193. </div>
  194. <div class="dialogBtn">
  195. <el-button type="info" @click="cancelForm">取消</el-button>
  196. <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
  197. </div>
  198. </el-form>
  199. </el-dialog>
  200. <!-- 弹出框 编辑 end----------------------------------------------------------->
  201. </div>
  202. </template>
  203. <script>
  204. //表格标题
  205. import tableTitle from './components/tableTitle.vue';
  206. import tagInput from '../../components/InputTag/index.vue';
  207. //引入公用样式
  208. import '@/styles/global.less';
  209. // import { getSectorList, addSector, delSector, updateSector, getSectorInfo } from '@/api/plate'
  210. // import { getTemplateClass } from '@/api/style'
  211. export default {
  212. components: {
  213. tableTitle,//表格标题-
  214. tagInput
  215. },
  216. data() {
  217. const validateEmpty = (rule, value, callback) => {
  218. if (value.length == 0) {
  219. callback(new Error('该项不能为空!'))
  220. } else {
  221. callback()
  222. }
  223. }
  224. const validateArray = (rule, value, callback) => {
  225. if (value.length == 0) {
  226. callback(new Error('该项不能为空!'))
  227. } else {
  228. callback()
  229. }
  230. }
  231. return {
  232. //1.1 初始化信息
  233. tableDivTitle: "通栏列表", //列表标题
  234. dialogTableVisible: false, //编辑弹框
  235. dialogName: '编辑', //编辑弹窗名称
  236. plateLoading: true, //表格内容加载中
  237. tableData: [],//表格数据
  238. class_options: [],//风格下拉列表
  239. template_options: [],//皮肤下拉列表
  240. size_options: [],//尺寸下拉列表
  241. sectorPlace_options: [],//通栏模版类型下拉列表
  242. tags: [],//标签数据
  243. // 1.2搜索框相关
  244. apiData:{
  245. pagetype: '',//页面类型
  246. template_class_id: '',//模板风格
  247. tempalte_id: '',//皮肤名称
  248. sector_name: '',//通栏名称
  249. width: '',//通栏宽度
  250. height: '',//通栏高度
  251. keyword: '',//通栏关键词
  252. },
  253. templateStyle: '',//风格
  254. plateName: '',
  255. pageType: '',//页面类型
  256. value: '',
  257. checkList: [
  258. {
  259. value: 1,
  260. label: '首页',
  261. },
  262. {
  263. value: 2,
  264. label: '分类页',
  265. },
  266. {
  267. value: 3,
  268. label: '列表页',
  269. },
  270. {
  271. value: 4,
  272. label: '详情页',
  273. },
  274. {
  275. value: 5,
  276. label: '搜索页',
  277. },
  278. {
  279. value: 6,
  280. label: '特殊列表页',
  281. },
  282. {
  283. value: 7,
  284. label: '特殊详情页',
  285. },
  286. ],
  287. //活动id
  288. activeid: "",
  289. newArr: [],
  290. // 1.3 分页相关
  291. page: 1,
  292. pageSize: 10,
  293. total: 0,
  294. formLabelWidth: '', //广告示例图相关
  295. //1.4 弹框相关数据
  296. ruleForm: {
  297. sectorName: '', //通栏名称
  298. sectorPlace: null, //通栏模版类型
  299. component_num: null, //组件数量
  300. sectorId: null, //通栏编号id
  301. templateStyle: '', //所属皮肤
  302. pageType: '', //页面类型
  303. sizeList: '', //尺寸
  304. sectorType: null, //通栏名称
  305. plateCode: '', //通栏代码
  306. pageType: [], //页面类型
  307. sectorKeyword: '', //通栏关键词
  308. image: '', //组件展示图
  309. },
  310. rules: {
  311. sectorName: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  312. component_num: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  313. sectorId: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  314. templateStyle: [{ required: true, trigger: 'blur', validator: validateEmpty }], //关联皮肤名称
  315. sizeList: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  316. // plateCode: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  317. sectorType: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  318. pageType: [{ required: true, trigger: 'blur', validator: validateArray }],
  319. sectorKeyword: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  320. image: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  321. },
  322. //1.5 弹窗中 上传logo图片
  323. logoUrl: '',
  324. hovering: false, // 鼠标悬浮状态 悬浮时显示删除
  325. }
  326. },
  327. methods: {
  328. //1.列表和分页相关 start ------------------------------------------------------------>
  329. //1.1 开始请求列表信息方法
  330. getData() {
  331. this.$store.dispatch('plate/getSectorList', { page: this.page, page_size: this.pageSize }).then(data => {
  332. this.tableData = data.data.data
  333. this.total = data.data.total
  334. console.log(typeof(data.data.data));
  335. for (let i = 0; i < data.data.data.length; i++) {
  336. const item = data.data.data[i];
  337. this.tableData[i].sector_size = item.width + ' * ' + item.height;
  338. let pageArray = JSON.parse(item.page_type);
  339. if (Array.isArray(pageArray)) {
  340. // item.tags = keywordArray;
  341. item.pagetype = pageArray.map(type => {
  342. const pageTypeMap = {
  343. 1: '首页',
  344. 2: '分类页',
  345. 3: '列表页',
  346. 4: '详情页',
  347. 5: '搜索页',
  348. 6: '特殊列表页',
  349. 7: '特殊详情页'
  350. };
  351. return pageTypeMap[type] || type;
  352. }).join(' | ');
  353. } else {
  354. item.pagetype = '';
  355. }
  356. }
  357. })
  358. },
  359. //获取风格列表
  360. getStyleList() {
  361. this.$store.dispatch('genre/getTemplateClass').then(res => {
  362. this.class_options = res.data
  363. // console.log(res.data);
  364. }).catch(() => {
  365. this.$message({
  366. type: 'error',
  367. message: '网络错误,请重试!'
  368. });
  369. })
  370. },
  371. //获取皮肤列表
  372. getSkinList() {
  373. let data = [];
  374. // console.log("5588888",this.apiData.template_class_id);
  375. if(this.apiData.template_class_id){
  376. let data = {
  377. templte_class_id: this.apiData.template_class_id,
  378. }
  379. }
  380. this.$store.dispatch('plate/getAllTemplate', data).then(res => {
  381. this.template_options = res.data
  382. console.log(res.data);
  383. }).catch(() => {
  384. this.$message({
  385. type: 'error',
  386. message: '网络错误,请重试!'
  387. });
  388. })
  389. },
  390. // 获取尺寸列表
  391. getSizeList() {
  392. this.$store.dispatch('plate/getAllSize').then(res => {
  393. this.size_options = res.data
  394. if(res.data){
  395. this.size_options.forEach(item => {
  396. item.label = item.width + ' * ' + item.height;
  397. })
  398. }
  399. console.log(res.data);
  400. }).catch(() => {
  401. this.$message({
  402. type: 'error',
  403. message: '网络错误,请重试!'
  404. });
  405. })
  406. },
  407. // 获取位置列表
  408. getPlaceList(sectorType) {
  409. // if( this.dialogName == '编辑' || this.dialogName == '添加'){
  410. let data = {
  411. sector_num : sectorType,
  412. }
  413. console.log("888888888888888888",data);
  414. this.$store.dispatch('plate/getSectorPlace',data).then(res => {
  415. this.sectorPlace_options = res.data
  416. console.log(res.data);
  417. }).catch(() => {
  418. this.$message({
  419. type: 'error',
  420. message: '网络错误,请重试!'
  421. });
  422. })
  423. // }
  424. },
  425. //1.2 删除内容
  426. deleteRow(id) {
  427. console.log(id);
  428. let data = new FormData()
  429. data.append('id', id)
  430. this.$confirm('注意:删除后,该条信息及其绑定关系全部删除', '是否确认删除该条信息?', {
  431. confirmButtonText: '确定',
  432. cancelButtonText: '取消',
  433. }).then(() => {
  434. console.log("当前删除:" + id)
  435. this.$store.dispatch('plate/delSector', {id:id}).then(res => {
  436. console.log(res);
  437. if (res.code = 200) {
  438. this.$message({
  439. message: '删除成功',
  440. type: 'success'
  441. })
  442. this.getData()
  443. } else if (res.code == 0) {
  444. this.$message({
  445. message: res.message,
  446. type: 'error'
  447. })
  448. }
  449. })
  450. }).catch(() => {
  451. this.$message({
  452. type: 'warning',
  453. message: '已取消删除'
  454. });
  455. });
  456. },
  457. //1.3 多选按钮发生变化
  458. changeCheckbox(val) {
  459. console.log(val);
  460. this.newArr = []
  461. val.forEach(item => {
  462. if (typeof item !== 'object' || !item.hasOwnProperty('__ob__')) {
  463. this.newArr.push(item);
  464. }
  465. });
  466. this.pageType = JSON.stringify(this.newArr);
  467. console.log(this.pageType);
  468. },
  469. changeTemplateStyle(val) {
  470. console.log('风格id', val);
  471. console.log(this.ruleForm.templateStyle);
  472. },
  473. //1.4 列表内容分页
  474. //直接跳转
  475. handleSizeChange(val) {
  476. this.page = val;
  477. this.getData();
  478. },
  479. //1.5 点击分页
  480. handleCurrentChange(val) {
  481. this.page = val;
  482. this.getData();
  483. },
  484. // 1.6 搜索按钮
  485. goSearch() {
  486. const data = {
  487. page: this.page,
  488. page_size: this.pageSize,
  489. sector_name: this.apiData.sector_name ?? '', //通栏名称
  490. template_class_id: this.apiData.template_class_id ?? null, //风格id
  491. template_id: this.apiData.template_id ?? null, //通栏id
  492. width: this.apiData.width ?? null, //通栏宽度
  493. height: this.apiData.height ?? null, //通栏高度
  494. keyword: this.apiData.keyword ?? '', //通栏关键词
  495. }
  496. this.$store.dispatch('plate/getSectorList',data ).then(data => {
  497. this.tableData = data.data.data
  498. this.total = data.data.total
  499. for (let i = 0; i < data.data.data.length; i++) {
  500. const item = data.data.data[i];
  501. this.tableData[i].sector_size = item.width + ' * ' + item.height;
  502. try {
  503. let pageArray = JSON.parse(item.pagetype);
  504. if (Array.isArray(pageArray)) {
  505. // item.tags = keywordArray;
  506. item.pagetype = pageArray.map(type => {
  507. const pageTypeMap = {
  508. '1': '首页',
  509. '2': '分类页',
  510. '3': '列表页',
  511. '4': '详情页',
  512. '5': '搜索页',
  513. '6': '特殊列表页',
  514. '7': '特殊详情页'
  515. };
  516. return pageTypeMap[type] || type;
  517. }).join(' | ');
  518. } else {
  519. item.pagetype = '';
  520. }
  521. } catch (error) {
  522. console.error('解析 keyword 失败:', error);
  523. }
  524. }
  525. })
  526. },
  527. //1.7 重置按钮
  528. goReset() {
  529. this.apiData.pagetype = '',//页面类型
  530. this.apiData.template_class_id= '',//模板风格
  531. this.apiData.template_id = '',//皮肤名称
  532. this.apiData.sector_name= '',//通栏名称
  533. this.apiData.width= '',//通栏宽度
  534. this.apiData.height= '',//通栏高度
  535. this.apiData.keyword= '',//通栏关键词
  536. this.page=1
  537. this.pageSize=10
  538. this.getData()
  539. },
  540. //列表和分页相关 end ------------------------------------------------------------>
  541. //1.9 编辑
  542. goEdit(id, val) {
  543. // console.log(id);
  544. this.dialogName = '编辑'
  545. this.activeid = id
  546. this.dialogTableVisible = true
  547. console.log(id, val);
  548. // console.log("状态", val.status);
  549. this.hovering = false
  550. //数据回显
  551. console.log("valbianji ",val);
  552. this.ruleForm.sectorName = val.sector_name; //通栏名称
  553. this.ruleForm.sectorId = val.sector_id; //通栏编号id
  554. this.ruleForm.templateStyle = val.template_id; //关联皮肤名称
  555. this.ruleForm.component_num = val.component_num; //组件数量
  556. this.ruleForm.sizeList = val.size_id; //通栏尺寸
  557. this.ruleForm.sectorType = val.place_type; //通栏类别
  558. this.ruleForm.pageType = JSON.parse(val.page_type); // 通栏页面类型,根据符号|划分字符串为数组
  559. this.ruleForm.sectorPlace = val.sector_place; //通栏模版类型
  560. this.tags = val.pagetype ? val.pagetype.split(' | ') : [];
  561. this.ruleForm.plateCode = val.sector_code; //通栏代码
  562. this.ruleForm.sectorKeyword = JSON.parse(val.sector_keyword); //通栏关键词
  563. this.ruleForm.image = val.sector_img; //通栏展示图
  564. this.logoUrl = val.sector_img;
  565. console.log("valruleForm ",this.ruleForm);
  566. },
  567. //1.7 添加
  568. addPlate() {
  569. this.dialogTableVisible = true
  570. this.dialogName = "添加"
  571. //添加时清空回显回来的数据
  572. this.ruleForm.sectorName = ''; //通栏名称
  573. this.ruleForm.sectorId = null; //通栏编号id
  574. this.ruleForm.templateStyle = ''; //关联皮肤名称
  575. this.ruleForm.sizeList = ''; //通栏尺寸
  576. this.ruleForm.sectorType = null; //通栏类别
  577. this.ruleForm.pageType = []; //通栏页面类型
  578. this.ruleForm.plateCode = ''; //通栏代码
  579. this.ruleForm.sectorKeyword = ''; //通栏关键词
  580. this.ruleForm.component_num = null; //组件数量
  581. this.ruleForm.image = ''; //通栏展示图
  582. // this.getPlaceList();
  583. },
  584. // 弹出层相关方法
  585. // 提交表单
  586. submitForm(formName) {
  587. if (this.dialogName == "添加") {
  588. const data = {
  589. sector_name: this.ruleForm.sectorName, //通栏名称
  590. sector_id: this.ruleForm.sectorId, //通栏编号
  591. template_id: this.ruleForm.templateStyle, //所属皮肤
  592. size_id: this.ruleForm.sizeList, //通栏尺寸
  593. sector_type: this.ruleForm.sectorType, //通栏类别
  594. sector_code: this.ruleForm.plateCode, //通栏代码
  595. page_type: this.ruleForm.pageType, //页面类型
  596. component_num: this.ruleForm.component_num, //组件数量
  597. sector_keyword: JSON.stringify(this.ruleForm.sectorKeyword), //通栏关键词
  598. sector_img: this.ruleForm.image, //通栏展示图
  599. }
  600. console.log("5555555555555",data);
  601. this.$store.dispatch('plate/addSector',data).then(data => {
  602. if (data.code == 200) {
  603. this.$message({
  604. message: '添加成功',
  605. type: 'success'
  606. })
  607. this.dialogTableVisible = false
  608. this.getData()
  609. }else{
  610. this.$message({
  611. message: data.message,
  612. type: 'error'
  613. })
  614. }
  615. })
  616. }
  617. if (this.dialogName == "编辑") {
  618. const data = {
  619. id: this.activeid,
  620. sector_name: this.ruleForm.sectorName, //通栏名称
  621. sector_id: this.ruleForm.sectorId, //通栏编号
  622. template_id: this.ruleForm.templateStyle, //所属皮肤
  623. size_id: this.ruleForm.sizeList, //通栏尺寸
  624. sector_type: this.ruleForm.sectorType, //通栏类别
  625. sector_code: this.ruleForm.plateCode, //通栏代码
  626. page_type: this.ruleForm.pageType, //页面类型
  627. component_num: this.ruleForm.component_num, //组件数量
  628. sector_keyword: JSON.stringify(this.ruleForm.sectorKeyword), //通栏关键词
  629. sector_img: this.ruleForm.image, //通栏展示图
  630. }
  631. console.log("data",data);
  632. this.$store.dispatch('plate/updateSector', data).then(data => {
  633. console.log(data);
  634. if (data.code == 200) {
  635. this.$message({
  636. message: '编辑成功',
  637. type: 'success'
  638. })
  639. this.dialogTableVisible = false
  640. this.getData()
  641. }else{
  642. this.$message({
  643. message: data.message,
  644. type: 'error'
  645. })
  646. }
  647. })
  648. }
  649. },
  650. //取消添加或编辑
  651. cancelForm() {
  652. this.dialogTableVisible = false
  653. },
  654. //3.6 上传图片操作
  655. beforeAvatarUpload(file) {
  656. const isJPG = file.type === 'image/jpeg';
  657. const isPNG = file.type === 'image/png';
  658. const isLt2M = file.size / 1024 / 1024 < 2;
  659. if (!isJPG && !isPNG) {
  660. this.$message.error('上传图片只能是 JPG 或 PNG 格式!');
  661. return false;
  662. }
  663. if (!isLt2M) {
  664. this.$message.error('上传图片大小不能超过 2MB!');
  665. return false;
  666. }
  667. const formData = new FormData();
  668. formData.append('file', file);
  669. this.$store.dispatch('pool/uploadFile', formData).then(res => {
  670. this.logoUrl = res.data.imgUrl;//显示缩略图
  671. this.ruleForm.image = res.data.imgUrl;//提供表单地址
  672. console.log(res.data.imgUrl)
  673. }).catch(() => {
  674. this.$message({
  675. type: 'info',
  676. message: '网络错误,请重试!'
  677. });
  678. })
  679. // 阻止默认的上传行为
  680. return false;
  681. },
  682. handleDelete() {
  683. // 删除图片
  684. this.logoUrl = ''; // 清空图片 URL
  685. },
  686. //
  687. getWebNavList(query) {
  688. if (query !== '') {
  689. this.webSiteLoading = true;
  690. let data = { keyword: query }
  691. let dataArr = [];
  692. this.$store.dispatch('pool/getNavWebList', data).then(res => {
  693. console.log(res.data)
  694. for (let item of res.data) {
  695. let data = {};
  696. data.key = item.id;
  697. data.value = item.id;
  698. data.label = item.website_name;
  699. dataArr.push(data)
  700. }
  701. this.webSiteList = dataArr;
  702. this.webSiteLoading = false;
  703. }).catch(() => {
  704. this.$message({
  705. type: 'info',
  706. message: '网络错误,请重试!'
  707. });
  708. })
  709. } else {
  710. this.navList = [];
  711. }
  712. },
  713. // 关键词标签
  714. updateTags(newTags) {
  715. // this.foem.seo_keywords = newTags;
  716. this.tags = newTags;
  717. this.ruleForm.sectorKeyword = newTags;
  718. },
  719. },
  720. mounted() {
  721. this.getData()
  722. this.getStyleList()
  723. this.getSkinList()
  724. this.getSizeList()
  725. // this.getPlaceList()
  726. },
  727. }
  728. </script>
  729. <style scoped lang="less">
  730. input[aria-hidden=true] {
  731. display: none !important;
  732. }
  733. // 提示信息
  734. .tips {
  735. margin: 30px;
  736. background-color: #e9ecf9;
  737. border-radius: 11px;
  738. .tipsIcon {
  739. margin: 10px 15px;
  740. display: inline-block;
  741. width: 24px;
  742. height: 24px;
  743. background: url("../../assets/advertise/Info Circle.png") no-repeat;
  744. vertical-align: middle;
  745. }
  746. .tipsText {
  747. font-size: 14px;
  748. color: #666666;
  749. }
  750. }
  751. // 头部
  752. .title {
  753. margin: 30px 30px 20px 30px;
  754. padding: 30px 30px 40px 30px;
  755. background-color: #fff;
  756. border-radius: 20px 20px 20px 20px;
  757. border: 1px solid #E9EDF7;
  758. .left {
  759. float: left;
  760. }
  761. .right {
  762. float: right;
  763. }
  764. .searchBox {
  765. ::v-deep .el-input {
  766. position: relative;
  767. font-size: 14px;
  768. display: inline-block;
  769. width: 80%;
  770. }
  771. .searchTitle {
  772. padding-bottom: 10px;
  773. font-family: Microsoft YaHei, Microsoft YaHei;
  774. font-weight: 400;
  775. font-size: 14px;
  776. color: #999999;
  777. line-height: 16px;
  778. }
  779. .el-select {
  780. width: 100%;
  781. display: inline-block;
  782. position: relative;
  783. }
  784. }
  785. .btnList {
  786. float: right;
  787. padding-top: 28px;
  788. button {
  789. height: 38px;
  790. border: none;
  791. border-radius: 8px;
  792. padding: 0 30px;
  793. }
  794. .search {
  795. background-color: #5570f1;
  796. color: #fff;
  797. margin-right: 20px;
  798. }
  799. .reset {
  800. font-family: Microsoft YaHei, Microsoft YaHei;
  801. font-weight: 400;
  802. font-size: 16px;
  803. color: #333333;
  804. background: #F5F7FB;
  805. border-radius: 8px 8px 8px 8px;
  806. border: 1px solid rgba(85, 112, 241, 0.11);
  807. }
  808. }
  809. }
  810. .layerBox {
  811. padding: 30px 20px;
  812. position: relative;
  813. .btn {
  814. position: absolute;
  815. top: 30px;
  816. right: 20px;
  817. height: 38px;
  818. color: #fff;
  819. background-color: #5570f1;
  820. border: none;
  821. border-radius: 8px;
  822. padding: 8px 28px 9px;
  823. box-sizing: border-box;
  824. }
  825. .listBtnBox {
  826. justify-content: left;
  827. }
  828. .listDeleteBtn,
  829. .listEditBtn {
  830. margin-left: 0px;
  831. padding-left: 0px;
  832. margin-right: 20px;
  833. width: 76px;
  834. height: 36px;
  835. line-height: 36px;
  836. }
  837. ::v-deep .el-form-item {
  838. margin-bottom: 50px;
  839. }
  840. ::v-deep .el-select {
  841. width: 100%;
  842. }
  843. ::v-deep .el-input--medium,
  844. ::v-deep .el-form-item__label {
  845. line-height: 36px;
  846. font-size: 16px;
  847. }
  848. }
  849. .sizeBox {
  850. display: flex;
  851. align-items: center;
  852. width: 80%;
  853. .sizeInputSymbol {
  854. width: 30px;
  855. display: flex;
  856. align-items: center;
  857. justify-content: center;
  858. }
  859. .sizeInput {
  860. width: 50%;
  861. ::v-deep .el-input {
  862. position: relative;
  863. font-size: 14px;
  864. display: inline-block;
  865. width: 100%;
  866. }
  867. }
  868. }
  869. // 弹出层内容
  870. .dialogText {
  871. margin: 0 7px 0 3px;
  872. padding-bottom: 1px;
  873. padding: 30px 60px 1px 20px;
  874. background-color: #f5f7fb;
  875. .adImage {
  876. width: 140px;
  877. height: 140px;
  878. line-height: 210px;
  879. border-radius: 12px;
  880. border: 1px solid rgba(85, 112, 241, 0.11);
  881. img {
  882. width: 140px;
  883. height: 80px;
  884. }
  885. }
  886. ::v-deep .avatar {
  887. width: 140px;
  888. height: auto;
  889. }
  890. .price {
  891. ::v-deep .el-input {
  892. width: 29%;
  893. }
  894. }
  895. .example {
  896. font-family: Microsoft YaHei;
  897. color: #5570F1;
  898. }
  899. .el_btnList {
  900. margin-right: 15px;
  901. margin-top: 20px;
  902. }
  903. //日期时间选择器的宽
  904. ::v-deep .el-date-editor.el-input {
  905. width: 48%;
  906. }
  907. ::v-deep .el-button+.el-button {
  908. margin-left: 0px;
  909. }
  910. ::v-deep .el-select {
  911. width: 100%;
  912. }
  913. ::v-deep .el-form-item {
  914. margin-bottom: 50px;
  915. }
  916. }
  917. // 弹出层按钮
  918. .dialogBtn {
  919. text-align: center;
  920. margin: 50px auto 20px;
  921. button {
  922. width: 184px;
  923. padding: 16px;
  924. font-family: Microsoft YaHei, Microsoft YaHei;
  925. font-weight: 400;
  926. font-size: 20px;
  927. border: none;
  928. border-radius: 12px 12px 12px 12px;
  929. }
  930. // 取消
  931. .cancel {
  932. color: #333333;
  933. background-color: #f5f7fb;
  934. border: 2px solid rgba(85, 112, 241, 0.11);
  935. }
  936. // 提交
  937. .submit {
  938. color: #fff;
  939. background-color: #5570F1;
  940. margin-left: 40px;
  941. }
  942. }
  943. //审核弹出框
  944. .radioGroup {
  945. ::v-deep .el-form-item {
  946. margin-top: 40px;
  947. margin-bottom: 0;
  948. }
  949. }
  950. .graph {
  951. background-color: #f5f7fb;
  952. padding: 60px 100px;
  953. overflow: hidden;
  954. li {
  955. float: left;
  956. }
  957. >li:first-child {
  958. margin-right: 100px;
  959. }
  960. }
  961. .dialog-footer {
  962. margin: 0 auto;
  963. }
  964. .rowMargin {
  965. margin-top: 20px;
  966. }
  967. </style>