<template>
|
<j-modal
|
:title="title"
|
:width="width"
|
:height="height"
|
:visible="visible"
|
:confirmLoading="confirmLoading"
|
switchFullscreen
|
@ok="handleOk"
|
@cancel="handleCancel"
|
cancelText="关闭">
|
<a-spin :spinning="confirmLoading">
|
<a-form-model ref="form" :model="model" :validatorRules="validatorRules">
|
<a-row>
|
<a-col :span="24">
|
<a-tabs :defaultActiveKey="defaultActiveKey" @change="changeTabs">
|
<a-tab-pane tab="组织部门" :key="1" >
|
<warehouse-depart-model
|
ref="departModel"
|
:enterpriseId="enterpriseId"
|
:mainId="mainId"
|
:originTargetKeys="originTargetKeys"
|
:addId="model.id"
|
@getAddDepartIds="getAddDepartIds"
|
/>
|
</a-tab-pane>
|
<a-tab-pane tab="工厂模型" :key="2" >
|
<warehouse-factory-model
|
ref="factoryModel"
|
:enterpriseId="enterpriseId"
|
:mainId="mainId"
|
:originTargetKeys="originTargetKeys"
|
:addId="model.id"
|
@getAddFactoryIds="getAddFactoryIds"
|
/>
|
</a-tab-pane>
|
</a-tabs>
|
</a-col>
|
</a-row>
|
</a-form-model>
|
</a-spin>
|
</j-modal>
|
</template>
|
|
<script>
|
import { httpAction } from '@/api/manage'
|
import { validateDuplicateValue } from '@/utils/util'
|
import { getAction } from '../../../api/manage'
|
import WarehouseDepartModel from './warehouse/WarehouseDepart.vue'
|
import WarehouseFactoryModel from './warehouse/WarehouseFactory.vue'
|
export default {
|
name: "WarehouseClientModal",
|
components: {
|
WarehouseDepartModel,
|
WarehouseFactoryModel
|
},
|
props:{
|
mainId:{
|
type:String,
|
required:false,
|
default:''
|
},
|
enterpriseId:{
|
type:String,
|
required:false,
|
default:''
|
},
|
originTargetKeys:{
|
type:Array,
|
required:false
|
}
|
},
|
data () {
|
return {
|
addDepartIds:[],
|
addFactoryIds:[],
|
modelMessage:{},
|
defaultActiveKey:1,
|
title:"操作",
|
width:1200,
|
height:1400,
|
visible: false,
|
canISubmmit:false,
|
model:{
|
},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 },
|
},
|
|
confirmLoading: false,
|
validatorRules: {
|
},
|
url: {
|
add: "/base/warehouse/addWarehouseClient",
|
edit: "/base/warehouse/editWarehouseClient",
|
}
|
}
|
},
|
created () {
|
//备份model原始值
|
this.modelDefault = JSON.parse(JSON.stringify(this.model));
|
},
|
methods: {
|
add () {
|
this.edit(this.modelDefault);
|
},
|
edit (record) {
|
this.model = Object.assign({}, record);
|
this.visible = true;
|
},
|
close () {
|
this.$emit('close');
|
this.visible = false;
|
this.$refs.form.clearValidate();
|
},
|
handleOk () {
|
const that = this;
|
// 触发表单验证
|
this.$refs.form.validate(valid => {
|
if(!this.addDepartIds[0]&&!this.addFactoryIds[0]){
|
this.$message.warning("请至少选择一项再进行添加")
|
}else if (valid) {
|
that.confirmLoading = true;
|
let httpurl = '';
|
let method = '';
|
if(!this.model.id){
|
httpurl+=this.url.add;
|
method = 'post';
|
this.model.warehouseId = this.mainId;
|
}else{
|
httpurl+=this.url.edit;
|
method = 'put';
|
}
|
this.model.addDepartIds=this.addDepartIds;
|
this.model.addFactoryIds = this.addFactoryIds;
|
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();
|
})
|
}
|
|
})
|
},
|
handleCancel () {
|
this.close()
|
},
|
getAddDepartIds(val){
|
this.addDepartIds=val
|
console.log(this.addDepartIds)
|
},
|
getAddFactoryIds(val){
|
this.addFactoryIds=val
|
console.log(this.addFactoryIds)
|
},
|
changeTabs(){
|
if(this.$refs.departModel){
|
this.$refs.departModel.clearList();
|
}
|
if(this.$refs.factoryModel){
|
this.$refs.factoryModel.clearList();
|
}
|
}
|
},
|
}
|
</script>
|