salesDetail.vue 12 KB

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