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