<template>
|
<a-modal
|
:title="title"
|
:visible="visible"
|
:fullScreen="true"
|
:width="1200"
|
@ok="handleOk"
|
@cancel="handleCancel"
|
>
|
<a-spin :spinning="confirmLoading">
|
<a-form-model ref="form" :model="model" :rules="validatorRules">
|
<a-row style="width: 100%">
|
<a-col :span="24 / 2">
|
<a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="工具分类编号">
|
<a-input v-model="model.classifyNum" placeholder="请输入工具分类编码" :disabled="true"></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="24 / 2">
|
<a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="工具分类名称">
|
<a-input v-model="model.typeName" placeholder="请输入工具分类名称" :disabled="true"></a-input>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
<a-row style="width: 100%">
|
<a-col :span="24 / 2">
|
<a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="入库类型" prop="inStorehouseType">
|
<j-dict-select-tag
|
:disabled="disableSubmit"
|
type="list"
|
v-model="model.inStorehouseType"
|
:triggerChange="true"
|
dictCode="in_storehouse_type"
|
placeholder="请选择入库类型"
|
@change="handleTypeChange"
|
/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="24 / 2">
|
<a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="入库时间" prop="inboundTime">
|
<a-date-picker
|
@change="onChange"
|
:disabled="disableSubmit"
|
style="width: 100%"
|
v-model="model.inboundTime"
|
/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row style="width: 100%">
|
<a-col :span="24 / 2">
|
<a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="库位号" prop="locationCodeId">
|
<a-select
|
:triggerChange="true"
|
:options="locationCodeOptions"
|
v-model="model.locationCodeId"
|
/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
</a-form-model>
|
</a-spin>
|
<a-button type="primary" :style="{ marginBottom: '8px' }" @click="selectReturnList()" v-show="returnShow && !disableSubmit">选择借出工具</a-button>
|
<a-button type="primary" :style="{ marginBottom: '8px' }" @click="selectTooling()" v-show="toolingShow && !disableSubmit">选择工具</a-button>
|
<a-button type="primary" :style="{ marginBottom: '8px' }" @click="selectSharpenList()" v-show="sharpenShow && !disableSubmit">选择刃磨工具</a-button>
|
<a-table
|
ref="table"
|
bordered
|
size="middle"
|
rowKey="id"
|
:columns="columns"
|
:dataSource="dataSource"
|
:pagination="ipagination"
|
:loading="loading"
|
@change="handleTableChange"
|
>
|
<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 == 'inStorageQuantity'"
|
:disabled="record.accuracyClass == '1'"
|
:value="text"
|
@change="(e) => handleChange(e, record, col, index)"
|
:min="1"
|
/>
|
</div>
|
</template>
|
<span slot="action" slot-scope="text, record, index">
|
<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record, index)" :disabled="disableSubmit">
|
<a>删除</a>
|
</a-popconfirm>
|
</span>
|
</a-table>
|
<template slot="footer" v-if="disableSubmit == false">
|
<a-button :style="{ marginRight: '8px' }" @click="handleCancel">关闭</a-button>
|
<a-button @click="handleOk" :disabled="isDisabled" type="primary">入库</a-button>
|
</template>
|
|
<template slot="footer" v-if="disableSubmit == true">
|
<a-button :style="{ marginRight: '8px' }" @click="handleCancel">关闭</a-button>
|
</template>
|
<j-select-tooling-modal ref="toolingModalForm" @ok="modalFormOk" :classifyId="classifyId"></j-select-tooling-modal>
|
<j-select-return-list-modal ref="returnModalForm" @ok="modalFormOk" :classifyId="classifyId"></j-select-return-list-modal>
|
<j-select-sharpen-list-modal ref="sharpenModalForm" @ok="modalFormOk" :classifyId="classifyId"></j-select-sharpen-list-modal>
|
</a-modal>
|
</template>
|
|
<script>
|
import pick from 'lodash.pick'
|
import JSelectToolingModal from '.././inboundOrder/JSelectToolingModal'
|
import { ajaxGetDictItems } from '@/api/api'
|
import moment from 'moment'
|
import { getAction, postAction, requestPut } from '@/api/manage'
|
import JDictSelectTag from '@/components/dict/JDictSelectTag'
|
import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
|
import JMultiSelectTag from '@/components/dict/JMultiSelectTag'
|
import { filterObj } from '@/utils/util'
|
import JSelectReturnListModal from '.././inboundOrder/JSelectReturnListModal'
|
import JSelectSharpenListModal from '.././inboundOrder/JSelectSharpenListModal'
|
|
export default {
|
name: 'InboundModel',
|
components: {
|
JSelectToolingModal,
|
JMultiSelectTag,
|
JDictSelectTag,
|
JSelectReturnListModal,
|
JSearchSelectTag,
|
JSelectSharpenListModal,
|
},
|
data() {
|
return {
|
/* 分页参数 */
|
ipagination: {
|
current: 1,
|
pageSize: 10,
|
pageSizeOptions: ['10', '20', '30'],
|
showTotal: (total, range) => {
|
return range[0] + '-' + range[1] + ' 共' + total + '条'
|
},
|
showQuickJumper: true,
|
showSizeChanger: true,
|
total: 0
|
},
|
form: this.$form.createForm(this),
|
isDisabled: false,
|
selectedRowKeys: {},
|
state: {
|
show: false,
|
maintenanceValue: 1,
|
checkValue: 1,
|
maintenanceState: false,
|
checkState: false,
|
},
|
disableSubmit: false,
|
quantityDisable:false,
|
returnShow:false,
|
toolingShow:false,
|
sharpenShow:false,
|
title: '操作',
|
visible: false,
|
model: {},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 6 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 18 },
|
},
|
confirmLoading: false,
|
loading: false,
|
dataSource: [],
|
param: {},
|
inboundOrderId:'',
|
validatorRules: {
|
inStorehouseType: [
|
{
|
required: true,
|
message: '请选择入库类型!',
|
},
|
],
|
inboundTime:[
|
{
|
required: true,
|
message: '请选择申请入库日期!',
|
},
|
],
|
locationCodeId:[
|
{
|
required: true,
|
message: '请选择库位号!',
|
},
|
]
|
},
|
url: {
|
addInStorage: '/tms/inboundOrder/addInStorage',
|
toolingList:'/tms/baseTools/list',
|
querySharpenList:'/tms/toolLedgerDetail/list',
|
queryReturnList:'/tms/toolLedgerDetail/list',
|
detailList:'/tms/inboundDetail/list',
|
},
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key: 'rowIndex',
|
width: 50,
|
align: 'center',
|
customRender: function (t, r, index) {
|
return parseInt(index) + 1
|
},
|
},
|
{
|
title: '工具编码',
|
align: 'center',
|
dataIndex: 'toolCode',
|
width: 150,
|
},
|
{
|
title: '工具类型',
|
align: 'center',
|
dataIndex: 'applicationType'
|
},
|
{
|
title: '中文名称',
|
align: 'center',
|
dataIndex: 'chineseName',
|
},
|
{
|
title: '型号/图号',
|
align: 'center',
|
dataIndex: 'toolModel'
|
},
|
{
|
title: '唯一编码',
|
align: 'center',
|
dataIndex: 'onlyCode',
|
width: 150,
|
},
|
{
|
title: '入库数量',
|
align: 'center',
|
dataIndex: 'inStorageQuantity',
|
scopedSlots: { customRender: 'inStorageQuantity' },
|
},
|
{
|
title: '操作',
|
dataIndex: 'action',
|
align: 'center',
|
scopedSlots: { customRender: 'action' },
|
},
|
],
|
classifyId:'',
|
locationCodeOptions:[]
|
}
|
},
|
created() {
|
//备份model原始值
|
this.modelDefault = JSON.parse(JSON.stringify(this.model));
|
ajaxGetDictItems("tms_goods_shelves,location_code,id", null).then((res) => {
|
if (res.success) {
|
this.locationCodeOptions = res.result
|
}
|
})
|
},
|
methods: {
|
modalFormOk() {
|
},
|
getQueryParams() {
|
this.param.pageNo = this.ipagination.current
|
this.param.pageSize = this.ipagination.pageSize
|
return filterObj(this.param)
|
},
|
add (nodeSelected) {
|
this.classifyId = nodeSelected.key
|
this.model.classifyNum = nodeSelected.entity.classifyId
|
this.model.typeName = nodeSelected.entity.typeName
|
this.dataSource = []
|
this.visible = true;
|
},
|
handleChange(value, record, column, index) {
|
//let t = (this.ipaginationm.current - 1) * this.ipaginationm.pageSize + index
|
let key = record.key
|
const temp = [...this.dataSource]
|
const target = temp.filter(item => key === item.key)[index];
|
if (target) {
|
target[column.dataIndex] = value
|
|
if(column.dataIndex === 'inStorageQuantity'){
|
if(target['quantity']<value){
|
this.$message.error('入库数量不能大于出库数量!')
|
this.isDisabled = true
|
}else{
|
this.isDisabled = false
|
}
|
}
|
this.dataSource = temp
|
}
|
},
|
close() {
|
this.$emit('close')
|
this.dataSource = []
|
this.model = {},
|
this.visible = false
|
this.disableSubmit = false,
|
this.quantityDisable = false,
|
this.returnShow = false,
|
this.toolingShow = false,
|
this.sharpenShow = false
|
},
|
handleTableChange(pagination, filters, sorter) {
|
this.ipagination = pagination
|
this.detailList(this.inboundOrderId);
|
},
|
handleOk() {
|
const that = this
|
// 触发表单验证
|
this.form.validateFields((err, values) => {
|
if (!err) {
|
that.confirmLoading = true
|
let formData = Object.assign(this.model, values)
|
formData.detailData = this.dataSource
|
formData.classifyId = this.classifyId
|
postAction(this.url.addInStorage, formData)
|
.then((res) => {
|
if (res.success) {
|
that.$message.success(res.message)
|
that.$emit('ok', new Date())
|
} else {
|
that.$message.warning(res.message)
|
}
|
})
|
.finally(() => {
|
that.confirmLoading = false
|
that.close()
|
})
|
}
|
})
|
},
|
handleCancel() {
|
this.close()
|
},
|
//选择工具
|
selectTooling: function () {
|
let ids = []
|
for (let i = 0; i < this.dataSource.length; i++) {
|
ids.push(this.dataSource[i].id)
|
}
|
this.$refs.toolingModalForm.showModal(ids)
|
this.$refs.toolingModalForm.title = '选择工具'
|
this.$refs.toolingModalForm.disableSubmit = false
|
},
|
//选择归还工具
|
selectReturnList: function () {
|
let ids = []
|
for (let i = 0; i < this.dataSource.length; i++) {
|
ids.push(this.dataSource[i].id)
|
}
|
this.$refs.returnModalForm.showModal(ids)
|
this.$refs.returnModalForm.title = '选择归还工具'
|
this.$refs.returnModalForm.disableSubmit = false
|
},
|
//选择刃磨工具
|
selectSharpenList: function () {
|
let ids = []
|
for (let i = 0; i < this.dataSource.length; i++) {
|
ids.push(this.dataSource[i].id)
|
}
|
this.$refs.sharpenModalForm.showModal(ids)
|
this.$refs.sharpenModalForm.title = '选择刃磨工具'
|
this.$refs.sharpenModalForm.disableSubmit = false
|
},
|
handleDelete(record, index) {
|
this.dataSource.splice(index, 1)
|
},
|
onChange() {},
|
//入库类型
|
handleTypeChange(value) {
|
this.dataSource = []
|
if(value == 1){
|
this.toolingShow = true
|
this.quantityDisable = false
|
}else{
|
this.toolingShow = false
|
}
|
if(value == 2){
|
this.returnShow = true
|
this.quantityDisable = true
|
}else{
|
this.returnShow = false
|
}
|
if (value == 5) {
|
this.sharpenShow = true
|
this.quantityDisable = true
|
} else {
|
this.sharpenShow = false
|
}
|
|
},
|
detailList(inboundOrderId) {
|
this.param.inboundOrderId = inboundOrderId
|
getAction(this.url.detailList, this.getQueryParams()).then((res) => {
|
if (res.success) {
|
this.dataSource = res.result.records
|
this.ipagination.total = res.result.total;
|
}
|
})
|
},
|
filterOption(input, option) {
|
return (
|
option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
);
|
},
|
},
|
watch: {},
|
mounted() {
|
this.$bus.$on('selectionRows', (data) => {
|
//getCurrSelected 事件 接收组件传递的参数
|
for (let i = 0; i < data.length; i++) {
|
this.dataSource.push({
|
id: data[i].id,
|
toolCodeId: data[i].toolCodeId,
|
toolCode: data[i].toolCode,
|
chineseName: data[i].chineseName,
|
toolModel: data[i].toolModel,
|
applicationType: data[i].applicationTypeName,
|
onlyCode:data[i].onlyCode,
|
inStorageQuantity:data[i].storageQuantity || data[i].quantity || 1,
|
quantity:data[i].quantity,
|
accuracyClass:data[i].accuracyClass
|
})
|
}
|
//this.ipaginationm.total = this.dataSource.length
|
})
|
},
|
}
|
</script>
|
|
|
<style lang="less" scoped>
|
.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;
|
}
|
|
/deep/ .notshow {
|
display: none;
|
}
|
</style>
|