chooseProduct.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <a-drawer
  3. :zIndex="zIndex"
  4. :title="title"
  5. placement="right"
  6. :visible="isShow"
  7. width="80%"
  8. :get-container="false"
  9. :wrap-style="{ position: 'absolute' }"
  10. :headerStyle="{ padding: '10px' }"
  11. @close="onClose"
  12. wrapClassName="chooseProducts-modal">
  13. <a-spin :spinning="spinning" tip="Loading...">
  14. <div class="products-con">
  15. <div>
  16. <!-- 查询配件列表 -->
  17. <!-- 正常产品 -->
  18. <queryPart v-if="cptype==0" ref="partQuery" :newLoading="isInster" @add="insterProduct"></queryPart>
  19. <!-- 活动产品 -->
  20. <activeQueryPart v-if="cptype==1" ref="partQuery" :newLoading="isInster" @add="insterProduct"></activeQueryPart>
  21. <!-- 累计产品 -->
  22. <cumulativeProduct v-if="cptype==2" ref="partQuery" :newLoading="isInster" @add="insterProduct"></cumulativeProduct>
  23. </div>
  24. </div>
  25. </a-spin>
  26. </a-drawer>
  27. </template>
  28. <script>
  29. import queryPart from './queryPart.vue'
  30. import activeQueryPart from './activeQueryPart.vue'
  31. import cumulativeProduct from './cumulativeProduct.vue'
  32. export default {
  33. name: 'ChooseProductsModal',
  34. components: { queryPart, activeQueryPart, cumulativeProduct },
  35. props: {
  36. openModal: { // 弹框显示状态
  37. type: Boolean,
  38. default: false
  39. },
  40. chooseData: { // 已选数据
  41. type: Array,
  42. default: () => {
  43. return []
  44. }
  45. },
  46. isInster: { // 弹框显示状态
  47. type: Boolean,
  48. default: false
  49. },
  50. zIndex: { // 层级
  51. type: [String, Number],
  52. default: 1000
  53. }
  54. },
  55. data () {
  56. return {
  57. spinning: false,
  58. cptype: 3, // 组件类型
  59. isShow: this.openModal, // 是否打开弹框
  60. orderData: null, // 订单数据
  61. promoData: null, // 促销活动数据
  62. title: '选择产品'
  63. }
  64. },
  65. methods: {
  66. // 关闭弹框
  67. onClose () {
  68. this.$emit('close')
  69. },
  70. // 添加产品,
  71. // row 产品信息, promoProductClz 促销产品类型, 0 正常产品
  72. insterProduct (row, promoProductClz) {
  73. this.$emit('addProduct', row, this.promoData, promoProductClz, this.cptype)
  74. },
  75. // 初始化数据,
  76. // data 销售单详情数据, promo 促销活动规则数据, type 组件类型
  77. pageInit (data, promo, type) {
  78. this.cptype = type
  79. this.orderData = data
  80. this.promoData = promo
  81. this.title = type == 2 ? '累计产品' : '选择产品'
  82. this.$nextTick(() => {
  83. this.$refs.partQuery.pageInit(data, promo)
  84. })
  85. }
  86. },
  87. watch: {
  88. // 父页面传过来的弹框状态
  89. openModal (newValue, oldValue) {
  90. this.isShow = newValue
  91. },
  92. // 重定义的弹框状态
  93. isShow (newValue, oldValue) {
  94. if (!newValue) {
  95. this.$emit('close', this.cptype)
  96. this.cptype = 3
  97. }
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="less" scoped>
  103. .chooseProducts-modal{
  104. .products-con{
  105. .btn-con{
  106. text-align: center;
  107. margin: 30px 0 20px;
  108. .button-cancel{
  109. font-size: 12px;
  110. }
  111. }
  112. }
  113. }
  114. </style>