salesDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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.buyerNameCurrent?detailData.buyerName?detailData.buyerName==detailData.buyerNameCurrent?detailData.buyerNameCurrent:detailData.buyerNameCurrent+'('+detailData.buyerName+')':detailData.buyerNameCurrent:'--' }}</text>
  9. </view>
  10. <view class="info-item-box">
  11. <text class="info-item-tit color_6">销售单号</text>
  12. <text>{{detailData && detailData.salesBillNo || '--'}}</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" v-if="detailData" class="sales-total-box border-b font_13 flex justify_between">
  24. <view class="sales-total-con flex_1">
  25. <view>
  26. 总款数:<text class="sales-total-num" :style="{ color: $config('warringColor') }">
  27. {{ (detailData.totalCategory || detailData.totalCategory == 0) ? toThousands(detailData.totalCategory) : '--' }}</text>;
  28. 总数量:<text class="sales-total-num" :style="{ color: $config('warringColor') }">
  29. {{ (detailData.totalQty || detailData.totalQty == 0) ? toThousands(detailData.totalQty) : '--' }}
  30. </text>;
  31. </view>
  32. <view>
  33. 总售价:<text class="sales-total-num" :style="{ color: $config('warringColor') }">
  34. ¥{{ detailData.totalAmount || detailData.totalAmount == 0 ? toThousands(detailData.totalAmount, 2) : '--' }}
  35. </text>;
  36. 折后总售价:<text class="sales-total-num" :style="{ color: $config('warringColor') }">
  37. ¥{{ detailData.discountedAmount || detailData.discountedAmount == 0 ? toThousands(detailData.discountedAmount, 2) : '--' }}
  38. </text>;
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 产品列表 -->
  43. <view class="sales-list-box">
  44. <scroll-view class="sales-list-con" :style="{height:scrollH+'upx'}" scroll-y @scrolltolower="onreachBottom">
  45. <view class="sales-list-item border-b flex align_center justify_between" v-for="(item, index) in listData" :key="item.id">
  46. <view class="font_13 flex_1 flex justify_between">
  47. <view class="pimgs">
  48. <u-image :src="item.productMainImage?item.productMainImage:`../../static/${$config('themePath')}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
  49. <view v-if="(isOwerEdit && item.oosFlag == 1) || (isOwerEdit && item.oosFlag == 1)" class="sign" :style="{backgroundColor: $config('errorColor')}">急</view>
  50. <view v-if="item.price < item.cost" class="sign" :style="{backgroundColor: $config('warringColor')}">亏</view>
  51. <view v-if="!isOwerEdit&&!isAudit&&(!item.currentStockQty || item.currentStockQty < item.qty)" class="sign" :style="{backgroundColor: $config('errorColor')}">缺</view>
  52. </view>
  53. <view class="sales-item-main flex_1">
  54. <view class="sales-item-name">{{item.productName || '--'}}</view>
  55. <view class="sales-item-txt">{{item.productCode || '--'}}</view>
  56. <!-- <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> -->
  57. <view class="sales-item-txt flex align_center justify_between">
  58. <view class="sales-item-priceInfo">
  59. <view :style="{color: $config('errorColor'), display: 'inline-block'}">¥<text style="font-size: 30upx;">{{toThousands(item.price||0, 2)}}</text></view>
  60. <text style="display: inline-block;margin: 0 10upx;">X</text>
  61. <text style="font-size: 30upx;">{{toThousands(item.qty||0)}}</text>
  62. <!-- {{item.productUnit}} -->
  63. </view>
  64. <view class="sales-item-price">¥{{item.totalAmount || item.totalAmount == 0?toThousands(item.totalAmount, 2):0}}</view>
  65. </view>
  66. <!-- <view class="sales-item-price" v-if="detailData&&detailData.discountAmount">折后:¥{{toThousands(item.discountedAmount||0, 2)}}</view> -->
  67. </view>
  68. </view>
  69. </view>
  70. <view v-if="listData && listData.length == 0">
  71. <u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="150" :text="noDataText" mode="list" :margin-top="50"></u-empty>
  72. </view>
  73. <view style="padding: 20upx;" v-else>
  74. <u-loadmore v-if="totalNum>listData.length || status=='loading'" :status="status" />
  75. </view>
  76. </scroll-view>
  77. </view>
  78. </view>
  79. <!-- 收款记录列表 -->
  80. <view class="flex flex_column" v-show="current == 1">
  81. <view class="sales-list-box">
  82. <scroll-view class="sales-list-con" :style="{height:scrollH+'upx'}" scroll-y>
  83. <view class="sales-list-item flex align_center justify_between" v-for="(con,i) in payRecode" :key="i">
  84. <view class="sales-list-l">
  85. <view>{{con.settleTime}}</view>
  86. <view v-if="con.settleStyleSnDictValue">{{con.settleStyleSnDictValue}}</view>
  87. </view>
  88. <view class="sales-list-r income" >
  89. {{con.settleAmount * 1 > 0?'+':'-'}}¥{{Number(con.settleAmount)?Number(con.settleAmount).toFixed(2):'0.00'}}
  90. </view>
  91. </view>
  92. <view v-if="payRecode.length==0">
  93. <u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="150" :text="noDataText" mode="list" :margin-top="50"></u-empty>
  94. </view>
  95. <view style="padding: 20upx;" v-if="payRecode.length!=0">
  96. <u-loadmore status="nomore" />
  97. </view>
  98. </scroll-view>
  99. </view>
  100. </view>
  101. </view>
  102. <!-- 基础信息 -->
  103. <orderInfoModal :infoFlag="true" :openModal="infoModal" :infoData="detailData" @close="infoModal=false" />
  104. </view>
  105. </template>
  106. <script>
  107. import OrderInfoModal from './orderInfoModal.vue'
  108. import { toThousands } from '@/libs/tools'
  109. import { salesDetailList, salesDetailDel, salesDel, salesDetailBySn, salesSubmit, salesDiscount, salesDetailUpdate,queryFlowByBizSn } from '@/api/sales'
  110. export default{
  111. components: { OrderInfoModal },
  112. data(){
  113. return{
  114. tabsList:[{
  115. name:'产品列表'
  116. },{
  117. name:'收款记录'
  118. }],
  119. current:0,
  120. activeItemStyle:{
  121. color:this.$config('primaryColor'),
  122. borderBottom:'4rpx solid '+this.$config('primaryColor')
  123. },
  124. toThousands,
  125. listData: [],
  126. pageNo: 1,
  127. pageSize: 10,
  128. totalNum: 0,
  129. status: 'loadmore',
  130. noDataText: '暂无数据',
  131. scrollH: 916,
  132. infoModal: false,
  133. discountModal: false,
  134. commonModal: false,
  135. modalText: '确认要删除吗?',
  136. detailData: null, // 销售单详情
  137. openProductModal: false, // 编辑产品信息弹框是否显示
  138. productData: null, // 当前操作的产品信息
  139. productInfo: null, // 编辑产品需要的参数
  140. editInfo: null, // 添加/编辑 提交的值
  141. commonType: 1, // 公共弹框类型 1删除产品,2删除销售单,3编辑产品时库存不足
  142. payRecode:[],
  143. toggle:true
  144. }
  145. },
  146. onLoad(options) {
  147. if(options && options.salesBillId){
  148. this.salesBillSn = options.salesBillId;
  149. this.init();
  150. }
  151. },
  152. onUnload() {
  153. uni.$off('refreshEditBL')
  154. },
  155. computed: {
  156. // 是否自建单据
  157. isOwerEdit () {
  158. return this.detailData && this.detailData.sourceType == 'SALES'
  159. },
  160. // 是否审核通过
  161. isAudit () {
  162. return this.detailData ? (this.detailData.billStatus == 'WAIT_OUT_WAREHOUSE' || this.detailData.billStatus == 'FINISH') : false
  163. },
  164. },
  165. watch: {
  166. toggle (newValue, oldValue) {
  167. this.changeScrollH()
  168. }
  169. },
  170. methods: {
  171. //获取收款记录
  172. getRecodeData(pageNo){
  173. if (pageNo) {
  174. this.pageNo = pageNo
  175. }
  176. queryFlowByBizSn({bizSn: this.salesBillSn}).then(res => {
  177. if (res.status == 200) {
  178. this.payRecode =res.data
  179. }
  180. })
  181. },
  182. changeTabs(index){
  183. this.current= index
  184. },
  185. init(){
  186. this.getList(1)
  187. this.getDetail()
  188. this.getRecodeData(1)
  189. },
  190. // 销售单详情
  191. getDetail(){
  192. salesDetailBySn({ salesBillSn: this.salesBillSn }).then(res => {
  193. if(res.status == 200){
  194. this.detailData = res.data
  195. }else{
  196. this.detailData = null
  197. }
  198. this.toggle = false
  199. })
  200. },
  201. // 列表
  202. getList(pageNo){
  203. const _this = this
  204. if (pageNo) {
  205. this.pageNo = pageNo
  206. }
  207. let params = {
  208. pageNo: this.pageNo,
  209. pageSize: this.pageSize,
  210. salesBillSn: this.salesBillSn
  211. }
  212. this.status = "loading"
  213. salesDetailList(params).then(res => {
  214. if (res.status == 200) {
  215. if(res.data && res.data.list){
  216. res.data.list.map(item => {
  217. item.productName = item.productEntity && item.productEntity.name || item.dealerProductEntity && item.dealerProductEntity.name
  218. item.productCode = item.productEntity && item.productEntity.code || item.dealerProductEntity && item.dealerProductEntity.code
  219. item.productUnit = item.productEntity && item.productEntity.unit || item.dealerProductEntity && item.dealerProductEntity.unit
  220. })
  221. if(this.pageNo>1){
  222. this.listData = this.listData.concat(res.data && res.data.list || [])
  223. }else{
  224. this.listData = res.data.list || []
  225. }
  226. }else{
  227. this.listData = []
  228. }
  229. this.totalNum = res.data && res.data.count || 0
  230. } else {
  231. this.listData = []
  232. this.totalNum = 0
  233. this.noDataText = res.message
  234. }
  235. this.status = "loadmore"
  236. })
  237. },
  238. // scroll-view到底部加载更多
  239. onreachBottom() {
  240. if(this.listData.length < this.totalNum){
  241. this.pageNo += 1
  242. this.getList()
  243. this.getRecodeData()
  244. }
  245. },
  246. changeScrollH(){
  247. const _this = this
  248. uni.getSystemInfo({
  249. success: function (res) {
  250. const winH = res.windowHeight * 2
  251. let totalH = _this.$refs.salesTotal && _this.$refs.salesTotal.$el && _this.$refs.salesTotal.$el.offsetHeight || 0
  252. if(_this.toggle){
  253. _this.scrollH = winH - 656 - totalH
  254. }else{
  255. _this.scrollH = winH - 522 - totalH
  256. }
  257. // if(_this.detailData&&_this.detailData.billStatus=='FINISH'){
  258. _this.scrollH = _this.scrollH + 100
  259. // }
  260. }
  261. })
  262. }
  263. }
  264. }
  265. </script>
  266. <style lang="scss">
  267. .sales-edit-wrap{
  268. width: 100%;
  269. .color_6{
  270. color: #666;
  271. }
  272. .font_13{
  273. font-size: 26upx;
  274. }
  275. .border-b{
  276. border-bottom: 1px solid #e4e7ed;
  277. }
  278. .sales-info-con{
  279. background-color: #fff;
  280. margin-bottom: 6upx;
  281. >view{
  282. padding: 14upx 20rpx;
  283. border-bottom: 1px solid #e4e7ed;
  284. }
  285. >view:last-child{
  286. border-bottom: none;
  287. }
  288. .info-item-box{
  289. .info-item-tit{
  290. display: inline-block;
  291. width: 20%;
  292. }
  293. }
  294. }
  295. .sales-product-con{
  296. background-color: #fff;
  297. .sales-product-header{
  298. ::v-deep .u-tab-item{
  299. border-bottom:1rpx solid #e4e7ed;
  300. }
  301. }
  302. .sales-total-box{
  303. align-items: flex-end;
  304. padding: 16upx 20rpx;
  305. .sales-total-con{
  306. color: #666;
  307. overflow: hidden;
  308. view{
  309. padding: 4upx 0;
  310. .sales-total-num{
  311. font-size: 24upx;
  312. color: rgb(48, 49, 51);
  313. }
  314. }
  315. }
  316. .sales-total-btn{
  317. display: inline-block;
  318. margin-bottom: 6upx;
  319. }
  320. }
  321. .sales-list-box{
  322. flex-grow: 1;
  323. .sales-list-con{
  324. .sales-list-item{
  325. padding: 20upx;
  326. .pimgs{
  327. margin-right: 20upx;
  328. position: relative;
  329. .sign{
  330. position: absolute;
  331. right: -2upx;
  332. top: -2upx;
  333. color: #fff;
  334. border-radius: 50%;
  335. width: 40upx;
  336. height: 40upx;
  337. text-align: center;
  338. }
  339. }
  340. .sales-item-main{
  341. .sales-item-name{
  342. font-size: 28upx;
  343. color: rgb(48, 49, 51);
  344. font-weight: bold;
  345. overflow: hidden;
  346. text-overflow: ellipsis;
  347. display: -webkit-box;
  348. -webkit-box-orient: vertical;
  349. -webkit-line-clamp: 1;
  350. }
  351. .sales-item-txt{
  352. margin: 8upx 0;
  353. }
  354. .sales-item-price{
  355. text-align: right;
  356. }
  357. }
  358. .btn-box{
  359. padding: 30upx 30upx;
  360. }
  361. .sales-list-l{
  362. font-size: 20rpx;
  363. view{
  364. &:last-child{
  365. font-size: 26rpx;
  366. margin-top:10rpx;
  367. }
  368. }
  369. }
  370. .sales-list-r.spending{
  371. color:$uni-color-error;
  372. }
  373. .sales-list-r.income{
  374. color:$uni-color-success;
  375. }
  376. }
  377. .sales-list-item:last-child{
  378. border: none;
  379. }
  380. }
  381. }
  382. }
  383. .sales-btn-box{
  384. background-color: #fff;
  385. padding: 12upx 50upx;
  386. .handle-btn{
  387. width: 47%;
  388. }
  389. .edit-btn{
  390. width: 100%;
  391. }
  392. }
  393. }
  394. </style>