You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.0 KiB
50 lines
1.0 KiB
import * as echarts from "echarts";
|
|
|
|
interface inputMessage {
|
|
info: string;
|
|
tooshort: string;
|
|
toolong: string;
|
|
}
|
|
|
|
interface selectMessage {
|
|
info: string;
|
|
}
|
|
|
|
/**
|
|
* 定义antd vue的验证规则
|
|
*/
|
|
export const validator = (
|
|
minLength: number,
|
|
maxLength: number,
|
|
message: inputMessage
|
|
) => {
|
|
return (_: any, value: string) => {
|
|
if (!value) {
|
|
return Promise.reject(message.info);
|
|
} else if (value.length < minLength) {
|
|
return Promise.reject(message.tooshort);
|
|
} else if (value.length > maxLength) {
|
|
return Promise.reject(message.toolong);
|
|
} else {
|
|
return Promise.resolve();
|
|
}
|
|
};
|
|
};
|
|
|
|
export const verifySelect = (message: selectMessage) => {
|
|
return (_: any, value: string) => {
|
|
if (!value) {
|
|
return Promise.reject(message.info);
|
|
} else {
|
|
return Promise.resolve();
|
|
}
|
|
};
|
|
};
|
|
|
|
/**
|
|
* echarts配置
|
|
*/
|
|
export const createEcharts = (chartRef: any, option: any) => {
|
|
const myChart = echarts.init(chartRef.value);
|
|
myChart.setOption(option);
|
|
};
|