线路信息管理调整
This commit is contained in:
parent
9a4a1d947c
commit
7e3173b076
@ -2,7 +2,7 @@
|
||||
<div class="q-pa-md">
|
||||
<q-table
|
||||
ref="tableRef"
|
||||
title="草稿图"
|
||||
title="线路信息"
|
||||
:style="{ height: tableHeight + 'px' }"
|
||||
:rows="rows"
|
||||
:columns="columnDefs"
|
||||
@ -34,12 +34,6 @@
|
||||
label="编辑"
|
||||
:to="`/painting/${props.row.id}`"
|
||||
/>
|
||||
<q-btn
|
||||
color="primary"
|
||||
:disable="operateDisabled"
|
||||
label="发布"
|
||||
@click="prePublish(props.row)"
|
||||
/>
|
||||
<q-btn
|
||||
color="red"
|
||||
:disable="operateDisabled"
|
||||
@ -58,58 +52,31 @@
|
||||
transition-hide="scale"
|
||||
>
|
||||
<q-card style="width: 300px">
|
||||
<q-card-section>
|
||||
<div class="text-h6">新建草稿图</div>
|
||||
<q-form ref="myForm" class="q-gutter-md">
|
||||
<q-form ref="myForm" @submit="onCreate" class="q-gutter-md">
|
||||
<q-card-section>
|
||||
<div class="text-h6">新建线路信息</div>
|
||||
<q-input
|
||||
outlined
|
||||
label="名称"
|
||||
v-model="draftName"
|
||||
v-model="LineName"
|
||||
lazy-rules
|
||||
:rules="[(val) => val.length > 0 || '请输入名称!']"
|
||||
/>
|
||||
<q-select
|
||||
v-model="createType"
|
||||
:options="typeOptions"
|
||||
emit-value
|
||||
map-options
|
||||
label="类型"
|
||||
<q-input
|
||||
outlined
|
||||
label="线路ID"
|
||||
v-model.number="LineId"
|
||||
type="number"
|
||||
lazy-rules
|
||||
:rules="[(val) => val || '请输入线路ID!']"
|
||||
/>
|
||||
</q-form>
|
||||
</q-card-section>
|
||||
</q-card-section>
|
||||
|
||||
<q-card-actions align="right">
|
||||
<q-btn color="primary" label="创建" type="submit" @click="onCreate" />
|
||||
<q-btn label="取消" v-close-popup />
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
|
||||
<q-dialog
|
||||
v-model="publishFormShow"
|
||||
persistent
|
||||
transition-show="scale"
|
||||
transition-hide="scale"
|
||||
>
|
||||
<q-card style="width: 300px">
|
||||
<q-card-section>
|
||||
<div class="text-h6">草稿发布</div>
|
||||
</q-card-section>
|
||||
|
||||
<q-card-section>
|
||||
<q-input
|
||||
outlined
|
||||
disable
|
||||
label="草稿名称"
|
||||
v-model="publishForm.draftName"
|
||||
/>
|
||||
<q-input outlined label="发布名称" v-model="publishForm.pubName" />
|
||||
</q-card-section>
|
||||
|
||||
<q-card-actions align="right">
|
||||
<q-btn color="primary" label="发布" @click="publishGraphics" />
|
||||
<q-btn label="取消" v-close-popup />
|
||||
</q-card-actions>
|
||||
<q-card-actions align="right">
|
||||
<q-btn color="primary" label="创建" type="submit" />
|
||||
<q-btn label="取消" v-close-popup />
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</div>
|
||||
@ -118,12 +85,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue';
|
||||
import { useQuasar, type QTableColumn, QForm } from 'quasar';
|
||||
import {
|
||||
pageQuery,
|
||||
publishDraft,
|
||||
createDraft,
|
||||
deleteDraft,
|
||||
} from '../api/DraftApi';
|
||||
import { pageQuery, createLine, deleteLine } from '../api/LineInfoApi';
|
||||
|
||||
const $q = useQuasar();
|
||||
|
||||
@ -138,20 +100,6 @@ const tableHeight = computed(() => {
|
||||
return props.sizeHeight - 32;
|
||||
});
|
||||
|
||||
const typeOptions = [
|
||||
{ label: '线路', value: 'Line' },
|
||||
{ label: '线网', value: 'LineNetwork' },
|
||||
];
|
||||
const createType = ref('Line');
|
||||
|
||||
const typeOptionsMap = computed(() => {
|
||||
const obj: { [k: string]: string } = {};
|
||||
typeOptions.forEach((item: { value: string; label: string }) => {
|
||||
obj[item.value] = item.label;
|
||||
});
|
||||
return obj;
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
tableRef.value.requestServerInteraction();
|
||||
});
|
||||
@ -164,15 +112,7 @@ const columnDefs: QTableColumn[] = [
|
||||
required: true,
|
||||
align: 'center',
|
||||
},
|
||||
// { name: 'creator', label: '创建人', field: 'creator', align: 'center' },
|
||||
{
|
||||
name: 'type',
|
||||
label: '类型',
|
||||
field: (row) => {
|
||||
return typeOptionsMap.value[row.type];
|
||||
},
|
||||
align: 'center',
|
||||
},
|
||||
{ name: 'lineId', label: '线路ID', field: 'lineId', align: 'center' },
|
||||
{
|
||||
name: 'createdAt',
|
||||
label: '创建时间',
|
||||
@ -232,16 +172,18 @@ async function onRequest(props: any) {
|
||||
}
|
||||
|
||||
const createFormShow = ref(false);
|
||||
const draftName = ref('');
|
||||
const LineName = ref('');
|
||||
const LineId = ref(1);
|
||||
const myForm = ref<QForm | null>(null);
|
||||
function onCreate() {
|
||||
myForm.value?.validate().then(async (res) => {
|
||||
if (res) {
|
||||
operateDisabled.value = true;
|
||||
try {
|
||||
await createDraft({
|
||||
name: draftName.value,
|
||||
type: createType.value,
|
||||
await createLine({
|
||||
name: LineName.value,
|
||||
lineId: LineId.value,
|
||||
config: '',
|
||||
});
|
||||
createFormShow.value = false;
|
||||
tableRef.value.requestServerInteraction(); // 刷新列表
|
||||
@ -257,50 +199,16 @@ function onCreate() {
|
||||
});
|
||||
}
|
||||
|
||||
const publishFormShow = ref(false);
|
||||
const publishForm = reactive({
|
||||
id: '',
|
||||
draftName: '',
|
||||
pubName: '',
|
||||
lineId: '',
|
||||
});
|
||||
function prePublish(row: any) {
|
||||
publishFormShow.value = true;
|
||||
publishForm.id = row.id;
|
||||
publishForm.draftName = row.name;
|
||||
publishForm.pubName = row.name;
|
||||
}
|
||||
|
||||
async function publishGraphics() {
|
||||
try {
|
||||
await publishDraft({
|
||||
draftingId: publishForm.id,
|
||||
name: publishForm.pubName,
|
||||
lineId: publishForm.lineId,
|
||||
});
|
||||
publishFormShow.value = false;
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: '发布成功',
|
||||
});
|
||||
} catch (error: any) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.message,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteData(row: any) {
|
||||
operateDisabled.value = true;
|
||||
$q.dialog({
|
||||
title: '确认',
|
||||
message: `确认删除草稿图 "${row.name}" 吗?`,
|
||||
message: `确认删除线路 "${row.name}" 吗?`,
|
||||
cancel: true,
|
||||
})
|
||||
.onOk(async () => {
|
||||
try {
|
||||
await deleteDraft(row.id);
|
||||
await deleteLine(row.id);
|
||||
tableRef.value.requestServerInteraction(); // 刷新列表
|
||||
} catch (error: any) {
|
||||
$q.notify({
|
||||
|
Loading…
Reference in New Issue
Block a user