bug修复以及数据分离操作

This commit is contained in:
zyh
2026-02-09 20:22:46 +08:00
parent ab3efaa405
commit 5555d6a747
11 changed files with 975 additions and 448 deletions

View File

@@ -107,7 +107,9 @@
</el-col>
<el-col :span="10">
<el-form-item label="技术员" prop="technician">
<el-input v-model="form.technician" placeholder="请输入技术员" />
<el-select v-model="form.technician" placeholder="请选择技术员" clearable filterable style="width: 100%">
<el-option v-for="item in technicalOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
@@ -130,7 +132,7 @@
<el-dialog title="导入羊只信息" v-model="importOpen" width="400px" append-to-body>
<el-upload ref="uploadRef" :limit="1" accept=".xlsx,.xls" :action="importUrl" :headers="headers"
:auto-upload="false" :on-success="handleImportSuccess" :on-error="handleImportError" drag>
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<template #tip>
<div class="el-upload__tip text-center">
@@ -154,7 +156,7 @@ import { listRanch } from '@/api/produce/manage_sheep/trans_group'
import { listSheepfold_management as listSheepfold } from '@/api/fileManagement/sheepfold_management'
import { getToken } from '@/utils/auth'
import { UploadFilled } from '@element-plus/icons-vue'
import { getUserByPost } from '@/api/common/user'
const { proxy } = getCurrentInstance()
const form = ref({
@@ -178,6 +180,27 @@ const formRef = ref(null)
const sheepfoldOptions = ref([])
const varietyOptions = ref([])
const ranchOptions = ref([])
// 技术员下拉选项
const technicalOptions = ref([])
// 获取技术员列表岗位编码techs
const fetchTechnicalList = () => {
getUserByPost({ postCode: "techs" })
.then(res => {
if (res.code === 200 && Array.isArray(res.data)) {
technicalOptions.value = res.data.map(item => ({
value: item.nickName,
label: item.nickName
}))
} else {
technicalOptions.value = []
}
})
.catch(() => {
technicalOptions.value = []
})
}
const rules = {
earNumber: [
{ required: true, message: '请输入耳号', trigger: 'blur' },
@@ -380,6 +403,7 @@ onMounted(() => {
loadSheepTypeList()
loadRanchList()
getVarietyOptions()
fetchTechnicalList()
})
</script>

View File

@@ -64,8 +64,9 @@
</el-select>
</el-form-item> -->
<el-form-item label="技术员" prop="technician">
<el-input v-model="queryParams.technician" placeholder="请输入技术员" clearable style="max-width: 160px"
@keyup.enter="handleQuery" />
<el-select v-model="queryParams.technician" placeholder="请选择技术员" clearable filterable style="max-width: 160px">
<el-option v-for="item in technicalOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="是否在群" prop="isDelete">
<el-select v-model="queryParams.isDelete" placeholder="全部" clearable style="min-width:120px">
@@ -152,14 +153,17 @@
<el-input v-model="form.newComment" placeholder="请输入新备注" :disabled="!isAddMode" />
</el-form-item>
<el-form-item label="原备注" prop="oldComment">
<el-input v-model="form.oldComment" placeholder="自动回显,多只羊只回显第一只" disabled />
<el-input v-model="form.oldComment" placeholder="页面自动获取展示" disabled />
</el-form-item>
<el-form-item label="事件日期" prop="eventDate">
<el-date-picker v-model="form.eventDate" type="date" placeholder="请选择事件日期" value-format="YYYY-MM-DD"
:disabled="!isAddMode" />
</el-form-item>
<el-form-item label="技术员" prop="technician">
<el-input v-model="form.technician" placeholder="请输入技术员" :disabled="!isAddMode" />
<el-select v-model="form.technician" placeholder="请选择技术员" :disabled="!isAddMode" clearable filterable
style="width: 100%">
<el-option v-for="item in technicalOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
</el-form>
<template #footer>
@@ -179,6 +183,7 @@ import { listSheepfold_management as listSheepfold } from '@/api/fileManagement/
import dayjs from 'dayjs'
import { nextTick } from 'vue'
import { Plus, Delete, ArrowUp, ArrowDown } from '@element-plus/icons-vue'
import { getUserByPost } from '@/api/common/user'
const { proxy } = getCurrentInstance()
const changeCommentList = ref([])
@@ -198,6 +203,27 @@ const isExpanded = ref(false) // 折叠状态
const defaultShowCount = 2 // 默认展示条数
const batchTags = ref([]) // 本次要新增的多条耳号
const batchSheep = ref([]) // 对应的羊只对象
// 技术员下拉选项
const technicalOptions = ref([])
// 获取技术员列表岗位编码techs
const fetchTechnicalList = () => {
getUserByPost({ postCode: "techs" })
.then(res => {
if (res.code === 200 && Array.isArray(res.data)) {
technicalOptions.value = res.data.map(item => ({
value: item.nickName,
label: item.nickName
}))
} else {
technicalOptions.value = []
}
})
.catch(() => {
technicalOptions.value = []
})
}
/* 计算:控制实际展示的耳号 */
const displayedEarTags = computed(() => {
const list = queryParams.value.manageTagsList
@@ -489,10 +515,9 @@ function clearBatchTags() {
form.value.oldComment = ''
}
/* 计算属性:实时显示已选数量(可选) */
const batchCount = computed(() => batchTags.value.length)
onMounted(() => {
getSheepfoldOptions();
fetchTechnicalList();
getList();
});
</script>

View File

@@ -59,8 +59,9 @@
style="max-width: 160px;" />
</el-form-item>
<el-form-item label="技术员" prop="technician">
<el-input v-model="queryParams.technician" placeholder="请输入技术员" clearable @keyup.enter="handleQuery"
style="max-width: 160px;" />
<el-select v-model="queryParams.technician" placeholder="请选择技术员" clearable filterable style="max-width: 160px">
<el-option v-for="item in technicalOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="是否在群" prop="inGroup">
<el-select v-model="queryParams.inGroup" placeholder="全部" clearable style="width:120px">
@@ -155,10 +156,13 @@
<el-input v-model="form.newTag" placeholder="请输入新耳号/电子耳号" @blur="checkNewTagExists" :disabled="!isAddMode" />
</el-form-item>
<el-form-item label="旧耳号" prop="oldTag">
<el-input v-model="form.oldTag" placeholder="请输入旧耳号/电子耳号" disabled />
<el-input v-model="form.oldTag" placeholder="自动获取" disabled />
</el-form-item>
<el-form-item label="技术员" prop="technician">
<el-input v-model="form.technician" placeholder="请输入技术员" :disabled="!isAddMode" />
<el-select v-model="form.technician" placeholder="请选择技术员" :disabled="!isAddMode" clearable filterable
style="width: 100%">
<el-option v-for="item in technicalOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="事件日期" prop="eventDate">
<el-date-picker v-model="form.eventDate" type="date" placeholder="请选择事件日期" value-format="YYYY-MM-DD"
@@ -184,8 +188,28 @@ import { listSheepfold_management as listSheepfold } from '@/api/fileManagement/
import dayjs from 'dayjs'
import { nextTick } from 'vue'
import { Plus, Delete, ArrowUp, ArrowDown } from '@element-plus/icons-vue'
import { getUserByPost } from '@/api/common/user'
const { proxy } = getCurrentInstance()
// 技术员下拉选项
const technicalOptions = ref([])
// 获取技术员列表岗位编码techs
const fetchTechnicalList = () => {
getUserByPost({ postCode: "techs" })
.then(res => {
if (res.code === 200 && Array.isArray(res.data)) {
technicalOptions.value = res.data.map(item => ({
value: item.nickName,
label: item.nickName
}))
} else {
technicalOptions.value = []
}
})
.catch(() => {
technicalOptions.value = []
})
}
const changeEarList = ref([])
const open = ref(false)
const loading = ref(true)
@@ -240,9 +264,6 @@ const data = reactive({
],
eventDate: [
{ required: true, message: "请选择事件日期", trigger: "change" }
],
comment: [
{ required: true, message: "请输入备注", trigger: "blur" }
]
}
})
@@ -417,7 +438,6 @@ function fetchOldTag() {
if (!earNumber || earType === null) {
form.value.oldTag = '';
form.value.sheepId = null;
form.value.comment = '';
return;
}
@@ -429,20 +449,16 @@ function fetchOldTag() {
if (!sheep || !sheep.id) {
form.value.oldTag = '';
form.value.sheepId = null;
form.value.comment = '';
proxy.$modal.warning("未找到对应的羊只");
return;
}
form.value.oldTag = oldTag;
form.value.sheepId = sheep.id;
form.value.comment = sheep.comment || '';
}).catch(error => {
console.error("查询失败:", error);
form.value.oldTag = '';
form.value.sheepId = null;
form.value.comment = '';
proxy.$modal.error("查询耳号失败,请重试");
});
}
@@ -531,6 +547,7 @@ function removeEarNumber(tag) {
onMounted(() => {
getSheepfoldOptions();
getList();
fetchTechnicalList();
});
</script>

View File

@@ -67,8 +67,9 @@
</el-select>
</el-form-item> -->
<el-form-item label="技术员" prop="technician">
<el-input v-model="queryParams.technician" placeholder="请输入技术员" clearable style="max-width: 160px"
@keyup.enter="handleQuery" />
<el-select v-model="queryParams.technician" placeholder="请选择技术员" clearable filterable style="max-width: 160px">
<el-option v-for="item in technicalOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="是否在群" prop="isDelete">
<el-select v-model="queryParams.isDelete" placeholder="全部" clearable style="min-width:120px">
@@ -156,7 +157,7 @@
</el-button>
</div>
<el-form-item label="原品种" prop="varietyOld">
<el-input v-model="form.varietyOld" placeholder="请输入原品种" disabled />
<el-input v-model="form.varietyOld" placeholder="页面自动获取展示" disabled />
</el-form-item>
<el-form-item label="新品种" prop="varietyNew">
<el-select v-model="form.varietyNew" placeholder="请选择新品种" clearable filterable :disabled="!isAdd">
@@ -168,10 +169,13 @@
:disabled="!isAdd" />
</el-form-item>
<el-form-item label="技术员" prop="technician">
<el-input v-model="form.technician" placeholder="请输入技术员" :disabled="!isAdd" />
<el-select v-model="form.technician" placeholder="请选择技术员" :disabled="!isAdd" clearable filterable
style="width: 100%">
<el-option v-for="item in technicalOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="备注" prop="comment" v-if="!isAdd">
<el-input v-model="form.comment" placeholder="请输入备注" :disabled="!isAdd" />
<el-form-item label="备注" prop="comment">
<el-input v-model="form.comment" placeholder="请填写备注" type="textarea" rows="2" />
</el-form-item>
</el-form>
<template #footer>
@@ -191,8 +195,28 @@ import { listVariety } from '@/api/fileManagement/variety'
import dayjs from 'dayjs'
import { nextTick } from 'vue'
import { Plus, Delete, ArrowUp, ArrowDown } from '@element-plus/icons-vue'
import { getUserByPost } from '@/api/common/user'
const { proxy } = getCurrentInstance()
// 技术员下拉选项
const technicalOptions = ref([])
// 获取技术员列表岗位编码techs
const fetchTechnicalList = () => {
getUserByPost({ postCode: "techs" })
.then(res => {
if (res.code === 200 && Array.isArray(res.data)) {
technicalOptions.value = res.data.map(item => ({
value: item.nickName,
label: item.nickName
}))
} else {
technicalOptions.value = []
}
})
.catch(() => {
technicalOptions.value = []
})
}
const changeVarietyList = ref([])
const open = ref(false)
const loading = ref(true)
@@ -384,7 +408,7 @@ function submitForm() {
varietyNew: form.value.varietyNew,
eventDate: form.value.eventDate,
technician: form.value.technician,
comment: sheep.comment || ""
comment: form.value.comment || ''
}
return addChangeVariety(submitData)
})
@@ -513,7 +537,6 @@ async function onManageTagsBlur() {
if (!batchTags.value.length) { // 全部无效
form.value.varietyOld = ""
form.value.sheepId = null
form.value.comment = ""
return
}
@@ -524,7 +547,6 @@ async function onManageTagsBlur() {
const firstSheep = batchSheep.value[0]
form.value.varietyOld = firstSheep.varietyName || ""
form.value.sheepId = firstSheep.id
form.value.comment = firstSheep.comment || ""
}
// 删除单个批量耳号
@@ -551,6 +573,7 @@ function clearBatchTags() {
onMounted(() => {
loadVarietyOptions();
getSheepfoldOptions();
fetchTechnicalList();
getList();
});
</script>

View File

@@ -77,7 +77,8 @@
</el-select>
</el-form-item>
<el-form-item label="技术员">
<el-select v-model="queryParams.technician" filterable allow-create clearable placeholder="请输入或选择技术员">
<el-select v-model="queryParams.technician" placeholder="请选择技术员" clearable filterable style="min-width:150px">
<el-option v-for="item in technicalOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="是否在群" prop="isDelete">
@@ -95,15 +96,15 @@
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd"
v-hasPermi="['trans_group:trans_group:add']">新增</el-button>
v-hasPermi="['produce:trans_group:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
v-hasPermi="['trans_group:trans_group:remove']">删除</el-button>
v-hasPermi="['produce:trans_group:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport"
v-hasPermi="['trans_group:trans_group:export']">导出</el-button>
v-hasPermi="['produce:trans_group:export']">导出</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@@ -129,7 +130,7 @@
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" min-width="160" fixed="right">
<template #default="scope">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
v-hasPermi="['trans_group:trans_group:remove']">
v-hasPermi="['produce:trans_group:remove']">
删除
</el-button>
</template>
@@ -200,7 +201,12 @@
style="width: 100%" required />
</el-form-item>
<el-form-item label="技术员" prop="technician">
<el-input v-model="form.technician" placeholder="请输入技术员" />
<el-select v-model="form.technician" placeholder="请选择技术员" clearable filterable style="width: 100%">
<el-option v-for="item in technicalOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="备注" prop="comment">
<el-input v-model="form.comment" placeholder="请填写备注" type="textarea" rows="2" />
</el-form-item>
</el-form>
<template #footer>
@@ -210,8 +216,6 @@
</div>
</template>
</el-dialog>
</div>
</template>
@@ -224,10 +228,29 @@ import request from '@/utils/request'
import dayjs from 'dayjs'
import { nextTick } from 'vue'
import { Plus, Delete, ArrowUp, ArrowDown } from '@element-plus/icons-vue'
import { getUserByPost } from '@/api/common/user'
const { proxy } = getCurrentInstance();
const { trans_group_reason, trans_group_event_type } = proxy.useDict('trans_group_reason', 'status', 'trans_group_event_type');
// 技术员下拉选项
const technicalOptions = ref([])
// 获取技术员列表岗位编码techs
const fetchTechnicalList = () => {
getUserByPost({ postCode: "techs" })
.then(res => {
if (res.code === 200 && Array.isArray(res.data)) {
technicalOptions.value = res.data.map(item => ({
value: item.nickName,
label: item.nickName
}))
} else {
technicalOptions.value = []
}
})
.catch(() => {
technicalOptions.value = []
})
}
const trans_groupList = ref([]);
const open = ref(false);
const loading = ref(true);
@@ -268,6 +291,7 @@ const data = reactive({
eventType: null,
transDate: null,
currentFoldAllEars: ref([]),
comment: null,
},
queryParams: {
pageNum: 1,
@@ -347,7 +371,9 @@ async function handleSheepFilter() {
let isOnlyTypeOrCombined = false;
if (!ranchId) {
form.value.manageTags = [];
form.value.manageTags = '';
batchTags.value = [];
batchSheep.value = [];
sheepOptions.value = [];
proxy.$message.warning("请先选择牧场");
return;
@@ -360,25 +386,33 @@ async function handleSheepFilter() {
} else if (foldFrom && sheepTypeId) {
isOnlyTypeOrCombined = true;
} else {
form.value.manageTags = [];
form.value.manageTags = '';
batchTags.value = [];
batchSheep.value = [];
sheepOptions.value = [];
return;
}
if (isOnlySheepfold) {
const list = await loadSheepBySheepfoldOnly(foldFrom, ranchId);
if (list.length === 0) {
const sheepList = await loadSheepBySheepfoldOnly(foldFrom, ranchId);
if (sheepList.length === 0) {
proxy.$message.info('当前转出羊舍暂无羊只');
form.value.manageTags = [];
form.value.manageTags = '';
batchTags.value = [];
batchSheep.value = [];
return;
}
form.value.manageTags = [...list];
await loadSheepInfo();
// 关键修改:填充 batchTags 和 batchSheep和手动输入保持一致
batchTags.value = sheepList.map(s => s.manageTags);
batchSheep.value = sheepList;
form.value.manageTags = batchTags.value.join(' ');
return;
}
if (isOnlyTypeOrCombined) {
form.value.manageTags = [];
form.value.manageTags = '';
batchTags.value = [];
batchSheep.value = [];
let loadedSheep = [];
if (foldFrom && sheepTypeId) {
@@ -388,9 +422,10 @@ async function handleSheepFilter() {
}
if (loadedSheep.length > 0) {
const list = loadedSheep.map(s => s.manageTags);
form.value.manageTags = [...list];
await loadSheepInfo();
// 关键修改:填充 batchTags 和 batchSheep和手动输入保持一致
batchTags.value = loadedSheep.map(s => s.manageTags);
batchSheep.value = loadedSheep;
form.value.manageTags = batchTags.value.join(' ');
} else {
proxy.$message.info("未查询到符合条件的耳号");
}
@@ -455,6 +490,8 @@ async function loadSheepBySheepfoldOnly(sheepfoldId, ranchId) {
id: sheep.id,
manageTags: sheep.manageTags || '未知耳号',
sheepfoldId: Number(sheepfoldId),
sheepTypeId: sheep.typeId, // 确保有 typeId
varietyId: sheep.varietyId, // 确保有 varietyId
})).filter(item => item.manageTags);
if (newSheepList.length === 0) {
@@ -463,8 +500,7 @@ async function loadSheepBySheepfoldOnly(sheepfoldId, ranchId) {
return [];
}
sheepOptions.value = newSheepList;
return newSheepList.map(s => s.manageTags);
return newSheepList; // 返回完整对象数组,不只是 manageTags
} catch (error) {
console.error('根据羊舍加载耳号失败:', error);
const errorMsg = error.response?.data?.msg || '加载羊舍耳号失败,请重试';
@@ -487,6 +523,8 @@ async function loadSheepBySheepfoldAndType(sheepfoldId, typeId) {
id: sheep.id,
manageTags: sheep.manageTags,
sheepfoldId: sheepfoldId,
sheepTypeId: sheep.typeId || typeId, // 确保有 typeId
varietyId: sheep.varietyId, // 确保有 varietyId
}));
sheepOptions.value = formattedSheep;
@@ -517,7 +555,9 @@ async function loadSheepByTypeOnly(typeId, ranchId) {
const formattedSheep = filtered.map(s => ({
id: s.id,
manageTags: s.manageTags,
sheepfoldId: s.sheepfoldId
sheepfoldId: s.sheepfoldId,
sheepTypeId: s.typeId || typeId, // 确保有 typeId
varietyId: s.varietyId, // 确保有 varietyId
}));
sheepOptions.value = formattedSheep;
return formattedSheep;
@@ -528,6 +568,7 @@ async function loadSheepByTypeOnly(typeId, ranchId) {
}
}
//加载羊只信息
async function loadSheepInfo() {
const tags = form.value.manageTags;
@@ -642,7 +683,8 @@ async function handleUpdate(row) {
reason: Number(d.reason || 0),
status: Number(d.status || 0),
varietyId: Number(d.varietyId || 0),
isEdit: true
isEdit: true,
comment: d.comment || '',
};
form.value = formData;
@@ -692,7 +734,7 @@ function submitForm() {
reason: form.value.reason,
transDate: form.value.transDate,
technician: form.value.technician,
comment: sheep.comment || ''
comment: form.value.comment || ''
})
})
).then(() => {
@@ -859,18 +901,18 @@ function removeBatchTag(idx) {
form.value.manageTags = batchTags.value.join(' ')
}
// 一键清空批量耳号(和改备注一致)
// 一键清空批量耳号
function clearBatchTags() {
batchTags.value = []
batchSheep.value = []
form.value.manageTags = ''
form.value.oldComment = ''
}
onMounted(() => {
loadSheepfold();
loadRanchList();
getVarietyOptions();
loadSheepTypeList();
fetchTechnicalList();
getList();
});
</script>

View File

@@ -90,10 +90,8 @@
</el-select>
</el-form-item>
<el-form-item label="技术员" prop="technician">
<el-select v-model="queryParams.technician" filterable allow-create clearable placeholder="请输入或选择技术员"
style="min-width:150px">
<!-- 如果有字典可以放开下面这行没有就纯输入 -->
<!-- <el-option v-for="item in technicianOptions" :key="item" :label="item" :value="item" /> -->
<el-select v-model="queryParams.technician" placeholder="请选择技术员" clearable filterable style="min-width:150px">
<el-option v-for="item in technicalOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="是否在群" prop="isDelete">
@@ -112,7 +110,7 @@
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd"
v-hasPermi="['transition_info:transition_info:add']">新增</el-button>
v-hasPermi="['produce:transition_info:add']">新增</el-button>
</el-col>
<!-- <el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate"
@@ -120,11 +118,11 @@
</el-col> -->
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
v-hasPermi="['transition_info:transition_info:remove']">删除</el-button>
v-hasPermi="['produce:transition_info:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport"
v-hasPermi="['transition_info:transition_info:export']">导出</el-button>
v-hasPermi="['produce:transition_info:export']">导出</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
</el-row>
@@ -167,9 +165,9 @@
<el-table-column label="操作" align="center" min-width="180" fixed="right">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleApprove(scope.row)"
v-hasPermi="['transition_info:transition_info:approve']" :disabled="scope.row.status !== 0">审批</el-button>
v-hasPermi="['produce:transition_info:approve']" :disabled="scope.row.status !== 0">审批</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
v-hasPermi="['transition_info:transition_info:remove']">删除</el-button>
v-hasPermi="['produce:transition_info:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
@@ -231,7 +229,13 @@
</el-form-item>
<el-form-item label="技术员" prop="technician">
<el-input v-model="form.technician" placeholder="请输入技术员" />
<el-select v-model="form.technician" placeholder="请选择技术员" clearable filterable style="width: 100%">
<el-option v-for="item in technicalOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="备注" prop="comment">
<el-input v-model="form.comment" placeholder="请填写备注" type="textarea" rows="2" />
</el-form-item>
</el-form>
@@ -296,10 +300,29 @@ import { listTransition_info, getTransition_info, delTransition_info, addTransit
import { checkSheepByManageTags, getSheepBySheepfoldId } from '@/api/produce/other/fixHoof'
import request from '@/utils/request'
import dayjs from 'dayjs'
import { getUserByPost } from '@/api/common/user'
const { proxy } = getCurrentInstance()
const { status, trans_type } = proxy.useDict('status', 'trans_type')
// 技术员下拉选项
const technicalOptions = ref([])
// 获取技术员列表岗位编码techs
const fetchTechnicalList = () => {
getUserByPost({ postCode: "techs" })
.then(res => {
if (res.code === 200 && Array.isArray(res.data)) {
technicalOptions.value = res.data.map(item => ({
value: item.nickName,
label: item.nickName
}))
} else {
technicalOptions.value = []
}
})
.catch(() => {
technicalOptions.value = []
})
}
const transition_infoList = ref([])
const open = ref(false)
const loading = ref(true)
@@ -341,6 +364,7 @@ const data = reactive({
transType: null,
transitionDate: null,
technician: null,
comment: null,
tagDetails: {}
},
queryParams: {
@@ -415,6 +439,7 @@ function reset() {
transType: null,
technician: null,
createBy: null,
comment: null,
tagDetails: {}
};
batchTags.value = [];
@@ -667,7 +692,8 @@ async function handleUpdate(row) {
getTransition_info(_id).then(response => {
form.value = {
...response.data,
manageTags: [response.data.manageTags]
manageTags: [response.data.manageTags],
comment: response.data.comment || ''
};
open.value = true;
title.value = "修改转场";
@@ -700,7 +726,7 @@ async function submitForm() {
eventType: form.value.eventType,
transitionDate: form.value.transitionDate,
technician: form.value.technician,
comment: batchSheep.value[idx].comment || '',
comment: form.value.comment || '',
status: 0,
}))
@@ -746,7 +772,9 @@ function searchEarNumber(query) {
async function handleRanchChange(ranchName) {
if (!ranchName) {
sheepOptions.value = [];
form.value.manageTags = [];
batchTags.value = []; // 清空
batchSheep.value = []; // 清空
form.value.manageTags = '';
return;
}
@@ -754,9 +782,23 @@ async function handleRanchChange(ranchName) {
if (!matched) return;
const res = await getSheepByRanchId(matched.id);
sheepOptions.value = (res.data || []).map(s => ({ id: s.id, manageTags: s.manageTags }));
form.value.manageTags = (res.data || []).map(s => s.manageTags);
await loadSheepInfo();
const sheepList = (res.data || []).map(s => ({
id: s.id,
manageTags: s.manageTags,
varietyId: s.varietyId, // 确保有品种ID
varietyName: s.varietyName || '', // 确保有品种名
ranchId: s.ranchId
}));
// 关键修改:填充 batchTags 和 batchSheep和手动输入保持一致
batchTags.value = sheepList.map(s => s.manageTags);
batchSheep.value = sheepList;
form.value.manageTags = batchTags.value.join(' ');
// 自动填充转出牧场(当前选中的牧场)
form.value.transFrom = ranchName;
sheepOptions.value = sheepList;
}
/* 粘贴事件 */
function handlePaste() {
@@ -888,6 +930,7 @@ onMounted(() => {
getVarietyOptions();
loadSheepOptions();
loadSheepTypeList();
fetchTechnicalList();
getList();
});
</script>