menuput.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. <uni-forms ref="form" class="ytforms" :modelValue="datainfo">
  11. <view class="ytbox" style="padding-bottom: 16rpx;" >
  12. <view class="yttit flexcj">
  13. {{datainfo.menuFoodTime}}
  14. </view>
  15. <!-- <view class="cooktit">
  16. <view class="label">早餐:</view>
  17. <textarea auto-height="true" v-model="datainfo.menuFoodDetailBk" class="textarea" maxlength='-1' placeholder="请输入或粘贴午餐菜品,用“,”隔开…"></textarea>
  18. </view> -->
  19. <view class="cooktit">
  20. <view class="label">午餐:</view>
  21. <textarea auto-height="true" v-model="datainfo.menuFoodDetailLu" class="textarea" maxlength='-1' placeholder="请输入或粘贴午餐菜品,用“,”隔开…"></textarea>
  22. </view>
  23. <view class="cooktit">
  24. <view class="label">晚餐:</view>
  25. <textarea auto-height="true" v-model="datainfo.menuFoodDetailDi" class="textarea" maxlength='-1' placeholder="请输入或粘贴晚餐菜品,用“,”隔开…"></textarea>
  26. </view>
  27. <view class="cooktita flexc mb10">
  28. <view class="label" style="flex: 1;">是否启用:</view>
  29. <switch :checked="datainfo.isUse=='Y'" @change="getChange"/>
  30. <!-- <uni-data-checkbox :selectedColor="color" :selectedTextColor="color" v-model="datainfo.isUse" :localdata="users" /> -->
  31. </view>
  32. </view>
  33. </uni-forms>
  34. <view class="btns">
  35. <view class="btn btnb" v-if="checkPermi(['system:menuFood:edit'])" @click="getSubmit">确认提交</view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  42. import {getMenuAdd,getMenuDetail,getMenuPut} from "@/api/mine/order.js"
  43. import {getDictionaryFn} from "@/api/mine/register.js"
  44. export default {
  45. components: {},
  46. data() {
  47. return {
  48. navbg:require("@/static/images/navbg.png"),
  49. upimg:require("@/work/static/yuy/up.png"),
  50. delimg:require("@/work/static/yuy/delw.png"),
  51. addimg:require("@/work/static/yuy/add.png"),
  52. backgroundColor: "transparent",
  53. datainfo:{},
  54. nvaHeight: 44,
  55. marTop: 0, //距离顶部的距离
  56. stubarHeight: 0, //
  57. userId:this.$store.state.user.userId,
  58. patype:'edit',
  59. id:'',
  60. color:'#0391FD',
  61. users: [{
  62. text: '启用',
  63. value: "Y"
  64. }, {
  65. text: '禁用',
  66. value: "N"
  67. }],
  68. }
  69. },
  70. onPageScroll(e) {
  71. var scrollTop = Number(e.scrollTop);
  72. if (scrollTop > 0) {
  73. this.backgroundColor = '#0491FD'
  74. } else {
  75. this.backgroundColor = 'transparent'
  76. }
  77. },
  78. onUnload() {
  79. },
  80. onLoad: function(e) {
  81. if(e.data){
  82. var data=JSON.parse(decodeURIComponent(e.data))
  83. this.patype=data.type;
  84. this.id=data.id;
  85. this.getMenuDetail()
  86. }
  87. uni.getSystemInfo({
  88. success: (e) => {
  89. this.stubarHeight = Number(e.statusBarHeight);
  90. this.nvaHeight = Number(e.statusBarHeight) + 44;
  91. }
  92. })
  93. },
  94. onShow() {},
  95. mounted() {
  96. },
  97. methods: {
  98. checkPermi,
  99. checkRole,
  100. getMenuDetail(){
  101. getMenuDetail(this.id).then(res=>{
  102. if(res.code==200){
  103. this.datainfo=res.data
  104. }
  105. })
  106. },
  107. getChange(e){
  108. var val=e.detail.value;
  109. if(val==false){
  110. this.datainfo.isUse='N'
  111. }else{
  112. this.datainfo.isUse='Y'
  113. }
  114. },
  115. getBack() {
  116. uni.navigateBack({
  117. delta: 1
  118. })
  119. },
  120. getSubmit(){
  121. var that=this;
  122. var params=JSON.parse(JSON.stringify(this.datainfo));
  123. getMenuPut(params).then(res=>{
  124. if(res.code==200){
  125. that.$toast("修改成功")
  126. setTimeout(function(){
  127. uni.$emit('refreshmenulist')
  128. uni.navigateBack({
  129. delta:1
  130. })
  131. },1200)
  132. }
  133. })
  134. },
  135. },
  136. }
  137. </script>
  138. <style>
  139. /* page {
  140. background: #ffffff;
  141. } */
  142. </style>
  143. <style lang="scss" scoped>
  144. .zxmain /deep/ .uni-switch-input.uni-switch-input-checked{background-color: #0391FD !important;}
  145. .zxmain /deep/ uni-switch::before{display: none;}
  146. .zxmain /deep/ .uni-forms .uni-forms-item{padding: 8rpx 26rpx 8rpx;border: 2rpx solid #0391FD;margin-bottom: 24rpx;border-radius: 12rpx;}
  147. .zxmain /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;}
  148. .zxmain /deep/ .uni-forms-item__label text{flex: 1;}
  149. .zxmain /deep/ .uni-forms-item__label .is-required{position: absolute;right: 0;color: #F10C31;margin-top: 16rpx;}
  150. // .zxmain /deep/ uni-textarea{flex: 1;width: auto;text-align: right;}
  151. .zxmain /deep/ .uni-textarea-placeholder{font-size: 28rpx;color: #DDDDDD !important;}
  152. .zxmain /deep/ .uni-easyinput__placeholder-class{font-size: 28rpx;color: #DDDDDD;}
  153. .zxmain /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
  154. .zxmain /deep/ .uni-easyinput{flex: 1;text-align: right;}
  155. .zxmain /deep/ .uni-easyinput__content-input{font-size: 28rpx;}
  156. .zxmain /deep/ .uni-forms-item__error{margin-top:20rpx;left: auto;right: 0;}
  157. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4; }
  158. .navbg{width: 100%;height: 692rpx;position: absolute;left: 0;right: 0;top: 0;z-index: -1;}
  159. .zxmain{position: relative;padding: 36rpx 32rpx 28rpx;box-sizing: border-box;}
  160. .ytforms{
  161. .yttit{font-size: 28rpx;font-weight: bold;margin-bottom: 32rpx;line-height: 40rpx;
  162. color: #161616;display: flex;align-items: center;padding: 0rpx 26rpx;box-sizing: border-box;position: relative;
  163. &::before{content: '';width: 6rpx;height: 34rpx;background: $com-cd3;border-radius: 4rpx;position: absolute;top: 50%;transform: translateY(-50%);left: 0rpx;}
  164. }
  165. .ytbox{background-color: #ffffff;padding: 36rpx 28rpx 12rpx;border-radius: 14rpx;box-sizing: border-box;margin-bottom: 18rpx;
  166. .cooktit{min-height: 152rpx;background: #FFFFFF;border-radius: 6rpx;border: 2rpx solid #0391FD;padding: 24rpx 26rpx;display: flex;margin-bottom: 24rpx;
  167. .textarea{font-size: 28rpx;}
  168. }
  169. .label{font-size: 28rpx;font-weight: bold;color: #161616;flex: 0 0 auto;}
  170. }
  171. }
  172. .btns{
  173. padding: 42rpx 28rpx 0;
  174. .btn{width: 100%;height: 90rpx;border-radius: 14rpx;font-weight: 500;font-size: 28rpx;margin-bottom: 34rpx;display: flex;align-items: center;justify-content: center;box-sizing: border-box;
  175. .addimg{width: 14rpx;height: 14rpx;flex: 0 0 auto;margin-right: 14rpx;}
  176. &.btna{background: #DFF1FF;border:2rpx solid #0391FD;color: #0391FD;}
  177. &.btnb{background: #0391FD;color: #ffffff;}
  178. }
  179. }
  180. </style>