草稿发布修改

This commit is contained in:
dong 2023-06-09 13:55:06 +08:00
parent 0dd5e9775a
commit 99ead17306
2 changed files with 75 additions and 44 deletions

View File

@ -52,11 +52,11 @@ export function deleteDraft(id: number) {
* @param id 稿id * @param id 稿id
*/ */
export function publishDraft(data: { export function publishDraft(data: {
layoutId: string;
name: string; name: string;
overwrite?: boolean; lineId: number;
draftingId: number;
}) { }) {
return api.post(`${DraftUriBase}/publish`, data); return api.post('/api/publishedGi/publish', data);
} }
/** /**

View File

@ -58,9 +58,9 @@
transition-hide="scale" transition-hide="scale"
> >
<q-card style="width: 300px"> <q-card style="width: 300px">
<q-card-section> <q-form ref="myForm" @submit="onCreate" class="q-gutter-md">
<div class="text-h6">新建草稿图</div> <q-card-section>
<q-form ref="myForm" class="q-gutter-md"> <div class="text-h6">新建草稿图</div>
<q-input <q-input
outlined outlined
label="名称" label="名称"
@ -73,15 +73,15 @@
:options="typeOptions" :options="typeOptions"
emit-value emit-value
map-options map-options
label="类型" label="类型 * "
/> />
</q-form> </q-card-section>
</q-card-section>
<q-card-actions align="right"> <q-card-actions align="right">
<q-btn color="primary" label="创建" type="submit" @click="onCreate" /> <q-btn color="primary" label="创建" type="submit" />
<q-btn label="取消" v-close-popup /> <q-btn label="取消" v-close-popup />
</q-card-actions> </q-card-actions>
</q-form>
</q-card> </q-card>
</q-dialog> </q-dialog>
@ -96,20 +96,42 @@
<div class="text-h6">草稿发布</div> <div class="text-h6">草稿发布</div>
</q-card-section> </q-card-section>
<q-card-section> <q-form ref="pubForm" @submit="publishGraphics" class="q-gutter-md">
<q-input <q-card-section>
outlined <q-input
disable outlined
label="草稿名称" disable
v-model="publishForm.draftName" label="草稿名称"
/> v-model="publishForm.draftName"
<q-input outlined label="发布名称" v-model="publishForm.pubName" /> />
</q-card-section> <q-input
outlined
label="发布名称 * "
v-model="publishForm.pubName"
lazy-rules
:rules="[(val) => val.length > 0 || '请输入名称!']"
/>
<q-select
v-model="publishForm.lineId"
:options="lineOptions"
emit-value
map-options
label="线路 * "
lazy-rules
:rules="[(val) => val || '请选择线路!']"
/>
</q-card-section>
<q-card-actions align="right"> <q-card-actions align="right">
<q-btn color="primary" label="发布" @click="publishGraphics" /> <q-btn
<q-btn label="取消" v-close-popup /> color="primary"
</q-card-actions> label="发布"
type="submit"
@click="publishGraphics"
/>
<q-btn label="取消" v-close-popup />
</q-card-actions>
</q-form>
</q-card> </q-card>
</q-dialog> </q-dialog>
</div> </div>
@ -143,6 +165,10 @@ const typeOptions = [
{ label: '线网', value: 'LineNetwork' }, { label: '线网', value: 'LineNetwork' },
]; ];
const createType = ref('Line'); const createType = ref('Line');
const lineOptions = [
{ label: '线路1', value: 1 },
{ label: '线路2', value: 2 },
];
const typeOptionsMap = computed(() => { const typeOptionsMap = computed(() => {
const obj: { [k: string]: string } = {}; const obj: { [k: string]: string } = {};
@ -256,7 +282,7 @@ function onCreate() {
} }
}); });
} }
const pubForm = ref<QForm | null>(null);
const publishFormShow = ref(false); const publishFormShow = ref(false);
const publishForm = reactive({ const publishForm = reactive({
id: '', id: '',
@ -269,26 +295,31 @@ function prePublish(row: any) {
publishForm.id = row.id; publishForm.id = row.id;
publishForm.draftName = row.name; publishForm.draftName = row.name;
publishForm.pubName = row.name; publishForm.pubName = row.name;
publishForm.lineId = '';
} }
async function publishGraphics() { async function publishGraphics() {
try { pubForm.value?.validate().then(async (res) => {
await publishDraft({ if (res) {
draftingId: publishForm.id, try {
name: publishForm.pubName, await publishDraft({
lineId: publishForm.lineId, draftingId: +publishForm.id,
}); name: publishForm.pubName,
publishFormShow.value = false; lineId: +publishForm.lineId,
$q.notify({ });
type: 'positive', publishFormShow.value = false;
message: '发布成功', $q.notify({
}); type: 'positive',
} catch (error: any) { message: '发布成功',
$q.notify({ });
type: 'negative', } catch (error: any) {
message: error.message, $q.notify({
}); type: 'negative',
} message: error.message,
});
}
}
});
} }
async function deleteData(row: any) { async function deleteData(row: any) {