文件结构修改,分组管理页面功能修改
This commit is contained in:
parent
315cfb1602
commit
bc70030714
44
src/api/fileManagement/group_management.js
Normal file
44
src/api/fileManagement/group_management.js
Normal file
@ -0,0 +1,44 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询分组管理列表
|
||||
export function listGroup_management(query) {
|
||||
return request({
|
||||
url: '/group_management/group_management/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询分组管理详细
|
||||
export function getGroup_management(groupId) {
|
||||
return request({
|
||||
url: '/group_management/group_management/' + groupId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增分组管理
|
||||
export function addGroup_management(data) {
|
||||
return request({
|
||||
url: '/group_management/group_management',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改分组管理
|
||||
export function updateGroup_management(data) {
|
||||
return request({
|
||||
url: '/group_management/group_management',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除分组管理
|
||||
export function delGroup_management(groupId) {
|
||||
return request({
|
||||
url: '/group_management/group_management/' + groupId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
27
src/api/fileManagement/sheep_file.js
Normal file
27
src/api/fileManagement/sheep_file.js
Normal file
@ -0,0 +1,27 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询羊只档案列表
|
||||
export function listSheep_file(query) {
|
||||
return request({
|
||||
url: '/sheep_file/sheep_file/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询羊只档案详细
|
||||
export function getSheep_file(id) {
|
||||
return request({
|
||||
url: '/sheep_file/sheep_file/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 删除羊只档案
|
||||
export function delSheep_file(id) {
|
||||
return request({
|
||||
url: '/sheep_file/sheep_file/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
57
src/api/fileManagement/sheepfold_management.js
Normal file
57
src/api/fileManagement/sheepfold_management.js
Normal file
@ -0,0 +1,57 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询羊舍管理列表
|
||||
export function listSheepfold_management(query) {
|
||||
return request({
|
||||
url: '/sheepfold_management/sheepfold_management/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询羊舍管理详细
|
||||
export function getSheepfold_management(id) {
|
||||
return request({
|
||||
url: '/sheepfold_management/sheepfold_management/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增羊舍管理
|
||||
export function addSheepfold_management(data) {
|
||||
return request({
|
||||
url: '/sheepfold_management/sheepfold_management',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改羊舍管理
|
||||
export function updateSheepfold_management(data) {
|
||||
return request({
|
||||
url: '/sheepfold_management/sheepfold_management',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除羊舍管理
|
||||
export function delSheepfold_management(id) {
|
||||
return request({
|
||||
url: '/sheepfold_management/sheepfold_management/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 检查羊舍编号是否已存在
|
||||
export function checkSheepfoldNoExist(ranchId, sheepfoldTypeId, sheepfoldNo) {
|
||||
return request({
|
||||
url: '/sheepfold_management/sheepfold_management/checkSheepfoldNoExist',
|
||||
method: 'get',
|
||||
params: {
|
||||
ranchId: ranchId,
|
||||
sheepfoldTypeId: sheepfoldTypeId,
|
||||
sheepfoldNo: sheepfoldNo
|
||||
}
|
||||
})
|
||||
}
|
304
src/views/fileManagement/group_management/index.vue
Normal file
304
src/views/fileManagement/group_management/index.vue
Normal file
@ -0,0 +1,304 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="分组名称" prop="groupName">
|
||||
<el-input
|
||||
v-model="queryParams.groupName"
|
||||
placeholder="请输入分组名称"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<!-- 单选框 -->
|
||||
<el-radio-group v-model="queryParams.status">
|
||||
<el-radio
|
||||
v-for="dict in group_status"
|
||||
:key="dict.value"
|
||||
:label="dict.value"
|
||||
>{{dict.label}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</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"
|
||||
v-hasPermi="['group_management:group_management:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="info"
|
||||
plain
|
||||
icon="Sort"
|
||||
@click="toggleExpandAll"
|
||||
>展开/折叠</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
v-if="refreshTable"
|
||||
v-loading="loading"
|
||||
:data="group_managementList"
|
||||
row-key="groupId"
|
||||
:default-expand-all="isExpandAll"
|
||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||
>
|
||||
<!-- <el-table-column label="上级分组" prop="parentId" /> -->
|
||||
<el-table-column label="分组名称" align="center" prop="groupName" />
|
||||
<!-- <el-table-column label="祖级列表" align="center" prop="ancestors" /> -->
|
||||
<el-table-column label="所属分组" align="center" prop="ancestorNames" />
|
||||
<!-- <el-table-column label="是否为叶子结点" align="center" prop="isLeaf" /> -->
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="group_status" :value="scope.row.status"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="创建者" align="center" prop="createBy" /> -->
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="更新者" align="center" prop="updateBy" /> -->
|
||||
<el-table-column label="更新时间" align="center" prop="updateTime" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['group_management:group_management:edit']">修改</el-button>
|
||||
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['group_management:group_management:add']">新增</el-button>
|
||||
<el-button v-if="scope.row.isLeaf === true" link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['group_management:group_management:remove']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 添加或修改分组管理对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||
<el-form ref="group_managementRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="上级分组" prop="parentId">
|
||||
<el-tree-select
|
||||
v-model="form.parentId"
|
||||
:data="group_managementOptions"
|
||||
:props="{ value: 'groupId', label: 'groupName', children: 'children' }"
|
||||
value-key="groupId"
|
||||
placeholder="请选择上级分组"
|
||||
check-strictly
|
||||
:disabled="title === '修改分组管理'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="分组名称" prop="groupName">
|
||||
<el-input v-model="form.groupName" placeholder="请输入分组名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio
|
||||
v-for="dict in group_status"
|
||||
:key="dict.value"
|
||||
:label="dict.value"
|
||||
>{{dict.label}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="Group_management">
|
||||
import { listGroup_management, getGroup_management, delGroup_management, addGroup_management, updateGroup_management } from "@/api/fileManagement/group_management"
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { group_status } = proxy.useDict('group_status')
|
||||
|
||||
const group_managementList = ref([])
|
||||
const group_managementOptions = ref([])
|
||||
const open = ref(false)
|
||||
const loading = ref(true)
|
||||
const showSearch = ref(true)
|
||||
const title = ref("")
|
||||
const isExpandAll = ref(true)
|
||||
const refreshTable = ref(true)
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
queryParams: {
|
||||
groupName: null,
|
||||
status: '0', // 默认启用状态
|
||||
},
|
||||
rules: {
|
||||
parentId: [
|
||||
{ required: true, message: "上级分组不能为空", trigger: "blur" }
|
||||
],
|
||||
groupName: [
|
||||
{ required: true, message: "分组名称不能为空", trigger: "blur" }
|
||||
],
|
||||
}
|
||||
})
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data)
|
||||
|
||||
/** 查询分组管理列表 */
|
||||
function getList() {
|
||||
loading.value = true
|
||||
listGroup_management(queryParams.value).then(response => {
|
||||
group_managementList.value = proxy.handleTree(response.data, "groupId", "parentId")
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
/** 查询分组管理下拉树结构 */
|
||||
function getTreeselect() {
|
||||
listGroup_management().then(response => {
|
||||
group_managementOptions.value = []
|
||||
const data = { groupId: 0, groupName: '顶级节点', ancestors:"0",children: [] }
|
||||
data.children = proxy.handleTree(response.data, "groupId", "parentId")
|
||||
group_managementOptions.value.push(data)
|
||||
})
|
||||
}
|
||||
|
||||
// 新增:递归查找节点函数
|
||||
function findNode(tree, id) {
|
||||
let result = null
|
||||
for (const node of tree) {
|
||||
if (node.groupId === id) return node
|
||||
if (node.children && node.children.length) {
|
||||
result = findNode(node.children, id)
|
||||
if (result) return result
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
function cancel() {
|
||||
open.value = false
|
||||
reset()
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
function reset() {
|
||||
form.value = {
|
||||
groupId: null,
|
||||
parentId: null,
|
||||
groupName: null,
|
||||
ancestors: null,
|
||||
status: '0', // 默认启用状态
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
updateBy: null,
|
||||
updateTime: null
|
||||
}
|
||||
proxy.resetForm("group_managementRef")
|
||||
}
|
||||
|
||||
/** 搜索功能 */
|
||||
function handleQuery() {
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
proxy.resetForm("queryRef")
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd(row) {
|
||||
reset()
|
||||
getTreeselect()
|
||||
if (row != null && row.groupId) {
|
||||
form.value.parentId = row.groupId
|
||||
} else {
|
||||
form.value.parentId = 0
|
||||
}
|
||||
open.value = true
|
||||
title.value = "添加分组管理"
|
||||
}
|
||||
|
||||
/** 展开/折叠操作 */
|
||||
function toggleExpandAll() {
|
||||
refreshTable.value = false
|
||||
isExpandAll.value = !isExpandAll.value
|
||||
nextTick(() => {
|
||||
refreshTable.value = true
|
||||
})
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
async function handleUpdate(row) {
|
||||
reset()
|
||||
await getTreeselect()
|
||||
if (row != null) {
|
||||
form.value.parentId = row.parentId
|
||||
}
|
||||
getGroup_management(row.groupId).then(response => {
|
||||
form.value = response.data
|
||||
open.value = true
|
||||
title.value = "修改分组管理"
|
||||
})
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["group_managementRef"].validate(valid => {
|
||||
if (valid) {
|
||||
// 新增:计算祖先路径
|
||||
if (form.value.parentId === 0) {
|
||||
form.value.ancestors = "0"
|
||||
} else {
|
||||
const parentNode = findNode(group_managementOptions.value, form.value.parentId)
|
||||
if (parentNode) {
|
||||
form.value.ancestors = `${parentNode.ancestors},${parentNode.groupId}`
|
||||
} else {
|
||||
// 找不到父节点时使用默认值
|
||||
form.value.ancestors = "0"
|
||||
}
|
||||
}
|
||||
|
||||
if (form.value.groupId != null) {
|
||||
updateGroup_management(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("修改成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
} else {
|
||||
addGroup_management(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("新增成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
proxy.$modal.confirm('是否确认删除分组管理编号为"' + row.groupId + '"的数据项?').then(function() {
|
||||
return delGroup_management(row.groupId)
|
||||
}).then(() => {
|
||||
getList()
|
||||
proxy.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
getList()
|
||||
</script>
|
1264
src/views/fileManagement/sheep_file/index.vue
Normal file
1264
src/views/fileManagement/sheep_file/index.vue
Normal file
File diff suppressed because it is too large
Load Diff
465
src/views/fileManagement/sheepfold_management/index.vue
Normal file
465
src/views/fileManagement/sheepfold_management/index.vue
Normal file
@ -0,0 +1,465 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="牧场" prop="ranchId">
|
||||
<el-select v-model="queryParams.ranchId" placeholder="请选择牧场" style="width:200px" clearable>
|
||||
<el-option
|
||||
v-for="dict in da_ranch"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="羊舍类型" prop="sheepfoldTypeId">
|
||||
<el-select v-model="queryParams.sheepfoldTypeId" placeholder="请选择羊舍类型" style="width:200px" clearable>
|
||||
<el-option
|
||||
v-for="dict in bas_sheepfold_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</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"
|
||||
v-hasPermi="['sheepfold_management:sheepfold_management:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="Edit"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['sheepfold_management:sheepfold_management:edit']"
|
||||
>修改</el-button>
|
||||
</el-col> -->
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['sheepfold_management:sheepfold_management:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="Download"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['sheepfold_management:sheepfold_management:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="sheepfold_managementList" @selection-change="handleSelectionChange" border>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="羊舍id" align="center" prop="id" sortable/>
|
||||
<el-table-column label="牧场" align="center" prop="ranchId" sortable>
|
||||
<template #default="scope">
|
||||
<dict-tag :options="da_ranch" :value="scope.row.ranchId"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="羊舍名称" align="center" prop="sheepfoldName" sortable/>
|
||||
<el-table-column label="羊舍类型" align="center" prop="sheepfoldTypeId" sortable>
|
||||
<template #default="scope">
|
||||
<dict-tag :options="bas_sheepfold_type" :value="scope.row.sheepfoldTypeId"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="羊舍编号" align="center" prop="sheepfoldNo" sortable/>
|
||||
<el-table-column label="排号" align="center" prop="rowNo" sortable/>
|
||||
<el-table-column label="栏号" align="center" prop="columns" sortable/>
|
||||
<el-table-column label="备注" align="center" prop="comment" sortable/>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<!-- <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['sheepfold_management:sheepfold_management:edit']">修改</el-button> -->
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['sheepfold_management:sheepfold_management:remove']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改羊舍管理对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||
<el-form ref="sheepfold_managementRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="牧场" prop="ranchId">
|
||||
<el-select v-model="form.ranchId" placeholder="请选择牧场">
|
||||
<el-option
|
||||
v-for="dict in da_ranch"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="parseInt(dict.value)"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="羊舍名称" prop="sheepfoldName">
|
||||
<el-input v-model="form.sheepfoldName" placeholder="请输入羊舍名称" />
|
||||
</el-form-item> -->
|
||||
<el-form-item label="羊舍类型" prop="sheepfoldTypeId">
|
||||
<el-select v-model="form.sheepfoldTypeId" placeholder="请选择羊舍类型">
|
||||
<el-option
|
||||
v-for="dict in bas_sheepfold_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="parseInt(dict.value)"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="羊舍编号" prop="sheepfoldNo">
|
||||
<el-input v-model="form.sheepfoldNo" placeholder="请输入羊舍编号" @input="validateSheepfoldNo" />
|
||||
<div v-if="sheepfoldNoExists" style="color: red; font-size: 12px; margin-top: 5px;">
|
||||
该羊舍编号已存在
|
||||
</div>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="排号" prop="rowNo">
|
||||
<el-input v-model="form.rowNo" placeholder="请输入排号" />
|
||||
</el-form-item> -->
|
||||
|
||||
<el-form-item label="排数" prop="rowCount">
|
||||
<el-input-number
|
||||
v-model="form.rowCount"
|
||||
:min="1"
|
||||
:max="10"
|
||||
@change="handleRowCountChange"
|
||||
placeholder="请输入排数"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<!-- <el-form-item label="栏号" prop="columns">
|
||||
<el-input v-model="form.columns" placeholder="请输入栏数" />
|
||||
</el-form-item> -->
|
||||
|
||||
|
||||
<!-- 动态栏位数配置 -->
|
||||
<div v-for="(row, index) in form.rowsConfig" :key="index" class="row-config">
|
||||
<el-form-item
|
||||
:label="`${String.fromCharCode(65 + index)}排栏位数`"
|
||||
:prop="`rowsConfig.${index}.columnCount`"
|
||||
:rules="{
|
||||
required: true,
|
||||
message: `请填写${String.fromCharCode(65 + index)}排栏位数`,
|
||||
trigger: 'blur'
|
||||
}"
|
||||
>
|
||||
<el-input-number
|
||||
v-model="row.columnCount"
|
||||
:min="1"
|
||||
:max="99"
|
||||
placeholder="请输入栏位数"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
|
||||
<el-form-item label="备注" prop="comment">
|
||||
<el-input v-model="form.comment" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="Sheepfold_management">
|
||||
import { listSheepfold_management, getSheepfold_management, delSheepfold_management, addSheepfold_management, updateSheepfold_management,checkSheepfoldNoExist } from "@/api/fileManagement/sheepfold_management"
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { bas_sheepfold_type, da_ranch } = proxy.useDict('bas_sheepfold_type', 'da_ranch')
|
||||
|
||||
const sheepfold_managementList = ref([])
|
||||
const open = ref(false)
|
||||
const loading = ref(true)
|
||||
const showSearch = ref(true)
|
||||
const ids = ref([])
|
||||
const single = ref(true)
|
||||
const multiple = ref(true)
|
||||
const total = ref(0)
|
||||
const title = ref("")
|
||||
const sheepfoldNoExists = ref(false) // 用于显示羊舍编号是否存在
|
||||
|
||||
const data = reactive({
|
||||
form: {
|
||||
id: null,
|
||||
ranchId: null,
|
||||
sheepfoldName: null,
|
||||
sheepfoldTypeId: null,
|
||||
sheepfoldNo: null,
|
||||
rowCount: 1, // 默认1排
|
||||
rowsConfig: [{ columnCount: 1 }], // 默认1栏
|
||||
comment: null
|
||||
},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
ranchId: null,
|
||||
sheepfoldTypeId: null,
|
||||
},
|
||||
rules: {
|
||||
rowCount: [
|
||||
{ required: true, message: "排数不能为空", trigger: "blur" },
|
||||
{ type: 'number', min: 1, max: 10, message: '排数在1-10之间', trigger: 'blur' }
|
||||
],
|
||||
sheepfoldNo: [
|
||||
{ required: true, message: "羊舍编号不能为空", trigger: "blur" },
|
||||
{ pattern: /^\d*$/, message: "羊舍编号必须为数字", trigger: "blur" }
|
||||
],
|
||||
ranchId: [
|
||||
{ required: true, message: "牧场不能为空", trigger: "blur" }
|
||||
],
|
||||
sheepfoldTypeId: [
|
||||
{ required: true, message: "羊舍类型不能为空", trigger: "blur" }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data)
|
||||
|
||||
// 排数变化处理
|
||||
const handleRowCountChange = (count) => {
|
||||
// 确保count是数字
|
||||
count = Number(count)
|
||||
|
||||
// 重置rowsConfig
|
||||
form.value.rowsConfig = []
|
||||
|
||||
// 根据排数生成配置项
|
||||
for (let i = 0; i < count; i++) {
|
||||
form.value.rowsConfig.push({
|
||||
rowLetter: String.fromCharCode(65 + i), // A, B, C...
|
||||
columnCount: 1 // 默认1栏
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询羊舍管理列表 */
|
||||
function getList() {
|
||||
loading.value = true
|
||||
listSheepfold_management(queryParams.value).then(response => {
|
||||
sheepfold_managementList.value = response.rows
|
||||
total.value = response.total
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
function cancel() {
|
||||
open.value = false
|
||||
reset()
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
function reset() {
|
||||
form.value = {
|
||||
id: null,
|
||||
ranchId: null,
|
||||
sheepfoldName: null,
|
||||
sheepfoldTypeId: null,
|
||||
sheepfoldNo: null,
|
||||
rowCount: 1,
|
||||
rowsConfig: [{ columnCount: 1 }],
|
||||
comment: null
|
||||
}
|
||||
proxy.resetForm("sheepfold_managementRef")
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
queryParams.value.pageNum = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
proxy.resetForm("queryRef")
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
// 多选框选中数据
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map(item => item.id)
|
||||
single.value = selection.length != 1
|
||||
multiple.value = !selection.length
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
reset()
|
||||
open.value = true
|
||||
sheepfoldNoExists.value = false
|
||||
title.value = "添加羊舍管理"
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
// function handleUpdate(row) {
|
||||
// reset()
|
||||
// const _id = row.id || ids.value
|
||||
// getSheepfold_management(_id).then(response => {
|
||||
// form.value = response.data
|
||||
// // 修改时不需要rowsConfig
|
||||
// if (form.value.rowsConfig) {
|
||||
// delete form.value.rowsConfig
|
||||
// delete form.value.rowCount
|
||||
// }
|
||||
// open.value = true
|
||||
// title.value = "修改羊舍管理"
|
||||
// })
|
||||
// }
|
||||
/**查找字典 */
|
||||
function findDictLabelByValue(dictOptions, value) {
|
||||
const formattedValue = String(value);
|
||||
const foundOption = dictOptions.value.find(option => option.value === formattedValue);
|
||||
return foundOption ? foundOption.label : '';
|
||||
}
|
||||
|
||||
// 验证羊舍编号,确保只能输入数字
|
||||
function validateSheepfoldNo() {
|
||||
const sheepfoldNo = form.value.sheepfoldNo
|
||||
if (sheepfoldNo) {
|
||||
// 移除非数字字符
|
||||
const cleanedInput = sheepfoldNo.replace(/\D/g, '')
|
||||
if (cleanedInput !== sheepfoldNo) {
|
||||
form.value.sheepfoldNo = cleanedInput
|
||||
proxy.$modal.msgWarning("羊舍编号只能输入数字")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查羊舍编号是否已存在
|
||||
async function checkSheepfoldNoExistence() {
|
||||
|
||||
if (!form.value.sheepfoldNo || !form.value.ranchId || !form.value.sheepfoldTypeId) {
|
||||
sheepfoldNoExists.value = false
|
||||
return
|
||||
}
|
||||
try {
|
||||
const exist = await checkSheepfoldNoExist(form.value.ranchId, form.value.sheepfoldTypeId, form.value.sheepfoldNo)
|
||||
|
||||
sheepfoldNoExists.value = exist.data
|
||||
} catch (error) {
|
||||
proxy.$modal.msgError("检查羊舍编号时出错:" + error.message)
|
||||
sheepfoldNoExists.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["sheepfold_managementRef"].validate(async valid => {
|
||||
if (valid) {
|
||||
// 检查羊舍编号是否已存在
|
||||
await checkSheepfoldNoExistence()
|
||||
if (sheepfoldNoExists.value) {
|
||||
proxy.$modal.msgError("该羊舍编号已存在,无法重复添加")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (form.value.id != null) {
|
||||
// 修改操作 - 单条记录
|
||||
updateSheepfold_management(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("修改成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
} else {
|
||||
// 新增操作 - 多条记录
|
||||
const requests = []
|
||||
const ranchName = findDictLabelByValue(da_ranch, form.value.ranchId)
|
||||
const typeName = findDictLabelByValue(bas_sheepfold_type, form.value.sheepfoldTypeId)
|
||||
|
||||
// 生成每条记录的数据
|
||||
form.value.rowsConfig.forEach((rowConfig, rowIndex) => {
|
||||
// 使用行索引 + 1 作为排号
|
||||
const rowNo = String.fromCharCode(65 + rowIndex) // A, B, C...
|
||||
|
||||
for (let i = 1; i <= rowConfig.columnCount; i++) {
|
||||
const columnNo = i.toString().padStart(2, '0') // 01, 02, 03...
|
||||
const record = {
|
||||
ranchId: form.value.ranchId,
|
||||
sheepfoldTypeId: form.value.sheepfoldTypeId,
|
||||
sheepfoldNo: form.value.sheepfoldNo,
|
||||
rowNo: rowNo, // 使用正确的排号
|
||||
columns: columnNo,
|
||||
comment: form.value.comment,
|
||||
// 自动生成羊舍名称:羊舍编号 + 类型 + 排号栏号
|
||||
sheepfoldName: `${form.value.sheepfoldNo}号-${typeName}-${rowNo}${columnNo}`
|
||||
}
|
||||
requests.push(addSheepfold_management(record))
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// 执行所有新增请求
|
||||
Promise.all(requests)
|
||||
.then(() => {
|
||||
proxy.$modal.msgSuccess(`新增成功,共添加${requests.length}条记录`)
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
.catch(error => {
|
||||
proxy.$modal.msgError("部分记录添加失败:" + error.message)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
const _ids = row.id || ids.value
|
||||
proxy.$modal.confirm('是否确认删除羊舍管理编号为"' + _ids + '"的数据项?').then(function() {
|
||||
return delSheepfold_management(_ids)
|
||||
}).then(() => {
|
||||
getList()
|
||||
proxy.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
function handleExport() {
|
||||
proxy.download('sheepfold_management/sheepfold_management/export', {
|
||||
...queryParams.value
|
||||
}, `sheepfold_management_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
getList()
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped>
|
||||
.row-config {
|
||||
margin-bottom: 15px;
|
||||
padding: 10px;
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 4px;
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
</style>
|
Loading…
x
Reference in New Issue
Block a user