YY 2 years ago
parent
commit
73b9f417e6
2 changed files with 10 additions and 171 deletions
  1. 5 90
      src/components/account/admin-1.vue
  2. 5 81
      src/components/account/updatepwd-1.vue

+ 5 - 90
src/components/account/admin-1.vue

@@ -1,98 +1,13 @@
 <template>
   <div id="admin-1">
     <el-row>
-      <el-col :span="24" class="main">
-        <data-form :fields="fields" :form="form" :rules="rules" @save="onSubmit">
-          <template #is_super="{ item }">
-            <template v-if="item.model === 'is_super'">
-              <el-col :span="24" class="one_1">{{ form.is_super == true ? '是' : '否' }}</el-col>
-            </template>
-          </template>
-          <template #role="{ item }">
-            <template v-if="item.model === 'role'">
-              <el-col :span="24" class="one_1" v-if="form.role?.length > 0">{{ getRole(form.role) }}</el-col>
-              <el-col :span="24" class="one_1" v-else>暂无角色</el-col>
-            </template>
-          </template>
-        </data-form>
-      </el-col>
+      <el-col :span="24" class="main"> test </el-col>
     </el-row>
   </div>
 </template>
 
-<script>
-import { mapState, createNamespacedHelpers } from 'vuex';
-const { mapActions } = createNamespacedHelpers('admin');
-const { mapActions: role } = createNamespacedHelpers('role');
-export default {
-  name: 'admin-1',
-  props: {},
-  components: {},
-  data: function () {
-    return {
-      form: {},
-      fields: [
-        { label: '用户昵称', model: 'name' },
-        { label: '用户账号', model: 'account', options: { readonly: true } },
-        { label: '角色', model: 'role', custom: true },
-        { label: '超级管理员', model: 'is_super', options: { readonly: true }, custom: true },
-      ],
-      rules: {
-        name: [{ required: true, message: '请输入用户昵称', trigger: 'blur' }],
-        is_super: [{ required: true, message: '请输入超级管理员', trigger: 'blur' }],
-        account: [{ required: true, message: '请输入用户账号', trigger: 'blur' }],
-      },
-      roleList: [],
-    };
-  },
-  async created() {
-    await this.searchOthers();
-    await this.search();
-  },
-  methods: {
-    ...role({ roleQuery: 'query' }),
-    ...mapActions(['fetch', 'update']),
-    //查询
-    async search() {
-      let res = await this.fetch(this.user._id);
-      if (this.$checkRes(res)) this.$set(this, `form`, res.data);
-    },
-    getRole(i) {
-      const arr = [];
-      for (const val of i) {
-        const r = this.roleList.find((f) => f._id === val);
-        if (r) arr.push(r.name);
-      }
-      return arr.join(';');
-    },
-    // 提交保存
-    async onSubmit({ data }) {
-      let object = { _id: data._id, account: data.account, name: data.name };
-      let res = await this.update(object);
-      if (this.$checkRes(res, '维护信息成功', res.errmsg)) this.search();
-    },
-    // 查询其他信息
-    async searchOthers() {
-      let res;
-      // 角色
-      res = await this.roleQuery();
-      if (this.$checkRes(res)) this.$set(this, `roleList`, res.data);
-    },
-  },
-  computed: {
-    ...mapState(['user']),
-  },
-  metaInfo() {
-    return { title: this.$route.meta.title };
-  },
-  watch: {
-    test: {
-      deep: true,
-      immediate: true,
-      handler(val) {},
-    },
-  },
-};
+<script setup lang="ts">
+import type { Ref } from 'vue';
+import { ref, toRefs } from 'vue';
 </script>
-
-<style lang="less" scoped></style>
+<style scoped></style>

+ 5 - 81
src/components/account/updatepwd-1.vue

@@ -1,89 +1,13 @@
 <template>
   <div id="updatepwd-1">
     <el-row>
-      <el-col :span="24" class="main animate__animated animate__backInRight">
-        <data-form :span="24" :fields="fields" :form="form" :rules="rules" @save="toSave"></data-form>
-      </el-col>
+      <el-col :span="24" class="main"> test </el-col>
     </el-row>
   </div>
 </template>
 
-<script>
-import { mapState, createNamespacedHelpers } from 'vuex';
-const { mapActions } = createNamespacedHelpers('admin');
-const { mapActions: unit } = createNamespacedHelpers('unit');
-const { mapActions: users } = createNamespacedHelpers('users');
-export default {
-  name: 'updatepwd-1',
-  props: {},
-  components: {},
-  data: function () {
-    return {
-      fields: [
-        { label: '新密码', model: 'password', type: 'password' },
-        { label: '确认新密码', model: 'ispassword', type: 'password' },
-      ],
-      form: {},
-      rules: {
-        password: [{ required: true, message: '请输入新密码' }],
-        ispassword: [
-          { required: true, message: '请输入确认新密码' },
-          {
-            trigger: 'blur',
-            validator: (rule, value, callback) => {
-              if (this.form.password !== value) {
-                callback(new Error('两次输入的密码不一致'));
-              } else {
-                callback();
-              }
-            },
-          },
-        ],
-      },
-      role_type: '0',
-    };
-  },
-  async created() {
-    await this.search();
-  },
-  methods: {
-    ...mapActions(['rp']),
-    ...unit({ uRp: 'rp' }),
-    ...users({ usRp: 'rp' }),
-    //查询
-    async search() {
-      let user = this.user;
-      if (user && user.role_type) this.$set(this, `role_type`, user.role_type);
-    },
-    // 保存
-    async toSave({ data }) {
-      let res;
-      if (this.role_type == '0' || this.role_type == '1') res = await this.rp(data.password);
-      else if (this.role_type == '2') res = await this.usRp(data.password);
-      else if (this.role_type == '3') res = await this.uRp(data.password);
-      this.$checkRes(res, '操作成功', res.errmsg);
-      this.logout();
-    },
-    // 退出登录
-    logout() {
-      localStorage.removeItem('token');
-      window.location.href = `${process.env.VUE_APP_HOST}`;
-    },
-  },
-  computed: {
-    ...mapState(['user']),
-  },
-  metaInfo() {
-    return { title: this.$route.meta.title };
-  },
-  watch: {
-    test: {
-      deep: true,
-      immediate: true,
-      handler(val) {},
-    },
-  },
-};
+<script setup lang="ts">
+import type { Ref } from 'vue';
+import { ref, toRefs } from 'vue';
 </script>
-
-<style lang="less" scoped></style>
+<style scoped></style>