eat.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <view>
  3. <view class="navbox">
  4. <uni-nav-bar color="#ffffff" left-icon="left" title="就餐预订" :background-color="backgroundColor"
  5. :border="false" statusBar='true' fixed="true" @clickLeft='getBack'>
  6. </uni-nav-bar>
  7. </view>
  8. <image :src="navbg" class="navbg"></image>
  9. <view class="zxmain" :style="'margin-top:-'+marTop+'rpx;'">
  10. <view class="ytbox">
  11. <uni-forms ref="form" class="ytforms" :modelValue="datainfo">
  12. <view class="ytsbox">
  13. <view class="yttit flexcj">预订信息
  14. <view class="cook flexcc" @click="getCookFn">
  15. <image :src="cookimg"></image>
  16. 本周食谱
  17. </view>
  18. </view>
  19. <view class="pt5">
  20. <uni-forms-item label="就餐日期" name="orderFoodTime">
  21. <picker mode="date" class="pickbox"
  22. @change="bindTimeChangea">
  23. <view class="flexc flex1">
  24. <view class="flex1 " :class="datainfo.orderFoodTime?'co16 fw5 f14':'coa f14'">
  25. {{datainfo.orderFoodTime||'请选择'}}</view>
  26. <image :src="hupimg" class="hupimg"></image>
  27. </view>
  28. </picker>
  29. </uni-forms-item>
  30. <uni-forms-item label="就餐类型" name="orderFoodType">
  31. <picker class="pickbox" range-key='label' :value="jclxidx"
  32. :range="jclxlist" @change="bindTimeChangeb">
  33. <view class="flexc flex1">
  34. <!-- <view class="flex1 " :class="orderFoodType?'co16 fw5 f14':'coa f14'">
  35. {{orderFoodType||'请选择'}}</view> -->
  36. <view class="flex1 f14" v-if="datainfo.orderFoodType&&!jclx">{{statusFormat(datainfo.orderFoodType,jclxlist,'jclx')}}</view>
  37. <view class="flex1 f14" v-else :class="jclx?'':'coa'">{{jclx||"请选择就餐类型"}}</view>
  38. <image :src="hupimg" class="hupimg"></image>
  39. </view>
  40. </picker>
  41. </uni-forms-item>
  42. <uni-forms-item label="姓名" class="disable" name="orderFoodUser">
  43. <view class="intit">{{datainfo.orderFoodUser}}</view>
  44. <!-- <uni-easyinput :inputBorder="false" disabled v-model="datainfo.visitName" placeholder="请输入姓名">
  45. </uni-easyinput> -->
  46. </uni-forms-item>
  47. <uni-forms-item label="部 门" class="disable" name="orderFoodDept">
  48. <view class="intit">{{datainfo.orderFoodDept}}</view>
  49. <!-- <uni-easyinput :inputBorder="false" disabled type="number" v-model="datainfo.visitPhone"
  50. placeholder="请输入手机号码">
  51. </uni-easyinput> -->
  52. </uni-forms-item>
  53. </view>
  54. <view class="ybtn flexcc" @click="getSubmit">确认提交</view>
  55. <view class="tips">* 为响应国家号召,请您视真实情况填写,珍惜粮食,适量定 餐,避免剩餐,减少浪费。</view>
  56. </view>
  57. </uni-forms>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  64. import {getFoodAdd,getFoodPut,getFoodDetail} from "@/api/mine/work.js"
  65. import {getDictionaryFn} from "@/api/mine/register.js"
  66. import {selectValueKey} from "@/utils/common.js"
  67. export default {
  68. components: {},
  69. data() {
  70. return {
  71. hupimg:require("@/static/images/order/hup.png"),
  72. cookimg:require("@/work/static/yuy/cook.png"),
  73. navbg:require("@/static/images/navbg.png"),
  74. backgroundColor: "transparent",
  75. nvaHeight: 44,
  76. marTop: 0, //距离顶部的距离
  77. stubarHeight: 0, //
  78. datainfo:{
  79. "orderFoodTime": "",//就餐时间
  80. "orderFoodType": "",//1:午餐 2:晚餐
  81. "orderFoodUser":"",//就餐人员名称
  82. "orderFoodUserId":"",//就餐人员id(用户id)
  83. "orderFoodDept":"",//就餐人员部门
  84. "orderFoodDeptId":"",//就餐人员部门id
  85. },
  86. jclx:'',
  87. jclxidx:'',
  88. jclxlist:[],
  89. ptype:'add',
  90. id:'',
  91. name:this.$store.state.user.name,
  92. userId:this.$store.state.user.userId,
  93. deptId:this.$store.state.user.deptId,
  94. deptName:this.$store.state.user.deptName,
  95. }
  96. },
  97. onPageScroll(e) {
  98. var scrollTop = Number(e.scrollTop);
  99. if (scrollTop > 0) {
  100. this.backgroundColor = '#0491FD'
  101. } else {
  102. this.backgroundColor = 'transparent'
  103. }
  104. },
  105. onLoad: function(e) {
  106. if(e.data){
  107. var data=JSON.parse(decodeURIComponent(e.data))
  108. if(data.type){
  109. this.ptype=data.type;
  110. this.id=data.id;
  111. this.getDetail()
  112. }
  113. }else{
  114. this.datainfo.orderFoodUser=this.name;
  115. this.datainfo.orderFoodUserId=this.userId;
  116. this.datainfo.orderFoodDept=this.deptName;
  117. this.datainfo.orderFoodDeptId=this.deptId;
  118. this.time()
  119. }
  120. this.init()
  121. // this.getDataFn()
  122. uni.getSystemInfo({
  123. success: (e) => {
  124. this.stubarHeight = Number(e.statusBarHeight);
  125. this.nvaHeight = Number(e.statusBarHeight) + 44;
  126. this.tabscheight = Number(this.nvaHeight) * 2 + 100;
  127. }
  128. })
  129. },
  130. onShow() {},
  131. mounted() {
  132. this.getHeightFn()
  133. },
  134. methods: {
  135. checkPermi,
  136. checkRole,
  137. getBack() {
  138. uni.navigateBack({
  139. delta: 1
  140. })
  141. },
  142. statusFormat(ite,list,type) {
  143. var aite=selectValueKey(list, ite);
  144. if(type=='jclx'){
  145. this.jclxidx=aite.key
  146. this.jclx=aite.actions
  147. }
  148. return aite.actions;
  149. },
  150. init() {
  151. // 就餐类型
  152. getDictionaryFn('jiucan').then(res=>{
  153. if(res.code==200){
  154. this.jclxlist = res.data.map(v => {
  155. return {
  156. label: v.dictLabel,
  157. value: v.dictValue
  158. }
  159. })
  160. }
  161. })
  162. },
  163. time() {
  164. var date = new Date();
  165. var y = date.getFullYear();
  166. var m = date.getMonth() + 1;
  167. var d = date.getDate();
  168. var yearStr = y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d)
  169. // var timeStr = (h < 10 ? ('0' + h) : h) + ':' + (min < 10 ? ('0' + min) : min) + ':' + (s < 10 ? (
  170. // '0' + s) : s);
  171. this.datainfo.orderFoodTime= yearStr
  172. },
  173. getCookFn(){
  174. this.$tab.navigateTo("/work/pages/yyorder/menu")
  175. },
  176. bindTimeChangea(e){
  177. var val=e.detail.value;
  178. this.datainfo.orderFoodTime=val
  179. },
  180. bindTimeChangeb(e){
  181. var val=e.detail.value;
  182. this.datainfo.orderFoodType=this.jclxlist[val].value
  183. this.jclx=this.jclxlist[val].label
  184. },
  185. getHeightFn() {
  186. let query = uni.createSelectorQuery().in(this);
  187. //需要给黄色区域设置一个id标识,在这里是demo
  188. query.select('.navbox').boundingClientRect(data => {
  189. var top = data.top < 0 ? -data.top : data.top;
  190. var stubarHeight = Number(this.stubarHeight);
  191. this.marTop = stubarHeight > 0 ? 692 - Number(data.height) * 2 : 692 - Number(data.height) *
  192. 2 + 40 //赋值,待会要用
  193. if (top <= this.nvaHeight) {
  194. const opacity = top / 100 // 计算透明度值
  195. const color = `rgba(4, 145, 253, ${opacity})`
  196. this.backgroundColor = color // 更新盒子背景颜色
  197. } else {
  198. this.backgroundColor = '#00A9F0'
  199. }
  200. }).exec();
  201. },
  202. getSubmit() {
  203. var that=this;
  204. var params = JSON.parse(JSON.stringify(this.datainfo))
  205. if(!params.orderFoodTime){
  206. this.$toast("请选择就餐日期")
  207. return
  208. }
  209. if(!this.jclx){
  210. this.$toast("请选择就餐类型")
  211. return
  212. }
  213. uni.showLoading({
  214. title:"加载中"
  215. })
  216. if(this.ptype=='add'){
  217. getFoodAdd(params).then(res => {
  218. uni.hideLoading()
  219. if (res.code == 200) {
  220. this.$toast("预约成功")
  221. setTimeout(function(){
  222. uni.$emit('refreshfoodlist')
  223. uni.navigateBack({
  224. delta:1
  225. })
  226. },1200)
  227. } else {
  228. this.$toast(res.msg)
  229. }
  230. })
  231. }else{
  232. getFoodPut(params).then(res => {
  233. uni.hideLoading()
  234. if (res.code == 200) {
  235. this.$toast("修改成功")
  236. setTimeout(function(){
  237. uni.$emit('refreshfoodlist')
  238. uni.navigateBack({
  239. delta:1
  240. })
  241. },1200)
  242. } else {
  243. this.$toast(res.msg)
  244. }
  245. })
  246. }
  247. },
  248. getDetail(){
  249. getFoodDetail(this.id).then(res=>{
  250. if(res.code==200){
  251. this.datainfo=JSON.parse(JSON.stringify(res.data))
  252. }
  253. })
  254. }
  255. },
  256. }
  257. </script>
  258. <style>
  259. /* page {
  260. background: #ffffff;
  261. } */
  262. </style>
  263. <style lang="scss" scoped>
  264. .ytbox /deep/ .uni-forms .uni-forms-item{padding: 10rpx 26rpx 10rpx;border: 2rpx solid #0391FD;margin-bottom: 24rpx;border-radius: 12rpx;}
  265. .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;}
  266. .ytbox /deep/ .uni-forms-item__label text{flex: 1;}
  267. .ytbox /deep/ .uni-forms-item__label .is-required{position: absolute;right: 0;color: #F10C31;margin-top: 16rpx;}
  268. .ytbox /deep/ uni-textarea{flex: 1;width: auto;text-align: right;}
  269. .ytbox /deep/ .uni-textarea-placeholder{font-size: 28rpx;color: #DDDDDD !important;}
  270. .ytbox /deep/ .uni-easyinput__placeholder-class{font-size: 28rpx;color: #DDDDDD;}
  271. .ytbox /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
  272. .ytbox /deep/ .uni-easyinput{flex: 1;text-align: right;}
  273. .ytbox /deep/ .uni-easyinput__content-input{font-size: 28rpx;}
  274. .ytbox /deep/ .uni-forms-item__error{margin-top:20rpx;left: auto;right: 0;}
  275. .disable{background: #EFF0F2;border: none !important;}
  276. .ytbox{width: 684rpx;margin: 0 auto;padding-top: 10rpx;position: relative;flex: 1;overflow: auto;background-color: #ffffff;padding-bottom: 4rpx;border-radius: 14rpx;}
  277. .ytforms{
  278. .yttit{font-size: 28rpx;font-weight: bold;margin-bottom: 40rpx;
  279. color: #161616;display: flex;align-items: center;padding: 0rpx 26rpx;box-sizing: border-box;position: relative;
  280. &::before{content: '';width: 6rpx;height: 34rpx;background: $com-cd3;border-radius: 4rpx;position: absolute;top: 50%;transform: translateY(-50%);left: 0rpx;}
  281. }
  282. .ytsbox{background-color: #ffffff;padding: 32rpx 28rpx 0;border-radius: 14rpx;margin-bottom: 24rpx;
  283. .intit{font-weight: 500;flex: 1;font-size: 26rpx;text-align: right;color: #666666;}
  284. .pickbox{flex: 1;text-align: right;font-weight: 500;font-size: 28rpx;color: #161616;
  285. .hupimg{width: 18rpx;height: 14rpx;margin-left: 12rpx;flex: 0 0 auto;}
  286. }
  287. }
  288. .cook{background: #FFEAC8;
  289. border-radius: 26rpx;width: 186rpx;height: 52rpx;font-weight: 500;
  290. font-size: 26rpx;
  291. color: #FE5A0E;
  292. image{margin-right: 6rpx;width: 28rpx;height: 26rpx;}
  293. }
  294. }
  295. // 按钮
  296. .ybtn{width: 100%;height: 90rpx;background: $com-cd3;border-radius: 14rpx;margin: 100rpx auto 0;font-size: 28rpx;font-weight: 500;color: #FFFFFF;
  297. &.btn1{background-color: #9a9c9e;}
  298. }
  299. .tips{font-weight: bold;margin-top: 28rpx;
  300. font-size: 22rpx;line-height: 34rpx;
  301. color: #FF0000;}
  302. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4; }
  303. .navbg{width: 100%;height: 692rpx;}
  304. .zxmain{position: relative;padding: 20rpx 32rpx 40rpx;box-sizing: border-box;display: flex;
  305. min-height: calc(100vh - 44px);
  306. }
  307. </style>