|
@@ -0,0 +1,167 @@
|
|
|
+<template>
|
|
|
+ <div id="mainForm">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" class="linksForm">
|
|
|
+ <el-form ref="form" :model="form" label-width="100px">
|
|
|
+ <el-form-item label="用户名称" prop="name">
|
|
|
+ <el-input v-model="form.name" placeholder="请输入用户名称"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="手机号" prop="phone">
|
|
|
+ <el-input v-model="form.phone" placeholder="请输入手机号" :minlength="11" :maxlength="11"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="登录密码" prop="password">
|
|
|
+ <el-input v-model="form.password" placeholder="请输入登录密码" show-password></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="身份证号" prop="cardnumber">
|
|
|
+ <el-input v-model="form.cardnumber" placeholder="请输入身份证号" :minlength="18" :maxlength="18"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="邮箱" prop="email">
|
|
|
+ <el-input v-model="form.email" placeholder="请输入邮箱"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="地址" prop="addr">
|
|
|
+ <el-input v-model="form.addr" placeholder="请输入地址"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="头像图片" prop="img_path">
|
|
|
+ <upload :limit="1" :data="form.img_path" type="img_path" :url="'/files/imgpath/upload'" @upload="uploadSuccess"></upload>
|
|
|
+ </el-form-item>
|
|
|
+ <!-- <el-form-item label="用户类别" prop="role">
|
|
|
+ <el-radio-group v-model="form.role">
|
|
|
+ <el-radio label="8">vip用户</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item> -->
|
|
|
+ <el-form-item label="简介" v-if="form.role == '6'" prop="resume">
|
|
|
+ <el-input v-model="form.remark" placeholder="请输入备注"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button @click="handleCancel">返回</el-button>
|
|
|
+ <el-button type="primary" @click="handleSave()">提交</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import upload from '@/components/upload.vue';
|
|
|
+import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: users } = createNamespacedHelpers('users');
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'mainForm',
|
|
|
+ props: {},
|
|
|
+ components: { upload },
|
|
|
+ data: () => ({
|
|
|
+ form: {},
|
|
|
+ // 性别
|
|
|
+ gender_list: [
|
|
|
+ {
|
|
|
+ name: '男',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '女',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ // 学历
|
|
|
+ edu_list: [
|
|
|
+ {
|
|
|
+ name: '中专及以上',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '大专及以上',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '本科及以上',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '研究生及以上',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ // 学位
|
|
|
+ degree_list: [
|
|
|
+ {
|
|
|
+ name: '学士',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '博士',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '其他',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ }),
|
|
|
+ created() {},
|
|
|
+ methods: {
|
|
|
+ ...users(['fetch', 'create', 'update']),
|
|
|
+
|
|
|
+ async search() {
|
|
|
+ const res = await this.fetch(this.id);
|
|
|
+ if (this.$checkRes(res)) this.$set(this, `form`, res.data);
|
|
|
+ },
|
|
|
+ async handleSave() {
|
|
|
+ let res;
|
|
|
+ let msg;
|
|
|
+ let data = this.form;
|
|
|
+ if (this.isNew) {
|
|
|
+ data.status = '1';
|
|
|
+ data.code = this.user.code;
|
|
|
+ data.status = '1';
|
|
|
+ data.role = '8';
|
|
|
+ console.log(data);
|
|
|
+
|
|
|
+ res = await this.create(data);
|
|
|
+ msg = '用户创建成功';
|
|
|
+ } else {
|
|
|
+ res = await this.update(data);
|
|
|
+ msg = '修改成功';
|
|
|
+ }
|
|
|
+ if (this.$checkRes(res, msg)) {
|
|
|
+ this.handleCancel();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleCancel() {
|
|
|
+ this.$router.push({ path: './index' });
|
|
|
+ },
|
|
|
+ setIsQy(data) {
|
|
|
+ let val = '0';
|
|
|
+ data == '2' ? (val = '0') : (val = '1');
|
|
|
+ this.$set(this.form, `is_qy`, val);
|
|
|
+ },
|
|
|
+ uploadSuccess({ type, data }) {
|
|
|
+ this.$set(this.form, `${type}`, data.uri);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState(['user']),
|
|
|
+ id() {
|
|
|
+ return this.$route.query.id;
|
|
|
+ },
|
|
|
+ role() {
|
|
|
+ return this.$route.query.role;
|
|
|
+ },
|
|
|
+ isNew() {
|
|
|
+ return this.$route.query.id ? false : true;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ isNew: {
|
|
|
+ handler(val) {
|
|
|
+ if (!val) {
|
|
|
+ console.log('in function:');
|
|
|
+ this.search();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ immediate: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.linksForm {
|
|
|
+ margin: 20px 0 0 0;
|
|
|
+}
|
|
|
+.el-form {
|
|
|
+ padding: 0 200px;
|
|
|
+}
|
|
|
+</style>
|