chooseImportModal.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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.allocateSn"
  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.errorDesc"
  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 { allocateBillParseProducts } from '@/api/allocateBill'
  62. export default {
  63. name: 'ChooseImportModal',
  64. props: {
  65. openModal: { // 弹框显示状态
  66. type: Boolean,
  67. default: false
  68. },
  69. paramsData: {
  70. type: Object,
  71. default: () => {
  72. return {}
  73. }
  74. }
  75. },
  76. data () {
  77. return {
  78. isShow: this.openModal, // 是否打开弹框
  79. nowColumns: [ // 正品
  80. { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
  81. { title: '产品编码', dataIndex: 'productCode', align: 'center', customRender: function (text) { return text || '--' } },
  82. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' } },
  83. { title: '数量', dataIndex: 'qtyText', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  84. { title: '库存', dataIndex: 'currentStockQty', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  85. { title: '单位', dataIndex: 'productUnit', width: 60, align: 'center', customRender: function (text) { return text || '--' } }
  86. ],
  87. nowUnColumns: [ // 促销品
  88. { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
  89. { title: '产品编码', dataIndex: 'productCode', align: 'center', customRender: function (text) { return text || '--' } },
  90. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' } },
  91. { title: '数量', dataIndex: 'qtyText', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  92. { title: '库存', dataIndex: 'currentStockQty', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  93. { title: '单位', dataIndex: 'productUnit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  94. { title: '备注', dataIndex: 'errorDesc', width: 180, align: 'center', customRender: function (text) { return text || '--' } }
  95. ],
  96. loadData: [],
  97. unLoadData: [],
  98. loading: false
  99. }
  100. },
  101. methods: {
  102. getData () {
  103. const _this = this
  104. this.loading = true
  105. allocateBillParseProducts(this.paramsData).then(res => {
  106. this.loading = false
  107. if (res.status == 200) {
  108. if (res.data.okList && res.data.okList.length > 0) {
  109. res.data.okList.map((item, index) => {
  110. item.no = index + 1
  111. })
  112. }
  113. if (res.data.failList && res.data.failList.length > 0) {
  114. res.data.failList.map((item, index) => {
  115. item.no = index + 1
  116. })
  117. }
  118. _this.loadData = res.data.okList || []
  119. _this.unLoadData = res.data.failList || []
  120. }
  121. })
  122. },
  123. // 确认导入
  124. handleSubmit () {
  125. if (this.loadData.length == 0) {
  126. this.$message.warning('无可导入产品!')
  127. } else {
  128. this.$emit('ok', this.loadData)
  129. this.isShow = false
  130. }
  131. }
  132. },
  133. watch: {
  134. // 父页面传过来的弹框状态
  135. openModal (newValue, oldValue) {
  136. this.isShow = newValue
  137. },
  138. // 重定义的弹框状态
  139. isShow (newValue, oldValue) {
  140. if (!newValue) {
  141. this.$emit('close')
  142. this.loadData = []
  143. this.unLoadData = []
  144. } else {
  145. this.getData()
  146. }
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="less" scoped>
  152. .chooseImport-modal{
  153. .chooseImport-con{
  154. .red{
  155. color: #f30;
  156. }
  157. .btn-con{
  158. text-align: center;
  159. margin: 30px 0 20px;
  160. .button-cancel{
  161. font-size: 12px;
  162. }
  163. }
  164. }
  165. }
  166. </style>