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

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