Commit 7afcd3fa authored by zhanglongbao's avatar zhanglongbao

fix

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