<template>
|
<GlobalWindow
|
:title="title"
|
:visible.sync="visible"
|
:confirm-working="isWorking"
|
@confirm="confirm"
|
>
|
<el-form :model="form" ref="form" :rules="rules">
|
<el-form-item label="设备编码:" prop="code">
|
<el-input v-model="form.code" :disabled="form.id" placeholder="可填写,忽略将自动生成" v-trim/>
|
</el-form-item>
|
<el-form-item label="设备名称:" prop="name">
|
<el-input v-model="form.name" placeholder="请输入设备名称" v-trim/>
|
</el-form-item>
|
<el-form-item label="设备型号:" prop="model">
|
<el-input v-model="form.model" placeholder="请输入设备型号" v-trim/>
|
</el-form-item>
|
<el-form-item label="所属工序:" prop="procedureId">
|
<el-select style="width:48%;" v-model="factory" @visible-change="visibleChange" :loading="loading" placeholder="请选择工厂" filterable clearable @change="selectFactory">
|
<el-option
|
v-for="item in factoreis"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
<div style="width:4%;display: inline-block;"></div>
|
<el-select style="width:48%" v-model="form.procedureId" placeholder="请选择工序" filterable clearable @change="selectProcedure">
|
<el-option
|
v-for="item in productes"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<!-- <el-select v-model="form.procedureId" placeholder="请选择" @change="selectProcedure">
|
<el-option
|
v-for="item in productes"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id">
|
</el-option>
|
</el-select>
|
</el-form-item> -->
|
<!-- <el-form-item label="关联货位" prop="updateTime">
|
<el-select v-model="form.updateTime" placeholder="请选择">
|
<el-option
|
v-for="item in options"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value">
|
</el-option>
|
</el-select>
|
</el-form-item> -->
|
<el-form-item label="设备类型" prop="type">
|
<el-select v-model="form.type" placeholder="请选择设备类型" filterable clearable @change="selectType">
|
<el-option
|
v-for="item in level"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item v-if="form.type==1" label="所属设备组:" prop="groupId">
|
<el-select v-model="form.groupId" placeholder="请选择设备组" filterable clearable @change="selectGroup">
|
<el-option
|
v-for="item in diveGroup"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="关联待生产货位:" prop="produceWarehouseLocationId">
|
<el-select style="width:48%;" v-model="produceWarehouse" placeholder="请选择仓库" @visible-change="visibleChange1" :loading="loading" filterable clearable :disabled="canSelect" @change="selectProduceWarehouse">
|
<el-option
|
v-for="item in warehousesone"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
<div style="width:4%;display: inline-block;"></div>
|
<el-select style="width:48%" v-model="form.produceWarehouseLocationId" filterable clearable :disabled="canSelect" placeholder="请选择">
|
<el-option
|
v-for="item in produceWarehouseLocation"
|
:key="item.id"
|
:label="item.unionName"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="关联已完工货位:" prop="finishWarehouseLocationId">
|
<el-select style="width:48%;" v-model="finishWarehouse" placeholder="请选择仓库" @visible-change="visibleChange2" :loading="loading" filterable clearable :disabled="canSelect" @change="selectFinishWarehouse">
|
<el-option
|
v-for="item in warehouses"
|
:key="item.id"
|
:label="item.name"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
<div style="width:4%;display: inline-block;"></div>
|
<el-select style="width:48%" v-model="form.finishWarehouseLocationId" filterable clearable :disabled="canSelect" placeholder="请选择">
|
<el-option
|
v-for="item in finishWarehouserLocation"
|
:key="item.id"
|
:label="item.unionName"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="所属员工:" prop="userIds">
|
<el-select v-model="form.userIds" @visible-change="visibleChange3" :loading="loading" multiple clearable filterable placeholder="请选择" @change="selectUser">
|
<el-option
|
v-for="(item, index) in user"
|
:key="item.id"
|
:label="index==0?'全部':(item.name + '-' + item.dmodel.name + '-' + item.phone)"
|
:value="item.id">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="工位编号:" prop="stationCode">
|
<el-input v-model="form.stationCode" placeholder="请输入工位编号" v-trim/>
|
</el-form-item>
|
</el-form>
|
</GlobalWindow>
|
</template>
|
|
<script>
|
import BaseOpera from '@/components/base/BaseOpera'
|
import GlobalWindow from '@/components/common/GlobalWindow'
|
import { productesGroup } from '@/api/ext/proceduresExt'
|
import { equipmentGroup } from '@/api/ext/deviceExt'
|
import { queryWarehouseAllData } from '@/api/ext/warehouseExt'
|
import { getDepartmentListByConditon } from '@/api/ext/departmentExt'
|
import { validateSpecialKey } from '@/assets/js/validate'
|
import { getListByWarehouseId } from '@/api/ext/warehouseLocationExt'
|
import { companyUserExtAllUser as getUserDevice } from '@/api/ext/companyUserExt'
|
export default {
|
name: 'OperaDeviceExtWindow',
|
extends: BaseOpera,
|
components: { GlobalWindow },
|
data () {
|
return {
|
options: [
|
{ label: '测试一', value: 'a' },
|
{ label: '测试二', value: 'w' }
|
],
|
loading: false,
|
factoreis: [],
|
factory: null,
|
productes: [],
|
diveGroup: [],
|
user: [],
|
level: [
|
// 0设备 1组
|
{ name: '设备', id: 1 },
|
{ name: '设备组', id: 0 }
|
],
|
// 表单数据
|
form: {
|
id: null,
|
// updateTime: '',
|
procedureId: '',
|
code: '',
|
type: '',
|
name: '',
|
model: '',
|
stationCode: '',
|
groupId: null,
|
userIds: [],
|
produceWarehouseLocationId: null,
|
finishWarehouseLocationId: null
|
},
|
warehouses: [],
|
warehousesone: [],
|
produceWarehouse: null,
|
produceWarehouseLocation: [],
|
finishWarehouse: null,
|
finishWarehouserLocation: [],
|
// 验证规则
|
rules: {
|
// code: [
|
// { required: true, message: '请输入设备编码', trigger: 'blur' },
|
// { max: 20, message: '输入字数不超过20', trigger: 'blur' },
|
// { validator: validateSpecialKey, trigger: 'blur' }
|
// ],
|
name: [
|
{ required: true, message: '请输入设备名称', trigger: 'blur' },
|
{ max: 20, message: '输入字数不超过20', trigger: 'blur' }
|
],
|
model: [
|
{ required: false, message: '请输入设型号', trigger: 'blur' },
|
{ max: 20, message: '输入字数不超过20', trigger: 'blur' }
|
],
|
procedureId: [{ required: true, message: '请选择工序', trigger: 'change' }],
|
type: [{ required: true, message: '请选择设备类型', trigger: 'change' }],
|
produceWarehouseLocationId: [{ required: true, message: '请选择待生产货位', trigger: 'change' }],
|
finishWarehouseLocationId: [{ required: true, message: '请选择已完工货位', trigger: 'change' }]
|
}
|
}
|
},
|
computed: {
|
canSelect: {
|
get () {
|
if (this.form.groupId) {
|
return true
|
}
|
return false
|
}
|
}
|
},
|
created () {
|
this.config({
|
api: '/ext/deviceExt',
|
'field.id': 'id'
|
})
|
// equipmentGroup({})
|
// .then(res => {
|
// this.diveGroup = res
|
// })
|
// .catch(err => {
|
// console.log(err)
|
// })
|
this.form.type=1;
|
},
|
methods: {
|
confirm() {
|
if (this.form.id == null || this.form.id === '') {
|
this.$refs.form.validate((valid) => {
|
if (!valid) {
|
return
|
}
|
// 调用新建接口
|
this.isWorking = true
|
let data = JSON.parse(JSON.stringify(this.form))
|
data.userIds = data.userIds.join(',')
|
this.api.create(data)
|
.then(() => {
|
this.visible = false
|
this.$tip.apiSuccess('新建成功')
|
this.$emit('success')
|
})
|
.catch(e => {
|
this.$tip.apiFailed(e)
|
})
|
.finally(() => {
|
this.isWorking = false
|
})
|
})
|
} else {
|
this.$refs.form.validate((valid) => {
|
if (!valid) {
|
return
|
}
|
// 调用更新接口
|
this.isWorking = true
|
let data = JSON.parse(JSON.stringify(this.form))
|
data.userIds = data.userIds.join(',')
|
this.api.updateById(data)
|
.then(() => {
|
this.visible = false
|
this.$tip.apiSuccess('修改成功')
|
this.$emit('success')
|
})
|
.catch(e => {
|
this.$tip.apiFailed(e)
|
})
|
.finally(() => {
|
this.isWorking = false
|
})
|
})
|
}
|
},
|
selectUser (v) {
|
if (v.indexOf('all') != -1) {
|
let all = this.user.map(item => item.id)
|
this.form.userIds = all.filter(item => item != 'all')
|
}
|
},
|
visibleChange3(e) {
|
// if (e) {
|
// this.loading = true
|
getUserDevice({ departmentId: this.$store.state.userInfo.curComDepartment.id })
|
.then(res => {
|
if (res.length > 0) {
|
this.user = [{ id: 'all' }, ...res]
|
}
|
this.loading = false
|
})
|
.catch(err => {
|
console.log(err)
|
this.loading = false
|
})
|
// }
|
},
|
visibleChange2(e) {
|
if (e) {
|
this.loading = true
|
queryWarehouseAllData({
|
useLocation: 1,
|
status: 1,
|
systemDicDataId: 7,
|
rootDepartId: this.$store.state.userInfo.curComDepartment.id
|
})
|
.then(res => {
|
this.warehouses = res
|
this.loading = false
|
})
|
.catch(err => {
|
console.log(err)
|
this.loading = false
|
})
|
}
|
},
|
visibleChange1(e) {
|
if (e) {
|
this.loading = true
|
queryWarehouseAllData({
|
useLocation: 1,
|
status: 1,
|
rootDepartId: this.$store.state.userInfo.curComDepartment.id
|
})
|
.then(res => {
|
this.warehousesone = res
|
this.loading = false
|
})
|
.catch(err => {
|
console.log(err)
|
this.loading = false
|
})
|
}
|
},
|
visibleChange(e) {
|
if (e) {
|
this.loading = true
|
getDepartmentListByConditon({
|
type: 1
|
})
|
.then(res => {
|
// console.log(res)
|
this.factoreis = res
|
this.loading = false
|
})
|
.catch(err => {
|
console.log(err)
|
this.loading = false
|
})
|
}
|
},
|
open (title, target) {
|
this.visibleChange3(true)
|
this.visibleChange2(true)
|
this.visibleChange1(true)
|
this.visibleChange(true)
|
this.title = title
|
this.visible = true
|
this.produceWarehouse = null
|
this.finishWarehouse = null
|
this.factory = null
|
this.productes = []
|
this.produceWarehouseLocation = []
|
this.finishWarehouserLocation = []
|
// 新建
|
if (target == null) {
|
this.$nextTick(() => {
|
this.$refs.form.resetFields()
|
this.form[this.configData['field.id']] = null
|
})
|
return
|
}
|
// 编辑
|
this.$nextTick(() => {
|
for (const key in this.form) {
|
if (key == 'userIds') {
|
this.form.userIds = target['userDeviceExtListVOS'].map(item => item.companyUserId)
|
console.log(this.form.userIds)
|
} else {
|
this.form[key] = target[key]
|
}
|
}
|
// console.log(this.form)
|
this.produceWarehouse = target.wpmodel.warehouseId
|
this.finishWarehouse = target.wfmodel.warehouseId
|
this.factory = target.pmodel.orgId
|
this.getProcedure(target.pmodel.orgId)
|
this.getDevice()
|
this.wareHouserAndLocaltion(target.wpmodel.warehouseId, 0)
|
this.wareHouserAndLocaltion(target.wfmodel.warehouseId, 1)
|
})
|
},
|
selectFactory (v) {
|
this.form.procedureId = null
|
this.getProcedure(v)
|
},
|
getProcedure (v) {
|
productesGroup({ orgId: v })
|
.then(res => {
|
this.productes = res
|
})
|
.catch(err => {
|
console.log(err)
|
})
|
},
|
selectProduceWarehouse (v) {
|
this.form.produceWarehouseLocationId = null
|
this.wareHouserAndLocaltion(v, 0, '')
|
},
|
selectFinishWarehouse (v) {
|
this.form.finishWarehouseLocationId = null
|
this.wareHouserAndLocaltion(v, 1, 7)
|
},
|
selectProcedure (v) {
|
if (this.form.type === 1 && v) {
|
this.diveGroup = []
|
this.getDevice()
|
}
|
},
|
selectType (v) {
|
this.produceWarehouse = null
|
this.finishWarehouse = null
|
this.form.finishWarehouseLocationId = null
|
this.form.produceWarehouseLocationId = null
|
this.produceWarehouseLocation = []
|
this.finishWarehouserLocation = []
|
if (v === 1 && this.form.procedureId) {
|
this.getDevice()
|
} else {
|
this.form.groupId = null
|
}
|
},
|
getDevice () {
|
equipmentGroup({
|
type: 0,
|
procedureId: this.form.procedureId
|
})
|
.then(res => {
|
this.diveGroup = res
|
})
|
.catch(err => {
|
console.log(err)
|
})
|
},
|
selectGroup (v) {
|
for (const item of this.diveGroup) {
|
if (item.id === v) {
|
this.setLocation(item)
|
return
|
}
|
}
|
},
|
setLocation (group) {
|
this.produceWarehouse = group.wpmodel.warehouseId
|
this.finishWarehouse = group.wfmodel.warehouseId
|
this.form.finishWarehouseLocationId = group.wfmodel.id
|
this.form.produceWarehouseLocationId = group.wpmodel.id
|
this.wareHouserAndLocaltion(group.wpmodel.warehouseId, 0)
|
this.wareHouserAndLocaltion(group.wfmodel.warehouseId, 1)
|
},
|
/**
|
* @param type 0 待产货位 1产出货位
|
*/
|
wareHouserAndLocaltion (v, type, systemDicDataId) {
|
getListByWarehouseId(v, 1, systemDicDataId)
|
.then(res => {
|
// console.log(res)
|
if (type === 0) {
|
this.produceWarehouseLocation = res
|
} else {
|
this.finishWarehouserLocation = res
|
}
|
})
|
.catch(err => {
|
console.log(err)
|
})
|
}
|
}
|
}
|
</script>
|