205 lines
4.2 KiB
TypeScript
205 lines
4.2 KiB
TypeScript
import { BasicColumn } from '/@/components/Table'
|
|
import { FormSchema } from '/@/components/Table'
|
|
import { Tag } from 'ant-design-vue'
|
|
import { h } from 'vue'
|
|
export const columns: BasicColumn[] = [
|
|
{
|
|
title: '名称',
|
|
dataIndex: 'name',
|
|
},
|
|
{
|
|
title: '年份',
|
|
dataIndex: 'year',
|
|
customRender: ({ text }) => {
|
|
return text + '年'
|
|
},
|
|
},
|
|
{
|
|
title: '季度',
|
|
dataIndex: 'quarter',
|
|
},
|
|
{
|
|
title: '类型',
|
|
dataIndex: 'type',
|
|
customRender: ({ record }) => {
|
|
const status = record.type
|
|
const list = [
|
|
{
|
|
value: 1,
|
|
color: 'green',
|
|
label: '饲料',
|
|
},
|
|
{
|
|
value: 2,
|
|
color: 'pink',
|
|
label: '肥料',
|
|
},
|
|
]
|
|
const item = list.find((e) => e.value === status)
|
|
const color = item?.color ?? 'red'
|
|
const text = item?.label ?? status
|
|
return h(Tag, { color: color }, () => text)
|
|
},
|
|
},
|
|
{
|
|
title: '最低价',
|
|
dataIndex: 'lowest_price',
|
|
customRender: ({ record: { lowest_price, unit } }) => {
|
|
return lowest_price + unit
|
|
},
|
|
},
|
|
{
|
|
title: '最高价',
|
|
dataIndex: 'highest_price',
|
|
customRender: ({ record: { highest_price, unit } }) => {
|
|
return highest_price + unit
|
|
},
|
|
},
|
|
{
|
|
title: '创建人',
|
|
dataIndex: 'name',
|
|
customRender: ({ record: { created_by } }) => {
|
|
return created_by.name
|
|
},
|
|
},
|
|
|
|
{
|
|
width: 180,
|
|
title: '操作',
|
|
dataIndex: 'action',
|
|
align: 'center',
|
|
fixed: undefined,
|
|
},
|
|
]
|
|
|
|
export const searchFormSchema: FormSchema[] = [
|
|
{
|
|
field: 'year',
|
|
label: '年份',
|
|
component: 'DatePicker',
|
|
componentProps: {
|
|
picker: 'year',
|
|
mode: 'year',
|
|
},
|
|
colProps: { span: 8 },
|
|
},
|
|
{
|
|
field: 'quarter',
|
|
label: '季度',
|
|
component: 'Select',
|
|
componentProps: {
|
|
options: [
|
|
{ label: '第一季度', value: '1' },
|
|
{ label: '第二季度', value: '2' },
|
|
{ label: '第三季度', value: '3' },
|
|
{ label: '第四季度', value: '4' },
|
|
],
|
|
},
|
|
colProps: { span: 8 },
|
|
},
|
|
{
|
|
field: 'type',
|
|
label: '类型',
|
|
component: 'Select',
|
|
componentProps: {
|
|
options: [
|
|
{ label: '饲料', value: '1' },
|
|
{ label: '肥料', value: '2' },
|
|
],
|
|
},
|
|
colProps: { span: 8 },
|
|
},
|
|
{
|
|
field: 'name',
|
|
label: '名称',
|
|
required: false,
|
|
component: 'Input',
|
|
colProps: { span: 8 },
|
|
},
|
|
]
|
|
|
|
export const accountFormSchema: FormSchema[] = [
|
|
{
|
|
field: 'id',
|
|
label: 'ID',
|
|
required: false,
|
|
dynamicDisabled: true,
|
|
component: 'Input',
|
|
ifShow: ({ values }) => {
|
|
return !!values.id
|
|
},
|
|
},
|
|
{
|
|
field: 'name',
|
|
label: '名称',
|
|
required: true,
|
|
component: 'Input',
|
|
},
|
|
{
|
|
field: 'year',
|
|
label: '年份',
|
|
component: 'DatePicker',
|
|
required: true,
|
|
componentProps: {
|
|
picker: 'year',
|
|
mode: 'year',
|
|
},
|
|
},
|
|
{
|
|
field: 'quarter',
|
|
label: '季度',
|
|
component: 'Select',
|
|
required: true,
|
|
componentProps: {
|
|
options: [
|
|
{ label: '第一季度', value: '1' },
|
|
{ label: '第二季度', value: '2' },
|
|
{ label: '第三季度', value: '3' },
|
|
{ label: '第四季度', value: '4' },
|
|
],
|
|
},
|
|
},
|
|
{
|
|
field: 'type',
|
|
label: '类型',
|
|
component: 'Select',
|
|
required: true,
|
|
componentProps: {
|
|
options: [
|
|
{ label: '饲料', value: 1 },
|
|
{ label: '肥料', value: 2 },
|
|
],
|
|
},
|
|
},
|
|
{
|
|
field: 'unit',
|
|
label: '单位',
|
|
required: true,
|
|
component: 'Input',
|
|
},
|
|
{
|
|
field: 'lowest_price',
|
|
label: '最低价',
|
|
required: true,
|
|
component: 'InputNumber',
|
|
componentProps: {
|
|
formatter: (value) => {
|
|
let reg = /^(-)*(\d+)\.(\d\d).*$/
|
|
return `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, '').replace(reg, '$1$2.$3')
|
|
},
|
|
},
|
|
},
|
|
{
|
|
field: 'highest_price',
|
|
label: '最高价',
|
|
required: true,
|
|
component: 'InputNumber',
|
|
componentProps: {
|
|
formatter: (value) => {
|
|
let reg = /^(-)*(\d+)\.(\d\d).*$/
|
|
return `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, '').replace(reg, '$1$2.$3')
|
|
},
|
|
},
|
|
},
|
|
]
|