<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='disabled'
|
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='disabled'
|
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
|
:value="text"
|
v-if="col.dataIndex == 'quantity'"
|
:min="0"
|
:max="record.mainQuantity-record.useQuantity"
|
@change="(e)=>handleChange(e, record.key, col, index)"
|
:disabled="record.disabled"
|
/>
|
|
</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-spare-part-modal
|
ref='sparePartModalForm'></j-select-spare-part-modal>
|
</a-modal>
|
</template>
|
|
<script>
|
|
import { httpAction, 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 JSelectSparePartModal from '../../../repairOrderFinishedReport/modules/JSelectSparePartModal'
|
|
export default {
|
name: 'RepairOrderActualMaterialReportModel',
|
components: { Tooltip,JMultiSelectTag,JSelectSparePartModal },
|
props: {},
|
data() {
|
return {
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key: 'rowIndex',
|
align: 'center',
|
customRender: function(t, r, index) {
|
return parseInt(index) + 1
|
},
|
width: 100
|
},
|
{
|
title: '领料出库单',
|
dataIndex: 'num',
|
align: "center",
|
width: 150,
|
},
|
{
|
title: '备件编码',
|
dataIndex: 'spareNum',
|
align: "center",
|
|
},
|
{
|
title: '备件名称',
|
dataIndex: 'spareName',
|
align: "center",
|
|
},
|
{
|
title: '规格',
|
dataIndex: 'specification',
|
align: "center",
|
},
|
{
|
title: '型号',
|
dataIndex: 'model',
|
align: "center",
|
},
|
{
|
title: '制造商',
|
dataIndex: 'constructorName',
|
align: "center",
|
},
|
{
|
title: '主单位',
|
dataIndex: 'mainUnitName',
|
align: "center",
|
|
},
|
{
|
title: '数量',
|
dataIndex: 'quantity',
|
align: "center",
|
scopedSlots: { customRender: 'quantity' },
|
className: 'red',
|
|
},
|
{
|
title: '操作',
|
align: 'center',
|
fixed: 'right',
|
width: 147,
|
dataIndex: 'action',
|
scopedSlots: {
|
customRender: 'action'
|
}
|
}
|
],
|
title: '操作',
|
width: 1400,
|
disabled:true,
|
codeDisable: true,
|
disableSubmit: false,
|
visible: false,
|
model: {},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 }
|
},
|
confirmLoading: false,
|
url: {
|
add: '/eam/repairOrderActualMaterial/add',
|
edit: '/eam/repairOrderActualMaterial/edit'
|
},
|
form: this.$form.createForm(this),
|
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,
|
num: data[i].num,
|
outboundOrderId:data[i].outboundOrderId,
|
sparePartId:data[i].sparePartId,
|
spareNum: data[i].spareNum,
|
spareName: data[i].spareName,
|
specification: data[i].specification,
|
model:data[i].model,
|
constructorName:data[i].constructorName,
|
constructorId:data[i].constructorId,
|
mainUnitName:data[i].mainUnitName,
|
mainUnitId:data[i].mainUnitId,
|
mainQuantity:data[i].mainQuantity,
|
useQuantity:data[i].useQuantity
|
|
})
|
}
|
|
})
|
},
|
|
methods: {
|
|
selectInspectionProjects: function() {
|
let ids = []
|
for (let i = 0; i < this.dataSource.length; i++) {
|
ids.push(this.dataSource[i].id)
|
}
|
this.$refs.sparePartModalForm.showModals(ids)
|
this.$refs.sparePartModalForm.title = '选择备件信息'
|
this.$refs.sparePartModalForm.disableSubmit = false
|
},
|
|
|
add(data) {
|
this.edit({sparePartList:[]})
|
// 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.sparePartList = this.dataSource
|
},
|
edit(record) {
|
console.log(record)
|
let that = this;
|
that.dataSource = [];
|
that.form.resetFields();
|
that.model = Object.assign({}, record)
|
that.visible = true
|
if (record.sparePartList != undefined) {
|
const temp = [...record.sparePartList]
|
that.dataSource = temp
|
}
|
that.$nextTick(() => {
|
that.form.setFieldsValue(pick(that.model, 'equipmentId', 'num'))
|
})
|
},
|
|
handleChange(value, key, column, index) {
|
let that = this;
|
const temp = [...that.dataSource];
|
const target = temp[index];
|
if (target) {
|
target[column.dataIndex] = value;
|
if ('quantity' == column.dataIndex) {
|
target['quantity'] = value;
|
}
|
that.dataSource = temp;
|
}
|
},
|
|
// 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.form.validateFields((err, values) => {
|
if (!err) {
|
that.confirmLoading = true
|
let formData = Object.assign(this.model, values);
|
formData.sparePartList = 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>
|