<template>
|
<a-modal
|
:title='title'
|
:width='width'
|
:visible='visible'
|
:confirmLoading='confirmLoading'
|
switchFullscreen
|
@ok='handleOk'
|
@cancel='handleCancel'
|
cancelText='关闭'
|
>
|
<a-spin :spinning='confirmLoading'>
|
<a-form-model
|
ref='form'
|
:model='model'
|
|
>
|
<a-row>
|
<a-col :span='12'>
|
<a-form-model-item
|
label='单据号'
|
:labelCol='labelCol'
|
:wrapperCol='wrapperCol'
|
prop='num'
|
>
|
<a-input
|
v-model='model.num'
|
disabled='true'
|
placeholder='请输入单据号'
|
></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span='12'>
|
<a-form-model-item
|
label='统一编码/名称/型号'
|
:labelCol='labelCol'
|
:wrapperCol='wrapperCol'
|
prop='equipmentId'
|
>
|
<a-input
|
v-model='model.equipmentId'
|
disabled='true'
|
placeholder='请输入编码/名称/型号'
|
></a-input>
|
</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: 1450, y: 1000 }'
|
>
|
<template
|
v-for='col in columns'
|
:slot='col.dataIndex'
|
slot-scope='text, record, index'
|
>
|
<div :key='col.dataIndex'>
|
|
|
<a-input-number
|
v-if="col.dataIndex == 'actualHour'"
|
:value='text'
|
placeholder='请选择'
|
:options='record.userVoList'
|
@change='(e) => handleChange(e, record.key, col, index)'
|
style='width: 100%'
|
/>
|
</div>
|
</template>
|
<span
|
slot='action'
|
slot-scope='text, record, index'>
|
<a-popconfirm
|
title='确定删除吗?'
|
@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'
|
:loading='confirmLoading'
|
>确定
|
</a-button>
|
</template>
|
<j-select-user-teaml-modal
|
ref='userTeamModalForm'></j-select-user-teaml-modal>
|
</a-modal>
|
</template>
|
|
<script>
|
|
import { httpAction } from '@/api/manage'
|
import pick from 'lodash.pick'
|
import JSelectUserTeamlModal from '../../../repairOrderFinishedReport/modules/JSelectUserTeamlModal'
|
|
export default {
|
name: 'RepairOrderActualHoursReportModel',
|
components: { JSelectUserTeamlModal },
|
props: {},
|
data() {
|
return {
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key: 'rowIndex',
|
align: 'center',
|
customRender: function(t, r, index) {
|
return parseInt(index) + 1
|
},
|
width: 100
|
},
|
{
|
title: '人员编码',
|
align: 'center',
|
dataIndex: 'userCode'
|
},
|
{
|
title: '人员名称',
|
align: 'center',
|
|
dataIndex: 'realName'
|
},
|
{
|
title: '所属班组',
|
align: 'center',
|
|
dataIndex: 'teamName'
|
},
|
{
|
title: '实时工时',
|
align: 'center',
|
|
dataIndex: 'actualHour',
|
scopedSlots: {
|
customRender: 'actualHour'
|
}
|
},
|
{
|
title: '操作',
|
align: 'center',
|
fixed: 'right',
|
width: 147,
|
dataIndex: 'action',
|
scopedSlots: {
|
customRender: 'action'
|
}
|
}
|
],
|
title: '操作',
|
width: 1400,
|
disableSubmit: false,
|
visible: false,
|
model: {},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 }
|
},
|
confirmLoading: false,
|
url: {
|
add: '/eam/repairOrderActualHours/add',
|
edit: '/eam/repairOrderActualHours/edit'
|
},
|
reportRepairStatus: false,
|
data: null,
|
dataSource: []
|
}
|
},
|
|
|
created() {
|
//备份model原始值
|
|
this.modelDefault = JSON.parse(JSON.stringify(this.model))
|
},
|
|
mounted() {
|
this.$bus.$on('selectionRows', (data) => {
|
for (let i = 0; i < data.length; i++) {
|
this.dataSource.push({
|
id: data[i].id,
|
realName: data[i].realName,
|
userCode: data[i].userCode,
|
teamName: data[i].teamName,
|
teamId: data[i].teamId
|
})
|
}
|
|
})
|
},
|
|
methods: {
|
|
selectInspectionProjects: function() {
|
let ids = []
|
for (let i = 0; i < this.dataSource.length; i++) {
|
ids.push(this.dataSource[i].id)
|
}
|
this.$refs.userTeamModalForm.showModals(ids)
|
this.$refs.userTeamModalForm.title = '选择人员信息'
|
this.$refs.userTeamModalForm.disableSubmit = false
|
},
|
|
add(data) {
|
this.edit(this.model,{userTeamList:[]})
|
this.model.id = this.getUuiD(16)
|
this.model.num = data.num
|
this.model.equipmentId = data.equipmentNum + '/' + data.equipmentName + '/' + data.equipmentModel
|
this.model.repairOrderId = data.id
|
this.model.userTeamList = this.dataSource
|
},
|
edit(record) {
|
this.model = Object.assign({}, record)
|
this.visible = true
|
if (record.userTeamList != undefined) {
|
const temp = [...record.userTeamList]
|
this.dataSource = temp
|
}
|
this.$nextTick(() => {
|
this.form.setFieldsValue(pick(this.model, 'equipmentId', 'num'))
|
})
|
},
|
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 == 'actualHour') {
|
|
|
target[column.dataIndex] = value
|
}
|
//显示带过来的数据
|
|
that.dataSource = temp
|
|
}
|
},
|
|
close() {
|
this.$emit('close')
|
this.visible = false
|
this.$refs.form.clearValidate()
|
},
|
handleOk() {
|
const that = this
|
// 触发表单验证
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
that.confirmLoading = true
|
this.model.userTeamList = that.dataSource
|
let httpurl = ''
|
let method = ''
|
if (this.title == '新增') {
|
httpurl += this.url.add
|
method = 'post'
|
} else {
|
httpurl += this.url.edit
|
method = 'put'
|
}
|
/* this.model.repairOrderId=data.id*/
|
//子表验证(维修内容)
|
//表单提交
|
httpAction(httpurl, this.model, method).then((res) => {
|
if (res.success) {
|
that.$message.success(res.message)
|
that.$emit('ok')
|
} else {
|
that.$message.warning(res.message)
|
}
|
}).finally(() => {
|
that.confirmLoading = false
|
that.close()
|
})
|
} else {
|
return false
|
}
|
})
|
},
|
handleCancel() {
|
this.close()
|
},
|
handleDelete(text, record, index) {
|
this.dataSource.splice(index, 1)
|
|
},
|
getUuiD(randomLength) {
|
return Number(
|
Math.random()
|
.toString()
|
.substr(2, randomLength) + Date.now()
|
).toString(36)
|
},
|
popupCallback(value, row) {
|
this.model = Object.assign(this.model, row)
|
console.log(this.model)
|
}
|
}
|
}
|
</script>
|