|
@@ -16,6 +16,7 @@
|
|
|
<script>
|
|
|
import dataForm from '@common/src/components/frame/form.vue';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: adminLogin } = createNamespacedHelpers('adminLogin');
|
|
|
export default {
|
|
|
metaInfo() {
|
|
|
return { title: this.$route.meta.title };
|
|
@@ -39,15 +40,45 @@ export default {
|
|
|
code: [{ required: true, message: '请输入机构代码或邀请码' }],
|
|
|
name: [{ required: true, message: '请输入姓名' }],
|
|
|
phone: [{ required: true, message: '请输入手机号' }],
|
|
|
- passwd: [{ required: true, message: '请输入密码' }],
|
|
|
+ passwd: [{ required: false, message: '请输入密码' }],
|
|
|
},
|
|
|
};
|
|
|
},
|
|
|
- created() {},
|
|
|
+ async created() {
|
|
|
+ if (this.id) await this.search();
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ ...adminLogin(['fetch', 'create', 'update']),
|
|
|
+ // 查询详情
|
|
|
+ async search() {
|
|
|
+ let res = await this.fetch(this.id);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `form`, res.data);
|
|
|
+ }
|
|
|
+ },
|
|
|
// 提交
|
|
|
- toSave({ data }) {
|
|
|
- console.log(data);
|
|
|
+ async toSave({ data }) {
|
|
|
+ data.role = '1';
|
|
|
+ data.pid = this.user.id;
|
|
|
+ if (data.id) {
|
|
|
+ let res = await this.update(data);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$message({
|
|
|
+ message: '信息修改成功',
|
|
|
+ type: 'success',
|
|
|
+ });
|
|
|
+ this.back();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ let res = await this.create(data);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$message({
|
|
|
+ message: '信息创建成功',
|
|
|
+ type: 'success',
|
|
|
+ });
|
|
|
+ this.back();
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
// 返回
|
|
|
back() {
|
|
@@ -56,6 +87,9 @@ export default {
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(['user']),
|
|
|
+ id() {
|
|
|
+ return this.$route.query.id;
|
|
|
+ },
|
|
|
},
|
|
|
watch: {},
|
|
|
};
|