chooseImportModal.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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.productCode"
  19. :columns="nowColumns"
  20. :dataSource="loadData"
  21. :loading="loading"
  22. :scroll="{ y: 200 }"
  23. :pagination="false"
  24. bordered>
  25. </a-table>
  26. <!-- 分割线 -->
  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.productCode"
  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. <a-button
  58. type="primary"
  59. id="chooseImport-error"
  60. size="large"
  61. class="button-error"
  62. @click="handleError"
  63. style="padding: 0 40px;margin-left: 15px;">导出错误项</a-button>
  64. </div>
  65. </div>
  66. </a-modal>
  67. </template>
  68. <script>
  69. import { commonMixin } from '@/utils/mixin'
  70. import { hdExportExcel } from '@/libs/exportExcel'
  71. import { salesFailExcel } from '@/api/salesDetailNew'
  72. export default {
  73. name: 'SalesChooseImportModal',
  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. // 正常列
  91. nowColumns: [
  92. { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
  93. { title: '产品编码', dataIndex: 'productCode', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
  94. { title: '产品名称', dataIndex: 'productName', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
  95. { title: '出库仓库', dataIndex: 'warehouseName', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  96. { title: '数量', dataIndex: 'qty', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  97. { title: '库存', dataIndex: 'stockQty', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  98. { title: '单位', dataIndex: 'productUnit', width: '14%', align: 'center', customRender: function (text) { return text || '--' } }
  99. ],
  100. loadData: [],
  101. // 错误项列
  102. nowUnColumns: [
  103. { title: '序号', dataIndex: 'no', width: '9%', align: 'center' },
  104. { title: '产品编码', dataIndex: 'productCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  105. { title: '产品名称', dataIndex: 'productName', width: '21%', align: 'center', customRender: function (text) { return text || '--' } },
  106. { title: '出库仓库', dataIndex: 'warehouseName', width: '21%', align: 'center', customRender: function (text) { return text || '--' } },
  107. { title: '数量', dataIndex: 'importQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  108. { title: '库存', dataIndex: 'stockQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  109. { title: '单位', dataIndex: 'productUnit', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  110. { title: '备注', dataIndex: 'errorDescSet', width: '20%', align: 'center', customRender: function (text) { return text || '--' } }
  111. ],
  112. unLoadData: [],
  113. loading: false
  114. }
  115. },
  116. methods: {
  117. // 获取数据,并格式化
  118. getData () {
  119. const paramsData = JSON.parse(JSON.stringify(this.paramsData))
  120. this.loadData = paramsData.rightList || [] // 可导入数据
  121. this.unLoadData = paramsData.errorList || [] // 错误数据
  122. // 格式化序号
  123. this.loadData.map((item, index) => {
  124. item.no = index + 1
  125. })
  126. this.unLoadData.map((item, index) => {
  127. item.no = index + 1
  128. })
  129. },
  130. // 确认导入
  131. handleSubmit () {
  132. if (this.loadData.length == 0) {
  133. this.$message.warning('无可导入产品!')
  134. } else {
  135. this.$emit('ok', this.loadData)
  136. this.isShow = false
  137. }
  138. },
  139. // 导出
  140. handleError () {
  141. const _this = this
  142. if (_this.unLoadData.length < 1) {
  143. _this.$message.info('暂无可导出错误项~')
  144. return
  145. }
  146. _this.spinning = true
  147. const params = {
  148. list: _this.unLoadData
  149. }
  150. hdExportExcel(salesFailExcel, params, '产品导入错误项', function () {
  151. _this.spinning = false
  152. })
  153. }
  154. },
  155. watch: {
  156. // 父页面传过来的弹框状态
  157. openModal (newValue, oldValue) {
  158. this.isShow = newValue
  159. },
  160. // 重定义的弹框状态
  161. isShow (newValue, oldValue) {
  162. if (!newValue) {
  163. this.$emit('close')
  164. this.loadData = []
  165. this.unLoadData = []
  166. } else {
  167. this.getData()
  168. }
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="less" scoped>
  174. .chooseImport-modal{
  175. .chooseImport-con{
  176. .red{
  177. color: #f30;
  178. }
  179. .btn-con{
  180. text-align: center;
  181. margin: 30px 0 20px;
  182. .button-cancel,.button-error{
  183. font-size: 12px;
  184. }
  185. }
  186. }
  187. }
  188. </style>