1/*
2 * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import type { BasicColumn, FormSchema } from '/@/components/Table';
17import { h } from 'vue';
18import { Avatar } from 'ant-design-vue';
19import { getFileAccessHttpUrl } from '/@/utils/common/compUtils';
20import { render } from '/@/utils/common/renderUtils';
21import type { Component } from 'vue';
22
23export const columns: BasicColumn[] = [
24  {
25    title: '名称',
26    dataIndex: 'name',
27  },
28  {
29    title: '封面',
30    dataIndex: 'cover',
31    width: 100,
32    customRender: ({ text }): Component => {
33      return h(Avatar, {
34        src: getFileAccessHttpUrl(text),
35        shape: 'square',
36        size: 'default',
37      });
38    },
39  },
40  {
41    title: '是否营业',
42    dataIndex: 'isOpen',
43    customRender: ({ text }): Component => {
44      return render.renderDict(text, 'yn');
45    },
46  },
47  {
48    title: '地址',
49    dataIndex: 'address',
50  },
51  {
52    title: '距离',
53    dataIndex: 'distance',
54    customRender: ({ text }): string => {
55      return text != null ? text + 'km' : '';
56    },
57  },
58  {
59    title: '营业开始时间',
60    dataIndex: 'startTime',
61    width: 120,
62  },
63  {
64    title: '营业结束时间',
65    dataIndex: 'endTime',
66    width: 120,
67  },
68];
69
70export const searchFormSchema: FormSchema[] = [
71  {
72    field: 'name',
73    label: '站点名称',
74    component: 'Input',
75    colProps: { span: 8 },
76  },
77  {
78    field: 'longitude',
79    label: '经度',
80    component: 'Input',
81    colProps: { span: 4 },
82  },
83  {
84    field: 'latitude',
85    label: '纬度',
86    component: 'Input',
87    colProps: { span: 4 },
88  },
89];
90
91export const formSchema: FormSchema[] = [
92  {
93    field: 'id',
94    label: 'id',
95    component: 'Input',
96    show: false,
97  },
98  {
99    field: 'createBy',
100    label: 'createBy',
101    component: 'Input',
102    show: false,
103  },
104  {
105    field: 'createTime',
106    label: 'createTime',
107    component: 'Input',
108    show: false,
109  },
110  {
111    field: 'name',
112    label: '商家名称',
113    component: 'Input',
114    required: true,
115    componentProps: {
116      placeholder: '请输入商家名称',
117    },
118  },
119  {
120    field: 'isOpen',
121    label: '是否营业',
122    component: 'JDictSelectTag',
123    required: true,
124    componentProps: {
125      dictCode: 'yn',
126      placeholder: '请选择',
127      stringToNumber: true,
128    },
129    colProps: {
130      span: 11,
131    },
132  },
133  {
134    field: 'address',
135    label: '地址',
136    component: 'Input',
137    componentProps: {
138      placeholder: '请输入地址',
139    },
140    colProps: {
141      span: 11,
142    },
143  },
144  {
145    field: 'longitude',
146    label: '经度',
147    component: 'Input',
148    componentProps: {
149      placeholder: '请输入经度',
150    },
151    colProps: {
152      span: 11,
153    },
154  },
155  {
156    field: 'latitude',
157    label: '纬度',
158    component: 'Input',
159    componentProps: {
160      placeholder: '请输入纬度',
161    },
162    colProps: {
163      span: 11,
164    },
165  },
166  {
167    field: 'startTime',
168    label: '营业开始时间',
169    component: 'Input',
170    componentProps: {
171      placeholder: '请输入开始时间',
172    },
173    colProps: {
174      span: 11,
175    },
176  },
177  {
178    field: 'endTime',
179    label: '营业结束时间',
180    component: 'Input',
181    componentProps: {
182      placeholder: '请输入结束时间',
183    },
184    colProps: {
185      span: 11,
186    },
187  },
188  {
189    field: 'cover',
190    label: '封面',
191    component: 'JImageUpload',
192    required: true,
193    componentProps: {
194      fileMax: 1,
195    },
196  },
197  {
198    field: 'notice',
199    label: '公告',
200    component: 'InputTextArea',
201    labelLength: 8,
202    componentProps: {
203      placeholder: '请输入公告',
204    },
205  },
206];
207