orderReport.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <view>
  3. <u-navbar title="订餐上报"></u-navbar>
  4. <view class="head">
  5. <view class="department">
  6. 订餐部门:{{orgName}}
  7. </view>
  8. <view class="date" @click="show = true">
  9. {{orderFoodDate}}<u-icon name="arrow-down" size="24"></u-icon>
  10. </view>
  11. </view>
  12. <u-picker mode="time" v-model="show" :params="params" :defaultTime="defaultTime" @confirm="confirm">
  13. </u-picker>
  14. <!-- 上报记录 -->
  15. <view class="records">
  16. <!-- <view class="record-item">
  17. <view class="date">
  18. {{today}}
  19. </view>
  20. <view class="number report" @click="maskShow">
  21. {{report}} <u-icon name="arrow-right" size="20"></u-icon>
  22. </view>
  23. </view> -->
  24. <view class="record-item" v-for="(item,index) in orderFoodList" :key="index">
  25. <view class="date">
  26. {{item.date}}
  27. </view>
  28. <view class="number report" @click="maskShow(item)" v-if="item.date == today">
  29. {{report}} <u-icon name="arrow-right" size="20"></u-icon>
  30. </view>
  31. <view class="number" v-else>
  32. 订餐{{item.peopleNum}}人
  33. </view>
  34. </view>
  35. </view>
  36. <!-- 遮罩层 -->
  37. <u-mask :show="show1" @click="show1 = false" :zoom='false'>
  38. <view class="warp">
  39. <view class="rect" @tap.stop>
  40. <view class="title">
  41. <u-icon name="close" color="#777777" @click="close"></u-icon>
  42. 订餐人数
  43. </view>
  44. <u-input v-model="name1" :clearable="false" type="number" placeholder="请填写订餐人数"> </u-input>
  45. <view class="unit">
  46. </view>
  47. <u-button class="btn" @click="submit">保存</u-button>
  48. </view>
  49. </view>
  50. </u-mask>
  51. </view>
  52. </template>
  53. <script>
  54. import * as staffHomeAPI from '@/apis/pagejs/staffHome.js'
  55. export default {
  56. data() {
  57. return {
  58. dateShow: false,
  59. show1: false,
  60. report: '点击上报',
  61. name1: '',
  62. defaultTime: '',
  63. params: {
  64. year: true,
  65. month: true,
  66. day: false,
  67. hour: false,
  68. minute: false,
  69. second: false,
  70. timestamp: true
  71. },
  72. show: false,
  73. orderFoodDate: '',
  74. orderFoodList: [],
  75. yearMonth: '',
  76. today: '',
  77. orgName: '',
  78. orderFoodId: ''
  79. }
  80. },
  81. onReady() {
  82. var date = new Date();
  83. var year = date.getFullYear();
  84. var month = date.getMonth() + 1;
  85. var day = date.getDate();
  86. var week = "星期" + "日一二三四五六".charAt(new Date().getDay())
  87. if (month >= 1 && month <= 9) {
  88. month = '0' + month;
  89. }
  90. this.defaultTime = year + '-' + month;
  91. this.yearMonth = year + '-' + month;
  92. this.orderFoodDate = year + '年' + parseInt(month) + '月';
  93. this.today = month + '月' + day + '日' + ' ' + week;
  94. this.getOrderFoodList();
  95. },
  96. methods: {
  97. getOrderFoodList() {
  98. uni.showLoading({
  99. title: "加载中",
  100. mask: true,
  101. })
  102. staffHomeAPI.monthList({
  103. yearMonth: this.yearMonth
  104. }).then((response) => {
  105. uni.hideLoading();
  106. var list = response.data.mapList;
  107. if(this.yearMonth == this.defaultTime) {
  108. if(list.length == 0) {
  109. list.unshift({
  110. id: '',
  111. date: this.today,
  112. peopleNum: 0
  113. });
  114. } else if(list[0].date != this.today) {
  115. list.unshift({
  116. id: '',
  117. date: this.today,
  118. peopleNum: 0
  119. });
  120. } else {
  121. this.report = "订餐" + list[0].peopleNum + "人";
  122. this.name1 = list[0].peopleNum;
  123. }
  124. }
  125. this.orderFoodList = list;
  126. this.orgName = response.data.orgName;
  127. }).catch(error => {
  128. uni.showToast({
  129. title: error,
  130. icon: "none"
  131. })
  132. })
  133. },
  134. confirm(params) {
  135. this.orderFoodDate = params.year + '年' + parseInt(params.month) + '月';
  136. this.yearMonth = params.year + '-' + params.month;
  137. this.getOrderFoodList();
  138. },
  139. maskShow(item) {
  140. this.show1 = true;
  141. this.orderFoodId = item.id;
  142. },
  143. close() {
  144. this.show1 = false;
  145. },
  146. submit() {
  147. uni.showLoading({
  148. title: "加载中",
  149. mask: true,
  150. })
  151. if(this.orderFoodId.length == 0) {
  152. staffHomeAPI.add({
  153. peopleNum: this.name1
  154. }).then((response) => {
  155. uni.hideLoading();
  156. this.show1 = false;
  157. this.getOrderFoodList();
  158. }).catch(error => {
  159. uni.showToast({
  160. title: error,
  161. icon: "none"
  162. })
  163. })
  164. } else {
  165. staffHomeAPI.update({
  166. id: this.orderFoodId,
  167. peopleNum: this.name1
  168. }).then((response) => {
  169. uni.hideLoading();
  170. this.show1 = false;
  171. this.getOrderFoodList();
  172. }).catch(error => {
  173. uni.showToast({
  174. title: error,
  175. icon: "none"
  176. })
  177. })
  178. }
  179. },
  180. }
  181. }
  182. </script>
  183. <style lang="scss" scoped>
  184. .head {
  185. background: linear-gradient(89.02deg, rgba(18, 114, 238, 1) 1.34%, rgba(102, 169, 255, 1) 99.5%);
  186. padding: 40rpx 32rpx;
  187. display: flex;
  188. justify-content: space-between;
  189. align-items: center;
  190. color: rgba(255, 255, 255, 1);
  191. .department {
  192. font-size: 36rpx;
  193. font-family: 'Medium';
  194. }
  195. .date {
  196. width: 218rpx;
  197. height: 72rpx;
  198. line-height: 72rpx;
  199. text-align: center;
  200. border-radius: 8px;
  201. border: 1px solid rgba(255, 255, 255, 1);
  202. position: relative;
  203. /deep/.uicon-arrow-down {
  204. margin-left: 8rpx;
  205. }
  206. .date-box {
  207. background-color: #fff;
  208. z-index: 999;
  209. width: 180rpx;
  210. box-shadow: 0px 0px 2px #999999;
  211. position: absolute;
  212. top: 70rpx;
  213. left: 0px;
  214. .options-item {
  215. line-height: 60rpx;
  216. padding-left: 16rpx;
  217. background-color: #fff;
  218. color: #101010;
  219. text-align: left;
  220. }
  221. }
  222. }
  223. }
  224. // 上报记录
  225. .records {
  226. background-color: #fff;
  227. .record-item {
  228. font-family: 'PingFang Regular';
  229. padding: 0 24rpx;
  230. line-height: 88rpx;
  231. display: flex;
  232. justify-content: space-between;
  233. align-items: center;
  234. color: rgba(16, 16, 16, 1);
  235. border-bottom: 1px solid rgba(232, 232, 232, 1);
  236. }
  237. .report {
  238. color: rgba(18, 114, 238, 1);
  239. /deep/.uicon-arrow-right {
  240. margin-left: 8rpx;
  241. }
  242. }
  243. }
  244. .warp {
  245. position: fixed;
  246. left: 0;
  247. bottom: 0;
  248. width: 100%;
  249. /deep/.uicon-close {
  250. position: absolute;
  251. left: 32rpx;
  252. top: 6rpx !important;
  253. }
  254. ;
  255. .title {
  256. color: rgba(16, 16, 16, 100);
  257. line-height: 48rpx;
  258. color: rgba(16, 16, 16, 1);
  259. font-size: 36rpx;
  260. text-align: center;
  261. position: relative;
  262. font-weight: bold
  263. }
  264. }
  265. .rect {
  266. width: 100%;
  267. height: 100%;
  268. background-color: #fff;
  269. padding: 32rpx 0;
  270. /deep/.u-input {
  271. width: 87.2%;
  272. border-radius: 8px;
  273. background-color: rgba(229, 231, 234, 100);
  274. margin: 40rpx auto 0;
  275. height: 96rpx;
  276. line-height: 96rpx !important;
  277. padding: 0 16rpx;
  278. position: relative;
  279. }
  280. /deep/.u-input__input {
  281. height: 96rpx !important;
  282. line-height: 96rpx !important;
  283. text-indent: 24rpx;
  284. }
  285. .unit {
  286. width: 20px;
  287. height: 20px;
  288. position: absolute;
  289. top: 140rpx;
  290. right: 60rpx;
  291. color: rgba(16, 16, 16, 1);
  292. font-size: 36rpx;
  293. }
  294. .u-btn {
  295. width: 89.2%;
  296. color: rgba(255, 255, 255, 100);
  297. font-size: 36rpx;
  298. border-radius: 8px;
  299. margin-top: 48rpx;
  300. z-index: 99999;
  301. background-color: rgba(31, 74, 153, 1);
  302. }
  303. }
  304. </style>