edit.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <view class="sales-edit-wrap">
  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>{{pageData.data && pageData.data.salesBillNo || '--'}}</text>
  9. </view>
  10. <view class="info-item-box">
  11. <text class="info-item-tit color_6">客户名称</text>
  12. <text>{{pageData.data && pageData.data.buyerName || '--'}}</text>
  13. </view>
  14. </view>
  15. <!-- 产品列表 -->
  16. <view class="sales-product-con">
  17. <!-- 标题 -->
  18. <view class="sales-product-header border-b flex align_center justify_between">
  19. <u-section title="产品列表" :line-color="$config('primaryColor')">
  20. <template slot="right">
  21. <view class="sales-product-operation">
  22. <u-button @click="discountModal=true" size="mini" :hair-line="false" plain type="primary" hover-class="none">打折</u-button>
  23. <u-button @click="" size="mini" :hair-line="false" plain type="primary" hover-class="none">选择产品</u-button>
  24. </view>
  25. </template>
  26. </u-section>
  27. </view>
  28. <!-- 合计 -->
  29. <view ref="salesTotal" class="sales-total-box border-b font_13 flex justify_between">
  30. <view class="sales-total-con flex_1" :style="{height: toggle ? 'auto' : '44upx'}">
  31. <view>
  32. 总款数:<text class="sales-total-num" :style="{color: $config('warringColor')}">{{pageData.data && (pageData.data.totalCategory || pageData.data.totalCategory==0) ? toThousands(pageData.data.totalCategory) : '--'}}</text>;总数量:<text class="sales-total-num" :style="{color: $config('warringColor')}">{{pageData.data && (pageData.data.totalQty || pageData.data.totalQty==0) ? toThousands(pageData.data.totalQty) : '--'}}</text>;总售价:<text class="sales-total-num" :style="{color: $config('warringColor')}">¥{{pageData.data && (pageData.data.totalAmount || pageData.data.totalAmount==0) ? toThousands(pageData.data.totalAmount, 2) : '--'}}</text>;
  33. </view>
  34. <view>
  35. 折扣金额:<text class="sales-total-num" :style="{color: $config('warringColor')}">¥{{pageData.data && (pageData.data.discountAmount || pageData.data.discountAmount==0) ? toThousands(pageData.data.discountAmount, 2) : '--'}}</text>;折扣:<text class="sales-total-num" :style="{color: $config('warringColor')}">{{pageData.data && (pageData.data.discountRate || pageData.data.discountRate==0) ? pageData.data.discountRate+'%' : '--'}}</text>;折后总售价:<text class="sales-total-num" :style="{color: $config('warringColor')}">¥{{pageData.data && (pageData.data.discountedAmount || pageData.data.discountedAmount==0) ? toThousands(pageData.data.discountedAmount, 2) : '--'}}</text>;
  36. </view>
  37. <view>
  38. 急件总款数:<text class="sales-total-num" :style="{color: $config('warringColor')}">{{pageData.data && (pageData.data.oosCategory || pageData.data.oosCategory==0) ? toThousands(pageData.data.oosCategory) : '--'}}</text>;急件总数量:<text class="sales-total-num" :style="{color: $config('warringColor')}">{{pageData.data && (pageData.data.oosQty || pageData.data.oosQty==0) ? toThousands(pageData.data.oosQty) : '--'}}</text>;赠品总数量:<text class="sales-total-num" :style="{color: $config('warringColor')}">{{pageData.data && (pageData.data.giftQty || pageData.data.giftQty==0) ? toThousands(pageData.data.giftQty) : '--'}}</text>;
  39. </view>
  40. <view>
  41. 总成本:<text class="sales-total-num" :style="{color: $config('warringColor')}">¥{{pageData.data && (pageData.data.totalCost || pageData.data.totalCost==0) ? toThousands(pageData.data.totalCost, 2) : '--'}}</text>;总毛利:<text class="sales-total-num" :style="{color: $config('warringColor')}">¥{{pageData.data && (pageData.data.grossProfit || pageData.data.grossProfit==0) ? toThousands(pageData.data.grossProfit, 2) : '--'}}</text>;
  42. </view>
  43. </view>
  44. <text class="sales-total-btn" @click="toggle=!toggle" :style="{color: $config('primaryColor')}">{{ toggle ? '收起' : '展开' }}</text>
  45. </view>
  46. <!-- 产品列表 -->
  47. <view class="sales-list-box">
  48. <scroll-view class="sales-list-con" :style="{height: scrollH+'upx'}" scroll-y @scrolltolower="onreachBottom">
  49. <view class="sales-list-item border-b font_13 flex justify_between" v-for="(item, index) in listData" :key="item.id">
  50. <view class="pimgs">
  51. <u-image :src="item.productMainMsg?item.productMainMsg:`../../static/${theme}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
  52. <view v-if="item.oosFlag == 1" class="sign" :style="{backgroundColor: $config('errorColor')}">急</view>
  53. <view v-if="item.price < item.cost" class="sign" :style="{backgroundColor: $config('errorColor')}">亏</view>
  54. <view v-if="item.price == 0" class="sign" :style="{backgroundColor: $config('errorColor')}">赠</view>
  55. </view>
  56. <view class="sales-item-main flex_1">
  57. <view class="sales-item-name">{{item.productName || '--'}}</view>
  58. <view class="sales-item-txt flex align_center justify_between">
  59. <view>{{item.productCode || '--'}}</view>
  60. <u-icon name="trash-fill" :color="$config('errorColor')" size="34"></u-icon>
  61. </view>
  62. <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>
  63. <view class="sales-item-txt flex align_center justify_between">
  64. <view class="sales-item-priceInfo">
  65. <view :style="{color: $config('errorColor'), display: 'inline-block'}">¥<text style="font-size: 30upx;">{{toThousands(item.price||0, 2)}}</text></view>
  66. <text style="display: inline-block;margin: 0 10upx;">*</text>
  67. <text style="font-size: 30upx;">{{toThousands(item.qty||0)}}</text>
  68. {{item.productUnit}}
  69. </view>
  70. <view class="sales-item-price">¥{{toThousands(item.totalAmount||0, 2)}}</view>
  71. </view>
  72. <view class="sales-item-price">折后¥{{toThousands(item.discountedAmount||0, 2)}}</view>
  73. </view>
  74. </view>
  75. <view v-if="listData && listData.length == 0">
  76. <u-empty :text="noDataText" mode="list" :img-width="200" :margin-top="30"></u-empty>
  77. </view>
  78. </scroll-view>
  79. </view>
  80. </view>
  81. <!-- 操作按钮 -->
  82. <view class="sales-btn-box flex align_center justify_between">
  83. <u-button class="handle-btn" size="medium" hover-class="none" @click="resetForm">整单删除</u-button>
  84. <u-button class="handle-btn search-btn" size="medium" hover-class="none" :custom-style="customBtnStyle" @click="handleSearch">提交</u-button>
  85. </view>
  86. <!-- 基础信息 -->
  87. <orderInfoModal :openModal="infoModal" :infoData="pageData.data" @close="infoModal=false" />
  88. <!-- 折扣 -->
  89. <discountModal :openModal="discountModal" :infoData="pageData.data" @close="discountModal=false" />
  90. </view>
  91. </template>
  92. <script>
  93. import OrderInfoModal from './orderInfoModal.vue'
  94. import DiscountModal from './discountModal.vue'
  95. import { toThousands } from '@/libs/tools'
  96. import { salesDetailList } from '@/api/sales'
  97. export default{
  98. components: { OrderInfoModal, DiscountModal },
  99. data(){
  100. return{
  101. pageData: {
  102. type: 'edit',
  103. data: null
  104. },
  105. toggle: false,
  106. toThousands,
  107. customBtnStyle: { // 自定义按钮样式
  108. borderColor: this.$config('primaryColor'),
  109. backgroundColor: this.$config('primaryColor'),
  110. color: '#fff'
  111. },
  112. listData: [],
  113. pageNo: 1,
  114. pageSize: 6,
  115. totalNum: 0,
  116. noDataText: '暂无数据',
  117. theme: '',
  118. scrollH: 836,
  119. infoModal: false,
  120. discountModal: false
  121. }
  122. },
  123. onLoad(opt) {
  124. this.theme = getApp().globalData.theme
  125. if(opt){
  126. this.pageData = {
  127. type: opt.pageType || 'edit',
  128. data: opt.data ? JSON.parse(opt.data) : null
  129. }
  130. }
  131. this.getList()
  132. },
  133. methods: {
  134. // 列表
  135. getList(pageNo){
  136. const _this = this
  137. if (pageNo) {
  138. this.pageNo = pageNo
  139. }
  140. let params = {
  141. pageNo: this.pageNo,
  142. pageSize: this.pageSize,
  143. salesBillSn: this.pageData.data && this.pageData.data.salesBillSn
  144. }
  145. salesDetailList(params).then(res => {
  146. if (res.status == 200) {
  147. if(res.data && res.data.list){
  148. res.data.list.map(item => {
  149. item.productName = item.productEntity && item.productEntity.name || item.dealerProductEntity && item.dealerProductEntity.name
  150. item.productCode = item.productEntity && item.productEntity.code || item.dealerProductEntity && item.dealerProductEntity.code
  151. item.productUnit = item.productEntity && item.productEntity.unit || item.dealerProductEntity && item.dealerProductEntity.unit
  152. })
  153. if(this.pageNo>1){
  154. this.listData = this.listData.concat(res.data && res.data.list || [])
  155. }else{
  156. this.listData = res.data.list || []
  157. }
  158. }else{
  159. this.listData = []
  160. }
  161. this.totalNum = res.data && res.data.count || 0
  162. } else {
  163. this.listData = []
  164. this.totalNum = 0
  165. this.noDataText = res.message
  166. }
  167. })
  168. },
  169. // scroll-view到底部加载更多
  170. onreachBottom() {
  171. if(this.listData.length < this.totalNum){
  172. this.pageNo += 1
  173. this.getList()
  174. }
  175. },
  176. },
  177. watch: {
  178. toggle (newValue, oldValue) {
  179. const winH = window.innerHeight * 2
  180. let totalH = this.$refs.salesTotal && this.$refs.salesTotal.$el && this.$refs.salesTotal.$el.offsetHeight || 0
  181. this.scrollH = winH - 396 - totalH
  182. }
  183. }
  184. }
  185. </script>
  186. <style lang="scss">
  187. .sales-edit-wrap{
  188. width: 100%;
  189. position: relative;
  190. .color_6{
  191. color: #666;
  192. }
  193. .font_13{
  194. font-size: 26upx;
  195. }
  196. .border-b{
  197. border-bottom: 1px solid #e4e7ed;
  198. }
  199. .u-line{
  200. display: inline-block;
  201. width: 8upx;
  202. height: 40upx;
  203. background-color: red;
  204. vertical-align: bottom;
  205. margin: 0 20upx 0 0;
  206. }
  207. .sales-info-con{
  208. background-color: #fff;
  209. margin-bottom: 20upx;
  210. padding: 0 20upx;
  211. >view{
  212. padding: 14upx 0;
  213. border-bottom: 1px solid #e4e7ed;
  214. }
  215. >view:last-child{
  216. border-bottom: none;
  217. }
  218. .info-item-box{
  219. .info-item-tit{
  220. display: inline-block;
  221. width: 20%;
  222. }
  223. }
  224. }
  225. .sales-product-con{
  226. background-color: #fff;
  227. padding: 0 20upx;
  228. .sales-product-header{
  229. padding: 14upx 0;
  230. .sales-product-operation{
  231. button{
  232. margin: 0 0 0 10upx;
  233. }
  234. }
  235. }
  236. .sales-total-box{
  237. align-items: flex-end;
  238. padding: 16upx 0;
  239. .sales-total-con{
  240. color: #666;
  241. overflow: hidden;
  242. view{
  243. padding: 4upx 0;
  244. .sales-total-num{
  245. font-size: 24upx;
  246. color: rgb(48, 49, 51);
  247. }
  248. }
  249. }
  250. .sales-total-btn{
  251. display: inline-block;
  252. margin-bottom: 6upx;
  253. }
  254. }
  255. .sales-list-box{
  256. .sales-list-con{
  257. .sales-list-item{
  258. padding: 20upx 0;
  259. .pimgs{
  260. margin-right: 20upx;
  261. position: relative;
  262. .sign{
  263. position: absolute;
  264. right: -14upx;
  265. top: -14upx;
  266. color: #fff;
  267. border-radius: 50%;
  268. width: 40upx;
  269. height: 40upx;
  270. text-align: center;
  271. }
  272. }
  273. .sales-item-main{
  274. .sales-item-name{
  275. font-size: 28upx;
  276. color: rgb(48, 49, 51);
  277. font-weight: bold;
  278. overflow: hidden;
  279. text-overflow: ellipsis;
  280. display: -webkit-box;
  281. -webkit-box-orient: vertical;
  282. -webkit-line-clamp: 1;
  283. }
  284. .sales-item-txt{
  285. margin: 8upx 0;
  286. }
  287. .sales-item-price{
  288. text-align: right;
  289. }
  290. }
  291. }
  292. .sales-list-item:last-child{
  293. border: none;
  294. }
  295. }
  296. }
  297. }
  298. .sales-btn-box{
  299. background-color: #fff;
  300. position: fixed;
  301. bottom: 0;
  302. left: 0;
  303. width: 100%;
  304. padding: 16upx 20upx 12upx;
  305. .handle-btn{
  306. width: 47%;
  307. }
  308. }
  309. }
  310. </style>