enterprisexuqiu.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div id="adviserList">
  3. <enterprisexuqiu-detail
  4. :info="info"
  5. :liebiaoList="liebiaoList"
  6. @onsave="onsaveClick"
  7. :demandForm="demandForm"
  8. @demandSubmit="demandSubmit"
  9. :columnList="columnList"
  10. @changeType="changeType"
  11. :totaltype="totaltype"
  12. ></enterprisexuqiu-detail>
  13. </div>
  14. </template>
  15. <script>
  16. import enterprisexuqiuDetail from '@/components/enterprise/enterprisexuqiu.vue';
  17. import { createNamespacedHelpers, mapGetters } from 'vuex';
  18. const { mapActions: mapSite } = createNamespacedHelpers('site');
  19. const { mapActions: mapMarkettype } = createNamespacedHelpers('markettype');
  20. const { mapActions: mapMarketproduct } = createNamespacedHelpers('marketproduct');
  21. export default {
  22. name: 'adviserList',
  23. props: {},
  24. components: {
  25. enterprisexuqiuDetail,
  26. },
  27. data: () => ({
  28. info: {},
  29. liebiaoList: [{ name: '基本信息' }, { name: '消息管理' }, { name: '我的发布' }, { name: '我的订购' }, { name: '注销账号' }],
  30. demandForm: {
  31. image: {},
  32. product_args: [],
  33. },
  34. columnList: [],
  35. totaltype: 0,
  36. }),
  37. created() {
  38. this.searchSite();
  39. this.maarkettype();
  40. this.searchInfo();
  41. },
  42. computed: {
  43. id() {
  44. return this.$route.query.id;
  45. },
  46. keyWord() {
  47. let meta = this.$route.meta;
  48. let main = meta.title || '';
  49. return main;
  50. },
  51. },
  52. methods: {
  53. ...mapSite(['showInfo']),
  54. ...mapMarkettype({ markettypeList: 'query' }),
  55. ...mapMarketproduct({ productFetch: 'fetch', productCreate: 'create', productUpdate: 'update' }),
  56. // 查询站点信息
  57. async searchSite() {
  58. let res = await this.showInfo();
  59. let object = JSON.parse(JSON.stringify(res.data));
  60. if (object) {
  61. this.$set(this, `info`, res.data);
  62. } else {
  63. this.$message.error(res.errmsg ? res.errmsg : 'error');
  64. }
  65. },
  66. async searchInfo() {
  67. if (this.$route.query.id) {
  68. const res = await this.productFetch(this.id);
  69. this.$set(this, `demandForm`, res.data);
  70. }
  71. },
  72. async demandSubmit(demandForm) {
  73. let data = this.demandForm;
  74. console.log(data);
  75. data.userid = '1234556677';
  76. console.log(data);
  77. let res;
  78. let msg;
  79. if (data.id) {
  80. res = await this.productUpdate(data);
  81. msg = `${this.keyWord}修改成功`;
  82. } else {
  83. res = await this.productCreate(data);
  84. msg = `${this.keyWord}添加成功`;
  85. }
  86. if (this.$checkRes(res, msg)) this.$router.push({ path: '/enterprise/enterprisefabu' });
  87. },
  88. // 查询类型
  89. async maarkettype({ category = 123, ...info } = {}) {
  90. const res = await this.markettypeList({ category, ...info });
  91. if (this.$checkRes(res)) {
  92. this.$set(this, `columnList`, res.data);
  93. }
  94. },
  95. // 栏目跳转
  96. async onsaveClick({ id }) {
  97. if (id === '基本信息') {
  98. this.$router.push({ path: '/enterprise/enterprisejb' });
  99. } else if (id === '消息管理') {
  100. this.$router.push({ path: '/enterprise/enterprisexx' });
  101. } else if (id === '我的发布') {
  102. this.$router.push({ path: '/enterprise/enterprisefabu' });
  103. } else if (id === '我的订购') {
  104. this.$router.push({ path: '/enterprise/enterprisedg' });
  105. }
  106. },
  107. changeType(item) {
  108. console.log(item);
  109. this.$set(this, `totaltype`, item);
  110. },
  111. },
  112. };
  113. </script>
  114. <style lang="less" scoped></style>