|
@@ -22,6 +22,7 @@
|
|
<script>
|
|
<script>
|
|
import dataForm from '@common/src/components/frame/form.vue';
|
|
import dataForm from '@common/src/components/frame/form.vue';
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
|
+const { mapActions: adminLogin } = createNamespacedHelpers('adminLogin');
|
|
export default {
|
|
export default {
|
|
metaInfo() {
|
|
metaInfo() {
|
|
return { title: this.$route.meta.title };
|
|
return { title: this.$route.meta.title };
|
|
@@ -50,17 +51,49 @@ export default {
|
|
passwd: [{ required: true, message: '请输入密码' }],
|
|
passwd: [{ required: true, message: '请输入密码' }],
|
|
},
|
|
},
|
|
// 机构管理员列表
|
|
// 机构管理员列表
|
|
- pidList: [
|
|
|
|
- { id: '1', name: '机构管理员1' },
|
|
|
|
- { id: '2', name: '机构管理员2' },
|
|
|
|
- ],
|
|
|
|
|
|
+ pidList: [],
|
|
};
|
|
};
|
|
},
|
|
},
|
|
- created() {},
|
|
|
|
|
|
+ async created() {
|
|
|
|
+ await this.search();
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
|
|
+ ...adminLogin(['query', 'fetch', 'create', 'update']),
|
|
|
|
+ async search() {
|
|
|
|
+ let res = await this.query({ role: '2' });
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$set(this, `pidList`, res.data);
|
|
|
|
+ }
|
|
|
|
+ if (this.id) {
|
|
|
|
+ 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 = '3';
|
|
|
|
+ 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() {
|
|
back() {
|
|
@@ -69,6 +102,9 @@ export default {
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
...mapState(['user']),
|
|
...mapState(['user']),
|
|
|
|
+ id() {
|
|
|
|
+ return this.$route.query.id;
|
|
|
|
+ },
|
|
},
|
|
},
|
|
watch: {},
|
|
watch: {},
|
|
};
|
|
};
|