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

377 lines
9.3 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="confirmDeliver">确认发货</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. </view>
  64. </template>
  65. <script>
  66. import { uploadFile } from '@/common/uploadFile.js'
  67. import lfYsteps from '@/components/lf-ysteps/lf-ysteps';
  68. import wybTable from '@/components/wyb-table/wyb-table';
  69. export default {
  70. components: { lfYsteps, wybTable },
  71. data(){
  72. return {
  73. stepList: [],
  74. headers: [{
  75. label: '菜品名称',
  76. key: 'name'
  77. },{
  78. label: '规格',
  79. key: 'spec'
  80. },{
  81. label: '税前价',
  82. key: 'pre_tax_price'
  83. },{
  84. label: '税后价',
  85. key: 'after_tax_price'
  86. }],
  87. contents: [],
  88. is_show_voucher: true, // 是否显示凭证上传弹出层
  89. voucher_list: [], // 已上传的凭证列表
  90. voucher_count: 6, // 最多可以上传多少张凭证
  91. type: 2, // 订单状态
  92. p_sn: '',
  93. order: {}
  94. }
  95. },
  96. onLoad(options){
  97. this.p_sn = options.p_sn;
  98. this.getData();
  99. },
  100. methods: {
  101. getData(){
  102. this.$http(this.API.API_SUPPLIER_PURCHASEDETAIL, {
  103. p_sn: this.p_sn
  104. }).then(res => {
  105. console.log("getData", res);
  106. let order = res.data.order || {};
  107. this.order = order;
  108. this.stepList = order.state_log.map((item, index) => {
  109. item.isFinished = false;
  110. if(index == order.state_log.length - 1){
  111. if(item.action == '订单已完成' || item.action == '订单已退款'){
  112. item.isFinished = true;
  113. }
  114. }
  115. return item;
  116. })
  117. // todo contents换成接口返回的值
  118. });
  119. },
  120. // 监听table删除操作
  121. onButtonClick(event){
  122. uni.showModal({
  123. title: '温馨提示',
  124. content: '您确定移除该项吗?',
  125. success: result => {
  126. if(result.confirm){
  127. console.log("移除某一项", event);
  128. let { contentIndex } = event;
  129. this.contents.splice(contentIndex, 1);
  130. }
  131. }
  132. })
  133. },
  134. // 上传凭证图片
  135. uploadImage(){
  136. let current_count = this.voucher_count - this.voucher_list.length;
  137. if(current_count == 0) return;
  138. uni.chooseImage({
  139. count: current_count,
  140. complete: result => {
  141. this.voucher_list.push(...result.tempFilePaths);
  142. }
  143. })
  144. },
  145. // 预览图片
  146. lookImage(current){
  147. if(this.voucher_list.length <= 0) return;
  148. this.$u.throttle(() => {
  149. uni.previewImage({
  150. urls: this.voucher_list,
  151. current: current
  152. })
  153. }, 500);
  154. },
  155. // 移除图片
  156. removeInage(current){
  157. this.voucher_list.splice(current, 1);
  158. },
  159. // 用户点击确定,将图片上传至oss,并将url发送给后端
  160. submitImage(){
  161. let that = this;
  162. let voucher_list = that.voucher_list;
  163. if(voucher_list.length <= 0){
  164. return that.$msg('您未上传图片哦');
  165. };
  166. that.is_show_voucher = false;
  167. uni.showLoading({
  168. title: '正在上传中...'
  169. })
  170. let http_list = [];
  171. voucher_list.map(item => {
  172. let itemP = new Promise((resolve, reject) => {
  173. uploadFile(item, (res) => {
  174. resolve(res);
  175. }, (err) => {
  176. reject(err);
  177. }, this);
  178. })
  179. http_list.push(itemP);
  180. })
  181. Promise.all(http_list).then(res => {
  182. console.log("上传完毕", res);
  183. let images = res.map(item => item.url);
  184. that.$http(that.API.API_SUPPLIER_PURCHASESAVEVOUCHER, {
  185. p_sn: that.p_sn,
  186. images: images,
  187. }).then(result => {
  188. uni.hideLoading();
  189. that.voucher_list = [];
  190. that.$msg('凭证已上传成功!')
  191. }).catch(err => uni.hideLoading());
  192. }).catch(err => {
  193. uni.hideLoading();
  194. uni.showModal({
  195. title: '',
  196. content: JSON.stringify(err),
  197. showCancel: false,
  198. confirmColor: '#1833F2'
  199. })
  200. })
  201. },
  202. // 立即接单
  203. orderTaking(){
  204. this.$http(this.API.API_SUPPLIER_PURCHASEORDERACCEPT, {
  205. p_sn: this.p_sn
  206. }).then(res => {
  207. console.log("orderTaking", res);
  208. this.$msg('接单成功')
  209. });
  210. },
  211. // 确认发货
  212. confirmDeliver(){
  213. this.$http(this.API.API_SUPPLIER_PURCHASEORDERSENDOUT, {
  214. p_sn: this.p_sn
  215. }).then(res => {
  216. console.log("confirmDeliver", res);
  217. this.$msg('确认收货成功')
  218. });
  219. }
  220. }
  221. }
  222. </script>
  223. <style lang="scss" scoped="scoped">
  224. .head{
  225. padding: 0 32rpx;
  226. width: 750rpx;
  227. box-sizing: border-box;
  228. height: auto;
  229. .list{
  230. padding: 30rpx 0;
  231. border-bottom: 1rpx solid #e5e5e5;
  232. font-size: 28rpx;
  233. color: #555555;
  234. &:last-child{
  235. border-bottom: none;
  236. }
  237. .image{
  238. width: 140rpx;
  239. height: 140rpx;
  240. border-radius: 10rpx;
  241. }
  242. .info{
  243. display: flex;
  244. flex-direction: column;
  245. justify-content: space-around;
  246. width: 530rpx;
  247. height: 140rpx;
  248. }
  249. }
  250. }
  251. .fixed-bottom{
  252. position: fixed;
  253. bottom: 0rpx;
  254. left: 0rpx;
  255. z-index: 99;
  256. width: 750rpx;
  257. height: 98rpx;
  258. display: flex;
  259. // justify-content: flex-end;
  260. align-items: center;
  261. border-top: 1rpx solid #E5E5E5;
  262. background-color: #FFFFFF;
  263. box-sizing: border-box;
  264. padding: 0 32rpx;
  265. .btn{
  266. width: 212rpx;
  267. height: 82rpx;
  268. border-radius: 41rpx;
  269. margin: 0;
  270. padding: 0;
  271. font-size: 32rpx;
  272. display: flex;
  273. justify-content: center;
  274. align-items: center;
  275. }
  276. .btn1{
  277. border: 2rpx solid #555555;
  278. opacity: .5;
  279. }
  280. .btn2{
  281. background: #1833F2;
  282. color: #FFFFFF;
  283. margin-left: 20rpx;
  284. }
  285. }
  286. .fixed-bottom>view{
  287. width: 100%;
  288. }
  289. .popup-box{
  290. width: 686rpx;
  291. // height: 727rpx;
  292. height: max-content;
  293. display: flex;
  294. justify-content: space-between;
  295. flex-direction: column;
  296. .content{
  297. .popup-title{
  298. font-size: 32rpx;
  299. font-weight: bold;
  300. color: #222222;
  301. text-align: center;
  302. margin-top: 40rpx;
  303. }
  304. .popup-desc{
  305. font-size: 28rpx;
  306. color: #555555;
  307. text-align: center;
  308. margin-top: 20rpx;
  309. margin-bottom: 18rpx;
  310. }
  311. .popup-images{
  312. display: flex;
  313. flex-wrap: wrap;
  314. padding: 22rpx;
  315. margin-bottom: 18rpx;
  316. .popup-image-item{
  317. width: 198rpx;
  318. height: 198rpx;
  319. margin: 8rpx;
  320. background: #F5F5F5;
  321. border-radius: 10rpx;
  322. position: relative;
  323. image{
  324. width: 100%;
  325. height: 100%;
  326. }
  327. .remove-image{
  328. position: absolute;
  329. right: -8rpx;
  330. top: -16rpx;
  331. color: #e74c3c;
  332. font-size: 40rpx;
  333. padding: 8rpx;
  334. }
  335. }
  336. .popup-image-item-after::after{
  337. content: '+';
  338. position: absolute;
  339. left: 30%;
  340. top: 14%;
  341. font-size: 100rpx;
  342. color: #777777;
  343. }
  344. }
  345. }
  346. .foot-btn{
  347. height: 90rpx;
  348. width: 100%;
  349. border-top: 1rpx solid #E5E5E5;
  350. display: flex;
  351. box-sizing: border-box;
  352. .popup-btn{
  353. width: 50%;
  354. height: 100%;
  355. border: none;
  356. border-radius: initial;
  357. &:last-child{
  358. border-left: 1rpx solid #E5E5E5;
  359. color: #1833F2;
  360. }
  361. }
  362. }
  363. }
  364. // 去掉u-button 外边框线
  365. /deep/.u-hairline-border::after{
  366. border: none;
  367. }
  368. </style>