chooseImportModal.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <a-modal
  3. centered
  4. class="chooseImport-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="导入"
  8. v-model="isShow"
  9. @cancle="isShow=false"
  10. :width="900">
  11. <div class="chooseImport-con">
  12. <!-- 可导入数据 -->
  13. <p class="">可导入数据{{ loadData.length }}条</p>
  14. <a-table
  15. class="sTable"
  16. ref="table"
  17. size="small"
  18. :rowKey="(record) => record.goodsSn"
  19. :columns="nowColumns"
  20. :dataSource="loadData"
  21. :loading="loading"
  22. :scroll="{ y: 200 }"
  23. :pagination="false"
  24. bordered>
  25. </a-table>
  26. <a-divider />
  27. <!-- 不可导入数据 -->
  28. <p class="red">不可导入数据{{ unLoadData.length }}条</p>
  29. <a-table
  30. class="unTable"
  31. ref="unTable"
  32. size="small"
  33. :rowKey="(record) => record.goodsCode"
  34. :columns="nowUnColumns"
  35. :dataSource="unLoadData"
  36. :loading="loading"
  37. :scroll="{ y: 200 }"
  38. :pagination="false"
  39. bordered>
  40. </a-table>
  41. <!-- 按钮 -->
  42. <div class="btn-con">
  43. <a-button
  44. type="primary"
  45. id="chooseImport-submit"
  46. size="large"
  47. :class="loadData.length==0?'button-grey':'button-primary'"
  48. @click="handleSubmit"
  49. style="padding: 0 60px;">确认导入</a-button>
  50. <a-button
  51. id="chooseImport-cancel"
  52. size="large"
  53. class="button-cancel"
  54. @click="isShow=false"
  55. style="padding: 0 60px;margin-left: 15px;">取消</a-button>
  56. </div>
  57. </div>
  58. </a-modal>
  59. </template>
  60. <script>
  61. import { promoRuleGoods } from '@/api/promoRule'
  62. export default {
  63. name: 'ChooseImportModal',
  64. props: {
  65. openModal: { // 弹框显示状态
  66. type: Boolean,
  67. default: false
  68. },
  69. itemId: {
  70. type: [Number, String],
  71. default: ''
  72. },
  73. paramsData: {
  74. type: Object,
  75. default: () => {
  76. return {}
  77. }
  78. }
  79. },
  80. computed: {
  81. nowColumns () {
  82. let columns = this.columns
  83. if ((this.paramsData && this.paramsData.promoRuleType == 'BUY_PROD_GIVE_PROD') || (this.paramsData && this.paramsData.promoRuleType == 'BUY_PROD_GIVE_MONEY')) { // 买产品送产品/买产品送采购额
  84. if (this.paramsData && this.paramsData.promoGoodsType == 'NORMAL_PROD') { // 正品
  85. columns = this.columns
  86. } else if (this.paramsData && this.paramsData.promoGoodsType == 'PROMO_PROD') { // 促销
  87. columns = this.promoColumns
  88. }
  89. } else if (this.paramsData && this.paramsData.promoRuleType == 'PROMO_PROD') { // 特价产品
  90. if (this.paramsData && this.paramsData.promoGoodsType == 'PROMO_PROD') { // 促销
  91. columns = this.promoSpecialColumns
  92. }
  93. } else if (this.paramsData && this.paramsData.promoRuleType == 'ADD_PRICE_PURCH') { // 加价换购
  94. if (this.paramsData && this.paramsData.promoGoodsType == 'NORMAL_PROD') { // 正品
  95. columns = this.columns
  96. } else if (this.paramsData && this.paramsData.promoGoodsType == 'PROMO_PROD') { // 促销
  97. columns = this.promoSpecialColumns
  98. }
  99. }
  100. return columns
  101. },
  102. nowUnColumns () {
  103. let columns = this.unColumns
  104. if ((this.paramsData && this.paramsData.promoRuleType == 'BUY_PROD_GIVE_PROD') || (this.paramsData && this.paramsData.promoRuleType == 'BUY_PROD_GIVE_MONEY')) { // 买产品送产品/买产品送采购额
  105. if (this.paramsData && this.paramsData.promoGoodsType == 'NORMAL_PROD') { // 正品
  106. columns = this.unColumns
  107. } else if (this.paramsData && this.paramsData.promoGoodsType == 'PROMO_PROD') { // 促销
  108. columns = this.unPromoColumns
  109. }
  110. } else if (this.paramsData && this.paramsData.promoRuleType == 'PROMO_PROD') { // 特价产品
  111. if (this.paramsData && this.paramsData.promoGoodsType == 'PROMO_PROD') { // 促销
  112. columns = this.unPromoSpecialColumns
  113. }
  114. } else if (this.paramsData && this.paramsData.promoRuleType == 'ADD_PRICE_PURCH') { // 加价换购
  115. if (this.paramsData && this.paramsData.promoGoodsType == 'NORMAL_PROD') { // 正品
  116. columns = this.unColumns
  117. } else if (this.paramsData && this.paramsData.promoGoodsType == 'PROMO_PROD') { // 促销
  118. columns = this.unPromoSpecialColumns
  119. }
  120. }
  121. return columns
  122. }
  123. },
  124. data () {
  125. return {
  126. isShow: this.openModal, // 是否打开弹框
  127. columns: [ // 正品
  128. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  129. { title: '产品编码', dataIndex: 'goodsCode', align: 'center', customRender: function (text) { return text || '--' } },
  130. { title: '起订量限制', dataIndex: 'orderGoodsUnitDictValue', align: 'center', customRender: function (text) { return text || '--' } },
  131. { title: '起订数量', dataIndex: 'orderGoodsQty', align: 'center', customRender: function (text) { return text || '--' } }
  132. ],
  133. promoColumns: [ // 促销品
  134. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  135. { title: '产品编码', dataIndex: 'goodsCode', align: 'center', customRender: function (text) { return text || '--' } }
  136. ],
  137. promoSpecialColumns: [ // 特价产品/加价促销品
  138. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  139. { title: '产品编码', dataIndex: 'goodsCode', align: 'center', customRender: function (text) { return text || '--' } },
  140. { title: this.paramsData && this.paramsData.promoRuleType == 'PROMO_PROD' ? '特惠单价(¥)' : '换购单价(¥)', dataIndex: 'goodsPrice', width: 200, align: 'center', customRender: function (text) { return text || '--' } }
  141. ],
  142. loadData: [],
  143. unColumns: [ // 不可导入产品 正品
  144. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  145. { title: '产品编码', dataIndex: 'goodsCode', align: 'center', customRender: function (text) { return text || '--' } },
  146. { title: '起订量限制', dataIndex: 'orderGoodsUnitDictValue', align: 'center', customRender: function (text) { return text || '--' } },
  147. { title: '起订数量', dataIndex: 'orderGoodsQty', align: 'center', customRender: function (text) { return text || '--' } },
  148. { title: '备注', dataIndex: 'remark', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
  149. ],
  150. unPromoColumns: [ // 不可导入产品 促销品
  151. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  152. { title: '产品编码', dataIndex: 'goodsCode', align: 'center', customRender: function (text) { return text || '--' } },
  153. { title: '备注', dataIndex: 'remark', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
  154. ],
  155. unPromoSpecialColumns: [ // 不可导入产品 特价产品/加价促销品
  156. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  157. { title: '产品编码', dataIndex: 'goodsCode', align: 'center', customRender: function (text) { return text || '--' } },
  158. { title: this.paramsData && this.paramsData.promoRuleType == 'PROMO_PROD' ? '特惠单价(¥)' : '换购单价(¥)', dataIndex: 'goodsPrice', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  159. { title: '备注', dataIndex: 'remark', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
  160. ],
  161. unLoadData: [],
  162. loading: false
  163. }
  164. },
  165. methods: {
  166. getData () {
  167. const _this = this
  168. this.loading = true
  169. promoRuleGoods(this.paramsData).then(res => {
  170. this.loading = false
  171. if (res.status == 200) {
  172. if (res.data.okGoodsList && res.data.okGoodsList.length > 0) {
  173. res.data.okGoodsList.map((item, index) => {
  174. item.no = index + 1
  175. })
  176. }
  177. if (res.data.erroGoodsList && res.data.erroGoodsList.length > 0) {
  178. res.data.erroGoodsList.map((item, index) => {
  179. item.no = index + 1
  180. })
  181. }
  182. _this.loadData = res.data.okGoodsList || []
  183. _this.unLoadData = res.data.erroGoodsList || []
  184. }
  185. })
  186. },
  187. // 确认导入
  188. handleSubmit () {
  189. if (this.loadData.length == 0) {
  190. this.$message.warning('无可导入产品!')
  191. } else {
  192. this.$emit('ok', this.loadData)
  193. this.isShow = false
  194. }
  195. }
  196. },
  197. watch: {
  198. // 父页面传过来的弹框状态
  199. openModal (newValue, oldValue) {
  200. this.isShow = newValue
  201. },
  202. // 重定义的弹框状态
  203. isShow (newValue, oldValue) {
  204. if (!newValue) {
  205. this.$emit('close')
  206. this.loadData = []
  207. this.unLoadData = []
  208. } else {
  209. this.getData()
  210. }
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="less" scoped>
  216. .chooseImport-modal{
  217. .chooseImport-con{
  218. .red{
  219. color: #f30;
  220. }
  221. .btn-con{
  222. text-align: center;
  223. margin: 30px 0 20px;
  224. .button-cancel{
  225. font-size: 12px;
  226. }
  227. }
  228. }
  229. }
  230. </style>