eat.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <view :style="'padding-top:'+nvaHeight+'px;'">
  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">
  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.nickName,
  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. }
  127. })
  128. },
  129. onShow() {},
  130. methods: {
  131. checkPermi,
  132. checkRole,
  133. getBack() {
  134. uni.navigateBack({
  135. delta: 1
  136. })
  137. },
  138. statusFormat(ite,list,type) {
  139. var aite=selectValueKey(list, ite);
  140. if(type=='jclx'){
  141. this.jclxidx=aite.key
  142. this.jclx=aite.actions
  143. }
  144. return aite.actions;
  145. },
  146. init() {
  147. // 就餐类型
  148. getDictionaryFn('jiucan').then(res=>{
  149. if(res.code==200){
  150. this.jclxlist = res.data.map(v => {
  151. return {
  152. label: v.dictLabel,
  153. value: v.dictValue
  154. }
  155. })
  156. }
  157. })
  158. },
  159. time() {
  160. var date = new Date();
  161. var y = date.getFullYear();
  162. var m = date.getMonth() + 1;
  163. var d = date.getDate();
  164. var yearStr = y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d)
  165. // var timeStr = (h < 10 ? ('0' + h) : h) + ':' + (min < 10 ? ('0' + min) : min) + ':' + (s < 10 ? (
  166. // '0' + s) : s);
  167. this.datainfo.orderFoodTime= yearStr
  168. },
  169. getCookFn(){
  170. this.$tab.navigateTo("/work/pages/yyorder/menu")
  171. },
  172. bindTimeChangea(e){
  173. var val=e.detail.value;
  174. this.datainfo.orderFoodTime=val
  175. },
  176. bindTimeChangeb(e){
  177. var val=e.detail.value;
  178. this.datainfo.orderFoodType=this.jclxlist[val].value
  179. this.jclx=this.jclxlist[val].label
  180. },
  181. getSubmit() {
  182. var that=this;
  183. var params = JSON.parse(JSON.stringify(this.datainfo))
  184. if(!params.orderFoodTime){
  185. this.$toast("请选择就餐日期")
  186. return
  187. }
  188. if(!this.jclx){
  189. this.$toast("请选择就餐类型")
  190. return
  191. }
  192. uni.showLoading({
  193. title:"加载中"
  194. })
  195. if(this.ptype=='add'){
  196. getFoodAdd(params).then(res => {
  197. uni.hideLoading()
  198. if (res.code == 200) {
  199. this.$toast("预约成功")
  200. setTimeout(function(){
  201. uni.$emit('refreshfoodlist')
  202. uni.navigateBack({
  203. delta:1
  204. })
  205. },1200)
  206. } else {
  207. this.$toast(res.msg)
  208. }
  209. })
  210. }else{
  211. getFoodPut(params).then(res => {
  212. uni.hideLoading()
  213. if (res.code == 200) {
  214. this.$toast("修改成功")
  215. setTimeout(function(){
  216. uni.$emit('refreshfoodlist')
  217. uni.navigateBack({
  218. delta:1
  219. })
  220. },1200)
  221. } else {
  222. this.$toast(res.msg)
  223. }
  224. })
  225. }
  226. },
  227. getDetail(){
  228. getFoodDetail(this.id).then(res=>{
  229. if(res.code==200){
  230. this.datainfo=JSON.parse(JSON.stringify(res.data))
  231. }
  232. })
  233. }
  234. },
  235. }
  236. </script>
  237. <style>
  238. /* page {
  239. background: #ffffff;
  240. } */
  241. </style>
  242. <style lang="scss" scoped>
  243. .ytbox /deep/ .uni-forms .uni-forms-item{padding: 10rpx 26rpx 10rpx;border: 2rpx solid #0391FD;margin-bottom: 24rpx;border-radius: 12rpx;}
  244. .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;}
  245. .ytbox /deep/ .uni-forms-item__label text{flex: 1;}
  246. .ytbox /deep/ .uni-forms-item__label .is-required{position: absolute;right: 0;color: #F10C31;margin-top: 16rpx;}
  247. .ytbox /deep/ uni-textarea{flex: 1;width: auto;text-align: right;}
  248. .ytbox /deep/ .uni-textarea-placeholder{font-size: 28rpx;color: #DDDDDD !important;}
  249. .ytbox /deep/ .uni-easyinput__placeholder-class{font-size: 28rpx;color: #DDDDDD;}
  250. .ytbox /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
  251. .ytbox /deep/ .uni-easyinput{flex: 1;text-align: right;}
  252. .ytbox /deep/ .uni-easyinput__content-input{font-size: 28rpx;}
  253. .ytbox /deep/ .uni-forms-item__error{margin-top:20rpx;left: auto;right: 0;}
  254. .disable{background: #EFF0F2;border: none !important;}
  255. .ytbox{width: 684rpx;margin: 0 auto;padding-top: 10rpx;position: relative;flex: 1;overflow: auto;background-color: #ffffff;padding-bottom: 4rpx;border-radius: 14rpx;}
  256. .ytforms{
  257. .yttit{font-size: 28rpx;font-weight: bold;margin-bottom: 40rpx;
  258. color: #161616;display: flex;align-items: center;padding: 0rpx 26rpx;box-sizing: border-box;position: relative;
  259. &::before{content: '';width: 6rpx;height: 34rpx;background: $com-cd3;border-radius: 4rpx;position: absolute;top: 50%;transform: translateY(-50%);left: 0rpx;}
  260. }
  261. .ytsbox{background-color: #ffffff;padding: 32rpx 28rpx 0;border-radius: 14rpx;margin-bottom: 24rpx;
  262. .intit{font-weight: 500;flex: 1;font-size: 26rpx;text-align: right;color: #666666;}
  263. .pickbox{flex: 1;text-align: right;font-weight: 500;font-size: 28rpx;color: #161616;
  264. .hupimg{width: 18rpx;height: 14rpx;margin-left: 12rpx;flex: 0 0 auto;}
  265. }
  266. }
  267. .cook{background: #FFEAC8;
  268. border-radius: 26rpx;width: 186rpx;height: 52rpx;font-weight: 500;
  269. font-size: 26rpx;
  270. color: #FE5A0E;
  271. image{margin-right: 6rpx;width: 28rpx;height: 26rpx;}
  272. }
  273. }
  274. // 按钮
  275. .ybtn{width: 100%;height: 90rpx;background: $com-cd3;border-radius: 14rpx;margin: 100rpx auto 0;font-size: 28rpx;font-weight: 500;color: #FFFFFF;
  276. &.btn1{background-color: #9a9c9e;}
  277. }
  278. .tips{font-weight: bold;margin-top: 28rpx;
  279. font-size: 22rpx;line-height: 34rpx;
  280. color: #FF0000;}
  281. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4; }
  282. .navbg{width: 100%;height: 692rpx;position: absolute;left: 0;right: 0;top: 0;z-index: -1;}
  283. .zxmain{position: relative;padding: 20rpx 32rpx 40rpx;box-sizing: border-box;display: flex;
  284. min-height: calc(100vh - 44px);
  285. }
  286. </style>