Files
dvcp_v2_webapp/project/xumu/AppWeightManage/add.vue
aixianling 07a4d0637f refactor(xumu): 优化体重录入对话框样式和功能
- 调整对话框宽度为 50vw,提高可读性和美观性
- 为日期选择器添加 value-format 属性,确保日期格式一致性
- 将普通输入框替换为自定义的 ai-input 组件,提升用户体验
2025-01-08 15:05:55 +08:00

146 lines
4.9 KiB
Vue

<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: "dataSources"},
{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,
form: {}
}
},
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(id) {
this.$confirm("确定删除该条数据?").then(() => {
this.instance.post("/api/breed/weight/del", null, {
params: {id}
}).then(res => {
if (res?.code == 0) {
this.getDetail()
}
})
})
},
submit() {
this.$refs.detail.validate().then(() => {
this.form.biochipEarNumber = this.detail.biochipEarNumber
this.instance.post("/api/breed/weight/addOrEdit", null, {params: this.form}).then(res => {
if (res?.code == 0) {
this.dialog = false
this.getDetail()
}
})
})
}
},
created() {
this.dict.load("yesOrNo", "category", "variety", "dataSources")
this.getDetail()
}
}
</script>
<template>
<ai-page :title="pageTitle" class="weightAdd" showBack content-string="blank">
<el-form size="small" label-width="120px">
<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" @click="dialog=true,form=row">编辑</el-button>
<el-button type="text" class="deleteBtn" @click="handleDelete(row.id)">删除</el-button>
</div>
</template>
</el-table-column>
</ai-table>
</ai-card>
<ai-dialog v-model="dialog" title="体重录入" @closed="form={}" @confirm="submit" width="50vw">
<el-form size="small" label-width="120px" :model="form" ref="detail" class="grid">
<el-form-item label="办理时间" prop="createTime" :rules="[{required:true,message:'请选择办理时间'}]">
<el-date-picker v-model="form.createTime" :readonly="form.id" value-format="yyyy-MM-dd HH:mm:ss"/>
</el-form-item>
<el-form-item label="体重(公斤)" prop="weight" :rules="[{required:true,message:'请输入体重(公斤)'}]">
<ai-input v-model.number="form.weight"/>
</el-form-item>
</el-form>
</ai-dialog>
</el-form>
<div slot="footer">
<el-button @click="back">返回</el-button>
</div>
</ai-page>
</template>
<style scoped lang="scss">
.weightAdd {
}
</style>