diff --git a/App.vue b/App.vue index 9dd5962..eb61edb 100644 --- a/App.vue +++ b/App.vue @@ -88,6 +88,11 @@ console.error('获取用户信息失败', err) }) } + + // #ifdef APP-PLUS + plus.screen.lockOrientation('portrait-primary'); //锁死屏幕方向为竖屏 + plus.navigator.setFullscreen(false); + // #endif }, onShow: function() { console.log('App Show') diff --git a/components/orderCard.vue b/components/orderCard.vue index 6e1c1a6..f01deae 100644 --- a/components/orderCard.vue +++ b/components/orderCard.vue @@ -241,6 +241,7 @@ * 接单 */ openFile(orderId) { + console.log('执行'); this.$emit('getOrder', orderId); }, /** diff --git a/main.js b/main.js index 59558d6..72ed18e 100644 --- a/main.js +++ b/main.js @@ -1,6 +1,12 @@ import App from './App' import uView from "uview-ui"; -import config from '@/config' +import config from '@/config'; +import { + checkPermi, + checkRole +} from './utils/permission' +Vue.prototype.checkPermi = checkPermi +Vue.prototype.checkRole = checkRole const baseUrl = config.baseUrl Vue.prototype.$baseUrl = baseUrl; const baseImageUrl = config.baseImageUrl diff --git a/pages-home/home/home.vue b/pages-home/home/home.vue index c3e2f0f..ddd09e9 100644 --- a/pages-home/home/home.vue +++ b/pages-home/home/home.vue @@ -31,7 +31,7 @@ 业务管理 - + 数据统计 @@ -70,23 +70,24 @@ 进厂数 - {{ bossNum.inCompanyNum }} + {{ bossNum.newOrderNum }} - + 维修中 {{ bossNum.workingNum }} - + 已竣工 {{ bossNum.overNum }} - + + @@ -423,6 +424,11 @@ url: '/pages-business/businessManage/businessManage' // 3. 建议使用单引号 }); break; + case 3: // 2. 补上冒号 + uni.navigateTo({ + url: '/pages-business/statistics/statistics' // 3. 建议使用单引号 + }); + break; case 4: uni.navigateTo({ url: '/pages-home/msg/message' // 3. 建议使用单引号 diff --git a/pages-home/service/todoDetail.vue b/pages-home/service/todoDetail.vue index 928a727..c513ee8 100644 --- a/pages-home/service/todoDetail.vue +++ b/pages-home/service/todoDetail.vue @@ -1,657 +1,697 @@ + .fullscreen-image { + max-width: 90vw; + /* 最大宽度为视口宽度的90% */ + max-height: 90vh; + /* 最大高度为视口高度的90% */ + object-fit: contain; + /* 保持宽高比 */ + cursor: pointer; + margin: 0 20rpx; + /* 增加左右边距,使图片距离屏幕边缘有一定距离 */ + } + + .popup-content { + width: 80%; + max-width: 400px; + background-color: #fff; + padding: 20px; + border-radius: 10px; + margin: auto; + } + + .popup-title { + font-size: 18px; + margin-bottom: 20px; + text-align: center; + } + + .uni-form-item { + display: flex; + align-items: center; + margin-bottom: 15px; + } + + .uni-label { + width: 20rem; + } + + .uni-input { + padding: 2px; + border: 1px solid #ccc; + border-radius: 5px; + box-sizing: border-box; + height: 2rem; + width: 26rem; + } + + .popup-footer { + display: flex; + justify-content: space-between; + margin-top: 20px; + } + + .confirm-btn, + .cancel-btn { + flex: 1; + margin: 0 5px; + height: 40px; + line-height: 40px; + border: none; + border-radius: 5px; + } + + .confirm-btn { + background-color: #0174F6; + color: #fff; + } + + .cancel-btn { + background-color: #f5f5f5; + color: #666; + } + \ No newline at end of file diff --git a/pages-internal/workReport/reportDetails.vue b/pages-internal/workReport/reportDetails.vue index f548a30..df9cfee 100644 --- a/pages-internal/workReport/reportDetails.vue +++ b/pages-internal/workReport/reportDetails.vue @@ -25,8 +25,8 @@ 汇报内容 - - + + 附件 上传附件 diff --git a/pages-order/addOrder/addOrder.vue b/pages-order/addOrder/addOrder.vue index 6dcdff5..1a6910c 100644 --- a/pages-order/addOrder/addOrder.vue +++ b/pages-order/addOrder/addOrder.vue @@ -233,7 +233,7 @@ - + + + 渠道/来源 + @@ -392,7 +398,8 @@ import config from "@/config"; import { formatTimestamp, - formatTimestampCustom + formatTimestampCustom, + handleTree } from "@/utils/utils"; import upload from "@/utils/upload"; import { @@ -424,6 +431,7 @@ cusFromIndex: 0, busiFromList: [], busiFromIndex: 0, + busiAndCusList: [], partDisposals: [], partDisposalIndex: 0, formData: { @@ -479,6 +487,7 @@ ticketNo: '', //前一个页面传过来的参数 pageData: {}, + busIAndCusValue: undefined } }, watch: { @@ -543,6 +552,7 @@ this.initDict("repair_type") this.initDict("cus_data_from") this.initDict("repair_part_disposal") + this.queryBusiAndCus() }, onShow() {}, methods: { @@ -588,8 +598,6 @@ this.partDisposalIndex = newIndex; this.formData.partDisposal = this.partDisposals[newIndex].value; }, - - async initDict(dictCode) { let dictArray = getStorageWithExpiry(dictCode); console.log(dictArray, "partDisposals") @@ -652,6 +660,24 @@ }) } }, + /** + * 获取业务来源和渠道 + */ + queryBusiAndCus() { + request({ + url: `/admin-api/business/list`, + method: 'GET', + params: { + systemCode: 'repair' + } + }).then(res => { + this.busiAndCusList = handleTree(res.data, 'id', 'pid') + }) + }, + onBusiAndCuschange(e) { + this.formData.busiFrom = e.detail.value[0].value + this.formData.cusFrom = e.detail.value[1].value + }, buildRepairType() { if (this.pageData.repairType) { this.repairTypes.map((item, index) => { @@ -708,7 +734,8 @@ * 创建工单前上传图片 */ submitUpload() { - if (this.userInfo === null || this.carList.length === 0 || this.selectedProj.length === 0) { + if (this.userInfo === null || this.carList.length === 0 || this.selectedProj.length === 0 || !this.formData + .busiFrom || !this.formData.cusFrom) { uni.showToast({ title: '请完善信息', icon: 'none' @@ -721,12 +748,12 @@ //新增工单 submit() { let fileStr = this.fileList.map(item => item.url.replace(config.baseImageUrl, "")).join(",") - if (!this.formData.busiFrom) { - this.formData.busiFrom = this.busiFromList[this.busiFromIndex].value - } - if (!this.formData.cusFrom) { - this.formData.cusFrom = this.cusFromList[this.cusFromIndex].value - } + // if (!this.formData.busiFrom) { + // this.formData.busiFrom = this.busiFromList[this.busiFromIndex].value + // } + // if (!this.formData.cusFrom) { + // this.formData.cusFrom = this.cusFromList[this.cusFromIndex].value + // } const data = { userId: this.userInfo.id, ticketNo: this.ticketNo, @@ -798,9 +825,20 @@ method: 'GET', params: params }).then(res => { - if (res.data.records.length > 0) { + if (res.data.records.length == 1) { this.userInfo = res.data.records[0] this.getCarList() + } else if (res.data.records.length != 0) { + uni.showActionSheet({ + title: '选择客户', + itemList: res.data.records.map(m => m.cusName + m.phoneNumber), + success: ({ + tapIndex + }) => { + this.userInfo = res.data.records[tapIndex] + this.getCarList() + } + }) } }) } else { diff --git a/pages-order/orderDetail/orderDetail.vue b/pages-order/orderDetail/orderDetail.vue index 60c77e9..06bb689 100644 --- a/pages-order/orderDetail/orderDetail.vue +++ b/pages-order/orderDetail/orderDetail.vue @@ -55,43 +55,46 @@ class="carImage" mode="aspectFit"> {{ ticketInfo.carNo }} - {{ ticketInfo.carBrandName+" " }} {{ ticketInfo.carBrandName+" " }} - - {{ticketInfo.carInfo.carModel}} + {{ticketInfo.carInfo.carModel}} - - 车主 - {{ ticketInfo.userName }} + + + 车主 + {{ ticketInfo.userName }} + + + 联系方式 + {{ ticketInfo.userMobile }} + + + 客户来源 + {{ ticketInfo.customerInfo.dataFromText }} + + + 性别 + {{ ticketInfo.customerInfo.sex === '1' ? '女' : '男' }} + + + 经办人 + {{ ticketInfo.handleName }} + + + 经办人电话 + {{ ticketInfo.handleMobile }} + + + 业务来源 + {{ ticketInfo.busiFrom }} + + - - 联系方式 - {{ ticketInfo.userMobile }} - - - 客户来源 - {{ ticketInfo.customerInfo.dataFromText }} - - - 性别 - {{ ticketInfo.customerInfo.sex === '1' ? '女' : '男' }} - - - 经办人 - {{ ticketInfo.handleName }} - - - 经办人电话 - {{ ticketInfo.handleMobile }} - - - 业务来源 - {{ ticketInfo.busiFrom }} - - + 车架号 {{ ticketInfo.carVin }} @@ -102,48 +105,62 @@ 车辆注册日期 - {{ ticketInfo.carRegisterDate }} + {{ formatDate(ticketInfo.carInfo.carRegisterDate) }} 车龄(年) {{ ticketInfo.carInfo.carYear }} - 年检到期时间 - {{ ticketInfo.nextInspectionDate}} + 当前表显里程 + {{ ticketInfo.carInfo.mileageTraveled}} + + + 下次年检时间 + {{ formatDate(ticketInfo.carInfo.nextInspectionDate)}} 保险到期时间 - {{ ticketInfo.insuranceExpiryDate}} + {{ formatDate(ticketInfo.carInfo.insuranceExpiryDate)}} - + + + 下次保养里程 + {{ ticketInfo.carInfo.nextMaintenanceMileage}} 最近保养日期 {{ ticketInfo.maintenanceDate}} - - 表显里程 - {{ ticketInfo.mileageTraveled}} - 最近保养公里数 {{ ticketInfo.maintenanceMileage}} - - - - + + 档案资料 + + + + + + + + + + 点击编辑车辆信息 + + @@ -456,6 +473,32 @@ + + + + + + + {{ carFormData.nextInspectionDate ? carFormData.nextInspectionDate : '选择日期' }} + + + + + + + + + + {{ carFormData.insuranceExpiryDate ? carFormData.insuranceExpiryDate : '选择日期' }} + + + + + + + @@ -487,7 +530,10 @@ setStorageWithExpiry, getStorageWithExpiry } from '@/utils/auth' - import config from '@/config' + import config from '@/config'; + import { + fixScreen + } from '@/utils/fixScreen.js'; export default { components: { VNavigationBar, @@ -526,10 +572,29 @@ repairItemId: "", itemName: "", }, + // 补充车辆信息 + carFormData: { + nextInspectionDate: undefined, + insuranceExpiryDate: undefined, + nextMaintenanceMileage: undefined, + mileageTraveled: undefined, + }, //是否可以授权给客户看 canOpenCus: false, //是否可以看见钱 canSeeMoney: false, + listStyles: { + // 是否显示边框 + border: false, + // 是否显示分隔线 + dividline: false, + // 线条样式 + borderStyle: { + width: 1, + color: 'blue', + radius: 2 + } + }, //当前选择的操作:working-维修期间|done_half-阶段完成|done-全部完成递交下一维修班组选人维修 nowChooseOperate: "", carInfo: {}, @@ -555,7 +620,8 @@ activeProjTabKey: 0, activePartTabKey: 0, processList: [{}, {}], - carImgList: [] + carImgList: [], + cararchivesPhotos: [] }; }, watch: { @@ -587,8 +653,20 @@ this.refreshData(false) } }, - + onShow() { + // 调用修复方法 + fixScreen(); + }, + computed: { + startDate() { + return this.getDate('start'); + }, + endDate() { + return this.getDate('end'); + } + }, methods: { + formatDate, chooseProjTab(index) { this.activeProjTabKey = index }, @@ -641,6 +719,67 @@ } }) }, + /** + * 打开编辑车辆弹窗 + */ + showCarPopup() { + this.carFormData = this.ticketInfo.carInfo + if (this.carFormData.insuranceExpiryDate) { + this.carFormData.insuranceExpiryDate = formatDate(this.carFormData.insuranceExpiryDate) + } + if (this.carFormData.nextInspectionDate) { + this.carFormData.nextInspectionDate = formatDate(this.carFormData.nextInspectionDate) + } + this.$refs.carPopup.open() + }, + /** + * @param {Object} type获取时间 + */ + getDate(type) { + const date = new Date(); + let year = date.getFullYear(); + let month = date.getMonth() + 1; + let day = date.getDate(); + + if (type === 'start') { + year = year - 10; + } else if (type === 'end') { + year = year + 10; + } + month = month > 9 ? month : '0' + month; + day = day > 9 ? day : '0' + day; + return `${year}-${month}-${day}`; + }, + /** + * 修改下次年检时间 + * @param {Object} e + */ + bindnextInspectionDateChange(e) { + console.log('e', e); + this.carFormData.nextInspectionDate = e.detail.value + }, + bindInsuranceExpiryDateChange(e) { + this.carFormData.insuranceExpiryDate = e.detail.value + }, + submitCarForm() { + // 如果 nextInspectionDate 有值,并且格式是 yyyy-MM-dd,就补上时分秒 + if (this.carFormData.nextInspectionDate) { + this.carFormData.nextInspectionDate = new Date(this.carFormData.nextInspectionDate).getTime() + } + // 如果 nextInspectionDate 有值,并且格式是 yyyy-MM-dd,就补上时分秒 + if (this.carFormData.insuranceExpiryDate) { + this.carFormData.insuranceExpiryDate = new Date(this.carFormData.insuranceExpiryDate).getTime() + } + + + request({ + url: `/admin-api/base/carMain/update`, + method: 'PUT', + data: this.carFormData + }) + + this.$refs.carPopup.close() + }, /** * 监听输入框 */ @@ -669,7 +808,11 @@ prviewImage(imgList, index) { let urls = [] imgList.forEach(i => { - urls.push(this.imgUrlPrex + i.image) + if (!i.image.includes("http")) { + urls.push(this.imgUrlPrex + i.image) + } else { + urls.push(i.image) + } }) uni.previewImage({ urls: urls, @@ -782,6 +925,7 @@ } }, afterRead(file) { + console.log('文件', file); uni.showLoading({ title: '正在上传中...', mask: true @@ -1012,8 +1156,11 @@ } if (this.loginUser.roleCodes.includes("repair_staff")) { //维修工角色,可以提交配件申请 + const has02 = this.ticketInfo.items.some(item => item.itemType === '02'); + console.log('has02', has02); this.content.push({ - text: '配件申请', + // text: '配件申请', + text: !has02 ? '是否申请配件' : '是否增加配件', active: false, code: "apply" }) @@ -1275,6 +1422,7 @@ }).then((res) => { let resultObj = res.data resultObj.statusStr = getOrderStatusText(res.data.ticketsStatus, res.data.isHandover) + //注册日期 if (null != resultObj.carInfo.carRegisterDate) { resultObj.carRegisterDate = formatDate(resultObj.carInfo.carRegisterDate) @@ -1379,8 +1527,17 @@ } if (resultObj.carInfo.carLicenseImg) { resultObj.carInfo.carLicenseImg.split(",").map((item) => { + let url = item.includes("http") ? item : this.imgUrlPrex + item; this.carImgList.push({ - image: item + image: url + }); + }); + + } + if (resultObj.carInfo.archivesPhoto) { + resultObj.carInfo.archivesPhoto.split(",").map((item) => { + this.cararchivesPhotos.push({ + url: this.$baseImageUrl + item }) }) } @@ -1457,7 +1614,7 @@ url: '/pages-order/reviewList/reviewList?formData=' + encodeURIComponent(JSON.stringify( formData)) }) - } + }, } } @@ -2309,4 +2466,8 @@ background-color: #efefef; } } + + .car-popup-out { + padding: 30rpx 40rpx; + } \ No newline at end of file diff --git a/pages-repair/apply/applyForm.vue b/pages-repair/apply/applyForm.vue index ce1645c..e2e306d 100644 --- a/pages-repair/apply/applyForm.vue +++ b/pages-repair/apply/applyForm.vue @@ -33,9 +33,9 @@ - - - + + + @@ -46,34 +46,38 @@ 确认添加 拍照上传 - - - - - - {{ item.name }} - - 单位: - {{ item.unitText }} - - - - {{ item.num }} - - - - - - - - - - - + + + + + + {{ item.name }} + + 单位: + {{ item.unitText }} + + + + {{ item.num }} + + + + + + + + + + + + + 备注 + + @@ -96,7 +100,9 @@ } from "@/utils/auth"; import upload from "@/utils/upload"; import config from "@/config"; - import {data} from "uview-ui/libs/mixin/mixin"; + import { + data + } from "uview-ui/libs/mixin/mixin"; export default { components: { VNavigationBar @@ -124,8 +130,10 @@ isTriggered: false, userInfo: null, fileList: [], + //备注 + remark: undefined, sizeType: ['compressed'], - twId: null + twId: null }; }, computed: { @@ -138,74 +146,74 @@ onLoad(data) { this.userInfo = getUserInfo() this.ticketId = data.ticketId - this.twId = data.twId - this.ifHouse = data.ifHouse + this.twId = data.twId + this.ifHouse = data.ifHouse }, onShow() { this.init() }, methods: { - closeWaresPopup(){ - this.$refs.waresPopup.close() - //刷新数据列表 - this.chooseTab("") - }, - /** - * 打开已选择的配件弹出框 - */ - openChoosed(){ - if(this.selectedRepairList.length==0){ - return - } - this.$refs.waresPopup.open("bottom") - }, - addTwi(){ - if (!this.selectedRepairList || this.selectedRepairList.length === 0){ - uni.showToast({ - title: '请选择配件!', - icon: 'none' - }) - return - } - let dataObj = { - id: this.twId - } - dataObj.items = [...this.selectedRepairList.map(item => { - return { - id: item.id, - count: item.num, - name: item.name - } - })] - if(this.ifHouse){ - //仓管 - dataObj.ifHouseAdd = true - }else{ - //服务顾问 - dataObj.ifHouseAdd = false - } - request({ - url: "/admin-api/repair/twi/addTwi", - method: 'post', - data: dataObj - }).then(res => { - uni.showToast({ - title: '提交成功!', - icon: 'none' - }) - setTimeout(() => { - uni.navigateBack() - }, 700) - }) - }, + closeWaresPopup() { + this.$refs.waresPopup.close() + //刷新数据列表 + this.chooseTab("") + }, + /** + * 打开已选择的配件弹出框 + */ + openChoosed() { + if (this.selectedRepairList.length == 0) { + return + } + this.$refs.waresPopup.open("bottom") + }, + addTwi() { + if (!this.selectedRepairList || this.selectedRepairList.length === 0) { + uni.showToast({ + title: '请选择配件!', + icon: 'none' + }) + return + } + let dataObj = { + id: this.twId + } + dataObj.items = [...this.selectedRepairList.map(item => { + return { + id: item.id, + count: item.num, + name: item.name + } + })] + if (this.ifHouse) { + //仓管 + dataObj.ifHouseAdd = true + } else { + //服务顾问 + dataObj.ifHouseAdd = false + } + request({ + url: "/admin-api/repair/twi/addTwi", + method: 'post', + data: dataObj + }).then(res => { + uni.showToast({ + title: '提交成功!', + icon: 'none' + }) + setTimeout(() => { + uni.navigateBack() + }, 700) + }) + }, openUpload() { this.$refs.popup.open("bottom") }, afterRead(file) { - uni.showLoading({ - title: '正在上传中...', - mask:true - }); + uni.showLoading({ + title: '正在上传中...', + mask: true + }); for (let i = 0; i < file.tempFilePaths.length; i++) { upload({ url: '/admin-api/infra/file/upload', @@ -214,9 +222,9 @@ this.fileList.push({ url: config.baseImageUrl + res.data }) - if(i==file.tempFilePaths.length-1){ - uni.hideLoading() - } + if (i == file.tempFilePaths.length - 1) { + uni.hideLoading() + } console.log(this.fileList) }) } @@ -291,7 +299,7 @@ * 分页加载所有配件 */ pageList() { - let that = this + let that = this let paramsObj = { pageNo: this.pageNo, pageSize: this.pageSize @@ -324,19 +332,19 @@ } return m }) - console.log(thisDataList,"thisDataList") + console.log(thisDataList, "thisDataList") //判断 如果获取的数据的页码不是第一页,就让之前赋值获取过的数组数据 concat连接 刚获取的第n页数据 if (that.pageNo != 1) { - that.repairList = that.repairList.concat(thisDataList) + that.repairList = that.repairList.concat(thisDataList) } else { - that.repairList = thisDataList + that.repairList = thisDataList } //将获取的总条数赋值 - that.total = res.data.total - that.isTriggered = false - }else{ - that.isTriggered = false - } + that.total = res.data.total + that.isTriggered = false + } else { + that.isTriggered = false + } }) }, addNum(repair) { @@ -390,34 +398,37 @@ }) dataObj.items = itemList } - if (this.fileList.length > 0){ - dataObj.images = this.fileList.map(item => { - console.log(item) - return item.path.replace(config.baseImageUrl, '') - }).join(",") - } + if (this.fileList.length > 0) { + dataObj.images = this.fileList.map(item => { + console.log(item) + return item.path.replace(config.baseImageUrl, '') + }).join(",") + } + if (this.remark) { + dataObj.remark = this.remark + } } - request({ - url: '/admin-api/repair/tw/update', - method: 'POST', - data:dataObj - }).then((res) => { - console.log(res) - if (res.code == 200) { - uni.showToast({ - title: '提交成功!', - icon: 'none' - }) - setTimeout(() => { - uni.navigateBack() - }, 700) - }else{ - uni.showToast({ - title: '提交失败!', - icon: 'none' - }) - } - }) + request({ + url: '/admin-api/repair/tw/update', + method: 'POST', + data: dataObj + }).then((res) => { + console.log(res) + if (res.code == 200) { + uni.showToast({ + title: '提交成功!', + icon: 'none' + }) + setTimeout(() => { + uni.navigateBack() + }, 700) + } else { + uni.showToast({ + title: '提交失败!', + icon: 'none' + }) + } + }) // if(this.selectedRepairList.length>0){ // let itemList = [] // this.selectedRepairList.map((item)=>{ @@ -608,39 +619,40 @@ color: #FFFFFF; } } - .listItem { - padding: 30rpx 0; - border-bottom: 2rpx solid #DDDDDD; - &:last-child { - border-bottom: none; - } + .listItem { + padding: 30rpx 0; + border-bottom: 2rpx solid #DDDDDD; - .repairName { - font-size: 32rpx; - color: #333333; - margin-bottom: 20rpx; - } + &:last-child { + border-bottom: none; + } - .repairBottom { - display: flex; - align-items: center; - justify-content: space-between; - } + .repairName { + font-size: 32rpx; + color: #333333; + margin-bottom: 20rpx; + } - .repairDesc { - font-size: 28rpx; - color: #858BA0; - } + .repairBottom { + display: flex; + align-items: center; + justify-content: space-between; + } - .repairUnit { - color: #333333; - } + .repairDesc { + font-size: 28rpx; + color: #858BA0; + } - .repairBtns { - display: flex; - align-items: center; - column-gap: 10rpx; - } - } - + .repairUnit { + color: #333333; + } + + .repairBtns { + display: flex; + align-items: center; + column-gap: 10rpx; + } + } + \ No newline at end of file diff --git a/pages.json b/pages.json index 19ce4da..f82db09 100644 --- a/pages.json +++ b/pages.json @@ -81,6 +81,13 @@ "style": { "navigationBarTitleText": "" } + }, + { + "path" : "pages/white/white", + "style" : + { + "navigationBarTitleText" : "" + } } ], "subPackages": [{ @@ -345,12 +352,11 @@ { "root": "pages-detail", "pages": [{ - "path": "detail/detail", - "style": { - "navigationBarTitleText": "详情页" - } + "path": "detail/detail", + "style": { + "navigationBarTitleText": "详情页" } - ] + }] }, { "root": "pages-business", @@ -368,7 +374,7 @@ } }, { - "path" : "white/white", + "path" : "statistics/statistics", "style" : { "navigationBarTitleText" : "" diff --git a/uni_modules/uni-icons/changelog.md b/uni_modules/uni-icons/changelog.md index 0261131..62e7682 100644 --- a/uni_modules/uni-icons/changelog.md +++ b/uni_modules/uni-icons/changelog.md @@ -1,5 +1,7 @@ -## 2.0.10(2024-06-07) -- 优化 uni-app x 中,size 属性的类型 +## 2.0.12(2025-08-26) +- 优化 uni-app x 下 size 类型问题 +## 2.0.11(2025-08-18) +- 修复 图标点击事件返回 ## 2.0.9(2024-01-12) fix: 修复图标大小默认值错误的问题 ## 2.0.8(2023-12-14) diff --git a/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue b/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue index 8740559..53eb2ea 100644 --- a/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue +++ b/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue @@ -1,91 +1,91 @@ diff --git a/uni_modules/uni-icons/components/uni-icons/uni-icons.vue b/uni_modules/uni-icons/components/uni-icons/uni-icons.vue index 7da5356..1bd3d5e 100644 --- a/uni_modules/uni-icons/components/uni-icons/uni-icons.vue +++ b/uni_modules/uni-icons/components/uni-icons/uni-icons.vue @@ -85,8 +85,8 @@ } }, methods: { - _onClick() { - this.$emit('click') + _onClick(e) { + this.$emit('click', e) } } } @@ -107,4 +107,4 @@ text-decoration: none; text-align: center; } - + \ No newline at end of file diff --git a/uni_modules/uni-icons/package.json b/uni_modules/uni-icons/package.json index 6b681b4..60e45f0 100644 --- a/uni_modules/uni-icons/package.json +++ b/uni_modules/uni-icons/package.json @@ -1,7 +1,7 @@ { "id": "uni-icons", "displayName": "uni-icons 图标", - "version": "2.0.10", + "version": "2.0.12", "description": "图标组件,用于展示移动端常见的图标,可自定义颜色、大小。", "keywords": [ "uni-ui", @@ -11,12 +11,14 @@ ], "repository": "https://github.com/dcloudio/uni-ui", "engines": { - "HBuilderX": "^3.2.14" + "HBuilderX": "^3.2.14", + "uni-app": "^4.08", + "uni-app-x": "^4.61" }, "directories": { "example": "../../temps/example_temps" }, -"dcloudext": { + "dcloudext": { "sale": { "regular": { "price": "0.00" @@ -34,56 +36,76 @@ "permissions": "无" }, "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui", - "type": "component-vue" + "type": "component-vue", + "darkmode": "x", + "i18n": "x", + "widescreen": "x" }, "uni_modules": { - "dependencies": ["uni-scss"], + "dependencies": [ + "uni-scss" + ], "encrypt": [], "platforms": { "cloud": { - "tcb": "y", - "aliyun": "y", - "alipay": "n" + "tcb": "x", + "aliyun": "x", + "alipay": "x" }, "client": { - "App": { - "app-vue": "y", - "app-nvue": "y", - "app-uvue": "y" + "uni-app": { + "vue": { + "vue2": "√", + "vue3": "√" + }, + "web": { + "safari": "√", + "chrome": "√" + }, + "app": { + "vue": "√", + "nvue": "-", + "android": { + "extVersion": "", + "minVersion": "29" + }, + "ios": "√", + "harmony": "√" + }, + "mp": { + "weixin": "√", + "alipay": "√", + "toutiao": "√", + "baidu": "√", + "kuaishou": "-", + "jd": "-", + "harmony": "-", + "qq": "√", + "lark": "-" + }, + "quickapp": { + "huawei": "√", + "union": "√" + } }, - "H5-mobile": { - "Safari": "y", - "Android Browser": "y", - "微信浏览器(Android)": "y", - "QQ浏览器(Android)": "y" - }, - "H5-pc": { - "Chrome": "y", - "IE": "y", - "Edge": "y", - "Firefox": "y", - "Safari": "y" - }, - "小程序": { - "微信": "y", - "阿里": "y", - "百度": "y", - "字节跳动": "y", - "QQ": "y", - "钉钉": "y", - "快手": "y", - "飞书": "y", - "京东": "y" - }, - "快应用": { - "华为": "y", - "联盟": "y" - }, - "Vue": { - "vue2": "y", - "vue3": "y" + "uni-app-x": { + "web": { + "safari": "√", + "chrome": "√" + }, + "app": { + "android": { + "extVersion": "", + "minVersion": "29" + }, + "ios": "√", + "harmony": "√" + }, + "mp": { + "weixin": "√" + } } } } } -} +} \ No newline at end of file diff --git a/utils/utils.js b/utils/utils.js index 3935065..b18f22f 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -333,6 +333,9 @@ export function builderOrder(order) { } export function formatDate(timestamp) { + if (!timestamp) { + return '' + } // 将时间戳转换为Date对象 const date = new Date(timestamp); // 获取年月日时分秒 @@ -503,4 +506,96 @@ export function formatDateCus(date) { const m = (date.getMonth() + 1).toString().padStart(2, '0') const d = date.getDate().toString().padStart(2, '0') return `${y}-${m}-${d}` +} + +/** + * 将扁平数组转换为树形结构,并支持按 sort 字段排序 + * @param {Array} data 源数据 + * @param {String} id 节点ID字段名,默认为 'id' + * @param {String} parentId 父节点ID字段名,默认为 'parentId' + * @param {String} children 子节点字段名,默认为 'children' + * @param {Number|String} rootId 根节点ID值,默认为最小的parentId或0 + * @param {String} sortKey 排序字段名,默认为 'sort' + * @returns {Array} 树形结构数据 + */ +export function handleTree(data, id, parentId, children, rootId, sortKey) { + // 参数默认值处理 + id = id || 'id'; + parentId = parentId || 'parentId'; + children = children || 'children'; + sortKey = sortKey || 'sort'; + + // 自动计算根节点ID(取最小的parentId,若无则用0) + rootId = rootId || Math.min(...data.map(item => item[parentId])) || 0; + + // 深拷贝源数据以避免污染原数组 + const cloneData = JSON.parse(JSON.stringify(data)); + + // 先对所有数据进行排序(确保父节点在前) + cloneData.sort((a, b) => { + const aSort = a[sortKey] ?? 0; // 使用空值合并运算符处理undefined + const bSort = b[sortKey] ?? 0; + return aSort - bSort; // 升序排序 + }); + + // 构建哈希表加速查找 + const nodeMap = {}; + cloneData.forEach(item => { + nodeMap[item[id]] = item; + item[children] = []; // 初始化children数组 + }); + + // 构建树形结构 + const tree = []; + cloneData.forEach(item => { + if (item[parentId] === rootId) { + // 根节点直接加入结果 + tree.push(item); + } else { + // 非根节点找到父节点并插入 + const parent = nodeMap[item[parentId]]; + parent?.[children]?.push(item); + } + }); + + // 递归排序所有子节点 + const sortChildren = (nodes) => { + nodes.forEach(node => { + if (node[children]?.length) { + node[children].sort((a, b) => { + const aSort = a[sortKey] ?? 0; + const bSort = b[sortKey] ?? 0; + return aSort - bSort; + }); + sortChildren(node[children]); + } + }); + }; + sortChildren(tree); + + return tree.length ? tree : data; // 空树时返回原数据 +} + +/** + * 将树形结构数据转成 uniapp multiSelector picker 可用的二维数组 + * @param {Array} tree 树形结构数据 + * @param {String} labelKey 节点显示字段,默认为 'name' + * @param {String} childrenKey 子节点字段,默认为 'children' + * @returns {Array} picker二维数组,例如 [[一级], [二级], [三级]...] + */ +export function toPickerData(tree, labelKey = 'name', childrenKey = 'children') { + const result = [] + + function buildColumns(nodes, level = 0) { + if (!nodes || !nodes.length) return + // 当前层级的所有 name + result[level] = nodes.map(n => n[labelKey]) + // 默认取第一个子节点继续递归 + if (nodes[0][childrenKey] && nodes[0][childrenKey].length) { + buildColumns(nodes[0][childrenKey], level + 1) + } + } + + buildColumns(tree, 0) + return result } \ No newline at end of file