Files
FT501-WCS/ruoyi-ui/src/views/device/ssj/index.vue
2025-08-11 14:35:00 +08:00

338 lines
11 KiB
Vue

<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item :label="$t('device.ssj.deviceCode')" prop="deviceCode ">
<el-input
v-model="queryParams.deviceCode "
:placeholder="$t('device.ssj.placeholder.deviceCode')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item :label="$t('device.ssj.name')" prop="name ">
<el-input
v-model="queryParams.name "
:placeholder="$t('device.ssj.placeholder.name')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item :label="$t('device.ssj.taskNo')" prop="taskNo">
<el-input
v-model="queryParams.taskNo"
:placeholder="$t('device.ssj.placeholder.taskNo')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{ $t('common.search') }}</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('common.reset') }}</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['device:ssj:add']"
>{{ $t('common.add') }}</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['device:ssj:edit']"
>{{ $t('common.edit') }}</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['device:ssj:remove']"
>{{ $t('common.delete') }}</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['device:ssj:export']"
>{{ $t('common.export') }}</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="ssjList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column :label="$t('common.id')" align="center" prop="id" />
<el-table-column :label="$t('device.ssj.deviceCode')" align="center" prop="deviceCode" />
<el-table-column :label="$t('device.ssj.name')" align="center" prop="name" />
<el-table-column :label="$t('device.ssj.type')" align="center" prop="type" >
<template slot-scope="scope">
<dict-tag :options="dict.type.ssj_type" :value="scope.row.type"/>
</template>
</el-table-column>
<el-table-column :label="$t('device.ssj.ipAddress')" align="center" prop="ipAddress" />
<el-table-column :label="$t('device.ssj.plcDbReadAddress')" align="center" prop="plcDbReadAddress" />
<el-table-column :label="$t('device.ssj.isActive')" align="center" prop="isActive" />
<el-table-column :label="$t('device.ssj.plcDbWriteAddress')" align="center" prop="plcDbWriteAddress" />
<el-table-column :label="$t('device.ssj.rkqq')" align="center" prop="rkqq" />
<el-table-column :label="$t('device.ssj.kx')" align="center" prop="kx" />
<el-table-column :label="$t('device.ssj.dw')" align="center" prop="dw" />
<el-table-column :label="$t('device.ssj.trayCode')" align="center" prop="trayCode" />
<el-table-column :label="$t('device.ssj.taskNo')" align="center" prop="taskNo" />
<el-table-column :label="$t('common.operation')" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['device:ssj:edit']"
>{{ $t('common.edit') }}</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['device:ssj:remove']"
>{{ $t('common.delete') }}</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- Add or Edit Conveyor Dialog -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item :label="$t('device.ssj.deviceCode')" prop="deviceCode ">
<el-input v-model="form.deviceCode " :placeholder="$t('device.ssj.placeholder.deviceCode')" />
</el-form-item>
<el-form-item :label="$t('device.ssj.name')" prop="name ">
<el-input v-model="form.name " :placeholder="$t('device.ssj.placeholder.name')" />
</el-form-item>
<el-form-item :label="$t('device.ssj.ipAddress')" prop="ipAddress">
<el-input v-model="form.ipAddress" :placeholder="$t('device.ssj.placeholder.ipAddress')" />
</el-form-item>
<el-form-item :label="$t('device.ssj.plcDbReadAddress')" prop="plcDbReadAddress">
<el-input v-model="form.plcDbReadAddress" :placeholder="$t('device.ssj.placeholder.plcDbReadAddress')" />
</el-form-item>
<el-form-item :label="$t('device.ssj.isActive')" prop="isActive">
<el-input v-model="form.isActive" :placeholder="$t('device.ssj.placeholder.isActive')" />
</el-form-item>
<el-form-item :label="$t('device.ssj.plcDbWriteAddress')" prop="plcDbWriteAddress">
<el-input v-model="form.plcDbWriteAddress" :placeholder="$t('device.ssj.placeholder.plcDbWriteAddress')" />
</el-form-item>
<el-form-item :label="$t('device.ssj.rkqq')" prop="rkqq">
<el-input v-model="form.rkqq" :placeholder="$t('device.ssj.placeholder.rkqq')" />
</el-form-item>
<el-form-item :label="$t('device.ssj.kx')" prop="kx">
<el-input v-model="form.kx" :placeholder="$t('device.ssj.placeholder.kx')" />
</el-form-item>
<el-form-item :label="$t('device.ssj.dw')" prop="dw">
<el-input v-model="form.dw" :placeholder="$t('device.ssj.placeholder.dw')" />
</el-form-item>
<el-form-item :label="$t('device.ssj.trayCode')" prop="trayCode">
<el-input v-model="form.trayCode" :placeholder="$t('device.ssj.placeholder.trayCode')" />
</el-form-item>
<el-form-item :label="$t('device.ssj.taskNo')" prop="taskNo">
<el-input v-model="form.taskNo" :placeholder="$t('device.ssj.placeholder.taskNo')" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">{{ $t('common.confirm') }}</el-button>
<el-button @click="cancel">{{ $t('common.cancel') }}</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listSsj, getSsj, delSsj, addSsj, updateSsj } from "@/api/device/ssj"
export default {
name: "Ssj",
dicts: ['ssj_type'],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 输送机表格数据
ssjList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
deviceCode : null,
name : null,
type: null,
ipAddress: null,
plcDbReadAddress: null,
isActive: null,
plcDbWriteAddress: null,
rkqq: null,
kx: null,
dw: null,
trayCode: null,
taskNo: null
},
// 表单参数
form: {},
// 表单校验
rules: {
}
}
},
created() {
this.getList()
},
methods: {
/** 查询输送机列表 */
getList() {
this.loading = true
listSsj(this.queryParams).then(response => {
this.ssjList = response.rows
this.total = response.total
this.loading = false
})
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
id: null,
deviceCode : null,
name : null,
type: null,
ipAddress: null,
plcDbReadAddress: null,
isActive: null,
createTime: null,
plcDbWriteAddress: null,
rkqq: null,
kx: null,
dw: null,
trayCode: null,
taskNo: null
}
this.resetForm("form")
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm")
this.handleQuery()
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset()
this.open = true
this.title = this.$t('device.ssj.dialog.add')
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const id = row.id || this.ids
getSsj(id).then(response => {
this.form = response.data
this.open = true
this.title = this.$t('device.ssj.dialog.edit')
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateSsj(this.form).then(response => {
this.$modal.msgSuccess(this.$t('common.editSuccess'))
this.open = false
this.getList()
})
} else {
addSsj(this.form).then(response => {
this.$modal.msgSuccess(this.$t('common.addSuccess'))
this.open = false
this.getList()
})
}
}
})
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids
this.$modal.confirm(this.$t('device.ssj.dialog.deleteConfirm', { id: ids })).then(function() {
return delSsj(ids)
}).then(() => {
this.getList()
this.$modal.msgSuccess(this.$t('common.deleteSuccess'))
}).catch(() => {})
},
/** 导出按钮操作 */
handleExport() {
this.download('device/ssj/export', {
...this.queryParams
}, `ssj_${new Date().getTime()}.xlsx`)
}
}
}
</script>
<style scoped>
.el-form-item >>> .el-form-item__label {
white-space: nowrap;
width: auto;
min-width: fit-content;
}
</style>