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

View File

@ -144,14 +144,14 @@ export const useStore = defineStore('myUser', {
editUserMenuList(type: number) {
const leaseList: any = [
{ title: '订单管理', name: 'orderManagementCz' },
{ title: '商品管理', name: 'goodsManagement' },
{ title: '装备管理', name: 'goodsManagement' },
{ title: '商品上下架', name: 'goodsUpdown' },
// { title: '机手管理', name: 'operatorManagement' },
// { title: '寻源竞价', name: 'sourcingBidding' },
// { title: '专区管理', name: 'zoneManag' },
]
const lesseeList: any = [
{ title: '寻源需求', name: 'sourcingNeed' },
{ title: '需求管理', name: 'sourcingNeed' },
{ title: '订单管理', name: 'orderManagement' },
]
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 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>
</el-col>
<el-col :span="4">
<div class="lease-date">
<div v-if="goods.rentBeginTime && goods.rentEndTime">
{{ goods.rentBeginTime }}-{{ goods.rentEndTime }}
<div style="margin-bottom: 8px">
{{ goods.rentBeginTime }}
<span v-if="goods.rentBeginTime && goods.rentEndTime">-</span>
{{ goods.rentEndTime }}
</div>
<el-date-picker
<!-- <el-date-picker
style="width: 100px; margin-top: 10px"
v-model="goods.lease_date"
type="daterange"
size="small"
value-format="YYYY-MM-DD"
@change="onLeaseDateChange($event, goods)"
>
</el-date-picker> -->
<CustomDatePickerButton
:modelValue="goods.lease_date"
:companyIndex="index"
:goodsIndex="j"
type="primary"
size="large"
placeholder="选择日期"
@onLeaseDateChange="onLeaseDateChange"
/>
</div>
</el-col>
@ -211,12 +226,11 @@ import {
} from '../../http/api/cart/index'
import moment, { max } from 'moment'
import { InfoFilled } from '@element-plus/icons-vue'
import CustomDatePickerButton from './components/date-picker-button.vue'
const protocolChecked = ref<boolean>(false)
const allKey = ref(0)
const cardList = ref<any>([])
const getBookCarDetailsData = async () => {
const res: any = await getBookCarDetailsApi()
@ -231,6 +245,7 @@ const getBookCarDetailsData = async () => {
j.costs = 0
j.rentBeginTime = ''
j.rentEndTime = ''
j.lease_date = null
})
})
@ -243,16 +258,30 @@ onMounted(() => {
})
// change
const onLeaseDateChange = (e: any, item: any) => {
console.log(e, '*****')
if (!e) {
item.rentBeginTime = ''
item.rentEndTime = ''
item.days = 0
// const onLeaseDateChange = (e: any, item: any) => {
// console.log(e, '*****')
// if (!e) {
// item.rentBeginTime = ''
// item.rentEndTime = ''
// 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 {
item.rentBeginTime = e[0]
item.rentEndTime = e[1]
item.days = moment(e[1]).diff(e[0], 'day')
cardList.value[companyIndex].devInfoVoList[goodsIndex].rentBeginTime = value[0]
cardList.value[companyIndex].devInfoVoList[goodsIndex].rentEndTime = value[1]
cardList.value[companyIndex].devInfoVoList[goodsIndex].days = moment(value[1]).diff(
value[0],
'day',
)
}
}
@ -366,6 +395,23 @@ const onCartSubmit = async () => {
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) => {
return {

View File

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