<template>
|
<a-modal
|
:title='title'
|
:width='1200'
|
:visible='visible'
|
:maskClosable='false'
|
@ok='handleOk'
|
cancelText='关闭'
|
@cancel='handleCancel'
|
:confirmLoading='confirmLoading'
|
>
|
|
<a-spin :spinning='confirmLoading'>
|
<a-form-model :form='form' ref='form' :model='model' :rules='validatorRules'>
|
<a-row :span='12'>
|
<a-col :span='12'>
|
<a-form-model-item label='单据号' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='num'>
|
<a-input v-model='model.num' placeholder='请输入单据号' :disabled="disableSubmit"></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span='12'>
|
<a-form-model-item label='调入公司' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='inEnterpriseId'>
|
<a-tree-select
|
style='width:100%'
|
tree-default-expand-all
|
:dropdown-style="{ maxHeight: '500px', overflow: 'auto' }"
|
:treeData='treeDataSource'
|
v-model='model.inEnterpriseId'
|
placeholder='请选择调入公司'
|
:replace-fields='replaceFields'
|
:disabled="disableSubmit"
|
@change='handleChangeInEnterpriseId'>
|
</a-tree-select>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row :Span='24'>
|
<a-col :span='12'>
|
<a-form-model-item label='调出公司' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='outEnterpriseId'>
|
<a-tree-select
|
style='width:100%'
|
tree-default-expand-all
|
:dropdown-style="{ maxHeight: '500px', overflow: 'auto' }"
|
:treeData='treeDataSource'
|
v-model='model.outEnterpriseId'
|
placeholder='请选择调出公司'
|
:replace-fields='replaceFields'
|
:disabled="disableSubmit"
|
@change='handleChangeOutEnterpriseId' />
|
</a-form-model-item>
|
</a-col>
|
|
<a-col :span='12'>
|
<a-form-model-item label='备注' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='remark'>
|
<a-textarea v-model='model.remark' placeholder='请输入备注' :disabled="disableSubmit"></a-textarea>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
</a-form-model>
|
</a-spin>
|
<a-button
|
type='primary'
|
:style="{ marginRight: '8px',marginBottom:'8px' }"
|
:loading='confirmLoading'
|
@click='selectInspectionProjects()'
|
>设备信息
|
</a-button>
|
|
<a-table
|
ref='table'
|
bordered
|
size='middle'
|
rowKey='id'
|
:columns='columns'
|
:dataSource='dataSource'
|
:scroll="{ x: 'calc(980px + 40%)', y: 900 }"
|
>
|
|
<template
|
v-for='col in columns'
|
:slot='col.dataIndex'
|
slot-scope='text, record, index'
|
>
|
<div :key='col.dataIndex'>
|
|
|
<a-select
|
:value='text'
|
placeholder='请选择'
|
:disabled="disableSubmit"
|
v-if="col.dataIndex == 'inDepartId'"
|
:options='record.departVoList'
|
@change='(e) => handleChange(e, record.key, col, index)'
|
style='width: 100%'
|
/>
|
<a-select
|
v-if="col.dataIndex == 'inManagerId'"
|
:value='text'
|
placeholder='请选择'
|
:disabled="disableSubmit"
|
:options='record.userVoList'
|
@change='(e) => handleChange(e, record.key, col, index)'
|
style='width: 100%'
|
/>
|
<a-input
|
:value='text'
|
placeholder='请输入'
|
:disabled="disableSubmit"
|
v-if="col.dataIndex == 'position'"
|
@change='(e)=>handleChange(e, record.key, col, index)'
|
/>
|
|
|
<a-select
|
v-if="col.dataIndex == 'responsibilityUserId'"
|
:value='text'
|
placeholder='请选择'
|
:disabled="disableSubmit"
|
:options='record.userVoList'
|
@change='(e) => handleChange(e, record.key, col, index)'
|
style='width: 100%'
|
/>
|
<a-select
|
v-if="col.dataIndex == 'responsibilityTeamId'"
|
:value='text'
|
placeholder='请选择'
|
:disabled="disableSubmit"
|
:options='record.teamVoList'
|
@change='(e) => handleChange(e, record.key, col, index)'
|
style='width: 100%'
|
/>
|
<!-- <a-input
|
:value='text'
|
placeholder='请输入'
|
v-if="col.dataIndex == 'responsibilityTeamId'"
|
@change='(e)=>handleChange(e, record.key, col, index)'
|
/>-->
|
|
<a-select
|
v-if="col.dataIndex == 'useDepartId'"
|
:value='text'
|
placeholder='请选择'
|
:disabled="disableSubmit"
|
:options='record.departVoList'
|
@change='(e) => handleChange(e, record.key, col, index)'
|
style='width: 100%'
|
/>
|
<a-date-picker
|
|
v-if="col.dataIndex == 'demandDate'"
|
:value='text'
|
:disabled="disableSubmit"
|
format='YYYY-MM-DD HH:mm:ss'
|
@change='(e)=>handleChange(e, record.key, col, index)'
|
/>
|
<a-date-picker
|
v-if="col.dataIndex == 'actualInDate'"
|
:value='text'
|
:disabled="disableSubmit"
|
format='YYYY-MM-DD HH:mm:ss'
|
@change='(e)=>handleChange(e, record.key, col, index)'
|
/>
|
|
<a-select
|
v-if="col.dataIndex == 'equipmentTransferCatrgoryId'"
|
:value='text'
|
placeholder='请选择'
|
:disabled="disableSubmit"
|
:options='record.transferMethodVoList'
|
@change='(e) => handleChange(e, record.key, col, index)'
|
style='width: 100%'
|
/>
|
|
</div>
|
</template>
|
<span
|
slot='action'
|
|
slot-scope='text, record, index'
|
>
|
<a-popconfirm
|
title='确定删除吗?'
|
:disabled="disableSubmit"
|
@confirm='() => handleDelete(text,record, index)'
|
>
|
<a>删除</a>
|
</a-popconfirm>
|
</span>
|
</a-table>
|
<template slot='footer'>
|
<a-button
|
:style="{marginRight: '8px'}"
|
@click='handleCancel()'
|
>
|
关闭
|
</a-button>
|
|
<a-button
|
@click='handleOk()'
|
type='primary'
|
:disabled="disableSubmit"
|
:loading='confirmLoading'
|
>确定
|
</a-button>
|
</template>
|
<j-select-equipment-modal
|
ref='equipmentTransferInModalForm'></j-select-equipment-modal>
|
</a-modal>
|
|
</template>
|
|
<script>
|
import { getAction, postAction, requestPut } from '@/api/manage'
|
import JMultiSelectTag from '@/components/dict/JMultiSelectTag'
|
import Tooltip from 'ant-design-vue/es/tooltip'
|
import pick from 'lodash.pick'
|
import { validateDuplicateValue } from '@/utils/util'
|
import JSelectEquipmentModal from '@views/common/JSelectEquipmentModal'
|
|
export default {
|
name: 'EquipmentTransferInDetailModal',
|
components: {
|
JMultiSelectTag,
|
Tooltip,
|
JSelectEquipmentModal
|
},
|
data() {
|
return {
|
replaceFields: {
|
value: 'key'
|
},
|
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key: 'rowIndex',
|
align: 'center',
|
customRender: function(t, r, index) {
|
return parseInt(index) + 1
|
},
|
width: 100
|
},
|
{
|
title: '统一编码',
|
align: 'center',
|
width: 100,
|
dataIndex: 'equipmentNum'
|
},
|
{
|
title: '设备名称',
|
align: 'center',
|
width: 100,
|
dataIndex: 'equipmentName'
|
},
|
{
|
title: '规格',
|
align: 'center',
|
width: 100,
|
dataIndex: 'specification'
|
},
|
{
|
title: '型号',
|
width: 100,
|
align: 'center',
|
dataIndex: 'model'
|
},
|
{
|
title: '技术状态',
|
align: 'center',
|
width: 100,
|
dataIndex: 'technicalStatus'
|
},
|
{
|
title: '需求日期',
|
align: 'center',
|
dataIndex: 'demandDate',
|
width: 200,
|
scopedSlots: {
|
customRender: 'demandDate'
|
}
|
|
},
|
{
|
title: '调入日期',
|
align: 'center',
|
width: 200,
|
dataIndex: 'actualInDate',
|
scopedSlots: {
|
customRender: 'actualInDate'
|
}
|
|
},
|
{
|
title: '增加方式',
|
align: 'center',
|
width: 150,
|
dataIndex: 'equipmentTransferCatrgoryId',
|
scopedSlots: {
|
customRender: 'equipmentTransferCatrgoryId'
|
}
|
},
|
|
{
|
title: '调入管理部门',
|
align: 'center',
|
width: 150,
|
dataIndex: 'inDepartId',
|
|
scopedSlots: {
|
customRender: 'inDepartId'
|
}
|
},
|
{
|
title: '调入管理人',
|
align: 'center',
|
width: 150,
|
dataIndex: 'inManagerId',
|
scopedSlots: {
|
customRender: 'inManagerId'
|
}
|
},
|
{
|
title: '调入责任班组',
|
width: 150,
|
align: 'center',
|
dataIndex: 'responsibilityTeamId',
|
scopedSlots: {
|
customRender: 'responsibilityTeamId'
|
}
|
},
|
{
|
title: '调入责任人',
|
width: 150,
|
align: 'center',
|
dataIndex: 'responsibilityUserId',
|
scopedSlots: {
|
customRender: 'responsibilityUserId'
|
}
|
},
|
{
|
title: '使用部门',
|
width: 150,
|
align: 'center',
|
dataIndex: 'useDepartId',
|
scopedSlots: {
|
customRender: 'useDepartId'
|
}
|
},
|
|
{
|
title: '调入位置',
|
width: 150,
|
align: 'center',
|
dataIndex: 'position',
|
scopedSlots: {
|
customRender: 'position'
|
}
|
},
|
{
|
title: '操作',
|
width: 100,
|
align: 'center',
|
dataIndex: 'action',
|
scopedSlots: {
|
customRender: 'action'
|
}
|
}
|
],
|
title: '操作',
|
visible: false,
|
visible4Confirm: false,
|
disableSubmit: false,
|
codeDisable: true,
|
model: {},
|
dateFormat: 'YYYY-MM-DD HH:mm:ss',
|
transferMethodVoList: {},
|
text: '',
|
position: '',
|
userVoList: {},
|
teamVoList: {},
|
departVoList: {},
|
workOrder: {},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 }
|
},
|
confirmLoading: false,
|
form: this.$form.createForm(this),
|
validatorRules: {
|
num: [
|
{ required: true, message: '请输入单号!' },
|
{ validator: (rule, value, callback) => validateDuplicateValue('mom_eam_equipment_transfer', 'num', value, this.model.id, callback) }
|
],
|
outEnterpriseId: [
|
{ required: true, message: '请输入调出企业!' }
|
|
],
|
inEnterpriseId: [
|
{ required: true, message: '请输入调入企业!' }
|
|
]
|
},
|
|
url: {
|
add: '/eam/equipmentTransfer/add',
|
edit: '/eam/equipmentTransfer/edit',
|
loadTree: '/base/enterprise/enterpriseTree',
|
getTransferMethod: '/eam/equipmentTransferInDetail/getTransferMethod',
|
userVoList: '/eam/equipmentTransferInDetail/getUser',
|
teamVoList: '/eam/equipmentTransferInDetail/getTeam',
|
departVoList: 'eam/equipmentTransferInDetail/getDepart'
|
},
|
treeDataSource: [],
|
dataSource: [],
|
enterpriseId: '',
|
inEnterpriseId: ''
|
|
|
}
|
},
|
created() {
|
//备份model原始值
|
this.queryTreeData()
|
},
|
|
mounted() {
|
this.$bus.$on('selectionRows', (data) => {
|
for (let i = 0; i < data.length; i++) {
|
this.dataSource.push({
|
id: data[i].id,
|
equipmentId: data[i].id,
|
equipmentNum: data[i].num,
|
equipmentName: data[i].name,
|
model: data[i].model,
|
specification: data[i].specification,
|
technicalStatus: data[i].technologyStatus_dictText,
|
transferMethodVoList: this.transferMethodVoList,
|
userVoList: this.userVoList,
|
teamVoList: this.teamVoList,
|
departVoList: this.departVoList
|
|
})
|
}
|
|
})
|
},
|
|
|
methods: {
|
|
getTransferMethod() {
|
getAction(this.url.getTransferMethod, { type: 'add' }).then((res) => {
|
if (res.success) {
|
this.transferMethodVoList = res.result
|
} else {
|
this.$message.warn(res.message)
|
}
|
})
|
},
|
|
/*获取部门列表*/
|
getInDepartList() {
|
getAction(this.url.departVoList).then((res) => {
|
if (res.success) {
|
this.departVoList = res.result
|
|
} else {
|
this.$message.warn(res.message)
|
}
|
})
|
},
|
/*获取管理人列表*/
|
getInUseList() {
|
getAction(this.url.userVoList).then((res) => {
|
if (res.success) {
|
|
this.userVoList = res.result
|
} else {
|
this.$message.warn(res.message)
|
}
|
})
|
},
|
|
/*获取责任班组列表*/
|
getInTeamList() {
|
getAction(this.url.teamVoList).then((res) => {
|
if (res.success) {
|
|
this.teamVoList = res.result
|
} else {
|
this.$message.warn(res.message)
|
}
|
})
|
},
|
|
/*获取企业树信息*/
|
queryTreeData() {
|
this.loading = true
|
this.cardLoading = true
|
getAction(this.url.loadTree, { version: 4 })
|
.then((res) => {
|
if (res.success) {
|
this.treeDataSource = res.result
|
} else {
|
this.$message.warn(res.message)
|
}
|
})
|
.finally((res) => {
|
this.loading = false
|
this.cardLoading = false
|
})
|
},
|
//选择点检项目
|
selectInspectionProjects: function() {
|
let ids = []
|
for (let i = 0; i < this.dataSource.length; i++) {
|
ids.push(this.dataSource[i].equipmentId)
|
}
|
this.$refs.equipmentTransferInModalForm.showModals(ids)
|
this.$refs.equipmentTransferInModalForm.title = '选择设备信息'
|
this.$refs.equipmentTransferInModalForm.disableSubmit = false
|
},
|
|
add() {
|
this.model.transferType = 'add'
|
this.edit(this.model, { equipmentTransferInDetailList: [] })
|
},
|
|
|
edit(record) {
|
let that = this
|
this.getTransferMethod()
|
this.getInDepartList()
|
this.getInUseList()
|
this.getInTeamList()
|
that.dataSource = []
|
this.form.resetFields()
|
this.model = Object.assign({}, record)
|
this.visible = true
|
if (record.equipmentTransferInDetailList != undefined) {
|
const temp = [...record.equipmentTransferInDetailList]
|
that.dataSource = temp
|
}
|
that.$nextTick(() => {
|
that.form.setFieldsValue(pick(that.model, 'num', 'inEnterpriseId', 'outEnterpriseId', 'remark'))
|
})
|
if (record.id) {
|
this.codeDisable = true
|
} else {
|
this.codeDisable = false
|
}
|
},
|
|
|
close() {
|
this.$emit('close')
|
this.visible = false
|
},
|
|
handleCancel() {
|
this.close()
|
},
|
handleChangeInEnterpriseId(value) {
|
this.enterpriseId = value
|
console.log('调出' + this.enterpriseId)
|
},
|
handleChangeOutEnterpriseId(value) {
|
this.inEnterpriseId = value
|
console.log('调入' + this.inEnterpriseId)
|
},
|
|
handleChange(value, key, column, index) {
|
let that = this
|
const temp = [...that.dataSource]
|
const target = temp.filter(item => key === item.key)[index]
|
if (target) {
|
|
if (column.dataIndex == 'demandDate') {
|
|
target[column.dataIndex] = value
|
|
} else if (column.dataIndex == 'actualInDate') {
|
target[column.dataIndex] = value
|
|
} else if (column.dataIndex == 'inManagerId') {
|
|
target[column.dataIndex] = value
|
} else if (column.dataIndex == 'equipmentTransferCatrgoryId') {
|
|
target[column.dataIndex] = value
|
this.text = value
|
|
} else if (column.dataIndex == 'inDepartId') {
|
|
target[column.dataIndex] = value
|
|
} else if (column.dataIndex == 'responsibilityUserId') {
|
|
target[column.dataIndex] = value
|
|
} else if (column.dataIndex == 'useDepartId') {
|
|
target[column.dataIndex] = value
|
|
} else if (column.dataIndex == 'position') {
|
|
target[column.dataIndex] = value.target.value
|
} else if (column.dataIndex == 'responsibilityTeamId') {
|
|
target[column.dataIndex] = value
|
}
|
//显示带过来的数据
|
|
that.dataSource = temp
|
|
}
|
},
|
|
handleOk() {
|
const that = this
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
that.confirmLoading = true
|
let formData = Object.assign(this.model, valid)
|
formData.equipmentTransferInDetailList = that.dataSource
|
if (that.dataSource.length ===0){
|
that.confirmLoading = false
|
that.$message.warning("请添加调入明细")
|
return
|
}
|
formData.equipmentTransferCatrgoryId = this.text
|
for (let annItem of that.dataSource) {
|
if (annItem.specification == undefined || annItem.specification == null || annItem.specification == '') {
|
that.$message.warning('请填写规格')
|
that.confirmLoading = false
|
return
|
}
|
if (annItem.model == undefined || annItem.model == null || annItem.model == '') {
|
that.$message.warning('请填写型号')
|
that.confirmLoading = false
|
return
|
}
|
if (annItem.equipmentName == undefined || annItem.equipmentName == null || annItem.equipmentName == '') {
|
that.$message.warning('设备名称不能为空')
|
that.confirmLoading = false
|
return
|
}
|
if (annItem.equipmentId == undefined || annItem.equipmentId == null || annItem.equipmentId == '') {
|
that.$message.warning('当前设备信息错误,重新选择设备')
|
that.confirmLoading = false
|
return
|
}
|
if (annItem.demandDate == undefined || annItem.demandDate == null || annItem.demandDate == '') {
|
that.$message.warning('请填写需求日期')
|
that.confirmLoading = false
|
return
|
}
|
if (annItem.inDepartId == undefined || annItem.inDepartId == null || annItem.inDepartId == '') {
|
that.$message.warning('请填写调入管理部门')
|
that.confirmLoading = false
|
return
|
}
|
if (annItem.inManagerId == undefined || annItem.inManagerId == null || annItem.inManagerId == '') {
|
that.$message.warning('请填写调入管理人')
|
that.confirmLoading = false
|
return
|
}
|
if (annItem.inManagerId == undefined || annItem.useDepartId == null || annItem.useDepartId == '') {
|
that.$message.warning('请填写调入责任部门')
|
that.confirmLoading = false
|
return
|
}
|
|
|
}
|
let obj
|
if (!this.model.id) {
|
obj = postAction(this.url.add, formData)
|
} else {
|
obj = requestPut(this.url.edit, formData, { id: this.model.id })
|
}
|
obj.then((res) => {
|
if (res.success) {
|
that.$message.success(res.message)
|
that.$emit('ok')
|
} else {
|
that.$message.warning(res.message)
|
}
|
}).finally(() => {
|
this.model = {}
|
that.confirmLoading = false
|
this.$set(this.model, 'auditStatus', 'notSubmitted')
|
that.close()
|
})
|
}
|
})
|
},
|
|
handleDelete(text, record, index) {
|
this.dataSource.splice(index, 1)
|
|
}
|
|
|
}
|
}
|
</script>
|
|
<style lang='less' scoped>
|
/deep/ .frozenRowClass {
|
color: #c9c9c9;
|
}
|
|
.fontweight {
|
font-weight: bold;
|
}
|
|
.ant-btn {
|
padding: 0 10px;
|
margin-left: 3px;
|
}
|
|
.ant-form-item-control {
|
line-height: 0px;
|
}
|
|
/** 主表单行间距 */
|
.ant-form .ant-form-item {
|
margin-bottom: 10px;
|
}
|
|
/** Tab页面行间距 */
|
.ant-tabs-content .ant-form-item {
|
margin-bottom: 0px;
|
}
|
</style>
|