-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
搜索
重置
@@ -166,31 +63,115 @@
v-hasPermi="['freshMilkTest:freshMilkTest:export']"
>导出
+
+ 列显示
+
+
-
-
-
+
+
- {{ parseTime(scope.row.datetime, '{y}-{m}-{d}') }}
+ {{ formatDate(scope.row.datetime) }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ formatDateTime(scope.row.createTime) }}
-
-
-
-
-
-
-
-
-
-
-
-
-
修改
@@ -207,9 +188,9 @@
@pagination="getList"
/>
-
+
-
+
@@ -218,7 +199,8 @@
v-model="form.datetime"
type="date"
value-format="YYYY-MM-DD"
- placeholder="请选择检测日期">
+ placeholder="请选择检测日期"
+ style="width: 100%">
@@ -233,32 +215,38 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
+
+
+
+
+
+
@@ -268,70 +256,164 @@
+
+
+
-
+
-
-
-
+
+
{{ getGroupName(scope.row.group_id) }}
@@ -127,8 +127,11 @@
-
+
+
+
@@ -155,7 +158,7 @@
import { listSheep_grouping, getSheep_grouping, delSheep_grouping, addSheep_grouping, updateSheep_grouping } from "@/api/fileManagement/sheep_grouping"
import {listLeafGroup} from "@/api/fileManagement/group_management"
import {listSheep_grouping_join} from "@/api/fileManagement/sheep_grouping"
-
+import { addByEarTags } from '@/api/fileManagement/sheep_grouping'
const { proxy } = getCurrentInstance()
@@ -172,7 +175,11 @@ const leafGroupOptions = ref([])
const { sheep_gender } = proxy.useDict('sheep_gender')
const data = reactive({
- form: {},
+ form: {
+ earTags: '',
+ groupId: null,
+ earTagsDisabled: false // 新增字段:是否禁用耳号输入框
+ },
queryParams: {
pageNum: 1,
pageSize: 10,
@@ -182,12 +189,12 @@ const data = reactive({
},
leafGroupOptions: [],
rules: {
- sheepId: [
- { required: true, message: "羊只ID不能为空", trigger: "blur" }
+ earTags: [
+ { required: true, message: "耳号不能为空", trigger: "blur" }
],
groupId: [
- { required: true, message: "分组ID不能为空", trigger: "change" }
- ]
+ { required: true, message: "分组不能为空", trigger: "change" }
+ ],
}
})
@@ -205,22 +212,16 @@ const { queryParams, form, rules } = toRefs(data)
import { getSheep_file } from '@/api/fileManagement/sheep_file'
+
async function getList() {
loading.value = true
try {
- // 1. 把耳号字符串拆成数组
+
const params = {
...queryParams.value,
- bsManageTags: queryParams.value.bsManageTags
- ? String(queryParams.value.bsManageTags)
- .split(/[,,\s]+/)
- .map(s => s.trim())
- .filter(Boolean)
- : undefined
+ bsManageTags: queryParams.value.bsManageTags || undefined
}
- console.log(params)
const { rows, total: t } = await listSheep_grouping_join(params)
- console.log(rows)
sheep_groupingList.value = rows
total.value = t
} finally {
@@ -266,6 +267,8 @@ function handleSelectionChange(selection) {
/** 新增按钮操作 */
function handleAdd() {
reset()
+ form.value.earTagsDisabled = false // 允许输入耳号
+ form.value.earTags = '' // 确保新增时输入框为空
open.value = true
title.value = "添加羊只分组关联"
}
@@ -273,35 +276,98 @@ function handleAdd() {
/** 修改按钮操作 */
function handleUpdate(row) {
reset()
- const _id = row.id || ids.value
- getSheep_grouping(_id).then(response => {
- form.value = response.data
- open.value = true
- title.value = "修改羊只分组关联"
- })
-}
+ form.value = {...row,
+ earTags: row.bs_manage_tags,
+ groupId: row.group_id,
+ originalGroupId: row.group_id, // 用于前端预校验
+ earTagsDisabled: true
+ }
+ open.value = true
+ title.value = "修改羊只分组关联"
+ }
+
+
+// /** 提交按钮 */
+// function submitForm() {
+// proxy.$refs["sheep_groupingRef"].validate(valid => {
+// if (valid) {
+// if (form.value.id != null) {
+// updateSheep_grouping(form.value).then(response => {
+// proxy.$modal.msgSuccess("修改成功")
+// open.value = false
+// getList()
+// })
+// } else {
+// addSheep_grouping(form.value).then(response => {
+// proxy.$modal.msgSuccess("新增成功")
+// open.value = false
+// getList()
+// })
+// }
+// }
+// })
+// }
+
-/** 提交按钮 */
function submitForm() {
proxy.$refs["sheep_groupingRef"].validate(valid => {
- if (valid) {
- if (form.value.id != null) {
- updateSheep_grouping(form.value).then(response => {
- proxy.$modal.msgSuccess("修改成功")
- open.value = false
- getList()
- })
- } else {
- addSheep_grouping(form.value).then(response => {
- proxy.$modal.msgSuccess("新增成功")
- open.value = false
- getList()
- })
+ if (!valid) return;
+
+ // ── 1. 修改模式(单条) ──
+ if (form.value.id != null) {
+
+ // 前端预校验:是否已在此分组
+ if (form.value.groupId === form.value.originalGroupId) {
+ proxy.$modal.msgWarning("该羊已在此分组,无需修改");
+ return;
}
+ // 只需要更新分组
+
+ console.log(form.value)
+ const data = {
+ id: form.value.id,
+ sheepId:form.value.sheep_id,
+ groupId: form.value.groupId
+ };
+ updateSheep_grouping(data).then(() => {
+ proxy.$modal.msgSuccess("修改成功");
+ open.value = false;
+ getList();
+ });
+ return;
}
- })
+
+ // ── 2. 新增模式(耳号批量) ──
+ const earTags = form.value.earTags
+ .split(/[,\n,\s]+/)
+ .map(tag => tag.trim())
+ .filter(tag => tag);
+
+ const data = { earTags, groupId: form.value.groupId };
+
+ addByEarTags(data)
+ .then(res => {
+ if (res.data?.success) {
+ proxy.$modal.msgSuccess(`新增成功,共 ${res.data.inserted} 条`);
+ open.value = false;
+ getList();
+ } else {
+ const missing = res.data?.missing || [];
+ const already = res.data?.alreadyInGroup || [];
+ if (missing.length) {
+ proxy.$modal.alertError(`以下耳号不存在:${missing.join(", ")}`);
+ } else if (already.length) {
+ proxy.$modal.alertWarning(`以下耳号已在该分组:${already.join(", ")}`);
+ } else {
+ proxy.$modal.alertWarning("所有羊只已存在于该分组");
+ }
+ }
+ })
+ .catch(() => proxy.$modal.msgError("系统异常,请联系管理员"));
+ });
}
+
/** 删除按钮操作 */
function handleDelete(row) {
const _ids = row.id || ids.value