update.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <div id="update">
  3. <el-row>
  4. <el-col :span="24" class="main">
  5. <el-col :span="24" class="top">
  6. <el-button type="primary" size="mini" @click="back">返回</el-button>
  7. </el-col>
  8. <el-col :span="24" class="down">
  9. <el-col :span="24" class="setp">
  10. <el-steps :active="active" align-center>
  11. <el-step title="(一)基本信息"> </el-step>
  12. <el-step title="(二)内容简介"> </el-step>
  13. <el-step title="(三)主研人员名单"></el-step>
  14. <el-step title="(四)评价委托方提供资料清单"></el-step>
  15. </el-steps>
  16. </el-col>
  17. <el-col :span="24" class="twoInfo">
  18. <basic :basicForm="form.basic" @resetBtn="back" @basicBtn="basicBtn" v-if="active == '1'"></basic>
  19. <brief :briefForm="form.brief" @briefUp="briefUp" @briefBtn="briefBtn" v-else-if="active == '2'"></brief>
  20. <research :researchForm="form.research" @researchUp="researchUp" @researchBtn="researchBtn" v-else-if="active == '3'"></research>
  21. <datalists :datalistForm="form.datalist" @detailedUp="detailedUp" @onSubmit="onSubmit" v-else-if="active == '4'"></datalists>
  22. </el-col>
  23. </el-col>
  24. </el-col>
  25. </el-row>
  26. </div>
  27. </template>
  28. <script>
  29. import basic from './updateParts/basic.vue';
  30. import brief from './updateParts/brief.vue';
  31. import research from './updateParts/research.vue';
  32. import datalists from './updateParts/datalists.vue';
  33. import { mapState, createNamespacedHelpers } from 'vuex';
  34. const { mapActions: achieveApply } = createNamespacedHelpers('achieveApply');
  35. export default {
  36. name: 'update',
  37. props: {},
  38. components: {
  39. basic,
  40. brief,
  41. research,
  42. datalists,
  43. },
  44. data: function() {
  45. return {
  46. // 步骤
  47. active: 3,
  48. form: {
  49. basic: {},
  50. brief: {},
  51. research: [],
  52. datalist: {},
  53. },
  54. };
  55. },
  56. async created() {
  57. console.log(this.user);
  58. await this.search();
  59. },
  60. methods: {
  61. ...achieveApply(['fetch', 'update', 'create']),
  62. async search() {
  63. if (this.id) {
  64. let res = await this.fetch(this.id);
  65. if (this.$checkRes(res)) {
  66. this.$set(this, `form`, res.data);
  67. }
  68. }
  69. },
  70. //基本信息下一步
  71. basicBtn() {
  72. this.active = 2;
  73. },
  74. // 内容简介上一步
  75. briefUp() {
  76. this.active = 1;
  77. },
  78. // 内容简介下一步
  79. briefBtn() {
  80. this.active = 3;
  81. },
  82. // 研发人员名单上一步
  83. researchUp() {
  84. this.active = 2;
  85. },
  86. // 研发人员名单下一步
  87. researchBtn({ data }) {
  88. this.$set(this.form, `research`, data);
  89. this.active = 4;
  90. },
  91. // 补充材料上一步
  92. detailedUp() {
  93. this.active = 3;
  94. },
  95. async onSubmit() {
  96. let data = this.form;
  97. data.status = this.status;
  98. if (data.id) {
  99. let res = await this.update(data);
  100. if (this.$checkRes(res)) {
  101. this.$message({
  102. message: '修改信息完成,等待审核',
  103. type: 'success',
  104. });
  105. this.back();
  106. }
  107. } else {
  108. data.user_id = this.user.id;
  109. let res = await this.create(data);
  110. if (this.$checkRes(res)) {
  111. this.$message({
  112. message: '申报完成,等待审核',
  113. type: 'success',
  114. });
  115. this.back();
  116. }
  117. }
  118. },
  119. // 返回
  120. back() {
  121. window.history.back();
  122. },
  123. },
  124. computed: {
  125. ...mapState(['user']),
  126. id() {
  127. return this.$route.query.id;
  128. },
  129. status() {
  130. return this.$route.query.status;
  131. },
  132. },
  133. metaInfo() {
  134. return { title: this.$route.meta.title };
  135. },
  136. watch: {
  137. test: {
  138. deep: true,
  139. immediate: true,
  140. handler(val) {},
  141. },
  142. },
  143. };
  144. </script>
  145. <style lang="less" scoped>
  146. .main {
  147. .top {
  148. text-align: right;
  149. margin: 0 0 10px 0;
  150. }
  151. }
  152. </style>