plate.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  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="goLook">查看测试</button> -->
  55. <!-- <button class="btn" @click="addPlate">添加通栏</button> -->
  56. <button class="btn" @click="addPlatetest">添加通栏</button>
  57. <el-row>
  58. <template>
  59. <el-table class="my-table" :data="tableData" style="width: 100%" >
  60. <el-table-column fixed prop="sector_id" label="编号" width="90"></el-table-column>
  61. <el-table-column prop="sector_name" label="通栏名称" width=""></el-table-column>
  62. <el-table-column prop="sector_size" label="尺寸" width=""></el-table-column>
  63. <el-table-column prop="template_name" label="所属皮肤" width=""></el-table-column>
  64. <el-table-column prop="class_name" label="所属风格" width=""></el-table-column>
  65. <el-table-column prop="place_name" label="所属版式" width="230">
  66. </el-table-column>
  67. <el-table-column prop="pagetype" label="所属页面" width="230">
  68. </el-table-column>
  69. <el-table-column prop="created_at" label="添加时间" width=""></el-table-column>
  70. <el-table-column prop="updated_at" label="修改时间" width=""></el-table-column>
  71. <el-table-column fixed="right" label="操作" width="200">
  72. <template slot-scope="scope">
  73. <div class="listBtnBox">
  74. <div class="listDeleteBtn" @click="deleteRow(scope.row.id)">
  75. <i class="el-icon-delete"></i>
  76. 删除
  77. </div>
  78. <!-- <div class="listEditBtn" @click="goEdit(scope.row.id, scope.row)">
  79. <i class="el-icon-edit-outline"></i>
  80. 编辑
  81. </div> -->
  82. <div class="listEditBtn" @click="goEdittest(scope.row.id, scope.row)">
  83. <i class="el-icon-edit-outline"></i>
  84. 编辑
  85. </div>
  86. </div>
  87. </template>
  88. </el-table-column>
  89. </el-table>
  90. </template>
  91. </el-row>
  92. </div>
  93. <!--分页 start------------------------------------------------------------>
  94. <div class="alignBox">
  95. <el-row>
  96. <el-col :span="24">
  97. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
  98. :current-page="page" :page-size="pageSize" layout="total, prev, pager, next, jumper"
  99. :total="total">
  100. </el-pagination>
  101. </el-col>
  102. </el-row>
  103. </div>
  104. <!--分页 end------------------------------------------------------------>
  105. <!--表格内容 end------------------------------------------------------------>
  106. <!-- 弹出框 编辑 end----------------------------------------------------------->
  107. </div>
  108. </template>
  109. <script>
  110. //表格标题
  111. import tableTitle from './components/tableTitle.vue';
  112. import tagInput from '../../components/InputTag/index.vue';
  113. //引入公用样式
  114. import '@/styles/global.less';
  115. // import { getSectorList, addSector, delSector, updateSector, getSectorInfo } from '@/api/plate'
  116. // import { getTemplateClass } from '@/api/style'
  117. export default {
  118. components: {
  119. tableTitle,//表格标题-
  120. tagInput
  121. },
  122. data() {
  123. const validateEmpty = (rule, value, callback) => {
  124. if (value.length == 0) {
  125. callback(new Error('该项不能为空!'))
  126. } else {
  127. callback()
  128. }
  129. }
  130. const validateArray = (rule, value, callback) => {
  131. if (value.length == 0) {
  132. callback(new Error('该项不能为空!'))
  133. } else {
  134. callback()
  135. }
  136. }
  137. return {
  138. //1.1 初始化信息
  139. tableDivTitle: "通栏列表", //列表标题
  140. dialogTableVisible: false, //编辑弹框
  141. dialogName: '编辑', //编辑弹窗名称
  142. plateLoading: true, //表格内容加载中
  143. tableData: [],//表格数据
  144. class_options: [],//风格下拉列表
  145. template_options: [],//皮肤下拉列表
  146. // componen_code: [],//组件版式及组件下拉列表
  147. sectorPlace_options: [],//通栏模版类型下拉列表
  148. component_option: [],
  149. tags: [],//标签数据
  150. // 1.2搜索框相关
  151. apiData:{
  152. pagetype: '',//页面类型
  153. template_class_id: '',//模板风格
  154. tempalte_id: '',//皮肤名称
  155. sector_name: '',//通栏名称
  156. width: '',//通栏宽度
  157. height: '',//通栏高度
  158. keyword: '',//通栏关键词
  159. },
  160. templateStyle: '',//风格
  161. plateName: '',
  162. pageType: '',//页面类型
  163. value: '',
  164. checkList: [
  165. {
  166. value: 1,
  167. label: '首页',
  168. },
  169. {
  170. value: 2,
  171. label: '分类页',
  172. },
  173. {
  174. value: 3,
  175. label: '列表页',
  176. },
  177. {
  178. value: 4,
  179. label: '详情页',
  180. },
  181. {
  182. value: 5,
  183. label: '搜索页',
  184. },
  185. {
  186. value: 6,
  187. label: '特殊列表页',
  188. },
  189. {
  190. value: 7,
  191. label: '特殊详情页',
  192. },
  193. ],
  194. //活动id
  195. activeid: "",
  196. newArr: [],
  197. // 1.3 分页相关
  198. page: 1,
  199. pageSize: 10,
  200. total: 0,
  201. formLabelWidth: '', //广告示例图相关
  202. //1.4 弹框相关数据
  203. ruleForm: {
  204. sectorName: '', //通栏名称
  205. sectorPlace: null, //通栏模版类型
  206. component_num: null, //组件数量
  207. sectorId: null, //通栏编号id
  208. templateStyle: '', //所属皮肤
  209. pageType: '', //页面类型
  210. sizeList: '', //尺寸
  211. sectorType: null, //通栏类别
  212. pageType: [], //页面类型
  213. sectorKeyword: '', //通栏关键词
  214. image: '', //通栏展示图
  215. sector_img:'', //通栏版式预览图
  216. component_code: [], //所选择位置的组件
  217. sector_width:'',
  218. sector_height:'',
  219. },
  220. rules: {
  221. sectorName: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  222. component_num: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  223. sectorId: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  224. templateStyle: [{ required: true, trigger: 'blur', validator: validateEmpty }], //关联皮肤名称
  225. sectorType: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  226. pageType: [{ required: true, trigger: 'blur', validator: validateArray }],
  227. image: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  228. sectorPlace: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  229. },
  230. //1.5 弹窗中 上传logo图片
  231. logoUrl: '',
  232. hovering: false, // 鼠标悬浮状态 悬浮时显示删除
  233. }
  234. },
  235. methods: {
  236. //1.列表和分页相关 start ------------------------------------------------------------>
  237. //1.1 开始请求列表信息方法
  238. getData() {
  239. const data = {
  240. page: this.page,
  241. page_size: this.pageSize,
  242. sector_name: this.apiData.sector_name ?? '', //通栏名称
  243. template_class_id: this.apiData.template_class_id ?? null, //风格id
  244. template_id: this.apiData.template_id ?? null, //通栏id
  245. width: this.apiData.width ?? null, //通栏宽度
  246. height: this.apiData.height ?? null, //通栏高度
  247. keyword: this.apiData.keyword ?? '', //通栏关键词
  248. }
  249. this.$store.dispatch('plate/getSectorList', data).then(data => {
  250. this.tableData = data.data.data
  251. this.total = data.data.total
  252. console.log("typeof(,",data.data.data);
  253. for (let i = 0; i < data.data.data.length; i++) {
  254. const item = data.data.data[i];
  255. this.tableData[i].sector_size = item.sector_width + ' * ' + item.sector_height;
  256. let pageArray = JSON.parse(item.page_type);
  257. if (Array.isArray(pageArray)) {
  258. // item.tags = keywordArray;
  259. item.pagetype = pageArray.map(type => {
  260. const pageTypeMap = {
  261. 1: '首页',
  262. 2: '分类页',
  263. 3: '列表页',
  264. 4: '详情页',
  265. 5: '搜索页',
  266. 6: '特殊列表页',
  267. 7: '特殊详情页'
  268. };
  269. return pageTypeMap[type] || type;
  270. }).join(' | ');
  271. } else {
  272. item.pagetype = '';
  273. }
  274. }
  275. })
  276. },
  277. // // 获取版式列表
  278. // getPlaceList(sectorType) {
  279. // let data = {
  280. // component_num : this.ruleForm.component_num,
  281. // type_id: 1,
  282. // }
  283. // this.$store.dispatch('plate/getAllSectorPlace',data).then(res => {
  284. // this.sectorPlace_options = res.data
  285. // }).catch(() => {
  286. // this.$message({
  287. // type: 'error',
  288. // message: '网络错误,请重试!'
  289. // });
  290. // })
  291. // },
  292. //获取风格列表
  293. getStyleList() {
  294. this.$store.dispatch('genre/getTemplateClass').then(res => {
  295. this.class_options = res.data
  296. // console.log(res.data);
  297. }).catch(() => {
  298. this.$message({
  299. type: 'error',
  300. message: '网络错误,请重试!'
  301. });
  302. })
  303. },
  304. //获取皮肤列表
  305. getSkinList() {
  306. let data = [];
  307. // console.log("5588888",this.apiData.template_class_id);
  308. if(this.apiData.template_class_id){
  309. let data = {
  310. templte_class_id: this.apiData.template_class_id,
  311. }
  312. }
  313. this.$store.dispatch('plate/getAllTemplate', data).then(res => {
  314. this.template_options = res.data
  315. console.log(res.data);
  316. }).catch(() => {
  317. this.$message({
  318. type: 'error',
  319. message: '网络错误,请重试!'
  320. });
  321. })
  322. },
  323. //1.2 删除内容
  324. deleteRow(id) {
  325. console.log(id);
  326. let data = new FormData()
  327. data.append('id', id)
  328. this.$confirm('注意:删除后,该条信息及其绑定关系全部删除', '是否确认删除该条信息?', {
  329. confirmButtonText: '确定',
  330. cancelButtonText: '取消',
  331. }).then(() => {
  332. console.log("当前删除:" + id)
  333. this.$store.dispatch('plate/delSector', {id:id}).then(res => {
  334. console.log(res);
  335. if (res.code = 200) {
  336. this.$message({
  337. message: '删除成功',
  338. type: 'success'
  339. })
  340. this.getData()
  341. } else if (res.code == 0) {
  342. this.$message({
  343. message: res.message,
  344. type: 'error'
  345. })
  346. }
  347. })
  348. }).catch(() => {
  349. this.$message({
  350. type: 'warning',
  351. message: '已取消删除'
  352. });
  353. });
  354. },
  355. goEdittest(id, val) {
  356. let data = {
  357. id: id
  358. }
  359. this.$router.push({
  360. path: '/plateDetail',
  361. query: data
  362. });
  363. },
  364. // 1.6 搜索按钮
  365. goSearch() {
  366. const data = {
  367. page: this.page,
  368. page_size: this.pageSize,
  369. sector_name: this.apiData.sector_name ?? '', //通栏名称
  370. template_class_id: this.apiData.template_class_id ?? null, //风格id
  371. template_id: this.apiData.template_id ?? null, //通栏id
  372. width: this.apiData.width ?? null, //通栏宽度
  373. height: this.apiData.height ?? null, //通栏高度
  374. keyword: this.apiData.keyword ?? '', //通栏关键词
  375. }
  376. this.$store.dispatch('plate/getSectorList',data ).then(data => {
  377. this.tableData = data.data.data
  378. this.total = data.data.total
  379. for (let i = 0; i < data.data.data.length; i++) {
  380. const item = data.data.data[i];
  381. this.tableData[i].sector_size = item.sector_width + ' * ' + item.sector_height;
  382. let pageArray = JSON.parse(item.page_type);
  383. if (Array.isArray(pageArray)) {
  384. // item.tags = keywordArray;
  385. item.pagetype = pageArray.map(type => {
  386. const pageTypeMap = {
  387. 1: '首页',
  388. 2: '分类页',
  389. 3: '列表页',
  390. 4: '详情页',
  391. 5: '搜索页',
  392. 6: '特殊列表页',
  393. 7: '特殊详情页'
  394. };
  395. return pageTypeMap[type] || type;
  396. }).join(' | ');
  397. } else {
  398. item.pagetype = '';
  399. }
  400. }
  401. })
  402. },
  403. //1.7 重置按钮
  404. goReset() {
  405. this.apiData.pagetype = '',//页面类型
  406. this.apiData.template_class_id= '',//模板风格
  407. this.apiData.template_id = '',//皮肤名称
  408. this.apiData.sector_name= '',//通栏名称
  409. this.apiData.width= '',//通栏宽度
  410. this.apiData.height= '',//通栏高度
  411. this.apiData.keyword= '',//通栏关键词
  412. this.page=1
  413. this.pageSize=10
  414. this.getData()
  415. },
  416. //直接跳转
  417. handleSizeChange(val) {
  418. this.page = val;
  419. this.getData();
  420. },
  421. //1.5 点击分页
  422. handleCurrentChange(val) {
  423. this.page = val;
  424. this.getData();
  425. },
  426. //列表和分页相关 end ------------------------------------------------------------>
  427. //1.10 添加通栏测试
  428. addPlatetest() {
  429. this.$router.push({
  430. path: '/plateDetail',
  431. });
  432. },
  433. },
  434. mounted() {
  435. this.getData()
  436. this.getStyleList()
  437. this.getSkinList()
  438. // this.getPlaceList()
  439. },
  440. }
  441. </script>
  442. <style scoped lang="less">
  443. input[aria-hidden=true] {
  444. display: none !important;
  445. }
  446. // 提示信息
  447. .tips {
  448. margin: 30px;
  449. background-color: #e9ecf9;
  450. border-radius: 11px;
  451. .tipsIcon {
  452. margin: 10px 15px;
  453. display: inline-block;
  454. width: 24px;
  455. height: 24px;
  456. background: url("../../assets/advertise/Info Circle.png") no-repeat;
  457. vertical-align: middle;
  458. }
  459. .tipsText {
  460. font-size: 14px;
  461. color: #666666;
  462. }
  463. }
  464. // 头部
  465. .title {
  466. margin: 30px 30px 20px 30px;
  467. padding: 30px 30px 40px 30px;
  468. background-color: #fff;
  469. border-radius: 20px 20px 20px 20px;
  470. border: 1px solid #E9EDF7;
  471. .left {
  472. float: left;
  473. }
  474. .right {
  475. float: right;
  476. }
  477. .searchBox {
  478. ::v-deep .el-input {
  479. position: relative;
  480. font-size: 14px;
  481. display: inline-block;
  482. width: 80%;
  483. }
  484. .searchTitle {
  485. padding-bottom: 10px;
  486. font-family: Microsoft YaHei, Microsoft YaHei;
  487. font-weight: 400;
  488. font-size: 14px;
  489. color: #999999;
  490. line-height: 16px;
  491. }
  492. .el-select {
  493. width: 100%;
  494. display: inline-block;
  495. position: relative;
  496. }
  497. }
  498. .btnList {
  499. float: right;
  500. padding-top: 28px;
  501. button {
  502. height: 38px;
  503. border: none;
  504. border-radius: 8px;
  505. padding: 0 30px;
  506. }
  507. .search {
  508. background-color: #5570f1;
  509. color: #fff;
  510. margin-right: 20px;
  511. }
  512. .reset {
  513. font-family: Microsoft YaHei, Microsoft YaHei;
  514. font-weight: 400;
  515. font-size: 16px;
  516. color: #333333;
  517. background: #F5F7FB;
  518. border-radius: 8px 8px 8px 8px;
  519. border: 1px solid rgba(85, 112, 241, 0.11);
  520. }
  521. }
  522. }
  523. .layerBox {
  524. padding: 30px 20px;
  525. position: relative;
  526. .btn {
  527. position: absolute;
  528. top: 30px;
  529. right: 20px;
  530. height: 38px;
  531. color: #fff;
  532. background-color: #5570f1;
  533. border: none;
  534. border-radius: 8px;
  535. padding: 8px 28px 9px;
  536. box-sizing: border-box;
  537. }
  538. .listBtnBox {
  539. justify-content: left;
  540. }
  541. .listDeleteBtn,
  542. .listEditBtn {
  543. margin-left: 0px;
  544. padding-left: 0px;
  545. margin-right: 20px;
  546. width: 76px;
  547. height: 36px;
  548. line-height: 36px;
  549. }
  550. ::v-deep .el-form-item {
  551. margin-bottom: 50px;
  552. }
  553. ::v-deep .el-select {
  554. width: 100%;
  555. }
  556. ::v-deep .el-input--medium,
  557. ::v-deep .el-form-item__label {
  558. line-height: 36px;
  559. font-size: 16px;
  560. }
  561. }
  562. .sizeBox {
  563. display: flex;
  564. align-items: center;
  565. width: 80%;
  566. .sizeInputSymbol {
  567. width: 30px;
  568. display: flex;
  569. align-items: center;
  570. justify-content: center;
  571. }
  572. .sizeInput {
  573. width: 50%;
  574. ::v-deep .el-input {
  575. position: relative;
  576. font-size: 14px;
  577. display: inline-block;
  578. width: 100%;
  579. }
  580. }
  581. }
  582. // 弹出层内容
  583. .dialogText {
  584. margin: 0 7px 0 3px;
  585. padding-bottom: 1px;
  586. padding: 30px 60px 1px 20px;
  587. background-color: #f5f7fb;
  588. .adImage {
  589. width: 140px;
  590. height: 140px;
  591. line-height: 210px;
  592. border-radius: 12px;
  593. border: 1px solid rgba(85, 112, 241, 0.11);
  594. img {
  595. width: 140px;
  596. height: 80px;
  597. }
  598. }
  599. ::v-deep .avatar {
  600. width: 140px;
  601. height: auto;
  602. }
  603. .price {
  604. ::v-deep .el-input {
  605. width: 29%;
  606. }
  607. }
  608. .example {
  609. font-family: Microsoft YaHei;
  610. color: #5570F1;
  611. }
  612. .el_btnList {
  613. margin-right: 15px;
  614. margin-top: 20px;
  615. }
  616. //日期时间选择器的宽
  617. ::v-deep .el-date-editor.el-input {
  618. width: 48%;
  619. }
  620. ::v-deep .el-button+.el-button {
  621. margin-left: 0px;
  622. }
  623. ::v-deep .el-select {
  624. width: 100%;
  625. }
  626. ::v-deep .el-form-item {
  627. margin-bottom: 50px;
  628. }
  629. }
  630. // 弹出层按钮
  631. .dialogBtn {
  632. text-align: center;
  633. margin: 50px auto 20px;
  634. clear: both;
  635. button {
  636. width: 184px;
  637. padding: 16px;
  638. font-family: Microsoft YaHei, Microsoft YaHei;
  639. font-weight: 400;
  640. font-size: 20px;
  641. border: none;
  642. border-radius: 12px 12px 12px 12px;
  643. }
  644. // 取消
  645. .cancel {
  646. color: #333333;
  647. background-color: #f5f7fb;
  648. border: 2px solid rgba(85, 112, 241, 0.11);
  649. }
  650. // 提交
  651. .submit {
  652. color: #fff;
  653. background-color: #5570F1;
  654. margin-left: 40px;
  655. }
  656. }
  657. //审核弹出框
  658. .radioGroup {
  659. ::v-deep .el-form-item {
  660. margin-top: 40px;
  661. margin-bottom: 0;
  662. }
  663. }
  664. .graph {
  665. background-color: #f5f7fb;
  666. padding: 60px 100px;
  667. overflow: hidden;
  668. li {
  669. float: left;
  670. }
  671. >li:first-child {
  672. margin-right: 100px;
  673. }
  674. }
  675. .dialog-footer {
  676. margin: 0 auto;
  677. }
  678. .rowMargin {
  679. margin-top: 20px;
  680. }
  681. .componentOptions{
  682. float: left;
  683. margin-right: 30px;
  684. width: 470px;
  685. }
  686. .componentOption_one{
  687. width: 337px;
  688. }
  689. </style>