|
@@ -1,9 +1,11 @@
|
|
-import { Button, Col, Form, Input, Row } from "ant-design-vue";
|
|
|
|
-import { defineComponent, onMounted, reactive, ref } from "vue";
|
|
|
|
-import { any } from "vue-types";
|
|
|
|
import Modal from "@/components/Provider/Modal";
|
|
import Modal from "@/components/Provider/Modal";
|
|
import { css } from "@linaria/core";
|
|
import { css } from "@linaria/core";
|
|
-
|
|
|
|
|
|
+import { Button, Checkbox, Form, Input, Select } from "ant-design-vue";
|
|
|
|
+import { defineComponent, onMounted, reactive, ref } from "vue";
|
|
|
|
+import { any } from "vue-types";
|
|
|
|
+import UploadImage from "./UploadImage";
|
|
|
|
+import { uploader } from "../objects";
|
|
|
|
+import loading from "@/components/Provider/Loading";
|
|
const layout = {
|
|
const layout = {
|
|
wrapperCol: { span: 24 },
|
|
wrapperCol: { span: 24 },
|
|
};
|
|
};
|
|
@@ -18,10 +20,10 @@ export default defineComponent({
|
|
formData: {
|
|
formData: {
|
|
...{
|
|
...{
|
|
name: "",
|
|
name: "",
|
|
- designer: "",
|
|
|
|
- thumbnail: "",
|
|
|
|
- compCounts: 0,
|
|
|
|
- components: [],
|
|
|
|
|
|
+ cover: "",
|
|
|
|
+ sort: 0,
|
|
|
|
+ type: "list",
|
|
|
|
+ isHome: false,
|
|
},
|
|
},
|
|
...props.data,
|
|
...props.data,
|
|
},
|
|
},
|
|
@@ -30,36 +32,28 @@ export default defineComponent({
|
|
onMounted(() => {});
|
|
onMounted(() => {});
|
|
|
|
|
|
const rules = reactive({
|
|
const rules = reactive({
|
|
- name: [
|
|
|
|
- { required: true, message: "名称不能为空", trigger: "change" },
|
|
|
|
- {
|
|
|
|
- min: 2,
|
|
|
|
- max: 20,
|
|
|
|
- message: "长度为2~20位字符",
|
|
|
|
- trigger: "change",
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
|
|
+ name: [{ required: true, message: "名称不能为空", trigger: "change" }],
|
|
|
|
+ cover: [{ required: false }],
|
|
|
|
+ isHome: [{ required: false }],
|
|
|
|
+ type: [{ required: true, message: "分类", trigger: "change" }],
|
|
});
|
|
});
|
|
|
|
|
|
- const loading = ref(false);
|
|
|
|
const { validate, validateInfos } = Form.useForm(formState.formData, rules);
|
|
const { validate, validateInfos } = Form.useForm(formState.formData, rules);
|
|
|
|
|
|
function submit() {
|
|
function submit() {
|
|
validate().then(async () => {
|
|
validate().then(async () => {
|
|
- // loading.value = true;
|
|
|
|
- // let res;
|
|
|
|
- // formState.formData.compCounts = formState.formData.components.length;
|
|
|
|
- // if (isCreate) {
|
|
|
|
- // res = await controls.packList.addItem(formState.formData);
|
|
|
|
- // } else {
|
|
|
|
- // res = await controls.packList.saveItem(formState.formData);
|
|
|
|
- // }
|
|
|
|
- // loading.value = false;
|
|
|
|
- // if (res.errorNo != 200) return;
|
|
|
|
-
|
|
|
|
- modal.submit();
|
|
|
|
|
|
+ await uploader.uploadBlobImages(formState.formData, {
|
|
|
|
+ onProgress() {
|
|
|
|
+ loading.show("上传中");
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ loading.hidden();
|
|
|
|
+ modal.submit(formState.formData);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+ const changeBanner = (v: string) => {
|
|
|
|
+ formState.formData.cover = v;
|
|
|
|
+ };
|
|
|
|
|
|
return () => {
|
|
return () => {
|
|
return (
|
|
return (
|
|
@@ -67,51 +61,42 @@ export default defineComponent({
|
|
<div class={"edit_content"}>
|
|
<div class={"edit_content"}>
|
|
<div class={"form_content"}>
|
|
<div class={"form_content"}>
|
|
<Form {...layout} class={EditFormStyle} onSubmit={submit}>
|
|
<Form {...layout} class={EditFormStyle} onSubmit={submit}>
|
|
- <Row>
|
|
|
|
- <Col span={22}>
|
|
|
|
- <Row>
|
|
|
|
- <Col>
|
|
|
|
- <Form.Item style={{ marginBottom: 0 }}>
|
|
|
|
- <div class={"thumb"}></div>
|
|
|
|
- </Form.Item>
|
|
|
|
- </Col>
|
|
|
|
- <Col class={"pl-10px"}>
|
|
|
|
- <Form.Item {...validateInfos.name}>
|
|
|
|
- <Input
|
|
|
|
- placeholder={"请输入包装名称"}
|
|
|
|
- v-model={[formState.formData.name, "value"]}
|
|
|
|
- maxlength={30}
|
|
|
|
- />
|
|
|
|
- </Form.Item>
|
|
|
|
-
|
|
|
|
- <Form.Item {...validateInfos.designer}>
|
|
|
|
- <Input
|
|
|
|
- placeholder={"请输入设计师名字"}
|
|
|
|
- v-model={[formState.formData.designer, "value"]}
|
|
|
|
- maxlength={10}
|
|
|
|
- />
|
|
|
|
- </Form.Item>
|
|
|
|
- </Col>
|
|
|
|
- </Row>
|
|
|
|
- </Col>
|
|
|
|
- <Col span={2}>
|
|
|
|
- <Form.Item
|
|
|
|
- style={{ marginBottom: 0, textAlign: "right" }}
|
|
|
|
- wrapperCol={{ span: 24 }}
|
|
|
|
- >
|
|
|
|
- <Button
|
|
|
|
- type="primary"
|
|
|
|
- htmlType="submit"
|
|
|
|
- loading={loading.value}
|
|
|
|
- >
|
|
|
|
- 保存
|
|
|
|
- </Button>
|
|
|
|
- </Form.Item>
|
|
|
|
- </Col>
|
|
|
|
- </Row>
|
|
|
|
|
|
+ <Form.Item {...validateInfos.cover}>
|
|
|
|
+ <UploadImage
|
|
|
|
+ data={formState.formData.cover}
|
|
|
|
+ text={"上传分类banner图"}
|
|
|
|
+ onChange={changeBanner}
|
|
|
|
+ ></UploadImage>
|
|
|
|
+ </Form.Item>
|
|
|
|
+ <Form.Item {...validateInfos.name} label={"分类名称"}>
|
|
|
|
+ <Input
|
|
|
|
+ placeholder={"请输入分类名称"}
|
|
|
|
+ v-model={[formState.formData.name, "value"]}
|
|
|
|
+ maxlength={30}
|
|
|
|
+ />
|
|
|
|
+ </Form.Item>
|
|
|
|
+ <Form.Item {...validateInfos.type} label={"分类类型"}>
|
|
|
|
+ <Select v-model={[formState.formData.type, "value"]}>
|
|
|
|
+ <Select.Option value="list">列表</Select.Option>
|
|
|
|
+ <Select.Option value="detail">详情</Select.Option>
|
|
|
|
+ <Select.Option value="download">下载</Select.Option>
|
|
|
|
+ </Select>
|
|
|
|
+ </Form.Item>
|
|
|
|
+ <Form.Item {...validateInfos.isHome} label={"是否首页展示"}>
|
|
|
|
+ <Checkbox
|
|
|
|
+ v-model={[formState.formData.isHome, "checked"]}
|
|
|
|
+ ></Checkbox>
|
|
|
|
+ </Form.Item>
|
|
|
|
+ <Form.Item
|
|
|
|
+ style={{ marginBottom: 0 }}
|
|
|
|
+ wrapperCol={{ span: 24 }}
|
|
|
|
+ >
|
|
|
|
+ <Button type="primary" htmlType="submit" block>
|
|
|
|
+ 保存
|
|
|
|
+ </Button>
|
|
|
|
+ </Form.Item>
|
|
</Form>
|
|
</Form>
|
|
</div>
|
|
</div>
|
|
- <div class={"comp_content mt-20px"}></div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
);
|
|
@@ -119,10 +104,10 @@ export default defineComponent({
|
|
},
|
|
},
|
|
});
|
|
});
|
|
const EditStyle = css`
|
|
const EditStyle = css`
|
|
|
|
+ width: 400px;
|
|
.edit_content {
|
|
.edit_content {
|
|
display: flex;
|
|
display: flex;
|
|
flex-direction: column;
|
|
flex-direction: column;
|
|
- padding: 24px;
|
|
|
|
height: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
.comp_content {
|
|
.comp_content {
|