|
@@ -56,6 +56,14 @@
|
|
|
@click="handleBatchDelete"
|
|
|
>删除选中项</el-button
|
|
|
>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ size="small"
|
|
|
+ plain
|
|
|
+ icon="el-icon-upload2"
|
|
|
+ @click="batchImportVisible = true"
|
|
|
+ >导入工会</el-button
|
|
|
+ >
|
|
|
</el-row>
|
|
|
<el-table
|
|
|
ref="formTable"
|
|
@@ -130,12 +138,64 @@
|
|
|
:title="modalTitle"
|
|
|
@close="onDetailModalClose"
|
|
|
></orgInfo-detail>
|
|
|
+ <el-dialog
|
|
|
+ title="导入"
|
|
|
+ :visible.sync="batchImportVisible"
|
|
|
+ :modal-append-to-body="false"
|
|
|
+ style="text-align: left"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ >
|
|
|
+ <el-form label-width="150px">
|
|
|
+ <el-form-item label="模板下载">
|
|
|
+ <el-link
|
|
|
+ href="http://rccs.oss-cn-hangzhou.aliyuncs.com/upload/%E5%B7%A5%E4%BC%9A%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xls"
|
|
|
+ type="primary"
|
|
|
+ target="_blank"
|
|
|
+ >点击下载模板</el-link
|
|
|
+ >
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="上传文件">
|
|
|
+ <el-upload
|
|
|
+ class="upload-demo"
|
|
|
+ accept=".xls"
|
|
|
+ :action="uploadUrlXls"
|
|
|
+ :data="uploadXlsData"
|
|
|
+ :headers="headers"
|
|
|
+ :on-preview="handleBatchImportPreview"
|
|
|
+ name="uploadFile"
|
|
|
+ :multiple="true"
|
|
|
+ :limit="1"
|
|
|
+ :on-remove="handleBatchImportRemove"
|
|
|
+ :before-remove="beforeBatchImportRemove"
|
|
|
+ :before-upload="beforeUpload"
|
|
|
+ :on-exceed="handleBatchImportExceed"
|
|
|
+ :on-success="handleBatchImportSuccess"
|
|
|
+ :file-list="batchImportFileList"
|
|
|
+ >
|
|
|
+ <el-button size="small" type="primary" :loading="xlsLoading"
|
|
|
+ >点击上传</el-button
|
|
|
+ >
|
|
|
+ <div slot="tip" class="el-upload__tip">
|
|
|
+ 只能上传xls文件,且不超过500kb
|
|
|
+ </div>
|
|
|
+ </el-upload>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="batchImportVisible = false"
|
|
|
+ >关 闭</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ <!--批量导入E-->
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
|
|
|
+import Constant from "@/constant";
|
|
|
import orgInfoDetail from "./orgInfo-detail";
|
|
|
import orgInfoApi from "@/api/base/orgInfo";
|
|
|
+import { getToken } from "@/utils/auth"; // get token from cookie
|
|
|
|
|
|
export default {
|
|
|
name: "BaseOrgInfoList",
|
|
@@ -176,14 +236,22 @@ export default {
|
|
|
label: "name",
|
|
|
children: "children",
|
|
|
},
|
|
|
- batchImportVisible: false,
|
|
|
- batchImportFileList: [],
|
|
|
xlsLoading: false,
|
|
|
sceneData: [],
|
|
|
typeData: [],
|
|
|
deviceRelationTitle: "",
|
|
|
showIconModal: false,
|
|
|
iconModalTitle: "",
|
|
|
+ batchImportVisible: false,
|
|
|
+ batchImportFileList: [],
|
|
|
+ uploadUrlXls: Constant.serverUrl + "/base/orgInfo/importXls",
|
|
|
+ uploadXlsData: {
|
|
|
+ subFolder: "orgInfo",
|
|
|
+ orgInfoId: "",
|
|
|
+ },
|
|
|
+ headers: {
|
|
|
+ Authorization: getToken(),
|
|
|
+ },
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
@@ -310,6 +378,61 @@ export default {
|
|
|
this.changePage(this.pageIndex);
|
|
|
}
|
|
|
},
|
|
|
+ beforeUpload(file, fileList) {
|
|
|
+ //导入前判断
|
|
|
+ },
|
|
|
+ //批量导入-上传成功
|
|
|
+ handleBatchImportSuccess(response, file, fileList) {
|
|
|
+ var self = this;
|
|
|
+ self.xlsLoading = false;
|
|
|
+ if (response.result) {
|
|
|
+ self.$message.success(response.message);
|
|
|
+ this.batchImportFileList = [];
|
|
|
+ this.changePage(1);
|
|
|
+ this.uploadCompanyId = "";
|
|
|
+ this.uploadXlsData.orgInfoId = "";
|
|
|
+ this.batchImportVisible = false;
|
|
|
+ } else {
|
|
|
+ //this.$message.error(response.message);
|
|
|
+ this.batchImportFileList = [];
|
|
|
+ this.changePage(1);
|
|
|
+ this.uploadCompanyId = "";
|
|
|
+ this.uploadXlsData.orgInfoId = "";
|
|
|
+
|
|
|
+ if (response.data != null) {
|
|
|
+ //下载有错误信息提示的报表
|
|
|
+ //window.open(response.data);
|
|
|
+ self.$message({
|
|
|
+ showClose: true,
|
|
|
+ dangerouslyUseHTMLString: true,
|
|
|
+ message:
|
|
|
+ response.message +
|
|
|
+ `,<a href="${response.data}" target="_blank">点击下载未导入的数据报表</a> `,
|
|
|
+ duration: 30000,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //批量导入-预览
|
|
|
+ handleBatchImportPreview(file) {
|
|
|
+ console.log(file.url);
|
|
|
+ },
|
|
|
+ //批量导入-移除
|
|
|
+ handleBatchImportRemove(file, fileList) {
|
|
|
+ console.log(file, fileList);
|
|
|
+ },
|
|
|
+ //批量导入-移除前操作
|
|
|
+ beforeBatchImportRemove(file, fileList) {
|
|
|
+ console.log(file, fileList);
|
|
|
+ },
|
|
|
+ //批量导入-文件超出个数限制时的钩子
|
|
|
+ handleBatchImportExceed(files, fileList) {
|
|
|
+ this.$message.warning(
|
|
|
+ `当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
|
|
|
+ files.length + fileList.length
|
|
|
+ } 个文件`
|
|
|
+ );
|
|
|
+ },
|
|
|
},
|
|
|
mounted: function () {},
|
|
|
components: {
|