tabbar.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  1. <template>
  2. <!-- 广告位管理 -->
  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="webSiteName_name" class="input" placeholder="请输入网站名称"></el-input>
  11. <!-- <el-select v-model="webSiteName_id" :multiple="false" :multiple-limit="1" filterable remote
  12. reserve-keyword placeholder="请输入网站名称" :remote-method="getWebNavList"
  13. :loading="webSiteLoading" @change="selectWebSite">
  14. <el-option v-for="item in webSiteList" :key="item.value" :label="item.label"
  15. :value="item.value">
  16. </el-option>
  17. </el-select> -->
  18. </div>
  19. </el-col>
  20. <el-col :span="6" class="left">
  21. <div class="searchBox">
  22. <div class="searchTitle">底部导航名称</div>
  23. <el-input v-model="tabbarName" class="input" placeholder="请输入底部导航名称"></el-input>
  24. </div>
  25. </el-col>
  26. <el-col :span="8" class="right">
  27. <div class="btnList">
  28. <button class="search" @click="goSearch">搜索</button>
  29. <button class="reset" @click="goReset">重置</button>
  30. </div>
  31. </el-col>
  32. </el-row>
  33. </div>
  34. <!--表格内容 start------------------------------------------------------------>
  35. <div class="layerBox">
  36. <tableTitle :name="tableDivTitle" />
  37. <button class="btn" @click="addWebsite">添加底部导航</button>
  38. <el-row>
  39. <template>
  40. <el-table class="my-table" :data="tableData" style="width: 100%">
  41. <el-table-column fixed prop="id" label="编号" width="90">
  42. </el-table-column>
  43. <el-table-column prop="website_name" label="网站" width="">
  44. </el-table-column>
  45. <el-table-column prop="name" label="底部导航名称" width="">
  46. </el-table-column>
  47. <el-table-column prop="created_at" label="添加时间" width="">
  48. </el-table-column>
  49. <el-table-column prop="updated_at" label="修改时间" width="">
  50. </el-table-column>
  51. <el-table-column fixed="right" label="操作" width="300">
  52. <template slot-scope="scope">
  53. <div class="listBtnBox">
  54. <div class="listDeleteBtn" @click="deleteRow(scope.row.id)">
  55. <i class="el-icon-delete"></i>
  56. 删除
  57. </div>
  58. <div class="listEditBtn" @click="goEdit(scope.row.id, scope.row)">
  59. <i class="el-icon-edit-outline"></i>
  60. 编辑
  61. </div>
  62. <div class="listLookBtn" @click="goLook(scope.row.id,scope.row)">
  63. <i class="el-icon-view"></i>
  64. 查看
  65. </div>
  66. </div>
  67. </template>
  68. </el-table-column>
  69. </el-table>
  70. </template>
  71. </el-row>
  72. </div>
  73. <!--分页 start------------------------------------------------------------>
  74. <div class="alignBox">
  75. <el-row>
  76. <el-col :span="24">
  77. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
  78. :current-page="page" :page-size="pageSize" layout="total, prev, pager, next, jumper"
  79. :total="total">
  80. </el-pagination>
  81. </el-col>
  82. </el-row>
  83. </div>
  84. <!--分页 end------------------------------------------------------------>
  85. <!--表格内容 end------------------------------------------------------------>
  86. <!-- 弹出框 编辑 start----------------------------------------------------------->
  87. <el-dialog :title="dialogName" :visible.sync="dialogTableVisible" width="50%" top="8vh"
  88. :close-on-click-modal="false">
  89. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
  90. <div class="dialogText">
  91. <el-form-item label="关联网站名称:" prop="webName">
  92. <el-select v-model="ruleForm.webName" :multiple="false" :multiple-limit="1" filterable remote
  93. reserve-keyword placeholder="请输入关联网站名称" :remote-method="getWebNavList"
  94. :loading="webSiteLoading" @change="detectionWebSite">
  95. <el-option v-for="item in webSiteList" :key="item.value" :label="item.label"
  96. :value="item.value">
  97. </el-option>
  98. </el-select>
  99. </el-form-item>
  100. <el-form-item label="底部导航名称:" prop="tabbarName">
  101. <el-input v-model="ruleForm.tabbarName" placeholder="请输入底部导航名称"></el-input>
  102. </el-form-item>
  103. <el-form-item label="页面类型:" prop="pageType">
  104. <el-radio v-model="ruleForm.pageType" label="1" :disabled="this.disabled">特殊列表页</el-radio>
  105. <el-radio v-model="ruleForm.pageType" label="0" :disabled="this.disabled">特殊详情页</el-radio>
  106. </el-form-item>
  107. </div>
  108. <div class="dialogBtn">
  109. <el-button type="info" @click="cancelForm">取消</el-button>
  110. <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
  111. </div>
  112. </el-form>
  113. </el-dialog>
  114. <!-- 弹出框 编辑 end----------------------------------------------------------->
  115. </div>
  116. </template>
  117. <script>
  118. //表格标题
  119. import tableTitle from './components/tableTitle.vue';
  120. //引入公用样式
  121. import '@/styles/global.less';
  122. import { getFooterCategory, getTemplateClass, upFooterCategory, delFooterCategory } from '@/api/tabbar'
  123. export default {
  124. components: {
  125. tableTitle,//表格标题-
  126. },
  127. data() {
  128. const validateEmpty = (rule, value, callback) => {
  129. if (value.length == 0) {
  130. callback(new Error('该项不能为空!'))
  131. } else {
  132. callback()
  133. }
  134. }
  135. return {
  136. tableDivTitle: "底部导航列表", //列表标题
  137. dialogTableVisible: false, //编辑弹框
  138. dialogName: '编辑', //编辑弹窗名称
  139. disabled: false, //禁用
  140. tableData: [],//表格数据
  141. // 可以输入的搜索框相关
  142. webSiteList: [],//获取关联网站列表
  143. webSiteLoading: false,
  144. //3.4 上传logo图片
  145. logoUrl: '',
  146. hovering: false, // 鼠标悬浮状态 悬浮时显示删除
  147. value: '',
  148. activeid: "", //活动id
  149. type:"", //查看时需要传递的类型
  150. // 分页相关
  151. page: 1,
  152. pageSize: 10,
  153. total: 0,
  154. formLabelWidth: '', //广告示例图相关
  155. // 搜索框相关
  156. webSiteName_name: '', //网站名称
  157. webSiteName_id: '', //网站名称id
  158. tabbarName: '', //底部导航名称
  159. website_id: "", //网站id
  160. ruleForm: {
  161. webName: '', //网站名称
  162. tabbarName: '', //底部导航名称
  163. pageType: '', //页面类型
  164. },
  165. rules: {
  166. webName: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  167. tabbarName: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  168. pageType: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  169. }
  170. }
  171. },
  172. methods: {
  173. //1.列表和分页相关 start ------------------------------------------------------------>
  174. //1.1 开始请求列表信息方法
  175. getData() {
  176. getFooterCategory({
  177. page: this.page,
  178. pageSize: this.pageSize
  179. }).then(data => {
  180. console.log(data);
  181. this.tableData = data.data.rows
  182. this.total = data.data.count
  183. })
  184. },
  185. //1.2 删除内容
  186. deleteRow(id) {
  187. console.log(id);
  188. let data = new FormData()
  189. data.append('id', id)
  190. this.$confirm('注意:删除后,该条信息及其绑定关系全部删除', '是否确认删除该条信息?', {
  191. confirmButtonText: '确定',
  192. cancelButtonText: '取消',
  193. }).then(() => {
  194. console.log("当前删除:" + id)
  195. delFooterCategory({
  196. id: id
  197. }).then(data => {
  198. console.log(data);
  199. if (data.code = 200) {
  200. this.$message({
  201. message: '删除成功',
  202. type: 'success'
  203. })
  204. this.getData()
  205. } else if (data.code == 0) {
  206. this.$message({
  207. message: data.message,
  208. type: 'error'
  209. })
  210. }
  211. })
  212. }).catch(() => {
  213. this.$message({
  214. type: 'warning',
  215. message: '已取消删除'
  216. });
  217. });
  218. },
  219. //1.3 查看示例图
  220. goGraph() {
  221. this.dialogVisible = true
  222. },
  223. //1.4 列表内容分页
  224. //直接跳转
  225. handleSizeChange(val) {
  226. this.page = val;
  227. this.getData();
  228. },
  229. //1.5 点击分页
  230. handleCurrentChange(val) {
  231. this.page = val;
  232. this.getData();
  233. },
  234. // 1.6 搜索按钮
  235. goSearch() {
  236. if (this.webSiteName_name && this.tabbarName) {
  237. getFooterCategory({
  238. page: this.page,
  239. pageSize: this.pageSize,
  240. name: this.tabbarName,
  241. website_name: this.webSiteName_name, //网站名称
  242. }).then(data => {
  243. console.log(data);
  244. this.tableData = data.data.rows
  245. this.total = data.data.count
  246. })
  247. } else if (this.webSiteName_name && !this.tabbarName) {
  248. getFooterCategory({
  249. page: this.page,
  250. pageSize: this.pageSize,
  251. // name: this.tabbarName,
  252. website_name: this.webSiteName_name, //网站名称
  253. }).then(data => {
  254. console.log(data);
  255. this.tableData = data.data.rows
  256. this.total = data.data.count
  257. })
  258. } else if (!this.webSiteName_name && this.tabbarName) {
  259. getFooterCategory({
  260. page: this.page,
  261. pageSize: this.pageSize,
  262. name: this.tabbarName,
  263. // website_name: this.webSiteName_name, //网站名称
  264. }).then(data => {
  265. console.log(data);
  266. this.tableData = data.data.rows
  267. this.total = data.data.count
  268. })
  269. }
  270. },
  271. //1.7 重置按钮
  272. goReset() {
  273. this.webSiteName_name = ""
  274. this.tabbarName = ""
  275. this.getData()
  276. },
  277. //列表和分页相关 end ------------------------------------------------------------>
  278. //1.9 编辑
  279. goEdit(id, val) {
  280. // console.log(id);
  281. this.dialogName = '编辑'
  282. this.activeid = id
  283. this.dialogTableVisible = true
  284. this.disabled=true
  285. console.log(id, val);
  286. console.log("状态", val);
  287. //数据回显
  288. this.website_id = val.website_id
  289. this.ruleForm.webName = val.website_name //网站名称
  290. this.ruleForm.tabbarName = val.name //底部导航名称
  291. if (val.type == 0) {
  292. this.ruleForm.pageType = '0' //页面类型
  293. } else if (val.type == 1) {
  294. this.ruleForm.pageType = '1' //页面类型
  295. }
  296. },
  297. //2.0 查看
  298. goLook(id,val) {
  299. this.activeid = id
  300. this.type=val.type
  301. this.$router.push({
  302. path: '/tabbarDetail',
  303. query: {
  304. id: this.activeid,
  305. type:this.type
  306. }
  307. })
  308. },
  309. //1.7 添加
  310. addWebsite() {
  311. this.dialogTableVisible = true
  312. this.dialogName = "添加"
  313. this.disabled=false
  314. //添加时清空回显回来的数据
  315. this.ruleForm.webName = '' //关联网站名称
  316. this.ruleForm.tabbarName = '' //底部导航名称
  317. this.ruleForm.pageType = '' //页面类型
  318. },
  319. // 弹出层相关方法
  320. // 提交表单
  321. submitForm(formName) {
  322. this.$refs[formName].validate((valid) => {
  323. if (valid) {
  324. console.log('submit!');
  325. } else {
  326. console.log('error submit!!');
  327. return false;
  328. }
  329. });
  330. if (this.dialogName == "添加") {
  331. getTemplateClass({
  332. website_id: this.website_id,
  333. name: this.ruleForm.tabbarName,
  334. type: this.ruleForm.pageType,
  335. }).then(data => {
  336. console.log(data);
  337. if (data.code == 200) {
  338. this.$message({
  339. message: '添加成功',
  340. type: 'success'
  341. })
  342. this.dialogTableVisible = false
  343. this.getData()
  344. } else if (data.code == 0) {
  345. this.$message({
  346. message: data.message,
  347. type: 'error'
  348. })
  349. this.dialogTableVisible = true
  350. return
  351. } else {
  352. this.$message({
  353. message: data.message,
  354. type: 'error'
  355. })
  356. this.dialogTableVisible = true
  357. return
  358. }
  359. })
  360. }
  361. if (this.website_id == '') {
  362. this.$message({
  363. message: '请输入并选择网站名称',
  364. type: 'error'
  365. })
  366. this.dialogVisible = true
  367. }
  368. if (this.dialogName == "编辑") {
  369. upFooterCategory({
  370. website_id: this.website_id,
  371. name: this.ruleForm.tabbarName,
  372. id: this.activeid
  373. }).then(data => {
  374. console.log(data);
  375. if (data.code == 200) {
  376. this.$message({
  377. message: '编辑成功',
  378. type: 'success'
  379. })
  380. this.dialogTableVisible = false
  381. }
  382. if (data.code == 0) {
  383. this.$message({
  384. message: data.message,
  385. type: 'error'
  386. })
  387. this.dialogTableVisible = true
  388. }
  389. this.getData()
  390. })
  391. }
  392. },
  393. //取消添加或编辑
  394. cancelForm() {
  395. this.dialogTableVisible = false
  396. },
  397. //3.6 上传图片操作
  398. beforeAvatarUpload(file) {
  399. const isJPG = file.type === 'image/jpeg';
  400. const isPNG = file.type === 'image/png';
  401. const isLt2M = file.size / 1024 / 1024 < 2;
  402. if (!isJPG && !isPNG) {
  403. this.$message.error('上传图片只能是 JPG 或 PNG 格式!');
  404. return false;
  405. }
  406. if (!isLt2M) {
  407. this.$message.error('上传图片大小不能超过 2MB!');
  408. return false;
  409. }
  410. const formData = new FormData();
  411. formData.append('file', file);
  412. this.$store.dispatch('pool/uploadFile', formData).then(res => {
  413. this.logoUrl = res.data.imgUrl;//显示缩略图
  414. this.ruleForm.adPhoto = res.data.imgUrl;//提供表单地址
  415. console.log(res.data.imgUrl)
  416. }).catch(() => {
  417. this.$message({
  418. type: 'info',
  419. message: '网络错误,请重试!'
  420. });
  421. })
  422. // 阻止默认的上传行为
  423. return false;
  424. },
  425. handleDelete() {
  426. // 删除图片
  427. this.logoUrl = ''; // 清空图片 URL
  428. },
  429. //搜索部分的输入关键词下拉框
  430. selectWebSite(value) {
  431. this.webSiteName_id = value
  432. },
  433. //添加 / 编辑弹窗中输入关键词下拉框
  434. // 判断是否已经关联了网站
  435. detectionWebSite(value) {
  436. console.log(value);
  437. this.website_id = value
  438. console.log(this.website_id);
  439. },
  440. //
  441. getWebNavList(query) {
  442. if (query !== '') {
  443. this.webSiteLoading = true;
  444. let data = { keyword: query }
  445. let dataArr = [];
  446. this.$store.dispatch('pool/getNavWebList', data).then(res => {
  447. console.log(res.data)
  448. for (let item of res.data) {
  449. let data = {};
  450. data.key = item.id;
  451. data.value = item.id;
  452. data.label = item.website_name;
  453. dataArr.push(data)
  454. }
  455. this.webSiteList = dataArr;
  456. this.webSiteLoading = false;
  457. }).catch(() => {
  458. this.$message({
  459. type: 'info',
  460. message: '网络错误,请重试!'
  461. });
  462. })
  463. } else {
  464. this.navList = [];
  465. }
  466. },
  467. },
  468. mounted() {
  469. this.getData()
  470. },
  471. }
  472. </script>
  473. <style scoped lang="less">
  474. input[aria-hidden=true] {
  475. display: none !important;
  476. }
  477. // 提示信息
  478. .tips {
  479. margin: 30px;
  480. background-color: #e9ecf9;
  481. border-radius: 11px;
  482. .tipsIcon {
  483. margin: 10px 15px;
  484. display: inline-block;
  485. width: 24px;
  486. height: 24px;
  487. background: url("../../assets/advertise/Info Circle.png") no-repeat;
  488. vertical-align: middle;
  489. }
  490. .tipsText {
  491. font-size: 14px;
  492. color: #666666;
  493. }
  494. }
  495. // 头部
  496. .title {
  497. margin: 30px 30px 20px 30px;
  498. padding: 30px 30px 40px 30px;
  499. background-color: #fff;
  500. border-radius: 20px 20px 20px 20px;
  501. border: 1px solid #E9EDF7;
  502. .left {
  503. float: left;
  504. }
  505. .right {
  506. float: right;
  507. }
  508. .searchBox {
  509. ::v-deep .el-input {
  510. position: relative;
  511. font-size: 14px;
  512. display: inline-block;
  513. width: 80%;
  514. }
  515. .searchTitle {
  516. padding-bottom: 10px;
  517. font-family: Microsoft YaHei, Microsoft YaHei;
  518. font-weight: 400;
  519. font-size: 14px;
  520. color: #999999;
  521. line-height: 16px;
  522. }
  523. .el-select {
  524. width: 100%;
  525. display: inline-block;
  526. position: relative;
  527. }
  528. }
  529. .btnList {
  530. float: right;
  531. padding-top: 28px;
  532. button {
  533. height: 38px;
  534. border: none;
  535. border-radius: 8px;
  536. padding: 0 30px;
  537. }
  538. .search {
  539. background-color: #5570f1;
  540. color: #fff;
  541. margin-right: 20px;
  542. }
  543. .reset {
  544. font-family: Microsoft YaHei, Microsoft YaHei;
  545. font-weight: 400;
  546. font-size: 16px;
  547. color: #333333;
  548. background: #F5F7FB;
  549. border-radius: 8px 8px 8px 8px;
  550. border: 1px solid rgba(85, 112, 241, 0.11);
  551. }
  552. }
  553. }
  554. .layerBox {
  555. padding: 30px 20px;
  556. position: relative;
  557. .btn {
  558. position: absolute;
  559. top: 30px;
  560. right: 20px;
  561. height: 38px;
  562. color: #fff;
  563. background-color: #5570f1;
  564. border: none;
  565. border-radius: 8px;
  566. padding: 8px 28px 9px;
  567. box-sizing: border-box;
  568. }
  569. .listBtnBox {
  570. justify-content: left;
  571. }
  572. .listDeleteBtn,
  573. .listEditBtn,
  574. .listLookBtn {
  575. margin-left: 0px;
  576. padding-left: 0px;
  577. margin-right: 20px;
  578. width: 76px;
  579. height: 36px;
  580. line-height: 36px;
  581. }
  582. .listLookBtn {
  583. text-align: center;
  584. border-radius: 8px;
  585. cursor: pointer;
  586. color: #55b5f1;
  587. background-color: rgba(85, 181, 241, 0.16);
  588. >i {
  589. padding-right: 8px;
  590. }
  591. }
  592. ::v-deep .el-form-item {
  593. margin-bottom: 50px;
  594. }
  595. ::v-deep .el-select {
  596. width: 100%;
  597. }
  598. ::v-deep .el-input--medium,
  599. ::v-deep .el-form-item__label {
  600. line-height: 36px;
  601. font-size: 16px;
  602. }
  603. }
  604. // 弹出层内容
  605. .dialogText {
  606. margin: 0 7px 0 3px;
  607. padding-bottom: 1px;
  608. padding: 30px 60px 1px 20px;
  609. background-color: #f5f7fb;
  610. .adImage {
  611. width: 140px;
  612. height: 140px;
  613. line-height: 210px;
  614. border-radius: 12px;
  615. border: 1px solid rgba(85, 112, 241, 0.11);
  616. img {
  617. width: 140px;
  618. height: 80px;
  619. }
  620. }
  621. ::v-deep .avatar {
  622. width: 140px;
  623. height: auto;
  624. }
  625. .price {
  626. ::v-deep .el-input {
  627. width: 29%;
  628. }
  629. }
  630. .example {
  631. font-family: Microsoft YaHei;
  632. color: #5570F1;
  633. }
  634. .el_btnList {
  635. margin-right: 15px;
  636. margin-top: 20px;
  637. }
  638. //日期时间选择器的宽
  639. ::v-deep .el-date-editor.el-input {
  640. width: 48%;
  641. }
  642. ::v-deep .el-button+.el-button {
  643. margin-left: 0px;
  644. }
  645. ::v-deep .el-select {
  646. width: 100%;
  647. }
  648. ::v-deep .el-form-item {
  649. margin-bottom: 50px;
  650. }
  651. }
  652. // 弹出层按钮
  653. .dialogBtn {
  654. text-align: center;
  655. margin: 50px auto 20px;
  656. button {
  657. width: 184px;
  658. padding: 16px;
  659. font-family: Microsoft YaHei, Microsoft YaHei;
  660. font-weight: 400;
  661. font-size: 20px;
  662. border: none;
  663. border-radius: 12px 12px 12px 12px;
  664. }
  665. // 取消
  666. .cancel {
  667. color: #333333;
  668. background-color: #f5f7fb;
  669. border: 2px solid rgba(85, 112, 241, 0.11);
  670. }
  671. // 提交
  672. .submit {
  673. color: #fff;
  674. background-color: #5570F1;
  675. margin-left: 40px;
  676. }
  677. }
  678. //审核弹出框
  679. .radioGroup {
  680. ::v-deep .el-form-item {
  681. margin-top: 40px;
  682. margin-bottom: 0;
  683. }
  684. }
  685. .graph {
  686. background-color: #f5f7fb;
  687. padding: 60px 100px;
  688. overflow: hidden;
  689. li {
  690. float: left;
  691. }
  692. >li:first-child {
  693. margin-right: 100px;
  694. }
  695. }
  696. .dialog-footer {
  697. margin: 0 auto;
  698. }
  699. </style>