Commit f0e8b089 by 张立顺

fix(venus-usedcar-h5): eslint报错修复

1 parent 03a7391f
......@@ -3,16 +3,16 @@ import { RouterView } from "vue-router";
</script>
<template>
<RouterView />
<RouterView />
</template>
<style lang="scss">
#app {
width: 100%;
min-height: 100vh;
background-color: var(--color-bg-page);
font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica,
Segoe UI, Arial, Roboto, "PingFang SC", "miui", "Hiragino Sans GB",
"Microsoft Yahei", sans-serif;
width: 100%;
min-height: 100vh;
font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica,
"Segoe UI", Arial, Roboto, "PingFang SC", miui, "Hiragino Sans GB",
"Microsoft Yahei", sans-serif;
background-color: var(--color-bg-page);
}
</style>
export * from "./modules/car";
export * from "./modules/inspect-report";
export * from "./modules/user";
export * from "./modules/work-order";
export * from "./modules/inspect-report";
......@@ -8,6 +8,7 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
ButtonSelect: typeof import('./components/CustomizeForm/buttonSelect.vue')['default']
ButtonSelectAndImageUpload: typeof import('./components/CustomizeForm/buttonSelectAndImageUpload.vue')['default']
CustomizeUploadFile: typeof import('./components/CustomizeForm/customizeUploadFile.vue')['default']
Index: typeof import('./components/CustomizeForm/Index.vue')['default']
Layouts: typeof import('./layouts/index.vue')['default']
......
......@@ -4,7 +4,7 @@ import { computed, ref } from "vue";
const props = defineProps({
item: {
type: Object,
default: () => { },
default: () => {},
},
});
const emit = defineEmits(["update"]);
......@@ -22,7 +22,7 @@ function initData() {
if (props?.item?.inspectionResultVO) {
const inspectionValueList = props?.item?.inspectionResultVO?.inspectionValueList || [];
for (const i of inspectionValueList) {
if (i.valueText && i.interactionType == "button_select") { pickerValue.value.push(i.valueKey) }
if (i.valueText && i.interactionType == "button_select") { pickerValue.value.push(i.valueKey); }
}
}
setupdate();
......@@ -67,20 +67,23 @@ function setupdate() {
</script>
<template>
<div class="buttonSelect">
<div class="title">
<span v-if="item.required === 1" class="isRequired">*</span>
<span>{{ item.nodeName }}</span>
</div>
<div class="selectList">
<div v-for="(col, index) in columnsList" :key="index" class="selectBut"
:class="{ 'pitchOn': pickerValue.includes(col.value) }" @click="handleBut(col)">
{{ col.text }}
<div v-if="pickerValue.includes(col.value)" class="pitchImg"></div>
</div>
</div>
</div>
<template>
<div class="buttonSelect">
<div class="title">
<span v-if="item.required === 1" class="isRequired">*</span>
<span>{{ item.nodeName }}</span>
</div>
<div class="selectList">
<div v-for="(col, index) in columnsList"
:key="index"
class="selectBut"
:class="{ 'pitchOn': pickerValue.includes(col.value) }"
@click="handleBut(col)">
{{ col.text }}
<div v-if="pickerValue.includes(col.value)" class="pitchImg"></div>
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
......
<script setup lang="ts">
import { ref } from "vue";
import { uploadFile } from "@/utils/upload.js";
import { showToast } from "vant";
......@@ -7,7 +8,7 @@ import { showToast } from "vant";
const props = defineProps({
item: {
type: Object,
default: () => { },
default: () => {},
},
});
......@@ -32,7 +33,7 @@ function initData() {
if (props?.item?.inspectionResultVO) {
const inspectionValueList = props?.item?.inspectionResultVO?.inspectionValueList || [];
for (const i of inspectionValueList) {
if (i.valueText && i.interactionType == "image_upload") { pickerValue.value.push(i.valueText) }
if (i.valueText && i.interactionType == "image_upload") { pickerValue.value.push(i.valueText); }
}
}
updateData();
......@@ -79,32 +80,48 @@ function updateData() {
</script>
<template>
<div class="buttonSelect">
<div class="title">
<div class="titleContent">
<span class="isRequired">*</span>
<span>异常图片</span>
</div>
<div class="titleTip">
有损伤请拍摄图片,无损伤请忽略
</div>
</div>
<input ref="fileInputRef" accept="image/*" class="hidden-input" type="file" @change="onFileChange">
<div class="uploadPage">
<div v-if="(validationRules.maxCount || 3) > pickerValue.length" class="uploadBox" @click="pickFile">
<van-icon class="plusBox" color="#999999" name="plus" size="24" />
<div class="uploadTxt">
添加照片
</div>
</div>
<div v-for="(url, index) in pickerValue" :key="index" class="uploadBox">
<div class="deleteBox" @click="handleDelete(url)">
<van-icon color="#999999" name="clear" size="20" />
</div>
<van-image height="96" :src="url" style="border-radius: 8px;" width="96" />
</div>
</div>
</div>
<div class="buttonSelect">
<div class="title">
<div class="titleContent">
<span class="isRequired">*</span>
<span>异常图片</span>
</div>
<div class="titleTip">
有损伤请拍摄图片,无损伤请忽略
</div>
</div>
<input ref="fileInputRef"
accept="image/*"
class="hidden-input"
type="file"
@change="onFileChange">
<div class="uploadPage">
<div v-if="(validationRules.maxCount || 3) > pickerValue.length"
class="uploadBox"
@click="pickFile">
<van-icon class="plusBox"
color="#999999"
name="plus"
size="24" />
<div class="uploadTxt">
添加照片
</div>
</div>
<div v-for="(url, index) in pickerValue"
:key="index"
class="uploadBox">
<div class="deleteBox" @click="handleDelete(url)">
<van-icon color="#999999"
name="clear"
size="20" />
</div>
<van-image height="96"
:src="url"
style="border-radius: 8px;"
width="96" />
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
......
......@@ -4,7 +4,7 @@ import { computed, ref } from "vue";
const props = defineProps({
item: {
type: Object,
default: () => { },
default: () => {},
},
});
......@@ -43,7 +43,7 @@ function initData() {
}
}
onConfirm();
console.log('pickerValue.value2222222222222222222', pickerValue.value);
console.log("pickerValue.value2222222222222222222", pickerValue.value);
}
// 计算属性
......@@ -62,9 +62,6 @@ function onConfirm() {
const picker = pickerValue.value && pickerValue.value.length > 0 ? pickerValue.value[0] : "";
showPicker.value = false;
const selected = columnsList.value.find((col) => col.value === picker) || {};
props.item.value = selected.value || "";
props.item.valueText = selected.text || "";
props.item.valueKey = selected.value || "";
emit("update", {
value: selected.value || "",
valueText: selected.text || "",
......@@ -75,14 +72,26 @@ function onConfirm() {
</script>
<template>
<div>
<van-field v-model="displayValueText" clearable is-link :label="item.nodeName" name="datePicker"
:placeholder="item.placeholder" readonly :required="item.required === 1" @click="showPicker = true" />
<van-popup v-model:show="showPicker" destroy-on-close position="bottom">
<van-picker v-model="pickerValue" :columns="columnsList" :title="item.nodeName" @cancel="showPicker = false"
@confirm="onConfirm" />
</van-popup>
</div>
<div>
<van-field v-model="displayValueText"
clearable
is-link
:label="item.nodeName"
name="datePicker"
:placeholder="item.placeholder"
readonly
:required="item.required === 1"
@click="showPicker = true" />
<van-popup v-model:show="showPicker"
destroy-on-close
position="bottom">
<van-picker v-model="pickerValue"
:columns="columnsList"
:title="item.nodeName"
@cancel="showPicker = false"
@confirm="onConfirm" />
</van-popup>
</div>
</template>
<style lang="scss" scoped></style>
import { ref } from "vue";
import { showToast } from "vant";
interface UseRequestOptions<T> {
......@@ -9,37 +10,37 @@ interface UseRequestOptions<T> {
}
export function useRequest<T>(
requestFn: () => Promise<T>,
options: UseRequestOptions<T> = {},
requestFn: () => Promise<T>,
options: UseRequestOptions<T> = {},
) {
const { immediate = false, initialData, onSuccess, onError } = options;
const { immediate = false, initialData, onSuccess, onError } = options;
const data = ref<T | undefined>(initialData as T);
const loading = ref(false);
const error = ref<unknown>(null);
const data = ref<T | undefined>(initialData as T);
const loading = ref(false);
const error = ref<unknown>(null);
async function execute() {
loading.value = true;
error.value = null;
try {
const result = await requestFn();
data.value = result;
onSuccess?.(result);
return result;
} catch (err) {
error.value = err;
onError?.(err);
throw err;
} finally {
loading.value = false;
}
}
async function execute() {
loading.value = true;
error.value = null;
try {
const result = await requestFn();
data.value = result;
onSuccess?.(result);
return result;
} catch (error_) {
error.value = error_;
onError?.(error_);
throw error_;
} finally {
loading.value = false;
}
}
if (immediate) {
execute();
}
if (immediate) {
execute();
}
return { data, loading, error, execute };
return { data, loading, error, execute };
}
interface UsePaginationOptions<T> {
......@@ -48,57 +49,57 @@ interface UsePaginationOptions<T> {
}
export function usePagination<T>(
requestFn: (page: number, pageSize: number) => Promise<{ list: T[]; total: number }>,
options: UsePaginationOptions<T> = {},
requestFn: (page: number, pageSize: number) => Promise<{ list: T[]; total: number }>,
options: UsePaginationOptions<T> = {},
) {
const { pageSize = 10, onSuccess } = options;
const { pageSize = 10, onSuccess } = options;
const list = ref<T[]>([]) as import("vue").Ref<T[]>;
const total = ref(0);
const page = ref(1);
const loading = ref(false);
const finished = ref(false);
const refreshing = ref(false);
const list = ref<T[]>([]) as import("vue").Ref<T[]>;
const total = ref(0);
const page = ref(1);
const loading = ref(false);
const finished = ref(false);
const refreshing = ref(false);
async function loadMore() {
if (loading.value || finished.value) return;
loading.value = true;
try {
const res = await requestFn(page.value, pageSize);
list.value.push(...res.list);
total.value = res.total;
async function loadMore() {
if (loading.value || finished.value) return;
loading.value = true;
try {
const res = await requestFn(page.value, pageSize);
list.value.push(...res.list);
total.value = res.total;
if (list.value.length >= res.total || res.list.length < pageSize) {
finished.value = true;
} else {
page.value += 1;
}
onSuccess?.(res.list, res.total);
} catch (err) {
showToast("加载失败,请重试");
throw err;
} finally {
loading.value = false;
refreshing.value = false;
}
}
if (list.value.length >= res.total || res.list.length < pageSize) {
finished.value = true;
} else {
page.value += 1;
}
onSuccess?.(res.list, res.total);
} catch (error) {
showToast("加载失败,请重试");
throw error;
} finally {
loading.value = false;
refreshing.value = false;
}
}
async function refresh() {
page.value = 1;
list.value = [];
finished.value = false;
refreshing.value = true;
await loadMore();
}
async function refresh() {
page.value = 1;
list.value = [];
finished.value = false;
refreshing.value = true;
await loadMore();
}
return {
list,
total,
page,
loading,
finished,
refreshing,
loadMore,
refresh,
};
return {
list,
total,
page,
loading,
finished,
refreshing,
loadMore,
refresh,
};
}
......@@ -9,10 +9,11 @@ import router from "./router";
import { initFlexible } from "./utils/flexible";
import { initTokenBridge } from "./utils/webviewBridge";
import "vant/es/toast/style";
import "@assets/styles/reset.scss";
import "@assets/styles/index.scss";
import "@assets/tailwind.css";
import "vant/es/toast/style";
async function bootstrap() {
initFlexible();
......
import { defineStore } from "pinia";
import { ref } from "vue";
import { defineStore } from "pinia";
export const useAppStore = defineStore(
"app",
() => {
const loading = ref(false);
const theme = ref<"light" | "dark">("light");
"app",
() => {
const loading = ref(false);
const theme = ref<"dark" | "light">("light");
function setLoading(val: boolean) {
loading.value = val;
}
function setLoading(val: boolean) {
loading.value = val;
}
function toggleTheme() {
theme.value = theme.value === "light" ? "dark" : "light";
}
function toggleTheme() {
theme.value = theme.value === "light" ? "dark" : "light";
}
return {
loading,
theme,
setLoading,
toggleTheme,
};
},
{
persist: {
pick: ["theme"],
},
},
return {
loading,
theme,
setLoading,
toggleTheme,
};
},
{
persist: {
pick: ["theme"],
},
},
);
......@@ -19,6 +19,6 @@ export interface PageData<T = unknown> {
export interface SelectOption {
label: string;
value: string | number;
value: number | string;
disabled?: boolean;
}
......@@ -4,76 +4,76 @@ import dayjs from "dayjs";
* 格式化价格,单位:万元
*/
export function formatPrice(price: number): string {
if (price >= 10000) {
return `${(price / 10000).toFixed(1)}万`;
}
return `${price}`;
if (price >= 10_000) {
return `${(price / 10_000).toFixed(1)}万`;
}
return `${price}`;
}
/**
* 格式化里程,单位:公里
*/
export function formatMileage(mileage: number): string {
if (mileage >= 10000) {
return `${(mileage / 10000).toFixed(1)}万公里`;
}
return `${mileage}公里`;
if (mileage >= 10_000) {
return `${(mileage / 10_000).toFixed(1)}万公里`;
}
return `${mileage}公里`;
}
/**
* 格式化时间
*/
export function formatDate(date: string | number | Date, format = "YYYY-MM-DD"): string {
return dayjs(date).format(format);
export function formatDate(date: Date | number | string, format = "YYYY-MM-DD"): string {
return dayjs(date).format(format);
}
/**
* 格式化相对时间
*/
export function formatRelativeTime(date: string | number | Date): string {
const now = dayjs();
const target = dayjs(date);
const diffMinutes = now.diff(target, "minute");
export function formatRelativeTime(date: Date | number | string): string {
const now = dayjs();
const target = dayjs(date);
const diffMinutes = now.diff(target, "minute");
if (diffMinutes < 1) return "刚刚";
if (diffMinutes < 60) return `${diffMinutes}分钟前`;
if (diffMinutes < 1) return "刚刚";
if (diffMinutes < 60) return `${diffMinutes}分钟前`;
const diffHours = now.diff(target, "hour");
if (diffHours < 24) return `${diffHours}小时前`;
const diffHours = now.diff(target, "hour");
if (diffHours < 24) return `${diffHours}小时前`;
const diffDays = now.diff(target, "day");
if (diffDays < 30) return `${diffDays}天前`;
const diffDays = now.diff(target, "day");
if (diffDays < 30) return `${diffDays}天前`;
return target.format("YYYY-MM-DD");
return target.format("YYYY-MM-DD");
}
/**
* 防抖
*/
export function debounce<T extends (...args: unknown[]) => unknown>(
fn: T,
delay = 300,
fn: T,
delay = 300,
): (...args: Parameters<T>) => void {
let timer: ReturnType<typeof setTimeout> | null = null;
return function (...args: Parameters<T>) {
if (timer) clearTimeout(timer);
timer = setTimeout(() => fn(...args), delay);
};
let timer: null | ReturnType<typeof setTimeout> = null;
return function (...args: Parameters<T>) {
if (timer) clearTimeout(timer);
timer = setTimeout(() => fn(...args), delay);
};
}
/**
* 节流
*/
export function throttle<T extends (...args: unknown[]) => unknown>(
fn: T,
limit = 300,
fn: T,
limit = 300,
): (...args: Parameters<T>) => void {
let lastTime = 0;
return function (...args: Parameters<T>) {
const now = Date.now();
if (now - lastTime >= limit) {
lastTime = now;
fn(...args);
}
};
let lastTime = 0;
return function (...args: Parameters<T>) {
const now = Date.now();
if (now - lastTime >= limit) {
lastTime = now;
fn(...args);
}
};
}
import GlOssApi from "glsk-oss-jssdk";
import { OSS_CONFIG } from "@/config/oss.ts";
import GlOssApi from "glsk-oss-jssdk";
let ossApi = null;
......
......@@ -376,6 +376,7 @@ onMounted(() => {
<div class="vehicle-plate">
<span>{{ reportData.licensePlate }}</span>
<span class="vehicle-vin">{{ reportData.vin }}</span>
</div>
<div class="vehicle-tags">
<img alt="认证标签"
......
/// <reference types="vite/client" />
// / <reference types="vite/client" />
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!