Compare commits

...

3 Commits

Author SHA1 Message Date
BianLzhaoMin 241d8b2b01 提交 2024-11-29 13:30:32 +08:00
BianLzhaoMin 77558c5c6b Merge branch 'dev-sy' 2024-11-29 13:30:25 +08:00
BianLzhaoMin c319692a07 代码有哈 2024-11-29 13:30:02 +08:00
5 changed files with 254 additions and 32 deletions

View File

@ -10,9 +10,7 @@
:on-error="errorUpload" :on-error="errorUpload"
:accept="props.acceptTypeList.join(',')" :accept="props.acceptTypeList.join(',')"
:before-upload="beforeUpload" :before-upload="beforeUpload"
:multiple="props.multiple" :multiple="false"
:limit="props.maxLimit"
:on-exceed="handleExceed"
:file-list="fileListNew" :file-list="fileListNew"
:disabled="props.disabledFlag" :disabled="props.disabledFlag"
:on-change="changeFileFn" :on-change="changeFileFn"
@ -92,6 +90,11 @@ const props = defineProps({
type: Number || String, type: Number || String,
default: 1, default: 1,
}, },
minLimit: {
//
type: Number || String,
default: 1,
},
maxSize: { maxSize: {
// M // M
type: Number || String, type: Number || String,
@ -200,6 +203,8 @@ const errorUpload = (res: any) => {
} }
const beforeUpload = (file: any) => { const beforeUpload = (file: any) => {
console.log('file', file) console.log('file', file)
console.log(props.minLimit, '个数---')
const { name = '', size } = file const { name = '', size } = file
if (size > props.maxSize * 1024 * 1000) { if (size > props.maxSize * 1024 * 1000) {
ElMessage({ ElMessage({
@ -208,6 +213,14 @@ const beforeUpload = (file: any) => {
}) })
return false return false
} }
if (fileListNew.value.length + props.minLimit >= 4) {
ElMessage({
type: 'warning',
message: `最多只能上传${props.maxLimit}个文件`,
})
return false
}
let names = name.split('.') let names = name.split('.')
let currentName = names[names.length - 1] let currentName = names[names.length - 1]
console.log('acceptTypeListacceptTypeList', props.acceptTypeList, currentName) console.log('acceptTypeListacceptTypeList', props.acceptTypeList, currentName)

View File

@ -144,14 +144,14 @@ export const useStore = defineStore('myUser', {
editUserMenuList(type: number) { editUserMenuList(type: number) {
const leaseList: any = [ const leaseList: any = [
{ title: '订单管理', name: 'orderManagementCz' }, { title: '订单管理', name: 'orderManagementCz' },
{ title: '商品管理', name: 'goodsManagement' }, { title: '装备管理', name: 'goodsManagement' },
{ title: '商品上下架', name: 'goodsUpdown' }, { title: '商品上下架', name: 'goodsUpdown' },
// { title: '机手管理', name: 'operatorManagement' }, // { title: '机手管理', name: 'operatorManagement' },
// { title: '寻源竞价', name: 'sourcingBidding' }, // { title: '寻源竞价', name: 'sourcingBidding' },
// { title: '专区管理', name: 'zoneManag' }, // { title: '专区管理', name: 'zoneManag' },
] ]
const lesseeList: any = [ const lesseeList: any = [
{ title: '寻源需求', name: 'sourcingNeed' }, { title: '需求管理', name: 'sourcingNeed' },
{ title: '订单管理', name: 'orderManagement' }, { title: '订单管理', name: 'orderManagement' },
] ]
this.leaseAndLesseeUserList = [] this.leaseAndLesseeUserList = []

View File

@ -0,0 +1,120 @@
<template>
<div class="custom-date-picker">
<el-button @click="showPicker = !showPicker" :size="size" class="date-picker-button">
{{ displayDate }}
</el-button>
<el-date-picker
v-model="selectedDate"
:type="pickerType"
:placeholder="placeholder"
:format="format"
:value-format="valueFormat"
:style="{ visibility: 'hidden' }"
@change="handleDateChange"
style="margin-top: -100px"
ref="datePicker"
/>
</div>
</template>
<script setup>
import { ref, computed, watch, nextTick } from 'vue'
import { ElDatePicker, ElButton } from 'element-plus'
const props = defineProps({
modelValue: {
type: [Date, String, Array],
default: [],
},
type: {
type: String,
default: 'primary',
},
size: {
type: String,
default: 'small',
},
pickerType: {
type: String,
default: 'daterange',
},
placeholder: {
type: String,
default: '选择日期',
},
format: {
type: String,
default: 'YYYY-MM-DD',
},
valueFormat: {
type: String,
default: 'YYYY-MM-DD',
},
companyIndex: {
type: Number,
default: 0,
},
goodsIndex: {
type: Number,
default: 0,
},
})
const emit = defineEmits(['update:modelValue', 'onLeaseDateChange'])
const selectedDate = ref(props.modelValue)
const showPicker = ref(false)
const datePicker = ref(null)
const displayDate = computed(() => {
return selectedDate.value ? '修改租期' : '请选择租期'
})
const handleDateChange = (value) => {
emit('update:modelValue', value, props.companyIndex, props.goodsIndex)
emit('onLeaseDateChange', value, props.companyIndex, props.goodsIndex)
showPicker.value = false
}
// const onVisibleChange = () => {
// console.log('')
// showPicker.value = false
// }
watch(
showPicker,
(newValue) => {
if (newValue) {
nextTick(() => {
datePicker.value.handleOpen()
})
} else {
nextTick(() => {
datePicker.value.handleClose()
})
}
},
{ deep: true, immediate: true },
)
watch(
() => props.modelValue,
(newValue) => {
selectedDate.value = newValue
},
)
</script>
<style scoped>
.custom-date-picker {
display: inline-block;
}
.date-picker-button {
/* min-width: 120px; */
background-color: #1abc9c;
color: #fff;
height: 30px;
border: none;
}
</style>

View File

@ -80,22 +80,37 @@
/> />
<div class="goods-code"> <div class="goods-code">
<div style="font-size: 14px; font-weight: bold">{{ goods.deviceName }}</div> <div style="font-size: 14px; font-weight: bold">{{ goods.deviceName }}</div>
<div>装备编号 {{ goods.code }}</div>
<div>装备型号 {{ goods.typeName }}</div> <!-- <div>装备编号 {{ goods.code }}</div>
<div>装备型号 {{ goods.typeName }}</div> -->
</div> </div>
</el-col> </el-col>
<el-col :span="4"> <el-col :span="4">
<div class="lease-date"> <div class="lease-date">
<div v-if="goods.rentBeginTime && goods.rentEndTime"> <div style="margin-bottom: 8px">
{{ goods.rentBeginTime }}-{{ goods.rentEndTime }} {{ goods.rentBeginTime }}
<span v-if="goods.rentBeginTime && goods.rentEndTime">-</span>
{{ goods.rentEndTime }}
</div> </div>
<el-date-picker
<!-- <el-date-picker
style="width: 100px; margin-top: 10px" style="width: 100px; margin-top: 10px"
v-model="goods.lease_date" v-model="goods.lease_date"
type="daterange" type="daterange"
size="small" size="small"
value-format="YYYY-MM-DD" value-format="YYYY-MM-DD"
@change="onLeaseDateChange($event, goods)" @change="onLeaseDateChange($event, goods)"
>
</el-date-picker> -->
<CustomDatePickerButton
:modelValue="goods.lease_date"
:companyIndex="index"
:goodsIndex="j"
type="primary"
size="large"
placeholder="选择日期"
@onLeaseDateChange="onLeaseDateChange"
/> />
</div> </div>
</el-col> </el-col>
@ -211,12 +226,11 @@ import {
} from '../../http/api/cart/index' } from '../../http/api/cart/index'
import moment, { max } from 'moment' import moment, { max } from 'moment'
import { InfoFilled } from '@element-plus/icons-vue' import { InfoFilled } from '@element-plus/icons-vue'
import CustomDatePickerButton from './components/date-picker-button.vue'
const protocolChecked = ref<boolean>(false) const protocolChecked = ref<boolean>(false)
const allKey = ref(0) const allKey = ref(0)
const cardList = ref<any>([]) const cardList = ref<any>([])
const getBookCarDetailsData = async () => { const getBookCarDetailsData = async () => {
const res: any = await getBookCarDetailsApi() const res: any = await getBookCarDetailsApi()
@ -231,6 +245,7 @@ const getBookCarDetailsData = async () => {
j.costs = 0 j.costs = 0
j.rentBeginTime = '' j.rentBeginTime = ''
j.rentEndTime = '' j.rentEndTime = ''
j.lease_date = null
}) })
}) })
@ -243,16 +258,30 @@ onMounted(() => {
}) })
// change // change
const onLeaseDateChange = (e: any, item: any) => { // const onLeaseDateChange = (e: any, item: any) => {
console.log(e, '*****') // console.log(e, '*****')
if (!e) { // if (!e) {
item.rentBeginTime = '' // item.rentBeginTime = ''
item.rentEndTime = '' // item.rentEndTime = ''
item.days = 0 // item.days = 0
// } else {
// item.rentBeginTime = e[0]
// item.rentEndTime = e[1]
// item.days = moment(e[1]).diff(e[0], 'day')
// }
// }
const onLeaseDateChange = (value: any, companyIndex: number, goodsIndex: number) => {
if (!value) {
cardList.value[companyIndex].devInfoVoList[goodsIndex].rentBeginTime = ''
cardList.value[companyIndex].devInfoVoList[goodsIndex].rentEndTime = ''
cardList.value[companyIndex].devInfoVoList[goodsIndex].days = 0
} else { } else {
item.rentBeginTime = e[0] cardList.value[companyIndex].devInfoVoList[goodsIndex].rentBeginTime = value[0]
item.rentEndTime = e[1] cardList.value[companyIndex].devInfoVoList[goodsIndex].rentEndTime = value[1]
item.days = moment(e[1]).diff(e[0], 'day') cardList.value[companyIndex].devInfoVoList[goodsIndex].days = moment(value[1]).diff(
value[0],
'day',
)
} }
} }
@ -366,6 +395,23 @@ const onCartSubmit = async () => {
return return
} }
let isDays = false
try {
amountDeviceList.value.forEach((e: any) => {
if (e.days < 1) {
ElMessage({
showClose: false,
message: '有装备租期未选择或租期为0请重新选择后再提交',
type: 'error',
})
isDays = true
throw new Error()
}
})
} catch (error) {}
if (isDays) return
// //
const detailsList = amountDeviceList.value.map((e: any) => { const detailsList = amountDeviceList.value.map((e: any) => {
return { return {

View File

@ -295,18 +295,25 @@
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="24"> <el-col :span="24">
<el-form-item label="参考图片/样式"> <el-form-item label="参考图片/样式">
<!-- <div class="img-list"> <div class="img-list" v-if="addOrEditForm.fileInfoList.length > 0">
<div <div
v-for="item in addOrEditForm.fileInfoList || []" v-for="(item, index) in addOrEditForm.fileInfoList"
:key="item.id" :key="item.id"
class="img-items" class="img-items"
> >
<img :src="item.fileUrl" alt="" /> <img :src="item.fileUrl" alt="" />
<div class="mask-img">
<el-icon class="delete-icon" @click="onDeleteImg(index)"
><DeleteFilled
/></el-icon>
</div>
</div> </div>
</div> --> </div>
<UploadComponentNew <UploadComponentNew
:maxSize="2" :maxSize="2"
:maxLimit="4" :minLimit="minLimit"
:max-limit="4"
width="120px" width="120px"
height="120px" height="120px"
:autoUpload="true" :autoUpload="true"
@ -373,6 +380,8 @@ const total = ref(0)
const endTime = ref([]) const endTime = ref([])
const releaseTime = ref([]) const releaseTime = ref([])
const dialogTitle = ref('新增') const dialogTitle = ref('新增')
const fileListTemp = ref<any>([])
const searchParams = reactive({ const searchParams = reactive({
leaseName: '', leaseName: '',
leaseCode: '', leaseCode: '',
@ -410,7 +419,7 @@ const addOrEditFormTemp = ref<any>({
endTime: '', endTime: '',
description: '', description: '',
isSubmit: '', isSubmit: '',
fileInfoList: [], fileInfoList: fileListTemp ? fileListTemp : [],
}) })
const addOrEditFormRules = reactive({ const addOrEditFormRules = reactive({
@ -438,10 +447,6 @@ const disabledDate = (date: any) => {
return date.getTime() < today.getTime() return date.getTime() < today.getTime()
} }
const successResultCallBackFnDevicePic = (list: any) => {
console.log(99999, list)
}
const getClassAndCompanyData = async () => { const getClassAndCompanyData = async () => {
const classResult: any = await getGoodsClassListApi() const classResult: any = await getGoodsClassListApi()
const companyResult: any = await getCompanyListApi() const companyResult: any = await getCompanyListApi()
@ -521,7 +526,7 @@ const onRepublish = async (id: any, type: any) => {
description, description,
typeIds, typeIds,
id, id,
fileInfoList, fileInfoList: fileInfoList ? fileInfoList : [],
}) })
addOrEditForm.value.typeIds = addOrEditForm.value.typeIds.map((e: any) => { addOrEditForm.value.typeIds = addOrEditForm.value.typeIds.map((e: any) => {
@ -538,6 +543,8 @@ const onSubmit = (type: boolean) => {
addOrEditForm.value.isSubmit = type addOrEditForm.value.isSubmit = type
addOrEditForm.value.typeId = addOrEditForm.value.typeId =
addOrEditForm.value.typeIds[addOrEditForm.value.typeIds.length - 1] addOrEditForm.value.typeIds[addOrEditForm.value.typeIds.length - 1]
addOrEditForm.value.fileInfoList.push(...fileListTemp.value)
const SUBMIT_API = isRepublish.value ? addLeaseInfoApi : editLeaseInfoApi const SUBMIT_API = isRepublish.value ? addLeaseInfoApi : editLeaseInfoApi
const res: any = await SUBMIT_API(addOrEditForm.value) const res: any = await SUBMIT_API(addOrEditForm.value)
if (res.code === 200) { if (res.code === 200) {
@ -555,12 +562,15 @@ const onSubmit = (type: boolean) => {
// //
const onFileChange = (fileList: any) => { const onFileChange = (fileList: any) => {
addOrEditForm.value.fileInfoList = fileList.map((e: any) => { fileListTemp.value = []
fileListTemp.value = fileList.map((e: any) => {
return { return {
fileName: e.name, fileName: e.name,
fileUrl: e.url, fileUrl: e.url,
} }
}) })
// addOrEditForm.value.fileInfoList.push(...fileListTemp.value)
} }
// //
@ -570,7 +580,15 @@ const onCancel = () => {
const onClose = () => { const onClose = () => {
addOrEditFormRef.value.resetFields() addOrEditFormRef.value.resetFields()
addOrEditForm.value = JSON.parse(JSON.stringify(addOrEditFormTemp.value)) addOrEditForm.value = JSON.parse(JSON.stringify(addOrEditFormTemp.value))
fileListTemp.value = []
} }
const onDeleteImg = (index: any) => {
addOrEditForm.value.fileInfoList.splice(index, 1)
}
const minLimit = computed(() => {
return addOrEditForm.value.fileInfoList.length
})
onMounted(() => { onMounted(() => {
getClassAndCompanyData() getClassAndCompanyData()
@ -602,11 +620,36 @@ onMounted(() => {
width: 120px; width: 120px;
height: 120px; height: 120px;
margin-right: 8px; margin-right: 8px;
position: relative;
img { img {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.mask-img {
visibility: hidden;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #000;
opacity: 0.5;
display: flex;
align-items: center;
justify-content: center;
.delete-icon {
font-size: 20px;
cursor: pointer;
z-index: 9;
color: #fff;
}
}
}
.img-items:hover .mask-img {
visibility: visible;
} }
} }
</style> </style>