index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <!-- 内容管理 视频管理 -->
  2. <template>
  3. <div class="app-container">
  4. <!-- 搜索 -->
  5. <el-form inline size="mini">
  6. <el-form-item label="创建时间:">
  7. <el-date-picker
  8. v-model="form.listDate"
  9. type="datetimerange"
  10. start-placeholder="开始日期"
  11. end-placeholder="结束日期"
  12. value-format="yyyy-MM-dd HH:mm:ss"
  13. />
  14. </el-form-item>
  15. <el-form-item>
  16. <el-button type="primary" icon="el-icon-search" @click="getSearch"
  17. >搜索</el-button
  18. >
  19. <el-button icon="el-icon-refresh" @click="getRefresh">重置</el-button>
  20. <el-button
  21. type="primary"
  22. icon="el-icon-plus"
  23. plain
  24. @click="getDetail()"
  25. v-hasPermi="['content:video:add']"
  26. >新增</el-button
  27. >
  28. </el-form-item>
  29. </el-form>
  30. <!-- 列表 -->
  31. <el-table :data="tableData" v-loading="loading">
  32. <el-table-column
  33. label="序号"
  34. type="index"
  35. align="center"
  36. ></el-table-column>
  37. <el-table-column
  38. label="视频宣传名称"
  39. prop="name"
  40. align="center"
  41. ></el-table-column>
  42. <el-table-column
  43. label="更新时间"
  44. prop="updateTime"
  45. align="center"
  46. ></el-table-column>
  47. <el-table-column
  48. label="创建时间"
  49. prop="createTime"
  50. align="center"
  51. ></el-table-column>
  52. <el-table-column label="操作" align="center">
  53. <template slot-scope="scope">
  54. <el-button type="text" @click="getDetail(scope.row.id, true)"
  55. >查看</el-button
  56. >
  57. <el-button
  58. type="text"
  59. @click="getDetail(scope.row.id)"
  60. v-hasPermi="['content:video:edit']"
  61. >编辑</el-button
  62. >
  63. <el-button
  64. type="text"
  65. v-clipboard:copy="getUrl(scope.row)"
  66. v-clipboard:success="copySuccess"
  67. >复制链接</el-button
  68. >
  69. <el-button type="text" @click="getCode(scope.row.id)"
  70. >下载二维码</el-button
  71. >
  72. <el-button
  73. type="delete"
  74. @click="getDelete(scope.row)"
  75. v-hasPermi="['content:video:delete']"
  76. >删除</el-button
  77. >
  78. <vue-qr
  79. :text="getUrl(scope.row)"
  80. :ref="`qrcode` + scope.row.id"
  81. style="display: none"
  82. />
  83. </template>
  84. </el-table-column>
  85. </el-table>
  86. <pagination
  87. v-show="total > 0"
  88. :total="total"
  89. :page.sync="form.pageNum"
  90. :limit.sync="form.pageSize"
  91. @pagination="getList"
  92. />
  93. </div>
  94. </template>
  95. <script>
  96. import { change, list } from "@/api/content/video";
  97. import { dialogCallBack } from "@/utils/DialogUtil";
  98. import VueQr from "vue-qr";
  99. export default {
  100. components: {
  101. VueQr,
  102. },
  103. data() {
  104. return {
  105. // 遮罩层
  106. loading: false,
  107. // 表单
  108. form: {
  109. pageNum: 1,
  110. pageSize: 10,
  111. },
  112. // 总数据
  113. total: 0,
  114. // 列表
  115. tableData: [],
  116. };
  117. },
  118. mounted() {
  119. this.getList();
  120. },
  121. methods: {
  122. // 列表
  123. getList() {
  124. this.loading = true;
  125. list(this.form).then((res) => {
  126. if (res.code === 0) {
  127. this.tableData = res.data.records;
  128. this.total = res.data.total;
  129. this.loading = false;
  130. }
  131. });
  132. },
  133. // 搜索
  134. getSearch() {
  135. this.form.pageNum = 1;
  136. this.getList();
  137. },
  138. // 重置
  139. getRefresh() {
  140. this.form = {
  141. pageNum: 1,
  142. pageSize: 10,
  143. };
  144. this.getList();
  145. },
  146. // 新增 查看 编辑
  147. getDetail(id, boolean) {
  148. this.$router.push({
  149. path: `/content/video/detail`,
  150. query: {
  151. id: id,
  152. boolean: boolean,
  153. },
  154. });
  155. },
  156. // H5路径
  157. getUrl(e) {
  158. return `${e.copyUrl}pages/devices/detail?clientType=${e.clientType}&id=${e.id}`;
  159. },
  160. // 复制成功
  161. copySuccess() {
  162. this.$message.success("复制成功!");
  163. },
  164. // 下载二维码
  165. getCode(id) {
  166. const url = this.$refs["qrcode" + id].$el.src;
  167. this.$download.saveAs(url, "二维码.png");
  168. },
  169. // 删除
  170. getDelete(row) {
  171. var that = this;
  172. dialogCallBack(that, function () {
  173. that
  174. .$confirm(`是否删除${row.name}?`, "提示", {
  175. type: "warning",
  176. })
  177. .then(() => {
  178. change(row.id, 2).then((res) => {
  179. if (res.code === 0) {
  180. that.$message.success("删除成功!");
  181. that.getList();
  182. }
  183. });
  184. });
  185. });
  186. },
  187. },
  188. };
  189. </script>