chooseImportModal.vue 10 KB

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