<template>
|
<a-modal
|
:title="title"
|
:maskClosable="true"
|
:width="modalWidth"
|
@cancel="visible=false"
|
:visible="visible"
|
:footer="null"
|
centered
|
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="equipmentId">
|
<a-input-search v-model="model.equipmentId" :disabled="disableSubmit" @search="deviceSearch" enter-button
|
placeholder='请选择统一编码'/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="设备名称">
|
<a-input :disabled="disableSubmit" allow-clear placeholder="请输入设备名称"
|
v-model="model.equipmentName"/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item v-if="isDepartType == 0" label="部门分配"
|
v-show="!departDisabled">
|
<j-select-equipment-depart :disabled="disableSubmit" v-model="model.selectedDeparts" :multi="false"
|
@back="backDepartInfo" :backDepart="true"
|
:treeOpera="true"></j-select-equipment-depart>
|
</a-form-model-item>
|
|
<a-form-model-item v-if="isDepartType == -1" label="设备类型">
|
<a-select :disabled="disableSubmit" placeholder="请选择设备类型" allow-clear
|
:triggerChange="true"
|
v-model="model.equipmentType">
|
<a-select-option v-for='item in equipmentTypeList' :key='item.id' :value='item.equipmentTypeName'>
|
{{item.equipmentTypeName}}
|
</a-select-option>
|
</a-select>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="车间分配" v-show="!productionDisabled"
|
ref="selectedProduction" prop="selectedProduction">
|
<j-select-equipment-production :disabled="disableSubmit" v-model="model.selectedProduction" :multi="false"
|
@back="backProductionInfo" :backProduction="true" :allowClear="false"
|
:treeProductOpera="true"></j-select-equipment-production>
|
</a-form-model-item>
|
|
</a-col>
|
</a-row>
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item v-if="isDepartType == -1" label="系统版本号">
|
<a-input :disabled="disableSubmit" allow-clear placeholder="请输入系统版本号"
|
v-model="model.systemVersion"/>
|
</a-form-model-item>
|
<a-form-model-item v-if="isDepartType == 0" label="设备类型">
|
<a-select :disabled="disableSubmit" placeholder="请选择设备类型"
|
:triggerChange="true"
|
v-model="model.equipmentType">
|
<a-select-option v-for='item in equipmentTypeList' :key='item.id' :value='item.equipmentTypeName'>
|
{{item.equipmentTypeName}}
|
</a-select-option>
|
</a-select>
|
</a-form-model-item>
|
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="设备功率(kw)">
|
<a-input :disabled="disableSubmit" allow-clear placeholder="请输入设备功率"
|
v-model="model.devicePower"/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item label="机床IP">
|
<a-input :disabled="true" placeholder="请输入机床IP"
|
v-model="model.equipmentIp"/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="机床端口">
|
<a-input :disabled="true" placeholder="请输入机床端口"
|
v-model="model.dataPort"/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item label="驱动类型">
|
<j-dict-select-tag :disabled="true" placeholder="请选择驱动类型"
|
:triggerChange="true" dictCode="mdc_driveType"
|
v-model="model.driveType"/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="设备型号">
|
<a-input :disabled="true" allow-clear placeholder="请输入设备型号"
|
v-model="model.equipmentModel"/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item label="系统类型">
|
<j-dict-select-tag placeholder="请选择系统类型" :triggerChange="true" dictCode="system_type"
|
:disabled="disableSubmit" v-model="model.systemType"/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="设备级别">
|
<j-dict-select-tag placeholder="请选择设备级别" dictCode="device_level" v-model="model.deviceLevel"
|
:disabled="disableSubmit"/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row :gutter="24">
|
<a-col :span="12">
|
<a-form-model-item label="设备种类">
|
<j-dict-select-tag placeholder="请选择设备种类" dictCode="device_category" v-model="model.deviceCategory"
|
:disabled="disableSubmit"/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12">
|
<a-form-model-item label="排序">
|
<a-input :disabled="disableSubmit" :readOnly="disableSubmit" placeholder="请输入排序"
|
v-model="model.sortNo" style="width: 100%"/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row :gutter="24">
|
<a-col :span='12'>
|
<a-form-model-item label="配送小组" prop="teamCode">
|
<j-dict-select-tag placeholder="请选择配送小组" dictCode="mdc_staff_team" v-model="model.teamCode"
|
:disabled="disableSubmit"/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span='12'>
|
<a-form-model-item label="设备图片">
|
<j-image-upload v-model="model.equipmentImage" :disabled="disableSubmit"/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row :gutter="24" v-if="systemType">
|
<a-col :span='24'>
|
<a-form-model-item label="系统类型" :labelCol="labelColLong" :wrapperCol="wrapperColLong">
|
<a-radio-group name="radioGroup" v-model="systemValue" :disabled="disableSubmit">
|
<a-radio value="1">DNC</a-radio>
|
<a-radio value="2">MDC</a-radio>
|
<a-radio value="3">通用</a-radio>
|
</a-radio-group>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
|
<a-row :gutter="24">
|
<a-col :span='12'>
|
<a-form-model-item v-if="isDepartType == 0" label="系统版本号">
|
<a-input :disabled="disableSubmit" :readOnly="disableSubmit" allow-clear placeholder="请输入系统版本号"
|
v-model="model.systemVersion"/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
|
<a-row :gutter="24">
|
<a-col :span="24">
|
<a-form-model-item :labelCol="labelColLong" :wrapperCol="wrapperColLong" label="备注">
|
<a-textarea :disabled="disableSubmit" :readOnly="disableSubmit" placeholder="请输入备注"
|
v-model="model.remark"/>
|
</a-form-model-item>
|
</a-col>
|
</a-row>
|
</a-form-model>
|
</a-spin>
|
|
|
<div class="drawer-bottom-button" v-show="!disableSubmit">
|
<a-popconfirm title="确定放弃操作?" @confirm="close" okText="确定" cancelText="取消">
|
<a-button style="margin-right: .8rem">取消</a-button>
|
</a-popconfirm>
|
<a-button @click="handleSubmit" type="primary" :loading="confirmLoading">提交</a-button>
|
</div>
|
<device-list-model ref="deviceListModel" @sendSelectionRows="getDeviceRows"></device-list-model>
|
</a-modal>
|
|
</template>
|
|
<script>
|
import pick from 'lodash.pick'
|
import { getAction } from '@/api/manage'
|
import { addEquipment, editEquipment } from '@/api/api'
|
import JSelectEquipmentProduction from '../../../../../components/jeecgbiz/JSelectEquipmentProduction'
|
import DeviceListModel from './DeviceListModal'
|
import JSelectEquipmentDepart from '../../../../../components/jeecgbiz/JSelectEquipmentDepart'
|
import { mapActions } from 'vuex'
|
|
export default {
|
name: 'UserModal',
|
components: {
|
JSelectEquipmentDepart,
|
JSelectEquipmentProduction,
|
DeviceListModel
|
},
|
data() {
|
return {
|
departDisabled: false, //是否是我的部门调用该页面
|
productionDisabled: false, //是否是我的车间调用该页面
|
roleDisabled: false, //是否是角色维护调用该页面
|
modalWidth: 900,
|
userId: '', //保存用户id
|
disableSubmit: true,
|
form: this.$form.createForm(this),
|
validatorRules: {
|
equipmentId: [{ required: true, message: '请选择设备编号!', trigger: 'change' }],
|
selectedProduction: [{ required: true, message: '请选择车间' }],
|
teamCode: [{ required: true, message: '请选择配送小组' }]
|
},
|
departIdShow: false,
|
title: '操作',
|
visible: false,
|
model: {
|
equipmentId: '',
|
equipmentName: '',
|
equipmentModel: '',
|
equipmentIp: '',
|
dataPort: '',
|
driveType: '',
|
systemType: '',
|
deviceLevel: '',
|
deviceCategory: '',
|
deviceTypeDnc: '',
|
deviceTypeMdc: ''
|
},
|
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,
|
systemType: false,
|
systemValue: '3',
|
url: {
|
userWithDepart: '/mdc/mdcEquipment/equipmentDepartList', // 引入为指定用户查看部门信息需要的url
|
//引入为指定用户查看车间信息需要的url
|
userProductionList: '/mdc/mdcEquipment/equipmentProductionList',
|
syncUserByUserName: '/act/process/extActProcess/doSyncUserByUserName',//同步用户到工作流
|
check: '/sys/duplicate/check',
|
queryEquipmentType: '/mdc/mdcEquipmentType/queryEquipmentType'
|
},
|
nextDepartOptions: [],
|
nextProductionOptions: [],
|
equipmentTypeList: [],
|
isDepartType: ''
|
}
|
},
|
created() {
|
this.queryGroup()
|
this.queryTreeData()
|
this.getAppPlatformName()
|
},
|
methods: {
|
...mapActions(['QueryDepartTree']),
|
queryTreeData() {
|
this.QueryDepartTree().then(res => {
|
if (res.success) {
|
this.isDepartType = res.result[0].value
|
} else {
|
this.$notification.warning({
|
message: '消息',
|
description: res.message
|
})
|
}
|
})
|
},
|
getAppPlatformName() {
|
getAction(`/system/sysParams/query/by/settingKey?settingKey=system_type`).then(res => {
|
if (res.success) {
|
this.systemType = res.result.settingValue === '0'
|
}
|
})
|
},
|
queryGroup() {
|
getAction(this.url.queryEquipmentType).then(res => {
|
if (res.success) {
|
this.equipmentTypeList = res.result
|
} else {
|
this.$notification.warning({
|
message: '消息',
|
description: res.message
|
})
|
}
|
}).finally(() => {
|
this.loading = false
|
})
|
},
|
getDeviceRows(val) {
|
if (val.equipmentid) {
|
this.model.equipmentId = val.equipmentid
|
this.model.equipmentName = val.equipmentname
|
this.model.equipmentModel = val.equipmentmodel
|
this.model.equipmentIp = val.equipmentip
|
this.model.dataPort = val.dataport
|
this.model.driveType = val.drivetype
|
this.model.controlSystem = val.controlsystem
|
this.model.saveTableName = val.savetablename
|
}
|
|
},
|
deviceSearch() {
|
this.$refs.deviceListModel.openPage()
|
this.$refs.deviceListModel.title = '选择设备'
|
this.$refs.deviceListModel.disableSubmit = false
|
},
|
add() {
|
this.refresh()
|
this.edit({
|
activitiSync: '1',
|
userIdentity: 1,
|
equipmentId: '',
|
equipmentName: '',
|
equipmentModel: '',
|
equipmentIp: '',
|
dataPort: '',
|
driveType: '',
|
controlSystem: '',
|
saveTableName: ''
|
})
|
},
|
edit(record) {
|
let that = this
|
that.visible = true
|
//根据屏幕宽度自适应抽屉宽度
|
this.resetScreenSize()
|
|
if (record.systemValue != null) {
|
this.systemValue = record.systemValue
|
} else {
|
this.systemValue = '3'
|
}
|
that.model = Object.assign({}, record)
|
|
this.$nextTick(() => {
|
this.form.setFieldsValue(pick(that.model, 'selectedDeparts', 'selectedProduction', 'equipmentId', 'equipmentName', 'equipmentModel', 'equipmentType', 'equipmentIp', 'dataPort',
|
'driveType', 'sortNo', 'remark', 'systemVersion', 'devicePower', 'controlSystem', 'saveTableName', 'systemValue'))
|
})
|
if (record.hasOwnProperty('id')) {
|
that.getUserDeparts(record.id)
|
}
|
},
|
// 根据屏幕变化,设置抽屉尺寸
|
resetScreenSize() {
|
let screenWidth = document.body.clientWidth
|
if (screenWidth < 900) {
|
this.modalWidth = screenWidth
|
} else {
|
this.modalWidth = 900
|
}
|
},
|
getUserDeparts(userid) {
|
let that = this
|
//部门的url
|
getAction(that.url.userWithDepart, { equipmentId: userid }).then((res) => {
|
if (res.success) {
|
// console.log(res.result)
|
let departOptions = []
|
let selectDepartKeys = []
|
for (let i = 0; i < res.result.length; i++) {
|
selectDepartKeys.push(res.result[i].key)
|
//新增负责部门选择下拉框
|
departOptions.push({
|
value: res.result[i].key,
|
label: res.result[i].title
|
})
|
}
|
|
that.model.selectedDeparts = selectDepartKeys.join(',')
|
that.nextDepartOptions = departOptions
|
}
|
})
|
|
getAction(that.url.userProductionList, { equipmentId: userid }).then((res) => {
|
if (res.success) {
|
// console.log(res.result)
|
let ProductionOptions = []
|
let selectProductKeys = []
|
// console.log(res.result)
|
for (let i = 0; i < res.result.length; i++) {
|
selectProductKeys.push(res.result[i].key)
|
//新增负责部门选择下拉框
|
ProductionOptions.push({
|
value: res.result[i].key,
|
label: res.result[i].title
|
})
|
}
|
|
that.model.selectedProduction = selectProductKeys.join(',')
|
|
that.nextProductionOptions = ProductionOptions
|
}
|
})
|
//车间的url
|
},
|
backDepartInfo(info) {
|
this.model.departIds = this.model.selectedDeparts
|
this.nextDepartOptions = info.map((item, index, arr) => {
|
let c = { label: item.text, value: item.value + '' }
|
return c
|
})
|
},
|
backProductionInfo(info) {
|
this.model.productionIds = this.model.selectedProduction
|
this.nextProductionOptions = info.map((item, index, arr) => {
|
let c = { label: item.text, value: item.value + '' }
|
return c
|
})
|
},
|
|
refresh() {
|
this.userId = ''
|
this.nextDepartOptions = []
|
this.nextProductionOptions = []
|
this.departIdShow = false
|
},
|
close() {
|
this.$emit('close')
|
this.visible = false
|
this.disableSubmit = false
|
this.nextDepartOptions = []
|
this.nextProductionOptions = []
|
this.departIdShow = false
|
},
|
handleSubmit() {
|
const that = this
|
// 触发表单验证
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
that.confirmLoading = true
|
if (this.systemValue == null) {
|
this.$message.warning('请选择系统类型!')
|
return false
|
}
|
let obj
|
if (!this.model.id) {
|
this.model.id = this.userId
|
this.model.systemValue = this.systemValue
|
obj = addEquipment(this.model)
|
} else {
|
this.model.systemValue = this.systemValue
|
obj = editEquipment(this.model, {
|
id: this.model.id
|
})
|
}
|
obj.then((res) => {
|
if (res.success) {
|
that.$notification.success({
|
message: '消息',
|
description: res.message
|
})
|
that.$emit('ok')
|
} else {
|
that.$notification.warning({
|
message: '消息',
|
description: res.message
|
})
|
}
|
}).finally(() => {
|
that.confirmLoading = false
|
that.close()
|
})
|
} else {
|
return false
|
}
|
})
|
},
|
/**
|
* 编辑或查看详情数据时清除抽屉表单验证
|
*/
|
removeValidate() {
|
this.$refs.form.clearValidate()
|
}
|
}
|
|
}
|
</script>
|
|
<style scoped>
|
.avatar-uploader > .ant-upload {
|
width: 104px;
|
height: 104px;
|
}
|
|
.ant-upload-select-picture-card i {
|
font-size: 49px;
|
color: #999;
|
}
|
|
.ant-upload-select-picture-card .ant-upload-text {
|
margin-top: 8px;
|
color: #666;
|
}
|
|
.ant-table-tbody .ant-table-row td {
|
padding-top: 10px;
|
padding-bottom: 10px;
|
}
|
|
.drawer-bottom-button {
|
position: absolute;
|
bottom: -8px;
|
width: 100%;
|
border-top: 1px solid #e8e8e8;
|
padding: 10px 16px;
|
text-align: right;
|
left: 0;
|
background: #fff;
|
border-radius: 0 0 2px 2px;
|
}
|
</style>
|