提交 64d7203b 编写于 作者: shuang.zhou's avatar shuang.zhou

Merge branch 'feature/zs-export' into 'testing/shield-upload'

屏蔽人员 批量导入

See merge request com.pica.cloud.education.frontend/pica.cloud.web-education-admin!381
......@@ -46,4 +46,15 @@ export const uploadPersonExcel = (data, projectId) => {
description: '上传excel文件',
})
// })
}
export const uploadShieldExcel = (data, projectId) => {
return fetch({
headers: {
token: localStorage.getItem('storageToken'),
},
url: getBaseUrl('black/setPeopleBlackStatus/batch/' + projectId),
method: 'post',
data: data,
description: '上传excel文件',
})
}
\ No newline at end of file
......@@ -49,6 +49,7 @@
</el-col>
<el-col :span="6" style="padding:0;text-align:right;padding-right:10px;">
<el-button type="primary" size="small" @click="searchList()">搜索</el-button>
<el-button type="primary" size="small" @click="importOrder()" v-if="shieldType == 1">批量导入</el-button>
</el-col>
</el-form>
</el-row>
......@@ -103,12 +104,60 @@
</span>
</el-dialog>
</div>
<!-- 导入屏蔽人员名单 -->
<el-dialog
class="exportlogistics-dialog"
title="批量导入"
:visible="isShowImport"
@close="isShowImport = false"
width="600px"
>
<el-form label-width="120px">
<el-form-item label="导入文档:">
<el-upload
class="upload-excel"
action="#"
accept=".xlsx"
multiple
:limit="1"
:show-file-list="true"
:before-upload="uploadfile"
>
<div class="upload-container">
<el-input
class="file-name"
v-model="fileData.fileName"
size="mini"
readonly
></el-input
>
<el-button type="primary" size="mini">选择文件</el-button>
</div>
</el-upload>
</el-form-item>
<el-form-item label="模板:">
<a class="import-url" :href="logisticsUrl" style="color: #449284">
批量导入模板.xlxs</a>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button size="small" @click="cancelImport">取消</el-button>
<el-button
size="small"
:loading="isLoading"
type="primary"
@click="confirmImport"
>确认</el-button
>
</div>
</el-dialog>
</div>
</template>
<script>
import BreadCrumb from "../../components/breadcrumb.vue";
import { mapGetters } from "vuex";
import { openLoading, closeLoading } from "../../utils/utils";
import { uploadShieldExcel } from "@/utils/education/educationApi";
import * as commonUtil from "../../utils/utils";
import * as operationData from "../../utils/operation";
let vm = null;
......@@ -118,6 +167,14 @@ export default {
},
data() {
return {
isShowImport: false,
isLoading: false,
logisticsUrl: 'https://files.yunqueyi.com/template/portal_template.xlsx',
fileData: {
ext: '',
file: "",
fileName: "",
},
curmbFirst: "教培项目",
curmbSecond: "屏蔽",
projectId: "",
......@@ -232,6 +289,60 @@ export default {
// }
// },
methods: {
// 批量导入
importOrder() {
this.isShowImport = true;
},
uploadfile(file) {
console.log(file, '导入file');
let _this = this;
let arr = file.name.split(".");
let ext = "." + arr[1];
let name = file.name;
let reader = new FileReader();
reader.onload = function (e) {
_this.fileData.fileName = name;
_this.fileData.file = e.target.result.substr(
e.target.result.indexOf("base64,") + 7
);
_this.fileData.ext = ext;
console.log("fileJson", _this.fileData);
};
reader.readAsDataURL(file);
},
// 确认导入
confirmImport() {
this.isLoading = true;
uploadShieldExcel(this.fileData, this.projectId).then(res => {
if (res.code == '000000') {
if (res.data == '') {
this.isLoading = false;
this.$message({
message: '导入成功',
type: 'success'
});
} else {
let a = document.createElement('a');
let href = res.data;
a.setAttribute('href',href);
a.click();
this.isLoading = false;
this.$message.error('导入失败');
}
}
}).catch(error => {
this.isLoading = false;
this.$message.error(error.message);
})
},
// 取消导入
cancelImport() {
this.fileData = {
file: "",
fileName: "",
};
this.isShowImport = false;
},
handleChange(value) {
let areaId = "000";
for (let i = 0; i < value.length; i++) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册