修改图表数据展示

master
夜笙歌 2 years ago
parent d1798d3dad
commit efc04c07a0

@ -0,0 +1,10 @@
import request from "@/utils/request";
export function uploadImg(data) {
return request({
url: '/system/user/profile/avatar',
method: 'post',
data: data,
isNoLang:true,
})
}

@ -105,7 +105,8 @@ export function uploadAvatar(data) {
return request({ return request({
url: '/system/user/profile/avatar', url: '/system/user/profile/avatar',
method: 'post', method: 'post',
data: data data: data,
isNoLang:true,
}) })
} }

@ -55,13 +55,15 @@ service.interceptors.request.use(config => {
config.url = url; config.url = url;
} }
if (config.method === 'post') { if (config.method === 'post') {
config.data = typeof config.data === 'object' ? JSON.stringify({ if (!config.isNoLang) {
...config.data, config.data = typeof config.data === 'object' ? JSON.stringify({
lang ...config.data,
}) : JSON.stringify({ lang
...JSON.parse(config.data || '{}'), }) : JSON.stringify({
lang ...JSON.parse(config.data || '{}'),
}); lang
});
}
} }
if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put')) { if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put')) {
const requestObj = { const requestObj = {

@ -1,127 +1,31 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="form" inline label-width="80px"> <el-form :model="form" label-width="120px">
<el-form-item label="所属车队"> <el-form-item label="Activity form">
<el-select v-model="form.carQueue" placeholder="请选择" @change="carQueueChange"> <el-upload
<el-option :http-request="requestUpload"
v-for="item in carQueueOption" :show-file-list="false"
:key="item.value" action="#"
:label="item.label" class="avatar-uploader"
:value="item.value" >
/> <img v-if="imageUrl" :src="imageUrl" class="avatar"/>
</el-select> <el-icon v-else class="avatar-uploader-icon">
<Plus/>
</el-icon>
</el-upload>
</el-form-item> </el-form-item>
<el-form-item label="车牌号"> <el-form-item>
<el-select v-model="form.licenseNumber" :disabled='isLicenseNumber' placeholder="请选择" <el-button type="primary" @click="onSubmit">Create</el-button>
@change="licenseNumberChange"> <el-button>Cancel</el-button>
<el-option
v-for="item in licenseNumberOption"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div style="display: inline-block;width: 560px;height:auto">
<div class="bg" style="margin-right: 40px;">
<div v-for="(item,index) in tireArrangement">
<div class="item" @click="tyreClick((index+1)+'-1-1',((index+1)+'排左侧外胎'))">
<div
:style="`background-color:${backgroundColorState((index+1)+'-1-1')};border-color:${borderColorState((index+1)+'-1-1')}`"
class="circle">
<span>{{ index + 1 }}排左侧外胎</span>
</div>
</div>
<div class="item" @click="tyreClick((index+1)+'-1-2',((index+1)+'排左侧内胎'))">
<div
:style="`${item === 2? '':'display:none;'}background-color:${backgroundColorState((index+1)+'-1-2')};border-color:${borderColorState((index+1)+'-1-2')}`"
class="circle">
<span>{{ index + 1 }}排左侧内胎</span>
</div>
</div>
</div>
</div>
<div class="bg">
<div v-for="(item,index) in tireArrangement">
<div class="item" @click="tyreClick((index+1)+'-2-2',((index+1)+'排右侧内胎'))">
<div
:style="`${item === 2? '':'display:none;'}background-color:${backgroundColorState((index+1)+'-2-2')};border-color:${borderColorState((index+1)+'-2-2')}`"
class="circle">
<span>{{ index + 1 }}排右侧内胎</span>
</div>
</div>
<div class="item" @click="tyreClick((index+1)+'-2-1',((index+1)+'排右侧外胎'))">
<div
:style="`background-color:${backgroundColorState((index+1)+'-2-1')};border-color:${borderColorState((index+1)+'-2-1')}`"
class="circle">
<span>{{ index + 1 }}排右侧外胎</span>
</div>
</div>
</div>
</div>
</div>
<div v-if="!!nowClick"
style="display: inline-block;width: calc(100% - 600px);margin-left: 40px;max-width:400px;height: 200px;vertical-align:top;">
<el-form ref="form22" :model="form2" :rules="rules" inline label-width="120px">
<el-form-item label="当前轮胎位置" style="width: 100%;">
{{ form2.location }}
</el-form-item>
<el-form-item label="轮胎编号" prop="outerTireNumber" style="width: 100%;">
<!-- <el-select-->
<!-- v-model="value"-->
<!-- :loading="loading"-->
<!-- :remote-method="outerTireNumberSearchClick"-->
<!-- filterable-->
<!-- multiple-->
<!-- placeholder="Please enter a keyword"-->
<!-- remote-->
<!-- reserve-keyword-->
<!-- >-->
<!-- <el-option-->
<!-- v-for="item in outerTireNumberOption"-->
<!-- :key="item.value"-->
<!-- :label="item.label"-->
<!-- :value="item.value"-->
<!-- />-->
<!-- </el-select>-->
<el-input v-model="form2.outerTireNumber">
<template #append>
<el-button :icon="Search" @click="outerTireNumberSearchClick"/>
</template>
</el-input>
</el-form-item>
<el-form-item label="轮胎品牌" style="width: 100%;">
<el-input v-model="form2.brand" disabled/>
</el-form-item>
<el-form-item label="规格型号" style="width: 100%;">
<el-input v-model="form2.size" disabled/>
</el-form-item>
<el-form-item label="传感器ID" style="width: 100%;">
<el-input v-model="form2.sensorId"/>
</el-form-item>
<el-form-item label="里程" style="width: 100%;">
<el-input-number v-model="form2.carOnlineMileage"/>
</el-form-item>
<el-form-item label="当前花纹深度" style="width: 100%;">
<el-input-number v-model="form2.currentTextureDepth" :precision="2" :step="0.1"/>
&nbsp; &nbsp;
<el-button @click="EditPatternTextureDepthFun"></el-button>
</el-form-item>
<el-form-item label=" ">
<el-button type="primary" @click="installClick()">/</el-button>
<!-- <el-button type="primary" @click="installClick(1)">/</el-button>-->
<!-- <el-button type="primary" @click="installClick(2)"></el-button>-->
<el-button :disabled="!form2?.tyreId" @click="uninstallClick(3)"></el-button>
</el-form-item>
</el-form>
</div>
</div> </div>
</template> </template>
<script name="basetyre" setup> <script name="basetyre" setup>
import {listCarQueue, setCarTyres, TyreInstall, getTyreInfo, TyreUnInstall,EditPatternTextureDepth} from "@/api/tireManagement/install"; import {
uploadImg
} from "@/api/feedback/feedback";
import {Search} from '@element-plus/icons-vue' import {Search} from '@element-plus/icons-vue'
import {useI18n} from 'vue-i18n'; import {useI18n} from 'vue-i18n';
import Cookies from "js-cookie"; import Cookies from "js-cookie";
@ -131,280 +35,43 @@ const {t} = useI18n();
const locale = (Cookies.get('language') || 'zhCn') === 'zhCn' const locale = (Cookies.get('language') || 'zhCn') === 'zhCn'
const {proxy} = getCurrentInstance(); const {proxy} = getCurrentInstance();
const {sys_normal_disable} = proxy.useDict("sys_normal_disable"); const {sys_normal_disable} = proxy.useDict("sys_normal_disable");
const tireArrangement = ref([]) const imageUrl = ref('http://localhost/dev-api/profile/avatar/2023/04/04/xy_logo_mini_20230404112436A006.png')
const tireList = ref({})
const isLicenseNumber = ref(true)
const carQueueList = ref([])
const carQueueOption = ref([])
const licenseNumberOption = ref([])
const nowClick = ref('')
// - 12 - 12
const installedTyre = ref([])
const form = ref({ const form = reactive({
carQueue: '', name: '',
licenseNumber: '',
}) })
const onSubmit = () => {
const form2 = ref({ console.log('submit!')
brand: "",
currentTextureDepth: null,
outerTireNumber: null,
sensorId: "",
size: "",
tyrePositionVal: '',
carOnlineMileage:'',
tyrePosition: "",
})
const rules = {
outerTireNumber: [
{required: true, message: '请输入轮胎编号', trigger: 'change'},
]
}
const outerTireNumberOption = ref([
{
value: 'Option1',
label: 'Option1',
},
{
value: 'Option2',
label: 'Option2',
},
{
value: 'Option3',
label: 'Option3',
},
{
value: 'Option4',
label: 'Option4',
},
{
value: 'Option5',
label: 'Option5',
}
])
const backgroundColorState = (e) => {
if (installedTyre.value.includes(e)) {
return '#41ca7f'
} else {
return '#90bfea'
}
}
const borderColorState = (e) => {
if (e === nowClick.value) {
return '#ffff00'
}
if (installedTyre.value.includes(e)) {
return '#41ca7f'
} else {
return '#90bfea'
}
}
const tyreClick = (e, location) => {
nowClick.value = e
let data = tireList.value.filter(res => res.tyrePositionVal === e)?.[0] || {}
form2.value = {...data, location}
console.log(data)
}
const getList = async () => {
let {rows: queueList} = await listCarQueue()
carQueueList.value = queueList
carQueueOption.value = queueList.map(e => {
return {
label: e.title,
value: e.id
}
})
}
const carQueueChange = (e) => {
form.value.licenseNumber = null
tireArrangement.value = []
nowClick.value = ''
form2.value = {
brand: "",
currentTextureDepth: null,
outerTireNumber: null,
sensorId: "",
size: "",
tyrePositionVal: '',
tyrePosition: "",
carOnlineMileage:'',
tyreiId: ''
}
let option = carQueueList.value.filter(res => res.id === e)[0]?.baseCarList || []
option.length !== 0 ? isLicenseNumber.value = false : isLicenseNumber.value = true
licenseNumberOption.value = option.map(e => {
return {
label: e.carLicense,
value: e.id
}
})
}
const licenseNumberChange = async (e) => {
form2.value = {
brand: "",
currentTextureDepth: null,
outerTireNumber: null,
sensorId: "",
size: "",
tyrePositionVal: "",
carOnlineMileage:'',
tyrePosition: "",
tyreiId: ''
}
nowClick.value = ''
const {data: res} = await setCarTyres({id: form.value.licenseNumber})
tireArrangement.value = (res.carType?.split('T')[1]?.split('|').filter(e => e !== '') || []).map((res) => {
return parseInt(res.split('-')[1])
})
installedTyre.value = res.carTyresList.map(e => (e.tyrePosition?.split('-')[0] + '-' + e.tyrePosition?.split('-')[1] + '-' + e.tyrePosition?.split('-')[2]))
tireList.value = res.carTyresList.map(e => {
return {
...e,
tyrePositionVal: e.tyrePosition?.split('-')[0] + '-' + e.tyrePosition?.split('-')[1] + '-' + e.tyrePosition?.split('-')[2]
}
})
} }
const requestUpload = (e) => {
const outerTireNumberSearchClick = async () => { console.log(e)
const {data} = await getTyreInfo({outerTireNumber: form2.value.outerTireNumber}) let formData = new FormData();
let list = nowClick.value?.split('-').map(e => parseFloat(e)) formData.append("avatarfile", e.file);
let num = 0 uploadImg(formData).then(response => {
if (list[0] === 1) { console.log(response)
if (list[1] === 1 && list[2] === 1) {
num += 2
}
if (list[1] === 2 && list[2] === 1) {
num += 1
}
} else {
num += 2
for (let i = 1; i < list?.[0] - 1; i++) {
num += (tireArrangement.value[i - 1] * 4)
}
if (list[1] === 1 && list[2] === 1) {
num += 4
}
if (list[1] === 1 && list[2] === 2) {
num += 3
}
if (list[1] === 2 && list[2] === 2) {
num += 2
}
if (list[1] === 2 && list[2] === 1) {
num += 1
}
}
form2.value.brand = data.brand
form2.value.size = data.size
form2.value.sensorId = data.sensorId
form2.value.tyreId = data.id
form2.value.tyrePosition = nowClick.value
}
const installClick = (e) => {
let state = e
if (!e) {
state = 1
}
proxy.$refs["form22"].validate((valid) => {
if (valid) {
console.log(form2.value)
TyreInstall({
...form2.value,
carLicense: licenseNumberOption.value.filter(e => e.value === form.value.licenseNumber)?.[0].label,
carId: form.value.licenseNumber,
type: state
}).then(async (e) => {
proxy.$modal.msgSuccess(e.msg);
let param = nowClick.value
let str = form2.value.location
await licenseNumberChange()
tyreClick(param, str)
})
}
});
}
const EditPatternTextureDepthFun = () => {
proxy.$refs["form22"].validate((valid) => {
if (valid) {
console.log(form2.value)
EditPatternTextureDepth({
...form2.value,
carLicense: licenseNumberOption.value.filter(e => e.value === form.value.licenseNumber)?.[0].label,
carId: form.value.licenseNumber,
type: 4
}).then(async (e) => {
proxy.$modal.msgSuccess(e.msg);
let param = nowClick.value
let str = form2.value.location
await licenseNumberChange()
tyreClick(param, str)
})
}
}); });
} }
const uninstallClick = (val) => {
if (form2.value.tyreId) {
TyreUnInstall({
...form2.value,
carLicense: licenseNumberOption.value.filter(e => e.value === form.value.licenseNumber)?.[0].label,
carId: form.value.licenseNumber,
type: val
}).then(async (e) => {
proxy.$modal.msgSuccess(e.msg);
let param = nowClick.value
let str = form2.value.location
await licenseNumberChange()
tyreClick(param, str)
})
}
}
getList()
</script> </script>
<style lang="scss"> <style lang="scss">
.bg { .avatar-uploader .el-upload {
display: inline-block; border: 1px dashed var(--el-border-color);
width: 260px; border-radius: 6px;
height: 100%; cursor: pointer;
background-color: #eee; position: relative;
overflow: hidden;
:not(:first-child) { transition: var(--el-transition-duration-fast);
margin-top: 20px; }
}
.item {
text-align: center;
width: 100px;
height: 100px;
display: inline-block;
margin-left: 20px;
}
.circle { .avatar-uploader .el-upload:hover {
width: 100%; border-color: var(--el-color-primary);
height: 100%; }
background-color: #90bfea;
border-radius: 50%;
border: 2px solid #90bfea;
span { .el-icon.avatar-uploader-icon {
display: inline-block; font-size: 28px;
width: 100%; color: #8c939d;
float: left; width: 178px;
line-height: 96px; height: 178px;
vertical-align: top; text-align: center;
}
}
} }
</style> </style>

@ -97,7 +97,7 @@ const cascaderChange = (e) => {
if (!nowClick) return if (!nowClick) return
getInfoById(nowClick) getInfoById(nowClick)
.then(val => { .then(val => {
console.log(val) form.value = val.data
}) })
} }
const handleQuery = (e) => { const handleQuery = (e) => {

@ -355,8 +355,10 @@ const getList = async () => {
const tableChange = async (e) => { const tableChange = async (e) => {
pageId.value = e.id pageId.value = e.id
const {data: info} = await getCarGpsList({id: pageId.value}) const {data: info} = await getCarGpsList({id: pageId.value})
console.log(info)
cardInfo.value = { cardInfo.value = {
carLicense: info.carLicense carLicense: info.carLicense,
name:info.carQueue
} }
let TireRow1 = info.cartype?.split('T')[1]?.split('|').filter(e => e !== '') || [] let TireRow1 = info.cartype?.split('T')[1]?.split('|').filter(e => e !== '') || []
let title = [] let title = []

@ -122,8 +122,11 @@ function beforeUpload(file) {
/** 上传图片 */ /** 上传图片 */
function uploadImg() { function uploadImg() {
proxy.$refs.cropper.getCropBlob(data => { proxy.$refs.cropper.getCropBlob(data => {
console.log(data)
let formData = new FormData(); let formData = new FormData();
formData.append("avatarfile", data); formData.append("avatarfile", data);
setTimeout(() => {console.log(formData)},1)
console.log(formData)
uploadAvatar(formData).then(response => { uploadAvatar(formData).then(response => {
open.value = false; open.value = false;
options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl; options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl;

Loading…
Cancel
Save