|
@@ -22,6 +22,8 @@
|
|
|
import topInfo from '@/layout/common/topInfo.vue';
|
|
|
import detailTop from '@/layout/common/detailTop.vue';
|
|
|
import otheruserForm from '@/layout/otheruser/otheruserForm.vue';
|
|
|
+import { createNamespacedHelpers, mapGetters } from 'vuex';
|
|
|
+const { mapActions: otheruser } = createNamespacedHelpers('otheruser');
|
|
|
export default {
|
|
|
name: 'detail',
|
|
|
props: {},
|
|
@@ -35,13 +37,41 @@ export default {
|
|
|
topTitle: '用户信息管理',
|
|
|
ruleForm: {},
|
|
|
}),
|
|
|
- created() {},
|
|
|
- computed: {},
|
|
|
+ created() {
|
|
|
+ this.searchInfo();
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ id() {
|
|
|
+ return this.$route.query.id;
|
|
|
+ },
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ ...otheruser(['query', 'fetch', 'update', 'create']),
|
|
|
+ async searchInfo() {
|
|
|
+ if (this.id) {
|
|
|
+ const res = await this.fetch(this.id);
|
|
|
+ this.$set(this, `ruleForm`, res.data);
|
|
|
+ }
|
|
|
+ },
|
|
|
// 提交
|
|
|
- submitForm(form) {
|
|
|
- console.log(form);
|
|
|
- this.resetForm();
|
|
|
+ async submitForm(form) {
|
|
|
+ let data = form;
|
|
|
+ let res;
|
|
|
+ let msg;
|
|
|
+ if (this.id) {
|
|
|
+ res = await this.updates(data);
|
|
|
+ this.$message({
|
|
|
+ message: '信息修改成功',
|
|
|
+ type: 'success',
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ res = await this.create(data);
|
|
|
+ this.$message({
|
|
|
+ message: '信息添加成功',
|
|
|
+ type: 'success',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (this.$checkRes(res, msg)) this.$router.push({ path: '/otheruser/index' });
|
|
|
},
|
|
|
// 取消
|
|
|
resetForm() {
|