|
@@ -7,13 +7,9 @@ import { httpDetail } from "/@/api/parameter/good";
|
|
|
import { BasicForm } from "/@/components/BasicForm";
|
|
|
import LadderModal from "./ladder-modal.vue";
|
|
|
import LadderTable from "./ladder-table.vue";
|
|
|
-import { ImageUpload } from "/@/components/Upload";
|
|
|
-import { ImageUploadList } from "/@/components/UploadList";
|
|
|
// import SearchTerrace from "/@/components/SearchTerrace";
|
|
|
import { Unit } from "/@/components/RemoteSelect";
|
|
|
import { transform, createDefaultData } from "/@/components/BasicForm";
|
|
|
-import { Customer } from "/@/components/RemoteSelect";
|
|
|
-// import { AmountInput } from "/@/components/Input";
|
|
|
import { useResponseHandle } from "/@/hooks/useAsync";
|
|
|
|
|
|
const emit = defineEmits(["create"]);
|
|
@@ -26,97 +22,33 @@ const props = defineProps<{
|
|
|
|
|
|
const loading = ref(false);
|
|
|
const { formItems } = projectFormConfig;
|
|
|
-console.log(formItems);
|
|
|
|
|
|
const responseHandle = useResponseHandle();
|
|
|
const basicFormRef = ref<InstanceType<typeof ElForm>>(null);
|
|
|
const formData = ref<Record<string, any>>(createDefaultData(formItems));
|
|
|
-console.log(formData);
|
|
|
const ladderModalRef = ref<InstanceType<typeof LadderModal>>(null);
|
|
|
|
|
|
-function requesetCategoryById(id: string) {
|
|
|
- const transform = ({ cat_name, ...rest }: any) => ({
|
|
|
- ...rest,
|
|
|
- name: cat_name
|
|
|
- });
|
|
|
- return new Promise(resolve => {
|
|
|
- httpDetail({ id }).then(({ code, message, data }) => {
|
|
|
- responseHandle({
|
|
|
- code,
|
|
|
- message,
|
|
|
- handler: () => resolve(transform(data))
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-async function ladderTransform(ladder) {
|
|
|
- loading.value = true;
|
|
|
- const { ladder: _ladder } = formData.value;
|
|
|
- const tasks = ladder.cat_info.map(async id => await requesetCategoryById(id));
|
|
|
- ladder.cat_info = await Promise.all(tasks);
|
|
|
- loading.value = false;
|
|
|
- return ladder;
|
|
|
-}
|
|
|
-
|
|
|
async function handlePush(_ladder) {
|
|
|
- const ladder = await ladderTransform(_ladder);
|
|
|
- if (!Array.isArray(formData.value.ladder)) {
|
|
|
- formData.value.ladder = [];
|
|
|
- }
|
|
|
- formData.value.ladder.push(ladder);
|
|
|
+ formData.value.good_param.push(unref(_ladder));
|
|
|
}
|
|
|
|
|
|
async function handleUpdate(_ladder, index) {
|
|
|
- const ladder = await ladderTransform(_ladder);
|
|
|
- formData.value.ladder[index] = ladder;
|
|
|
-}
|
|
|
-
|
|
|
-function disabledDate(date) {
|
|
|
- return date.getTime() < new Date().getTime() - 86400000;
|
|
|
-}
|
|
|
-
|
|
|
-function handleDateChange(prop: string) {
|
|
|
- const { arrtime, endtime } = formData.value;
|
|
|
- const start = new Date(arrtime).valueOf();
|
|
|
- const end = new Date(endtime).valueOf();
|
|
|
- if (start > end) {
|
|
|
- formData.value[prop] = "";
|
|
|
- ElMessage.warning(`竞价截止时间不能大于要求到货时间!`);
|
|
|
- }
|
|
|
+ formData.value.good_param[index] = _ladder;
|
|
|
}
|
|
|
|
|
|
function handleCreate() {
|
|
|
- console.log(formData.value);
|
|
|
basicFormRef.value.validate(isValid => {
|
|
|
if (!isValid) return;
|
|
|
- // const { ladder, ...rest } = unref(formData);
|
|
|
- // const transform = ladder => {
|
|
|
- // return {
|
|
|
- // ...(ladder.good_img ? { good_img: ladder.good_img } : {}),
|
|
|
- // ...{
|
|
|
- // budget_price: ladder.budget_price,
|
|
|
- // good_name: ladder.good_name,
|
|
|
- // good_type: ladder.good_type,
|
|
|
- // num: ladder.num
|
|
|
- // }
|
|
|
- // };
|
|
|
- // };
|
|
|
-
|
|
|
- // const params = {
|
|
|
- // ...rest,
|
|
|
- // ladder: ladder.map(transform)
|
|
|
- // };
|
|
|
-
|
|
|
- // emit("create", params);
|
|
|
+ const params = unref(formData);
|
|
|
+ emit("create", params);
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
watchEffect(() => {
|
|
|
const { readonly, data } = props;
|
|
|
if (readonly && !data) {
|
|
|
return;
|
|
|
}
|
|
|
+ formData.value = transform(formItems, data, {});
|
|
|
});
|
|
|
</script>
|
|
|
|
|
@@ -135,14 +67,13 @@ watchEffect(() => {
|
|
|
</template>
|
|
|
|
|
|
<template #good_param>
|
|
|
- 111 先展示
|
|
|
- <!-- <LadderTable
|
|
|
+ <LadderTable
|
|
|
:readonly="readonly"
|
|
|
:ladder="formData.good_param"
|
|
|
@choose="() => ladderModalRef.onDisplay()"
|
|
|
@update="({ data, index }) => ladderModalRef.onDisplay(data, index)"
|
|
|
- @delete="index => formData.ladder.splice(index, 1)"
|
|
|
- /> -->
|
|
|
+ @delete="index => formData.good_param.splice(index, 1)"
|
|
|
+ />
|
|
|
</template>
|
|
|
|
|
|
<template #footer>
|
|
@@ -152,10 +83,10 @@ watchEffect(() => {
|
|
|
</template>
|
|
|
</BasicForm>
|
|
|
|
|
|
- <!-- <LadderModal
|
|
|
+ <LadderModal
|
|
|
ref="ladderModalRef"
|
|
|
@update="handleUpdate"
|
|
|
@push="handlePush"
|
|
|
- /> -->
|
|
|
+ />
|
|
|
</ElScrollbar>
|
|
|
</template>
|