index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <div class="videos pagePadding">
  3. <div
  4. v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
  5. >
  6. <ex-table
  7. v-loading="loading"
  8. v-if="
  9. powers && powers.length > 0 && powers.some((item) => item == '001')
  10. "
  11. :table="table"
  12. :data="tableData"
  13. :columns="columns"
  14. :page="pageInfo"
  15. :size="size"
  16. @page-curr-change="handlePageChange"
  17. @page-size-change="handleSizeChange"
  18. @screen-reset="
  19. pageInfo.curr = 1;
  20. searchList();
  21. "
  22. @screen-submit="
  23. pageInfo.curr = 1;
  24. searchList();
  25. "
  26. >
  27. <template #table-header="{}">
  28. <el-col style="width: 150px;">
  29. <el-select
  30. :size="searchSize"
  31. v-model="parmValue.status"
  32. placeholder="请选择状态">
  33. <el-option
  34. v-for="item in statusList"
  35. :key="'status' + item.id"
  36. :label="item.label"
  37. :value="item.id"/>
  38. </el-select>
  39. </el-col>
  40. <div style="width: 100%">
  41. <el-row>
  42. <el-col :span="15">
  43. <el-input
  44. :size="searchSize"
  45. placeholder="请输入内容"
  46. v-model="input"
  47. class="input-with-select">
  48. <el-select
  49. v-model="select"
  50. slot="prepend"
  51. placeholder="请选择"
  52. style="width:120px;">
  53. <el-option label="视频名称" value="1"></el-option>
  54. <el-option label="视频链接" value="2"></el-option>
  55. <el-option label="视频编号" value="3"></el-option>
  56. </el-select>
  57. <el-button
  58. slot="append"
  59. @click.native="searchList"
  60. icon="el-icon-search">
  61. </el-button>
  62. </el-input>
  63. </el-col>
  64. <el-col
  65. :span="3"
  66. style="width: 60px; float: left;margin-left:10px">
  67. <el-button
  68. type="warning"
  69. :size="searchSize"
  70. @click="restSearch">
  71. 重置
  72. </el-button>
  73. </el-col>
  74. <el-col
  75. :span="3"
  76. v-if="powers.some((item) => item == '003')"
  77. style="width: 60px; float: right">
  78. <el-button
  79. type="primary"
  80. :size="searchSize"
  81. @click="restSearch">
  82. 搜索
  83. </el-button>
  84. </el-col>
  85. <el-col
  86. :span="2"
  87. v-if="powers.some((item) => item == '003')"
  88. style="width: 60px; float: right;margin-right:20px">
  89. <el-button
  90. v-if="powers.some((item) => item == '003')"
  91. type="primary"
  92. :size="searchSize"
  93. @click="openModal('add', '003', {})">
  94. 添加
  95. </el-button>
  96. </el-col>
  97. </el-row>
  98. </div>
  99. </template>
  100. <template #operation="{ scope }">
  101. <el-tooltip
  102. v-if="powers.some((item) => item == '007')"
  103. class="item"
  104. effect="dark"
  105. content="详情"
  106. placement="top"
  107. >
  108. <i
  109. class="el-icon-view tb-icon"
  110. @click="openModal(scope.row.id, '007', scope.row)"
  111. ></i>
  112. </el-tooltip>
  113. <el-tooltip
  114. v-if="powers.some((item) => item == '005')"
  115. class="item"
  116. effect="dark"
  117. content="修改"
  118. placement="top"
  119. >
  120. <i
  121. class="el-icon-edit tb-icon"
  122. @click="openModal(scope.row.id, '005', scope.row)"
  123. ></i>
  124. </el-tooltip>
  125. <el-tooltip
  126. v-if="powers.some((item) => item == '004')&&scope.row.status==='1'"
  127. class="item"
  128. effect="dark"
  129. content="禁用"
  130. placement="top"
  131. @click="openModal(scope.row.id, '004', scope.row)"
  132. >
  133. <i
  134. class="tb-icon el-icon-error"
  135. @click="selectPop(scope.row.status,scope.row.id)"
  136. ></i>
  137. </el-tooltip>
  138. <el-tooltip
  139. v-if="powers.some((item) => item == '004')&&scope.row.status!=='1'"
  140. class="item"
  141. effect="dark"
  142. content="启用"
  143. placement="top"
  144. @click="openModal(scope.row.id, '004', scope.row)"
  145. >
  146. <i
  147. class="tb-icon el-icon-success"
  148. @click="selectPop(scope.row.status,scope.row.id)"
  149. ></i>
  150. </el-tooltip>
  151. <el-tooltip
  152. v-if="powers.some((item) => item == '006')"
  153. class="item"
  154. effect="dark"
  155. content="删除"
  156. placement="top"
  157. @click="openModal(scope.row.id, '006', scope.row)"
  158. >
  159. <i
  160. class="tb-icon el-icon-delete-solid"
  161. @click="deletePop(scope.row.id)"
  162. ></i>
  163. </el-tooltip>
  164. </template>
  165. <template #status="{ scope }">
  166. <el-tag
  167. :size="tablebtnSize"
  168. :type="scope.row.status == '0' ? 'danger' : scope.row.status == '1'?'success':''"
  169. v-text="
  170. (statusList.find((item) => item.status == scope.row.status) || {})
  171. .label || '--'
  172. ">
  173. </el-tag>
  174. </template>
  175. </ex-table>
  176. <add-edit
  177. :id="modelId"
  178. :sitem="sitem"
  179. :show-model="showModel"
  180. :is-detail="isDetail"
  181. @refresh="searchList"
  182. @cancel="showModel = false"
  183. />
  184. </div>
  185. <div v-else>
  186. <no-auth></no-auth>
  187. </div>
  188. </div>
  189. </template>
  190. <script>
  191. import mixinPage from "@/mixins/elPaginationHandle";
  192. import asyncRequest from "@/apis/service/videos/videoList";
  193. import ExTable from "@/components/ExTableNew.vue";
  194. import addEdit from "./addEdit";
  195. import { mapGetters } from "vuex";
  196. import resToken from "@/mixins/resToken";
  197. export default {
  198. name: "videos",
  199. components: {
  200. addEdit,
  201. ExTable,
  202. },
  203. mixins: [mixinPage, resToken],
  204. computed: {
  205. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  206. powers() {
  207. let tran = this.$store.getters.btnList.find((item) => item.menu_route == "videos") || {};
  208. if (tran && tran.action && tran.action.length > 0) {
  209. return tran.action;
  210. } else {
  211. return [];
  212. }
  213. },
  214. },
  215. data() {
  216. return {
  217. sitem: null,
  218. select: "",
  219. input: "",
  220. statusList: [
  221. { status: "1", label: "启用" },
  222. { status: "0", label: "禁用" },
  223. ],
  224. loading: true,
  225. showModel: false,
  226. isDetail: false,
  227. modelId: 0,
  228. parmValue: {
  229. page: 1, // 页码数
  230. size: 15, // 页容量
  231. status: "", //视频状态
  232. video_sn: "",//视频编号
  233. video_name: "", // 视频名称
  234. video_url: "", // 视频地址
  235. },
  236. tableData: [],
  237. // 表格 - 数据
  238. table: {
  239. stripe: true,//是否是斑马条纹边框
  240. border: true,//是否显示纵向边框
  241. // _defaultHeader_: ["setcol"]
  242. },
  243. // 表格 - 分页
  244. pageInfo: {
  245. size: 15,
  246. curr: 1,
  247. total: 0,
  248. },
  249. // 表格 - 列参数
  250. columns: [
  251. {
  252. prop: "id",
  253. label: "视频编号",
  254. width: "70px",
  255. fixed: "left",
  256. },
  257. {
  258. prop: "video_name",
  259. label: "视频名称",
  260. width: "250px",
  261. },
  262. {
  263. prop: "remark",
  264. label: "视频描述",
  265. },
  266. {
  267. prop: "status",
  268. label:"视频状态",
  269. _slot_: "status",
  270. width:"100px"
  271. },
  272. {
  273. prop: "addtime",
  274. label: "创建时间",
  275. sortable: true,
  276. width: "140px",
  277. },
  278. {
  279. prop: "",
  280. label: "操作",
  281. fixed: "right",
  282. _noset_: true,
  283. width: "150px",
  284. _slot_: "operation",
  285. },
  286. ],
  287. };
  288. },
  289. mounted() {
  290. this.searchList();//异步调用接口,请求数据
  291. },
  292. methods: {
  293. selectPop(staus,id) {
  294. this.$confirm('此操作将切换视频状态, 是否继续?', '提示', {
  295. confirmButtonText: '确定',
  296. cancelButtonText: '取消',
  297. type: 'warning'
  298. }).then(() => {
  299. this.changeBtnStatus(staus,id)
  300. })
  301. },
  302. msgPop(){
  303. this.$alert(res.msg, {
  304. confirmButtonText: '确定',
  305. callback: action => {
  306. this.$message({
  307. type: 'info',
  308. message: `action: ${ action }`
  309. });
  310. }
  311. });
  312. },
  313. deletePop(id){
  314. this.$alert("请确认要删除吗?","提示",{
  315. confirmButtonText: '确定',
  316. cancelButtonText: '取消',
  317. type: 'warning'
  318. }).then(() => {
  319. this.deleteBtnProject(id)
  320. });
  321. },
  322. //-重置-输入框数据
  323. restSearch() {
  324. this.select = "1";
  325. this.input = "";
  326. // 表格 - 分页
  327. this.pageInfo = {
  328. size: 15,
  329. curr: 1,
  330. total: 0,
  331. };
  332. this.parmValue = {
  333. video_name: "", // 视频名称
  334. video_url: "", // 视频链接
  335. video_sn:"",//视频编号
  336. status: "", //视频状态
  337. page: 1, // 页码
  338. size: 15, // 每页显示条数
  339. };
  340. this.searchList();//请求接口数据
  341. },
  342. // 打开弹窗,添加-详情-修改-启/禁用-删除按钮
  343. openModal(id, isDetail, sitem) {
  344. this.showModel = true;
  345. this.modelId = id;
  346. this.isDetail = isDetail;
  347. },
  348. //
  349. async changeBtnStatus(status,id){
  350. this.loading = false;//开启loading加载
  351. let changeValue = {
  352. id:"",
  353. status:"",
  354. };
  355. changeValue.status = (status === "1" ? "0" : "1");
  356. changeValue.id = id;
  357. var res = await asyncRequest.change(changeValue);//请求更新视频接口/admin/Change
  358. if (res && res.code === 0 && res.data) {
  359. //正常响应的操作
  360. } else if (res && res.code >= 100 && res.code <= 104) {
  361. await this.logout();//登出
  362. } else {
  363. this.msgPop();//警告弹窗,提示接口返回信息
  364. }
  365. this.loading = false;//停止loading
  366. this.searchList();
  367. },
  368. async deleteBtnProject(id){
  369. this.loading = false;
  370. let deleteValue = {
  371. id:"",
  372. }
  373. deleteValue.id = id;//入参
  374. var res = await asyncRequest.delete(deleteValue);//调用/admin/Delete接口,
  375. if(res && res.code === 0){
  376. //正常响应后的操作
  377. }else if(res && res.code >= 100 && res.code <= 104){
  378. await this.logout();
  379. }else{
  380. this.msgPop();
  381. }
  382. this.loading = false;
  383. this.searchList();
  384. },
  385. async searchList() {
  386. this.loading = true;//开启加载loading
  387. this.parmValue.video_name = this.select === "1" ? this.input : "";//把用户输入的name赋到video_name上
  388. this.parmValue.video_url = this.select === "2" ? this.input : "";//赋url
  389. this.parmValue.video_sn = this.select === "3" ? this.input : "";//赋video_sn
  390. const res = await asyncRequest.list(this.parmValue);//调用视频列表接口/admin/video
  391. if (res && res.code === 0 && res.data) {
  392. this.tableData = res.data.video;//正常响应把响应数据存到tableData中。
  393. this.pageInfo.total = Number(res.data.count);//存入总数据量
  394. } else if (res && res.code >= 100 && res.code <= 104) {
  395. await this.logout();//超时登出
  396. } else {
  397. this.tableData = [];//如果服务器未正常响应且不是登出状态,初始化数据
  398. this.pageInfo.total = 0;
  399. }
  400. this.loading = false;//关闭loading
  401. },
  402. },
  403. };
  404. </script>
  405. <style lang="scss" scoped>
  406. .el-select .el-input {
  407. width: 130px;
  408. }
  409. .input-with-select .el-input-group__prepend {
  410. background-color: #fff;
  411. width: 100px;
  412. }
  413. </style>