chooseImportModal.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <a-modal
  3. centered
  4. wrapClassName="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. <div style="display:flex;justify-content: space-between;align-items: center;padding:10px 0;">
  14. <div style="display:flex;align-items: center;">
  15. 可导入数据{{ loadData.length }}条
  16. <div v-if="disableProduct.length">
  17. ,其中<span style="color: red;">{{ disableProduct.length }}个禁用产品</span>,请确认已禁用的产品是否导入?
  18. <a-radio-group v-model="importDisabled">
  19. <a-radio :value="1">
  20. 导入
  21. </a-radio>
  22. <a-radio :value="0">
  23. 不导入
  24. </a-radio>
  25. </a-radio-group>
  26. </div>
  27. </div>
  28. <div v-if="disableProduct.length">
  29. <a-checkbox v-model="showDisable">
  30. 仅显示已禁用产品
  31. </a-checkbox>
  32. </div>
  33. </div>
  34. <a-table
  35. class="sTable"
  36. ref="table"
  37. size="small"
  38. :rowKey="(record) => record.productCode"
  39. :rowClassName="(record, index) => record.productEnableFlag == 0 ? 'redBg-row':''"
  40. :columns="nowColumns"
  41. :dataSource="loadData"
  42. :loading="loading"
  43. :scroll="{ y: 200 }"
  44. :pagination="false"
  45. bordered>
  46. </a-table>
  47. <a-divider />
  48. <!-- 不可导入数据 -->
  49. <p class="red">不可导入数据{{ unLoadData.length }}条</p>
  50. <a-table
  51. class="unTable"
  52. ref="unTable"
  53. size="small"
  54. :rowKey="(record) => record.productCode"
  55. :columns="nowUnColumns"
  56. :dataSource="unLoadData"
  57. :loading="loading"
  58. :scroll="{ y: 200 }"
  59. :pagination="false"
  60. bordered>
  61. <template slot="errorMsg" slot-scope="text,record">
  62. <a-popover placement="topRight">
  63. <template slot="content">
  64. <p v-for="d in record.errorMsgList">{{ d }}</p>
  65. </template>
  66. <a-button type="link">
  67. 查看
  68. </a-button>
  69. </a-popover>
  70. </template>
  71. </a-table>
  72. <!-- 按钮 -->
  73. <div class="btn-con">
  74. <a-button
  75. type="primary"
  76. id="chooseImport-submit"
  77. size="large"
  78. :class="loadData.length==0?'button-grey':'button-primary'"
  79. @click="handleSubmit"
  80. style="padding: 0 40px;">确认导入</a-button>
  81. <a-button
  82. id="chooseImport-cancel"
  83. size="large"
  84. class="button-cancel"
  85. @click="isShow=false"
  86. style="padding: 0 40px;margin-left: 15px;">取消</a-button>
  87. <a-button
  88. type="primary"
  89. id="chooseImport-error"
  90. size="large"
  91. class="button-error"
  92. @click="handleError"
  93. style="padding: 0 40px;margin-left: 15px;">导出错误项</a-button>
  94. </div>
  95. </div>
  96. </a-modal>
  97. </template>
  98. <script>
  99. import { hdExportExcel } from '@/libs/exportExcel'
  100. import { commonMixin } from '@/utils/mixin'
  101. import { sparePartsPurExportErrorLine } from '@/api/sparePartsPur.js'
  102. export default {
  103. name: 'ChooseImportModal',
  104. mixins: [commonMixin],
  105. props: {
  106. openModal: { // 弹框显示状态
  107. type: Boolean,
  108. default: false
  109. },
  110. paramsData: {
  111. type: Object,
  112. default: () => {
  113. return {}
  114. }
  115. }
  116. },
  117. data () {
  118. const _this = this
  119. return {
  120. isShow: this.openModal, // 是否打开弹框
  121. nowColumns: [
  122. { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
  123. { title: '产品编码', dataIndex: 'productCode', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
  124. { title: '产品名称', dataIndex: 'productName', width: '25%', align: 'left', customRender: function (text) { return text || '--' } },
  125. { title: '成本价', dataIndex: 'putCost', width: '14%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  126. { title: '数量', dataIndex: 'putQty', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  127. { title: '仓库', dataIndex: 'warehouseName', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  128. { title: '仓位', dataIndex: 'warehouseLocationName', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  129. { title: '单位', dataIndex: 'productUnit', align: 'center', width: '15%', customRender: function (text) { return text || '--' } }
  130. ],
  131. nowUnColumns: [
  132. { title: '序号', dataIndex: 'no', width: '9%', align: 'center' },
  133. { title: '产品编码', dataIndex: 'productCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  134. { title: '成本价', dataIndex: 'putCost', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  135. { title: '数量', dataIndex: 'putQty', width: '20%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  136. { title: '仓库', dataIndex: 'warehouseName', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  137. { title: '仓位', dataIndex: 'warehouseLocationName', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  138. { title: '错误说明', scopedSlots: { customRender: 'errorMsg' }, width: '10%', align: 'center' }
  139. ],
  140. unLoadData: [],
  141. loading: false,
  142. importDisabled: undefined,
  143. showDisable: false,
  144. rightData: []
  145. }
  146. },
  147. computed: {
  148. // 启用产品
  149. enableProduct () {
  150. return this.rightData.filter(item => item.productEnableFlag == 1)
  151. },
  152. // 禁用产品
  153. disableProduct () {
  154. return this.rightData.filter(item => item.productEnableFlag == 0)
  155. },
  156. loadData () {
  157. return this.showDisable ? this.rightData.filter(item => item.productEnableFlag == 0) : this.rightData
  158. }
  159. },
  160. methods: {
  161. getData () {
  162. const paramsData = JSON.parse(JSON.stringify(this.paramsData))
  163. this.rightData = paramsData.okList || []
  164. this.rightData.map((item, index) => {
  165. item.no = index + 1
  166. item.sparePartsPurchaseSn = paramsData.sparePartsPurchaseSn
  167. })
  168. this.unLoadData = paramsData.errorList || []
  169. this.unLoadData.map((item, index) => {
  170. item.no = index + 1
  171. item.sparePartsPurchaseSn = paramsData.sparePartsPurchaseSn
  172. })
  173. },
  174. // 确认导入
  175. handleSubmit () {
  176. if (this.loadData.length == 0) {
  177. this.$message.warning('无可导入的产品!')
  178. } else {
  179. // 有禁用产品
  180. if (this.disableProduct.length > 0) {
  181. if (this.importDisabled == undefined) {
  182. this.$message.warning('请先确认已禁用的产品是否导入?')
  183. } else {
  184. this.$emit('ok', this.importDisabled == 1 ? this.rightData : this.enableProduct)
  185. this.isShow = false
  186. }
  187. } else {
  188. this.$emit('ok', this.rightData)
  189. this.isShow = false
  190. }
  191. }
  192. },
  193. // 导出
  194. handleError () {
  195. const _this = this
  196. if (_this.paramsData.errorList.length < 1) {
  197. _this.$message.info('暂无可导出错误项~')
  198. return
  199. }
  200. _this.spinning = true
  201. hdExportExcel(sparePartsPurExportErrorLine, _this.paramsData.errorList, '散件入库导出错误项', function () {
  202. _this.spinning = false
  203. })
  204. }
  205. },
  206. watch: {
  207. // 父页面传过来的弹框状态
  208. openModal (newValue, oldValue) {
  209. this.isShow = newValue
  210. },
  211. // 重定义的弹框状态
  212. isShow (newValue, oldValue) {
  213. if (!newValue) {
  214. this.$emit('close')
  215. this.rightData = []
  216. this.unLoadData = []
  217. this.importDisabled = undefined
  218. this.showDisable = false
  219. } else {
  220. this.getData()
  221. }
  222. }
  223. }
  224. }
  225. </script>
  226. <style lang="less">
  227. .chooseImport-modal{
  228. .chooseImport-con{
  229. .red{
  230. color: #f30;
  231. }
  232. .btn-con{
  233. text-align: center;
  234. margin: 30px 0 20px;
  235. .button-cancel,.button-error{
  236. font-size: 12px;
  237. }
  238. }
  239. }
  240. .redBg-row{
  241. background-color: #f5cdc8;
  242. }
  243. }
  244. </style>