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

243 lines
5.7 KiB

  1. <template>
  2. <view>
  3. <view class="box">
  4. <view class="title">报价清单</view>
  5. <view class="lf-font-24 lf-color-gray lf-m-t-5">请在以下物资信息表内填写报价</view>
  6. </view>
  7. <!-- 修饰条 -->
  8. <self-line></self-line>
  9. <view class="box lf-row-between relation">
  10. <view>
  11. <text class="title">关联食堂</text>
  12. <text class="lf-font-24 lf-color-555 lf-m-l-10">(多选)</text>
  13. </view>
  14. <view class="lf-font-24 lf-color-gray lf-text-right lf-row-center" style="width: 370rpx; justify-content: flex-end;" @click="switchRelation">
  15. <view class="lf-line-1">{{ selectName }}</view>
  16. <u-icon name="arrow-right" class="lf-text-vertical"></u-icon>
  17. </view>
  18. <view class="mask" :style="{top: node_top +'px'}" v-if="is_show" @click="is_show = false">
  19. <view class="list">
  20. <view class="lf-row-between item" v-for="(item, index) in relation_list" :key="index" @click.stop="selectItem(index)">
  21. <view>{{ item.canteen_name }}</view>
  22. <u-icon name="checkmark-circle" color="#1833F2" size="40" v-if="item.checked"></u-icon>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <self-line></self-line>
  28. <!-- 物料table -->
  29. <view class="box">
  30. <wyb-table :first-line-fixed="true" contentBgColor="#eef6fe" :headers="headers" :contents="contents" @onInputChange="onInputChange" width="max-content" height="800rpx"></wyb-table>
  31. </view>
  32. <!-- 操作按钮 -->
  33. <view class="fixed-bottom">
  34. <button class="btn btn1" @click="save(1)">临时保存</button>
  35. <button class="btn btn2" @click="save(2)">直接报价</button>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import wybTable from '@/components/wyb-table/wyb-table';
  41. let app = getApp();
  42. export default {
  43. components: {
  44. wybTable
  45. },
  46. data(){
  47. return {
  48. headers: [{
  49. label: '菜品名称',
  50. key: 'name'
  51. },{
  52. label: '规格',
  53. key: 'spec'
  54. },{
  55. label: '税前价',
  56. key: 'pre_tax_price'
  57. },{
  58. label: '税后价',
  59. key: 'after_tax_price'
  60. }],
  61. contents: [],
  62. is_show: false,
  63. relation_list: [],
  64. node_top: 0
  65. }
  66. },
  67. computed: {
  68. selectName(){
  69. let arr = [];
  70. this.relation_list.map(item => {
  71. if(item.checked){
  72. arr.push(item.canteen_name);
  73. }
  74. });
  75. let str = '请选择...';
  76. if(arr.length > 0){
  77. str = arr.join(',');
  78. }
  79. return str;
  80. }
  81. },
  82. onLoad(){
  83. this.getMaterialList();
  84. this.getCanteenList();
  85. },
  86. onReady(){
  87. let that = this;
  88. let info = uni.createSelectorQuery().select(".relation");
  89.     info.boundingClientRect(function(data) {
  90. let num = app.globalData.customBarH;
  91. num += data.height;
  92. num += data.top;
  93. that.node_top = num;
  94.    }).exec()
  95. },
  96. methods: {
  97. // 获取物资列表
  98. getMaterialList(){
  99. this.$http(this.API.API_SUPPLIER_MATERIALLIST, {
  100. supplier_id: 1
  101. }).then(res => {
  102. let list = res.data.material || [];
  103. let contents = list.map(item => {
  104. return {
  105. name: item.material.m_name,
  106. spec: item.name,
  107. pre_tax_price: {edit: true, value: item.tax_standard_price},
  108. after_tax_price: {edit: true, value: item.non_tax_standard_price},
  109. spec_id: item.id,
  110. material_id: item.material.id
  111. }
  112. })
  113. this.contents = contents;
  114. })
  115. },
  116. // 关联食堂列表
  117. getCanteenList(){
  118. this.$http(this.API.API_SUPPLIER_CANTEENLIST).then(res => {
  119. let list = res.data.list.map(item => {
  120. item.checked = false;
  121. return item;
  122. })
  123. this.relation_list = list;
  124. })
  125. },
  126. // 监听表格被输入
  127. onInputChange(event){
  128. console.log("检测到table input被更改", event);
  129. this.contents[event.contentIndex][event.key].value = event.detailValue;
  130. },
  131. // 切换显示关联食堂modal
  132. switchRelation(){
  133. this.is_show = !this.is_show;
  134. },
  135. // 选择食堂
  136. selectItem(index){
  137. this.relation_list[index].checked = !this.relation_list[index].checked;
  138. },
  139. // 保存
  140. save(_t){
  141. // TODO: 保存逻辑 & 食堂的参数传入 & tax_price和non_tax_price字段都不填时不上传
  142. console.log("dddddd", this.contents)
  143. let list = this.contents.map(item => {
  144. return {
  145. m_id: item.material_id,
  146. m_spec_id: item.spec_id,
  147. tax_price: item.pre_tax_price.value,
  148. non_tax_price: item.after_tax_price.value
  149. }
  150. });
  151. this.$http(this.API.API_SUPPLIER_QUOTATIONAPPLY, {
  152. data: list
  153. }).then(res => {
  154. console.log("save", res);
  155. this.$msg('操作成功');
  156. })
  157. }
  158. }
  159. }
  160. </script>
  161. <style>
  162. page{
  163. overflow: hidden;
  164. }
  165. </style>
  166. <style lang="scss" scoped="scoped">
  167. .lf-m-t-5{
  168. margin-top: 5rpx;
  169. }
  170. .box{
  171. padding: 30rpx 32rpx;
  172. width: 100%;
  173. height: max-content;
  174. box-sizing: border-box;
  175. }
  176. .title{
  177. color: #222222;
  178. font-size: 28rpx;
  179. font-weight: bold;
  180. }
  181. .fixed-bottom{
  182. position: fixed;
  183. bottom: 0rpx;
  184. left: 0rpx;
  185. z-index: 99;
  186. width: 750rpx;
  187. height: 98rpx;
  188. display: flex;
  189. justify-content: center;
  190. align-items: center;
  191. border-top: 1rpx solid #E5E5E5;
  192. .btn{
  193. width: 320rpx;
  194. height: 82rpx;
  195. border-radius: 41rpx;
  196. margin: 0;
  197. padding: 0;
  198. font-size: 32rpx;
  199. display: flex;
  200. justify-content: center;
  201. align-items: center;
  202. }
  203. .btn1{
  204. border: 2rpx solid #555555;
  205. opacity: .5;
  206. }
  207. .btn2{
  208. background: #1833F2;
  209. color: #FFFFFF;
  210. margin-left: 50rpx;
  211. }
  212. }
  213. .relation{
  214. position: relative;
  215. border-bottom: 1rpx solid #E5E5E5;
  216. }
  217. .mask{
  218. position: fixed;
  219. background-color: rgba(0,0,0,0.4);
  220. width: 100%;
  221. // top: 149px;
  222. bottom: 0;
  223. left: 0;
  224. z-index: 100;
  225. .list{
  226. min-height: max-content;
  227. max-height: 500rpx;
  228. overflow: scroll;
  229. background-color: #FFFFFF;
  230. width: 100%;
  231. .item{
  232. height: 92rpx;
  233. padding: 0 32rpx;
  234. border-bottom: 1rpx solid #E5E5E5;
  235. color: #222222;
  236. font-size: 24rpx;
  237. }
  238. }
  239. }
  240. </style>