table.vue 10 KB

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