menulist.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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 class="table" :style="'background:'+backgroundColor">
  8. <view class="tlist" :class="weekidx==ite.dictValue?'act':''" v-for="(ite,idx) in weekList" :key="ite.dictValue" @click="getTable(ite)">{{ite.dictLabel}}</view>
  9. </view>
  10. </view>
  11. <image :src="navbg" class="navbg"></image>
  12. <view class="zxmain" style="margin-top: 100rpx;">
  13. <!-- 列表 -->
  14. <y-list type='menulist' :datalist="list" :wtdt="wtdt" @getDetail='getDetail' @getPut="getPut" @getDelFn="getDelFn"></y-list>
  15. <view class="yyfbtn flexcc">
  16. <view class="mfbtn btna" v-if="checkPermi(['system:foodRecord:list'])" @click="getRecordFn">食谱记录</view>
  17. <view class="mfbtn btnb" v-if="checkPermi(['system:menuFood:add'])" @click="getAddFn">新增食谱</view>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  24. import yList from "@/work/components/yuyue/list.vue"
  25. import {getMenuList,getMenuPut,getMenuDel} from "@/api/mine/order.js"
  26. import {getDictionaryFn} from "@/api/mine/register.js"
  27. export default {
  28. components: {yList},
  29. data() {
  30. return {
  31. wupimg:require("@/work/static/record/wup.png"),
  32. serimg:require("@/work/static/record/search.png"),
  33. licoimg:require("@/work/static/record/lico.png"),
  34. navbg:require("@/static/images/navbg.png"),
  35. dayimg:require("@/work/static/yuy/day.png"),
  36. backgroundColor: "transparent",
  37. datainfo:{},
  38. nvaHeight: 44,
  39. marTop: 0, //距离顶部的距离
  40. stubarHeight: 0, //
  41. title:'',
  42. jclxlist:[],
  43. list:[],
  44. pageSize: 10,
  45. pageNum: 1,
  46. reachflag: false,
  47. wtdt:'',
  48. userId:this.$store.state.user.userId,
  49. weekList:[],
  50. weekidx:'',
  51. weektit:'',
  52. }
  53. },
  54. onPageScroll(e) {
  55. var scrollTop = Number(e.scrollTop);
  56. if (scrollTop > 0) {
  57. this.backgroundColor = '#0491FD'
  58. } else {
  59. this.backgroundColor = 'transparent'
  60. }
  61. },
  62. onUnload() {
  63. uni.$off('refreshmenulist')
  64. },
  65. onLoad: function() {
  66. uni.$on('refreshmenulist',(e) => {
  67. this.getConfirm()
  68. })
  69. this.init()
  70. uni.getSystemInfo({
  71. success: (e) => {
  72. this.stubarHeight = Number(e.statusBarHeight);
  73. this.nvaHeight = Number(e.statusBarHeight) + 44;
  74. }
  75. })
  76. },
  77. onShow() {},
  78. mounted() {
  79. },
  80. // 上拉触底加载更多触发事件
  81. onReachBottom() {
  82. if (this.reachflag) {
  83. this.pageNum++
  84. this.getDataFn()
  85. }
  86. },
  87. methods: {
  88. checkPermi,
  89. checkRole,
  90. getConfirm(){
  91. this.pageNum=1;
  92. this.list=[];
  93. this.reachflag=true;
  94. this.getDataFn()
  95. },
  96. getTable(ite){
  97. this.weekidx=ite.dictValue;
  98. this.weektit=ite.dictLabel
  99. this.getConfirm()
  100. },
  101. getBack() {
  102. uni.navigateBack({
  103. delta: 1
  104. })
  105. },
  106. getDetail(id){
  107. var obj={
  108. id:id,
  109. type:'edit'
  110. }
  111. this.$tab.navigateTo('/work/pages/yyorder/menuadd?data='+encodeURIComponent(JSON.stringify(obj)))
  112. },
  113. getPut(data){
  114. var that=this;
  115. var info=JSON.parse(JSON.stringify(data))
  116. var ite=info.ite;
  117. if(info.type=='use'){
  118. var isUse=ite.isUse;
  119. var str='启用';
  120. var params={
  121. menuFoodId:ite.menuFoodId,
  122. menuFoodTime:ite.menuFoodTime,
  123. }
  124. if(isUse=='Y'){
  125. params.isUse='N'
  126. str="禁用"
  127. }else{
  128. params.isUse='Y'
  129. str="启用"
  130. }
  131. this.$modal.confirm('确定'+str+'该食谱').then(() => {
  132. getMenuPut(params).then(res=>{
  133. if(res.code==200){
  134. that.$toast(str+'成功')
  135. setTimeout(function(){
  136. that.getConfirm();
  137. },1200)
  138. }
  139. })
  140. })
  141. }else{
  142. var obj={
  143. id:ite.menuFoodId,
  144. type:'edit'
  145. }
  146. this.$tab.navigateTo('/work/pages/yyorder/menuput?data='+encodeURIComponent(JSON.stringify(obj)))
  147. }
  148. },
  149. getAddFn(){
  150. this.$tab.navigateTo('/work/pages/yyorder/menuadd')
  151. },
  152. getRecordFn(){
  153. this.$tab.navigateTo('/work/pages/yyorder/menuRecord')
  154. },
  155. init() {
  156. // 星期
  157. getDictionaryFn('week').then(res=>{
  158. if(res.code==200){
  159. this.weekList = res.data.map(v => {
  160. return {
  161. dictLabel: v.dictLabel,
  162. dictValue: v.dictValue
  163. }
  164. })
  165. if(res.data&&res.data.length){
  166. this.weekidx=res.data[0].dictValue
  167. this.weektit=res.data[0].dictLabel
  168. this.getDataFn()
  169. }
  170. }
  171. })
  172. },
  173. getDelFn(id){
  174. var that=this;
  175. getMenuDel(id).then(res=>{
  176. if(res.code==200){
  177. that.$toast('删除成功')
  178. setTimeout(function(){
  179. that.getConfirm()
  180. },1200)
  181. }
  182. })
  183. },
  184. getDataFn() {
  185. var params = {
  186. pageSize: this.pageSize,
  187. pageNum: this.pageNum,
  188. }
  189. // if(!checkRole(['administrators'])){
  190. // params.orderFoodUserId=this.userId
  191. // }
  192. if(this.weektit){
  193. params.menuFoodTime=this.weektit
  194. }
  195. getMenuList(params).then(res => {
  196. if (res.code == 200) {
  197. if (res.rows.length < this.pageSize) {
  198. this.reachflag = false
  199. this.wtdt = '到底了~';
  200. } else {
  201. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum -
  202. 1)
  203. if (num < res.total) {
  204. this.reachflag = true
  205. this.wtdt = '上拉加载更多'
  206. } else {
  207. this.reachflag = false
  208. this.wtdt = '到底了~';
  209. }
  210. }
  211. if (this.pageNum == 1) {
  212. this.list = res.rows;
  213. } else {
  214. this.list = this.list.concat(res.rows)
  215. }
  216. var newArr=JSON.parse(JSON.stringify(res.rows))
  217. newArr.forEach(ite=>{
  218. ite.right=0;
  219. })
  220. // console.log(newArr,555)
  221. if (this.pageNum == 1) {
  222. this.list = newArr;
  223. } else {
  224. this.list = this.list.concat(newArr)
  225. }
  226. } else {
  227. this.$toast(res.msg)
  228. }
  229. })
  230. },
  231. },
  232. }
  233. </script>
  234. <style>
  235. /* page {
  236. background: #ffffff;
  237. } */
  238. </style>
  239. <style lang="scss" scoped>
  240. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4; }
  241. .navbg{width: 100%;height: 692rpx;position: absolute;left: 0;right: 0;top: 0;z-index: -1;}
  242. .zxmain{position: relative;padding: 8rpx 0rpx 100rpx;box-sizing: border-box;}
  243. .table{
  244. display: flex;align-items: center;padding: 0 20rpx;overflow: auto;
  245. .tlist{font-weight: 500;font-size: 26rpx;color: #FFFFFF;height: 60rpx;position: relative;line-height: 60rpx;padding: 0 12rpx;flex: 0 0 auto;
  246. &.act{font-weight: bold;font-size: 30rpx;
  247. &::after{content: '';width: 54rpx;height: 6rpx;background: #FFFFFF;
  248. border-radius: 4rpx;position: absolute;left: 50%;margin-left: -27rpx;bottom: 0;
  249. }
  250. }
  251. }
  252. }
  253. .yyfbtn{background:none;}
  254. .mfbtn{
  255. display: flex;align-items: center;justify-content: center;flex: 1;font-weight: bold;font-size: 28rpx;height: 90rpx;
  256. &.btna{background: #FFFFFF;color: #0391FD;}
  257. &.btnb{background: #0391FD;color: #FFFFFF;}
  258. }
  259. </style>