chooseImportModal.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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 { sparePartsPurExportErrorLine } from '@/api/sparePartsPur.js'
  101. export default {
  102. name: 'ChooseImportModal',
  103. props: {
  104. openModal: { // 弹框显示状态
  105. type: Boolean,
  106. default: false
  107. },
  108. paramsData: {
  109. type: Object,
  110. default: () => {
  111. return {}
  112. }
  113. }
  114. },
  115. data () {
  116. return {
  117. isShow: this.openModal, // 是否打开弹框
  118. nowColumns: [
  119. { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
  120. { title: '产品编码', dataIndex: 'productCode', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
  121. { title: '产品名称', dataIndex: 'productName', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
  122. { title: '成本价', dataIndex: 'putCost', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  123. { title: '数量', dataIndex: 'putQty', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  124. { title: '仓库', dataIndex: 'warehouseName', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  125. { title: '仓位', dataIndex: 'warehouseLocationName', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  126. { title: '单位', dataIndex: 'productUnit', align: 'center', width: '15%', customRender: function (text) { return text || '--' } }
  127. ],
  128. nowUnColumns: [
  129. { title: '序号', dataIndex: 'no', width: '9%', align: 'center' },
  130. { title: '产品编码', dataIndex: 'productCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  131. { title: '成本价', dataIndex: 'putCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  132. { title: '数量', dataIndex: 'putQty', width: '20%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  133. { title: '仓库', dataIndex: 'warehouseName', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  134. { title: '仓位', dataIndex: 'warehouseLocationName', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  135. { title: '错误说明', scopedSlots: { customRender: 'errorMsg' }, width: '10%', align: 'center' }
  136. ],
  137. unLoadData: [],
  138. loading: false,
  139. importDisabled: undefined,
  140. showDisable: false,
  141. rightData: []
  142. }
  143. },
  144. computed: {
  145. // 启用产品
  146. enableProduct () {
  147. return this.rightData.filter(item => item.productEnableFlag == 1)
  148. },
  149. // 禁用产品
  150. disableProduct () {
  151. return this.rightData.filter(item => item.productEnableFlag == 0)
  152. },
  153. loadData () {
  154. return this.showDisable ? this.rightData.filter(item => item.productEnableFlag == 0) : this.rightData
  155. }
  156. },
  157. methods: {
  158. getData () {
  159. const paramsData = JSON.parse(JSON.stringify(this.paramsData))
  160. this.rightData = paramsData.okList || []
  161. this.rightData.map((item, index) => {
  162. item.no = index + 1
  163. item.sparePartsPurchaseSn = paramsData.sparePartsPurchaseSn
  164. })
  165. this.unLoadData = paramsData.errorList || []
  166. this.unLoadData.map((item, index) => {
  167. item.no = index + 1
  168. item.sparePartsPurchaseSn = paramsData.sparePartsPurchaseSn
  169. })
  170. },
  171. // 确认导入
  172. handleSubmit () {
  173. if (this.loadData.length == 0) {
  174. this.$message.warning('无可导入的产品!')
  175. } else {
  176. // 有禁用产品
  177. if (this.disableProduct.length > 0) {
  178. if (this.importDisabled == undefined) {
  179. this.$message.warning('请先确认已禁用的产品是否导入?')
  180. } else {
  181. this.$emit('ok', this.importDisabled == 1 ? this.rightData : this.enableProduct)
  182. this.isShow = false
  183. }
  184. } else {
  185. this.$emit('ok', this.rightData)
  186. this.isShow = false
  187. }
  188. }
  189. },
  190. // 导出
  191. handleError () {
  192. const _this = this
  193. if (_this.paramsData.errorList.length < 1) {
  194. _this.$message.info('暂无可导出错误项~')
  195. return
  196. }
  197. _this.spinning = true
  198. hdExportExcel(sparePartsPurExportErrorLine, _this.paramsData.errorList, '散件入库导出错误项', function () {
  199. _this.spinning = false
  200. })
  201. }
  202. },
  203. watch: {
  204. // 父页面传过来的弹框状态
  205. openModal (newValue, oldValue) {
  206. this.isShow = newValue
  207. },
  208. // 重定义的弹框状态
  209. isShow (newValue, oldValue) {
  210. if (!newValue) {
  211. this.$emit('close')
  212. this.rightData = []
  213. this.unLoadData = []
  214. this.importDisabled = undefined
  215. this.showDisable = false
  216. } else {
  217. this.getData()
  218. }
  219. }
  220. }
  221. }
  222. </script>
  223. <style lang="less">
  224. .chooseImport-modal{
  225. .chooseImport-con{
  226. .red{
  227. color: #f30;
  228. }
  229. .btn-con{
  230. text-align: center;
  231. margin: 30px 0 20px;
  232. .button-cancel,.button-error{
  233. font-size: 12px;
  234. }
  235. }
  236. }
  237. .redBg-row{
  238. background-color: #f5cdc8;
  239. }
  240. }
  241. </style>