mirror of
https://gitee.com/elegant_wings/xiongan-meeting-html.git
synced 2025-08-08 10:42:43 +08:00
修改了企业的导出和导入的功能
This commit is contained in:
parent
6652ebce7a
commit
6b2e85cbe9
@ -104,8 +104,15 @@ export function importData (data) {
|
||||
return axios({
|
||||
url: api.icsCustomerStaff + '/importData',
|
||||
method: 'post',
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
params: data
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function exportTemplate () {
|
||||
return axios({
|
||||
url: api.icsCustomerStaff + '/exportTemplate',
|
||||
method: 'post',
|
||||
data: { }
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -315,43 +315,26 @@
|
||||
</a-tabs>
|
||||
</a-form>
|
||||
<customer-contacts-modal ref='contactModal' @ok='handleContactSaved' />
|
||||
<a-modal v-model="visible" title="导入用户" @ok="handleFileOk">
|
||||
<!-- <a-upload-dragger-->
|
||||
<!-- name="file"-->
|
||||
<!-- :multiple="true"-->
|
||||
<!-- :file-list="fileList"-->
|
||||
<!-- :action="uploadUrl"-->
|
||||
<!-- :headers="headers"-->
|
||||
<!-- @change="handleFileChange"-->
|
||||
<!-- >-->
|
||||
<!-- <p class="ant-upload-drag-icon">-->
|
||||
<!-- <a-icon type="inbox" />-->
|
||||
<!-- </p>-->
|
||||
<!-- <p class="ant-upload-text">-->
|
||||
<!-- 单击或拖动文件到此区域进行上传-->
|
||||
<!-- </p>-->
|
||||
<!-- </a-upload-dragger>-->
|
||||
|
||||
<a-modal v-model="visible" title="导入用户" @ok="handleFileOk" >
|
||||
<div style='display: flex'>
|
||||
<a-upload
|
||||
:fileList="fileList"
|
||||
:headers="headers"
|
||||
accept=".xlsx,.xls"
|
||||
@change="customChange"
|
||||
:customRequest="customRequest">
|
||||
<a-button type="primary" >导入</a-button>
|
||||
|
||||
|
||||
<a-button type="primary" >导入用户数据</a-button>
|
||||
</a-upload>
|
||||
<!-- <a-upload-->
|
||||
<!-- accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"-->
|
||||
<!-- :customRequest="customRequest"-->
|
||||
<!-- @change="customChange"-->
|
||||
<!-- :disabled="uploadDisabled">-->
|
||||
<!-- <a-button type="primary" :icon="uploadIcon" :disabled="uploadDisabled">导入</a-button>-->
|
||||
<!-- </a-upload>-->
|
||||
<a-button style='margin-left: 40px' type="primary" @click='exportTemplate'>导出用户模板</a-button>
|
||||
</div>
|
||||
|
||||
</a-modal>
|
||||
</a-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
let downloadLoadingInstance;
|
||||
import moment from 'moment'
|
||||
import storage from 'store'
|
||||
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
||||
@ -362,7 +345,8 @@ import {
|
||||
getStaffList,
|
||||
selectCustomerStaffList,
|
||||
updateStaffByCustomer,
|
||||
importData
|
||||
importData,
|
||||
exportTemplate
|
||||
} from '@/api/admin/customer'
|
||||
import {
|
||||
getFloorList,
|
||||
@ -372,7 +356,8 @@ import { getCustomerContractList } from '@/api/admin/customerContract'
|
||||
import CustomerContactsModal from './modules/CustomerContactsModal.vue'
|
||||
import CustomerAttachmentList from './modules/CustomerAttachmentList.vue'
|
||||
import pick from 'lodash.pick'
|
||||
|
||||
import { message } from 'ant-design-vue'
|
||||
import { download } from '@/utils/request'
|
||||
export default {
|
||||
name: 'BaseForm',
|
||||
components: {
|
||||
@ -430,6 +415,10 @@ export default {
|
||||
title: '手机号',
|
||||
dataIndex: 'mobile'
|
||||
},
|
||||
{
|
||||
title: '性别',
|
||||
dataIndex: 'gender'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'operation',
|
||||
@ -511,17 +500,58 @@ export default {
|
||||
this.floorList = res.data
|
||||
})
|
||||
},
|
||||
exportTemplate(){
|
||||
exportTemplate().then(res =>{
|
||||
console.log(res)
|
||||
this.downloadFile(res)
|
||||
})
|
||||
},
|
||||
downloadFile (data) {
|
||||
let fileName = '客户导入模板'
|
||||
|
||||
let link = document.createElement('a')
|
||||
let blob = new Blob([data], {type: 'application/vnd.ms-excel;charset=utf-8'});
|
||||
console.log(blob)
|
||||
link.style.display = 'none';
|
||||
link.download = fileName+'.xlsx';
|
||||
link.href = URL.createObjectURL(blob);
|
||||
// link.setAttribute('download', fileName+'.xlsx');
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
URL.revokeObjectURL(link.href); // 释放URL 对象
|
||||
document.body.removeChild(link);
|
||||
|
||||
|
||||
|
||||
// console.log(data)
|
||||
// var link = document.createElement('a')
|
||||
// // 文件导出
|
||||
// if (!data) {
|
||||
// return
|
||||
// }
|
||||
// link.style.display = 'none'
|
||||
// link.href = window.URL.createObjectURL(new Blob([data]))
|
||||
// link.setAttribute('download', '用户导入模板.xls')
|
||||
// document.body.appendChild(link)
|
||||
// link.click()
|
||||
},
|
||||
|
||||
|
||||
customRequest(file){
|
||||
// file 是上传的文件 其内容会在放在下面截图中
|
||||
// 后端需要接受的参数是 formData数据,
|
||||
// uploadFile 我自己的接口
|
||||
|
||||
const formData = new FormData()
|
||||
formData.append('file', file.file)
|
||||
console.log(file)
|
||||
importData({ filePath:file.file.name }).then(res => {
|
||||
if (res.success) {
|
||||
importData(formData).then(res => {
|
||||
if (res.code == 0) {
|
||||
// 调用组件内方法, 设置为成功状态
|
||||
file.onSuccess(res, file.file)
|
||||
file.status = 'done'
|
||||
this.visible =false
|
||||
this.$message.success(res.msg)
|
||||
} else {
|
||||
file.onError()
|
||||
file.status = 'error'
|
||||
@ -537,6 +567,9 @@ export default {
|
||||
this.file =info.file.response
|
||||
this.fileName = result.fileName
|
||||
}
|
||||
},
|
||||
customChange(){
|
||||
|
||||
},
|
||||
//导入用户数据
|
||||
importUser(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user