Commit 7afcd3fa authored by zhanglongbao's avatar zhanglongbao

fix

parent ab3e03a7
......@@ -9,6 +9,7 @@
<formContentComp
:form_detail="form_detail"
:modelValue="data"
:defaultData="defaultData"
@editData="editData" />
<div class="bottom bottom_button">
......@@ -27,12 +28,15 @@ import formContentComp from "@/components/widget/index.vue";
export interface Props {
form_id: string;
data?: object;
data?: object; // 修改初始化数据
defaultData?: object; // 默认数据(用于兼容初始化关联数据的字段,里面会弹出eidtData)
onHide?: () => void;
onConfirm?: (data: object) => void;
onEditConfirm?: (data: object) => void;
}
const props = defineProps<Props>();
const props = withDefaults(defineProps<Props>(), {});
console.log("defaultData", props);
const show = ref(false);
onMounted(() => {
show.value = true;
......@@ -55,6 +59,7 @@ const editData = (edit_data: any) => {
for (const key in edit_data) {
data.value[key] = edit_data[key];
}
console.log("data", data.value);
};
// 表单信息
......
......@@ -6,6 +6,7 @@ export interface FieldProps {
disabled?: boolean;
data: any;
required?: boolean;
defaultData?: any;
}
// 基础字段配置
......
......@@ -45,6 +45,7 @@
import { ref, onBeforeUnmount } from "vue";
import { FieldProps } from "../config";
import { $selectClient } from "@/components/select_client/index";
import { container } from "@/utils/container/index";
const props = defineProps<FieldProps>();
const emit = defineEmits(["edit"]);
......@@ -59,6 +60,8 @@ const change = () => {
const client = ref<any>({});
const selectClient = () => {
if (container.qr_code) return;
$selectClient({
value: client.value,
onConfirm: (data) => {
......@@ -79,6 +82,12 @@ onBeforeUnmount(() => {
const init = () => {
client.value = props.data[props.config.key_id] || {};
const defaultData = props.defaultData[props.config.key_id];
if (defaultData) {
client.value = defaultData;
change();
}
};
init();
</script>
......
......@@ -37,17 +37,22 @@
import { onBeforeUnmount, ref } from "vue";
import { FieldProps } from "../config";
import { $selectProduct } from "@/components/select_product/index";
import { container } from "@/utils/container/index";
const props = defineProps<FieldProps>();
const emit = defineEmits(["edit"]);
const change = () => {
emit("edit", { [props.config.key_id]: [product.value.id] });
emit("edit", {
[props.config.key_id]: product.value.id ? [product.value.id] : [],
});
};
const product = ref<any>({});
const selectProduct = () => {
if (container.qr_code) return;
$selectProduct({
value: product.value,
onConfirm: async (data) => {
......@@ -68,6 +73,12 @@ onBeforeUnmount(() => {
const init = () => {
product.value = props.data[props.config.key_id] || {};
const defaultData = props.defaultData[props.config.key_id];
if (defaultData) {
product.value = defaultData;
change();
}
};
init();
</script>
......
......@@ -8,6 +8,7 @@
:config="it"
:disabled="disabled"
:data="modelValue"
:defaultData="defaultData"
@edit="edit" />
</template>
</div>
......@@ -18,12 +19,14 @@ import { computed } from "vue";
import { allFieldConfig, widgetKeyName } from "./field/config";
interface Props {
modelValue?: any; // 数据
modelValue?: object; // 数据
form_detail: FormDetail; // 表单详情
disabled?: boolean; // 是否禁用
defaultData?: object; // 创建时默认数据(用于兼容初始化关联数据的字段,里面会弹出eidtData)
}
const props = withDefaults(defineProps<Props>(), {
modelValue: {},
modelValue: () => ({}),
defaultData: () => ({}),
});
const emit = defineEmits([
"addNewFormItem",
......
......@@ -175,6 +175,10 @@ const toOrderList = () => {
const createFormData = (button: ButtonType) => {
$createFormData({
form_id: button.order_form_id,
defaultData: {
product_id: product_detail.value.product_info,
customer_id: product_detail.value.customer_info,
},
onConfirm: async (data) => {
const msg = await api.order.saveOrder({
...data,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment