style.vue 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265
  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-select v-model="templateStyle" clearable placeholder="请选择">
  11. <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id">
  12. </el-option>
  13. </el-select>
  14. </div>
  15. </el-col>
  16. <el-col :span="6" class="left">
  17. <div class="searchBox">
  18. <div class="searchTitle">模板名称</div>
  19. <el-input v-model="templateName" clearable placeholder="请输入模板名称"></el-input>
  20. </div>
  21. </el-col>
  22. <el-col :span="8" class="right">
  23. <div class="btnList">
  24. <button class="search" @click="goSearch">搜索</button>
  25. <button class="reset" @click="goReset">重置</button>
  26. </div>
  27. </el-col>
  28. </el-row>
  29. </div>
  30. <!--表格内容 start------------------------------------------------------------>
  31. <div class="layerBox">
  32. <tableTitle :name="tableDivTitle" />
  33. <button class="btn" @click="addWebsite">添加风格</button>
  34. <el-row>
  35. <template>
  36. <el-table class="my-table" :data="tableData" style="width: 100%" v-loading="templateLoading">
  37. <el-table-column fixed prop="id" label="编号" width="90">
  38. </el-table-column>
  39. <el-table-column prop="template_class_name" label="模板风格" width="">
  40. </el-table-column>
  41. <el-table-column prop="template_name" label="模板名称" width="">
  42. </el-table-column>
  43. <el-table-column prop="created_at" label="添加时间" width="">
  44. </el-table-column>
  45. <el-table-column prop="updated_at" label="修改时间" width="">
  46. </el-table-column>
  47. <el-table-column fixed="right" label="操作" width="200">
  48. <template slot-scope="scope">
  49. <div class="listBtnBox">
  50. <div class="listDeleteBtn" @click="deleteRow(scope.row.id)">
  51. <i class="el-icon-delete"></i>
  52. 删除
  53. </div>
  54. <div class="listEditBtn" @click="goEdit(scope.row.id, scope.row)">
  55. <i class="el-icon-edit-outline"></i>
  56. 编辑
  57. </div>
  58. </div>
  59. </template>
  60. </el-table-column>
  61. </el-table>
  62. </template>
  63. </el-row>
  64. </div>
  65. <!--分页 start------------------------------------------------------------>
  66. <div class="alignBox">
  67. <el-row>
  68. <el-col :span="24">
  69. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
  70. :current-page="page" :page-size="pageSize" layout="total, prev, pager, next, jumper"
  71. :total="total">
  72. </el-pagination>
  73. </el-col>
  74. </el-row>
  75. </div>
  76. <!--分页 end------------------------------------------------------------>
  77. <!--表格内容 end------------------------------------------------------------>
  78. <!-- 弹出框 编辑 start----------------------------------------------------------->
  79. <el-dialog :title="dialogName" :visible.sync="dialogTableVisible" width="50%" top="6vh"
  80. :close-on-click-modal="false">
  81. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
  82. <div class="dialogText">
  83. <el-form-item label="模板风格:" prop="templateStyle">
  84. <el-select v-model="ruleForm.templateStyle" placeholder="请选择模板风格">
  85. <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id">
  86. </el-option>
  87. </el-select>
  88. </el-form-item>
  89. <el-form-item label="模板名称:" prop="templateName">
  90. <el-input v-model="ruleForm.templateName" placeholder="请输入模板名称"></el-input>
  91. </el-form-item>
  92. <el-form-item label="风格图:" prop="templateImg" :label-width="formLabelWidth"
  93. :class="['custom-form-item']" class="custom-align-right">
  94. <div class="uploaderBox">
  95. <!--图片上传组件 start ------------------------------------------------------------>
  96. <div class="avatar-upload-container" @mouseenter="hovering = true"
  97. @mouseleave="hovering = false">
  98. <!-- 上传组件 -->
  99. <el-upload class="avatar-uploader" action="#" :show-file-list="false"
  100. :before-upload="beforeAvatarUpload_home">
  101. <!-- 预览图片 -->
  102. <img v-if="logoUrl_home" :src="logoUrl_home" class="avatar">
  103. <!-- 上传图标 -->
  104. <div v-else class="chooseImgDiv">
  105. <div>
  106. <img src="@/assets/public/upload/noImage.png">
  107. <div>选择图片</div>
  108. </div>
  109. </div>
  110. <input type="hidden" name="logo" v-model="homeImg">
  111. </el-upload>
  112. <!-- 删除按钮,当鼠标悬浮时显示 -->
  113. <div v-if="hovering && logoUrl_home" class="delete-button" @click="handleDelete_home">
  114. <i class="el-icon-delete"></i>
  115. </div>
  116. <h5>首页</h5>
  117. </div>
  118. <!--图片上传组件 end ------------------------------------------------------------>
  119. </div>
  120. <div class="uploaderBox">
  121. <!--图片上传组件 start ------------------------------------------------------------>
  122. <div class="avatar-upload-container" @mouseenter="hovering = true"
  123. @mouseleave="hovering = false">
  124. <!-- 上传组件 -->
  125. <el-upload class="avatar-uploader" action="#" :show-file-list="false"
  126. :before-upload="beforeAvatarUpload_classify">
  127. <!-- 预览图片 -->
  128. <img v-if="logoUrl_class" :src="logoUrl_class" class="avatar">
  129. <!-- 上传图标 -->
  130. <div v-else class="chooseImgDiv">
  131. <div>
  132. <img src="@/assets/public/upload/noImage.png">
  133. <div>选择图片</div>
  134. </div>
  135. </div>
  136. <input type="hidden" name="logo" v-model="classifyImg">
  137. </el-upload>
  138. <!-- 删除按钮,当鼠标悬浮时显示 -->
  139. <div v-if="hovering && logoUrl_class" class="delete-button" @click="handleDelete_class">
  140. <i class="el-icon-delete"></i>
  141. </div>
  142. <h5>分类页</h5>
  143. </div>
  144. <!--图片上传组件 end ------------------------------------------------------------>
  145. </div>
  146. <div class="uploaderBox">
  147. <!--图片上传组件 start ------------------------------------------------------------>
  148. <div class="avatar-upload-container" @mouseenter="hovering = true"
  149. @mouseleave="hovering = false">
  150. <!-- 上传组件 -->
  151. <el-upload class="avatar-uploader" action="#" :show-file-list="false"
  152. :before-upload="beforeAvatarUpload_list">
  153. <!-- 预览图片 -->
  154. <img v-if="logoUrl_list" :src="logoUrl_list" class="avatar">
  155. <!-- 上传图标 -->
  156. <div v-else class="chooseImgDiv">
  157. <div>
  158. <img src="@/assets/public/upload/noImage.png">
  159. <div>选择图片</div>
  160. </div>
  161. </div>
  162. <input type="hidden" name="logo" v-model="listImg">
  163. </el-upload>
  164. <!-- 删除按钮,当鼠标悬浮时显示 -->
  165. <div v-if="hovering && logoUrl_list" class="delete-button" @click="handleDelete_list">
  166. <i class="el-icon-delete"></i>
  167. </div>
  168. <h5>列表页</h5>
  169. </div>
  170. <!--图片上传组件 end ------------------------------------------------------------>
  171. </div>
  172. <div class="uploaderBox">
  173. <!--图片上传组件 start ------------------------------------------------------------>
  174. <div class="avatar-upload-container" @mouseenter="hovering = true"
  175. @mouseleave="hovering = false">
  176. <!-- 上传组件 -->
  177. <el-upload class="avatar-uploader" action="#" :show-file-list="false"
  178. :before-upload="beforeAvatarUpload_detail">
  179. <!-- 预览图片 -->
  180. <img v-if="logoUrl_detail" :src="logoUrl_detail" class="avatar">
  181. <!-- 上传图标 -->
  182. <div v-else class="chooseImgDiv">
  183. <div>
  184. <img src="@/assets/public/upload/noImage.png">
  185. <div>选择图片</div>
  186. </div>
  187. </div>
  188. <input type="hidden" name="logo" v-model="detailImg">
  189. </el-upload>
  190. <!-- 删除按钮,当鼠标悬浮时显示 -->
  191. <div v-if="hovering && logoUrl_detail" class="delete-button"
  192. @click="handleDelete_detail">
  193. <i class="el-icon-delete"></i>
  194. </div>
  195. <h5>详情页</h5>
  196. </div>
  197. <!--图片上传组件 end ------------------------------------------------------------>
  198. </div>
  199. <div class="uploaderBox">
  200. <!--图片上传组件 start ------------------------------------------------------------>
  201. <div class="avatar-upload-container" @mouseenter="hovering = true"
  202. @mouseleave="hovering = false">
  203. <!-- 上传组件 -->
  204. <el-upload class="avatar-uploader" action="#" :show-file-list="false"
  205. :before-upload="beforeAvatarUpload_search">
  206. <!-- 预览图片 -->
  207. <img v-if="logoUrl_search" :src="logoUrl_search" class="avatar">
  208. <!-- 上传图标 -->
  209. <div v-else class="chooseImgDiv">
  210. <div>
  211. <img src="@/assets/public/upload/noImage.png">
  212. <div>选择图片</div>
  213. </div>
  214. </div>
  215. <input type="hidden" name="logo" v-model="searchImg">
  216. </el-upload>
  217. <!-- 删除按钮,当鼠标悬浮时显示 -->
  218. <div v-if="hovering && logoUrl_search" class="delete-button"
  219. @click="handleDelete_search">
  220. <i class="el-icon-delete"></i>
  221. </div>
  222. <h5>搜索页</h5>
  223. </div>
  224. <!--图片上传组件 end ------------------------------------------------------------>
  225. </div>
  226. <div class="uploaderBox">
  227. <!--图片上传组件 start ------------------------------------------------------------>
  228. <div class="avatar-upload-container" @mouseenter="hovering = true"
  229. @mouseleave="hovering = false">
  230. <!-- 上传组件 -->
  231. <el-upload class="avatar-uploader" action="#" :show-file-list="false"
  232. :before-upload="beforeAvatarUpload_sList">
  233. <!-- 预览图片 -->
  234. <img v-if="logoUrl_sList" :src="logoUrl_sList" class="avatar">
  235. <!-- 上传图标 -->
  236. <div v-else class="chooseImgDiv">
  237. <div>
  238. <img src="@/assets/public/upload/noImage.png">
  239. <div>选择图片</div>
  240. </div>
  241. </div>
  242. <input type="hidden" name="logo" v-model="sListImg">
  243. </el-upload>
  244. <!-- 删除按钮,当鼠标悬浮时显示 -->
  245. <div v-if="hovering && logoUrl_sList" class="delete-button" @click="handleDelete_sList">
  246. <i class="el-icon-delete"></i>
  247. </div>
  248. <h5>特殊列表页</h5>
  249. </div>
  250. <!--图片上传组件 end ------------------------------------------------------------>
  251. </div>
  252. <div class="uploaderBox">
  253. <!--图片上传组件 start ------------------------------------------------------------>
  254. <div class="avatar-upload-container" @mouseenter="hovering = true"
  255. @mouseleave="hovering = false">
  256. <!-- 上传组件 -->
  257. <el-upload class="avatar-uploader" action="#" :show-file-list="false"
  258. :before-upload="beforeAvatarUpload_sDetail">
  259. <!-- 预览图片 -->
  260. <img v-if="logoUrl_sDetail" :src="logoUrl_sDetail" class="avatar">
  261. <!-- 上传图标 -->
  262. <div v-else class="chooseImgDiv">
  263. <div>
  264. <img src="@/assets/public/upload/noImage.png">
  265. <div>选择图片</div>
  266. </div>
  267. </div>
  268. <input type="hidden" name="logo" v-model="sDetailImg">
  269. </el-upload>
  270. <!-- 删除按钮,当鼠标悬浮时显示 -->
  271. <div v-if="hovering && logoUrl_sDetail" class="delete-button"
  272. @click="handleDelete_sDetail">
  273. <i class="el-icon-delete"></i>
  274. </div>
  275. <h5>特殊详情页</h5>
  276. </div>
  277. <!--图片上传组件 end ------------------------------------------------------------>
  278. </div>
  279. <!-- -->
  280. </el-form-item>
  281. </div>
  282. <div class="dialogBtn">
  283. <el-button type="info" @click="cancelForm">取消</el-button>
  284. <el-button type="primary" @click="submitForm">提交</el-button>
  285. </div>
  286. </el-form>
  287. </el-dialog>
  288. <!-- 弹出框 编辑 end----------------------------------------------------------->
  289. </div>
  290. </template>
  291. <script>
  292. //表格标题
  293. import tableTitle from './components/tableTitle.vue';
  294. //引入公用样式
  295. import '@/styles/global.less';
  296. import { getTemplateClass, getTemplateList, addTemplate, delTemplate, updateTemplate, getTemplateInfo } from '@/api/style'
  297. export default {
  298. components: {
  299. tableTitle,//表格标题-
  300. },
  301. data() {
  302. const validateEmpty = (rule, value, callback) => {
  303. if (value.length == 0) {
  304. callback(new Error('该项不能为空!'))
  305. } else {
  306. callback()
  307. }
  308. }
  309. return {
  310. // 1.1 初始化数据 ---------------------------------
  311. tableDivTitle: "模板列表", //列表标题
  312. dialogTableVisible: false, //编辑弹框
  313. dialogName: '编辑', //编辑弹窗名称
  314. templateLoading: true,//页面加载中
  315. tableData: [],//表格数据
  316. //1.2 搜索框相关 ----------------------------------
  317. templateStyle: '',//模板风格
  318. templateName: '',//模板名称
  319. // 1.3 分页相关 -----------------------------------
  320. page: 1,
  321. pageSize: 10,
  322. total: 0,
  323. //3.4 上传logo图片 --------------------------------
  324. // logoUrl: '',
  325. hovering: false, // 鼠标悬浮状态 悬浮时显示删除
  326. //首页图片
  327. homeImg: '',
  328. logoUrl_home: '',
  329. home_obj: {
  330. url: '',
  331. name: '首页',
  332. value: '1',
  333. },
  334. //分类页图片
  335. classifyImg: '',
  336. logoUrl_class: '',
  337. class_obj: {
  338. url: '',
  339. name: '分类页',
  340. value: '2',
  341. },
  342. //列表页图片
  343. listImg: '',
  344. logoUrl_list: '',
  345. list_obj: {
  346. url: '',
  347. name: '列表页',
  348. value: '3',
  349. },
  350. //详情页图片
  351. detailImg: '',
  352. logoUrl_detail: '',
  353. detail_obj: {
  354. url: '',
  355. name: '详情页',
  356. value: '4',
  357. },
  358. //搜索页图片
  359. searchImg: '',
  360. logoUrl_search: '',
  361. search_obj: {
  362. url: '',
  363. name: '搜索页',
  364. value: '5',
  365. },
  366. //特殊列表页图片
  367. sListImg: '',
  368. logoUrl_sList: '',
  369. sList_obj: {
  370. url: '',
  371. name: '特殊列表页',
  372. value: '6',
  373. },
  374. //特殊详情页图片
  375. sDetailImg: '',
  376. logoUrl_sDetail: '',
  377. sDetail_obj: {
  378. url: '',
  379. name: '特殊详情页',
  380. value: '7',
  381. },
  382. //图片json
  383. img_arr: [],
  384. value: '',
  385. options: [],
  386. //活动id
  387. activeid: "",
  388. formLabelWidth: '', //广告示例图相关
  389. // 弹框相关 -------------------------------------------
  390. ruleForm: {
  391. templateStyle: '', //模板风格
  392. templateName: '', //模板名称
  393. templateImg: [], //模板图片
  394. },
  395. rules: {
  396. templateStyle: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  397. templateName: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  398. templateImg: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  399. }
  400. }
  401. },
  402. methods: {
  403. //1.列表和分页相关 start ------------------------------------------------------------>
  404. //1.1 开始请求列表信息方法
  405. getData() {
  406. if(this.templateStyle != '' || this.templateName != ''){
  407. getTemplateList({
  408. page: this.page,
  409. page_size: this.pageSize,
  410. template_class_id: this.templateStyle, //模板风格id
  411. template_name: this.templateName, //模板名称
  412. }).then(data => {
  413. console.log(data);
  414. this.tableData = data.data.data
  415. this.total = data.data.total
  416. })
  417. }else{
  418. getTemplateList({
  419. page: this.page,
  420. page_size: this.pageSize
  421. }).then(data => {
  422. console.log(data);
  423. if (data.code == 200) {
  424. this.templateLoading = false
  425. }
  426. this.tableData = data.data.data
  427. this.total = data.data.total
  428. })
  429. }
  430. },
  431. //获取模板风格
  432. getStyleList() {
  433. getTemplateClass({
  434. page: this.page,
  435. page_size: this.pageSize
  436. }).then(data => {
  437. console.log('模板风格列表', data);
  438. this.options = data.data
  439. })
  440. },
  441. //1.2 删除内容
  442. deleteRow(id) {
  443. console.log(id);
  444. let data = new FormData()
  445. data.append('id', id)
  446. this.$confirm('注意:删除后,该条信息及其绑定关系全部删除', '是否确认删除该条信息?', {
  447. confirmButtonText: '确定',
  448. cancelButtonText: '取消',
  449. }).then(() => {
  450. console.log("当前删除:" + id)
  451. delTemplate({
  452. id: id
  453. }).then(data => {
  454. console.log(data);
  455. if (data.code = 200) {
  456. this.$message({
  457. message: '删除成功',
  458. type: 'success'
  459. })
  460. this.getData()
  461. } else if (data.code == 0) {
  462. this.$message({
  463. message: data.message,
  464. type: 'error'
  465. })
  466. }
  467. })
  468. }).catch(() => {
  469. this.$message({
  470. type: 'warning',
  471. message: '已取消删除'
  472. });
  473. });
  474. },
  475. //1.3 列表内容分页
  476. //直接跳转
  477. handleSizeChange(val) {
  478. this.page = val;
  479. this.getData();
  480. },
  481. //1.4 点击分页
  482. handleCurrentChange(val) {
  483. this.page = val;
  484. this.getData();
  485. },
  486. // 1.5 搜索按钮
  487. goSearch() {
  488. getTemplateList({
  489. page: this.page,
  490. page_size: this.pageSize,
  491. template_class_id: this.templateStyle, //模板风格id
  492. template_name: this.templateName, //模板名称
  493. }).then(data => {
  494. console.log(data);
  495. this.tableData = data.data.data
  496. this.total = data.data.total
  497. })
  498. },
  499. //1.6 重置按钮
  500. goReset() {
  501. this.templateStyle = ""
  502. this.templateName = ""
  503. this.page=1
  504. this.pageSize=10
  505. this.getData()
  506. },
  507. //列表和分页相关 end ------------------------------------------------------------>
  508. //1.7 编辑
  509. goEdit(id, val) {
  510. this.dialogName = '编辑'
  511. this.activeid = id
  512. this.dialogTableVisible = true
  513. console.log(id, val);
  514. //数据回显
  515. this.ruleForm.templateStyle = val.template_class_id
  516. this.ruleForm.templateName = val.template_name
  517. this.img_arr = JSON.parse(val.template_img)
  518. this.homeImg = ''
  519. this.logoUrl_home = ''
  520. this.classifyImg = ''
  521. this.logoUrl_class = ''
  522. this.listImg = ''
  523. this.logoUrl_list = ''
  524. this.detailImg = ''
  525. this.logoUrl_detail = ''
  526. this.searchImg = ''
  527. this.logoUrl_search = ''
  528. this.sListImg = ''
  529. this.logoUrl_sList = ''
  530. this.sDetailImg = ''
  531. this.logoUrl_sDetail = ''
  532. for (let item of this.img_arr) {
  533. if (item.name == '首页') {
  534. this.logoUrl_home = item.url
  535. this.homeImg = item.url
  536. }
  537. if (item.name == '分类页') {
  538. this.logoUrl_class = item.url
  539. this.classifyImg = item.url
  540. }
  541. if (item.name == '列表页') {
  542. this.logoUrl_list = item.url
  543. this.listImg = item.url
  544. }
  545. if (item.name == '详情页') {
  546. this.logoUrl_detail = item.url
  547. this.detailImg = item.url
  548. }
  549. if (item.name == '搜索页') {
  550. this.logoUrl_search = item.url
  551. this.searchImg = item.url
  552. }
  553. if (item.name == '特殊列表页') {
  554. this.logoUrl_sList = item.url
  555. this.sListImg = item.url
  556. }
  557. if (item.name == '特殊详情页') {
  558. this.logoUrl_sDetail = item.url
  559. this.sDetailImg = item.url
  560. }
  561. }
  562. },
  563. //1.8 添加
  564. addWebsite() {
  565. this.dialogTableVisible = true
  566. this.dialogName = "添加"
  567. //添加时清空回显回来的数据
  568. this.ruleForm.templateStyle = ''
  569. this.ruleForm.templateName = ''
  570. this.ruleForm.templateImg = []
  571. this.img_arr = []
  572. this.homeImg = ''
  573. this.logoUrl_home = ''
  574. this.classifyImg = ''
  575. this.logoUrl_class = ''
  576. this.listImg = ''
  577. this.logoUrl_list = ''
  578. this.detailImg = ''
  579. this.logoUrl_detail = ''
  580. this.searchImg = ''
  581. this.logoUrl_search = ''
  582. this.sListImg = ''
  583. this.logoUrl_sList = ''
  584. this.sDetailImg = ''
  585. this.logoUrl_sDetail = ''
  586. },
  587. // 弹出层相关方法 ---------------------------------------------------->
  588. // 1.9 提交表单
  589. submitForm() {
  590. this.img_arr = []
  591. //首页
  592. if (this.logoUrl_home) {
  593. this.home_obj.url = this.homeImg
  594. this.img_arr.push(this.home_obj)
  595. }
  596. //分类页
  597. if (this.logoUrl_class) {
  598. this.class_obj.url = this.classifyImg
  599. this.img_arr.push(this.class_obj)
  600. }
  601. //列表页
  602. if (this.logoUrl_list) {
  603. this.list_obj.url = this.listImg
  604. this.img_arr.push(this.list_obj)
  605. }
  606. //详情页
  607. if (this.logoUrl_detail) {
  608. this.detail_obj.url = this.detailImg
  609. this.img_arr.push(this.detail_obj)
  610. }
  611. //搜索页
  612. if (this.logoUrl_search) {
  613. this.search_obj.url = this.searchImg
  614. this.img_arr.push(this.search_obj)
  615. }
  616. //特殊列表页
  617. if (this.logoUrl_sList) {
  618. this.sList_obj.url = this.sListImg
  619. this.img_arr.push(this.sList_obj)
  620. }
  621. //特殊详情页
  622. if (this.logoUrl_sDetail) {
  623. this.sDetail_obj.url = this.sDetailImg
  624. this.img_arr.push(this.sDetail_obj)
  625. }
  626. function cleanObProp(arr) {
  627. return arr.map(item => {
  628. const newItem = {};
  629. for (const key in item) {
  630. if (key !== '__ob__') {
  631. newItem[key] = item[key];
  632. }
  633. }
  634. return newItem;
  635. });
  636. }
  637. const cleanArray = cleanObProp(this.img_arr);
  638. this.ruleForm.templateImg = JSON.stringify(cleanArray);
  639. console.log(this.ruleForm.templateImg);
  640. if (this.dialogName == "添加") {
  641. addTemplate({
  642. template_name: this.ruleForm.templateName, //模板名称
  643. template_img: this.ruleForm.templateImg, // 模板图片
  644. template_class_id: this.ruleForm.templateStyle, //模板风格id
  645. }).then(data => {
  646. console.log(data);
  647. if (data.code == 200) {
  648. this.$message({
  649. message: '添加成功',
  650. type: 'success'
  651. })
  652. this.dialogTableVisible = false
  653. this.getData()
  654. } else if (data.code == 0) {
  655. this.$message({
  656. message: data.message,
  657. type: 'error'
  658. })
  659. this.dialogTableVisible = true
  660. return
  661. } else {
  662. this.$message({
  663. message: data.message,
  664. type: 'error'
  665. })
  666. this.dialogTableVisible = true
  667. return
  668. }
  669. })
  670. }
  671. if (this.dialogName == "编辑") {
  672. updateTemplate({
  673. id: this.activeid, //活动id
  674. template_name: this.ruleForm.templateName, //模板名称
  675. template_img: this.ruleForm.templateImg, // 模板图片
  676. template_class_id: this.ruleForm.templateStyle, //模板风格id
  677. }).then(data => {
  678. console.log(data);
  679. if (data.code == 200) {
  680. this.$message({
  681. message: '编辑成功',
  682. type: 'success'
  683. })
  684. this.dialogTableVisible = false
  685. }
  686. if (data.code == 0) {
  687. this.$message({
  688. message: data.message,
  689. type: 'error'
  690. })
  691. this.dialogTableVisible = true
  692. }
  693. this.getData()
  694. })
  695. }
  696. },
  697. //取消添加或编辑
  698. cancelForm() {
  699. this.dialogTableVisible = false
  700. },
  701. //3.6 上传图片操作
  702. beforeAvatarUpload_home(file) {
  703. const isJPG = file.type === 'image/jpeg';
  704. const isPNG = file.type === 'image/png';
  705. const isLt2M = file.size / 1024 / 1024 < 2;
  706. if (!isJPG && !isPNG) {
  707. this.$message.error('上传图片只能是 JPG 或 PNG 格式!');
  708. return false;
  709. }
  710. if (!isLt2M) {
  711. this.$message.error('上传图片大小不能超过 2MB!');
  712. return false;
  713. }
  714. const formData = new FormData();
  715. formData.append('file', file);
  716. this.$store.dispatch('pool/uploadFile', formData).then(res => {
  717. this.logoUrl_home = res.data.imgUrl;//显示缩略图
  718. this.homeImg = res.data.imgUrl;//提供表单地址
  719. console.log(res.data.imgUrl)
  720. }).catch(() => {
  721. this.$message({
  722. type: 'info',
  723. message: '网络错误,请重试!'
  724. });
  725. })
  726. // 阻止默认的上传行为
  727. return false;
  728. },
  729. beforeAvatarUpload_classify(file) {
  730. const isJPG = file.type === 'image/jpeg';
  731. const isPNG = file.type === 'image/png';
  732. const isLt2M = file.size / 1024 / 1024 < 2;
  733. if (!isJPG && !isPNG) {
  734. this.$message.error('上传图片只能是 JPG 或 PNG 格式!');
  735. return false;
  736. }
  737. if (!isLt2M) {
  738. this.$message.error('上传图片大小不能超过 2MB!');
  739. return false;
  740. }
  741. const formData = new FormData();
  742. formData.append('file', file);
  743. this.$store.dispatch('pool/uploadFile', formData).then(res => {
  744. this.logoUrl_class = res.data.imgUrl;//显示缩略图
  745. this.classifyImg = res.data.imgUrl;//提供表单地址
  746. console.log(res.data.imgUrl)
  747. }).catch(() => {
  748. this.$message({
  749. type: 'info',
  750. message: '网络错误,请重试!'
  751. });
  752. })
  753. // 阻止默认的上传行为
  754. return false;
  755. },
  756. beforeAvatarUpload_list(file) {
  757. const isJPG = file.type === 'image/jpeg';
  758. const isPNG = file.type === 'image/png';
  759. const isLt2M = file.size / 1024 / 1024 < 2;
  760. if (!isJPG && !isPNG) {
  761. this.$message.error('上传图片只能是 JPG 或 PNG 格式!');
  762. return false;
  763. }
  764. if (!isLt2M) {
  765. this.$message.error('上传图片大小不能超过 2MB!');
  766. return false;
  767. }
  768. const formData = new FormData();
  769. formData.append('file', file);
  770. this.$store.dispatch('pool/uploadFile', formData).then(res => {
  771. this.logoUrl_list = res.data.imgUrl;//显示缩略图
  772. this.listImg = res.data.imgUrl;//提供表单地址
  773. console.log(res.data.imgUrl)
  774. }).catch(() => {
  775. this.$message({
  776. type: 'info',
  777. message: '网络错误,请重试!'
  778. });
  779. })
  780. // 阻止默认的上传行为
  781. return false;
  782. },
  783. beforeAvatarUpload_detail(file) {
  784. const isJPG = file.type === 'image/jpeg';
  785. const isPNG = file.type === 'image/png';
  786. const isLt2M = file.size / 1024 / 1024 < 2;
  787. if (!isJPG && !isPNG) {
  788. this.$message.error('上传图片只能是 JPG 或 PNG 格式!');
  789. return false;
  790. }
  791. if (!isLt2M) {
  792. this.$message.error('上传图片大小不能超过 2MB!');
  793. return false;
  794. }
  795. const formData = new FormData();
  796. formData.append('file', file);
  797. this.$store.dispatch('pool/uploadFile', formData).then(res => {
  798. this.logoUrl_detail = res.data.imgUrl;//显示缩略图
  799. this.detailImg = res.data.imgUrl;//提供表单地址
  800. console.log(res.data.imgUrl)
  801. }).catch(() => {
  802. this.$message({
  803. type: 'info',
  804. message: '网络错误,请重试!'
  805. });
  806. })
  807. // 阻止默认的上传行为
  808. return false;
  809. },
  810. beforeAvatarUpload_search(file) {
  811. const isJPG = file.type === 'image/jpeg';
  812. const isPNG = file.type === 'image/png';
  813. const isLt2M = file.size / 1024 / 1024 < 2;
  814. if (!isJPG && !isPNG) {
  815. this.$message.error('上传图片只能是 JPG 或 PNG 格式!');
  816. return false;
  817. }
  818. if (!isLt2M) {
  819. this.$message.error('上传图片大小不能超过 2MB!');
  820. return false;
  821. }
  822. const formData = new FormData();
  823. formData.append('file', file);
  824. this.$store.dispatch('pool/uploadFile', formData).then(res => {
  825. this.logoUrl_search = res.data.imgUrl;//显示缩略图
  826. this.searchImg = res.data.imgUrl;//提供表单地址
  827. console.log(res.data.imgUrl)
  828. }).catch(() => {
  829. this.$message({
  830. type: 'info',
  831. message: '网络错误,请重试!'
  832. });
  833. })
  834. // 阻止默认的上传行为
  835. return false;
  836. },
  837. beforeAvatarUpload_sList(file) {
  838. const isJPG = file.type === 'image/jpeg';
  839. const isPNG = file.type === 'image/png';
  840. const isLt2M = file.size / 1024 / 1024 < 2;
  841. if (!isJPG && !isPNG) {
  842. this.$message.error('上传图片只能是 JPG 或 PNG 格式!');
  843. return false;
  844. }
  845. if (!isLt2M) {
  846. this.$message.error('上传图片大小不能超过 2MB!');
  847. return false;
  848. }
  849. const formData = new FormData();
  850. formData.append('file', file);
  851. this.$store.dispatch('pool/uploadFile', formData).then(res => {
  852. this.logoUrl_sList = res.data.imgUrl;//显示缩略图
  853. this.sListImg = res.data.imgUrl;//提供表单地址
  854. console.log(res.data.imgUrl)
  855. }).catch(() => {
  856. this.$message({
  857. type: 'info',
  858. message: '网络错误,请重试!'
  859. });
  860. })
  861. // 阻止默认的上传行为
  862. return false;
  863. },
  864. beforeAvatarUpload_sDetail(file) {
  865. const isJPG = file.type === 'image/jpeg';
  866. const isPNG = file.type === 'image/png';
  867. const isLt2M = file.size / 1024 / 1024 < 2;
  868. if (!isJPG && !isPNG) {
  869. this.$message.error('上传图片只能是 JPG 或 PNG 格式!');
  870. return false;
  871. }
  872. if (!isLt2M) {
  873. this.$message.error('上传图片大小不能超过 2MB!');
  874. return false;
  875. }
  876. const formData = new FormData();
  877. formData.append('file', file);
  878. this.$store.dispatch('pool/uploadFile', formData).then(res => {
  879. this.logoUrl_sDetail = res.data.imgUrl;//显示缩略图
  880. this.sDetailImg = res.data.imgUrl;//提供表单地址
  881. console.log(res.data.imgUrl)
  882. }).catch(() => {
  883. this.$message({
  884. type: 'info',
  885. message: '网络错误,请重试!'
  886. });
  887. })
  888. // 阻止默认的上传行为
  889. return false;
  890. },
  891. handleDelete_home() {
  892. // 删除图片
  893. this.logoUrl_home = ''; // 清空图片 URL
  894. },
  895. handleDelete_class() {
  896. // 删除图片
  897. this.logoUrl_class = ''; // 清空图片 URL
  898. },
  899. handleDelete_list() {
  900. // 删除图片
  901. this.logoUrl_list = ''; // 清空图片 URL
  902. },
  903. handleDelete_detail() {
  904. // 删除图片
  905. this.logoUrl_detail = ''; // 清空图片 URL
  906. },
  907. handleDelete_search() {
  908. // 删除图片
  909. this.logoUrl_search = ''; // 清空图片 URL
  910. },
  911. handleDelete_sList() {
  912. // 删除图片
  913. this.logoUrl_sList = ''; // 清空图片 URL
  914. },
  915. handleDelete_sDetail() {
  916. // 删除图片
  917. this.logoUrl_sDetail = ''; // 清空图片 URL
  918. },
  919. // 3.7 弹出层相关方法 end ------------------------------------------------------------>
  920. },
  921. mounted() {
  922. this.getData()
  923. this.getStyleList() //获取模板风格
  924. },
  925. }
  926. </script>
  927. <style scoped lang="less">
  928. input[aria-hidden=true] {
  929. display: none !important;
  930. }
  931. // 提示信息
  932. .tips {
  933. margin: 30px;
  934. background-color: #e9ecf9;
  935. border-radius: 11px;
  936. .tipsIcon {
  937. margin: 10px 15px;
  938. display: inline-block;
  939. width: 24px;
  940. height: 24px;
  941. background: url("../../assets/advertise/Info Circle.png") no-repeat;
  942. vertical-align: middle;
  943. }
  944. .tipsText {
  945. font-size: 14px;
  946. color: #666666;
  947. }
  948. }
  949. // 头部
  950. .title {
  951. margin: 30px 30px 20px 30px;
  952. padding: 30px 30px 40px 30px;
  953. background-color: #fff;
  954. border-radius: 20px 20px 20px 20px;
  955. border: 1px solid #E9EDF7;
  956. .left {
  957. float: left;
  958. }
  959. .right {
  960. float: right;
  961. }
  962. .searchBox {
  963. ::v-deep .el-input {
  964. position: relative;
  965. font-size: 14px;
  966. display: inline-block;
  967. width: 80%;
  968. }
  969. .searchTitle {
  970. padding-bottom: 10px;
  971. font-family: Microsoft YaHei, Microsoft YaHei;
  972. font-weight: 400;
  973. font-size: 14px;
  974. color: #999999;
  975. line-height: 16px;
  976. }
  977. .el-select {
  978. width: 100%;
  979. display: inline-block;
  980. position: relative;
  981. }
  982. }
  983. .btnList {
  984. float: right;
  985. padding-top: 28px;
  986. button {
  987. height: 38px;
  988. border: none;
  989. border-radius: 8px;
  990. padding: 0 30px;
  991. }
  992. .search {
  993. background-color: #5570f1;
  994. color: #fff;
  995. margin-right: 20px;
  996. }
  997. .reset {
  998. font-family: Microsoft YaHei, Microsoft YaHei;
  999. font-weight: 400;
  1000. font-size: 16px;
  1001. color: #333333;
  1002. background: #F5F7FB;
  1003. border-radius: 8px 8px 8px 8px;
  1004. border: 1px solid rgba(85, 112, 241, 0.11);
  1005. }
  1006. }
  1007. }
  1008. .layerBox {
  1009. padding: 30px 20px;
  1010. position: relative;
  1011. .btn {
  1012. position: absolute;
  1013. top: 30px;
  1014. right: 20px;
  1015. height: 38px;
  1016. color: #fff;
  1017. background-color: #5570f1;
  1018. border: none;
  1019. border-radius: 8px;
  1020. padding: 8px 28px 9px;
  1021. box-sizing: border-box;
  1022. }
  1023. .listBtnBox {
  1024. justify-content: left;
  1025. }
  1026. .listDeleteBtn,
  1027. .listEditBtn {
  1028. margin-left: 0px;
  1029. padding-left: 0px;
  1030. margin-right: 20px;
  1031. width: 76px;
  1032. height: 36px;
  1033. line-height: 36px;
  1034. }
  1035. ::v-deep .el-form-item {
  1036. margin-bottom: 50px;
  1037. }
  1038. ::v-deep .el-select {
  1039. width: 100%;
  1040. }
  1041. ::v-deep .el-input--medium,
  1042. ::v-deep .el-form-item__label {
  1043. line-height: 36px;
  1044. font-size: 16px;
  1045. }
  1046. }
  1047. // 弹出层内容
  1048. .dialogText {
  1049. margin: 0 7px 0 3px;
  1050. padding-bottom: 1px;
  1051. padding: 30px 60px 1px 20px;
  1052. background-color: #f5f7fb;
  1053. .adImage {
  1054. width: 140px;
  1055. height: 140px;
  1056. line-height: 210px;
  1057. border-radius: 12px;
  1058. border: 1px solid rgba(85, 112, 241, 0.11);
  1059. img {
  1060. width: 140px;
  1061. height: 80px;
  1062. }
  1063. }
  1064. .uploaderBox,
  1065. .avatar-upload-container {
  1066. display: inline-block;
  1067. }
  1068. .avatar-uploader {
  1069. background-color: #fff;
  1070. }
  1071. .uploaderBox {
  1072. margin-right: 20px;
  1073. position: relative;
  1074. h5 {
  1075. text-align: center;
  1076. font-size: 14px;
  1077. font-weight: 400;
  1078. color: #999999;
  1079. margin-top: 0px;
  1080. }
  1081. }
  1082. ::v-deep .avatar {
  1083. width: 140px;
  1084. height: auto;
  1085. }
  1086. .price {
  1087. ::v-deep .el-input {
  1088. width: 29%;
  1089. }
  1090. }
  1091. .example {
  1092. font-family: Microsoft YaHei;
  1093. color: #5570F1;
  1094. }
  1095. .el_btnList {
  1096. margin-right: 15px;
  1097. margin-top: 20px;
  1098. }
  1099. //日期时间选择器的宽
  1100. ::v-deep .el-date-editor.el-input {
  1101. width: 48%;
  1102. }
  1103. ::v-deep .el-button+.el-button {
  1104. margin-left: 0px;
  1105. }
  1106. ::v-deep .el-select {
  1107. width: 100%;
  1108. }
  1109. ::v-deep .el-form-item {
  1110. margin-bottom: 50px;
  1111. }
  1112. }
  1113. // 弹出层按钮
  1114. .dialogBtn {
  1115. text-align: center;
  1116. margin: 50px auto 20px;
  1117. button {
  1118. width: 184px;
  1119. padding: 16px;
  1120. font-family: Microsoft YaHei, Microsoft YaHei;
  1121. font-weight: 400;
  1122. font-size: 20px;
  1123. border: none;
  1124. border-radius: 12px 12px 12px 12px;
  1125. }
  1126. // 取消
  1127. .cancel {
  1128. color: #333333;
  1129. background-color: #f5f7fb;
  1130. border: 2px solid rgba(85, 112, 241, 0.11);
  1131. }
  1132. // 提交
  1133. .submit {
  1134. color: #fff;
  1135. background-color: #5570F1;
  1136. margin-left: 40px;
  1137. }
  1138. }
  1139. //审核弹出框
  1140. .radioGroup {
  1141. ::v-deep .el-form-item {
  1142. margin-top: 40px;
  1143. margin-bottom: 0;
  1144. }
  1145. }
  1146. .graph {
  1147. background-color: #f5f7fb;
  1148. padding: 60px 100px;
  1149. overflow: hidden;
  1150. li {
  1151. float: left;
  1152. }
  1153. >li:first-child {
  1154. margin-right: 100px;
  1155. }
  1156. }
  1157. .dialog-footer {
  1158. margin: 0 auto;
  1159. }
  1160. </style>