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: 'price', 43 }, 44 { 45 title: '总量', 46 dataIndex: 'totalNumber', 47 }, 48 { 49 title: '销量', 50 dataIndex: 'salesNumber', 51 }, 52 { 53 title: '规格', 54 dataIndex: 'standards', 55 }, 56 { 57 title: '重量', 58 dataIndex: 'weight', 59 }, 60 { 61 title: '品牌', 62 dataIndex: 'brand', 63 }, 64 { 65 title: '品种', 66 dataIndex: 'breed', 67 }, 68 { 69 title: '产地', 70 dataIndex: 'producer', 71 }, 72 { 73 title: '国产/进口', 74 dataIndex: 'made', 75 customRender: ({ text }): Component => { 76 return render.renderDict(text, 'made'); 77 }, 78 }, 79 { 80 title: '保质期', 81 dataIndex: 'qualityDate', 82 }, 83 { 84 title: '包装方式', 85 dataIndex: 'packing', 86 }, 87 { 88 title: '类别', 89 dataIndex: 'category', 90 }, 91 { 92 title: '口味', 93 dataIndex: 'taste', 94 }, 95 { 96 title: '储存方式', 97 dataIndex: 'keepType', 98 }, 99]; 100 101export const searchFormSchema: FormSchema[] = [ 102 { 103 field: 'name', 104 label: '商品名称', 105 component: 'JInput', 106 colProps: { span: 8 }, 107 }, 108 { 109 field: 'category', 110 label: '类别', 111 component: 'JInput', 112 colProps: { span: 8 }, 113 }, 114]; 115export const formSchema: FormSchema[] = [ 116 { 117 field: 'id', 118 label: 'id', 119 component: 'Input', 120 show: false, 121 }, 122 { 123 field: 'createBy', 124 label: 'createBy', 125 component: 'Input', 126 show: false, 127 }, 128 { 129 field: 'createTime', 130 label: 'createTime', 131 component: 'Input', 132 show: false, 133 }, 134 { 135 field: 'name', 136 label: '商品名称', 137 component: 'Input', 138 required: true, 139 componentProps: { 140 placeholder: '请输入商品名称', 141 }, 142 colProps: { 143 span: 11, 144 }, 145 }, 146 { 147 field: 'category', 148 label: '类别', 149 component: 'Input', 150 componentProps: { 151 placeholder: '请输入类别', 152 }, 153 colProps: { 154 span: 11, 155 }, 156 }, 157 { 158 field: 'price', 159 label: '价格', 160 component: 'Input', 161 componentProps: { 162 placeholder: '请输入价格', 163 }, 164 colProps: { 165 span: 11, 166 }, 167 }, 168 { 169 field: 'salePrice', 170 label: '折后价格', 171 component: 'Input', 172 componentProps: { 173 placeholder: '请输入折后价格', 174 }, 175 colProps: { 176 span: 11, 177 }, 178 }, 179 { 180 field: 'totalNumber', 181 label: '总量', 182 component: 'Input', 183 componentProps: { 184 placeholder: '请输入总量', 185 }, 186 colProps: { 187 span: 11, 188 }, 189 }, 190 { 191 field: 'salesNumber', 192 label: '销量', 193 component: 'Input', 194 componentProps: { 195 placeholder: '请输入销量', 196 }, 197 colProps: { 198 span: 11, 199 }, 200 }, 201 { 202 field: 'standards', 203 label: '规格', 204 component: 'Input', 205 componentProps: { 206 placeholder: '请输入规格', 207 }, 208 colProps: { 209 span: 11, 210 }, 211 }, 212 { 213 field: 'weight', 214 label: '重量', 215 component: 'Input', 216 componentProps: { 217 placeholder: '请输入重量', 218 }, 219 colProps: { 220 span: 11, 221 }, 222 }, 223 { 224 field: 'brand', 225 label: '品牌', 226 component: 'Input', 227 componentProps: { 228 placeholder: '请输入品牌', 229 }, 230 colProps: { 231 span: 11, 232 }, 233 }, 234 { 235 field: 'breed', 236 label: '品种', 237 component: 'Input', 238 componentProps: { 239 placeholder: '请输入品种', 240 }, 241 colProps: { 242 span: 11, 243 }, 244 }, 245 { 246 field: 'producer', 247 label: '产地', 248 component: 'Input', 249 componentProps: { 250 placeholder: '请输入产地', 251 }, 252 colProps: { 253 span: 11, 254 }, 255 }, 256 { 257 field: 'made', 258 label: '进口/国产', 259 component: 'JDictSelectTag', 260 componentProps: { 261 dictCode: 'made', 262 placeholder: '请选择', 263 stringToNumber: true, 264 }, 265 colProps: { 266 span: 11, 267 }, 268 }, 269 { 270 field: 'packing', 271 label: '包装方式', 272 component: 'Input', 273 componentProps: { 274 placeholder: '请输入包装方式', 275 }, 276 colProps: { 277 span: 11, 278 }, 279 }, 280 { 281 field: 'taste', 282 label: '口味', 283 component: 'Input', 284 componentProps: { 285 placeholder: '请输入口味', 286 }, 287 colProps: { 288 span: 11, 289 }, 290 }, 291 { 292 field: 'keepType', 293 label: '存储方式', 294 component: 'Input', 295 componentProps: { 296 placeholder: '请输入存储方式', 297 }, 298 colProps: { 299 span: 11, 300 }, 301 }, 302 { 303 field: 'qualityDate', 304 label: '保质期', 305 component: 'DatePicker', 306 defaultValue: '', 307 componentProps: { 308 valueFormat: 'YYYY-MM-DD', 309 placeholder: '请选择保质期', 310 }, 311 colProps: { 312 span: 11, 313 }, 314 }, 315 { 316 field: 'cover', 317 label: '封面', 318 component: 'JImageUpload', 319 componentProps: { 320 fileMax: 1, 321 }, 322 }, 323 { 324 field: 'description', 325 label: '描述', 326 component: 'InputTextArea', 327 labelLength: 8, 328 componentProps: { 329 placeholder: '请输入描述', 330 }, 331 }, 332]; 333