uniqueCodeModal.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <a-modal
  3. centered
  4. class="unique-code-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. v-model="isShow"
  8. @cancel="isShow=false"
  9. :width="960">
  10. <solt>
  11. <div class="unique-code-tit">查看唯一码(产品编码:{{ itemData&&itemData.productCode }},唯一码数量:{{ uniqueList&&uniqueList.length?uniqueList.length:0 }})</div>
  12. </solt>
  13. <a-card size="small" :bordered="false" class="unique-code-con">
  14. <!-- 列表 -->
  15. <s-table
  16. class="sTable"
  17. ref="table"
  18. size="small"
  19. :rowKey="(record) => record.id"
  20. :columns="columns"
  21. :data="loadData"
  22. :scroll="{ y: 360 }"
  23. :showPagination="false"
  24. :defaultLoadData="false"
  25. bordered>
  26. </s-table>
  27. </a-card>
  28. <div class="btn-cont">
  29. <a-button id="unique-code-modal-back" @click="isShow = false" style="margin-left: 15px;">关闭</a-button>
  30. </div>
  31. </a-modal>
  32. </template>
  33. <script>
  34. import { commonMixin } from '@/utils/mixin'
  35. // 组件
  36. import { STable } from '@/components'
  37. // 接口
  38. import { traceCodeQueryList } from '@/api/purchase'
  39. export default {
  40. name: 'UniqueCodeModal',
  41. mixins: [commonMixin],
  42. components: { STable },
  43. props: {
  44. openModal: { // 弹框显示状态
  45. type: Boolean,
  46. default: false
  47. },
  48. itemData: {
  49. type: Object,
  50. default: () => {
  51. return {}
  52. }
  53. }
  54. },
  55. data () {
  56. return {
  57. isShow: this.openModal, // 是否打开弹框
  58. uniqueList: [], // 唯一码数据
  59. // 加载数据方法 必须为 Promise 对象
  60. loadData: parameter => {
  61. const newData = JSON.parse(JSON.stringify(this.itemData))
  62. delete newData.productCode
  63. return traceCodeQueryList(Object.assign(parameter, newData)).then(res => {
  64. let data
  65. if (res.status == 200) {
  66. data = res.data
  67. const no = 0
  68. for (var i = 0; i < data.length; i++) {
  69. data[i].no = no + i + 1
  70. }
  71. this.uniqueList = data
  72. }
  73. return data
  74. })
  75. },
  76. columns: [
  77. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  78. { title: '唯一码', dataIndex: 'bizCode', width: '15%', align: 'left', customRender: function (text) { return text || '--' } }
  79. ]
  80. }
  81. },
  82. watch: {
  83. // 父页面传过来的弹框状态
  84. openModal (newValue, oldValue) {
  85. this.isShow = newValue
  86. },
  87. // 重定义的弹框状态
  88. isShow (newValue, oldValue) {
  89. if (!newValue) {
  90. this.$emit('close')
  91. } else {
  92. this.$nextTick(() => {
  93. this.$refs.table.refresh()
  94. })
  95. }
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="less">
  101. .unique-code-modal{
  102. .unique-code-tit{
  103. padding-bottom:20px;
  104. margin-bottom:20px;
  105. border-bottom:1px solid #e8e8e8;
  106. }
  107. .btn-cont {
  108. text-align: center;
  109. margin: 5px 0 10px;
  110. }
  111. }
  112. </style>