<template>
|
<el-dialog
|
v-diadrag
|
:title="!dataForm.id ? '新增' : '修改'"
|
:close-on-click-modal="false"
|
:visible.sync="visible"
|
style="min-width: 2000px"
|
>
|
<el-row>
|
<el-form
|
:model="dataForm"
|
:rules="dataRule"
|
ref="dataForm"
|
label-width="100px"
|
class="l-mes"
|
>
|
<el-col :span="12">
|
<el-form-item label="工作站编号" prop="workstationNo">
|
<el-input
|
v-model="dataForm.workstationNo"
|
placeholder="工作站编号"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="工作站名称" prop="name">
|
<el-input
|
v-model="dataForm.name"
|
placeholder="工作站名称"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="备注" prop="remark">
|
<el-input v-model="dataForm.remark" placeholder="备注"></el-input>
|
</el-form-item>
|
<el-form-item label="工作中心" prop="workCenter">
|
<el-select
|
v-model="dataForm.workCenter"
|
placeholder="工作中心"
|
filterable
|
style="width: 100%"
|
>
|
<el-option
|
v-for="item in workCenterOptions"
|
:key="item.id"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
|
<el-col :span="12">
|
<el-form-item label="工作站类型" prop="type">
|
<el-select
|
v-model="dataForm.type"
|
placeholder="工作站类型"
|
filterable
|
style="width: 100%"
|
>
|
<el-option
|
v-for="item in typeOptions"
|
:key="item.id"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="工厂" prop="factoryId">
|
<el-select
|
v-model="dataForm.factoryId"
|
placeholder="工厂"
|
filterable
|
style="width: 100%"
|
>
|
<el-option
|
v-for="item in factoryOptions"
|
:label="item.factoryName"
|
:value="item.id"
|
:key="item.id"
|
></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="人工类型" prop="artificialType">
|
<el-radio-group v-model="dataForm.artificialType">
|
<el-radio :label="false">按组报工</el-radio>
|
<el-radio :label="true">按人员报工</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
</el-col>
|
</el-form>
|
</el-row>
|
<el-row style="width: 100%;">
|
<el-tabs
|
type="card"
|
v-model="activeTabName"
|
ref="tabs"
|
style="height: 400px;width: 100%;"
|
>
|
<el-tab-pane label="设备" name="equip">
|
<el-transfer
|
filterable
|
v-model="ids"
|
ref="workstation"
|
:data="allEquipList"
|
:titles="['未关联', '已关联']"
|
@change="handleChange"
|
>
|
</el-transfer>
|
</el-tab-pane>
|
<el-tab-pane label="线边仓" name="feed">
|
<el-transfer
|
filterable
|
v-model="feedLocationIds"
|
ref="location"
|
:data="allFeedLocation"
|
:titles="['未关联', '已关联']"
|
@change="handleChangeFeedLocation"
|
>
|
</el-transfer>
|
</el-tab-pane>
|
<el-tab-pane label="机台已投料库位" name="fed">
|
<el-transfer
|
filterable
|
v-model="fedLocationIds"
|
ref="location"
|
:data="allLocation"
|
:titles="['未关联', '已关联']"
|
@change="handleChangeFedLocation"
|
>
|
</el-transfer>
|
</el-tab-pane>
|
<el-tab-pane label="产出待检库位" name="inspection">
|
<el-transfer
|
filterable
|
v-model="inspectionLocationIds"
|
ref="location"
|
:data="allLocation"
|
:titles="['未关联', '已关联']"
|
@change="handleChangeInspectionLocation"
|
>
|
</el-transfer>
|
</el-tab-pane>
|
<el-tab-pane label="产出不合格库位" name="disqualified">
|
<el-transfer
|
filterable
|
v-model="disqualifiedLocationIds"
|
ref="location"
|
:data="allLocation"
|
:titles="['未关联', '已关联']"
|
@change="handleChangeDisqualifiedLocation"
|
>
|
</el-transfer>
|
</el-tab-pane>
|
<el-tab-pane label="产出合格库位" name="qualified">
|
<el-transfer
|
filterable
|
v-model="qualifiedLocationIds"
|
ref="location"
|
:data="allLocation"
|
:titles="['未关联', '已关联']"
|
@change="handleChangeQualifiedLocation"
|
>
|
</el-transfer>
|
</el-tab-pane>
|
<!-- <el-tab-pane label="检验待处理库位" name="pending">
|
<el-transfer
|
filterable
|
v-model="pendingLocationIds"
|
ref="location"
|
:data="allLocation"
|
:titles="['未关联', '已关联']"
|
@change="handleChangePendingLocation"
|
>
|
</el-transfer>
|
</el-tab-pane>
|
<el-tab-pane label="成品待检库位" name="product">
|
<el-transfer
|
filterable
|
v-model="productInspectionLocationIds"
|
ref="product"
|
:data="allLocation"
|
:titles="['未关联', '已关联']"
|
@change="handleProductInspectionLocation"
|
>
|
</el-transfer>
|
</el-tab-pane> -->
|
<el-tab-pane label="人工模板" name="handyman">
|
<el-transfer
|
filterable
|
v-model="handymanTypeIds"
|
ref="handyman"
|
:data="allHandyman"
|
:props="{ key: 'id', label: 'templateDescription' }"
|
:titles="['未关联', '已关联']"
|
@change="handleChangeHandyman"
|
>
|
</el-transfer>
|
</el-tab-pane>
|
</el-tabs>
|
</el-row>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="visible = false">取消</el-button>
|
<el-button type="primary" @click="dataFormSubmit()">提交</el-button>
|
</span>
|
</el-dialog>
|
</template>
|
|
<script>
|
import { getObj, addObj, putObj } from '@/api/basic/workstation'
|
import { remote } from '../../../api/admin/dict'
|
import { loadFactoryList } from '@/api/basic/factory'
|
import { loadLocation } from '../../../api/warehouse/location'
|
import { getAllHandymanTemplate } from '../../../api/product/handymantemplate'
|
import { getEquipmentByFactoryId } from '../../../api/basic/workstation'
|
|
export default {
|
data() {
|
return {
|
change: 'false',
|
visible: false,
|
dataForm: {
|
id: 0,
|
workstationNo: '',
|
name: '',
|
type: '',
|
factoryId: '',
|
remark: '',
|
artificialType: '',
|
workCenter: '',
|
workstationEquipment: [],
|
workstationLocation: [],
|
workstationTemplate: [],
|
equipments: [],
|
equipmentIds: [],
|
allEquipmentIds: [],
|
handymanTypeIds: [],
|
productInspectionLocationIds: [],
|
locations: []
|
},
|
dataRule: {
|
workstationNo: [
|
{ required: true, message: '工作站编号不能为空', trigger: 'blur' }
|
],
|
name: [
|
{ required: true, message: '工作站名称不能为空', trigger: 'blur' }
|
],
|
type: [
|
{ required: true, message: '工作站类型不能为空', trigger: 'blur' }
|
],
|
factoryId: [
|
{ required: true, message: '工厂不能为空', trigger: 'blur' }
|
]
|
},
|
allEquipmentIds: [],
|
allData: [],
|
ids: [],
|
handymanTypeIds: [],
|
feedLocationIds: [],
|
fedLocationIds: [],
|
inspectionLocationIds: [],
|
qualifiedLocationIds: [],
|
disqualifiedLocationIds: [],
|
pendingLocationIds: [],
|
productInspectionLocationIds: [],
|
typeOptions: [],
|
factoryOptions: [],
|
allEquipList: [],
|
allFeedLocation: [],
|
allLocation: [],
|
allHandyman: [],
|
myHandyman: [],
|
myEquipList: [],
|
myFeedLocation: [],
|
myFedLocation: [],
|
myInspectionLocation: [],
|
myQualifiedLocation: [],
|
myDisqualifiedLocation: [],
|
myPendingLocation: [],
|
myProductInspectionLocation: [],
|
workstation: [],
|
equipList: [],
|
dataList: [],
|
dataListLoading: false,
|
addOrUpdateVisible: false,
|
workId: '',
|
workstationFactory: {},
|
clickDateArr: [],
|
activeTabName: 'equip',
|
workCenterOptions: []
|
}
|
},
|
created() {
|
this.getType()
|
this.getFactory()
|
this.getWorkCenter()
|
},
|
watch: {
|
'dataForm.factoryId': {
|
handler(newValue, oldValue) {
|
if (!this.dataForm.id) {
|
console.log(1);
|
if (newValue) {
|
this.workstationFactory.factoryId = this.dataForm.factoryId
|
getEquipmentByFactoryId(this.workstationFactory).then(
|
(response) => {
|
this.allEquipList = response.data.data.equipments
|
}
|
)
|
}
|
}
|
},
|
immediate: true,
|
deep: true
|
}
|
},
|
methods: {
|
handleChange(value, direction, movedKeys) {
|
this.myEquipList = value
|
},
|
// 4个库位(投料,待检,不合格,合格)
|
handleChangeFeedLocation(value, direction, movedKeys) {
|
this.myFeedLocation = value
|
},
|
handleChangeFedLocation(value, direction, movedKeys) {
|
if (value && value.length > 1) {
|
this.fedLocationIds = this.myFedLocation
|
this.$message.warning('该库位只能存在一个')
|
} else {
|
this.myFedLocation = value
|
}
|
},
|
handleChangeInspectionLocation(value, direction, movedKeys) {
|
if (value && value.length > 1) {
|
this.inspectionLocationIds = this.myInspectionLocation
|
this.$message.warning('该库位只能存在一个')
|
} else {
|
this.myInspectionLocation = value
|
}
|
},
|
handleChangeQualifiedLocation(value, direction, movedKeys) {
|
// if (value && value.length > 1) {
|
// this.qualifiedLocationIds = this.myQualifiedLocation
|
// this.$message.warning('该库位只能存在一个')
|
// } else {
|
this.myQualifiedLocation = value
|
// }
|
},
|
handleChangeDisqualifiedLocation(value, direction, movedKeys) {
|
if (value && value.length > 1) {
|
this.disqualifiedLocationIds = this.myDisqualifiedLocation
|
this.$message.warning('该库位只能存在一个')
|
} else {
|
this.myDisqualifiedLocation = value
|
}
|
},
|
handleChangePendingLocation(value, direction, movedKeys) {
|
if (value && value.length > 1) {
|
this.pendingLocationIds = this.myPendingLocation
|
this.$message.warning('该库位只能存在一个')
|
} else {
|
this.myPendingLocation = value
|
}
|
},
|
handleProductInspectionLocation(value, direction, movedKeys) {
|
if (value && value.length > 1) {
|
this.productInspectionLocationIds = this.myProductInspectionLocation
|
this.$message.warning('该库位只能存在一个')
|
} else {
|
this.myProductInspectionLocation = value
|
}
|
},
|
handleChangeHandyman(value, direction, movedKeys) {
|
this.myHandyman = value
|
},
|
getFactory() {
|
loadFactoryList().then((res) => {
|
this.factoryOptions = res.data
|
})
|
},
|
getType() {
|
remote('workstation_type').then((response) => {
|
if (response.data.code === 0) {
|
this.typeOptions = response.data.data
|
}
|
})
|
},
|
getWorkCenter() {
|
remote('work_center_type').then((response) => {
|
if (response.data.code === 0) {
|
this.workCenterOptions = response.data.data
|
this.workCenterOptions.forEach((item) => {
|
item.label = '(' + item.value + ') ' + item.label
|
})
|
}
|
})
|
},
|
init(id) {
|
this.dataForm.id = id || 0
|
this.visible = true
|
this.addVisible = true
|
// 清空数据源
|
this.allEquipList = []
|
this.allFeedLocation = []
|
this.allLocation = []
|
this.allHandyman = []
|
this.myEquipList = []
|
this.myFeedLocation = []
|
this.myFedLocation = []
|
this.myInspectionLocation = []
|
this.myQualifiedLocation = []
|
this.myDisqualifiedLocation = []
|
this.myPendingLocation = []
|
this.myProductInspectionLocation = []
|
this.myHandyman = []
|
this.clickDateArr = []
|
this.$nextTick(() => {
|
// 清空穿梭框
|
this.$refs.dataForm.resetFields()
|
getObj(this.dataForm.id).then((response) => {
|
if (this.dataForm) {
|
this.dataForm = response.data.data
|
console.log(this.dataForm)
|
this.allEquipList = this.dataForm.equipments
|
this.allFeedLocation = this.dataForm.locations
|
this.allLocation = JSON.parse(
|
JSON.stringify(this.dataForm.locations)
|
)
|
this.allLocation.forEach((e) => (e.disabled = false))
|
getAllHandymanTemplate().then((res) => {
|
this.allHandyman = res.data.data
|
})
|
this.ids = this.dataForm.equipmentIds
|
? this.dataForm.equipmentIds
|
: []
|
this.feedLocationIds = this.dataForm.feedLocationIds
|
? this.dataForm.feedLocationIds
|
: []
|
this.fedLocationIds = this.dataForm.fedLocationIds
|
? this.dataForm.fedLocationIds
|
: []
|
|
this.inspectionLocationIds = this.dataForm.inspectionLocationIds
|
? this.dataForm.inspectionLocationIds
|
: []
|
this.qualifiedLocationIds = this.dataForm.qualifiedLocationIds
|
? this.dataForm.qualifiedLocationIds
|
: []
|
this.disqualifiedLocationIds = this.dataForm.disqualifiedLocationIds
|
? this.dataForm.disqualifiedLocationIds
|
: []
|
this.pendingLocationIds = this.dataForm.inspToDealLocationIds
|
? this.dataForm.inspToDealLocationIds
|
: []
|
this.handymanTypeIds = this.dataForm.handymanTypeIds
|
? this.dataForm.handymanTypeIds
|
: []
|
this.productInspectionLocationIds = this.dataForm
|
.productInspectionLocationIds
|
? this.dataForm.productInspectionLocationIds
|
: []
|
this.myEquipList = this.ids
|
this.myFeedLocation = this.feedLocationIds
|
this.myFedLocation = this.fedLocationIds
|
this.myInspectionLocation = this.inspectionLocationIds
|
this.myQualifiedLocation = this.qualifiedLocationIds
|
this.myDisqualifiedLocation = this.disqualifiedLocationIds
|
this.myPendingLocation = this.pendingLocationIds
|
this.myHandyman = this.handymanTypeIds
|
this.myProductInspectionLocation = this.productInspectionLocationIds
|
}
|
})
|
})
|
},
|
// 表单提交
|
dataFormSubmit() {
|
var canClickFlag = true
|
this.clickDateArr.push(new Date().getTime())
|
if (this.clickDateArr.length > 1) {
|
if (
|
this.clickDateArr[this.clickDateArr.length - 1] -
|
this.clickDateArr[this.clickDateArr.length - 2] <
|
2000
|
) {
|
// 小于2秒则认为重复提交
|
canClickFlag = false
|
}
|
}
|
if (canClickFlag) {
|
this.$refs.dataForm.validate((valid) => {
|
if (valid) {
|
const upEquipmentList = new Array()
|
for (let i = 0; i < this.myEquipList.length; i++) {
|
upEquipmentList.push(
|
Object.assign({
|
equipmentId: this.myEquipList[i],
|
workstationId: this.dataForm.id
|
})
|
)
|
}
|
this.dataForm.workstationEquipment = upEquipmentList
|
const workstationLocationList = []
|
for (let i = 0; i < this.myFeedLocation.length; i++) {
|
workstationLocationList.push(
|
Object.assign({
|
locationId: this.myFeedLocation[i],
|
workstationId: this.dataForm.id,
|
locationType: 1
|
})
|
)
|
}
|
this.myInspectionLocation.forEach((id) => {
|
workstationLocationList.push(
|
Object.assign({
|
locationId: id,
|
workstationId: this.dataForm.id,
|
locationType: 2
|
})
|
)
|
})
|
this.myQualifiedLocation.forEach((id) => {
|
workstationLocationList.push(
|
Object.assign({
|
locationId: id,
|
workstationId: this.dataForm.id,
|
locationType: 4
|
})
|
)
|
})
|
this.myDisqualifiedLocation.forEach((id) => {
|
workstationLocationList.push(
|
Object.assign({
|
locationId: id,
|
workstationId: this.dataForm.id,
|
locationType: 3
|
})
|
)
|
})
|
this.myFedLocation.forEach((id) => {
|
workstationLocationList.push(
|
Object.assign({
|
locationId: id,
|
workstationId: this.dataForm.id,
|
locationType: 5
|
})
|
)
|
})
|
this.myPendingLocation.forEach((id) => {
|
workstationLocationList.push(
|
Object.assign({
|
locationId: id,
|
workstationId: this.dataForm.id,
|
locationType: 6
|
})
|
)
|
})
|
this.myProductInspectionLocation.forEach((id) => {
|
workstationLocationList.push(
|
Object.assign({
|
locationId: id,
|
workstationId: this.dataForm.id,
|
locationType: 9
|
})
|
)
|
})
|
|
this.dataForm.workstationLocation = workstationLocationList
|
|
const workstationTemplateList = []
|
for (let i = 0; i < this.myHandyman.length; i++) {
|
workstationTemplateList.push(
|
Object.assign({
|
handymanTemplateId: this.myHandyman[i],
|
workstationId: this.dataForm.id
|
})
|
)
|
}
|
this.dataForm.workstationTemplate = workstationTemplateList
|
if (this.dataForm.id) {
|
putObj(this.dataForm).then((data) => {
|
this.$message.success('修改成功')
|
this.visible = false
|
this.$emit('refreshDataList')
|
})
|
} else {
|
addObj(this.dataForm).then((data) => {
|
this.$message.success('添加成功')
|
this.visible = false
|
this.$emit('refreshDataList')
|
})
|
}
|
}
|
})
|
}
|
}
|
}
|
}
|
</script>
|
<style scoped>
|
|
</style>
|