chooseShelfImportModal.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <a-modal
  3. centered
  4. class="chooseImport-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="确认导入货位"
  8. v-model="isShow"
  9. @cancle="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.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="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. :disabled="disabled"
  48. :class="loadData.length==0?'button-grey':'button-primary'"
  49. @click="handleSubmit"
  50. style="padding: 0 40px;">确认导入</a-button>
  51. <a-button
  52. id="chooseImport-cancel"
  53. size="large"
  54. :disabled="disabled"
  55. class="button-cancel"
  56. @click="isShow=false"
  57. style="padding: 0 40px;margin-left: 15px;">取消</a-button>
  58. <a-button
  59. type="primary"
  60. id="chooseImport-error"
  61. size="large"
  62. :disabled="disabled"
  63. class="button-error"
  64. @click="handleError"
  65. style="padding: 0 40px;margin-left: 15px;">导出错误项</a-button>
  66. </div>
  67. </div>
  68. </a-modal>
  69. </template>
  70. <script>
  71. import { hdExportExcel } from '@/libs/exportExcel'
  72. import { shelfPlaceReadExcel, shelfSaveBatchExcel, shelfPlaceFailExcel } from '@/api/shelf'
  73. import { toThousands } from '@/libs/tools.js'
  74. export default {
  75. name: 'ChooseImportModal',
  76. props: {
  77. openModal: { // 弹框显示状态
  78. type: Boolean,
  79. default: false
  80. },
  81. paramsData: { // 参数
  82. type: Object,
  83. default: () => {
  84. return {}
  85. }
  86. }
  87. },
  88. data () {
  89. const _this = this
  90. return {
  91. toThousands,
  92. isShow: this.openModal, // 是否打开弹框
  93. nowColumns: [
  94. { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
  95. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  96. { title: '产品编码', dataIndex: 'productCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  97. { title: '产品名称', dataIndex: 'productName', width: '45%', align: 'center', customRender: function (text) { return text || '--' } },
  98. { title: '车主价', dataIndex: 'price', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) && text.length ? _this.toThousands(text, 2) : '--') } },
  99. { title: '结算价', dataIndex: 'cost', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) && text.length ? _this.toThousands(text, 2) : '--') } },
  100. { title: '最大库容', dataIndex: 'maxQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  101. ],
  102. loadData: [], // 正确列表数据
  103. nowUnColumns: [
  104. { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
  105. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  106. { title: '产品编码', dataIndex: 'productCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  107. { title: '产品名称', dataIndex: 'productName', width: '30%', align: 'center', customRender: function (text) { return text || '--' } },
  108. { title: '车主价', dataIndex: 'price', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) && text.length ? _this.toThousands(text, 2) : '--') } },
  109. { title: '结算价', dataIndex: 'cost', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) && text.length ? _this.toThousands(text, 2) : '--') } },
  110. { title: '最大库容', dataIndex: 'maxQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  111. { title: '错误原因', dataIndex: 'remarks', width: '15%', align: 'center', customRender: function (text) { return text || '--' } }
  112. ],
  113. unLoadData: [], // 错误列表数据
  114. loading: false,
  115. disabled: false
  116. }
  117. },
  118. methods: {
  119. // 获取解析后的数据
  120. getData () {
  121. const _this = this
  122. this.loading = true
  123. const params = {
  124. shelfSn: this.paramsData.shelfSn,
  125. path: this.paramsData.path
  126. }
  127. this.disabled = true
  128. shelfPlaceReadExcel(params).then(res => {
  129. this.loading = false
  130. this.disabled = false
  131. if (res.status == 200) {
  132. // 正确列表
  133. if (res.data.successList && res.data.successList.length > 0) {
  134. res.data.successList.map((item, index) => {
  135. item.no = index + 1
  136. })
  137. }
  138. // 错误列表
  139. if (res.data.failList && res.data.failList.length > 0) {
  140. res.data.failList.map((item, index) => {
  141. item.no = index + 1
  142. })
  143. }
  144. _this.loadData = res.data.successList || []
  145. _this.unLoadData = res.data.failList || []
  146. }
  147. })
  148. },
  149. // 确认导入
  150. handleSubmit () {
  151. if (this.loadData.length == 0) {
  152. this.$message.warning('无可导入产品!')
  153. } else {
  154. this.disabled = true
  155. shelfSaveBatchExcel(this.loadData).then(res => {
  156. if (res.status == 200) {
  157. this.$emit('ok', this.loadData)
  158. this.isShow = false
  159. }
  160. this.disabled = false
  161. })
  162. }
  163. },
  164. // 导出错误项
  165. handleError () {
  166. const _this = this
  167. if (_this.unLoadData.length < 1) {
  168. _this.$message.info('暂无可导出错误项~')
  169. return
  170. }
  171. _this.disabled = true
  172. hdExportExcel(shelfPlaceFailExcel, _this.unLoadData, '货位绑定产品错误项导出', function () {
  173. _this.disabled = false
  174. }, true)
  175. }
  176. },
  177. watch: {
  178. // 父页面传过来的弹框状态
  179. openModal (newValue, oldValue) {
  180. this.isShow = newValue
  181. },
  182. // 重定义的弹框状态
  183. isShow (newValue, oldValue) {
  184. if (!newValue) {
  185. this.$emit('close')
  186. this.loadData = []
  187. this.unLoadData = []
  188. } else {
  189. this.getData()
  190. }
  191. }
  192. }
  193. }
  194. </script>
  195. <style lang="less" scoped>
  196. .chooseImport-modal{
  197. .chooseImport-con{
  198. .red{
  199. color: #f30;
  200. }
  201. .btn-con{
  202. text-align: center;
  203. margin: 30px 0 20px;
  204. .button-cancel,.button-error{
  205. font-size: 12px;
  206. }
  207. }
  208. }
  209. }
  210. </style>