<template>
|
<a-modal
|
:title="title"
|
:width="700"
|
@cancel="close"
|
:visible="visible"
|
:footer="null"
|
style="height: 100%;overflow: auto;padding-bottom: 53px;">
|
|
<a-spin :spinning="confirmLoading">
|
<a-form-model ref="form" :form="form" :model="model" :rules="validatorRules" :labelCol="labelCol"
|
:wrapperCol="wrapperCol">
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item label="车间分配" prop="productionId">
|
<a-select v-model="model.productionId" placeholder="请选择车间" @change="handleSelectChange"
|
:disabled="disabledEdit">
|
<a-select-option v-for="item in workshopTreeData" :key="item.id">
|
{{ item.productionName }}
|
</a-select-option>
|
</a-select>
|
</a-form-model-item>
|
</a-col>
|
|
<a-col :span="12">
|
<a-form-model-item label="轴数" prop="deviceManagementCode">
|
<a-input allow-clear placeholder="请输入轴数" :readOnly="disabledEdit"
|
v-model="model.deviceManagementCode"/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item label="数控系统类别" prop="deviceManagementName">
|
<a-input allow-clear placeholder="请输入数控系统类别" :readOnly="disabledEdit"
|
v-model="model.deviceManagementName"/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row :gutter="24">
|
<a-col :span="24">
|
<a-form-model-item label="设备组编号" :labelCol="labelColLong" :wrapperCol="wrapperColLong"
|
prop="equipmentIds">
|
<a-input-search v-model="model.equipmentIds" readOnly :disabled="!model.productionId" @search="deviceSearch"
|
enter-button :placeholder='!model.productionId?"请选择车间":"请选择设备组编号"'/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
</a-form-model>
|
</a-spin>
|
|
|
<div class="drawer-bottom-button">
|
<a-space>
|
<a-button @click="close">取消</a-button>
|
<a-button @click="handleSubmit" type="primary" :loading="confirmLoading">提交</a-button>
|
</a-space>
|
</div>
|
|
<workshop-device-list-modal :productionId="model.productionId" ref="deviceListModel"
|
@sendSelectedRowKeys="getDeviceRowKeys"/>
|
</a-modal>
|
</template>
|
|
<script>
|
import { httpAction } from '@/api/manage'
|
import WorkshopDeviceListModal from '@views/dnc/base/modules/DeviceCustomTypeManagement/WorkshopDeviceListModal.vue'
|
|
export default {
|
name: 'DeviceCustomTypeManagementModal',
|
components: { WorkshopDeviceListModal },
|
props: {
|
workshopTreeData: {
|
type: Array
|
}
|
},
|
data() {
|
return {
|
title: '',
|
form: this.$form.createForm(this),
|
validatorRules: {
|
productionId: [
|
{
|
required: true, message: '请选择车间!'
|
}
|
],
|
deviceManagementCode: [
|
{
|
required: true, message: '请输入轴数!'
|
}
|
],
|
deviceManagementName: [
|
{
|
required: true, message: '请输入数控系统类别!'
|
}
|
],
|
equipmentIds: [
|
{
|
required: true, message: '请选择设备编号!',trigger:'change'
|
}
|
]
|
},
|
visible: false,
|
disabledEdit: false,
|
model: {},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 8 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 14 }
|
},
|
labelColLong: {
|
xs: { span: 24 },
|
sm: { span: 4 }
|
},
|
wrapperColLong: {
|
xs: { span: 24 },
|
sm: { span: 19 }
|
},
|
confirmLoading: false,
|
url: {
|
add: '/nc/deviceManagement/add',
|
edit: '/nc/deviceManagement/edit'
|
}
|
}
|
},
|
methods: {
|
// 车间选择器值发生改变时触发清空已选择的设备编号组
|
handleSelectChange() {
|
if (this.model.equipmentIds) delete this.model.equipmentIds
|
},
|
|
/**
|
* 当设备选择完成后提交将已选择的设备编号列表以逗号隔开拆分到参数中
|
* @param selectedRowKeys
|
*/
|
getDeviceRowKeys(selectedRowKeys) {
|
if (selectedRowKeys.length === 0) return
|
this.$set(this.model, 'equipmentIds', selectedRowKeys.join(','))
|
this.$refs.form.clearValidate()
|
},
|
|
deviceSearch() {
|
this.$refs.deviceListModel.openPage()
|
this.$refs.deviceListModel.title = '选择设备'
|
this.$refs.deviceListModel.disableSubmit = false
|
},
|
|
add() {
|
this.edit({})
|
},
|
|
edit(record) {
|
this.visible = true
|
this.model = Object.assign({}, record)
|
},
|
|
handleSubmit() {
|
const that = this
|
// 触发表单验证
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
that.confirmLoading = true
|
let apiUrl, method
|
if (!this.model.id) {
|
apiUrl = this.url.add
|
method = 'post'
|
} else {
|
apiUrl = this.url.edit
|
method = 'put'
|
}
|
httpAction(apiUrl, this.model, method)
|
.then((res) => {
|
if (res.success) {
|
that.$notification.success({
|
message: '消息',
|
description: res.message
|
})
|
that.$emit('ok')
|
that.close()
|
} else {
|
that.$notification.warning({
|
message: '消息',
|
description: res.message
|
})
|
}
|
})
|
.finally(() => {
|
that.confirmLoading = false
|
})
|
} else {
|
return false
|
}
|
})
|
},
|
|
close() {
|
this.$emit('close')
|
this.visible = false
|
this.$refs.form.clearValidate()
|
}
|
}
|
|
}
|
</script>
|
|
<style scoped>
|
.drawer-bottom-button {
|
position: absolute;
|
bottom: -40px;
|
width: 100%;
|
border-top: 1px solid #e8e8e8;
|
padding: 10px 16px;
|
text-align: right;
|
left: 0;
|
background: #fff;
|
border-radius: 0 0 2px 2px;
|
}
|
</style>
|