shujudetail.vue 2.9 KB

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