This commit is contained in:
SelfRidicule 2024-04-02 15:40:09 +08:00
commit e1147d96b4
3 changed files with 215 additions and 7 deletions

View File

@ -100,6 +100,22 @@ export function getCustomer (parameter) {
}) })
} }
export function importData (data) {
return axios({
url: api.icsCustomerStaff + '/importData',
method: 'post',
data: data
})
}
export function exportTemplate () {
return axios({
url: api.icsCustomerStaff + '/exportTemplate',
method: 'post',
data: { }
})
}
export function getQiXinBasicInfo (parameter) { export function getQiXinBasicInfo (parameter) {
return axios({ return axios({
url: api.customer + '/getBasicInfo', url: api.customer + '/getBasicInfo',

View File

@ -290,6 +290,9 @@
<a-button type='primary' @click='$refs.contactModal.add({ customerId: $route.query.customerId })'> <a-button type='primary' @click='$refs.contactModal.add({ customerId: $route.query.customerId })'>
新建企业员工 新建企业员工
</a-button> </a-button>
<a-button style='margin-left: 30px' type='success' @click='importUser'>
导入用户
</a-button>
</div> </div>
<a-table :pagination='false' :columns='contactsItemColumns' :dataSource='contactsItemData' rowKey='id'> <a-table :pagination='false' :columns='contactsItemColumns' :dataSource='contactsItemData' rowKey='id'>
<template slot='operation' slot-scope='text, record'> <template slot='operation' slot-scope='text, record'>
@ -312,10 +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" >
<div style='display: flex'>
<a-upload
:fileList="fileList"
:headers="headers"
accept=".xlsx,.xls"
@change="customChange"
:customRequest="customRequest">
<a-button type="primary" >导入用户数据</a-button>
</a-upload>
<a-button style='margin-left: 40px' type="primary" @click='exportTemplate'>导出用户模板</a-button>
</div>
</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'
@ -325,7 +344,9 @@ import {
getQiXinBasicInfo, getQiXinBasicInfo,
getStaffList, getStaffList,
selectCustomerStaffList, selectCustomerStaffList,
updateStaffByCustomer updateStaffByCustomer,
importData,
exportTemplate
} from '@/api/admin/customer' } from '@/api/admin/customer'
import { import {
getFloorList, getFloorList,
@ -335,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: {
@ -393,6 +415,10 @@ export default {
title: '手机号', title: '手机号',
dataIndex: 'mobile' dataIndex: 'mobile'
}, },
{
title: '性别',
dataIndex: 'gender'
},
{ {
title: '操作', title: '操作',
key: 'operation', key: 'operation',
@ -439,6 +465,8 @@ export default {
form: this.$form.createForm(this), form: this.$form.createForm(this),
floorList: [], floorList: [],
roomList: [], roomList: [],
file:'',
visible:false
} }
}, },
filters: { filters: {
@ -472,6 +500,87 @@ 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){
// file
// formData
// uploadFile
const formData = new FormData()
formData.append('file', file.file)
console.log(file)
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'
}
})
},
handleFileChange(info){
this.fileList = info.fileList
if (info.file.status === 'done') {
const result = info.file.response
this.file =info.file.response
this.fileName = result.fileName
}
},
customChange(){
},
//
importUser(){
this.visible = true
},
handleFileOk(){
console.log(this.file)
importData({file:this.file}).then(res =>{
console.log(res)
})
},
// //
getRoomList(value) { getRoomList(value) {
let param = { let param = {

View File

@ -81,7 +81,6 @@
<a-input placeholder='紧急联系人' v-decorator="['urgent']" /> <a-input placeholder='紧急联系人' v-decorator="['urgent']" />
</a-form-item> </a-form-item>
</a-form-item>
<!-- <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="联系电话">--> <!-- <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="联系电话">-->
<!-- <a-input placeholder="联系电话" v-decorator="['phone']"/>--> <!-- <a-input placeholder="联系电话" v-decorator="['phone']"/>-->
<!-- </a-form-item>--> <!-- </a-form-item>-->
@ -92,8 +91,10 @@
</a-modal> </a-modal>
</template> </template>
<script> <script>
import { saveCustomerContacts,getStaffList,updateStaff,getStaffListNotId } from '@/api/admin/customer' import { importData,getStaffList,updateStaff,getCustomer,getStaffListNotId } from '@/api/admin/customer'
import pick from 'lodash.pick' import pick from 'lodash.pick'
import storage from 'store'
import { ACCESS_TOKEN } from '@/store/mutation-types'
export default { export default {
name: 'CustomerContactsModal', name: 'CustomerContactsModal',
props: { props: {
@ -112,12 +113,21 @@ export default {
xs: { span: 24 }, xs: { span: 24 },
sm: { span: 16 } sm: { span: 16 }
}, },
uploadUrl: process.env.VUE_APP_API_BASE_URL + '/api/dfs/upload',
imageUrl: '',
headers: {
Authorization: 'Bearer ' + storage.get(ACCESS_TOKEN)
},
confirmLoading: false, confirmLoading: false,
mdl: {}, mdl: {},
customerId: undefined, customerId: undefined,
contactId: undefined, contactId: undefined,
form: this.$form.createForm(this), form: this.$form.createForm(this),
data:[], data:[],
photoImageUrl: '',
photoLoading: false,
avatarImageUrl: '',
avatarLoading: false
} }
}, },
beforeCreate () { beforeCreate () {
@ -126,6 +136,79 @@ export default {
}, },
methods: { methods: {
//
photoBeforeUpload(file) {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'
if (!isJpgOrPng) {
this.$message.error('You can only upload JPG file!')
}
const isLt2M = file.size / 1024 < 5000
if (!isLt2M) {
this.$message.error('图片必须小于 5M!')
}
return isJpgOrPng && isLt2M
},
photoHandleChange(info) {
if (info.file.status === 'uploading') {
this.photoLoading = true
return
}
if (info.file.status === 'done') {
const { form: { setFieldsValue } } = this
const result = info.file.response
//
this.$nextTick(() => {
setFieldsValue({
//
photo: result.fileName
})
})
// Get this url from response in real world.
this.getBase64(info.file.originFileObj, imageUrl => {
this.photoImageUrl = imageUrl
this.photoLoading = false
})
}
},
//
avatarBeforeUpload(file) {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'
if (!isJpgOrPng) {
this.$message.error('You can only upload JPG file!')
}
const isLt2M = file.size / 1024 < 5000
if (!isLt2M) {
this.$message.error('图片必须小于 5M!')
}
return isJpgOrPng && isLt2M
},
avatarHandleChange(info) {
if (info.file.status === 'uploading') {
this.avatarLoading = true
return
}
if (info.file.status === 'done') {
const { form: { setFieldsValue } } = this
const result = info.file.response
//
this.$nextTick(() => {
setFieldsValue({
//
avatar: result.fileName
})
})
// Get this url from response in real world.
this.getBase64(info.file.originFileObj, imageUrl => {
this.avatarImageUrl = imageUrl
this.avatarLoading = false
})
}
},
getBase64(img, callback) {
const reader = new FileReader()
reader.addEventListener('load', () => callback(reader.result))
reader.readAsDataURL(img)
},
handleSearch(value){ handleSearch(value){
let param = { let param = {
mobile:value mobile:value
@ -151,7 +234,7 @@ export default {
let param = { let param = {
icsCustomerId:contactInfo.customerId icsCustomerId:contactInfo.customerId
} }
getStaffListNotId(param).then(res =>{ getCustomer(param).then(res =>{
this.data =res.rows this.data =res.rows
}) })
@ -159,10 +242,10 @@ export default {
edit (record) { edit (record) {
this.mdl = Object.assign(record) this.mdl = Object.assign(record)
console.log(this.mdl) console.log(this.mdl)
// this.mdl = record
this.visible = true this.visible = true
this.$nextTick(() => { this.$nextTick(() => {
this.form.setFieldsValue(pick(this.mdl, 'id', 'customerId', 'name', 'phone', 'remark')) this.form.setFieldsValue(pick(this.mdl, 'id','name','username','mobile','gender',
'photo','avatar','cardNo','address','email','degree','urgent', 'customerId', 'remark'))
}) })
}, },
handleSubmit (e) { handleSubmit (e) {