edit.vue 14 KB

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