index.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <div id="index">
  3. <list-frame title="问卷列表页" @query="search" :total="total" :filter="filFields" @add="$router.push({ path: '/questionnaire/detail' })">
  4. <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit" @delete="toDelete"></data-table>
  5. </list-frame>
  6. </div>
  7. </template>
  8. <script>
  9. import listFrame from '@frame/layout/admin/list-frame';
  10. import dataTable from '@frame/components/data-table';
  11. import { createNamespacedHelpers } from 'vuex';
  12. const { mapActions: questionnaire } = createNamespacedHelpers('questionnaire');
  13. export default {
  14. name: 'index',
  15. props: {},
  16. components: {
  17. listFrame,
  18. dataTable,
  19. },
  20. data: () => ({
  21. opera: [
  22. {
  23. label: '编辑',
  24. icon: 'el-icon-edit',
  25. method: 'edit',
  26. },
  27. {
  28. label: '删除',
  29. icon: 'el-icon-delete',
  30. method: 'delete',
  31. },
  32. ],
  33. fields: [
  34. { label: '问卷序号', prop: 'num' },
  35. { label: '问卷标题', prop: 'name' },
  36. ],
  37. filFields: [
  38. { label: '问卷名', model: 'name' },
  39. { label: '问卷序号', model: 'id' },
  40. ],
  41. list: [],
  42. total: 0,
  43. }),
  44. created() {
  45. this.search();
  46. },
  47. computed: {},
  48. methods: {
  49. ...questionnaire(['query', 'delete']),
  50. async search({ skip = 0, limit = 10, ...info } = {}) {
  51. const res = await this.query({ skip, limit, ...info });
  52. if (this.$checkRes(res)) {
  53. this.$set(this, `list`, res.data);
  54. this.$set(this, `total`, res.total);
  55. }
  56. },
  57. toEdit({ data }) {
  58. this.$router.push({ path: '/questionnaire/detail', query: { id: data.id } });
  59. },
  60. async toDelete({ data }) {
  61. const res = await this.delete(data.id);
  62. this.$checkRes(res, '删除成功', '删除失败');
  63. this.search();
  64. },
  65. },
  66. };
  67. </script>
  68. <style lang="less" scoped></style>