YY 2 년 전
부모
커밋
6e7f05b8ae

+ 98 - 0
src/components/account/admin-1.vue

@@ -0,0 +1,98 @@
+<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-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>
+
+<style lang="less" scoped></style>

+ 89 - 0
src/components/account/updatepwd-1.vue

@@ -0,0 +1,89 @@
+<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-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>
+
+<style lang="less" scoped></style>

+ 30 - 0
src/components/frame/c-dialog.vue

@@ -0,0 +1,30 @@
+<template>
+  <div id="e-dialog">
+    <el-dialog :title="dialog.title" v-model="dialog.show" :width="width" :before-close="handleClose" :close-on-click-modal="false" :append-to-body="true">
+      <slot name="info"></slot>
+    </el-dialog>
+  </div>
+</template>
+
+<script lang="ts" setup>
+import { toRefs } from 'vue';
+const props = defineProps({
+  dialog: { type: Object, default: () => {} },
+  width: { type: String, default: '40%' },
+});
+const { dialog } = toRefs(props);
+const { width } = toRefs(props);
+const emit = defineEmits(['handleClose']);
+const handleClose = () => {
+  emit('handleClose');
+};
+</script>
+
+<style lang="scss" scoped>
+:deep(.el-dialog__body) {
+  padding: 10px;
+  min-height: 30px;
+  max-height: 400px;
+  overflow-y: auto;
+}
+</style>

+ 172 - 0
src/components/frame/c-search.vue

@@ -0,0 +1,172 @@
+<template>
+  <div id="c-search">
+    <el-row>
+      <el-col :span="24" class="title" v-if="is_title">
+        <el-col :span="24" class="title_1">
+          <span>{{ title || $route.meta.title }}</span>
+          <span>{{ tip }}</span>
+        </el-col>
+        <el-col :span="24" class="title_2">
+          <span>{{ remark }}</span>
+        </el-col>
+      </el-col>
+      <el-col :span="24" class="search" v-if="is_search">
+        <el-form ref="formRef" :model="form" label-width="auto">
+          <el-col :span="24" class="form">
+            <template v-for="(item, index) in fields">
+              <el-col :span="8" class="form_1" :key="'form-field-' + index" v-if="item.isSearch == true">
+                <el-form-item :label="getField('label', item)" :prop="item.model">
+                  <template v-if="!item.custom">
+                    <template v-if="item.type === 'select'">
+                      <el-select v-model="form[item.model]" v-bind="item.options" filterable clearable @change="dataChange(item.model)">
+                        <slot :name="item.model" v-bind="{ item }"></slot>
+                      </el-select>
+                    </template>
+                    <template v-else>
+                      <el-input
+                        v-model="form[item.model]"
+                        :type="getField('type', item)"
+                        :placeholder="getField('place', item)"
+                        clearable
+                        v-bind="item.options"
+                        @change="dataChange(item.model)"
+                      ></el-input>
+                    </template>
+                  </template>
+                  <template v-else>
+                    <slot :name="item.model" v-bind="{ item }"></slot>
+                    <!-- <el-input v-model="form[item.model]" clearable :placeholder="`输入${item.label}`"></el-input> -->
+                  </template>
+                </el-form-item>
+              </el-col>
+            </template>
+          </el-col>
+          <el-col :span="24" class="btn">
+            <el-button type="primary" @click="toSubmit()">查询</el-button>
+            <el-button type="danger" @click="toReset()">重置</el-button>
+          </el-col>
+        </el-form>
+      </el-col>
+      <el-col :span="24" class="back" v-if="is_back">
+        <el-button type="primary" @click="toBack()">返回</el-button>
+        <slot name="custombtn"></slot>
+      </el-col>
+      <el-col :span="24" class="slot">
+        <slot name="isslot"></slot>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+<script lang="ts" setup>
+import { ref, toRefs } from 'vue';
+import type { Ref } from 'vue';
+import _ from 'lodash';
+interface fieldsItem {
+  model: string;
+  type: string;
+  // readonly: string;
+  options: object;
+  custom: string;
+  // required: string;
+  // limit: number | undefined;
+  isSearch: boolean;
+}
+const props = defineProps({
+  is_title: { type: Boolean, default: true },
+  is_search: { type: Boolean, default: false },
+  is_back: { type: Boolean, default: false },
+  fields: { type: Array<fieldsItem> },
+  title: { type: String },
+  tip: { type: String },
+  remark: { type: String },
+});
+const { is_title } = toRefs(props);
+const { is_search } = toRefs(props);
+const { is_back } = toRefs(props);
+const { fields } = toRefs(props);
+const { title } = toRefs(props);
+const { tip } = toRefs(props);
+const { remark } = toRefs(props);
+
+let form: Ref<{}> = ref({});
+const emit = defineEmits(['search', 'toReset', 'toBack', 'dataChange']);
+const toSubmit = () => {
+  const obj = _.pickBy(form.value);
+  emit('search', { ...obj });
+};
+// 重置
+const toReset = () => {
+  form.value = {};
+  emit('search', form.value);
+};
+// 文字描述
+const getField = (item: any, data: any) => {
+  let res = _.get(data, item, null);
+  if (item === 'type') res = res === null ? `text` : res;
+  if (item === 'place') res = res === null ? `请输入${data.label}` : res;
+  if (item === 'required') res = res === null ? false : res;
+  if (item === `error`) res = res === null ? `${data.label}错误` : res;
+  return res;
+};
+// 获取输入值
+const dataChange = (model: string) => {
+  const value = form.value[model];
+  emit('dataChange', { model, value });
+};
+// 返回
+const toBack = () => {
+  emit('toBack');
+};
+</script>
+
+<style lang="scss" scoped>
+.title {
+  margin: 0 0 5px 0;
+  .title_1 {
+    margin: 0 0 5px 0;
+    span:first-child {
+      font-size: 20px;
+      font-weight: 700;
+      margin-right: 10px;
+    }
+    span:last-child {
+      font-size: 14px;
+      color: #979797;
+    }
+  }
+  .title_2 {
+    span {
+      color: #8baae7;
+      font-size: 14px;
+      margin-top: 10px;
+    }
+  }
+}
+.search {
+  margin: 0 0 10px 0;
+  .form {
+    display: flex;
+    flex-direction: row;
+    flex-wrap: wrap;
+    .form_1 {
+      padding: 0 0 0 10px;
+      .el-form-item {
+        float: left;
+        width: 100%;
+        margin: 0 0 10px 0;
+      }
+      .el-select {
+        width: 100%;
+      }
+    }
+  }
+
+  .btn {
+    text-align: right;
+  }
+}
+.back {
+  text-align: left;
+  margin: 0 0 10px 0;
+}
+</style>

+ 4 - 2
src/components/frame/c-table.vue

@@ -4,7 +4,9 @@
       ref="table"
       :row-key="rowKey"
       :data="data"
-      :border="true"
+      size="small"
+      border
+      stripe
       :max-height="height !== null ? height : ''"
       @select="handleSelectionChange"
       @select-all="handleSelectAll"
@@ -134,7 +136,7 @@ const props = defineProps({
   sumcol: { type: Array, default: () => [] },
   sumres: { type: String, default: 'total' },
   // limit: { type: Number, default: 10 },
-  height: { type: Number, default: 1000 },
+  height: null,
   operaWidth: { type: Number, default: 200 },
   vOpera: { type: Boolean, default: false },
 });

+ 1 - 1
src/components/frame/c-upload.vue

@@ -44,7 +44,7 @@ const props = defineProps({
   url: { type: String, default: () => '' },
   limit: { type: Number, default: () => 6 },
   accept: { type: String, default: () => 'image/png, image/jpeg' },
-  listType: { type: String, default: () => 'text' },
+  listType: { type: String, default: () => 'text' }, //'text' | 'picture' | 'picture-card'
   tip: { type: String, default: () => undefined },
   list: { type: Array<ListItem>, default: () => [] },
   model: { type: String, default: () => '' },

+ 4 - 2
src/components/frame/file-1.vue

@@ -4,7 +4,7 @@
       <el-col :span="24" class="main">
         <el-form :model="form" ref="formRef" label-width="auto">
           <el-form-item label="佐证资料" prop="file">
-            <component :is="CUpload" :limit="limit" :url="url" :list="form.file" @change="onChange" style="width: 100%"></component>
+            <component :is="CUpload" :limit="limit" :model="model" :url="url" :list="form.file" @change="onChange" style="width: 100%"></component>
           </el-form-item>
           <el-col :span="24" class="btn" v-if="!noEdit">
             <el-button type="primary" @click="onSubmit()">确定</el-button>
@@ -17,7 +17,7 @@
 </template>
 
 <script setup lang="ts">
-import CUpload from '@/components/c-upload.vue';
+import CUpload from '@/components/frame/c-upload.vue';
 import type { Ref } from 'vue';
 import { ref, toRefs } from 'vue';
 import type { FormInstance } from 'element-plus';
@@ -28,12 +28,14 @@ const formRef = ref<FormInstance>();
 // #region 参数传递
 const props = defineProps({
   form: { type: Object, default: () => {} },
+  model: { type: String, default: () => '' },
   noEdit: { type: Boolean, default: () => false },
   url: { type: String, default: () => '/files/freeLabel/upload' },
 });
 const { form } = toRefs(props);
 const { noEdit } = toRefs(props);
 const { url } = toRefs(props);
+const { model } = toRefs(props);
 // #endregion
 
 const emit = defineEmits(['onSubmit', 'resetForm']);