1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <template>
- <div id="index">
- <el-row>
- <el-col :span="24" class="main">
- <el-col :span="24" class="one">
- <el-col :span="24" class="text"> 基本信息 </el-col>
- <el-col :span="24" class="form"> <one :form="form" :rules="rules"></one> </el-col>
- <el-col :span="24" class="btn">
- <el-button type="primary" @click="onSubmit">保存信息</el-button>
- </el-col>
- </el-col>
- </el-col>
- </el-row>
- </div>
- </template>
- <script>
- import one from './parts/one.vue';
- import { mapState, createNamespacedHelpers } from 'vuex';
- const { mapActions: mechanism } = createNamespacedHelpers('mechanism');
- export default {
- name: 'index',
- props: {},
- components: {
- one,
- },
- data: function () {
- return {
- form: {},
- rules: {},
- };
- },
- async created() {
- await this.search();
- },
- methods: {
- ...mechanism(['fetch', 'update']),
- async search() {
- if (this.user.id) {
- let res = await this.fetch(this.user.id);
- if (this.$checkRes(res)) {
- this.$set(this, `form`, res.data);
- }
- }
- },
- async onSubmit() {
- let data = this.form;
- let res = await this.update(data);
- if (this.$checkRes(res)) {
- this.$message({
- message: '修改信息成功',
- type: 'success',
- });
- this.search();
- }
- },
- },
- computed: {
- ...mapState(['user']),
- },
- metaInfo() {
- return { title: this.$route.meta.title };
- },
- watch: {
- test: {
- deep: true,
- immediate: true,
- handler(val) {},
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .main {
- border-radius: 10px;
- box-shadow: 0 0 5px #cccccc;
- padding: 20px;
- .one {
- .text {
- height: 40px;
- line-height: 40px;
- border-bottom: 1px dashed #000;
- margin: 0 0 10px 0;
- }
- .btn {
- text-align: center;
- padding: 15px 0;
- }
- }
- }
- .main:hover {
- box-shadow: 0 0 5px #409eff;
- }
- </style>
|