自主项目,食堂系统,前端uniapp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

266 lines
6.8 KiB

  1. <template>
  2. <view class="content">
  3. <view class="card" v-for="(item, index) in list" :key="index">
  4. <view class="lf-row-between">
  5. <view class="lf-color-black lf-font-bold">{{ item.title }}</view>
  6. <!-- 修改功能先隐藏 -->
  7. <!-- <view style="color: #11D189;" @click="showEdit">修改</view> -->
  8. </view>
  9. <view class="lf-row-between lf-m-t-30">
  10. <view>订购数</view>
  11. <view class="lf-color-black">{{ item.orderNum }}</view>
  12. </view>
  13. <view class="lf-row-between lf-m-t-30">
  14. <view>实到数</view>
  15. <view class="lf-flex">
  16. <input class="input" placeholder="0" type="number" :value="item.realNum" @blur="inputBlur(index, 'realNum', $event)" />
  17. <text class="lf-color-black"></text>
  18. </view>
  19. </view>
  20. <view class="lf-row-between lf-m-t-30">
  21. <view>实收数</view>
  22. <view class="lf-flex">
  23. <input class="input" placeholder="0" type="number" :value="item.receiptsNum" @blur="inputBlur(index, 'receiptsNum', $event)" />
  24. <text class="lf-color-black"></text>
  25. </view>
  26. </view>
  27. </view>
  28. <view style="height: 120rpx;"></view>
  29. <view class="fixed-bottom">
  30. <button class="btn" @click="comfirm">确认收货</button>
  31. </view>
  32. <!-- 弹出层-确认收货修改 TODO每个都应该是动态 -->
  33. <u-popup v-model="is_show_edit" mode="bottom" border-radius="20">
  34. <view class="popup-box">
  35. <view class="popup-content">
  36. <view>
  37. <view class="popup-item" hover-class="lf-opacity" :style="currentObj(1)?'border-bottom:none':''" @click="switchItem(1)">
  38. <text class="lf-font-bold">选择供应商</text>
  39. <u-icon name="arrow-up" color="#777777" v-if="currentObj(1)"></u-icon>
  40. <u-icon name="arrow-down" color="#777777" v-else></u-icon>
  41. </view>
  42. <scroll-view :scroll-y="true" class="scroll-box" :style="currentObj(1)?'max-height:360rpx':'max-height:0rpx'">
  43. <view class="lf-row-between scroll-item" v-for="(item, index) in supplier_list" :key="index" @click="checkItem(index, 'supplier_list')">
  44. <view>{{ item.name }}</view>
  45. <u-icon name="checkmark-circle" color="#11D189" v-if="item.checked"></u-icon>
  46. </view>
  47. </scroll-view>
  48. </view>
  49. <view>
  50. <view class="popup-item" hover-class="lf-opacity" :style="currentObj(2)?'border-bottom:none':''" @click="switchItem(2)">
  51. <text class="lf-font-bold">选择物资</text>
  52. <u-icon name="arrow-up" color="#777777" v-if="currentObj(2)"></u-icon>
  53. <u-icon name="arrow-down" color="#777777" v-else></u-icon>
  54. </view>
  55. <scroll-view :scroll-y="true" class="scroll-box" :style="currentObj(2)?'max-height:360rpx':'max-height:0rpx'">
  56. <view class="lf-row-between scroll-item" v-for="(item, index) in material_list" :key="index" @click="checkItem(index, 'material_list')">
  57. <view>{{ item.name }}</view>
  58. <u-icon name="checkmark-circle" color="#11D189" v-if="item.checked"></u-icon>
  59. </view>
  60. </scroll-view>
  61. </view>
  62. </view>
  63. <u-button class="popup-btn" @click="comfirmEdit">确认修改</u-button>
  64. </view>
  65. </u-popup>
  66. </view>
  67. </template>
  68. <script>
  69. export default {
  70. data(){
  71. return {
  72. list: [{
  73. title: '大白菜 / 长叶子 / 斤',
  74. orderNum: '300斤',
  75. realNum: '',
  76. receiptsNum: ''
  77. },{
  78. title: '拌凉菜 / 好好次 / 斤',
  79. orderNum: '100斤',
  80. realNum: '',
  81. receiptsNum: ''
  82. },{
  83. title: '你是真的菜 / 菜鸡 / 斤',
  84. orderNum: '1000吨',
  85. realNum: '',
  86. receiptsNum: ''
  87. }],
  88. is_show_edit: false,
  89. current_show: {
  90. type: 1,
  91. open: false
  92. },
  93. supplier_list: [{
  94. name: '南开大学',
  95. checked: false
  96. },{
  97. name: '华侨大学',
  98. checked: false
  99. }],
  100. material_list: [{
  101. name: '哈哈哈哈',
  102. checked: false
  103. },{
  104. name: '嘿嘿嘿',
  105. checked: false
  106. }]
  107. }
  108. },
  109. computed: {
  110. currentObj(){
  111. let current_show = this.current_show;
  112. return function(num){
  113. return current_show.type == num && current_show.open
  114. }
  115. }
  116. },
  117. onLoad(){
  118. },
  119. methods: {
  120. inputBlur(current, key, event){
  121. console.log("inputBlur", current, key, event);
  122. this.list[current][key] = event.detail.value;
  123. },
  124. comfirm(){
  125. // 使用延迟器,以防input还没有赋值成功
  126. setTimeout(() => {
  127. console.log("comfirm", this.list);
  128. this.$msg('确认收货成功!');
  129. }, 100);
  130. },
  131. switchItem(current){
  132. let current_show = this.current_show;
  133. if(current_show.type != current){
  134. current_show.open = false;
  135. }
  136. current_show.type = current;
  137. current_show.open = !current_show.open;
  138. this.current_show = current_show;
  139. },
  140. checkItem(index, name){
  141. this[name].forEach(item => item.checked = false);
  142. this[name][index].checked = true;
  143. },
  144. // 确认修改
  145. comfirmEdit(){
  146. this.$msg('修改成功!');
  147. this.is_show_edit = false;
  148. },
  149. // 显示修改弹出层
  150. showEdit(){
  151. this.current_show = {
  152. type: 1,
  153. open: false
  154. };
  155. this.is_show_edit = true;
  156. }
  157. }
  158. }
  159. </script>
  160. <style>
  161. page{
  162. background-color: #F6F6F6;
  163. overflow-x: hidden;
  164. }
  165. </style>
  166. <style lang="scss" scoped="scoped">
  167. .content{
  168. display: flex;
  169. align-items: center;
  170. flex-wrap: wrap;
  171. flex-direction: column;
  172. }
  173. .card{
  174. width: 686rpx;
  175. height: auto;
  176. background-color: #FFFFFF;
  177. border-radius: 20rpx;
  178. margin-top: 30rpx;
  179. font-size: 28rpx;
  180. box-sizing: border-box;
  181. padding: 30rpx;
  182. color: #777777;
  183. .input{
  184. width: 88rpx;
  185. border-bottom: 1rpx solid #e5e5e5;
  186. margin-right: 14rpx;
  187. text-align: center;
  188. color: #222222;
  189. }
  190. }
  191. .fixed-bottom{
  192. position: fixed;
  193. bottom: 0rpx;
  194. left: 0rpx;
  195. z-index: 99;
  196. width: 750rpx;
  197. height: 98rpx;
  198. display: flex;
  199. justify-content: flex-end;
  200. align-items: center;
  201. border-top: 1rpx solid #E5E5E5;
  202. background-color: #FFFFFF;
  203. box-sizing: border-box;
  204. padding: 0 32rpx;
  205. .btn{
  206. width: 212rpx;
  207. background-color: #11D189;
  208. font-size: 32rpx;
  209. line-height: 82rpx;
  210. margin: 0;
  211. height: 82rpx;
  212. border-radius: 40rpx;
  213. color: #FFFFFF;
  214. }
  215. }
  216. /deep/.placeholder-class{
  217. color: #777777;
  218. }
  219. // 去掉u-button 外边框线
  220. /deep/.u-hairline-border::after{
  221. border: none;
  222. }
  223. .popup-box{
  224. width: 100%;
  225. min-height: 484rpx;
  226. max-height: 64vh;
  227. padding: 10rpx 32rpx;
  228. display: flex;
  229. flex-direction: column;
  230. justify-content: space-between;
  231. .popup-content{
  232. min-height: 332rpx;
  233. // max-height: 54vh;
  234. margin-bottom: 40rpx;
  235. .popup-item{
  236. padding: 30rpx 0;
  237. box-sizing: border-box;
  238. border-bottom: 1rpx solid #E5E5E5;
  239. display: flex;
  240. justify-content: space-between;
  241. font-size: 28rpx;
  242. color: #222222;
  243. }
  244. .scroll-box{
  245. transition: all .5s;
  246. .scroll-item{
  247. padding: 30rpx 0;
  248. }
  249. }
  250. }
  251. .popup-btn{
  252. width: 100%;
  253. height: 82rpx;
  254. background: #11D189;
  255. border-radius: 10rpx;
  256. font-size: 32rpx;
  257. color: #FFFFFF;
  258. margin-bottom: 30rpx;
  259. }
  260. }
  261. </style>