|
@@ -0,0 +1,115 @@
|
|
|
|
+<template>
|
|
|
|
+ <div id="detail">
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="24" class="debt">
|
|
|
|
+ <el-col :span="24" class="top">
|
|
|
|
+ <topInfo :topTitle="topTitle" :display="display"></topInfo>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="24" class="main">
|
|
|
|
+ <el-col :span="24" class="back">
|
|
|
|
+ <detailTop @goBack="goBack"></detailTop>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="24" class="info">
|
|
|
|
+ <regionForm :ruleForm="ruleForm" :rolesList="rolesList" @submitForm="submitForm" @resetForm="resetForm"></regionForm>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import topInfo from '@/layout/common/topInfo.vue';
|
|
|
|
+import detailTop from '@/layout/common/detailTop.vue';
|
|
|
|
+import regionForm from '@/layout/region/regionForm.vue';
|
|
|
|
+import { createNamespacedHelpers, mapGetters } from 'vuex';
|
|
|
|
+const { mapActions: region } = createNamespacedHelpers('region');
|
|
|
|
+export default {
|
|
|
|
+ name: 'detail',
|
|
|
|
+ props: {},
|
|
|
|
+ components: {
|
|
|
|
+ topInfo, //头部导航
|
|
|
|
+ detailTop, //头部返回
|
|
|
|
+ regionForm, //添加其他用户
|
|
|
|
+ },
|
|
|
|
+ data: () => ({
|
|
|
|
+ display: 'none',
|
|
|
|
+ topTitle: '用户信息管理',
|
|
|
|
+ ruleForm: {
|
|
|
|
+ passwd: '123456',
|
|
|
|
+ roles: [],
|
|
|
|
+ },
|
|
|
|
+ }),
|
|
|
|
+ created() {
|
|
|
|
+ this.searchInfo();
|
|
|
|
+ this.searchRole();
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ id() {
|
|
|
|
+ return this.$route.query.id;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ ...region(['query', 'fetch', 'update', 'create']),
|
|
|
|
+ async searchInfo() {
|
|
|
|
+ if (this.id) {
|
|
|
|
+ const res = await this.fetch(this.id);
|
|
|
|
+ if (`${res.errcode}` === '0') {
|
|
|
|
+ this.$set(this, `ruleForm`, res.data);
|
|
|
|
+ } else {
|
|
|
|
+ this.$message.error(result.errmsg ? result.errmsg : 'error');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 提交
|
|
|
|
+ async submitForm({ data }) {
|
|
|
|
+ let res;
|
|
|
|
+ if (this.id) {
|
|
|
|
+ res = await this.update(data);
|
|
|
|
+ if (res.errcode === 0) {
|
|
|
|
+ this.$message({
|
|
|
|
+ message: '信息修改成功',
|
|
|
|
+ type: 'success',
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ res = await this.create(data);
|
|
|
|
+ if (res.errcode === 0) {
|
|
|
|
+ this.$message({
|
|
|
|
+ message: '信息创建成功',
|
|
|
|
+ type: 'success',
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (this.$checkRes(res)) this.resetForm();
|
|
|
|
+
|
|
|
|
+ console.log(res.data);
|
|
|
|
+ },
|
|
|
|
+ // 取消
|
|
|
|
+ resetForm() {
|
|
|
|
+ this.$router.push({ path: '/region/index' });
|
|
|
|
+ },
|
|
|
|
+ // 返回
|
|
|
|
+ goBack() {
|
|
|
|
+ this.$router.go(-1);
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style lang="less" scoped>
|
|
|
|
+.debt {
|
|
|
|
+ padding: 20px;
|
|
|
|
+}
|
|
|
|
+.top {
|
|
|
|
+ border-bottom: 1px solid #ccc;
|
|
|
|
+}
|
|
|
|
+.main {
|
|
|
|
+ border-radius: 10px;
|
|
|
|
+ margin: 20px 0 0 0;
|
|
|
|
+ box-shadow: 0 0 3px #666;
|
|
|
|
+}
|
|
|
|
+.main .back {
|
|
|
|
+ padding: 10px 0 10px 15px;
|
|
|
|
+}
|
|
|
|
+</style>
|