import.vue 7.1 KB

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