arrival.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. <template>
  2. <view class="app-content">
  3. <view v-if="!$util.isEmpty(detailInfo)" class="info-content_box">
  4. <view class="module-com content-box">
  5. <view class="commodity-view">
  6. <view style="text-align:right;margin-right:20upx;padding-top:10upx;" v-if="detailInfo.book == 1 && detailInfo.status == 2 && parseFloat(detailInfo.actPrice) == 0">
  7. <button class="admin-button-com default middle" @click="usePrice(detailInfo,0)" style="margin-right:20upx;">使用填单价</button>
  8. <button class="admin-button-com default middle" @click="usePrice(detailInfo,1)" style="margin-right:20upx;">使用自带价</button>
  9. <button class="admin-button-com blue middle" @click="addItem(detailInfo)">添加花材</button>
  10. </view>
  11. <view class="commodity-list">
  12. <view v-for="(s, idx) in detailInfo.product" :key="idx" class="commodity-item" style="position:relative;">
  13. <image class="item-icon" :src="s.cover" alt="" @click="pageTo({url:'/admin/item/detail?id='+s.productId})" />
  14. <!-- <button v-if="detailInfo.book == 1 && detailInfo.status == 2 && parseFloat(detailInfo.actPrice) == 0" style="position:absolute;left:26upx;font-size:22upx;" class="admin-button-com default mini-btn" @click="changeOption(s)">更换</button> -->
  15. <button v-if="detailInfo.book == 1 && detailInfo.status == 2 && parseFloat(detailInfo.actPrice) == 0" style="position:absolute;top:95upx;left:26upx;font-size:22upx;" class="admin-button-com default mini-btn" @click="delOption(s)">删除</button>
  16. <text style="position:absolute;left:595upx;top:120upx;color:#CCCCCC;font-size:21upx;width:110upx;">剩 {{ s.stock }}</text>
  17. <text style="position:absolute;left:442upx;top:120upx;color:#CCCCCC;font-size:21upx;width:110upx;">成本{{ s.cost?parseFloat(s.cost):0 }}</text>
  18. <view class="item-info">
  19. <view class="info-line">
  20. <text class="item-name" @click="pageTo({url:'/admin/item/detail?id='+s.productId})">{{ s.name }}</text>
  21. <text class="item-price">
  22. <text class="unit"></text>
  23. <text class="price"><text>{{s.xhPreNum}}{{s.xhUnitName}}</text></text>
  24. </text>
  25. </view>
  26. <view class="info-line">
  27. <text class="item-type"></text>
  28. <view class="item-count" style="width:310upx;">
  29. <input type="number" class="num" :class="[Number(s.xhNum)>Number(s.stock) ? 'stock-red' : '']" v-model="s.xhNum" placeholder="数量" style="width:100upx;" />
  30. <input type="digit" class="price" :class="[Number(s.cost)>Number(s.currentHdPrice) ? 'cost-blue' : '']" v-model="s.currentHdPrice" placeholder="价格" style="width:120upx;" />
  31. <text style="display:inline-block;height:50upx;line-height:50upx;">价格</text>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="summary-bar">
  38. <view class="operate-view">合计 ¥{{ itemPrice }},成本 ¥{{ itemCost }},利润 ¥{{ parseFloat((Number(itemPrice)-Number(itemCost)).toFixed(2)) }}</view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="content-box price-detail">
  43. <view class="module-com input-line-wrap">
  44. <tui-list-cell class="line-cell" :hover="false">
  45. <view class="tui-title">客户</view>
  46. <view class="detail-price_box" style="font-size: 28upx;">{{ detailInfo.customName||'' }}</view>
  47. </tui-list-cell>
  48. <tui-list-cell class="line-cell" :hover="false">
  49. <view class="tui-title">商品金额</view>
  50. <view class="detail-price_box" style="font-size: 28upx;">¥{{itemPrice}}</view>
  51. </tui-list-cell>
  52. <tui-list-cell class="line-cell" :hover="false">
  53. <view class="tui-title">总计</view>
  54. <view class="detail-price_box red" style="font-size: 28upx;">¥{{allPrice}}</view>
  55. </tui-list-cell>
  56. <tui-list-cell class="line-cell" :hover="false">
  57. <view class="tui-title">预付金额</view>
  58. <view class="detail-price_box red" style="font-size: 28upx;">¥{{ detailInfo.bookPrice ? parseFloat(detailInfo.bookPrice) : 0}}</view>
  59. </tui-list-cell>
  60. <tui-list-cell class="line-cell" :hover="false">
  61. <view class="tui-title">结账</view>
  62. <view class="detail-price_box" style="font-size: 28upx;color:green;" v-if="settlePrice > 0">
  63. 退 ¥{{settlePrice}},确认后自动退款
  64. </view>
  65. <view class="detail-price_box" style="font-size: 28upx;color:red;" v-else-if="settlePrice < 0">
  66. 欠 ¥{{Math.abs(settlePrice)}},确认后变成欠款单
  67. </view>
  68. <view class="detail-price_box" style="font-size: 28upx;" v-else>0</view>
  69. </tui-list-cell>
  70. <tui-list-cell class="line-cell" :hover="false">
  71. <div class="tui-title">账单日期</div>
  72. <view class="detail-price_box">
  73. <button class="admin-button-com middle" :class="[todayBill == 1 ? 'blue' : 'default']" @click="todayBill=1">今天</button>
  74. <button class="admin-button-com middle" :class="[todayBill == 0 ? 'blue' : 'default']" @click="todayBill=0" style="margin-left:30upx;">昨天</button>
  75. </view>
  76. </tui-list-cell>
  77. <tui-list-cell class="line-cell" :hover="false">
  78. <div class="tui-title">允许低于成本</div>
  79. <view class="detail-price_box">
  80. <switch style="transform:scale(0.7,0.7)" :checked="lessCostCould == 0 ? false : true" @change="lessChangeFn" />
  81. </view>
  82. </tui-list-cell>
  83. </view>
  84. </view>
  85. </view>
  86. <view class="app-footer">
  87. <button class="admin-button-com big default" @click="goBack()" style="margin-left:10upx;">取消</button>
  88. <button class="admin-button-com big default" @click="savePrice()" style="margin:0 10upx 0 10upx;">保存</button>
  89. <button class="admin-button-com big blue" @click="commitItem()" style="margin-right:10upx;">确认提交</button>
  90. </view>
  91. </view>
  92. </template>
  93. <script>
  94. import { mapGetters } from "vuex";
  95. import TuiListCell from "@/components/plugin/list-cell";
  96. import { getArrivalDetail,arrival } from "@/api/order/index";
  97. import { modifyBookItem,delItem } from "@/api/order-item";
  98. export default {
  99. name: "arrival",
  100. components: {
  101. TuiListCell
  102. },
  103. mixins: [],
  104. data() {
  105. return {
  106. detailInfo: {},
  107. itemPrice:0,
  108. itemCost:0,
  109. settlePrice:0,
  110. sendCost:0,
  111. packCost:0,
  112. addSelectItem:1,
  113. lessCostCould:0,
  114. todayBill:1
  115. };
  116. },
  117. onLoad(){
  118. //返回上一页时不需要刷新
  119. let pages = getCurrentPages();
  120. let prevPage = pages[ pages.length - 2 ];
  121. prevPage.$vm.fromDetail = {status:1}
  122. },
  123. onShow() {
  124. if(this.addSelectItem == 1){
  125. this.init()
  126. this.addSelectItem = 0
  127. }
  128. },
  129. computed: {
  130. ...mapGetters({ loginInfo: "getLoginInfo" }),
  131. allPrice() {
  132. let price = 0
  133. this.itemPrice = 0
  134. this.itemCost = 0
  135. this.totalWeight = 0
  136. if (this.detailInfo && this.detailInfo.product) {
  137. for (const item of this.detailInfo.product) {
  138. if(item.currentHdPrice){
  139. let currentPrice = Number(item.xhNum) * Number(item.currentHdPrice)
  140. currentPrice = currentPrice.toFixed(2)
  141. this.itemPrice = Number(this.itemPrice) + Number(currentPrice)
  142. this.itemPrice.toFixed(2)
  143. let currentCost = Number(item.xhNum)*Number(item.cost)
  144. currentCost = currentCost.toFixed(2)
  145. this.itemCost = Number(this.itemCost)+Number(currentCost)
  146. this.itemCost.toFixed(2)
  147. }
  148. }
  149. }
  150. this.itemCost = parseFloat(this.itemCost.toFixed(2))
  151. this.itemPrice = parseFloat(this.itemPrice.toFixed(2))
  152. price = Number(this.itemPrice)
  153. if(Number(this.sendCost)>0){
  154. price = price + Number(this.sendCost)
  155. }
  156. if(Number(this.packCost)>0){
  157. price = price + Number(this.packCost)
  158. }
  159. price = parseFloat(price.toFixed(2))
  160. this.settlePrice = Number(this.detailInfo.bookPrice) - Number(price)
  161. this.settlePrice = parseFloat(this.settlePrice.toFixed(2))
  162. return price
  163. }
  164. },
  165. methods: {
  166. changeBill(e){
  167. this.todayBill = e.detail.value == true ? 1 : 0;
  168. },
  169. lessChangeFn(e){
  170. this.lessCostCould = e.detail.value == true ? 1 : 0;
  171. },
  172. usePrice(info,flag){
  173. if(info.product && !this.$util.isEmpty(info.product)){
  174. info.product.forEach((item,idx,array) => {
  175. if(flag == 0){
  176. item.currentHdPrice = item.itemModifyPrice
  177. }else{
  178. item.currentHdPrice = item.itemSalePrice
  179. }
  180. })
  181. this.$forceUpdate()
  182. }
  183. },
  184. changeOption(info){
  185. let id = info.id ? info.id : 0
  186. let orderSn = info.orderSn ? info.orderSn : ''
  187. this.$util.pageTo({url: '/admin/item/change?id='+id+'&orderSn='+orderSn})
  188. },
  189. addItem(info){
  190. let id = info.id ? info.id : 0
  191. this.$util.pageTo({url: '/admin/item/select?id='+id})
  192. },
  193. delOption(item){
  194. let that = this
  195. that.$util.confirmModal({content:'确认删除?'},() => {
  196. delItem({id:that.detailInfo.id,smallId:item.id}).then(res=>{
  197. if(res.code == 1){
  198. that.$msg(res.msg)
  199. that.init()
  200. }
  201. })
  202. })
  203. },
  204. goBack(){
  205. uni.navigateBack({ delta: 1 })
  206. },
  207. async init() {
  208. const res = await getArrivalDetail({ id: this.option.id })
  209. this.detailInfo = res.data;
  210. this.sendCost = res.data.sendCost ? parseFloat(res.data.sendCost) : 0
  211. this.packCost = res.data.packCost ? parseFloat(res.data.packCost) : 0
  212. },
  213. savePrice(){
  214. if(this.$util.isEmpty(this.detailInfo.product)){
  215. this.$msg('没有花材信息')
  216. return false
  217. }
  218. this.$util.confirmModal({content:'确认保存?'},() => {
  219. const data = this.detailInfo.product.map(ele => {
  220. return { orderSn: ele.orderSn, xhNum:ele.xhNum,xhUnitPrice:ele.currentHdPrice,id:ele.id}
  221. })
  222. modifyBookItem({data:data,id:this.detailInfo.id,packCost:this.packCost,sendCost:this.sendCost}).then(res=>{
  223. if(res.code == 1){
  224. this.$msg(res.msg)
  225. }
  226. })
  227. })
  228. },
  229. commitItem(){
  230. let product = []
  231. let hasError = false
  232. let that = this
  233. let hasLessCostPrice = false
  234. if (this.detailInfo && this.detailInfo.product) {
  235. for (const item of this.detailInfo.product) {
  236. if(item.currentHdPrice.length <= 0){
  237. this.$msg('请填写价格,价格要大于0')
  238. hasError = true;
  239. break;
  240. }
  241. if(this.$util.isEmpty(item.xhNum) || Number(item.xhNum) < 0){
  242. this.$msg('请填写到货数,没有填0')
  243. hasError = true;
  244. break;
  245. }
  246. let num = item.xhNum ? Number(item.xhNum) : 0
  247. let price = item.currentHdPrice ? Number(item.currentHdPrice) : 0
  248. let productId = item.productId || 0
  249. product = [...product,{productId,price,num}]
  250. if(Number(item.cost)>Number(item.currentHdPrice)){
  251. hasLessCostPrice = true
  252. }
  253. }
  254. }
  255. if(hasLessCostPrice == true && this.lessCostCould == 0){
  256. this.$msg('有花材低于成本销售,请允许')
  257. return false
  258. }
  259. if(hasError == true){
  260. return false
  261. }
  262. that.$util.confirmModal({content:'确认提交?'},() => {
  263. uni.showLoading({mask:true})
  264. arrival({id:that.option.id,product:JSON.stringify(product),packCost:that.packCost,sendCost:that.sendCost,todayBill:that.todayBill}).then(res=>{
  265. uni.hideLoading()
  266. if(res.code == 1){
  267. let id = res.data.id ? res.data.id : 0
  268. that.pageTo({url: '/pagesOrder/result?id='+id,type:2})
  269. }
  270. })
  271. })
  272. }
  273. }
  274. };
  275. </script>
  276. <style lang="scss" scoped>
  277. .info-content_box {
  278. padding: 15upx 20upx 120upx;
  279. & > .title {
  280. color: #666666;
  281. font-size: 28upx;
  282. font-weight: 600;
  283. padding: 30upx 3upx;
  284. }
  285. & .address-des_bx {
  286. display: flex;
  287. padding: 20upx 10upx 30upx 20upx;
  288. & > view:nth-child(1) {
  289. flex: 1;
  290. margin-top: 10upx;
  291. & > view:nth-child(1) {
  292. color: #333333;
  293. font-size: 32upx;
  294. font-weight: bold;
  295. }
  296. & > view:nth-child(2) {
  297. color: #666666;
  298. font-size: 28upx;
  299. font-weight: 400;
  300. margin-top: 20upx;
  301. }
  302. }
  303. & > view:nth-child(2) {
  304. display: flex;
  305. & .icondianhua1 {
  306. font-size: 50upx;
  307. color: #3385ff;
  308. margin-left: 0upx;
  309. }
  310. }
  311. }
  312. .bills-info_box {
  313. padding: 30upx 20upx 30upx;
  314. & > .order-info_box {
  315. display: flex;
  316. align-items: center;
  317. font-size: 26upx;
  318. font-weight: 400;
  319. margin-bottom: 5upx;
  320. & > view:nth-child(1) {
  321. color: #999999;
  322. width: 135upx;
  323. text-align: right;
  324. }
  325. & > view:nth-child(2) {
  326. color: #333333;
  327. }
  328. & > .price {
  329. flex: 1;
  330. font-size: 30upx;
  331. color: #333333;
  332. display: flex;
  333. align-items: center;
  334. justify-content: flex-end;
  335. & .iconxiangyou {
  336. color: #999999;
  337. font-size: 25upx;
  338. margin-left: 12upx;
  339. }
  340. }
  341. }
  342. }
  343. .content-box {
  344. background-color: #ffffff;
  345. border-radius: 10upx;
  346. }
  347. .commodity-view {
  348. display: flex;
  349. flex-direction: column;
  350. .commodity-list {
  351. padding: 20upx;
  352. .commodity-item {
  353. display: flex;
  354. margin-bottom: 20upx;
  355. .item-icon {
  356. flex-shrink: 0;
  357. width: 140upx;
  358. height: 140upx;
  359. }
  360. .item-info {
  361. display: flex;
  362. flex-direction: column;
  363. justify-content: center;
  364. flex: 1;
  365. margin-left: 20upx;
  366. .info-line {
  367. margin-bottom: 20upx;
  368. display: flex;
  369. justify-content: space-between;
  370. align-items: flex-end;
  371. .item-name {
  372. color: black;
  373. font-size: 30upx;
  374. font-weight: 700;
  375. overflow: hidden;
  376. white-space: nowrap;
  377. text-overflow: ellipsis;
  378. width:360upx;
  379. }
  380. .item-price {
  381. color: #333;
  382. font-size: 22upx;
  383. .price {
  384. font-size:25upx;
  385. }
  386. }
  387. .item-type {
  388. color: #999;
  389. font-size: 24upx;
  390. }
  391. .item-count {
  392. color: #666;
  393. font-size: 24upx;
  394. width:380upx;
  395. .price{
  396. text-align: center;
  397. width:150upx;
  398. height:20upx;
  399. border:2upx solid #cccccc;
  400. float:right;
  401. margin-right:30upx;
  402. }
  403. .num{
  404. text-align: center;
  405. width:150upx;
  406. height:20upx;
  407. border:2upx solid #cccccc;
  408. float:right;
  409. }
  410. .stock-red{
  411. border:4upx solid red;
  412. color:red;
  413. font-weight:bold;
  414. }
  415. .cost-blue{
  416. border:4upx solid blue;
  417. color:blue;
  418. font-weight:bold;
  419. }
  420. }
  421. }
  422. }
  423. }
  424. }
  425. .summary-bar {
  426. padding: 0 20upx;
  427. height: 90upx;
  428. display: flex;
  429. align-items: center;
  430. justify-content: space-between;
  431. border-top: 1upx solid #eeeeee;
  432. .operate-view {
  433. width:100%;
  434. text-align: right;
  435. color: black;
  436. font-size:28upx;
  437. font-weight:bold;
  438. .iconfont {
  439. margin-right: 20upx;
  440. font-size: 40upx;
  441. }
  442. }
  443. .describe-view {
  444. display: flex;
  445. align-items: center;
  446. color: #333;
  447. font-size: 24upx;
  448. .price {
  449. font-weight: bold;
  450. font-size: 28upx;
  451. }
  452. }
  453. }
  454. }
  455. .shipping-address {
  456. display: flex;
  457. align-items: center;
  458. margin-top: 20upx;
  459. & > view:nth-child(1) {
  460. color: #999999;
  461. font-size: 28upx;
  462. font-weight: 400;
  463. display: inline-block;
  464. padding: 30upx 0 30upx 20upx;
  465. flex: 1;
  466. & > text {
  467. color: #333333;
  468. font-weight: 600;
  469. }
  470. }
  471. & > view:nth-child(2) {
  472. font-size: 60upx;
  473. color: #d6e7ff;
  474. margin-right: 10upx;
  475. }
  476. }
  477. .price-detail {
  478. margin-top: 20upx;
  479. margin-bottom: 20upx;
  480. }
  481. .detail-price_box {
  482. color: #333333;
  483. font-size: 22upx;
  484. text-align: right;
  485. flex: 1;
  486. font-weight: 600;
  487. &.red {
  488. color: #ff2842;
  489. }
  490. }
  491. }
  492. .app-footer {
  493. justify-content: space-evenly;
  494. z-index: 9999;
  495. .admin-button-com {
  496. width: 46%;
  497. }
  498. }
  499. </style>