123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- <template>
- <view>
- <view class="navbox">
- <uni-nav-bar color="#ffffff" left-icon="left" title="就餐预订" :background-color="backgroundColor"
- :border="false" statusBar='true' fixed="true" @clickLeft='getBack'>
- </uni-nav-bar>
- </view>
- <image :src="navbg" class="navbg"></image>
- <view class="zxmain" :style="'margin-top:-'+marTop+'rpx;'">
- <view class="ytbox">
- <uni-forms ref="form" class="ytforms" :modelValue="datainfo">
- <view class="ytsbox">
- <view class="yttit">预订信息</view>
- <view class="pt5">
- <uni-forms-item label="就餐日期" name="orderFoodTime">
- <picker mode="date" class="pickbox"
- @change="bindTimeChangea">
- <view class="flexc flex1">
- <view class="flex1 " :class="datainfo.orderFoodTime?'co16 fw5 f14':'coa f14'">
- {{datainfo.orderFoodTime||'请选择'}}</view>
- <image :src="hupimg" class="hupimg"></image>
- </view>
- </picker>
-
- </uni-forms-item>
- <uni-forms-item label="就餐类型" name="orderFoodType">
- <picker class="pickbox" range-key='label' :value="jclxidx"
- :range="jclxlist" @change="bindTimeChangeb">
- <view class="flexc flex1">
- <!-- <view class="flex1 " :class="orderFoodType?'co16 fw5 f14':'coa f14'">
- {{orderFoodType||'请选择'}}</view> -->
- <view class="flex1 f14" v-if="datainfo.orderFoodType&&!jclx">{{statusFormat(datainfo.orderFoodType,jclxlist,'jclx')}}</view>
- <view class="flex1 f14" v-else :class="jclx?'':'coa'">{{jclx||"请选择就餐类型"}}</view>
- <image :src="hupimg" class="hupimg"></image>
- </view>
- </picker>
- </uni-forms-item>
- <uni-forms-item label="姓名" class="disable" name="orderFoodUser">
- <view class="intit">{{datainfo.orderFoodUser}}</view>
- <!-- <uni-easyinput :inputBorder="false" disabled v-model="datainfo.visitName" placeholder="请输入姓名">
- </uni-easyinput> -->
- </uni-forms-item>
- <uni-forms-item label="部 门" class="disable" name="orderFoodDept">
- <view class="intit">{{datainfo.orderFoodDept}}</view>
- <!-- <uni-easyinput :inputBorder="false" disabled type="number" v-model="datainfo.visitPhone"
- placeholder="请输入手机号码">
- </uni-easyinput> -->
- </uni-forms-item>
- </view>
- <view class="ybtn flexcc" @click="getSubmit">确认提交</view>
- <view class="tips">* 为响应国家号召,请您视真实情况填写,珍惜粮食,适量定 餐,避免剩餐,减少浪费。</view>
- </view>
- </uni-forms>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
- import {getFoodAdd,getFoodPut,getFoodDetail} from "@/api/mine/work.js"
- import {getDictionaryFn} from "@/api/mine/register.js"
- import {selectValueKey} from "@/utils/common.js"
- export default {
- components: {},
- data() {
- return {
- hupimg:require("@/static/images/order/hup.png"),
- navbg:require("@/static/images/navbg.png"),
- backgroundColor: "transparent",
- nvaHeight: 44,
- marTop: 0, //距离顶部的距离
- stubarHeight: 0, //
- datainfo:{
- "orderFoodTime": "",//就餐时间
- "orderFoodType": "",//1:午餐 2:晚餐
- "orderFoodUser":"",//就餐人员名称
- "orderFoodUserId":"",//就餐人员id(用户id)
- "orderFoodDept":"",//就餐人员部门
- "orderFoodDeptId":"",//就餐人员部门id
- },
- jclx:'',
- jclxidx:'',
- jclxlist:[],
- ptype:'add',
- id:'',
- name:this.$store.state.user.name,
- userId:this.$store.state.user.userId,
- deptId:this.$store.state.user.deptId,
- deptName:this.$store.state.user.deptName,
- }
- },
- onPageScroll(e) {
- var scrollTop = Number(e.scrollTop);
- if (scrollTop > 0) {
- this.backgroundColor = '#0491FD'
- } else {
- this.backgroundColor = 'transparent'
- }
- },
- onLoad: function(e) {
- if(e.data){
- var data=JSON.parse(decodeURIComponent(e.data))
- if(data.type){
- this.ptype=data.type;
- this.id=data.id;
- this.getDetail()
- }
- }else{
- this.datainfo.orderFoodUser=this.name;
- this.datainfo.orderFoodUserId=this.userId;
- this.datainfo.orderFoodDept=this.deptName;
- this.datainfo.orderFoodDeptId=this.deptId;
- this.time()
- }
-
- this.init()
- // this.getDataFn()
- uni.getSystemInfo({
- success: (e) => {
- this.stubarHeight = Number(e.statusBarHeight);
- this.nvaHeight = Number(e.statusBarHeight) + 44;
- this.tabscheight = Number(this.nvaHeight) * 2 + 100;
- }
- })
- },
- onShow() {},
- mounted() {
- this.getHeightFn()
- },
- methods: {
- checkPermi,
- checkRole,
- getBack() {
- uni.navigateBack({
- delta: 1
- })
- },
- statusFormat(ite,list,type) {
- var aite=selectValueKey(list, ite);
- if(type=='jclx'){
- this.jclxidx=aite.key
- }
- return aite.actions;
- },
- init() {
- // 就餐类型
- getDictionaryFn('jiucan').then(res=>{
- if(res.code==200){
- this.jclxlist = res.data.map(v => {
- return {
- label: v.dictLabel,
- value: v.dictValue
- }
- })
- }
- })
- },
- time() {
- var date = new Date();
- var y = date.getFullYear();
- var m = date.getMonth() + 1;
- var d = date.getDate();
- var yearStr = y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d)
- // var timeStr = (h < 10 ? ('0' + h) : h) + ':' + (min < 10 ? ('0' + min) : min) + ':' + (s < 10 ? (
- // '0' + s) : s);
- this.datainfo.orderFoodTime= yearStr
- },
- bindTimeChangea(e){
- var val=e.detail.value;
- this.datainfo.orderFoodTime=val
- },
- bindTimeChangeb(e){
- var val=e.detail.value;
- this.datainfo.orderFoodType=this.jclxlist[val].value
- this.jclx=this.jclxlist[val].label
- },
- getHeightFn() {
- let query = uni.createSelectorQuery().in(this);
- //需要给黄色区域设置一个id标识,在这里是demo
- query.select('.navbox').boundingClientRect(data => {
- var top = data.top < 0 ? -data.top : data.top;
- var stubarHeight = Number(this.stubarHeight);
- this.marTop = stubarHeight > 0 ? 692 - Number(data.height) * 2 : 692 - Number(data.height) *
- 2 + 40 //赋值,待会要用
- if (top <= this.nvaHeight) {
- const opacity = top / 100 // 计算透明度值
- const color = `rgba(4, 145, 253, ${opacity})`
- this.backgroundColor = color // 更新盒子背景颜色
- } else {
- this.backgroundColor = '#00A9F0'
- }
- }).exec();
- },
- getSubmit() {
- var that=this;
- var params = JSON.parse(JSON.stringify(this.datainfo))
- if(!params.orderFoodTime){
- this.$toast("请选择就餐日期")
- return
- }
- if(!this.jclx){
- this.$toast("请选择就餐类型")
- return
- }
- uni.showLoading({
- title:"加载中"
- })
- if(this.ptype=='add'){
- getFoodAdd(params).then(res => {
- uni.hideLoading()
- if (res.code == 200) {
- this.$toast("预约成功")
- setTimeout(function(){
- uni.$emit('refreshfoodlist')
- uni.navigateBack({
- delta:1
- })
- },1200)
- } else {
- this.$toast(res.msg)
- }
- })
- }else{
- getFoodPut(params).then(res => {
- uni.hideLoading()
- if (res.code == 200) {
- this.$toast("修改成功")
- setTimeout(function(){
- uni.$emit('refreshfoodlist')
- uni.navigateBack({
- delta:1
- })
- },1200)
- } else {
- this.$toast(res.msg)
- }
- })
- }
- },
- getDetail(){
- getFoodDetail(this.id).then(res=>{
- if(res.code==200){
- this.datainfo=JSON.parse(JSON.stringify(res.data))
- }
- })
- }
- },
- }
- </script>
- <style>
- /* page {
- background: #ffffff;
- } */
- </style>
- <style lang="scss" scoped>
- .ytbox /deep/ .uni-forms .uni-forms-item{padding: 10rpx 26rpx 10rpx;border: 2rpx solid #0391FD;margin-bottom: 24rpx;border-radius: 12rpx;}
- .ytbox /deep/ .uni-forms-item__label{flex: 0 0 auto;width: 144rpx !important;font-size: 28rpx;font-weight: bold;position: relative;color: #161616;text-align-last: justify;}
- .ytbox /deep/ .uni-forms-item__label text{flex: 1;}
- .ytbox /deep/ .uni-forms-item__label .is-required{position: absolute;right: 0;color: #F10C31;margin-top: 16rpx;}
- .ytbox /deep/ uni-textarea{flex: 1;width: auto;text-align: right;}
- .ytbox /deep/ .uni-textarea-placeholder{font-size: 28rpx;color: #DDDDDD !important;}
- .ytbox /deep/ .uni-easyinput__placeholder-class{font-size: 28rpx;color: #DDDDDD;}
- .ytbox /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
- .ytbox /deep/ .uni-easyinput{flex: 1;text-align: right;}
- .ytbox /deep/ .uni-easyinput__content-input{font-size: 28rpx;}
- .ytbox /deep/ .uni-forms-item__error{margin-top:20rpx;left: auto;right: 0;}
- .disable{background: #EFF0F2;border: none !important;}
- .ytbox{width: 684rpx;margin: 0 auto;padding-top: 24rpx;position: relative;flex: 1;overflow: auto;background-color: #ffffff;padding-bottom: 4rpx;border-radius: 14rpx;}
- .ytforms{
- .yttit{font-size: 28rpx;font-weight: bold;margin-bottom: 56rpx;
- color: #161616;display: flex;align-items: center;padding: 0rpx 26rpx;box-sizing: border-box;position: relative;
- &::before{content: '';width: 6rpx;height: 34rpx;background: $com-cd3;border-radius: 4rpx;position: absolute;top: 50%;transform: translateY(-50%);left: 0rpx;}
- }
- .ytsbox{background-color: #ffffff;padding: 32rpx 28rpx 0;border-radius: 14rpx;margin-bottom: 24rpx;
- .intit{font-weight: 500;flex: 1;font-size: 26rpx;text-align: right;color: #666666;}
- .pickbox{flex: 1;text-align: right;font-weight: 500;font-size: 28rpx;color: #161616;
- .hupimg{width: 18rpx;height: 14rpx;margin-left: 12rpx;flex: 0 0 auto;}
- }
-
- }
- }
- // 按钮
- .ybtn{width: 100%;height: 90rpx;background: $com-cd3;border-radius: 14rpx;margin: 100rpx auto 0;font-size: 28rpx;font-weight: 500;color: #FFFFFF;
- &.btn1{background-color: #9a9c9e;}
- }
- .tips{font-weight: bold;margin-top: 28rpx;
- font-size: 22rpx;line-height: 34rpx;
- color: #FF0000;}
- .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4; }
- .navbg{width: 100%;height: 692rpx;}
- .zxmain{position: relative;padding: 20rpx 32rpx 40rpx;box-sizing: border-box;display: flex;
- min-height: calc(100vh - 44px);
- }
- </style>
|