工作站设置设备资源

This commit is contained in:
JinLu.Yin 2022-05-12 16:06:49 +08:00
parent 1629e7f625
commit 5d549525ad
6 changed files with 775 additions and 7 deletions

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询设备资源列表
export function listWorkstationmachine(query) {
return request({
url: '/mes/md/workstationmachine/list',
method: 'get',
params: query
})
}
// 查询设备资源详细
export function getWorkstationmachine(recordId) {
return request({
url: '/mes/md/workstationmachine/' + recordId,
method: 'get'
})
}
// 新增设备资源
export function addWorkstationmachine(data) {
return request({
url: '/mes/md/workstationmachine',
method: 'post',
data: data
})
}
// 修改设备资源
export function updateWorkstationmachine(data) {
return request({
url: '/mes/md/workstationmachine',
method: 'put',
data: data
})
}
// 删除设备资源
export function delWorkstationmachine(recordId) {
return request({
url: '/mes/md/workstationmachine/' + recordId,
method: 'delete'
})
}

View File

@ -103,7 +103,7 @@ import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "MdItem",
name: "MdItemSelect",
dicts: ['sys_yes_no','mes_item_product'],
components: { Treeselect },
data() {

View File

@ -0,0 +1,251 @@
<template>
<el-dialog title="设备选择"
v-if="showFlag"
:visible.sync="showFlag"
:modal= false
width="80%"
center
>
<el-row :gutter="20">
<!--分类数据-->
<el-col :span="4" :xs="24">
<div class="head-container">
<el-input
v-model="machineryTypeName"
placeholder="请输入分类名称"
clearable
size="small"
prefix-icon="el-icon-search"
style="margin-bottom: 20px"
/>
</div>
<div class="head-container">
<el-tree
:data="machineryTypeOptions"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree"
default-expand-all
@node-click="handleNodeClick"
/>
</div>
</el-col>
<!--设备数据-->
<el-col :span="20" :xs="24">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="设备编码" prop="machineryCode">
<el-input
v-model="queryParams.machineryCode"
placeholder="请输入设备编码"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="设备名称" prop="machineryName">
<el-input
v-model="queryParams.machineryName"
placeholder="请输入设备名称"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="machineryList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="设备编码" width = "120" align="center" key="machineryCode" prop="machineryCode">
</el-table-column>
<el-table-column label="设备名称" min-width="120" align="left" key="machineryName" prop="machineryName" :show-overflow-tooltip="true" />
<el-table-column label="品牌" align="left" key="machineryBrand" prop="machineryBrand" :show-overflow-tooltip="true" />
<el-table-column label="规格型号" align="left" key="machinerySpec" prop="machinerySpec" :show-overflow-tooltip="true" />
<el-table-column label="所属车间" align="center" key="machineryTypeName" prop="machineryTypeName" :show-overflow-tooltip="true" />
<el-table-column label="设备状态" align="center" key="status" prop="status" >
<template slot-scope="scope">
<dict-tag :options="dict.type.mes_machinery_status" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="160">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-col>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmSelect"> </el-button>
<el-button @click="showFlag=false"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { listMachinery, getMachinery, delMachinery, addMachinery, updateMachinery } from "@/api/mes/dv/machinery";
import { listMachinerytype } from "@/api/mes/dv/machinerytype";
import { listAllWorkshop } from "@/api/mes/md/workshop";
import { getToken } from "@/utils/auth";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "MachinerySelect",
dicts: ['sys_yes_no','mes_machinery_status'],
components: { Treeselect },
data() {
return {
showFlag: false,
//
loading: true,
//
ids: [],
selectedRows: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
machineryList: [],
//
title: "",
//
machineryTypeOptions: [],
//
workshopOptions:[],
//
open: false,
//
machineryTypeName: undefined,
//
autoGenFlag: false,
//
form: {},
defaultProps: {
children: "children",
label: "machineryTypeName"
},
//
queryParams: {
pageNum: 1,
pageSize: 10,
machineryCode: null,
machineryName: null,
machineryBrand: null,
machinerySpec: null,
machineryTypeId: null,
machineryTypeCode: null,
machineryTypeName: null,
workshopId: null,
workshopCode: null,
workshopName: null,
status: null
}
};
},
watch: {
//
machineryTypeName(val) {
this.$refs.tree.filter(val);
}
},
created() {
this.getList();
this.getTreeselect();
},
methods: {
/** 查询物料编码列表 */
getList() {
this.loading = true;
listMachinery(this.queryParams).then(response => {
this.machineryList = response.rows;
this.total = response.total;
this.loading = false;
}
);
},
getWorkshops(){
listAllWorkshop().then( response => {
debugger;
this.workshopOptions =response.data;
});
},
/** 转换设备类型数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.machineryTypeId,
label: node.machineryTypeName,
children: node.children
};
},
/** 查询设备类型下拉树结构 */
getTreeselect() {
listMachinerytype().then(response => {
debugger;
this.machineryTypeOptions = [];
const data = this.handleTree(response.data, "machineryTypeId", "parentTypeId")[0];
this.machineryTypeOptions.push(data);
});
},
//
filterNode(value, data) {
if (!value) return true;
return data.machineryTypeName.indexOf(value) !== -1;
},
//
handleNodeClick(data) {
this.queryParams.machineryTypeId = data.machineryTypeId;
this.handleQuery();
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.machineryId);
this.single = selection.length != 1;
this.multiple = !selection.length;
},
//
confirmSelect(){
if(this.ids ==[] || this.ids.length==0){
this.$notify({
title:'提示',
type:'warning',
message: '请至少选择一条数据!'
});
return;
}
this.$emit('onSelected',this.selectedRows);
this.showFlag = false;
}
}
};
</script>

View File

@ -0,0 +1,268 @@
<template>
<el-dialog title="设备选择"
v-if="showFlag"
:visible.sync="showFlag"
:modal= false
width="80%"
center
>
<el-row :gutter="20">
<!--分类数据-->
<el-col :span="4" :xs="24">
<div class="head-container">
<el-input
v-model="machineryTypeName"
placeholder="请输入分类名称"
clearable
size="small"
prefix-icon="el-icon-search"
style="margin-bottom: 20px"
/>
</div>
<div class="head-container">
<el-tree
:data="machineryTypeOptions"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree"
default-expand-all
@node-click="handleNodeClick"
/>
</div>
</el-col>
<!--设备数据-->
<el-col :span="20" :xs="24">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="设备编码" prop="machineryCode">
<el-input
v-model="queryParams.machineryCode"
placeholder="请输入设备编码"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="设备名称" prop="machineryName">
<el-input
v-model="queryParams.machineryName"
placeholder="请输入设备名称"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="machineryList" @current-change="handleCurrent" @row-dblclick="handleRowDbClick">
<el-table-column width="50" align="center" >
<template v-slot="scope">
<el-radio v-model="selectedMachineryId" :label="scope.row.machineryId" @change="handleRowChange(scope.row)">{{""}}</el-radio>
</template>
</el-table-column>
<el-table-column label="设备编码" width = "120" align="center" key="machineryCode" prop="machineryCode">
</el-table-column>
<el-table-column label="设备名称" min-width="120" align="left" key="machineryName" prop="machineryName" :show-overflow-tooltip="true" />
<el-table-column label="品牌" align="left" key="machineryBrand" prop="machineryBrand" :show-overflow-tooltip="true" />
<el-table-column label="规格型号" align="left" key="machinerySpec" prop="machinerySpec" :show-overflow-tooltip="true" />
<el-table-column label="所属车间" align="center" key="machineryTypeName" prop="machineryTypeName" :show-overflow-tooltip="true" />
<el-table-column label="设备状态" align="center" key="status" prop="status" >
<template slot-scope="scope">
<dict-tag :options="dict.type.mes_machinery_status" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="160">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-col>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmSelect"> </el-button>
<el-button @click="showFlag=false"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { listMachinery, getMachinery, delMachinery, addMachinery, updateMachinery } from "@/api/mes/dv/machinery";
import { listMachinerytype } from "@/api/mes/dv/machinerytype";
import { listAllWorkshop } from "@/api/mes/md/workshop";
import { getToken } from "@/utils/auth";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "MachinerySelectSingle",
dicts: ['sys_yes_no','mes_machinery_status'],
components: { Treeselect },
data() {
return {
showFlag: false,
//
loading: true,
//
selectedMachineryId: undefined,
selectedRows: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
machineryList: [],
//
title: "",
//
machineryTypeOptions: [],
//
workshopOptions:[],
//
open: false,
//
machineryTypeName: undefined,
//
autoGenFlag: false,
//
form: {},
defaultProps: {
children: "children",
label: "machineryTypeName"
},
//
queryParams: {
pageNum: 1,
pageSize: 10,
machineryCode: null,
machineryName: null,
machineryBrand: null,
machinerySpec: null,
machineryTypeId: null,
machineryTypeCode: null,
machineryTypeName: null,
workshopId: null,
workshopCode: null,
workshopName: null,
status: null
}
};
},
watch: {
//
machineryTypeName(val) {
this.$refs.tree.filter(val);
}
},
created() {
this.getList();
this.getTreeselect();
},
methods: {
/** 查询物料编码列表 */
getList() {
this.loading = true;
listMachinery(this.queryParams).then(response => {
this.machineryList = response.rows;
this.total = response.total;
this.loading = false;
}
);
},
getWorkshops(){
listAllWorkshop().then( response => {
debugger;
this.workshopOptions =response.data;
});
},
/** 转换设备类型数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.machineryTypeId,
label: node.machineryTypeName,
children: node.children
};
},
/** 查询设备类型下拉树结构 */
getTreeselect() {
listMachinerytype().then(response => {
debugger;
this.machineryTypeOptions = [];
const data = this.handleTree(response.data, "machineryTypeId", "parentTypeId")[0];
this.machineryTypeOptions.push(data);
});
},
//
filterNode(value, data) {
if (!value) return true;
return data.machineryTypeName.indexOf(value) !== -1;
},
//
handleNodeClick(data) {
this.queryParams.machineryTypeId = data.machineryTypeId;
this.handleQuery();
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
handleCurrent(row){
if(row){
this.selectedRows = row;
}
},
//
handleRowDbClick(row){
if(row){
this.selectedRows = row;
this.$emit('onSelected',this.selectedRows);
this.showFlag = false;
}
},
//
handleRowChange(row) {
if(row){
this.selectedRows = row;
}
},
//
confirmSelect(){
if(this.selectedMachineryId == null || this.selectedMachineryId == 0){
this.$notify({
title:'提示',
type:'warning',
message: '请至少选择一条数据!'
});
return;
}
this.$emit('onSelected',this.selectedRows);
this.showFlag = false;
}
}
};
</script>

View File

@ -0,0 +1,146 @@
<template>
<div class="app-container">
<el-table v-loading="loading" :data="workstationmachineList">
<el-table-column label="设备编号" align="center" prop="machineryCode" />
<el-table-column label="设备名称" align="center" width="150px" prop="machineryName" />
<el-table-column label="数量" width="50px" align="center" prop="quantity" />
<el-table-column label="操作" v-if="optType !='view'" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['md:workstationmachine:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
import { listWorkstationmachine, getWorkstationmachine, delWorkstationmachine, addWorkstationmachine, updateWorkstationmachine } from "@/api/mes/md/workstationmachine";
export default {
name: "Workstationmachine",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
workstationmachineList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
workstationId: null,
machineId: null,
machineCode: null,
machineName: null,
quantity: null,
},
//
form: {}
};
},
props: {
workstationId: undefined,
optType: undefined,
},
created() {
this.getList();
},
methods: {
/** 查询设备资源列表 */
getList() {
this.loading = true;
this.queryParams.workstationId = this.workstationId;
listWorkstationmachine(this.queryParams).then(response => {
this.workstationmachineList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
reset() {
this.form = {
recordId: null,
workstationId: null,
machineId: null,
machineCode: null,
machineName: null,
quantity: null,
remark: null,
attr1: null,
attr2: null,
attr3: null,
attr4: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null
};
this.resetForm("form");
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.recordId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加设备资源";
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.recordId != null) {
updateWorkstationmachine(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addWorkstationmachine(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const recordIds = row.recordId || this.ids;
this.$modal.confirm('是否确认删除设备资源?').then(function() {
return delWorkstationmachine(recordIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
}
};
</script>

View File

@ -103,7 +103,7 @@
<el-table v-loading="loading" :data="workstationList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="工作站编" align="center" prop="workstationCode" >
<el-table-column label="工作站编" align="center" prop="workstationCode" >
<template slot-scope="scope">
<el-button
type="text"
@ -155,7 +155,7 @@
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-row>
<el-col :span="8">
<el-form-item label="工作站编" prop="workstationCode">
<el-form-item label="工作站编" prop="workstationCode">
<el-input v-model="form.workstationCode" placeholder="请输入工作站编码" />
</el-form-item>
</el-col>
@ -233,10 +233,45 @@
</el-col>
</el-row>
</el-form>
<el-divider content-position="center" v-if="form.workstationId !=null">工作站资源</el-divider>
<MachinerySelectSingle ref="machinerySelect" @onSelected="onMachineryAdd"></MachinerySelectSingle>
<el-row v-if="form.workstationId !=null">
<el-col :span=24>
<el-carousel trigger="click" type="card" :autoplay="false" height="300px">
<el-carousel-item>
<el-card shadow="always" style="width:450px">
<div slot="header">
<span>设备资源</span>
<el-button style="float:right; padding 3px 0" @click="handleMachineryAdd" v-if="optType !='view'" type="text">新增</el-button>
</div>
<WorkStationMachine ref="machineryList" :optType="optType" :workstationId="form.workstationId" style="align:center"></WorkStationMachine>
</el-card>
</el-carousel-item>
<el-carousel-item>
<el-card shadow="always" style="width:400px">
<div slot="header">
<span>人力资源</span>
<el-button style="float:right; padding 3px 0" v-if="optType !='view'" type="text">新增</el-button>
</div>
人员清单
</el-card>
</el-carousel-item>
<el-carousel-item>
<el-card shadow="always" style="width:400px">
<div slot="header">
<span>工装夹具</span>
<el-button style="float:right; padding 5px 0" v-if="optType !='view'" type="text">新增</el-button>
</div>
工装夹具清单
</el-card>
</el-carousel-item>
</el-carousel>
</el-col>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="cancel" v-if="optType =='view'">返回</el-button>
<el-button type="primary" @click="submitForm" v-else> </el-button>
<el-button @click="cancel"> </el-button>
<el-button type="primary" @click="submitForm" v-else></el-button>
<el-button @click="cancel"></el-button>
</div>
</el-dialog>
</div>
@ -244,12 +279,23 @@
<script>
import { listWorkstation, getWorkstation, delWorkstation, addWorkstation, updateWorkstation } from "@/api/mes/md/workstation";
//
import WorkStationMachine from "./components/machine";
import MachinerySelectSingle from "@/components/machinerySelect/single.vue";
import {addWorkstationmachine} from "@/api/mes/md/workstationmachine";
//
//
import {listAllProcess} from "@/api/mes/pro/process";
import {genCode} from "@/api/system/autocode/rule";
import { listAllWorkshop } from "@/api/mes/md/workshop";
export default {
name: "Workstation",
dicts: ['sys_yes_no'],
components: {WorkStationMachine,MachinerySelectSingle},
data() {
return {
//
@ -297,7 +343,7 @@ export default {
//
rules: {
workstationCode: [
{ required: true, message: "工作站编不能为空", trigger: "blur" }
{ required: true, message: "工作站编不能为空", trigger: "blur" }
],
workstationName: [
{ required: true, message: "工作站名称不能为空", trigger: "blur" }
@ -332,7 +378,6 @@ export default {
//
getProcess(){
listAllProcess().then( response =>{
debugger;
this.processOptions = response.data;
});
},
@ -457,6 +502,20 @@ export default {
}else{
this.form.workstationCode = null;
}
},
//
handleMachineryAdd(){
this.$refs.machinerySelect.showFlag = true;
},
//
onMachineryAdd(rows){
debugger
this.loading = true;
rows.workstationId = this.form.workstationId;
addWorkstationmachine(rows).then(response =>{
this.$refs.machineryList.getList();
this.loading = false;
});
}
}
};