chooseImportModal.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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="80%">
  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. <template slot="errorMsg" slot-scope="text,record">
  41. <a-popover placement="topRight">
  42. <template slot="content">
  43. <p v-for="d in record.importErrorMsgSet">{{ d }}</p>
  44. </template>
  45. <a-button type="link">
  46. 查看
  47. </a-button>
  48. </a-popover>
  49. </template>
  50. </a-table>
  51. <!-- 按钮 -->
  52. <div class="btn-con">
  53. <a-button
  54. type="primary"
  55. id="chooseImport-submit"
  56. size="large"
  57. :class="loadData.length==0?'button-grey':'button-primary'"
  58. @click="handleSubmit"
  59. style="padding: 0 40px;">确认导入</a-button>
  60. <a-button
  61. id="chooseImport-cancel"
  62. size="large"
  63. class="button-cancel"
  64. @click="isShow=false"
  65. style="padding: 0 40px;margin-left: 15px;">取消</a-button>
  66. <a-button
  67. type="primary"
  68. id="chooseImport-error"
  69. size="large"
  70. class="button-error"
  71. @click="handleError"
  72. style="padding: 0 40px;margin-left: 15px;">导出错误项</a-button>
  73. </div>
  74. </div>
  75. </a-modal>
  76. </template>
  77. <script>
  78. import { commonMixin } from '@/utils/mixin'
  79. import { hdExportExcel } from '@/libs/exportExcel'
  80. import { salesDetailFailExcel } from '@/api/salesDetail'
  81. export default {
  82. name: 'ChooseImportModal',
  83. mixins: [commonMixin],
  84. props: {
  85. openModal: { // 弹框显示状态
  86. type: Boolean,
  87. default: false
  88. },
  89. paramsData: { // 参数
  90. type: Object,
  91. default: () => {
  92. return {}
  93. }
  94. }
  95. },
  96. data () {
  97. const _this = this
  98. return {
  99. isShow: this.openModal, // 是否打开弹框
  100. // 正确数据列表
  101. nowColumns: [
  102. { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
  103. { title: '产品编码', dataIndex: 'productCode', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
  104. { title: '产品名称', dataIndex: 'productName', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
  105. { title: '仓库', dataIndex: 'warehouseName', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  106. { title: '仓位', dataIndex: 'warehouseLocationName', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  107. { title: '售价', dataIndex: 'importPrice', width: '14%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  108. { title: '数量', dataIndex: 'importQty', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  109. { title: '单位', dataIndex: 'importProductUnit', align: 'center', width: '15%', customRender: function (text) { return text || '--' } }
  110. ],
  111. loadData: [],
  112. // 错误数据列表
  113. nowUnColumns: [
  114. { title: '序号', dataIndex: 'no', width: '9%', align: 'center' },
  115. { title: '产品编码', dataIndex: 'productCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  116. { title: '仓库', dataIndex: 'warehouseName', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  117. { title: '仓位', dataIndex: 'warehouseLocationName', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  118. { title: '售价', dataIndex: 'importPrice', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  119. { title: '数量', dataIndex: 'importQty', width: '20%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
  120. { title: '错误说明', scopedSlots: { customRender: 'errorMsg' }, width: '10%', align: 'center' }
  121. ],
  122. unLoadData: [],
  123. loading: false
  124. }
  125. },
  126. methods: {
  127. // 获取上传的模板数据
  128. getData () {
  129. const paramsData = JSON.parse(JSON.stringify(this.paramsData))
  130. this.loadData = paramsData.rightList || []
  131. this.unLoadData = paramsData.errorList || []
  132. // 正确数据
  133. this.loadData.map((item, index) => {
  134. item.no = index + 1
  135. item.salesBillNo = paramsData.salesBillNo
  136. item.salesBillSn = paramsData.salesBillSn
  137. })
  138. // 错误数据
  139. this.unLoadData.map((item, index) => {
  140. item.no = index + 1
  141. item.salesBillNo = paramsData.salesBillNo
  142. item.salesBillSn = paramsData.salesBillSn
  143. })
  144. },
  145. // 确认导入
  146. handleSubmit () {
  147. if (this.paramsData.rightList.length == 0) {
  148. this.$message.warning('无可导入的产品!')
  149. } else {
  150. const data = this.paramsData.rightList
  151. data.map(item => {
  152. item.salesBillNo = this.paramsData.salesBillNo
  153. item.salesBillSn = this.paramsData.salesBillSn
  154. })
  155. this.$emit('ok', data)
  156. this.isShow = false
  157. }
  158. },
  159. // 导出错误项
  160. handleError () {
  161. const _this = this
  162. if (_this.paramsData.errorList.length < 1) {
  163. _this.$message.info('暂无可导出错误项~')
  164. return
  165. }
  166. _this.spinning = true
  167. hdExportExcel(salesDetailFailExcel, _this.paramsData.errorList, '销售产品导出错误项', function () {
  168. _this.spinning = false
  169. })
  170. }
  171. },
  172. watch: {
  173. // 父页面传过来的弹框状态
  174. openModal (newValue, oldValue) {
  175. this.isShow = newValue
  176. },
  177. // 重定义的弹框状态
  178. isShow (newValue, oldValue) {
  179. if (!newValue) {
  180. this.$emit('close')
  181. this.loadData = []
  182. this.unLoadData = []
  183. } else {
  184. this.getData()
  185. }
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="less" scoped>
  191. .chooseImport-modal{
  192. .chooseImport-con{
  193. .red{
  194. color: #f30;
  195. }
  196. .btn-con{
  197. text-align: center;
  198. margin: 30px 0 20px;
  199. .button-cancel,.button-error{
  200. font-size: 12px;
  201. }
  202. }
  203. }
  204. }
  205. </style>