dbd-meeting-html/src/views/admin/meeting/modules/ShowroomRecordModal.vue

505 lines
16 KiB
Vue
Raw Normal View History

<template>
<a-modal
2024-04-04 18:00:33 +08:00
title='操作'
style='top: 20px;'
:width='800'
v-model='visible'
:confirmLoading='confirmLoading'
@ok='handleSubmit'
>
2024-04-04 18:00:33 +08:00
<a-form :form='form'>
<a-form-item style='display:none'>
<a-input v-decorator="['id']" />
</a-form-item>
2024-04-04 18:00:33 +08:00
<a-form-item style='display:none'>
<a-input v-decorator="['version']" />
</a-form-item>
2024-04-04 18:00:33 +08:00
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='所属地区'>
<a-select v-decorator="['tenantId', {rules: [{ required: true, message: '请选择所属地区' }]}]"
@change='selectTenant'
:disabled='tenantEnable'>
<a-select-option v-for='item in tenantList' :key='item.id'>{{ item.name }}</a-select-option>
</a-select>
</a-form-item>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='所属园区'>
<a-select v-decorator="['parkId', {rules: [{ required: true, message: '请选择所属园区' }]}]"
@change='selectPark'
:disabled='parkEnable'>
<a-select-option v-for='item in parkList' :key='item.id'>{{ item.name }}</a-select-option>
</a-select>
</a-form-item>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='所属楼宇'>
<a-select v-decorator="['buildingId', {rules: [{ required: true, message: '请选择所属楼宇' }]}]"
@change='selectBuilding'>
<a-select-option v-for='item in buildingList' :key='item.id'>{{ item.buildingName }}</a-select-option>
</a-select>
</a-form-item>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='展厅'>
<a-select v-decorator="['showroomId',{rules: [{ required: true, message: '请选择展厅' }]}]"
placeholder='请选择展厅'>
<a-select-option v-for='item in showRoomList' :key='item.id' :value='item.id'>
{{ item.meetingName }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='主题'>
<a-input placeholder='展厅主题' v-decorator="['title',{rules: [{ required: true, message: '主题'}]}]" />
</a-form-item>
2024-04-04 18:00:33 +08:00
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='预约开始时间'>
<a-date-picker
format='YYYY-MM-DD HH:mm:ss'
valueFormat='YYYY-MM-DD HH:mm:ss'
v-decorator="['startTime',{rules: [{ required: true, message: '预约开始时间'}]}]"
:show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }"
2024-04-04 18:00:33 +08:00
type='date'
placeholder='选择时间'
style='width: 100%;'
/>
</a-form-item>
2024-04-04 18:00:33 +08:00
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='预约开始时间'>
<a-date-picker
format='YYYY-MM-DD HH:mm:ss'
valueFormat='YYYY-MM-DD HH:mm:ss'
v-decorator="['endDate',{rules: [{ required: true, message: '预约结束时间'}]}]"
:show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }"
2024-04-04 18:00:33 +08:00
type='date'
placeholder='选择时间'
style='width: 100%;'
/>
</a-form-item>
2024-04-04 18:00:33 +08:00
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='拟参观区域'>
<a-select
2024-04-04 18:00:33 +08:00
mode='multiple'
placeholder='拟参观区域'
style='width: 200px'
@change='handleChange'
@popupScroll='popupScroll'
v-decorator="['visitArea',{rules: [{ required: true, message: '请选择拟参观区域'}]}]"
>
2024-04-04 18:00:33 +08:00
<a-select-option value='展厅(2楼)'>
展厅(2)
</a-select-option>
2024-04-04 18:00:33 +08:00
<a-select-option value='公共服务配套区(15 楼)'>
公共服务配套区(15)
</a-select-option>
2024-04-04 18:00:33 +08:00
<a-select-option value='中电郑州、生态企业(16楼)'>
中电郑州生态企业(16)
</a-select-option>
</a-select>
</a-form-item>
2024-04-04 18:00:33 +08:00
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='预约人员'>
<a-button type='dashed' icon='plus' @click='addRow' class='addRowBtn'>
新增一行
</a-button>
</a-form-item>
<div style='margin-left: 80px'>
2024-04-04 18:00:33 +08:00
<div class='dynamic-wrap' :style="{ maxHeight: wrapHeight + 'px' }">
<div v-for='item in keysList' :key='item'>
<a-row :gutter='24'>
<a-col :span='6'>
<a-form-item label='名称' :labelCol='{span: 8}' :wrapperCol='{span: 16}'>
<a-input
2024-04-04 18:00:33 +08:00
placeholder='请填写名称'
v-decorator="[
`${title}Name[${item}]`,
{
initialValue: arr[item] ? arr[item].name : undefined,
rules: [{ required: true, message: '请填职位' }]
}
]"
/>
</a-form-item>
</a-col>
2024-04-04 18:00:33 +08:00
<a-col :span='6'>
<a-form-item label='职位' :labelCol='{span: 9}' :wrapperCol='{span: 15}'>
<a-input
2024-04-04 18:00:33 +08:00
placeholder='请填职位'
v-decorator="[
2024-03-21 14:34:02 +08:00
`${title}Job[${item}]`,
{
initialValue: arr[item] ? arr[item].job : undefined,
rules: [{ required: true, message: '请填职位' }]
}
]"
/>
</a-form-item>
</a-col>
2024-04-04 18:00:33 +08:00
<a-col :span='6'>
<a-form-item label='手机号' :labelCol='{span: 8}' :wrapperCol='{span: 16}'>
<a-input
2024-04-04 18:00:33 +08:00
placeholder='请填手机号'
v-decorator='[
`${title}Phone[${item}]`,
{
initialValue: arr[item] ? arr[item].phone : undefined,
}
2024-04-04 18:00:33 +08:00
]'
/>
</a-form-item>
</a-col>
2024-04-04 18:00:33 +08:00
<a-col :span='2' style='padding-left: 0px'>
<a-form-item :labelCol='{span: 0}' :wrapperCol='{span: 24}'>
<template v-if='keysList.length > 1'>
<a-button type='dashed' icon='minus' @click='removeRow(item)' class='minusRowBtn'></a-button>
</template>
</a-form-item>
</a-col>
</a-row>
</div>
</div>
</div>
2024-04-04 18:00:33 +08:00
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='拟参观区域'>
<a-select
2024-04-04 18:00:33 +08:00
placeholder='选择参观目的'
style='width: 200px'
v-decorator="['visitType',{rules: [{ required: true, message: '拟参观区域'}]}]"
>
2024-04-04 18:00:33 +08:00
<a-select-option v-for='item in recordOptions' :key='item' :value='item.value'>
{{ item.text }}
</a-select-option>
</a-select>
</a-form-item>
2024-04-04 18:00:33 +08:00
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='讲解需求'>
<a-switch
v-decorator="['explainNeedType',{valuePropName: 'checked' , rules: [{ message: '讲解需求'}]}]" />
</a-form-item>
2024-04-04 18:00:33 +08:00
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='会议室需求'>
<a-switch
v-decorator="['meetingNeedType',{valuePropName: 'checked' ,rules: [{ message: '会议室需求'}]}]" />
</a-form-item>
2024-04-04 18:00:33 +08:00
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='摄影需求'>
<a-switch
v-decorator="['photographType',{valuePropName: 'checked' ,rules: [{ message: '摄影需求'}]}]" />
</a-form-item>
</a-form>
</a-modal>
</template>
<script>
2024-04-04 18:00:33 +08:00
import { saveShowroomRecord, get } from '@/api/admin/meeting/showroomRecord'
import { showroomListRq } from '@/api/admin/meeting/showroom'
import pick from 'lodash.pick'
import storage from 'store'
import moment from 'moment'
import { getDictArray } from '@/utils/dict'
import { getInfo } from '@/api/login'
import { getTenantList } from '@/api/tenant'
import { getParkList } from '@/api/admin/park'
import { getBuildingList } from '@/api/admin/building'
import { roomContentList } from '@/api/admin/meeting/reservation'
2024-04-04 18:00:33 +08:00
let id = 0
export default {
name: 'ShowroomRecordModal',
props: {
title: {
type: String,
default: ''
},
wrapHeight: { // 表单容器的高度
type: Number,
default: 120
},
arr: {
type: Array,
2024-04-04 18:00:33 +08:00
default: function() {
return []
}
}
},
2024-04-04 18:00:33 +08:00
components: {},
2024-04-04 18:00:33 +08:00
data() {
return {
2024-03-21 14:34:02 +08:00
ids: 0,
keysList: [],
2024-04-04 18:00:33 +08:00
recordOptions: [],
visible: false,
labelCol: {
xs: { span: 24 },
sm: { span: 5 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 }
},
confirmLoading: false,
mdl: {},
2024-04-04 18:00:33 +08:00
form: this.$form.createForm(this),
tenantList: [], // 地区
parkList: [], // 园区
buildingList: [], // 楼宇
showRoomList: [], // 展厅
tenantEnable: false,
parkEnable: false
}
},
2024-04-04 18:00:33 +08:00
beforeCreate() {
},
2024-04-04 18:00:33 +08:00
async created() {
this.form = this.$form.createForm(this)
this.init()
const recordData = await getDictArray('visit_type')
// 下拉选项
recordData.map(d => {
this.recordOptions.push({ text: d.dictLabel, value: d.dictValue })
})
},
methods: {
2024-04-04 18:00:33 +08:00
// 获取用户详细信息
getUserDetail() {
getInfo().then(res => {
console.log('getUserDetail', res)
this.userDetail = res
// 园区5
if (this.userDetail.roleIds && this.userDetail.roleIds.length > 0 && this.userDetail.roleIds[0] == 5) {
//
// 判断:是新增就查询园区
let { id } = this.mdl
if (!id) {
// 选择地区 -> 查询园区
this.selectTenant(this.userDetail.tenantId)
// 选择园区 -> 查询楼宇
this.selectPark(this.userDetail.parkId)
}
//
// 不可编辑
this.tenantEnable = true
this.parkEnable = true
// 关联地区和园区
this.mdl.parkId = this.userDetail.parkId
this.mdl.tenantId = this.userDetail.tenantId
this.form.setFieldsValue({
parkId: this.mdl.parkId,
tenantId: this.mdl.tenantId
})
}
})
},
// 查询地区
getTenantData() {
getTenantList().then(res => {
this.tenantList = res.rows
})
},
// 选择地区 -> 查询园区
selectTenant(id) {
console.log('selectTenant', id)
// 清空数据
this.mdl.parkId = null // 园区
this.mdl.buildingId = null // 楼宇
this.mdl.showroomId = null // 展厅
this.form.setFieldsValue({
parkId: null, // 园区
buildingId: null, // 楼宇
showroomId: null // 展厅
})
// 查询园区
getParkList({
tenantId: id
}).then(res => {
this.parkList = res.rows
})
},
// 选择园区 -> 查询楼宇
selectPark(id) {
// 清空数据
this.mdl.buildingId = null // 楼宇
this.mdl.showroomId = null // 展厅
this.form.setFieldsValue({
buildingId: null, // 楼宇
showroomId: null // 展厅
})
// 查询楼宇
getBuildingList({
parkId: id
}).then(res => {
this.buildingList = res.rows
})
},
// 选择楼宇 -> 查询展厅
selectBuilding(id) {
// 清空数据
this.mdl.showroomId = null // 展厅
this.form.setFieldsValue({
showroomId: null // 展厅
})
showroomListRq({
buildingId: id
}).then(res => {
console.log('showroomListRq', res)
this.showRoomList = res.data
})
},
init() {
const arr = [0]
if (this.arr.length !== 0) {
for (let i = 1; i < (this.arr).length; i++) {
arr.push(i)
this.id = this.id + 1
}
}
this.keysList = arr
},
// 移除某行
2024-04-04 18:00:33 +08:00
removeRow(k) {
if (this.keysList.length === 1) { // 如果存在可以移除所有行的情况把条件改为this.keysList.length === 0即可
return
}
this.keysList = this.keysList.filter(item => item !== k)
},
// 新增一行
2024-04-04 18:00:33 +08:00
addRow() {
2024-03-21 14:34:02 +08:00
this.ids = this.ids + 1
this.keysList = this.keysList.concat(this.ids)
console.log(this.keysList)
},
moment,
handleChange(value) {
},
2024-04-04 18:00:33 +08:00
popupScroll() {
},
2024-04-04 18:00:33 +08:00
add() {
this.form.resetFields()
this.edit({ id: 0 })
},
2024-04-04 18:00:33 +08:00
edit(record) {
this.mdl = Object.assign(this.mdl, record)
let copyMdl = JSON.parse(JSON.stringify(this.mdl))
this.getUserDetail()
this.getTenantData()
//
this.visible = true
2024-04-04 18:00:33 +08:00
if (record.id) {
get(record.id).then(res => {
res.visitArea = res.visitArea.split(',')
let persons = JSON.parse(res.persons)
let names = persons.map(item => item.name)
let jobs = persons.map(item => item.job)
let phones = persons.map(item => item.phone)
this.form.setFieldsValue({
visitType: res.visitType.toString(),
visitArea: res.visitArea,
Name: names,
Job: jobs,
Phone: phones
})
2024-03-21 14:34:02 +08:00
})
2024-04-04 18:00:33 +08:00
// 选择地区 -> 查询园区
if (copyMdl.tenantId) {
this.mdl = JSON.parse(JSON.stringify(copyMdl))
this.selectTenant(copyMdl.tenantId)
}
// 选择园区 -> 查询楼宇
if (copyMdl.parkId) {
this.mdl = JSON.parse(JSON.stringify(copyMdl))
this.selectPark(copyMdl.parkId)
}
// 选择楼宇 -> 查询展厅
if (copyMdl.buildingId) {
this.mdl = JSON.parse(JSON.stringify(copyMdl))
this.selectBuilding(copyMdl.buildingId)
}
// 防止替换
this.mdl = JSON.parse(JSON.stringify(copyMdl))
}
this.$nextTick(() => {
2024-04-04 18:00:33 +08:00
this.form.setFieldsValue(pick(this.mdl, 'id', 'userId', 'title', 'stauts',
'explainNeedType', 'meetingNeedType', 'photographType',
'reservationNumber', 'cancelTime', 'cancelResaon',
'startTime', 'endDate', 'deleteFlag', 'createBy', 'createTime',
'updateBy', 'updateTime', 'remake',
'tenantId', 'parkId', 'buildingId', 'showroomId'))
})
2024-03-21 14:34:02 +08:00
},
2024-04-04 18:00:33 +08:00
handleSubmit(e) {
e.preventDefault()
this.form.validateFields((err, values) => {
2024-03-21 14:34:02 +08:00
if (!err) {
console.log('Received values of form: ', values)
this.confirmLoading = true
2024-04-04 18:00:33 +08:00
const partOneArr = []
2024-03-21 14:34:02 +08:00
values[`Name`].forEach((item, index) => {
console.log(index)
const obj = {
2024-04-04 18:00:33 +08:00
id: new Date().getTime(),
2024-03-21 14:34:02 +08:00
name: item,
job: values[`Job`][index],
phone: values[`Phone`][index]
}
partOneArr.push(obj)
})
values.persons = JSON.stringify(partOneArr)
2024-04-04 18:00:33 +08:00
values.visitArea = values.visitArea.join(',')
2024-03-21 14:34:02 +08:00
values.explainNeedType = values.explainNeedType === true ? 1 : 0
values.meetingNeedType = values.meetingNeedType === true ? 1 : 0
values.photographType = values.photographType === true ? 1 : 0
2024-03-21 14:34:02 +08:00
saveShowroomRecord(values).then(res => {
if (res.code === 0) {
this.$message.success('保存成功')
this.$emit('ok')
this.visible = false
} else {
this.$message.error(res.msg)
}
}).catch(() => {
this.$message.error('系统错误,请稍后再试')
}).finally(() => {
this.confirmLoading = false
})
}
})
}
},
watch: {
/*
'selectedRows': function (selectedRows) {
this.needTotalList = this.needTotalList.map(item => {
return {
...item,
total: selectedRows.reduce( (sum, val) => {
return sum + val[item.dataIndex]
}, 0)
}
})
}
*/
}
}
</script>
<style>
.dynamic-delete-button {
cursor: pointer;
position: relative;
top: 4px;
font-size: 24px;
color: #999;
transition: all 0.3s;
}
2024-04-04 18:00:33 +08:00
.dynamic-delete-button:hover {
color: #777;
}
2024-04-04 18:00:33 +08:00
.dynamic-delete-button[disabled] {
cursor: not-allowed;
opacity: 0.5;
}
</style>