enterprisexuqiu.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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, mapState } from 'vuex';
  18. const { mapActions: mapMarkettype } = createNamespacedHelpers('markettype');
  19. const { mapActions: mapMarketproduct } = createNamespacedHelpers('marketproduct');
  20. export default {
  21. name: 'adviserList',
  22. props: {},
  23. components: {
  24. enterprisexuqiuDetail,
  25. },
  26. data: () => ({
  27. info: {},
  28. liebiaoList: [{ name: '基本信息' }, { name: '消息管理' }, { name: '我的发布' }, { name: '我的订购' }, { name: '注销账号' }],
  29. demandForm: {
  30. image: {},
  31. product_args: [],
  32. },
  33. columnList: [],
  34. totaltype: 0,
  35. }),
  36. created() {
  37. this.maarkettype();
  38. this.searchInfo();
  39. },
  40. computed: {
  41. ...mapState(['user']),
  42. id() {
  43. return this.$route.query.id;
  44. },
  45. keyWord() {
  46. let meta = this.$route.meta;
  47. let main = meta.title || '';
  48. return main;
  49. },
  50. },
  51. methods: {
  52. ...mapMarkettype({ markettypeList: 'query' }),
  53. ...mapMarketproduct({ productFetch: 'fetch', productCreate: 'create', productUpdate: 'update' }),
  54. async searchInfo() {
  55. if (this.$route.query.id) {
  56. const res = await this.productFetch(this.id);
  57. this.$set(this, `demandForm`, res.data);
  58. }
  59. },
  60. async demandSubmit(demandForm) {
  61. let data = this.demandForm;
  62. console.log(data);
  63. data.userid = this.user.uid;
  64. console.log(data.userid);
  65. let res;
  66. let msg;
  67. if (data.id) {
  68. res = await this.productUpdate(data);
  69. msg = `${this.keyWord}修改成功`;
  70. } else {
  71. res = await this.productCreate(data);
  72. msg = `${this.keyWord}添加成功`;
  73. }
  74. if (this.$checkRes(res, msg)) this.$router.push({ path: '/enterprise/enterprisefabu' });
  75. },
  76. // 查询类型
  77. async maarkettype({ category = 123, ...info } = {}) {
  78. const res = await this.markettypeList({ category, ...info });
  79. if (this.$checkRes(res)) {
  80. this.$set(this, `columnList`, res.data);
  81. }
  82. },
  83. // 栏目跳转
  84. async onsaveClick({ id }) {
  85. if (id === '基本信息') {
  86. this.$router.push({ path: '/enterprise/enterprisejb' });
  87. } else if (id === '消息管理') {
  88. this.$router.push({ path: '/enterprise/enterprisexx' });
  89. } else if (id === '我的发布') {
  90. this.$router.push({ path: '/enterprise/enterprisefabu' });
  91. } else if (id === '我的订购') {
  92. this.$router.push({ path: '/enterprise/enterprisedg' });
  93. }
  94. },
  95. changeType(item) {
  96. console.log(item);
  97. this.$set(this, `totaltype`, item);
  98. },
  99. },
  100. };
  101. </script>
  102. <style lang="less" scoped></style>