|
@@ -19,11 +19,30 @@
|
|
|
<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 #shop>
|
|
|
+ <el-option v-for="i in shopList" :key="i._id" :label="i.name" :value="i._id"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #brand>
|
|
|
+ <el-select
|
|
|
+ v-model="form.brand"
|
|
|
+ multiple
|
|
|
+ filterable
|
|
|
+ remote
|
|
|
+ reserve-keyword
|
|
|
+ placeholder="请选择品牌"
|
|
|
+ remote-show-suffix
|
|
|
+ :remote-method="remoteMethod"
|
|
|
+ :loading="loading"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-option v-for="item in brandList" :key="item._id" :label="item.name" :value="item.name" />
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
<template #status>
|
|
|
<el-radio v-for="i in statusList" :key="i._id" :label="i.value">{{ i.label }}</el-radio>
|
|
|
</template>
|
|
|
<template #file>
|
|
|
- <cUpload model="file" :list="form.file" :limit="1" url="/files/usedCar/car/upload" listType="picture-card" @change="onUpload"></cUpload>
|
|
|
+ <cUpload model="file" :list="form.file" :limit="9" url="/files/usedCar/car/upload" listType="picture-card" @change="onUpload"></cUpload>
|
|
|
</template>
|
|
|
</cForm>
|
|
|
</el-col>
|
|
@@ -35,6 +54,7 @@ import { ref, Ref, onMounted, inject } from 'vue';
|
|
|
// NeedChange
|
|
|
import { CarStore } from '@/stores/car';
|
|
|
import { ShopStore } from '@/stores/shop';
|
|
|
+import { BrandStore } from '@/stores/system/brand';
|
|
|
import { DictDataStore } from '@/stores/system/dictData';
|
|
|
import type { IQueryResult } from '@/util/types.util';
|
|
|
import { cloneDeep, get } from 'lodash';
|
|
@@ -52,19 +72,25 @@ const loading: Ref<any> = ref(false);
|
|
|
const store = CarStore();
|
|
|
const dictDataStore = DictDataStore();
|
|
|
const shopStore = ShopStore();
|
|
|
+const brandStore = BrandStore();
|
|
|
const $checkRes = inject('$checkRes') as Function;
|
|
|
|
|
|
// #region 字典
|
|
|
// NeedChange
|
|
|
const statusList: Ref<any> = ref([]);
|
|
|
const shopList: Ref<any> = ref([]);
|
|
|
+const brandList: Ref<any> = ref([]);
|
|
|
|
|
|
const searchOther = async () => {
|
|
|
// 是否使用
|
|
|
const statusResult: IQueryResult = await dictDataStore.query({ code: 'isUse' });
|
|
|
if ($checkRes(statusResult)) statusList.value = statusResult.data;
|
|
|
- const shopResult: IQueryResult = await shopStore.query({ status: '0' });
|
|
|
+ // 店铺信息
|
|
|
+ const shopResult: IQueryResult = await shopStore.query({ is_use: '0' });
|
|
|
if ($checkRes(shopResult)) shopList.value = shopResult.data;
|
|
|
+ // 品牌
|
|
|
+ const brandResult: IQueryResult = await brandStore.query({ is_use: '0' });
|
|
|
+ if ($checkRes(brandResult)) brandList.value = brandResult.data;
|
|
|
};
|
|
|
// #endregion
|
|
|
|
|
@@ -125,7 +151,7 @@ let opera: Ref<any[]> = ref([
|
|
|
{ label: '使用', method: 'changeUse', type: 'success', confirm: true, display: (i) => i.status === '1' },
|
|
|
{ label: '删除', method: 'del', confirm: true, type: 'danger' }
|
|
|
]);
|
|
|
-
|
|
|
+// 转化字典表
|
|
|
const getDict = (data, model) => {
|
|
|
let list;
|
|
|
switch (model) {
|
|
@@ -139,12 +165,26 @@ const getDict = (data, model) => {
|
|
|
const res = list.find((f) => f.value == data);
|
|
|
return get(res, 'label');
|
|
|
};
|
|
|
+// 远程搜索品牌
|
|
|
+const remoteMethod = (query: string) => {
|
|
|
+ if (query) {
|
|
|
+ loading.value = true;
|
|
|
+ setTimeout(() => {
|
|
|
+ loading.value = false;
|
|
|
+ brandList.value = brandList.value.filter((item) => {
|
|
|
+ return item.name.toLowerCase().includes(query.toLowerCase());
|
|
|
+ });
|
|
|
+ }, 200);
|
|
|
+ }
|
|
|
+};
|
|
|
+// 新增弹框
|
|
|
const toAdd = () => {
|
|
|
formFields.value = formFieldsForCreate;
|
|
|
// 所属人是自己,需要把自己的id放进去
|
|
|
form.value = { ...cloneDeep(defaultForm) };
|
|
|
dialog.value.show = true;
|
|
|
};
|
|
|
+// 修改弹框
|
|
|
const toEdit = async (data) => {
|
|
|
formFields.value = formFieldsForUpdate;
|
|
|
form.value = { ...data };
|
|
@@ -153,6 +193,7 @@ const toEdit = async (data) => {
|
|
|
// #endregion
|
|
|
|
|
|
// #region 常规接口
|
|
|
+// 添加/修改
|
|
|
const toSave = async () => {
|
|
|
const data = cloneDeep(form.value);
|
|
|
let res: IQueryResult;
|
|
@@ -163,6 +204,7 @@ const toSave = async () => {
|
|
|
toClose();
|
|
|
}
|
|
|
};
|
|
|
+// 删除
|
|
|
const toDel = async (data) => {
|
|
|
const res = await store.del(data._id);
|
|
|
if ($checkRes(res, true)) {
|
|
@@ -174,22 +216,24 @@ const toDel = async (data) => {
|
|
|
|
|
|
// #region 表单及操作
|
|
|
// NeedChange
|
|
|
-const defaultForm = { status: '0', logo: [] };
|
|
|
+const defaultForm = { status: '0', file: [] };
|
|
|
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: 'brand' },
|
|
|
+ { label: '店铺', model: 'shop', type: 'select' },
|
|
|
+ { label: '品牌', model: 'brand', custom: true },
|
|
|
{ label: '车型', model: 'series' },
|
|
|
{ label: '年份', model: 'year' },
|
|
|
{ label: '车款', model: 'style' },
|
|
|
{ label: '图片', model: 'file', custom: true }
|
|
|
];
|
|
|
const formFieldsForUpdate = [
|
|
|
- { label: '店铺名称', model: 'name' },
|
|
|
- { label: '店铺地址', model: 'address' },
|
|
|
- { label: '联系电话', model: 'tel' },
|
|
|
- { label: '联系人', model: 'contacts' },
|
|
|
+ { label: '店铺', model: 'shop', type: 'select' },
|
|
|
+ { label: '品牌', model: 'brand', custom: true },
|
|
|
+ { label: '车型', model: 'series' },
|
|
|
+ { label: '年份', model: 'year' },
|
|
|
+ { label: '车款', model: 'style' },
|
|
|
{ label: '图片', model: 'file', custom: true }
|
|
|
];
|
|
|
// 关闭弹框
|