朱思禹提交:完成批量导入功能

init
Administrator 4 years ago
parent 677444c0fe
commit 80e74fdd42

@ -1,4 +1,5 @@
<template> <template>
<a-config-provider :locale="locale">
<div class="app-style" ref="app"> <div class="app-style" ref="app">
<Menu @onLoad="menuOnLoad" @menuChange="menuChanged"/> <Menu @onLoad="menuOnLoad" @menuChange="menuChanged"/>
<div class="content-style"> <div class="content-style">
@ -13,18 +14,21 @@
</div> </div>
<modal-panel></modal-panel> <modal-panel></modal-panel>
</div> </div>
</a-config-provider>
</template> </template>
<script> <script>
import {Spin,Icon} from 'ant-design-vue' import {Spin,Icon,ConfigProvider} from 'ant-design-vue'
import Menu from './menu/Menu' import Menu from './menu/Menu'
import PageConfig from './pageConfig' import PageConfig from './pageConfig'
import ModalPanel from '../../components/common/modal/ModalPanel'; import ModalPanel from '../../components/common/modal/ModalPanel';
import OfficeMenuConfig from "../../utils/officeMenuConfig" import OfficeMenuConfig from "../../utils/officeMenuConfig"
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN';
export default { export default {
name: 'App', name: 'App',
data:function(){ data:function(){
return{ return{
locale: zhCN,
is_loaded_data:false, is_loaded_data:false,
selectedMenu:null, selectedMenu:null,
contentUrl:"", contentUrl:"",
@ -35,7 +39,8 @@ export default {
ASpin:Spin, ASpin:Spin,
AIcon:Icon, AIcon:Icon,
Menu, Menu,
ModalPanel ModalPanel,
AConfigProvider:ConfigProvider
}, },
methods:{ methods:{
menuOnLoad:function (ary) { menuOnLoad:function (ary) {

@ -12,7 +12,7 @@
{{ person.person_name }} {{ person.person_name }}
</a-select-option> </a-select-option>
</a-select> </a-select>
<a-button class="left-top-add-btn-style" type="primary">批量导入</a-button> <a-button class="left-top-add-btn-style" type="primary" @click="importData"></a-button>
</div> </div>
</div> </div>
<div class="table-container-style"> <div class="table-container-style">
@ -38,19 +38,34 @@
</a-table> </a-table>
</div> </div>
<a-pagination :current="pageNumber" :pageSize="pageSize" :hideOnSinglePage="true" :total="totalRow" class="pagination-style" @change="pageChange"/> <a-pagination :current="pageNumber" :pageSize="pageSize" :hideOnSinglePage="true" :total="totalRow" class="pagination-style" @change="pageChange"/>
<ModalPanel addChildType="slot" modalTitle="批量导入" :show="showImportPanel" :OKButton="false" @callback="panelCallback">
<a-spin :spinning="isUploading" tip="正在上传,请稍候...">
<div class="import-container-style">
<div style="font-size: 0.875rem;color: #31a8fa;margin-bottom: 0.5rem">请选择导入数据的文件</div>
<a-upload accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
:beforeUpload="beforeUpload" :withCredentials="true" :fileList="fileList">
<a-button> <a-icon type="upload" /> 上传文件 </a-button>
</a-upload>
<a-button type="link" style="color: #31a8fa" @click="downloadTemplate" class="down-style">下载模板</a-button>
<div ref="tip" class="tip-style"></div>
</div>
</a-spin>
</ModalPanel>
</div> </div>
<edit-and-view-form v-else-if="formData !== null && formData !== undefined" :pageType="editPageType" :dataNumType="data_num_type" :dataInfo="formData" :showOperateList="true" <edit-and-view-form v-else-if="formData !== null && formData !== undefined" :pageType="editPageType" :dataNumType="data_num_type" :dataInfo="formData" :showOperateList="true"
@back="returnBack" :form_id="purview_id" @submitSuccess="onSubmitSuccess" :businessType="4" :person-info="personInfo"/> @back="returnBack" :form_id="purview_id" @submitSuccess="onSubmitSuccess" :businessType="4" :person-info="personInfo"/>
</template> </template>
<script> <script>
import {Button,Table,Pagination,Select,Spin} from 'ant-design-vue' import {Button,Table,Pagination,Select,Spin,Upload,Icon} from 'ant-design-vue'
import InterfaceConfig from './interfaceConfig' import InterfaceConfig from './interfaceConfig'
import EditAndViewForm from '../formCommon/EditAndViewForm' import EditAndViewForm from '../formCommon/EditAndViewForm'
import CommonOperate from '../utils/commonOperate' import CommonOperate from '../utils/commonOperate'
import debounce from 'lodash/debounce' import debounce from 'lodash/debounce'
import CommonInterfaceConfig from '../../../commonInterface/interfaceConfig' import CommonInterfaceConfig from '../../../commonInterface/interfaceConfig'
import ShowAttachment from '../../../components/common/showAttachment/ShowAttachment' import ShowAttachment from '../../../components/common/showAttachment/ShowAttachment'
import ModalPanel from "../../../components/common/modal/ModalPanel"
import axios from 'axios'
export default { export default {
name: "TeacherInfoList", name: "TeacherInfoList",
props:["purview_id","purview_name","data_num_type",], props:["purview_id","purview_name","data_num_type",],
@ -71,10 +86,14 @@
searchValue:undefined, searchValue:undefined,
personData:[], personData:[],
fetching: false, fetching: false,
personInfo:{} personInfo:{},
showImportPanel:false,
fileList:[],
isUploading:false
} }
}, },
components:{ components:{
ModalPanel,
AButton:Button, AButton:Button,
ATable:Table, ATable:Table,
EditAndViewForm, EditAndViewForm,
@ -82,7 +101,9 @@
ASelect:Select, ASelect:Select,
ASpin:Spin, ASpin:Spin,
ASelectOption:Select.Option, ASelectOption:Select.Option,
ShowAttachment ShowAttachment,
AUpload:Upload,
AIcon:Icon
}, },
computed:{ computed:{
getColumns:function () { getColumns:function () {
@ -116,7 +137,6 @@
ary.push({title:"最新修改时间",dataIndex:"last_modify_time",fixed:'right',align:'center',width:160}) ary.push({title:"最新修改时间",dataIndex:"last_modify_time",fixed:'right',align:'center',width:160})
ary.push({title:"操作",scopedSlots:{customRender:"operate"},fixed:'right',align:'center'}) ary.push({title:"操作",scopedSlots:{customRender:"operate"},fixed:'right',align:'center'})
} }
return ary return ary
} }
}, },
@ -124,6 +144,56 @@
this.getListData() this.getListData()
}, },
methods:{ methods:{
beforeUpload:function(file){
this.isUploading = true;
this.$refs.tip.innerText = "";
let fd = new FormData()//
fd.append('file', file)//file
let url = this.BaseConfig.url_path_action + "/intellioa/java/teacher/importTeacherFormTemplate?org_id=" + this.BaseConfig.person_info_my.bureau_id
+ "&system_id=10&form_id="+this.purview_id+"&dept_id="+this.BaseConfig.person_info_my.dep_id + "&person_id=" + this.BaseConfig.userInfo.person_id_cookie;
axios({
method: 'post',
url: url,
data: fd,
headers: {
'Content-Type':'multipart/form-data;boundary=' + new Date().getTime(),
},
}).then((rsp) => {
this.isUploading = false;
if (rsp.data.success === true){
this.fileList = [{
uid:file.uid,
name:file.name,
status: 'done',
}]
this.$toast("上传成功");
this.pageNumber = 1;
this.getListData();
}else{
this.$refs.tip.innerText = rsp.data.info
}
console.log(rsp)
}).catch((error) => {
this.isUploading = false;
this.$refs.tip.innerText = error;
})
return false
},
downloadTemplate:function(){
// let url = this.BaseConfig.url_path_action + "/intellioa/java/teacher/downloadTeacherFormTemplate?org_id=" + this.BaseConfig.person_info_my.bureau_id
// + "&system_id=10&form_id="+this.purview_id;
let url = "http://10.10.14.199/dsideal_yy/ypt/intellioa/java/teacher/downloadTeacherFormTemplate?org_id=" + this.BaseConfig.person_info_my.bureau_id
+ "&system_id=10&form_id="+this.purview_id;
window.location.href = url;
},
panelCallback:function(){
this.showImportPanel = false;
},
importData:function(){
this.fileList = [];
this.showImportPanel = true;
},
getBadgeCount:function(value){ getBadgeCount:function(value){
let ary = JSON.parse(value); let ary = JSON.parse(value);
return ary.length > 1?ary.length:0; return ary.length > 1?ary.length:0;
@ -301,4 +371,22 @@
color:#31a8fa; color:#31a8fa;
cursor:pointer; cursor:pointer;
} }
.import-container-style{
height: 8rem;
position: relative;
.down-style{
position: absolute;
top: 2rem;
left: 6.5rem;
}
.tip-style{
position: absolute;
bottom:0;
right: 0;
width: 100%;
text-align: right;
color: red;
line-height: 1rem;
}
}
</style> </style>

Loading…
Cancel
Save