更新代码

This commit is contained in:
xiao-fajia 2024-09-20 16:21:46 +08:00
parent ba4d3db00d
commit f7699f76bd
4 changed files with 341 additions and 45 deletions

View File

@ -1 +1,11 @@
import request from '@/utils/request'
const preUrl = '/repair/tickets'
export function createTickets(data){
return request({
url: preUrl + "/create",
method: "post",
data
})
}

View File

@ -1,5 +1,5 @@
<template>
<el-select v-model="staffSelected" clearable filterable>
<el-select v-model="staffSelected" clearable filterable @blur="$emit('input-blur', $event)">
<el-option v-for="staff in staffList" :key="staff.id" :label="staff.name" :value="staff.id"/>
</el-select>
</template>

View File

@ -18,22 +18,74 @@
</el-table-column>
<el-table-column align="center" label="规格" width="180" prop="model"/>
<el-table-column align="center" label="编码" width="180" prop="code"/>
<el-table-column align="center" label="数量" width="180" prop="count"/>
<el-table-column align="center" label="数量" width="180" prop="count">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.count"/>
<span class="item__txt">{{ scope.row.count }}</span>
</div>
</el-table-column>
<el-table-column align="center" label="单位" width="180" prop="unit"/>
<el-table-column align="center" label="折扣" width="180"/>
<el-table-column align="center" label="金额" width="180"/>
<el-table-column align="center" label="施工人员" width="180"/>
<el-table-column align="center" label="销售人员" width="180"/>
<el-table-column align="center" label="类型" width="180"/>
<el-table-column align="center" label="账类" width="180"/>
<el-table-column align="center" label="状态" width="180"/>
<el-table-column align="center" label="备注" width="180"/>
<el-table-column align="center" label="单价" width="180" prop="price">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.price"/>
<span class="item__txt">{{ scope.row.price }}</span>
</div>
</el-table-column>
<el-table-column align="center" label="折扣" width="180" prop="discount">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.discount"/>
<span class="item__txt">{{ scope.row.discount }}</span>
</div>
</el-table-column>
<el-table-column align="center" label="金额" width="180" prop="totalPrice">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.totalPrice"/>
<span class="item__txt">{{ scope.row.totalPrice }}</span>
</div>
</el-table-column>
<el-table-column align="center" label="施工人员" width="180" prop="repair">
<div class="item" slot-scope="scope">
<StaffChoose @input-blur="save(scope.row)" class="item__input" v-model="scope.row.repair"
:select-width="'15rem'"/>
<span class="item__txt">{{ scope.row.repair ? scope.row.repair.name : scope.row.repair }}</span>
</div>
</el-table-column>
<el-table-column align="center" label="销售人员" width="180" prop="sale">
<div class="item" slot-scope="scope">
<StaffChoose @input-blur="save(scope.row)" class="item__input" v-model="scope.row.sale"
:select-width="'15rem'"/>
<span class="item__txt">{{ scope.row.sale ? scope.row.sale.name : scope.row.sale }}</span>
</div>
</el-table-column>
<el-table-column align="center" label="类型" width="180" prop="type">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.type"/>
<span class="item__txt">{{ scope.row.type }}</span>
</div>
</el-table-column>
<el-table-column align="center" label="账类" width="180" prop="accountType">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.accountType"/>
<span class="item__txt">{{ scope.row.accountType }}</span>
</div>
</el-table-column>
<el-table-column align="center" label="状态" width="180" prop="itemStatus">
<template slot-scope="scope">
<dict-tag v-if="scope.row.itemStatus" :type="DICT_TYPE.REPAIR_ITEM_STATUS" v-model="scope.row.itemStatus"/>
</template>
</el-table-column>
<el-table-column align="center" label="备注" width="180" prop="remark">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.remark"/>
<span class="item__txt">{{ scope.row.remark }}</span>
</div>
</el-table-column>
<el-table-column label="操作" fixed="right" align="center" width="150">
<template v-slot="scope">
<el-button size="mini" type="text" icon="el-icon-delete"
<el-button size="mini" type="text" icon="el-icon-plus"
>新增
</el-button>
<el-button size="mini" type="text" icon="el-icon-delete"
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDeleteItem(scope.$index)"
>删除
</el-button>
</template>
@ -44,10 +96,11 @@
<script>
import PartChoose from "@/views/repair/Components/PartChoose.vue";
import StaffChoose from "@/views/repair/Components/StaffChoose.vue";
export default {
name: "TicketItem",
components: {PartChoose},
components: {StaffChoose, PartChoose},
props: {
itemType: {
type: String,
@ -60,9 +113,23 @@ export default {
loading: false,
list: [{}],
//
editProp: ["goods"],
editProp: ["goods", 'count', 'price', 'discount', 'repair', 'sale', 'remark', 'type', 'accountType'],
// cell
clickCellMap: {}
clickCellMap: {},
selectRepair: {},
selectSale: {},
formData: {
repair: null,
sale: null,
}
}
},
watch:{
list:{
handler(val){
this.$emit("tableData", val)
},
deep: true
}
},
computed: {
@ -98,12 +165,14 @@ export default {
handleCellClick(row, column, cell, event) {
const property = column.property
if (this.editProp.includes(property)) {
if (!row.id || property !== 'goods') {
// cell
this.saveCellClick(row, cell)
cell.querySelector('.item__txt').style.display = 'none'
cell.querySelector('.item__input').style.display = 'inline'
cell.querySelector('input').focus()
}
}
},
/** 取消编辑状态 */
cancelEditable(cell) {
@ -123,6 +192,11 @@ export default {
},
/** 保存数据 */
save(row) {
// TODO BUG
if (row.id){
row.itemStatus = row.repair ? "02" : "01"
row.totalPrice = row.count * row.price * (row.discount / 10)
}
const id = row.id
// cell
this.clickCellMap[id].forEach(cell => {
@ -131,7 +205,20 @@ export default {
this.clickCellMap[id] = []
},
getPart(data) {
data = {
...data,
count: 1,
discount: 10,
remark: null,
itemStatus: '01',
totalPrice: data.price
}
this.list.splice(this.list.length - 1, 0, data)
},
handleDeleteItem(index) {
if (this.list[index].id) {
this.list.splice(index, 1)
}
}
}
}

View File

@ -92,12 +92,12 @@
</template>
<el-input v-model="selectCar.newMaintenanceMileage"/>
</el-descriptions-item>
<el-descriptions-item :span="3">
<template slot="label">
备注
</template>
<el-input v-model="formData.remark"/>
</el-descriptions-item>
<!-- <el-descriptions-item :span="3">-->
<!-- <template slot="label">-->
<!-- 备注-->
<!-- </template>-->
<!-- <el-input v-model="formData.remark"/>-->
<!-- </el-descriptions-item>-->
<el-descriptions-item>
<template slot="label">
服务顾问
@ -129,9 +129,9 @@
</el-select>
</el-col>
</el-row>
<TicketItem item-type="project"/>
<TicketItem v-if="createTicketType" item-type="part"/>
<TicketItem v-if="createTicketType" item-type="other"/>
<TicketItem item-type="project" @tableData="projectData"/>
<TicketItem v-if="createTicketType" item-type="part" @tableData="partData"/>
<TicketItem v-if="createTicketType" item-type="other" @tableData="otherData"/>
<el-row :gutter="createTicketType ? 2 : 3" style="margin-top: 1rem">
<el-col :span="createTicketType ? 12 : 16">
<el-descriptions class="margin-top" :column="createTicketType ? 2 : 3" border :size="'medium'"
@ -164,11 +164,11 @@
<el-col v-if="createTicketType" :span="12">
<el-descriptions class="margin-top" :column="5" :size="'medium'"
style="margin-left: 1rem;margin-top: 1rem">
<el-descriptions-item label="数量">0</el-descriptions-item>
<el-descriptions-item label="项目">0</el-descriptions-item>
<el-descriptions-item label="配件">0</el-descriptions-item>
<el-descriptions-item label="附加">0</el-descriptions-item>
<el-descriptions-item label="合计">0</el-descriptions-item>
<el-descriptions-item label="数量">{{ formData.count }}</el-descriptions-item>
<el-descriptions-item label="项目">{{ formData.projectPrice }}</el-descriptions-item>
<el-descriptions-item label="配件">{{ formData.partPrice }}</el-descriptions-item>
<el-descriptions-item label="附加">{{ formData.otherPrice }}</el-descriptions-item>
<el-descriptions-item label="合计">{{ formData.totalPrice }}</el-descriptions-item>
</el-descriptions>
</el-col>
<el-col v-else :span="8" style="margin-top:1rem;display: flex;justify-content: right">
@ -183,11 +183,12 @@
<template slot="label">
备注
</template>
<el-input/>
<el-input v-model="formData.remark"/>
</el-descriptions-item>
</el-descriptions>
</el-col>
<el-col :span="12" style="margin-top:1rem;display: flex;justify-content: right">
<el-button type="success" @click="handleSave">登记保存</el-button>
<el-button type="danger">结算</el-button>
<el-button type="success">完成</el-button>
<el-button type="primary">通知施工</el-button>
@ -203,7 +204,8 @@ import UserChoose from "@/views/repair/Components/UserChoose.vue";
import StaffChoose from "@/views/repair/Components/StaffChoose.vue";
import TicketItem from "@/views/repair/tickets/Components/TicketItem.vue";
import CarChoose from "@/views/repair/Components/CarChoose.vue";
import {parseTime} from "../../../../utils/ruoyi";
import {createUniqueCodeByHead} from "@/utils/createUniqueCode";
import {createTickets} from "@/api/repair/tickets/Tickets";
export default {
name: "UserInfo",
@ -236,15 +238,212 @@ export default {
remark: null,
inTime: Date.now(),
outTime: null,
ticketTime: Date.now()
ticketTime: Date.now(),
projectPrice: 0,
partPrice: 0,
otherPrice: 0,
totalPrice: 0,
count: 0,
userId: null,
userName: null,
userMobile: null,
carId: null,
carNo: null,
carVin: null,
carBrandId: null,
carBrandName: null,
carBrandType: null,
adviserId: null,
adviserName: null,
payType: null,
repairAdvice: null,
qualityExplain: null,
ticketType: null,
itemList: [],
},
selectUser: {},
selectCar: {},
selectStaff: {},
projectList: [],
partList: [],
otherList: []
}
},
methods: {
parseTime
projectData(data) {
//
this.projectList = [...data]
this.projectList.pop()
//
this.computedData()
},
partData(data) {
//
this.partList = [...data]
this.partList.pop()
//
this.computedData()
},
otherData(data) {
//
this.otherList = [...data]
this.otherList.pop()
//
this.computedData()
},
computedData() {
const data = this.formData
this.formData = {
...data,
projectPrice: 0,
partPrice: 0,
otherPrice: 0,
totalPrice: 0,
count: 0
}
//
if (this.projectList) {
this.formData.projectPrice = this.computeByItem(this.projectList)
}
//
if (this.partList) {
this.formData.partPrice = this.computeByItem(this.partList)
}
//
if (this.otherList) {
this.formData.otherPrice = this.computeByItem(this.otherList)
}
},
computeByItem(item) {
const count = item.reduce((x, y) => {
return x + y.count
}, 0)
const totalPrice = item.reduce((x, y) => {
return x + y.totalPrice
}, 0)
this.formData.count += parseInt(count)
this.formData.totalPrice += parseFloat(totalPrice)
return parseFloat(totalPrice)
},
//
async handleSave() {
this.createInit()
this.createItemInit()
try {
// await createTickets(this.formData)
this.$modal.msgSuccess("新增成功")
this.init()
}catch{}
},
//
init(){
this.formData = {
endCheck: 1,
partDisposal: '01',
repairType: '01',
ticketNo: null,
remark: null,
inTime: Date.now(),
outTime: null,
ticketTime: Date.now(),
projectPrice: 0,
partPrice: 0,
otherPrice: 0,
totalPrice: 0,
count: 0,
userId: null,
userName: null,
userMobile: null,
carId: null,
carNo: null,
carVin: null,
carBrandId: null,
carBrandName: null,
carBrandType: null,
adviserId: null,
adviserName: null,
payType: null,
repairAdvice: null,
qualityExplain: null,
ticketType: null,
itemList: [],
}
this.selectUser ={}
this.selectCar = {}
this.selectStaff = {}
this.projectList = []
this.partList = []
this.otherList = []
},
// init
createInit() {
//
this.formData.ticketNo = createUniqueCodeByHead("GD")
//
this.formData.userId = this.selectUser?.userId
this.formData.userName = this.selectUser?.cusName
this.formData.userMobile = this.selectUser?.phoneNumber
//
this.formData.carId = this.selectCar?.id
this.formData.carNo = this.selectCar?.licenseNumber
this.formData.carVin = this.selectCar?.vin
this.formData.carBrandId = this.selectCar?.carBrand
this.formData.carBrandName = this.selectCar?.brandStr
this.formData.carBrandType = this.selectCar?.brandType
//
this.formData.adviserId = this.selectStaff?.id
this.formData.adviserName = this.selectStaff?.name
},
// init
createItemInit() {
//
this.formData.itemList = [...this.formData.itemList, ...this.formatItem("project", this.projectList)]
//
this.formData.itemList = [...this.formData.itemList, ...this.formatItem("part", this.partList)]
//
this.formData.itemList = [...this.formData.itemList, ...this.formatItem("other", this.otherList)]
},
//
formatItem(type, list) {
if (!(list && list.length > 0)){
return []
}
return list.map(item => {
const temp = {
...item,
itemName: item.name,
itemCount: item.count,
itemUnit: item.unit,
itemPrice: item.price,
itemDiscount: item.discount,
itemMoney: item.totalPrice,
repairId: item?.repair?.id,
repairName: item?.repair?.name,
saleId: item?.sale?.id,
saleName: item?.sale?.name,
itemTypeId: item?.type?.id,
remark: item.remark,
itemStatus: item.itemStatus,
}
switch (type) {
case 'project':
temp['itemType'] = "01"
break;
case 'part':
temp['itemType'] = "02"
break;
case 'other':
temp['itemType'] = "03"
break;
default:
return "";
}
temp[type + 'Id'] = item.id
return temp;
})
}
}
}
</script>