Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -57,4 +57,12 @@ export function searchEarNumbers(query) {
|
||||
method: 'get',
|
||||
params: { query }
|
||||
})
|
||||
}
|
||||
|
||||
// 获取繁殖状态列表
|
||||
export function listBreedStatus() {
|
||||
return request({
|
||||
url: '/body_measure/body_measure/breedStatus',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
@@ -10,19 +10,45 @@
|
||||
start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="管理耳号" prop="manageTagsList">
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="请输入耳号,支持多选" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option style="width: 260px">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
<el-button type="text" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" style="margin-left: 8px">
|
||||
清空
|
||||
</el-button>
|
||||
<div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap;">
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="输入耳号搜索" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option collapse-tags :max-collapse-tags="0" style="width:260px" @change="handleEarChange">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
<el-input v-model="pasteText" placeholder="或粘贴多个耳号(空格/换行/逗号分隔)" style="width:260px" @paste="handlePaste"
|
||||
@keyup.enter="handlePasteSubmit" clearable>
|
||||
<template #append>
|
||||
<el-button @click="handlePasteSubmit" :icon="Plus">添加</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
<el-tag v-if="queryParams.manageTagsList.length" type="info" effect="plain" size="large">
|
||||
已选: {{ queryParams.manageTagsList.length }} 个
|
||||
</el-tag>
|
||||
<el-button type="danger" plain :icon="Delete" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList.length">
|
||||
清空全部
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-if="queryParams.manageTagsList.length" class="selected-ear-numbers">
|
||||
<el-tag v-for="tag in displayedEarTags" :key="tag" closable @close="removeEarNumber(tag)" style="margin:4px"
|
||||
type="success">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
<el-button v-if="queryParams.manageTagsList.length > defaultShowCount" type="primary" link
|
||||
@click="toggleExpand">
|
||||
{{ isExpanded ? '收起' : `展开剩余 ${queryParams.manageTagsList.length - defaultShowCount} 个` }}
|
||||
<el-icon class="el-icon--right">
|
||||
<component :is="isExpanded ? ArrowUp : ArrowDown" />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="羊舍" prop="sheepfoldId">
|
||||
<el-select v-model="queryParams.sheepfoldId" placeholder="请选择羊舍" style="min-width:150px" clearable>
|
||||
<el-option v-for="item in sheepfoldOptions" :key="item.id" :label="item.sheepfoldName" :value="item.id" />
|
||||
<el-form-item label="性别" prop="gender">
|
||||
<el-select v-model="queryParams.gender" placeholder="请选择性别" clearable style="min-width:120px">
|
||||
<el-option label="母" value="1" />
|
||||
<el-option label="公" value="2" />
|
||||
<el-option label="阉羊" value="3" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="品种" prop="varietyId">
|
||||
@@ -30,23 +56,49 @@
|
||||
<el-option v-for="item in varietyOptions" :key="item.id" :label="item.variety" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="羊只类别" prop="sheepTypeId">
|
||||
<el-select v-model="queryParams.sheepTypeId" placeholder="请选择羊只类别" clearable style="min-width:150px">
|
||||
<el-form-item label="月龄" style="width: 308px">
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<el-input-number v-model="queryParams.monthAgeStart" :min="0" :max="300" placeholder="最小月龄"
|
||||
style="width: 120px; flex-shrink: 0;" controls-position="right" />
|
||||
<span>-</span>
|
||||
<el-input-number v-model="queryParams.monthAgeEnd" :min="0" :max="300" placeholder="最大月龄"
|
||||
style="width: 120px; flex-shrink: 0;" controls-position="right" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="羊只类型" prop="sheepTypeId">
|
||||
<el-select v-model="queryParams.sheepTypeId" placeholder="请选择羊只类型" clearable style="min-width:150px">
|
||||
<el-option v-for="type in sheepTypeList" :key="type.id" :label="type.name" :value="type.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="繁殖状态" prop="breedStatusName">
|
||||
<el-select v-model="queryParams.breedStatusName" placeholder="请选择繁殖状态" clearable style="min-width:150px">
|
||||
<el-option v-for="item in breedStatusOptions" :key="item.id" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="羊舍" prop="sheepfoldId">
|
||||
<el-select v-model="queryParams.sheepfoldId" placeholder="请选择羊舍" style="min-width:150px" clearable>
|
||||
<el-option v-for="item in sheepfoldOptions" :key="item.id" :label="item.sheepfoldName" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item label="技术员" prop="technician">
|
||||
<el-select v-model="queryParams.technician" placeholder="请选择技术员" clearable filterable style="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">
|
||||
<el-select v-model="queryParams.isDelete" placeholder="全部" clearable style="min-width:120px">
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="在群" :value="0" />
|
||||
<el-option label="离群" :value="1" />
|
||||
</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-button icon="Refresh" @click="resetQuery">重置</el-button> -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" class="selected-ear-numbers">
|
||||
<span style="margin-right: 10px; color: #606266;">已选耳号:</span>
|
||||
<el-tag v-for="tag in queryParams.manageTagsList" :key="tag" closable @close="removeEarNumber(tag)"
|
||||
style="margin-right: 8px;">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd"
|
||||
@@ -64,6 +116,10 @@
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport"
|
||||
v-hasPermi="['body_measure:body_measure:export']">导出</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Upload" @click="handleImport"
|
||||
v-hasPermi="['body_measure:body_measure:import']">导入</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
@@ -73,7 +129,12 @@
|
||||
<el-table-column label="羊舍" align="center" prop="sheepfoldName" width="100" />
|
||||
<el-table-column label="品种" align="center" prop="varietyName" width="100" />
|
||||
<el-table-column label="事件类型" align="center" prop="eventType" width="120" />
|
||||
<el-table-column label="羊只类别" align="center" prop="sheepTypeName" width="100" />
|
||||
<el-table-column label="测量日期" align="center" prop="measureDate" width="120">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.measureDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="测量时羊只类别" align="center" prop="sheepTypeName" width="100" />
|
||||
<el-table-column label="性别" align="center" prop="gender" width="100">
|
||||
<template #default="scope">
|
||||
<span>{{ genderMap[scope.row.gender] || '未知' }}</span>
|
||||
@@ -103,11 +164,7 @@
|
||||
<el-table-column label="配后天数" align="center" prop="postMatingDay" width="150" sortable />
|
||||
<el-table-column label="备注" align="center" prop="comment" width="100" />
|
||||
<el-table-column label="技术员" align="center" prop="technician" width="100" />
|
||||
<el-table-column label="测量日期" align="center" prop="measureDate" width="120">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.measureDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="创建人" align="center" prop="createBy" width="100" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
<template #default="scope">
|
||||
@@ -161,7 +218,10 @@
|
||||
<el-input v-model="form.pipeLength" placeholder="请输入管围" :disabled="!isAdd" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="技术员" prop="technician">
|
||||
<el-input v-model="form.technician" placeholder="请输入技术员" :disabled="!isAdd" clearable />
|
||||
<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-col>
|
||||
@@ -205,16 +265,61 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<!-- 导入对话框 -->
|
||||
<el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body>
|
||||
<el-upload ref="uploadRef" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url"
|
||||
:disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess"
|
||||
:auto-upload="false" drag>
|
||||
<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">
|
||||
<span>仅允许导入xls、xlsx格式文件。</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitFileForm">确 定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="Body_measure">
|
||||
import { listBody_measure, getBody_measure, delBody_measure, addBody_measure, updateBody_measure, getSheepTypeList, searchEarNumbers } from "@/api/produce/bodyManage/body_measure"
|
||||
import { listBody_measure, getBody_measure, delBody_measure, addBody_measure, updateBody_measure, getSheepTypeList, searchEarNumbers, listBreedStatus } from "@/api/produce/bodyManage/body_measure"
|
||||
import { getSheepByManageTags } from "@/api/produce/manage_sheep/changeVariety"
|
||||
import { listSheepfold_management as listSheepfold } from '@/api/fileManagement/sheepfold_management'
|
||||
import { getVarietyOptions } from '@/api/produce/other/fixHoof'
|
||||
import { getCurrentInstance } from 'vue'
|
||||
import { getUserByPost } from '@/api/common/user'
|
||||
import { Plus, Delete, ArrowUp, ArrowDown } from '@element-plus/icons-vue'
|
||||
import { nextTick } from 'vue'
|
||||
import dayjs from 'dayjs'
|
||||
import { UploadFilled } from '@element-plus/icons-vue'
|
||||
import { getToken } from "@/utils/auth"
|
||||
|
||||
// 技术员下拉选项
|
||||
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 { proxy } = getCurrentInstance()
|
||||
|
||||
const body_measureList = ref([])
|
||||
@@ -229,12 +334,29 @@ const title = ref("")
|
||||
const daterangeCreateTime = ref([])
|
||||
const isAdd = ref(false)
|
||||
const daterangeMeasureDate = ref([]);
|
||||
const breedStatusOptions = ref([])
|
||||
|
||||
const genderMap = {
|
||||
1: '母',
|
||||
2: '公',
|
||||
3: '阉羊'
|
||||
};
|
||||
const pasteText = ref('')
|
||||
const isExpanded = ref(false)
|
||||
const defaultShowCount = 2
|
||||
const displayedEarTags = computed(() => {
|
||||
const list = queryParams.value.manageTagsList
|
||||
if (isExpanded.value || list.length <= defaultShowCount) return list
|
||||
return list.slice(0, defaultShowCount)
|
||||
})
|
||||
|
||||
const upload = reactive({
|
||||
open: false,
|
||||
title: '',
|
||||
isUploading: false,
|
||||
headers: { Authorization: "Bearer " + getToken() },
|
||||
url: import.meta.env.VITE_APP_BASE_API + '/body_measure/body_measure/import'
|
||||
})
|
||||
|
||||
const data = reactive({
|
||||
form: { manageTags: null, technician: null },
|
||||
@@ -246,7 +368,12 @@ const data = reactive({
|
||||
varietyId: null,
|
||||
manageTags: null,
|
||||
measureDate: null,
|
||||
createTime: null
|
||||
createTime: null,
|
||||
manageTagsList: [],
|
||||
gender: null,
|
||||
technician: null,
|
||||
isDelete: null,
|
||||
breedStatusName: null,
|
||||
},
|
||||
rules: {
|
||||
manageTags: [
|
||||
@@ -342,6 +469,18 @@ function reset() {
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
if (queryParams.value.monthAgeStart !== null) {
|
||||
queryParams.value.params["monthAgeStart"] = queryParams.value.monthAgeStart
|
||||
}
|
||||
if (queryParams.value.monthAgeEnd !== null) {
|
||||
queryParams.value.params["monthAgeEnd"] = queryParams.value.monthAgeEnd
|
||||
}
|
||||
if (queryParams.value.breedStatusName) {
|
||||
queryParams.value.params = {
|
||||
...queryParams.value.params,
|
||||
breedStatusName: queryParams.value.breedStatusName
|
||||
}
|
||||
}
|
||||
queryParams.value.pageNum = 1
|
||||
getList()
|
||||
}
|
||||
@@ -354,7 +493,12 @@ function resetQuery() {
|
||||
queryParams.value.varietyId = null;
|
||||
data.varietyName = '';
|
||||
daterangeMeasureDate.value = [];
|
||||
queryParams.value.manageTagsList = []
|
||||
queryParams.value.manageTagsList = [];
|
||||
queryParams.value.gender = null;
|
||||
queryParams.value.technician = null;
|
||||
queryParams.value.isDelete = null;
|
||||
queryParams.value.monthAgeStart = null
|
||||
queryParams.value.monthAgeEnd = null
|
||||
proxy.resetForm("queryRef");
|
||||
handleQuery();
|
||||
}
|
||||
@@ -372,6 +516,7 @@ function handleAdd() {
|
||||
isAdd.value = true
|
||||
open.value = true
|
||||
title.value = "添加体尺测量"
|
||||
form.value.measureDate = dayjs().format('YYYY-MM-DD')
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
@@ -457,25 +602,110 @@ function searchEarNumber(query) {
|
||||
earOptions.value = res.data || []
|
||||
}).finally(() => earLoading.value = false)
|
||||
}
|
||||
function handlePaste() {
|
||||
nextTick(() => handlePasteSubmit())
|
||||
}
|
||||
|
||||
function handlePasteSubmit() {
|
||||
if (!pasteText.value.trim()) return
|
||||
const separators = /[\s,,\n\r\t]+/
|
||||
const raw = pasteText.value.trim().split(separators).filter(v => v)
|
||||
const exist = new Set(queryParams.value.manageTagsList)
|
||||
const adds = []
|
||||
const dups = []
|
||||
raw.forEach(v => {
|
||||
if (!exist.has(v)) { adds.push(v); exist.add(v) }
|
||||
else dups.push(v)
|
||||
})
|
||||
if (adds.length) {
|
||||
queryParams.value.manageTagsList = [...queryParams.value.manageTagsList, ...adds]
|
||||
proxy.$modal.msgSuccess(`成功添加 ${adds.length} 个耳号${dups.length ? `,已忽略 ${dups.length} 个重复` : ''}`)
|
||||
} else if (dups.length) {
|
||||
proxy.$modal.msgWarning('所有耳号均已存在')
|
||||
}
|
||||
pasteText.value = ''
|
||||
}
|
||||
|
||||
function toggleExpand() {
|
||||
isExpanded.value = !isExpanded.value
|
||||
}
|
||||
|
||||
function handleEarChange(val) {
|
||||
queryParams.value.manageTagsList = [...new Set(val)]
|
||||
}
|
||||
function clearEarNumbers() {
|
||||
queryParams.value.manageTagsList = []
|
||||
}
|
||||
|
||||
function removeEarNumber(tag) {
|
||||
const idx = queryParams.value.manageTagsList.indexOf(tag)
|
||||
if (idx > -1) queryParams.value.manageTagsList.splice(idx, 1)
|
||||
}
|
||||
|
||||
/** 导入按钮操作 */
|
||||
function handleImport() {
|
||||
upload.title = "体尺测量数据导入"
|
||||
upload.open = true
|
||||
}
|
||||
|
||||
/** 下载模板 */
|
||||
function importTemplate() {
|
||||
proxy.download('body_measure/body_measure/importTemplate', {}, `体尺测量导入模板_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
/** 文件上传中处理 */
|
||||
function handleFileUploadProgress(event, file, fileList) {
|
||||
upload.isUploading = true
|
||||
}
|
||||
|
||||
/** 文件上传成功处理 */
|
||||
function handleFileSuccess(response, file, fileList) {
|
||||
upload.open = false
|
||||
upload.isUploading = false
|
||||
proxy.$refs["uploadRef"].clearFiles()
|
||||
proxy.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true })
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 提交上传文件 */
|
||||
function submitFileForm() {
|
||||
proxy.$refs["uploadRef"].submit()
|
||||
}
|
||||
|
||||
// 加载繁殖状态
|
||||
function loadBreedStatusOptions() {
|
||||
listBreedStatus().then(res => {
|
||||
breedStatusOptions.value = res.data || []
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
getSheepfoldOptions()
|
||||
loadSheepTypeList()
|
||||
loadVarietyOptions()
|
||||
fetchTechnicalList()
|
||||
loadBreedStatusOptions()
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
<style scoped>
|
||||
.selected-ear-numbers{
|
||||
margin-bottom: 16px;
|
||||
padding: 10px;
|
||||
.selected-ear-numbers {
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
border: 1px dashed #dcdfe6;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.selected-ear-numbers::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.selected-ear-numbers::-webkit-scrollbar-thumb {
|
||||
background-color: #dcdfe6;
|
||||
border-radius: 3px;
|
||||
}
|
||||
</style>
|
||||
@@ -6,15 +6,39 @@
|
||||
start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="管理耳号" prop="manageTagsList">
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="请输入耳号,支持多选" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option style="width: 260px">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
<el-button type="text" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" style="margin-left: 8px">
|
||||
清空
|
||||
</el-button>
|
||||
<div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap;">
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="输入耳号搜索" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option collapse-tags :max-collapse-tags="0" style="width:260px" @change="handleEarChange">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
<el-input v-model="pasteText" placeholder="或粘贴多个耳号(空格/换行/逗号分隔)" style="width:260px" @paste="handlePaste"
|
||||
@keyup.enter="handlePasteSubmit" clearable>
|
||||
<template #append>
|
||||
<el-button @click="handlePasteSubmit" :icon="Plus">添加</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
<el-tag v-if="queryParams.manageTagsList.length" type="info" effect="plain" size="large">
|
||||
已选: {{ queryParams.manageTagsList.length }} 个
|
||||
</el-tag>
|
||||
<el-button type="danger" plain :icon="Delete" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList.length">
|
||||
清空全部
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-if="queryParams.manageTagsList.length" class="selected-ear-numbers">
|
||||
<el-tag v-for="tag in displayedEarTags" :key="tag" closable @close="removeEarNumber(tag)" style="margin:4px"
|
||||
type="success">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
<el-button v-if="queryParams.manageTagsList.length > defaultShowCount" type="primary" link
|
||||
@click="toggleExpand">
|
||||
{{ isExpanded ? '收起' : `展开剩余 ${queryParams.manageTagsList.length - defaultShowCount} 个` }}
|
||||
<el-icon class="el-icon--right">
|
||||
<component :is="isExpanded ? ArrowUp : ArrowDown" />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="品种" prop="varietyId">
|
||||
<el-select v-model="queryParams.varietyId" placeholder="请选择品种" clearable style="min-width:150px">
|
||||
@@ -26,18 +50,18 @@
|
||||
<el-option v-for="item in sheepfoldOptions" :key="item.id" :label="item.sheepfoldName" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否在群" prop="isDelete">
|
||||
<el-select v-model="queryParams.isDelete" placeholder="全部" clearable style="min-width:120px">
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="在群" :value="0" />
|
||||
<el-option label="离群" :value="1" />
|
||||
</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-button icon="Refresh" @click="resetQuery">重置</el-button> -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" class="selected-ear-numbers">
|
||||
<span style="margin-right: 10px; color: #606266;">已选耳号:</span>
|
||||
<el-tag v-for="tag in queryParams.manageTagsList" :key="tag" closable @close="removeEarNumber(tag)"
|
||||
style="margin-right: 8px;">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd"
|
||||
@@ -129,11 +153,13 @@
|
||||
</template>
|
||||
|
||||
<script setup name="Body_score">
|
||||
import { listBody_score, getBody_score, delBody_score, addBody_score, updateBody_score ,searchEarNumbers} from "@/api/produce/bodyManage/body_score"
|
||||
import { listBody_score, getBody_score, delBody_score, addBody_score, updateBody_score, searchEarNumbers } from "@/api/produce/bodyManage/body_score"
|
||||
import { listSheepfold_management as listSheepfold } from '@/api/fileManagement/sheepfold_management'
|
||||
import { checkSheepByManageTags, getVarietyOptions } from "@/api/produce/other/fixHoof"
|
||||
import { getCurrentInstance, ref, reactive, toRefs } from 'vue'
|
||||
|
||||
import { Plus, Delete, ArrowUp, ArrowDown } from '@element-plus/icons-vue'
|
||||
import { nextTick } from 'vue'
|
||||
import dayjs from 'dayjs'
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const body_scoreList = ref([])
|
||||
@@ -149,7 +175,14 @@ const daterangeDatetime = ref([])
|
||||
const daterangeCreateTime = ref([])
|
||||
const sheepfoldList = ref([])
|
||||
const isAdd = ref(false)
|
||||
|
||||
const pasteText = ref('')
|
||||
const isExpanded = ref(false)
|
||||
const defaultShowCount = 2
|
||||
const displayedEarTags = computed(() => {
|
||||
const list = queryParams.value.manageTagsList
|
||||
if (isExpanded.value || list.length <= defaultShowCount) return list
|
||||
return list.slice(0, defaultShowCount)
|
||||
})
|
||||
const data = reactive({
|
||||
form: {
|
||||
id: null,
|
||||
@@ -167,7 +200,9 @@ const data = reactive({
|
||||
varietyId: null,
|
||||
sheepfold: null,
|
||||
score: null,
|
||||
createTime: null
|
||||
createTime: null,
|
||||
manageTagsList: [],
|
||||
isDelete: null
|
||||
},
|
||||
rules: {
|
||||
manageTags: [
|
||||
@@ -277,8 +312,9 @@ function handleQuery() {
|
||||
function resetQuery() {
|
||||
daterangeDatetime.value = []
|
||||
daterangeCreateTime.value = []
|
||||
queryParams.value.varietyId = null;
|
||||
queryParams.value.varietyId = null
|
||||
queryParams.value.manageTagsList = []
|
||||
queryParams.value.isDelete = null
|
||||
proxy.resetForm("queryRef")
|
||||
handleQuery()
|
||||
}
|
||||
@@ -296,6 +332,7 @@ function handleAdd() {
|
||||
isAdd.value = true
|
||||
open.value = true
|
||||
title.value = "添加体况评分"
|
||||
form.value.datetime = dayjs().format('YYYY-MM-DD')
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
@@ -370,10 +407,42 @@ function searchEarNumber(query) {
|
||||
function clearEarNumbers() {
|
||||
queryParams.value.manageTagsList = []
|
||||
}
|
||||
|
||||
function removeEarNumber(tag) {
|
||||
const idx = queryParams.value.manageTagsList.indexOf(tag)
|
||||
if (idx > -1) queryParams.value.manageTagsList.splice(idx, 1)
|
||||
}
|
||||
function handlePaste() {
|
||||
nextTick(() => handlePasteSubmit())
|
||||
}
|
||||
|
||||
function handlePasteSubmit() {
|
||||
if (!pasteText.value.trim()) return
|
||||
const separators = /[\s,,\n\r\t]+/
|
||||
const raw = pasteText.value.trim().split(separators).filter(v => v)
|
||||
const exist = new Set(queryParams.value.manageTagsList)
|
||||
const adds = []
|
||||
const dups = []
|
||||
raw.forEach(v => {
|
||||
if (!exist.has(v)) { adds.push(v); exist.add(v) }
|
||||
else dups.push(v)
|
||||
})
|
||||
if (adds.length) {
|
||||
queryParams.value.manageTagsList = [...queryParams.value.manageTagsList, ...adds]
|
||||
proxy.$modal.msgSuccess(`成功添加 ${adds.length} 个耳号${dups.length ? `,已忽略 ${dups.length} 个重复` : ''}`)
|
||||
} else if (dups.length) {
|
||||
proxy.$modal.msgWarning('所有耳号均已存在')
|
||||
}
|
||||
pasteText.value = ''
|
||||
}
|
||||
|
||||
function toggleExpand() {
|
||||
isExpanded.value = !isExpanded.value
|
||||
}
|
||||
|
||||
function handleEarChange(val) {
|
||||
queryParams.value.manageTagsList = [...new Set(val)]
|
||||
}
|
||||
onMounted(() => {
|
||||
loadVarietyOptions()
|
||||
getSheepfoldOptions()
|
||||
@@ -381,10 +450,24 @@ onMounted(() => {
|
||||
})
|
||||
</script>
|
||||
<style scoped>
|
||||
.selected-ear-numbers{
|
||||
margin-bottom: 16px;
|
||||
padding: 10px;
|
||||
.selected-ear-numbers {
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
border: 1px dashed #dcdfe6;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.selected-ear-numbers::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.selected-ear-numbers::-webkit-scrollbar-thumb {
|
||||
background-color: #dcdfe6;
|
||||
border-radius: 3px;
|
||||
}
|
||||
</style>
|
||||
@@ -10,15 +10,39 @@
|
||||
start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="管理耳号" prop="manageTagsList">
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="请输入耳号,支持多选" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option style="width: 260px">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
<el-button type="text" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" style="margin-left: 8px">
|
||||
清空
|
||||
</el-button>
|
||||
<div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap;">
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="输入耳号搜索" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option collapse-tags :max-collapse-tags="0" style="width:260px" @change="handleEarChange">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
<el-input v-model="pasteText" placeholder="或粘贴多个耳号(空格/换行/逗号分隔)" style="width:260px" @paste="handlePaste"
|
||||
@keyup.enter="handlePasteSubmit" clearable>
|
||||
<template #append>
|
||||
<el-button @click="handlePasteSubmit" :icon="Plus">添加</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
<el-tag v-if="queryParams.manageTagsList.length" type="info" effect="plain" size="large">
|
||||
已选: {{ queryParams.manageTagsList.length }} 个
|
||||
</el-tag>
|
||||
<el-button type="danger" plain :icon="Delete" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList.length">
|
||||
清空全部
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-if="queryParams.manageTagsList.length" class="selected-ear-numbers">
|
||||
<el-tag v-for="tag in displayedEarTags" :key="tag" closable @close="removeEarNumber(tag)" style="margin:4px"
|
||||
type="success">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
<el-button v-if="queryParams.manageTagsList.length > defaultShowCount" type="primary" link
|
||||
@click="toggleExpand">
|
||||
{{ isExpanded ? '收起' : `展开剩余 ${queryParams.manageTagsList.length - defaultShowCount} 个` }}
|
||||
<el-icon class="el-icon--right">
|
||||
<component :is="isExpanded ? ArrowUp : ArrowDown" />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="品种" prop="varietyId">
|
||||
<el-select v-model="queryParams.varietyId" placeholder="请选择品种" clearable style="min-width:150px">
|
||||
@@ -30,9 +54,16 @@
|
||||
<el-option v-for="item in sheepfoldOptions" :key="item.id" :label="item.sheepfoldName" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否在群" prop="isDelete">
|
||||
<el-select v-model="queryParams.isDelete" placeholder="全部" clearable style="min-width:120px">
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="在群" :value="0" />
|
||||
<el-option label="离群" :value="1" />
|
||||
</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-button icon="Refresh" @click="resetQuery">重置</el-button> -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
@@ -54,13 +85,6 @@
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
<div v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" class="selected-ear-numbers">
|
||||
<span style="margin-right: 10px; color: #606266;">已选耳号:</span>
|
||||
<el-tag v-for="tag in queryParams.manageTagsList" :key="tag" closable @close="removeEarNumber(tag)"
|
||||
style="margin-right: 8px;">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="breast_ratingList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="管理耳号" align="center" prop="manageTags" min-width="100px" fixed />
|
||||
@@ -151,7 +175,9 @@ import { listBreast_rating, getBreast_rating, delBreast_rating, addBreast_rating
|
||||
import { checkSheepByManageTags, getVarietyOptions } from "@/api/produce/other/fixHoof"
|
||||
import { listSheepfold_management as listSheepfold } from '@/api/fileManagement/sheepfold_management'
|
||||
import { getCurrentInstance, reactive, ref } from "vue"
|
||||
|
||||
import { Plus, Delete, ArrowUp, ArrowDown } from '@element-plus/icons-vue'
|
||||
import { nextTick } from 'vue'
|
||||
import dayjs from 'dayjs'
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const breast_ratingList = ref([])
|
||||
@@ -166,7 +192,14 @@ const title = ref("")
|
||||
const daterangeCreateTime = ref([])
|
||||
const daterangeEventDate = ref([]);
|
||||
const isAdd = ref(false)
|
||||
|
||||
const pasteText = ref('')
|
||||
const isExpanded = ref(false)
|
||||
const defaultShowCount = 2
|
||||
const displayedEarTags = computed(() => {
|
||||
const list = queryParams.value.manageTagsList
|
||||
if (isExpanded.value || list.length <= defaultShowCount) return list
|
||||
return list.slice(0, defaultShowCount)
|
||||
})
|
||||
const data = reactive({
|
||||
form: {
|
||||
id: null,
|
||||
@@ -184,7 +217,9 @@ const data = reactive({
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
manageTags: null
|
||||
manageTags: null,
|
||||
manageTagsList: [],
|
||||
isDelete: null
|
||||
},
|
||||
rules: {
|
||||
manageTags: [
|
||||
@@ -285,8 +320,9 @@ function handleQuery() {
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
daterangeCreateTime.value = []
|
||||
daterangeEventDate.value = [];
|
||||
daterangeEventDate.value = []
|
||||
queryParams.value.manageTagsList = []
|
||||
queryParams.value.isDelete = null
|
||||
proxy.resetForm("queryRef")
|
||||
handleQuery()
|
||||
}
|
||||
@@ -304,6 +340,7 @@ function handleAdd() {
|
||||
isAdd.value = true
|
||||
open.value = true
|
||||
title.value = "添加乳房评分"
|
||||
form.value.eventDate = dayjs().format('YYYY-MM-DD')
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
@@ -386,10 +423,42 @@ function searchEarNumber(query) {
|
||||
function clearEarNumbers() {
|
||||
queryParams.value.manageTagsList = []
|
||||
}
|
||||
|
||||
function removeEarNumber(tag) {
|
||||
const idx = queryParams.value.manageTagsList.indexOf(tag)
|
||||
if (idx > -1) queryParams.value.manageTagsList.splice(idx, 1)
|
||||
}
|
||||
function handlePaste() {
|
||||
nextTick(() => handlePasteSubmit())
|
||||
}
|
||||
|
||||
function handlePasteSubmit() {
|
||||
if (!pasteText.value.trim()) return
|
||||
const separators = /[\s,,\n\r\t]+/
|
||||
const raw = pasteText.value.trim().split(separators).filter(v => v)
|
||||
const exist = new Set(queryParams.value.manageTagsList)
|
||||
const adds = []
|
||||
const dups = []
|
||||
raw.forEach(v => {
|
||||
if (!exist.has(v)) { adds.push(v); exist.add(v) }
|
||||
else dups.push(v)
|
||||
})
|
||||
if (adds.length) {
|
||||
queryParams.value.manageTagsList = [...queryParams.value.manageTagsList, ...adds]
|
||||
proxy.$modal.msgSuccess(`成功添加 ${adds.length} 个耳号${dups.length ? `,已忽略 ${dups.length} 个重复` : ''}`)
|
||||
} else if (dups.length) {
|
||||
proxy.$modal.msgWarning('所有耳号均已存在')
|
||||
}
|
||||
pasteText.value = ''
|
||||
}
|
||||
|
||||
function toggleExpand() {
|
||||
isExpanded.value = !isExpanded.value
|
||||
}
|
||||
|
||||
function handleEarChange(val) {
|
||||
queryParams.value.manageTagsList = [...new Set(val)]
|
||||
}
|
||||
onMounted(() => {
|
||||
loadVarietyOptions()
|
||||
getSheepfoldOptions()
|
||||
@@ -398,9 +467,23 @@ onMounted(() => {
|
||||
</script>
|
||||
<style scoped>
|
||||
.selected-ear-numbers {
|
||||
margin-bottom: 16px;
|
||||
padding: 10px;
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
border: 1px dashed #dcdfe6;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.selected-ear-numbers::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.selected-ear-numbers::-webkit-scrollbar-thumb {
|
||||
background-color: #dcdfe6;
|
||||
border-radius: 3px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 顶部按钮 -->
|
||||
<el-button type="primary" plain icon="Plus" @click="handleImport"
|
||||
<el-button type="success" plain icon="Upload" @click="handleImport"
|
||||
v-hasPermi="['produce:add_sheep:import']">导入</el-button>
|
||||
<el-button type="warning" icon="Upload" @click="handleExportForm">下载模板</el-button>
|
||||
|
||||
@@ -130,8 +130,13 @@
|
||||
<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>
|
||||
<i class="el-icon-upload" />
|
||||
<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">
|
||||
<span>仅允许导入xls、xlsx格式文件。</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="submitUpload">确 定</el-button>
|
||||
@@ -148,6 +153,7 @@ import { getSheepTypeList } from "@/api/produce/bodyManage/body_measure"
|
||||
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'
|
||||
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
@@ -6,45 +6,79 @@
|
||||
end-placeholder="结束日期" value-format="YYYY-MM-DD" />
|
||||
</el-form-item>
|
||||
<el-form-item label="管理耳号" prop="manageTagsList">
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="请输入耳号,支持多选" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option style="width: 260px">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
<el-button type="text" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" style="margin-left: 8px">
|
||||
清空
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item label="新备注" prop="newComment">
|
||||
<el-input v-model="queryParams.newComment" placeholder="请输入新备注" clearable @keyup.enter="handleQuery"
|
||||
style="max-width: 160px;" />
|
||||
<div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap;">
|
||||
<!-- 主选择器:不展示已选标签 -->
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="输入耳号搜索" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option collapse-tags :max-collapse-tags="0" style="width:300px" @change="handleEarChange">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
|
||||
<!-- 批量粘贴框 -->
|
||||
<el-input v-model="pasteText" placeholder="或粘贴多个耳号(空格/换行/逗号分隔)" style="width:300px" @paste="handlePaste"
|
||||
@keyup.enter="handlePasteSubmit" clearable>
|
||||
<template #append>
|
||||
<el-button @click="handlePasteSubmit" :icon="Plus">添加</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
|
||||
<!-- 计数标签 -->
|
||||
<el-tag v-if="queryParams.manageTagsList.length" type="info" effect="plain" size="large">
|
||||
已选: {{ queryParams.manageTagsList.length }} 个
|
||||
</el-tag>
|
||||
|
||||
<!-- 一键清空 -->
|
||||
<el-button type="danger" plain :icon="Delete" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList.length">
|
||||
清空全部
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 已选耳号展示区(可折叠) -->
|
||||
<div v-if="queryParams.manageTagsList.length" class="selected-ear-numbers">
|
||||
<el-tag v-for="tag in displayedEarTags" :key="tag" closable @close="removeEarNumber(tag)" style="margin:4px"
|
||||
type="success">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
|
||||
<el-button v-if="queryParams.manageTagsList.length > defaultShowCount" type="primary" link
|
||||
@click="toggleExpand">
|
||||
{{ isExpanded ? '收起' : `展开剩余 ${queryParams.manageTagsList.length - defaultShowCount} 个` }}
|
||||
<el-icon class="el-icon--right">
|
||||
<component :is="isExpanded ? ArrowUp : ArrowDown" />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="原备注" prop="oldComment">
|
||||
<el-input v-model="queryParams.oldComment" placeholder="请输入原备注" clearable @keyup.enter="handleQuery"
|
||||
style="max-width: 160px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="羊舍" prop="sheepfoldId">
|
||||
<el-form-item label="新备注" prop="newComment">
|
||||
<el-input v-model="queryParams.newComment" placeholder="请输入新备注" clearable @keyup.enter="handleQuery"
|
||||
style="max-width: 160px;" />
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="羊舍" prop="sheepfoldId">
|
||||
<el-select v-model="queryParams.sheepfoldId" placeholder="请选择羊舍" style="min-width:150px" clearable>
|
||||
<el-option v-for="fold in sheepfoldOptions" :key="fold.id" :label="fold.sheepfoldName" :value="fold.id" />
|
||||
</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-form-item>
|
||||
<el-form-item label="是否在群" prop="isDelete">
|
||||
<el-select v-model="queryParams.isDelete" placeholder="全部" clearable style="min-width:120px">
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="在群" :value="0" />
|
||||
<el-option label="离群" :value="1" />
|
||||
</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-button icon="Refresh" @click="resetQuery">重置</el-button> -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" class="selected-ear-numbers">
|
||||
<span style="margin-right: 10px; color: #606266;">已选择耳号:</span>
|
||||
<el-tag
|
||||
v-for="tag in queryParams.manageTagsList"
|
||||
:key="tag"
|
||||
closable
|
||||
@close="removeEarNumber(tag)"
|
||||
style="margin-right: 8px;">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd"
|
||||
@@ -68,15 +102,15 @@
|
||||
<el-table v-loading="loading" :data="changeCommentList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="管理耳号" align="center" prop="manageTags" />
|
||||
<el-table-column label="羊舍" align="center" prop="sheepfoldName" />
|
||||
<el-table-column label="事件类型" align="center" prop="eventType" width="120" />
|
||||
<el-table-column label="新备注" align="center" prop="newComment" />
|
||||
<el-table-column label="原备注" align="center" prop="oldComment" />
|
||||
<el-table-column label="事件日期" align="center" prop="eventDate">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.eventDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="新备注" align="center" prop="newComment" />
|
||||
<el-table-column label="原备注" align="center" prop="oldComment" />
|
||||
<el-table-column label="羊舍" align="center" prop="sheepfoldName" />
|
||||
<el-table-column label="技术员" align="center" prop="technician" />
|
||||
<el-table-column label="创建人" align="center" prop="createBy" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
@@ -103,11 +137,22 @@
|
||||
<el-form-item label="管理耳号" prop="manageTags">
|
||||
<el-input v-model="form.manageTags" placeholder="请输入管理耳号" @blur="onManageTagsBlur" :disabled="!isAddMode" />
|
||||
</el-form-item>
|
||||
<!-- 新增弹窗已选耳号展示区 -->
|
||||
<div v-if="batchTags.length" class="selected-ear-numbers">
|
||||
<el-tag v-for="(tag, idx) in batchTags" :key="tag" closable @close="removeBatchTag(idx)" style="margin:4px"
|
||||
type="success">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
|
||||
<el-button type="primary" link @click="clearBatchTags">
|
||||
一键清空 ({{ batchTags.length }})
|
||||
</el-button>
|
||||
</div>
|
||||
<el-form-item label="新备注" prop="newComment">
|
||||
<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"
|
||||
@@ -128,10 +173,12 @@
|
||||
</template>
|
||||
|
||||
<script setup name="ChangeComment">
|
||||
import { listChangeComment, getChangeComment, delChangeComment, addChangeComment, updateChangeComment ,searchEarNumbers} from "@/api/produce/manage_sheep/changeComment"
|
||||
import { listChangeComment, getChangeComment, delChangeComment, addChangeComment, updateChangeComment, searchEarNumbers } from "@/api/produce/manage_sheep/changeComment"
|
||||
import { getSheepByManageTags } from "@/api/produce/manage_sheep/changeVariety"
|
||||
import { listSheepfold_management as listSheepfold } from '@/api/fileManagement/sheepfold_management'
|
||||
|
||||
import dayjs from 'dayjs'
|
||||
import { nextTick } from 'vue'
|
||||
import { Plus, Delete, ArrowUp, ArrowDown } from '@element-plus/icons-vue'
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const changeCommentList = ref([])
|
||||
@@ -146,6 +193,18 @@ const title = ref("")
|
||||
const daterangeCreateTime = ref([])
|
||||
const isAddMode = ref(true);
|
||||
const daterangeEventDate = ref([])
|
||||
const pasteText = ref('') // 粘贴框
|
||||
const isExpanded = ref(false) // 折叠状态
|
||||
const defaultShowCount = 2 // 默认展示条数
|
||||
const batchTags = ref([]) // 本次要新增的多条耳号
|
||||
const batchSheep = ref([]) // 对应的羊只对象
|
||||
/* 计算:控制实际展示的耳号 */
|
||||
const displayedEarTags = computed(() => {
|
||||
const list = queryParams.value.manageTagsList
|
||||
if (isExpanded.value || list.length <= defaultShowCount) return list
|
||||
return list.slice(0, defaultShowCount)
|
||||
})
|
||||
|
||||
const data = reactive({
|
||||
form: { manageTags: null, eventDate: null, technician: null },
|
||||
queryParams: {
|
||||
@@ -156,7 +215,9 @@ const data = reactive({
|
||||
sheepfoldId: null,
|
||||
newComment: null,
|
||||
oldComment: null,
|
||||
createTime: null
|
||||
createTime: null,
|
||||
manageTagsList: [],
|
||||
isDelete: null
|
||||
},
|
||||
rules: {
|
||||
manageTags: [
|
||||
@@ -200,24 +261,47 @@ function getList() {
|
||||
}
|
||||
|
||||
//校验和回显
|
||||
function onManageTagsBlur() {
|
||||
const tag = form.value.manageTags?.trim();
|
||||
if (!tag) return;
|
||||
async function onManageTagsBlur() {
|
||||
const raw = form.value.manageTags?.trim()
|
||||
if (!raw) return
|
||||
|
||||
getSheepByManageTags(tag).then(res => {
|
||||
const sheep = res.data;
|
||||
// 1. 先按分隔符拆
|
||||
const separators = /[\p{White_Space},,]+/u
|
||||
const tags = [...new Set(raw.split(separators).filter(v => v))]
|
||||
|
||||
// 2. 只有一条 → 走老逻辑
|
||||
if (tags.length === 1) {
|
||||
const sheep = await getSheepByManageTags(tags[0]).then(r => r.data).catch(() => null)
|
||||
if (sheep) {
|
||||
form.value.sheepId = sheep.id;
|
||||
form.value.oldComment = sheep.comment || "";
|
||||
batchTags.value = [tags[0]]
|
||||
batchSheep.value = [sheep]
|
||||
form.value.oldComment = sheep.comment || ''
|
||||
} else {
|
||||
proxy.$modal.msgWarning("未找到该管理耳号对应的羊只");
|
||||
form.value.sheepId = null;
|
||||
form.value.oldComment = "";
|
||||
proxy.$modal.msgWarning('未找到该耳号对应羊只')
|
||||
batchTags.value = []
|
||||
batchSheep.value = []
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error("查询羊只失败:", err);
|
||||
proxy.$modal.msgError("查询失败,请重试");
|
||||
});
|
||||
return
|
||||
}
|
||||
|
||||
// 3. 多条 → 批量校验
|
||||
batchTags.value = []
|
||||
batchSheep.value = []
|
||||
for (const tag of tags) {
|
||||
const sheep = await getSheepByManageTags(tag).then(r => r.data).catch(() => null)
|
||||
if (sheep) {
|
||||
batchTags.value.push(tag)
|
||||
batchSheep.value.push(sheep)
|
||||
} else {
|
||||
proxy.$modal.msgWarning(`耳号 ${tag} 未找到对应羊只,已跳过`)
|
||||
}
|
||||
}
|
||||
|
||||
if (!batchTags.value.length) return // 全部无效
|
||||
// 把合法耳号重新拼回输入框,用半角空格分隔,用户一眼能看到哪些生效
|
||||
form.value.manageTags = batchTags.value.join(' ')
|
||||
// 旧备注取第一条的,提交时再循环
|
||||
form.value.oldComment = batchSheep.value[0].comment || ''
|
||||
}
|
||||
|
||||
|
||||
@@ -238,6 +322,8 @@ function reset() {
|
||||
createBy: null,
|
||||
createTime: null
|
||||
}
|
||||
batchTags.value = []
|
||||
batchSheep.value = []
|
||||
proxy.resetForm("changeCommentRef")
|
||||
}
|
||||
|
||||
@@ -253,6 +339,7 @@ function resetQuery() {
|
||||
daterangeEventDate.value = []
|
||||
queryParams.value.sheepfoldId = null
|
||||
queryParams.value.manageTagsList = []
|
||||
queryParams.value.isDelete = null
|
||||
proxy.resetForm("queryRef")
|
||||
handleQuery()
|
||||
}
|
||||
@@ -270,6 +357,7 @@ function handleAdd() {
|
||||
isAddMode.value = true;
|
||||
open.value = true
|
||||
title.value = "添加改备注"
|
||||
form.value.eventDate = dayjs().format('YYYY-MM-DD');
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
@@ -286,30 +374,27 @@ function handleUpdate(row) {
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["changeCommentRef"].validate(valid => {
|
||||
if (valid) {
|
||||
if (!form.value.id) {
|
||||
if (!form.value.sheepId) {
|
||||
proxy.$modal.msgError('未找到对应的羊只,请检查耳号');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (form.value.id != null) {
|
||||
updateChangeComment(form.value).then(() => {
|
||||
proxy.$modal.msgSuccess("修改成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
} else {
|
||||
addChangeComment(form.value).then(() => {
|
||||
proxy.$modal.msgSuccess("新增成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
if (batchTags.value.length === 0) {
|
||||
proxy.$modal.msgError('请输入至少一个有效耳号')
|
||||
return
|
||||
}
|
||||
// 批量新增
|
||||
Promise.all(
|
||||
batchTags.value.map((tag, idx) =>
|
||||
addChangeComment({
|
||||
sheepId: batchSheep.value[idx].id,
|
||||
manageTags: tag,
|
||||
oldComment: batchSheep.value[idx].comment || '',
|
||||
newComment: form.value.newComment,
|
||||
eventDate: form.value.eventDate,
|
||||
technician: form.value.technician
|
||||
})
|
||||
)
|
||||
).then(() => {
|
||||
proxy.$modal.msgSuccess(`成功新增 ${batchTags.value.length} 条改备注`)
|
||||
open.value = false
|
||||
getList() // 刷新表格
|
||||
}).catch(() => { })
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
@@ -356,6 +441,56 @@ function removeEarNumber(tag) {
|
||||
const idx = queryParams.value.manageTagsList.indexOf(tag)
|
||||
if (idx > -1) queryParams.value.manageTagsList.splice(idx, 1)
|
||||
}
|
||||
/* 粘贴事件 */
|
||||
function handlePaste() {
|
||||
nextTick(() => handlePasteSubmit())
|
||||
}
|
||||
/* 批量提交 */
|
||||
function handlePasteSubmit() {
|
||||
if (!pasteText.value.trim()) return
|
||||
const separators = /[\s,,\n\r\t]+/;
|
||||
const raw = pasteText.value.trim().split(separators).filter(v => v)
|
||||
const exist = new Set(queryParams.value.manageTagsList)
|
||||
const adds = []
|
||||
const dups = []
|
||||
raw.forEach(v => {
|
||||
if (!exist.has(v)) { adds.push(v); exist.add(v) }
|
||||
else dups.push(v)
|
||||
})
|
||||
if (adds.length) {
|
||||
queryParams.value.manageTagsList = [...queryParams.value.manageTagsList, ...adds]
|
||||
proxy.$modal.msgSuccess(`成功添加 ${adds.length} 个耳号${dups.length ? `,已忽略 ${dups.length} 个重复` : ''}`)
|
||||
} else if (dups.length) {
|
||||
proxy.$modal.msgWarning('所有耳号均已存在')
|
||||
}
|
||||
pasteText.value = ''
|
||||
}
|
||||
/* 折叠/收起 */
|
||||
function toggleExpand() {
|
||||
isExpanded.value = !isExpanded.value
|
||||
}
|
||||
/* 选择器变化时去重 */
|
||||
function handleEarChange(val) {
|
||||
queryParams.value.manageTagsList = [...new Set(val)]
|
||||
}
|
||||
/* 删除单个批量耳号 */
|
||||
function removeBatchTag(idx) {
|
||||
batchTags.value.splice(idx, 1)
|
||||
batchSheep.value.splice(idx, 1)
|
||||
// 实时回写输入框,保持可视化
|
||||
form.value.manageTags = batchTags.value.join(' ')
|
||||
}
|
||||
|
||||
/* 一键清空批量耳号 */
|
||||
function clearBatchTags() {
|
||||
batchTags.value = []
|
||||
batchSheep.value = []
|
||||
form.value.manageTags = ''
|
||||
form.value.oldComment = ''
|
||||
}
|
||||
|
||||
/* 计算属性:实时显示已选数量(可选) */
|
||||
const batchCount = computed(() => batchTags.value.length)
|
||||
onMounted(() => {
|
||||
getSheepfoldOptions();
|
||||
getList();
|
||||
@@ -363,10 +498,24 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.selected-ear-numbers{
|
||||
margin-bottom: 16px;
|
||||
padding: 10px;
|
||||
.selected-ear-numbers {
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
border: 1px dashed #dcdfe6;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.selected-ear-numbers::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.selected-ear-numbers::-webkit-scrollbar-thumb {
|
||||
background-color: #dcdfe6;
|
||||
border-radius: 3px;
|
||||
}
|
||||
</style>
|
||||
@@ -6,15 +6,49 @@
|
||||
end-placeholder="结束日期" value-format="YYYY-MM-DD" />
|
||||
</el-form-item>
|
||||
<el-form-item label="耳号" prop="manageTagsList">
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="请输入耳号,支持多选" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option style="width: 260px">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
<el-button type="text" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" style="margin-left: 8px">
|
||||
清空
|
||||
</el-button>
|
||||
<div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap;">
|
||||
<!-- 主选择器:不展示已选标签 -->
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="输入耳号搜索" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option collapse-tags :max-collapse-tags="0" style="width:300px" @change="handleEarChange">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
|
||||
<!-- 批量粘贴框 -->
|
||||
<el-input v-model="pasteText" placeholder="或粘贴多个耳号(空格/换行/逗号分隔)" style="width:300px" @paste="handlePaste"
|
||||
@keyup.enter="handlePasteSubmit" clearable>
|
||||
<template #append>
|
||||
<el-button @click="handlePasteSubmit" :icon="Plus">添加</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
|
||||
<!-- 计数标签 -->
|
||||
<el-tag v-if="queryParams.manageTagsList && queryParams.manageTagsList.length" type="info" effect="plain"
|
||||
size="large">
|
||||
已选: {{ queryParams.manageTagsList.length }} 个
|
||||
</el-tag>
|
||||
|
||||
<!-- 一键清空 -->
|
||||
<el-button type="danger" plain :icon="Delete" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList && queryParams.manageTagsList.length">
|
||||
清空全部
|
||||
</el-button>
|
||||
</div>
|
||||
<!-- 已选耳号展示区(可折叠) -->
|
||||
<div v-if="queryParams.manageTagsList && queryParams.manageTagsList.length" class="selected-ear-numbers">
|
||||
<el-tag v-for="tag in displayedEarTags" :key="tag" closable @close="removeEarNumber(tag)" style="margin:4px"
|
||||
type="success">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
|
||||
<el-button v-if="queryParams.manageTagsList.length > defaultShowCount" type="primary" link
|
||||
@click="toggleExpand">
|
||||
{{ isExpanded ? '收起' : `展开剩余 ${queryParams.manageTagsList.length - defaultShowCount} 个` }}
|
||||
<el-icon class="el-icon--right">
|
||||
<component :is="isExpanded ? ArrowUp : ArrowDown" />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="新耳号" prop="newTag">
|
||||
<el-input v-model="queryParams.newTag" placeholder="请输入新耳号" clearable @keyup.enter="handleQuery"
|
||||
@@ -24,9 +58,15 @@
|
||||
<el-input v-model="queryParams.oldTag" placeholder="请输入旧耳号" clearable @keyup.enter="handleQuery"
|
||||
style="max-width: 160px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="羊舍" prop="sheepfoldId">
|
||||
<el-select v-model="queryParams.sheepfoldId" placeholder="请选择羊舍" style="min-width:150px" clearable>
|
||||
<el-option v-for="fold in sheepfoldOptions" :key="fold.id" :label="fold.sheepfoldName" :value="fold.id" />
|
||||
<el-form-item label="技术员" prop="technician">
|
||||
<el-input v-model="queryParams.technician" placeholder="请输入技术员" clearable @keyup.enter="handleQuery"
|
||||
style="max-width: 160px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="是否在群" prop="inGroup">
|
||||
<el-select v-model="queryParams.inGroup" placeholder="全部" clearable style="width:120px">
|
||||
<el-option label="全部" :value="0" />
|
||||
<el-option label="在群" :value="1" />
|
||||
<el-option label="离群" :value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="耳号类型" prop="earType">
|
||||
@@ -37,16 +77,9 @@
|
||||
</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-button icon="Refresh" @click="resetQuery">重置</el-button> -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" class="selected-ear-numbers">
|
||||
<span style="margin-right: 10px; color: #606266;">已选耳号:</span>
|
||||
<el-tag v-for="tag in queryParams.manageTagsList" :key="tag" closable @close="removeEarNumber(tag)"
|
||||
style="margin-right: 8px;">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd"
|
||||
@@ -70,8 +103,13 @@
|
||||
<el-table v-loading="loading" :data="changeEarList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="耳号" align="center" prop="manageTags" />
|
||||
<el-table-column label="羊舍" align="center" prop="sheepfoldName" />
|
||||
<el-table-column label="品种" align="center" prop="varietyName" />
|
||||
<el-table-column label="事件类型" align="center" prop="eventType" />
|
||||
<el-table-column label="事件日期" align="center" prop="eventDate">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.eventDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="耳号类型" align="center" prop="earType">
|
||||
<template #default="scope">
|
||||
{{ scope.row.earType === 0 ? '电子耳号' : '管理耳号' }}
|
||||
@@ -79,19 +117,15 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="新耳号" align="center" prop="newTag" />
|
||||
<el-table-column label="旧耳号" align="center" prop="oldTag" />
|
||||
<el-table-column label="事件日期" align="center" prop="eventDate">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.eventDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="羊舍" align="center" prop="sheepfoldName" />
|
||||
<el-table-column label="技术员" align="center" prop="technician" />
|
||||
<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} {h}:{i}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="comment" />
|
||||
<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)"
|
||||
@@ -145,8 +179,11 @@
|
||||
</template>
|
||||
|
||||
<script setup name="ChangeEar">
|
||||
import { listChangeEar, getChangeEar, delChangeEar, addChangeEar, updateChangeEar, getSheepByEarNumber, checkTagExists,searchEarNumbers } from "@/api/produce/manage_sheep/changeEar"
|
||||
import { listChangeEar, getChangeEar, delChangeEar, addChangeEar, updateChangeEar, getSheepByEarNumber, checkTagExists, searchEarNumbers } from "@/api/produce/manage_sheep/changeEar"
|
||||
import { listSheepfold_management as listSheepfold } from '@/api/fileManagement/sheepfold_management'
|
||||
import dayjs from 'dayjs'
|
||||
import { nextTick } from 'vue'
|
||||
import { Plus, Delete, ArrowUp, ArrowDown } from '@element-plus/icons-vue'
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const changeEarList = ref([])
|
||||
@@ -161,7 +198,15 @@ const title = ref("")
|
||||
const daterangeCreateTime = ref([])
|
||||
const isAddMode = ref(true);
|
||||
const daterangeEventDate = ref([]);
|
||||
|
||||
const pasteText = ref('') // 批量粘贴输入框
|
||||
const isExpanded = ref(false) // 折叠状态
|
||||
const defaultShowCount = 2 // 默认展示条数
|
||||
/* 计算:控制实际展示的耳号列表 */
|
||||
const displayedEarTags = computed(() => {
|
||||
const list = queryParams.value.manageTagsList || []
|
||||
if (isExpanded.value || list.length <= defaultShowCount) return list
|
||||
return list.slice(0, defaultShowCount)
|
||||
})
|
||||
const data = reactive({
|
||||
form: {
|
||||
technician: null,
|
||||
@@ -171,12 +216,14 @@ const data = reactive({
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
manageTags: null,
|
||||
sheepfoldId: null,
|
||||
// sheepfoldId: null,
|
||||
technician: null,
|
||||
earType: null,
|
||||
newTag: null,
|
||||
oldTag: null,
|
||||
createTime: null,
|
||||
earType: null,
|
||||
inGroup: 0
|
||||
},
|
||||
rules: {
|
||||
earNumber: [
|
||||
@@ -188,9 +235,6 @@ const data = reactive({
|
||||
newTag: [
|
||||
{ required: true, message: "请输入新耳号", trigger: "blur" }
|
||||
],
|
||||
oldTag: [
|
||||
{ required: true, message: "请输入旧耳号", trigger: "change" }
|
||||
],
|
||||
technician: [
|
||||
{ required: true, message: "请输入技术员", trigger: "blur" }
|
||||
],
|
||||
@@ -213,9 +257,9 @@ async function getList() {
|
||||
if (queryParams.value.manageTags) {
|
||||
queryParams.value.params["manageTags"] = queryParams.value.manageTags;
|
||||
}
|
||||
if (queryParams.value.sheepfoldId) {
|
||||
queryParams.value.params["sheepfoldId"] = queryParams.value.sheepfoldId;
|
||||
}
|
||||
// if (queryParams.value.sheepfoldId) {
|
||||
// queryParams.value.params["sheepfoldId"] = queryParams.value.sheepfoldId;
|
||||
// }
|
||||
if (daterangeCreateTime.value && daterangeCreateTime.value.length > 0) {
|
||||
queryParams.value.params["beginCreateTime"] = daterangeCreateTime.value[0];
|
||||
queryParams.value.params["endCreateTime"] = daterangeCreateTime.value[1];
|
||||
@@ -224,6 +268,9 @@ async function getList() {
|
||||
queryParams.value.params["beginEventDate"] = daterangeEventDate.value[0];
|
||||
queryParams.value.params["endEventDate"] = daterangeEventDate.value[1];
|
||||
}
|
||||
if (queryParams.value.technician) { // ✅ 新增
|
||||
queryParams.value.params["technician"] = queryParams.value.technician
|
||||
}
|
||||
const response = await listChangeEar(queryParams.value);
|
||||
|
||||
changeEarList.value = response.rows.map(item => {
|
||||
@@ -267,13 +314,14 @@ function handleQuery() {
|
||||
function resetQuery() {
|
||||
daterangeCreateTime.value = []
|
||||
daterangeEventDate.value = []
|
||||
queryParams.value.sheepfoldName = null
|
||||
// queryParams.value.sheepfoldName = null
|
||||
queryParams.value.technician = null
|
||||
queryParams.value.manageTags = null
|
||||
queryParams.value.newTag = null
|
||||
queryParams.value.oldTag = null
|
||||
queryParams.value.earType = null
|
||||
queryParams.value.manageTagsList = []
|
||||
|
||||
queryParams.value.inGroup = 0
|
||||
proxy.resetForm("queryRef")
|
||||
|
||||
handleQuery()
|
||||
@@ -289,9 +337,10 @@ function handleSelectionChange(selection) {
|
||||
// 新增按钮操作
|
||||
function handleAdd() {
|
||||
reset()
|
||||
isAddMode.value = true;
|
||||
isAddMode.value = true
|
||||
open.value = true
|
||||
title.value = "添加耳号记录"
|
||||
title.value = '添加耳号记录'
|
||||
form.value.eventDate = dayjs().format('YYYY-MM-DD')
|
||||
}
|
||||
|
||||
// 修改按钮操作
|
||||
@@ -430,9 +479,51 @@ function searchEarNumber(query) {
|
||||
earOptions.value = res.data || []
|
||||
}).finally(() => earLoading.value = false)
|
||||
}
|
||||
/* 粘贴事件 */
|
||||
function handlePaste() {
|
||||
nextTick(() => handlePasteSubmit())
|
||||
}
|
||||
|
||||
/* 批量提交 */
|
||||
function handlePasteSubmit() {
|
||||
if (!pasteText.value || !pasteText.value.trim()) return
|
||||
const separators = /[\p{White_Space},,\n\r\t]+/u
|
||||
const raw = pasteText.value.trim().split(separators).filter(v => v)
|
||||
const exist = new Set(queryParams.value.manageTagsList || [])
|
||||
const adds = []
|
||||
const dups = []
|
||||
raw.forEach(v => {
|
||||
if (!exist.has(v)) { adds.push(v); exist.add(v) }
|
||||
else dups.push(v)
|
||||
})
|
||||
if (adds.length) {
|
||||
queryParams.value.manageTagsList = [...(queryParams.value.manageTagsList || []), ...adds]
|
||||
proxy.$modal.msgSuccess(`成功添加 ${adds.length} 个耳号,当前共 ${queryParams.value.manageTagsList.length} 个` +
|
||||
(dups.length > 0 ? `,已忽略 ${dups.length} 个重复耳号` : ''))
|
||||
} else if (dups.length > 0) {
|
||||
proxy.$modal.msgWarning('所有耳号均已存在')
|
||||
}
|
||||
pasteText.value = ''
|
||||
}
|
||||
|
||||
/* 切换展开/收起 */
|
||||
function toggleExpand() {
|
||||
isExpanded.value = !isExpanded.value
|
||||
}
|
||||
|
||||
/* 选择器变化时去重 */
|
||||
function handleEarChange(val) {
|
||||
queryParams.value.manageTagsList = [...new Set(val)]
|
||||
}
|
||||
|
||||
/* 一键清空 */
|
||||
function clearEarNumbers() {
|
||||
queryParams.value.manageTagsList = []
|
||||
pasteText.value = ''
|
||||
isExpanded.value = false
|
||||
}
|
||||
|
||||
/* 删除单个耳号 */
|
||||
function removeEarNumber(tag) {
|
||||
const idx = queryParams.value.manageTagsList.indexOf(tag)
|
||||
if (idx > -1) queryParams.value.manageTagsList.splice(idx, 1)
|
||||
@@ -444,7 +535,7 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.selected-ear-numbers{
|
||||
.selected-ear-numbers {
|
||||
margin-bottom: 16px;
|
||||
padding: 10px;
|
||||
background: #f5f7fa;
|
||||
|
||||
@@ -6,15 +6,50 @@
|
||||
end-placeholder="结束日期" value-format="YYYY-MM-DD" />
|
||||
</el-form-item>
|
||||
<el-form-item label="管理耳号" prop="manageTagsList">
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="请输入耳号,支持多选" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option style="width: 260px">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
<el-button type="text" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" style="margin-left: 8px">
|
||||
清空
|
||||
</el-button>
|
||||
<div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap;">
|
||||
<!-- 主选择器:不展示已选标签 -->
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="输入耳号搜索" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option collapse-tags :max-collapse-tags="0" style="width:300px" @change="handleEarChange">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
|
||||
<!-- 批量粘贴框 -->
|
||||
<el-input v-model="pasteText" placeholder="或粘贴多个耳号(空格/换行/逗号分隔)" style="width:300px" @paste="handlePaste"
|
||||
@keyup.enter="handlePasteSubmit" clearable>
|
||||
<template #append>
|
||||
<el-button @click="handlePasteSubmit" :icon="Plus">添加</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
|
||||
<!-- 计数标签 -->
|
||||
<el-tag v-if="queryParams.manageTagsList && queryParams.manageTagsList.length" type="info" effect="plain"
|
||||
size="large">
|
||||
已选: {{ queryParams.manageTagsList.length }} 个
|
||||
</el-tag>
|
||||
|
||||
<!-- 一键清空 -->
|
||||
<el-button type="danger" plain :icon="Delete" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList && queryParams.manageTagsList.length">
|
||||
清空全部
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 已选耳号展示区(可折叠) -->
|
||||
<div v-if="queryParams.manageTagsList && queryParams.manageTagsList.length" class="selected-ear-numbers">
|
||||
<el-tag v-for="tag in displayedEarTags" :key="tag" closable @close="removeEarNumber(tag)" style="margin:4px"
|
||||
type="success">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
|
||||
<el-button v-if="queryParams.manageTagsList.length > defaultShowCount" type="primary" link
|
||||
@click="toggleExpand">
|
||||
{{ isExpanded ? '收起' : `展开剩余 ${queryParams.manageTagsList.length - defaultShowCount} 个` }}
|
||||
<el-icon class="el-icon--right">
|
||||
<component :is="isExpanded ? ArrowUp : ArrowDown" />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="原品种" prop="varietyOld">
|
||||
<el-select v-model="queryParams.varietyOld" placeholder="请选择原品种" clearable filterable>
|
||||
@@ -26,23 +61,27 @@
|
||||
<el-option v-for="item in varietyOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="羊舍" prop="sheepfoldId">
|
||||
<!-- <el-form-item label="羊舍" prop="sheepfoldId">
|
||||
<el-select v-model="queryParams.sheepfoldId" placeholder="请选择羊舍" style="min-width:150px" clearable>
|
||||
<el-option v-for="fold in sheepfoldOptions" :key="fold.id" :label="fold.sheepfoldName" :value="fold.id" />
|
||||
</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-form-item>
|
||||
<el-form-item label="是否在群" prop="isDelete">
|
||||
<el-select v-model="queryParams.isDelete" placeholder="全部" clearable style="min-width:120px">
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="在群" :value="0" />
|
||||
<el-option label="离群" :value="1" />
|
||||
</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-button icon="Refresh" @click="resetQuery">重置</el-button> -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" class="selected-ear-numbers">
|
||||
<span style="margin-right: 10px; color: #606266;">已选耳号:</span>
|
||||
<el-tag v-for="tag in queryParams.manageTagsList" :key="tag" closable @close="removeEarNumber(tag)"
|
||||
style="margin-right: 8px;">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd"
|
||||
@@ -66,23 +105,24 @@
|
||||
<el-table v-loading="loading" :data="changeVarietyList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="管理耳号" align="center" prop="manageTags" />
|
||||
<el-table-column label="羊舍" align="center" prop="sheepfoldName" />
|
||||
<el-table-column label="品种" align="center" prop="varietyOld" />
|
||||
<el-table-column label="事件类型" align="center" prop="eventType" width="120" />
|
||||
<el-table-column label="原品种" align="center" prop="varietyOld" />
|
||||
<el-table-column label="新品种" align="center" prop="varietyNew" />
|
||||
<el-table-column label="事件日期" align="center" prop="eventDate">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.eventDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="新品种" align="center" prop="varietyNew" />
|
||||
<el-table-column label="旧品种" align="center" prop="varietyOld" />
|
||||
<el-table-column label="羊舍" align="center" prop="sheepfoldName" />
|
||||
<el-table-column label="技术员" align="center" prop="technician" />
|
||||
<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} {h}:{i}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="comment" />
|
||||
<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)"
|
||||
@@ -100,8 +140,21 @@
|
||||
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||
<el-form ref="changeVarietyRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="管理耳号" prop="manageTags">
|
||||
<el-input v-model="form.manageTags" placeholder="请输入管理耳号" @blur="onManageTagsBlur" :disabled="!isAdd" />
|
||||
<el-input v-model="form.manageTags" placeholder="请输入管理耳号,支持批量输入(空格/换行/逗号分隔)" @blur="onManageTagsBlur"
|
||||
:disabled="!isAdd" />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 新增弹窗已选耳号展示区(和改备注、转群完全一致) -->
|
||||
<div v-if="batchTags.length" class="selected-ear-numbers" style="margin-left: 80px; margin-bottom: 18px;">
|
||||
<el-tag v-for="(tag, idx) in batchTags" :key="tag" closable @close="removeBatchTag(idx)" style="margin:4px"
|
||||
type="success">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
|
||||
<el-button type="primary" link @click="clearBatchTags">
|
||||
一键清空 ({{ batchTags.length }})
|
||||
</el-button>
|
||||
</div>
|
||||
<el-form-item label="原品种" prop="varietyOld">
|
||||
<el-input v-model="form.varietyOld" placeholder="请输入原品种" disabled />
|
||||
</el-form-item>
|
||||
@@ -132,10 +185,12 @@
|
||||
</template>
|
||||
|
||||
<script setup name="ChangeVariety">
|
||||
import { listChangeVariety, getChangeVariety, delChangeVariety, addChangeVariety, updateChangeVariety, getSheepByManageTags,searchEarNumbers } from "@/api/produce/manage_sheep/changeVariety"
|
||||
import { listChangeVariety, getChangeVariety, delChangeVariety, addChangeVariety, updateChangeVariety, getSheepByManageTags, searchEarNumbers } from "@/api/produce/manage_sheep/changeVariety"
|
||||
import { listSheepfold_management as listSheepfold } from '@/api/fileManagement/sheepfold_management'
|
||||
import { listVariety } from '@/api/fileManagement/variety'
|
||||
|
||||
import dayjs from 'dayjs'
|
||||
import { nextTick } from 'vue'
|
||||
import { Plus, Delete, ArrowUp, ArrowDown } from '@element-plus/icons-vue'
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const changeVarietyList = ref([])
|
||||
@@ -152,6 +207,19 @@ const isAdd = ref(false);
|
||||
|
||||
const varietyOptions = ref([])
|
||||
const daterangeEventDate = ref([]);
|
||||
|
||||
const pasteText = ref('') // 批量粘贴输入框
|
||||
const isExpanded = ref(false) // 折叠状态
|
||||
const defaultShowCount = 2 // 默认展示条数
|
||||
const batchTags = ref([]) // 本次要新增的多条耳号
|
||||
const batchSheep = ref([]) // 对应的羊只对象
|
||||
/* 计算:控制实际展示的耳号列表 */
|
||||
const displayedEarTags = computed(() => {
|
||||
const list = queryParams.value.manageTagsList || []
|
||||
if (isExpanded.value || list.length <= defaultShowCount) return list
|
||||
return list.slice(0, defaultShowCount)
|
||||
})
|
||||
|
||||
const data = reactive({
|
||||
form: {
|
||||
manageTags: null,
|
||||
@@ -166,6 +234,7 @@ const data = reactive({
|
||||
varietyOld: null,
|
||||
varietyNew: null,
|
||||
createTime: null,
|
||||
isDelete: null,
|
||||
},
|
||||
rules: {
|
||||
manageTags: [
|
||||
@@ -211,28 +280,6 @@ function getList() {
|
||||
})
|
||||
}
|
||||
|
||||
function onManageTagsBlur() {
|
||||
const tag = form.value.manageTags?.trim();
|
||||
if (!tag) return;
|
||||
|
||||
getSheepByManageTags(tag).then(res => {
|
||||
const sheep = res.data;
|
||||
if (sheep) {
|
||||
form.value.varietyOld = sheep.varietyName || "";
|
||||
form.value.sheepId = sheep.id;
|
||||
form.value.comment = sheep.comment || "";
|
||||
} else {
|
||||
proxy.$modal.msgWarning("未找到该管理耳号对应的羊只");
|
||||
form.value.varietyOld = "";
|
||||
form.value.sheepId = null;
|
||||
form.value.comment = "";
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error("查询羊只失败:", err);
|
||||
proxy.$modal.msgError("查询失败,请重试");
|
||||
});
|
||||
}
|
||||
|
||||
function loadVarietyOptions() {
|
||||
listVariety().then(res => {
|
||||
varietyOptions.value = res.rows.map(item => ({
|
||||
@@ -257,8 +304,11 @@ function reset() {
|
||||
varietyNew: null,
|
||||
comment: null,
|
||||
createBy: null,
|
||||
createTime: null
|
||||
createTime: null,
|
||||
manageTags: ''
|
||||
}
|
||||
batchTags.value = [] // 清空
|
||||
batchSheep.value = [] // 清空
|
||||
proxy.resetForm("changeVarietyRef")
|
||||
}
|
||||
|
||||
@@ -281,6 +331,7 @@ function resetQuery() {
|
||||
daterangeCreateTime.value = []
|
||||
queryParams.value.sheepfoldId = null
|
||||
daterangeEventDate.value = []
|
||||
queryParams.value.isDelete = null
|
||||
queryParams.value.manageTagsList = []
|
||||
proxy.resetForm("queryRef")
|
||||
handleQuery()
|
||||
@@ -300,6 +351,7 @@ function handleAdd() {
|
||||
loadVarietyOptions()
|
||||
open.value = true
|
||||
title.value = "添加改品种记录"
|
||||
form.value.eventDate = dayjs().format('YYYY-MM-DD')
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
@@ -317,30 +369,35 @@ function handleUpdate(row) {
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["changeVarietyRef"].validate(valid => {
|
||||
if (valid) {
|
||||
if (!form.value.id) {
|
||||
if (!form.value.sheepId) {
|
||||
proxy.$modal.msgError('未找到对应的羊只,请检查耳号');
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (batchTags.value.length === 0) {
|
||||
proxy.$modal.msgError('请输入至少一个有效耳号')
|
||||
return
|
||||
}
|
||||
|
||||
if (form.value.id != null) {
|
||||
updateChangeVariety(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("修改成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
} else {
|
||||
addChangeVariety(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("新增成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
}
|
||||
// 批量构建提交数据
|
||||
const requests = batchTags.value.map((tag, idx) => {
|
||||
const sheep = batchSheep.value[idx]
|
||||
const submitData = {
|
||||
sheepId: sheep.id,
|
||||
manageTags: tag,
|
||||
varietyOld: sheep.varietyName || "",
|
||||
varietyNew: form.value.varietyNew,
|
||||
eventDate: form.value.eventDate,
|
||||
technician: form.value.technician,
|
||||
comment: sheep.comment || ""
|
||||
}
|
||||
return addChangeVariety(submitData)
|
||||
})
|
||||
|
||||
Promise.all(requests)
|
||||
.then(() => {
|
||||
proxy.$modal.msgSuccess(`成功新增 ${batchTags.value.length} 条改品种记录`)
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
.catch(() => {
|
||||
proxy.$modal.msgError('新增失败')
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
@@ -376,13 +433,121 @@ function searchEarNumber(query) {
|
||||
earOptions.value = res.data || []
|
||||
}).finally(() => earLoading.value = false)
|
||||
}
|
||||
/* 粘贴事件 */
|
||||
function handlePaste() {
|
||||
nextTick(() => handlePasteSubmit())
|
||||
}
|
||||
|
||||
/* 批量提交 */
|
||||
function handlePasteSubmit() {
|
||||
if (!pasteText.value || !pasteText.value.trim()) return
|
||||
const separators = /[\p{White_Space},,\n\r\t]+/u
|
||||
const raw = pasteText.value.trim().split(separators).filter(v => v)
|
||||
const exist = new Set(queryParams.value.manageTagsList || [])
|
||||
const adds = []
|
||||
const dups = []
|
||||
raw.forEach(v => {
|
||||
if (!exist.has(v)) { adds.push(v); exist.add(v) }
|
||||
else dups.push(v)
|
||||
})
|
||||
if (adds.length) {
|
||||
queryParams.value.manageTagsList = [...(queryParams.value.manageTagsList || []), ...adds]
|
||||
proxy.$modal.msgSuccess(`成功添加 ${adds.length} 个耳号,当前共 ${queryParams.value.manageTagsList.length} 个` +
|
||||
(dups.length > 0 ? `,已忽略 ${dups.length} 个重复耳号` : ''))
|
||||
} else if (dups.length > 0) {
|
||||
proxy.$modal.msgWarning('所有耳号均已存在')
|
||||
}
|
||||
pasteText.value = ''
|
||||
}
|
||||
|
||||
/* 切换展开/收起 */
|
||||
function toggleExpand() {
|
||||
isExpanded.value = !isExpanded.value
|
||||
}
|
||||
|
||||
/* 选择器变化时去重 */
|
||||
function handleEarChange(val) {
|
||||
queryParams.value.manageTagsList = [...new Set(val)]
|
||||
}
|
||||
|
||||
/* 一键清空 */
|
||||
function clearEarNumbers() {
|
||||
queryParams.value.manageTagsList = []
|
||||
pasteText.value = ''
|
||||
isExpanded.value = false
|
||||
}
|
||||
|
||||
/* 删除单个耳号 */
|
||||
function removeEarNumber(tag) {
|
||||
const idx = queryParams.value.manageTagsList.indexOf(tag)
|
||||
if (idx > -1) queryParams.value.manageTagsList.splice(idx, 1)
|
||||
}
|
||||
|
||||
// 校验和回显(支持单条和批量,和改备注、转群完全一致)
|
||||
async function onManageTagsBlur() {
|
||||
const raw = form.value.manageTags?.trim()
|
||||
if (!raw) return
|
||||
|
||||
// 1. 先按分隔符拆
|
||||
const separators = /[\p{White_Space},,]+/u
|
||||
const tags = [...new Set(raw.split(separators).filter(v => v))]
|
||||
|
||||
// 2. 批量校验(包括单条的情况)
|
||||
batchTags.value = []
|
||||
batchSheep.value = []
|
||||
|
||||
for (const tag of tags) {
|
||||
try {
|
||||
const { data: sheep } = await getSheepByManageTags(tag.trim())
|
||||
if (sheep) {
|
||||
batchTags.value.push(tag)
|
||||
batchSheep.value.push(sheep)
|
||||
} else {
|
||||
proxy.$modal.msgWarning(`耳号 ${tag} 未找到对应羊只,已跳过`)
|
||||
}
|
||||
} catch (err) {
|
||||
proxy.$modal.msgWarning(`耳号 ${tag} 查询失败`)
|
||||
}
|
||||
}
|
||||
|
||||
if (!batchTags.value.length) { // 全部无效
|
||||
form.value.varietyOld = ""
|
||||
form.value.sheepId = null
|
||||
form.value.comment = ""
|
||||
return
|
||||
}
|
||||
|
||||
// 把合法耳号重新拼回输入框,用半角空格分隔
|
||||
form.value.manageTags = batchTags.value.join(' ')
|
||||
|
||||
// 原品种、sheepId、comment 取第一条的
|
||||
const firstSheep = batchSheep.value[0]
|
||||
form.value.varietyOld = firstSheep.varietyName || ""
|
||||
form.value.sheepId = firstSheep.id
|
||||
form.value.comment = firstSheep.comment || ""
|
||||
}
|
||||
|
||||
// 删除单个批量耳号
|
||||
function removeBatchTag(idx) {
|
||||
batchTags.value.splice(idx, 1)
|
||||
batchSheep.value.splice(idx, 1)
|
||||
// 实时回写输入框
|
||||
form.value.manageTags = batchTags.value.join(' ')
|
||||
// 更新原品种显示
|
||||
if (batchSheep.value.length > 0) {
|
||||
form.value.varietyOld = batchSheep.value[0].varietyName || ""
|
||||
} else {
|
||||
form.value.varietyOld = ""
|
||||
}
|
||||
}
|
||||
|
||||
// 一键清空批量耳号
|
||||
function clearBatchTags() {
|
||||
batchTags.value = []
|
||||
batchSheep.value = []
|
||||
form.value.manageTags = ''
|
||||
form.value.varietyOld = ''
|
||||
}
|
||||
onMounted(() => {
|
||||
loadVarietyOptions();
|
||||
getSheepfoldOptions();
|
||||
@@ -391,9 +556,14 @@ onMounted(() => {
|
||||
</script>
|
||||
<style scoped>
|
||||
.selected-ear-numbers {
|
||||
margin-bottom: 16px;
|
||||
padding: 10px;
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
border: 1px dashed #dcdfe6;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
@@ -6,25 +6,50 @@
|
||||
start-placeholder="开始日期" end-placeholder="结束日期" />
|
||||
</el-form-item>
|
||||
<el-form-item label="管理耳号" prop="manageTagsList">
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="请输入耳号,支持多选" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option style="width: 260px">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
<el-button type="text" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" style="margin-left: 8px">
|
||||
清空
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item label="转出羊舍" prop="foldFrom" style="width: 308px">
|
||||
<el-select v-model="queryParams.foldFrom" placeholder="请选择转出羊舍" style="min-width:150px" clearable>
|
||||
<el-option v-for="item in sheepfoldOptions" :key="item.id" :label="item.sheepfoldName" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="转入羊舍" prop="foldTo" style="width: 308px">
|
||||
<el-select v-model="queryParams.foldTo" placeholder="请选择转入羊舍" style="min-width:150px" clearable>
|
||||
<el-option v-for="item in sheepfoldOptions" :key="item.id" :label="item.sheepfoldName" :value="item.id" />
|
||||
</el-select>
|
||||
<div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap;">
|
||||
<!-- 主选择器:不展示已选标签 -->
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="输入耳号搜索" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option collapse-tags :max-collapse-tags="0" style="width:300px" @change="handleEarChange">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
|
||||
<!-- 批量粘贴框 -->
|
||||
<el-input v-model="pasteText" placeholder="或粘贴多个耳号(空格/换行/逗号分隔)" style="width:300px" @paste="handlePaste"
|
||||
@keyup.enter="handlePasteSubmit" clearable>
|
||||
<template #append>
|
||||
<el-button @click="handlePasteSubmit" :icon="Plus">添加</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
|
||||
<!-- 计数标签 -->
|
||||
<el-tag v-if="queryParams.manageTagsList && queryParams.manageTagsList.length" type="info" effect="plain"
|
||||
size="large">
|
||||
已选: {{ queryParams.manageTagsList.length }} 个
|
||||
</el-tag>
|
||||
|
||||
<!-- 一键清空 -->
|
||||
<el-button type="danger" plain :icon="Delete" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList && queryParams.manageTagsList.length">
|
||||
清空全部
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 已选耳号展示区(可折叠) -->
|
||||
<div v-if="queryParams.manageTagsList && queryParams.manageTagsList.length" class="selected-ear-numbers">
|
||||
<el-tag v-for="tag in displayedEarTags" :key="tag" closable @close="removeEarNumber(tag)" style="margin:4px"
|
||||
type="success">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
|
||||
<el-button v-if="queryParams.manageTagsList.length > defaultShowCount" type="primary" link
|
||||
@click="toggleExpand">
|
||||
{{ isExpanded ? '收起' : `展开剩余 ${queryParams.manageTagsList.length - defaultShowCount} 个` }}
|
||||
<el-icon class="el-icon--right">
|
||||
<component :is="isExpanded ? ArrowUp : ArrowDown" />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="品种" prop="varietyId">
|
||||
<el-select v-model="queryParams.varietyId" placeholder="请选择品种" style="min-width:150px" clearable>
|
||||
@@ -36,18 +61,37 @@
|
||||
<el-option v-for="type in sheepTypeOptions" :key="type.id" :label="type.name" :value="type.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="事件类型">
|
||||
<el-select v-model="queryParams.eventType" filterable allow-create clearable placeholder="请选择或输入">
|
||||
<el-option v-for="d in eventTypeOptions" :key="d.value" :label="d.label" :value="d.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="转出羊舍" prop="foldFrom" style="width: 308px">
|
||||
<el-select v-model="queryParams.foldFrom" placeholder="请选择转出羊舍" style="min-width:150px" clearable>
|
||||
<el-option v-for="item in sheepfoldOptions" :key="item.id" :label="item.sheepfoldName" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="转入羊舍" prop="foldTo" style="width: 308px">
|
||||
<el-select v-model="queryParams.foldTo" placeholder="请选择转入羊舍" style="min-width:150px" clearable>
|
||||
<el-option v-for="item in sheepfoldOptions" :key="item.id" :label="item.sheepfoldName" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="技术员">
|
||||
<el-select v-model="queryParams.technician" filterable allow-create clearable placeholder="请输入或选择技术员">
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否在群" prop="isDelete">
|
||||
<el-select v-model="queryParams.isDelete" placeholder="全部" clearable style="min-width:120px">
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="在群" :value="0" />
|
||||
<el-option label="离群" :value="1" />
|
||||
</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-button icon="Refresh" @click="resetQuery">重置</el-button> -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" class="selected-ear-numbers">
|
||||
<span style="margin-right: 10px; color: #606266;">已选耳号:</span>
|
||||
<el-tag v-for="tag in queryParams.manageTagsList" :key="tag" closable @close="removeEarNumber(tag)"
|
||||
style="margin-right: 8px;">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd"
|
||||
@@ -67,21 +111,21 @@
|
||||
<el-table v-loading="loading" :data="trans_groupList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="管理耳号" align="center" prop="manageTags" min-width="100" fixed />
|
||||
<el-table-column label="事件类型" align="center" prop="eventTypeText" />
|
||||
<el-table-column label="转出羊舍" align="center" prop="foldFromName" min-width="130" />
|
||||
<el-table-column label="转入羊舍" align="center" prop="foldToName" min-width="130" />
|
||||
<el-table-column label="转群日期" align="center" prop="transDate" min-width="120" />
|
||||
<el-table-column label="品种" align="center" prop="varietyName" />
|
||||
<el-table-column label="羊只类别" align="center" prop="sheepTypeName" />
|
||||
<el-table-column label="事件类型" align="center" prop="eventTypeText" />
|
||||
<el-table-column label="转群日期" align="center" prop="transDate" min-width="120" />
|
||||
<el-table-column label="转入羊舍" align="center" prop="foldToName" min-width="130" />
|
||||
<el-table-column label="转出羊舍" align="center" prop="foldFromName" min-width="130" />
|
||||
<!-- <el-table-column label="羊只类别" align="center" prop="sheepTypeName" /> -->
|
||||
<el-table-column label="转群原因" align="center" prop="reasonText" min-width="120" />
|
||||
<el-table-column label="技术员" align="center" prop="technician" />
|
||||
<el-table-column label="备注" align="center" prop="comment" min-width="120" />
|
||||
<el-table-column label="创建人" align="center" prop="createBy" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" min-width="120">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="comment" min-width="120" />
|
||||
<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)"
|
||||
@@ -96,22 +140,26 @@
|
||||
v-model:limit="queryParams.pageSize" @pagination="getList" :page-sizes="[20, 50, 100, 200, 500, 1000, 2000]" />
|
||||
|
||||
<!-- 添加或修改转群记录对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||
<el-dialog :title="title" v-model="open" width="700px" append-to-body>
|
||||
<el-form ref="trans_groupRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="管理耳号" prop="manageTags">
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<el-select v-model="form.manageTags" placeholder="请输入或选择耳号" multiple filterable allow-create
|
||||
style="width: 100%; flex:1;" @change="loadSheepInfo" :disabled="!isAdd">
|
||||
<el-option v-for="sheep in sheepOptions" :key="sheep.id" :label="sheep.manageTags"
|
||||
:value="sheep.manageTags" />
|
||||
</el-select>
|
||||
<span v-if="form.manageTags?.length > 0" class="tag-count">
|
||||
已选 {{ form.manageTags.length }} 个
|
||||
</span>
|
||||
</div>
|
||||
<el-input v-model="form.manageTags" placeholder="请输入管理耳号" @blur="onManageTagsBlur" :disabled="!isAdd" />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 新增弹窗已选耳号展示区(和改备注完全一致) -->
|
||||
<div v-if="batchTags.length" class="selected-ear-numbers" style="margin-left: 80px; margin-bottom: 18px;">
|
||||
<el-tag v-for="(tag, idx) in batchTags" :key="tag" closable @close="removeBatchTag(idx)" style="margin:4px"
|
||||
type="success">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
|
||||
<el-button type="primary" link @click="clearBatchTags">
|
||||
一键清空 ({{ batchTags.length }})
|
||||
</el-button>
|
||||
</div>
|
||||
<el-form-item label="事件类型" prop="eventType">
|
||||
<el-select v-model="form.eventType" placeholder="请选择事件类型" clearable required>
|
||||
<el-select v-model="form.eventType" filterable allow-create default-first-option placeholder="请选择或输入事件类型"
|
||||
clearable required>
|
||||
<el-option v-for="dict in eventTypeOptions" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -136,14 +184,15 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="isAdd" label="羊只类型" prop="sheepTypeId">
|
||||
<el-select v-model="form.sheepTypeId" placeholder="请选择羊只类型" clearable @change="handleSheepFilter">
|
||||
<el-select v-model="form.sheepTypeId" placeholder="请选择羊只类型" :disabled="!form.ranchId" clearable
|
||||
@change="handleSheepFilter">
|
||||
<el-option v-for="type in sheepTypeOptions" :key="type.id" :label="type.name" :value="type.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="转群原因" prop="reason">
|
||||
<el-select v-model="form.reason" placeholder="请选择转群原因" clearable>
|
||||
<el-option v-for="dict in trans_group_reason" :key="dict.value" :label="dict.label"
|
||||
:value="Number(dict.value)" />
|
||||
<el-select v-model="form.reason" filterable allow-create default-first-option placeholder="请选择或输入转群原因"
|
||||
clearable>
|
||||
<el-option v-for="dict in trans_group_reason" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="转群日期" prop="transDate">
|
||||
@@ -172,9 +221,12 @@ import { listSheepfold_management as listSheepfold } from '@/api/fileManagement/
|
||||
import { checkSheepByManageTags, getSheepBySheepfoldId } from '@/api/produce/other/fixHoof'
|
||||
import { getSheepTypeList } from "@/api/produce/bodyManage/body_measure"
|
||||
import request from '@/utils/request'
|
||||
import dayjs from 'dayjs'
|
||||
import { nextTick } from 'vue'
|
||||
import { Plus, Delete, ArrowUp, ArrowDown } from '@element-plus/icons-vue'
|
||||
|
||||
const { proxy } = getCurrentInstance();
|
||||
const { trans_group_reason, status, trans_group_event_type } = proxy.useDict('trans_group_reason', 'status', 'trans_group_event_type');
|
||||
const { trans_group_reason, trans_group_event_type } = proxy.useDict('trans_group_reason', 'status', 'trans_group_event_type');
|
||||
|
||||
const trans_groupList = ref([]);
|
||||
const open = ref(false);
|
||||
@@ -196,12 +248,26 @@ const isAdd = ref(false);
|
||||
const ranchOptions = ref([]);
|
||||
const currentRanchSheepfolds = ref([]);
|
||||
|
||||
const pasteText = ref('') // 批量粘贴输入框
|
||||
const isExpanded = ref(false) // 折叠状态
|
||||
const defaultShowCount = 2 // 默认展示条数
|
||||
|
||||
/* 计算:控制实际展示的耳号列表 */
|
||||
const displayedEarTags = computed(() => {
|
||||
const list = queryParams.value.manageTagsList || []
|
||||
if (isExpanded.value || list.length <= defaultShowCount) return list
|
||||
return list.slice(0, defaultShowCount)
|
||||
})
|
||||
|
||||
const batchTags = ref([]) // 本次要新增的多条耳号
|
||||
const batchSheep = ref([]) // 对应的羊只对象
|
||||
const data = reactive({
|
||||
form: {
|
||||
manageTags: [],
|
||||
tagDetails: {},
|
||||
eventType: null,
|
||||
transDate: null,
|
||||
currentFoldAllEars: ref([]),
|
||||
},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
@@ -214,7 +280,9 @@ const data = reactive({
|
||||
varietyId: null,
|
||||
sheepTypeId: null,
|
||||
status: null,
|
||||
isDelete: null,
|
||||
},
|
||||
manageTagsRaw: '',
|
||||
rules: {
|
||||
manageTags: [{ required: true, message: '请输入耳号', trigger: 'blur' }],
|
||||
eventType: [{ required: true, message: '请选择事件类型', trigger: 'change' }],
|
||||
@@ -226,7 +294,7 @@ const data = reactive({
|
||||
technician: [{ required: true, message: '请输入技术员', trigger: 'blur' }],
|
||||
},
|
||||
});
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
const { queryParams, form, rules, manageTagsRaw } = toRefs(data)
|
||||
const earOptions = ref([])
|
||||
const earLoading = ref(false)
|
||||
/** 查询转群记录列表 */
|
||||
@@ -262,10 +330,13 @@ function reset() {
|
||||
comment: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
manageTags: [],
|
||||
manageTags: '',
|
||||
tagDetails: {},
|
||||
sheepTypeId: null,
|
||||
transDate: dayjs().format('YYYY-MM-DD')
|
||||
};
|
||||
batchTags.value = []
|
||||
batchSheep.value = []
|
||||
proxy.resetForm('trans_groupRef');
|
||||
}
|
||||
|
||||
@@ -295,8 +366,18 @@ async function handleSheepFilter() {
|
||||
}
|
||||
|
||||
if (isOnlySheepfold) {
|
||||
await loadSheepBySheepfoldOnly(foldFrom, ranchId);
|
||||
} else if (isOnlyTypeOrCombined) {
|
||||
const list = await loadSheepBySheepfoldOnly(foldFrom, ranchId);
|
||||
if (list.length === 0) {
|
||||
proxy.$message.info('当前转出羊舍暂无羊只');
|
||||
form.value.manageTags = [];
|
||||
return;
|
||||
}
|
||||
form.value.manageTags = [...list];
|
||||
await loadSheepInfo();
|
||||
return;
|
||||
}
|
||||
|
||||
if (isOnlyTypeOrCombined) {
|
||||
form.value.manageTags = [];
|
||||
let loadedSheep = [];
|
||||
|
||||
@@ -307,7 +388,8 @@ async function handleSheepFilter() {
|
||||
}
|
||||
|
||||
if (loadedSheep.length > 0) {
|
||||
form.value.manageTags = loadedSheep.map((sheep) => sheep.manageTags);
|
||||
const list = loadedSheep.map(s => s.manageTags);
|
||||
form.value.manageTags = [...list];
|
||||
await loadSheepInfo();
|
||||
} else {
|
||||
proxy.$message.info("未查询到符合条件的耳号");
|
||||
@@ -381,7 +463,8 @@ async function loadSheepBySheepfoldOnly(sheepfoldId, ranchId) {
|
||||
return [];
|
||||
}
|
||||
sheepOptions.value = newSheepList;
|
||||
return newSheepList;
|
||||
|
||||
return newSheepList.map(s => s.manageTags);
|
||||
} catch (error) {
|
||||
console.error('根据羊舍加载耳号失败:', error);
|
||||
const errorMsg = error.response?.data?.msg || '加载羊舍耳号失败,请重试';
|
||||
@@ -416,20 +499,26 @@ async function loadSheepBySheepfoldAndType(sheepfoldId, typeId) {
|
||||
}
|
||||
|
||||
//只通过羊只类型
|
||||
async function loadSheepByTypeOnly(typeId) {
|
||||
async function loadSheepByTypeOnly(typeId, ranchId) {
|
||||
try {
|
||||
const res = await request({
|
||||
url: '/sheep/sheep/listByTypeId',
|
||||
method: 'get',
|
||||
params: { typeId },
|
||||
params: { typeId, ranchId }
|
||||
});
|
||||
const sheepList = res.rows || [];
|
||||
const formattedSheep = sheepList.map((sheep) => ({
|
||||
id: sheep.id,
|
||||
manageTags: sheep.manageTags,
|
||||
sheepfoldId: sheep.sheepfoldId,
|
||||
const all = res.rows || [];
|
||||
// 只保留当前牧场
|
||||
const filtered = all.filter(s => s.ranchId === ranchId);
|
||||
if (filtered.length === 0) {
|
||||
proxy.$message.info('当前牧场下无此类型羊只');
|
||||
sheepOptions.value = [];
|
||||
return [];
|
||||
}
|
||||
const formattedSheep = filtered.map(s => ({
|
||||
id: s.id,
|
||||
manageTags: s.manageTags,
|
||||
sheepfoldId: s.sheepfoldId
|
||||
}));
|
||||
|
||||
sheepOptions.value = formattedSheep;
|
||||
return formattedSheep;
|
||||
} catch (error) {
|
||||
@@ -480,15 +569,6 @@ async function loadSheepInfo() {
|
||||
proxy.$message.warning('部分耳号不合法,已自动过滤');
|
||||
}
|
||||
form.value.tagDetails = tagDetails;
|
||||
|
||||
if (firstRanchId && isAdd.value) {
|
||||
form.value.ranchId = firstRanchId;
|
||||
handleRanchChange(firstRanchId);
|
||||
}
|
||||
|
||||
if (firstSheepfoldId && isAdd.value) {
|
||||
form.value.foldFrom = Number(firstSheepfoldId);
|
||||
}
|
||||
}
|
||||
|
||||
//取消按钮
|
||||
@@ -506,7 +586,11 @@ function handleQuery() {
|
||||
//重置搜索框
|
||||
function resetQuery() {
|
||||
daterangeTransDate.value = [];
|
||||
queryParams.value.manageTagsList = []
|
||||
queryParams.value.manageTagsList = [];
|
||||
queryParams.value.eventType = null;
|
||||
queryParams.value.technician = null;
|
||||
queryParams.value.isDelete = null;
|
||||
manageTagsRaw.value = '';
|
||||
proxy.resetForm('queryRef');
|
||||
handleQuery();
|
||||
}
|
||||
@@ -524,7 +608,7 @@ function handleAdd() {
|
||||
title.value = '添加转群记录';
|
||||
isAdd.value = true;
|
||||
sheepOptions.value = [];
|
||||
form.value.manageTags = [];
|
||||
form.value.manageTags = '';
|
||||
}
|
||||
|
||||
//修改
|
||||
@@ -577,46 +661,50 @@ async function handleUpdate(row) {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
//提交
|
||||
function submitForm() {
|
||||
proxy.$refs.trans_groupRef.validate((valid) => {
|
||||
if (!valid) return;
|
||||
|
||||
const allTags = form.value.manageTags;
|
||||
const tagDetails = form.value.tagDetails || {};
|
||||
if (!allTags || allTags.length === 0) {
|
||||
proxy.$modal.msgError('请选择或输入至少一个耳号');
|
||||
return;
|
||||
if (batchTags.value.length === 0) {
|
||||
proxy.$modal.msgError('请输入至少一个有效耳号')
|
||||
return
|
||||
}
|
||||
|
||||
const requests = allTags.map(async (tag) => {
|
||||
const formData = { ...form.value };
|
||||
const details = tagDetails[tag] || {};
|
||||
formData.manageTags = tag;
|
||||
formData.sheepId = details.sheepId;
|
||||
formData.foldFrom = details.sheepfoldId;
|
||||
formData.comment = details.comment || '';
|
||||
formData.varietyId = details.varietyId || formData.varietyId;
|
||||
// 批量新增
|
||||
Promise.all(
|
||||
batchTags.value.map((tag, idx) => {
|
||||
const sheep = batchSheep.value[idx]
|
||||
|
||||
if (formData.id) {
|
||||
return updateTrans_group(formData);
|
||||
} else {
|
||||
return addTrans_group(formData);
|
||||
}
|
||||
});
|
||||
// 检查转入转出是否相同
|
||||
if (sheep.sheepfoldId === form.value.foldTo) {
|
||||
throw new Error(`耳号 ${tag} 转入转出羊舍不能相同`)
|
||||
}
|
||||
|
||||
Promise.all(requests)
|
||||
.then(() => {
|
||||
proxy.$modal.msgSuccess('操作成功');
|
||||
open.value = false;
|
||||
getList();
|
||||
return addTrans_group({
|
||||
sheepId: sheep.id,
|
||||
manageTags: tag,
|
||||
eventType: form.value.eventType,
|
||||
ranchId: form.value.ranchId,
|
||||
foldFrom: sheep.sheepfoldId,
|
||||
foldTo: form.value.foldTo,
|
||||
sheepTypeId: sheep.sheepTypeId || form.value.sheepTypeId,
|
||||
varietyId: sheep.varietyId,
|
||||
reason: form.value.reason,
|
||||
transDate: form.value.transDate,
|
||||
technician: form.value.technician,
|
||||
comment: sheep.comment || ''
|
||||
})
|
||||
})
|
||||
.catch((error) => {
|
||||
proxy.$modal.msgError(`处理失败:${error.message}`);
|
||||
});
|
||||
});
|
||||
).then(() => {
|
||||
proxy.$modal.msgSuccess(`成功新增 ${batchTags.value.length} 条转群记录`)
|
||||
open.value = false
|
||||
getList()
|
||||
}).catch((error) => {
|
||||
proxy.$modal.msgError(error.message || '新增失败')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
//删除
|
||||
function handleDelete(row) {
|
||||
const _ids = row.id || ids.value;
|
||||
@@ -673,19 +761,110 @@ function loadSheepTypeList() {
|
||||
sheepTypeOptions.value = [];
|
||||
});
|
||||
}
|
||||
function searchEarNumber(query) {
|
||||
if (!query) { earOptions.value = []; return }
|
||||
earLoading.value = true
|
||||
searchEarNumbers(query.trim()).then(res => {
|
||||
earOptions.value = res.data || []
|
||||
}).finally(() => earLoading.value = false)
|
||||
/* 粘贴事件 */
|
||||
function handlePaste() {
|
||||
nextTick(() => handlePasteSubmit())
|
||||
}
|
||||
/* 批量提交:拆词 → 去重 → 回填 */
|
||||
function handlePasteSubmit() {
|
||||
if (!pasteText.value || !pasteText.value.trim()) return
|
||||
const separators = /[\p{White_Space},,\n\r\t]+/u
|
||||
const raw = pasteText.value.trim().split(separators).filter(v => v)
|
||||
const exist = new Set(queryParams.value.manageTagsList || [])
|
||||
const adds = []
|
||||
const dups = []
|
||||
raw.forEach(v => {
|
||||
if (!exist.has(v)) { adds.push(v); exist.add(v) }
|
||||
else dups.push(v)
|
||||
})
|
||||
if (adds.length) {
|
||||
queryParams.value.manageTagsList = [...(queryParams.value.manageTagsList || []), ...adds]
|
||||
proxy.$modal.msgSuccess(`成功添加 ${adds.length} 个耳号,当前共 ${queryParams.value.manageTagsList.length} 个` +
|
||||
(dups.length > 0 ? `,已忽略 ${dups.length} 个重复耳号` : ''))
|
||||
} else if (dups.length > 0) {
|
||||
proxy.$modal.msgWarning('所有耳号均已存在')
|
||||
}
|
||||
pasteText.value = ''
|
||||
}
|
||||
|
||||
/* 切换展开/收起 */
|
||||
function toggleExpand() {
|
||||
isExpanded.value = !isExpanded.value
|
||||
}
|
||||
|
||||
/* 选择器变化时去重 */
|
||||
function handleEarChange(val) {
|
||||
queryParams.value.manageTagsList = [...new Set(val)]
|
||||
}
|
||||
|
||||
/* 一键清空 */
|
||||
function clearEarNumbers() {
|
||||
queryParams.value.manageTagsList = []
|
||||
pasteText.value = ''
|
||||
isExpanded.value = false
|
||||
}
|
||||
function removeEarNumber(tag) {
|
||||
const idx = queryParams.value.manageTagsList.indexOf(tag)
|
||||
if (idx > -1) queryParams.value.manageTagsList.splice(idx, 1)
|
||||
|
||||
//校验和回显(和改备注完全一致)
|
||||
async function onManageTagsBlur() {
|
||||
const raw = form.value.manageTags?.trim()
|
||||
if (!raw) return
|
||||
|
||||
const separators = /[\p{White_Space},,]+/u
|
||||
const tags = [...new Set(raw.split(separators).filter(v => v))]
|
||||
|
||||
if (tags.length === 1) {
|
||||
try {
|
||||
const { data: sheep } = await checkSheepByManageTags(tags[0].trim())
|
||||
if (sheep) {
|
||||
batchTags.value = [tags[0]]
|
||||
batchSheep.value = [sheep]
|
||||
} else {
|
||||
proxy.$modal.msgWarning('未找到该耳号对应羊只')
|
||||
batchTags.value = []
|
||||
batchSheep.value = []
|
||||
}
|
||||
} catch {
|
||||
proxy.$modal.msgWarning('未找到该耳号对应羊只')
|
||||
batchTags.value = []
|
||||
batchSheep.value = []
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
batchTags.value = []
|
||||
batchSheep.value = []
|
||||
for (const tag of tags) {
|
||||
try {
|
||||
const { data: sheep } = await checkSheepByManageTags(tag.trim())
|
||||
if (sheep) {
|
||||
batchTags.value.push(tag)
|
||||
batchSheep.value.push(sheep)
|
||||
} else {
|
||||
proxy.$modal.msgWarning(`耳号 ${tag} 未找到对应羊只,已跳过`)
|
||||
}
|
||||
} catch {
|
||||
proxy.$modal.msgWarning(`耳号 ${tag} 未找到对应羊只,已跳过`)
|
||||
}
|
||||
}
|
||||
|
||||
if (!batchTags.value.length) return
|
||||
form.value.manageTags = batchTags.value.join(' ')
|
||||
}
|
||||
|
||||
// 删除单个批量耳号(和改备注一致)
|
||||
function removeBatchTag(idx) {
|
||||
batchTags.value.splice(idx, 1)
|
||||
batchSheep.value.splice(idx, 1)
|
||||
// 实时回写输入框,保持可视化
|
||||
form.value.manageTags = batchTags.value.join(' ')
|
||||
}
|
||||
|
||||
// 一键清空批量耳号(和改备注一致)
|
||||
function clearBatchTags() {
|
||||
batchTags.value = []
|
||||
batchSheep.value = []
|
||||
form.value.manageTags = ''
|
||||
form.value.oldComment = ''
|
||||
}
|
||||
onMounted(() => {
|
||||
loadSheepfold();
|
||||
@@ -704,10 +883,25 @@ onMounted(() => {
|
||||
border-radius: 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.selected-ear-numbers{
|
||||
margin-bottom: 16px;
|
||||
padding: 10px;
|
||||
|
||||
.selected-ear-numbers {
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
border: 1px dashed #dcdfe6;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.selected-ear-numbers::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.selected-ear-numbers::-webkit-scrollbar-thumb {
|
||||
background-color: #dcdfe6;
|
||||
border-radius: 3px;
|
||||
}
|
||||
</style>
|
||||
@@ -7,21 +7,61 @@
|
||||
start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="管理耳号" prop="manageTagsList">
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="请输入耳号,支持多选" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option style="width: 260px">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
<el-button type="text" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" style="margin-left: 8px">
|
||||
清空
|
||||
</el-button>
|
||||
<div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap;">
|
||||
<!-- 主选择器:使用 collapse-tags 显示 +n -->
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="输入耳号搜索" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option collapse-tags :max-collapse-tags="0" style="width:300px" @change="handleEarChange">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
|
||||
<!-- 批量粘贴框 -->
|
||||
<el-input v-model="pasteText" placeholder="或粘贴多个耳号(空格/换行/逗号分隔)" style="width:300px" @paste="handlePaste"
|
||||
@keyup.enter="handlePasteSubmit" clearable>
|
||||
<template #append>
|
||||
<el-button @click="handlePasteSubmit" :icon="Plus">添加</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
|
||||
<!-- 计数标签 -->
|
||||
<el-tag v-if="queryParams.manageTagsList && queryParams.manageTagsList.length" type="info" effect="plain"
|
||||
size="large">
|
||||
已选: {{ queryParams.manageTagsList.length }} 个
|
||||
</el-tag>
|
||||
|
||||
<!-- 一键清空 -->
|
||||
<el-button type="danger" plain :icon="Delete" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList && queryParams.manageTagsList.length">
|
||||
清空全部
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 已选耳号展示区(可折叠) -->
|
||||
<div v-if="queryParams.manageTagsList && queryParams.manageTagsList.length" class="selected-ear-numbers">
|
||||
<el-tag v-for="tag in displayedEarTags" :key="tag" closable @close="removeEarNumber(tag)" style="margin:4px"
|
||||
type="success">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
|
||||
<el-button v-if="queryParams.manageTagsList.length > defaultShowCount" type="primary" link
|
||||
@click="toggleExpand">
|
||||
{{ isExpanded ? '收起' : `展开剩余 ${queryParams.manageTagsList.length - defaultShowCount} 个` }}
|
||||
<el-icon class="el-icon--right">
|
||||
<component :is="isExpanded ? ArrowUp : ArrowDown" />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<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>
|
||||
<el-form-item label="羊只类型" prop="sheepTypeId">
|
||||
<el-select v-model="queryParams.sheepTypeId" placeholder="请选择羊只类型" clearable style="min-width:150px">
|
||||
<el-option v-for="type in sheepTypeList" :key="type.id" :label="type.name" :value="type.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="转场类型" prop="transType" style="width: 308px">
|
||||
<el-select v-model="queryParams.transType" placeholder="请选择转场类型" clearable style="min-width:150px">
|
||||
<el-option label="内部调拨" :value="0" />
|
||||
@@ -34,28 +74,40 @@
|
||||
<el-option v-for="ranch in ranchOptions" :key="ranch.id" :label="ranch.ranchName" :value="ranch.ranchName" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="当前牧场" prop="transFrom">
|
||||
<el-select v-model="queryParams.transFrom" placeholder="请选择当前牧场" clearable style="min-width:150px">
|
||||
<!-- <el-form-item label="转出牧场" prop="transFrom">
|
||||
<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>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="当前场区" prop="currentRanchId">
|
||||
<el-select v-model="queryParams.currentRanchId" placeholder="请选择当前场区" clearable style="min-width:150px">
|
||||
<el-option v-for="ranch in ranchOptions" :key="ranch.id" :label="ranch.ranchName" :value="ranch.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<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" />
|
||||
</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>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否在群" prop="isDelete">
|
||||
<el-select v-model="queryParams.isDelete" placeholder="全部" clearable style="min-width:120px">
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="在群" :value="0" />
|
||||
<el-option label="离群" :value="1" />
|
||||
</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-button icon="Refresh" @click="resetQuery">重置</el-button> -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" class="selected-ear-numbers">
|
||||
<span style="margin-right: 10px; color: #606266;">已选耳号:</span>
|
||||
<el-tag v-for="tag in queryParams.manageTagsList" :key="tag" closable @close="removeEarNumber(tag)"
|
||||
style="margin-right: 8px;">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<!-- 按钮行 -->
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
@@ -81,36 +133,37 @@
|
||||
<el-table v-loading="loading" :data="transition_infoList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="管理耳号" align="center" prop="manageTags" min-width="100" fixed />
|
||||
<el-table-column label="品种" align="center" prop="varietyName" />
|
||||
<el-table-column label="事件类型" align="center" prop="eventType" min-width="120" />
|
||||
<el-table-column label="转场类型" align="center" prop="transTypeText" />
|
||||
<el-table-column label="转场日期" align="center" prop="transitionDate" min-width="150">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.transitionDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="品种" align="center" prop="varietyName" />
|
||||
<el-table-column label="转场类型" align="center" prop="transTypeText" />
|
||||
<el-table-column label="转入牧场" align="center" prop="transTo" min-width="120" />
|
||||
<el-table-column label="当前牧场" align="center" prop="transFrom" />
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="status" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="转出牧场" align="center" prop="transFrom" />
|
||||
<el-table-column label="羊舍" align="center" prop="sheepfoldName" min-width="120" />
|
||||
<el-table-column label="技术员" align="center" prop="technician" />
|
||||
<el-table-column label="当前状态" align="center" prop="status" min-width="120">
|
||||
<template #default="scope">
|
||||
<span v-if="scope.row.status === 0">待审批</span>
|
||||
<span v-else-if="scope.row.status === 1 || scope.row.status === 2">审批完成</span>
|
||||
<span v-else>未知状态</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="comment" />
|
||||
<el-table-column label="创建人" align="center" prop="createBy" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" min-width="130">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="comment" />
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="status" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="当前状态" align="center" prop="status" min-width="120">
|
||||
<template #default="scope">
|
||||
<span v-if="scope.row.status === 0">待审批</span>
|
||||
<span v-else-if="scope.row.status === 1 || scope.row.status === 2">审批完成</span>
|
||||
<span v-else>未知状态</span>
|
||||
</template>
|
||||
</el-table-column> -->
|
||||
<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)"
|
||||
@@ -125,21 +178,25 @@
|
||||
v-model:limit="queryParams.pageSize" @pagination="getList" :page-sizes="[20, 50, 100, 200, 500, 1000, 2000]" />
|
||||
|
||||
<!-- 新增/修改 -->
|
||||
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||
<el-dialog :title="title" v-model="open" width="700px" append-to-body>
|
||||
<el-form ref="transition_infoRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="管理耳号" prop="manageTags">
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<el-select v-model="form.manageTags" placeholder="请输入或选择耳号" filterable multiple allow-create
|
||||
@change="loadSheepInfo" :disabled="!isAdd" style="flex:1;">
|
||||
<el-option v-for="sheep in sheepOptions" :key="sheep.id" :label="sheep.manageTags"
|
||||
:value="sheep.manageTags" />
|
||||
</el-select>
|
||||
<span v-if="form.manageTags?.length > 0" class="tag-count">
|
||||
已选 {{ form.manageTags.length }} 个
|
||||
</span>
|
||||
</div>
|
||||
<el-input v-model="form.manageTags" placeholder="请输入管理耳号,支持批量输入(空格/换行/逗号分隔)" @blur="onManageTagsBlur"
|
||||
:disabled="!isAdd" />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 新增弹窗已选耳号展示区(和改备注、转群完全一致) -->
|
||||
<div v-if="batchTags.length" class="selected-ear-numbers" style="margin-left: 80px; margin-bottom: 18px;">
|
||||
<el-tag v-for="(tag, idx) in batchTags" :key="tag" closable @close="removeBatchTag(idx)" style="margin:4px"
|
||||
type="success">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
|
||||
<el-button type="primary" link @click="clearBatchTags">
|
||||
一键清空 ({{ batchTags.length }})
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<el-form-item label="转入牧场" prop="transTo">
|
||||
<el-select v-model="form.transTo" placeholder="请选择转入牧场" clearable :disabled="!isAdd">
|
||||
<el-option v-for="ranch in ranchOptions" :key="ranch.id" :label="ranch.ranchName"
|
||||
@@ -147,8 +204,8 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="当前牧场" prop="transFrom">
|
||||
<el-select v-model="form.transFrom" placeholder="请选择当前牧场" clearable @change="handleRanchChange"
|
||||
<el-form-item label="转出牧场" prop="transFrom">
|
||||
<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" />
|
||||
@@ -201,7 +258,7 @@
|
||||
<el-form-item label="转入牧场">
|
||||
<el-input :value="approveForm.transTo" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="当前牧场">
|
||||
<el-form-item label="转出牧场">
|
||||
<el-input :value="approveForm.transFrom" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="转场类型">
|
||||
@@ -216,10 +273,10 @@
|
||||
<el-form-item label="状态">
|
||||
<el-input :value="getStatusLabel(approveForm.status)" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="接收羊舍" v-if="approveForm.eventType === '转场转入'">
|
||||
<el-select v-model="approveForm.sheepfoldId" placeholder="请选择接收羊舍" clearable>
|
||||
<el-option v-for="sheepfold in acceptSheepfold" :key="sheepfold.id" :label="sheepfold.sheepfoldName"
|
||||
:value="sheepfold.id" />
|
||||
<el-form-item label="转入羊舍" prop="sheepfoldId">
|
||||
<el-select v-model="approveForm.sheepfoldId" placeholder="请输入或选择转入羊舍" filterable clearable allow-create
|
||||
default-first-option @change="handleSheepfoldInputChange" style="width: 100%;">
|
||||
<el-option v-for="sf in acceptSheepfold" :key="sf.id" :label="sf.sheepfoldName" :value="sf.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -235,10 +292,10 @@
|
||||
</template>
|
||||
|
||||
<script setup name="Transition_info">
|
||||
import { listTransition_info, getTransition_info, delTransition_info, addTransition_info, getSheepByRanchId, updateTransition_info, listRanch, approveTransitionInfo,searchEarNumbers } from "@/api/produce/manage_sheep/transition_info"
|
||||
import { listTransition_info, getTransition_info, delTransition_info, addTransition_info, getSheepByRanchId, updateTransition_info, listRanch, approveTransitionInfo, searchEarNumbers } from "@/api/produce/manage_sheep/transition_info"
|
||||
import { checkSheepByManageTags, getSheepBySheepfoldId } from '@/api/produce/other/fixHoof'
|
||||
import request from '@/utils/request'
|
||||
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { status, trans_type } = proxy.useDict('status', 'trans_type')
|
||||
@@ -262,7 +319,18 @@ const sheepOptions = ref([])
|
||||
const isAdd = ref(true)
|
||||
const isEdit = ref(false)
|
||||
const acceptSheepfold = ref([])
|
||||
|
||||
const sheepTypeList = ref([])
|
||||
const pasteText = ref('') // 批量粘贴输入框
|
||||
const isExpanded = ref(false) // 折叠状态
|
||||
const defaultShowCount = 2 // 默认展示条数
|
||||
const batchTags = ref([]) // 本次要新增的多条耳号
|
||||
const batchSheep = ref([]) // 对应的羊只对象
|
||||
// 计算属性:控制实际展示的耳号列表
|
||||
const displayedEarTags = computed(() => {
|
||||
const list = queryParams.value.manageTagsList || []
|
||||
if (isExpanded.value || list.length <= defaultShowCount) return list
|
||||
return list.slice(0, defaultShowCount)
|
||||
})
|
||||
const data = reactive({
|
||||
form: {
|
||||
id: null,
|
||||
@@ -284,7 +352,11 @@ const data = reactive({
|
||||
transTo: null,
|
||||
transFrom: null,
|
||||
status: null,
|
||||
transitionDate: null
|
||||
transitionDate: null,
|
||||
technician: null,
|
||||
isDelete: null,
|
||||
sheepTypeId: null,
|
||||
currentRanchId: null
|
||||
},
|
||||
rules: {
|
||||
manageTags: [
|
||||
@@ -294,7 +366,7 @@ const data = reactive({
|
||||
{ required: true, message: "请输入转入牧场", trigger: "blur" }
|
||||
],
|
||||
transFrom: [
|
||||
{ required: false, message: "请选择当前牧场", trigger: "blur" }
|
||||
{ required: false, message: "请选择转出牧场", trigger: "blur" }
|
||||
],
|
||||
eventType: [
|
||||
{ required: true, message: '请选择事件类型', trigger: 'change' }
|
||||
@@ -320,6 +392,9 @@ function getList() {
|
||||
if (queryParams.value.transType !== null) {
|
||||
queryParams.value.params.transType = queryParams.value.transType;
|
||||
}
|
||||
if (queryParams.value.currentRanchId !== null) {
|
||||
queryParams.value.params.currentRanchId = queryParams.value.currentRanchId
|
||||
}
|
||||
if (transitionDateRange.value && transitionDateRange.value.length > 0) {
|
||||
queryParams.value.params["beginTransitionDate"] = transitionDateRange.value[0];
|
||||
queryParams.value.params["endTransitionDate"] = transitionDateRange.value[1];
|
||||
@@ -334,7 +409,7 @@ function getList() {
|
||||
function reset() {
|
||||
form.value = {
|
||||
id: null,
|
||||
manageTags: [],
|
||||
manageTags: '',
|
||||
transTo: null,
|
||||
transFrom: null,
|
||||
transType: null,
|
||||
@@ -342,6 +417,8 @@ function reset() {
|
||||
createBy: null,
|
||||
tagDetails: {}
|
||||
};
|
||||
batchTags.value = [];
|
||||
batchSheep.value = [];
|
||||
sheepOptions.value = [];
|
||||
proxy.resetForm("transition_infoRef");
|
||||
isAdd.value = true;
|
||||
@@ -361,7 +438,7 @@ function loadRanchOptions() {
|
||||
} else {
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch(() => {
|
||||
proxy.$modal.msgError('获取牧场数据失败');
|
||||
});
|
||||
}
|
||||
@@ -372,8 +449,8 @@ function loadSheepOptions() {
|
||||
id: sheep.id,
|
||||
manageTags: sheep.manageTags
|
||||
})) || [];
|
||||
}).catch(error => {
|
||||
console.error('加载耳号选项失败', error);
|
||||
}).catch(() => {
|
||||
proxy.$modal.msgError('加载耳号选项失败,请重试');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -400,11 +477,10 @@ function loadSheepfoldsByRanch(ranchName) {
|
||||
}).then(res => {
|
||||
acceptSheepfold.value = res.rows || [];
|
||||
if (acceptSheepfold.value.length === 0) {
|
||||
proxy.$modal.msgWarning(`转入牧场“${ranchName}”没有可用的接收羊舍`);
|
||||
proxy.$modal.msgWarning(`转入牧场“${ranchName}”没有可用的羊舍`);
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('加载接收羊舍失败:', error);
|
||||
proxy.$modal.msgError('获取接收羊舍数据失败');
|
||||
}).catch(() => {
|
||||
proxy.$modal.msgError('获取转入羊舍数据失败');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -419,50 +495,10 @@ async function getRanchNameByRanchId(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;
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -498,7 +534,6 @@ async function loadSheepInfo() {
|
||||
form.value.transFrom = ranchName;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取耳号信息失败:', error);
|
||||
validResults.push(false);
|
||||
proxy.$modal.msgError(`耳号 ${tag} 验证失败`);
|
||||
}
|
||||
@@ -532,48 +567,38 @@ function handleApprove(row) {
|
||||
displayManageTags.value = Array.isArray(row.manageTags)
|
||||
? row.manageTags.join(',')
|
||||
: row.manageTags || '';
|
||||
|
||||
if (row.eventType === '转场转入') {
|
||||
loadSheepfoldsByRanch(row.transTo);
|
||||
} else {
|
||||
acceptSheepfold.value = [];
|
||||
}
|
||||
approveDialog.value = true;
|
||||
loadSheepfoldsByRanch(row.transTo);
|
||||
}
|
||||
|
||||
// 审批同意
|
||||
function handleApproveAgree() {
|
||||
if (!approveForm.value.transTo) {
|
||||
proxy.$modal.msgError('转入牧场不能为空');
|
||||
// ① 先置状态为“通过”
|
||||
approveForm.value.status = 1;
|
||||
|
||||
// ② 再校验接收羊舍(仅同意时)
|
||||
if (approveForm.value.eventType === "转场转入" && !approveForm.value.sheepfoldId) {
|
||||
proxy.$modal.msgError('转场转入时,转入羊舍不能为空');
|
||||
return;
|
||||
}
|
||||
|
||||
approveForm.value.status = 1;
|
||||
if (approveForm.value.eventType === '转场转入' && !approveForm.value.sheepfoldId) {
|
||||
proxy.$modal.msgError('请选择接收羊舍');
|
||||
return;
|
||||
}
|
||||
// ③ 提交后台
|
||||
approveTransitionInfo(approveForm.value).then(() => {
|
||||
approveDialog.value = false;
|
||||
proxy.$modal.msgSuccess('通过请求,已更新羊只信息');
|
||||
proxy.$modal.msgSuccess('审批通过');
|
||||
getList();
|
||||
}).catch(error => {
|
||||
proxy.$modal.msgError(`审批失败:${error.message}`);
|
||||
});
|
||||
}
|
||||
|
||||
// 驳回审批
|
||||
function handleApproveReject() {
|
||||
approveForm.value.status = 2;
|
||||
updateTransition_info(approveForm.value).then(() => {
|
||||
approveForm.value.sheepfoldId = null;
|
||||
approveTransitionInfo(approveForm.value).then(() => {
|
||||
approveDialog.value = false;
|
||||
proxy.$modal.msgSuccess('驳回请求');
|
||||
proxy.$modal.msgSuccess('已驳回');
|
||||
getList();
|
||||
}).catch(error => {
|
||||
proxy.$modal.msgError(`审批失败:${error.message}`);
|
||||
});
|
||||
}
|
||||
|
||||
// 获取转场类型文本
|
||||
function getTransTypeLabel(value) {
|
||||
const transTypeArray = trans_type.value;
|
||||
@@ -610,9 +635,13 @@ function handleQuery() {
|
||||
function resetQuery() {
|
||||
queryParams.value.transType = null;
|
||||
transitionDateRange.value = [];
|
||||
queryParams.value.manageTagsList = []
|
||||
proxy.resetForm("queryRef")
|
||||
handleQuery()
|
||||
queryParams.value.manageTagsList = [];
|
||||
queryParams.value.sheepTypeId = null;
|
||||
queryParams.value.currentRanchId = null;
|
||||
queryParams.value.isDelete = null;
|
||||
queryParams.value.technician = null;
|
||||
proxy.resetForm("queryRef");
|
||||
handleQuery();
|
||||
}
|
||||
|
||||
function handleSelectionChange(selection) {
|
||||
@@ -625,11 +654,10 @@ function handleSelectionChange(selection) {
|
||||
function handleAdd() {
|
||||
reset();
|
||||
open.value = true;
|
||||
title.value = "添加转场";
|
||||
title.value = '添加转场';
|
||||
isAdd.value = true;
|
||||
isEdit.value = false;
|
||||
sheepOptions.value = [];
|
||||
form.value.manageTags = [];
|
||||
form.value.transitionDate = dayjs().format('YYYY-MM-DD');
|
||||
}
|
||||
|
||||
//修改
|
||||
@@ -646,7 +674,6 @@ async function handleUpdate(row) {
|
||||
isAdd.value = false;
|
||||
isEdit.value = true;
|
||||
}).catch(error => {
|
||||
console.error('获取转场详情失败:', error);
|
||||
proxy.$modal.msgError('加载数据失败,请重试');
|
||||
});
|
||||
}
|
||||
@@ -654,65 +681,38 @@ async function handleUpdate(row) {
|
||||
//提交
|
||||
async function submitForm() {
|
||||
proxy.$refs.transition_infoRef.validate(async (valid) => {
|
||||
if (!valid) return;
|
||||
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;
|
||||
if (batchTags.value.length === 0) {
|
||||
proxy.$modal.msgError('请输入至少一个有效耳号')
|
||||
return
|
||||
}
|
||||
|
||||
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,
|
||||
eventType: form.value.eventType,
|
||||
transitionDate: form.value.transitionDate,
|
||||
technician: form.value.technician,
|
||||
comment: form.value.tagDetails[tag].comment,
|
||||
status: 0,
|
||||
}));
|
||||
} else {
|
||||
submitData = {
|
||||
...form.value,
|
||||
manageTags: validTags.join(','),
|
||||
eventType: form.value.eventType,
|
||||
};
|
||||
}
|
||||
// 批量构建提交数据
|
||||
const submitData = batchTags.value.map((tag, idx) => ({
|
||||
sheepId: batchSheep.value[idx].id,
|
||||
varietyId: batchSheep.value[idx].varietyId,
|
||||
varietyName: batchSheep.value[idx].varietyName || '',
|
||||
manageTags: tag,
|
||||
transTo: form.value.transTo,
|
||||
transFrom: form.value.transFrom,
|
||||
transType: form.value.transType,
|
||||
eventType: form.value.eventType,
|
||||
transitionDate: form.value.transitionDate,
|
||||
technician: form.value.technician,
|
||||
comment: batchSheep.value[idx].comment || '',
|
||||
status: 0,
|
||||
}))
|
||||
|
||||
try {
|
||||
if (isAdd.value) {
|
||||
await addTransition_info(submitData);
|
||||
} else {
|
||||
await updateTransition_info(submitData);
|
||||
}
|
||||
proxy.$modal.msgSuccess(isAdd.value ? '提交成功' : '修改成功');
|
||||
open.value = false;
|
||||
getList();
|
||||
await addTransition_info(submitData)
|
||||
proxy.$modal.msgSuccess(`成功新增 ${batchTags.value.length} 条转场记录`)
|
||||
open.value = false
|
||||
getList()
|
||||
} catch (error) {
|
||||
proxy.$modal.msgError(isAdd.value ? '提交失败,请重试' : '修改失败,请重试');
|
||||
proxy.$modal.msgError('提交失败,请重试')
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
//加载品种信息
|
||||
function getVarietyOptions() {
|
||||
@@ -743,17 +743,151 @@ function searchEarNumber(query) {
|
||||
earOptions.value = res.data || []
|
||||
}).finally(() => earLoading.value = false)
|
||||
}
|
||||
async function handleRanchChange(ranchName) {
|
||||
if (!ranchName) {
|
||||
sheepOptions.value = [];
|
||||
form.value.manageTags = [];
|
||||
return;
|
||||
}
|
||||
|
||||
const matched = ranchOptions.value.find(r => r.ranchName === 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();
|
||||
}
|
||||
/* 粘贴事件 */
|
||||
function handlePaste() {
|
||||
nextTick(() => handlePasteSubmit())
|
||||
}
|
||||
|
||||
/* 批量提交:拆词 → 去重 → 回填 */
|
||||
function handlePasteSubmit() {
|
||||
if (!pasteText.value || !pasteText.value.trim()) return
|
||||
const separators = /[\p{White_Space},,\n\r\t]+/u
|
||||
const raw = pasteText.value.trim().split(separators).filter(v => v)
|
||||
const exist = new Set(queryParams.value.manageTagsList || [])
|
||||
const adds = []
|
||||
const dups = []
|
||||
raw.forEach(v => {
|
||||
if (!exist.has(v)) { adds.push(v); exist.add(v) }
|
||||
else dups.push(v)
|
||||
})
|
||||
if (adds.length) {
|
||||
queryParams.value.manageTagsList = [...(queryParams.value.manageTagsList || []), ...adds]
|
||||
proxy.$modal.msgSuccess(`成功添加 ${adds.length} 个耳号,当前共 ${queryParams.value.manageTagsList.length} 个` +
|
||||
(dups.length > 0 ? `,已忽略 ${dups.length} 个重复耳号` : ''))
|
||||
} else if (dups.length > 0) {
|
||||
proxy.$modal.msgWarning('所有耳号均已存在')
|
||||
}
|
||||
pasteText.value = ''
|
||||
}
|
||||
|
||||
/* 切换展开/收起 */
|
||||
function toggleExpand() {
|
||||
isExpanded.value = !isExpanded.value
|
||||
}
|
||||
|
||||
/* 选择器变化时去重 */
|
||||
function handleEarChange(val) {
|
||||
queryParams.value.manageTagsList = [...new Set(val)]
|
||||
}
|
||||
|
||||
/* 一键清空 */
|
||||
function clearEarNumbers() {
|
||||
queryParams.value.manageTagsList = []
|
||||
pasteText.value = ''
|
||||
isExpanded.value = false
|
||||
}
|
||||
|
||||
/* 删除单个耳号 */
|
||||
function removeEarNumber(tag) {
|
||||
const idx = queryParams.value.manageTagsList.indexOf(tag)
|
||||
if (idx > -1) queryParams.value.manageTagsList.splice(idx, 1)
|
||||
}
|
||||
|
||||
// 校验和回显(和改备注、转群完全一致)
|
||||
async function onManageTagsBlur() {
|
||||
const raw = form.value.manageTags?.trim()
|
||||
if (!raw) return
|
||||
|
||||
// 1. 先按分隔符拆
|
||||
const separators = /[\p{White_Space},,]+/u
|
||||
const tags = [...new Set(raw.split(separators).filter(v => v))]
|
||||
|
||||
// 2. 只有一条 → 走老逻辑
|
||||
if (tags.length === 1) {
|
||||
const { data: sheep } = await checkSheepByManageTags(tags[0].trim()).catch(() => ({ data: null }))
|
||||
if (sheep) {
|
||||
batchTags.value = [tags[0]]
|
||||
batchSheep.value = [sheep]
|
||||
// 自动填充转出牧场
|
||||
const ranchName = await getRanchNameByRanchId(sheep.ranchId)
|
||||
form.value.transFrom = ranchName
|
||||
} else {
|
||||
proxy.$modal.msgWarning('未找到该耳号对应羊只')
|
||||
batchTags.value = []
|
||||
batchSheep.value = []
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 3. 多条 → 批量校验
|
||||
batchTags.value = []
|
||||
batchSheep.value = []
|
||||
for (const tag of tags) {
|
||||
const { data: sheep } = await checkSheepByManageTags(tag.trim()).catch(() => ({ data: null }))
|
||||
if (sheep) {
|
||||
batchTags.value.push(tag)
|
||||
batchSheep.value.push(sheep)
|
||||
} else {
|
||||
proxy.$modal.msgWarning(`耳号 ${tag} 未找到对应羊只,已跳过`)
|
||||
}
|
||||
}
|
||||
|
||||
if (!batchTags.value.length) return // 全部无效
|
||||
|
||||
// 把合法耳号重新拼回输入框,用半角空格分隔
|
||||
form.value.manageTags = batchTags.value.join(' ')
|
||||
|
||||
// 自动填充第一条的转出牧场
|
||||
const firstSheep = batchSheep.value[0]
|
||||
const ranchName = await getRanchNameByRanchId(firstSheep.ranchId)
|
||||
form.value.transFrom = ranchName
|
||||
}
|
||||
|
||||
// 删除单个批量耳号
|
||||
function removeBatchTag(idx) {
|
||||
batchTags.value.splice(idx, 1)
|
||||
batchSheep.value.splice(idx, 1)
|
||||
// 实时回写输入框
|
||||
form.value.manageTags = batchTags.value.join(' ')
|
||||
}
|
||||
|
||||
// 一键清空批量耳号
|
||||
function clearBatchTags() {
|
||||
batchTags.value = []
|
||||
batchSheep.value = []
|
||||
form.value.manageTags = ''
|
||||
form.value.transFrom = ''
|
||||
}
|
||||
// 加载羊只类型数据
|
||||
function loadSheepTypeList() {
|
||||
request({
|
||||
url: '/base/base/list',
|
||||
method: 'get',
|
||||
params: { pageNum: 1, pageSize: 9999 }
|
||||
}).then(res => {
|
||||
sheepTypeList.value = res.rows || []
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
loadRanchOptions();
|
||||
getVarietyOptions();
|
||||
loadSheepOptions();
|
||||
loadSheepTypeList();
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
@@ -768,9 +902,24 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.selected-ear-numbers {
|
||||
margin-bottom: 16px;
|
||||
padding: 10px;
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
border: 1px dashed #dcdfe6;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.selected-ear-numbers::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.selected-ear-numbers::-webkit-scrollbar-thumb {
|
||||
background-color: #dcdfe6;
|
||||
border-radius: 3px;
|
||||
}
|
||||
</style>
|
||||
@@ -7,15 +7,39 @@
|
||||
start-placeholder="开始日期" end-placeholder="结束日期" />
|
||||
</el-form-item>
|
||||
<el-form-item label="管理耳号" prop="manageTagsList">
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="请输入耳号,支持多选" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option style="width: 260px">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
<el-button type="text" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" style="margin-left: 8px">
|
||||
清空
|
||||
</el-button>
|
||||
<div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap;">
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="输入耳号搜索" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option collapse-tags :max-collapse-tags="0" style="width:260px" @change="handleEarChange">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
<el-input v-model="pasteText" placeholder="或粘贴多个耳号(空格/换行/逗号分隔)" style="width:260px" @paste="handlePaste"
|
||||
@keyup.enter="handlePasteSubmit" clearable>
|
||||
<template #append>
|
||||
<el-button @click="handlePasteSubmit" :icon="Plus">添加</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
<el-tag v-if="queryParams.manageTagsList.length" type="info" effect="plain" size="large">
|
||||
已选: {{ queryParams.manageTagsList.length }} 个
|
||||
</el-tag>
|
||||
<el-button type="danger" plain :icon="Delete" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList.length">
|
||||
清空全部
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-if="queryParams.manageTagsList.length" class="selected-ear-numbers">
|
||||
<el-tag v-for="tag in displayedEarTags" :key="tag" closable @close="removeEarNumber(tag)" style="margin:4px"
|
||||
type="success">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
<el-button v-if="queryParams.manageTagsList.length > defaultShowCount" type="primary" link
|
||||
@click="toggleExpand">
|
||||
{{ isExpanded ? '收起' : `展开剩余 ${queryParams.manageTagsList.length - defaultShowCount} 个` }}
|
||||
<el-icon class="el-icon--right">
|
||||
<component :is="isExpanded ? ArrowUp : ArrowDown" />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="羊舍" prop="sheepfold">
|
||||
<el-select v-model="queryParams.sheepfold" placeholder="请选择羊舍" style="min-width:150px" clearable>
|
||||
@@ -27,18 +51,18 @@
|
||||
<el-option v-for="item in varietyOptions" :key="item.id" :label="item.variety" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否在群" prop="isDelete">
|
||||
<el-select v-model="queryParams.isDelete" placeholder="全部" clearable style="min-width:120px">
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="在群" :value="0" />
|
||||
<el-option label="离群" :value="1" />
|
||||
</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-button icon="Refresh" @click="resetQuery">重置</el-button> -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" class="selected-ear-numbers">
|
||||
<span style="margin-right: 10px; color: #606266;">已选耳号:</span>
|
||||
<el-tag v-for="tag in queryParams.manageTagsList" :key="tag" closable @close="removeEarNumber(tag)"
|
||||
style="margin-right: 8px;">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<!-- 按钮区域 -->
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
@@ -136,7 +160,9 @@
|
||||
import { listCastrate, getCastrate, delCastrate, addCastrate, searchEarNumbers } from '@/api/produce/other/castrate'
|
||||
import { checkSheepByManageTags, getVarietyOptions, getSheepBySheepfoldId } from '@/api/produce/other/fixHoof'
|
||||
import { listSheepfold_management as listSheepfold } from '@/api/fileManagement/sheepfold_management'
|
||||
|
||||
import { Plus, Delete, ArrowUp, ArrowDown } from '@element-plus/icons-vue'
|
||||
import { nextTick } from 'vue'
|
||||
import dayjs from 'dayjs'
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const castrateList = ref([])
|
||||
@@ -152,7 +178,14 @@ const daterangeCreateTime = ref([])
|
||||
const sheepOptions = ref([])
|
||||
const varietyOptions = ref([])
|
||||
const daterangeEventDate = ref([])
|
||||
|
||||
const pasteText = ref('')
|
||||
const isExpanded = ref(false)
|
||||
const defaultShowCount = 2
|
||||
const displayedEarTags = computed(() => {
|
||||
const list = queryParams.value.manageTagsList
|
||||
if (isExpanded.value || list.length <= defaultShowCount) return list
|
||||
return list.slice(0, defaultShowCount)
|
||||
})
|
||||
const data = reactive({
|
||||
form: {
|
||||
manageTags: [],
|
||||
@@ -173,6 +206,8 @@ const data = reactive({
|
||||
createTime: null,
|
||||
beginEventDate: null,
|
||||
endEventDate: null,
|
||||
manageTagsList: [],
|
||||
isDelete: null
|
||||
},
|
||||
rules: {
|
||||
manageTags: [
|
||||
@@ -327,6 +362,7 @@ function resetQuery() {
|
||||
daterangeCreateTime.value = []
|
||||
daterangeEventDate.value = []
|
||||
queryParams.value.manageTagsList = []
|
||||
queryParams.value.isDelete = null
|
||||
proxy.resetForm('queryRef')
|
||||
handleQuery()
|
||||
}
|
||||
@@ -342,6 +378,7 @@ function handleAdd() {
|
||||
reset()
|
||||
open.value = true
|
||||
title.value = '添加去势'
|
||||
form.value.eventDate = dayjs().format('YYYY-MM-DD')
|
||||
}
|
||||
|
||||
//修改
|
||||
@@ -469,10 +506,43 @@ function searchEarNumber(query) {
|
||||
function clearEarNumbers() {
|
||||
queryParams.value.manageTagsList = []
|
||||
}
|
||||
|
||||
function removeEarNumber(tag) {
|
||||
const idx = queryParams.value.manageTagsList.indexOf(tag)
|
||||
if (idx > -1) queryParams.value.manageTagsList.splice(idx, 1)
|
||||
}
|
||||
|
||||
function handlePaste() {
|
||||
nextTick(() => handlePasteSubmit())
|
||||
}
|
||||
|
||||
function handlePasteSubmit() {
|
||||
if (!pasteText.value.trim()) return
|
||||
const separators = /[\s,,\n\r\t]+/
|
||||
const raw = pasteText.value.trim().split(separators).filter(v => v)
|
||||
const exist = new Set(queryParams.value.manageTagsList)
|
||||
const adds = []
|
||||
const dups = []
|
||||
raw.forEach(v => {
|
||||
if (!exist.has(v)) { adds.push(v); exist.add(v) }
|
||||
else dups.push(v)
|
||||
})
|
||||
if (adds.length) {
|
||||
queryParams.value.manageTagsList = [...queryParams.value.manageTagsList, ...adds]
|
||||
proxy.$modal.msgSuccess(`成功添加 ${adds.length} 个耳号${dups.length ? `,已忽略 ${dups.length} 个重复` : ''}`)
|
||||
} else if (dups.length) {
|
||||
proxy.$modal.msgWarning('所有耳号均已存在')
|
||||
}
|
||||
pasteText.value = ''
|
||||
}
|
||||
|
||||
function toggleExpand() {
|
||||
isExpanded.value = !isExpanded.value
|
||||
}
|
||||
|
||||
function handleEarChange(val) {
|
||||
queryParams.value.manageTagsList = [...new Set(val)]
|
||||
}
|
||||
onMounted(() => {
|
||||
getSheepfoldOptions()
|
||||
getVarietyOptions()
|
||||
@@ -488,10 +558,25 @@ onMounted(() => {
|
||||
border-radius: 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.selected-ear-numbers{
|
||||
margin-bottom: 16px;
|
||||
padding: 10px;
|
||||
|
||||
.selected-ear-numbers {
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
border: 1px dashed #dcdfe6;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.selected-ear-numbers::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.selected-ear-numbers::-webkit-scrollbar-thumb {
|
||||
background-color: #dcdfe6;
|
||||
border-radius: 3px;
|
||||
}
|
||||
</style>
|
||||
@@ -6,15 +6,39 @@
|
||||
start-placeholder="开始日期" end-placeholder="结束日期" />
|
||||
</el-form-item>
|
||||
<el-form-item label="管理耳号" prop="manageTagsList">
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="请输入耳号,支持多选" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option style="width: 260px">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
<el-button type="text" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" style="margin-left: 8px">
|
||||
清空
|
||||
</el-button>
|
||||
<div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap;">
|
||||
<el-select v-model="queryParams.manageTagsList" multiple filterable remote reserve-keyword
|
||||
placeholder="输入耳号搜索" :remote-method="searchEarNumber" :loading="earLoading" allow-create
|
||||
default-first-option collapse-tags :max-collapse-tags="0" style="width:260px" @change="handleEarChange">
|
||||
<el-option v-for="item in earOptions" :key="item" :label="item" :value="item" />
|
||||
</el-select>
|
||||
<el-input v-model="pasteText" placeholder="或粘贴多个耳号(空格/换行/逗号分隔)" style="width:260px" @paste="handlePaste"
|
||||
@keyup.enter="handlePasteSubmit" clearable>
|
||||
<template #append>
|
||||
<el-button @click="handlePasteSubmit" :icon="Plus">添加</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
<el-tag v-if="queryParams.manageTagsList.length" type="info" effect="plain" size="large">
|
||||
已选: {{ queryParams.manageTagsList.length }} 个
|
||||
</el-tag>
|
||||
<el-button type="danger" plain :icon="Delete" @click="clearEarNumbers"
|
||||
v-if="queryParams.manageTagsList.length">
|
||||
清空全部
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-if="queryParams.manageTagsList.length" class="selected-ear-numbers">
|
||||
<el-tag v-for="tag in displayedEarTags" :key="tag" closable @close="removeEarNumber(tag)" style="margin:4px"
|
||||
type="success">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
<el-button v-if="queryParams.manageTagsList.length > defaultShowCount" type="primary" link
|
||||
@click="toggleExpand">
|
||||
{{ isExpanded ? '收起' : `展开剩余 ${queryParams.manageTagsList.length - defaultShowCount} 个` }}
|
||||
<el-icon class="el-icon--right">
|
||||
<component :is="isExpanded ? ArrowUp : ArrowDown" />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="羊舍" prop="sheepfold">
|
||||
<el-select v-model="queryParams.sheepfold" placeholder="请选择羊舍" style="min-width:150px" clearable>
|
||||
@@ -26,18 +50,18 @@
|
||||
<el-option v-for="item in varietyOptions" :key="item.id" :label="item.variety" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否在群" prop="isDelete">
|
||||
<el-select v-model="queryParams.isDelete" placeholder="全部" clearable style="min-width:120px">
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="在群" :value="0" />
|
||||
<el-option label="离群" :value="1" />
|
||||
</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-button icon="Refresh" @click="resetQuery">重置</el-button> -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div v-if="queryParams.manageTagsList && queryParams.manageTagsList.length > 0" class="selected-ear-numbers">
|
||||
<span style="margin-right: 10px; color: #606266;">已选耳号:</span>
|
||||
<el-tag v-for="tag in queryParams.manageTagsList" :key="tag" closable @close="removeEarNumber(tag)"
|
||||
style="margin-right: 8px;">
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<!-- 按钮 -->
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
@@ -133,9 +157,11 @@
|
||||
</template>
|
||||
|
||||
<script setup name="FixHoof">
|
||||
import { listFixHoof, getFixHoof, delFixHoof, addFixHoof, updateFixHoof, checkSheepByManageTags, getVarietyOptions, getSheepBySheepfoldId,searchEarNumbers } from '@/api/produce/other/fixHoof'
|
||||
import { listFixHoof, getFixHoof, delFixHoof, addFixHoof, updateFixHoof, checkSheepByManageTags, getVarietyOptions, getSheepBySheepfoldId, searchEarNumbers } from '@/api/produce/other/fixHoof'
|
||||
import { listSheepfold_management as listSheepfold } from '@/api/fileManagement/sheepfold_management'
|
||||
|
||||
import { Plus, Delete, ArrowUp, ArrowDown } from '@element-plus/icons-vue'
|
||||
import { nextTick } from 'vue'
|
||||
import dayjs from 'dayjs'
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const fixHoofList = ref([])
|
||||
@@ -151,7 +177,14 @@ const daterangeCreateTime = ref([])
|
||||
const varietyOptions = ref([])
|
||||
const sheepOptions = ref([])
|
||||
const daterangeEventDate = ref([])
|
||||
|
||||
const pasteText = ref('')
|
||||
const isExpanded = ref(false)
|
||||
const defaultShowCount = 2
|
||||
const displayedEarTags = computed(() => {
|
||||
const list = queryParams.value.manageTagsList
|
||||
if (isExpanded.value || list.length <= defaultShowCount) return list
|
||||
return list.slice(0, defaultShowCount)
|
||||
})
|
||||
const data = reactive({
|
||||
form: {
|
||||
sheepfold: null,
|
||||
@@ -166,7 +199,9 @@ const data = reactive({
|
||||
sheepfold: null,
|
||||
varietyId: null,
|
||||
technician: null,
|
||||
createTime: null
|
||||
createTime: null,
|
||||
manageTagsList: [],
|
||||
isDelete: null
|
||||
},
|
||||
rules: {
|
||||
manageTags: [
|
||||
@@ -315,6 +350,7 @@ function resetQuery() {
|
||||
daterangeEventDate.value = []
|
||||
queryParams.value.varietyId = null
|
||||
queryParams.value.manageTagsList = []
|
||||
queryParams.value.isDelete = null
|
||||
proxy.resetForm('queryRef')
|
||||
handleQuery()
|
||||
}
|
||||
@@ -330,6 +366,7 @@ function handleAdd() {
|
||||
reset()
|
||||
open.value = true
|
||||
title.value = '添加修蹄'
|
||||
form.value.eventDate = dayjs().format('YYYY-MM-DD')
|
||||
}
|
||||
|
||||
//修改
|
||||
@@ -414,10 +451,42 @@ function searchEarNumber(query) {
|
||||
function clearEarNumbers() {
|
||||
queryParams.value.manageTagsList = []
|
||||
}
|
||||
|
||||
function removeEarNumber(tag) {
|
||||
const idx = queryParams.value.manageTagsList.indexOf(tag)
|
||||
if (idx > -1) queryParams.value.manageTagsList.splice(idx, 1)
|
||||
}
|
||||
function handlePaste() {
|
||||
nextTick(() => handlePasteSubmit())
|
||||
}
|
||||
|
||||
function handlePasteSubmit() {
|
||||
if (!pasteText.value.trim()) return
|
||||
const separators = /[\s,,\n\r\t]+/
|
||||
const raw = pasteText.value.trim().split(separators).filter(v => v)
|
||||
const exist = new Set(queryParams.value.manageTagsList)
|
||||
const adds = []
|
||||
const dups = []
|
||||
raw.forEach(v => {
|
||||
if (!exist.has(v)) { adds.push(v); exist.add(v) }
|
||||
else dups.push(v)
|
||||
})
|
||||
if (adds.length) {
|
||||
queryParams.value.manageTagsList = [...queryParams.value.manageTagsList, ...adds]
|
||||
proxy.$modal.msgSuccess(`成功添加 ${adds.length} 个耳号${dups.length ? `,已忽略 ${dups.length} 个重复` : ''}`)
|
||||
} else if (dups.length) {
|
||||
proxy.$modal.msgWarning('所有耳号均已存在')
|
||||
}
|
||||
pasteText.value = ''
|
||||
}
|
||||
|
||||
function toggleExpand() {
|
||||
isExpanded.value = !isExpanded.value
|
||||
}
|
||||
|
||||
function handleEarChange(val) {
|
||||
queryParams.value.manageTagsList = [...new Set(val)]
|
||||
}
|
||||
onMounted(() => {
|
||||
getSheepfoldOptions()
|
||||
getVarietyOptions()
|
||||
@@ -435,9 +504,23 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.selected-ear-numbers {
|
||||
margin-bottom: 16px;
|
||||
padding: 10px;
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
border: 1px dashed #dcdfe6;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.selected-ear-numbers::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.selected-ear-numbers::-webkit-scrollbar-thumb {
|
||||
background-color: #dcdfe6;
|
||||
border-radius: 3px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user