增加档案管理及其基本功能,添加一些注释、优化标识符名称、优化交互逻辑

This commit is contained in:
bicey 2024-05-21 21:27:25 +08:00
parent 5b3019d967
commit 31bc249039
12 changed files with 710 additions and 325 deletions

View File

@ -1,4 +1,6 @@
<script> <script>
import {copy} from "@/utils/common.js";
export default { export default {
name: "ZooAnimalFormDialog", name: "ZooAnimalFormDialog",
data() { data() {
@ -16,25 +18,25 @@ export default {
features: '',// features: '',//
phase: '幼年期'// phase: '幼年期'//
}, },
formAction: {
idDisable:false,
}
} }
}, },
props: { props: {
animal: { data: {
type: Object, type: Object,
}, },
detail:{ detail:{
type: Boolean, type: Boolean,
default: false default: false
},
edit:{
type: Boolean,
default: false
} }
}, },
mounted() { mounted() {
// //
if (this.animal) { if (this.data) {
this.form = this.animal this.form = copy(this.data)
this.formAction.idDisable = true
} }
}, },
beforeUnmount() { beforeUnmount() {
@ -45,23 +47,8 @@ export default {
<template> <template>
<el-form label-width="auto"> <el-form label-width="auto">
<!-- <div>-->
<!-- animalForm:{-->
<!-- id: '',-->
<!-- name: '',-->
<!-- sex: '雄',-->
<!-- species: '',//-->
<!-- weight: 0,-->
<!-- height: 0,-->
<!-- state: 0,//0 1-->
<!-- roleId: null,//id-->
<!-- color: '',//-->
<!-- features: '',//-->
<!-- habit: ''//-->
<!-- }-->
<!-- </div>-->
<el-form-item label="动物ID"> <el-form-item label="动物ID">
<el-input v-model="form.id" placeholder="请设置动物ID" type="number" :disabled="formAction.idDisable || detail"/> <el-input v-model="form.id" placeholder="请设置动物ID" type="number" :disabled="edit || detail"/>
</el-form-item> </el-form-item>
<el-form-item label="动物名称"> <el-form-item label="动物名称">
<el-input v-model="form.name" placeholder="动物名称" :disabled="detail"/> <el-input v-model="form.name" placeholder="动物名称" :disabled="detail"/>

View File

@ -1,4 +1,6 @@
<script> <script>
import {copy} from "@/utils/common.js";
export default { export default {
name: "ZooArchiveFormDialog", name: "ZooArchiveFormDialog",
data() { data() {
@ -15,26 +17,25 @@ export default {
roleId: null,//id roleId: null,//id
description: '',// description: '',//
}, },
formAction: {
idDisable: false,
}
} }
}, },
props: { props: {
archive: { data: {
type: Object, type: Object,
}, },
detail: { detail: {
type: Boolean, type: Boolean,
default: false default: false
},
edit: {
type: Boolean,
default: false
} }
}, },
mounted() { mounted() {
// //
if (this.archive) { if (this.data) {
console.log('传入了数据') this.form = copy(this.data)
this.form = this.archive
this.formAction.idDisable = true
} }
}, },
beforeUnmount() { beforeUnmount() {
@ -46,7 +47,7 @@ export default {
<template> <template>
<el-form label-width="auto"> <el-form label-width="auto">
<el-form-item label="档案号"> <el-form-item label="档案号">
<el-input v-model="form.id" type="number" placeholder="记录号" :disabled="formAction.idDisable || detail"/> <el-input v-model="form.id" type="number" placeholder="记录号" :disabled="edit || detail"/>
</el-form-item> </el-form-item>
<el-form-item label="记录的动物ID"> <el-form-item label="记录的动物ID">
<el-input v-model="form.animalId" type="number" placeholder="记录的动物ID" :disabled="detail"/> <el-input v-model="form.animalId" type="number" placeholder="记录的动物ID" :disabled="detail"/>
@ -85,7 +86,8 @@ export default {
/> />
</el-form-item> </el-form-item>
<el-form-item label="记录时间"> <el-form-item label="记录时间">
<el-time-picker v-model="form.time" type="time" placeholder="选择时间" value-format="HH:mm:ss" :disabled="detail"/> <el-time-picker v-model="form.time" type="time" placeholder="选择时间" value-format="HH:mm:ss"
:disabled="detail"/>
</el-form-item> </el-form-item>
<el-form-item label="记录人ID"> <el-form-item label="记录人ID">
<el-input v-model="form.roleId" type="number" placeholder="记录人ID" :disabled="detail"/> <el-input v-model="form.roleId" type="number" placeholder="记录人ID" :disabled="detail"/>

View File

@ -1,11 +1,130 @@
<script> <script>
import {copy, sortByDateTime} from "@/utils/common.js";
export default { export default {
name: "ZooArchiveTimeline" name: "ZooArchiveTimeline",
data() {
return {
archives: [],
order:1
}
},
props: {
data: {
type: Object,
required:true
},
},
methods: {
sort(){
//
if (this.order===0){
this.order++
sortByDateTime(this.archives)
return
}
//
if (this.order===1){
this.order--
sortByDateTime(this.archives)
this.archives.reverse()
}
},
nodeType(type) {
if (type === '日常饲养') {
return 'success'
}
if (type === '疫苗接种') {
return 'primary'
}
if (type === '疾病治疗') {
return 'warning'
}
},
nodeHollow(state) {
if (state === 0) {
return false
}
if (state === 1) {
return true
}
}
},
mounted() {
//
if (this.data) {
this.archives = copy(this.data)
//
sortByDateTime(this.archives)
}
},
beforeUnmount() {
console.log('ZooArchiveTimeline-beforeUnmount', this);
}
} }
</script> </script>
<template> <template>
<div class="relative" style="height: 40px">
<el-button type="primary" class="right" @click="sort()">按时间升 / 降序</el-button>
</div>
<el-scrollbar height="500px">
<el-timeline style="max-width: 600px">
<el-timeline-item v-for="a in archives"
:type="nodeType(a.type)"
:hollow="nodeHollow(a.state)"
style="margin-top: 15px;margin-right: 20px">
<el-descriptions
:title="a.type"
:column="2"
size="small"
border
>
<template #extra>
<slot :archive="a" name="operate"></slot>
</template>
<el-descriptions-item>
<template #label>
动物名ID
</template>
{{ a.animalName }}{{a.animalId}}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
记录类型
</template>
{{ a.type }}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
生长阶段
</template>
{{ a.phase }}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
状态
</template>
<span v-if="a.state===0" style="color: green">正常</span>
<span v-else-if="a.state===1" style="color: red">异常</span>
<span v-else>未知</span>
</el-descriptions-item>
<el-descriptions-item>
<template #label>
描述
</template>
{{ a.description }}
</el-descriptions-item>
</el-descriptions>
<div class="left">记录号{{ a.id }}</div>
<div class="right">{{ a.roleId }} 记录于 {{ a.date }} {{ a.time }}</div>
</el-timeline-item>
</el-timeline>
</el-scrollbar>
<div class="right" style="margin-top: 10px">
<slot name="footer"></slot>
</div>
</template> </template>
<style scoped> <style scoped>

View File

@ -1,4 +1,6 @@
<script> <script>
import {copy} from "@/utils/common.js";
export default { export default {
name: "ZooBreedingFormDialog", name: "ZooBreedingFormDialog",
data() { data() {
@ -13,25 +15,25 @@ export default {
roleId: null,//id roleId: null,//id
describe: ''// describe: ''//
}, },
formAction: {
idDisable: false,
}
} }
}, },
props: { props: {
breedingPlan: { data: {
type: Object, type: Object,
}, },
detail: { detail: {
type: Boolean, type: Boolean,
default: false default: false
},
edit: {
type: Boolean,
default: false
} }
}, },
mounted() { mounted() {
// //
if (this.breedingPlan) { if (this.data) {
this.form = this.breedingPlan this.form = copy(this.data)
this.formAction.idDisable = true
} }
}, },
beforeUnmount() { beforeUnmount() {
@ -43,7 +45,7 @@ export default {
<template> <template>
<el-form label-width="auto"> <el-form label-width="auto">
<el-form-item label="饲养计划ID"> <el-form-item label="饲养计划ID">
<el-input v-model="form.id" type="number" placeholder="饲养计划ID" :disabled="formAction.idDisable || detail"/> <el-input v-model="form.id" type="number" placeholder="饲养计划ID" :disabled="edit || detail"/>
</el-form-item> </el-form-item>
<el-form-item label="计划名称"> <el-form-item label="计划名称">
<el-input v-model="form.name" placeholder="计划名称" :disabled="detail"/> <el-input v-model="form.name" placeholder="计划名称" :disabled="detail"/>

View File

@ -12,25 +12,25 @@ export default {
password: '', password: '',
auth: 0, auth: 0,
}, },
formAction: {
usernameDisable: false,
}
} }
}, },
props: { props: {
user: { data: {
type: Object, type: Object,
}, },
detail: { detail: {
type: Boolean, type: Boolean,
default: false default: false
},
edit:{
type: Boolean,
default: false
} }
}, },
mounted() { mounted() {
// //
if (this.user) { if (this.data) {
this.formAction.usernameDisable = true this.form = this.data
this.form = this.user
} }
}, },
beforeUnmount() { beforeUnmount() {
@ -43,22 +43,29 @@ export default {
<el-form label-width="auto"> <el-form label-width="auto">
<el-form-item label="用户ID"> <el-form-item label="用户ID">
<el-input v-model="form.id" placeholder="请设置用户ID" type="number" <el-input v-model="form.id" placeholder="请设置用户ID" type="number"
:disabled="formAction.usernameDisable || detail"/> :disabled="edit || detail"/>
</el-form-item> </el-form-item>
<el-form-item label="用户名"> <el-form-item label="用户名">
<el-input v-model="form.username" placeholder="请设置用户名" :disabled="detail"/> <el-input v-model="form.username" placeholder="请设置用户名" :disabled="detail"/>
</el-form-item> </el-form-item>
<el-form-item label="密码"> <el-form-item label="密码">
<div v-if="detail" @mouseover="showPassword($event,form.password)"
@mouseleave="hidePassword($event)">
</div>
<el-input <el-input
v-model="form.password" v-model="form.password"
type="password" type="password"
placeholder="请设置登录密码" placeholder="请设置登录密码"
show-password show-password
v-if="detail===false" v-else-if="edit"
/>
<el-input
v-model="form.password"
type="password"
placeholder="请设置登录密码"
show-password
v-else
/> />
<div v-else-if="detail===true" @mouseover="showPassword($event,form.password)"
@mouseleave="hidePassword($event)">
</div>
</el-form-item> </el-form-item>
<el-form-item label="身份"> <el-form-item label="身份">
<el-radio-group v-model="form.auth" :disabled="detail"> <el-radio-group v-model="form.auth" :disabled="detail">

View File

@ -1,24 +1,31 @@
<script> <script>
import {copy, fuzzyMatching, splitKeyWords} from "@/utils/common.js"; import {copy, fuzzyMatching, splitKeyWords} from "@/utils/common.js";
import {Delete, Document, DocumentAdd,Edit, Search} from "@element-plus/icons-vue"; import {Delete, Document, DocumentAdd, Edit, Search, Tickets} from "@element-plus/icons-vue";
import ZooAnimalFormDialog from "@/components/ZooAnimalFormDialog.vue"; import ZooAnimalFormDialog from "@/components/ZooAnimalFormDialog.vue";
import {mapActions,mapState} from "vuex"; import {mapActions,mapState} from "vuex";
import ZooArchiveTimeline from "@/components/ZooArchiveTimeline.vue";
export default { export default {
name: "ZooAnimal", name: "ZooAnimal",
components: {ZooAnimalFormDialog}, components: {ZooArchiveTimeline, ZooAnimalFormDialog},
data() { data() {
return { return {
tableData: [], tableData: [],//
//
searchInput: { searchInput: {
state: '',//0 1 option: '',//0 1
keyword: '' keyword: ''
}, },
//
dialog: { dialog: {
addDialogVisible: false,// dialogData: {},//
editDialogVisible: false,// addDialogVisible: false,//
editData: {}, editDialogVisible: false,//
detailDialogVisible: false,// detailDialogVisible: false,//
timelineDialogVisible:false,//线
timelineData:[]//线
} }
} }
}, },
@ -40,45 +47,55 @@ export default {
DocumentAdd() { DocumentAdd() {
return DocumentAdd return DocumentAdd
}, },
Tickets() {
return Tickets
},
//endregion //endregion
...mapState(["animals"]) ...mapState(["animals",'archives'])
}, },
watch: { watch: {
//
searchInput: { searchInput: {
deep: true, deep: true,
handler(val) { handler(val) {
this.searchAnimal(); this.search();
} }
} }
}, },
methods: { methods: {
...mapActions(["getAnimals"]), ...mapActions(["getAnimals"]),
showDetailDialog(animal) {
//使animalid //
this.dialog.editData = this.animals.find(e => e.id === animal.id) showDetail(data) {
console.log('点击了动物详情', this.dialog.editData) console.log('显示详情', data)
//
//
this.dialog.dialogData = this.animals.find(e => e.id === data.id)
//
this.dialog.detailDialogVisible = true this.dialog.detailDialogVisible = true
}, },
showEditDialog(animal) {
//使animalid //
this.dialog.editData = this.animals.find(e => e.id === animal.id) showEdit(data) {
console.log('点击了动物编辑', this.dialog.editData) console.log('显示编辑', data)
//
//
this.dialog.dialogData = this.animals.find(e => e.id === data.id)
//
this.dialog.editDialogVisible = true this.dialog.editDialogVisible = true
}, },
edit(data) {
console.log('编辑', data)
// //
isEmpty(form) { return this.isEmpty(data);
if (!form.name) {
// //
return ElMessage({
message: '动物名不能为空',
type: 'warning',
})
}
},
editAnimal(form) {
console.log('确认编辑动物', form)
//
return this.isEmpty(form);
// //
if (false) { if (false) {
return ElMessage({ return ElMessage({
@ -86,6 +103,7 @@ export default {
type: 'warning', type: 'warning',
}) })
} }
// //
if (false) { if (false) {
return ElMessage({ return ElMessage({
@ -93,14 +111,20 @@ export default {
type: 'success', type: 'success',
}) })
} }
//
this.dialog.editDialogVisible = false// //
this.getAnimals()
//
this.dialog.editDialogVisible = false
}, },
deleteAnimal(animal) {
console.log('删除动物', animal) delete_(data) {
console.log('删除', data)
return ElMessageBox.confirm( return ElMessageBox.confirm(
'该操作不可撤销,是否继续?', '该操作不可撤销,是否继续?',
'删除动物:' + animal.name, '删除动物:' + data.name + ''+data.id+'',
{ {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
@ -108,7 +132,11 @@ export default {
} }
).then(() => { ).then(() => {
// //
//
//
this.getAnimals()
//
ElMessage({ ElMessage({
type: 'success', type: 'success',
message: '删除成功', message: '删除成功',
@ -120,10 +148,15 @@ export default {
}) })
}) })
}, },
addAnimal(form) {
console.log('添加动物', form) add(data) {
console.log('添加', data)
// //
return this.isEmpty(form); return this.isEmpty(data);
//
// //
if (false) { if (false) {
return ElMessage({ return ElMessage({
@ -139,16 +172,47 @@ export default {
}) })
} }
// //
this.getAnimals()
this.dialog.addDialogVisible = false// this.dialog.addDialogVisible = false//
}, },
searchAnimal() {
console.log('动物搜索', this.searchInput) //线
showArchives(data) {
console.log('显示档案', data)
this.dialog.timelineData = []
//
//
this.archives.forEach(e=>{
if (e.animalId === data.id) {
this.dialog.timelineData.push(e)
}
})
//
this.dialog.timelineDialogVisible = true
},
//
isEmpty(form) {
if (!form.name) {
//
return ElMessage({
message: '动物名不能为空',
type: 'warning',
})
}
},
search() {
console.log('搜索', this.searchInput)
let searchResult = []// let searchResult = []//
//
if (typeof this.searchInput.state === 'number') { //
if (typeof this.searchInput.option === 'number') {
this.animals.forEach(e => { this.animals.forEach(e => {
if (e.state === this.searchInput.state) { if (e.state === this.searchInput.option) {
searchResult.push(copy(e))// searchResult.push(copy(e))//
} }
}) })
@ -175,8 +239,11 @@ export default {
}, },
}, },
mounted() { mounted() {
//
this.getAnimals() this.getAnimals()
this.tableData = copy(this.animals);//
//
this.tableData = copy(this.animals);
} }
} }
</script> </script>
@ -194,14 +261,14 @@ export default {
placeholder="搜索动物 空格隔开关键字" placeholder="搜索动物 空格隔开关键字"
> >
<template #prepend> <template #prepend>
<el-select v-model="searchInput.state" placeholder="状态" style="width: 80px"> <el-select v-model="searchInput.option" placeholder="状态" style="width: 80px">
<el-option label="不选择" value=""/> <el-option label="不选择" value=""/>
<el-option label="正常" :value="0"/> <el-option label="正常" :value="0"/>
<el-option label="异常" :value="1"/> <el-option label="异常" :value="1"/>
</el-select> </el-select>
</template> </template>
<template #append> <template #append>
<el-button :icon="Search" @click="searchAnimal()"/> <el-button :icon="Search" @click="search()"/>
</template> </template>
</el-input> </el-input>
</div> </div>
@ -209,7 +276,7 @@ export default {
<!-- <hr/>--> <!-- <hr/>-->
<div class="table"> <div class="table">
<el-table :data="tableData" style="width: 100%;height: 100%" empty-text="暂无数据" border> <el-table :data="tableData" style="width: 100%;height: 100%" empty-text="暂无数据" border stripe>
<el-table-column fixed prop="id" label="动物ID" width="70"/> <el-table-column fixed prop="id" label="动物ID" width="70"/>
<el-table-column fixed prop="name" label="动物名称" width="100"/> <el-table-column fixed prop="name" label="动物名称" width="100"/>
<el-table-column prop="sex" label="性别" width="60"/> <el-table-column prop="sex" label="性别" width="60"/>
@ -232,15 +299,18 @@ export default {
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="features" label="动物特征" width="200"/> <el-table-column prop="features" label="动物特征" width="200"/>
<el-table-column fixed="right" label="操作" width="190"> <el-table-column fixed="right" label="操作" width="250">
<template #default="scope"> <template #default="scope">
<el-button link type="primary" size="small" :icon="Document" @click="showDetailDialog(scope.row)"> <el-button link type="success" size="small" :icon="Tickets" @click="showArchives(scope.row)">
档案
</el-button>
<el-button link type="primary" size="small" :icon="Document" @click="showDetail(scope.row)">
详情 详情
</el-button> </el-button>
<el-button link type="primary" size="small" :icon="Edit" @click="showEditDialog(scope.row)"> <el-button link type="primary" size="small" :icon="Edit" @click="showEdit(scope.row)">
编辑 编辑
</el-button> </el-button>
<el-button link type="danger" size="small" :icon="Delete" @click="deleteAnimal(scope.row)"> <el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)">
删除 删除
</el-button> </el-button>
</template> </template>
@ -256,7 +326,7 @@ export default {
<el-button @click="dialog.addDialogVisible = false"> <el-button @click="dialog.addDialogVisible = false">
取消 取消
</el-button> </el-button>
<el-button type="primary" @click="addAnimal(scope.form)"> <el-button type="primary" @click="add(scope.form)">
添加 添加
</el-button> </el-button>
</template> </template>
@ -266,12 +336,12 @@ export default {
<!-- 编辑动物对话框--> <!-- 编辑动物对话框-->
<el-dialog v-model="dialog.editDialogVisible" title="编辑动物" width="500" align-center draggable overflow <el-dialog v-model="dialog.editDialogVisible" title="编辑动物" width="500" align-center draggable overflow
destroy-on-close> destroy-on-close>
<ZooAnimalFormDialog :animal="dialog.editData"> <ZooAnimalFormDialog :data="dialog.dialogData" edit>
<template #default="scope"> <template #default="scope">
<el-button @click="dialog.editDialogVisible = false"> <el-button @click="dialog.editDialogVisible = false">
取消 取消
</el-button> </el-button>
<el-button type="primary" @click="editAnimal(scope.form)"> <el-button type="primary" @click="edit(scope.form)">
修改 修改
</el-button> </el-button>
</template> </template>
@ -281,7 +351,7 @@ export default {
<!-- 查看动物对话框--> <!-- 查看动物对话框-->
<el-dialog v-model="dialog.detailDialogVisible" title="查询动物" width="500" align-center draggable overflow <el-dialog v-model="dialog.detailDialogVisible" title="查询动物" width="500" align-center draggable overflow
destroy-on-close> destroy-on-close>
<ZooAnimalFormDialog :animal="dialog.editData" detail> <ZooAnimalFormDialog :data="dialog.dialogData" detail>
<template #default="scope"> <template #default="scope">
<el-button @click="dialog.detailDialogVisible = false"> <el-button @click="dialog.detailDialogVisible = false">
关闭 关闭
@ -289,6 +359,22 @@ export default {
</template> </template>
</ZooAnimalFormDialog> </ZooAnimalFormDialog>
</el-dialog> </el-dialog>
<!--查看动物所有记录-->
<el-dialog v-model="dialog.timelineDialogVisible" :title="'动物档案'" width="600" align-center draggable overflow
destroy-on-close>
<ZooArchiveTimeline :data="dialog.timelineData">
<!-- <template #operate="scope">-->
<!-- <el-button type="primary" link @click="showEdit(scope.archive)">编辑</el-button>-->
<!-- <el-button type="danger" link @click="delete_(scope.archive)">删除</el-button>-->
<!-- </template>-->
<template #footer>
<el-button @click="dialog.timelineDialogVisible = false">
关闭
</el-button>
</template>
</ZooArchiveTimeline>
</el-dialog>
</template> </template>
<style scoped> <style scoped>

View File

@ -1,24 +1,31 @@
<script> <script>
import ZooArchiveFormDialog from "@/components/ZooArchiveFormDialog.vue"; import ZooArchiveFormDialog from "@/components/ZooArchiveFormDialog.vue";
import {Delete, DocumentAdd, Document,Edit, Search} from "@element-plus/icons-vue"; import {Delete, DocumentAdd, Document, Edit, Search, Tickets} from "@element-plus/icons-vue";
import {mapState,mapActions} from "vuex"; import {mapState,mapActions} from "vuex";
import {copy, splitKeyWords, fuzzyMatching, sortByDateTime} from "@/utils/common.js"; import {copy, splitKeyWords, fuzzyMatching, sortByDateTime} from "@/utils/common.js";
import ZooArchiveTimeline from "@/components/ZooArchiveTimeline.vue";
export default { export default {
name: "ZooArchive", name: "ZooArchive",
components: {ZooArchiveFormDialog}, components: {ZooArchiveTimeline, ZooArchiveFormDialog},
data() { data() {
return { return {
tableData: [], tableData: [],//
//
searchInput: { searchInput: {
state: '',//0 1 option: '',//0 1
keyword: '' keyword: ''
}, },
//
dialog: { dialog: {
dialogData: {},//
addDialogVisible: false,// addDialogVisible: false,//
editDialogVisible: false,// editDialogVisible: false,//
editData: {}, detailDialogVisible:false,//
detailDialogVisible:false// timelineDialogVisible:false,//线
timelineData:[]//线
} }
} }
}, },
@ -40,45 +47,55 @@ export default {
Document() { Document() {
return Document return Document
}, },
Tickets() {
return Tickets
},
//endregion //endregion
...mapState(["archives"]) ...mapState(["archives"])
}, },
watch: { watch: {
//
searchInput: { searchInput: {
deep: true, deep: true,
handler(val) { handler(val) {
this.searchArchive(); this.search();
} }
} }
}, },
methods: { methods: {
...mapActions(["getArchives"]), ...mapActions(["getArchives"]),
showDetailDialog(archive) {
//使id //
this.dialog.editData = this.archives.find(e => e.id === archive.id) showDetail(data) {
console.log('点击了详情', this.dialog.editData) console.log('显示详情', data)
//
//
this.dialog.dialogData = this.archives.find(e => e.id === data.id)
//
this.dialog.detailDialogVisible = true this.dialog.detailDialogVisible = true
}, },
showEditDialog(archive) {
//使id //
this.dialog.editData = this.archives.find(e => e.id === archive.id) showEdit(data) {
console.log('点击了编辑', this.dialog.editData) console.log('显示编辑', data)
//
//
this.dialog.dialogData = this.archives.find(e => e.id === data.id)
//
this.dialog.editDialogVisible = true this.dialog.editDialogVisible = true
}, },
edit(data) {
console.log('编辑', data)
// //
isEmpty(form) { return this.isEmpty(data);
if (!form.animalId) {
// //
return ElMessage({
message: '记录的动物ID不能为空',
type: 'warning',
})
}
},
editArchive(form) {
console.log('确认编辑档案', form)
//
return this.isEmpty(form);
// //
if (false) { if (false) {
return ElMessage({ return ElMessage({
@ -86,6 +103,7 @@ export default {
type: 'warning', type: 'warning',
}) })
} }
// //
if (false) { if (false) {
return ElMessage({ return ElMessage({
@ -93,15 +111,20 @@ export default {
type: 'success', type: 'success',
}) })
} }
//
//
this.getArchives() this.getArchives()
this.dialog.editDialogVisible = false//
//
this.dialog.editDialogVisible = false
}, },
deleteArchive(archive) {
console.log('删除档案', archive) delete_(data) {
console.log('删除', data)
return ElMessageBox.confirm( return ElMessageBox.confirm(
'该操作不可撤销,是否继续?', '该操作不可撤销,是否继续?',
'删除档案:' + archive.id, '删除记录:' +data.id,
{ {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
@ -109,7 +132,11 @@ export default {
} }
).then(() => { ).then(() => {
// //
//
//
this.getArchives()
//
ElMessage({ ElMessage({
type: 'success', type: 'success',
message: '删除成功', message: '删除成功',
@ -121,14 +148,19 @@ export default {
}) })
}) })
}, },
addArchive(form) {
console.log('添加档案', form) add(data) {
console.log('添加', data)
// //
return this.isEmpty(form); return this.isEmpty(data);
//
// //
if (false) { if (false) {
return ElMessage({ return ElMessage({
message: '该饲养计划已存在', message: '该记录已存在',
type: 'warning', type: 'warning',
}) })
} }
@ -140,15 +172,47 @@ export default {
}) })
} }
// //
this.getArchives()
this.dialog.addDialogVisible = false// this.dialog.addDialogVisible = false//
}, },
searchArchive() {
console.log('档案搜索', this.searchInput) //线
let searchResult = []// showArchives(data) {
// console.log('显示档案', data)
if (typeof this.searchInput.state === 'number') {
this.dialog.timelineData = []
//
//
this.archives.forEach(e=>{ this.archives.forEach(e=>{
if (e.state === this.searchInput.state) { if (e.animalId === data.animalId) {
this.dialog.timelineData.push(e)
}
})
//
this.dialog.timelineDialogVisible = true
},
//
isEmpty(form) {
if (!form.animalId) {
//
return ElMessage({
message: '记录的动物ID不能为空',
type: 'warning',
})
}
},
search() {
console.log('搜索', this.searchInput)
let searchResult = []//
//
if (typeof this.searchInput.option === 'number') {
this.archives.forEach(e => {
if (e.state === this.searchInput.option) {
searchResult.push(copy(e))// searchResult.push(copy(e))//
} }
}) })
@ -175,8 +239,11 @@ export default {
}, },
}, },
mounted() { mounted() {
//
this.getArchives() this.getArchives()
this.tableData = copy(this.archives);//
//
this.tableData = copy(this.archives);
} }
} }
</script> </script>
@ -194,21 +261,21 @@ export default {
placeholder="搜索记录 空格隔开关键字" placeholder="搜索记录 空格隔开关键字"
> >
<template #prepend> <template #prepend>
<el-select v-model="searchInput.state" placeholder="状态" style="width: 80px"> <el-select v-model="searchInput.option" placeholder="状态" style="width: 80px">
<el-option label="不选择" value=""/> <el-option label="不选择" value=""/>
<el-option label="正常" :value="0"/> <el-option label="正常" :value="0"/>
<el-option label="异常" :value="1"/> <el-option label="异常" :value="1"/>
</el-select> </el-select>
</template> </template>
<template #append> <template #append>
<el-button :icon="Search" @click="searchArchive()"/> <el-button :icon="Search" @click="search()"/>
</template> </template>
</el-input> </el-input>
</div> </div>
</div> </div>
<div class="table"> <div class="table">
<el-table :data="tableData" style="width: 100%;height: 100%" empty-text="暂无数据" border> <el-table :data="tableData" style="width: 100%;height: 100%" empty-text="暂无数据" border stripe :default-sort="{prop: 'date', order: 'descending'}">
<el-table-column fixed prop="id" label="记录号" width="100"/> <el-table-column fixed prop="id" label="记录号" width="100"/>
<el-table-column fixed prop="animalId" label="记录的动物ID" width="120"/> <el-table-column fixed prop="animalId" label="记录的动物ID" width="120"/>
<el-table-column prop="animalName" label="记录的动物名" width="110"/> <el-table-column prop="animalName" label="记录的动物名" width="110"/>
@ -221,19 +288,22 @@ export default {
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="type" label="记录类型" width="90"/> <el-table-column prop="type" label="记录类型" width="90"/>
<el-table-column prop="date" label="记录日期" width="110"/> <el-table-column prop="date" label="记录日期" width="110" sortable/>
<el-table-column prop="time" label="记录时间" width="90" /> <el-table-column prop="time" label="记录时间" width="90" />
<el-table-column prop="roleId" label="记录人ID" width="90"/> <el-table-column prop="roleId" label="记录人ID" width="90"/>
<el-table-column prop="describe" label="记录描述" width="300"/> <el-table-column prop="describe" label="记录描述" width="300"/>
<el-table-column fixed="right" label="操作" width="190"> <el-table-column fixed="right" label="操作" width="250">
<template #default="scope"> <template #default="scope">
<el-button link type="primary" size="small" :icon="Document" @click="showDetailDialog(scope.row)"> <el-button link type="success" size="small" :icon="Tickets" @click="showArchives(scope.row)">
查询 档案
</el-button> </el-button>
<el-button link type="primary" size="small" :icon="Edit" @click="showEditDialog(scope.row)"> <el-button link type="primary" size="small" :icon="Document" @click="showDetail(scope.row)">
详情
</el-button>
<el-button link type="primary" size="small" :icon="Edit" @click="showEdit(scope.row)">
编辑 编辑
</el-button> </el-button>
<el-button link type="danger" size="small" :icon="Delete" @click="deleteArchive(scope.row)"> <el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)">
删除 删除
</el-button> </el-button>
</template> </template>
@ -249,7 +319,7 @@ export default {
<el-button @click="dialog.addDialogVisible = false"> <el-button @click="dialog.addDialogVisible = false">
取消 取消
</el-button> </el-button>
<el-button type="primary" @click="addArchive(scope.form)"> <el-button type="primary" @click="add(scope.form)">
添加 添加
</el-button> </el-button>
</template> </template>
@ -257,14 +327,14 @@ export default {
</el-dialog> </el-dialog>
<!-- 编辑记录对话框--> <!-- 编辑记录对话框-->
<el-dialog v-model="dialog.editDialogVisible" title="编辑饲养计划" width="500" align-center draggable overflow <el-dialog v-model="dialog.editDialogVisible" title="编辑记录" width="500" align-center draggable overflow
destroy-on-close> destroy-on-close>
<ZooArchiveFormDialog :archive="dialog.editData"> <ZooArchiveFormDialog :data="dialog.dialogData" edit>
<template #default="scope"> <template #default="scope">
<el-button @click="dialog.editDialogVisible = false"> <el-button @click="dialog.editDialogVisible = false">
取消 取消
</el-button> </el-button>
<el-button type="primary" @click="editArchive(scope.form)"> <el-button type="primary" @click="edit(scope.form)">
修改 修改
</el-button> </el-button>
</template> </template>
@ -272,9 +342,9 @@ export default {
</el-dialog> </el-dialog>
<!-- 查看记录对话框--> <!-- 查看记录对话框-->
<el-dialog v-model="dialog.detailDialogVisible" title="查询饲养计划" width="500" align-center draggable overflow <el-dialog v-model="dialog.detailDialogVisible" title="查询记录" width="500" align-center draggable overflow
destroy-on-close> destroy-on-close>
<ZooArchiveFormDialog :archive="dialog.editData" detail> <ZooArchiveFormDialog :data="dialog.dialogData" detail>
<template #default="scope"> <template #default="scope">
<el-button @click="dialog.detailDialogVisible = false"> <el-button @click="dialog.detailDialogVisible = false">
关闭 关闭
@ -282,7 +352,25 @@ export default {
</template> </template>
</ZooArchiveFormDialog> </ZooArchiveFormDialog>
</el-dialog> </el-dialog>
<!--查看动物所有记录-->
<el-dialog v-model="dialog.timelineDialogVisible" :title="'动物档案'" width="600" align-center draggable overflow
destroy-on-close>
<ZooArchiveTimeline :data="dialog.timelineData">
<template #operate="scope">
<el-button type="primary" link @click="showEdit(scope.archive)">编辑</el-button>
<el-button type="danger" link @click="delete_(scope.archive)">删除</el-button>
</template> </template>
<template #footer>
<el-button @click="dialog.timelineDialogVisible = false">
关闭
</el-button>
</template>
</ZooArchiveTimeline>
</el-dialog>
</template>
<style scoped> <style scoped>

View File

@ -9,15 +9,19 @@ export default {
components: {ZooBreedingPlanFormDialog}, components: {ZooBreedingPlanFormDialog},
data() { data() {
return { return {
tableData: [], tableData: [],//
//
searchInput: { searchInput: {
state: '',//0 1 option: '',//0 1
keyword: '' keyword: ''
}, },
//
dialog: { dialog: {
dialogData: {},
addDialogVisible: false,// addDialogVisible: false,//
editDialogVisible: false,// editDialogVisible: false,//
editData: {},
detailDialogVisible:false// detailDialogVisible:false//
} }
} }
@ -44,41 +48,48 @@ export default {
...mapState(["breedingPlans"]) ...mapState(["breedingPlans"])
}, },
watch: { watch: {
//
searchInput: { searchInput: {
deep: true, deep: true,
handler(val) { handler(val) {
this.searchBreedingPlan(); this.search();
} }
} }
}, },
methods: { methods: {
...mapActions(["getBreedingPlans"]), ...mapActions(["getBreedingPlans"]),
showDetailDialog(breedingPlan) {
//使id //
this.dialog.editData = this.breedingPlans.find(e => e.id === breedingPlan.id) showDetail(data) {
console.log('点击了详情', this.dialog.editData) console.log('显示详情', data)
//
//
this.dialog.dialogData = this.breedingPlans.find(e => e.id === data.id)
//
this.dialog.detailDialogVisible = true this.dialog.detailDialogVisible = true
}, },
showEditDialog(breedingPlan) {
//使id //
this.dialog.editData = this.breedingPlans.find(e => e.id === breedingPlan.id) showEdit(data) {
console.log('点击了编辑', this.dialog.editData) console.log('显示编辑', data)
//
//
this.dialog.dialogData = this.breedingPlans.find(e => e.id === data.id)
//
this.dialog.editDialogVisible = true this.dialog.editDialogVisible = true
}, },
edit(data) {
console.log('编辑', data)
// //
isEmpty(form) { return this.isEmpty(data);
if (!form.name) {
// //
return ElMessage({
message: '计划名不能为空',
type: 'warning',
})
}
},
editBreedingPlan(form) {
console.log('确认编辑饲养计划', form)
//
return this.isEmpty(form);
// //
if (false) { if (false) {
return ElMessage({ return ElMessage({
@ -86,6 +97,7 @@ export default {
type: 'warning', type: 'warning',
}) })
} }
// //
if (false) { if (false) {
return ElMessage({ return ElMessage({
@ -93,15 +105,20 @@ export default {
type: 'success', type: 'success',
}) })
} }
//
//
this.getBreedingPlans() this.getBreedingPlans()
this.dialog.editDialogVisible = false//
//
this.dialog.editDialogVisible = false
}, },
deleteBreedingPlan(breedingPlan) {
console.log('删除饲养计划', breedingPlan) delete_(data) {
console.log('删除', data)
return ElMessageBox.confirm( return ElMessageBox.confirm(
'该操作不可撤销,是否继续?', '该操作不可撤销,是否继续?',
'删除饲养计划:' + breedingPlan.name, '删除计划:' + data.name + ''+data.id+'',
{ {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
@ -109,7 +126,11 @@ export default {
} }
).then(() => { ).then(() => {
// //
//
//
this.getBreedingPlans()
//
ElMessage({ ElMessage({
type: 'success', type: 'success',
message: '删除成功', message: '删除成功',
@ -121,14 +142,19 @@ export default {
}) })
}) })
}, },
addBreedingPlan(form) {
console.log('添加饲养计划', form) add(data) {
console.log('添加', data)
// //
return this.isEmpty(form); return this.isEmpty(data);
//
// //
if (false) { if (false) {
return ElMessage({ return ElMessage({
message: '该饲养计划已存在', message: '该计划已存在',
type: 'warning', type: 'warning',
}) })
} }
@ -140,15 +166,30 @@ export default {
}) })
} }
// //
this.getBreedingPlans()
this.dialog.addDialogVisible = false// this.dialog.addDialogVisible = false//
}, },
searchBreedingPlan() {
console.log('饲养计划搜索', this.searchInput) //
isEmpty(form) {
if (!form.name) {
//
return ElMessage({
message: '计划名不能为空',
type: 'warning',
})
}
},
search() {
console.log('搜索', this.searchInput)
let searchResult = []// let searchResult = []//
// //
if (typeof this.searchInput.state === 'number') { if (typeof this.searchInput.option === 'number') {
this.breedingPlans.forEach(e => { this.breedingPlans.forEach(e => {
if (e.state === this.searchInput.state) { if (e.state === this.searchInput.option) {
searchResult.push(copy(e))// searchResult.push(copy(e))//
} }
}) })
@ -175,8 +216,11 @@ export default {
}, },
}, },
mounted() { mounted() {
//
this.getBreedingPlans() this.getBreedingPlans()
this.tableData = copy(this.breedingPlans);//
//
this.tableData = copy(this.breedingPlans);
} }
} }
</script> </script>
@ -194,29 +238,21 @@ export default {
placeholder="搜索饲养计划 空格隔开关键字" placeholder="搜索饲养计划 空格隔开关键字"
> >
<template #prepend> <template #prepend>
<el-select v-model="searchInput.state" placeholder="状态" style="width: 80px"> <el-select v-model="searchInput.option" placeholder="状态" style="width: 80px">
<el-option label="不选择" value=""/> <el-option label="不选择" value=""/>
<el-option label="正常" :value="0"/> <el-option label="正常" :value="0"/>
<el-option label="异常" :value="1"/> <el-option label="异常" :value="1"/>
</el-select> </el-select>
</template> </template>
<template #append> <template #append>
<el-button :icon="Search" @click="searchBreedingPlan()"/> <el-button :icon="Search" @click="search()"/>
</template> </template>
</el-input> </el-input>
</div> </div>
</div> </div>
<!-- <hr/>-->
<!-- id: '',//int id-->
<!-- name: '',// -->
<!-- species: '',// -->
<!-- sex: '雄性',// -->
<!-- phase: '',// -->
<!-- state: 0,//int 0 1-->
<!-- describe: ''// -->
<div class="table"> <div class="table">
<el-table :data="tableData" style="width: 100%;height: 100%" empty-text="暂无数据" border> <el-table :data="tableData" style="width: 100%;height: 100%" empty-text="暂无数据" border stripe>
<el-table-column fixed prop="id" label="饲养计划ID" width="100"/> <el-table-column fixed prop="id" label="饲养计划ID" width="100"/>
<el-table-column fixed prop="name" label="饲养计划名称" width="200"/> <el-table-column fixed prop="name" label="饲养计划名称" width="200"/>
<el-table-column prop="roleId" label="执行饲养员" width="100"/> <el-table-column prop="roleId" label="执行饲养员" width="100"/>
@ -233,13 +269,13 @@ export default {
<el-table-column prop="describe" label="计划描述" width="300"/> <el-table-column prop="describe" label="计划描述" width="300"/>
<el-table-column fixed="right" label="操作" width="190"> <el-table-column fixed="right" label="操作" width="190">
<template #default="scope"> <template #default="scope">
<el-button link type="primary" size="small" :icon="Document" @click="showDetailDialog(scope.row)"> <el-button link type="primary" size="small" :icon="Document" @click="showDetail(scope.row)">
详情 详情
</el-button> </el-button>
<el-button link type="primary" size="small" :icon="Edit" @click="showEditDialog(scope.row)"> <el-button link type="primary" size="small" :icon="Edit" @click="showEdit(scope.row)">
编辑 编辑
</el-button> </el-button>
<el-button link type="danger" size="small" :icon="Delete" @click="deleteBreedingPlan(scope.row)"> <el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)">
删除 删除
</el-button> </el-button>
</template> </template>
@ -255,7 +291,7 @@ export default {
<el-button @click="dialog.addDialogVisible = false"> <el-button @click="dialog.addDialogVisible = false">
取消 取消
</el-button> </el-button>
<el-button type="primary" @click="addBreedingPlan(scope.form)"> <el-button type="primary" @click="add(scope.form)">
添加 添加
</el-button> </el-button>
</template> </template>
@ -265,12 +301,12 @@ export default {
<!-- 编辑饲养计划对话框--> <!-- 编辑饲养计划对话框-->
<el-dialog v-model="dialog.editDialogVisible" title="编辑饲养计划" width="500" align-center draggable overflow <el-dialog v-model="dialog.editDialogVisible" title="编辑饲养计划" width="500" align-center draggable overflow
destroy-on-close> destroy-on-close>
<ZooBreedingPlanFormDialog :breedingPlan="dialog.editData"> <ZooBreedingPlanFormDialog :data="dialog.dialogData" edit>
<template #default="scope"> <template #default="scope">
<el-button @click="dialog.editDialogVisible = false"> <el-button @click="dialog.editDialogVisible = false">
取消 取消
</el-button> </el-button>
<el-button type="primary" @click="editBreedingPlan(scope.form)"> <el-button type="primary" @click="edit(scope.form)">
修改 修改
</el-button> </el-button>
</template> </template>
@ -280,7 +316,7 @@ export default {
<!-- 查看饲养计划对话框--> <!-- 查看饲养计划对话框-->
<el-dialog v-model="dialog.detailDialogVisible" title="查询饲养计划" width="500" align-center draggable overflow <el-dialog v-model="dialog.detailDialogVisible" title="查询饲养计划" width="500" align-center draggable overflow
destroy-on-close> destroy-on-close>
<ZooBreedingPlanFormDialog :breedingPlan="dialog.editData" detail> <ZooBreedingPlanFormDialog :data="dialog.dialogData" detail>
<template #default="scope"> <template #default="scope">
<el-button @click="dialog.detailDialogVisible = false"> <el-button @click="dialog.detailDialogVisible = false">
关闭 关闭

View File

@ -6,7 +6,8 @@ export default {
name: "ZooContainer", name: "ZooContainer",
data() { data() {
return { return {
user: { //
form: {
username: '', username: '',
password: '123456', password: '123456',
} }
@ -18,9 +19,11 @@ export default {
methods: { methods: {
...mapActions(['getLoginUser']), ...mapActions(['getLoginUser']),
...mapMutations(['updateLoginUser']), ...mapMutations(['updateLoginUser']),
onSubmit() { //
console.log('点击了登录按钮') login() {
if (!this.user.username || !this.user.password) { console.log('登录',this.form)
//
if (!this.form.username || !this.form.password) {
// //
return ElMessage({ return ElMessage({
message: '用户名和密码不能为空', message: '用户名和密码不能为空',
@ -28,20 +31,28 @@ export default {
}) })
} }
this.getLoginUser(this.user)// //
this.getLoginUser(this.form)//
// //
if (this.loginUser) { if (this.loginUser) {
localStorage.setItem('username', this.loginUser.username);// localStorage.setItem('username', this.loginUser.username);//
//
this.$router.push('/panel/home') this.$router.push('/panel/home')
} }
}, },
//
reset() { reset() {
this.user = {} this.form = {}
}, },
}, },
mounted() { mounted() {
this.updateLoginUser('');//退 //退
this.user.username = localStorage.getItem('username');// this.updateLoginUser('');
//
this.form.username = localStorage.getItem('username');
} }
} }
@ -49,20 +60,22 @@ export default {
<template> <template>
<div id="login-root"> <div id="login-root">
<!-- 背景图片-->
<el-carousel height="400px" motion-blur> <el-carousel height="400px" motion-blur>
<el-carousel-item v-for="item in 4" :key="item"> <el-carousel-item v-for="item in 4" :key="item">
<h3 class="small justify-center" text="2xl">{{ item }}</h3> <h3 class="small justify-center" text="2xl">{{ item }}</h3>
</el-carousel-item> </el-carousel-item>
</el-carousel> </el-carousel>
<!-- 登录表单-->
<div class="center"> <div class="center">
<el-card style="width: 480px" shadow="always" header="登录"> <el-card style="width: 480px" shadow="always" header="登录">
<el-form :model="user" label-width="auto" style="max-width: 600px"> <el-form :model="form" label-width="auto" style="max-width: 600px">
<el-form-item label="用户名"> <el-form-item label="用户名">
<el-input v-model="user.username" style="width: 240px" placeholder="请输入用户名"/> <el-input v-model="form.username" style="width: 240px" placeholder="请输入用户名"/>
</el-form-item> </el-form-item>
<el-form-item label="密码"> <el-form-item label="密码">
<el-input <el-input
v-model="user.password" v-model="form.password"
style="width: 240px" style="width: 240px"
type="password" type="password"
placeholder="请输入密码" placeholder="请输入密码"
@ -70,7 +83,7 @@ export default {
/> />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="onSubmit">登录</el-button> <el-button type="primary" @click="login">登录</el-button>
<el-button @click="reset">重置</el-button> <el-button @click="reset">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>

View File

@ -8,6 +8,25 @@ import {copy, fuzzyMatching, splitKeyWords,showPassword,hidePassword} from "@/ut
export default { export default {
name: "ZooUser", name: "ZooUser",
components: {ZooUserFormDialog}, components: {ZooUserFormDialog},
data() {
return {
tableData: [],//
//
searchInput: {
option: '',
keyword: ''
},
//
dialog: {
dialogData: {},//
addDialogVisible: false,//
editDialogVisible: false,//
detailDialogVisible: false,//
}
}
},
computed: { computed: {
// //
// region // region
@ -28,29 +47,14 @@ export default {
}, },
// endregion // endregion
...mapState(["users"]) ...mapState(["users"])
}, },
watch: { watch: {
//
searchInput: { searchInput: {
deep: true, deep: true,
handler(val) { handler(val) {
this.searchUser(); this.search();
}
}
},
data() {
return {
tableData: [],//
searchInput: {
auth: '',
keyword: ''
},
dialog: {
addDialogVisible: false,//
editDialogVisible: false,//
editData: {},
detailDialogVisible: false,//
} }
} }
}, },
@ -58,32 +62,38 @@ export default {
hidePassword, hidePassword,
showPassword, showPassword,
...mapActions(['getUsers']), ...mapActions(['getUsers']),
showDetailDialog(user) {
//使user //
this.dialog.editData = this.users.find(e => e.username === user.username) showDetail(data) {
console.log('点击了查询', this.dialog.editData) console.log('显示详情', data)
//
//
this.dialog.dialogData = this.users.find(e => e.username === data.username)
//
this.dialog.detailDialogVisible = true this.dialog.detailDialogVisible = true
}, },
showEditDialog(user) {
//使user //
this.dialog.editData = this.users.find(e => e.username === user.username) showEdit(data) {
console.log('点击了编辑', this.dialog.editData) console.log('编辑弹窗', data)
//
//
this.dialog.dialogData = this.users.find(e => e.id === data.id)
//
this.dialog.editDialogVisible = true this.dialog.editDialogVisible = true
}, },
edit(data) {
console.log('编辑', data)
// //
isEmpty(form) { return this.isEmpty(data);
if (!form.username || !form.password) {
// //
return ElMessage({
message: '用户名和密码不能为空',
type: 'warning',
})
}
},
editUser(form) {
console.log('确认编辑用户', form)
//
return this.isEmpty(form);
// //
if (false) { if (false) {
return ElMessage({ return ElMessage({
@ -91,6 +101,7 @@ export default {
type: 'warning', type: 'warning',
}) })
} }
// //
if (false) { if (false) {
return ElMessage({ return ElMessage({
@ -98,17 +109,20 @@ export default {
type: 'success', type: 'success',
}) })
} }
//
//
this.getUsers() this.getUsers()
this.dialog.editDialogVisible = false//
//
this.dialog.editDialogVisible = false
}, },
deleteUser(user) {
//使user delete_(data) {
user = this.users.find(e => e.username === user.username) console.log('删除', data)
console.log('删除用户', user)
return ElMessageBox.confirm( return ElMessageBox.confirm(
'该操作不可撤销,是否继续?', '该操作不可撤销,是否继续?',
'删除用户:' + user.username, '删除用户:' + data.username + ''+data.id+'',
{ {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
@ -116,8 +130,11 @@ export default {
} }
).then(() => { ).then(() => {
// //
//
//
this.getUsers() this.getUsers()
//
ElMessage({ ElMessage({
type: 'success', type: 'success',
message: '删除成功', message: '删除成功',
@ -129,10 +146,15 @@ export default {
}) })
}) })
}, },
addUser(form) {
console.log('添加用户', form) add(data) {
console.log('添加', data)
// //
return this.isEmpty(form); return this.isEmpty(data);
//
// //
if (false) { if (false) {
return ElMessage({ return ElMessage({
@ -147,18 +169,32 @@ export default {
type: 'success', type: 'success',
}) })
} }
// //
this.getUsers() this.getUsers()
this.dialog.addDialogVisible = false// this.dialog.addDialogVisible = false//
}, },
searchUser() {
console.log('用户搜索',this.searchInput) //
isEmpty(form) {
if (!form.username || !form.password) {
//
return ElMessage({
message: '用户名和密码不能为空',
type: 'warning',
})
}
},
search() {
console.log('搜索',this.searchInput)
let searchResult = []// let searchResult = []//
//
if (typeof this.searchInput.auth ==='number') { //
if (typeof this.searchInput.option ==='number') {
this.users.forEach(e=>{ this.users.forEach(e=>{
if (e.auth === this.searchInput.auth) { if (e.auth === this.searchInput.option) {
searchResult.push(copy(e))// searchResult.push(copy(e))//
} }
}) })
@ -186,8 +222,11 @@ export default {
}, },
}, },
mounted() { mounted() {
this.getUsers()// //
this.tableData = copy(this.users);// this.getUsers()
//
this.tableData = copy(this.users);
} }
} }
</script> </script>
@ -205,7 +244,7 @@ export default {
placeholder="搜索用户 空格隔开关键字" placeholder="搜索用户 空格隔开关键字"
> >
<template #prepend> <template #prepend>
<el-select v-model="searchInput.auth" placeholder="身份" style="width: 90px"> <el-select v-model="searchInput.option" placeholder="身份" style="width: 90px">
<el-option label="不选择" value=""/> <el-option label="不选择" value=""/>
<el-option label="管理员" :value="0"/> <el-option label="管理员" :value="0"/>
<el-option label="饲养员" :value="1"/> <el-option label="饲养员" :value="1"/>
@ -213,7 +252,7 @@ export default {
</el-select> </el-select>
</template> </template>
<template #append> <template #append>
<el-button :icon="Search" @click="searchUser()"/> <el-button :icon="Search" @click="search()"/>
</template> </template>
</el-input> </el-input>
</div> </div>
@ -221,7 +260,7 @@ export default {
<!-- <hr/>--> <!-- <hr/>-->
<div class="table"> <div class="table">
<el-table :data="tableData" style="height: 100%" empty-text="暂无数据" border> <el-table :data="tableData" style="height: 100%" empty-text="暂无数据" border stripe>
<el-table-column fixed prop="id" label="用户ID" width="70"/> <el-table-column fixed prop="id" label="用户ID" width="70"/>
<el-table-column fixed prop="username" label="用户名" width="150"/> <el-table-column fixed prop="username" label="用户名" width="150"/>
<el-table-column prop="password" label="密码" width="150"> <el-table-column prop="password" label="密码" width="150">
@ -239,13 +278,13 @@ export default {
</el-table-column> </el-table-column>
<el-table-column fixed="right" label="操作" width="190"> <el-table-column fixed="right" label="操作" width="190">
<template #default="scope"> <template #default="scope">
<el-button link type="primary" size="small" :icon="Document" @click="showDetailDialog(scope.row)"> <el-button link type="primary" size="small" :icon="Document" @click="showDetail(scope.row)">
详情 详情
</el-button> </el-button>
<el-button link type="primary" size="small" :icon="Edit" @click="showEditDialog(scope.row)"> <el-button link type="primary" size="small" :icon="Edit" @click="showEdit(scope.row)">
编辑 编辑
</el-button> </el-button>
<el-button link type="danger" size="small" :icon="Delete" @click="deleteUser(scope.row)"> <el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)">
删除 删除
</el-button> </el-button>
</template> </template>
@ -261,7 +300,7 @@ export default {
<el-button @click="dialog.addDialogVisible = false"> <el-button @click="dialog.addDialogVisible = false">
取消 取消
</el-button> </el-button>
<el-button type="primary" @click="addUser(scope.form)"> <el-button type="primary" @click="add(scope.form)">
添加 添加
</el-button> </el-button>
</template> </template>
@ -271,12 +310,12 @@ export default {
<!-- 编辑用户对话框--> <!-- 编辑用户对话框-->
<el-dialog v-model="dialog.editDialogVisible" title="编辑用户" width="400" align-center draggable overflow <el-dialog v-model="dialog.editDialogVisible" title="编辑用户" width="400" align-center draggable overflow
destroy-on-close> destroy-on-close>
<ZooUserFormDialog :user="dialog.editData"> <ZooUserFormDialog :data="dialog.dialogData" edit>
<template #default="scope"> <template #default="scope">
<el-button @click="dialog.editDialogVisible = false"> <el-button @click="dialog.editDialogVisible = false">
取消 取消
</el-button> </el-button>
<el-button type="primary" @click="editUser(scope.form)"> <el-button type="primary" @click="edit(scope.form)">
修改 修改
</el-button> </el-button>
</template> </template>
@ -286,7 +325,7 @@ export default {
<!-- 用户详情对话框--> <!-- 用户详情对话框-->
<el-dialog v-model="dialog.detailDialogVisible" title="查询用户" width="400" align-center draggable overflow <el-dialog v-model="dialog.detailDialogVisible" title="查询用户" width="400" align-center draggable overflow
destroy-on-close> destroy-on-close>
<ZooUserFormDialog :user="dialog.editData" detail> <ZooUserFormDialog :data="dialog.dialogData" detail>
<template #default="scope"> <template #default="scope">
<el-button @click="dialog.detailDialogVisible = false"> <el-button @click="dialog.detailDialogVisible = false">
关闭 关闭

View File

@ -2,7 +2,7 @@ import {createStore} from "vuex";
import {generateAnimals, generateArchives, generateBreedingPlans, generateUsers} from "@/utils/common.js"; import {generateAnimals, generateArchives, generateBreedingPlans, generateUsers} from "@/utils/common.js";
const actions = { const actions = {
//更新登录用户 //获取登录用户
getLoginUser(context, user) { getLoginUser(context, user) {
//此处接入后端登录接口验证登录用户名和密码,验证通过方可通行 //此处接入后端登录接口验证登录用户名和密码,验证通过方可通行
//密码错误 //密码错误
@ -63,15 +63,22 @@ const state = {
username: 'user1', username: 'user1',
auth: 0 auth: 0
}, },
// //用户数据
// users: [],
// //动物数据
// animals: [],
// //饲养计划
// breedingPlans:[],
// //动物档案
// archives:[],
//用户数据 //用户数据
users: [], users: generateUsers(),
//动物数据 //动物数据
animals: [], animals: generateAnimals(),
//饲养计划 //饲养计划
breedingPlans:[], breedingPlans:generateBreedingPlans(),
//动物档案 //动物档案
archives:[] archives:generateArchives()
} }
export default createStore({ export default createStore({

View File

@ -116,7 +116,6 @@ export function copy(value) {
//鼠标悬浮显示密码 //鼠标悬浮显示密码
//region //region
export function showPassword(event,password){ export function showPassword(event,password){
console.log('showPassword')
event.target.innerText = password event.target.innerText = password
} }