修改了企业添加人员设备功能

This commit is contained in:
chendaze 2024-04-02 17:32:50 +08:00
parent 6b2e85cbe9
commit 37f55d869e
2 changed files with 187 additions and 52 deletions

View File

@ -33,6 +33,36 @@ export function selectCustomerStaffList (parameter) {
}
//获取企业下用户设备信息
export function selectUserDeviceList (data) {
return axios({
url: api.icsCustomerStaff + '/selectUserDeviceList',
method: 'post',
data: data
})
}
export function selectEquipmentListById (data) {
return axios({
url: api.icsCustomerStaff + '/selectEquipmentListById',
method: 'post',
data: data
})
}
// 保存用户和设备关联
export function saveUserEquipment (parameter) {
return axios({
url: api.icsCustomerStaff + '/saveUserEquipment',
method: 'post',
data: parameter,
headers: {
'Content-Type': 'application/json;charset=UTF-8'
}
})
}
export function getStaffListNotId (parameter) {
return axios({

View File

@ -110,7 +110,8 @@
</a-col>
<a-col :span='12'>
<a-form-item :labelCol='labelColHalf' :wrapperCol='wrapperColHalf' label='联系人'>
<a-input placeholder='联系人' v-decorator="['contacts',{rules: [{ required: true, message: '请输入联系人' }]}]" />
<a-input placeholder='联系人'
v-decorator="['contacts',{rules: [{ required: true, message: '请输入联系人' }]}]" />
</a-form-item>
</a-col>
<a-col :span='12'>
@ -294,11 +295,21 @@
导入用户
</a-button>
</div>
<a-table :pagination='false' :columns='contactsItemColumns' :dataSource='contactsItemData' rowKey='id'>
<a-table :pagination='false' :columns='contactsItemColumns'
:dataSource='contactsItemData'
ref='userTable'
rowKey='id'>
<span slot='gender' slot-scope='text, record'>
{{ record.gender === '1' ? '女' : '男' }}
</span>
<span slot='num' slot-scope='text, record'>
<a @click='handleDeviceTable(record)'>{{ record.num }}</a>
</span>
<template slot='operation' slot-scope='text, record'>
<a-button type="link" @click="$refs.contactModal.add(record)">编辑</a-button>
<a-divider type="vertical" />
<a-button type='link' @click='$refs.contactModal.add(record)'>编辑</a-button>
<a-divider type='vertical' />
<a-popconfirm @confirm='handleDeleteContact(record)'>
<template slot='title'>
<span>确定删除 {{ record.name }} </span>
</template>
@ -315,26 +326,57 @@
</a-tabs>
</a-form>
<customer-contacts-modal ref='contactModal' @ok='handleContactSaved' />
<a-modal v-model="visible" title="导入用户" @ok="handleFileOk" >
<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>
: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>
<a-button style='margin-left: 40px' type='primary' @click='exportTemplate'>导出用户模板</a-button>
</div>
</a-modal>
<a-modal v-model='visible1' title='设备授权' width='500px' @ok='itemHandleOk()'>
<div class='table-page-search-wrapper'>
<a-form layout='inline'>
<a-row :gutter='48'>
<a-col :md='8' :sm='24'>
<span class='table-page-search-submitButtons'>
<!-- 查询有问题-->
<a-button type='primary' @click='$refs.table.refresh(true)'>查询</a-button>
<a-button style='margin-left: 8px' @click='() => (deviceQueryParam = {})'>重置</a-button>
</span>
</a-col>
</a-row>
</a-form>
</div>
<div class='table-operator'>
</div>
<a-table
size='default'
ref='itemTable'
rowKey='id'
:rowSelection='{ selectedRowKeys: selectedDeviceRowKeys, onChange: onDeviceSelectChange }'
:columns='deviceColumns'
:dataSource='deviceData'
>
<span slot='floorName' slot-scope='text, record'>
{{ record.buildName + record.roomName }}
</span>
</a-table>
</a-modal>
</a-card>
</template>
<script>
let downloadLoadingInstance;
let downloadLoadingInstance
import moment from 'moment'
import storage from 'store'
import { ACCESS_TOKEN } from '@/store/mutation-types'
@ -346,7 +388,10 @@ import {
selectCustomerStaffList,
updateStaffByCustomer,
importData,
exportTemplate
exportTemplate,
selectUserDeviceList,
selectEquipmentListById,
saveUserEquipment
} from '@/api/admin/customer'
import {
getFloorList,
@ -358,6 +403,7 @@ 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: {
@ -415,9 +461,18 @@ export default {
title: '手机号',
dataIndex: 'mobile'
},
{
title: '授权设备数量',
dataIndex: 'num',
scopedSlots: { customRender: 'num' }
},
{
title: '性别',
dataIndex: 'gender'
dataIndex: 'gender',
scopedSlots: { customRender: 'gender' }
},
{
title: '操作',
@ -425,6 +480,23 @@ export default {
scopedSlots: { customRender: 'operation' }
}
],
deviceColumns:[
{
title: '设备名称',
dataIndex: 'equipmentName'
},
{
title: '设备编号',
dataIndex: 'equipmentNum'
},
{
title: '所属地区',
dataIndex: 'floorName',
scopedSlots: { customRender: 'floorName' }
},
],
deviceData:[],
labelColHalf: {
span: 6
},
@ -451,6 +523,9 @@ export default {
orderShippingData: [],
orderReturnsData: [],
contactsItemData: [],
selectedDeviceRowKeys:[],
selectedRowKeys:[],
customerForm: {},
uploadUrl: process.env.VUE_APP_API_BASE_URL + '/api/dfs/upload',
headers: {
@ -461,12 +536,14 @@ export default {
previewImage: '',
loading: false,
imageUrl: '',
userId:'',
// form
form: this.$form.createForm(this),
floorList: [],
roomList: [],
file:'',
visible:false
file: '',
visible: false,
visible1:false,
}
},
filters: {
@ -491,53 +568,81 @@ export default {
}
this.handleInit()
//
this.getFloorDataList();
this.getFloorDataList()
this.selectUserDeviceList()
},
methods: {
//
handleDeviceTable(record){
this.visible1 = true
this.userId =record.id
selectEquipmentListById({userId:record.id}).then(res =>{
if (res.data){
this.selectedDeviceRowKeys = res.data.map(d => d.id)
this.selectedRowKeys = res.data
}else {
this.selectedDeviceRowKeys = []
this.selectedRowKeys = []
}
})
},
//
onDeviceSelectChange(selectedRowKeys,selectedRows){
this.selectedDeviceRowKeys = selectedRowKeys
this.selectedRowKeys = selectedRows
},
itemHandleOk(){
saveUserEquipment(
{
userId:this.userId,
userIds:this.selectedDeviceRowKeys
}
).then(res =>{
this.$refs.userTable.$forceUpdate()
this.visible1 =false
this.$message.success(res.msg)
})
},
//
selectUserDeviceList(){
selectUserDeviceList().then(res =>{
this.deviceData = res.data
})
},
//
getFloorDataList() {
getFloorList().then((res) => {
this.floorList = res.data
})
},
exportTemplate(){
exportTemplate().then(res =>{
exportTemplate() {
exportTemplate().then(res => {
console.log(res)
this.downloadFile(res)
})
},
downloadFile (data) {
downloadFile(data) {
let fileName = '客户导入模板'
let link = document.createElement('a')
let blob = new Blob([data], {type: 'application/vnd.ms-excel;charset=utf-8'});
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.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()
document.body.appendChild(link)
link.click()
URL.revokeObjectURL(link.href) // URL
document.body.removeChild(link)
},
customRequest(file){
customRequest(file) {
// file
// formData
// uploadFile
@ -550,7 +655,7 @@ export default {
// ,
file.onSuccess(res, file.file)
file.status = 'done'
this.visible =false
this.visible = false
this.$message.success(res.msg)
} else {
file.onError()
@ -559,25 +664,25 @@ export default {
})
},
handleFileChange(info){
handleFileChange(info) {
this.fileList = info.fileList
if (info.file.status === 'done') {
const result = info.file.response
this.file =info.file.response
this.file = info.file.response
this.fileName = result.fileName
}
},
customChange(){
customChange() {
},
//
importUser(){
importUser() {
this.visible = true
},
handleFileOk(){
handleFileOk() {
console.log(this.file)
importData({file:this.file}).then(res =>{
importData({ file: this.file }).then(res => {
console.log(res)
})
},
@ -640,7 +745,7 @@ export default {
this.fileList = this.customerForm.bannerImages
this.form.setFieldsValue(pick(this.customerForm, 'id', 'name', 'shortName', 'type', 'customerStatus', 'sector', 'country', 'process', 'contacts', 'phone', 'email', 'creditNo', 'mailAddress',
'postalCode', 'channelType', 'channelName', 'isBlacklist', 'regNo', 'status', 'orgNo', 'operName', 'econKind', 'startDate', 'registCapi', 'endDate'
, 'address', 'scope', 'delFlag', 'belongOrg', 'remark', 'headImg', 'bannerImages' , 'roomId' , 'buildId'))
, 'address', 'scope', 'delFlag', 'belongOrg', 'remark', 'headImg', 'bannerImages', 'roomId', 'buildId'))
})
}
this.getContastsList()