zs 1 年之前
父节点
当前提交
b6b373891d

+ 2 - 2
src/components/admin-frame/home.vue

@@ -9,7 +9,7 @@
             <transition name="move" mode="out-in">
               <el-row>
                 <component :is="cBreadcrumb" :breadcrumbTitle="route.meta.title"></component>
-                <el-col :span="24" class="container" :style="{ padding: '10px 0' }"><router-view :style="testInfo"></router-view></el-col>
+                <el-col :span="24" class="container" :style="{ padding: '10px 0 0 0' }"><router-view :style="testInfo"></router-view></el-col>
               </el-row>
             </transition>
             <el-backtop target=".content"></el-backtop>
@@ -50,7 +50,7 @@ const testInfo: Ref<any> = ref({
     border-bottom: 1px solid;
   }
   .el-aside {
-    height: 93.3vh;
+    height: 93vh;
     overflow-x: auto;
     overflow-y: auto;
   }

+ 17 - 14
src/components/admin-frame/parts/Sidebar.vue

@@ -3,16 +3,10 @@
   <div id="Sidebar">
     <el-row class="sidebar">
       <el-col :span="24" class="main">
-        <el-col :span="24" class="one">
-          <el-menu
-            class="sidebar-el-menu"
-            :default-active="onRoutes"
-            unique-opened
-            router
-            :background-color="styleInfo.backColor"
-            :text-color="styleInfo.textColor"
-            :active-text-color="styleInfo.activeColor"
-          >
+        <el-col :span="24" class="first">
+          <el-menu class="sidebar-el-menu" :default-active="onRoutes" unique-opened router
+            :background-color="styleInfo.backColor" :text-color="styleInfo.textColor"
+            :active-text-color="styleInfo.activeColor">
             <template v-for="item in items">
               <template v-if="item.type === '0'">
                 <el-sub-menu :index="item._id" :key="item._id">
@@ -23,7 +17,8 @@
                   <template v-for="subItem in item.children">
                     <!-- TODO:这里有问题需要改成自引用输出方式.实现无线嵌套.目前只是最多三级 -->
                     <template v-if="subItem.type === '0'">
-                      <el-sub-menu v-if="subItem.children && subItem.children.length > 0" :index="subItem._id" :key="subItem._id">
+                      <el-sub-menu v-if="subItem.children && subItem.children.length > 0" :index="subItem._id"
+                        :key="subItem._id">
                         <template #title>
                           <i :class="['iconfont', subItem.icon]"></i>
                           <span>{{ subItem.name }}</span>
@@ -96,14 +91,22 @@ watch(
 .sidebar::-webkit-scrollbar {
   width: 0;
 }
+
 .sidebar-el-menu:not(.el-menu--collapse) {
-  width: 201px;
+  // width: 200px;
 }
-.sidebar > ul {
+
+.sidebar>ul {
   height: 100%;
 }
+
 .main {
-  .one {
+  .first {
+    padding: 0 2px 0 0;
+    .el-menu {
+      border-right: none;
+    }
+
     .iconfont {
       font-size: 18px;
       margin: 0 5px 0 0;

+ 5 - 0
src/router/index.ts

@@ -58,6 +58,11 @@ const core = [
     path: '/car',
     meta: { title: '管理员-车源管理' },
     component: () => import('@/views/car/index.vue')
+  },
+  {
+    path: '/estimate',
+    meta: { title: '管理员-车辆估价' },
+    component: () => import('@/views/estimate/index.vue')
   }
 ];
 const router = createRouter({

+ 126 - 8
src/views/car/index.vue

@@ -38,6 +38,33 @@
             <el-option v-for="item in brandList" :key="item._id" :label="item.name" :value="item.name" />
           </el-select>
         </template>
+        <template #use_type>
+          <el-option v-for="i in useTypeList" :key="i._id" :label="i.label" :value="i.value"></el-option>
+        </template>
+        <template #type>
+          <el-option v-for="i in boxTypeList" :key="i._id" :label="i.label" :value="i.value"></el-option>
+        </template>
+        <template #structure>
+          <el-option v-for="i in structureList" :key="i._id" :label="i.label" :value="i.value"></el-option>
+        </template>
+        <template #emission>
+          <el-option v-for="i in emissionList" :key="i._id" :label="i.label" :value="i.value"></el-option>
+        </template>
+        <template #energy>
+          <el-option v-for="i in energyList" :key="i._id" :label="i.label" :value="i.value"></el-option>
+        </template>
+        <template #displacement>
+          <el-option v-for="i in displacementList" :key="i._id" :label="i.label" :value="i.value"></el-option>
+        </template>
+        <template #set>
+          <el-option v-for="i in setList" :key="i._id" :label="i.label" :value="i.value"></el-option>
+        </template>
+        <template #level>
+          <el-option v-for="i in levelList" :key="i._id" :label="i.label" :value="i.value"></el-option>
+        </template>
+        <template #drive>
+          <el-option v-for="i in driveList" :key="i._id" :label="i.label" :value="i.value"></el-option>
+        </template>
         <template #status>
           <el-radio v-for="i in statusList" :key="i._id" :label="i.value">{{ i.label }}</el-radio>
         </template>
@@ -80,17 +107,54 @@ const $checkRes = inject('$checkRes') as Function;
 const statusList: Ref<any> = ref([]);
 const shopList: Ref<any> = ref([]);
 const brandList: Ref<any> = ref([]);
+const useTypeList: Ref<any> = ref([]);
+const boxTypeList: Ref<any> = ref([]);
+const structureList: Ref<any> = ref([]);
+const emissionList: Ref<any> = ref([]);
+const energyList: Ref<any> = ref([]);
+const displacementList: Ref<any> = ref([]);
+const setList: Ref<any> = ref([]);
+const levelList: Ref<any> = ref([]);
+const driveList: Ref<any> = ref([]);
 
 const searchOther = async () => {
+  let res: IQueryResult;
   // 是否使用
-  const statusResult: IQueryResult = await dictDataStore.query({ code: 'isUse' });
-  if ($checkRes(statusResult)) statusList.value = statusResult.data;
+  res = await dictDataStore.query({ code: 'isUse', is_use: '0' });
+  if ($checkRes(res)) statusList.value = res.data;
   // 店铺信息
-  const shopResult: IQueryResult = await shopStore.query({ is_use: '0' });
-  if ($checkRes(shopResult)) shopList.value = shopResult.data;
+  res = await shopStore.query({ is_use: '0' });
+  if ($checkRes(res)) shopList.value = res.data;
   // 品牌
-  const brandResult: IQueryResult = await brandStore.query({ is_use: '0' });
-  if ($checkRes(brandResult)) brandList.value = brandResult.data;
+  res = await brandStore.query({ is_use: '0' });
+  if ($checkRes(res)) brandList.value = res.data;
+  // 车辆使用性质
+  res = await dictDataStore.query({ code: 'useType', is_use: '0' });
+  if ($checkRes(res)) useTypeList.value = res.data;
+  // 变速箱
+  res = await dictDataStore.query({ code: 'boxType', is_use: '0' });
+  if ($checkRes(res)) boxTypeList.value = res.data;
+  // 车身结构
+  res = await dictDataStore.query({ code: 'structure', is_use: '0' });
+  if ($checkRes(res)) structureList.value = res.data;
+  // 排放标准
+  res = await dictDataStore.query({ code: 'emission', is_use: '0' });
+  if ($checkRes(res)) emissionList.value = res.data;
+  // 能源类型
+  res = await dictDataStore.query({ code: 'energy', is_use: '0' });
+  if ($checkRes(res)) energyList.value = res.data;
+  // 排量
+  res = await dictDataStore.query({ code: 'displacement', is_use: '0' });
+  if ($checkRes(res)) displacementList.value = res.data;
+  // 座椅
+  res = await dictDataStore.query({ code: 'set', is_use: '0' });
+  if ($checkRes(res)) setList.value = res.data;
+  // 车辆级别
+  res = await dictDataStore.query({ code: 'level', is_use: '0' });
+  if ($checkRes(res)) levelList.value = res.data;
+  // 驱动方式
+  res = await dictDataStore.query({ code: 'drive', is_use: '0' });
+  if ($checkRes(res)) driveList.value = res.data;
 };
 // #endregion
 
@@ -223,17 +287,71 @@ const form: Ref<any> = ref({ file: [] });
 const formFieldsForCreate = [
   { label: '店铺', model: 'shop', type: 'select' },
   { label: '品牌', model: 'brand', custom: true },
-  { label: '车型', model: 'series' },
   { label: '年份', model: 'year' },
+  { label: '车型', model: 'series' },
   { label: '车款', model: 'style' },
+  { label: '车辆识别VIN', model: 'vin' },
+  { label: '首次上牌时间', model: 'f_time', type: 'date' },
+  { label: '车源地', model: 'place' },
+  { label: '车牌地', model: 'license' },
+  { label: '外观颜色', model: 'out_color' },
+  { label: '内饰颜色', model: 'in_color' },
+  { label: '车辆使用性质', model: 'use_type', type: 'select' },
+  { label: '价格', model: 'price' },
+  { label: '车龄', model: 'age' },
+  { label: '里程', model: 'mileage' },
+  { label: '变速箱', model: 'type', type: 'select' },
+  { label: '车身结构', model: 'structure', type: 'select' },
+  { label: '排放标准', model: 'emission', type: 'select' },
+  { label: '能源类型', model: 'energy', type: 'select' },
+  { label: '排量', model: 'displacement', type: 'select' },
+  { label: '座椅', model: 'set', type: 'select' },
+  { label: '车辆级别', model: 'level', type: 'select' },
+  { label: '驱动方式', model: 'drive', type: 'select' },
+  { label: '油耗', model: 'oil' },
+  { label: '年均保险费', model: 'premium' },
+  { label: '年均保养费', model: 'maintenance' },
+  { label: '百公里加速', model: 'hundred_time' },
+  { label: '轴距', model: 'wheelbase' },
+  { label: '总价', model: 'total_money' },
+  { label: '付款方式', model: 'pay_type' },
+  { label: '首付', model: 'first_pay' },
+  { label: '实付价格', model: 'real_pay' },
   { label: '图片', model: 'file', custom: true }
 ];
 const formFieldsForUpdate = [
   { label: '店铺', model: 'shop', type: 'select' },
   { label: '品牌', model: 'brand', custom: true },
-  { label: '车型', model: 'series' },
   { label: '年份', model: 'year' },
+  { label: '车型', model: 'series' },
   { label: '车款', model: 'style' },
+  { label: '车辆识别VIN', model: 'vin' },
+  { label: '首次上牌时间', model: 'f_time', type: 'date' },
+  { label: '车源地', model: 'place' },
+  { label: '车牌地', model: 'license' },
+  { label: '外观颜色', model: 'out_color' },
+  { label: '内饰颜色', model: 'in_color' },
+  { label: '车辆使用性质', model: 'use_type', type: 'select' },
+  { label: '价格', model: 'price' },
+  { label: '车龄', model: 'age' },
+  { label: '里程', model: 'mileage' },
+  { label: '变速箱', model: 'type', type: 'select' },
+  { label: '车身结构', model: 'structure', type: 'select' },
+  { label: '排放标准', model: 'emission', type: 'select' },
+  { label: '能源类型', model: 'energy', type: 'select' },
+  { label: '排量', model: 'displacement', type: 'select' },
+  { label: '座椅', model: 'set', type: 'select' },
+  { label: '车辆级别', model: 'level', type: 'select' },
+  { label: '驱动方式', model: 'drive', type: 'select' },
+  { label: '油耗', model: 'oil' },
+  { label: '年均保险费', model: 'premium' },
+  { label: '年均保养费', model: 'maintenance' },
+  { label: '百公里加速', model: 'hundred_time' },
+  { label: '轴距', model: 'wheelbase' },
+  { label: '总价', model: 'total_money' },
+  { label: '付款方式', model: 'pay_type' },
+  { label: '首付', model: 'first_pay' },
+  { label: '实付价格', model: 'real_pay' },
   { label: '图片', model: 'file', custom: true }
 ];
 // 关闭弹框

+ 207 - 0
src/views/estimate/index.vue

@@ -0,0 +1,207 @@
+<template>
+  <el-row>
+    <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
+      <el-col :span="24" class="one">
+        <cSearch :is_title="false" :is_search="true" :fields="fields" @search="toSearch">
+          <template #is_use>
+            <el-option v-for="i in statusList" :key="i._id" :label="i.label" :value="i.value"></el-option>
+          </template>
+        </cSearch>
+      </el-col>
+      <el-col :span="24" class="two">
+        <cButton @toAdd="toAdd"> </cButton>
+      </el-col>
+      <el-col :span="24" class="thr">
+        <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @edit="toEdit" @del="toDel" @changeUse="toChangeUse"> </cTable>
+      </el-col>
+    </el-col>
+  </el-row>
+  <cDialog :dialog="dialog" @toClose="toClose">
+    <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
+      <cForm :span="24" :fields="formFields" :form="form" :rules="{}" @save="toSave" label-width="auto">
+        <template #is_use>
+          <el-radio v-for="i in statusList" :key="i._id" :label="i.value">{{ i.label }}</el-radio>
+        </template>
+        <template #logo>
+          <cUpload model="logo" :list="form.logo" :limit="1" url="/files/usedCar/shop/upload" listType="picture-card" @change="onUpload"></cUpload>
+        </template>
+        <template #file>
+          <cUpload model="file" :list="form.file" :limit="1" url="/files/usedCar/shop/upload" listType="picture-card" @change="onUpload"></cUpload>
+        </template>
+      </cForm>
+    </el-col>
+  </cDialog>
+</template>
+
+<script setup lang="ts">
+import { ref, Ref, onMounted, inject } from 'vue';
+// NeedChange
+import { ShopStore } from '@/stores/shop';
+import { DictDataStore } from '@/stores/system/dictData';
+import type { IQueryResult } from '@/util/types.util';
+import { cloneDeep, get } from 'lodash';
+import baseStore from '@/stores/counter';
+const user = ref(baseStore.state.user);
+onMounted(async () => {
+  loading.value = true;
+  await searchOther();
+  await search({ skip, limit });
+  loading.value = false;
+});
+
+const loading: Ref<any> = ref(false);
+// NeedChange
+const store = ShopStore();
+const dictDataStore = DictDataStore();
+const $checkRes = inject('$checkRes') as Function;
+
+// #region 字典
+// NeedChange
+const statusList: Ref<any> = ref([]);
+
+const searchOther = async () => {
+  const statusResult: IQueryResult = await dictDataStore.query({ code: 'isUse' });
+  if ($checkRes(statusResult)) {
+    statusList.value = statusResult.data;
+  }
+};
+// #endregion
+
+// #region 查询相关
+let list: Ref<any> = ref([]);
+let total: Ref<number> = ref(0);
+let skip = 0;
+let limit = inject('$limit') as number;
+let searchForm: Ref<any> = ref({});
+
+const search = async (e: { skip: number; limit: number }) => {
+  const info = { skip: e.skip, limit: e.limit, ...searchForm.value };
+  const res: IQueryResult = await store.query(info);
+  if (res.errcode == '0') {
+    list.value = res.data;
+    total.value = res.total;
+  }
+};
+const toSearch = (query) => {
+  searchForm.value = query;
+  search({ skip, limit });
+};
+const toChangeUse = async (data) => {
+  let status = '0';
+  switch (data.is_use) {
+    case '0':
+      status = '1';
+      break;
+    case '1':
+      status = '0';
+      break;
+    default:
+      break;
+  }
+  const udata = { _id: data._id, is_use: status };
+  const res = await store.update(udata);
+  if ($checkRes(res, true)) {
+    search({ skip: 0, limit });
+  }
+};
+// #endregion
+
+// #region 表格及操作
+// NeedChange
+let fields: Ref<any[]> = ref([
+  { label: '店铺名称', model: 'name', isSearch: true },
+  { label: '店铺地址', model: 'address' },
+  { label: '联系电话', model: 'tel' },
+  { label: '联系人', model: 'contacts' },
+  { label: '状态', model: 'is_use', format: (i) => getDict(i, 'is_use'), isSearch: true, type: 'select' }
+]);
+// 操作
+let opera: Ref<any[]> = ref([
+  { label: '修改', method: 'edit' },
+  { label: '禁用', method: 'changeUse', type: 'warning', confirm: true, display: (i) => i.is_use === '0' },
+  { label: '使用', method: 'changeUse', type: 'success', confirm: true, display: (i) => i.is_use === '1' },
+  { label: '删除', method: 'del', confirm: true, type: 'danger' }
+]);
+
+const getDict = (data, model) => {
+  let list;
+  switch (model) {
+    case 'is_use':
+      list = statusList.value;
+      break;
+    default:
+      break;
+  }
+  if (!list) return;
+  const res = list.find((f) => f.value == data);
+  return get(res, 'label');
+};
+const toAdd = () => {
+  formFields.value = formFieldsForCreate;
+  // 所属人是自己,需要把自己的id放进去
+  form.value = { ...cloneDeep(defaultForm) };
+  dialog.value.show = true;
+};
+const toEdit = async (data) => {
+  formFields.value = formFieldsForUpdate;
+  form.value = { ...data };
+  dialog.value.show = true;
+};
+// #endregion
+
+// #region 常规接口
+const toSave = async () => {
+  const data = cloneDeep(form.value);
+  let res: IQueryResult;
+  if (get(data, '_id')) res = await store.update(data);
+  else res = await store.create(data);
+  if ($checkRes(res, true)) {
+    search({ skip: 0, limit });
+    toClose();
+  }
+};
+const toDel = async (data) => {
+  const res = await store.del(data._id);
+  if ($checkRes(res, true)) {
+    search({ skip: 0, limit });
+  }
+};
+
+// #endregion
+
+// #region 表单及操作
+// NeedChange
+const defaultForm = { is_use: '0', logo: [] };
+const formFields: Ref<any> = ref();
+const dialog: Ref<any> = ref({ title: '数据信息', show: false, type: '1' });
+const form: Ref<any> = ref({ file: [] });
+const formFieldsForCreate = [
+  { label: '店铺名称', model: 'name' },
+  { label: '店铺地址', model: 'address' },
+  { label: '联系电话', model: 'tel' },
+  { label: '联系人', model: 'contacts' },
+  { label: 'logo', model: 'logo', custom: true },
+  { label: '营业执照', model: 'file', custom: true }
+];
+const formFieldsForUpdate = [
+  { label: '店铺名称', model: 'name' },
+  { label: '店铺地址', model: 'address' },
+  { label: '联系电话', model: 'tel' },
+  { label: '联系人', model: 'contacts' },
+  { label: 'logo', model: 'logo', custom: true },
+  { label: '营业执照', model: 'file', custom: true }
+];
+// 关闭弹框
+const toClose = () => {
+  form.value = {};
+  dialog.value.show = false;
+};
+const onUpload = (e: { model: string; value: Array<[]> }) => {
+  console.log(e);
+  const { model, value } = e;
+  form.value[model] = value;
+};
+// #endregion
+</script>
+
+<style scoped></style>