chooseImportModal.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <a-modal
  3. centered
  4. class="chooseImport-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="导入"
  8. v-model="isShow"
  9. @cancel="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 40px;">确认导入</a-button>
  50. <a-button
  51. id="chooseImport-cancel"
  52. size="large"
  53. class="button-cancel"
  54. @click="isShow=false"
  55. style="padding: 0 40px;margin-left: 15px;">取消</a-button>
  56. <a-button
  57. type="primary"
  58. id="chooseImport-error"
  59. size="large"
  60. class="button-error"
  61. @click="handleError"
  62. style="padding: 0 40px;margin-left: 15px;">导出错误项</a-button>
  63. </div>
  64. </div>
  65. </a-modal>
  66. </template>
  67. <script>
  68. import { hdExportExcel } from '@/libs/exportExcel'
  69. import { stackPlaceImport, stackPlaceExportError } from '@/api/product'
  70. export default {
  71. name: 'ChooseImportModal',
  72. props: {
  73. openModal: { // 弹框显示状态
  74. type: Boolean,
  75. default: false
  76. },
  77. paramsData: {
  78. type: Object,
  79. default: () => {
  80. return {}
  81. }
  82. }
  83. },
  84. data () {
  85. return {
  86. isShow: this.openModal, // 是否打开弹框
  87. nowColumns: [
  88. { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
  89. { title: '产品编码', dataIndex: 'code', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
  90. { title: '产品名称', dataIndex: 'name', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
  91. { title: '货位编号-变更前', dataIndex: 'oldStackPlaceCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  92. { title: '货位编号-变更后', dataIndex: 'newStackPlaceCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } }
  93. ],
  94. loadData: [],
  95. nowUnColumns: [
  96. { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
  97. { title: '产品编码', dataIndex: 'code', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  98. { title: '产品名称', dataIndex: 'name', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  99. { title: '货位编号-变更前', dataIndex: 'oldStackPlaceCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  100. { title: '货位编号-变更后', dataIndex: 'newStackPlaceCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  101. { title: '备注', dataIndex: 'errorMsg', width: '15%', align: 'center', customRender: function (text) { return text || '--' } }
  102. ],
  103. unLoadData: [],
  104. loading: false
  105. }
  106. },
  107. methods: {
  108. getData () {
  109. const _this = this
  110. this.loading = true
  111. const params = {
  112. path: this.paramsData.path
  113. }
  114. stackPlaceImport(params).then(res => {
  115. this.loading = false
  116. if (res.status == 200) {
  117. if (res.data.rightList && res.data.rightList.length > 0) {
  118. res.data.rightList.map((item, index) => {
  119. item.no = index + 1
  120. })
  121. }
  122. if (res.data.errorList && res.data.errorList.length > 0) {
  123. res.data.errorList.map((item, index) => {
  124. item.no = index + 1
  125. })
  126. }
  127. _this.loadData = res.data.rightList || []
  128. _this.unLoadData = res.data.errorList || []
  129. }
  130. })
  131. },
  132. // 确认导入
  133. handleSubmit () {
  134. if (this.loadData.length == 0) {
  135. this.$message.warning('无可导入货位编号!')
  136. } else {
  137. this.$emit('ok', this.loadData)
  138. this.isShow = false
  139. }
  140. },
  141. // 导出
  142. handleError () {
  143. const _this = this
  144. if (_this.unLoadData.length < 1) {
  145. _this.$message.info('暂无可导出的错误项~')
  146. return
  147. }
  148. _this.spinning = true
  149. hdExportExcel(stackPlaceExportError, _this.unLoadData, '货位编号导入错误项', function () {
  150. _this.spinning = false
  151. })
  152. }
  153. },
  154. watch: {
  155. // 父页面传过来的弹框状态
  156. openModal (newValue, oldValue) {
  157. this.isShow = newValue
  158. },
  159. // 重定义的弹框状态
  160. isShow (newValue, oldValue) {
  161. if (!newValue) {
  162. this.$emit('close')
  163. this.loadData = []
  164. this.unLoadData = []
  165. } else {
  166. this.getData()
  167. }
  168. }
  169. }
  170. }
  171. </script>
  172. <style lang="less" scoped>
  173. .chooseImport-modal{
  174. .chooseImport-con{
  175. .red{
  176. color: #f30;
  177. }
  178. .btn-con{
  179. text-align: center;
  180. margin: 30px 0 20px;
  181. .button-cancel,.button-error{
  182. font-size: 12px;
  183. }
  184. }
  185. }
  186. }
  187. </style>