shujulist.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <div id="shujulist">
  3. <shujulist-detail
  4. :info="info"
  5. :liebiaoList="liebiaoList"
  6. :display="display"
  7. :columnName="columnName"
  8. :contentList="contentList"
  9. :total="total"
  10. :columnTitle="columnTitle"
  11. :policyInfo="policyInfo"
  12. @clickLists="submit"
  13. @fetch="fetchInfo"
  14. ></shujulist-detail>
  15. </div>
  16. </template>
  17. <script>
  18. import shujulistDetail from '@/components/shuju/shujulist.vue';
  19. import { createNamespacedHelpers, mapGetters } from 'vuex';
  20. import _ from 'loadsh';
  21. const { mapActions: mapSite } = createNamespacedHelpers('site');
  22. const { mapActions: mappolicyColumn } = createNamespacedHelpers('recordColumn');
  23. const { mapActions: mappolicyNews } = createNamespacedHelpers('recordNews');
  24. export default {
  25. name: 'shujulist',
  26. props: {},
  27. components: { shujulistDetail },
  28. data: () => ({
  29. info: {},
  30. liebiaoList: [],
  31. display: 'list',
  32. columnName: '',
  33. contentList: [],
  34. total: 1,
  35. leftId: '',
  36. columnTitle: '',
  37. policyInfo: {},
  38. }),
  39. async created() {
  40. this.searchSite();
  41. await this.policyColumn();
  42. await this.defaultColumn();
  43. },
  44. computed: {},
  45. methods: {
  46. ...mapSite(['showInfo']),
  47. ...mappolicyColumn({ policyColumns: 'query', policyfetch: 'fetch' }),
  48. ...mappolicyNews({ policyNew: 'query', newsFetch: 'fetch' }),
  49. // 查询站点信息
  50. async searchSite() {
  51. let res = await this.showInfo();
  52. let object = JSON.parse(JSON.stringify(res.data));
  53. if (object) {
  54. this.$set(this, `info`, res.data);
  55. } else {
  56. this.$message.error(res.errmsg ? res.errmsg : 'error');
  57. }
  58. },
  59. async policyColumn({ ...info } = {}) {
  60. const res = await this.policyColumns({ ...info });
  61. if (this.$checkRes(res)) {
  62. this.$set(this, `liebiaoList`, res.data);
  63. }
  64. },
  65. submit({ id }) {
  66. this.$set(this, `leftId`, id);
  67. this.display = 'list';
  68. this.searchRight();
  69. },
  70. async searchRight({ skip = 0, limit = 10, column_id } = {}) {
  71. const res = await this.policyNew({ column_id: this.leftId });
  72. for (const val of res.data) {
  73. const result = await this.policyfetch(val.column_id);
  74. val.column_name = result.data.name;
  75. }
  76. this.$set(this, `contentList`, res.data);
  77. this.$set(this, `total`, res.data.length);
  78. for (const val of res.data) {
  79. this.$set(this, `columnName`, val.column_name);
  80. }
  81. },
  82. async defaultColumn() {
  83. if (!(this.liebiaoList.length > 0)) return;
  84. let id = _.get(this.liebiaoList[0], 'id', false);
  85. if (!id) return;
  86. this.submit({ id });
  87. },
  88. async fetchInfo(id) {
  89. this.display = 'detail';
  90. const res = await this.newsFetch(id);
  91. const result = await this.policyfetch(res.data.column_id);
  92. this.$set(this, `columnTitle`, result.data.name);
  93. this.$set(this, `policyInfo`, res.data);
  94. // 查询详情,赋值
  95. },
  96. },
  97. };
  98. </script>
  99. <style lang="scss" scoped></style>