|
@@ -0,0 +1,107 @@
|
|
|
|
+<template>
|
|
|
|
+ <div id="index">
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="24" class="main animate__animated animate__backInRight">
|
|
|
|
+ <el-col :span="24" class="one">
|
|
|
|
+ <c-search :is_search="true" :fields="fields" @search="btSearch"> </c-search>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="24" class="thr">
|
|
|
|
+ <data-table :fields="fields" :opera="opera" @query="search" :data="list" :total="total" @edit="toEdit" @del="toDel"> </data-table>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
|
+const { mapActions } = createNamespacedHelpers('users');
|
|
|
|
+const { mapActions: dictdata } = createNamespacedHelpers('dictdata');
|
|
|
|
+
|
|
|
|
+export default {
|
|
|
|
+ name: 'index',
|
|
|
|
+ props: {},
|
|
|
|
+ components: {},
|
|
|
|
+ data: function () {
|
|
|
|
+ return {
|
|
|
|
+ // 查询
|
|
|
|
+ searchInfo: {},
|
|
|
|
+ fields: [
|
|
|
|
+ { label: '序号', options: { type: 'index' } },
|
|
|
|
+ { label: '账号', model: 'account', isSearch: true },
|
|
|
|
+ { label: '昵称', model: 'nick_name', isSearch: true },
|
|
|
|
+ { label: '联系电话', model: 'phone', isSearch: true },
|
|
|
|
+ {
|
|
|
|
+ label: '性别',
|
|
|
|
+ model: 'gender',
|
|
|
|
+ format: (i) => {
|
|
|
|
+ let data = this.genderList.find((r) => r.value == i);
|
|
|
|
+ if (data) return data.label;
|
|
|
|
+ else return '暂无';
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ opera: [
|
|
|
|
+ { label: '修改', method: 'edit' },
|
|
|
|
+ { label: '删除', method: 'del', confirm: true, type: 'danger' },
|
|
|
|
+ ],
|
|
|
|
+ list: [],
|
|
|
|
+ total: 0,
|
|
|
|
+ // 字典
|
|
|
|
+ // 性别
|
|
|
|
+ genderList: [],
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ async created() {
|
|
|
|
+ await this.searchOther();
|
|
|
|
+ await this.search();
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ ...mapActions(['query', 'delete']),
|
|
|
|
+ ...dictdata({ dQuery: 'query' }),
|
|
|
|
+ async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
|
+ let res = await this.query({ skip, limit, ...info, ...this.searchInfo });
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$set(this, `list`, res.data);
|
|
|
|
+ this.$set(this, `total`, res.total);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ btSearch(query) {
|
|
|
|
+ this.$set(this, `searchInfo`, query);
|
|
|
|
+ this.search();
|
|
|
|
+ },
|
|
|
|
+ // 修改
|
|
|
|
+ toEdit({ data }) {
|
|
|
|
+ this.$router.push({ path: '/app/users/add', query: { id: data._id } });
|
|
|
|
+ },
|
|
|
|
+ async toDel({ data }) {
|
|
|
|
+ let res = await this.delete(data._id);
|
|
|
|
+ if (this.$checkRes(res, '删除信息成功', res.errmsg)) this.search();
|
|
|
|
+ },
|
|
|
|
+ // 字典表
|
|
|
|
+ async searchOther() {
|
|
|
|
+ let res;
|
|
|
|
+ // 性别
|
|
|
|
+ res = await this.dQuery({ type: 'gender' });
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$set(this, `genderList`, 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>
|