chooseImportModal.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. <template slot="unitTypeShow" slot-scope="text,record">
  26. {{ record.unitType==='SL'?'按数量设置':'按整箱设置' }}
  27. </template>
  28. </a-table>
  29. <a-divider />
  30. <!-- 不可导入数据 -->
  31. <p class="red">不可导入数据{{ unLoadData.length }}条</p>
  32. <a-table
  33. class="unTable"
  34. ref="unTable"
  35. size="small"
  36. :rowKey="(record) => record.errorDesc"
  37. :columns="nowUnColumns"
  38. :dataSource="unLoadData"
  39. :loading="loading"
  40. :scroll="{ y: 200 }"
  41. :pagination="false"
  42. bordered>
  43. <template slot="unitTypeShow" slot-scope="text,record">
  44. {{ record.unitType==='SL'?'按数量设置':'按整箱设置' }}
  45. </template>
  46. <!-- <template slot="errorMsg" slot-scope="text,record">
  47. <a-popover placement="topRight">
  48. <template slot="content">
  49. <p v-for="d in record.importErrorMsgSet">{{ d }}</p>
  50. </template>
  51. <a-button type="link">
  52. 查看
  53. </a-button>
  54. </a-popover>
  55. </template> -->
  56. </a-table>
  57. <!-- 按钮 -->
  58. <div class="btn-con">
  59. <a-button
  60. type="primary"
  61. id="chooseImport-submit"
  62. size="large"
  63. :class="loadData.length==0?'button-grey':'button-primary'"
  64. @click="handleSubmit"
  65. style="padding: 0 40px;">确认导入</a-button>
  66. <a-button
  67. id="chooseImport-cancel"
  68. size="large"
  69. class="button-cancel"
  70. @click="isShow=false"
  71. style="padding: 0 40px;margin-left: 15px;">取消</a-button>
  72. <a-button
  73. type="primary"
  74. id="chooseImport-error"
  75. size="large"
  76. class="button-error"
  77. @click="handleError"
  78. style="padding: 0 40px;margin-left: 15px;">导出错误项</a-button>
  79. </div>
  80. </div>
  81. </a-modal>
  82. </template>
  83. <script>
  84. import { commonMixin } from '@/utils/mixin'
  85. import { hdExportExcel } from '@/libs/exportExcel'
  86. import { downNormalFail, downSpecialFail } from '@/api/promotion'
  87. export default {
  88. name: 'ChooseImportModal',
  89. mixins: [commonMixin],
  90. props: {
  91. openModal: { // 弹框显示状态
  92. type: Boolean,
  93. default: false
  94. },
  95. paramsData: {
  96. type: Object,
  97. default: () => {
  98. return {}
  99. }
  100. }
  101. },
  102. data () {
  103. return {
  104. isShow: this.openModal, // 是否打开弹框
  105. loadData: [],
  106. unLoadData: [],
  107. loading: false,
  108. goodsFlag: '',
  109. discountType: ''
  110. }
  111. },
  112. computed: {
  113. nowColumns () {
  114. const _this = this
  115. let columnsArr = [
  116. { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
  117. { title: '产品编码', dataIndex: 'productCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  118. { title: '产品名称', dataIndex: 'product.name', width: '30%', align: 'center', customRender: function (text) { return text || '--' } },
  119. { title: '起订类型', scopedSlots: { customRender: 'unitTypeShow' }, dataIndex: 'unitType', width: '20%', align: 'center' },
  120. { title: '起订数量', dataIndex: 'unitQty', width: '20%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } }
  121. ]
  122. if (_this.goodsFlag == '0' && _this.discountType == '0') {
  123. const arr = [
  124. { title: '省级特价', dataIndex: 'provinceDiscountPriceText', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  125. { title: '市级特价', dataIndex: 'cityDiscountPriceText', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  126. { title: '特约特价', dataIndex: 'specialDiscountPriceText', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  127. ]
  128. columnsArr = columnsArr.concat(arr)
  129. }
  130. return columnsArr
  131. },
  132. nowUnColumns () {
  133. const _this = this
  134. const unColumnsArr = [
  135. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  136. { title: '产品编码', dataIndex: 'productCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  137. { title: '产品名称', dataIndex: 'product.name', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  138. { title: '起订类型', scopedSlots: { customRender: 'unitTypeShow' }, dataIndex: 'unitType', width: '10%', align: 'center' },
  139. { title: '起订数量', dataIndex: 'unitQty', width: '10%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
  140. { title: '错误说明', dataIndex: 'remarks', width: '30%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
  141. ]
  142. if (_this.goodsFlag == '0' && _this.discountType == '0') {
  143. unColumnsArr.splice(3, 0, { title: '省级特价', dataIndex: 'provinceDiscountPriceText', width: '10%', align: 'right', customRender: function (text) { return text || '--' } },
  144. { title: '市级特价', dataIndex: 'cityDiscountPriceText', width: '10%', align: 'right', customRender: function (text) { return text || '--' } },
  145. { title: '特约特价', dataIndex: 'specialDiscountPriceText', width: '10%', align: 'right', customRender: function (text) { return text || '--' } })
  146. }
  147. return unColumnsArr
  148. }
  149. },
  150. methods: {
  151. setFlag (val) {
  152. this.goodsFlag = val.goodFlag
  153. this.discountType = val.discountType
  154. },
  155. getData () {
  156. const paramsData = JSON.parse(JSON.stringify(this.paramsData))
  157. this.loadData = paramsData.rightList || []
  158. this.unLoadData = paramsData.errorList || []
  159. this.loadData.map((item, index) => {
  160. item.no = index + 1
  161. })
  162. this.unLoadData.map((item, index) => {
  163. item.no = index + 1
  164. item.importErrorMsgSet = item.remarks.split(',')
  165. })
  166. },
  167. // 确认导入
  168. handleSubmit () {
  169. if (this.loadData.length == 0) {
  170. this.$message.warning('没有可导入的数据!')
  171. } else {
  172. const data = this.paramsData.rightList
  173. this.$emit('ok', data)
  174. this.isShow = false
  175. }
  176. },
  177. // 导出错误项
  178. handleError () {
  179. const _this = this
  180. if (_this.unLoadData.length < 1) {
  181. _this.$message.info('暂无可导出的错误项~')
  182. return
  183. }
  184. _this.spinning = true
  185. const ajaxName = _this.goodsFlag == '0' ? downSpecialFail : downNormalFail
  186. var ajaxData = {}
  187. ajaxData.unLoadData = _this.unLoadData
  188. if (_this.goodsFlag == '0') {
  189. ajaxData.discountType = _this.discountType
  190. }
  191. hdExportExcel(ajaxName, ajaxData, '导出产品错误项', function () {
  192. _this.spinning = false
  193. })
  194. }
  195. },
  196. watch: {
  197. // 父页面传过来的弹框状态
  198. openModal (newValue, oldValue) {
  199. this.isShow = newValue
  200. },
  201. // 重定义的弹框状态
  202. isShow (newValue, oldValue) {
  203. if (!newValue) {
  204. this.$emit('close')
  205. this.loadData = []
  206. this.unLoadData = []
  207. } else {
  208. this.getData()
  209. }
  210. }
  211. }
  212. }
  213. </script>
  214. <style lang="less" scoped>
  215. .chooseImport-modal{
  216. .chooseImport-con{
  217. .red{
  218. color: #f30;
  219. }
  220. .btn-con{
  221. text-align: center;
  222. margin: 30px 0 20px;
  223. .button-cancel,.button-error{
  224. font-size: 12px;
  225. }
  226. }
  227. }
  228. }
  229. </style>