salesDetail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. <template>
  2. <view class="sales-edit-wrap flex flex_column">
  3. <!-- 基础信息 -->
  4. <view class="sales-info-con">
  5. <u-section @click="infoModal=true" title="基础信息" sub-title="查看更多" :line-color="$config('primaryColor')"></u-section>
  6. <view class="info-item-box">
  7. <text class="info-item-tit color_6">销售单号</text>
  8. <text>{{detailData && detailData.salesBillNo || '--'}}</text>
  9. </view>
  10. <view class="info-item-box">
  11. <text class="info-item-tit color_6">客户名称</text>
  12. <text>{{detailData && detailData.buyerName || '--'}}</text>
  13. </view>
  14. </view>
  15. <!-- 产品列表 -->
  16. <view class="sales-product-con">
  17. <!-- 标题 -->
  18. <view class="sales-product-header">
  19. <u-tabs :show-bar="false" :active-item-style="activeItemStyle" :list="tabsList" :is-scroll="false" :current="current" @change="changeTabs"></u-tabs>
  20. </view>
  21. <view class="flex flex_column" v-show="current == 0">
  22. <!-- 合计 -->
  23. <view ref="salesTotal" class="sales-total-box border-b font_13 flex justify_between">
  24. <view class="sales-total-con flex_1" :style="{height: toggle ? 'auto' : '44upx'}">
  25. <view>
  26. 总款数:<text class="sales-total-num" :style="{ color: $config('warringColor') }">
  27. {{ detailData && (detailData.totalCategory || detailData.totalCategory == 0) ? toThousands(detailData.totalCategory) : '--' }}</text>;总数量:<text class="sales-total-num" :style="{ color: $config('warringColor') }">
  28. {{ detailData && (detailData.totalQty || detailData.totalQty == 0) ? toThousands(detailData.totalQty) : '--' }}
  29. </text>;
  30. </view>
  31. <view>
  32. 总售价:<text class="sales-total-num" :style="{ color: $config('warringColor') }">
  33. ¥{{ detailData && (detailData.totalAmount || detailData.totalAmount == 0) ? toThousands(detailData.totalAmount, 2) : '--' }}
  34. </text>;折后总售价:<text class="sales-total-num" :style="{ color: $config('warringColor') }">
  35. ¥{{ detailData && (detailData.discountedAmount || detailData.discountedAmount == 0) ? toThousands(detailData.discountedAmount, 2) : '--' }}
  36. </text>;
  37. </view>
  38. </view>
  39. </view>
  40. <!-- 产品列表 -->
  41. <view class="sales-list-box">
  42. <scroll-view class="sales-list-con" :style="{height:scrollH+'upx'}" scroll-y @scrolltolower="onreachBottom">
  43. <view class="sales-list-item border-b flex align_center justify_between" v-for="(item, index) in listData" :key="item.id">
  44. <view class="font_13 flex_1 flex justify_between">
  45. <view class="pimgs">
  46. <u-image :src="item.productMainImage?item.productMainImage:`../../static/${$config('themePath')}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
  47. <view v-if="item.oosFlag == 1" class="sign" :style="{backgroundColor: $config('errorColor')}">急</view>
  48. <view v-if="item.price < item.cost" class="sign" :style="{backgroundColor: $config('errorColor')}">亏</view>
  49. <view v-if="item.price == 0" class="sign" :style="{backgroundColor: $config('errorColor')}">赠</view>
  50. </view>
  51. <view class="sales-item-main flex_1">
  52. <view class="sales-item-name">{{item.productName || '--'}}</view>
  53. <view class="sales-item-txt">{{item.productCode || '--'}}</view>
  54. <view class="sales-item-txt color_6" style="font-size: 24upx;" v-if="item.warehouseEntity&&item.warehouseEntity.name || item.warehouseLocationEntity&&item.warehouseLocationEntity.name">{{item.warehouseEntity&&item.warehouseEntity.name}} > {{item.warehouseLocationEntity&&item.warehouseLocationEntity.name}}</view>
  55. <view class="sales-item-txt flex align_center justify_between">
  56. <view class="sales-item-priceInfo">
  57. <view :style="{color: $config('errorColor'), display: 'inline-block'}">¥<text style="font-size: 30upx;">{{toThousands(item.price||0, 2)}}</text></view>
  58. <text style="display: inline-block;margin: 0 10upx;">X</text>
  59. <text style="font-size: 30upx;">{{toThousands(item.qty||0)}}</text>
  60. {{item.productUnit}}
  61. </view>
  62. <view class="sales-item-price">¥{{toThousands(item.totalAmount||0, 2)}}</view>
  63. </view>
  64. <view class="sales-item-price" v-if="detailData&&detailData.discountAmount">折后:¥{{toThousands(item.discountedAmount||0, 2)}}</view>
  65. </view>
  66. </view>
  67. </view>
  68. <view v-if="listData && listData.length == 0">
  69. <u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="150" :text="noDataText" mode="list" :margin-top="50"></u-empty>
  70. </view>
  71. <view style="padding: 20upx;">
  72. <u-loadmore v-if="totalNum>listData.length || status=='loading'" :status="status" />
  73. </view>
  74. </scroll-view>
  75. </view>
  76. </view>
  77. <!-- 收款记录列表 -->
  78. <view class="flex flex_column" v-show="current == 1">
  79. <!-- <view ref="salesTotal" class="sales-total-box border-b font_13 flex justify_between">
  80. <view class="sales-total-con flex_1" :style="{height: toggle ? 'auto' : '44upx'}">
  81. 应收:<text class="sales-total-num" :style="{color: $config('warringColor')}">{{detailData && (detailData.totalCategory || detailData.totalCategory==0) ? toThousands(detailData.totalCategory) : '--'}}</text>;已收:<text class="sales-total-num" :style="{color: $config('warringColor')}">{{detailData && (detailData.totalQty || detailData.totalQty==0) ? toThousands(detailData.totalQty) : '--'}}</text>;待收:<text class="sales-total-num" :style="{color: $config('warringColor')}">¥{{detailData && (detailData.discountAmount || detailData.discountAmount==0) ? toThousands(detailData.discountAmount, 2) : '--'}}</text>;
  82. </view>
  83. </view> -->
  84. <view class="sales-list-box">
  85. <scroll-view class="sales-list-con" :style="{height:scrollH+'upx'}" scroll-y>
  86. <view class="sales-list-item flex align_center justify_between" v-for="(con,i) in payRecode" :key="">
  87. <view class="sales-list-l">
  88. <view>{{con.createDate}}</view>
  89. <view>微信支付(线上)</view>
  90. </view>
  91. <view class="sales-list-r income" >
  92. +¥32.00
  93. </view>
  94. </view>
  95. <view v-if="false">
  96. <u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="150" :text="noDataText" mode="list" :margin-top="50"></u-empty>
  97. </view>
  98. <view style="padding: 20upx;">
  99. <u-loadmore v-if="totalNum>listData.length || status=='loading'" :status="status" />
  100. </view>
  101. </scroll-view>
  102. </view>
  103. </view>
  104. </view>
  105. <!-- 基础信息 -->
  106. <orderInfoModal :infoFlag="true" :openModal="infoModal" :infoData="detailData" @close="infoModal=false" />
  107. </view>
  108. </template>
  109. <script>
  110. import commonModal from '@/pages/common/commonModal.vue'
  111. import OrderInfoModal from './orderInfoModal.vue'
  112. import DiscountModal from './discountModal.vue'
  113. import ProductModal from './productModal.vue'
  114. import { toThousands } from '@/libs/tools'
  115. import { stockByProductSn } from '@/api/stock'
  116. import { salesDetailList, salesDetailDel, salesDel, salesDetailBySn, salesSubmit, salesDiscount, salesDetailUpdate,queryFlowByBizSn } from '@/api/sales'
  117. export default{
  118. components: { OrderInfoModal, DiscountModal, commonModal, ProductModal },
  119. data(){
  120. return{
  121. tabsList:[{
  122. name:'产品列表'
  123. },{
  124. name:'收款记录'
  125. }],
  126. current:0,
  127. activeItemStyle:{
  128. color:this.$config('primaryColor'),
  129. borderBottom:'4rpx solid '+this.$config('primaryColor')
  130. },
  131. pageData: {
  132. type: 'edit',
  133. data: null
  134. },
  135. toggle: true,
  136. toThousands,
  137. customBtnStyle: { // 自定义按钮样式
  138. borderColor: this.$config('primaryColor'),
  139. backgroundColor: this.$config('primaryColor'),
  140. color: '#fff'
  141. },
  142. listData: [],
  143. pageNo: 1,
  144. pageSize: 6,
  145. totalNum: 0,
  146. status: 'loadmore',
  147. noDataText: '暂无数据',
  148. scrollH: 916,
  149. infoModal: false,
  150. discountModal: false,
  151. commonModal: false,
  152. modalText: '确认要删除吗?',
  153. detailData: null, // 销售单详情
  154. openProductModal: false, // 编辑产品信息弹框是否显示
  155. productData: null, // 当前操作的产品信息
  156. productInfo: null, // 编辑产品需要的参数
  157. editInfo: null, // 添加/编辑 提交的值
  158. commonType: 1, // 公共弹框类型 1删除产品,2删除销售单,3编辑产品时库存不足
  159. payRecode:null
  160. }
  161. },
  162. onLoad(options) {
  163. if(options && options.salesBillId){
  164. this.salesBillSn = options.salesBillId;
  165. this.init();
  166. }
  167. },
  168. onUnload() {
  169. uni.$off('refreshEditBL')
  170. },
  171. methods: {
  172. //获取收款记录
  173. getRecodeData(pageNo){
  174. if (pageNo) {
  175. this.pageNo = pageNo
  176. }
  177. let params = {
  178. pageNo: this.pageNo,
  179. pageSize: this.pageSize,
  180. bizSn: this.salesBillSn
  181. }
  182. this.status = "loading"
  183. queryFlowByBizSn(params).then(res => {
  184. if (res.status == 200) {
  185. if (this.pageNo > 1) {
  186. this.payRecode = this.payRecode.concat(res.data.list || []);
  187. } else {
  188. this.payRecode = res.data.list || [];
  189. }
  190. this.totalNum = res.data.count || 0;
  191. } else {
  192. this.payRecode = [];
  193. this.totalNum = 0;
  194. this.noDataText = res.message;
  195. }
  196. this.status = 'loadmore';
  197. })
  198. },
  199. changeTabs(index){
  200. this.current= index
  201. },
  202. init(){
  203. this.getList(1)
  204. this.getDetail()
  205. this.getRecodeData(1)
  206. },
  207. // 列表
  208. getList(pageNo){
  209. const _this = this
  210. if (pageNo) {
  211. this.pageNo = pageNo
  212. }
  213. let params = {
  214. pageNo: this.pageNo,
  215. pageSize: this.pageSize,
  216. salesBillSn: this.salesBillSn
  217. }
  218. this.status = "loading"
  219. salesDetailList(params).then(res => {
  220. if (res.status == 200) {
  221. if(res.data && res.data.list){
  222. res.data.list.map(item => {
  223. item.productName = item.productEntity && item.productEntity.name || item.dealerProductEntity && item.dealerProductEntity.name
  224. item.productCode = item.productEntity && item.productEntity.code || item.dealerProductEntity && item.dealerProductEntity.code
  225. item.productUnit = item.productEntity && item.productEntity.unit || item.dealerProductEntity && item.dealerProductEntity.unit
  226. })
  227. if(this.pageNo>1){
  228. this.listData = this.listData.concat(res.data && res.data.list || [])
  229. }else{
  230. this.listData = res.data.list || []
  231. }
  232. }else{
  233. this.listData = []
  234. }
  235. this.totalNum = res.data && res.data.count || 0
  236. } else {
  237. this.listData = []
  238. this.totalNum = 0
  239. this.noDataText = res.message
  240. }
  241. this.status = "loadmore"
  242. })
  243. },
  244. // scroll-view到底部加载更多
  245. onreachBottom() {
  246. if(this.listData.length < this.totalNum){
  247. this.pageNo += 1
  248. this.getList()
  249. this.getRecodeData()
  250. }
  251. },
  252. // 折扣金额
  253. discountConfirm(amount){
  254. let params = {
  255. discountAmount: amount,
  256. salesBillSn: this.detailData.salesBillSn,
  257. id: this.detailData.id
  258. }
  259. salesDiscount(params).then(res => {
  260. if(res.status == 200){
  261. this.init()
  262. this.discountModal = false
  263. }
  264. })
  265. },
  266. // 提交
  267. handleSubmit(){
  268. salesSubmit({ id: this.detailData.id }).then(res => {
  269. if(res.status == 200){
  270. this.toashMsg(res.message)
  271. uni.$emit('refreshSalesBL')
  272. uni.navigateBack()
  273. }
  274. })
  275. },
  276. // 编辑
  277. handleEdit(data){
  278. this.productInfo = {
  279. productName: data.productName,
  280. productMainImage: data.productMainImage,
  281. productCode: data.productCode,
  282. productOrigCode: data.productOrigCode,
  283. warehouseName: data.warehouseEntity && data.warehouseEntity.name,
  284. warehouseLocationName: data.warehouseLocationEntity && data.warehouseLocationEntity.name,
  285. price: data.price,
  286. qty: data.qty
  287. }
  288. this.openProductModal = true
  289. this.productData = data
  290. },
  291. // 确认产品信息
  292. productConfirm(data){
  293. this.editInfo = data
  294. this.validateStock() //验证 库存是否不足
  295. },
  296. // 库存不足
  297. validateStock(){
  298. // 校验库存
  299. stockByProductSn({ productSn: this.productData.productSn }).then(res => {
  300. if (res.status == 200) {
  301. if (res.data && (!res.data.currentStockQty || this.editInfo.qty <= res.data.currentStockQty)) {
  302. this.editProduct()
  303. } else { // 库存不足
  304. this.commonType = 3
  305. this.modalText = '库存不足,将产生急件,确认修改吗?'
  306. this.commonModal = true
  307. }
  308. }
  309. })
  310. },
  311. // 编辑产品
  312. editProduct(){
  313. let params = {
  314. id: this.productData.id,
  315. qty: this.editInfo.qty,
  316. price: this.editInfo.price,
  317. productSn: this.productData.productSn,
  318. salesBillSn: this.detailData.salesBillSn,
  319. }
  320. salesDetailUpdate(params).then(res => {
  321. if(res.status == 200){
  322. this.toashMsg(res.message)
  323. this.init()
  324. this.commonModal = false
  325. this.openProductModal = false
  326. }
  327. })
  328. },
  329. // 删除
  330. handleDel(item){
  331. if(item){ // 删除产品
  332. this.commonType = 1
  333. this.productData = item
  334. this.modalText = '确认要删除吗?'
  335. this.commonModal = true
  336. }else{ // 整单删除
  337. this.commonType = 2
  338. this.productData = null
  339. this.modalText = '确认删除该销售单吗?'
  340. this.commonModal = true
  341. }
  342. },
  343. // 公共弹框 确定
  344. handleCommon(){
  345. if(this.commonType == 1){ // 删除产品
  346. this.delFun()
  347. }else if(this.commonType == 2){ // 整单删除
  348. this.delFun()
  349. }else if(this.commonType == 3){ // 编辑产品时库存不足
  350. this.editProduct()
  351. }
  352. },
  353. // 公共弹框 取消
  354. handleCancel(){
  355. this.openProductModal = false
  356. },
  357. // 删除
  358. delFun(){
  359. let url = salesDetailDel
  360. let params = {}
  361. console.log(this.commonType)
  362. if(this.commonType == 1){ // 删除产品
  363. url = salesDetailDel
  364. params = { id: this.productData.id }
  365. }else if(this.commonType == 2){ // 整单删除
  366. console.log('整单删除', this.detailData)
  367. url = salesDel
  368. params = { id: this.detailData && this.detailData.id }
  369. }
  370. url(params).then(res => {
  371. if (res.status == 200) {
  372. if(this.productData){ // 删除产品
  373. this.toashMsg(res.message)
  374. this.init()
  375. }else{ // 整单删除
  376. this.toashMsg(res.message)
  377. uni.$emit('refreshSalesBL')
  378. uni.navigateBack()
  379. }
  380. this.commonModal = false
  381. } else {
  382. this.commonModal = false
  383. }
  384. })
  385. },
  386. // 选择产品
  387. handleProduct(){
  388. uni.navigateTo({ url: '/pages/sales/chooseProduct?data='+JSON.stringify(this.detailData) })
  389. },
  390. // 编辑
  391. goPage(){
  392. uni.redirectTo({ url: '/pages/sales/edit?pageType=edit&data='+JSON.stringify(this.detailData) })
  393. },
  394. // 销售单详情
  395. getDetail(){
  396. salesDetailBySn({ salesBillSn: this.salesBillSn }).then(res => {
  397. if(res.status == 200){
  398. this.detailData = res.data
  399. }else{
  400. this.detailData = null
  401. }
  402. this.toggle = false
  403. })
  404. },
  405. changeScrollH(){
  406. const _this = this
  407. uni.getSystemInfo({
  408. success: function (res) {
  409. const winH = res.windowHeight * 2
  410. let totalH = _this.$refs.salesTotal && _this.$refs.salesTotal.$el && _this.$refs.salesTotal.$el.offsetHeight || 0
  411. if(_this.toggle){
  412. _this.scrollH = winH - 656 - totalH
  413. }else{
  414. _this.scrollH = winH - 522 - totalH
  415. }
  416. // if(_this.detailData&&_this.detailData.billStatus=='FINISH'){
  417. _this.scrollH = _this.scrollH + 100
  418. // }
  419. }
  420. })
  421. }
  422. },
  423. watch: {
  424. toggle (newValue, oldValue) {
  425. this.changeScrollH()
  426. }
  427. }
  428. }
  429. </script>
  430. <style lang="scss">
  431. .sales-edit-wrap{
  432. width: 100%;
  433. .color_6{
  434. color: #666;
  435. }
  436. .font_13{
  437. font-size: 26upx;
  438. }
  439. .border-b{
  440. border-bottom: 1px solid #e4e7ed;
  441. }
  442. .sales-info-con{
  443. background-color: #fff;
  444. margin-bottom: 6upx;
  445. >view{
  446. padding: 14upx 20rpx;
  447. border-bottom: 1px solid #e4e7ed;
  448. }
  449. >view:last-child{
  450. border-bottom: none;
  451. }
  452. .info-item-box{
  453. .info-item-tit{
  454. display: inline-block;
  455. width: 20%;
  456. }
  457. }
  458. }
  459. .sales-product-con{
  460. background-color: #fff;
  461. .sales-product-header{
  462. /deep/.u-tab-item{
  463. border-bottom:1rpx solid #e4e7ed;
  464. }
  465. }
  466. .sales-total-box{
  467. align-items: flex-end;
  468. padding: 16upx 20rpx;
  469. .sales-total-con{
  470. color: #666;
  471. overflow: hidden;
  472. view{
  473. padding: 4upx 0;
  474. .sales-total-num{
  475. font-size: 24upx;
  476. color: rgb(48, 49, 51);
  477. }
  478. }
  479. }
  480. .sales-total-btn{
  481. display: inline-block;
  482. margin-bottom: 6upx;
  483. }
  484. }
  485. .sales-list-box{
  486. flex-grow: 1;
  487. .sales-list-con{
  488. .sales-list-item{
  489. padding: 20upx;
  490. .pimgs{
  491. margin-right: 20upx;
  492. position: relative;
  493. .sign{
  494. position: absolute;
  495. right: -2upx;
  496. top: -2upx;
  497. color: #fff;
  498. border-radius: 50%;
  499. width: 40upx;
  500. height: 40upx;
  501. text-align: center;
  502. }
  503. }
  504. .sales-item-main{
  505. .sales-item-name{
  506. font-size: 28upx;
  507. color: rgb(48, 49, 51);
  508. font-weight: bold;
  509. overflow: hidden;
  510. text-overflow: ellipsis;
  511. display: -webkit-box;
  512. -webkit-box-orient: vertical;
  513. -webkit-line-clamp: 1;
  514. }
  515. .sales-item-txt{
  516. margin: 8upx 0;
  517. }
  518. .sales-item-price{
  519. text-align: right;
  520. }
  521. }
  522. .btn-box{
  523. padding: 30upx 30upx;
  524. }
  525. .sales-list-l{
  526. font-size: 20rpx;
  527. view{
  528. &:last-child{
  529. font-size: 26rpx;
  530. margin-top:10rpx;
  531. }
  532. }
  533. }
  534. .sales-list-r.spending{
  535. color:$uni-color-error;
  536. }
  537. .sales-list-r.income{
  538. color:$uni-color-success;
  539. }
  540. }
  541. .sales-list-item:last-child{
  542. border: none;
  543. }
  544. }
  545. }
  546. }
  547. .sales-btn-box{
  548. background-color: #fff;
  549. padding: 12upx 50upx;
  550. .handle-btn{
  551. width: 47%;
  552. }
  553. .edit-btn{
  554. width: 100%;
  555. }
  556. }
  557. }
  558. </style>