|
@@ -9,10 +9,31 @@
|
|
|
<cButton @toAdd="toAdd()"> </cButton>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="thr">
|
|
|
- <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @edit="toEdit" @del="toDel" :select="false"> </cTable>
|
|
|
+ <cTable
|
|
|
+ :fields="fields"
|
|
|
+ :opera="opera"
|
|
|
+ :list="list"
|
|
|
+ @query="search"
|
|
|
+ :total="total"
|
|
|
+ @view="toView"
|
|
|
+ @edit="toEdit"
|
|
|
+ @exam="toExam"
|
|
|
+ @del="toDel"
|
|
|
+ :select="false"
|
|
|
+ >
|
|
|
+ </cTable>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
+ <cDialog :dialog="dialog" @handleClose="toClose">
|
|
|
+ <template v-slot:info>
|
|
|
+ <cForm v-if="dialog.type == '1'" :span="24" :fields="formFields" :form="form" :rules="{}" @save="onSubmit">
|
|
|
+ <template #status>
|
|
|
+ <el-option v-for="(i, index) in statusList" :key="index" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ </cForm>
|
|
|
+ </template>
|
|
|
+ </cDialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script lang="ts" setup>
|
|
@@ -22,8 +43,10 @@ import { ref, onMounted, getCurrentInstance } from 'vue';
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
import { useRouter } from 'vue-router';
|
|
|
import { PersonalStore } from '@common/src/stores/admins/personal';
|
|
|
+import { DictDataStore } from '@common/src/stores/system/dictData'; // 字典表
|
|
|
import type { IQueryResult } from '@/util/types.util';
|
|
|
const personal = PersonalStore();
|
|
|
+const dictData = DictDataStore();
|
|
|
const router = useRouter();
|
|
|
const { proxy } = getCurrentInstance() as any;
|
|
|
// 列表数据
|
|
@@ -39,18 +62,24 @@ let fields: Ref<any[]> = ref([
|
|
|
{ label: '姓名', model: 'name', isSearch: true },
|
|
|
{ label: '手机号', model: 'phone', isSearch: true },
|
|
|
{ label: '所属辖区', model: 'area' },
|
|
|
- { label: '状态', model: 'status' }
|
|
|
+ { label: '状态', model: 'status', format: (i) => getDict(i, 'status') }
|
|
|
]);
|
|
|
// 操作
|
|
|
let opera: Ref<any[]> = ref([
|
|
|
+ { label: '查看', method: 'view', type: 'success' },
|
|
|
{ label: '修改', method: 'edit' },
|
|
|
+ { label: '审核', method: 'exam', type: 'warning' },
|
|
|
{ label: '删除', method: 'del', confirm: true, type: 'danger' }
|
|
|
]);
|
|
|
-
|
|
|
+const dialog: Ref<{ type: string; show: boolean; title: string }> = ref({ type: '1', show: false, title: '信息管理' });
|
|
|
+let form: Ref<{}> = ref({});
|
|
|
+// 表单
|
|
|
+let formFields: Ref<any[]> = ref([{ label: '状态', model: 'status', type: 'select' }]);
|
|
|
// 查询数据
|
|
|
let searchForm: Ref<any> = ref({});
|
|
|
-
|
|
|
+let statusList: Ref<any> = ref([]);
|
|
|
onMounted(async () => {
|
|
|
+ await searchOther();
|
|
|
await search({ skip, limit });
|
|
|
});
|
|
|
// 查询
|
|
@@ -68,15 +97,48 @@ const toSearch = (query) => {
|
|
|
searchForm.value = query;
|
|
|
search({ skip, limit });
|
|
|
};
|
|
|
+const getDict = (e, model) => {
|
|
|
+ if (model == 'status') {
|
|
|
+ let data: any = statusList.value.find((i: any) => i.value == e);
|
|
|
+ if (data) return data.label;
|
|
|
+ else return '暂无';
|
|
|
+ }
|
|
|
+};
|
|
|
// 新增
|
|
|
const toAdd = () => {
|
|
|
router.push({ path: '/user/personal/detail' });
|
|
|
};
|
|
|
+const toView = (data) => {
|
|
|
+ router.push({ path: '/user/personal/detail', query: { id: data._id, isdisabled: 'true' } });
|
|
|
+};
|
|
|
// 修改
|
|
|
const toEdit = async (data) => {
|
|
|
router.push({ path: '/user/personal/detail', query: { id: data._id } });
|
|
|
};
|
|
|
-
|
|
|
+const toExam = async (data) => {
|
|
|
+ let res: IQueryResult = await personal.fetch(data._id);
|
|
|
+ if (res.errcode == 0) {
|
|
|
+ form.value = res.data;
|
|
|
+ dialog.value = { title: '信息管理', show: true, type: '1' };
|
|
|
+ }
|
|
|
+};
|
|
|
+// 提交
|
|
|
+const onSubmit = async (data) => {
|
|
|
+ let res: IQueryResult;
|
|
|
+ if (data._id) res = await personal.update(data);
|
|
|
+ else res = await personal.create(data);
|
|
|
+ if (res.errcode == 0) {
|
|
|
+ ElMessage({ type: `success`, message: `审核成功` });
|
|
|
+ toClose();
|
|
|
+ }
|
|
|
+};
|
|
|
+// 弹框关闭
|
|
|
+const toClose = () => {
|
|
|
+ form.value = {};
|
|
|
+ searchForm.value = {};
|
|
|
+ dialog.value = { title: '信息管理', show: false, type: '1' };
|
|
|
+ search({ skip, limit });
|
|
|
+};
|
|
|
// 删除
|
|
|
const toDel = async (data) => {
|
|
|
let res: IQueryResult = await personal.del(data._id);
|
|
@@ -85,6 +147,12 @@ const toDel = async (data) => {
|
|
|
search({ skip, limit });
|
|
|
}
|
|
|
};
|
|
|
+const searchOther = async () => {
|
|
|
+ let res: IQueryResult;
|
|
|
+ // 状态
|
|
|
+ res = await dictData.query({ type: 'common_status' });
|
|
|
+ if (res.errcode == 0) statusList.value = res.data;
|
|
|
+};
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
.main {
|