index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <!-- 签到管理 内容配置 -->
  2. <template>
  3. <div class="app-container">
  4. <!-- 搜索 -->
  5. <el-form inline size="mini">
  6. <el-form-item label="资源平台:">
  7. <el-select
  8. v-model="form.platformId"
  9. placeholder="请选择资源平台"
  10. clearable
  11. >
  12. <el-option
  13. v-for="item in platformOptions"
  14. :key="item.value"
  15. :value="item.value"
  16. :label="item.label"
  17. />
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item label="音频类型:">
  21. <el-select
  22. v-model="form.audioType"
  23. placeholder="请选择音频类型"
  24. clearable
  25. >
  26. <el-option
  27. v-for="item in form.platformId === ''
  28. ? audioOptions
  29. : audioTypeOptions"
  30. :key="item.value"
  31. :value="item.value"
  32. :label="item.label"
  33. />
  34. </el-select>
  35. </el-form-item>
  36. <el-form-item label="内容标题:">
  37. <el-input
  38. v-model="form.audioName"
  39. placeholder="请输入内容标题"
  40. clearable
  41. />
  42. </el-form-item>
  43. <el-form-item label="当前状态:">
  44. <el-select v-model="form.status" placeholder="请选择当前状态" clearable>
  45. <el-option
  46. v-for="item in disabledOptions"
  47. :key="item.value"
  48. :value="item.value"
  49. :label="item.label"
  50. />
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item>
  54. <el-button type="primary" icon="el-icon-search" @click="getSearch"
  55. >搜索</el-button
  56. >
  57. <el-button icon="el-icon-refresh" @click="getRefresh">重置</el-button>
  58. <el-button
  59. type="primary"
  60. plain
  61. icon="el-icon-plus"
  62. @click="getDetail()"
  63. v-hasPermi="['registration:content:add']"
  64. >新增</el-button
  65. >
  66. </el-form-item>
  67. </el-form>
  68. <!-- 列表 -->
  69. <el-table :data="tableData" v-loading="loading">
  70. <el-table-column label="序号" type="index" align="center" />
  71. <el-table-column label="内容标题" prop="audioName" align="center" />
  72. <el-table-column label="内容图片" align="center" width="100px">
  73. <template slot-scope="scope">
  74. <el-image :src="scope.row.pic" />
  75. </template>
  76. </el-table-column>
  77. <el-table-column
  78. label="资源平台"
  79. prop="platformId"
  80. align="center"
  81. :formatter="platformFormatter"
  82. />
  83. <el-table-column
  84. label="音频类型"
  85. prop="audioType"
  86. align="center"
  87. :formatter="audioTypeFormatter"
  88. />
  89. <el-table-column
  90. label="当前状态"
  91. prop="status"
  92. align="center"
  93. :formatter="statusFormatter"
  94. />
  95. <el-table-column
  96. label="内容状态"
  97. prop="currentStatus"
  98. align="center"
  99. :formatter="currentFormatter"
  100. />
  101. <el-table-column label="有效时间" align="center" show-overflow-tooltip>
  102. <template slot-scope="scope">
  103. {{ scope.row.startTime }} 至 {{ scope.row.endTime }}
  104. </template>
  105. </el-table-column>
  106. <el-table-column label="操作" align="center">
  107. <template slot-scope="scope">
  108. <el-button type="text" @click="getDetail(scope.row.id, true)"
  109. >查看</el-button
  110. >
  111. <span v-if="scope.row.status === 1">
  112. <el-button
  113. type="text"
  114. @click="getDetail(scope.row.id)"
  115. v-hasPermi="['registration:content:edit']"
  116. style="margin-left: 10px"
  117. >编辑</el-button
  118. >
  119. <el-button
  120. type="text"
  121. @click="getChange(scope.row, 0)"
  122. v-hasPermi="['registration:content:up']"
  123. >
  124. 上架</el-button
  125. >
  126. <el-button
  127. type="delete"
  128. @click="getDelete(scope.row)"
  129. v-hasPermi="['registration:content:delete']"
  130. >删除</el-button
  131. >
  132. </span>
  133. <el-button
  134. v-else
  135. type="delete"
  136. @click="getChange(scope.row, 1)"
  137. v-hasPermi="['registration:content:down']"
  138. >下架</el-button
  139. >
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. <pagination
  144. v-show="total > 0"
  145. :total="total"
  146. :page.sync="form.pageNum"
  147. :limit.sync="form.pageSize"
  148. @pagination="getList"
  149. />
  150. </div>
  151. </template>
  152. <script>
  153. import { change, list, remove } from "@/api/registration/content";
  154. import {
  155. audioMixin,
  156. currentMixin,
  157. disabledMixin,
  158. platformMixin,
  159. } from "@/mixin/index";
  160. import { dialogCallBack } from "@/utils/DialogUtil";
  161. export default {
  162. mixins: [platformMixin, audioMixin, disabledMixin, currentMixin],
  163. data() {
  164. return {
  165. // 遮罩层
  166. loading: false,
  167. // 表单
  168. form: {
  169. pageNum: 1,
  170. pageSize: 10,
  171. audioType: "",
  172. platformId: "",
  173. },
  174. // 列表
  175. tableData: [],
  176. // 总数据
  177. total: 0,
  178. };
  179. },
  180. watch: {
  181. "form.platformId": {
  182. handler(val) {
  183. if (val && this.form.audioType == "") {
  184. this.form.audioType = "";
  185. this.getAudioType(val);
  186. this.getList();
  187. }
  188. },
  189. deep: true,
  190. },
  191. "form.audioType": {
  192. handler(val) {
  193. if (val && this.form.platformId == "") {
  194. this.form.platformId = "";
  195. this.getPlatform({
  196. audioType: val,
  197. });
  198. this.getList();
  199. }
  200. },
  201. deep: true,
  202. },
  203. },
  204. mounted() {
  205. this.getList();
  206. this.getPlatform({});
  207. },
  208. methods: {
  209. // 列表
  210. getList() {
  211. this.loading = true;
  212. list(this.form).then((res) => {
  213. if (res.code === 0) {
  214. this.tableData = res.data.records;
  215. this.total = res.data.total;
  216. this.loading = false;
  217. }
  218. });
  219. },
  220. // 搜索
  221. getSearch() {
  222. this.form.pageNum = 1;
  223. this.getList();
  224. },
  225. // 重置
  226. getRefresh() {
  227. this.form = {
  228. pageNum: 1,
  229. pageSize: 10,
  230. platformId: "",
  231. audioType: "",
  232. };
  233. this.getList();
  234. },
  235. // 新增 查看 编辑
  236. getDetail(id, boolean) {
  237. this.$router.push({
  238. path: `/registration/contentConfig/detail`,
  239. query: {
  240. id: id,
  241. disabled: boolean,
  242. },
  243. });
  244. },
  245. // 上下架
  246. getChange(row, status) {
  247. let title = status === 0 ? "上架" : "下架";
  248. this.$confirm(`是否${title}${row.audioName}?`, "提示", {
  249. type: "warning",
  250. })
  251. .then(() => {
  252. change({
  253. id: row.id,
  254. status: status,
  255. }).then((res) => {
  256. if (res.code === 0) {
  257. this.$message.success(`${title}成功!`);
  258. this.getList();
  259. }
  260. });
  261. })
  262. .catch(() => {});
  263. },
  264. // 删除
  265. getDelete(row) {
  266. var that = this;
  267. dialogCallBack(that, function () {
  268. that
  269. .$confirm(`是否有删除${row.audioName}?`, "提示", {
  270. type: "warning",
  271. })
  272. .then(() => {
  273. remove({
  274. id: row.id,
  275. }).then((res) => {
  276. if (res.code === 0) {
  277. that.$message.success("删除成功!");
  278. that.getList();
  279. }
  280. });
  281. })
  282. .catch(() => {});
  283. });
  284. },
  285. // 字典翻译
  286. platformFormatter(row) {
  287. return this.selectDictLabel(this.platformOptions, row.platformId);
  288. },
  289. audioTypeFormatter(row) {
  290. return this.selectDictLabel(this.audioOptions, row.audioType);
  291. },
  292. statusFormatter(row) {
  293. return this.selectDictLabel(this.disabledOptions, row.status);
  294. },
  295. currentFormatter(row) {
  296. return this.selectDictLabel(this.currentOptions, row.currentStatus);
  297. },
  298. },
  299. };
  300. </script>