salesDetail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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="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="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. watch: {
  156. toggle (newValue, oldValue) {
  157. this.changeScrollH()
  158. }
  159. },
  160. methods: {
  161. //获取收款记录
  162. getRecodeData(pageNo){
  163. if (pageNo) {
  164. this.pageNo = pageNo
  165. }
  166. queryFlowByBizSn({bizSn: this.salesBillSn}).then(res => {
  167. if (res.status == 200) {
  168. this.payRecode =res.data
  169. }
  170. })
  171. },
  172. changeTabs(index){
  173. this.current= index
  174. },
  175. init(){
  176. this.getList(1)
  177. this.getDetail()
  178. this.getRecodeData(1)
  179. },
  180. // 销售单详情
  181. getDetail(){
  182. salesDetailBySn({ salesBillSn: this.salesBillSn }).then(res => {
  183. if(res.status == 200){
  184. this.detailData = res.data
  185. }else{
  186. this.detailData = null
  187. }
  188. this.toggle = false
  189. })
  190. },
  191. // 列表
  192. getList(pageNo){
  193. const _this = this
  194. if (pageNo) {
  195. this.pageNo = pageNo
  196. }
  197. let params = {
  198. pageNo: this.pageNo,
  199. pageSize: this.pageSize,
  200. salesBillSn: this.salesBillSn
  201. }
  202. this.status = "loading"
  203. salesDetailList(params).then(res => {
  204. if (res.status == 200) {
  205. if(res.data && res.data.list){
  206. res.data.list.map(item => {
  207. item.productName = item.productEntity && item.productEntity.name || item.dealerProductEntity && item.dealerProductEntity.name
  208. item.productCode = item.productEntity && item.productEntity.code || item.dealerProductEntity && item.dealerProductEntity.code
  209. item.productUnit = item.productEntity && item.productEntity.unit || item.dealerProductEntity && item.dealerProductEntity.unit
  210. })
  211. if(this.pageNo>1){
  212. this.listData = this.listData.concat(res.data && res.data.list || [])
  213. }else{
  214. this.listData = res.data.list || []
  215. }
  216. }else{
  217. this.listData = []
  218. }
  219. this.totalNum = res.data && res.data.count || 0
  220. } else {
  221. this.listData = []
  222. this.totalNum = 0
  223. this.noDataText = res.message
  224. }
  225. this.status = "loadmore"
  226. })
  227. },
  228. // scroll-view到底部加载更多
  229. onreachBottom() {
  230. if(this.listData.length < this.totalNum){
  231. this.pageNo += 1
  232. this.getList()
  233. this.getRecodeData()
  234. }
  235. },
  236. changeScrollH(){
  237. const _this = this
  238. uni.getSystemInfo({
  239. success: function (res) {
  240. const winH = res.windowHeight * 2
  241. let totalH = _this.$refs.salesTotal && _this.$refs.salesTotal.$el && _this.$refs.salesTotal.$el.offsetHeight || 0
  242. if(_this.toggle){
  243. _this.scrollH = winH - 656 - totalH
  244. }else{
  245. _this.scrollH = winH - 522 - totalH
  246. }
  247. // if(_this.detailData&&_this.detailData.billStatus=='FINISH'){
  248. _this.scrollH = _this.scrollH + 100
  249. // }
  250. }
  251. })
  252. }
  253. }
  254. }
  255. </script>
  256. <style lang="scss">
  257. .sales-edit-wrap{
  258. width: 100%;
  259. .color_6{
  260. color: #666;
  261. }
  262. .font_13{
  263. font-size: 26upx;
  264. }
  265. .border-b{
  266. border-bottom: 1px solid #e4e7ed;
  267. }
  268. .sales-info-con{
  269. background-color: #fff;
  270. margin-bottom: 6upx;
  271. >view{
  272. padding: 14upx 20rpx;
  273. border-bottom: 1px solid #e4e7ed;
  274. }
  275. >view:last-child{
  276. border-bottom: none;
  277. }
  278. .info-item-box{
  279. .info-item-tit{
  280. display: inline-block;
  281. width: 20%;
  282. }
  283. }
  284. }
  285. .sales-product-con{
  286. background-color: #fff;
  287. .sales-product-header{
  288. ::v-deep .u-tab-item{
  289. border-bottom:1rpx solid #e4e7ed;
  290. }
  291. }
  292. .sales-total-box{
  293. align-items: flex-end;
  294. padding: 16upx 20rpx;
  295. .sales-total-con{
  296. color: #666;
  297. overflow: hidden;
  298. view{
  299. padding: 4upx 0;
  300. .sales-total-num{
  301. font-size: 24upx;
  302. color: rgb(48, 49, 51);
  303. }
  304. }
  305. }
  306. .sales-total-btn{
  307. display: inline-block;
  308. margin-bottom: 6upx;
  309. }
  310. }
  311. .sales-list-box{
  312. flex-grow: 1;
  313. .sales-list-con{
  314. .sales-list-item{
  315. padding: 20upx;
  316. .pimgs{
  317. margin-right: 20upx;
  318. position: relative;
  319. .sign{
  320. position: absolute;
  321. right: -2upx;
  322. top: -2upx;
  323. color: #fff;
  324. border-radius: 50%;
  325. width: 40upx;
  326. height: 40upx;
  327. text-align: center;
  328. }
  329. }
  330. .sales-item-main{
  331. .sales-item-name{
  332. font-size: 28upx;
  333. color: rgb(48, 49, 51);
  334. font-weight: bold;
  335. overflow: hidden;
  336. text-overflow: ellipsis;
  337. display: -webkit-box;
  338. -webkit-box-orient: vertical;
  339. -webkit-line-clamp: 1;
  340. }
  341. .sales-item-txt{
  342. margin: 8upx 0;
  343. }
  344. .sales-item-price{
  345. text-align: right;
  346. }
  347. }
  348. .btn-box{
  349. padding: 30upx 30upx;
  350. }
  351. .sales-list-l{
  352. font-size: 20rpx;
  353. view{
  354. &:last-child{
  355. font-size: 26rpx;
  356. margin-top:10rpx;
  357. }
  358. }
  359. }
  360. .sales-list-r.spending{
  361. color:$uni-color-error;
  362. }
  363. .sales-list-r.income{
  364. color:$uni-color-success;
  365. }
  366. }
  367. .sales-list-item:last-child{
  368. border: none;
  369. }
  370. }
  371. }
  372. }
  373. .sales-btn-box{
  374. background-color: #fff;
  375. padding: 12upx 50upx;
  376. .handle-btn{
  377. width: 47%;
  378. }
  379. .edit-btn{
  380. width: 100%;
  381. }
  382. }
  383. }
  384. </style>