selectedProductsModal.vue 7.0 KB

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