|
@@ -0,0 +1,130 @@
|
|
|
+<template>
|
|
|
+ <div id="business">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" class="add" style="text-align:right;padding: 10px 20px;">
|
|
|
+ <el-button size="mini" type="primary" @click="toAdd" icon="el-icon-plus" v-if="user.pid">添加{{ theme }}</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="main">
|
|
|
+ <data-table :fields="fields" @delete="toDelete" :data="list" :opera="opera" @edit="toEdit" :total="total" @query="search"></data-table>
|
|
|
+ </el-col>
|
|
|
+ <el-dialog :title="theme" width="60%" :visible.sync="dialog" @closed="handleClose" :destroy-on-close="true">
|
|
|
+ <data-form :data="form" :fields="formFields" @save="toSave" :isNew="dialogIsNew" :rules="rules"></data-form>
|
|
|
+ </el-dialog>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import dataForm from '@/components/form.vue';
|
|
|
+import dataTable from '@/components/data-table.vue';
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: users } = createNamespacedHelpers('users');
|
|
|
+const { mapActions: authUser } = createNamespacedHelpers('authUser');
|
|
|
+export default {
|
|
|
+ name: 'business',
|
|
|
+ props: {},
|
|
|
+ components: { dataTable, dataForm },
|
|
|
+ data: function() {
|
|
|
+ return {
|
|
|
+ theme: '业务管理员',
|
|
|
+ dialog: false,
|
|
|
+ form: {},
|
|
|
+ dialogIsNew: true,
|
|
|
+ opera: [
|
|
|
+ {
|
|
|
+ label: '编辑',
|
|
|
+ icon: 'el-icon-edit',
|
|
|
+ method: 'edit',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '删除',
|
|
|
+ icon: 'el-icon-delete',
|
|
|
+ method: 'delete',
|
|
|
+ confirm: true,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ fields: [
|
|
|
+ { label: '机构代码或邀请码', prop: 'code' },
|
|
|
+ { label: '用户名', prop: 'name', filter: 'input' },
|
|
|
+ { label: '机构名称', prop: 'deptname', filter: 'input' },
|
|
|
+ { label: '电话', prop: 'phone', filter: 'input' },
|
|
|
+ ],
|
|
|
+ list: [],
|
|
|
+ total: 0,
|
|
|
+
|
|
|
+ formFields: [
|
|
|
+ { label: '机构代码或邀请码', prop: 'code', model: 'code' },
|
|
|
+ { label: '姓名', prop: 'name', model: 'name' },
|
|
|
+ { label: '机构名称', prop: 'deptname', model: 'deptname' },
|
|
|
+ { label: '手机号', prop: 'phone', model: 'phone', options: { maxLength: 11, minLength: 11, type: 'number' } },
|
|
|
+ { label: '密码', prop: 'password', model: 'password', type: 'password' },
|
|
|
+ ],
|
|
|
+ rules: {
|
|
|
+ code: [{ required: true, message: '请输入推荐码' }],
|
|
|
+ },
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...users(['query', 'fetch', 'create', 'update', 'delete']),
|
|
|
+ ...authUser({ authUserDelete: 'delete' }),
|
|
|
+ async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
+ const res = await this.query({ skip, limit, pid: this.user.uid, ...info });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `list`, res.data);
|
|
|
+ this.$set(this, `total`, res.total);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 添加
|
|
|
+ toAdd() {
|
|
|
+ this.dialog = true;
|
|
|
+ },
|
|
|
+ toEdit({ data }) {
|
|
|
+ this.$set(this, 'form', data);
|
|
|
+ this.dialog = true;
|
|
|
+ this.dialogIsNew = false;
|
|
|
+ },
|
|
|
+ async toSave({ isNew, data }) {
|
|
|
+ let res;
|
|
|
+ let msg;
|
|
|
+ if (isNew) {
|
|
|
+ data.pid = this.user.uid;
|
|
|
+ data.status = '1';
|
|
|
+ data.role = '1';
|
|
|
+ res = await this.create(data);
|
|
|
+ msg = '创建成功';
|
|
|
+ } else {
|
|
|
+ res = await this.update(data);
|
|
|
+ msg = '修改成功';
|
|
|
+ }
|
|
|
+ if (this.$checkRes(res, msg, res.errmsg)) {
|
|
|
+ this.handleClose();
|
|
|
+ this.search();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async toDelete({ data }) {
|
|
|
+ const res = await this.delete(data.id);
|
|
|
+ const arr = await this.authUserDelete(data.id);
|
|
|
+ if (this.$checkRes(arr, '删除成功', res.errmsg || '删除失败')) this.search();
|
|
|
+ },
|
|
|
+ handleClose() {
|
|
|
+ this.dialog = false;
|
|
|
+ this.form = {};
|
|
|
+ this.dialogIsNew = true;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState(['user']),
|
|
|
+ pageTitle() {
|
|
|
+ return `${this.$route.meta.title}`;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ metaInfo() {
|
|
|
+ return { title: this.$route.meta.title };
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped></style>
|