modal.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div>
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 列表 -->
  5. <s-table
  6. class="sTable fixPagination"
  7. ref="table"
  8. size="small"
  9. :rowKey="(record) => record.id"
  10. :columns="columns"
  11. :scroll="{ y: 400 }"
  12. :data="loadData"
  13. :defaultLoadData="false"
  14. :showPagination="false"
  15. bordered>
  16. </s-table>
  17. <div style="padding-top: 15px;">
  18. <a-button @click="viewMore" block type="primary" ghost>查看更多{{ onlineFalg==1?'新品':'下线产品' }}</a-button>
  19. </div>
  20. </a-spin>
  21. </div>
  22. </template>
  23. <script>
  24. import { commonMixin } from '@/utils/mixin'
  25. import { STable } from '@/components'
  26. import { queryNewProductPage } from '@/api/product'
  27. export default {
  28. name: 'NewProductListModal',
  29. mixins: [commonMixin],
  30. components: { STable },
  31. props: {
  32. onlineFalg: { // 上下线标识 1为上线,0为下线
  33. type: [ String, Number ],
  34. default: '1'
  35. }
  36. },
  37. data () {
  38. return {
  39. spinning: false,
  40. queryParam: {},
  41. // 加载数据方法 必须为 Promise 对象
  42. loadData: parameter => {
  43. this.spinning = true
  44. return queryNewProductPage(Object.assign(parameter, this.queryParam, { onlineFalg: this.onlineFalg })).then(res => {
  45. let data
  46. if (res.status == 200) {
  47. data = res.data
  48. const no = (data.pageNo - 1) * data.pageSize
  49. for (var i = 0; i < data.list.length; i++) {
  50. data.list[i].no = no + i + 1
  51. }
  52. }
  53. this.spinning = false
  54. return data
  55. })
  56. }
  57. }
  58. },
  59. computed: {
  60. columns () {
  61. const arr = [
  62. { title: '序号', dataIndex: 'no', width: 50, align: 'center' },
  63. { title: '产品品牌', dataIndex: 'productBrandName', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  64. { title: '产品编码', dataIndex: 'code', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  65. { title: '产品名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  66. { title: '单位', dataIndex: 'unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } }
  67. ]
  68. if (this.onlineFalg == '1') {
  69. arr.push({ title: '上线时间', dataIndex: 'auditTime', width: 140, align: 'center', customRender: function (text) { return text || '--' } })
  70. } else if (this.onlineFalg == '0') {
  71. arr.push({ title: '下线时间', dataIndex: 'auditTime', width: 140, align: 'center', customRender: function (text) { return text || '--' } })
  72. }
  73. return arr
  74. }
  75. },
  76. methods: {
  77. viewMore () {
  78. this.$emit('seeMore')
  79. }
  80. },
  81. mounted () {
  82. this.$nextTick(() => {
  83. this.$refs.table.refresh(true)
  84. })
  85. },
  86. watch: {
  87. onlineFalg (newValue, oldValue) {
  88. const _this = this
  89. setTimeout(() => {
  90. _this.$refs.table && _this.$refs.table.refresh(true)
  91. }, 400)
  92. }
  93. }
  94. }
  95. </script>