2025-07-12 17:58:55 +08:00
|
|
|
<template>
|
|
|
|
<div class="app-container">
|
2025-07-18 11:35:41 +08:00
|
|
|
<!-- 查询表单 -->
|
2025-07-29 22:01:14 +08:00
|
|
|
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
|
|
|
<el-form-item label="管理耳号" prop="manageTags">
|
|
|
|
<el-input v-model="queryParams.manageTags" placeholder="请输入管理耳号" clearable @keyup.enter="handleQuery" style="width: 150px;"/>
|
2025-07-12 17:58:55 +08:00
|
|
|
</el-form-item>
|
2025-07-18 11:35:41 +08:00
|
|
|
<el-form-item label="品种" prop="varietyId">
|
|
|
|
<el-select v-model="queryParams.varietyId" placeholder="请选择品种" style="min-width:150px" clearable>
|
|
|
|
<el-option v-for="item in varietyOptions" :key="item.id" :label="item.variety" :value="item.id" />
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
2025-07-12 17:58:55 +08:00
|
|
|
<el-form-item label="转入牧场" prop="transTo">
|
2025-07-29 22:01:14 +08:00
|
|
|
<el-select v-model="queryParams.transTo" placeholder="请选择转入牧场" clearable style="min-width:150px">
|
|
|
|
<el-option v-for="ranch in ranchOptions" :key="ranch.id" :label="ranch.ranchName" :value="ranch.ranchName" />
|
|
|
|
</el-select>
|
2025-07-12 17:58:55 +08:00
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="当前牧场" prop="transFrom">
|
2025-07-29 22:01:14 +08:00
|
|
|
<el-select v-model="queryParams.transFrom" placeholder="请选择当前牧场" clearable style="min-width:150px">
|
|
|
|
<el-option v-for="ranch in ranchOptions" :key="ranch.id" :label="ranch.ranchName" :value="ranch.ranchName" />
|
|
|
|
</el-select>
|
2025-07-12 17:58:55 +08:00
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="状态" prop="status">
|
2025-07-18 11:35:41 +08:00
|
|
|
<el-select v-model="queryParams.status" style="width: 150px" placeholder="请选择状态" clearable>
|
|
|
|
<el-option v-for="dict in status" :key="dict.value" :label="dict.label" :value="dict.value" />
|
2025-07-12 17:58:55 +08:00
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="创建时间" style="width: 308px">
|
2025-07-29 22:01:14 +08:00
|
|
|
<el-date-picker v-model="daterangeCreateTime" value-format="YYYY-MM-DD" type="daterange" range-separator="-"
|
|
|
|
start-placeholder="开始日期" end-placeholder="结束日期" />
|
2025-07-12 17:58:55 +08:00
|
|
|
</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>
|
|
|
|
|
2025-07-18 11:35:41 +08:00
|
|
|
<!-- 按钮行 -->
|
2025-07-12 17:58:55 +08:00
|
|
|
<el-row :gutter="10" class="mb8">
|
|
|
|
<el-col :span="1.5">
|
2025-07-18 11:35:41 +08:00
|
|
|
<el-button type="primary" plain icon="Plus" @click="handleAdd"
|
2025-07-29 22:01:14 +08:00
|
|
|
v-hasPermi="['transition_info:transition_info:add']">新增</el-button>
|
2025-07-12 17:58:55 +08:00
|
|
|
</el-col>
|
|
|
|
<el-col :span="1.5">
|
2025-07-18 11:35:41 +08:00
|
|
|
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate"
|
2025-07-29 22:01:14 +08:00
|
|
|
v-hasPermi="['transition_info:transition_info:edit']">修改</el-button>
|
2025-07-12 17:58:55 +08:00
|
|
|
</el-col>
|
|
|
|
<el-col :span="1.5">
|
2025-07-18 11:35:41 +08:00
|
|
|
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
|
2025-07-29 22:01:14 +08:00
|
|
|
v-hasPermi="['transition_info:transition_info:remove']">删除</el-button>
|
2025-07-12 17:58:55 +08:00
|
|
|
</el-col>
|
|
|
|
<el-col :span="1.5">
|
2025-07-18 11:35:41 +08:00
|
|
|
<el-button type="warning" plain icon="Download" @click="handleExport"
|
2025-07-29 22:01:14 +08:00
|
|
|
v-hasPermi="['transition_info:transition_info:export']">导出</el-button>
|
2025-07-12 17:58:55 +08:00
|
|
|
</el-col>
|
2025-07-18 11:35:41 +08:00
|
|
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
|
2025-07-12 17:58:55 +08:00
|
|
|
</el-row>
|
|
|
|
|
2025-07-18 11:35:41 +08:00
|
|
|
<!-- 列表 -->
|
2025-07-12 17:58:55 +08:00
|
|
|
<el-table v-loading="loading" :data="transition_infoList" @selection-change="handleSelectionChange">
|
|
|
|
<el-table-column type="selection" width="55" align="center" />
|
2025-07-29 22:01:14 +08:00
|
|
|
<el-table-column label="耳号" align="center" prop="manageTags" />
|
|
|
|
<el-table-column label="品种" align="center" prop="varietyName" />
|
2025-07-12 17:58:55 +08:00
|
|
|
<el-table-column label="转入牧场" align="center" prop="transTo" />
|
|
|
|
<el-table-column label="当前牧场" align="center" prop="transFrom" />
|
|
|
|
<el-table-column label="状态" align="center" prop="status">
|
|
|
|
<template #default="scope">
|
2025-07-18 11:35:41 +08:00
|
|
|
<dict-tag :options="status" :value="scope.row.status" />
|
2025-07-12 17:58:55 +08:00
|
|
|
</template>
|
|
|
|
</el-table-column>
|
2025-07-29 22:01:14 +08:00
|
|
|
<el-table-column label="技术员" align="center" prop="technician" />
|
|
|
|
<el-table-column label="状态" align="center" prop="statusText" />
|
2025-07-12 17:58:55 +08:00
|
|
|
<el-table-column label="备注" align="center" prop="comment" />
|
|
|
|
<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>
|
2025-07-18 11:35:41 +08:00
|
|
|
<el-table-column label="操作" align="center" min-width="180">
|
2025-07-12 17:58:55 +08:00
|
|
|
<template #default="scope">
|
2025-07-18 11:35:41 +08:00
|
|
|
<el-button link type="primary" icon="Edit" @click="handleApprove(scope.row)"
|
2025-07-29 22:01:14 +08:00
|
|
|
v-hasPermi="['transition_info:transition_info:approve']">审批</el-button>
|
2025-07-18 11:35:41 +08:00
|
|
|
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
|
2025-07-29 22:01:14 +08:00
|
|
|
v-hasPermi="['transition_info:transition_info:remove']">删除</el-button>
|
2025-07-12 17:58:55 +08:00
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
|
|
|
2025-07-18 11:35:41 +08:00
|
|
|
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
|
2025-07-29 22:01:14 +08:00
|
|
|
v-model:limit="queryParams.pageSize" @pagination="getList" />
|
2025-07-18 11:35:41 +08:00
|
|
|
|
|
|
|
<!-- 新增/修改 -->
|
2025-07-12 17:58:55 +08:00
|
|
|
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
|
|
|
<el-form ref="transition_infoRef" :model="form" :rules="rules" label-width="80px">
|
2025-07-29 22:01:14 +08:00
|
|
|
<el-form-item label="管理耳号" prop="manageTags">
|
|
|
|
<el-select v-model="form.manageTags" placeholder="请输入或选择耳号" filterable multiple allow-create
|
|
|
|
@change="loadSheepInfo" :disabled="!isAdd" >
|
|
|
|
<el-option v-for="sheep in sheepOptions" :key="sheep.id" :label="sheep.manageTags"
|
|
|
|
:value="sheep.manageTags" />
|
2025-07-18 11:35:41 +08:00
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
|
2025-07-12 17:58:55 +08:00
|
|
|
<el-form-item label="转入牧场" prop="transTo">
|
2025-07-29 22:01:14 +08:00
|
|
|
<el-select v-model="form.transTo" placeholder="请选择转入牧场" clearable :disabled="!isAdd" >
|
|
|
|
<el-option v-for="ranch in ranchOptions" :key="ranch.id" :label="ranch.ranchName"
|
|
|
|
:value="ranch.ranchName" />
|
|
|
|
</el-select>
|
2025-07-12 17:58:55 +08:00
|
|
|
</el-form-item>
|
2025-07-18 11:35:41 +08:00
|
|
|
|
2025-07-12 17:58:55 +08:00
|
|
|
<el-form-item label="当前牧场" prop="transFrom">
|
2025-07-29 22:01:14 +08:00
|
|
|
<el-select v-model="form.transFrom" placeholder="请选择当前牧场" clearable @change="handleRanchChange" :disabled="!isAdd" >
|
|
|
|
<el-option v-for="ranch in ranchOptions" :key="ranch.id" :label="ranch.ranchName"
|
|
|
|
:value="ranch.ranchName" />
|
|
|
|
</el-select>
|
2025-07-12 17:58:55 +08:00
|
|
|
</el-form-item>
|
2025-07-18 11:35:41 +08:00
|
|
|
|
2025-07-12 17:58:55 +08:00
|
|
|
<el-form-item label="转场类型" prop="transType">
|
|
|
|
<el-select v-model="form.transType" placeholder="请选择转场类型">
|
2025-07-29 22:01:14 +08:00
|
|
|
<el-option v-for="dict in trans_type" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
|
2025-07-12 17:58:55 +08:00
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
2025-07-18 11:35:41 +08:00
|
|
|
|
2025-07-12 17:58:55 +08:00
|
|
|
<el-form-item label="技术员" prop="technician">
|
|
|
|
<el-input v-model="form.technician" placeholder="请输入技术员" />
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
2025-07-18 11:35:41 +08:00
|
|
|
|
2025-07-12 17:58:55 +08:00
|
|
|
<template #footer>
|
|
|
|
<div class="dialog-footer">
|
|
|
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
|
<el-button @click="cancel">取 消</el-button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</el-dialog>
|
|
|
|
|
2025-07-18 11:35:41 +08:00
|
|
|
<!-- 审批对话框 -->
|
|
|
|
<el-dialog :title="'审批转场记录'" v-model="approveDialog" width="500px" append-to-body>
|
|
|
|
<el-form ref="approveFormRef" :model="approveForm" label-width="120px">
|
2025-07-29 22:01:14 +08:00
|
|
|
<el-form-item label="管理耳号">
|
|
|
|
<el-input v-model="displayManageTags" disabled />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="品种">
|
|
|
|
<el-input :value="approveForm.varietyName" disabled />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="转入牧场">
|
|
|
|
<el-input :value="approveForm.transTo" disabled />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="当前牧场">
|
|
|
|
<el-input :value="approveForm.transFrom" disabled />
|
|
|
|
</el-form-item>
|
2025-07-18 11:35:41 +08:00
|
|
|
<el-form-item label="转场类型">
|
2025-07-29 22:01:14 +08:00
|
|
|
<el-input :value="approveForm.transTypeText || '未知类型'" disabled />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="技术员">
|
|
|
|
<el-input v-model="approveForm.technician" disabled />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="备注">
|
|
|
|
<el-input v-model="approveForm.comment" disabled />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="状态">
|
|
|
|
<el-input :value="getStatusLabel(approveForm.status)" disabled />
|
2025-07-18 11:35:41 +08:00
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
<template #footer>
|
|
|
|
<div class="dialog-footer">
|
|
|
|
<el-button type="primary" @click="handleApproveAgree">同意</el-button>
|
|
|
|
<el-button type="danger" @click="handleApproveReject">驳回</el-button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</el-dialog>
|
|
|
|
</div>
|
2025-07-12 17:58:55 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup name="Transition_info">
|
2025-07-29 22:01:14 +08:00
|
|
|
import { listTransition_info, getTransition_info, delTransition_info, addTransition_info, getSheepByRanchId, updateTransition_info, listRanch,approveTransitionInfo } from "@/api/produce/manage_sheep/transition_info"
|
|
|
|
import { checkSheepByManageTags, getSheepBySheepfoldId } from '@/api/produce/other/fixHoof'
|
2025-07-18 11:35:41 +08:00
|
|
|
import request from '@/utils/request'
|
2025-07-12 17:58:55 +08:00
|
|
|
|
2025-07-29 22:01:14 +08:00
|
|
|
|
2025-07-12 17:58:55 +08:00
|
|
|
const { proxy } = getCurrentInstance()
|
|
|
|
const { status, trans_type } = proxy.useDict('status', 'trans_type')
|
|
|
|
|
|
|
|
const transition_infoList = ref([])
|
2025-07-29 22:01:14 +08:00
|
|
|
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('')
|
2025-07-12 17:58:55 +08:00
|
|
|
const daterangeCreateTime = ref([])
|
2025-07-18 11:35:41 +08:00
|
|
|
const approveDialog = ref(false)
|
2025-07-29 22:01:14 +08:00
|
|
|
const approveForm = ref({})
|
|
|
|
const displayManageTags = ref('')
|
2025-07-18 11:35:41 +08:00
|
|
|
const varietyOptions = ref([])
|
2025-07-29 22:01:14 +08:00
|
|
|
const ranchOptions = ref([]);
|
|
|
|
const sheepOptions = ref([]);
|
|
|
|
const isAdd = ref(true);
|
|
|
|
const isEdit = ref(false);
|
2025-07-18 11:35:41 +08:00
|
|
|
|
2025-07-12 17:58:55 +08:00
|
|
|
const data = reactive({
|
2025-07-29 22:01:14 +08:00
|
|
|
form: {
|
|
|
|
id: null,
|
|
|
|
manageTags: [],
|
|
|
|
transTo: null,
|
|
|
|
transFrom: null,
|
|
|
|
transType: null,
|
|
|
|
technician: null,
|
|
|
|
tagDetails: {}
|
|
|
|
},
|
2025-07-12 17:58:55 +08:00
|
|
|
queryParams: {
|
|
|
|
pageNum: 1,
|
|
|
|
pageSize: 10,
|
2025-07-29 22:01:14 +08:00
|
|
|
manageTags: [],
|
2025-07-18 11:35:41 +08:00
|
|
|
varietyId: null,
|
2025-07-12 17:58:55 +08:00
|
|
|
transTo: null,
|
|
|
|
transFrom: null,
|
|
|
|
status: null,
|
|
|
|
createTime: null
|
|
|
|
},
|
|
|
|
rules: {
|
2025-07-29 22:01:14 +08:00
|
|
|
manageTags:[
|
|
|
|
{ required: true, message: "请输入管理耳号", trigger: "blur" }
|
2025-07-18 11:35:41 +08:00
|
|
|
],
|
2025-07-12 17:58:55 +08:00
|
|
|
transTo: [
|
2025-07-29 22:01:14 +08:00
|
|
|
{ required: true, message: "请输入转入牧场", trigger: "blur" }
|
2025-07-12 17:58:55 +08:00
|
|
|
],
|
|
|
|
transFrom: [
|
2025-07-29 22:01:14 +08:00
|
|
|
{ required: false, message: "请选择当前牧场", trigger: "blur" }
|
2025-07-12 17:58:55 +08:00
|
|
|
],
|
|
|
|
transType: [
|
2025-07-29 22:01:14 +08:00
|
|
|
{ required: true, message: "请选择转场类型", trigger: "change" }
|
2025-07-12 17:58:55 +08:00
|
|
|
],
|
|
|
|
technician: [
|
2025-07-29 22:01:14 +08:00
|
|
|
{ required: true, message: "请输入技术员", trigger: "blur" }
|
2025-07-18 11:35:41 +08:00
|
|
|
]
|
2025-07-12 17:58:55 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
const { queryParams, form, rules } = toRefs(data)
|
|
|
|
|
2025-07-29 22:01:14 +08:00
|
|
|
//获取转场记录列表
|
2025-07-12 17:58:55 +08:00
|
|
|
function getList() {
|
|
|
|
loading.value = true
|
|
|
|
queryParams.value.params = {}
|
2025-07-18 11:35:41 +08:00
|
|
|
if (daterangeCreateTime.value?.length) {
|
|
|
|
queryParams.value.params.beginCreateTime = daterangeCreateTime.value[0]
|
2025-07-29 22:01:14 +08:00
|
|
|
queryParams.value.params.endCreateTime = daterangeCreateTime.value[1]
|
2025-07-12 17:58:55 +08:00
|
|
|
}
|
2025-07-18 11:35:41 +08:00
|
|
|
listTransition_info(queryParams.value).then(res => {
|
|
|
|
transition_infoList.value = res.rows
|
2025-07-29 22:01:14 +08:00
|
|
|
total.value = res.total
|
|
|
|
loading.value = false
|
2025-07-12 17:58:55 +08:00
|
|
|
})
|
|
|
|
}
|
2025-07-29 22:01:14 +08:00
|
|
|
//重置
|
2025-07-12 17:58:55 +08:00
|
|
|
function reset() {
|
|
|
|
form.value = {
|
|
|
|
id: null,
|
2025-07-29 22:01:14 +08:00
|
|
|
manageTags: [],
|
2025-07-12 17:58:55 +08:00
|
|
|
transTo: null,
|
|
|
|
transFrom: null,
|
|
|
|
transType: null,
|
|
|
|
technician: null,
|
2025-07-29 22:01:14 +08:00
|
|
|
createBy:null,
|
|
|
|
tagDetails: {}
|
|
|
|
};
|
|
|
|
sheepOptions.value = [];
|
|
|
|
proxy.resetForm("transition_infoRef");
|
|
|
|
isAdd.value = true;
|
|
|
|
isEdit.value = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 加载牧场列表
|
|
|
|
function loadRanchOptions() {
|
|
|
|
return listRanch()
|
|
|
|
.then((res) => {
|
|
|
|
if (res.rows && Array.isArray(res.rows)) {
|
|
|
|
const mapped = res.rows.map((ranch) => ({
|
|
|
|
id: Number(ranch.id),
|
|
|
|
ranchName: ranch.ranch || '未知牧场',
|
|
|
|
}));
|
|
|
|
ranchOptions.value = mapped;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
proxy.$modal.msgError('获取牧场数据失败');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// 加载耳号选项
|
|
|
|
function loadSheepOptions() {
|
|
|
|
getSheepBySheepfoldId().then(res => {
|
|
|
|
sheepOptions.value = res.data?.map(sheep => ({
|
|
|
|
id: sheep.id,
|
|
|
|
manageTags: sheep.manageTags
|
|
|
|
})) || [];
|
|
|
|
}).catch(error => {
|
|
|
|
console.error('加载耳号选项失败', error);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// 通过牧场 ID 查询牧场名称
|
|
|
|
async function getRanchNameByRanchId(ranchId) {
|
|
|
|
if (!ranchId) return '';
|
|
|
|
try {
|
|
|
|
if (ranchOptions.value.length === 0) {
|
|
|
|
await loadRanchOptions();
|
|
|
|
}
|
|
|
|
const matchedRanch = ranchOptions.value.find(
|
|
|
|
(item) => item.id === Number(ranchId)
|
|
|
|
);
|
|
|
|
return matchedRanch ? matchedRanch.ranchName : '';
|
|
|
|
} catch (error) {
|
|
|
|
console.error('通过 ranchId 查询牧场名称失败:', error);
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function handleRanchChange(ranchName) {
|
|
|
|
if (!ranchName) {
|
|
|
|
sheepOptions.value = [];
|
|
|
|
form.value.manageTags = [];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const matchedRanch = ranchOptions.value.find(
|
|
|
|
(ranch) => ranch.ranchName === ranchName
|
|
|
|
);
|
|
|
|
if (!matchedRanch) {
|
|
|
|
proxy.$modal.msgError('未找到该牧场信息,请重新选择');
|
|
|
|
return;
|
2025-07-12 17:58:55 +08:00
|
|
|
}
|
2025-07-29 22:01:14 +08:00
|
|
|
|
|
|
|
const ranchIdNum = matchedRanch.id;
|
|
|
|
|
|
|
|
getSheepByRanchId(ranchIdNum)
|
|
|
|
.then((res) => {
|
|
|
|
if (res.code === 200) {
|
|
|
|
if (res.data && res.data.length > 0) {
|
|
|
|
sheepOptions.value = res.data.map((sheep) => ({
|
|
|
|
id: sheep.id,
|
|
|
|
manageTags: sheep.manageTags,
|
|
|
|
}));
|
|
|
|
} else {
|
|
|
|
sheepOptions.value = [];
|
|
|
|
proxy.$message.error('该牧场暂无羊只数据');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
sheepOptions.value = [];
|
|
|
|
proxy.$modal.msgError('获取羊只数据失败,请重试');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('羊只列表加载失败:', error);
|
|
|
|
sheepOptions.value = [];
|
|
|
|
proxy.$modal.msgError('获取羊只信息失败,请重试');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
async function loadSheepInfo() {
|
|
|
|
if (isEdit.value) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const tags = form.value.manageTags;
|
|
|
|
if (!tags || tags.length === 0) return;
|
|
|
|
|
|
|
|
const tagDetails = {};
|
|
|
|
const validResults = [];
|
|
|
|
|
|
|
|
for (const tag of tags) {
|
|
|
|
try {
|
|
|
|
const { data: sheepData } = await checkSheepByManageTags(tag.trim());
|
|
|
|
if (!sheepData) {
|
|
|
|
validResults.push(false);
|
|
|
|
proxy.$modal.msgError(`耳号 ${tag} 不存在`);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const ranchName = await getRanchNameByRanchId(sheepData.ranchId);
|
|
|
|
|
|
|
|
tagDetails[tag] = {
|
|
|
|
sheepId: sheepData.id,
|
|
|
|
varietyId: sheepData.varietyId,
|
|
|
|
varietyName: sheepData.varietyName || '',
|
|
|
|
ranchName: ranchName,
|
|
|
|
comment: sheepData.comment || ''
|
|
|
|
};
|
|
|
|
validResults.push(true);
|
|
|
|
|
|
|
|
if (!form.value.transFrom && tags.indexOf(tag) === 0) {
|
|
|
|
form.value.transFrom = ranchName;
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
console.error('获取耳号信息失败:', error);
|
|
|
|
validResults.push(false);
|
|
|
|
proxy.$modal.msgError(`耳号 ${tag} 验证失败`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (validResults.includes(false)) {
|
|
|
|
form.value.manageTags = tags.filter((_, index) => validResults[index]);
|
|
|
|
proxy.$message.warning('部分耳号不合法,已过滤');
|
|
|
|
}
|
|
|
|
|
|
|
|
form.value.tagDetails = tagDetails;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 导出
|
|
|
|
function handleExport() {
|
|
|
|
proxy.download(
|
|
|
|
'/produce/manage_sheep/transition_info/export',
|
|
|
|
{ ...queryParams.value },
|
|
|
|
`transition_info_${Date.now()}.xlsx`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 审批
|
|
|
|
function handleApprove(row) {
|
|
|
|
approveForm.value = { ...row };
|
|
|
|
approveDialog.value = true;
|
|
|
|
displayManageTags.value = Array.isArray(row.manageTags)
|
|
|
|
? row.manageTags.join(',')
|
|
|
|
: row.manageTags || '';
|
|
|
|
}
|
|
|
|
|
|
|
|
// 审批同意
|
|
|
|
function handleApproveAgree() {
|
|
|
|
if (!approveForm.value.transTo) {
|
|
|
|
proxy.$modal.msgError('转入牧场不能为空');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
approveForm.value.status = 1;
|
|
|
|
|
|
|
|
approveTransitionInfo(approveForm.value).then(() => {
|
|
|
|
approveDialog.value = false;
|
|
|
|
proxy.$modal.msgSuccess('审批通过,已更新羊只所在牧场');
|
|
|
|
getList();
|
|
|
|
}).catch(error => {
|
|
|
|
proxy.$modal.msgError(`审批失败:${error.message}`);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// 驳回审批
|
|
|
|
function handleApproveReject() {
|
|
|
|
approveForm.value.status = 2;
|
|
|
|
updateTransition_info(approveForm.value).then(() => {
|
|
|
|
approveDialog.value = false;
|
|
|
|
proxy.$modal.msgSuccess('审批成功,状态已更新为驳回');
|
|
|
|
getList();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取转场类型文本
|
|
|
|
function getTransTypeLabel(value) {
|
|
|
|
const transTypeArray = trans_type.value;
|
|
|
|
if (!Array.isArray(transTypeArray)) {
|
|
|
|
return '未知类型';
|
|
|
|
}
|
|
|
|
const item = transTypeArray.find(item => item.value === value);
|
|
|
|
return item ? item.label : '未知类型';
|
2025-07-12 17:58:55 +08:00
|
|
|
}
|
|
|
|
|
2025-07-29 22:01:14 +08:00
|
|
|
// 获取状态文本(与转群页面一致)
|
|
|
|
function getStatusLabel(value) {
|
|
|
|
const statusArray = status.value;
|
|
|
|
if (!Array.isArray(statusArray)) {
|
|
|
|
return '未知状态';
|
|
|
|
}
|
|
|
|
const item = statusArray.find(item => item.value === value);
|
|
|
|
return item ? item.label : '未知状态';
|
|
|
|
}
|
|
|
|
|
|
|
|
//取消
|
2025-07-18 11:35:41 +08:00
|
|
|
function cancel() {
|
|
|
|
open.value = false
|
|
|
|
reset()
|
|
|
|
}
|
2025-07-29 22:01:14 +08:00
|
|
|
|
|
|
|
//搜索
|
2025-07-12 17:58:55 +08:00
|
|
|
function handleQuery() {
|
|
|
|
queryParams.value.pageNum = 1
|
|
|
|
getList()
|
|
|
|
}
|
2025-07-29 22:01:14 +08:00
|
|
|
|
|
|
|
//重置
|
2025-07-12 17:58:55 +08:00
|
|
|
function resetQuery() {
|
|
|
|
daterangeCreateTime.value = []
|
|
|
|
proxy.resetForm("queryRef")
|
|
|
|
handleQuery()
|
|
|
|
}
|
2025-07-29 22:01:14 +08:00
|
|
|
|
2025-07-12 17:58:55 +08:00
|
|
|
function handleSelectionChange(selection) {
|
|
|
|
ids.value = selection.map(item => item.id)
|
2025-07-18 11:35:41 +08:00
|
|
|
single.value = selection.length !== 1
|
2025-07-12 17:58:55 +08:00
|
|
|
multiple.value = !selection.length
|
|
|
|
}
|
2025-07-29 22:01:14 +08:00
|
|
|
|
|
|
|
//新增
|
2025-07-12 17:58:55 +08:00
|
|
|
function handleAdd() {
|
2025-07-29 22:01:14 +08:00
|
|
|
reset();
|
|
|
|
open.value = true;
|
|
|
|
title.value = "添加转场";
|
|
|
|
isAdd.value = true;
|
|
|
|
isEdit.value = false;
|
|
|
|
sheepOptions.value = [];
|
|
|
|
form.value.manageTags = [];
|
2025-07-12 17:58:55 +08:00
|
|
|
}
|
2025-07-29 22:01:14 +08:00
|
|
|
|
|
|
|
//修改
|
|
|
|
async function handleUpdate(row) {
|
|
|
|
reset();
|
|
|
|
const _id = row.id || ids.value;
|
2025-07-12 17:58:55 +08:00
|
|
|
getTransition_info(_id).then(response => {
|
2025-07-29 22:01:14 +08:00
|
|
|
form.value = {
|
|
|
|
...response.data,
|
|
|
|
manageTags: [response.data.manageTags]
|
|
|
|
};
|
|
|
|
open.value = true;
|
|
|
|
title.value = "修改转场";
|
|
|
|
isAdd.value = false;
|
|
|
|
isEdit.value = true;
|
|
|
|
}).catch(error => {
|
|
|
|
console.error('获取转场详情失败:', error);
|
|
|
|
proxy.$modal.msgError('加载数据失败,请重试');
|
|
|
|
});
|
2025-07-12 17:58:55 +08:00
|
|
|
}
|
2025-07-29 22:01:14 +08:00
|
|
|
|
|
|
|
//提交
|
|
|
|
async function submitForm() {
|
|
|
|
proxy.$refs.transition_infoRef.validate(async (valid) => {
|
|
|
|
if (!valid) return;
|
|
|
|
|
|
|
|
const allTags = form.value.manageTags;
|
|
|
|
let validTags = [];
|
|
|
|
|
|
|
|
if (isAdd.value) {
|
|
|
|
if (!allTags || allTags.length === 0) {
|
|
|
|
proxy.$modal.msgError('请选择至少一个耳号');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const tagDetails = form.value.tagDetails || {};
|
|
|
|
validTags = allTags.filter(tag => tagDetails[tag]);
|
|
|
|
|
|
|
|
if (validTags.length === 0) {
|
|
|
|
proxy.$modal.msgError('所有耳号均无效,请重新输入');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
validTags = allTags;
|
|
|
|
}
|
|
|
|
|
|
|
|
let submitData = {};
|
|
|
|
if (isAdd.value) {
|
|
|
|
submitData = validTags.map(tag => ({
|
|
|
|
sheepId: form.value.tagDetails[tag].sheepId,
|
|
|
|
varietyId: form.value.tagDetails[tag].varietyId,
|
|
|
|
varietyName: form.value.tagDetails[tag].varietyName,
|
|
|
|
manageTags: tag,
|
|
|
|
transTo: form.value.transTo,
|
|
|
|
transFrom: form.value.tagDetails[tag].ranchName,
|
|
|
|
transType: form.value.transType,
|
|
|
|
technician: form.value.technician,
|
|
|
|
comment: form.value.tagDetails[tag].comment,
|
|
|
|
status: 0,
|
|
|
|
}));
|
|
|
|
} else {
|
|
|
|
submitData = {
|
|
|
|
...form.value,
|
|
|
|
manageTags: validTags.join(','),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (isAdd.value) {
|
|
|
|
await addTransition_info(submitData);
|
|
|
|
} else {
|
|
|
|
await updateTransition_info(submitData);
|
|
|
|
}
|
|
|
|
proxy.$modal.msgSuccess(isAdd.value ? '提交成功' : '修改成功');
|
|
|
|
open.value = false;
|
|
|
|
getList();
|
|
|
|
} catch (error) {
|
|
|
|
proxy.$modal.msgError(isAdd.value ? '提交失败,请重试' : '修改失败,请重试');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
//加载品种信息
|
|
|
|
function getVarietyOptions() {
|
|
|
|
request({
|
|
|
|
url: '/base/variety/list',
|
|
|
|
method: 'get',
|
|
|
|
params: { pageNum: 1, pageSize: 9999 },
|
|
|
|
}).then((res) => {
|
|
|
|
varietyOptions.value = res.rows || [];
|
|
|
|
});
|
2025-07-12 17:58:55 +08:00
|
|
|
}
|
2025-07-29 22:01:14 +08:00
|
|
|
|
|
|
|
//删除
|
2025-07-12 17:58:55 +08:00
|
|
|
function handleDelete(row) {
|
|
|
|
const _ids = row.id || ids.value
|
2025-07-18 11:35:41 +08:00
|
|
|
proxy.$modal.confirm('是否确认删除转场编号为"' + _ids + '"的数据项?')
|
|
|
|
.then(() => delTransition_info(_ids))
|
|
|
|
.then(() => {
|
|
|
|
getList()
|
|
|
|
proxy.$modal.msgSuccess("删除成功")
|
|
|
|
})
|
2025-07-12 17:58:55 +08:00
|
|
|
}
|
2025-07-18 18:13:18 +08:00
|
|
|
|
|
|
|
|
2025-07-29 22:01:14 +08:00
|
|
|
onMounted(() => {
|
|
|
|
loadRanchOptions();
|
|
|
|
getVarietyOptions();
|
|
|
|
loadSheepOptions();
|
|
|
|
getList();
|
|
|
|
});
|
|
|
|
</script>
|