<template>
|
<div>
|
<!-- 查询开始 -->
|
<el-form :model="params" :inline="true" class="demo-form-inline">
|
<el-form-item label="车间编号">
|
<!--<el-input type="text" v-model="params.workshopNo" show-word-limit width="200" placeholder="请输入车间编号" clearable></el-input>-->
|
<el-select v-model="params.workshopNo" placeholder="请选择车间" style="width: 100%;">
|
<el-option v-for="item in departList" :key="item.dicName" :label="item.dicName" :value="item.dicName"></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="设备编号">
|
<el-input type="text" v-model="params.equipmentId" show-word-limit width="200" placeholder="请输入设备编号" clearable></el-input>
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" @click="assignSearch" size="small" icon="el-icon-search">查询</el-button>
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" @click="reSearch" icon="el-icon-search" size="small">重置</el-button>
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" @click="addFormShow" size="small" icon="el-icon-circle-plus">新增</el-button>
|
</el-form-item>
|
</el-form>
|
<!-- 查询结束 -->
|
<el-table :data="pageDate.list" v-if="pageDate.list" class="show_table" highlight-current-row v-loading="listLoading"
|
:style="conHeight" :height="conHeight.height" style="width: 100%" @sort-change="sortTableFun">
|
<el-table-column type="expand">
|
<template slot-scope="props">
|
<el-form label-position="left" inline class="demo-table-expand">
|
<el-form-item label="车间编号">
|
<span>{{ props.row.workshopNo}}</span>
|
</el-form-item>
|
<el-form-item label="设备组">
|
<span>{{ props.row.equipmentIds }}</span>
|
</el-form-item>
|
<el-form-item label="设备类型编号">
|
<span>{{ props.row.classType}}</span>
|
</el-form-item>
|
<el-form-item label="设备类型名称">
|
<span>{{ props.row.className}}</span>
|
</el-form-item>
|
<el-form-item label="备注">
|
<span>{{ props.row.remarks}}</span>
|
</el-form-item>
|
</el-form>
|
</template>
|
</el-table-column>
|
<el-table-column type="index" label="序号" align="center">
|
</el-table-column>
|
<el-table-column prop="workshopNo" label="车间编号" class-name="center" sortable="custom" min-width="30%">
|
</el-table-column>
|
<el-table-column prop="classType" label="设备类型编号" class-name="center" sortable="custom" min-width="50%">
|
</el-table-column>
|
<el-table-column prop="className" label="设备类型名称" class-name="center" sortable="custom" min-width="50%">
|
</el-table-column>
|
<el-table-column prop="equipmentIds" label="设备组" class-name="center" sortable="custom" >
|
</el-table-column>
|
<el-table-column prop="createTime" label="时间" class-name="center" :formatter="formatTime" min-width="60%">
|
</el-table-column>
|
<el-table-column prop="remarks" label="备注" class-name="center" min-width="60%">
|
</el-table-column>
|
<el-table-column label="操作" align="center" min-width="60%">
|
<template slot-scope="scope">
|
<el-button size="mini" @click.native="editFormShow(scope.$index, scope.row)" icon="el-icon-edit"
|
>编辑
|
</el-button>
|
<el-button size="mini" @click.native="deleteSingle(scope.$index, scope.row)" icon="el-icon-delete"
|
>删除
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
|
<!-- 分页开始 -->
|
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageDate.page" :page-sizes="pageDate.pageSizeArr" :page-size="pageDate.size" layout="total, sizes, prev, pager, next, jumper" :total="pageDate.total"></el-pagination>
|
<!-- 分页结束 -->
|
<!--编辑弹窗开始-->
|
<el-dialog :visible.sync="addvisible" title="新增" :close-on-click-modal="false" @close="editFormClose" width="680px">
|
<el-form :model="addForm" :rules="editFormRules" ref="assignAddForm" label-position="left" label-width="110px">
|
|
<el-form-item label="车间" prop="workshopNo">
|
<el-select v-model="addForm.workshopNo" placeholder="请选择车间" style="width: 100%;">
|
<el-option v-for="item in departList" :key="item.dicName" :label="item.dicName" :value="item.dicName"></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="设备类型编号" prop="classType">
|
<el-input placeholder="请输入设备类型编号" v-model.trim="addForm.classType"></el-input>
|
</el-form-item>
|
<el-form-item label="设备类型名称" prop="className">
|
<el-input placeholder="请输入设备类型名称" v-model.trim="addForm.className"></el-input>
|
</el-form-item>
|
<el-form-item label="设备组编号" prop="equipmentIds">
|
<el-input placeholder="请输入设备组编号" v-model.trim="addForm.equipmentIds"></el-input>
|
</el-form-item>
|
<el-form-item label="备注">
|
<el-input
|
type="textarea"
|
placeholder="请输入备注"
|
rows="3"
|
resize="none"
|
v-model.trim="addForm.remarks"
|
></el-input>
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click.native="addAssign" :loading="submitLoading" type="primary" class="btn-custom">
|
<span>保 存</span>
|
</el-button>
|
<el-button @click="editFormClose" class="btn-custom">
|
<span>取 消</span>
|
</el-button>
|
|
</div>
|
</el-dialog>
|
<!--编辑弹窗结束-->
|
<!--编辑字典信息开始-->
|
<el-dialog :visible.sync="editFormVisible" :close-on-click-modal="false" title="编辑信" @close="editFormClose" width="680px">
|
<el-form :model="addForm" :rules="editFormRules" ref="assignEditForm" label-width="110px" label-position="left">
|
<el-form-item label="车间" prop="workshopNo">
|
<el-select v-model="addForm.workshopNo" placeholder="请选择车间" style="width: 100%;">
|
<el-option v-for="item in departList" :key="item.dicName" :label="item.dicName" :value="item.dicName"></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="设备类型编号" prop="classType">
|
<el-input placeholder="请输入设备类型编号" v-model.trim="addForm.classType"></el-input>
|
</el-form-item>
|
<el-form-item label="设备类型名称" prop="className">
|
<el-input placeholder="请输入设备类型名称" v-model.trim="addForm.className"></el-input>
|
</el-form-item>
|
<el-form-item label="设备组编号" prop="equipmentIds">
|
<el-input placeholder="请输入设备组编号" v-model.trim="addForm.equipmentIds"></el-input>
|
</el-form-item>
|
<el-form-item label="备注">
|
<!--<el-input placeholder="请输入备注" v-model.trim="addForm.remarks"></el-input>-->
|
<el-input
|
type="textarea"
|
placeholder="请输入备注"
|
rows="3"
|
resize="none"
|
v-model.trim="addForm.remarks"
|
></el-input>
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="primary" :loading="submitLoading" @click.native="editSingle" class="btn-custom">保存
|
</el-button>
|
<el-button @click="editFormClose">取消</el-button>
|
|
</div>
|
</el-dialog>
|
<!--编辑字典信息结束-->
|
</div>
|
</template>
|
|
<script>
|
import * as assignApi from '../api/tableMessage'
|
import * as SystemApi from '../../../base/api/system'
|
|
export default {
|
data() {
|
return {
|
defaultForm: {},//初始表单
|
selectedRow: {},
|
departList: [],
|
userList: [],
|
params: {
|
|
},
|
conHeight: {
|
height: '',
|
overflow: 'auto'
|
},
|
pageDate: {
|
page: 1, //页码
|
size: 10, //每页显示个数
|
list: [],
|
pageSizeArr: [10, 20, 40],
|
total: 0
|
},
|
buttonList: {
|
deviceManagement_add: {show: false, code: 'deviceManagement_add'},
|
deviceManagement_edit: {show: false, code: 'deviceManagement_edit'},
|
deviceManagement_delete: {show: false, code: 'deviceManagement_delete'}
|
},
|
addvisible: false,
|
editFormVisible: false,
|
submitLoading: false,
|
selectUserId: {id: ''},
|
listLoading: false,
|
|
addForm: {
|
workshopNo:'',
|
equipmentIds: '',
|
classType: '',
|
className: '',
|
remarks: ''
|
},
|
editFormRules: {
|
workshopNo: [
|
{required: true, message: '请选择车间', trigger: 'blur'}
|
],
|
equipmentIds: [
|
{required: true, message: '请输入设备组', trigger: 'blur'}
|
],
|
classType: [
|
{required: true, message: '请输入类型编号', trigger: 'blur'}
|
],
|
className: [
|
{required: true, message: '请输入类型名称', trigger: 'blur'}
|
]
|
},
|
};
|
},
|
methods: {
|
//格式化时间
|
formatTime(row,column){
|
if(row[column.property] != null){
|
let data = row[column.property];
|
let dtime = new Date(data);
|
const year = dtime.getFullYear();
|
let month = dtime.getMonth() + 1;
|
if (month < 10) {
|
month = '0' + month
|
}
|
let day = dtime.getDate();
|
if (day < 10) {
|
day = '0' + day
|
}
|
let hour = dtime.getHours();
|
if (hour < 10) {
|
hour = '0' + hour
|
}
|
let minute = dtime.getMinutes();
|
if (minute < 10) {
|
minute = '0' + minute
|
}
|
let second = dtime.getSeconds();
|
if (second < 10) {
|
second = '0' + second
|
}
|
return year+ '-' + month+ '-' + day + ' ' + hour + ':' + minute + ':' + second
|
|
}
|
|
},
|
getDepartList() {
|
assignApi.depart_list().then((res) => {
|
if (res.success && res.list && res.list.length > 0) {
|
this.departList = res.list;
|
} else {
|
this.departList = [];
|
}
|
})
|
},
|
sortTableFun(column){
|
this.column = column.prop; //该方法获取到当前列绑定的prop字段名赋值给一个变量,之后这个变量做为入参传给后端
|
// console.log(this.column);
|
// console.log(column.order)
|
if (column.prop) { //该列有绑定prop字段走这个分支
|
if(this.column === 'workshopNo' && column.order === 'ascending'){
|
this.params.descStr = 'workshopNo,asc'
|
}else if(this.column === 'workshopNo' && column.order === 'descending'){
|
this.params.descStr = 'workshopNo,desc'
|
}else if(this.column === 'equipmentIds' && column.order === 'ascending'){
|
this.params.descStr = 'equipmentIds,asc'
|
}else if(this.column === 'equipmentIds' && column.order === 'descending'){
|
this.params.descStr = 'equipmentIds,desc'
|
}else if(this.column === 'classType' && column.order === 'ascending'){
|
this.params.descStr = 'classType,asc'
|
}else if(this.column === 'classType' && column.order === 'descending'){
|
this.params.descStr = 'classType,desc'
|
}else if(this.column === 'className' && column.order === 'ascending'){
|
this.params.descStr = 'className,asc'
|
}else if(this.column === 'className' && column.order === 'descending'){
|
this.params.descStr = 'className,desc'
|
}
|
// if (column.order == 'ascending') {//当用户点击的是升序按钮,即ascending时
|
// this.params.descStr = 'asc'; //将order这个变量赋值为后端接口文档定义的升序的字段名,之后作为入参传给后端
|
// } else if (column.order == 'descending') {
|
// //当用户点击的是升序按钮,即descending时
|
// this.params.descStr = 'desc';//将order这个变量赋值为后端接口文档定义的降序的字段名,之后作为入参传给后端
|
// }
|
this.assignQuery()//且发起后端请求的接口
|
}
|
},
|
userIdFormat(row, col, cellVal) {
|
let text = "";
|
if (cellVal && cellVal.length > 0) {
|
let idArr = cellVal.split(',');
|
if (idArr.length > 0) {
|
idArr.forEach((v, k) => {
|
this.userList.forEach((m, i) => {
|
if (m.userId == v) {
|
if (text === '') {
|
text += m.nickname;
|
} else {
|
text += ',' + m.nickname;
|
}
|
}
|
});
|
});
|
}
|
}
|
return text;
|
},
|
departListFormat(row, col, cellVal) {
|
let text = "";
|
this.departList.forEach((v, k) => {
|
if (v.departId == cellVal) {
|
text = v.departName;
|
}
|
});
|
return text;
|
},
|
getUserList() {
|
SystemApi.user_select_list()
|
.then(res => {
|
if (res.success && res.list && res.list.length > 0) {
|
this.userList = res.list;
|
// console.log(this.userList);
|
} else {
|
this.userList = [];
|
}
|
})
|
.catch(error => {
|
this.userList = [];
|
});
|
},
|
approveChange(val) {
|
this.addForm.approve_user_list = val;
|
if (val && val.length > 0) {
|
this.addForm.approveUsers = val.join(",");
|
} else {
|
this.addForm.approveUsers = '';
|
}
|
this.$forceUpdate();
|
},
|
addAssign() {
|
this.$refs.assignAddForm.validate((valid) => {
|
if (valid) {
|
this.$confirm('确认提交吗?', '提示', {}).then(() => {
|
this.submitLoading = true;
|
assignApi.assign_add(this.addForm).then((res) => {
|
if (res.success) {
|
this.submitLoading = false;
|
this.$message({
|
message: res.message,
|
type: 'success'
|
});
|
this.editFormClose();
|
this.assignQuery();
|
} else if (res.message) {
|
this.submitLoading = false;
|
this.$message({
|
message: res.message,
|
type: 'error'
|
});
|
}
|
});
|
});
|
}
|
});
|
},
|
assignSearch(){
|
this.pageDate.page = 1;
|
this.assignQuery();
|
},
|
reSearch(){
|
this.params = {};
|
this.assignQuery();
|
},
|
assignQuery() {
|
this.listLoading = true;
|
assignApi.assign_list(this.pageDate.page, this.pageDate.size, this.params).then((res) => {
|
if (res.success) {
|
this.listLoading = false;
|
this.pageDate.total = res.page.total;
|
this.pageDate.list = res.page.records;
|
} else if (res.message) {
|
this.listLoading = false;
|
this.$message({
|
type: 'error',
|
message: res.message
|
});
|
}
|
}).catch((error) => {
|
this.$message({
|
type: 'error',
|
message: '服务器异常!'
|
});
|
});
|
},
|
//删除事件
|
deleteSingle(index, row) {
|
this.selectUserId.id = row.id;
|
this.getDeleteArray(this.selectUserId);
|
},
|
getDeleteArray(Id) {
|
this.$confirm('确认提交吗?', '提示', {}).then(() => {
|
assignApi.assign_deletl(Id).then((res) => {
|
if (res.success) {
|
this.assignQuery();
|
this.$message({
|
message: res.message,
|
type: 'success'
|
});
|
} else if (res.message) {
|
this.$message({
|
message: res.message,
|
type: 'error'
|
});
|
}
|
});
|
});
|
},
|
//动态权限
|
getButtonList() {
|
let params = {flag: 1, param: this.$route.path};
|
SystemApi.button_list(params).then((res) => {
|
if (res.success && res.list.length > 0) {
|
res.list.forEach((v, k) => {
|
if (this.buttonList[v] && this.buttonList[v].code == v) {
|
this.buttonList[v].show = true
|
}
|
});
|
}
|
})
|
},
|
editSingle() {
|
this.$refs.assignEditForm.validate((valid) => {
|
if (valid) {
|
this.$confirm('确认提交吗?', '提示', {}).then(() => {
|
this.submitLoading = true;
|
assignApi.assign_eitd(this.selectedRow.id, this.addForm).then((res) => {
|
if (res.success) {
|
console.log(111)
|
this.submitLoading = false;
|
this.$message({
|
message: res.message,
|
type: 'success'
|
});
|
this.editFormClose();
|
this.assignQuery();
|
} else if (res.message) {
|
this.submitLoading = false;
|
this.$message({
|
message: res.message,
|
type: 'error'
|
});
|
}
|
});
|
});
|
}
|
});
|
|
},
|
editFormShow(index, row) {
|
console.log(row);
|
this.editFormVisible = true;
|
this.addForm = Object.assign({}, row);
|
this.selectedRow = row;
|
// this.addForm.approve_user_list = row.approveUsers.split(',');
|
},
|
addFormShow() {
|
this.addvisible = true
|
},
|
editFormClose() {
|
this.editFormVisible = false;
|
this.addvisible = false;
|
this.selectedRow = {};
|
this.addForm = JSON.parse(JSON.stringify(this.defaultForm));//表单内容清空
|
},
|
changePage(page) {
|
this.pageDate.page = page;
|
this.assignQuery()
|
},
|
getHeight() {
|
this.conHeight.height = window.innerHeight - 160 + 'px';
|
},
|
handleSizeChange(val) {
|
this.pageDate.size = val;
|
this.assignQuery();
|
},
|
handleCurrentChange(val) {
|
this.pageDate.page = val;
|
this.assignQuery();
|
}
|
},
|
created() {
|
//初始化信息
|
this.defaultForm = JSON.parse(JSON.stringify(this.addForm));//初始化默认新增对象表单数据
|
this.getHeight();
|
},
|
mounted() {
|
this.getButtonList();
|
//默认查询页面
|
this.assignQuery();
|
//初始化查询条件
|
this.getUserList();
|
this.getDepartList();
|
},
|
|
};
|
</script>
|
|
<style scoped>
|
.demo-table-expand {
|
font-size: 0;
|
}
|
|
.demo-table-expand label {
|
width: 130px;
|
color: #99a9bf;
|
}
|
|
.demo-table-expand .el-form-item {
|
margin-right: 0;
|
margin-bottom: 0;
|
width: 50%;
|
}
|
</style>
|