feat(xumu): 新增体重管理功能

- 添加体重管理列表和新增页面
- 实现体重数据的查询、新增和编辑功能- 优化表格展示和搜索过滤
This commit is contained in:
aixianling
2024-12-26 18:01:44 +08:00
parent 0e35945d4a
commit e11d504f18
5 changed files with 281 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<script>
import add from "./add.vue";
import list from "./list.vue";
export default {
name: "AppWeightManage",
label: "体重管理",
props: {
instance: Function,
dict: Object,
permissions: Function
},
computed: {
currentPage() {
let {hash} = this.$route
return hash == "#add" ? add : list
}
},
data() {
return {}
}
}
</script>
<template>
<section class="AppWeightManage">
<component :is="currentPage" v-bind="$props"/>
</section>
</template>
<style scoped lang="scss">
.AppWeightManage {
height: 100%;
}
</style>

View File

@@ -0,0 +1,129 @@
<script>
import {mapState} from "vuex"
import AiSelect from "dui/packages/basic/AiSelect.vue";
import AiDialog from "dui/packages/basic/AiDialog.vue";
const columns = [
{label: "序号", type: "index"},
{label: "数据来源", prop: "source", dict: "source"},
{label: "重量", prop: "weight"},
{label: "称重时间", prop: "createTime"},
{label: "是否变更过", prop: "isUpdate", dict: "yesOrNo"},
]
export default {
name: "weightAdd",
components: {AiDialog, AiSelect},
props: {
instance: Function,
permissions: Function,
dict: Object
},
data() {
return {
detail: {detailList: []},
columns,
dialog: false,
}
},
computed: {
...mapState(["user"]),
userinfo: v => v.user.info || {},
pageTitle: v => {
const appName = v.$parent.menuName || v.$parent.$options.label
return v.$route.query.id ? v.isEdit ? `编辑${appName}` : `${appName}详情` : `新增${appName}`
},
},
methods: {
back(params = {}) {
this.$router.push(params)
},
getDetail() {
const {id} = this.$route.query
return id && this.instance.post("/api/breed/weight/getInfo", null, {params: {biochipEarNumber: id}}).then(res => {
if (res?.data) {
const detail = res.data
detail.detailList = detail.weightList || []
return this.detail = {...detail}
}
})
},
handleDelete(index) {
this.$confirm("确定删除该条数据?").then(() => {
this.detail.detailList.splice(index, 1)
})
},
submit() {
this.$refs.detail.validate().then(() => {
this.instance.post("/api/breed/weight/addOrEdit", this.detail).then(res => {
if (res?.code == 0) {
this.dialog = false
this.getDetail()
}
})
})
}
},
created() {
this.dict.load("yesOrNo", "category", "variety", "source")
this.getDetail()
}
}
</script>
<template>
<ai-page :title="pageTitle" class="weightAdd" showBack content-string="blank">
<el-form size="small" label-width="120px" :model="detail" ref="detail">
<ai-card title="基础信息">
<div class="grid c-4">
<el-form-item label="生物芯片耳标号">
<b v-text="detail.biochipEarNumber"/>
</el-form-item>
<el-form-item label="养殖场" prop="farmId">
<b v-text="detail.farmName"/>
</el-form-item>
<el-form-item label="养殖舍" prop="houseId">
<b v-text="detail.houseName"/>
</el-form-item>
<el-form-item label="养殖栏" prop="penId">
<b v-text="detail.penName"/>
</el-form-item>
<el-form-item label="类别" prop="penId">
<b v-text="detail.category"/>
</el-form-item>
<el-form-item label="品种" prop="penId">
<b v-text="detail.variety"/>
</el-form-item>
<el-form-item label="最近称重时间">
<b v-text="detail.lastCreateTime"/>
</el-form-item>
<el-form-item label="最新体重(公斤)">
<b v-text="detail.todayWeight||detail.lastWeight"/>
</el-form-item>
</div>
</ai-card>
<ai-card title="体重录入">
<el-button type="text" slot="right" @click="dialog=true">新增</el-button>
<ai-table :tableData="detail.detailList" :colConfigs="columns" :isShowPagination="!1">
<el-table-column slot="options" label="操作" fixed="right" align="center">
<template slot-scope="{row,$index}">
<div class="table-options">
<el-button type="text" class="deleteBtn" @click="handleDelete($index)">编辑</el-button>
<el-button type="text" class="deleteBtn" @click="handleDelete($index)">删除</el-button>
</div>
</template>
</el-table-column>
</ai-table>
</ai-card>
<ai-dialog v-model="dialog">
</ai-dialog>
</el-form>
<div slot="footer">
<el-button @click="back">返回</el-button>
</div>
</ai-page>
</template>
<style scoped lang="scss">
.weightAdd {
}
</style>

View File

@@ -0,0 +1,105 @@
<script>
import {mapState} from "vuex"
const columns = [
{label: "序号", type: "index"},
{label: "养殖场", prop: "userName", format: (v, row) => `${[row.farmName, row.houseName, row.penName].join("-")}`},
{label: "生物芯片耳标号", prop: "biochipEarNumber"},
{label: "类别", prop: "category", dict: "category"},
{label: "品种", prop: "variety", dict: "variety"},
{label: "称重日期", prop: "todayCreateTime", width: 160},
{label: "当日体重(公斤)", prop: "todayWeight", width: 120},
{label: "上次称重日期", prop: "lastCreateTime", width: 160},
{label: "上次体重(公斤)", prop: "lastWeight", width: 120},
]
export default {
name: "weightList",
props: {
instance: Function,
dict: Object,
permissions: Function
},
data() {
return {
columns,
tableData: [],
page: {pageNum: 1, pageSize: 10, total: 0},
search: {},
dialog: false,
form: {}
}
},
computed: {
...mapState(['user']),
userinfo: v => v.user.info || {},
pageTitle: v => v.$parent.menuName || v.$parent.$options.label
},
watch: {
search: {
deep: true,
handler() {
this.page.pageNum = 1
this.getTableData()
}
}
},
methods: {
getTableData() {
this.instance.post("/api/breed/weight/page", {...this.page, ...this.search}).then(res => {
if (res?.data) {
this.tableData = res.data?.records
this.page.total = res.data.total
}
})
},
},
created() {
this.dict.load("auditStatus", "category", "variety")
this.getTableData()
}
}
</script>
<template>
<ai-page class="weightList" :title="pageTitle">
<ai-search-bar>
<template #left>
<ai-select placeholder="全部养殖场" v-model="search.farmId" :instance="instance" :action="`/api/siteUser/querySiteByUserId?userId=${userinfo.id}`" :prop="{label:'name'}"/>
<ai-select placeholder="全部养殖舍" v-model="search.houseId" :instance="instance" :action="`/api/siteUser/querySiteById?id=${search.farmId||-1}`" :prop="{label:'name'}"/>
<ai-select placeholder="全部养殖栏" v-model="search.penId" :instance="instance" :action="`/api/siteUser/querySiteById?id=${search.houseId||-1}`" :prop="{label:'name'}"/>
<ai-select placeholder="全部类别" v-model="search.category" dict="category"/>
<ai-select placeholder="全部品种" v-model="search.variety" dict="variety"/>
<el-input placeholder="生物芯片耳标号" v-model="search.biochipEarNumber" dict="authStatus" size="small" clearable/>
<ai-search label="称重日期">
<el-date-picker v-model="search.weightBeginDate" type="datetime" placeholder="开始日期" size="small"/>
<el-date-picker v-model="search.weightEndDate" type="datetime" placeholder="结束日期" size="small"/>
</ai-search>
</template>
</ai-search-bar>
<ai-search-bar>
<template #left>
<ai-download :instance="instance" url="/api/breed/earTag/export" :params="{...search,...page}" :fileName="`称重导出表-${Date.now()}`"/>
</template>
</ai-search-bar>
<ai-table :tableData="tableData" :colConfigs="columns" :dict="dict" @gweightList="getTableData"
:total="page.total" :current.sync="page.pageNum" :size.sync="page.pageSize">
<el-table-column slot="options" label="操作" fixed="right" align="center">
<template slot-scope="{row}">
<div class="table-options">
<el-button type="text" @click="$router.push({hash:'#add',query:{id:row.biochipEarNumber}})">查看</el-button>
</div>
</template>
</el-table-column>
</ai-table>
</ai-page>
</template>
<style scoped lang="scss">
.weightList {
height: 100%;
.deleteBtn {
color: $errorColor;
}
}
</style>