tab1.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <div id="tab1">
  3. <div class="postMs">
  4. <el-tabs v-model="activeName">
  5. <el-tab-pane label="推荐课程" name="first"></el-tab-pane>
  6. <el-tab-pane label="推荐题库" name="second"></el-tab-pane>
  7. </el-tabs>
  8. <el-button class="topPost" size="mini" type="success" @click="add"
  9. >添加</el-button
  10. >
  11. </div>
  12. <div>
  13. <el-table
  14. v-loading="loading"
  15. :data="tableData"
  16. style="width: 100%; margin-top: 10px"
  17. border
  18. >
  19. <template v-for="(item, index) in tableSet">
  20. <af-table-column
  21. :width="item.width"
  22. :key="index"
  23. :prop="item.prop"
  24. :label="item.label"
  25. align="center"
  26. >
  27. <template slot-scope="scope">
  28. <span v-if="item.scope === 'status'">
  29. {{
  30. scope.row[item.prop] === 1
  31. ? "启用"
  32. : scope.row[item.prop] === 0
  33. ? "关闭"
  34. : "未知"
  35. }}
  36. </span>
  37. <div v-else-if="item.scope === 'businType'">
  38. {{ scope.row[item.prop1] + "-" + scope.row[item.prop2] }}
  39. </div>
  40. <div v-else-if="item.scope === 'aboutChapter'" class="ulAuto">
  41. <ul>
  42. <template v-for="(itm, inds) in scope.row[item.prop]">
  43. <li class="jumpStys" :key="inds" v-if="inds === 0">
  44. {{ itm[item.prop1] }}
  45. </li>
  46. </template>
  47. </ul>
  48. <el-popover
  49. :key="Math.random()"
  50. placement="right"
  51. trigger="click"
  52. >
  53. <ul style="overflow: auto; max-height: 500px; margin: 0px">
  54. <li
  55. v-for="(itm, inds) in scope.row[item.prop]"
  56. :key="inds"
  57. class="jumpStys"
  58. >
  59. {{ inds + 1 }}、
  60. {{ itm[item.prop1] }}
  61. </li>
  62. </ul>
  63. <el-button
  64. slot="reference"
  65. style="margin-left: 6px"
  66. type="text"
  67. v-if="scope.row[item.prop].length > 1"
  68. size="mini"
  69. >更多</el-button
  70. >
  71. </el-popover>
  72. </div>
  73. <div v-else>{{ scope.row[item.prop] }}</div>
  74. </template></af-table-column
  75. ></template
  76. >
  77. <el-table-column fixed="right" label="操作" width="100" align="center">
  78. <template slot-scope="scope">
  79. <el-button type="text" size="small" @click="editList(scope.row)"
  80. >修改</el-button
  81. ><el-button type="text" size="small" @click="del(scope.row)"
  82. >删除</el-button
  83. >
  84. </template>
  85. </el-table-column>
  86. </el-table>
  87. </div>
  88. <add-gl ref="addGL" />
  89. </div>
  90. </template>
  91. <script>
  92. import addGl from "./addGL.vue";
  93. export default {
  94. components: { addGl },
  95. data() {
  96. return {
  97. activeName: "first",
  98. tableSet: [
  99. {
  100. label: "排序",
  101. prop: "sort",
  102. width: "120px",
  103. },
  104. {
  105. label: "名称",
  106. prop: "name",
  107. },
  108. {
  109. label: "教育类型",
  110. prop: "educationName",
  111. },
  112. {
  113. label: "业务层次",
  114. prop1: "projectName",
  115. prop2: "businessName",
  116. scope: "businType",
  117. },
  118. {
  119. label: "关联商品",
  120. prop: "goodsList",
  121. prop1: "goodsName",
  122. scope: "aboutChapter",
  123. },
  124. {
  125. label: "状态",
  126. prop: "status",
  127. scope: "status",
  128. },
  129. ],
  130. tableData: [],
  131. loading: false,
  132. };
  133. },
  134. watch: {
  135. activeName(val) {
  136. this.search();
  137. },
  138. },
  139. mounted() {
  140. this.search();
  141. },
  142. methods: {
  143. search() {
  144. this.loading = true;
  145. this.$api
  146. .inquireactivityrecommendList({
  147. platform: 1,
  148. type: this.activeName === "first" ? 1 : 2
  149. })
  150. .then((res) => {
  151. this.tableData = res.rows;
  152. })
  153. .finally(() => {
  154. this.loading = false;
  155. });
  156. },
  157. /**
  158. * 新增
  159. */
  160. add() {
  161. this.$refs.addGL.openBox(1);
  162. },
  163. editList(row) {
  164. this.$refs.addGL.openBox(0, row.recommendId);
  165. },
  166. del(v) {
  167. this.$alert(
  168. "确定删除此内容?<br />内容删除后将无法恢复,请慎重考虑",
  169. "提示",
  170. {
  171. dangerouslyUseHTMLString: true,
  172. }
  173. )
  174. .then(() => {
  175. var data = {
  176. recommendId: v.recommendId
  177. };
  178. this.$api.removeactivityrecommend(data).then((res) => {
  179. this.$message.success("删除成功");
  180. this.search();
  181. });
  182. })
  183. .catch(() => {
  184. });
  185. },
  186. },
  187. };
  188. </script>
  189. <style lang="less" scoped>
  190. .postMs {
  191. position: relative;
  192. .topPost {
  193. position: absolute;
  194. top: 10%;
  195. right: 10px;
  196. }
  197. }
  198. .ulAuto {
  199. display: flex;
  200. justify-content: center;
  201. align-items: center;
  202. & > ul {
  203. margin: 0px;
  204. }
  205. }
  206. </style>