table.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <div v-loading="loading" class="cred_table">
  3. <Header v-if="!userID" />
  4. <div class="main" v-if="showPage">
  5. <div>
  6. <div class="title">字词练习卡</div>
  7. <div class="number_cread">
  8. <span class="left">文件数量:{{ data.total_count }}</span>
  9. <div class="right" @click="Startcread">开始创建</div>
  10. </div>
  11. <div class="table">
  12. <div>
  13. <div class="number"></div>
  14. <div class="dv dv1" style="font-weight: 500">名称</div>
  15. <div class="dv" style="font-weight: 500">卡片类型</div>
  16. <div class="dv" style="font-weight: 500">创建内容</div>
  17. <div class="dv" style="font-weight: 500">创建日期</div>
  18. </div>
  19. <div v-for="(item, i) in data.word_sentence_card_list" :key="i + 'one'">
  20. <div class="number">{{ item.number }}</div>
  21. <div
  22. class="dv dv1"
  23. @click="
  24. $router.push({
  25. path: '/wordcard/cread',
  26. query: {
  27. id: item.id,
  28. cachesType: 'pop',
  29. userID: userID,
  30. },
  31. })
  32. "
  33. >
  34. {{ item.name }}
  35. </div>
  36. <div class="dv">
  37. {{ item.type == 'WORD' ? '字卡片' : '句卡片' }}
  38. </div>
  39. <div class="dv">{{ item.text }}</div>
  40. <div class="dv">{{ item.create_time }}</div>
  41. <el-popconfirm title="确定删除这一条记录吗?" @confirm="deleteOne(item.id, i)">
  42. <img slot="reference" src="../../assets/teacherdev/delete-one.png" alt="" />
  43. </el-popconfirm>
  44. </div>
  45. <p v-if="data.total_count == 0" style="background-color: #fff; text-align: center; line-height: 200px">
  46. <!-- <img src="../../assets/teacherdev/nodata.png" style="width: 1200px" /> -->
  47. 暂无数据
  48. </p>
  49. </div>
  50. <div v-if="data.total_count > 0" class="page">
  51. <el-pagination
  52. background
  53. :page-sizes="[10, 20, 30, 40, 50]"
  54. layout="prev, pager, next,jumper"
  55. :current-page="page"
  56. :page-size="pageSize"
  57. :total="data.total_count"
  58. @current-change="handleCurrentChange"
  59. />
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. </template>
  65. <script>
  66. // 这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  67. // 例如:import 《组件名称》from ‘《组件路径》';
  68. import Header from '@/components/Header';
  69. import { LearnWebSI, getStaticContent } from '@/api/api';
  70. import { getConfigInfor } from '@/utils/index';
  71. import { setToken, getToken } from '@/utils/auth';
  72. export default {
  73. // import引入的组件需要注入到对象中才能使用
  74. components: {
  75. Header,
  76. },
  77. props: {},
  78. data() {
  79. // 这里存放数据
  80. return {
  81. data: [],
  82. page: 1,
  83. pageSize: 10,
  84. loading: false,
  85. AccessToken: this.$route.query.AccessToken,
  86. AppID: this.$route.query.AppID,
  87. showPage: false,
  88. userID: this.$route.query.UserID ? this.$route.query.UserID : '',
  89. };
  90. },
  91. // 计算属性 类似于data概念
  92. computed: {},
  93. // 监控data中数据变化
  94. watch: {},
  95. // 生命周期 - 创建完成(可以访问当前this实例)
  96. async created() {
  97. const _this = this;
  98. if (this.AccessToken) {
  99. const Mname = 'login_control-ParseAccessToken';
  100. await getStaticContent(Mname, {
  101. access_token: _this.AccessToken,
  102. }).then((res) => {
  103. res.access_token = _this.AccessToken;
  104. setToken(res);
  105. sessionStorage.setItem('GCLS_Token_Tc', JSON.stringify(res));
  106. this.showPage = true;
  107. });
  108. await getConfigInfor();
  109. }
  110. this.showPage = true;
  111. this.getdata();
  112. },
  113. // 生命周期 - 挂载完成(可以访问DOM元素)
  114. mounted() {},
  115. // 生命周期-挂载之前
  116. beforeMount() {},
  117. // 生命周期-更新之后
  118. updated() {},
  119. // 如果页面有keep-alive缓存功能,这个函数会触发
  120. activated() {},
  121. // 方法集合
  122. methods: {
  123. // 创建
  124. Startcread() {
  125. this.$router.push({
  126. path: '/wordcard/cread',
  127. query: { cachesType: 'pop', userID: this.userID },
  128. });
  129. },
  130. deleteOne(id, index) {
  131. this.loading = true;
  132. let Mname = 'tr_tool-wsc_manager-DeleteMyWordSentenceCard';
  133. LearnWebSI(Mname, {
  134. id,
  135. })
  136. .then((res) => {
  137. this.getdata();
  138. })
  139. .catch((res) => {
  140. this.loading = false;
  141. });
  142. },
  143. handleCurrentChange(val) {
  144. this.page = val;
  145. this.getdata();
  146. },
  147. getdata() {
  148. this.loading = true;
  149. let Mname = 'page_query-PageQueryMyWordSentenceCardList';
  150. LearnWebSI(Mname, {
  151. cur_page: this.page,
  152. page_capacity: this.pageSize,
  153. app_user_id: this.userID,
  154. })
  155. .then((res) => {
  156. this.data = res;
  157. let num = this.page * this.pageSize - this.pageSize + 1;
  158. this.data.word_sentence_card_list.forEach((item) => {
  159. item.number = num;
  160. num++;
  161. });
  162. this.loading = false;
  163. })
  164. .catch((res) => {
  165. this.loading = false;
  166. });
  167. },
  168. },
  169. // 生命周期-创建之前
  170. beforeCreated() {},
  171. // 生命周期-更新之前
  172. beforUpdate() {},
  173. // 生命周期-销毁之前
  174. beforeDestory() {},
  175. // 生命周期-销毁完成
  176. destoryed() {},
  177. };
  178. </script>
  179. <style lang="scss" scoped>
  180. /* @import url(); 引入css类 */
  181. .cred_table {
  182. height: 100%;
  183. .main {
  184. min-height: 91%;
  185. background: #f7f7f7;
  186. padding-top: 54px;
  187. > div {
  188. width: 1200px;
  189. margin: 0 auto;
  190. }
  191. .title {
  192. font-weight: 700;
  193. font-size: 30px;
  194. line-height: 43px;
  195. text-transform: uppercase;
  196. color: #2c2c2c;
  197. }
  198. .number_cread {
  199. display: flex;
  200. justify-content: space-between;
  201. margin-top: 12px;
  202. .left {
  203. margin-top: 40px;
  204. font-weight: 400;
  205. font-size: 16px;
  206. line-height: 24px;
  207. color: #000000;
  208. }
  209. .right {
  210. width: 112px;
  211. height: 40px;
  212. background: #669aff;
  213. border-radius: 4px;
  214. font-weight: 500;
  215. font-size: 16px;
  216. line-height: 40px;
  217. text-align: center;
  218. color: #ffffff;
  219. cursor: pointer;
  220. }
  221. }
  222. .table {
  223. margin-top: 16px;
  224. > div {
  225. display: flex;
  226. align-items: center;
  227. height: 48px;
  228. background: #ffffff;
  229. border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  230. font-weight: 400;
  231. font-size: 16px;
  232. color: #000000;
  233. padding: 0 16px;
  234. .number {
  235. width: 20px;
  236. text-align: right;
  237. flex-shrink: 0;
  238. }
  239. .dv1 {
  240. cursor: pointer;
  241. }
  242. .dv {
  243. margin-left: 24px;
  244. width: 250px;
  245. overflow: hidden;
  246. white-space: nowrap;
  247. text-overflow: ellipsis;
  248. flex-shrink: 0;
  249. }
  250. img {
  251. width: 24px;
  252. height: 24px;
  253. cursor: pointer;
  254. margin-left: 24px;
  255. }
  256. }
  257. }
  258. .page {
  259. margin-top: 24px;
  260. }
  261. }
  262. }
  263. </style>
  264. <style lang="scss">
  265. .cred_table {
  266. .page {
  267. .el-pagination.is-background .el-pager li:not(.disabled).active {
  268. background: none;
  269. }
  270. .el-pagination {
  271. .btn-prev {
  272. padding: 0 !important;
  273. border: 1px solid #d9d9d9 !important;
  274. background: none;
  275. }
  276. .btn-next {
  277. padding: 0 !important;
  278. border: 1px solid #d9d9d9 !important;
  279. background: none;
  280. }
  281. }
  282. .el-pager {
  283. li {
  284. border: 1px solid #d9d9d9 !important;
  285. box-sizing: border-box;
  286. border-radius: 2px;
  287. margin: 0 7.5px;
  288. background: none;
  289. }
  290. .el-icon,
  291. .more,
  292. .btn-quicknext,
  293. .el-icon-more {
  294. border: none !important;
  295. }
  296. .active {
  297. color: black !important;
  298. border: 1px solid black !important;
  299. }
  300. }
  301. }
  302. }
  303. </style>