|
|
@ -8,11 +8,11 @@ import { schemaToModel } from "../../utils/index.js"; |
|
|
|
import request from "../../request/index.js"; |
|
|
|
|
|
|
|
export default function (type) { |
|
|
|
return { |
|
|
|
components: { AppList, AppForm }, |
|
|
|
template: html`<app-list ref="appListRef" :config="config" @command="onCommand" />
|
|
|
|
return { |
|
|
|
components: { AppList, AppForm }, |
|
|
|
template: html`<app-list ref="appListRef" :config="config" @command="onCommand" />
|
|
|
|
<el-dialog v-model="dialogVisable" align-center :close-on-click-modal="false" destroy-on-close style="width:40%;height:50%;"> |
|
|
|
<template #header> <span class="el-dialog__title"> 库存余额任务 </span> </template> |
|
|
|
<template #header> <span class="el-dialog__title"> 数据生成任务 </span> </template> |
|
|
|
<el-scrollbar> |
|
|
|
<app-form ref="formRef" :mode="create" label-position="left" :schema="schema" v-model="model" :hideButton="true" @submit="submit" /> |
|
|
|
</el-scrollbar> |
|
|
@ -22,54 +22,54 @@ export default function (type) { |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
</el-dialog>`, |
|
|
|
styles: html`<style>
|
|
|
|
styles: html`<style>
|
|
|
|
.el-dialog__body { |
|
|
|
height: calc(100% - 120px); |
|
|
|
} |
|
|
|
</style>`, |
|
|
|
setup() { |
|
|
|
const route = useRoute(); |
|
|
|
const businessType = route.meta.businessType; |
|
|
|
const dialogVisable = ref(false); |
|
|
|
const loading = ref(false); |
|
|
|
const config = useConfig(businessType, type); |
|
|
|
const schema = config.compare.schema; |
|
|
|
const defaultModel = schemaToModel(schema); |
|
|
|
const model = ref(null); |
|
|
|
const formRef = ref(null); |
|
|
|
const onCommand = async (item, rows) => { |
|
|
|
console.log(item.path, item, rows); |
|
|
|
if (item.path === "compare") { |
|
|
|
model.value = Object.assign({}, defaultModel); |
|
|
|
dialogVisable.value = true; |
|
|
|
} |
|
|
|
}; |
|
|
|
const submit = async () => { |
|
|
|
try { |
|
|
|
const valid = await formRef.value.validate(); |
|
|
|
if (valid) { |
|
|
|
loading.value = true; |
|
|
|
} |
|
|
|
const url = config.edit.compareUrl; |
|
|
|
const data = Object.assign(model.value); |
|
|
|
setup() { |
|
|
|
const route = useRoute(); |
|
|
|
const businessType = route.meta.businessType; |
|
|
|
const dialogVisable = ref(false); |
|
|
|
const loading = ref(false); |
|
|
|
const config = useConfig(businessType, type); |
|
|
|
const schema = config.compare.schema; |
|
|
|
const defaultModel = schemaToModel(schema); |
|
|
|
const model = ref(null); |
|
|
|
const formRef = ref(null); |
|
|
|
const onCommand = async (item, rows) => { |
|
|
|
console.log(item.path, item, rows); |
|
|
|
if (item.path === "compare") { |
|
|
|
model.value = Object.assign({}, defaultModel); |
|
|
|
dialogVisable.value = true; |
|
|
|
} |
|
|
|
}; |
|
|
|
const submit = async () => { |
|
|
|
try { |
|
|
|
const valid = await formRef.value.validate(); |
|
|
|
if (valid) { |
|
|
|
loading.value = true; |
|
|
|
} |
|
|
|
const url = config.edit.compareUrl; |
|
|
|
const data = Object.assign(model.value); |
|
|
|
|
|
|
|
const result = await request(url, data, { method: "POST" }, true); |
|
|
|
if (!result.errors) { |
|
|
|
dialogVisable.value = false; |
|
|
|
await load(); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.log(error); |
|
|
|
} finally { |
|
|
|
loading.value = false; |
|
|
|
} |
|
|
|
}; |
|
|
|
//
|
|
|
|
const appListRef = ref(null); |
|
|
|
const event = "SaSeCompare"; |
|
|
|
onMounted(() => PubSub.subscribe(event, async () => await appListRef.value.load())); |
|
|
|
onUnmounted(() => PubSub.unsubscribe(event)); |
|
|
|
return { config, onCommand, appListRef, dialogVisable, loading, schema, model, formRef, submit }; |
|
|
|
}, |
|
|
|
}; |
|
|
|
const result = await request(url, data, { method: "POST" }, true); |
|
|
|
if (!result.errors) { |
|
|
|
dialogVisable.value = false; |
|
|
|
await load(); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.log(error); |
|
|
|
} finally { |
|
|
|
loading.value = false; |
|
|
|
} |
|
|
|
}; |
|
|
|
//
|
|
|
|
const appListRef = ref(null); |
|
|
|
const event = "SaSeCompare"; |
|
|
|
onMounted(() => PubSub.subscribe(event, async () => await appListRef.value.load())); |
|
|
|
onUnmounted(() => PubSub.unsubscribe(event)); |
|
|
|
return { config, onCommand, appListRef, dialogVisable, loading, schema, model, formRef, submit }; |
|
|
|
}, |
|
|
|
}; |
|
|
|
} |
|
|
|