selectedProductsModal.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <view class="selectedProducts-modal">
  3. <u-popup v-model="isShow" @close="isShow=false" mode="bottom" z-index="9999">
  4. <!-- 已选产品 -->
  5. <scroll-view class="product-list-con" scroll-y @scrolltolower="onreachBottom">
  6. <view class="product-list-item flex align_center justify_between" v-for="(item, index) in listData" :key="item.id">
  7. <view class="product-item-main font_13 flex_1" @click="handleEdit(item)">
  8. <view class="flex align_center justify_between">
  9. <view>{{item.productCode || '--'}}</view>
  10. <view class="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>
  11. <u-tag v-if="item.oosFlag==1" text="急件" type="error" mode="light" shape="circle" size="mini" style="vertical-align: text-top;" />
  12. </view>
  13. <view class="product-item-name">{{item.productName || '--'}}</view>
  14. <view class="product-item-priceInfo">
  15. <view :style="{color: $config('errorColor'), display: 'inline-block'}">¥<text style="font-size: 30upx;">{{toThousands(item.price||0, 2)}}</text></view>
  16. <text style="display: inline-block;margin: 0 10upx;">*</text>
  17. <text style="font-size: 30upx;">{{toThousands(item.qty||0)}}</text>
  18. {{item.productUnit}}
  19. </view>
  20. </view>
  21. <view class="btn-box">
  22. <u-icon @click="handleDel(item, index)" name="trash-fill" :color="$config('errorColor')" size="34"></u-icon>
  23. </view>
  24. </view>
  25. <view v-if="listData && listData.length == 0">
  26. <u-empty :text="noDataText" mode="list" :img-width="200" :margin-top="30"></u-empty>
  27. </view>
  28. </scroll-view>
  29. <!-- 合计 -->
  30. <view ref="productTotal" class="selected-box flex align_center justify_between">
  31. <view class="choose-info flex_1 flex align_center justify_between" @click="isShow=false">
  32. <text>已选 {{nowData && (nowData.totalCategory || nowData.totalCategory==0) ? toThousands(nowData.totalCategory) : '--'}} 款,合计 ¥{{nowData && (nowData.totalAmount || nowData.totalAmount==0) ? toThousands(nowData.totalAmount, 2) : '--'}}</text>
  33. <u-icon name="arrow-down" :color="$config('primaryColor')" size="34" class="close-circle"></u-icon>
  34. </view>
  35. <view class="choose-btn" @click="handleChoose" :style="{backgroundColor: $config('primaryColor')}">选好了</view>
  36. </view>
  37. </u-popup>
  38. <!-- 弹框 -->
  39. <common-modal :openModal="commonModal" content="确认要删除吗?" @confirm="handleCommon" @close="commonModal=false" />
  40. </view>
  41. </template>
  42. <script>
  43. import commonModal from '@/pages/common/commonModal.vue'
  44. import { toThousands } from '@/libs/tools'
  45. import { salesDetailList, salesDetailDel } from '@/api/sales'
  46. export default {
  47. components: { commonModal },
  48. props: {
  49. openModal: { // 弹框显示状态
  50. type: Boolean,
  51. default: false
  52. },
  53. nowData: {
  54. type: Object,
  55. default: ()=>{
  56. return null
  57. }
  58. }
  59. },
  60. data() {
  61. return {
  62. isShow: this.openModal, // 是否打开弹框
  63. listData: [],
  64. pageNo: 1,
  65. pageSize: 6,
  66. totalNum: 0,
  67. noDataText: '暂无数据',
  68. toThousands,
  69. theme: '',
  70. commonModal: false,
  71. infoData: null, //
  72. detailData: null
  73. }
  74. },
  75. mounted() {
  76. this.theme = getApp().globalData.theme
  77. },
  78. methods: {
  79. // 列表
  80. getList(pageNo){
  81. const _this = this
  82. if (pageNo) {
  83. this.pageNo = pageNo
  84. }
  85. let params = {
  86. pageNo: this.pageNo,
  87. pageSize: this.pageSize,
  88. salesBillSn: this.nowData && this.nowData.salesBillSn
  89. }
  90. salesDetailList(params).then(res => {
  91. if (res.status == 200) {
  92. if(res.data && res.data.list){
  93. res.data.list.map(item => {
  94. item.productName = item.productEntity && item.productEntity.name || item.dealerProductEntity && item.dealerProductEntity.name
  95. item.productCode = item.productEntity && item.productEntity.code || item.dealerProductEntity && item.dealerProductEntity.code
  96. item.productUnit = item.productEntity && item.productEntity.unit || item.dealerProductEntity && item.dealerProductEntity.unit
  97. })
  98. if(this.pageNo>1){
  99. this.listData = this.listData.concat(res.data && res.data.list || [])
  100. }else{
  101. this.listData = res.data.list || []
  102. }
  103. }else{
  104. this.listData = []
  105. }
  106. this.totalNum = res.data && res.data.count || 0
  107. } else {
  108. this.listData = []
  109. this.totalNum = 0
  110. this.noDataText = res.message
  111. }
  112. })
  113. },
  114. // scroll-view到底部加载更多
  115. onreachBottom() {
  116. if(this.listData.length < this.totalNum){
  117. this.pageNo += 1
  118. this.getList()
  119. }
  120. },
  121. // 编辑产品
  122. handleEdit(data){
  123. this.$emit('edit', data)
  124. },
  125. // 已选产品 删除
  126. handleDel(data, ind){
  127. this.infoData = data
  128. this.infoData.no = ind
  129. this.commonModal = true
  130. },
  131. // 删除
  132. handleCommon(){
  133. salesDetailDel({ id: this.infoData.id }).then(res => {
  134. if(res.status == 200){
  135. this.listData.splice(this.infoData.no, 1)
  136. this.commonModal = false
  137. this.$emit('refreshTotal')
  138. }
  139. })
  140. },
  141. // 选好了
  142. handleChoose(){
  143. this.$emit('confirm')
  144. },
  145. // 已选产品合计
  146. selectedProductTotal(){
  147. salesDetail({ id: this.infoData.id }).then(res => {
  148. if(res.status == 200){
  149. this.detailData = res.data
  150. }else{
  151. this.detailData = null
  152. }
  153. })
  154. },
  155. },
  156. watch: {
  157. // 父页面传过来的弹框状态
  158. openModal (newValue, oldValue) {
  159. this.isShow = newValue
  160. },
  161. // 重定义的弹框状态
  162. isShow (newValue, oldValue) {
  163. if (!newValue) {
  164. this.$emit('close')
  165. }else{
  166. this.getList(1) // 已选产品列表
  167. }
  168. }
  169. }
  170. }
  171. </script>
  172. <style lang="scss" scoped>
  173. .selectedProducts-modal{
  174. .product-list-con{
  175. height: 700upx;
  176. padding: 20upx 20upx 30upx;
  177. box-sizing: border-box;
  178. .product-list-item{
  179. border-bottom: 1px solid #e4e7ed;
  180. padding: 10upx 0;
  181. .product-item-main{
  182. .product-item-name{
  183. padding: 6upx 0;
  184. overflow: hidden;
  185. text-overflow: ellipsis;
  186. display: -webkit-box;
  187. -webkit-line-clamp: 1;
  188. line-clamp: 1;
  189. -webkit-box-orient: vertical;
  190. }
  191. }
  192. .btn-box{
  193. padding: 30upx 30upx;
  194. }
  195. }
  196. .product-list-item:last-child{
  197. border: none;
  198. }
  199. }
  200. .selected-box{
  201. position: fixed;
  202. bottom: 0;
  203. left: 0;
  204. width: 100%;
  205. background-color: #fff;
  206. box-shadow: 1px -1px 3px #EEEEEE;
  207. .choose-info{
  208. padding: 0 30upx;
  209. }
  210. .choose-btn{
  211. color: #fff;
  212. width: 28%;
  213. padding: 26upx 0;
  214. text-align: center;
  215. }
  216. }
  217. }
  218. </style>