繁育多耳号查询
This commit is contained in:
@@ -369,7 +369,8 @@
|
||||
<el-row :gutter="20" class="lamb-form-content">
|
||||
<el-col :span="8">
|
||||
<el-form-item :label="`羔羊耳号`" :prop="`lambForms.${index}.lambEarNumber`">
|
||||
<el-input v-model="lamb.lambEarNumber" placeholder="请输入羔羊耳号" />
|
||||
<el-input v-model="lamb.lambEarNumber" placeholder="请输入羔羊耳号"
|
||||
@input="handleLambEarNumberInput(index)"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
@@ -567,6 +568,64 @@ const data = reactive({
|
||||
}
|
||||
})
|
||||
|
||||
// 品种 ID 常量定义 (对应 ScEmbryoFlushServiceImpl)
|
||||
const VARIETY_IDS = {
|
||||
HUYANG: 1, // 湖羊
|
||||
DONGFULISHENG: 2, // 东佛里生
|
||||
HUIJIAO: 3, // 回交
|
||||
JIZA_1: 4, // 级杂一代
|
||||
JIZA_2: 5, // 级杂二代
|
||||
JIZA_3: 6, // 级杂三代
|
||||
SHIDAI_1: 7, // 一世代
|
||||
SHIDAI_2: 8, // 二世代
|
||||
SHIDAI_3: 9, // 三世代
|
||||
SHIDAI_4: 10 // 四世代
|
||||
};
|
||||
|
||||
/** * 品种计算核心逻辑 (参考后端 calculateEmbryoVarietyById)
|
||||
* @param {number} maleId 公羊品种ID
|
||||
* @param {number} femaleId 母羊品种ID
|
||||
* @returns {number|null} 羔羊品种ID
|
||||
*/
|
||||
function calculateLambBreedId(maleId, femaleId) {
|
||||
if (!maleId || !femaleId) return null;
|
||||
|
||||
// 湖羊 x 湖羊 -> 湖羊
|
||||
if (maleId === VARIETY_IDS.HUYANG && femaleId === VARIETY_IDS.HUYANG) return VARIETY_IDS.HUYANG;
|
||||
|
||||
// 东佛里生 x 东佛里生 -> 东佛里生
|
||||
if (maleId === VARIETY_IDS.DONGFULISHENG && femaleId === VARIETY_IDS.DONGFULISHENG) return VARIETY_IDS.DONGFULISHENG;
|
||||
|
||||
// 东佛里生 x 湖羊 -> 级杂一代
|
||||
if (maleId === VARIETY_IDS.DONGFULISHENG && femaleId === VARIETY_IDS.HUYANG) return VARIETY_IDS.JIZA_1;
|
||||
|
||||
// 东佛里生 x 级杂一代 -> 级杂二代
|
||||
if (maleId === VARIETY_IDS.DONGFULISHENG && femaleId === VARIETY_IDS.JIZA_1) return VARIETY_IDS.JIZA_2;
|
||||
|
||||
// 东佛里生 x 级杂二代 -> 级杂三代
|
||||
if (maleId === VARIETY_IDS.DONGFULISHENG && femaleId === VARIETY_IDS.JIZA_2) return VARIETY_IDS.JIZA_3;
|
||||
|
||||
// 东佛里生 x 级杂三代 -> 东佛里生
|
||||
if (maleId === VARIETY_IDS.DONGFULISHENG && femaleId === VARIETY_IDS.JIZA_3) return VARIETY_IDS.DONGFULISHENG;
|
||||
|
||||
// 湖羊 x 级杂三代 -> 回交
|
||||
if (maleId === VARIETY_IDS.HUYANG && femaleId === VARIETY_IDS.JIZA_3) return VARIETY_IDS.HUIJIAO;
|
||||
|
||||
// 湖羊 x 回交 -> 回交
|
||||
if (maleId === VARIETY_IDS.HUYANG && femaleId === VARIETY_IDS.HUIJIAO) return VARIETY_IDS.HUIJIAO;
|
||||
|
||||
// 世代计算规则
|
||||
const isMaleCapable = (maleId >= 3 && maleId <= 10);
|
||||
if (isMaleCapable) {
|
||||
if (femaleId === VARIETY_IDS.JIZA_2) return VARIETY_IDS.SHIDAI_1;
|
||||
if (femaleId === VARIETY_IDS.SHIDAI_1) return VARIETY_IDS.SHIDAI_2;
|
||||
if (femaleId === VARIETY_IDS.SHIDAI_2) return VARIETY_IDS.SHIDAI_3;
|
||||
if (femaleId === VARIETY_IDS.SHIDAI_3) return VARIETY_IDS.SHIDAI_4;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data)
|
||||
|
||||
// 新增:获取技术员列表
|
||||
@@ -767,11 +826,8 @@ function handleEarNumberInput() {
|
||||
|
||||
/** 母羊耳号失焦处理 - 自动查询配种信息 */
|
||||
function handleEarNumberBlur() {
|
||||
const earNumber = form.value.femaleEarNumber
|
||||
if (!earNumber || earNumber.trim() === '') {
|
||||
return
|
||||
}
|
||||
|
||||
const earNumber = form.value.femaleEarNumber;
|
||||
if (!earNumber || earNumber.trim() === '') return;
|
||||
// 调用API查询配种信息
|
||||
getBreedingInfo(earNumber.trim()).then(response => {
|
||||
if (response.code === 200 && response.data) {
|
||||
@@ -784,7 +840,19 @@ function handleEarNumberBlur() {
|
||||
form.value.breedingDate = breedingData.breeding_date
|
||||
form.value.pregnancyDays = breedingData.pregnancy_days
|
||||
form.value.technician = breedingData.technician || ''
|
||||
const mVariety = varietyList.value.find(v => v.variety === breedingData.male_breed);
|
||||
const fVariety = varietyList.value.find(v => v.variety === breedingData.female_breed);
|
||||
|
||||
// 临时存储这些信息,用于初始化羔羊列表
|
||||
form.value._calculatedLambBreedId = calculateLambBreedId(mVariety?.id, fVariety?.id);
|
||||
form.value._fatherLineage = breedingData.male_lineage || ''; // 确保后端返回了家系字段
|
||||
if (lambForms.value && lambForms.value.length > 0) {
|
||||
lambForms.value.forEach(lamb => {
|
||||
lamb.lineage = form.value._fatherLineage;
|
||||
lamb.lambBreed = form.value._calculatedLambBreedId;
|
||||
});
|
||||
}
|
||||
proxy.$modal.msgSuccess("已自动匹配父母品种及家系信息");
|
||||
proxy.$modal.msgSuccess("已自动填充配种信息")
|
||||
} else {
|
||||
proxy.$modal.msgWarning(response.msg || "未找到该母羊的配种记录")
|
||||
@@ -801,6 +869,7 @@ function handleEarNumberBlur() {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/** 查询产羔记录列表 */
|
||||
function getList() {
|
||||
loading.value = true
|
||||
@@ -886,21 +955,21 @@ function handleUpdate(row) {
|
||||
|
||||
/** 产羔数量变化处理 */
|
||||
function handleLambsBornChange() {
|
||||
const count = parseInt(form.value.lambsBorn) || 0
|
||||
if (count > 0 && count <= 10) { // 限制最大数量
|
||||
showLambForms.value = true
|
||||
lambForms.value = Array.from({ length: count }, (_, index) => ({
|
||||
const count = parseInt(form.value.lambsBorn) || 0;
|
||||
if (count > 0 && count <= 10) {
|
||||
showLambForms.value = true;
|
||||
lambForms.value = Array.from({ length: count }, () => ({
|
||||
lambEarNumber: '',
|
||||
gender: '',
|
||||
isRetained: false,
|
||||
isRetained: true, // 默认留养
|
||||
birthWeight: null,
|
||||
lambBreed: null,
|
||||
lineage: '',
|
||||
birthday: ''
|
||||
}))
|
||||
lambBreed: form.value._calculatedLambBreedId, // 自动填充计算出的品种
|
||||
lineage: form.value._fatherLineage, // 随父亲家系
|
||||
birthday: form.value.createTime || new Date().toISOString().split('T')[0] // 随产羔日期
|
||||
}));
|
||||
} else {
|
||||
showLambForms.value = false
|
||||
lambForms.value = []
|
||||
showLambForms.value = false;
|
||||
lambForms.value = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -967,6 +1036,24 @@ function submitForm() {
|
||||
}
|
||||
})
|
||||
}
|
||||
/** 监听羔羊耳号输入,自动识别性别 */
|
||||
function handleLambEarNumberInput(index) {
|
||||
const lamb = lambForms.value[index]
|
||||
const earNumber = lamb.lambEarNumber
|
||||
|
||||
// 确保耳号长度至少有2位
|
||||
if (earNumber && earNumber.length >= 2) {
|
||||
// 获取第二个字符并转大写
|
||||
const secondChar = earNumber.charAt(1).toUpperCase()
|
||||
|
||||
if (secondChar === 'F') {
|
||||
lamb.gender = 'female' // 对应 <el-option label="母" value="female">
|
||||
} else if (secondChar === 'M') {
|
||||
lamb.gender = 'male' // 对应 <el-option label="公" value="male">
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
|
||||
Reference in New Issue
Block a user