import.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <div class="intelligentReplenishmentImport-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="intelligentReplenishmentImport-back">
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="intelligentReplenishmentImport-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. </template>
  9. </a-page-header>
  10. <a-card size="small" :bordered="false" class="intelligentReplenishmentImport-cont">
  11. <div>
  12. <p class="total">共 <span>{{ listData.length }}</span> 条数据,红色字体表示数据不符合规范,请返回上一步修改文件后重新上传</p>
  13. <ve-table
  14. border-y
  15. :border-around="false"
  16. :max-height="tableHeight"
  17. :row-style-option="{clickHighlight: true}"
  18. :cellSelectionOption="{enable: false}"
  19. :virtual-scroll-option="{enable: true}"
  20. :columns="columns"
  21. :table-data="listData"
  22. row-key-field-name="id"
  23. />
  24. <div class="btn-cont">
  25. <a-button
  26. type="primary"
  27. v-if="errorFlag.indexOf('1')==-1"
  28. id="intelligentReplenishmentLevel-submit"
  29. size="large"
  30. class="button-primary"
  31. @click="handleSubmit"
  32. style="padding: 0 60px;">确认导入</a-button>
  33. <a-button
  34. type="primary"
  35. v-if="errorFlag.indexOf('1')!=-1"
  36. id="intelligentReplenishmentLevel-set"
  37. size="large"
  38. class="button-primary"
  39. @click="handleBackSet"
  40. style="padding: 0 60px;">上一步</a-button>
  41. <a-button
  42. id="intelligentReplenishmentLevel-back"
  43. size="large"
  44. class="button-cancel"
  45. @click="handleBack"
  46. style="padding: 0 60px;">取消</a-button>
  47. </div>
  48. </div>
  49. </a-card>
  50. </a-spin>
  51. </div>
  52. </template>
  53. <script>
  54. import { commonMixin } from '@/utils/mixin'
  55. import { STable } from '@/components'
  56. import { predictProductInfoGoods, predictProductInfoInsert } from '@/api/predict'
  57. export default {
  58. name: 'IntelligentReplenishmentImport',
  59. mixins: [commonMixin],
  60. components: { STable },
  61. data () {
  62. return {
  63. spinning: false,
  64. tableHeight: 500,
  65. columns: [
  66. { title: '序号', field: 'no',key: "a", width: 80, align: 'center', fixed: 'left',operationColumn: false },
  67. { title: '产品编码', field: 'productCode',key: "b", width: 220, align: 'center',operationColumn: false,renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'} },
  68. { title: '产品名称', field: 'productName',key: "c", align: 'center',operationColumn: false , ellipsis: { showTitle: true },renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'}},
  69. { title: '产品状态', field: 'productStateDictValue',key: "d", width: 100, align: 'center',operationColumn: false,renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'} },
  70. { title: '订货周期(天)', field: 'cycle',key: "e", width: 120, align: 'center',operationColumn: false,renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || row[column.field] == 0 ? row[column.field] : '--'}},
  71. { title: '是否淘汰', field: 'eliminateText',key: "f", width: 100, align: 'center',operationColumn: false,renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'}},
  72. { title: '淘汰描述', field: 'eliminateDesc',key: "g", width: 200, align: 'center',operationColumn: false, ellipsis: { showTitle: true },renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'}},
  73. { title: '备注', field: 'remark', width: 200,key: "h", align: 'center',operationColumn: false, ellipsis: { showTitle: true },renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'} },
  74. { title: '错误原因', field: 'errorDesc',key: "i", width: 200, align: 'center',operationColumn: false, ellipsis: { showTitle: true } ,renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--'}}
  75. ],
  76. listData: [],
  77. errorFlag: []
  78. }
  79. },
  80. methods: {
  81. // 返回
  82. handleBack () {
  83. this.$router.push({ path: `/inventoryManagement/intelligentReplenishment/list`, query: { closeLastOldTab: true } })
  84. },
  85. // 返回基础设置页
  86. handleBackSet () {
  87. this.$router.push({ path: `/inventoryManagement/intelligentReplenishment/set` })
  88. },
  89. getTable(){
  90. this.tableHeight = window.innerHeight - 325
  91. this.spinning = true
  92. predictProductInfoGoods({ path: JSON.parse(this.$cookies.get('REPLENISHMENT_PATH')) }).then(res => {
  93. let data
  94. if (res.status == 200) {
  95. data = res.data
  96. for (var i = 0; i < data.list.length; i++) {
  97. data.list[i].no = i + 1
  98. this.errorFlag.push(data.list[i].errorFlag)
  99. }
  100. this.listData = data.list
  101. }
  102. this.spinning = false
  103. })
  104. },
  105. // 确认导入
  106. handleSubmit () {
  107. const _this = this
  108. _this.spinning = true
  109. predictProductInfoInsert(this.listData).then(res => {
  110. _this.spinning = false
  111. if (res.status == 200) {
  112. _this.$success({
  113. content: '数据导入成功!',
  114. centered: true,
  115. onOk () {
  116. _this.handleBack()
  117. }
  118. })
  119. } else {
  120. _this.$error({
  121. content: '数据导入失败,请重试!',
  122. centered: true,
  123. onOk () {}
  124. })
  125. }
  126. })
  127. }
  128. },
  129. mounted () {
  130. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  131. this.getTable()
  132. }
  133. },
  134. activated () {
  135. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  136. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  137. this.getTable()
  138. }
  139. }
  140. }
  141. </script>
  142. <style lang="less">
  143. .intelligentReplenishmentImport-wrap{
  144. .intelligentReplenishmentImport-back{
  145. margin-bottom: 10px;
  146. }
  147. .intelligentReplenishmentImport-cont{
  148. .total{
  149. margin: 20px 0 30px;
  150. span{
  151. font-weight: bold;
  152. }
  153. }
  154. .btn-cont{
  155. margin: 30px 0 20px;
  156. text-align: center;
  157. .button-cancel{
  158. font-size: 12px;
  159. margin-left: 15px;
  160. }
  161. }
  162. }
  163. .redBg-row{
  164. background-color: #f5cdc8;
  165. }
  166. }
  167. </style>