# Conflicts:
#	utils/utils.js
This commit is contained in:
Vinjor 2024-10-22 15:07:17 +08:00
commit 124492b152
7 changed files with 192 additions and 70 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()
if (this.typeList && this.typeList.length > 0) {
this.typeId = this.typeList[0].id
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

@ -12,7 +12,7 @@
<!-- <u-checkbox-group-->
<!-- placement="column"-->
<!-- v-model="checked">-->
<radio-group @change="radioChange" v-if="type == 'xs'">
<radio-group @change="radioChange" v-if="type == 'xs' || !type">
<label v-for="(item, index) in list" :key="item.userId" class="userItem">
<view class="info">
<text class="name">{{ item.userName }}</text>
@ -70,16 +70,16 @@ export default {
checkedUserId: "",
checkedUserName: "",
ifDetail: false,
type: "sg",
type: "",
sgIds: [], //
sgNames : [],
xsId: [],
xsName: []
projectId: ''
}
},
onLoad(data) {
console.log("data", data)
if (data.id) {
console.log('执行了派单')
this.ticketId = data.id
this.workByTicketId()
}
@ -99,6 +99,9 @@ export default {
if (data.ticketId) {
this.ticketId = data.ticketId
}
if (data.projectId) {
this.projectId = data.projectId
}
},
methods: {
radioChange: function (evt) {
@ -124,6 +127,11 @@ export default {
this.list.map((item) => {
item.userName = item.name
})
if (this.list.length > 0) {
console.log(this.list[0].userId)
this.checkedUserId = this.list[0].userId
this.checkedUserName = this.list[0].userName
}
})
},
/**
@ -157,6 +165,11 @@ export default {
this.list.map((item) => {
item.workTypeText = getDictTextByCodeAndValue('repair_work_type', item.workType)
})
if (this.list.length > 0) {
console.log(this.list[0].userId)
this.checkedUserId = this.list[0].userId
this.checkedUserName = this.list[0].userName
}
})
},
cs(e){
@ -188,10 +201,10 @@ export default {
//
const sgIds = this.sgIds.join(',')
const sgNames = this.sgNames.join(',')
console.log(sgIds)
console.log(sgNames)
console.log('this.projectId',this.projectId)
const param = {
ticketId: this.ticketId,
projectId: this.projectId,
repairIds: sgIds,
repairNames: sgNames,
}
@ -220,6 +233,7 @@ export default {
//
const param = {
ticketId: this.ticketId,
projectId: this.projectId,
saleId: this.checkedUserId,
saleName: this.checkedUserName,
}

View File

@ -349,7 +349,8 @@ export default {
salesman: [],
constructor: []
}
]
],
submitData:[]
};
},
onLoad(data) {
@ -692,7 +693,7 @@ export default {
console.log('proj', proj)
})
uni.navigateTo({
url: `/pages-order/choosePeople/choosePeople?type=${type}&ticketId=${this.ticketId}`
url: `/pages-order/choosePeople/choosePeople?type=${type}&ticketId=${this.ticketId}&projectId=${proj.projectId}`
// url: `/pages-order/choosePeople/choosePeople?type=${type}&id=${this.ticketId}`
})
},

View File

@ -5,19 +5,51 @@
<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">
<picker @change="picker($event)" :value="arrayIndex" :range="unitList" range-key="label">
<view class="uni-input">{{ unitList[arrayIndex].label }}</view>
</picker>
</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 +61,86 @@
<script>
import VNavigationBar from "@/components/VNavigationBar.vue";
import {getDictByCode, convertToDouble} from "@/utils/utils";
import request from "@/utils/request";
import {browser} from "@/unpackage/dist/dev/mp-weixin/common/vendor";
export default {
components: {VNavigationBar},
data() {
return {
pageTitle: '新增维修项目',
project:{},
project: {
isPublic: 0,
isSelf: 0
},
unitType: false,
unitList: [],
unit: '',
arrayIndex: 0,
};
},
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.name == null || this.project.code == null || this.project.cost == null || this.project.price == null || this.project.spec == null || this.project.unit == null || this.project.manHour == null){
uni.showToast({
title: '请完善信息',
icon: 'none'
})
return
}
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'
})
}
})
},
picker(e) {
//
this.arrayIndex = e.target.value;
this.project.unit = this.unitList[e.target.value].value
},
getDictByCode() {
this.unitList = getDictByCode('repair_unit')
if (this.unitList.length > 0) {
this.project.unit = this.unitList[0].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,6 +230,24 @@ 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'; // 可以设置一个默认值
}
}
/**
* 生成一个16位的纯数字的唯一ID
* 生成策略 head + 当前时间戳 + 随机数