自主项目,食堂系统,前端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.

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