test
This commit is contained in:
57
src/api/materialManagement/mminventory.js
Normal file
57
src/api/materialManagement/mminventory.js
Normal file
@@ -0,0 +1,57 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
/**
|
||||
* 库存表分页查询
|
||||
* @param {查询条件} data
|
||||
*/
|
||||
export function listMmInventory(query) {
|
||||
return request({
|
||||
url: 'BZFM/MmInventory/list',
|
||||
method: 'get',
|
||||
params: query,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增库存表
|
||||
* @param data
|
||||
*/
|
||||
export function addMmInventory(data) {
|
||||
return request({
|
||||
url: 'BZFM/MmInventory',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 修改库存表
|
||||
* @param data
|
||||
*/
|
||||
export function updateMmInventory(data) {
|
||||
return request({
|
||||
url: 'BZFM/MmInventory',
|
||||
method: 'PUT',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 获取库存表详情
|
||||
* @param {Id}
|
||||
*/
|
||||
export function getMmInventory(id) {
|
||||
return request({
|
||||
url: 'BZFM/MmInventory/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除库存表
|
||||
* @param {主键} pid
|
||||
*/
|
||||
export function delMmInventory(pid) {
|
||||
return request({
|
||||
url: 'BZFM/MmInventory/delete/' + pid,
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
44
src/api/testModule/index.js
Normal file
44
src/api/testModule/index.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询测试模块列表
|
||||
export function listTestModule(query) {
|
||||
return request({
|
||||
url: '/testModule/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询测试模块详细
|
||||
export function getTestModule(id) {
|
||||
return request({
|
||||
url: '/testModule/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增测试模块
|
||||
export function addTestModule(data) {
|
||||
return request({
|
||||
url: '/testModule/add',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改测试模块
|
||||
export function updateTestModule(data) {
|
||||
return request({
|
||||
url: '/testModule/edit',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除测试模块
|
||||
export function delTestModule(id) {
|
||||
return request({
|
||||
url: '/testModule/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
@@ -164,6 +164,18 @@ export const constantRoutes = [
|
||||
meta: { title: '个人中心', icon: 'user', titleKey: 'menu.personalCenter' }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/testModule',
|
||||
component: Layout,
|
||||
children: [
|
||||
{
|
||||
path: 'index',
|
||||
component: () => import('@/views/testModule/index'),
|
||||
name: 'TestModule',
|
||||
meta: { title: '测试模块', icon: 'component', titleKey: 'menu.testModule' }
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
365
src/views/materialManagement/MmInventory.vue
Normal file
365
src/views/materialManagement/MmInventory.vue
Normal file
@@ -0,0 +1,365 @@
|
||||
<!--
|
||||
* @Descripttion: (库存表/mm_inventory)
|
||||
* @Author: (mes)
|
||||
* @Date: (2025-12-24)
|
||||
-->
|
||||
<template>
|
||||
<div>
|
||||
<el-form :model="queryParams" label-position="right" inline ref="queryRef" v-show="showSearch" @submit.prevent>
|
||||
<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="['mminventory: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="主键ID" align="center" v-if="columns.showColumn('id')"/>
|
||||
<el-table-column prop="materialCode" label="物料编码" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('materialCode')"/>
|
||||
<el-table-column prop="warehouseCode" label="仓库编码" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('warehouseCode')"/>
|
||||
<el-table-column prop="warehouseName" label="仓库名称" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('warehouseName')"/>
|
||||
<el-table-column prop="locationCode" label="库位编码" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('locationCode')"/>
|
||||
<el-table-column prop="locationName" label="库位名称" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('locationName')"/>
|
||||
<el-table-column prop="batchNo" label="批次号" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('batchNo')"/>
|
||||
<el-table-column prop="currentQty" label="当前库存量" align="center" v-if="columns.showColumn('currentQty')"/>
|
||||
<el-table-column prop="unit" label="计量单位" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('unit')"/>
|
||||
<el-table-column prop="productionDate" label="生产日期" :show-overflow-tooltip="true" v-if="columns.showColumn('productionDate')"/>
|
||||
<el-table-column prop="expiryDate" label="有效期至" :show-overflow-tooltip="true" v-if="columns.showColumn('expiryDate')"/>
|
||||
<el-table-column prop="lastUpdatedTime" label="最后更新时间" :show-overflow-tooltip="true" v-if="columns.showColumn('lastUpdatedTime')"/>
|
||||
<el-table-column prop="createdTime" label="创建时间" :show-overflow-tooltip="true" v-if="columns.showColumn('createdTime')"/>
|
||||
<el-table-column label="操作" width="160">
|
||||
<template #default="scope">
|
||||
<el-button type="success" size="small" icon="edit" title="编辑" v-hasPermi="['mminventory:edit']" @click="handleUpdate(scope.row)"></el-button>
|
||||
<el-button type="danger" size="small" icon="delete" title="删除" v-hasPermi="['mminventory: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" v-if="opertype != 1">
|
||||
<el-form-item label="主键ID" prop="id">
|
||||
<el-input-number v-model.number="form.id" controls-position="right" placeholder="请输入主键ID" :disabled="true"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="物料编码" prop="materialCode">
|
||||
<el-input v-model="form.materialCode" placeholder="请输入物料编码" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="仓库编码" prop="warehouseCode">
|
||||
<el-input v-model="form.warehouseCode" placeholder="请输入仓库编码" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="仓库名称" prop="warehouseName">
|
||||
<el-input v-model="form.warehouseName" placeholder="请输入仓库名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="库位编码" prop="locationCode">
|
||||
<el-input v-model="form.locationCode" placeholder="请输入库位编码" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="库位名称" prop="locationName">
|
||||
<el-input v-model="form.locationName" placeholder="请输入库位名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="批次号" prop="batchNo">
|
||||
<el-input v-model="form.batchNo" placeholder="请输入批次号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="当前库存量" prop="currentQty">
|
||||
<el-input v-model="form.currentQty" placeholder="请输入当前库存量" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="计量单位" prop="unit">
|
||||
<el-input v-model="form.unit" placeholder="请输入计量单位" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="生产日期" prop="productionDate">
|
||||
<el-date-picker
|
||||
v-model="form.productionDate"
|
||||
type="datetime"
|
||||
placeholder="选择日期时间"
|
||||
value-format="YYYY-MM-DD HH:mm:ss">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="有效期至" prop="expiryDate">
|
||||
<el-date-picker
|
||||
v-model="form.expiryDate"
|
||||
type="datetime"
|
||||
placeholder="选择日期时间"
|
||||
value-format="YYYY-MM-DD HH:mm:ss">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="最后更新时间" prop="lastUpdatedTime">
|
||||
<el-date-picker
|
||||
v-model="form.lastUpdatedTime"
|
||||
type="datetime"
|
||||
placeholder="选择日期时间"
|
||||
value-format="YYYY-MM-DD HH:mm:ss">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item label="创建时间" prop="createdTime">
|
||||
<el-date-picker
|
||||
v-model="form.createdTime"
|
||||
type="datetime"
|
||||
placeholder="选择日期时间"
|
||||
value-format="YYYY-MM-DD HH:mm:ss">
|
||||
</el-date-picker>
|
||||
</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="mminventory">
|
||||
import { listMmInventory,
|
||||
addMmInventory, delMmInventory,
|
||||
updateMmInventory,getMmInventory,
|
||||
}
|
||||
from '@/api/materialManagement/mminventory.js'
|
||||
const { proxy } = getCurrentInstance()
|
||||
const ids = ref([])
|
||||
const loading = ref(false)
|
||||
const showSearch = ref(true)
|
||||
const queryParams = reactive({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
sort: '',
|
||||
sortType: 'asc',
|
||||
})
|
||||
const columns = ref([
|
||||
{ visible: true, align: 'center', type: '', prop: 'id', label: '主键ID' },
|
||||
{ visible: true, align: 'center', type: '', prop: 'materialCode', label: '物料编码' ,showOverflowTooltip: true },
|
||||
{ visible: true, align: 'center', type: '', prop: 'warehouseCode', label: '仓库编码' ,showOverflowTooltip: true },
|
||||
{ visible: true, align: 'center', type: '', prop: 'warehouseName', label: '仓库名称' ,showOverflowTooltip: true },
|
||||
{ visible: true, align: 'center', type: '', prop: 'locationCode', label: '库位编码' ,showOverflowTooltip: true },
|
||||
{ visible: true, align: 'center', type: '', prop: 'locationName', label: '库位名称' ,showOverflowTooltip: true },
|
||||
{ visible: true, align: 'center', type: '', prop: 'batchNo', label: '批次号' ,showOverflowTooltip: true },
|
||||
{ visible: true, align: 'center', type: '', prop: 'currentQty', label: '当前库存量' },
|
||||
{ visible: false, align: 'center', type: '', prop: 'unit', label: '计量单位' ,showOverflowTooltip: true },
|
||||
{ visible: false, align: 'center', type: '', prop: 'productionDate', label: '生产日期' ,showOverflowTooltip: true },
|
||||
{ visible: false, align: 'center', type: '', prop: 'expiryDate', label: '有效期至' ,showOverflowTooltip: true },
|
||||
{ visible: false, align: 'center', type: '', prop: 'lastUpdatedTime', label: '最后更新时间' ,showOverflowTooltip: true },
|
||||
{ visible: false, 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
|
||||
listMmInventory(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: {
|
||||
materialCode: [{ required: true, message: "物料编码不能为空", trigger: "blur" }],
|
||||
warehouseCode: [{ required: true, message: "仓库编码不能为空", trigger: "blur" }],
|
||||
locationCode: [{ 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,
|
||||
materialCode: null,
|
||||
warehouseCode: null,
|
||||
warehouseName: null,
|
||||
locationCode: null,
|
||||
locationName: null,
|
||||
batchNo: null,
|
||||
currentQty: null,
|
||||
unit: null,
|
||||
productionDate: null,
|
||||
expiryDate: null,
|
||||
lastUpdatedTime: 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
|
||||
getMmInventory(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) {
|
||||
updateMmInventory(form.value).then((res) => {
|
||||
proxy.$modal.msgSuccess("修改成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
} else {
|
||||
addMmInventory(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 delMmInventory(Ids)
|
||||
})
|
||||
.then(() => {
|
||||
getList()
|
||||
proxy.$modal.msgSuccess("删除成功")
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
handleQuery()
|
||||
</script>
|
||||
269
src/views/testModule/index.vue
Normal file
269
src/views/testModule/index.vue
Normal file
@@ -0,0 +1,269 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="80px">
|
||||
<el-form-item label="测试名称" prop="name">
|
||||
<el-input v-model="queryParams.name" placeholder="请输入测试名称" clearable style="width: 240px" @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="选择状态" clearable style="width: 240px">
|
||||
<el-option label="全部" :value="''" />
|
||||
<el-option label="启用" :value="1" />
|
||||
<el-option label="禁用" :value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="search" @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="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd">
|
||||
{{ $t('btn.add') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate">
|
||||
{{ $t('btn.edit') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete">
|
||||
{{ $t('btn.delete') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="testModuleList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="50" align="center" />
|
||||
<el-table-column label="ID" align="center" prop="id" width="80" />
|
||||
<el-table-column label="测试名称" align="center" prop="name" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="状态" align="center" prop="status" width="100">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="statusOptions" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button size="small" type="primary" icon="Edit" @click="handleUpdate(scope.row)">
|
||||
{{ $t('btn.edit') }}
|
||||
</el-button>
|
||||
<el-button size="small" type="danger" icon="Delete" @click="handleDelete(scope.row)">
|
||||
{{ $t('btn.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"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改测试模块对话框 -->
|
||||
<el-dialog v-model="open" title="{{ $t('testModule.title') }}" width="500px" append-to-body>
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="测试名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入测试名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio label="1">启用</el-radio>
|
||||
<el-radio label="0">禁用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="cancel">取消</el-button>
|
||||
<el-button type="primary" @click="submitForm">确定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, toRefs, onMounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { ElMessageBox, ElMessage } from 'element-plus'
|
||||
import { listTestModule, getTestModule, delTestModule, addTestModule, updateTestModule } from '@/api/testModule'
|
||||
import Pagination from '@/components/Pagination'
|
||||
import RightToolbar from '@/components/RightToolbar'
|
||||
import DictTag from '@/components/DictTag'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
// 表格数据
|
||||
const testModuleList = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const columns = ref({})
|
||||
const showSearch = ref(true)
|
||||
|
||||
// 表单引用
|
||||
const formRef = ref(null)
|
||||
const queryRef = ref(null)
|
||||
|
||||
// 表单参数
|
||||
const form = reactive({
|
||||
id: null,
|
||||
name: '',
|
||||
status: '1'
|
||||
})
|
||||
|
||||
// 查询参数
|
||||
const queryParams = reactive({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
name: '',
|
||||
status: ''
|
||||
})
|
||||
|
||||
// 表单校验
|
||||
const rules = reactive({
|
||||
name: [
|
||||
{ required: true, message: '请输入测试名称', trigger: 'blur' }
|
||||
]
|
||||
})
|
||||
|
||||
// 状态字典
|
||||
const statusOptions = ref([])
|
||||
|
||||
// 弹窗状态
|
||||
const open = ref(false)
|
||||
|
||||
// 选中的行
|
||||
const ids = ref([])
|
||||
const single = ref(true)
|
||||
const multiple = ref(true)
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
|
||||
// 获取列表
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const { data } = await listTestModule(queryParams)
|
||||
testModuleList.value = data.rows
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 查询按钮
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNum = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
// 重置按钮
|
||||
const resetQuery = () => {
|
||||
Object.assign(queryParams, {
|
||||
name: '',
|
||||
status: ''
|
||||
})
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
// 新增按钮
|
||||
const handleAdd = () => {
|
||||
open.value = true
|
||||
resetForm()
|
||||
}
|
||||
|
||||
// 修改按钮
|
||||
const handleUpdate = (row) => {
|
||||
resetForm()
|
||||
if (row) {
|
||||
form.id = row.id
|
||||
getTestModule(row.id).then(response => {
|
||||
Object.assign(form, response.data)
|
||||
open.value = true
|
||||
})
|
||||
} else {
|
||||
const id = ids.value[0]
|
||||
getTestModule(id).then(response => {
|
||||
Object.assign(form, response.data)
|
||||
open.value = true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 删除按钮
|
||||
const handleDelete = (row) => {
|
||||
const ids = row ? [row.id] : ids.value
|
||||
ElMessageBox.confirm(
|
||||
'确定要删除选中的数据吗?',
|
||||
'警告',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}
|
||||
).then(() => {
|
||||
return delTestModule(ids)
|
||||
}).then(() => {
|
||||
ElMessage.success('删除成功')
|
||||
getList()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
// 选择行变化
|
||||
const handleSelectionChange = (selection) => {
|
||||
ids.value = selection.map(item => item.id)
|
||||
single.value = selection.length !== 1
|
||||
multiple.value = !selection.length
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
const resetForm = () => {
|
||||
Object.assign(form, {
|
||||
id: null,
|
||||
name: '',
|
||||
status: '1'
|
||||
})
|
||||
}
|
||||
|
||||
// 表单提交
|
||||
const submitForm = () => {
|
||||
formRef.value.validate((valid) => {
|
||||
if (valid) {
|
||||
if (form.id) {
|
||||
updateTestModule(form).then(response => {
|
||||
ElMessage.success('修改成功')
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
} else {
|
||||
addTestModule(form).then(response => {
|
||||
ElMessage.success('新增成功')
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
const cancel = () => {
|
||||
open.value = false
|
||||
resetForm()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 可以添加自定义样式 */
|
||||
</style>
|
||||
Reference in New Issue
Block a user