chooseImportModal.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. nowColumns: [
  101. { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
  102. { title: '产品编码', dataIndex: 'productCode', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
  103. { title: '产品名称', dataIndex: 'productName', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
  104. { title: '仓库', dataIndex: 'warehouseName', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  105. { title: '仓位', dataIndex: 'warehouseLocationName', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  106. { title: '售价', dataIndex: 'importPrice', width: '14%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  107. { title: '数量', dataIndex: 'importQty', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  108. { title: '单位', dataIndex: 'importProductUnit', align: 'center', width: '15%', customRender: function (text) { return text || '--' } }
  109. ],
  110. loadData: [],
  111. nowUnColumns: [
  112. { title: '序号', dataIndex: 'no', width: '9%', align: 'center' },
  113. { title: '产品编码', dataIndex: 'productCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  114. { title: '仓库', dataIndex: 'warehouseName', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  115. { title: '仓位', dataIndex: 'warehouseLocationName', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  116. { title: '售价', dataIndex: 'importPrice', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  117. { title: '数量', dataIndex: 'importQty', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  118. { title: '错误说明', scopedSlots: { customRender: 'errorMsg' }, width: '10%', align: 'center' }
  119. ],
  120. unLoadData: [],
  121. loading: false
  122. }
  123. },
  124. methods: {
  125. getData () {
  126. const paramsData = JSON.parse(JSON.stringify(this.paramsData))
  127. this.loadData = paramsData.rightList || []
  128. this.unLoadData = paramsData.errorList || []
  129. this.loadData.map((item, index) => {
  130. item.no = index + 1
  131. item.salesBillNo = paramsData.salesBillNo
  132. item.salesBillSn = paramsData.salesBillSn
  133. })
  134. this.unLoadData.map((item, index) => {
  135. item.no = index + 1
  136. item.salesBillNo = paramsData.salesBillNo
  137. item.salesBillSn = paramsData.salesBillSn
  138. })
  139. },
  140. // 确认导入
  141. handleSubmit () {
  142. if (this.paramsData.rightList.length == 0) {
  143. this.$message.warning('无可导入的产品!')
  144. } else {
  145. const data = this.paramsData.rightList
  146. data.map(item => {
  147. item.salesBillNo = this.paramsData.salesBillNo
  148. item.salesBillSn = this.paramsData.salesBillSn
  149. })
  150. this.$emit('ok', data)
  151. this.isShow = false
  152. }
  153. },
  154. // 导出
  155. handleError () {
  156. const _this = this
  157. if (_this.paramsData.errorList.length < 1) {
  158. _this.$message.info('暂无可导出错误项~')
  159. return
  160. }
  161. _this.spinning = true
  162. hdExportExcel(salesDetailFailExcel, _this.paramsData.errorList, '销售产品导出错误项', function () {
  163. _this.spinning = false
  164. })
  165. }
  166. },
  167. watch: {
  168. // 父页面传过来的弹框状态
  169. openModal (newValue, oldValue) {
  170. this.isShow = newValue
  171. },
  172. // 重定义的弹框状态
  173. isShow (newValue, oldValue) {
  174. if (!newValue) {
  175. this.$emit('close')
  176. this.loadData = []
  177. this.unLoadData = []
  178. } else {
  179. this.getData()
  180. }
  181. }
  182. }
  183. }
  184. </script>
  185. <style lang="less" scoped>
  186. .chooseImport-modal{
  187. .chooseImport-con{
  188. .red{
  189. color: #f30;
  190. }
  191. .btn-con{
  192. text-align: center;
  193. margin: 30px 0 20px;
  194. .button-cancel,.button-error{
  195. font-size: 12px;
  196. }
  197. }
  198. }
  199. }
  200. </style>