chooseImportModal.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <a-modal
  3. centered
  4. class="chooseImportSubsidy-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="确认导入"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. width="80%">
  11. <div class="chooseImportSubsidy-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="chooseImportSubsidy-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="chooseImportSubsidy-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="chooseImportSubsidy-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 { exportImportDetailError } from '@/api/shopProductSubsidy'
  81. export default {
  82. name: 'ChooseImportSubsidyModal',
  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 || '--' }, ellipsis: true },
  105. { title: '原售价', dataIndex: 'shopProductPrice', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  106. { title: '抵扣金额', dataIndex: 'subsidyAmount', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  107. { title: '抵扣后售价', dataIndex: 'subsidyedPrice', width: '14%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  108. ],
  109. loadData: [],
  110. // 错误项
  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: 'productName', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  115. { title: '原售价', dataIndex: 'shopProductPrice', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  116. { title: '抵扣金额', dataIndex: 'subsidyAmount', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  117. { title: '抵扣后售价', dataIndex: 'subsidyedPrice', width: '20%', align: 'center', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  118. { title: '备注', scopedSlots: { customRender: 'errorMsg' }, width: '10%', align: 'center' }
  119. ],
  120. unLoadData: [],
  121. loading: false
  122. }
  123. },
  124. methods: {
  125. // 获取数据
  126. getData () {
  127. const paramsData = JSON.parse(JSON.stringify(this.paramsData))
  128. this.loadData = paramsData.rightList || []
  129. this.unLoadData = paramsData.errorList || []
  130. // 正确的
  131. this.loadData.map((item, index) => {
  132. item.no = index + 1
  133. })
  134. // 错误的
  135. this.unLoadData.map((item, index) => {
  136. item.no = index + 1
  137. })
  138. },
  139. // 确认导入
  140. handleSubmit () {
  141. if (this.paramsData.rightList.length == 0) {
  142. this.$message.warning('无可导入的产品!')
  143. } else {
  144. const data = this.paramsData.rightList
  145. this.$emit('ok', data)
  146. this.isShow = false
  147. }
  148. },
  149. // 导出错误项
  150. handleError () {
  151. const _this = this
  152. if (_this.paramsData.errorList.length < 1) {
  153. _this.$message.info('暂无可导出错误项~')
  154. return
  155. }
  156. _this.spinning = true
  157. hdExportExcel(exportImportDetailError, _this.paramsData.errorList, '抵扣金额错误项', function () {
  158. _this.spinning = false
  159. })
  160. }
  161. },
  162. watch: {
  163. // 父页面传过来的弹框状态
  164. openModal (newValue, oldValue) {
  165. this.isShow = newValue
  166. },
  167. // 重定义的弹框状态
  168. isShow (newValue, oldValue) {
  169. if (!newValue) {
  170. this.$emit('close')
  171. this.loadData = []
  172. this.unLoadData = []
  173. } else {
  174. this.getData()
  175. }
  176. }
  177. }
  178. }
  179. </script>
  180. <style lang="less" scoped>
  181. .chooseImportSubsidy-modal{
  182. .chooseImportSubsidy-con{
  183. .red{
  184. color: #f30;
  185. }
  186. .btn-con{
  187. text-align: center;
  188. margin: 30px 0 20px;
  189. .button-cancel,.button-error{
  190. font-size: 12px;
  191. }
  192. }
  193. }
  194. }
  195. </style>