123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- <template>
- <view :style="'padding-top:'+nvaHeight+'px;'">
- <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">
- <uni-forms ref="form" class="ytforms" :modelValue="datainfo">
- <!-- <view class="ytbox">
- <view class="yttit">预订信息</view>
- <uni-forms-item label="选择星期" name="orderFoodTime">
- <view class="flexc flex1">
- <view class="flex1 " :class="datainfo.orderFoodTime?'co16 fw5 f14':'coa f14'">
- {{datainfo.orderFoodTime||'请选择'}}</view>
- <image :src="upimg" class="hupimg"></image>
- </view>
- </uni-forms-item>
- </view> -->
- <!-- <view class="ytbox" style="padding: 0rpx 16rpx;">
- <view class="table">
- <view class="tatit act">星期一</view>
- <view class="tatit">星期二</view>
- <view class="tatit">星期二</view>
- <view class="tatit">星期二</view>
- <view class="tatit">星期二</view>
- <view class="tatit">星期二</view>
- <view class="tatit">星期二</view>
- </view>
- </view> -->
- <view class="ytbox" style="padding-bottom: 16rpx;" v-for="(ite,idx) in menuFoodList" :key="ite.value">
- <view class="yttit flexcj">{{ite.menuFoodTime}}
- <view class="cooktita flexcc">
- <!-- <view class="label">是否启用:</view> -->
- <uni-data-checkbox :selectedColor="color" :selectedTextColor="color" v-model="ite.isUse" :localdata="users" />
- </view>
- <!-- <view class="delbox flexc"><image :src="delimg"></image>删除食谱</view> -->
- </view>
- <view class="cooktit">
- <view class="label">午餐:</view>
- <textarea auto-height="true" v-model="ite.menuFoodDetailLu" class="textarea" maxlength='-1' placeholder="请输入或粘贴午餐菜品,用“,”隔开…"></textarea>
- </view>
- <view class="cooktit">
- <view class="label">晚餐:</view>
- <textarea auto-height="true" v-model="ite.menuFoodDetailDi" class="textarea" maxlength='-1' placeholder="请输入或粘贴晚餐菜品,用“,”隔开…"></textarea>
- </view>
- </view>
- </uni-forms>
- <view class="btns">
- <!-- <view class="btn btna"><image :src="addimg" class="addimg"></image>添加食谱</view> -->
- <view class="btn btnb" v-if="checkPermi(['system:menuFood:add'])" @click="getSubmit">确认提交</view>
- </view>
-
- </view>
- </view>
- </template>
- <script>
- import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
- import {getMenuAdd} from "@/api/mine/order.js"
- import {getDictionaryFn} from "@/api/mine/register.js"
- export default {
- components: {},
- data() {
- return {
- navbg:require("@/static/images/navbg.png"),
- upimg:require("@/work/static/yuy/up.png"),
- delimg:require("@/work/static/yuy/delw.png"),
- addimg:require("@/work/static/yuy/add.png"),
- backgroundColor: "transparent",
- datainfo:{},
- nvaHeight: 44,
- marTop: 0, //距离顶部的距离
- stubarHeight: 0, //
- userId:this.$store.state.user.userId,
- weeklist:[],//食谱日期,
- menuFoodList:[],//食谱
- color:'#0391FD',
- users: [{
- text: '启用',
- value: "Y"
- }, {
- text: '禁用',
- value: "N"
- }],
- }
- },
- onPageScroll(e) {
- var scrollTop = Number(e.scrollTop);
- if (scrollTop > 0) {
- this.backgroundColor = '#0491FD'
- } else {
- this.backgroundColor = 'transparent'
- }
- },
- onUnload() {
-
- },
- onLoad: function() {
- this.init()
- // this.getDataFn()
- uni.getSystemInfo({
- success: (e) => {
- this.stubarHeight = Number(e.statusBarHeight);
- this.nvaHeight = Number(e.statusBarHeight) + 44;
- }
- })
- },
- onShow() {},
- mounted() {
-
- },
- methods: {
- checkPermi,
- checkRole,
- init(){
- // 食谱日期
- getDictionaryFn('week').then(res=>{
- if(res.code==200){
- // this.weeklist = res.data.map(v => {
- // return {
- // label: v.dictLabel,
- // value: v.dictValue,
-
- // }
- // })
- this.menuFoodList = res.data.map(v => {
- return {
- menuFoodTime: v.dictLabel,
- menuFoodDetailBk: '',
- menuFoodDetailLu: '',
- menuFoodDetailDi: '',
- isUse: 'Y',
- }
- })
- }
- })
- },
- getBack() {
- uni.navigateBack({
- delta: 1
- })
- },
- getSubmit(){
- var that=this;
- var foodlist=JSON.parse(JSON.stringify(this.menuFoodList));
- var newArr=[];
- foodlist.forEach(ite=>{
- if(ite.menuFoodDetailLu||ite.menuFoodDetailDi){
- newArr.push(ite)
- }
- })
- if(newArr.length<1){
- this.$toast("请输入食谱")
- return
- }
- var params={
- menuFoodList:newArr
- }
- getMenuAdd(params).then(res=>{
- if(res.code==200){
- that.$toast("新增成功")
- setTimeout(function(){
- uni.$emit('refreshmenulist')
- uni.navigateBack({
- delta:1
- })
- },1200)
- }
- })
- },
- },
- }
- </script>
- <style>
- /* page {
- background: #ffffff;
- } */
- </style>
- <style lang="scss" scoped>
- .zxmain /deep/ .uni-forms .uni-forms-item{padding: 8rpx 26rpx 8rpx;border: 2rpx solid #0391FD;margin-bottom: 24rpx;border-radius: 12rpx;}
- .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;}
- .zxmain /deep/ .uni-forms-item__label text{flex: 1;}
- .zxmain /deep/ .uni-forms-item__label .is-required{position: absolute;right: 0;color: #F10C31;margin-top: 16rpx;}
- // .zxmain /deep/ uni-textarea{flex: 1;width: auto;text-align: right;}
- .zxmain /deep/ .uni-textarea-placeholder{font-size: 28rpx;color: #DDDDDD !important;}
- .zxmain /deep/ .uni-easyinput__placeholder-class{font-size: 28rpx;color: #DDDDDD;}
- .zxmain /deep/ .uni-forms-item__content{display: flex;align-items: center;flex-direction: row;}
- .zxmain /deep/ .uni-easyinput{flex: 1;text-align: right;}
- .zxmain /deep/ .uni-easyinput__content-input{font-size: 28rpx;}
- .zxmain /deep/ .uni-forms-item__error{margin-top:20rpx;left: auto;right: 0;}
- .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4; }
- .navbg{width: 100%;height: 692rpx;position: absolute;left: 0;right: 0;top: 0;z-index: -1;}
- .zxmain{position: relative;padding: 36rpx 32rpx 28rpx;box-sizing: border-box;}
- .ytforms{
- .yttit{font-size: 28rpx;font-weight: bold;margin-bottom: 32rpx;line-height: 40rpx;
- color: #161616;display: flex;align-items: center;padding-left: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;}
- }
- .ytbox{background-color: #ffffff;padding: 36rpx 28rpx 12rpx;border-radius: 14rpx;box-sizing: border-box;margin-bottom: 18rpx;
- .hupimg{width: 18rpx;height: 14rpx;margin-left: 12rpx;flex: 0 0 auto;}
- .delbox{font-weight: 500;font-size: 26rpx;color: #FF6969;line-height: 1;
- image{width: 26rpx;height: 24rpx;margin-right: 10rpx;}
- }
- .cooktit{min-height: 152rpx;background: #FFFFFF;border-radius: 6rpx;border: 2rpx solid #0391FD;padding: 24rpx 26rpx;display: flex;margin-bottom: 24rpx;
- .label{font-size: 28rpx;font-weight: bold;color: #161616;flex: 0 0 auto;}
- .textarea{font-size: 28rpx;}
- }
- }
- .table{border-bottom: 2rpx solid #DADADA;display: flex;align-items: center;overflow: auto;
- .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;
- &.act{font-weight: bold;font-size: 30rpx;color: #0391FD;
- border-bottom: 4rpx solid #0391FD;
- }
- }
- }
- }
- .btns{
- padding: 42rpx 28rpx 0;
- .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;
- .addimg{width: 14rpx;height: 14rpx;flex: 0 0 auto;margin-right: 14rpx;}
- &.btna{background: #DFF1FF;border:2rpx solid #0391FD;color: #0391FD;}
- &.btnb{background: #0391FD;color: #ffffff;}
- }
- }
- </style>
|