menuadd.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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">
  12. <view class="yttit">预订信息</view>
  13. <uni-forms-item label="选择星期" name="orderFoodTime">
  14. <view class="flexc flex1">
  15. <view class="flex1 " :class="datainfo.orderFoodTime?'co16 fw5 f14':'coa f14'">
  16. {{datainfo.orderFoodTime||'请选择'}}</view>
  17. <image :src="upimg" class="hupimg"></image>
  18. </view>
  19. </uni-forms-item>
  20. </view> -->
  21. <!-- <view class="ytbox" style="padding: 0rpx 16rpx;">
  22. <view class="table">
  23. <view class="tatit act">星期一</view>
  24. <view class="tatit">星期二</view>
  25. <view class="tatit">星期二</view>
  26. <view class="tatit">星期二</view>
  27. <view class="tatit">星期二</view>
  28. <view class="tatit">星期二</view>
  29. <view class="tatit">星期二</view>
  30. </view>
  31. </view> -->
  32. <view class="ytbox" style="padding-bottom: 16rpx;" v-for="(ite,idx) in menuFoodList" :key="ite.value">
  33. <view class="yttit flexcj">{{ite.menuFoodTime}}
  34. <view class="cooktita flexcc">
  35. <!-- <view class="label">是否启用:</view> -->
  36. <uni-data-checkbox :selectedColor="color" :selectedTextColor="color" v-model="ite.isUse" :localdata="users" />
  37. </view>
  38. <!-- <view class="delbox flexc"><image :src="delimg"></image>删除食谱</view> -->
  39. </view>
  40. <view class="cooktit">
  41. <view class="label">午餐:</view>
  42. <textarea auto-height="true" v-model="ite.menuFoodDetailLu" class="textarea" maxlength='-1' placeholder="请输入或粘贴午餐菜品,用“,”隔开…"></textarea>
  43. </view>
  44. <view class="cooktit">
  45. <view class="label">晚餐:</view>
  46. <textarea auto-height="true" v-model="ite.menuFoodDetailDi" class="textarea" maxlength='-1' placeholder="请输入或粘贴晚餐菜品,用“,”隔开…"></textarea>
  47. </view>
  48. </view>
  49. </uni-forms>
  50. <view class="btns">
  51. <!-- <view class="btn btna"><image :src="addimg" class="addimg"></image>添加食谱</view> -->
  52. <view class="btn btnb" v-if="checkPermi(['system:menuFood:add'])" @click="getSubmit">确认提交</view>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  59. import {getMenuAdd} from "@/api/mine/order.js"
  60. import {getDictionaryFn} from "@/api/mine/register.js"
  61. export default {
  62. components: {},
  63. data() {
  64. return {
  65. navbg:require("@/static/images/navbg.png"),
  66. upimg:require("@/work/static/yuy/up.png"),
  67. delimg:require("@/work/static/yuy/delw.png"),
  68. addimg:require("@/work/static/yuy/add.png"),
  69. backgroundColor: "transparent",
  70. datainfo:{},
  71. nvaHeight: 44,
  72. marTop: 0, //距离顶部的距离
  73. stubarHeight: 0, //
  74. userId:this.$store.state.user.userId,
  75. weeklist:[],//食谱日期,
  76. menuFoodList:[],//食谱
  77. color:'#0391FD',
  78. users: [{
  79. text: '启用',
  80. value: "Y"
  81. }, {
  82. text: '禁用',
  83. value: "N"
  84. }],
  85. }
  86. },
  87. onPageScroll(e) {
  88. var scrollTop = Number(e.scrollTop);
  89. if (scrollTop > 0) {
  90. this.backgroundColor = '#0491FD'
  91. } else {
  92. this.backgroundColor = 'transparent'
  93. }
  94. },
  95. onUnload() {
  96. },
  97. onLoad: function() {
  98. this.init()
  99. // this.getDataFn()
  100. uni.getSystemInfo({
  101. success: (e) => {
  102. this.stubarHeight = Number(e.statusBarHeight);
  103. this.nvaHeight = Number(e.statusBarHeight) + 44;
  104. }
  105. })
  106. },
  107. onShow() {},
  108. mounted() {
  109. },
  110. methods: {
  111. checkPermi,
  112. checkRole,
  113. init(){
  114. // 食谱日期
  115. getDictionaryFn('week').then(res=>{
  116. if(res.code==200){
  117. // this.weeklist = res.data.map(v => {
  118. // return {
  119. // label: v.dictLabel,
  120. // value: v.dictValue,
  121. // }
  122. // })
  123. this.menuFoodList = res.data.map(v => {
  124. return {
  125. menuFoodTime: v.dictLabel,
  126. menuFoodDetailBk: '',
  127. menuFoodDetailLu: '',
  128. menuFoodDetailDi: '',
  129. isUse: 'Y',
  130. }
  131. })
  132. }
  133. })
  134. },
  135. getBack() {
  136. uni.navigateBack({
  137. delta: 1
  138. })
  139. },
  140. getSubmit(){
  141. var that=this;
  142. var foodlist=JSON.parse(JSON.stringify(this.menuFoodList));
  143. var newArr=[];
  144. foodlist.forEach(ite=>{
  145. if(ite.menuFoodDetailLu||ite.menuFoodDetailDi){
  146. newArr.push(ite)
  147. }
  148. })
  149. if(newArr.length<1){
  150. this.$toast("请输入食谱")
  151. return
  152. }
  153. var params={
  154. menuFoodList:newArr
  155. }
  156. getMenuAdd(params).then(res=>{
  157. if(res.code==200){
  158. that.$toast("新增成功")
  159. setTimeout(function(){
  160. uni.$emit('refreshmenulist')
  161. uni.navigateBack({
  162. delta:1
  163. })
  164. },1200)
  165. }
  166. })
  167. },
  168. },
  169. }
  170. </script>
  171. <style>
  172. /* page {
  173. background: #ffffff;
  174. } */
  175. </style>
  176. <style lang="scss" scoped>
  177. .zxmain /deep/ .uni-forms .uni-forms-item{padding: 8rpx 26rpx 8rpx;border: 2rpx solid #0391FD;margin-bottom: 24rpx;border-radius: 12rpx;}
  178. .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;}
  179. .zxmain /deep/ .uni-forms-item__label text{flex: 1;}
  180. .zxmain /deep/ .uni-forms-item__label .is-required{position: absolute;right: 0;color: #F10C31;margin-top: 16rpx;}
  181. // .zxmain /deep/ uni-textarea{flex: 1;width: auto;text-align: right;}
  182. .zxmain /deep/ .uni-textarea-placeholder{font-size: 28rpx;color: #DDDDDD !important;}
  183. .zxmain /deep/ .uni-easyinput__placeholder-class{font-size: 28rpx;color: #DDDDDD;}
  184. .zxmain /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
  185. .zxmain /deep/ .uni-easyinput{flex: 1;text-align: right;}
  186. .zxmain /deep/ .uni-easyinput__content-input{font-size: 28rpx;}
  187. .zxmain /deep/ .uni-forms-item__error{margin-top:20rpx;left: auto;right: 0;}
  188. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4; }
  189. .navbg{width: 100%;height: 692rpx;position: absolute;left: 0;right: 0;top: 0;z-index: -1;}
  190. .zxmain{position: relative;padding: 36rpx 32rpx 28rpx;box-sizing: border-box;}
  191. .ytforms{
  192. .yttit{font-size: 28rpx;font-weight: bold;margin-bottom: 32rpx;line-height: 40rpx;
  193. color: #161616;display: flex;align-items: center;padding-left:26rpx;box-sizing: border-box;position: relative;
  194. &::before{content: '';width: 6rpx;height: 34rpx;background: $com-cd3;border-radius: 4rpx;position: absolute;top: 50%;transform: translateY(-50%);left: 0rpx;}
  195. }
  196. .ytbox{background-color: #ffffff;padding: 36rpx 28rpx 12rpx;border-radius: 14rpx;box-sizing: border-box;margin-bottom: 18rpx;
  197. .hupimg{width: 18rpx;height: 14rpx;margin-left: 12rpx;flex: 0 0 auto;}
  198. .delbox{font-weight: 500;font-size: 26rpx;color: #FF6969;line-height: 1;
  199. image{width: 26rpx;height: 24rpx;margin-right: 10rpx;}
  200. }
  201. .cooktit{min-height: 152rpx;background: #FFFFFF;border-radius: 6rpx;border: 2rpx solid #0391FD;padding: 24rpx 26rpx;display: flex;margin-bottom: 24rpx;
  202. .label{font-size: 28rpx;font-weight: bold;color: #161616;flex: 0 0 auto;}
  203. .textarea{font-size: 28rpx;}
  204. }
  205. }
  206. .table{border-bottom: 2rpx solid #DADADA;display: flex;align-items: center;overflow: auto;
  207. .tatit{font-weight: 500;font-size: 26rpx;color: #666666;height: 100rpx;display: flex;align-items: center;justify-content: center;min-width: 92rpx;flex: 0 0 auto;
  208. &.act{font-weight: bold;font-size: 30rpx;color: #0391FD;
  209. border-bottom: 4rpx solid #0391FD;
  210. }
  211. }
  212. }
  213. }
  214. .btns{
  215. padding: 42rpx 28rpx 0;
  216. .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;
  217. .addimg{width: 14rpx;height: 14rpx;flex: 0 0 auto;margin-right: 14rpx;}
  218. &.btna{background: #DFF1FF;border:2rpx solid #0391FD;color: #0391FD;}
  219. &.btnb{background: #0391FD;color: #ffffff;}
  220. }
  221. }
  222. </style>