chooseImportModal.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 { shelfTemplateImportDetailError } from '@/api/shelfTemplate'
  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: '35%', 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: '35%', 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: 'remark', width: '25%', 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 paramsData = JSON.parse(JSON.stringify(this.paramsData))
  122. this.loadData = paramsData.rightList || []
  123. this.unLoadData = paramsData.errorList || []
  124. this.loadData.map((item, index) => {
  125. item.no = index + 1
  126. item.templateSn = paramsData.templateSn
  127. })
  128. this.unLoadData.map((item, index) => {
  129. item.no = index + 1
  130. item.templateSn = paramsData.templateSn
  131. })
  132. },
  133. // 确认导入
  134. handleSubmit () {
  135. if (this.paramsData.rightList.length == 0) {
  136. this.$message.warning('无可导入的货位!')
  137. } else {
  138. const data = this.paramsData.rightList
  139. this.$emit('ok', data)
  140. this.isShow = false
  141. }
  142. },
  143. // 导出错误项
  144. handleError () {
  145. const _this = this
  146. if (_this.paramsData.errorList.length < 1) {
  147. _this.$message.info('暂无可导出错误项~')
  148. return
  149. }
  150. _this.spinning = true
  151. hdExportExcel(shelfTemplateImportDetailError, _this.paramsData.errorList, '货架模板货位错误项', function () {
  152. _this.spinning = false
  153. })
  154. }
  155. },
  156. watch: {
  157. // 父页面传过来的弹框状态
  158. openModal (newValue, oldValue) {
  159. this.isShow = newValue
  160. },
  161. // 重定义的弹框状态
  162. isShow (newValue, oldValue) {
  163. if (!newValue) {
  164. this.$emit('close')
  165. this.loadData = []
  166. this.unLoadData = []
  167. } else {
  168. this.getData()
  169. }
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="less" scoped>
  175. .chooseImport-modal{
  176. .chooseImport-con{
  177. .red{
  178. color: #f30;
  179. }
  180. .btn-con{
  181. text-align: center;
  182. margin: 30px 0 20px;
  183. .button-cancel,.button-error{
  184. font-size: 12px;
  185. }
  186. }
  187. }
  188. }
  189. </style>