|
@@ -0,0 +1,174 @@
|
|
|
+<template>
|
|
|
+ <div id="detail">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
|
|
|
+ <el-col :span="24" class="one">
|
|
|
+ <cSearch :is_back="true" @toBack="toBack"></cSearch>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="two">
|
|
|
+ <cForm :span="24" :fields="fields" :form="form" :rules="rules" @save="toSave" label-width="auto">
|
|
|
+ <template #gender>
|
|
|
+ <el-option v-for="i in genderList" :key="i.value" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #role>
|
|
|
+ <el-option v-for="i in roleList" :key="i.code" :label="i.name" :value="i.code"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #street>
|
|
|
+ <el-option @click="toChange(i)" v-for="i in streetList" :key="i._id" :label="i.name" :value="i._id"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #community>
|
|
|
+ <el-option v-for="i in communityList" :key="i._id" :label="i.name" :value="i._id"></el-option>
|
|
|
+ </template>
|
|
|
+ </cForm>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+// 基础
|
|
|
+import type { Ref } from 'vue';
|
|
|
+import { ref, reactive, onMounted } from 'vue';
|
|
|
+import { ElMessage } from 'element-plus';
|
|
|
+import type { FormRules } from 'element-plus';
|
|
|
+import { useRoute } from 'vue-router';
|
|
|
+// 接口
|
|
|
+import { UserStore } from '@/stores/users/user';
|
|
|
+import { OfficeStore } from '@/stores/office/office';
|
|
|
+import { RoleStore } from '@/stores/role/role'; // 角色
|
|
|
+import { DictDataStore } from '@/stores/dict/dictData'; // 字典表
|
|
|
+import type { IQueryResult } from '@/util/types.util';
|
|
|
+const userAxios = UserStore();
|
|
|
+const dictAxios = DictDataStore();
|
|
|
+const officeAxios = OfficeStore();
|
|
|
+const roleAxios = RoleStore();
|
|
|
+// 路由
|
|
|
+const route = useRoute();
|
|
|
+// 加载中
|
|
|
+const loading: Ref<any> = ref(false);
|
|
|
+// 表单
|
|
|
+let form: Ref<any> = ref({});
|
|
|
+let fields: Ref<any[]> = ref([
|
|
|
+ { label: '微信用户标识', model: 'openid', options: { disabled: true } },
|
|
|
+ { label: '联系电话', model: 'tel' },
|
|
|
+ { label: '姓名', model: 'name' },
|
|
|
+ { label: '性别', model: 'gender', type: 'select' },
|
|
|
+ { label: '角色', model: 'role', type: 'select' },
|
|
|
+ { label: '所属街道', model: 'street', type: 'select' },
|
|
|
+ { label: '所属社区', model: 'community', type: 'select' }
|
|
|
+]);
|
|
|
+const rules = reactive<FormRules>({});
|
|
|
+// 字典表
|
|
|
+const genderList: Ref<any> = ref([]);
|
|
|
+const roleList: Ref<any> = ref([]);
|
|
|
+const streetList: Ref<any> = ref([]);
|
|
|
+const communityList: Ref<any> = ref([]);
|
|
|
+const statusList: Ref<any> = ref([]);
|
|
|
+// 请求
|
|
|
+onMounted(async () => {
|
|
|
+ loading.value = true;
|
|
|
+ await searchOther();
|
|
|
+ await search();
|
|
|
+ loading.value = false;
|
|
|
+});
|
|
|
+const search = async () => {
|
|
|
+ let id = route.query.id;
|
|
|
+ if (id) {
|
|
|
+ let res: IQueryResult = await userAxios.fetch(id);
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ let info: any = res.data as {};
|
|
|
+ form.value = info;
|
|
|
+ // 所属社区
|
|
|
+ res = await officeAxios.query({ belong: info.street, type: '1', is_use: '0' });
|
|
|
+ if (res.errcode == '0') communityList.value = res.data;
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+const toChange = async (val: any) => {
|
|
|
+ form.value.community = '';
|
|
|
+ let res: IQueryResult;
|
|
|
+ // 所属社区
|
|
|
+ res = await officeAxios.query({ belong: val._id, type: '1', is_use: '0' });
|
|
|
+ if (res.errcode == '0') communityList.value = res.data;
|
|
|
+};
|
|
|
+// 保存
|
|
|
+const toSave = async (data) => {
|
|
|
+ let res: IQueryResult;
|
|
|
+ if (data._id) res = await userAxios.update(data);
|
|
|
+ else res = await userAxios.create(data);
|
|
|
+ if (res.errcode == 0) {
|
|
|
+ ElMessage({ type: `success`, message: `维护信息成功` });
|
|
|
+ toBack();
|
|
|
+ }
|
|
|
+};
|
|
|
+// 查询其他信息
|
|
|
+const searchOther = async () => {
|
|
|
+ let res: IQueryResult;
|
|
|
+ // 性别
|
|
|
+ res = await dictAxios.query({ type: 'gender', is_use: '0' });
|
|
|
+ if (res.errcode == '0') genderList.value = res.data;
|
|
|
+ // 角色
|
|
|
+ res = await roleAxios.query({ type: 'role', is_use: '0' });
|
|
|
+ if (res.errcode == '0') roleList.value = res.data;
|
|
|
+ // 所属街道
|
|
|
+ res = await officeAxios.query({ type: '0', is_use: '0' });
|
|
|
+ if (res.errcode == '0') streetList.value = res.data;
|
|
|
+ // 状态
|
|
|
+ res = await dictAxios.query({ type: 'status', is_use: '0' });
|
|
|
+ if (res.errcode == '0') statusList.value = res.data;
|
|
|
+};
|
|
|
+// 返回上一页
|
|
|
+const toBack = () => {
|
|
|
+ window.history.go(-1);
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style scoped lang="scss">
|
|
|
+.study {
|
|
|
+ width: 100%;
|
|
|
+ .study_1 {
|
|
|
+ margin: 0 0 10px 0;
|
|
|
+ span {
|
|
|
+ font-size: 16px;
|
|
|
+ }
|
|
|
+ span:first-child {
|
|
|
+ color: #ff0000;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .study_2 {
|
|
|
+ .study_2_info {
|
|
|
+ width: 100%;
|
|
|
+ display: flex;
|
|
|
+ .info_1 {
|
|
|
+ position: relative;
|
|
|
+ max-width: 24%;
|
|
|
+ border: 1px solid #67c23a;
|
|
|
+ padding: 0 10px;
|
|
|
+ border-radius: 5px;
|
|
|
+ margin: 0 10px 0 0;
|
|
|
+ .txt {
|
|
|
+ position: absolute;
|
|
|
+ top: -15px;
|
|
|
+ left: 10px;
|
|
|
+ span {
|
|
|
+ display: inline-block;
|
|
|
+ padding: 6px 15px;
|
|
|
+ background: #67c23a;
|
|
|
+ color: #fff;
|
|
|
+ border-radius: 5px;
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: bold;
|
|
|
+ line-height: 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .info {
|
|
|
+ margin: 15px 0 0 0;
|
|
|
+ .label {
|
|
|
+ margin: 0 0 10px 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|