servicelist.vue 2.9 KB

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