tabbarDetail.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. <template>
  2. <!-- 广告位管理 -->
  3. <div>
  4. <!-- 头部搜索框部分 -->
  5. <div class="title" v-if="this.tabbarType == 1">
  6. <el-row>
  7. <el-col :span="6" class="left">
  8. <div class="searchBox">
  9. <div class="searchTitle">列表标题</div>
  10. <el-input v-model="listTitle" class="input" placeholder="请输入列表标题" clearable ></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-input v-model="contentTitle" class="input" placeholder="请输入内容标题" clearable ></el-input>
  17. </div>
  18. </el-col>
  19. <el-col :span="8" class="right">
  20. <div class="btnList">
  21. <button class="search" @click="goSearch">搜索</button>
  22. <button class="reset" @click="goReset">重置</button>
  23. </div>
  24. </el-col>
  25. </el-row>
  26. </div>
  27. <!--表格内容 start------------------------------------------------------------>
  28. <div class="layerBox">
  29. <tableTitle :name="tableDivTitle" />
  30. <button class="btn" @click="addWebsite">添加详情</button>
  31. <el-row>
  32. <template>
  33. <el-table class="my-table" :data="tableData" style="width: 100%">
  34. <el-table-column fixed prop="id" label="编号" width="90">
  35. </el-table-column>
  36. <el-table-column prop="list_title" label="列表标题" width="" v-if="this.tabbarType == 1">
  37. </el-table-column>
  38. <el-table-column prop="con_title" label="内容标题" width="">
  39. </el-table-column>
  40. <el-table-column prop="created_at" label="添加时间" width="">
  41. </el-table-column>
  42. <el-table-column prop="updated_at" label="修改时间" width="">
  43. </el-table-column>
  44. <el-table-column fixed="right" label="操作" width="200">
  45. <template slot-scope="scope">
  46. <div class="listBtnBox">
  47. <div class="listDeleteBtn" @click="deleteRow(scope.row.id)">
  48. <i class="el-icon-delete"></i>
  49. 删除
  50. </div>
  51. <div class="listEditBtn" @click="goEdit(scope.row.id, scope.row)">
  52. <i class="el-icon-edit-outline"></i>
  53. 编辑
  54. </div>
  55. </div>
  56. </template>
  57. </el-table-column>
  58. </el-table>
  59. </template>
  60. </el-row>
  61. </div>
  62. <!--分页 start------------------------------------------------------------>
  63. <div class="alignBox">
  64. <el-row>
  65. <el-col :span="24">
  66. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
  67. :current-page="page" :page-size="pageSize" layout="total, prev, pager, next, jumper"
  68. :total="total">
  69. </el-pagination>
  70. </el-col>
  71. </el-row>
  72. </div>
  73. <!--分页 end------------------------------------------------------------>
  74. <!--表格内容 end------------------------------------------------------------>
  75. <!-- 弹出框 编辑 start----------------------------------------------------------->
  76. <el-dialog :title="dialogName" :visible.sync="dialogTableVisible" width="50%" top="8vh"
  77. :close-on-click-modal="false">
  78. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
  79. <div class="dialogText">
  80. <el-form-item label="列表标题:" prop="listTitle" v-if="this.tabbarType == 1">
  81. <el-input v-model="ruleForm.listTitle" placeholder="请输入列表标题"></el-input>
  82. </el-form-item>
  83. <el-form-item label="内容标题:" prop="contentTitle">
  84. <el-input v-model="ruleForm.contentTitle" placeholder="请输入内容标题"></el-input>
  85. </el-form-item>
  86. <el-form-item label="内容详情" prop="contentDetail">
  87. <myEditor ref="myEditor" v-model="ruleForm.contentDetail"></myEditor>
  88. </el-form-item>
  89. <!--el-form-item label="内容详情:" prop="contentDetail">
  90. <el-input v-model="ruleForm.contentDetail" type="textarea" :rows="10" placeholder="请输入内容详情"
  91. resize="none">
  92. </el-input>
  93. </el-form-item-->
  94. </div>
  95. <div class="dialogBtn">
  96. <el-button type="info" @click="cancelForm">取消</el-button>
  97. <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
  98. </div>
  99. </el-form>
  100. </el-dialog>
  101. <!-- 弹出框 编辑 end----------------------------------------------------------->
  102. </div>
  103. </template>
  104. <script>
  105. //表格标题
  106. import tableTitle from './components/tableTitle.vue';
  107. //引入公用样式
  108. import '@/styles/global.less';
  109. import { addFooterContent, getFooterContent, upFooterContent, delFooterContent } from '@/api/tabbar'
  110. //引入富文本编辑器
  111. import myEditor from '../../components/edit/myEditor.vue';
  112. export default {
  113. components: {
  114. tableTitle,//表格标题
  115. myEditor,
  116. },
  117. data() {
  118. const validateEmpty = (rule, value, callback) => {
  119. if (value.length == 0) {
  120. callback(new Error('该项不能为空!'))
  121. } else {
  122. callback()
  123. }
  124. }
  125. return {
  126. tableDivTitle: "单页详情", //列表标题
  127. dialogTableVisible: false, //编辑弹框
  128. dialogName: '编辑', //编辑弹窗名称
  129. tableData: [],//表格数据
  130. tabbarId: '',//底部导航传递的id
  131. tabbarType: 1,//底部导航传递的类型
  132. //活动id
  133. activeid: "",
  134. // 分页相关
  135. page: 1,
  136. pageSize: 10,
  137. total: 0,
  138. // 搜索框相关
  139. listTitle: '', //网站名称id
  140. contentTitle: '', //广告位名称
  141. //弹框相关
  142. ruleForm: {
  143. listTitle: '', //列表标题
  144. contentTitle: '', //内容标题
  145. contentDetail: '', //内容详情
  146. },
  147. rules: {
  148. listTitle: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  149. contentTitle: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  150. contentDetail: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  151. }
  152. }
  153. },
  154. methods: {
  155. //1.列表和分页相关 start ------------------------------------------------------------>
  156. //1.1 开始请求列表信息方法
  157. getData() {
  158. getFooterContent({
  159. fcat_id: this.tabbarId,
  160. page: this.page,
  161. pageSize: this.pageSize
  162. }).then(data => {
  163. console.log(data);
  164. this.tableData = data.data.rows
  165. this.total = data.data.count
  166. })
  167. },
  168. //1.2 删除内容
  169. deleteRow(id) {
  170. console.log(id);
  171. let data = new FormData()
  172. data.append('id', id)
  173. this.$confirm('注意:删除后,该条信息及其绑定关系全部删除', '是否确认删除该条信息?', {
  174. confirmButtonText: '确定',
  175. cancelButtonText: '取消',
  176. }).then(() => {
  177. console.log("当前删除:" + id)
  178. delFooterContent({
  179. id: id
  180. }).then(data => {
  181. console.log(data);
  182. if (data.code = 200) {
  183. this.$message({
  184. message: '删除成功',
  185. type: 'success'
  186. })
  187. this.getData()
  188. } else if (data.code == 0) {
  189. this.$message({
  190. message: data.message,
  191. type: 'error'
  192. })
  193. }
  194. })
  195. }).catch(() => {
  196. this.$message({
  197. type: 'warning',
  198. message: '已取消删除'
  199. });
  200. });
  201. },
  202. //1.3 列表内容分页
  203. //直接跳转
  204. handleSizeChange(val) {
  205. this.page = val;
  206. this.getData();
  207. },
  208. //1.4 点击分页
  209. handleCurrentChange(val) {
  210. this.page = val;
  211. this.getData();
  212. },
  213. // 1.5 搜索按钮
  214. goSearch() {
  215. getFooterContent({
  216. fcat_id: this.tabbarId,
  217. page: this.page,
  218. pageSize: this.pageSize,
  219. list_title:this.listTitle,
  220. con_title:this.contentTitle,
  221. }).then(data => {
  222. console.log(data);
  223. this.tableData = data.data.rows
  224. this.total = data.data.count
  225. })
  226. },
  227. //1.6 重置按钮
  228. goReset() {
  229. this.listTitle = ""
  230. this.contentTitle = ""
  231. this.getData()
  232. },
  233. //列表和分页相关 end ------------------------------------------------------------>
  234. //1.7 编辑
  235. goEdit(id, val) {
  236. // console.log(id);
  237. this.dialogName = '编辑'
  238. this.activeid = id
  239. this.dialogTableVisible = true
  240. console.log(id, val);
  241. //数据回显
  242. this.ruleForm.listTitle = val.list_title //列表标题
  243. this.ruleForm.contentTitle = val.con_title //内容标题
  244. this.$nextTick(() => {
  245. this.ruleForm.contentDetail = val.content //内容详情
  246. });
  247. },
  248. //1.8 添加
  249. addWebsite() {
  250. this.dialogTableVisible = true
  251. this.dialogName = "添加"
  252. //添加时清空回显回来的数据
  253. this.ruleForm.contentTitle = '' //内容标题
  254. this.ruleForm.contentDetail = '' //内容详情
  255. },
  256. // 弹出层相关方法
  257. // 1.9 提交表单
  258. submitForm(formName) {
  259. // 判断用户是否输入数据
  260. this.$refs[formName].validate((valid) => {
  261. if (valid) {
  262. console.log('submit!');
  263. } else {
  264. console.log('error submit!!');
  265. return false;
  266. }
  267. });
  268. if (this.dialogName == "添加") {
  269. if (this.tabbarType == 0) { //详情页类型
  270. addFooterContent({
  271. fcat_id: this.tabbarId,
  272. type: this.tabbarType,
  273. con_title: this.ruleForm.contentTitle,
  274. content: this.ruleForm.contentDetail,
  275. }).then(data => {
  276. console.log(data);
  277. if (data.code == 200) {
  278. this.$message({
  279. message: '添加成功',
  280. type: 'success'
  281. })
  282. this.dialogTableVisible = false
  283. this.getData()
  284. } else {
  285. this.$message({
  286. message: data.message,
  287. type: 'error'
  288. })
  289. }
  290. })
  291. } else if (this.tabbarType == 1) { //列表页类型
  292. addFooterContent({
  293. fcat_id: this.tabbarId,
  294. type: this.tabbarType,
  295. list_title: this.ruleForm.listTitle,
  296. con_title: this.ruleForm.contentTitle,
  297. content: this.ruleForm.contentDetail,
  298. }).then(data => {
  299. console.log(data);
  300. if (data.code == 200) {
  301. this.$message({
  302. message: '添加成功',
  303. type: 'success'
  304. })
  305. this.dialogTableVisible = false
  306. this.getData()
  307. } else {
  308. this.$message({
  309. message: data.message,
  310. type: 'error'
  311. })
  312. }
  313. })
  314. }
  315. }
  316. if (this.dialogName == "编辑") {
  317. if (this.tabbarType == 0) { //详情页类型
  318. upFooterContent({
  319. id: this.activeid, //内容id
  320. type: this.tabbarType,
  321. con_title: this.ruleForm.contentTitle,
  322. content: this.ruleForm.contentDetail,
  323. }).then(data => {
  324. console.log(data);
  325. if (data.code == 200) {
  326. this.$message({
  327. message: '修改成功!',
  328. type: 'success'
  329. })
  330. this.dialogTableVisible = false
  331. this.getData()
  332. } else {
  333. this.$message({
  334. message: data.message,
  335. type: 'error'
  336. })
  337. }
  338. })
  339. } else if (this.tabbarType == 1) { //列表页类型
  340. upFooterContent({
  341. id: this.activeid, //内容id
  342. type: this.tabbarType,
  343. list_title: this.ruleForm.listTitle,
  344. con_title: this.ruleForm.contentTitle,
  345. content: this.ruleForm.contentDetail,
  346. }).then(data => {
  347. console.log(data);
  348. if (data.code == 200) {
  349. this.$message({
  350. message: '修改成功!',
  351. type: 'success'
  352. })
  353. this.dialogTableVisible = false
  354. this.getData()
  355. } else {
  356. this.$message({
  357. message: data.message,
  358. type: 'error'
  359. })
  360. }
  361. })
  362. }
  363. }
  364. },
  365. //取消
  366. cancelForm() {
  367. this.dialogTableVisible = false
  368. },
  369. },
  370. mounted() {
  371. console.log(this.$route.query.id);
  372. this.tabbarId = this.$route.query.id
  373. this.tabbarType = this.$route.query.type
  374. this.getData() //获取数据
  375. },
  376. }
  377. </script>
  378. <style scoped lang="less">
  379. input[aria-hidden=true] {
  380. display: none !important;
  381. }
  382. // 提示信息
  383. .tips {
  384. margin: 30px;
  385. background-color: #e9ecf9;
  386. border-radius: 11px;
  387. .tipsIcon {
  388. margin: 10px 15px;
  389. display: inline-block;
  390. width: 24px;
  391. height: 24px;
  392. background: url("../../assets/advertise/Info Circle.png") no-repeat;
  393. vertical-align: middle;
  394. }
  395. .tipsText {
  396. font-size: 14px;
  397. color: #666666;
  398. }
  399. }
  400. // 头部
  401. .title {
  402. margin: 30px 30px 20px 30px;
  403. padding: 30px 30px 40px 30px;
  404. background-color: #fff;
  405. border-radius: 20px 20px 20px 20px;
  406. border: 1px solid #E9EDF7;
  407. .left {
  408. float: left;
  409. }
  410. .right {
  411. float: right;
  412. }
  413. .searchBox {
  414. ::v-deep .el-input {
  415. position: relative;
  416. font-size: 14px;
  417. display: inline-block;
  418. width: 80%;
  419. }
  420. .searchTitle {
  421. padding-bottom: 10px;
  422. font-family: Microsoft YaHei, Microsoft YaHei;
  423. font-weight: 400;
  424. font-size: 14px;
  425. color: #999999;
  426. line-height: 16px;
  427. }
  428. .el-select {
  429. width: 100%;
  430. display: inline-block;
  431. position: relative;
  432. }
  433. }
  434. .btnList {
  435. float: right;
  436. padding-top: 28px;
  437. button {
  438. height: 38px;
  439. border: none;
  440. border-radius: 8px;
  441. padding: 0 30px;
  442. }
  443. .search {
  444. background-color: #5570f1;
  445. color: #fff;
  446. margin-right: 20px;
  447. }
  448. .reset {
  449. font-family: Microsoft YaHei, Microsoft YaHei;
  450. font-weight: 400;
  451. font-size: 16px;
  452. color: #333333;
  453. background: #F5F7FB;
  454. border-radius: 8px 8px 8px 8px;
  455. border: 1px solid rgba(85, 112, 241, 0.11);
  456. }
  457. }
  458. }
  459. .layerBox {
  460. padding: 30px 20px;
  461. position: relative;
  462. .btn {
  463. position: absolute;
  464. top: 30px;
  465. right: 20px;
  466. height: 38px;
  467. color: #fff;
  468. background-color: #5570f1;
  469. border: none;
  470. border-radius: 8px;
  471. padding: 8px 28px 9px;
  472. box-sizing: border-box;
  473. }
  474. .listBtnBox {
  475. justify-content: left;
  476. }
  477. .listDeleteBtn,
  478. .listEditBtn {
  479. margin-left: 0px;
  480. padding-left: 0px;
  481. margin-right: 20px;
  482. width: 76px;
  483. height: 36px;
  484. line-height: 36px;
  485. }
  486. ::v-deep .el-form-item {
  487. margin-bottom: 50px;
  488. }
  489. ::v-deep .el-select {
  490. width: 100%;
  491. }
  492. ::v-deep .el-input--medium,
  493. ::v-deep .el-form-item__label {
  494. line-height: 36px;
  495. font-size: 16px;
  496. }
  497. }
  498. // 弹出层内容
  499. .dialogText {
  500. margin: 0 7px 0 3px;
  501. padding-bottom: 1px;
  502. padding: 30px 60px 1px 20px;
  503. background-color: #f5f7fb;
  504. .adImage {
  505. width: 140px;
  506. height: 140px;
  507. line-height: 210px;
  508. border-radius: 12px;
  509. border: 1px solid rgba(85, 112, 241, 0.11);
  510. img {
  511. width: 140px;
  512. height: 80px;
  513. }
  514. }
  515. ::v-deep .avatar {
  516. width: 140px;
  517. height: auto;
  518. }
  519. .price {
  520. ::v-deep .el-input {
  521. width: 29%;
  522. }
  523. }
  524. .example {
  525. font-family: Microsoft YaHei;
  526. color: #5570F1;
  527. }
  528. .el_btnList {
  529. margin-right: 15px;
  530. margin-top: 20px;
  531. }
  532. //日期时间选择器的宽
  533. ::v-deep .el-date-editor.el-input {
  534. width: 48%;
  535. }
  536. ::v-deep .el-button+.el-button {
  537. margin-left: 0px;
  538. }
  539. ::v-deep .el-select {
  540. width: 100%;
  541. }
  542. ::v-deep .el-form-item {
  543. margin-bottom: 50px;
  544. }
  545. }
  546. // 弹出层按钮
  547. .dialogBtn {
  548. text-align: center;
  549. margin: 50px auto 20px;
  550. button {
  551. width: 184px;
  552. padding: 16px;
  553. font-family: Microsoft YaHei, Microsoft YaHei;
  554. font-weight: 400;
  555. font-size: 20px;
  556. border: none;
  557. border-radius: 12px 12px 12px 12px;
  558. }
  559. // 取消
  560. .cancel {
  561. color: #333333;
  562. background-color: #f5f7fb;
  563. border: 2px solid rgba(85, 112, 241, 0.11);
  564. }
  565. // 提交
  566. .submit {
  567. color: #fff;
  568. background-color: #5570F1;
  569. margin-left: 40px;
  570. }
  571. }
  572. //审核弹出框
  573. .radioGroup {
  574. ::v-deep .el-form-item {
  575. margin-top: 40px;
  576. margin-bottom: 0;
  577. }
  578. }
  579. .graph {
  580. background-color: #f5f7fb;
  581. padding: 60px 100px;
  582. overflow: hidden;
  583. li {
  584. float: left;
  585. }
  586. >li:first-child {
  587. margin-right: 100px;
  588. }
  589. }
  590. .dialog-footer {
  591. margin: 0 auto;
  592. }
  593. </style>