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

346 lines
8.3 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"
  31. contentBgColor="#eef6fe"
  32. :headers="headers"
  33. :contents="contents"
  34. @onInputChange="onInputChange"
  35. width="100%" height="800rpx"></wyb-table>
  36. </view>
  37. <!-- 操作按钮 -->
  38. <view class="fixed-bottom">
  39. <button class="btn btn1" @click="save(0)">临时保存</button>
  40. <button class="btn btn2" @click="save(1)">直接报价</button>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import wybTable from '@/components/wyb-table/wyb-table';
  46. let app = getApp();
  47. export default {
  48. components: {
  49. wybTable
  50. },
  51. data(){
  52. return {
  53. headers: [{
  54. label: '菜品名称',
  55. key: 'name'
  56. },{
  57. label: '规格',
  58. key: 'spec'
  59. },{
  60. label: '单位',
  61. key: 'unit'
  62. },{
  63. label: '品牌',
  64. key: 'brand'
  65. },{
  66. label: '品质',
  67. key: 'quality_level'
  68. },{
  69. label: '报价',
  70. key: 'offer'
  71. }],
  72. contents: [],
  73. is_show: false,
  74. relation_list: [], // 关联食堂列表
  75. node_top: 0,
  76. code: '', // 订单号,批次号,如果有
  77. type: 0
  78. }
  79. },
  80. computed: {
  81. selectName(){
  82. let arr = [];
  83. this.relation_list.map(item => {
  84. if(item.checked){
  85. arr.push(item.canteen_name);
  86. }
  87. });
  88. let str = '请选择...';
  89. if(arr.length > 0){
  90. str = arr.join(',');
  91. }
  92. return str;
  93. }
  94. },
  95. onLoad(options){
  96. this.code = options.code || '';
  97. this.type = options.type || 0;
  98. if(options.type == 1){
  99. // 编辑,不可更换食堂
  100. this.editMaterialList();
  101. }else if(options.type == 2){
  102. // 复用订单号
  103. this.materialListByOrder();
  104. }else if(options.type == 3){
  105. // 复用批次号
  106. this.materialListByBatch();
  107. }else{
  108. // 单纯发起报价
  109. this.getMaterialList();
  110. }
  111. },
  112. onReady(){
  113. let that = this;
  114. let info = uni.createSelectorQuery().select(".relation");
  115.     info.boundingClientRect(function(data) {
  116. let num = app.globalData.customBarH;
  117. num += data.height;
  118. num += data.top;
  119. that.node_top = num;
  120.    }).exec()
  121. },
  122. methods: {
  123. // 获取物资列表
  124. getMaterialList(){
  125. this.$http(this.API.API_SUPPLIER_MATERIALLIST).then(res => {
  126. let list = res.data.spec || [];
  127. let contents = list.map(item => {
  128. return {
  129. name: item?.material?.m_name || '',
  130. material_id: item?.material?.id || 0,
  131. spec: item.name,
  132. spec_id: item.id,
  133. unit: item?.material?.unit?.unit_name || '',
  134. brand: item?.material?.brand || '',
  135. quality_level: item?.material?.quality_level || '',
  136. offer: {edit: true, value: ''}
  137. }
  138. })
  139. this.contents = contents;
  140. this.getCanteenList();
  141. })
  142. },
  143. // 编辑物资列表
  144. editMaterialList(){
  145. // this.$http(this.API.).then(res => {
  146. // console.log("editMaterialList", res);
  147. // })
  148. },
  149. // 复用报价订单号
  150. materialListByOrder(){
  151. this.$http(this.API.API_SUPPLIER_QUOTATIONREUSEBYORDER, {
  152. q_sn: this.code
  153. }).then(res => {
  154. console.log("materialListByOrder", res);
  155. let list = res.data.order || [];
  156. let canteen = res.data.canteen || [];
  157. let contents = list.map(item => {
  158. return {
  159. name: item?.material?.m_name || '',
  160. material_id: item?.material?.id || 0,
  161. spec: item.name,
  162. spec_id: item.id,
  163. unit: item?.material?.unit?.unit_name || '',
  164. brand: item?.material?.brand || '',
  165. quality_level: item?.material?.quality_level || '',
  166. offer: {edit: true, value: ''}
  167. }
  168. })
  169. this.contents = contents;
  170. this.getCanteenList(canteen);
  171. })
  172. },
  173. // 复用批次号
  174. materialListByBatch(){
  175. this.$http(this.API.API_SUPPLIER_QUOTATIONREUSEBYBATCH, {
  176. batch_sn: this.code
  177. }).then(res => {
  178. console.log("materialListByBatch", res);
  179. let list = res.data.order || [];
  180. let canteen = res.data.canteen || [];
  181. let contents = list.map(item => {
  182. return {
  183. name: item?.material?.m_name || '',
  184. material_id: item?.material?.id || 0,
  185. spec: item.name,
  186. spec_id: item.id,
  187. unit: item?.material?.unit?.unit_name || '',
  188. brand: item?.material?.brand || '',
  189. quality_level: item?.material?.quality_level || '',
  190. offer: {edit: true, value: ''}
  191. }
  192. })
  193. this.contents = contents;
  194. this.getCanteenList(canteen);
  195. })
  196. },
  197. // 关联食堂列表
  198. getCanteenList(canteen = []){
  199. this.$http(this.API.API_SUPPLIER_CANTEENLIST).then(res => {
  200. let list = res.data.list.map(item => {
  201. item.checked = false;
  202. canteen.map(ct => {
  203. if(ct == item.id){
  204. item.checked = true;
  205. }
  206. })
  207. return item;
  208. })
  209. this.relation_list = list;
  210. })
  211. },
  212. // 监听表格被输入
  213. onInputChange(event){
  214. this.contents[event.contentIndex][event.key].value = event.detailValue;
  215. },
  216. // 切换显示关联食堂modal
  217. switchRelation(){
  218. this.is_show = !this.is_show;
  219. },
  220. // 选择食堂
  221. selectItem(index){
  222. this.relation_list[index].checked = !this.relation_list[index].checked;
  223. },
  224. // 保存
  225. save(_t){
  226. // 物资列表
  227. let list = [];
  228. this.contents.map(item => {
  229. if(item.offer.value){
  230. list.push({
  231. m_id: item.material_id,
  232. m_spec_id: item.spec_id,
  233. offer: item.offer.value
  234. })
  235. }
  236. });
  237. // 关联食堂
  238. let canteen_ids = [];
  239. this.relation_list.map(item => {
  240. if(item.checked){
  241. canteen_ids.push(item.id);
  242. }
  243. })
  244. if(canteen_ids.length <= 0){
  245. return this.$msg('您未选择关联食堂哦')
  246. }
  247. if(list.length <= 0){
  248. return this.$msg('没有需要报价的物资')
  249. }
  250. // 操作状态,是保存还是直接发起
  251. let state = ['待发起', '待审核'][_t];
  252. this.$http(this.API.API_SUPPLIER_QUOTATIONAPPLY, {
  253. data: list,
  254. state: state,
  255. canteen_ids: canteen_ids
  256. }).then(res => {
  257. console.log("save", res);
  258. this.$msg('操作成功');
  259. })
  260. }
  261. }
  262. }
  263. </script>
  264. <style>
  265. page{
  266. overflow: hidden;
  267. }
  268. </style>
  269. <style lang="scss" scoped="scoped">
  270. .lf-m-t-5{
  271. margin-top: 5rpx;
  272. }
  273. .box{
  274. padding: 30rpx 32rpx;
  275. width: 100%;
  276. height: max-content;
  277. box-sizing: border-box;
  278. }
  279. .title{
  280. color: #222222;
  281. font-size: 28rpx;
  282. font-weight: bold;
  283. }
  284. .fixed-bottom{
  285. position: fixed;
  286. bottom: 0rpx;
  287. left: 0rpx;
  288. z-index: 99;
  289. width: 750rpx;
  290. height: 98rpx;
  291. display: flex;
  292. justify-content: center;
  293. align-items: center;
  294. border-top: 1rpx solid #E5E5E5;
  295. .btn{
  296. width: 320rpx;
  297. height: 82rpx;
  298. border-radius: 41rpx;
  299. margin: 0;
  300. padding: 0;
  301. font-size: 32rpx;
  302. display: flex;
  303. justify-content: center;
  304. align-items: center;
  305. }
  306. .btn1{
  307. border: 2rpx solid #555555;
  308. opacity: .5;
  309. }
  310. .btn2{
  311. background: #1833F2;
  312. color: #FFFFFF;
  313. margin-left: 50rpx;
  314. }
  315. }
  316. .relation{
  317. position: relative;
  318. border-bottom: 1rpx solid #E5E5E5;
  319. }
  320. .mask{
  321. position: fixed;
  322. background-color: rgba(0,0,0,0.4);
  323. width: 100%;
  324. // top: 149px;
  325. bottom: 0;
  326. left: 0;
  327. z-index: 100;
  328. .list{
  329. min-height: max-content;
  330. max-height: 500rpx;
  331. overflow: scroll;
  332. background-color: #FFFFFF;
  333. width: 100%;
  334. .item{
  335. height: 92rpx;
  336. padding: 0 32rpx;
  337. border-bottom: 1rpx solid #E5E5E5;
  338. color: #222222;
  339. font-size: 24rpx;
  340. }
  341. }
  342. }
  343. </style>