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

427 lines
11 KiB

  1. <template>
  2. <view>
  3. <view class="head">
  4. <view class="lf-row-between lf-color-gray list">
  5. <view>采购单 {{ order.p_sn }}</view>
  6. </view>
  7. <view class="lf-row-between list" v-if="order.canteen">
  8. <image :src="order.canteen.logo" class="image"></image>
  9. <view class="info">
  10. <view class="lf-font-32 lf-color-black lf-font-bold">{{ order.canteen.canteen_name }}</view>
  11. <view class="lf-font-24 lf-color-555">{{ order.canteen.address }}</view>
  12. </view>
  13. </view>
  14. </view>
  15. <self-line></self-line>
  16. <view class="lf-border-box lf-bg-white">
  17. <lf-stepbar :list="stepList"></lf-stepbar>
  18. </view>
  19. <self-line></self-line>
  20. <view class="lf-m-t-30 lf-m-l-32">
  21. <view class="lf-font-32 lf-color-black lf-font-bold lf-m-b-20">物资明细</view>
  22. <wyb-table v-if="contents.length" :first-line-fixed="true" contentBgColor="#eef6fe" :headers="headers" :contents="contents" @onButtonClick="onButtonClick" width="max-content" height="350rpx"></wyb-table>
  23. </view>
  24. <view style="height: 100rpx;"></view>
  25. <!-- 操作按钮 -->
  26. <view class="fixed-bottom">
  27. <view v-if="type == 1" class="lf-row-flex-end">
  28. <button class="btn btn2" style="background-color: #1833F2;" @click="orderTaking">立即接单</button>
  29. </view>
  30. <view v-if="type == 2" class="lf-row-flex-end">
  31. <button class="btn btn1" @click="is_show_voucher = true">上传凭证</button>
  32. <button class="btn btn2" @click="is_show_receiving = true">确认发货</button>
  33. </view>
  34. <view v-if="type == 3" class="lf-row-flex-end">
  35. <view class="lf-font-32" style="color: #11D189;">已完成</view>
  36. </view>
  37. <view v-if="type == 4" class="lf-row-flex-end">
  38. <view class="lf-font-32" style="color: #222222;">已退单</view>
  39. </view>
  40. </view>
  41. <!-- 弹出层-上传凭证 -->
  42. <u-popup v-model="is_show_voucher" mode="center" border-radius="20">
  43. <view class="popup-box">
  44. <view class="content">
  45. <view class="popup-title">上传凭证信息</view>
  46. <view class="popup-desc">请在此处上传检验检疫凭证售卖资质等证书</view>
  47. <view class="popup-images">
  48. <view class="popup-image-item" v-for="(item, index) in voucher_list" :key="index" @click="lookImage(index)">
  49. <image :src="item" mode="aspectFill"></image>
  50. <view class="remove-image" @click.stop="removeInage(index)">
  51. <u-icon name="close-circle"></u-icon>
  52. </view>
  53. </view>
  54. <view class="popup-image-item popup-image-item-after" @click="uploadImage" v-if="voucher_list.length < 6"></view>
  55. </view>
  56. </view>
  57. <view class="foot-btn">
  58. <u-button class="popup-btn" @click="is_show_voucher = false">取消</u-button>
  59. <u-button class="popup-btn" @click="submitImage">确定</u-button>
  60. </view>
  61. </view>
  62. </u-popup>
  63. <!-- 弹出层-确认收货 -->
  64. <u-popup v-model="is_show_receiving" mode="center" border-radius="20">
  65. <view class="popup-box">
  66. <view class="content">
  67. <view class="popup-title">发货提醒</view>
  68. <view class="popup-desc">请填写车辆信息司机信息</view>
  69. <view class="lf-row-between popup-input">
  70. <view>车牌号</view>
  71. <input placeholder="请输入车牌号" v-model="l_p_num" />
  72. </view>
  73. <view class="lf-row-between popup-input">
  74. <view>司机姓名</view>
  75. <input placeholder="请输入司机姓名" v-model="driver_name" />
  76. </view>
  77. <view class="lf-row-between popup-input lf-m-b-30">
  78. <view>司机电话</view>
  79. <input placeholder="请输入司机电话" maxlength="11" v-model="driver_phone" />
  80. </view>
  81. </view>
  82. <view class="foot-btn">
  83. <u-button class="popup-btn" @click="is_show_receiving = false">取消</u-button>
  84. <u-button class="popup-btn" @click="confirmDeliver">确定</u-button>
  85. </view>
  86. </view>
  87. </u-popup>
  88. </view>
  89. </template>
  90. <script>
  91. import { uploadFile } from '@/common/uploadFile.js'
  92. import lfYsteps from '@/components/lf-ysteps/lf-ysteps';
  93. import wybTable from '@/components/wyb-table/wyb-table';
  94. export default {
  95. components: { lfYsteps, wybTable },
  96. data(){
  97. return {
  98. stepList: [],
  99. headers: [{
  100. label: '菜品名称',
  101. key: 'name'
  102. },{
  103. label: '规格',
  104. key: 'spec'
  105. },{
  106. label: '税前价',
  107. key: 'pre_tax_price'
  108. },{
  109. label: '税后价',
  110. key: 'after_tax_price'
  111. }],
  112. contents: [],
  113. is_show_voucher: false, // 是否显示凭证上传弹出层
  114. is_show_receiving: false,
  115. voucher_list: [], // 已上传的凭证列表
  116. voucher_count: 6, // 最多可以上传多少张凭证
  117. type: 2, // 订单状态
  118. p_sn: '',
  119. order: {},
  120. l_p_num: '',
  121. driver_name: '',
  122. driver_phone: ''
  123. }
  124. },
  125. onLoad(options){
  126. this.p_sn = options.p_sn;
  127. // this.getData();
  128. },
  129. methods: {
  130. getData(){
  131. this.$http(this.API.API_SUPPLIER_PURCHASEDETAIL, {
  132. p_sn: this.p_sn
  133. }).then(res => {
  134. console.log("getData", res);
  135. let order = res.data.order || {};
  136. this.order = order;
  137. this.stepList = order.state_log.map((item, index) => {
  138. item.isFinished = false;
  139. if(index == order.state_log.length - 1){
  140. if(item.action == '订单已完成' || item.action == '订单已退款'){
  141. item.isFinished = true;
  142. }
  143. }
  144. return item;
  145. })
  146. // todo contents换成接口返回的值
  147. });
  148. },
  149. // 监听table删除操作
  150. onButtonClick(event){
  151. uni.showModal({
  152. title: '温馨提示',
  153. content: '您确定移除该项吗?',
  154. success: result => {
  155. if(result.confirm){
  156. console.log("移除某一项", event);
  157. let { contentIndex } = event;
  158. this.contents.splice(contentIndex, 1);
  159. }
  160. }
  161. })
  162. },
  163. // 上传凭证图片
  164. uploadImage(){
  165. let current_count = this.voucher_count - this.voucher_list.length;
  166. if(current_count == 0) return;
  167. uni.chooseImage({
  168. count: current_count,
  169. complete: result => {
  170. this.voucher_list.push(...result.tempFilePaths);
  171. }
  172. })
  173. },
  174. // 预览图片
  175. lookImage(current){
  176. if(this.voucher_list.length <= 0) return;
  177. this.$u.throttle(() => {
  178. uni.previewImage({
  179. urls: this.voucher_list,
  180. current: current
  181. })
  182. }, 500);
  183. },
  184. // 移除图片
  185. removeInage(current){
  186. this.voucher_list.splice(current, 1);
  187. },
  188. // 用户点击确定,将图片上传至oss,并将url发送给后端
  189. submitImage(){
  190. let that = this;
  191. let voucher_list = that.voucher_list;
  192. if(voucher_list.length <= 0){
  193. return that.$msg('您未上传图片哦');
  194. };
  195. that.is_show_voucher = false;
  196. uni.showLoading({
  197. title: '正在上传中...'
  198. })
  199. let http_list = [];
  200. voucher_list.map(item => {
  201. let itemP = new Promise((resolve, reject) => {
  202. uploadFile(item, (res) => {
  203. resolve(res);
  204. }, (err) => {
  205. reject(err);
  206. }, this);
  207. })
  208. http_list.push(itemP);
  209. })
  210. Promise.all(http_list).then(res => {
  211. console.log("上传完毕", res);
  212. let images = res.map(item => item.url);
  213. that.$http(that.API.API_SUPPLIER_PURCHASESAVEVOUCHER, {
  214. p_sn: that.p_sn,
  215. images: images,
  216. }).then(result => {
  217. uni.hideLoading();
  218. that.voucher_list = [];
  219. that.$msg('凭证已上传成功!')
  220. }).catch(err => uni.hideLoading());
  221. }).catch(err => {
  222. uni.hideLoading();
  223. uni.showModal({
  224. title: '',
  225. content: JSON.stringify(err),
  226. showCancel: false,
  227. confirmColor: '#1833F2'
  228. })
  229. })
  230. },
  231. // 立即接单
  232. orderTaking(){
  233. this.$http(this.API.API_SUPPLIER_PURCHASEORDERACCEPT, {
  234. p_sn: this.p_sn
  235. }).then(res => {
  236. console.log("orderTaking", res);
  237. this.$msg('接单成功')
  238. });
  239. },
  240. // 确认发货
  241. confirmDeliver(){
  242. let l_p_num = this.l_p_num;
  243. let driver_name = this.driver_name;
  244. let driver_phone = this.driver_phone;
  245. if(!l_p_num){
  246. return this.$msg('请输入车牌号')
  247. }else if(!driver_name){
  248. return this.$msg('请输入司机姓名')
  249. }else if(!driver_phone){
  250. return this.$msg('请输入司机电话')
  251. }
  252. this.is_show_receiving = false;
  253. this.$http(this.API.API_SUPPLIER_PURCHASEORDERSENDOUT, {
  254. p_sn: this.p_sn
  255. }).then(res => {
  256. console.log("confirmDeliver", res);
  257. this.$msg('确认收货成功')
  258. });
  259. }
  260. }
  261. }
  262. </script>
  263. <style lang="scss" scoped="scoped">
  264. .head{
  265. padding: 0 32rpx;
  266. width: 750rpx;
  267. box-sizing: border-box;
  268. height: auto;
  269. .list{
  270. padding: 30rpx 0;
  271. border-bottom: 1rpx solid #e5e5e5;
  272. font-size: 28rpx;
  273. color: #555555;
  274. &:last-child{
  275. border-bottom: none;
  276. }
  277. .image{
  278. width: 140rpx;
  279. height: 140rpx;
  280. border-radius: 10rpx;
  281. }
  282. .info{
  283. display: flex;
  284. flex-direction: column;
  285. justify-content: space-around;
  286. width: 530rpx;
  287. height: 140rpx;
  288. }
  289. }
  290. }
  291. .fixed-bottom{
  292. position: fixed;
  293. bottom: 0rpx;
  294. left: 0rpx;
  295. z-index: 99;
  296. width: 750rpx;
  297. height: 98rpx;
  298. display: flex;
  299. // justify-content: flex-end;
  300. align-items: center;
  301. border-top: 1rpx solid #E5E5E5;
  302. background-color: #FFFFFF;
  303. box-sizing: border-box;
  304. padding: 0 32rpx;
  305. .btn{
  306. width: 212rpx;
  307. height: 82rpx;
  308. border-radius: 41rpx;
  309. margin: 0;
  310. padding: 0;
  311. font-size: 32rpx;
  312. display: flex;
  313. justify-content: center;
  314. align-items: center;
  315. }
  316. .btn1{
  317. border: 2rpx solid #555555;
  318. opacity: .5;
  319. }
  320. .btn2{
  321. background: #1833F2;
  322. color: #FFFFFF;
  323. margin-left: 20rpx;
  324. }
  325. }
  326. .fixed-bottom>view{
  327. width: 100%;
  328. }
  329. .popup-box{
  330. width: 686rpx;
  331. // height: 727rpx;
  332. height: max-content;
  333. display: flex;
  334. justify-content: space-between;
  335. flex-direction: column;
  336. .content{
  337. .popup-title{
  338. font-size: 32rpx;
  339. font-weight: bold;
  340. color: #222222;
  341. text-align: center;
  342. margin-top: 40rpx;
  343. }
  344. .popup-desc{
  345. font-size: 28rpx;
  346. color: #555555;
  347. text-align: center;
  348. margin-top: 20rpx;
  349. margin-bottom: 18rpx;
  350. }
  351. .popup-images{
  352. display: flex;
  353. flex-wrap: wrap;
  354. padding: 22rpx;
  355. margin-bottom: 18rpx;
  356. .popup-image-item{
  357. width: 198rpx;
  358. height: 198rpx;
  359. margin: 8rpx;
  360. background: #F5F5F5;
  361. border-radius: 10rpx;
  362. position: relative;
  363. image{
  364. width: 100%;
  365. height: 100%;
  366. }
  367. .remove-image{
  368. position: absolute;
  369. right: -8rpx;
  370. top: -16rpx;
  371. color: #e74c3c;
  372. font-size: 40rpx;
  373. padding: 8rpx;
  374. }
  375. }
  376. .popup-image-item-after::after{
  377. content: '+';
  378. position: absolute;
  379. left: 30%;
  380. top: 14%;
  381. font-size: 100rpx;
  382. color: #777777;
  383. }
  384. }
  385. .popup-input{
  386. padding: 0 60rpx;
  387. box-sizing: border-box;
  388. height: 90rpx;
  389. font-size: 28rpx;
  390. color: #555555;
  391. input{
  392. text-align: right;
  393. }
  394. }
  395. }
  396. .foot-btn{
  397. height: 90rpx;
  398. width: 100%;
  399. border-top: 1rpx solid #E5E5E5;
  400. display: flex;
  401. box-sizing: border-box;
  402. .popup-btn{
  403. width: 50%;
  404. height: 100%;
  405. border: none;
  406. border-radius: initial;
  407. &:last-child{
  408. border-left: 1rpx solid #E5E5E5;
  409. color: #1833F2;
  410. }
  411. }
  412. }
  413. }
  414. // 去掉u-button 外边框线
  415. /deep/.u-hairline-border::after{
  416. border: none;
  417. }
  418. </style>