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

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) { export function getStaffListNotId (parameter) {
return axios({ return axios({

View File

@ -110,7 +110,8 @@
</a-col> </a-col>
<a-col :span='12'> <a-col :span='12'>
<a-form-item :labelCol='labelColHalf' :wrapperCol='wrapperColHalf' label='联系人'> <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-form-item>
</a-col> </a-col>
<a-col :span='12'> <a-col :span='12'>
@ -294,11 +295,21 @@
导入用户 导入用户
</a-button> </a-button>
</div> </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'> <template slot='operation' slot-scope='text, record'>
<a-button type="link" @click="$refs.contactModal.add(record)">编辑</a-button> <a-button type='link' @click='$refs.contactModal.add(record)'>编辑</a-button>
<a-divider type="vertical" /> <a-divider type='vertical' />
<a-popconfirm @confirm='handleDeleteContact(record)'> <a-popconfirm @confirm='handleDeleteContact(record)'>
<template slot='title'> <template slot='title'>
<span>确定删除 {{ record.name }} </span> <span>确定删除 {{ record.name }} </span>
</template> </template>
@ -315,26 +326,57 @@
</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'>
<div style='display: flex'> <div style='display: flex'>
<a-upload <a-upload
:fileList="fileList" :fileList='fileList'
:headers="headers" :headers='headers'
accept=".xlsx,.xls" accept='.xlsx,.xls'
@change="customChange" @change='customChange'
:customRequest="customRequest"> :customRequest='customRequest'>
<a-button type="primary" >导入用户数据</a-button> <a-button type='primary'>导入用户数据</a-button>
</a-upload> </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> </div>
</a-modal> </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> </a-card>
</template> </template>
<script> <script>
let downloadLoadingInstance; 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'
@ -346,7 +388,10 @@ import {
selectCustomerStaffList, selectCustomerStaffList,
updateStaffByCustomer, updateStaffByCustomer,
importData, importData,
exportTemplate exportTemplate,
selectUserDeviceList,
selectEquipmentListById,
saveUserEquipment
} from '@/api/admin/customer' } from '@/api/admin/customer'
import { import {
getFloorList, getFloorList,
@ -358,6 +403,7 @@ import CustomerAttachmentList from './modules/CustomerAttachmentList.vue'
import pick from 'lodash.pick' import pick from 'lodash.pick'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { download } from '@/utils/request' import { download } from '@/utils/request'
export default { export default {
name: 'BaseForm', name: 'BaseForm',
components: { components: {
@ -415,9 +461,18 @@ export default {
title: '手机号', title: '手机号',
dataIndex: 'mobile' dataIndex: 'mobile'
}, },
{
title: '授权设备数量',
dataIndex: 'num',
scopedSlots: { customRender: 'num' }
},
{ {
title: '性别', title: '性别',
dataIndex: 'gender' dataIndex: 'gender',
scopedSlots: { customRender: 'gender' }
}, },
{ {
title: '操作', title: '操作',
@ -425,6 +480,23 @@ export default {
scopedSlots: { customRender: 'operation' } scopedSlots: { customRender: 'operation' }
} }
], ],
deviceColumns:[
{
title: '设备名称',
dataIndex: 'equipmentName'
},
{
title: '设备编号',
dataIndex: 'equipmentNum'
},
{
title: '所属地区',
dataIndex: 'floorName',
scopedSlots: { customRender: 'floorName' }
},
],
deviceData:[],
labelColHalf: { labelColHalf: {
span: 6 span: 6
}, },
@ -451,6 +523,9 @@ export default {
orderShippingData: [], orderShippingData: [],
orderReturnsData: [], orderReturnsData: [],
contactsItemData: [], contactsItemData: [],
selectedDeviceRowKeys:[],
selectedRowKeys:[],
customerForm: {}, customerForm: {},
uploadUrl: process.env.VUE_APP_API_BASE_URL + '/api/dfs/upload', uploadUrl: process.env.VUE_APP_API_BASE_URL + '/api/dfs/upload',
headers: { headers: {
@ -461,12 +536,14 @@ export default {
previewImage: '', previewImage: '',
loading: false, loading: false,
imageUrl: '', imageUrl: '',
userId:'',
// form // form
form: this.$form.createForm(this), form: this.$form.createForm(this),
floorList: [], floorList: [],
roomList: [], roomList: [],
file: '', file: '',
visible:false visible: false,
visible1:false,
} }
}, },
filters: { filters: {
@ -491,9 +568,51 @@ export default {
} }
this.handleInit() this.handleInit()
// //
this.getFloorDataList(); this.getFloorDataList()
this.selectUserDeviceList()
}, },
methods: { 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() { getFloorDataList() {
getFloorList().then((res) => { getFloorList().then((res) => {
@ -510,30 +629,16 @@ export default {
let fileName = '客户导入模板' let fileName = '客户导入模板'
let link = document.createElement('a') 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) console.log(blob)
link.style.display = 'none'; link.style.display = 'none'
link.download = fileName+'.xlsx'; link.download = fileName + '.xlsx'
link.href = URL.createObjectURL(blob); link.href = URL.createObjectURL(blob)
// link.setAttribute('download', fileName+'.xlsx'); // link.setAttribute('download', fileName+'.xlsx');
document.body.appendChild(link); document.body.appendChild(link)
link.click(); link.click()
URL.revokeObjectURL(link.href); // URL URL.revokeObjectURL(link.href) // URL
document.body.removeChild(link); 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()
}, },