维修app完善了再预约工单页面跳转到新建工单页面,新增维修项目功能

This commit is contained in:
许允枞 2024-10-22 11:54:28 +08:00
parent c4a0c71e4c
commit 85defcaac3
5 changed files with 168 additions and 62 deletions

View File

@ -39,8 +39,9 @@
<image v-if="selectedProj && selectedProj.find(f => f.id === item.id)" class="projChooseIcon" <image v-if="selectedProj && selectedProj.find(f => f.id === item.id)" class="projChooseIcon"
mode="aspectFit" src="/static/icons/duihao.png"></image> mode="aspectFit" src="/static/icons/duihao.png"></image>
</view> </view>
<view class="projItem" @click="addProject()"> <view class="projItem" @click="addProject()" v-if="show">
<text class="projName">新增维修项目</text> <!-- <text class="projName">新增维修项目</text>-->
<button class="addBtn">新增维修项目</button>
</view> </view>
</view> </view>
</view> </view>
@ -63,18 +64,39 @@ export default {
], ],
typeList: [], typeList: [],
typeId: 1, typeId: 1,
groupList: [] groupList: [],
show: false
} }
}, },
onLoad() {
//
uni.$on('projectCreated', this.handleProjectCreated);
},
onUnload() {
//
uni.$off('projectCreated');
},
methods: { methods: {
open(selectedProj = []) { open(selectedProj = []) {
console.log("执行onload") if (selectedProj) {
this.selectedProj = JSON.parse(JSON.stringify(selectedProj))
}
this.$refs.popup.open() this.$refs.popup.open()
this.getProjeectList() this.getProjeectList()
if (this.typeList && this.typeList.length > 0) { setTimeout(() => {
this.typeId = this.typeList[0].id if (this.typeList && this.typeList.length > 0) {
this.typeId = this.typeList[0].id
this.getProject()
this.show = true
}
},500)
//
uni.$on('projectCreated', (data) => {
//
this.selectedProj.push(data)
this.getProject() this.getProject()
} });
// this.selectedProj = JSON.parse(JSON.stringify(selectedProj)) // this.selectedProj = JSON.parse(JSON.stringify(selectedProj))
}, },
removeProj(index) { removeProj(index) {
@ -91,7 +113,6 @@ export default {
chooseType(type) { chooseType(type) {
this.typeId = type.id this.typeId = type.id
this.getProject() this.getProject()
console.log("this.groupList",this.groupList)
// this.typeId = type.typeId // this.typeId = type.typeId
}, },
addProject() { addProject() {
@ -102,7 +123,7 @@ export default {
getProjeectList() { getProjeectList() {
const params = { const params = {
pageNo: 1, pageNo: 1,
pageSize: 10000, pageSize: 100000,
type: '03' type: '03'
} }
request({ request({
@ -111,7 +132,6 @@ export default {
method: 'GET', method: 'GET',
params: params params: params
}).then(res => { }).then(res => {
console.log("分类",res);
this.typeList = res.data this.typeList = res.data
}) })
}, },
@ -125,7 +145,6 @@ export default {
type: this.typeId type: this.typeId
} }
}).then(res => { }).then(res => {
console.log("项目",res);
this.groupList = res.data.records this.groupList = res.data.records
}) })
}, },

View File

@ -202,11 +202,22 @@ export default {
} }
}, },
onLoad(data) { onLoad(data) {
console.log('预约订单页面跳转传进来的数据',data)
this.ticketNo = this.createUniqueCodeByHead('GD') this.ticketNo = this.createUniqueCodeByHead('GD')
if (data.phone) { if (data.phone) {
this.phone = data.phone this.phone = data.phone
this.listUserInfo() this.listUserInfo()
} }
setTimeout(() => {
if (data.carId) {
for (let i = 0; i < this.carList.length; i++) {
if (data.carId == this.carList[i].id) {
this.activeCarIndex = i
break
}
}
}
},500)
}, },
onShow() { onShow() {
if (this.phone != '') { if (this.phone != '') {
@ -221,11 +232,6 @@ export default {
}, },
// //
submit() { submit() {
console.log('userInfo', this.userInfo)
console.log(this.carList[this.activeCarIndex])
console.log('selectedProj', this.selectedProj)
console.log("ticketType", this.ticketType)
console.log('登陆人信息', getUserInfo())
if (this.userInfo === null || this.carList.length === 0 || this.selectedProj.length === 0) { if (this.userInfo === null || this.carList.length === 0 || this.selectedProj.length === 0) {
uni.showToast({ uni.showToast({
title: '请完善信息', title: '请完善信息',
@ -257,7 +263,6 @@ export default {
title: '创建成功', title: '创建成功',
icon: 'success' icon: 'success'
}) })
console.log("工单提交返回的结果", res)
uni.navigateTo({ uni.navigateTo({
url: `/pages-order/orderDetail/orderDetail?id=${res.data.id}&isDetail=0` url: `/pages-order/orderDetail/orderDetail?id=${res.data.id}&isDetail=0`
}); });
@ -266,7 +271,6 @@ export default {
listUserInfo() { listUserInfo() {
this.carList = [] this.carList = []
this.userInfo = null this.userInfo = null
console.log("获取用户信息")
if (this.phone != '') { if (this.phone != '') {
const params = { const params = {
phoneNumber: this.phone phoneNumber: this.phone
@ -276,7 +280,6 @@ export default {
method: 'GET', method: 'GET',
params: params params: params
}).then(res => { }).then(res => {
console.log(res);
if (res.data.records.length > 0) { if (res.data.records.length > 0) {
this.userInfo = res.data.records[0] this.userInfo = res.data.records[0]
this.getCarList() this.getCarList()
@ -325,7 +328,6 @@ export default {
method: 'GET', method: 'GET',
params: params params: params
}).then(res => { }).then(res => {
console.log(res);
this.carList = res.data.records this.carList = res.data.records
// //
this.carList.forEach(item => { this.carList.forEach(item => {
@ -338,7 +340,6 @@ export default {
editCarInfo(index) { editCarInfo(index) {
bus.$off('updateCarInfo') bus.$off('updateCarInfo')
bus.$on('updateCarInfo', (carInfo) => { bus.$on('updateCarInfo', (carInfo) => {
console.log('Car', carInfo)
if (index) { if (index) {
this.carList[index] = carInfo this.carList[index] = carInfo
} else { } else {
@ -361,7 +362,6 @@ export default {
editUserInfo(userInfo) { editUserInfo(userInfo) {
bus.$off('updateUserInfo') bus.$off('updateUserInfo')
bus.$on('updateUserInfo', (userInfo) => { bus.$on('updateUserInfo', (userInfo) => {
console.log('userInfo', userInfo)
this.userInfo = userInfo this.userInfo = userInfo
}) })
uni.navigateTo({ uni.navigateTo({
@ -373,7 +373,6 @@ export default {
}, },
projConfirm(proj) { projConfirm(proj) {
this.selectedProj = proj this.selectedProj = proj
console.log("回到主页后", proj)
} }
} }
} }

View File

@ -20,7 +20,7 @@
</view> </view>
<view class="orderList"> <view class="orderList">
<view v-for="item in orderList" :key="item.id" class="orderItem" @click="addOrder"> <view v-for="item in orderList" :key="item.id" class="orderItem" @click="addOrder(item.carId)">
<booking-order-card :order="item"></booking-order-card> <booking-order-card :order="item"></booking-order-card>
</view> </view>
</view> </view>
@ -46,36 +46,7 @@ export default {
phone: '', phone: '',
userInfo: null, userInfo: null,
carList: [], carList: [],
orderList: [ orderList: []
// {
// orderNo: '1209840149750105501',
// flag: 1, flagStr: '', carNum: 'A 184AO1',
// carModel: ' 2024 A6L',
// projectList: [
// {name: '', id: 1},
// {name: '', id: 2},
// {name: '', id: 3}
// ],
// userName: '',
// userPhone: '157****6879',
// appointDate: '2024-10-20 12:00',
// counselorName: ''
// },
// {
// orderNo: '1209840149750105501',
// flag: 1, flagStr: '', carNum: 'A 184AO1',
// carModel: ' 2024 A6L',
// projectList: [
// {name: '', id: 1},
// {name: '', id: 2},
// {name: '', id: 3}
// ],
// userName: '',
// userPhone: '157****6879',
// appointDate: '2024-10-20 12:00',
// counselorName: ''
// }
]
} }
}, },
onLoad(data) { onLoad(data) {
@ -120,10 +91,10 @@ export default {
}) })
} }
}, },
addOrder(){ addOrder(carId){
console.log('执行') console.log('执行')
uni.navigateTo({ uni.navigateTo({
url: `/pages-order/addOrder/addOrder?phone=${this.phone}` url: `/pages-order/addOrder/addOrder?phone=${this.phone}&carId=${carId}`
}); });
}, },
} }

View File

@ -5,19 +5,57 @@
<u-form labelPosition="top"> <u-form labelPosition="top">
<view class="card"> <view class="card">
<u-form-item borderBottom label="名称" labelWidth="200"> <u-form-item borderBottom label="名称" labelWidth="200">
<u-input v-model="project.vin" border="none" placeholder="请输入名称"></u-input> <u-input v-model="project.name" border="none" placeholder="请输入名称"></u-input>
</u-form-item> </u-form-item>
<u-form-item borderBottom label="编码" labelWidth="200"> <u-form-item borderBottom label="编码" labelWidth="200">
<u-input v-model="project.engineNumber" border="none" placeholder="请输入编码"></u-input> <u-input v-model="project.code" border="none" placeholder="请输入编码"></u-input>
</u-form-item>
<u-form-item borderBottom label="成本" labelWidth="200">
<u-input v-model="project.cost" border="none" placeholder="请输入成本" @blur="costBlur('cost')"></u-input>
</u-form-item>
<u-form-item borderBottom label="售价" labelWidth="200">
<u-input v-model="project.price" border="none" placeholder="请输入售价" @blur="costBlur('price')"></u-input>
</u-form-item> </u-form-item>
<u-form-item borderBottom label="规格" labelWidth="200"> <u-form-item borderBottom label="规格" labelWidth="200">
<u-input v-model="project.engineNumber" border="none" placeholder="请输入规格"></u-input> <u-input v-model="project.spec" border="none" placeholder="请输入规格"></u-input>
</u-form-item>
<u-form-item borderBottom label="单位" labelWidth="200" @click="unitType = true;">
<u-input
v-model="unit"
border="none"
disabled
disabledColor="#ffffff"
placeholder="请选择单位"
></u-input>
<u-icon
slot="right"
name="arrow-right"
></u-icon>
</u-form-item> </u-form-item>
<u-form-item borderBottom label="工时" labelWidth="200"> <u-form-item borderBottom label="工时" labelWidth="200">
<u-input v-model="project.engineNumber" border="none" placeholder="请输入规格"></u-input> <u-input v-model="project.manHour" border="none" placeholder="请输入工时"></u-input>
</u-form-item>
<u-form-item borderBottom label="备注" labelWidth="200">
<u-input v-model="project.remark" border="none" placeholder="请输入备注"></u-input>
</u-form-item>
<u-form-item borderBottom label="是否自助" labelWidth="200">
<switch v-model="project.isSelf" @change="handleSwitchChange('isSelf',project.isSelf)" style="transform:scale(0.7)"/>
</u-form-item>
<u-form-item borderBottom label="分店公用" labelWidth="200">
<switch v-model="project.isPublic" @change="handleSwitchChange('isPublic',project.isPublic)" style="transform:scale(0.7)"/>
</u-form-item> </u-form-item>
</view> </view>
</u-form> </u-form>
<!-- 单位 -->
<u-action-sheet
:actions="unitList"
:show="unitType"
title="请选择单位"
@close="unitType = false"
@select="unitSelect"
>
</u-action-sheet>
</view> </view>
<view class="footer"> <view class="footer">
<view class="btnItem edit" @click="submit"> <view class="btnItem edit" @click="submit">
@ -29,18 +67,79 @@
<script> <script>
import VNavigationBar from "@/components/VNavigationBar.vue"; import VNavigationBar from "@/components/VNavigationBar.vue";
import {getDictByCode, convertToDouble} from "@/utils/utils";
import request from "@/utils/request";
export default { export default {
components: {VNavigationBar}, components: {VNavigationBar},
data() { data() {
return { return {
pageTitle: '新增维修项目', pageTitle: '新增维修项目',
project:{}, project: {
isPublic: 0,
isSelf: 0
},
unitType: false,
unitList: [],
unit: '',
}; };
}, },
onLoad(options) { onLoad(options) {
console.log("options",options) console.log("options", options)
if (options.typeId) {
this.project.type = options.typeId
}
this.getDictByCode()
}, },
methods: {
submit() {
if (this.project.cost != null){
this.project.cost = Math.floor(this.project.cost,)
}
console.log("this.project", this.project)
request({
url: '/admin-api/repair/project/create',
method: 'POST',
data: this.project,
}).then(res => {
if (res.code == 200) {
//
uni.$emit('projectCreated', res.data);
uni.navigateBack();
} else {
uni.showToast({
title: '添加维修项目失败',
icon: 'none'
})
}
})
},
getDictByCode() {
this.unitList = getDictByCode('repair_unit')
this.unitList.forEach(item => {
item.name = item.label
item.value = item.value
})
},
unitSelect(e) {
console.log('e', e)
this.brandId = e.value
this.unit = e.name
this.project.unit = e.value
},
costBlur(value) {
this.project[value] = convertToDouble(this.project[value], 2)
},
handleSwitchChange(name, value) {
console.log(`${name} 状态改变:`, value);
if (value == 1) {
value =0
}else {
value = 1
}
this.project[name] = value
}
}
} }
</script> </script>

View File

@ -230,4 +230,22 @@ export function formatDate(timestamp) {
return `${year}-${month}-${day}`; return `${year}-${month}-${day}`;
} }
//转换为double
// utils.js
export function convertToDouble(value, decimalPlaces = 1) {
if (value !== undefined && value !== null) {
const parsedValue = parseFloat(value);
if (!isNaN(parsedValue)) {
return parsedValue.toFixed(decimalPlaces);
} else {
console.error('转换失败,值不是有效的数字');
return '0.0'; // 可以设置一个默认值
}
} else {
console.error('值不存在');
return '0.0'; // 可以设置一个默认值
}
}