|
|
@@ -21,103 +21,6 @@ wapBannerUrl: "https://4dkk.4dage.com/shop/huafa/20220302/23135195983e96.png?x-o
|
|
|
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
|
|
|
|
|
const isLevel2 = (type: string) => type === 'L2';
|
|
|
- const schemas: FormSchema[] = [
|
|
|
- {
|
|
|
- field: 'name',
|
|
|
- component: 'Input',
|
|
|
- label: '分类名称',
|
|
|
- colProps: {
|
|
|
- span: 24,
|
|
|
- },
|
|
|
- required: true,
|
|
|
- },
|
|
|
- {
|
|
|
- field: 'level',
|
|
|
- component: 'RadioGroup',
|
|
|
- label: '级别',
|
|
|
- defaultValue: 'L1',
|
|
|
- colProps: {
|
|
|
- span: 24,
|
|
|
- },
|
|
|
- componentProps: {
|
|
|
- options: [
|
|
|
- {
|
|
|
- label: '一级分类',
|
|
|
- value: 'L1',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '二级分类',
|
|
|
- value: 'L2',
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- },
|
|
|
-
|
|
|
- {
|
|
|
- field: 'parentId',
|
|
|
- component: 'ApiSelect',
|
|
|
- label: '上级分类',
|
|
|
- ifShow: ({ values }) => isLevel2(values.level),
|
|
|
- colProps: {
|
|
|
- span: 18,
|
|
|
- },
|
|
|
- componentProps: {
|
|
|
- api: async function (params) {
|
|
|
- console.log('params', params);
|
|
|
- const res = (await categoryApi(params)) as any as TreeNode[];
|
|
|
- // const treeData = makeTree(res);
|
|
|
- return res.filter((i) => i.level === 'L1');
|
|
|
- },
|
|
|
- labelField: 'name',
|
|
|
- valueField: 'id',
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- field: 'isShow',
|
|
|
- component: 'RadioGroup',
|
|
|
- label: '是否显示',
|
|
|
- defaultValue: '1',
|
|
|
- colProps: {
|
|
|
- span: 24,
|
|
|
- },
|
|
|
- componentProps: {
|
|
|
- options: [
|
|
|
- {
|
|
|
- label: '显示',
|
|
|
- value: '1',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '不显示',
|
|
|
- value: '0',
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- field: 'type',
|
|
|
- component: 'InputNumber',
|
|
|
- label: '排序',
|
|
|
- defaultValue: 1,
|
|
|
- colProps: {
|
|
|
- span: 24,
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- field: 'wapBannerUrl',
|
|
|
- component: 'Upload',
|
|
|
- label: '手机banner',
|
|
|
- rules: [{ required: true, message: '请选择上传文件' }],
|
|
|
- componentProps: {
|
|
|
- api: uploadBannerApi,
|
|
|
- maxNumber: 1,
|
|
|
- afterFetch: function (data) {
|
|
|
- Reflect.set(data, 'url', data.message.url);
|
|
|
- return data;
|
|
|
- },
|
|
|
- },
|
|
|
- required: true,
|
|
|
- },
|
|
|
- ];
|
|
|
export default defineComponent({
|
|
|
components: { BasicModal, BasicForm },
|
|
|
props: {
|
|
|
@@ -125,7 +28,7 @@ wapBannerUrl: "https://4dkk.4dage.com/shop/huafa/20220302/23135195983e96.png?x-o
|
|
|
},
|
|
|
emits: ['update', 'register'],
|
|
|
setup(_, { emit }) {
|
|
|
- const [registerForm, { validate, getFieldsValue, resetFields }] = useForm({
|
|
|
+ const [registerForm, { validate, getFieldsValue, resetFields, validateFields }] = useForm({
|
|
|
labelWidth: 120,
|
|
|
schemas,
|
|
|
showActionButtonGroup: false,
|
|
|
@@ -133,7 +36,106 @@ wapBannerUrl: "https://4dkk.4dage.com/shop/huafa/20220302/23135195983e96.png?x-o
|
|
|
span: 24,
|
|
|
},
|
|
|
});
|
|
|
+ const schemas: FormSchema[] = [
|
|
|
+ {
|
|
|
+ field: 'name',
|
|
|
+ component: 'Input',
|
|
|
+ label: '分类名称',
|
|
|
+ colProps: {
|
|
|
+ span: 24,
|
|
|
+ },
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'level',
|
|
|
+ component: 'RadioGroup',
|
|
|
+ label: '级别',
|
|
|
+ defaultValue: 'L1',
|
|
|
+ colProps: {
|
|
|
+ span: 24,
|
|
|
+ },
|
|
|
+ componentProps: {
|
|
|
+ options: [
|
|
|
+ {
|
|
|
+ label: '一级分类',
|
|
|
+ value: 'L1',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '二级分类',
|
|
|
+ value: 'L2',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ },
|
|
|
|
|
|
+ {
|
|
|
+ field: 'parentId',
|
|
|
+ component: 'ApiSelect',
|
|
|
+ label: '上级分类',
|
|
|
+ ifShow: ({ values }) => isLevel2(values.level),
|
|
|
+ colProps: {
|
|
|
+ span: 18,
|
|
|
+ },
|
|
|
+ componentProps: {
|
|
|
+ api: async function (params) {
|
|
|
+ console.log('params', params);
|
|
|
+ const res = (await categoryApi(params)) as any as TreeNode[];
|
|
|
+ // const treeData = makeTree(res);
|
|
|
+ return res.filter((i) => i.level === 'L1');
|
|
|
+ },
|
|
|
+ labelField: 'name',
|
|
|
+ valueField: 'id',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'isShow',
|
|
|
+ component: 'RadioGroup',
|
|
|
+ label: '是否显示',
|
|
|
+ defaultValue: '1',
|
|
|
+ colProps: {
|
|
|
+ span: 24,
|
|
|
+ },
|
|
|
+ componentProps: {
|
|
|
+ options: [
|
|
|
+ {
|
|
|
+ label: '显示',
|
|
|
+ value: '1',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '不显示',
|
|
|
+ value: '0',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'type',
|
|
|
+ component: 'InputNumber',
|
|
|
+ label: '排序',
|
|
|
+ defaultValue: 1,
|
|
|
+ colProps: {
|
|
|
+ span: 24,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'wapBannerUrl',
|
|
|
+ component: 'Upload',
|
|
|
+ label: '手机banner',
|
|
|
+ rules: [{ required: true, message: '请选择上传文件' }],
|
|
|
+ componentProps: {
|
|
|
+ onChange: async () => {
|
|
|
+ await validateFields(['wapBannerUrl']);
|
|
|
+ },
|
|
|
+ api: uploadBannerApi,
|
|
|
+ maxNumber: 1,
|
|
|
+ afterFetch: function (data) {
|
|
|
+ Reflect.set(data, 'url', data.message.url);
|
|
|
+ return data;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ ];
|
|
|
const [register, { closeModal }] = useModalInner((data) => {
|
|
|
data && onDataReceive(data);
|
|
|
});
|