teamInfo.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <div>
  3. <el-alert :closable="false" class="alert marginBtm22" type="info">
  4. <template slot="title">
  5. <div class="alerTitle">
  6. <div class="shapeWrap">
  7. <span class="shape"></span>
  8. <p style="margin-right: 5px">乐团资讯</p>
  9. </div>
  10. <auth auths="musicGroupNews/add">
  11. <el-button type="text" @click="addInfo">+新增乐团资讯</el-button>
  12. </auth>
  13. </div>
  14. </template>
  15. </el-alert>
  16. <el-table
  17. :data="tableList"
  18. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  19. >
  20. <el-table-column align="center" prop="title" label="资讯标题">
  21. </el-table-column>
  22. <el-table-column align="center" prop="author" label="作者">
  23. </el-table-column>
  24. <el-table-column align="center" prop="linkUrl" label="资讯链接">
  25. <template slot-scope="scope">
  26. <div @click="gotoLink(scope.row.linkUrl)" class="link">
  27. {{ scope.row.linkUrl }}
  28. </div>
  29. </template>
  30. </el-table-column>
  31. <el-table-column align="center" prop="id" label="添加时间">
  32. <template slot-scope="scope">
  33. <div>
  34. {{ scope.row.createTime | formatTimer }}
  35. </div>
  36. </template>
  37. </el-table-column>
  38. <el-table-column align="center" prop="operatorName" label="添加人">
  39. </el-table-column>
  40. <el-table-column align="center" prop="id" label="操作">
  41. <template slot-scope="scope">
  42. <div>
  43. <auth auths="musicGroupNews/update">
  44. <el-button type="text" @click="resetInfo(scope.row)"
  45. >修改</el-button
  46. >
  47. </auth>
  48. <auth auths="musicGroupNews/del">
  49. <el-button type="text" @click="deleteInfo(scope.row)"
  50. >删除</el-button
  51. >
  52. </auth>
  53. </div>
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. <pagination
  58. save-key="team-teamInfo"
  59. sync
  60. :total.sync="rules.total"
  61. :page.sync="rules.page"
  62. :limit.sync="rules.limit"
  63. :page-sizes="rules.page_size"
  64. @pagination="getList"
  65. />
  66. <el-dialog
  67. :title="infoTitle"
  68. :visible.sync="infoVisible"
  69. width="600px"
  70. v-if="infoVisible"
  71. >
  72. <el-form
  73. :inline="true"
  74. :model.sync="form"
  75. ref="form"
  76. label-width="80px"
  77. append-to-body
  78. >
  79. <el-form-item
  80. prop="title"
  81. label="资讯标题"
  82. :rules="[{ required: true, message: '请输入资讯标题' }]"
  83. >
  84. <el-input
  85. style="width: 400px !important"
  86. v-model="form.title"
  87. ></el-input>
  88. </el-form-item>
  89. <el-form-item
  90. prop="author"
  91. label="作者"
  92. :rules="[{ required: true, message: '请输入作者名称' }]"
  93. >
  94. <el-input
  95. style="width: 400px !important"
  96. v-model="form.author"
  97. ></el-input>
  98. </el-form-item>
  99. <el-form-item
  100. prop="linkUrl"
  101. label="资讯链接"
  102. :rules="[{ required: true, message: '请输入资讯链接' }]"
  103. >
  104. <el-input
  105. style="width: 400px !important"
  106. v-model="form.linkUrl"
  107. ></el-input>
  108. </el-form-item>
  109. </el-form>
  110. <span slot="footer" class="dialog-footer">
  111. <el-button @click="infoVisible = false">取 消</el-button>
  112. <el-button type="primary" @click="submitInfo">确 定</el-button>
  113. </span>
  114. </el-dialog>
  115. </div>
  116. </template>
  117. <script>
  118. import {
  119. getMusicGroupNews,
  120. addMusicGroupNews,
  121. resetMusicGroupNews,
  122. delMusicGroupNews,
  123. } from "./api";
  124. import pagination from "@/components/Pagination/index";
  125. export default {
  126. components: {
  127. pagination,
  128. },
  129. data() {
  130. return {
  131. tableList: [],
  132. rules: {
  133. // 分页规则
  134. limit: 10, // 限制显示条数
  135. page: 1, // 当前页
  136. total: 1, // 总条数
  137. page_size: [10, 20, 40, 50], // 选择限制显示条数
  138. },
  139. infoVisible: false,
  140. infoTitle: "新增资讯",
  141. form: {
  142. author: "",
  143. linkUrl: "",
  144. title: "",
  145. },
  146. activeRow: null,
  147. };
  148. },
  149. mounted() {
  150. this.getList();
  151. },
  152. methods: {
  153. addInfo() {
  154. this.infoTitle = "新增资讯";
  155. this.infoVisible = true;
  156. this.$nextTick((res) => {
  157. this.form = {
  158. author: "",
  159. linkUrl: "",
  160. title: "",
  161. };
  162. this.$refs.form.resetFields();
  163. });
  164. },
  165. async getList() {
  166. try {
  167. const res = await getMusicGroupNews({
  168. rows: this.rules.limit,
  169. page: this.rules.page,
  170. search: this.$route.query.id,
  171. });
  172. this.tableList = res.data.rows;
  173. this.rules.total = res.data.total;
  174. } catch (e) {}
  175. },
  176. resetInfo(row) {
  177. this.infoTitle = "修改资讯";
  178. this.activeRow = row;
  179. this.form = { ...row };
  180. this.infoVisible = true;
  181. },
  182. deleteInfo(row) {
  183. this.$confirm("确定删除?", "提示", {
  184. confirmButtonText: "确定",
  185. cancelButtonText: "取消",
  186. type: "warning",
  187. })
  188. .then(async () => {
  189. delMusicGroupNews({ id: row.id }).then((res) => {
  190. if (res.code === 200) {
  191. this.$message.success("删除成功");
  192. this.getList();
  193. // this.routeOrderStatus = false;
  194. }
  195. });
  196. })
  197. .catch();
  198. },
  199. submitInfo() {
  200. this.$refs.form.validate(async (flag) => {
  201. if (flag) {
  202. if (this.activeRow) {
  203. try {
  204. const res = await resetMusicGroupNews({ ...this.form });
  205. this.$message.success("修改成功");
  206. this.infoVisible = false;
  207. this.getList();
  208. } catch (e) {
  209. console.log(e);
  210. }
  211. // 修改
  212. } else {
  213. try {
  214. const res = await addMusicGroupNews({
  215. ...this.form,
  216. musicGroupId: this.$route.query.id,
  217. });
  218. this.$message.success("新增成功");
  219. this.infoVisible = false;
  220. this.getList();
  221. } catch (e) {
  222. console.log(e);
  223. }
  224. }
  225. }
  226. });
  227. },
  228. gotoLink(url) {
  229. var p = window.location.protocol;
  230. if (url.indexOf("http") != -1) {
  231. console.log(url);
  232. window.open(url, "_blank");
  233. } else {
  234. console.log(url);
  235. window.open(`${p}//${url}`, "_blank");
  236. }
  237. },
  238. },
  239. };
  240. </script>
  241. <style lang="scss" scoped>
  242. /deep/.el-alert__content {
  243. width: 100%;
  244. }
  245. .alerTitle {
  246. width: 100%;
  247. display: flex;
  248. flex-direction: row;
  249. justify-content: space-between;
  250. .el-button {
  251. padding: 0 20px !important;
  252. }
  253. }
  254. .title {
  255. padding: 8px 16px;
  256. }
  257. .divider {
  258. margin-top: 0 !important;
  259. }
  260. .marginBtm22 {
  261. margin-bottom: 22px;
  262. }
  263. .shapeWrap {
  264. display: flex;
  265. flex-direction: row;
  266. justify-content: flex-start;
  267. align-items: center;
  268. .shape {
  269. position: relative;
  270. top: -1px;
  271. display: block;
  272. margin-right: 10px;
  273. height: 14px;
  274. width: 4px;
  275. background-color: var(--color-primary);
  276. z-index: 500;
  277. }
  278. }
  279. .link {
  280. color: var(--color-primary);
  281. cursor: pointer;
  282. }
  283. </style>