chooseImportModal.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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.shelfSn"
  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="sTable 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. <template slot="errorMsg" slot-scope="text,record">
  41. <a-popover placement="topRight">
  42. <template slot="content">
  43. <p v-for="d in record.importErrorMsgSet" v-if="d">{{ d }};</p>
  44. </template>
  45. <a-button type="link">
  46. 查看
  47. </a-button>
  48. </a-popover>
  49. </template>
  50. </a-table>
  51. <!-- 按钮 -->
  52. <div class="btn-con">
  53. <a-button
  54. type="primary"
  55. id="chooseImport-submit"
  56. size="large"
  57. :class="loadData.length==0?'button-grey':'button-primary'"
  58. @click="handleSubmit"
  59. style="padding: 0 40px;">确认导入</a-button>
  60. <a-button
  61. id="chooseImport-cancel"
  62. size="large"
  63. class="button-cancel"
  64. @click="isShow=false"
  65. style="padding: 0 40px;margin-left: 15px;">取消</a-button>
  66. <a-button
  67. type="primary"
  68. id="chooseImport-error"
  69. size="large"
  70. class="button-error"
  71. @click="handleError"
  72. style="padding: 0 40px;margin-left: 15px;">导出错误项</a-button>
  73. </div>
  74. </div>
  75. </a-modal>
  76. </template>
  77. <script>
  78. import { importProduct, importProductExportError, importProductInsertBatch } from '@/api/allocWarehouse'
  79. import { hdExportExcel } from '@/libs/exportExcel'
  80. export default {
  81. name: 'ChooseImportModal',
  82. props: {
  83. openModal: { // 弹框显示状态
  84. type: Boolean,
  85. default: false
  86. },
  87. paramsData: { // 参数
  88. type: Object,
  89. default: () => {
  90. return {}
  91. }
  92. }
  93. },
  94. data () {
  95. return {
  96. isShow: this.openModal, // 是否打开弹框
  97. nowColumns: [ // 可导入
  98. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  99. { title: '产品编码', dataIndex: 'productCode', width: '17%', align: 'center', customRender: function (text) { return text || '--' } },
  100. { title: '产品名称', dataIndex: 'productName', width: '26%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  101. { title: '调出仓位', dataIndex: 'outWarehouseLocationName', width: '26%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  102. { title: '调入仓位', dataIndex: 'putWarehouseLocationName', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  103. { title: '单位', dataIndex: 'unit', width: '17%', align: 'center', customRender: function (text) { return text || '--' } },
  104. { title: '调出数量', dataIndex: 'allocationQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  105. ],
  106. nowUnColumns: [ // 不可导入
  107. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  108. { title: '产品编码', dataIndex: 'productCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  109. { title: '调出仓位', dataIndex: 'outWarehouseLocationName', width: '8%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  110. { title: '调入仓位', dataIndex: 'putWarehouseLocationName', width: '8%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  111. { title: '调出数量', dataIndex: 'allocationQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  112. { title: '错误原因', scopedSlots: { customRender: 'errorMsg' }, width: '10%', align: 'center' }
  113. ],
  114. loadData: [], // 正确数据列表
  115. unLoadData: [], // 错误数据列表
  116. loading: false
  117. }
  118. },
  119. methods: {
  120. getData () {
  121. const _this = this
  122. this.loading = true
  123. importProduct(this.paramsData).then(res => {
  124. this.loading = false
  125. if (res.status == 200) {
  126. // 正确数据
  127. if (res.data.rightList && res.data.rightList.length > 0) {
  128. res.data.rightList.map((item, index) => {
  129. item.no = index + 1
  130. })
  131. }
  132. // 错误数据
  133. if (res.data.errorList && res.data.errorList.length > 0) {
  134. res.data.errorList.map((item, index) => {
  135. item.no = index + 1
  136. item.importErrorMsgSet = item.errorMsg ? item.errorMsg.split(';') : []
  137. })
  138. }
  139. _this.loadData = res.data.rightList || []
  140. _this.unLoadData = res.data.errorList || []
  141. }
  142. })
  143. },
  144. // 确认导入
  145. handleSubmit () {
  146. if (this.loadData.length == 0) {
  147. this.$message.warning('暂无可导入产品!')
  148. } else {
  149. this.spinning = true
  150. importProductInsertBatch(this.loadData).then(res => {
  151. if (res.status == 200) {
  152. this.$emit('ok', this.loadData)
  153. this.isShow = false
  154. }
  155. this.spinning = false
  156. })
  157. }
  158. },
  159. // 导出错误项
  160. handleError () {
  161. const _this = this
  162. if (_this.unLoadData.length < 1) {
  163. _this.$message.info('暂无可导出错误项~')
  164. return
  165. }
  166. _this.spinning = true
  167. hdExportExcel(importProductExportError, _this.unLoadData, '仓库调拨产品导入错误项', function () {
  168. _this.spinning = false
  169. })
  170. }
  171. },
  172. watch: {
  173. // 父页面传过来的弹框状态
  174. openModal (newValue, oldValue) {
  175. this.isShow = newValue
  176. },
  177. // 重定义的弹框状态
  178. isShow (newValue, oldValue) {
  179. if (!newValue) {
  180. this.$emit('close')
  181. this.loadData = []
  182. this.unLoadData = []
  183. } else {
  184. this.getData()
  185. }
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="less" scoped>
  191. .chooseImport-modal{
  192. .chooseImport-con{
  193. .red{
  194. color: #f30;
  195. }
  196. .btn-con{
  197. text-align: center;
  198. margin: 30px 0 20px;
  199. .button-cancel,.button-error{
  200. font-size: 12px;
  201. }
  202. }
  203. }
  204. }
  205. </style>