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

366 lines
9.0 KiB

  1. <template>
  2. <view>
  3. <view class="head">
  4. <view class="lf-row-between lf-color-gray list">
  5. <view>采购单 492461046128742764</view>
  6. </view>
  7. <view class="lf-row-between list">
  8. <image src="../../../static/logo.png" class="image"></image>
  9. <view class="info">
  10. <view class="lf-font-32 lf-color-black lf-font-bold">广西美味生活有限公司</view>
  11. <view class="lf-font-24 lf-color-555">广西南宁青秀区民族大道118号可爱大厦A座0930室</view>
  12. </view>
  13. </view>
  14. </view>
  15. <self-line></self-line>
  16. <view class="lf-p-l-32 lf-p-r-32 lf-border-box lf-bg-white">
  17. <lf-ysteps :stepList="stepList"></lf-ysteps>
  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 :first-line-fixed="true" contentBgColor="#eef6fe" :headers="headers" :contents="contents" @onButtonClick="onButtonClick" width="100%" height="350rpx"></wyb-table>
  23. </view>
  24. <view style="height: 100rpx;"></view>
  25. <!-- 操作按钮 -->
  26. <view class="fixed-bottom">
  27. <button class="btn btn1" @click="is_show_voucher = true">上传凭证</button>
  28. <button class="btn btn2">确认发货</button>
  29. </view>
  30. <!-- 弹出层-上传凭证 -->
  31. <u-popup v-model="is_show_voucher" mode="center" border-radius="20">
  32. <view class="popup-box">
  33. <view class="content">
  34. <view class="popup-title">上传凭证信息</view>
  35. <view class="popup-desc">请在此处上传检验检疫凭证售卖资质等证书</view>
  36. <view class="popup-images">
  37. <view class="popup-image-item" v-for="(item, index) in voucher_list" :key="index" @click="lookImage(index)">
  38. <image :src="item" mode="aspectFill"></image>
  39. <view class="remove-image" @click.stop="removeInage(index)">
  40. <u-icon name="close-circle"></u-icon>
  41. </view>
  42. </view>
  43. <view class="popup-image-item popup-image-item-after" @click="uploadImage" v-if="voucher_list.length < 6"></view>
  44. </view>
  45. </view>
  46. <view class="foot-btn">
  47. <u-button class="popup-btn" @click="is_show_voucher = false">取消</u-button>
  48. <u-button class="popup-btn" @click="submitImage">确定</u-button>
  49. </view>
  50. </view>
  51. </u-popup>
  52. </view>
  53. </template>
  54. <script>
  55. import lfYsteps from '@/components/lf-ysteps/lf-ysteps';
  56. import wybTable from '@/components/wyb-table/wyb-table';
  57. export default {
  58. components: { lfYsteps, wybTable },
  59. data(){
  60. return {
  61. stepList: [
  62. {
  63. time: '2021-07-23 13:23:52', // 左侧时间 -- 必选
  64. info: '订单创建', // 右侧内容 -- 可选
  65. isFinished: true, // 是否已完成(完成 index 为 √)-- 可选
  66. isActive: false, // 是否为当前节点 Active(当前节点 即使完成 index 也不会显示 √)-- 可选
  67. isShowSlot: false // 右侧是否有 Slot(显示在 右侧内容下方)-- 可选
  68. },
  69. {
  70. time: '2021-07-23 13:23:52',
  71. info: '采购订单发起,等待供应商接单',
  72. isFinished: false,
  73. isActive: true,
  74. isShowSlot: true
  75. },
  76. {
  77. time: '2021-07-23 13:23:52',
  78. info: '供应商已接单,正在装车',
  79. isFinished: false,
  80. isActive: true,
  81. isShowSlot: true
  82. }
  83. ],
  84. headers: [{
  85. key: 'name',
  86. label: '姓名'
  87. },{
  88. key: 'age',
  89. label: '年龄'
  90. },{
  91. key: 'sex',
  92. label: '性别'
  93. },{
  94. key: 'height',
  95. label: '身高'
  96. },{
  97. key: 'info',
  98. label: '描述'
  99. },{
  100. key: 'operation',
  101. label: '操作'
  102. }],
  103. contents: [{
  104. name: '张三',
  105. age: '18',
  106. sex: '男',
  107. height: '192cm',
  108. info: '无敌叫是',
  109. operation: {button: true, key: 'delete', value: '删除'}
  110. }, {
  111. name: '李四',
  112. age: '18',
  113. sex: '男',
  114. height: '192cm',
  115. info: '无敌叫是'
  116. }, {
  117. name: '赵五',
  118. age: '18',
  119. sex: '男',
  120. height: '192cm',
  121. info: '无敌叫是'
  122. },{
  123. name: '王六',
  124. age: '18',
  125. sex: '男',
  126. height: '192cm',
  127. info: '无敌叫是'
  128. }],
  129. is_show_voucher: false, // 是否显示凭证上传弹出层
  130. voucher_list: [], // 已上传的凭证列表
  131. voucher_count: 6 // 最多可以上传多少张凭证
  132. }
  133. },
  134. onLoad(){
  135. },
  136. methods: {
  137. // 监听table删除操作
  138. onButtonClick(event){
  139. uni.showModal({
  140. title: '温馨提示',
  141. content: '您确定移除该项吗?',
  142. success: result => {
  143. if(result.confirm){
  144. console.log("移除某一项", event);
  145. let { contentIndex } = event;
  146. this.contents.splice(contentIndex, 1);
  147. }
  148. }
  149. })
  150. },
  151. // 上传凭证图片
  152. uploadImage(){
  153. let current_count = this.voucher_count - this.voucher_list.length;
  154. if(current_count == 0) return;
  155. uni.chooseImage({
  156. count: current_count,
  157. complete: result => {
  158. this.voucher_list.push(...result.tempFilePaths);
  159. }
  160. })
  161. },
  162. // 预览图片
  163. lookImage(current){
  164. if(this.voucher_list.length <= 0) return;
  165. this.$u.throttle(() => {
  166. uni.previewImage({
  167. urls: this.voucher_list,
  168. current: current
  169. })
  170. }, 500);
  171. },
  172. // 移除图片
  173. removeInage(current){
  174. this.voucher_list.splice(current, 1);
  175. },
  176. // 用户点击确定,将图片上传至oss,并将url发送给后端
  177. submitImage(){
  178. let that = this;
  179. let voucher_list = that.voucher_list;
  180. if(voucher_list.length <= 0){
  181. return that.$msg('您未上传图片哦');
  182. };
  183. that.is_show_voucher = false;
  184. uni.showLoading({
  185. title: '正在上传中...'
  186. })
  187. let http_list = [];
  188. voucher_list.map(item => {
  189. let itemP = new Promise((resolve, reject) => {
  190. that.$http(that.API.XXXX, {url: item})
  191. .then(res => resolve(res))
  192. .catch(err => reject(err));
  193. })
  194. http_list.push(itemP);
  195. })
  196. // todo 上传对接
  197. Promise.all(http_list).then(res => {
  198. console.log("上传完毕", res);
  199. // 此处res需要处理一下,有可能格式是这样的,res.data.images
  200. that.$http(that.API.XXXX, {urls: res}).then(result => {
  201. uni.hideLoading();
  202. that.$msg('凭证已上传成功!')
  203. }).catch(err => uni.hideLoading());
  204. }).catch(err => {
  205. uni.hideLoading();
  206. uni.showModal({
  207. title: '',
  208. content: JSON.stringify(err),
  209. showCancel: false,
  210. confirmColor: '#1833F2'
  211. })
  212. })
  213. }
  214. }
  215. }
  216. </script>
  217. <style lang="scss" scoped="scoped">
  218. .head{
  219. padding: 0 32rpx;
  220. width: 750rpx;
  221. box-sizing: border-box;
  222. height: auto;
  223. .list{
  224. padding: 30rpx 0;
  225. border-bottom: 1rpx solid #e5e5e5;
  226. font-size: 28rpx;
  227. color: #555555;
  228. &:last-child{
  229. border-bottom: none;
  230. }
  231. .image{
  232. width: 140rpx;
  233. height: 140rpx;
  234. border-radius: 10rpx;
  235. }
  236. .info{
  237. display: flex;
  238. flex-direction: column;
  239. justify-content: space-around;
  240. width: 530rpx;
  241. height: 140rpx;
  242. }
  243. }
  244. }
  245. .fixed-bottom{
  246. position: fixed;
  247. bottom: 0rpx;
  248. left: 0rpx;
  249. z-index: 99;
  250. width: 750rpx;
  251. height: 98rpx;
  252. display: flex;
  253. justify-content: flex-end;
  254. align-items: center;
  255. border-top: 1rpx solid #E5E5E5;
  256. background-color: #FFFFFF;
  257. box-sizing: border-box;
  258. padding: 0 32rpx;
  259. .btn{
  260. width: 212rpx;
  261. height: 82rpx;
  262. border-radius: 41rpx;
  263. margin: 0;
  264. padding: 0;
  265. font-size: 32rpx;
  266. display: flex;
  267. justify-content: center;
  268. align-items: center;
  269. }
  270. .btn1{
  271. border: 2rpx solid #555555;
  272. opacity: .5;
  273. }
  274. .btn2{
  275. background: #1833F2;
  276. color: #FFFFFF;
  277. margin-left: 20rpx;
  278. }
  279. }
  280. .popup-box{
  281. width: 686rpx;
  282. // height: 727rpx;
  283. height: max-content;
  284. display: flex;
  285. justify-content: space-between;
  286. flex-direction: column;
  287. .content{
  288. .popup-title{
  289. font-size: 32rpx;
  290. font-weight: bold;
  291. color: #222222;
  292. text-align: center;
  293. margin-top: 40rpx;
  294. }
  295. .popup-desc{
  296. font-size: 28rpx;
  297. color: #555555;
  298. text-align: center;
  299. margin-top: 20rpx;
  300. margin-bottom: 18rpx;
  301. }
  302. .popup-images{
  303. display: flex;
  304. flex-wrap: wrap;
  305. padding: 22rpx;
  306. margin-bottom: 18rpx;
  307. .popup-image-item{
  308. width: 198rpx;
  309. height: 198rpx;
  310. margin: 8rpx;
  311. background: #F5F5F5;
  312. border-radius: 10rpx;
  313. position: relative;
  314. image{
  315. width: 100%;
  316. height: 100%;
  317. }
  318. .remove-image{
  319. position: absolute;
  320. right: -8rpx;
  321. top: -16rpx;
  322. color: #e74c3c;
  323. font-size: 40rpx;
  324. padding: 8rpx;
  325. }
  326. }
  327. .popup-image-item-after::after{
  328. content: '+';
  329. position: absolute;
  330. left: 30%;
  331. top: 14%;
  332. font-size: 100rpx;
  333. color: #777777;
  334. }
  335. }
  336. }
  337. .foot-btn{
  338. height: 90rpx;
  339. width: 100%;
  340. border-top: 1rpx solid #E5E5E5;
  341. display: flex;
  342. box-sizing: border-box;
  343. .popup-btn{
  344. width: 50%;
  345. height: 100%;
  346. border: none;
  347. border-radius: initial;
  348. &:last-child{
  349. border-left: 1rpx solid #E5E5E5;
  350. color: #1833F2;
  351. }
  352. }
  353. }
  354. }
  355. // 去掉u-button 外边框线
  356. /deep/.u-hairline-border::after{
  357. border: none;
  358. }
  359. </style>