storage_table.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import { goodsPurchaseDetail } from '@/api/goodsPurchasedStored.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. !!~[0,1].indexOf(this.formDialogType) ? (
  26. <div style="margin-bottom:10px">
  27. <el-button type="primary" onClick={this.addGoodsInfo}>
  28. 添加
  29. </el-button>
  30. </div>
  31. ) : this.formDialogType == 1 && this.joinCode ? (
  32. <div style="margin-bottom:10px">
  33. <el-button type="primary" onClick={this.domlMban}>
  34. 下载导入模板
  35. </el-button>
  36. </div>
  37. ) : null,
  38. <zj-table
  39. columns={this.storage_goods}
  40. tableData={this.formData.items}
  41. tableAttributes={{
  42. size: 'mini',
  43. border: true
  44. }}
  45. />
  46. ]
  47. : this.activeName == 'codeInfo' && this.joinCode
  48. ? [
  49. !!~[0,1].indexOf(this.formDialogType) ? (
  50. <div style="margin-bottom:10px">
  51. <el-button type="primary" onClick={this.addCodeInfo} disabled={this.isEditIndex != -1}>
  52. 添加
  53. </el-button>
  54. </div>
  55. ) : null,
  56. <zj-table
  57. columns={this.storage_codes}
  58. tableData={this.formData.codeInfoList}
  59. tableAttributes={{
  60. size: 'mini',
  61. border: true
  62. }}
  63. />
  64. ]
  65. : null}
  66. </div>
  67. )
  68. }
  69. }
  70. ]
  71. }
  72. },
  73. watch: {
  74. activeName(newVal) {
  75. this.isEditIndex = -1
  76. if (newVal == 'codeInfo') {
  77. // 获取单据下的条码
  78. this.getGoodsPurchaseCodeList()
  79. } else {
  80. if (this.formData.id) {
  81. // 更新表单信息
  82. goodsPurchaseDetail({ id: this.formData.id }).then(res => {
  83. Object.assign(this.formData, res.data, {
  84. fileUrl: res.data.fileUrl ? [{ url: res.data.fileUrl }] : [],
  85. items: res.data.items.map(item => ({ ...item, details: {} }))
  86. })
  87. })
  88. }
  89. // 清空条码数据列表
  90. this.formData.codeInfoList = []
  91. }
  92. }
  93. },
  94. methods: {
  95. domlMban() {
  96. commonTemplateDownload({ name: '商品采购条码模板.xlsx' }, `${this.$route.meta.title}`)
  97. .then(res => {
  98. this.$message({
  99. message: '下载成功',
  100. type: 'success'
  101. })
  102. })
  103. .catch(err => {
  104. this.$message.error('下载失败')
  105. })
  106. }
  107. }
  108. }