Browse Source

修复:车辆二维码的bug

dev
科技小王子 2 months ago
parent
commit
8a08ce1b40
  1. 8
      src/api/hjm/hjmBxLog/model/index.ts
  2. 334
      src/views/hjm/hjmBxLog/components/hjmBxLogEdit.vue
  3. 42
      src/views/hjm/hjmBxLog/index.vue
  4. 4
      src/views/hjm/hjmCar/index.vue

8
src/api/hjm/hjmBxLog/model/index.ts

@ -10,6 +10,14 @@ export interface HjmBxLog {
userId?: number; userId?: number;
// 车辆ID // 车辆ID
carId?: number; carId?: number;
// 车牌号
carNo?: string;
// 操作员
realName?: string;
// 事故类型
accidentType?: string;
// 部门
parentOrganization?: string;
// 保险图片 // 保险图片
image?: string; image?: string;
// 排序(数字越小越靠前) // 排序(数字越小越靠前)

334
src/views/hjm/hjmBxLog/components/hjmBxLogEdit.vue

@ -19,214 +19,190 @@
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' } styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
" "
> >
<a-form-item label="用户ID" name="userId">
<a-input
allow-clear
placeholder="请输入用户ID"
v-model:value="form.userId"
/>
<a-form-item label="车辆编号" name="carNo">
{{ form.carNo }}
</a-form-item> </a-form-item>
<a-form-item label="车辆ID" name="carId">
<a-input
allow-clear
placeholder="请输入车辆ID"
v-model:value="form.carId"
/>
<a-form-item label="事故类型" name="accidentType">
{{ form.accidentType }}
</a-form-item> </a-form-item>
<a-form-item
label="保险图片"
name="image">
<SelectFile
:placeholder="`请选择图片`"
:limit="1"
:data="images"
@done="chooseImage"
@del="onDeleteItem"
/>
</a-form-item>
<a-form-item label="排序(数字越小越靠前)" name="sortNumber">
<a-input-number
:min="0"
:max="9999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
<a-form-item
label="保险图片"
name="image">
<SelectFile
:placeholder="`请选择图片`"
:limit="1"
:data="images"
@done="chooseImage"
@del="onDeleteItem"
/> />
</a-form-item> </a-form-item>
<a-form-item label="备注" name="comments">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入描述"
v-model:value="form.comments"
/>
<a-form-item label="事故描述" name="comments">
{{ form.comments }}
<!-- <a-textarea-->
<!-- :rows="4"-->
<!-- :maxlength="200"-->
<!-- placeholder="请输入描述"-->
<!-- v-model:value="form.comments"-->
<!-- />-->
</a-form-item> </a-form-item>
<a-form-item label="状态, 0正常, 1冻结" name="status">
<a-form-item label="操作员" name="realName">
{{ form.realName }}
</a-form-item>
<a-form-item label="状态" name="status">
<a-radio-group v-model:value="form.status"> <a-radio-group v-model:value="form.status">
<a-radio :value="0">显示</a-radio>
<a-radio :value="1">隐藏</a-radio>
<a-radio :value="0">待处理</a-radio>
<a-radio :value="1">已处理</a-radio>
</a-radio-group> </a-radio-group>
</a-form-item> </a-form-item>
<a-form-item label="是否删除, 0否, 1是" name="deleted">
<a-input
allow-clear
placeholder="请输入是否删除, 0否, 1是"
v-model:value="form.deleted"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</a-form-item>
</a-form> </a-form>
</ele-modal> </ele-modal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addHjmBxLog, updateHjmBxLog } from '@/api/hjm/hjmBxLog';
import { HjmBxLog } from '@/api/hjm/hjmBxLog/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
import {ref, reactive, watch} from 'vue';
import {Form, message} from 'ant-design-vue';
import {assignObject, uuid} from 'ele-admin-pro';
import {addHjmBxLog, updateHjmBxLog} from '@/api/hjm/hjmBxLog';
import {HjmBxLog} from '@/api/hjm/hjmBxLog/model';
import {useThemeStore} from '@/store/modules/theme';
import {storeToRefs} from 'pinia';
import {ItemType} from 'ele-admin-pro/es/ele-image-upload/types';
import {FormInstance} from 'ant-design-vue/es/form';
import {FileRecord} from '@/api/system/file/model';
//
const isUpdate = ref(false);
const useForm = Form.useForm;
//
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
//
const isUpdate = ref(false);
const useForm = Form.useForm;
//
const themeStore = useThemeStore();
const {styleResponsive} = storeToRefs(themeStore);
const props = defineProps<{
//
visible: boolean;
//
data?: HjmBxLog | null;
}>();
const props = defineProps<{
//
visible: boolean;
//
data?: HjmBxLog | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
//
const loading = ref(false);
//
const maxable = ref(true);
//
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
//
const loading = ref(false);
//
const maxable = ref(true);
//
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
//
const form = reactive<HjmBxLog>({
id: undefined,
userId: undefined,
carId: undefined,
image: undefined,
sortNumber: undefined,
comments: undefined,
status: undefined,
deleted: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
hjmBxLogId: undefined,
hjmBxLogName: '',
status: 0,
comments: '',
sortNumber: 100
});
//
const form = reactive<HjmBxLog>({
id: undefined,
userId: undefined,
carId: undefined,
carNo: undefined,
realName: undefined,
accidentType: undefined,
parentOrganization: undefined,
image: undefined,
comments: undefined,
status: undefined,
deleted: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
//
const rules = reactive({
hjmBxLogName: [
{
required: true,
type: 'string',
message: '请填写黄家明_报险记录名称',
trigger: 'blur'
}
]
});
//
const rules = reactive({
hjmBxLogName: [
{
required: true,
type: 'string',
message: '请填写黄家明_报险记录名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const { resetFields } = useForm(form, rules);
const {resetFields} = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateHjmBxLog : addHjmBxLog;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateHjmBxLog : addHjmBxLog;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {
});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if (props.data.image) {
const arr = JSON.parse(props.data.image);
arr.map((item) => {
images.value.push({ images.value.push({
uid: uuid(), uid: uuid(),
url: props.data.image,
url: item.url,
status: 'done' status: 'done'
})
}
isUpdate.value = true;
} else {
isUpdate.value = false;
});
});
} }
isUpdate.value = true;
} else { } else {
resetFields();
isUpdate.value = false;
} }
},
{ immediate: true }
);
} else {
resetFields();
}
},
{immediate: true}
);
</script> </script>

42
src/views/hjm/hjmBxLog/index.vue

@ -21,14 +21,15 @@
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'"> <template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50"/>
<template v-if="record.image" v-for="(item,index) in JSON.parse(record.image)" :key="index">
<a-image :src="item.url" :width="50"/>
</template>
</template> </template>
<template v-if="column.key === 'status'"> <template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">处理</a-tag>
<a-tag v-if="record.status === 1" color="red">处理</a-tag>
<a-tag v-if="record.status === 0" color="red">处理</a-tag>
<a-tag v-if="record.status === 1" color="green">处理</a-tag>
</template> </template>
<template v-if="column.key === 'action'"> <template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a> <a @click="openEdit(record)">修改</a>
<a-divider type="vertical"/> <a-divider type="vertical"/>
<a-popconfirm <a-popconfirm
@ -37,7 +38,6 @@
> >
<a class="ele-text-danger">删除</a> <a class="ele-text-danger">删除</a>
</a-popconfirm> </a-popconfirm>
</a-space>
</template> </template>
</template> </template>
</ele-pro-table> </ele-pro-table>
@ -110,51 +110,53 @@ const columns = ref<ColumnItem[]>([
dataIndex: 'carNo', dataIndex: 'carNo',
key: 'carNo', key: 'carNo',
align: 'center', align: 'center',
width: 120
}, },
{ {
title: '事故类型', title: '事故类型',
dataIndex: 'accidentType', dataIndex: 'accidentType',
key: 'accidentType', key: 'accidentType',
align: 'center', align: 'center',
width: 170
width: 120
}, },
{ {
title: '事故描述',
dataIndex: 'comments',
key: 'comments'
},
{
title: '报险图片',
title: '现场图片',
dataIndex: 'image', dataIndex: 'image',
key: 'image', key: 'image',
align: 'center',
width: 170
align: 'center'
},
{
title: '事故描述',
dataIndex: 'comments',
key: 'comments',
align: 'center'
}, },
{ {
title: '操作员', title: '操作员',
dataIndex: 'realName', dataIndex: 'realName',
key: 'realName', key: 'realName',
align: 'center', align: 'center',
width: 170
width: 120
}, },
{ {
title: '状态', title: '状态',
dataIndex: 'status', dataIndex: 'status',
key: 'status', key: 'status',
align: 'center', align: 'center',
width: 170
width: 120
}, },
{ {
title: '创建时间', title: '创建时间',
dataIndex: 'createTime', dataIndex: 'createTime',
key: 'createTime', key: 'createTime',
align: 'center', align: 'center',
sorter: true
sorter: true,
width: 180
}, },
{ {
title: '操作', title: '操作',
key: 'action', key: 'action',
width: 180,
width: 120,
fixed: 'right', fixed: 'right',
align: 'center', align: 'center',
hideInSetting: true hideInSetting: true
@ -181,7 +183,7 @@ const openMove = () => {
/* 删除单个 */ /* 删除单个 */
const remove = (row: HjmBxLog) => { const remove = (row: HjmBxLog) => {
const hide = message.loading('请求中..', 0); const hide = message.loading('请求中..', 0);
removeHjmBxLog(row.hjmBxLogId)
removeHjmBxLog(row.id)
.then((msg) => { .then((msg) => {
hide(); hide();
message.success(msg); message.success(msg);
@ -206,7 +208,7 @@ const removeBatch = () => {
maskClosable: true, maskClosable: true,
onOk: () => { onOk: () => {
const hide = message.loading('请求中..', 0); const hide = message.loading('请求中..', 0);
removeBatchHjmBxLog(selection.value.map((d) => d.hjmBxLogId))
removeBatchHjmBxLog(selection.value.map((d) => d.id))
.then((msg) => { .then((msg) => {
hide(); hide();
message.success(msg); message.success(msg);

4
src/views/hjm/hjmCar/index.vue

@ -102,7 +102,7 @@ const showMove = ref(false);
// //
const loading = ref(true); const loading = ref(true);
// //
const qrcode = ref<number>();
const qrcode = ref<string>('');
// //
const showQrcode = ref(false); const showQrcode = ref(false);
@ -244,7 +244,7 @@ const openMove = () => {
}; };
const onShare = (row?: HjmCar) => { const onShare = (row?: HjmCar) => {
qrcode.value = row?.id;
qrcode.value = row?.code;
showQrcode.value = true; showQrcode.value = true;
} }

Loading…
Cancel
Save