修改客户所提基础问题

This commit is contained in:
lizhenhua 2025-07-12 14:39:07 +08:00
parent e947cccdda
commit 5db45230fd
1 changed files with 118 additions and 25 deletions

View File

@ -48,22 +48,6 @@
<el-col :span="18"> <el-col :span="18">
<el-form-item> <el-form-item>
<el-button class="primary-lease" type="primary" @click="addContract">新增装备</el-button> <el-button class="primary-lease" type="primary" @click="addContract">新增装备</el-button>
<el-col :span="3" :offset="1">
<el-upload
class="primary-lease"
:action="uploadUrl"
:headers="headerInfo"
:show-file-list="false"
accept=".xlsx"
:on-success="handleUpload"
name="file"
>
<el-button type="primary">批量装备上传</el-button>
</el-upload>
</el-col>
<a :href="uploadUrlTemp" download="装备模板下载">
<el-button class="primary-lease" type="primary" style="margin-left: 20px">装备模板下载</el-button>
</a>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -155,6 +139,75 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<!-- 图片一类的处理 -->
<el-row :gutter="20" v-if="!isViewForm">
<el-col :span="24">
<el-form-item label="1" style="margin-bottom: 0" class="upload-tip">
<div class="tipBox">
*: 支持格式.jpg.png 单个文件大小不能超过5M
</div>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
<el-form-item
style="font-weight: bold"
label="主展示图:"
prop="mainFileList"
>
<div
class="img-list"
v-if="addAndEditForm.mainFileList.length > 0 && !isAdd"
>
<div
v-for="(j, i) in addAndEditForm.mainFileList"
:key="j.fileUrl"
class="img-items"
>
<img :src="j.fileUrl" alt="" />
<div class="mask-img">
<div>
<el-icon
class="delete-icon"
@click="onDeleteImgInMain(i)"
v-if="!isViewForm"
>
<DeleteFilled />
</el-icon>
<el-icon
class="delete-icon"
style="margin-left: 10px"
@click="onPreviewImg(j.fileUrl)"
>
<ZoomIn />
</el-icon>
</div>
</div>
</div>
</div>
<UploadComponentNew
v-if="!isViewForm"
:maxSize="5"
:max-limit="6"
width="100px"
height="100px"
:actionUrl="uploadUrl"
:autoUpload="true"
:multiple="true"
:minLimit="addAndEditForm.mainFileList.length"
listType="picture-card"
:acceptTypeList="['.jpg', '.png']"
@onFileChange="onMainFileChange"
>
<template v-slot:default>
<el-icon size="42" color="#aaa"><Plus /></el-icon>
</template>
</UploadComponentNew>
</el-form-item>
</el-col>
</el-row>
</el-form> </el-form>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
@ -167,6 +220,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import UploadComponentNew from 'components/uploadComponentNew/index.vue'
import PagingComponent from 'components/PagingComponent/index.vue' import PagingComponent from 'components/PagingComponent/index.vue'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import { ref, reactive, onMounted } from 'vue' import { ref, reactive, onMounted } from 'vue'
@ -183,7 +237,9 @@ import {
} from 'http/api/owner-manage' } from 'http/api/owner-manage'
const uploadUrlTemp = ref('') const uploadUrlTemp = ref('')
const isViewForm = ref(false)
const qualityLis = ref<any>([]) const qualityLis = ref<any>([])
const isAdd = ref(false)
const queryFormRef = ref<any>(null) const queryFormRef = ref<any>(null)
const total = ref(0) const total = ref(0)
const equipmentNameOptions = ref<any[]>([]) const equipmentNameOptions = ref<any[]>([])
@ -200,15 +256,22 @@ const addAndEditForm = ref<any>({
maType: '', maType: '',
maModel: '', maModel: '',
maNum: '', maNum: '',
type: '1' type: '1',
mainFileList: [], //
mainFileTempList: [] //
}) })
const addAndEditFormRef = ref() const addAndEditFormRef = ref()
const mainFileList: any = ref([]) //
const settleinTitle = ref('') const settleinTitle = ref('')
const dialogVisibleSettlein: any = ref(false) const dialogVisibleSettlein: any = ref(false)
const headerInfo = reactive({ const headerInfo = reactive({
Authorization: 'Bearer ' + store2.token, Authorization: 'Bearer ' + store2.token,
}) })
const uploadUrl = import.meta.env.VITE_API_URL + '/material-mall/owner/importData?type='+2 const uploadUrl = import.meta.env.VITE_API_URL + '/file/upload'
const onDeleteImgInMain = (index: any) => {
addAndEditForm.value.mainFileList.splice(index, 1)
}
const handleUpload = (file: any, fileList: any) => { const handleUpload = (file: any, fileList: any) => {
if (file.code == 200) { if (file.code == 200) {
@ -219,6 +282,15 @@ const handleUpload = (file: any, fileList: any) => {
getContractListData() getContractListData()
} }
//
const onMainFileChange = (fileList: any[]) => {
//
addAndEditForm.value.mainFileTempList = fileList.map(file => ({
fileName: file.name, //
fileUrl: file.url // URL
}))
}
// //
const getContractListData = async () => { const getContractListData = async () => {
const { data: res }: any = await getContractListApi(queryParams) const { data: res }: any = await getContractListApi(queryParams)
@ -256,28 +328,36 @@ const addContract = () => {
settleinTitle.value = '外租装备新建' settleinTitle.value = '外租装备新建'
dialogVisibleSettlein.value = true dialogVisibleSettlein.value = true
addAndEditForm.value.id = null addAndEditForm.value.id = null
isViewForm.value = false
addAndEditForm.value.maNameId = '' addAndEditForm.value.maNameId = ''
addAndEditForm.value.maType = '' addAndEditForm.value.maType = ''
addAndEditForm.value.maModel = '' addAndEditForm.value.maModel = ''
addAndEditForm.value.maNum = '' addAndEditForm.value.maNum = ''
addAndEditForm.value.mainFileList = [] // .value
addAndEditForm.value.mainFileTempList = [] // .value
} }
// //
const onContract = (row: any) => { const onContract = (row: any) => {
console.log('编辑行数据:', row) // //
console.log('当前下拉选项:', equipmentNameOptions.value) // if (row.mainFileList) {
addAndEditForm.value.mainFileList = row.mainFileList.map((img: any) => ({
fileName: img.fileName,
fileUrl: img.fileUrl
}))
} else {
addAndEditForm.value.mainFileList = []
}
addAndEditForm.value.mainFileTempList = []
addAndEditForm.value.id = row.id addAndEditForm.value.id = row.id
// id // id
const matchedOption = equipmentNameOptions.value.find(option => option.label === row.maName) const matchedOption = equipmentNameOptions.value.find(option => option.label === row.maName)
if (matchedOption) { if (matchedOption) {
addAndEditForm.value.maNameId = matchedOption.value addAndEditForm.value.maNameId = matchedOption.value
console.log('通过名称匹配到ID:', matchedOption.value)
} else { } else {
// 使 // 使
addAndEditForm.value.maNameId = row.maNameId || row.maName_id || row.equipmentId || row.id addAndEditForm.value.maNameId = row.maNameId || row.maName_id || row.equipmentId || row.id
console.log('使用备用ID:', addAndEditForm.value.maNameId)
} }
addAndEditForm.value.maType = row.maType addAndEditForm.value.maType = row.maType
@ -314,6 +394,13 @@ const addAndEditFormRules = reactive({
const onSubmit = () => { const onSubmit = () => {
addAndEditFormRef.value.validate(async (valid: any) => { addAndEditFormRef.value.validate(async (valid: any) => {
if (valid) { if (valid) {
//
addAndEditForm.value.mainFileList = [
...addAndEditForm.value.mainFileList,
...addAndEditForm.value.mainFileTempList
]
//
addAndEditForm.value.mainFileTempList = []
const SEN_API = settleinTitle.value === '外租装备修改' ? editContractApi : addContractApi const SEN_API = settleinTitle.value === '外租装备修改' ? editContractApi : addContractApi
const res: any = await SEN_API(addAndEditForm.value) const res: any = await SEN_API(addAndEditForm.value)
if (res.code === 200) { if (res.code === 200) {
@ -359,6 +446,12 @@ onMounted(() => {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.tipBox {
color: red;
font-size: 12px;
margin-left: 20px;
}
:deep.editor { :deep.editor {
height: 300px; height: 300px;
} }