<template>
|
<a-card
|
:bordered="false"
|
:class="'cust-erp-sub-tab'"
|
>
|
<a-table
|
ref="table"
|
bordered
|
rowKey="id"
|
:columns="columns"
|
:dataSource="dataSource"
|
:pagination="ipagination"
|
@change="handleTableChange"
|
>
|
|
<template
|
v-for="col in columns"
|
:slot="col.dataIndex"
|
slot-scope='text, record, index'
|
>
|
<div :key="col.dataIndex">
|
<a-input-search
|
v-if="col.dataIndex == 'materialName'"
|
enter-button
|
@search="onSearchMaterial(index)"
|
:value="text"
|
:read-only="true"
|
@change="(e) => handleChange(e, record.key, col, index)"
|
/>
|
<a-input-number
|
:value="text"
|
v-if="col.dataIndex == 'quantity'"
|
:min="1"
|
:max="99999"
|
@change="(e)=>handleChange(e, record.key, col, index)"
|
:disabled="record.isLock == 'yes'||specialyMaintenanceOrderStatus!='4'"
|
/>
|
|
</div>
|
</template>
|
<span
|
slot='action'
|
slot-scope='text, record'
|
>
|
<a-popconfirm
|
title="确认锁料吗?"
|
@confirm="() => handleLock(record)"
|
>
|
<a
|
v-has="'specialtyMaintenanceOrder:actualMaterialLock'"
|
v-if="record.isLock=='no'&&specialyMaintenanceOrderStatus=='4'"
|
>锁料</a>
|
</a-popconfirm>
|
<a-divider
|
v-if="record.isLock=='no'"
|
type="vertical"
|
/>
|
<a-popconfirm
|
title="解锁后会自动释放库存,确认解锁吗?"
|
@confirm="() => handleUnLock(record)"
|
>
|
<a
|
v-has="'specialtyMaintenanceOrder:actualMaterialLock'"
|
v-if="record.isLock=='yes'&&specialyMaintenanceOrderStatus=='4'"
|
>解锁</a>
|
</a-popconfirm>
|
<a-popconfirm
|
title="确定删除吗?"
|
@confirm="() => handleDelete(record.id)"
|
>
|
<a
|
v-has="'specialtyMaintenanceOrder:actualMaterialDelete'"
|
v-if="record.isLock=='no'&&specialyMaintenanceOrderStatus=='4'"
|
>删除</a>
|
</a-popconfirm>
|
</span>
|
</a-table>
|
<a-button
|
style="width: 100%; margin-top: 16px; margin-bottom: 8px"
|
type="dashed"
|
icon="plus"
|
@click="addMaterial"
|
:disabled="specialyMaintenanceOrderStatus!='4'"
|
v-has="'specialtyMaintenanceOrder:actualMaterialAdd'"
|
>添加实际用料</a-button>
|
<div :style="{width: '100%',border: '1px solid #e9e9e9',padding: '10px 16px',background: '#fff',}">
|
<a-row :style="{textAlign:'right'}">
|
<!-- <a-button
|
:style="{marginRight: '8px'}"
|
@click="handleCancel"
|
>
|
取消
|
</a-button> -->
|
<!-- <a-button
|
@click="handleOk(1)"
|
type="primary"
|
:style="{marginRight: '8px'}"
|
:disabled="specialyMaintenanceOrderStatus!='4'"
|
>暂存</a-button>
|
<a-button
|
@click="handleOk(0)"
|
type="primary"
|
:disabled="specialyMaintenanceOrderStatus!='4'"
|
>保存</a-button> -->
|
</a-row>
|
<!-- :disabled="false" -->
|
</div>
|
<actual-material-select
|
ref="actualMaterialSelect"
|
@sendMaterialRecord="sendMaterialRecord"
|
>
|
</actual-material-select>
|
<j-select-spare-part-modal ref='JSelectSparePartModal'></j-select-spare-part-modal>
|
</a-card>
|
</template>
|
<script>
|
import { postAction, getAction } from '@/api/manage'
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
import pick from 'lodash.pick'
|
import JEllipsis from '@/components/jeecg/JEllipsis'
|
import ActualMaterialSelect from './ActualMaterialSelect.vue'
|
import JSelectSparePartModal from './JSelectSparePartModal'
|
export default {
|
name: 'ActualMaterialEditTable',
|
mixins: [JeecgListMixin],
|
components: {
|
JEllipsis,
|
ActualMaterialSelect,
|
JSelectSparePartModal
|
},
|
props: {
|
specialyMaintenanceOrderId: {
|
type: String,
|
required: false,
|
default: '-1'
|
},
|
specialyMaintenanceOrderStatus: {
|
type: String,
|
required: false,
|
default: ''
|
},
|
equipmentId: {
|
type: String,
|
required: false,
|
default: ''
|
},
|
},
|
data() {
|
return {
|
title: "实际用料",
|
visible: false,
|
model: {},
|
maskClosable: true,
|
confirmLoading: false,
|
// specialyMaintenanceOrderStatus: '',
|
form: this.$form.createForm(this),
|
/* 分页参数 */
|
ipagination: {
|
current: 1,
|
pageSize: 99,
|
pageSizeOptions: ['99', '199'],
|
showTotal: (total, range) => {
|
return range[0] + "-" + range[1] + " 共" + total + "条"
|
},
|
showQuickJumper: true,
|
showSizeChanger: true,
|
total: 0
|
},
|
validatorRules: {
|
materialId: {
|
rules: [
|
{ required: true, message: '请选择物料!' },
|
]
|
},
|
quantity: {
|
rules: [
|
{ required: false, message: '请填写数量!' },
|
]
|
},
|
},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 7 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 },
|
},
|
drawerWidth: "100%",
|
visible: false,
|
disableSubmit: false,
|
disableSelect: false,
|
loading: false,
|
dataSource: [],
|
columns: [
|
{
|
title: '领料出库单',
|
dataIndex: 'num',
|
align: "center",
|
width: 150,
|
},
|
{
|
title: '备件编码',
|
dataIndex: 'sparePartNum',
|
align: "center",
|
|
},
|
{
|
title: '备件名称',
|
dataIndex: 'sparePartName',
|
align: "center",
|
|
},
|
{
|
title: '规格',
|
dataIndex: 'specification',
|
align: "center",
|
},
|
{
|
title: '型号',
|
dataIndex: 'model',
|
align: "center",
|
},
|
{
|
title: '制造商',
|
dataIndex: 'constructorName',
|
align: "center",
|
},
|
{
|
title: '主单位',
|
dataIndex: 'mainUnitName',
|
align: "center",
|
|
},
|
{
|
title: '主数量',
|
align: 'center',
|
dataIndex: 'mainQuantity'
|
},
|
{
|
title: '可用数量',
|
align: 'center',
|
dataIndex: 'availableQuantity'
|
},
|
{
|
title: '使用数量',
|
dataIndex: 'quantity',
|
align: "center",
|
scopedSlots: { customRender: 'quantity' },
|
className: 'red',
|
|
},
|
{
|
title: '操作',
|
dataIndex: 'action',
|
align: 'center',
|
width: 250,
|
scopedSlots: { customRender: 'action' }
|
}
|
],
|
url: {
|
list: "/eam/maintenanceOrderActualMaterial/getMaintenanceOrderActualMaterialList",
|
confirmMaterial: "/eam/maintenanceOrderActualMaterial/add",
|
delete: "/eam/maintenanceOrderActualMaterial/delete",
|
addInit: "/eam/maintenanceOrderActualMaterial/addInit",
|
lock: "/eam/maintenanceOrderActualMaterial/lock",
|
unLock: "/eam/maintenanceOrderActualMaterial/unLock"
|
},
|
changeIndex: 0
|
}
|
},
|
watch: {
|
specialyMaintenanceOrderId: {
|
immediate: true,
|
handler(val) {
|
this.clearList();
|
this.queryParam['maintenanceOrderId'] = val
|
this.queryParam['equipmentId'] = this.equipmentId
|
this.loadData(1);
|
}
|
},
|
equipmentId: {
|
immediate: true,
|
handler(val) {
|
this.clearList();
|
this.queryParam['maintenanceOrderId'] = this.specialyMaintenanceOrderIdmaintenanceOrderId
|
this.queryParam['equipmentId'] = val
|
this.loadData(1);
|
}
|
}
|
},
|
created() {
|
this.queryParam['maintenanceOrderId'] = this.specialyMaintenanceOrderId;
|
this.queryParam['equipmentId'] = this.equipmentId
|
this.loadData(1);
|
},
|
methods: {
|
addMaterial() {
|
let ids = [];
|
for (let i = 0; i < this.dataSource.length; i++) {
|
ids.push(this.dataSource[i].outboundOrderDetailId);
|
}
|
this.$refs.JSelectSparePartModal.showModals(ids);
|
this.$refs.JSelectSparePartModal.title = '选择备件信息'
|
this.$refs.JSelectSparePartModal.disableSubmit = false
|
},
|
handleCancel() {
|
this.$bus.$emit('closeDrawer');
|
},
|
close() {
|
this.$emit('close');
|
this.dataSource = [];
|
this.disableSubmit = false;
|
this.visible = false;
|
},
|
handleDeleteFake(index) {
|
this.dataSource.pop(index);
|
},
|
handleOk(saveStatus) {
|
const that = this
|
if (saveStatus == 0) {
|
let materialDataSource = that.dataSource;
|
let indexIdList = [];
|
for (let i = 0; i < materialDataSource.length; i++) {
|
if (materialDataSource[i].materialId == undefined || materialDataSource[i].materialId == null || materialDataSource[i].materialId == '') {
|
that.$message.warning("请选择第" + (i + 1) + "行物料!");
|
return false;
|
}
|
if (materialDataSource[i].quantity == undefined || materialDataSource[i].quantity == null || materialDataSource[i].quantity == '') {
|
that.$message.warning("请填写第" + (i + 1) + "行用料数!");
|
return false;
|
}
|
}
|
}
|
if (that.dataSource.length === 0) {
|
that.$message.warning("请添加物料!")
|
return
|
}
|
this.form.validateFields((err, values) => {
|
if (!err) {
|
that.confirmLoading = true
|
let formData = {}
|
formData.maintenanceOrderId = that.specialyMaintenanceOrderId;
|
formData.maintenanceOrderActualMaterials = that.dataSource;
|
formData.equipmentId = that.equipmentId;
|
let obj = obj = postAction(this.url.confirmMaterial, formData)
|
obj.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()
|
that.loadData(1);
|
})
|
}
|
})
|
},
|
handleChange(value, key, column, index) {
|
console.log(column)
|
const temp = [...this.dataSource]
|
const target = temp[index]
|
let availableQuantity = target['availableQuantity']
|
if (target) {
|
if (value != undefined && value != null && value != '' && availableQuantity < value) {
|
this.$message.error('使用数量不能大于可用数量!')
|
} else {
|
}
|
target[column.dataIndex] = value
|
this.dataSource = temp
|
}
|
},
|
onSearchMaterial(index) {
|
this.recordIndex = index
|
this.$refs.actualMaterialSelect.list()
|
this.$refs.actualMaterialSelect.title = '物料选择'
|
},
|
sendMaterialRecord(data, val) {
|
let record = data.record
|
const temp = [...this.dataSource]
|
const target = temp[this.recordIndex]
|
if (target) {
|
target.materialId = record.id;
|
target.materialName = record.name;
|
target.materialNum = record.num;
|
target.materialModel = record.model;
|
target.materialSpecification = record.specification;
|
target.unitId_dictText = record.unitId_dictText;
|
this.dataSource = temp
|
}
|
},
|
clearList() {
|
this.dataSource = [];
|
this.ipagination.current = 1
|
},
|
getUuiD(randomLength) {
|
return Number(
|
Math.random()
|
.toString()
|
.substr(2, randomLength) + Date.now()
|
).toString(36)
|
},
|
handleLock(record) {
|
let that = this;
|
if (record.quantity == null || record.quantity == undefined || record.quantity == '') {
|
this.$message.error('请先填写数量!');
|
return false
|
}
|
if (record.availableQuantity < record.quantity) {
|
this.$message.error('使用数量不能大于可用数量!');
|
return false;
|
}
|
this.confirmLoading = true;
|
postAction(this.url.lock, record).then(res => {
|
if (res.success) {
|
this.$message.success("库存锁定成功!")
|
} else {
|
this.$message.error(res.message)
|
}
|
}).finally(res => {
|
that.confirmLoading = false
|
that.loadData();
|
})
|
|
},
|
handleUnLock(record) {
|
let that = this;
|
this.confirmLoading = true;
|
postAction(this.url.unLock, record).then(res => {
|
if (res.success) {
|
this.$message.success("库存解锁成功!")
|
} else {
|
this.$message.error(res.message)
|
}
|
}).finally(res => {
|
that.confirmLoading = false
|
that.loadData();
|
})
|
},
|
loadData(arg) {
|
if (!this.url.list) {
|
this.$message.error('请设置url.list属性!')
|
return
|
}
|
//加载数据 若传入参数1则加载第一页的内容
|
if (arg === 1) {
|
this.ipagination.current = 1
|
}
|
this.queryParam['maintenanceOrderId'] = this.specialyMaintenanceOrderId
|
this.queryParam['equipmentId'] = this.equipmentId
|
var params = this.getQueryParams() //查询条件
|
this.loading = true
|
getAction(this.url.list, params)
|
.then(res => {
|
if (res.success) {
|
//update-begin---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
|
this.dataSource = res.result.records || res.result
|
if (res.result.total) {
|
this.ipagination.total = res.result.total
|
} else {
|
this.ipagination.total = 0
|
}
|
//update-end---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
|
} else {
|
this.$message.warning(res.message)
|
}
|
})
|
.finally(() => {
|
this.loading = false
|
})
|
},
|
},
|
mounted() {
|
let newActualMaterials = [];
|
this.$bus.$on('selectionRows', (data) => {
|
for (let i = 0; i < data.length; i++) {
|
var actualMaterial
|
=
|
{
|
id: this.getUuiD(16),
|
num: data[i].num,
|
outboundOrderDetailId: data[i].id,
|
sparePartId: data[i].sparePartId,
|
sparePartNum: data[i].spareNum,
|
sparePartName: 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,
|
availableQuantity: data[i].availableQuantity,
|
maintenanceOrderId: this.specialyMaintenanceOrderId,
|
equipmentId: this.equipmentId,
|
isLock: 'no'
|
}
|
newActualMaterials.push(actualMaterial);
|
}
|
let that = this
|
let obj = obj = postAction(this.url.addInit, newActualMaterials)
|
obj.then((res) => {
|
if (res.success) {
|
that.$message.success(res.message)
|
|
that.$emit('ok')
|
} else {
|
that.$message.warning(res.message)
|
}
|
}).finally(res => {
|
that.loadData();
|
newActualMaterials = []
|
})
|
})
|
},
|
|
}
|
</script>
|
|
<style scoped>
|
/deep/ .red {
|
color: red;
|
}
|
</style>
|