chooseImportModal.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 { commonMixin } from '@/utils/mixin'
  69. import { hdExportExcel } from '@/libs/exportExcel'
  70. // 接口
  71. import { allocateBillParseProducts, allocateBillFailExcel } from '@/api/allocateBill'
  72. export default {
  73. name: 'TransferOutChooseImportModal',
  74. mixins: [commonMixin],
  75. props: {
  76. openModal: { // 弹框显示状态
  77. type: Boolean,
  78. default: false
  79. },
  80. paramsData: {
  81. type: Object,
  82. default: () => {
  83. return {}
  84. }
  85. }
  86. },
  87. data () {
  88. return {
  89. isShow: this.openModal, // 是否打开弹框
  90. nowColumns: [ // 正品
  91. { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
  92. { title: '产品编码', dataIndex: 'productCode', align: 'center', customRender: function (text) { return text || '--' } },
  93. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' } },
  94. { title: '数量', dataIndex: 'qtyText', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  95. { title: '库存', dataIndex: 'currentStockQty', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  96. { title: '单位', dataIndex: 'productUnit', width: 60, align: 'center', customRender: function (text) { return text || '--' } }
  97. ],
  98. nowUnColumns: [ // 促销品
  99. { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
  100. { title: '产品编码', dataIndex: 'productCode', align: 'center', customRender: function (text) { return text || '--' } },
  101. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' } },
  102. { title: '数量', dataIndex: 'qtyText', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  103. { title: '库存', dataIndex: 'currentStockQty', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  104. { title: '单位', dataIndex: 'productUnit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  105. { title: '备注', dataIndex: 'errorDesc', width: 180, align: 'center', customRender: function (text) { return text || '--' } }
  106. ],
  107. loadData: [], // 可导入数据
  108. unLoadData: [], // 错误数据
  109. loading: false// 表格加载状态
  110. }
  111. },
  112. methods: {
  113. // 获取表格数据
  114. getData () {
  115. const _this = this
  116. this.loading = true
  117. // 获取列表数据 无分页
  118. allocateBillParseProducts(this.paramsData).then(res => {
  119. this.loading = false
  120. if (res.status == 200) {
  121. if (res.data.okList && res.data.okList.length > 0) {
  122. res.data.okList.map((item, index) => {
  123. item.no = index + 1
  124. })
  125. }
  126. if (res.data.failList && res.data.failList.length > 0) {
  127. res.data.failList.map((item, index) => {
  128. item.no = index + 1
  129. })
  130. }
  131. _this.loadData = res.data.okList || []
  132. _this.unLoadData = res.data.failList || []
  133. }
  134. })
  135. },
  136. // 确认导入
  137. handleSubmit () {
  138. if (this.loadData.length == 0) {
  139. this.$message.warning('无可导入产品!')
  140. } else {
  141. this.$emit('ok', this.loadData)
  142. this.isShow = false
  143. }
  144. },
  145. // 导出
  146. handleError () {
  147. const _this = this
  148. if (_this.unLoadData.length < 1) {
  149. _this.$message.info('暂无可导出错误项~')
  150. return
  151. }
  152. _this.spinning = true
  153. hdExportExcel(allocateBillFailExcel, _this.unLoadData, '产品导入错误项', function () {
  154. _this.spinning = false
  155. })
  156. }
  157. },
  158. watch: {
  159. // 父页面传过来的弹框状态
  160. openModal (newValue, oldValue) {
  161. this.isShow = newValue
  162. },
  163. // 重定义的弹框状态
  164. isShow (newValue, oldValue) {
  165. if (!newValue) {
  166. this.$emit('close')
  167. this.loadData = []
  168. this.unLoadData = []
  169. } else {
  170. this.getData()
  171. }
  172. }
  173. }
  174. }
  175. </script>
  176. <style lang="less" scoped>
  177. .chooseImport-modal{
  178. .chooseImport-con{
  179. .red{
  180. color: #f30;
  181. }
  182. .btn-con{
  183. text-align: center;
  184. margin: 30px 0 20px;
  185. .button-cancel,.button-error{
  186. font-size: 12px;
  187. }
  188. }
  189. }
  190. }
  191. </style>