dialog.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. <template>
  2. <div class="pb_content" style="background: unset">
  3. <div class="pb_content_body" style="
  4. background: #fff;
  5. padding: 0px 25px;
  6. box-sizing: border-box;
  7. border-radius: 5px;
  8. ">
  9. <div class="reBox">
  10. <div class="reTop">
  11. <div>分类筛选</div>
  12. <div>
  13. <!-- @click="getCourse" -->
  14. <div class="search">
  15. <img src="../../../assets/icon/search.png" alt="" />
  16. </div>
  17. <input class="sInput" type="text" placeholder="请输入关键字" v-model="sourceName"
  18. @keyup.enter="getSource" />
  19. </div>
  20. </div>
  21. <div class="choose">
  22. <div class="all_choose" v-for="(item, index) in CourseType[0]" :key="index"
  23. :style="{ margin: !CourseTypeJson[item.id].length && 0 }">
  24. <span v-if="CourseTypeJson[item.id].length">{{ item.name }}:</span>
  25. <div class="typeCss" v-if="CourseTypeJson[item.id].length">
  26. <div class="cName" @click="getCourse2(item.name, '', item.id, 1)"
  27. :class="typeE.indexOf(item.id) != -1 ? 'isCType' : ''">
  28. 全部
  29. </div>
  30. <div v-for="(item1, index1) in CourseTypeJson[item.id]" :key="index + '-' + index1"
  31. :label="item1.id" @click="getCourse2(item.name, item.id, item1.id, 2)">
  32. <div class="cName" :class="typea == item1.id || typeb == item1.id
  33. ? 'isCType'
  34. : ''
  35. ">
  36. {{ item1.name }}
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="pb_content_body">
  45. <div class="student_table" v-loading="loading">
  46. <div class="source-box" v-for="(item, index) in res" :key="index">
  47. <img class="checkImg" src="../../../assets/icon/source/checka.png" @click="checka(item)" v-if="json[item.id]"/>
  48. <img class="checkImg" src="../../../assets/icon/source/check.png" @click="checka(item)" v-else/>
  49. <div class="iamge"><img src="../../../assets/icon/source/image.png" alt=""></div>
  50. <div class="title"><span>{{ item.name }}</span></div>
  51. <div class="detail">{{ item.detail }}</div>
  52. <div class="label"><span v-for="(k, ki) in item.label.split(',')" :key="index + '-' + ki">{{ k ? k : "无" }}</span>
  53. </div>
  54. <div class="button"><span @click="check(item.url)">查看</span></div>
  55. </div>
  56. <div v-if="!res.length" style="text-align: center; width: 100%;">暂无数据</div>
  57. </div>
  58. <div class="student_page">
  59. <el-pagination background layout="prev, pager, next" :page-size="pageSize" :total="total" v-if="page && total"
  60. @current-change="handleCurrentChange">
  61. </el-pagination>
  62. </div>
  63. </div>
  64. <el-dialog title="添加资源" :visible.sync="dialogVisible" :append-to-body="true" width="800px"
  65. :before-close="handleClose" class="dialog_diy">
  66. <div class="add-box">
  67. <div class="span-box">
  68. <span><span style="color: red">*</span>工具名称</span><el-input class="input" v-model="s_title"
  69. placeholder="请输入工具名称"></el-input>
  70. </div>
  71. <div class="type-box">
  72. <div class="both">
  73. <div class="choose2">
  74. <div class="all_choose2" v-for="(item, index) in CourseType[0]" :key="index">
  75. <span v-if="CourseTypeJson[item.id].length > 0
  76. ">{{ item.name }}</span>
  77. <el-checkbox-group v-model="courseTypeId2" v-if="CourseTypeJson[item.id].length > 0
  78. ">
  79. <el-checkbox v-for="item1 in CourseTypeJson[item.id]" :key="item1.id"
  80. :label="item1.id">{{ item1.name }}</el-checkbox>
  81. </el-checkbox-group>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. <div class="span-box">
  87. <span><span style="color: red">*</span>网址来源</span><el-input class="input" v-model="s_url"
  88. placeholder="请输入网址来源"></el-input>
  89. </div>
  90. <div class="span-box">
  91. <span><span style="color: red">*</span>工具描述</span><el-input class="input" type="textarea" resize="none"
  92. rows="5" v-model="s_detail" placeholder="请输入工具描述"></el-input>
  93. </div>
  94. <div class="span-box">
  95. <span>标签</span><el-select class="input" v-model="s_label" multiple placeholder="请选择标签">
  96. <el-option label="无需登录" value="无需登录"></el-option>
  97. <el-option label="扫码登录" value="扫码登录"></el-option>
  98. <el-option label="注册登录" value="注册登录"></el-option>
  99. <el-option label="免费" value="免费"></el-option>
  100. <el-option label="付费" value="付费"></el-option>
  101. <el-option label="中文" value="中文"></el-option>
  102. <el-option label="英文" value="英文"></el-option>
  103. </el-select>
  104. </div>
  105. </div>
  106. <span slot="footer" class="dialog-footer">
  107. <el-button @click="dialogVisible = false">取 消</el-button>
  108. <el-button type="primary" @click="add()">确定</el-button>
  109. </span>
  110. </el-dialog>
  111. </div>
  112. </template>
  113. <script>
  114. export default {
  115. data() {
  116. return {
  117. page: 1,
  118. pageSize: 20,
  119. total: 0,
  120. isLoading: false,
  121. dialogVisible: false,
  122. title: "",
  123. tableData: [],
  124. res: [],
  125. userid: this.$route.query.userid,
  126. org: this.$route.query.org,
  127. oid: this.$route.query.oid,
  128. CourseType: [],
  129. CourseTypeJson: {},
  130. courseTypeId: {},
  131. courseTypeSon: [],
  132. isChoose: 0,
  133. sourceName: "",
  134. typea: "",
  135. typeb: "",
  136. typeE: [],
  137. courseTypeId2: [],
  138. s_title: "",
  139. s_url: "",
  140. s_detail: "",
  141. s_label: [],
  142. json:{}
  143. };
  144. },
  145. mounted() {
  146. this.selectAllType();
  147. },
  148. methods: {
  149. checka(item){
  150. if(this.json[item.id]){
  151. delete this.json[item.id]
  152. }else{
  153. this.json[item.id] = item
  154. }
  155. this.$forceUpdate()
  156. this.$emit("update",this.json)
  157. },
  158. check(url){
  159. window.open(url)
  160. },
  161. handleCurrentChange(val) {
  162. this.page = val;
  163. this.getSource();
  164. },
  165. handleClose(done) {
  166. done();
  167. },
  168. selectAllType() {
  169. let params = {
  170. org: this.org && this.org != "" ? this.org : "",
  171. oid: this.oid && this.oid != "" ? this.oid : "",
  172. };
  173. this.ajax
  174. .get(this.$store.state.api + "selectAllSourceType", params)
  175. .then((res) => {
  176. this.CourseType = res.data;
  177. for (var i = 0; i < res.data[0].length; i++) {
  178. if (!this.cid) {
  179. this.courseTypeId[res.data[0][i].id] = [];
  180. }
  181. if (!this.CourseTypeJson[res.data[0][i].id]) {
  182. this.CourseTypeJson[res.data[0][i].id] = [];
  183. }
  184. if (res.data[2].length == 0 && res.data[3].length == 0) {
  185. for (var j = 0; j < res.data[1].length; j++) {
  186. if (res.data[0][i].id == res.data[1][j].pid) {
  187. this.CourseTypeJson[res.data[0][i].id].push(res.data[1][j]); // 去除公共分类
  188. }
  189. }
  190. } else {
  191. if (res.data[2].length > 0) {
  192. for (var j = 0; j < res.data[2].length; j++) {
  193. if (res.data[0][i].id == res.data[2][j].pid) {
  194. this.CourseTypeJson[res.data[0][i].id].push(res.data[2][j]); // 去除公共分类
  195. }
  196. }
  197. }
  198. if (res.data[3].length > 0) {
  199. for (var j = 0; j < res.data[3].length; j++) {
  200. if (res.data[0][i].id == res.data[3][j].pid) {
  201. this.CourseTypeJson[res.data[0][i].id].push(res.data[3][j]); // 去除公共分类
  202. }
  203. }
  204. }
  205. }
  206. }
  207. })
  208. .catch((err) => {
  209. console.error(err);
  210. });
  211. },
  212. getCourse2(typeName, ftypeId, typeid, type) {
  213. this.page = 1;
  214. if (typeName == "场景") {
  215. if (type == 1) {
  216. if (this.typeE.indexOf(typeid) != -1) {
  217. this.typeE.splice(this.typeE.indexOf(typeid), 1);
  218. } else {
  219. this.typeE.push(typeid);
  220. if (this.typea != "") {
  221. this.typea = "";
  222. }
  223. }
  224. } else {
  225. if (this.typea == typeid) {
  226. this.typea = "";
  227. } else {
  228. this.typea = typeid;
  229. if (this.typeE.indexOf(ftypeId) != -1) {
  230. this.typeE.splice(this.typeE.indexOf(ftypeId), 1);
  231. }
  232. }
  233. }
  234. } else if (typeName == "类型") {
  235. if (type == 1) {
  236. if (this.typeE.indexOf(typeid) != -1) {
  237. this.typeE.splice(this.typeE.indexOf(typeid), 1);
  238. } else {
  239. this.typeE.push(typeid);
  240. if (this.typeb != "") {
  241. this.typeb = "";
  242. }
  243. }
  244. } else {
  245. if (this.typeb == typeid) {
  246. this.typeb = "";
  247. } else {
  248. this.typeb = typeid;
  249. if (this.typeE.indexOf(ftypeId) != -1) {
  250. this.typeE.splice(this.typeE.indexOf(ftypeId), 1);
  251. }
  252. }
  253. }
  254. }
  255. this.getSource();
  256. },
  257. getSource() {
  258. this.loading = true
  259. let params = {
  260. uid: this.userid,
  261. oid: this.oid,
  262. org: this.org,
  263. typea: this.typea != undefined ? this.typea : "",
  264. typeb: this.typeb != undefined ? this.typeb : "",
  265. typeE: this.typeE.join(","),
  266. cn: this.sourceName,
  267. page: this.page,
  268. pageSize: this.pageSize,
  269. };
  270. this.ajax
  271. .get(this.$store.state.api + "selectSource", params)
  272. .then((res) => {
  273. this.loading = false
  274. this.res = res.data[0];
  275. this.total = res.data[0].length ? res.data[0][0].num : 0;
  276. })
  277. .catch((err) => {
  278. console.error(err);
  279. });
  280. },
  281. addSource() {
  282. this.courseTypeId2 = []
  283. this.s_title = ""
  284. this.s_url = ""
  285. this.s_detail = ""
  286. this.s_label = []
  287. this.dialogVisible = true
  288. },
  289. add() {
  290. if (this.s_title == '') {
  291. this.$message.error('请填写工具名称')
  292. return
  293. }
  294. if (this.s_url == '') {
  295. this.$message.error('请填写网址来源')
  296. return
  297. }
  298. if (this.s_detail == '') {
  299. this.$message.error('请填写工具描述')
  300. return
  301. }
  302. let params = [{
  303. name: this.s_title,
  304. url: this.s_url,
  305. detail: this.s_detail,
  306. label: this.s_label.join(","),
  307. userid: this.userid,
  308. courseType: JSON.stringify(this.courseTypeId2)
  309. }]
  310. this.ajax
  311. .post(this.$store.state.api + "addSource", params)
  312. .then((res) => {
  313. this.$message({
  314. message: "添加成功",
  315. type: "success",
  316. });
  317. this.dialogVisible = false
  318. this.getSource();
  319. })
  320. .catch((err) => {
  321. this.$message.error("网络不佳");
  322. console.error(err);
  323. });
  324. }
  325. },
  326. created() {
  327. this.getSource();
  328. },
  329. };
  330. </script>
  331. <style scoped>
  332. .pb_head {
  333. display: flex;
  334. justify-content: space-between;
  335. }
  336. .student_head {
  337. margin-bottom: 20px;
  338. }
  339. .student_page {
  340. margin-top: 10px;
  341. }
  342. .pb_head {
  343. margin: 0 !important;
  344. width: 100% !important;
  345. }
  346. .bgColor {
  347. background: #466b99;
  348. }
  349. .reBox {
  350. background: #fff;
  351. margin: 0 auto;
  352. padding: 10px 5px;
  353. box-sizing: border-box;
  354. }
  355. .reTop {
  356. padding: 0 0 5px;
  357. /* padding: 20px 0 0 0; */
  358. /* border-bottom: 1px solid #eee; */
  359. display: flex;
  360. flex-direction: row;
  361. flex-wrap: nowrap;
  362. align-items: center;
  363. justify-content: space-between;
  364. }
  365. .reTop>div:nth-child(1) {
  366. font-weight: bold;
  367. /* width: 40px; */
  368. /* border-bottom: 1px solid #205cc6; */
  369. /* padding-bottom: 20px; */
  370. color: #205cc6;
  371. /* font-size: 20px; */
  372. }
  373. .reTop>div:nth-child(2) {
  374. display: flex;
  375. flex-direction: row;
  376. align-items: center;
  377. border: 1px solid #ccced3;
  378. width: 300px;
  379. border-radius: 8px;
  380. padding: 5px 0;
  381. /* margin-bottom: 10px; */
  382. background: #fafafa;
  383. }
  384. .search {
  385. width: 20px;
  386. padding: 0 5px;
  387. }
  388. .search>img {
  389. width: 100%;
  390. height: 100%;
  391. }
  392. .sInput {
  393. border: none;
  394. width: 85%;
  395. background: #fafafa;
  396. }
  397. .sInput:focus-visible {
  398. outline: none;
  399. }
  400. .typeCss {
  401. display: flex;
  402. flex-direction: row;
  403. flex-wrap: wrap;
  404. justify-content: flex-start;
  405. align-items: center;
  406. }
  407. .choose {
  408. display: flex;
  409. flex-direction: column;
  410. flex-wrap: nowrap;
  411. height: 100%;
  412. justify-content: space-evenly;
  413. align-items: flex-start;
  414. padding: 10px 0;
  415. }
  416. .all_choose {
  417. display: flex;
  418. flex-direction: row;
  419. align-items: baseline;
  420. margin: 2px 0;
  421. width: 100%;
  422. }
  423. .all_choose>span {
  424. min-width: 80px;
  425. display: block;
  426. letter-spacing: 14px;
  427. }
  428. .all_choose>span:nth-child(1) {
  429. font-weight: bold;
  430. }
  431. .cName {
  432. cursor: pointer;
  433. margin: 0 10px 5px 0;
  434. color: #b9b6b9;
  435. min-width: 80px;
  436. width: 80px;
  437. white-space: nowrap;
  438. overflow: hidden;
  439. text-overflow: ellipsis;
  440. }
  441. .isCType {
  442. color: #6282c2;
  443. }
  444. .dialog_diy>>>.el-dialog {
  445. height: 100% !important;
  446. margin: 0 auto !important;
  447. }
  448. .dialog_diy>>>.el-dialog__header {
  449. background: #3c3c3c !important;
  450. padding: 15px 20px;
  451. }
  452. .dialog_diy>>>.el-dialog__title {
  453. color: #fff;
  454. }
  455. .dialog_diy>>>.el-dialog__headerbtn {
  456. top: 19px;
  457. }
  458. .dialog_diy>>>.el-dialog__headerbtn .el-dialog__close {
  459. color: #fff;
  460. }
  461. .dialog_diy>>>.el-dialog__headerbtn .el-dialog__close:hover {
  462. color: #fff;
  463. }
  464. .dialog_diy>>>.el-dialog__body,
  465. .dialog_diy>>>.el-dialog__footer {
  466. background: #fafafa;
  467. }
  468. .dialog_diy>>>.el-dialog__body {
  469. height: calc(100% - 125px);
  470. box-sizing: border-box;
  471. }
  472. .both {
  473. display: flex;
  474. flex-direction: row;
  475. flex-wrap: wrap;
  476. width: 100%;
  477. align-items: center;
  478. justify-content: flex-start;
  479. margin: 15px 0;
  480. }
  481. .all_choose2 {
  482. display: flex;
  483. flex-direction: row;
  484. align-items: flex-start;
  485. width: 100%;
  486. }
  487. .all_choose2>span {
  488. min-width: 100px;
  489. display: block;
  490. letter-spacing: 14px;
  491. white-space: nowrap;
  492. overflow: hidden;
  493. text-overflow: ellipsis;
  494. }
  495. .all_choose2>span:nth-child(1) {
  496. font-weight: bold;
  497. }
  498. .all_choose2>>>.el-checkbox-group {
  499. display: flex;
  500. flex-direction: row;
  501. width: 100%;
  502. flex-wrap: wrap;
  503. align-content: center;
  504. justify-content: flex-start;
  505. align-items: center;
  506. margin-top: 3px;
  507. }
  508. .all_choose2>.el-checkbox-group>>>.el-checkbox {
  509. margin-bottom: 10px;
  510. display: flex;
  511. flex-direction: row;
  512. align-items: center;
  513. }
  514. .all_choose2>.el-checkbox-group>.el-checkbox>>>.el-checkbox__label {
  515. min-width: 80px;
  516. overflow: hidden;
  517. width: 80px;
  518. text-overflow: ellipsis;
  519. white-space: nowrap;
  520. }
  521. .all_choose2>.el-checkbox-group>.el-checkbox>>>.el-checkbox__label:hover {
  522. width: auto;
  523. }
  524. .choose2 {
  525. display: flex;
  526. flex-direction: column;
  527. flex-wrap: nowrap;
  528. height: 100%;
  529. justify-content: space-evenly;
  530. align-items: flex-start;
  531. }
  532. .add-box {
  533. height: 100%;
  534. overflow: auto;
  535. width: 100%;
  536. background: #fff;
  537. border-radius: 10px;
  538. box-sizing: border-box;
  539. padding: 20px;
  540. }
  541. .span-box {
  542. display: flex;
  543. margin-bottom: 20px;
  544. }
  545. .span-box>span {
  546. font-weight: bold;
  547. min-width: 100px;
  548. }
  549. .span-box>.input {
  550. width: 100%;
  551. }
  552. .type-box {
  553. width: 100%;
  554. }
  555. .student_table {
  556. display: flex;
  557. flex-wrap: wrap;
  558. }
  559. .source-box {
  560. width: calc(100% / 4 - 15px);
  561. background: #fff;
  562. overflow: hidden;
  563. margin: 0 20px 20px 0;
  564. position: relative;
  565. }
  566. .source-box:nth-child(4n){
  567. margin-right: 0;
  568. }
  569. .checkImg{
  570. position: absolute;
  571. top: 10px;
  572. z-index: 10;
  573. right: 10px;
  574. cursor: pointer;
  575. }
  576. .source-box .iamge {
  577. width: 208px;
  578. height: 180px;
  579. margin: 0 auto;
  580. }
  581. .source-box .iamge>img {
  582. width: 100%;
  583. height: 100%;
  584. }
  585. .source-box .title {
  586. width: 90%;
  587. font-size: 18px;
  588. text-align: center;
  589. margin: 5px auto;
  590. font-weight: 700;
  591. overflow: hidden;
  592. white-space: nowrap;
  593. text-overflow: ellipsis;
  594. height:24px;
  595. }
  596. .source-box .detail {
  597. text-align: center;
  598. width: 90%;
  599. margin: 5px auto;
  600. color: #acacac;
  601. display: block;
  602. overflow: hidden;
  603. text-overflow: ellipsis;
  604. -o-text-overflow: ellipsis;
  605. display: -webkit-box;
  606. -webkit-line-clamp: 2;
  607. -webkit-box-orient: vertical;
  608. height: 42px;
  609. }
  610. .source-box .label {
  611. width: 90%;
  612. margin: 10px auto 5px;
  613. display: flex;
  614. flex-wrap: wrap;
  615. }
  616. .source-box .label>span {
  617. padding: 5px 10px;
  618. background: rgb(98, 180, 238);
  619. color: #fff;
  620. border-radius: 5px;
  621. margin: 0 0 5px 5px;
  622. }
  623. .source-box .button {
  624. width: 100%;
  625. text-align: center;
  626. display: flex;
  627. height: 40px;
  628. background: rgb(244, 244, 244);
  629. }
  630. .source-box .button>span {
  631. width: 100%;
  632. cursor: pointer;
  633. height: 100%;
  634. line-height: 40px;
  635. }</style>