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

286 lines
7.0 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(0)">临时保存</button>
  35. <button class="btn btn2" @click="save(1)">直接报价</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. q_sn: '' // 订单号,如果有
  66. }
  67. },
  68. computed: {
  69. selectName(){
  70. let arr = [];
  71. this.relation_list.map(item => {
  72. if(item.checked){
  73. arr.push(item.canteen_name);
  74. }
  75. });
  76. let str = '请选择...';
  77. if(arr.length > 0){
  78. str = arr.join(',');
  79. }
  80. return str;
  81. }
  82. },
  83. onLoad(options){
  84. this.q_sn = options.q_sn || '';
  85. // todo 临时保存的数据,下次进来再请求一个接口,页面显示出来
  86. this.getMaterialList();
  87. // this.getCanteenList();
  88. },
  89. onReady(){
  90. let that = this;
  91. let info = uni.createSelectorQuery().select(".relation");
  92.     info.boundingClientRect(function(data) {
  93. let num = app.globalData.customBarH;
  94. num += data.height;
  95. num += data.top;
  96. that.node_top = num;
  97.    }).exec()
  98. },
  99. methods: {
  100. // 获取物资列表
  101. getMaterialList(){
  102. this.$http(this.API.API_SUPPLIER_TEMPORARYQUOTATION, {
  103. supplier_id: getApp().globalData.supplier_id,
  104. // q_sn: this.q_sn // 传入订单号
  105. }).then(res => {
  106. let list = res.data.order || [];
  107. let contents = list.map(item => {
  108. let obj = {
  109. name: item.material?.m_name,
  110. material_id: item.material?.id,
  111. spec: item.name,
  112. spec_id: item.id,
  113. pre_tax_price: {edit: true, value: ''},
  114. after_tax_price: {edit: true, value: ''}
  115. }
  116. if(item.quotation && Object.keys(item.quotation).length){
  117. obj.pre_tax_price.value = item.quotation.tax_price;
  118. obj.after_tax_price.value = item.quotation.non_tax_price;
  119. }
  120. return obj;
  121. });
  122. this.contents = contents;
  123. this.getCanteenList(res.data.canteen || []);
  124. // let list = res.data.material || [];
  125. // let contents = list.map(item => {
  126. // console.log("item", item)
  127. // return {
  128. // name: item.material?.m_name,
  129. // spec: item.name,
  130. // pre_tax_price: {edit: true, value: item.tax_standard_price},
  131. // after_tax_price: {edit: true, value: item.non_tax_standard_price},
  132. // spec_id: item.id,
  133. // material_id: item.material?.id
  134. // }
  135. // })
  136. // this.contents = contents;
  137. })
  138. },
  139. // 关联食堂列表
  140. getCanteenList(canteen){
  141. this.$http(this.API.API_SUPPLIER_CANTEENLIST).then(res => {
  142. let list = res.data.list.map(item => {
  143. item.checked = false;
  144. canteen.map(ct => {
  145. if(ct == item.id){
  146. item.checked = true;
  147. }
  148. })
  149. return item;
  150. })
  151. this.relation_list = list;
  152. })
  153. },
  154. // 监听表格被输入
  155. onInputChange(event){
  156. this.contents[event.contentIndex][event.key].value = event.detailValue;
  157. },
  158. // 切换显示关联食堂modal
  159. switchRelation(){
  160. this.is_show = !this.is_show;
  161. },
  162. // 选择食堂
  163. selectItem(index){
  164. this.relation_list[index].checked = !this.relation_list[index].checked;
  165. },
  166. // 保存
  167. save(_t){
  168. // 物资列表
  169. let list = [];
  170. this.contents.map(item => {
  171. if(item.pre_tax_price.value || item.after_tax_price.value){
  172. list.push({
  173. m_id: item.material_id,
  174. m_spec_id: item.spec_id,
  175. tax_price: item.pre_tax_price.value,
  176. non_tax_price: item.after_tax_price.value
  177. })
  178. }
  179. });
  180. // 关联食堂
  181. let canteen_ids = [];
  182. this.relation_list.map(item => {
  183. if(item.checked){
  184. canteen_ids.push(item.id);
  185. }
  186. })
  187. if(canteen_ids.length <= 0){
  188. return this.$msg('您未选择关联食堂哦')
  189. }
  190. // 操作状态,是保存还是直接发起
  191. let state = ['待发单', '待审核'][_t];
  192. this.$http(this.API.API_SUPPLIER_QUOTATIONAPPLY, {
  193. data: list,
  194. state: state,
  195. canteen_ids: canteen_ids
  196. }).then(res => {
  197. console.log("save", res);
  198. this.$msg('操作成功');
  199. })
  200. }
  201. }
  202. }
  203. </script>
  204. <style>
  205. page{
  206. overflow: hidden;
  207. }
  208. </style>
  209. <style lang="scss" scoped="scoped">
  210. .lf-m-t-5{
  211. margin-top: 5rpx;
  212. }
  213. .box{
  214. padding: 30rpx 32rpx;
  215. width: 100%;
  216. height: max-content;
  217. box-sizing: border-box;
  218. }
  219. .title{
  220. color: #222222;
  221. font-size: 28rpx;
  222. font-weight: bold;
  223. }
  224. .fixed-bottom{
  225. position: fixed;
  226. bottom: 0rpx;
  227. left: 0rpx;
  228. z-index: 99;
  229. width: 750rpx;
  230. height: 98rpx;
  231. display: flex;
  232. justify-content: center;
  233. align-items: center;
  234. border-top: 1rpx solid #E5E5E5;
  235. .btn{
  236. width: 320rpx;
  237. height: 82rpx;
  238. border-radius: 41rpx;
  239. margin: 0;
  240. padding: 0;
  241. font-size: 32rpx;
  242. display: flex;
  243. justify-content: center;
  244. align-items: center;
  245. }
  246. .btn1{
  247. border: 2rpx solid #555555;
  248. opacity: .5;
  249. }
  250. .btn2{
  251. background: #1833F2;
  252. color: #FFFFFF;
  253. margin-left: 50rpx;
  254. }
  255. }
  256. .relation{
  257. position: relative;
  258. border-bottom: 1rpx solid #E5E5E5;
  259. }
  260. .mask{
  261. position: fixed;
  262. background-color: rgba(0,0,0,0.4);
  263. width: 100%;
  264. // top: 149px;
  265. bottom: 0;
  266. left: 0;
  267. z-index: 100;
  268. .list{
  269. min-height: max-content;
  270. max-height: 500rpx;
  271. overflow: scroll;
  272. background-color: #FFFFFF;
  273. width: 100%;
  274. .item{
  275. height: 92rpx;
  276. padding: 0 32rpx;
  277. border-bottom: 1rpx solid #E5E5E5;
  278. color: #222222;
  279. font-size: 24rpx;
  280. }
  281. }
  282. }
  283. </style>