out_storage_table.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import { goodsPurchaseRetDetail } from '@/api/merchandisePurchaseReturn.js'
  2. import { commonTemplateDownload } from '@/api/common.js'
  3. export default {
  4. data() {
  5. return {}
  6. },
  7. computed: {
  8. formItems2() {
  9. return [
  10. {
  11. md: 24,
  12. isShow: true,
  13. name: 'slot-component',
  14. formItemAttributes: {
  15. label: '',
  16. prop: '',
  17. 'label-width': '0px'
  18. },
  19. render: (h, { props, onInput }) => {
  20. var { value } = props
  21. return (
  22. <div>
  23. {this.activeName == 'goodsInfo'
  24. ? [
  25. this.formDialogType == 1 ? (
  26. <div style="margin-bottom:10px">
  27. <el-button type="primary" onClick={this.domlMban}>
  28. 下载导入模板
  29. </el-button>
  30. </div>
  31. ) : null,
  32. <zj-table
  33. columns={this.storage_goods}
  34. tableData={this.formData.items}
  35. tableAttributes={{
  36. size: 'mini',
  37. border: true
  38. }}
  39. />
  40. ]
  41. : this.activeName == 'codeInfo'
  42. ? [
  43. this.formDialogType == 1 ? (
  44. <div style="margin-bottom:10px">
  45. <el-button type="primary" onClick={this.addCodeInfo} disabled={this.isEditIndex != -1}>
  46. 添加
  47. </el-button>
  48. </div>
  49. ) : null,
  50. <zj-table
  51. columns={this.storage_codes}
  52. tableData={this.formData.codeInfoList}
  53. tableAttributes={{
  54. size: 'mini',
  55. border: true
  56. }}
  57. />
  58. ]
  59. : null}
  60. </div>
  61. )
  62. }
  63. }
  64. ]
  65. }
  66. },
  67. watch: {
  68. activeName(newVal) {
  69. this.isEditIndex = -1
  70. if (newVal == 'codeInfo') {
  71. // 获取单据下的条码
  72. this.getGoodsPurchaseRetCodeList()
  73. } else {
  74. if (this.formData.id) {
  75. // 更新表单信息
  76. goodsPurchaseRetDetail({ id: this.formData.id }).then(res => {
  77. Object.assign(this.formData, res.data, {
  78. fileUrl: res.data.fileUrl ? [{ url: res.data.fileUrl }] : [],
  79. items: res.data.items.map(item => ({ ...item, details: {} }))
  80. })
  81. })
  82. }
  83. // 清空条码数据列表
  84. this.formData.codeInfoList = []
  85. }
  86. }
  87. },
  88. methods: {
  89. domlMban() {
  90. commonTemplateDownload({ name: '商品采购条码模板.xlsx' }, `${this.$route.meta.title}`)
  91. .then(res => {
  92. this.$message({
  93. message: '下载成功',
  94. type: 'success'
  95. })
  96. })
  97. .catch(err => {
  98. this.$message.error('下载失败')
  99. })
  100. }
  101. }
  102. }