chooseImportModal.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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="80%">
  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="sTable"
  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 { batchImportProduct, exportErrorProduct } from '@/api/product'
  72. export default {
  73. name: 'ProductChooseImportModal',
  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: '3%', align: 'center' },
  92. { title: '产品名称', dataIndex: 'name', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  93. { title: '产品编码', dataIndex: 'code', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  94. { title: '原厂编码', dataIndex: 'origCode', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  95. { title: '其它编码', dataIndex: 'otherCode', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  96. { title: '产品品牌', dataIndex: 'productBrandName', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  97. { title: '一级分类', dataIndex: 'productTypeName1', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  98. { title: '二级分类', dataIndex: 'productTypeName2', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  99. { title: '三级分类', dataIndex: 'productTypeName3', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  100. { title: '单位', dataIndex: 'unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  101. { title: '包装数', dataIndex: 'packQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  102. { title: '包装数单位', dataIndex: 'packQtyUnit', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  103. { title: '是否箭冠产品', dataIndex: 'arrow', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  104. { title: '条形码', dataIndex: 'qrCode', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  105. { title: '产品尺寸', dataIndex: 'size', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  106. { title: '产品重量(g)', dataIndex: 'weight', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  107. { title: '颜色', dataIndex: 'color', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  108. { title: '产品内盒尺寸', dataIndex: 'boxSize', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  109. { title: '产品说明', dataIndex: 'description', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  110. { title: '出库仓库', dataIndex: 'outWarehouseName', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  111. { title: '退货仓库', dataIndex: 'returnWarehouseName', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  112. { title: '其他说明', dataIndex: 'otherDesc', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  113. ],
  114. loadData: [], // 可导入数据
  115. nowUnColumns: [
  116. { title: '序号', dataIndex: 'no', width: '3%', align: 'center' },
  117. { title: '产品名称', dataIndex: 'name', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  118. { title: '产品编码', dataIndex: 'code', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  119. { title: '原厂编码', dataIndex: 'origCode', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  120. { title: '其它编码', dataIndex: 'otherCode', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  121. { title: '产品品牌', dataIndex: 'productBrandName', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  122. { title: '一级分类', dataIndex: 'productTypeName1', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  123. { title: '二级分类', dataIndex: 'productTypeName2', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  124. { title: '三级分类', dataIndex: 'productTypeName3', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  125. { title: '单位', dataIndex: 'unit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  126. { title: '包装数', dataIndex: 'packQty', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  127. { title: '包装数单位', dataIndex: 'packQtyUnit', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  128. { title: '是否箭冠产品', dataIndex: 'arrow', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  129. { title: '条形码', dataIndex: 'qrCode', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  130. { title: '产品尺寸', dataIndex: 'size', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  131. { title: '产品重量(g)', dataIndex: 'weight', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  132. { title: '颜色', dataIndex: 'color', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  133. { title: '产品内盒尺寸', dataIndex: 'boxSize', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  134. { title: '产品说明', dataIndex: 'description', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  135. { title: '其他说明', dataIndex: 'otherDesc', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  136. { title: '出库仓库', dataIndex: 'outWarehouseName', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  137. { title: '退货仓库', dataIndex: 'returnWarehouseName', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  138. { title: '备注', dataIndex: 'errorMsg', width: '5%', align: 'center', customRender: function (text) { return text || '--' } }
  139. ],
  140. unLoadData: [], // 导入错误数据
  141. loading: false// 列表加载状态
  142. }
  143. },
  144. methods: {
  145. // 获取导入列表数据
  146. getData () {
  147. const _this = this
  148. this.loading = true
  149. const params = {
  150. path: this.paramsData.path
  151. }
  152. batchImportProduct(params).then(res => {
  153. this.loading = false
  154. if (res.status == 200) {
  155. // 计算可导入列表序号
  156. if (res.data.rightList && res.data.rightList.length > 0) {
  157. res.data.rightList.map((item, index) => {
  158. item.no = index + 1
  159. })
  160. }
  161. // 计算错误项列表序号
  162. if (res.data.errorList && res.data.errorList.length > 0) {
  163. res.data.errorList.map((item, index) => {
  164. item.no = index + 1
  165. })
  166. }
  167. _this.loadData = res.data.rightList || []
  168. _this.unLoadData = res.data.errorList || []
  169. }
  170. })
  171. },
  172. // 确认导入
  173. handleSubmit () {
  174. if (this.loadData.length == 0) {
  175. this.$message.warning('无可导入产品!')
  176. } else {
  177. this.$emit('ok', this.loadData)
  178. this.isShow = false
  179. }
  180. },
  181. // 导出错误项
  182. handleError () {
  183. const _this = this
  184. if (_this.unLoadData.length < 1) {
  185. _this.$message.info('暂无可导出的错误项~')
  186. return
  187. }
  188. _this.spinning = true
  189. hdExportExcel(exportErrorProduct, _this.unLoadData, '导出产品错误项', function () {
  190. _this.spinning = false
  191. })
  192. }
  193. },
  194. watch: {
  195. // 父页面传过来的弹框状态
  196. openModal (newValue, oldValue) {
  197. this.isShow = newValue
  198. },
  199. // 重定义的弹框状态
  200. isShow (newValue, oldValue) {
  201. if (!newValue) {
  202. this.$emit('close')
  203. this.loadData = []
  204. this.unLoadData = []
  205. } else {
  206. this.getData()
  207. }
  208. }
  209. }
  210. }
  211. </script>
  212. <style lang="less" scoped>
  213. .chooseImport-modal{
  214. .chooseImport-con{
  215. .red{
  216. color: #f30;
  217. }
  218. .btn-con{
  219. text-align: center;
  220. margin: 30px 0 20px;
  221. .button-cancel,.button-error{
  222. font-size: 12px;
  223. }
  224. }
  225. }
  226. }
  227. </style>