提交 3cfe1f36 编写于 作者: shuang.zhou's avatar shuang.zhou

Merge branch 'testing/shield-upload' into 'release'

Testing/shield upload

See merge request com.pica.cloud.education.frontend/pica.cloud.web-education-admin!392
...@@ -46,4 +46,15 @@ export const uploadPersonExcel = (data, projectId) => { ...@@ -46,4 +46,15 @@ export const uploadPersonExcel = (data, projectId) => {
description: '上传excel文件', description: '上传excel文件',
}) })
// }) // })
}
export const uploadShieldExcel = (data, projectId) => {
return fetch({
headers: {
token: localStorage.getItem('storageToken'),
},
url: getBaseUrl('aggregate/black/setPeopleBlackStatus/batch/' + projectId),
method: 'post',
data: data,
description: '上传excel文件',
})
} }
\ No newline at end of file
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
</el-col> </el-col>
<el-col :span="6" style="padding:0;text-align:right;padding-right:10px;"> <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="searchList()">搜索</el-button>
<el-button type="primary" size="small" @click="importOrder()" v-if="shieldType == 1">批量导入</el-button>
</el-col> </el-col>
</el-form> </el-form>
</el-row> </el-row>
...@@ -103,12 +104,60 @@ ...@@ -103,12 +104,60 @@
</span> </span>
</el-dialog> </el-dialog>
</div> </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> </div>
</template> </template>
<script> <script>
import BreadCrumb from "../../components/breadcrumb.vue"; import BreadCrumb from "../../components/breadcrumb.vue";
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
import { openLoading, closeLoading } from "../../utils/utils"; import { openLoading, closeLoading } from "../../utils/utils";
import { uploadShieldExcel } from "@/utils/education/educationApi";
import * as commonUtil from "../../utils/utils"; import * as commonUtil from "../../utils/utils";
import * as operationData from "../../utils/operation"; import * as operationData from "../../utils/operation";
let vm = null; let vm = null;
...@@ -118,6 +167,14 @@ export default { ...@@ -118,6 +167,14 @@ export default {
}, },
data() { data() {
return { return {
isShowImport: false,
isLoading: false,
logisticsUrl: 'https://files.yunqueyi.com/template/portal_template.xlsx',
fileData: {
ext: '',
file: "",
fileName: "",
},
curmbFirst: "教培项目", curmbFirst: "教培项目",
curmbSecond: "屏蔽", curmbSecond: "屏蔽",
projectId: "", projectId: "",
...@@ -232,6 +289,69 @@ export default { ...@@ -232,6 +289,69 @@ export default {
// } // }
// }, // },
methods: { 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;
let parmas = {
base64: this.fileData,
type: ''
}
uploadShieldExcel(parmas, this.projectId).then(res => {
if (res.code == '000000') {
if (res.data == '') {
this.isLoading = false;
this.isShowImport = 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('导入失败');
}
} else {
this.isLoading = false;
this.$message.error(res.message);
}
}).catch(error => {
this.isLoading = false;
this.$message.error(error.message);
})
},
// 取消导入
cancelImport() {
this.fileData = {
file: "",
fileName: "",
};
this.isShowImport = false;
},
handleChange(value) { handleChange(value) {
let areaId = "000"; let areaId = "000";
for (let i = 0; i < value.length; i++) { for (let i = 0; i < value.length; i++) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册