Merge remote-tracking branch 'origin/Vue健康'

# Conflicts:
#	src/store/modules/user.js
master
31353 2023-12-22 21:22:22 +08:00
commit a3cdeb529f
6 changed files with 438 additions and 1 deletions

30
src/api/health.js 100644
View File

@ -0,0 +1,30 @@
import request from '@/utils/request'
export function healthList(data) {
return request({
url: '/health/health/list',
method: 'post',
data
})
}
export function healthAdd(data) {
return request({
url: '/health/health/addHealth',
method: 'post',
data
})
}
export function healthUpdate(data) {
return request({
url: '/health/health/updateHealth',
method: 'post',
data
})
}
export function healthDelete(healthId) {
return request({
url: '/health/health/deleteHealth?healthId='+healthId,
method: 'post'
})
}

14
src/api/trees.js 100644
View File

@ -0,0 +1,14 @@
import request from '@/utils/request'
export function tree() {
return request({
url: '/trees/tress/selectOne',
method: 'post'
})
}
export function trees() {
return request({
url: '/trees/tress/selectTwo',
method: 'post'
})
}

View File

@ -101,6 +101,30 @@ export const constantRoutes = [
}
]
},
{
path: '/healthList',
component: Layout,
children: [
{
path: 'index',
name: 'HealthList',
component: () => import('@/views/healthList/index'),
meta: { title: 'HealthList', icon: 'form' }
}
]
},
{
path: '/trees',
component: Layout,
children: [
{
path: 'index',
name: 'Trees',
component: () => import('@/views/trees/index'),
meta: { title: 'trees', icon: 'form' }
}
]
},
{
path: '/case',

View File

@ -0,0 +1,279 @@
<template>
<center>
<div>
<el-form :inline="true" :model="health" class="demo-form-inline">
<el-form-item label="健康教育标题">
<el-input v-model="health.healthTitle" placeholder="标题"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit"></el-button>
</el-form-item>
</el-form>
<div style="width: 100%">
<template>
<el-table
:data="tableData"
style="width: 100%"
height="500">
<el-table-column
prop="healthId"
label="健康教育ID"
width="150">
</el-table-column>
<el-table-column
prop="healthTitle"
label="健康教育标题"
width="120">
</el-table-column>
<el-table-column
prop="healthContent"
label="内容"
width="120">
</el-table-column>
<el-table-column
prop="healthDate"
label="发布时间"
width="120">
</el-table-column>
<el-table-column
prop="username"
label="发布人"
width="300">
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button type="text" @click="handlerClient(scope.row)"></el-button>
<el-button size="mini" type="danger"@click="handleDelete(scope.row.healthId)"></el-button>
</template>
</el-table-column>
</el-table>
</template>
<div>
<el-dialog
title="提示"
:visible.sync="dialogVisible"
width="30%"
:before-close="handleCloses">
<el-form ref="formone" :model="formone" label-width="80px">
<el-form-item label="标题">
<el-input v-model="formone.healthTitle"></el-input>
</el-form-item>
<el-form-item label="内容">
<el-input v-model="formone.healthContent"></el-input>
</el-form-item>
<el-form-item label="发布时间">
<el-input v-model="formone.healthDate"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="handlerSubmit"> </el-button>
</span>
</el-dialog>
</div>
<div class="block">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page.sync="health.pageNum"
:page-sizes="[2, 3, 5, 7]"
:page-size=health.pageSize
layout="sizes, prev, pager, next"
:total=total>
</el-pagination>
</div>
<el-button type="text" @click="dialog = true">注入健康数据</el-button>
<el-drawer
title=" 注入健康教育 !"
:before-close="handleClose"
:visible.sync="dialog"
direction="ltr"
custom-class="demo-drawer"
ref="drawer"
>
<div class="demo-drawer__content">
<h1>发布人 :{{ name }}</h1>
<el-form :model="form">
<el-form-item label="健康教育标题" :label-width="formLabelWidth">
<el-input v-model="form.healthTitle" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="教育健康内容" :label-width="formLabelWidth">
<el-input v-model="form.healthContent" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="发布时间" :label-width="formLabelWidth">
<el-input v-model="form.healthDate" autocomplete="off"></el-input>
</el-form-item>
</el-form>
<div class="demo-drawer__footer">
<el-button @click="cancelForm"> </el-button>
<el-button type="primary" @click="$refs.drawer.closeDrawer()" :loading="loading">{{ loading ? '注入中 ...' : '确 定' }}</el-button>
</div>
</div>
</el-drawer>
</div>
</div>
</center>
</template>
<script>
//jsjsjson,
//import from ',
import {healthAdd, healthDelete, healthList, healthUpdate} from "@/api/health";
import {mapGetters} from "vuex";
export default {
//import使"
components: {},
props: {},
data() {
//"
return {
dialogVisible: false,
centerDialogVisible: false,
dialog: false,
loading: false,
tableData:[],
health:{
pageNum:1,
pageSize:2
},
total:0,
form: {},
formLabelWidth:"120px",
timer:null,
formone:{}
};
},
// data",
computed: {
...mapGetters([
'name'
])
},
//data",
watch: {},
//",
methods: {
list() {
healthList(this.health).then(
res => {
console.log(res)
this.tableData = res.data.list
this.total = res.data.total
}
)
},
handleSizeChange(val) {
console.log(`每页 ${val}`)
this.health.pageSize = val
this.list()
},
handleCurrentChange(val) {
console.log(`当前页: ${val}`)
this.health.pageNum = val
this.list()
},
handleClose(done) {
if (this.loading) {
return;
}
this.$confirm('确定要提交表单吗?')
.then(_ => {
this.loading = true;
this.timer = setTimeout(() => {
done();
//
setTimeout(() => {
this.loading = false;
}, 400);
}, 2000);
healthAdd(this.form)
})
.catch(_ => {
});
},
cancelForm() {
this.loading = false;
this.dialog = false;
clearTimeout(this.timer);
},
onSubmit(){
healthList(this.health).then(
res => {
console.log(res)
this.tableData = res.data.list
this.total = res.data.total
}
)
},
handleCloses(done) {
this.$confirm('确认关闭?')
.then(_ => {
done();
})
.catch(_ => {
});
},
handlerClient(healthValues) {
console.log(healthValues)
this.formone = healthValues
this.dialogVisible = true
},
handlerSubmit() {
healthUpdate(this.formone).then(
res => {
alert(res.msg)
}
)
this.dialogVisible = false
},
/*删除*/
handleDelete(healthId) {
healthDelete(healthId).then(
res => {
console.log(res)
alert(res.msg)
this.list()
}
)
},
},
// - 访this",
created: function () {
this.list()
this.form.healthDate = new Date().getFullYear() + "-" + new Date().getMonth() + "-" + new Date().getDay()
this.formone=this.health
},
// - 访DOM",
mounted() {
},
beforeCreate() {
}, // - ",
beforeMount() {
}, // - ",
beforeUpdate() {
}, // - ",
updated() {
}, // - ",
beforeDestroy() {
}, // - ",
destroyed() {
}, // - ",
activated() {
} //keep-alive",
};
</script>
<style scoped>
</style>

View File

@ -0,0 +1,90 @@
<template>
<div>
<div style="width: 100%">
<template style="width: 100%"
height="500">
<el-table :data="tableData" stripe style="width: 100%">
<el-table-column prop="id" label="编号" width="180"></el-table-column>
<el-table-column prop="treesName" label="名称" width="180"></el-table-column>
</el-table>
</template>
</div>
<el-tree :data="tree" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
</div>
</template>
<script>
//jsjsjson,
//import from ',
import {tree,trees} from "@/api/trees";
export default {
//import使"
components: {},
props: {},
data() {
//"
return {
tableData:[],
tree: [],
defaultProps: {
children: 'children',
label: 'treesName'
}
};
},
// data",
computed: {},
//data",
watch: {},
//",
methods: {
list(){
tree().then(
res=>{
console.log(res)
this.tableData = res.data
}
)
},
treeslist() {
trees().then(
res => {
console.log(res)
this.tree = res.data
}
)
},
handleNodeClick(tree) {
console.log('- - - '+JSON.stringify(tree));
}
},
// - 访this",
created() {
this.list()
this.treeslist()
},
// - 访DOM",
mounted() {
},
beforeCreate() {
}, // - ",
beforeMount() {
}, // - ",
beforeUpdate() {
}, // - ",
updated() {
}, // - ",
beforeDestroy() {
}, // - ",
destroyed() {
}, // - ",
activated() {
} //keep-alive",
};
</script>
<style scoped>
</style>