index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <div id="goodTopic">
  3. <!-- <search-box-new
  4. ref="searchBox"
  5. :formData="formData"
  6. :formList="formList"
  7. @search="search"
  8. @init="init"
  9. :topType="topType"
  10. /> -->
  11. <table-list
  12. :tableSets="tableSet"
  13. :tableData="tableData"
  14. :navText="navText"
  15. :loading="loading"
  16. >
  17. <template slot="btn" slot-scope="props">
  18. <el-button type="text" @click="share(props.scope.row)">分享</el-button>
  19. </template>
  20. </table-list>
  21. <pagination
  22. :total="total"
  23. :pageSize="formData.pageSize"
  24. :currentPage="formData.pageNum"
  25. @handleSizeChange="handleSizeChange"
  26. @handleCurrentChange="handleCurrentChange"
  27. />
  28. <el-dialog
  29. :visible.sync="dialogVisible"
  30. width="650px"
  31. :show-close="false"
  32. :close-on-click-modal="false"
  33. destroy-on-close
  34. >
  35. <div slot="title" class="hearders">
  36. <div class="leftTitle">分享</div>
  37. <div class="rightBoxs">
  38. <img
  39. src="@/assets/images/Close@2x.png"
  40. alt=""
  41. @click="dialogVisible = false"
  42. />
  43. </div>
  44. </div>
  45. <el-form label-width="180px" :model="formLabelAlign">
  46. <el-form-item label="观看链接:">
  47. <span id="copycode">{{ formLabelAlign.enCodePC }}</span
  48. ><el-button
  49. v-if="formLabelAlign.enCodePC"
  50. type="text"
  51. style="margin-left: 10px"
  52. @click="copyUrl"
  53. >复制</el-button
  54. >
  55. </el-form-item>
  56. <el-form-item label="观看二维码:" v-if="false">
  57. <img
  58. style="width: 100px; height: 100px"
  59. :src="formLabelAlign.enCode"
  60. alt=""
  61. />
  62. <el-button
  63. type="text"
  64. @click="downloadFileByBase64(formLabelAlign.enCode, '小程序二维码')"
  65. >下载</el-button
  66. >
  67. </el-form-item>
  68. </el-form>
  69. <span slot="footer" class="dialog-footer">
  70. <el-button @click="dialogVisible = false">关 闭</el-button>
  71. <!-- <el-button type="primary" @click="submitTable">保 存</el-button> -->
  72. </span>
  73. </el-dialog>
  74. </div>
  75. </template>
  76. <script>
  77. import searchBoxNew from "@/components/searchBoxNew";
  78. import tableList from "@/components/tableList";
  79. import pagination from "@/components/pagination";
  80. export default {
  81. name: "GoodTopic",
  82. components: { searchBoxNew, tableList, pagination },
  83. data() {
  84. return {
  85. loading: false, //当前表单加载是否加载动画
  86. navText: {
  87. title: "商品专题页",
  88. index: 0,
  89. ch: "条",
  90. num: false,
  91. border: true,
  92. choice: true,
  93. addHide: true,
  94. changeWidth: "180px",
  95. backFatherBtn: {
  96. status: false,
  97. title: "未定义",
  98. },
  99. },
  100. topType: true,
  101. dialogVisible: false, //分享窗口
  102. formLabelAlign: {
  103. enCodePC: '',
  104. enCode: '',
  105. },
  106. //搜索
  107. formList: [],
  108. formData: {
  109. pageSize: 10,
  110. pageNum: 1,
  111. },
  112. // 表单
  113. tableSet: [
  114. {
  115. label: "教育类型",
  116. prop: "educationName",
  117. hidden: true,
  118. },
  119. {
  120. label: "业务层次",
  121. prop1: "projectName",
  122. prop2: "businessName",
  123. hidden: true,
  124. scope: "InfoMore",
  125. },
  126. {
  127. label: "业务层次别名",
  128. prop: "aliasName",
  129. hidden: true,
  130. },
  131. {
  132. label: "专题页状态",
  133. prop: "status",
  134. hidden: true,
  135. scope: "isOptions",
  136. options: [
  137. {
  138. label: "启用",
  139. value: 1,
  140. },
  141. {
  142. label: "关闭",
  143. value: 0,
  144. },
  145. ],
  146. },
  147. ],
  148. tableData: [], //表单数据
  149. total: 0, //一共多少条
  150. };
  151. },
  152. mounted() {
  153. this.search();
  154. },
  155. activated() {
  156. this.search();
  157. },
  158. methods: {
  159. share(v) {
  160. this.formLabelAlign.enCodePC = v.enCodePC
  161. this.formLabelAlign.enCode = v.enCode
  162. this.dialogVisible = true
  163. },
  164. search(int) {
  165. this.loading = true;
  166. if (int === 1) {
  167. this.formData.pageNum = 1;
  168. }
  169. if (int === 2) {
  170. this.formData = {
  171. pageSize: 10,
  172. pageNum: 1,
  173. };
  174. }
  175. if (int === 3) {
  176. this.formData.pageNum = 1;
  177. }
  178. var data = JSON.parse(JSON.stringify(this.formData));
  179. this.$api
  180. .inquirecoursetopiclist(data)
  181. .then((res) => {
  182. this.tableData = res.rows;
  183. this.total = res.total;
  184. this.navText.index = res.total;
  185. })
  186. .finally(() => {
  187. this.loading = false;
  188. });
  189. },
  190. init() {
  191. this.search(2);
  192. },
  193. /**
  194. * 复制地址
  195. */
  196. copyUrl() {
  197. const range = document.createRange();//创建range对象;
  198. range.selectNode(document.getElementById("copycode")); //获取复制内容的 id 选择器
  199. const selection = window.getSelection(); //创建 selection对象
  200. if (selection.rangeCount > 0) selection.removeAllRanges(); //如果页面已经有选取了的话,会自动删除这个选区,没有选区的话,会把这个选取加入选区
  201. selection.addRange(range); //将range对象添加到selection选区当中,会高亮文本块
  202. document.execCommand("copy"); //复制选中的文字到剪贴板
  203. this.$message.success("复制成功");
  204. selection.removeRange(range); // 移除选中的元素
  205. },
  206. //将base64转换为blob
  207. dataURLtoBlob(dataurl) {
  208. if (!dataurl) {
  209. this.$message.error("下载失败");
  210. return;
  211. }
  212. var arr = dataurl.split(","),
  213. mime = arr[0].match(/:(.*?);/)[1],
  214. bstr = atob(arr[1]),
  215. n = bstr.length,
  216. u8arr = new Uint8Array(n);
  217. while (n--) {
  218. u8arr[n] = bstr.charCodeAt(n);
  219. }
  220. return new Blob([u8arr], { type: mime });
  221. },
  222. //下载方法
  223. downloadFile(url, name = "下载图") {
  224. var a = document.createElement("a");
  225. a.setAttribute("href", url);
  226. a.setAttribute("download", name);
  227. a.setAttribute("target", "_blank");
  228. let clickEvent = document.createEvent("MouseEvents");
  229. clickEvent.initEvent("click", true, true);
  230. a.dispatchEvent(clickEvent);
  231. },
  232. downloadFileByBase64(base64, name) {
  233. var myBlob = this.dataURLtoBlob(base64);
  234. var myUrl = URL.createObjectURL(myBlob);
  235. this.downloadFile(myUrl, name);
  236. },
  237. del(v) {
  238. this.$api.gradecheckGoodsChange({ goodsId: v.goodsId }).then((res) => {
  239. if (res.data > 0) {
  240. this.$message.error("已有学员正在学习该商品,无法删除");
  241. return;
  242. } else {
  243. this.$alert(
  244. "确定删除此内容?<br />内容删除后将无法恢复,请慎重考虑",
  245. "提示",
  246. {
  247. dangerouslyUseHTMLString: true,
  248. }
  249. )
  250. .then(() => {
  251. var data = {
  252. goodsId: v.goodsId,
  253. status: -1,
  254. };
  255. this.$api.editGoods(data).then((res) => {
  256. this.$message.success("删除成功");
  257. this.search();
  258. });
  259. })
  260. .catch(() => {
  261. this.$message({
  262. type: "info",
  263. message: "已取消删除",
  264. });
  265. });
  266. }
  267. });
  268. },
  269. handleSizeChange(v) {
  270. this.formData.pageSize = v;
  271. this.formData.pageNum = 1;
  272. this.search();
  273. },
  274. handleCurrentChange(v) {
  275. this.formData.pageNum = v;
  276. this.search();
  277. },
  278. },
  279. };
  280. </script>
  281. <style lang="less" scoped>
  282. /deep/.el-button {
  283. border-radius: 8px;
  284. }
  285. /deep/.el-dialog {
  286. border-radius: 8px;
  287. .el-dialog__header {
  288. padding: 0;
  289. .hearders {
  290. height: 40px;
  291. display: flex;
  292. align-items: center;
  293. justify-content: space-between;
  294. padding: 0px 18px 0px 20px;
  295. border-bottom: 1px solid #e2e2e2;
  296. .leftTitle {
  297. font-size: 14px;
  298. font-weight: bold;
  299. color: #2f4378;
  300. }
  301. .rightBoxs {
  302. display: flex;
  303. align-items: center;
  304. img {
  305. width: 14px;
  306. height: 14px;
  307. margin-left: 13px;
  308. cursor: pointer;
  309. }
  310. }
  311. }
  312. }
  313. .el-dialog__footer {
  314. padding: 0;
  315. .dialog-footer {
  316. padding: 0px 40px;
  317. height: 70px;
  318. border-top: 1px solid #e2e2e2;
  319. display: flex;
  320. align-items: center;
  321. justify-content: flex-end;
  322. }
  323. }
  324. }
  325. .imgBox {
  326. width: 100%;
  327. // height: 210px;
  328. border: 1px solid #e2e2e2;
  329. border-radius: 8px;
  330. padding: 8px 8px 3px;
  331. display: flex;
  332. flex-direction: column;
  333. align-items: center;
  334. .imgLabel {
  335. flex: 1;
  336. width: 100%;
  337. border: 1px dotted #e2e2e2;
  338. color: #999;
  339. font-size: 14px;
  340. cursor: pointer;
  341. border-radius: 8px;
  342. .msPhoto {
  343. display: flex;
  344. justify-content: center;
  345. align-items: center;
  346. max-width: 100%;
  347. max-height: 270px;
  348. img {
  349. max-width: 100%;
  350. max-height: 270px;
  351. }
  352. }
  353. .imgbbx {
  354. display: flex;
  355. flex-direction: column;
  356. align-items: center;
  357. justify-content: center;
  358. width: 100%;
  359. height: 100%;
  360. i {
  361. font-weight: bold;
  362. margin: 14px 0;
  363. font-size: 24px;
  364. }
  365. }
  366. }
  367. p {
  368. margin: 5px 0px;
  369. }
  370. }
  371. </style>