cloudroam
2025-03-28 cef2bb0eeeb91a22860cf5d23c7348af1ba921dc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<template>
  <el-bus-crud v-bind="tableConfig" />
</template>
 
<script>
import { getSortConfig } from '@/utils/form-item-config'
export default {
  data() {
    return {
      tableConfig: {
        url: 'flower/api/flower/zone/page',
        columns: [
          { label: '专区标题', prop: 'name' },
          {
            label: '专区图片',
            formatter: (row) => (
              <el-bus-image
                src={row.bgUrl}
                lazy={true}
                style="height:44px"
              ></el-bus-image>
            ),
          },
          { label: '排序', prop: 'seq' },
          { label: '状态', prop: 'statusStr' },
        ],
        searchForm: [
          {
            type: 'row',
            items: [{ label: '专区标题', id: 'name', type: 'input' }],
          },
        ],
        form: [
          {
            label: '专区标题:',
            id: 'name',
            type: 'input',
            rules: {
              required: true,
              message: '请输入专区标题',
              trigger: 'blur',
            },
          },
          {
            label: '专区图片:',
            id: 'bgUrl',
            type: 'bus-upload',
            el: {
              listType: 'picture-card',
              limit: 1,
              limitSize: 2,
              tipText: '大小不超过2M',
              valueType: 'string',
            },
            rules: {
              required: true,
              message: '请上传专区图片',
            },
            forceDisabled: true,
          },
          {
            ...getSortConfig('seq'),
          },
        ],
        extraButtons: [
          {
            text: (row) => (row.status === 'unpublished' ? '发布' : '下架'),
            atClick: async (row) => {
              const action = row.status === 'unpublished' ? '发布' : '下架'
              try {
                await this.$elBusUtil.confirm(`确定要${action}吗?`)
                const { code } = await this.$elBusHttp.request(
                  'flower/api/flower/zone/page/changeStatus',
                  { params: { id: row.id } }
                )
                if (code === 0) {
                  this.$message.success(`${action}成功`)
                }
              } catch (e) {
                return false
              }
            },
          },
          {
            text: '查看商品',
            atClick: (row) => {
              const url = this.$router.resolve(
                `${this.$route.path}/${row.id}`
              ).href
              window.open(url, '_blank')
            },
          },
        ],
      },
    }
  },
  head() {
    return {
      title: '专区列表',
    }
  },
}
</script>