修改了企业联系人功能

This commit is contained in:
chendaze 2024-04-02 08:49:14 +08:00
parent ec052fd417
commit 863db086c7
3 changed files with 174 additions and 6 deletions

View File

@ -100,6 +100,15 @@ export function getCustomer (parameter) {
})
}
export function importData (data) {
return axios({
url: api.icsCustomerStaff + '/importData',
method: 'post',
headers: { 'Content-Type': 'multipart/form-data' },
params: data
})
}
export function getQiXinBasicInfo (parameter) {
return axios({
url: api.customer + '/getBasicInfo',

View File

@ -290,6 +290,9 @@
<a-button type='primary' @click='$refs.contactModal.add({ customerId: $route.query.customerId })'>
新建企业员工
</a-button>
<a-button style='margin-left: 30px' type='success' @click='importUser'>
导入用户
</a-button>
</div>
<a-table :pagination='false' :columns='contactsItemColumns' :dataSource='contactsItemData' rowKey='id'>
<template slot='operation' slot-scope='text, record'>
@ -312,6 +315,39 @@
</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-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-card>
</template>
@ -325,7 +361,8 @@ import {
getQiXinBasicInfo,
getStaffList,
selectCustomerStaffList,
updateStaffByCustomer
updateStaffByCustomer,
importData
} from '@/api/admin/customer'
import {
getFloorList,
@ -439,6 +476,8 @@ export default {
form: this.$form.createForm(this),
floorList: [],
roomList: [],
file:'',
visible:false
}
},
filters: {
@ -472,6 +511,43 @@ export default {
this.floorList = res.data
})
},
customRequest(file){
// file
// formData
// uploadFile
console.log(file)
importData({ filePath:file.file.name }).then(res => {
if (res.success) {
// ,
file.onSuccess(res, file.file)
file.status = 'done'
} 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
}
},
//
importUser(){
this.visible = true
},
handleFileOk(){
console.log(this.file)
importData({file:this.file}).then(res =>{
console.log(res)
})
},
//
getRoomList(value) {
let param = {

View File

@ -81,7 +81,6 @@
<a-input placeholder='紧急联系人' v-decorator="['urgent']" />
</a-form-item>
</a-form-item>
<!-- <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="联系电话">-->
<!-- <a-input placeholder="联系电话" v-decorator="['phone']"/>-->
<!-- </a-form-item>-->
@ -92,8 +91,10 @@
</a-modal>
</template>
<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 storage from 'store'
import { ACCESS_TOKEN } from '@/store/mutation-types'
export default {
name: 'CustomerContactsModal',
props: {
@ -112,12 +113,21 @@ export default {
xs: { span: 24 },
sm: { span: 16 }
},
uploadUrl: process.env.VUE_APP_API_BASE_URL + '/api/dfs/upload',
imageUrl: '',
headers: {
Authorization: 'Bearer ' + storage.get(ACCESS_TOKEN)
},
confirmLoading: false,
mdl: {},
customerId: undefined,
contactId: undefined,
form: this.$form.createForm(this),
data:[],
photoImageUrl: '',
photoLoading: false,
avatarImageUrl: '',
avatarLoading: false
}
},
beforeCreate () {
@ -126,6 +136,79 @@ export default {
},
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){
let param = {
mobile:value
@ -151,7 +234,7 @@ export default {
let param = {
icsCustomerId:contactInfo.customerId
}
getStaffListNotId(param).then(res =>{
getCustomer(param).then(res =>{
this.data =res.rows
})
@ -159,10 +242,10 @@ export default {
edit (record) {
this.mdl = Object.assign(record)
console.log(this.mdl)
// this.mdl = record
this.visible = true
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) {