index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. <template>
  2. <el-card :bordered="false" shadow="never" class="ivu-mt">
  3. <div class="Modal">
  4. <div class="colLeft">
  5. <div class="Nav">
  6. <div class="trees-coadd">
  7. <div class="tree_tit" v-db-click @click="append">
  8. <i class="el-icon-circle-plus"></i>
  9. 添加分类
  10. </div>
  11. <div class="scollhide">
  12. <div class="tree" v-if="treeData.length">
  13. <el-tree
  14. ref="tree"
  15. :data="treeData"
  16. node-key="id"
  17. default-expand-all
  18. :highlight-current="highlightCurrent"
  19. :expand-on-click-node="true"
  20. :check-on-click-node="false"
  21. @node-click="appendBtn"
  22. @node-expand="nodeExpand"
  23. :current-node-key="treeId"
  24. >
  25. <span class="custom-tree-node" slot-scope="{ data }">
  26. <div class="file-name">
  27. <img v-if="data.pid == 1" class="icon" src="@/assets/images/file.jpg" />
  28. <el-tooltip class="item" effect="dark" :content="data.title" placement="top">
  29. <div class="text line1">
  30. {{ data.title }}
  31. </div>
  32. </el-tooltip>
  33. </div>
  34. <span>
  35. <el-dropdown @command="(command) => clickMenu(data, command)">
  36. <i class="el-icon-more el-icon--right"></i>
  37. <template slot="dropdown">
  38. <el-dropdown-menu>
  39. <el-dropdown-item v-if="data.pid == 1" command="1">新增分类</el-dropdown-item>
  40. <el-dropdown-item v-if="data.id" command="2">编辑分类</el-dropdown-item>
  41. <el-dropdown-item v-if="data.id" command="3">删除</el-dropdown-item>
  42. </el-dropdown-menu>
  43. </template>
  44. </el-dropdown>
  45. </span>
  46. </span>
  47. </el-tree>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="conter">
  53. <el-button type="primary" @click="addLink">添加链接</el-button>
  54. <el-table
  55. :data="linkList"
  56. ref="couponTable"
  57. class="mt20"
  58. v-loading="loading"
  59. highlight-current-row
  60. no-userFrom-text="暂无数据"
  61. no-filtered-userFrom-text="暂无筛选结果"
  62. >
  63. <el-table-column label="ID" width="70">
  64. <template slot-scope="scope">
  65. <span>{{ scope.row.id }}</span>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="名称" width="150">
  69. <template slot-scope="scope">
  70. <span>{{ scope.row.name }}</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="H5链接" minWidth="170">
  74. <template slot-scope="scope">
  75. <el-tooltip class="item pointer" content="点击复制">
  76. <span v-db-click @click="onCopy(scope.row.h5_url)">{{ scope.row.h5_url }}</span>
  77. </el-tooltip>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="小程序链接" minWidth="140">
  81. <template slot-scope="scope">
  82. <el-tooltip class="item pointer" content="点击复制">
  83. <span v-db-click @click="onCopy(scope.row.url)">{{ scope.row.url }}</span>
  84. </el-tooltip>
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="添加时间" minWidth="90">
  88. <template slot-scope="scope">
  89. <span>{{ scope.row.add_time }}</span>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="操作" fixed="right" width="90">
  93. <template slot-scope="scope">
  94. <a v-db-click @click="edit(scope.row)">编辑</a>
  95. <el-divider direction="vertical"></el-divider>
  96. <a v-db-click @click="del(scope.row, '删除链接', scope.$index)">删除</a>
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. <div class="acea-row row-right page">
  101. <pagination
  102. v-if="total"
  103. :total="total"
  104. :page.sync="fileData.page"
  105. :limit.sync="fileData.limit"
  106. @pagination="getLinkList"
  107. />
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. <el-dialog
  113. title="链接"
  114. :visible.sync="dialogVisible"
  115. width="40%"
  116. :before-close="handleClose"
  117. :close-on-click-modal="false"
  118. >
  119. <el-form :model="linkForm" ref="linkForm" label-width="80px">
  120. <el-form-item label="名称:" prop="name">
  121. <el-input v-model="linkForm.name" placeholder="请输入名称"></el-input>
  122. </el-form-item>
  123. <el-form-item label="跳转链接:" prop="url">
  124. <el-input v-model="linkForm.url" placeholder="请输入跳转链接"></el-input>
  125. </el-form-item>
  126. <el-form-item label="排序:" prop="url">
  127. <el-input v-model="linkForm.sort" placeholder="请输入排序"></el-input>
  128. </el-form-item>
  129. <el-form-item label="是否开启:" prop="url">
  130. <el-switch v-model="linkForm.status" :active-value="1" :inactive-value="0"></el-switch>
  131. </el-form-item>
  132. </el-form>
  133. <div slot="footer" class="dialog-footer">
  134. <el-button @click="dialogVisible = false">取 消</el-button>
  135. <el-button type="primary" @click="addLinkSubmit">确 定</el-button>
  136. </div>
  137. </el-dialog>
  138. </el-card>
  139. </template>
  140. <script>
  141. import { diyLinkCategoryListApi, linkCategoryFormApi, linkListApi, linkCreateApi } from '@/api/setting';
  142. export default {
  143. name: 'linkLisk',
  144. props: {},
  145. data() {
  146. return {
  147. dialogVisible: false,
  148. treeData: [],
  149. linkList: [],
  150. uploadName: {
  151. name: '',
  152. all: 1,
  153. },
  154. treeId: 0,
  155. fileData: {
  156. page: 1,
  157. limit: 15,
  158. },
  159. total: 0,
  160. pids: 0,
  161. loading: false,
  162. multipleSelection: [],
  163. linkForm: {
  164. id: 0,
  165. name: '',
  166. url: '',
  167. sort: 0,
  168. status: 1,
  169. },
  170. highlightCurrent: true,
  171. };
  172. },
  173. mounted() {
  174. this.getList();
  175. },
  176. methods: {
  177. handleClose() {
  178. this.dialogVisible = false;
  179. this.initData();
  180. },
  181. onCopy(copyData) {
  182. this.$copyText(copyData)
  183. .then((message) => {
  184. this.$message.success('复制成功');
  185. })
  186. .catch((err) => {
  187. this.$message.error('复制失败');
  188. });
  189. },
  190. edit(row) {
  191. this.linkForm.name = row.name;
  192. this.linkForm.url = row.url;
  193. this.linkForm.sort = row.sort;
  194. this.linkForm.status = row.status;
  195. this.linkForm.id = row.id;
  196. this.dialogVisible = true;
  197. },
  198. addLinkSubmit() {
  199. this.$refs.linkForm.validate((valid) => {
  200. if (valid) {
  201. let data = {
  202. cate_id: this.treeId,
  203. id: this.linkForm.id,
  204. name: this.linkForm.name,
  205. url: this.linkForm.url,
  206. sort: this.linkForm.sort,
  207. status: this.linkForm.status,
  208. };
  209. linkCreateApi(data)
  210. .then((res) => {
  211. this.$message.success(res.msg);
  212. this.dialogVisible = false;
  213. this.getLinkList();
  214. })
  215. .catch((err) => {
  216. this.$message.error(err);
  217. });
  218. } else {
  219. return false;
  220. }
  221. });
  222. },
  223. // 点击菜单
  224. clickMenu(data, name) {
  225. if (name == 1) {
  226. this.editLinkCategory(data, 0);
  227. } else if (name == 2) {
  228. this.editLinkCategory(data, 1);
  229. } else if (name == 3) {
  230. this.remove(data, '分类');
  231. }
  232. },
  233. delImg(id) {
  234. let ids = {
  235. ids: id,
  236. };
  237. let delfromData = {
  238. title: '删除选中图片',
  239. url: `file/file/delete`,
  240. method: 'POST',
  241. ids: ids,
  242. };
  243. this.$modalSure(delfromData)
  244. .then((res) => {
  245. this.$message.success(res.msg);
  246. this.getLinkList();
  247. this.checkPicList = [];
  248. })
  249. .catch((res) => {
  250. this.$message.error(res.msg);
  251. });
  252. },
  253. // 删除图片
  254. editPicList(id) {
  255. let ids = {
  256. ids: id || this.ids.toString(),
  257. };
  258. let delfromData = {
  259. title: '删除选中图片',
  260. url: `file/file/delete`,
  261. method: 'POST',
  262. ids: ids,
  263. };
  264. this.$modalSure(delfromData)
  265. .then((res) => {
  266. this.$message.success(res.msg);
  267. this.getLinkList();
  268. this.initData();
  269. })
  270. .catch((res) => {
  271. this.$message.error(res.msg);
  272. });
  273. },
  274. initData() {
  275. this.fileData.page = 1;
  276. this.fileData.id = '';
  277. this.linkForm.name = '';
  278. this.linkForm.h5_url = '';
  279. this.linkForm.url = '';
  280. },
  281. // 鼠标移入 移出
  282. onMouseOver(root, node, data) {
  283. event.preventDefault();
  284. data.flag = !data.flag;
  285. if (data.flag2) {
  286. data.flag2 = false;
  287. }
  288. },
  289. addLink() {
  290. this.initData();
  291. this.dialogVisible = true;
  292. },
  293. // 点击树
  294. appendBtn(data, n, d) {
  295. if (data.pid == 1 && !n.expanded) {
  296. this.highlightCurrent = false;
  297. return;
  298. } else if (data.pid != 1) {
  299. this.treeId = data.id;
  300. this.fileData.page = 1;
  301. this.getLinkList();
  302. }
  303. },
  304. nodeExpand(data, n, d) {
  305. if (n.expanded) {
  306. if (data.children.length) {
  307. this.highlightCurrent = true;
  308. this.$nextTick(() => {
  309. this.fileData.page = 1;
  310. this.treeId = data.children[0].id || '';
  311. this.$refs['tree'].setCurrentKey(this.treeId);
  312. this.getLinkList();
  313. });
  314. }
  315. }
  316. },
  317. // 点击添加
  318. append() {
  319. this.getFrom();
  320. },
  321. // 删除分类
  322. remove(data, tit) {
  323. this.tits = tit;
  324. let delfromData = {
  325. title: '删除 [ ' + data.title + ' ] ' + '分类',
  326. url: `diy/link/category/del/${data.id}`,
  327. method: 'DELETE',
  328. ids: '',
  329. };
  330. this.$modalSure(delfromData)
  331. .then((res) => {
  332. this.$message.success(res.msg);
  333. this.getList();
  334. this.checkPicList = [];
  335. })
  336. .catch((res) => {
  337. this.$message.error(res.msg);
  338. });
  339. },
  340. // 编辑树表单
  341. editLinkCategory(data, type) {
  342. this.$modalForm(linkCategoryFormApi(type ? data.id : 0, data.id ? data.id : 1)).then(() => this.getList());
  343. },
  344. // 分类列表树
  345. getList(type) {
  346. diyLinkCategoryListApi(this.uploadName)
  347. .then((res) => {
  348. this.treeId = res.data.length > 0 ? res.data[0]?.children[0]?.id : '';
  349. this.treeData = res.data;
  350. this.getLinkList();
  351. })
  352. .catch((res) => {
  353. this.$message.error(res.msg);
  354. });
  355. },
  356. // 文件列表
  357. getLinkList() {
  358. this.fileData.id = this.treeId;
  359. this.loading = true;
  360. linkListApi(this.fileData)
  361. .then(async (res) => {
  362. this.linkList = res.data.list;
  363. this.total = res.data.count;
  364. this.loading = false;
  365. })
  366. .catch((res) => {
  367. this.loading = false;
  368. this.$message.error(res.msg);
  369. });
  370. },
  371. del(row, tit, num) {
  372. let delfromData = {
  373. title: tit,
  374. num: num,
  375. url: `diy/link/del/${row.id}`,
  376. method: 'DELETE',
  377. ids: '',
  378. };
  379. this.$modalSure(delfromData)
  380. .then((res) => {
  381. this.$message.success(res.msg);
  382. this.linkList.splice(num, 1);
  383. })
  384. .catch((res) => {
  385. this.$message.error(res.msg);
  386. });
  387. },
  388. addFlag(treedata) {
  389. treedata.map((item) => {
  390. this.$set(item, 'flag', false);
  391. this.$set(item, 'flag2', false);
  392. item.children && this.addFlag(item.children);
  393. });
  394. },
  395. pageChange(index) {
  396. this.fileData.page = index;
  397. this.getLinkList();
  398. this.checkPicList = [];
  399. },
  400. // 新建分类表单
  401. getFrom() {
  402. this.$modalForm(linkCategoryFormApi(0, 1)).then((res) => {
  403. this.getList();
  404. });
  405. },
  406. },
  407. };
  408. </script>
  409. <style scoped lang="scss">
  410. .box {
  411. width: 100%;
  412. height: 100%;
  413. background: #fff;
  414. }
  415. ::v-deep .el-card__body {
  416. min-height: 700px;
  417. padding: 16px 16px 16px 0;
  418. }
  419. ::v-deep .conter .linkList {
  420. max-width: 100%;
  421. }
  422. .nameStyle {
  423. position: absolute;
  424. white-space: nowrap;
  425. z-index: 9;
  426. background: #eee;
  427. height: 20px;
  428. line-height: 20px;
  429. color: #555;
  430. border: 1px solid #ebebeb;
  431. padding: 0 5px;
  432. left: 56px;
  433. bottom: -18px;
  434. }
  435. .tree_tit {
  436. padding-top: 7px;
  437. padding-bottom: 22px;
  438. }
  439. .treeBox {
  440. width: 100%;
  441. height: 100%;
  442. max-width: 180px;
  443. }
  444. .Nav {
  445. width: 100%;
  446. border-right: 1px solid #eee;
  447. min-width: 220px;
  448. max-width: max-content;
  449. }
  450. ::v-deep .tree .is-current {
  451. background-color: #fff !important;
  452. }
  453. .trees-coadd {
  454. width: 100%;
  455. border-radius: 4px;
  456. overflow: hidden;
  457. position: relative;
  458. .scollhide {
  459. overflow-x: hidden;
  460. overflow-y: scroll;
  461. padding: 0px 0 10px 0;
  462. box-sizing: border-box;
  463. .isTree {
  464. min-height: 374px;
  465. max-height: 550px;
  466. ::v-deep .file-name {
  467. display: flex;
  468. align-items: center;
  469. .name {
  470. max-width: 7em;
  471. }
  472. .icon {
  473. width: 12px;
  474. height: 12px;
  475. margin-right: 8px;
  476. }
  477. }
  478. ::v-deep .el-tree-node {
  479. margin-right: 16px;
  480. }
  481. ::v-deep .el-tree-node__children .el-tree-node {
  482. margin-right: 0;
  483. }
  484. ::v-deep .el-tree-node__content {
  485. width: 100%;
  486. height: 36px;
  487. }
  488. ::v-deep .custom-tree-node {
  489. flex: 1;
  490. display: flex;
  491. align-items: center;
  492. justify-content: space-between;
  493. padding-right: 20px;
  494. font-size: 13px;
  495. font-weight: 400;
  496. color: rgba(0, 0, 0, 0.6);
  497. line-height: 13px;
  498. }
  499. ::v-deep .is-current {
  500. background: #f1f9ff !important;
  501. color: var(--prev-color-primary) !important;
  502. }
  503. ::v-deep .is-current .custom-tree-node {
  504. color: var(--prev-color-primary) !important;
  505. }
  506. }
  507. }
  508. .scollhide::-webkit-scrollbar {
  509. display: none;
  510. }
  511. }
  512. .treeSel ::v-deep .ivu-select-dropdown-list {
  513. padding: 0 5px !important;
  514. box-sizing: border-box;
  515. width: 200px;
  516. }
  517. .imagesNo {
  518. display: flex;
  519. justify-content: center;
  520. flex-direction: column;
  521. align-items: center;
  522. margin: 65px 0;
  523. .imagesNo_sp {
  524. font-size: 13px;
  525. color: #dbdbdb;
  526. line-height: 3;
  527. }
  528. }
  529. .Modal {
  530. width: 100%;
  531. height: 100%;
  532. background: #fff !important;
  533. }
  534. .fill-window {
  535. height: 100vh;
  536. }
  537. .colLeft {
  538. padding-right: 0 !important;
  539. height: 100%;
  540. display: flex;
  541. flex-wrap: nowrap;
  542. }
  543. .conter {
  544. width: 100%;
  545. height: 100%;
  546. margin-left: 20px !important;
  547. .iconliebiao {
  548. font-size: 12px;
  549. }
  550. }
  551. .conter .bnt {
  552. width: 100%;
  553. padding: 0 0px 20px 0px;
  554. box-sizing: border-box;
  555. }
  556. .conter .linkList {
  557. // width: 100%;
  558. overflow-x: hidden;
  559. overflow-y: auto;
  560. min-height: 463px;
  561. }
  562. .conter .linkList.is-modal {
  563. max-height: 480px;
  564. }
  565. .conter .linkList img {
  566. max-width: 100%;
  567. }
  568. .conter .linkList .img.on {
  569. border: 2px solid var(--prev-color-primary);
  570. }
  571. .conter .footer {
  572. padding: 0 20px 10px 20px;
  573. }
  574. .card-tree {
  575. background: #fff;
  576. height: 72px;
  577. box-sizing: border-box;
  578. overflow-x: scroll; /* 设置溢出滚动 */
  579. white-space: nowrap;
  580. overflow-y: hidden;
  581. /* 隐藏滚动条 */
  582. border-radius: 4px;
  583. scrollbar-width: none; /* firefox */
  584. -ms-overflow-style: none; /* IE 10+ */
  585. }
  586. .card-tree::-webkit-scrollbar {
  587. display: none; /* Chrome Safari */
  588. }
  589. </style>