chooseImportModal.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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="unLoadData.length?'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. export default {
  80. name: 'ChooseImportModal',
  81. mixins: [commonMixin],
  82. props: {
  83. openModal: { // 弹框显示状态
  84. type: Boolean,
  85. default: false
  86. },
  87. paramsData: {
  88. type: Object,
  89. default: () => {
  90. return {}
  91. }
  92. }
  93. },
  94. data () {
  95. return {
  96. isShow: this.openModal, // 是否打开弹框
  97. loadData: [],
  98. unLoadData: [],
  99. loading: false,
  100. goodsFlag: ''
  101. }
  102. },
  103. computed: {
  104. nowColumns () {
  105. const _this = this
  106. let columnsArr = [
  107. { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
  108. { title: '产品编码', dataIndex: 'productCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  109. { title: '产品名称', dataIndex: 'product.name', width: '50%', align: 'center', customRender: function (text) { return text || '--' } }
  110. ]
  111. if (_this.goodsFlag == '0') {
  112. const arr = [
  113. { title: '省价特价', dataIndex: 'provinceDiscountPriceText', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  114. { title: '市价特价', dataIndex: 'cityDiscountPriceText', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  115. { title: '特约特价', dataIndex: 'specialDiscountPriceText', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  116. ]
  117. columnsArr = columnsArr.concat(arr)
  118. }
  119. return columnsArr
  120. },
  121. nowUnColumns () {
  122. const _this = this
  123. let unColumnsArr = [
  124. { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
  125. { title: '产品编码', dataIndex: 'productCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  126. { title: '产品名称', dataIndex: 'product.name', width: '50%', align: 'center', customRender: function (text) { return text || '--' } },
  127. { title: '错误说明', scopedSlots: { customRender: 'errorMsg' }, width: '20%', align: 'center' }
  128. ]
  129. if (_this.goodsFlag == '0') {
  130. unColumnsArr.splice(3,0,{ title: '省价特价', dataIndex: 'provinceDiscountPriceText', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  131. { title: '市价特价', dataIndex: 'cityDiscountPriceText', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  132. { title: '特约特价', dataIndex: 'specialDiscountPriceText', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  133. }
  134. return unColumnsArr
  135. }
  136. },
  137. methods: {
  138. setFlag (val) {
  139. this.goodsFlag = val
  140. },
  141. getData () {
  142. const paramsData = JSON.parse(JSON.stringify(this.paramsData))
  143. this.loadData = paramsData.rightList || []
  144. this.unLoadData = paramsData.errorList || []
  145. this.loadData.map((item, index) => {
  146. item.no = index + 1
  147. })
  148. this.unLoadData.map((item, index) => {
  149. item.no = index + 1
  150. item.importErrorMsgSet = item.remarks.split(',')
  151. })
  152. },
  153. // 确认导入
  154. handleSubmit () {
  155. if (this.unLoadData.length) {
  156. this.$message.warning('有错误数据不可导入,请修改正确后再试!')
  157. } else {
  158. const data = this.paramsData.rightList
  159. this.$emit('ok', data)
  160. this.isShow = false
  161. }
  162. }
  163. },
  164. watch: {
  165. // 父页面传过来的弹框状态
  166. openModal (newValue, oldValue) {
  167. this.isShow = newValue
  168. },
  169. // 重定义的弹框状态
  170. isShow (newValue, oldValue) {
  171. if (!newValue) {
  172. this.$emit('close')
  173. this.loadData = []
  174. this.unLoadData = []
  175. } else {
  176. this.getData()
  177. }
  178. }
  179. }
  180. }
  181. </script>
  182. <style lang="less" scoped>
  183. .chooseImport-modal{
  184. .chooseImport-con{
  185. .red{
  186. color: #f30;
  187. }
  188. .btn-con{
  189. text-align: center;
  190. margin: 30px 0 20px;
  191. .button-cancel,.button-error{
  192. font-size: 12px;
  193. }
  194. }
  195. }
  196. }
  197. </style>