chooseImportModal.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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.shelfSn"
  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 unTable"
  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. </div>
  57. </div>
  58. </a-modal>
  59. </template>
  60. <script>
  61. import { shelfProductParseProducts } from '@/api/shelf'
  62. import { toThousands } from '@/libs/tools.js'
  63. export default {
  64. name: 'ChooseImportModal',
  65. props: {
  66. openModal: { // 弹框显示状态
  67. type: Boolean,
  68. default: false
  69. },
  70. paramsData: { // 参数
  71. type: Object,
  72. default: () => {
  73. return {}
  74. }
  75. }
  76. },
  77. data () {
  78. const _this = this
  79. return {
  80. toThousands,
  81. isShow: this.openModal, // 是否打开弹框
  82. nowColumns: [ // 可导入
  83. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  84. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '19%', align: 'center', customRender: function (text) { return text || '--' } },
  85. { title: '绑定产品编码', dataIndex: 'productCode', width: '17%', align: 'center', customRender: function (text) { return text || '--' } },
  86. { title: '绑定产品名称', dataIndex: 'productName', width: '26%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  87. { title: '车主价', dataIndex: 'price', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  88. { title: '结算价', dataIndex: 'cost', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  89. { title: '最大库容', dataIndex: 'maxQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  90. ],
  91. nowUnColumns: [ // 不可导入
  92. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  93. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  94. { title: '绑定产品编码', dataIndex: 'productCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  95. { title: '绑定产品名称', dataIndex: 'productName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  96. { title: '车主价', dataIndex: 'price', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  97. { title: '结算价', dataIndex: 'cost', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  98. { title: '最大库容', dataIndex: 'maxQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  99. { title: '错误原因', dataIndex: 'remarks', width: '17%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true }
  100. ],
  101. loadData: [], // 正常表格数据
  102. unLoadData: [], // 错误表格数据
  103. loading: false
  104. }
  105. },
  106. methods: {
  107. // 获取表格数据
  108. getData () {
  109. const _this = this
  110. this.loading = true
  111. shelfProductParseProducts(this.paramsData).then(res => {
  112. this.loading = false
  113. if (res.status == 200) {
  114. // 正确列表
  115. if (res.data.successList && res.data.successList.length > 0) {
  116. res.data.successList.map((item, index) => {
  117. item.no = index + 1
  118. })
  119. }
  120. // 错误列表
  121. if (res.data.failList && res.data.failList.length > 0) {
  122. res.data.failList.map((item, index) => {
  123. item.no = index + 1
  124. })
  125. }
  126. _this.loadData = res.data.successList || []
  127. _this.unLoadData = res.data.failList || []
  128. }
  129. })
  130. },
  131. // 确认导入
  132. handleSubmit () {
  133. if (this.loadData.length == 0) {
  134. this.$message.warning('无可导入产品!')
  135. } else {
  136. this.$emit('ok', this.loadData)
  137. this.isShow = false
  138. }
  139. }
  140. },
  141. watch: {
  142. // 父页面传过来的弹框状态
  143. openModal (newValue, oldValue) {
  144. this.isShow = newValue
  145. },
  146. // 重定义的弹框状态
  147. isShow (newValue, oldValue) {
  148. if (!newValue) {
  149. this.$emit('close')
  150. this.loadData = []
  151. this.unLoadData = []
  152. } else {
  153. this.getData()
  154. }
  155. }
  156. }
  157. }
  158. </script>
  159. <style lang="less" scoped>
  160. .chooseImport-modal{
  161. .chooseImport-con{
  162. .red{
  163. color: #f30;
  164. }
  165. .btn-con{
  166. text-align: center;
  167. margin: 30px 0 20px;
  168. .button-cancel,.button-error{
  169. font-size: 12px;
  170. }
  171. }
  172. }
  173. }
  174. </style>