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

204 lines
5.0 KiB

  1. <template>
  2. <view>
  3. <view class="head">
  4. <view class="list">
  5. <view class="lf-row-between">
  6. <view>供应商</view>
  7. <view class="lf-icon" @click="$url('/pages/canteen/classification/supplier')">
  8. <u-icon name="plus-circle" size="42"></u-icon>
  9. </view>
  10. </view>
  11. </view>
  12. <view class="list">
  13. <view class="lf-row-between">
  14. <view>采购清单</view>
  15. <view class="lf-icon" @click="$url('/pages/canteen/classification/index?type=2')">
  16. <u-icon name="plus-circle" size="42"></u-icon>
  17. </view>
  18. </view>
  19. <view class="lf-font-24 lf-color-gray">添加物资后可以编辑数量</view>
  20. </view>
  21. </view>
  22. <!-- 修饰条 -->
  23. <self-line></self-line>
  24. <!-- 收货时间 -->
  25. <view class="lf-row-between lf-p-30 lf-p-l-32 lf-p-r-32 lf-font-28">
  26. <view class="lf-color-black">收货时间</view>
  27. <picker mode="date" :value="date" @change="pickerChange">
  28. <view class="lf-color-555 lf-text-right" style="width: 400rpx;">{{ date }}</view>
  29. </picker>
  30. </view>
  31. <self-line></self-line>
  32. <!-- 物料table -->
  33. <view class="lf-p-32 lf-p-t-30 lf-p-b-30 lf-w-100 lf-h-maxcontent lf-border-box">
  34. <view class="lf-font-32 lf-font-bold">物资明细</view>
  35. <!-- 多个供应商多个table :headers="headers" :contents="contents" -->
  36. <view v-for="(item,index) in 2" class="lf-m-t-20">
  37. <view class="lf-m-b-10 lf-row-between">
  38. <text>我是供应商</text>
  39. <text>删除</text>
  40. </view>
  41. <wyb-table contentBgColor="#ecfaf5" :first-line-fixed="true" @onInputChange="onInputChange" width="max-content" height="800rpx"></wyb-table>
  42. </view>
  43. </view>
  44. <!-- 操作按钮 -->
  45. <view style="height: 100rpx;"></view>
  46. <view class="fixed-bottom">
  47. <button class="btn btn1" @click="save(1)">临时保存</button>
  48. <button class="btn btn2" @click="save(2)">保存并发单</button>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import wybTable from '@/components/wyb-table/wyb-table';
  54. export default {
  55. components: {
  56. wybTable
  57. },
  58. data(){
  59. return {
  60. headers: [{
  61. label: '菜品名称',
  62. key: 'name'
  63. },{
  64. label: '规格',
  65. key: 'spec'
  66. },{
  67. label: '税前价',
  68. key: 'pre_tax_price'
  69. },{
  70. label: '税后价',
  71. key: 'after_tax_price'
  72. }],
  73. contents: [],
  74. date: this.$shared.recordTime(new Date(), '-', 'date'), // 选择时间
  75. material_list: {} // 供应商,物资列表
  76. }
  77. },
  78. onLoad(){
  79. // 监听MaterialList被操作
  80. uni.$on('addMaterialList', res => {
  81. this.material_list = res;
  82. })
  83. },
  84. onShow(){
  85. console.log("material_list", this.material_list)
  86. },
  87. methods: {
  88. // 改接口废弃
  89. getMaterialList(){
  90. this.$http(this.API.API_CANTEEN_MATERIALLIST, {
  91. // category_id: 1 // 分类id 不传则显示默认分类
  92. }).then(res => {
  93. let list = res.data.material || [];
  94. let contents = list.map(item => {
  95. return {
  96. name: item.material.m_name,
  97. spec: item.name,
  98. pre_tax_price: {edit: true, value: item.tax_standard_price},
  99. after_tax_price: {edit: true, value: item.non_tax_standard_price},
  100. spec_id: item.id,
  101. material_id: item.material.id
  102. }
  103. })
  104. this.contents = contents;
  105. })
  106. },
  107. // table-input值被改变 todo
  108. onInputChange(event){
  109. console.log("检测到table input被更改", event);
  110. // this.contents[event.contentIndex][event.key].value = event.detailValue;
  111. },
  112. // 时间选择
  113. pickerChange(event){
  114. this.date = event.detail.value;
  115. },
  116. // 保存并发单
  117. save(){
  118. // todo
  119. console.log("dddddd", this.contents)
  120. return;
  121. let list = this.contents.map(item => {
  122. return {
  123. m_id: item.material_id,
  124. m_spec_id: item.spec_id,
  125. tax_price: item.pre_tax_price.value,
  126. non_tax_price: item.after_tax_price.value
  127. }
  128. });
  129. this.$http(this.API.API_CANTEEN_PURCHASEAPPLY, {
  130. data: list
  131. }).then(res => {
  132. console.log("save", res);
  133. this.$msg('操作成功');
  134. })
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped="scoped">
  140. .lf-m-t-5{
  141. margin-top: 5rpx;
  142. }
  143. .head{
  144. width: 750rpx;
  145. height: max-content;
  146. padding: 0 32rpx;
  147. box-sizing: border-box;
  148. .list{
  149. width: 100%;
  150. border-bottom: 1rpx solid #e5e5e5;
  151. padding: 30rpx 0;
  152. font-size: 28rpx;
  153. &:last-child{
  154. border-bottom: none;
  155. }
  156. .lf-icon{
  157. padding: 2rpx 10rpx;
  158. display: flex;
  159. align-items: center;
  160. justify-content: center;
  161. }
  162. }
  163. }
  164. .fixed-bottom{
  165. position: fixed;
  166. bottom: 0rpx;
  167. left: 0rpx;
  168. z-index: 99;
  169. width: 750rpx;
  170. height: 98rpx;
  171. display: flex;
  172. justify-content: center;
  173. align-items: center;
  174. border-top: 1rpx solid #E5E5E5;
  175. background-color: #FFFFFF;
  176. .btn{
  177. width: 320rpx;
  178. height: 82rpx;
  179. border-radius: 41rpx;
  180. margin: 0;
  181. padding: 0;
  182. font-size: 32rpx;
  183. display: flex;
  184. justify-content: center;
  185. align-items: center;
  186. }
  187. .btn1{
  188. border: 2rpx solid #555555;
  189. opacity: .5;
  190. }
  191. .btn2{
  192. background: #11D189;
  193. color: #FFFFFF;
  194. margin-left: 50rpx;
  195. }
  196. }
  197. </style>