Skip to content

Commit

Permalink
fix(lostFound & suit):修复了失物招领 API 中的类型问题和正装的页面的 CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianci-King committed Feb 28, 2024
1 parent d30f8ac commit 5e58aa5
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 94 deletions.
Binary file added dist.zip
Binary file not shown.
15 changes: 8 additions & 7 deletions src/apis/LostfoundAPI/getRecords.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import request from "../request";

type GetRecordsData = {
interface GetRecordsData<Ttype> {
page_num: number;
page_size: number;
};
lost_or_found: Ttype;
}

type GetRecordsResult = Common.IResponse<{
data: LostfoundAPI.Item[];
total_page_num: number
type GetRecordsResult<Ttype> = Common.IResponse<{
data: Ttype extends "失物" ? LostfoundAPI.LostItem[] : LostfoundAPI.FoundItem[];
total_page_num: number;
}>;

const getRecordsAPI = (params: GetRecordsData) => {
return request<GetRecordsResult>({
const getRecordsAPI = <Ttype extends "失物" | "寻物">(params: GetRecordsData<Ttype>) => {
return request<GetRecordsResult<Ttype>>({
method: "GET",
url: "/api/foru/lost",
params
Expand Down
41 changes: 34 additions & 7 deletions src/apis/LostfoundAPI/typing.d.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,48 @@
declare namespace LostfoundAPI {
interface Item {
id: number;

/** 类型, false: 寻物启事, true: 失物招领 */
type: boolean;

/** 物品名称 */
item_name: string;

/** 校区 */
campus: string;

/** 物品分类 */
kind: string;

/** 公布时间 */
publish_time: string;
/** 类型, false: 丢失, true: 招领 */
type: boolean;
/** 是否已处理 */
is_processed: boolean;
/** 内容 */
content: string;
publisher: string;

/** 物品介绍 */
introduction: string;

/** 遗失/拾得时间 */
lost_or_found_time: string;

/** 遗失/拾得地点 */
lost_or_found_place: string;

img1: null | string;
img2: null | string;
img3: null | string;
}

/** 寻物启事 */
interface FoundItem extends Item {
/** 联系方式 */
contact: string;

/** 发布组织 */
publisher: string;
}

/** 失物招领 */
interface LostItem extends Item {
/** 领取地点 */
pickup_place: string;
}
}
2 changes: 1 addition & 1 deletion src/apis/LostfoundAPI/updateRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import request from "../request";

type UpdateRecordData = Omit<
LostfoundAPI.Item,
"publish_time" | "is_processed"
"id" | "publish_time" | "is_processed"
>;

type UpdateRecordResult = Common.IResponse<null>;
Expand Down
2 changes: 1 addition & 1 deletion src/components/FoundForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const emit = defineEmits(["finish", "delete", "open"]);
const message = useMessage();
const formData = ref<Partial<LostfoundAPI.FoundItem>>(initialValue?.value || {
kind: "其他",
type: true,
type: false,
campus: "朝晖"
});
const kindOptions = ref<{ label: string; value: string }[]>();
Expand Down
4 changes: 2 additions & 2 deletions src/components/InformationForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ const handleDelete = () => {
<n-space style="width: 100%">
<n-form style="max-width: 400px">
<n-form-item label="标题">
<n-input v-model:value="formData.title" style="width: 400px" maxlength="15"/>
<n-input v-model:value="formData.title" style="width: 400px" maxlength="9999999"/>
</n-form-item>
<n-form-item label="内容">
<n-input type="textarea" v-model:value="formData.content" :autosize="{ minRows: 5 }"
<n-input type="textarea" v-model:value="formData.content" :autosize="{ minRows: 5 } " maxlength="9999999"
style="width: 400px" />
</n-form-item>
<n-form-item label="上传图片 (最多3张)">
Expand Down
2 changes: 1 addition & 1 deletion src/components/LostForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const emit = defineEmits(["finish", "delete", "open"]);
const message = useMessage();
const formData = ref<Partial<LostfoundAPI.LostItem>>(initialValue?.value || {
kind: "其他",
type: false,
type: true,
campus: "朝晖",
});
const kindOptions = ref<{ label: string; value: string }[]>();
Expand Down
150 changes: 75 additions & 75 deletions src/pages/SuitApply/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,76 +47,76 @@
size="large"
:round="true"
@click="$router.push('/suitFaq')"
>&ensp;&ensp;问答页面&ensp;&ensp;</n-button
>&ensp;&ensp;问答页面&ensp;&ensp;</n-button
>
<n-button type="primary" size="large" :round="true" @click="showPublish()"
>发布正装信息</n-button
>发布正装信息</n-button
>
<n-button
type="primary"
size="large"
:round="true"
@click="$router.push('/suitManger')"
>&ensp;&ensp;审批清点&ensp;&ensp;</n-button
>&ensp;&ensp;审批清点&ensp;&ensp;</n-button
>
</n-space>
<div style="display: flex; margin-left: 1.8vw; margin-top: -15vh">
<div style="display: flex; margin-left: 20px; margin-top: -100px">
<n-table :bordered="false" :single-line="false" style="width: 70%">
<thead>
<tr>
<th>物资</th>
<th>类别</th>
<th>库存</th>
<th>已借出</th>
<th>操作</th>
</tr>
<tr>
<th>物资</th>
<th>类别</th>
<th>库存</th>
<th>已借出</th>
<th>操作</th>
</tr>
</thead>
<!-- 表格代码 -->
<tbody>
<tr v-for="item in suitList" :key="item.name">
<td>{{ item.name }}</td>
<td>正装</td>
<!-- 类别默认显示正装 -->
<td>{{ item.totalStock }}</td>
<td>{{ item.totalBorrowed }}</td>
<td>
<n-button text @click="showEditorSuit(item)">编辑</n-button>
<n-button
style="margin-left: 2vw; color: red"
text
@click="deleteSuit(item)"
>删除</n-button
<tr v-for="item in suitList" :key="item.name">
<td>{{ item.name }}</td>
<td>正装</td>
<!-- 类别默认显示正装 -->
<td>{{ item.totalStock }}</td>
<td>{{ item.totalBorrowed }}</td>
<td>
<n-button text @click="showEditorSuit(item)">编辑</n-button>
<n-button
style="margin-left: 2vw; color: red"
text
@click="deleteSuit(item)"
>删除</n-button
>
<n-modal v-model:show="showModalConfirmDelete">
<n-card
style="width: 400px"
title="确认删除"
:bordered="false"
size="huge"
role="dialog"
aria-modal="true"
>
<n-modal v-model:show="showModalConfirmDelete">
<n-card
style="width: 400px"
title="确认删除"
:bordered="false"
size="huge"
role="dialog"
aria-modal="true"
>
<span>同步删除关于该物资的统计数据,借用记录会保留</span>
<div
style="
<span>同步删除关于该物资的统计数据,借用记录会保留</span>
<div
style="
display: flex;
justify-content: space-around;
margin-top: 30px;
"
>
<n-button
type="primary"
@click="deleteConfirmSuit(deleteItem)"
>确认删除</n-button
>
<n-button
type="primary"
@click="deleteConfirmSuit(deleteItem)"
>确认删除</n-button
>
<n-button @click="showModalConfirmDelete = false"
>取消</n-button
>
</div>
</n-card>
</n-modal>
</td>
</tr>
<n-button @click="showModalConfirmDelete = false"
>取消</n-button
>
</div>
</n-card>
</n-modal>
</td>
</tr>
</tbody>
</n-table>
<n-modal v-model:show="showModal">
Expand Down Expand Up @@ -181,37 +181,37 @@
<n-button
@click="addSpec"
style="margin-left: 30%; margin-top: -20%"
>+</n-button
>+</n-button
>
</n-form-item>
<n-form-item
style="display: flex; justify-content: center; margin-top: 4vh"
size="small"
>
<n-table :bordered="true" :single-line="false" style="width: 30vw">
<n-table :bordered="true" :single-line="false" style="width: 500px">
<thead>
<tr>
<th>尺码</th>
<th>库存</th>
<th v-if="showModalEditorSuit">已借出</th>
<th>操作</th>
</tr>
<tr>
<th>尺码</th>
<th>库存</th>
<th v-if="showModalEditorSuit">已借出</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="item in publishSuitForm.specs" :key="item.spec">
<td>{{ item.spec }}</td>
<td>{{ item.stock }}</td>
<td v-if="showModalEditorSuit">{{ item.borrowed }}</td>
<td>
<n-button text @click="showEditor(item)">修改</n-button>
<n-button
style="margin-left: 2vw; color: red"
text
@click="deleteSpecConfirm(item)"
>删除</n-button
>
</td>
</tr>
<tr v-for="item in publishSuitForm.specs" :key="item.spec">
<td>{{ item.spec }}</td>
<td>{{ item.stock }}</td>
<td v-if="showModalEditorSuit">{{ item.borrowed }}</td>
<td>
<n-button text @click="showEditor(item)">修改</n-button>
<n-button
style="margin-left: 2vw; color: red"
text
@click="deleteSpecConfirm(item)"
>删除</n-button
>
</td>
</tr>
</tbody>
</n-table>
</n-form-item>
Expand All @@ -222,13 +222,13 @@
v-if="showModalPublish"
type="primary"
@click="publishSuitFunction(publishSuitForm)"
>确认</n-button
>确认</n-button
>
<n-button
v-else
type="primary"
@click="setSuitFunction(publishSuitForm)"
>确认</n-button
>确认</n-button
>
<n-button
@click="
Expand All @@ -238,7 +238,7 @@
cleanPublishSuitForm();
"
style="margin-left: 10vh"
>取消</n-button
>取消</n-button
>
</div>
</template>
Expand Down Expand Up @@ -309,7 +309,7 @@
style="display: flex; justify-content: space-around; margin-top: 30px"
>
<n-button type="primary" @click="deleteSpec(deleteSpecItem)"
>确认删除</n-button
>确认删除</n-button
>
<n-button @click="showModalConfirmDeleteSpec = false">取消</n-button>
</div>
Expand Down

0 comments on commit 5e58aa5

Please sign in to comment.