|
@@ -115,7 +115,7 @@
|
|
type="primary"
|
|
type="primary"
|
|
plain
|
|
plain
|
|
icon="icon icon-import"
|
|
icon="icon icon-import"
|
|
- @click="impUser"
|
|
|
|
|
|
+ @click="importUser"
|
|
>导入
|
|
>导入
|
|
</el-button>
|
|
</el-button>
|
|
</div>
|
|
</div>
|
|
@@ -466,70 +466,15 @@
|
|
>
|
|
>
|
|
</div>
|
|
</div>
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
|
+
|
|
<!-- 导入弹窗 -->
|
|
<!-- 导入弹窗 -->
|
|
- <el-dialog
|
|
|
|
- title="导入用户"
|
|
|
|
- width="520px"
|
|
|
|
- :visible.sync="impDialog"
|
|
|
|
- :modal="false"
|
|
|
|
- :close-on-click-modal="false"
|
|
|
|
- :close-on-press-escape="false"
|
|
|
|
- append-to-body
|
|
|
|
- custom-class="side-dialog"
|
|
|
|
- >
|
|
|
|
- <el-form>
|
|
|
|
- <el-form-item style="margin-left: 20px">
|
|
|
|
- <el-upload
|
|
|
|
- ref="upload"
|
|
|
|
- class="form_left"
|
|
|
|
- accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
|
|
- :action="uploadAction"
|
|
|
|
- :headers="uploadHeaders"
|
|
|
|
- :data="uploadData"
|
|
|
|
- :on-success="uploadSuccess"
|
|
|
|
- :on-error="uploadError"
|
|
|
|
- :file-list="fileList"
|
|
|
|
- :auto-upload="false"
|
|
|
|
- :multiple="false"
|
|
|
|
- >
|
|
|
|
- <el-button
|
|
|
|
- slot="trigger"
|
|
|
|
- size="small"
|
|
|
|
- type="primary"
|
|
|
|
- icon="icon icon-search-white"
|
|
|
|
- >
|
|
|
|
- 选择文件
|
|
|
|
- </el-button>
|
|
|
|
- <el-button
|
|
|
|
- size="small"
|
|
|
|
- type="primary"
|
|
|
|
- icon="icon icon-save-white"
|
|
|
|
- @click="submitUpload"
|
|
|
|
- >
|
|
|
|
- 确认上传
|
|
|
|
- </el-button>
|
|
|
|
- <el-button
|
|
|
|
- size="small"
|
|
|
|
- type="primary"
|
|
|
|
- icon="icon icon-delete-white"
|
|
|
|
- @click="removeFile"
|
|
|
|
- >
|
|
|
|
- 清空文件
|
|
|
|
- </el-button>
|
|
|
|
- <el-button
|
|
|
|
- size="small"
|
|
|
|
- type="primary"
|
|
|
|
- icon="icon icon-export-white"
|
|
|
|
- :loading="tempDownloading"
|
|
|
|
- @click="exportFile"
|
|
|
|
- >
|
|
|
|
- 下载模板
|
|
|
|
- </el-button>
|
|
|
|
- <div slot="tip" class="el-upload__tip">只能上传xlsx文件</div>
|
|
|
|
- </el-upload>
|
|
|
|
- </el-form-item>
|
|
|
|
- </el-form>
|
|
|
|
- </el-dialog>
|
|
|
|
|
|
+ <import-file-dialog
|
|
|
|
+ ref="ImportUserDialog"
|
|
|
|
+ dialog-title="导入用户"
|
|
|
|
+ :template-url="userTemplateUrl"
|
|
|
|
+ :upload-url="uploadUserUrl"
|
|
|
|
+ @uploaded="uploadSuccess"
|
|
|
|
+ ></import-file-dialog>
|
|
|
|
|
|
<!-- 导入错误信息列表 -->
|
|
<!-- 导入错误信息列表 -->
|
|
<el-dialog title="错误提示" :visible.sync="errDialog" append-to-body>
|
|
<el-dialog title="错误提示" :visible.sync="errDialog" append-to-body>
|
|
@@ -550,10 +495,11 @@
|
|
<script>
|
|
<script>
|
|
import { QUESTION_API } from "@/constants/constants.js";
|
|
import { QUESTION_API } from "@/constants/constants.js";
|
|
import { mapState } from "vuex";
|
|
import { mapState } from "vuex";
|
|
-import { downloadByApi } from "@/plugins/download";
|
|
|
|
|
|
+import ImportFileDialog from "@/components/ImportFileDialog.vue";
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: "User",
|
|
name: "User",
|
|
|
|
+ components: { ImportFileDialog },
|
|
data() {
|
|
data() {
|
|
var validateRootOrg = (rule, value, callback) => {
|
|
var validateRootOrg = (rule, value, callback) => {
|
|
if (0 != value && !value) {
|
|
if (0 != value && !value) {
|
|
@@ -570,14 +516,10 @@ export default {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
return {
|
|
return {
|
|
- impDialog: false,
|
|
|
|
- uploadAction: QUESTION_API + "/user/import",
|
|
|
|
- uploadHeaders: {},
|
|
|
|
- uploadData: {},
|
|
|
|
|
|
+ uploadUserUrl: `${QUESTION_API}/user/import`,
|
|
|
|
+ userTemplateUrl: `${QUESTION_API}/user/importTemplate`,
|
|
errMessages: [],
|
|
errMessages: [],
|
|
errDialog: false,
|
|
errDialog: false,
|
|
- fileLoading: false,
|
|
|
|
- fileList: [],
|
|
|
|
|
|
|
|
courseList4Search: [],
|
|
courseList4Search: [],
|
|
courseLoading4Search: false,
|
|
courseLoading4Search: false,
|
|
@@ -749,10 +691,6 @@ export default {
|
|
created() {
|
|
created() {
|
|
this.initPrivileges();
|
|
this.initPrivileges();
|
|
this.init();
|
|
this.init();
|
|
- this.uploadHeaders = {
|
|
|
|
- key: this.user.key,
|
|
|
|
- token: this.user.token,
|
|
|
|
- };
|
|
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
roleDis(code) {
|
|
roleDis(code) {
|
|
@@ -762,97 +700,23 @@ export default {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- impUser() {
|
|
|
|
- this.impDialog = true;
|
|
|
|
- this.initUpload();
|
|
|
|
- },
|
|
|
|
- initUpload() {
|
|
|
|
- this.fileList = [];
|
|
|
|
|
|
+ //导入
|
|
|
|
+ importUser() {
|
|
|
|
+ this.$refs.ImportUserDialog.open();
|
|
},
|
|
},
|
|
uploadSuccess(response) {
|
|
uploadSuccess(response) {
|
|
- if (!response.hasError) {
|
|
|
|
|
|
+ const { hasError, failRecords } = response.data;
|
|
|
|
+ if (!hasError) {
|
|
this.$notify({
|
|
this.$notify({
|
|
message: "上传成功",
|
|
message: "上传成功",
|
|
type: "success",
|
|
type: "success",
|
|
});
|
|
});
|
|
- this.fileLoading = false;
|
|
|
|
- this.impDialog = false;
|
|
|
|
this.searchForm();
|
|
this.searchForm();
|
|
} else {
|
|
} else {
|
|
- this.fileLoading = false;
|
|
|
|
- this.impDialog = false;
|
|
|
|
- this.errMessages = response.failRecords;
|
|
|
|
|
|
+ this.errMessages = failRecords;
|
|
this.errDialog = true;
|
|
this.errDialog = true;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- uploadError(response) {
|
|
|
|
- var json = JSON.parse(response.message);
|
|
|
|
- if (response.status == 500) {
|
|
|
|
- this.$notify({
|
|
|
|
- message: json.desc,
|
|
|
|
- type: "error",
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- this.fileLoading = false;
|
|
|
|
- },
|
|
|
|
- //确定上传
|
|
|
|
- submitUpload() {
|
|
|
|
- if (!this.checkUpload()) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- this.$refs.upload.submit();
|
|
|
|
- this.fileLoading = true;
|
|
|
|
- },
|
|
|
|
- checkUpload() {
|
|
|
|
- var fileList = this.$refs.upload.uploadFiles;
|
|
|
|
- if (fileList.length == 0) {
|
|
|
|
- this.$notify({
|
|
|
|
- message: "上传文件不能为空",
|
|
|
|
- type: "error",
|
|
|
|
- });
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- if (fileList.length > 1) {
|
|
|
|
- this.$notify({
|
|
|
|
- message: "每次只能上传一个文件",
|
|
|
|
- type: "error",
|
|
|
|
- });
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- for (let file of fileList) {
|
|
|
|
- if (!file.name.endsWith(".xlsx")) {
|
|
|
|
- this.$notify({
|
|
|
|
- message: "上传文件必须为xlsx格式",
|
|
|
|
- type: "error",
|
|
|
|
- });
|
|
|
|
- this.initUpload();
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return true;
|
|
|
|
- },
|
|
|
|
- //清空文件
|
|
|
|
- removeFile() {
|
|
|
|
- // this.fileList = [];
|
|
|
|
- this.$refs.upload.clearFiles();
|
|
|
|
- },
|
|
|
|
- //下载模板
|
|
|
|
- async exportFile() {
|
|
|
|
- if (this.tempDownloading) return;
|
|
|
|
- this.tempDownloading = true;
|
|
|
|
-
|
|
|
|
- const res = await downloadByApi(() => {
|
|
|
|
- return this.$httpWithMsg.get(`${QUESTION_API}/user/importTemplate`, {
|
|
|
|
- responseType: "blob",
|
|
|
|
- });
|
|
|
|
- }).catch((e) => {
|
|
|
|
- this.$message.error(e || "下载失败,请重新尝试!");
|
|
|
|
- });
|
|
|
|
- this.tempDownloading = false;
|
|
|
|
-
|
|
|
|
- if (!res) return;
|
|
|
|
- this.$message.success("下载成功!");
|
|
|
|
- },
|
|
|
|
getCourses4Search(query) {
|
|
getCourses4Search(query) {
|
|
this.courseLoading4Search = true;
|
|
this.courseLoading4Search = true;
|
|
this.$httpWithMsg
|
|
this.$httpWithMsg
|