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

142 lines
3.4 KiB

  1. <template>
  2. <view>
  3. <view class="lf-p-32 lf-p-t-30 lf-p-b-30 lf-w-100 lf-h-maxcontent lf-border-box">
  4. <view class="lf-font-28 lf-color-black lf-row-between">
  5. <view>出库清单</view>
  6. <view class="lf-icon" @click="$url('/pages/canteen/classification/index?type=3')">
  7. <u-icon name="plus-circle" size="42"></u-icon>
  8. </view>
  9. </view>
  10. <view class="lf-font-24 lf-color-gray lf-m-t-5">添加物资后可以编辑数量</view>
  11. </view>
  12. <!-- 修饰条 -->
  13. <self-line></self-line>
  14. <!-- 物料table -->
  15. <view class="lf-p-32 lf-p-t-30 lf-p-b-30 lf-w-100 lf-h-maxcontent lf-border-box">
  16. <view class="lf-font-32 lf-color-black lf-font-bold lf-m-b-20">物资明细</view>
  17. <wyb-table :headers="headers" contentBgColor="#ecfaf5" :first-line-fixed="true" :contents="contents" @onInputChange="onInputChange" width="max-content" height="800rpx"></wyb-table>
  18. </view>
  19. <!-- 操作按钮 -->
  20. <view class="fixed-bottom">
  21. <button class="btn btn1" @click="save(1)">临时保存</button>
  22. <button class="btn btn2" @click="save(2)">直接申请</button>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import wybTable from '@/components/wyb-table/wyb-table';
  28. export default {
  29. components: {
  30. wybTable
  31. },
  32. data(){
  33. return {
  34. headers: [{
  35. label: '菜品名称',
  36. key: 'name'
  37. },{
  38. label: '规格',
  39. key: 'spec'
  40. },{
  41. label: '税前价',
  42. key: 'pre_tax_price'
  43. },{
  44. label: '税后价',
  45. key: 'after_tax_price'
  46. }],
  47. contents: []
  48. }
  49. },
  50. onLoad(){
  51. this.getMaterialList();
  52. },
  53. methods: {
  54. getMaterialList(){
  55. this.$http(this.API.API_CANTEEN_MATERIALLIST, {
  56. // category_id: 1 // 分类id 不传则显示默认分类
  57. }).then(res => {
  58. let list = res.data.material || [];
  59. let contents = list.map(item => {
  60. return {
  61. name: item.material.m_name,
  62. spec: item.name,
  63. pre_tax_price: {edit: true, value: item.tax_standard_price},
  64. after_tax_price: {edit: true, value: item.non_tax_standard_price},
  65. spec_id: item.id,
  66. material_id: item.material.id
  67. }
  68. })
  69. this.contents = contents;
  70. })
  71. },
  72. onInputChange(event){
  73. console.log("检测到table input被更改", event);
  74. this.contents[event.contentIndex][event.key].value = event.detailValue;
  75. },
  76. save(_t){
  77. // todo
  78. console.log("dddddd", this.contents)
  79. let list = this.contents.map(item => {
  80. return {
  81. m_id: item.material_id,
  82. m_spec_id: item.spec_id,
  83. tax_price: item.pre_tax_price.value,
  84. non_tax_price: item.after_tax_price.value
  85. }
  86. });
  87. this.$http(this.API.API_CANTEEN_WAREHOUSEOUT, {
  88. data: list
  89. }).then(res => {
  90. console.log("save", res);
  91. this.$msg('操作成功');
  92. })
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang="scss" scoped="scoped">
  98. .lf-m-t-5{
  99. margin-top: 5rpx;
  100. }
  101. .lf-icon{
  102. padding: 2rpx 10rpx;
  103. display: flex;
  104. align-items: center;
  105. justify-content: center;
  106. }
  107. .fixed-bottom{
  108. position: fixed;
  109. bottom: 0rpx;
  110. left: 0rpx;
  111. z-index: 99;
  112. width: 750rpx;
  113. height: 98rpx;
  114. display: flex;
  115. justify-content: center;
  116. align-items: center;
  117. border-top: 1rpx solid #E5E5E5;
  118. .btn{
  119. width: 320rpx;
  120. height: 82rpx;
  121. border-radius: 41rpx;
  122. margin: 0;
  123. padding: 0;
  124. font-size: 32rpx;
  125. display: flex;
  126. justify-content: center;
  127. align-items: center;
  128. }
  129. .btn1{
  130. border: 2rpx solid #555555;
  131. opacity: .5;
  132. }
  133. .btn2{
  134. background: #11D189;
  135. color: #FFFFFF;
  136. margin-left: 50rpx;
  137. }
  138. }
  139. </style>