|
@@ -6,23 +6,40 @@
|
|
|
*/
|
|
|
|
|
|
import { ref } from 'vue';
|
|
|
-import { ElIcon, ElMessage } from 'element-plus';
|
|
|
-import { Delete, EditPen, Picture as IconPicture, Search } from '@element-plus/icons-vue';
|
|
|
+import { ElCol, ElIcon } from 'element-plus';
|
|
|
+import { EditPen, Picture as IconPicture, Plus, Search } from '@element-plus/icons-vue';
|
|
|
import * as api from '/@/views/computer-information/api';
|
|
|
import { useRouter } from 'vue-router';
|
|
|
import { usePagination } from '/@/utils/usePagination';
|
|
|
import { useTableData } from '/@/utils/useTableData';
|
|
|
+import EditComputerInfo from '/@/views/computer-information/components/EditComputerInfo.vue';
|
|
|
+import { useResponse } from '/@/utils/useResponse';
|
|
|
+import CreateComputer from '/@/views/computer-information/components/CreateComputer.vue';
|
|
|
|
|
|
const router = useRouter();
|
|
|
const loading = ref();
|
|
|
+
|
|
|
+const showDialog = ref(false);
|
|
|
+const isDrawerVisible = ref(false);
|
|
|
+
|
|
|
+const computerInfo = ref([]);
|
|
|
+const shopOptions = ref([]);
|
|
|
+const userOptions = ref([]);
|
|
|
+
|
|
|
const { tableOptions, handlePageChange } = usePagination(fetchCardData);
|
|
|
+tableOptions.value.limit = 12;
|
|
|
|
|
|
async function fetchCardData() {
|
|
|
const query = {
|
|
|
page: tableOptions.value.page,
|
|
|
limit: tableOptions.value.limit,
|
|
|
};
|
|
|
- await useTableData(api.getCardData, query, tableOptions);
|
|
|
+ await useTableData(api.getCardData, query, tableOptions,loading);
|
|
|
+}
|
|
|
+
|
|
|
+// 打开创建弹窗
|
|
|
+async function addComputer() {
|
|
|
+ showDialog.value = true;
|
|
|
}
|
|
|
|
|
|
const checkItem = (item) => {
|
|
@@ -35,20 +52,13 @@ const checkItem = (item) => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
-// 编辑和删除的事件处理
|
|
|
-const editItem = (item) => {
|
|
|
- router.push({
|
|
|
- path: '/computer/edit',
|
|
|
- query: { computerNumber: item.computerNumber },
|
|
|
- });
|
|
|
-};
|
|
|
-
|
|
|
-const deleteItem = (item) => {
|
|
|
- ElMessage({
|
|
|
- message: `删除 ${item.computerNumber}`,
|
|
|
- type: 'warning',
|
|
|
- });
|
|
|
-};
|
|
|
+async function editItem(item) {
|
|
|
+ const res = await useResponse(item.id, api.getComputerDetailOverview);
|
|
|
+ computerInfo.value = res.data;
|
|
|
+ if (computerInfo.value) {
|
|
|
+ isDrawerVisible.value = true; // 显示 Drawer
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
// 处理图片地址
|
|
|
const getImageUrl = (images) => {
|
|
@@ -56,17 +66,53 @@ const getImageUrl = (images) => {
|
|
|
return images.length > 0 ? images[0].image_url : '';
|
|
|
};
|
|
|
|
|
|
+async function fetchShopOptions() {
|
|
|
+ try {
|
|
|
+ const resp = await useResponse(null, api.getShopList);
|
|
|
+ shopOptions.value = resp.data.map((item: any) => {
|
|
|
+ return { value: item.id, label: item.platformNumber };
|
|
|
+ });
|
|
|
+ } catch (e) {
|
|
|
+ console.log('error', e);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+async function fetchUserOptions() {
|
|
|
+ try {
|
|
|
+ const resp = await useResponse(null, api.getUserList);
|
|
|
+ userOptions.value = resp.data.map((item: any) => {
|
|
|
+ return { value: item.id, label: item.name };
|
|
|
+ });
|
|
|
+ } catch (e) {
|
|
|
+ console.log('error', e);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
fetchCardData();
|
|
|
+ fetchShopOptions();
|
|
|
+ fetchUserOptions();
|
|
|
});
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
+ <!-- 标题区域 -->
|
|
|
+ <el-card class="my-2.5" shadow="never" style="border: none;">
|
|
|
+ <div class="flex justify-between items-baseline">
|
|
|
+ <div>
|
|
|
+ <span class="font-bold text-xl">电脑信息概览</span>
|
|
|
+ <el-divider class=" text-3xl" direction="vertical"/>
|
|
|
+ </div>
|
|
|
+ <span>
|
|
|
+ <el-button :icon="Plus" text bg type="primary" @click="addComputer">添 加</el-button>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
<!-- 卡片展示区域 -->
|
|
|
- <el-card shadow="never" style="border: none; min-height: 750px; position: relative;">
|
|
|
+ <el-card v-loading="loading" shadow="never" style="border: none; min-height: 820px; position: relative">
|
|
|
<div class="card-container">
|
|
|
<el-row :gutter="20">
|
|
|
- <el-col v-for="(item, index) in tableOptions.data" :key="index" :span="4" class="my-2.5">
|
|
|
+ <el-col v-for="(item, index) in tableOptions.data" :key="index" :lg="6" :md="8" :sm="8" :xl="4" :xs="12" class="my-2.5">
|
|
|
<el-card class="item-card" shadow="hover">
|
|
|
<el-image :src="getImageUrl(item.images)" alt="电脑图片" class="card-image">
|
|
|
<template #error>
|
|
@@ -77,28 +123,28 @@ onMounted(() => {
|
|
|
</el-image>
|
|
|
<div class="card-content">
|
|
|
<div>
|
|
|
- <span style="color: #808d97;font-weight: 500">电脑编号: </span>
|
|
|
+ <span style="color: #808d97; font-weight: 500">电脑编号: </span>
|
|
|
<span style="font-weight: 500">{{ item.computerNumber }}</span>
|
|
|
</div>
|
|
|
<div>
|
|
|
- <span style="color: #808d97;font-weight: 500">所属店铺: </span>
|
|
|
+ <span style="color: #808d97; font-weight: 500">所属店铺: </span>
|
|
|
<span style="font-weight: 500">{{ item.shopName }}</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="card-footer">
|
|
|
- <el-button :icon="Search" circle text bg type="primary" @click="checkItem(item)" />
|
|
|
- <el-button :icon="EditPen" circle text bg type="warning" @click="editItem(item)" />
|
|
|
- <el-button :icon="Delete" circle text bg type="danger" @click="deleteItem(item)" />
|
|
|
+ <el-button :icon="Search" bg circle text type="primary" @click="checkItem(item)" />
|
|
|
+ <el-button :icon="EditPen" bg circle text type="warning" @click="editItem(item)" />
|
|
|
+ <!--<el-button :icon="Delete" circle text bg type="danger" @click="deleteItem(item)" />-->
|
|
|
</div>
|
|
|
</el-card>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
|
- <div class="pagination-container" style="position: absolute; right: 32px; bottom: 32px;">
|
|
|
+ <div class="pagination-container" style="position: absolute; right: 32px; bottom: 32px">
|
|
|
<el-pagination
|
|
|
v-model:current-page="tableOptions.page"
|
|
|
v-model:page-size="tableOptions.limit"
|
|
|
- :page-sizes="[6, 12, 24,36,48,60]"
|
|
|
+ :page-sizes="[6, 12, 24, 36, 48, 60]"
|
|
|
:total="tableOptions.total"
|
|
|
background
|
|
|
layout="sizes, prev, pager, next, total"
|
|
@@ -106,6 +152,10 @@ onMounted(() => {
|
|
|
/>
|
|
|
</div>
|
|
|
</el-card>
|
|
|
+ <!-- 新增 Dialog -->
|
|
|
+ <CreateComputer v-model="showDialog" :shopOptions :userOptions @refresh="fetchCardData"></CreateComputer>
|
|
|
+ <!-- 编辑 Drawer -->
|
|
|
+ <EditComputerInfo v-if="isDrawerVisible" v-model="isDrawerVisible" :shopOptions="shopOptions" :userOptions="userOptions" :computerInfo :computerNumber="computerInfo.computerNumber" />
|
|
|
</template>
|
|
|
|
|
|
<style lang="scss" scoped>
|