From 441da7ecd798f8b51cdefc7d0f5cde54399a4ca3 Mon Sep 17 00:00:00 2001 From: RuoYi <yzz_ivy@163.com> Date: 星期三, 01 四月 2020 12:21:48 +0800 Subject: [PATCH] 添加handle控制允许拖动的元素 --- ruoyi-ui/src/views/system/user/index.vue | 136 +++++++++++++++++++++++++++++++++++---------- 1 files changed, 105 insertions(+), 31 deletions(-) diff --git a/ruoyi-ui/src/views/system/user/index.vue b/ruoyi-ui/src/views/system/user/index.vue index 760036b..8d290b8 100644 --- a/ruoyi-ui/src/views/system/user/index.vue +++ b/ruoyi-ui/src/views/system/user/index.vue @@ -114,6 +114,15 @@ </el-col> <el-col :span="1.5"> <el-button + type="info" + icon="el-icon-upload2" + size="mini" + @click="handleImport" + v-hasPermi="['system:user:import']" + >瀵煎叆</el-button> + </el-col> + <el-col :span="1.5"> + <el-button type="warning" icon="el-icon-download" size="mini" @@ -126,9 +135,9 @@ <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange"> <el-table-column type="selection" width="40" align="center" /> <el-table-column label="鐢ㄦ埛缂栧彿" align="center" prop="userId" /> - <el-table-column label="鐢ㄦ埛鍚嶇О" align="center" prop="userName" /> - <el-table-column label="鐢ㄦ埛鏄电О" align="center" prop="nickName" /> - <el-table-column label="閮ㄩ棬" align="center" prop="dept.deptName" /> + <el-table-column label="鐢ㄦ埛鍚嶇О" align="center" prop="userName" :show-overflow-tooltip="true" /> + <el-table-column label="鐢ㄦ埛鏄电О" align="center" prop="nickName" :show-overflow-tooltip="true" /> + <el-table-column label="閮ㄩ棬" align="center" prop="dept.deptName" :show-overflow-tooltip="true" /> <el-table-column label="鎵嬫満鍙风爜" align="center" prop="phonenumber" width="120" /> <el-table-column label="鐘舵��" align="center"> <template slot-scope="scope"> @@ -284,18 +293,49 @@ <el-button @click="cancel">鍙� 娑�</el-button> </div> </el-dialog> + + <!-- 鐢ㄦ埛瀵煎叆瀵硅瘽妗� --> + <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px"> + <el-upload + ref="upload" + :limit="1" + accept=".xlsx, .xls" + :headers="upload.headers" + :action="upload.url + '?updateSupport=' + upload.updateSupport" + :disabled="upload.isUploading" + :on-progress="handleFileUploadProgress" + :on-success="handleFileSuccess" + :auto-upload="false" + drag + > + <i class="el-icon-upload"></i> + <div class="el-upload__text"> + 灏嗘枃浠舵嫋鍒版澶勶紝鎴� + <em>鐐瑰嚮涓婁紶</em> + </div> + <div class="el-upload__tip" slot="tip"> + <el-checkbox v-model="upload.updateSupport" />鏄惁鏇存柊宸茬粡瀛樺湪鐨勭敤鎴锋暟鎹� + <el-link type="info" style="font-size:12px" @click="importTemplate">涓嬭浇妯℃澘</el-link> + </div> + <div class="el-upload__tip" style="color:red" slot="tip">鎻愮ず锛氫粎鍏佽瀵煎叆鈥渪ls鈥濇垨鈥渪lsx鈥濇牸寮忔枃浠讹紒</div> + </el-upload> + <div slot="footer" class="dialog-footer"> + <el-button type="primary" @click="submitFileForm">纭� 瀹�</el-button> + <el-button @click="upload.open = false">鍙� 娑�</el-button> + </div> + </el-dialog> </div> </template> <script> -import { listUser, getUser, delUser, addUser, updateUser, exportUser, resetUserPwd, changeUserStatus } from "@/api/system/user"; +import { listUser, getUser, delUser, addUser, updateUser, exportUser, resetUserPwd, changeUserStatus, importTemplate } from "@/api/system/user"; +import { getToken } from "@/utils/auth"; import { treeselect } from "@/api/system/dept"; -import { listPost } from "@/api/system/post"; -import { listRole } from "@/api/system/role"; import Treeselect from "@riophae/vue-treeselect"; import "@riophae/vue-treeselect/dist/vue-treeselect.css"; export default { + name: "User", components: { Treeselect }, data() { return { @@ -337,6 +377,21 @@ children: "children", label: "label" }, + // 鐢ㄦ埛瀵煎叆鍙傛暟 + upload: { + // 鏄惁鏄剧ず寮瑰嚭灞傦紙鐢ㄦ埛瀵煎叆锛� + open: false, + // 寮瑰嚭灞傛爣棰橈紙鐢ㄦ埛瀵煎叆锛� + title: "", + // 鏄惁绂佺敤涓婁紶 + isUploading: false, + // 鏄惁鏇存柊宸茬粡瀛樺湪鐨勭敤鎴锋暟鎹� + updateSupport: 0, + // 璁剧疆涓婁紶鐨勮姹傚ご閮� + headers: { Authorization: "Bearer " + getToken() }, + // 涓婁紶鐨勫湴鍧� + url: process.env.VUE_APP_BASE_API + "/system/user/importData" + }, // 鏌ヨ鍙傛暟 queryParams: { pageNum: 1, @@ -361,6 +416,7 @@ { required: true, message: "鐢ㄦ埛瀵嗙爜涓嶈兘涓虹┖", trigger: "blur" } ], email: [ + { required: true, message: "閭鍦板潃涓嶈兘涓虹┖", trigger: "blur" }, { type: "email", message: "'璇疯緭鍏ユ纭殑閭鍦板潃", @@ -368,6 +424,7 @@ } ], phonenumber: [ + { required: true, message: "鎵嬫満鍙风爜涓嶈兘涓虹┖", trigger: "blur" }, { pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "璇疯緭鍏ユ纭殑鎵嬫満鍙风爜", @@ -393,7 +450,7 @@ this.sexOptions = response.data; }); this.getConfigKey("sys.user.initPassword").then(response => { - this.initPassword = response.data; + this.initPassword = response.msg; }); }, methods: { @@ -423,18 +480,6 @@ this.queryParams.deptId = data.id; this.getList(); }, - /** 鏌ヨ宀椾綅鍒楄〃 */ - getPosts() { - listPost().then(response => { - this.postOptions = response.rows; - }); - }, - /** 鏌ヨ瑙掕壊鍒楄〃 */ - getRoles() { - listRole().then(response => { - this.roleOptions = response.rows; - }); - }, // 鐢ㄦ埛鐘舵�佷慨鏀� handleStatusChange(row) { let text = row.status === "0" ? "鍚敤" : "鍋滅敤"; @@ -459,7 +504,7 @@ reset() { this.form = { userId: undefined, - deptId: 100, + deptId: undefined, userName: undefined, nickName: undefined, password: undefined, @@ -486,29 +531,31 @@ }, // 澶氶�夋閫変腑鏁版嵁 handleSelectionChange(selection) { - this.ids = selection.map(item => item.userId) - this.single = selection.length!=1 - this.multiple = !selection.length + this.ids = selection.map(item => item.userId); + this.single = selection.length != 1; + this.multiple = !selection.length; }, /** 鏂板鎸夐挳鎿嶄綔 */ handleAdd() { this.reset(); this.getTreeselect(); - this.getPosts(); - this.getRoles(); - this.open = true; - this.title = "娣诲姞鐢ㄦ埛"; - this.form.password = this.initPassword; + getUser().then(response => { + this.postOptions = response.posts; + this.roleOptions = response.roles; + this.open = true; + this.title = "娣诲姞鐢ㄦ埛"; + this.form.password = this.initPassword; + }); }, /** 淇敼鎸夐挳鎿嶄綔 */ handleUpdate(row) { this.reset(); this.getTreeselect(); - this.getPosts(); - this.getRoles(); - const userId = row.userId || this.ids + const userId = row.userId || this.ids; getUser(userId).then(response => { this.form = response.data; + this.postOptions = response.posts; + this.roleOptions = response.roles; this.form.postIds = response.postIds; this.form.roleIds = response.roleIds; this.open = true; @@ -585,6 +632,33 @@ }).then(response => { this.download(response.msg); }).catch(function() {}); + }, + /** 瀵煎叆鎸夐挳鎿嶄綔 */ + handleImport() { + this.upload.title = "鐢ㄦ埛瀵煎叆"; + this.upload.open = true; + }, + /** 涓嬭浇妯℃澘鎿嶄綔 */ + importTemplate() { + importTemplate().then(response => { + this.download(response.msg); + }); + }, + // 鏂囦欢涓婁紶涓鐞� + handleFileUploadProgress(event, file, fileList) { + this.upload.isUploading = true; + }, + // 鏂囦欢涓婁紶鎴愬姛澶勭悊 + handleFileSuccess(response, file, fileList) { + this.upload.open = false; + this.upload.isUploading = false; + this.$refs.upload.clearFiles(); + this.$alert(response.msg, "瀵煎叆缁撴灉", { dangerouslyUseHTMLString: true }); + this.getList(); + }, + // 鎻愪氦涓婁紶鏂囦欢 + submitFileForm() { + this.$refs.upload.submit(); } } }; -- Gitblit v1.9.3