chooseImportModal.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. <p class="red">注意:成功导入后,现有的货位将会被全部删除,即覆盖导入的方式,您所看到的货位就是可导入的数据,请谨慎操作</p>
  15. <a-table
  16. class="sTable"
  17. ref="table"
  18. size="small"
  19. :rowKey="(record) => record.allocateSn"
  20. :columns="nowColumns"
  21. :dataSource="loadData"
  22. :loading="loading"
  23. :scroll="{ y: 200 }"
  24. :pagination="false"
  25. bordered>
  26. </a-table>
  27. <a-divider />
  28. <!-- 不可导入数据 -->
  29. <p class="red">不可导入数据{{ unLoadData.length }}条</p>
  30. <a-table
  31. class="unTable"
  32. ref="unTable"
  33. size="small"
  34. :rowKey="(record) => record.errorDesc"
  35. :columns="nowUnColumns"
  36. :dataSource="unLoadData"
  37. :loading="loading"
  38. :scroll="{ y: 200 }"
  39. :pagination="false"
  40. bordered>
  41. </a-table>
  42. <!-- 按钮 -->
  43. <div class="btn-con">
  44. <a-button
  45. type="primary"
  46. id="chooseImport-submit"
  47. size="large"
  48. :class="loadData.length==0?'button-grey':'button-primary'"
  49. @click="handleSubmit"
  50. style="padding: 0 40px;">确认导入</a-button>
  51. <a-button
  52. id="chooseImport-cancel"
  53. size="large"
  54. class="button-cancel"
  55. @click="isShow=false"
  56. style="padding: 0 40px;margin-left: 15px;">取消</a-button>
  57. </div>
  58. </div>
  59. </a-modal>
  60. </template>
  61. <script>
  62. // import { hdExportExcel } from '@/libs/exportExcel'
  63. import { saveBatchExcel, exportExcelData } from '@/api/shelf'
  64. export default {
  65. name: 'ChooseImportModal',
  66. props: {
  67. openModal: { // 弹框显示状态
  68. type: Boolean,
  69. default: false
  70. },
  71. paramsData: {
  72. type: Object,
  73. default: () => {
  74. return {}
  75. }
  76. }
  77. },
  78. data () {
  79. return {
  80. isShow: this.openModal, // 是否打开弹框
  81. nowColumns: [
  82. { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
  83. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '90%', align: 'center', customRender: function (text) { return text || '--' } }
  84. ],
  85. loadData: [],
  86. nowUnColumns: [
  87. { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
  88. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '40%', align: 'center', customRender: function (text) { return text || '--' } },
  89. { title: '错误原因', dataIndex: 'remarks', width: '50%', align: 'center', customRender: function (text) { return text || '--' } }
  90. ],
  91. unLoadData: [],
  92. loading: false
  93. }
  94. },
  95. methods: {
  96. getData () {
  97. const _this = this
  98. this.loading = true
  99. const params = {
  100. shelfSn: this.paramsData.shelfSn,
  101. path: this.paramsData.path
  102. }
  103. exportExcelData(params).then(res => {
  104. this.loading = false
  105. if (res.status == 200) {
  106. if (res.data.successList && res.data.successList.length > 0) {
  107. res.data.successList.map((item, index) => {
  108. item.no = index + 1
  109. })
  110. }
  111. if (res.data.failList && res.data.failList.length > 0) {
  112. res.data.failList.map((item, index) => {
  113. item.no = index + 1
  114. })
  115. }
  116. _this.loadData = res.data.successList || []
  117. _this.unLoadData = res.data.failList || []
  118. }
  119. })
  120. },
  121. // 确认导入
  122. handleSubmit () {
  123. if (this.loadData.length == 0) {
  124. this.$message.warning('无可导入产品!')
  125. } else {
  126. saveBatchExcel(this.loadData).then(res => {
  127. if (res.status == 200) {
  128. this.$emit('ok', this.loadData)
  129. this.isShow = false
  130. }
  131. })
  132. }
  133. }
  134. },
  135. watch: {
  136. // 父页面传过来的弹框状态
  137. openModal (newValue, oldValue) {
  138. this.isShow = newValue
  139. },
  140. // 重定义的弹框状态
  141. isShow (newValue, oldValue) {
  142. if (!newValue) {
  143. this.$emit('close')
  144. this.loadData = []
  145. this.unLoadData = []
  146. } else {
  147. this.getData()
  148. }
  149. }
  150. }
  151. }
  152. </script>
  153. <style lang="less" scoped>
  154. .chooseImport-modal{
  155. .chooseImport-con{
  156. .red{
  157. color: #f30;
  158. }
  159. .btn-con{
  160. text-align: center;
  161. margin: 30px 0 20px;
  162. .button-cancel,.button-error{
  163. font-size: 12px;
  164. }
  165. }
  166. }
  167. }
  168. </style>