detail.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <div id="detail">
  3. <policy-detail
  4. :info="info"
  5. :zongheList="zongheList"
  6. :contentList="contentList"
  7. :total="total"
  8. :columnName="columnName"
  9. :liebiaoList="liebiaoList"
  10. @clickLists="submit"
  11. ></policy-detail>
  12. </div>
  13. </template>
  14. <script>
  15. import policyDetail from '@/components/policy/policy.vue';
  16. import { createNamespacedHelpers, mapGetters } from 'vuex';
  17. const { mapActions: mapSite } = createNamespacedHelpers('site');
  18. const { mapActions: mappolicyColumn } = createNamespacedHelpers('policyColumn');
  19. const { mapActions: mappolicyNews } = createNamespacedHelpers('policyNews');
  20. export default {
  21. name: 'detail',
  22. props: {},
  23. components: {
  24. policyDetail,
  25. },
  26. data: () => ({
  27. liebiaoList: [],
  28. info: {},
  29. zongheList: {},
  30. contentList: [],
  31. total: 1,
  32. leftId: '',
  33. columnName: '',
  34. }),
  35. created() {
  36. this.searchSite();
  37. this.policyColumn();
  38. },
  39. computed: {},
  40. methods: {
  41. ...mapSite(['showInfo']),
  42. ...mappolicyColumn({ policyColumns: 'query', policyfetch: 'fetch' }),
  43. ...mappolicyNews({ policyNew: 'query' }),
  44. // 查询站点信息
  45. async searchSite() {
  46. let res = await this.showInfo();
  47. let object = JSON.parse(JSON.stringify(res.data));
  48. if (object) {
  49. this.$set(this, `info`, res.data);
  50. } else {
  51. this.$message.error(res.errmsg ? res.errmsg : 'error');
  52. }
  53. },
  54. async policyColumn({ ...info } = {}) {
  55. const res = await this.policyColumns({ ...info });
  56. if (this.$checkRes(res)) {
  57. this.$set(this, `liebiaoList`, res.data);
  58. }
  59. },
  60. submit({ id }) {
  61. this.$set(this, `leftId`, id);
  62. this.searchRight();
  63. },
  64. async searchRight({ skip = 0, limit = 10, column_id } = {}) {
  65. const res = await this.policyNew({ skip, limit, column_id: this.leftId });
  66. for (const val of res.data) {
  67. const result = await this.policyfetch(val.column_id);
  68. val.column_name = result.data.name;
  69. }
  70. this.$set(this, `contentList`, res.data);
  71. this.$set(this, `total`, res.data.length);
  72. for (const val of res.data) {
  73. this.$set(this, `columnName`, val.column_name);
  74. }
  75. },
  76. },
  77. };
  78. </script>
  79. <style lang="scss" scoped></style>