251 lines
8.2 KiB
Vue
251 lines
8.2 KiB
Vue
<!--
|
|
* @Descripttion: (/light_log)
|
|
* @Author: (admin)
|
|
* @Date: (2024-11-01)
|
|
-->
|
|
<template>
|
|
<div>
|
|
<el-form :model="queryParams" label-position="right" inline ref="queryRef" v-show="showSearch" @submit.prevent>
|
|
<el-form-item label="查询时间" prop="timeRange">
|
|
<el-date-picker v-model="queryParams.timeRange" type="datetimerange" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" />
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-button icon="search" type="primary" @click="handleQuery">{{ $t('btn.search') }}</el-button>
|
|
<el-button icon="refresh" @click="resetQuery">{{ $t('btn.reset') }}</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
<!-- 工具区域 -->
|
|
<el-row :gutter="15" class="mb10">
|
|
<!-- <el-col :span="1.5">
|
|
<el-button type="primary" v-hasPermi="['lightlog:add']" plain icon="plus" @click="handleAdd">
|
|
{{ $t('btn.add') }}
|
|
</el-button>
|
|
</el-col> -->
|
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
|
|
</el-row>
|
|
|
|
<el-table :data="dataList" v-loading="loading" ref="table" border header-cell-class-name="el-table-header-cell" highlight-current-row @sort-change="sortChange">
|
|
<el-table-column prop="id" label="雪花" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('id')" />
|
|
<el-table-column type="index" width="50" align="center" />
|
|
<el-table-column prop="lightOperation" label="操作内容" align="center" v-if="columns.showColumn('lightOperation')">
|
|
<template #default="scope">
|
|
{{ scope.row.lightOperation == 1 ? '亮灯' : '灭灯' }}
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="shelfCode" label="货架号" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('shelfCode')" />
|
|
<el-table-column prop="operationer" label="操作人" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('operationer')"> </el-table-column>
|
|
<el-table-column prop="createdTime" label="创建时间" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('createdTime')" />
|
|
<el-table-column label="操作" width="160" align="center">
|
|
<template #default="scope">
|
|
<!-- <el-button type="success" size="small" icon="edit" title="编辑" v-hasPermi="['lightlog:edit']" @click="handleUpdate(scope.row)"></el-button> -->
|
|
<el-button type="danger" size="small" icon="delete" title="删除" v-hasPermi="['lightlog:delete']" @click="handleDelete(scope.row)"></el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<pagination :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
|
|
|
<el-dialog :title="title" :lock-scroll="false" v-model="open">
|
|
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
|
|
<el-row :gutter="20">
|
|
<el-col :lg="12">
|
|
<el-form-item label="雪花" prop="id">
|
|
<el-input v-model="form.id" placeholder="请输入雪花" :disabled="opertype != 1" />
|
|
</el-form-item>
|
|
</el-col>
|
|
|
|
<el-col :lg="12">
|
|
<el-form-item label="1亮灯、2灭灯" prop="lightOperation">
|
|
<el-input v-model.number="form.lightOperation" placeholder="请输入1亮灯、2灭灯" />
|
|
</el-form-item>
|
|
</el-col>
|
|
|
|
<el-col :lg="12">
|
|
<el-form-item label="货架号" prop="shelfCode">
|
|
<el-input v-model="form.shelfCode" placeholder="请输入货架号" />
|
|
</el-form-item>
|
|
</el-col>
|
|
|
|
<el-col :lg="12">
|
|
<el-form-item label="操作类别" prop="operationer">
|
|
<el-input v-model="form.operationer" placeholder="请输入P操作类别" />
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
</el-form>
|
|
<template #footer v-if="opertype != 3">
|
|
<el-button text @click="cancel">{{ $t('btn.cancel') }}</el-button>
|
|
<el-button type="primary" @click="submitForm">{{ $t('btn.submit') }}</el-button>
|
|
</template>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup name="lightlog">
|
|
import { listLightLog, addLightLog, delLightLog, updateLightLog, getLightLog } from '@/api/PBL/lightlog.js'
|
|
const { proxy } = getCurrentInstance()
|
|
const ids = ref([])
|
|
const loading = ref(false)
|
|
const showSearch = ref(true)
|
|
const queryParams = reactive({
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
timeRange: [proxy.dayjs().subtract(3, 'day').format('YYYY-MM-DD 00:00:00'), proxy.dayjs().format('YYYY-MM-DD 23:59:59')],
|
|
sort: '',
|
|
sortType: 'asc'
|
|
})
|
|
const columns = ref([
|
|
{ visible: false, align: 'center', type: '', prop: 'id', label: '雪花', showOverflowTooltip: true },
|
|
{ visible: true, align: 'center', type: '', prop: 'lightOperation', label: '1亮灯、2灭灯' },
|
|
{ visible: true, align: 'center', type: '', prop: 'shelfCode', label: '货架号', showOverflowTooltip: true },
|
|
{ visible: true, align: 'center', type: '', prop: 'operationer', label: 'PBL系统、人工', showOverflowTooltip: true },
|
|
{ visible: true, align: 'center', type: '', prop: 'createdTime', label: '创建时间', showOverflowTooltip: true }
|
|
//{ visible: false, prop: 'actions', label: '操作', type: 'slot', width: '160' }
|
|
])
|
|
const total = ref(0)
|
|
const dataList = ref([])
|
|
const queryRef = ref()
|
|
const defaultTime = ref([new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)])
|
|
|
|
var dictParams = []
|
|
|
|
function getList() {
|
|
loading.value = true
|
|
listLightLog(queryParams).then((res) => {
|
|
const { code, data } = res
|
|
if (code == 200) {
|
|
dataList.value = data.result
|
|
total.value = data.totalNum
|
|
loading.value = false
|
|
}
|
|
})
|
|
}
|
|
|
|
// 查询
|
|
function handleQuery() {
|
|
queryParams.pageNum = 1
|
|
getList()
|
|
}
|
|
|
|
// 重置查询操作
|
|
function resetQuery() {
|
|
proxy.resetForm('queryRef')
|
|
handleQuery()
|
|
}
|
|
// 自定义排序
|
|
function sortChange(column) {
|
|
var sort = undefined
|
|
var sortType = undefined
|
|
|
|
if (column.prop != null && column.order != null) {
|
|
sort = column.prop
|
|
sortType = column.order
|
|
}
|
|
queryParams.sort = sort
|
|
queryParams.sortType = sortType
|
|
handleQuery()
|
|
}
|
|
|
|
/*************** form操作 ***************/
|
|
const formRef = ref()
|
|
const title = ref('')
|
|
// 操作类型 1、add 2、edit 3、view
|
|
const opertype = ref(0)
|
|
const open = ref(false)
|
|
const state = reactive({
|
|
single: true,
|
|
multiple: true,
|
|
form: {},
|
|
rules: {
|
|
id: [{ required: true, message: '雪花不能为空', trigger: 'blur' }]
|
|
},
|
|
options: {}
|
|
})
|
|
|
|
const { form, rules, options, single, multiple } = toRefs(state)
|
|
|
|
// 关闭dialog
|
|
function cancel() {
|
|
open.value = false
|
|
reset()
|
|
}
|
|
|
|
// 重置表单
|
|
function reset() {
|
|
form.value = {
|
|
id: null,
|
|
lightOperation: null,
|
|
shelfCode: null,
|
|
operationer: null,
|
|
createdTime: null
|
|
}
|
|
proxy.resetForm('formRef')
|
|
}
|
|
|
|
// 添加按钮操作
|
|
function handleAdd() {
|
|
reset()
|
|
open.value = true
|
|
title.value = '添加'
|
|
opertype.value = 1
|
|
}
|
|
// 修改按钮操作
|
|
function handleUpdate(row) {
|
|
reset()
|
|
const id = row.id || ids.value
|
|
getLightLog(id).then((res) => {
|
|
const { code, data } = res
|
|
if (code == 200) {
|
|
open.value = true
|
|
title.value = '修改'
|
|
opertype.value = 2
|
|
|
|
form.value = {
|
|
...data
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
// 添加&修改 表单提交
|
|
function submitForm() {
|
|
proxy.$refs['formRef'].validate((valid) => {
|
|
if (valid) {
|
|
if (form.value.id != undefined && opertype.value === 2) {
|
|
updateLightLog(form.value).then((res) => {
|
|
proxy.$modal.msgSuccess('修改成功')
|
|
open.value = false
|
|
getList()
|
|
})
|
|
} else {
|
|
addLightLog(form.value).then((res) => {
|
|
proxy.$modal.msgSuccess('新增成功')
|
|
open.value = false
|
|
getList()
|
|
})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
// 删除按钮操作
|
|
function handleDelete(row) {
|
|
const Ids = row.id || ids.value
|
|
|
|
proxy
|
|
.$confirm('是否确认删除参数编号为"' + Ids + '"的数据项?', '警告', {
|
|
confirmButtonText: proxy.$t('common.ok'),
|
|
cancelButtonText: proxy.$t('common.cancel'),
|
|
type: 'warning'
|
|
})
|
|
.then(function () {
|
|
return delLightLog(Ids)
|
|
})
|
|
.then(() => {
|
|
getList()
|
|
proxy.$modal.msgSuccess('删除成功')
|
|
})
|
|
}
|
|
|
|
handleQuery()
|
|
</script>
|