parent
b542fd4131
commit
3d3aef776a
12 changed files with 835 additions and 112 deletions
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 6.2 KiB |
@ -0,0 +1,652 @@ |
||||
<template> |
||||
<basic-container class="content"> |
||||
<div class="content-top"> |
||||
<el-form |
||||
:inline="true" |
||||
:model="queryForm" |
||||
class="serch_form" |
||||
> |
||||
<el-form-item label="类型"> |
||||
<el-select |
||||
class="search_select" |
||||
v-model="queryForm.type" |
||||
placeholder="请选择类型" |
||||
clearable |
||||
filterable |
||||
> |
||||
<el-option |
||||
v-for="item in typeList" |
||||
:key="item.dictValue" |
||||
:label="item.dictKey" |
||||
:value="item.dictValue"> |
||||
</el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
<el-form-item> |
||||
<el-button class="search_button" @click="handleSearch"> |
||||
<i class="el-icon-search"></i> |
||||
</el-button> |
||||
</el-form-item> |
||||
</el-form> |
||||
<div> |
||||
<el-button v-if="multipleSelection.length != 0" class="register" @click="batchDeletion">批量删除</el-button> |
||||
<el-button class="register" @click="handleAdd">新增</el-button> |
||||
<el-button class="register" @click="handleBack">返回</el-button> |
||||
</div> |
||||
</div> |
||||
<div class="content-main"> |
||||
<el-table |
||||
:data="tableData" |
||||
stripe |
||||
border |
||||
style="width: 100%" |
||||
:header-cell-style="{'text-align':'center'}" |
||||
:cell-style="{'text-align':'center'}" |
||||
@selection-change="handleSelectionChange"> |
||||
<el-table-column |
||||
type="selection" |
||||
width="55"> |
||||
</el-table-column> |
||||
<el-table-column |
||||
type="index" |
||||
label="序号" |
||||
width="70"> |
||||
</el-table-column> |
||||
<el-table-column |
||||
prop="code" |
||||
label="设备编码"> |
||||
</el-table-column> |
||||
<el-table-column |
||||
prop="name" |
||||
label="设备名称"> |
||||
</el-table-column> |
||||
<el-table-column |
||||
prop="type" |
||||
label="类型"> |
||||
</el-table-column> |
||||
<el-table-column |
||||
prop="operateTime" |
||||
label="操作时间"> |
||||
</el-table-column> |
||||
<el-table-column |
||||
prop="operateUser" |
||||
label="操作人员"> |
||||
</el-table-column> |
||||
<el-table-column |
||||
prop="remarks" |
||||
label="备注"> |
||||
</el-table-column> |
||||
<el-table-column |
||||
prop="address" |
||||
label="操作" |
||||
width="150" |
||||
align="center" |
||||
> |
||||
<template slot-scope="scope"> |
||||
<el-popover |
||||
placement="bottom" |
||||
width="150" |
||||
trigger="hover"> |
||||
<div class="more-box"> |
||||
<div |
||||
class="item" |
||||
@click="handleOperation('view', scope.row)">查看 |
||||
</div> |
||||
<div |
||||
class="item" |
||||
@click="handleOperation('edit', scope.row)">编辑 |
||||
</div> |
||||
<div |
||||
class="item" |
||||
@click="handleOperation('delete', scope.row)">删除 |
||||
</div> |
||||
</div> |
||||
<div class="more" slot="reference">更多</div> |
||||
</el-popover> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
<div class="el_pagination"> |
||||
<!-- <div |
||||
style=" |
||||
width: 100%; |
||||
height: 100%; |
||||
position: absolute; |
||||
background: rgba(255,255,255,.9); |
||||
z-index: 9; |
||||
position: absolute; |
||||
top: 0; |
||||
left: 0; |
||||
" |
||||
v-show="loading" |
||||
></div> --> |
||||
<el-pagination |
||||
@size-change="handleSizeChange" |
||||
@current-change="handleCurrentChange" |
||||
:current-page="currentPage" |
||||
:page-sizes="[6, 10, 20, 50, 100]" |
||||
:page-size="pageSize" |
||||
layout="total, sizes, prev, pager, next, jumper" |
||||
:total="total" |
||||
> |
||||
</el-pagination> |
||||
</div> |
||||
</div> |
||||
<el-dialog |
||||
:title="title" |
||||
:append-to-body="true" |
||||
:visible.sync="dialongVisable" |
||||
width="50%" |
||||
:before-close="handleClose"> |
||||
<el-form |
||||
class="dialogForm" |
||||
:model="dialogForm" |
||||
label-width="80px" |
||||
ref="dialogForm" |
||||
> |
||||
<el-col :span="8"> |
||||
<el-form-item label="设备名称" prop="name"> |
||||
<el-input |
||||
v-model="dialogForm.name" |
||||
disabled |
||||
/> |
||||
</el-form-item> |
||||
</el-col> |
||||
<el-col :span="8"> |
||||
<el-form-item label="设备编码" prop="code"> |
||||
<el-input |
||||
v-model="dialogForm.code" |
||||
disabled |
||||
/> |
||||
</el-form-item> |
||||
</el-col> |
||||
<el-col :span="8"> |
||||
<el-form-item label="类型" prop="type"> |
||||
<el-select |
||||
v-model="dialogForm.type" |
||||
placeholder="请选择类型" |
||||
:disabled="dialogFormDisabled" |
||||
> |
||||
<el-option |
||||
v-for="item in typeList" |
||||
:key="item.dictValue" |
||||
:label="item.dictKey" |
||||
:value="item.dictValue"> |
||||
</el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
</el-col> |
||||
<el-col :span="8"> |
||||
<el-form-item label="操作人员" prop="operateUser"> |
||||
<el-input |
||||
v-model="dialogForm.operateUser" |
||||
placeholder="请输入操作人员" |
||||
:disabled="dialogFormDisabled" |
||||
/> |
||||
</el-form-item> |
||||
</el-col> |
||||
<el-col :span="8"> |
||||
<el-form-item label="操作时间" prop="operateTime"> |
||||
<el-date-picker |
||||
v-model="dialogForm.operateTime" |
||||
value-format="yyyy-MM-dd" |
||||
type="date" |
||||
placeholder="选择操作时间" |
||||
:disabled="dialogFormDisabled"> |
||||
</el-date-picker> |
||||
</el-form-item> |
||||
</el-col> |
||||
<el-col :span="24"> |
||||
<el-form-item label="备注" prop="remarks"> |
||||
<el-input |
||||
v-model="dialogForm.remarks" |
||||
placeholder="选输入备注" |
||||
:disabled="dialogFormDisabled" |
||||
/> |
||||
</el-form-item> |
||||
</el-col> |
||||
</el-form> |
||||
<div class="dialog-footer"> |
||||
<el-button v-if="dialogFormType != 'view'" @click="dialogHandleClick('cancel')">取 消</el-button> |
||||
<el-button type="primary" @click="dialogHandleClick('confirm')">确 定</el-button> |
||||
</div> |
||||
</el-dialog> |
||||
|
||||
</basic-container> |
||||
</template> |
||||
|
||||
<script> |
||||
import { save, findPage, detail, equipOperateRemove } from "@/api/equipment/index"; |
||||
import {getDictionary} from '@/api/system/dictbiz' |
||||
export default { |
||||
data() { |
||||
return { |
||||
queryForm: { |
||||
type: '', |
||||
}, |
||||
typeList: [], |
||||
tableData: [], |
||||
multipleSelection: [], |
||||
currentPage: 1, |
||||
pageSize: 10, |
||||
total: 0, |
||||
dialongVisable: false, |
||||
dialogFormDisabled: false, |
||||
dialogFormType: '', |
||||
dialogForm: { |
||||
name: '', |
||||
code: '', |
||||
type: '', |
||||
operateUser: '', |
||||
operateTime: '', |
||||
remarks: '', |
||||
}, |
||||
rules: { |
||||
type: [ |
||||
{ required: true, message: '请选择类型', trigger: 'blur' }, |
||||
], |
||||
operateTime: [ |
||||
{ required: true, message: '请选择操作时间', trigger: 'blur' }, |
||||
], |
||||
operateUser: [ |
||||
{ required: true, message: '请选择操作人员', trigger: 'blur' }, |
||||
], |
||||
} |
||||
} |
||||
}, |
||||
computed: { |
||||
title() { |
||||
if(this.dialogFormType == 'view') { |
||||
return '查看详情' |
||||
} else if(this.dialogFormType == 'edit') { |
||||
return '编辑' |
||||
} else if(this.dialogFormType == 'add') { |
||||
return '新增' |
||||
} |
||||
} |
||||
}, |
||||
mounted() { |
||||
this.dialogForm.name = this.$route.query.name |
||||
this.dialogForm.code = this.$route.query.code |
||||
this.init() |
||||
}, |
||||
methods: { |
||||
// init |
||||
init() { |
||||
this.findPage() |
||||
this.selectDict() |
||||
}, |
||||
// 字典 |
||||
selectDict() { |
||||
getDictionary({code: 'operate_type'}).then(res => { |
||||
this.typeList = res.data.data.filter(item => item.parentId != '0') |
||||
}) |
||||
}, |
||||
// 查询列表数据 |
||||
findPage() { |
||||
let params = { |
||||
...this.queryForm, |
||||
code: this.dialogForm.code, |
||||
current: this.currentPage, |
||||
size: this.pageSize |
||||
} |
||||
findPage(params).then(res => { |
||||
this.tableData = res.data.data.records |
||||
this.total = res.data.data.total |
||||
}) |
||||
}, |
||||
// 点击搜索按钮 |
||||
handleSearch() { |
||||
this.currentPage = 1 |
||||
this.findPage() |
||||
}, |
||||
// 表格选择变化 |
||||
handleSelectionChange(val) { |
||||
this.multipleSelection = val; |
||||
}, |
||||
handleAdd() { |
||||
this.dialogFormType = 'add' |
||||
this.dialongVisable = true |
||||
}, |
||||
// 批量删除 |
||||
batchDeletion() { |
||||
this.$confirm('确认批量删除删除所选数据?', '提示', { |
||||
confirmButtonText: '确定', |
||||
cancelButtonText: '取消', |
||||
type: 'warning' |
||||
}).then(() => { |
||||
let ids = [] |
||||
this.multipleSelection.forEach(item => { |
||||
ids.push(item.id) |
||||
}) |
||||
equipOperateRemove({ids: ids.join(',')}).then(res => { |
||||
this.$message({ |
||||
message: '删除成功', |
||||
type: 'success' |
||||
}) |
||||
this.findPage() |
||||
}).catch(err => { |
||||
this.$message({ |
||||
type: 'error', |
||||
message: '删除失败!' |
||||
}) |
||||
}) |
||||
}).catch(() => { |
||||
this.$message({ |
||||
type: 'info', |
||||
message: '已取消删除' |
||||
}) |
||||
}) |
||||
}, |
||||
// 查看弹窗表单详情 |
||||
detail(id) { |
||||
detail({id}).then(res => { |
||||
console.log(res) |
||||
this.dialogForm = res.data.data |
||||
}) |
||||
}, |
||||
// 表格更多选项点击 |
||||
handleOperation(type, row) { |
||||
this.dialogFormType = type |
||||
if(type == 'view') { |
||||
this.dialongVisable = true |
||||
this.dialogFormDisabled = true |
||||
this.detail(row.id) |
||||
} else if(type == 'edit') { |
||||
this.dialongVisable = true |
||||
this.detail(row.id) |
||||
} else if(type == 'delete') { |
||||
this.$confirm('确认删除该条数据?', '提示', { |
||||
confirmButtonText: '确定', |
||||
cancelButtonText: '取消', |
||||
type: 'warning' |
||||
}).then(() => { |
||||
equipOperateRemove({ids: row.id}).then(res => { |
||||
this.$message({ |
||||
message: '删除成功', |
||||
type: 'success' |
||||
}) |
||||
this.findPage() |
||||
}).catch(err => { |
||||
this.$message({ |
||||
type: 'error', |
||||
message: '删除失败!' |
||||
}) |
||||
}) |
||||
}).catch(() => { |
||||
this.$message({ |
||||
type: 'info', |
||||
message: '已取消删除' |
||||
}) |
||||
}) |
||||
} |
||||
}, |
||||
dialogHandleClick(type) { |
||||
if(type == 'confirm') { |
||||
if(this.dialogFormType == 'add') { |
||||
const fieldsToValidate = ['type','operateUser','operateTime'] |
||||
this.$refs.dialogForm.validate((valid) => { |
||||
if (valid) { |
||||
save(this.dialogForm).then(res => { |
||||
this.$message({ |
||||
message: '入库成功', |
||||
type: 'success' |
||||
}); |
||||
this.handleClose() |
||||
this.currentPage = 1 |
||||
this.pageSize = 10 |
||||
this.findPage() |
||||
}).catch(error => { |
||||
this.$message({ |
||||
message: '入库失败', |
||||
type: 'error' |
||||
}); |
||||
}) |
||||
} else { |
||||
return false; |
||||
} |
||||
}, fieldsToValidate); |
||||
} else if(this.dialogFormType == 'edit') { |
||||
const fieldsToValidate = ['type','operateUser','operateTime'] |
||||
this.$refs.dialogForm.validate((valid) => { |
||||
if (valid) { |
||||
save(this.dialogForm).then(res => { |
||||
this.$message({ |
||||
message: '修改成功', |
||||
type: 'success' |
||||
}); |
||||
this.handleClose() |
||||
this.currentPage = 1 |
||||
this.pageSize = 10 |
||||
this.findPage() |
||||
}).catch(error => { |
||||
this.$message({ |
||||
message: '修改失败', |
||||
type: 'error' |
||||
}); |
||||
}) |
||||
} else { |
||||
return false; |
||||
} |
||||
}, fieldsToValidate); |
||||
} |
||||
} else { |
||||
this.handleClose() |
||||
} |
||||
}, |
||||
// 弹窗关闭 |
||||
handleClose() { |
||||
this.dialongVisable = false |
||||
this.dialogFormDisabled = false |
||||
this.resetForm() |
||||
this.dialogForm = { |
||||
name: this.$route.query.name, |
||||
code: this.$route.query.code, |
||||
type: '', |
||||
operateUser: '', |
||||
operateTime: '', |
||||
remarks: '', |
||||
} |
||||
}, |
||||
// 重置表单 |
||||
resetForm() { |
||||
this.$refs['dialogForm'].resetFields(); |
||||
}, |
||||
// 分页 |
||||
handleSizeChange(val) { |
||||
this.currentPage = 1 |
||||
this.pageSize = val |
||||
this.findPage() |
||||
}, |
||||
handleCurrentChange(val) { |
||||
this.currentPage = val |
||||
this.findPage() |
||||
}, |
||||
handleBack() { |
||||
this.$router.push({path: '/equipment/index'}) |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style lang="scss" scoped> |
||||
.content { |
||||
height: 100%; |
||||
background-color: white; |
||||
padding: 20px !important; |
||||
.content-top{ |
||||
display: flex; |
||||
justify-content: space-between; |
||||
align-items: flex-start; |
||||
.register{ |
||||
height: 40px; |
||||
} |
||||
.serch_form { |
||||
// display: flex; |
||||
// margin-bottom: 30px; |
||||
.el-form-item{ |
||||
// padding: 0 10px; |
||||
margin-right: 20px !important; |
||||
} |
||||
.search_select { |
||||
// width: 138px; |
||||
height: 40px; |
||||
} |
||||
.search_input { |
||||
// width: 238px; |
||||
height: 40px; |
||||
} |
||||
/deep/.el-input__inner { |
||||
border-radius: 0; |
||||
} |
||||
.search_button { |
||||
width: 50px; |
||||
height: 40px; |
||||
border-radius: 0; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
margin-left: 6px; |
||||
.el-icon-search { |
||||
font-size: 19px; |
||||
color: #c9c9c9; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
.content-main{ |
||||
.more{ |
||||
cursor: pointer; |
||||
} |
||||
.el_pagination { |
||||
display: flex; |
||||
justify-content: end; |
||||
margin-top: 20px; |
||||
} |
||||
} |
||||
} |
||||
.more-box{ |
||||
display: flex; |
||||
flex-direction: column; |
||||
align-items: center; |
||||
justify-content: center; |
||||
.item{ |
||||
width: 100%; |
||||
padding: 5px 0; |
||||
text-align: center; |
||||
cursor: pointer; |
||||
} |
||||
} |
||||
.dialogForm{ |
||||
display: flex; |
||||
flex-wrap: wrap; |
||||
.el-select{ |
||||
width: 100%; |
||||
} |
||||
} |
||||
.dialog-footer{ |
||||
height: 40px; |
||||
display: flex; |
||||
justify-content: flex-end; |
||||
} |
||||
.message{ |
||||
// padding: 0 20px; |
||||
margin: 0 20px 0px 20px; |
||||
display: flex; |
||||
flex-direction: column; |
||||
border: 1px solid #D1D1D1; |
||||
.box{ |
||||
margin: 0 20px 0px 20px; |
||||
} |
||||
.title{ |
||||
height: 40px; |
||||
background: #FFFFFF; |
||||
border-radius: 0px 0px 0px 0px; |
||||
display: flex; |
||||
align-items: center; |
||||
margin: 0 20px 0px 20px; |
||||
} |
||||
.item{ |
||||
display: flex; |
||||
align-items: center; |
||||
margin-bottom: 10px; |
||||
.label{ |
||||
width: 80px; |
||||
text-align: end; |
||||
margin-right: 10px; |
||||
} |
||||
} |
||||
} |
||||
.history{ |
||||
// padding: 0 20px; |
||||
margin: 0 20px 20px 20px; |
||||
display: flex; |
||||
flex-direction: column; |
||||
border: 1px solid #D1D1D1; |
||||
border-top: none; |
||||
.title{ |
||||
height: 40px; |
||||
background: #FFFFFF; |
||||
border-radius: 0px 0px 0px 0px; |
||||
display: flex; |
||||
align-items: center; |
||||
margin: 0 20px 0px 20px; |
||||
} |
||||
.el-collapse{ |
||||
margin: 0 20px; |
||||
border: none !important; |
||||
margin-bottom: 20px; |
||||
} |
||||
} |
||||
.title-text{ |
||||
margin: 0 20px; |
||||
} |
||||
.name-time{ |
||||
// width: 327px; |
||||
height: 40px; |
||||
background: #F9F9F9; |
||||
display: flex; |
||||
align-items: center; |
||||
padding: 0 20px; |
||||
.time{ |
||||
margin-left: 30px; |
||||
} |
||||
} |
||||
.form-title{ |
||||
// width: 100%; |
||||
height: 40px; |
||||
background: #F9F9F9; |
||||
border-radius: 0px 0px 0px 0px; |
||||
border: 1px solid #D1D1D1; |
||||
display: flex; |
||||
align-items: center; |
||||
padding: 0 20px; |
||||
margin-bottom: 20px; |
||||
} |
||||
.status-box-wrapper{ |
||||
width: 100%; |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
} |
||||
.status-box{ |
||||
width: 62px; |
||||
height: 25px; |
||||
} |
||||
.blue{ |
||||
background: rgba(43, 142, 229, 0.2); |
||||
color: #2B8EE5; |
||||
} |
||||
.green{ |
||||
background: rgba(30, 185, 76, 0.2); |
||||
color: #1EB94C; |
||||
} |
||||
.red{ |
||||
background: rgba(225, 75, 51, 0.2); |
||||
color: #E14B33; |
||||
} |
||||
.grey{ |
||||
background: rgba(151, 151, 151, 0.2); |
||||
color: #333333; |
||||
} |
||||
</style> |
||||
Loading…
Reference in new issue