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

View File

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

View File

@ -20,7 +20,7 @@
</view>
<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>
</view>
</view>
@ -46,36 +46,7 @@ export default {
phone: '',
userInfo: null,
carList: [],
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: ''
// }
]
orderList: []
}
},
onLoad(data) {
@ -120,10 +91,10 @@ export default {
})
}
},
addOrder(){
addOrder(carId){
console.log('执行')
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">
<view class="card">
<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 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 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 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>
</view>
</u-form>
<!-- 单位 -->
<u-action-sheet
:actions="unitList"
:show="unitType"
title="请选择单位"
@close="unitType = false"
@select="unitSelect"
>
</u-action-sheet>
</view>
<view class="footer">
<view class="btnItem edit" @click="submit">
@ -29,18 +67,79 @@
<script>
import VNavigationBar from "@/components/VNavigationBar.vue";
import {getDictByCode, convertToDouble} from "@/utils/utils";
import request from "@/utils/request";
export default {
components: {VNavigationBar},
data() {
return {
pageTitle: '新增维修项目',
project:{},
project: {
isPublic: 0,
isSelf: 0
},
unitType: false,
unitList: [],
unit: '',
};
},
onLoad(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>

View File

@ -230,4 +230,22 @@ export function formatDate(timestamp) {
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'; // 可以设置一个默认值
}
}