detail.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="style">
  5. <el-col :span="24" class="top">
  6. <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
  7. </el-col>
  8. <el-col :span="24" class="main">
  9. <detail :form="form" @onSubmit="onSubmit" @placesubmit="placesubmit" :option="option" :options="options"></detail>
  10. </el-col>
  11. </el-col>
  12. </el-row>
  13. </div>
  14. </template>
  15. <script>
  16. import NavBar from '@/layout/common/topInfo.vue';
  17. import detail from '@/layout/duijiehui/detail.vue';
  18. import { mapState, createNamespacedHelpers } from 'vuex';
  19. const { mapActions: dock } = createNamespacedHelpers('dock');
  20. const { mapActions: place } = createNamespacedHelpers('place');
  21. export default {
  22. name: 'index',
  23. props: {},
  24. components: {
  25. NavBar,
  26. detail, //个人信息维护
  27. },
  28. data: () => ({
  29. // 头部标题
  30. title: '',
  31. // meta为true
  32. isleftarrow: '',
  33. // 返回
  34. navShow: true,
  35. // 个人信息
  36. form: {},
  37. option: [],
  38. options: [],
  39. }),
  40. created() {
  41. this.searchinfo();
  42. this.search();
  43. this.searchplace();
  44. },
  45. computed: {
  46. ...mapState(['user']),
  47. id() {
  48. return this.$route.query.id;
  49. },
  50. role() {
  51. return this.$route.query.role;
  52. },
  53. },
  54. methods: {
  55. ...place({ palcequery: 'query', transactiondtetle: 'delete' }),
  56. ...dock({ livefetch: 'fetch', livelist: 'query', livecreate: 'create', liveupdate: 'update' }),
  57. async placesubmit({ value }) {
  58. let level = 2;
  59. let parent = value;
  60. let res = await this.palcequery({ level, parent });
  61. this.$set(this, `options`, res.data);
  62. },
  63. async searchplace() {
  64. if (this.id) {
  65. let level = 2;
  66. let ress = await this.livefetch(this.id);
  67. let parent = ress.data.place;
  68. let res = await this.palcequery({ level, parent });
  69. this.$set(this, `options`, res.data);
  70. }
  71. },
  72. async searchinfo() {
  73. let level = 1;
  74. let res = await this.palcequery({ level });
  75. console.log(res.data);
  76. console.log(res.data);
  77. this.$set(this, `option`, res.data);
  78. },
  79. async search() {
  80. if (this.id) {
  81. let res = await this.livefetch(this.id);
  82. this.$set(this, `form`, res.data);
  83. }
  84. },
  85. async onSubmit({ data }) {
  86. console.log(data);
  87. if (this.id) {
  88. let res = await this.liveupdate(data);
  89. this.$checkRes(res, '修改成功', '修改失败');
  90. } else {
  91. this.form.user_id = this.user.uid;
  92. this.form.is_allowed = '1';
  93. let res = await this.livecreate(data);
  94. this.$checkRes(res, '创建成功', '添加失败');
  95. }
  96. this.$router.push({ path: './index' });
  97. },
  98. },
  99. mounted() {
  100. this.title = this.$route.meta.title;
  101. this.isleftarrow = this.$route.meta.isleftarrow;
  102. },
  103. };
  104. </script>
  105. <style lang="less" scoped>
  106. .style {
  107. width: 100%;
  108. min-height: 667px;
  109. position: relative;
  110. background-color: #f9fafc;
  111. }
  112. .top {
  113. height: 46px;
  114. overflow: hidden;
  115. position: relative;
  116. z-index: 999;
  117. }
  118. .main {
  119. min-height: 570px;
  120. }
  121. .foot {
  122. position: absolute;
  123. bottom: 0;
  124. }
  125. </style>