This commit is contained in:
xuyuncong 2025-10-20 11:41:40 +08:00
parent 9762746eef
commit 5398a129dc
7 changed files with 1645 additions and 1460 deletions

View File

@ -0,0 +1,132 @@
<template>
<view class="date-range-selector">
<u-subsection :list="dateRangeList" keyName="label" :current="selected" @change="handleSubsectionChange" />
<uni-datetime-picker :value="internalDateRange" type="daterange" @change="handleDatePickerChange" />
</view>
</template>
<script>
export default {
props: {
// Vue2 使 value v-model prop
value: {
type: Array,
required: true
},
dateRangeList: {
type: Array,
default: () => [{
label: "今日",
value: "day"
},
{
label: "本周",
value: "week"
},
{
label: "本月",
value: "month"
}
]
}
},
data() {
return {
selected: 0,
internalDateRange: this.value
};
},
watch: {
value(newVal) {
if (JSON.stringify(newVal) !== JSON.stringify(this.internalDateRange)) {
this.internalDateRange = newVal;
this.resetSelectedIndex();
}
},
internalDateRange(newVal) {
this.$emit('input', newVal); // Vue2 使 input
this.$emit('subsection-change', newVal);
}
},
methods: {
//
getDateRange(type) {
const now = new Date()
let start, end
if (type === 'week') {
//
const day = now.getDay() || 7 // Sunday 0 7
start = new Date(now)
start.setDate(now.getDate() - day + 1)
end = new Date(start)
end.setDate(start.getDate() + 6)
} else if (type === 'month') {
//
start = new Date(now.getFullYear(), now.getMonth(), 1)
end = new Date(now.getFullYear(), now.getMonth() + 1, 0) //
} else if (type === 'day') {
// 00:00:00 23:59:59
start = new Date(now)
start.setHours(0, 0, 0, 0)
end = new Date(now)
end.setHours(23, 59, 59, 999)
} else {
console.warn('不支持的类型:', type)
return []
}
return [
this.formatDateCus(start),
this.formatDateCus(end)
]
},
//
formatDateCus(date) {
const y = date.getFullYear()
const m = (date.getMonth() + 1).toString().padStart(2, '0')
const d = date.getDate().toString().padStart(2, '0')
return `${y}-${m}-${d}`
},
handleSubsectionChange(index) {
this.selected = index;
const {
value
} = this.dateRangeList[index];
this.internalDateRange = this.getDateRange(value);
},
handleDatePickerChange(newRange) {
this.internalDateRange = newRange;
this.resetSelectedIndex();
},
resetSelectedIndex() {
const isPreset = this.dateRangeList.some((item, index) => {
const range = this.getDateRange(item.value);
return JSON.stringify(range) === JSON.stringify(this.internalDateRange);
});
if (!isPreset) {
this.selected = -1; //
}
}
},
created() {
//
if (!this.value || this.value.length === 0) {
this.internalDateRange = this.getDateRange('day');
} else {
this.resetSelectedIndex();
}
}
};
</script>
<style scoped>
.date-range-selector {
/* 可以写样式 */
}
</style>

View File

@ -55,11 +55,11 @@
</view>
<view class="finance" v-if="checkPermi(['repair:tick:profit'])">
<view class="fin-card receivable" @click.self="goListByPayStatus('receivable')">
<view class="fin-card receivable" @click="goListByPayStatus('receivable')">
<view class="fin-top">
<text class="fin-title">应收款</text>
<uni-icons :type="financeVisibility.receivable ? 'eye' : 'eye-slash'" color="#7aa6ff" size="20"
@click="toggleFinance('receivable')" />
@click.native.stop="toggleFinance('receivable')" />
</view>
<!-- 已收款金额 -->
<text
@ -69,11 +69,11 @@
<image src="../images/money_one.png" mode="widthFix" class="tap_icon"></image>
</view>
</view>
<view class="fin-card collected" @click.self="goListByPayStatus('receivedAmount')">
<view class="fin-card collected" @click="goListByPayStatus('receivedAmount')">
<view class="fin-top">
<text class="fin-title">已收款</text>
<uni-icons :type="financeVisibility.collected ? 'eye' : 'eye-slash'" color="#a896ff" size="20"
@click="toggleFinance('collected')" />
@click.native.stop="toggleFinance('collected')" />
</view>
<text
class="fin-amount">{{ financeVisibility.collected ? formatCurrency(otherInfo.receivedAmount) : '*****' }}</text>
@ -82,11 +82,11 @@
<image src="../images/money_two.png" mode="widthFix" class="tap_icon"></image>
</view>
</view>
<view class="fin-card pending" @click.self="goListByPayStatus('pendingAmount')">
<view class="fin-card pending" @click="goListByPayStatus('pendingAmount')">
<view class="fin-top">
<text class="fin-title">待收款</text>
<uni-icons :type="financeVisibility.pending ? 'eye' : 'eye-slash'" color="#ffcf7a" size="20"
@click="toggleFinance('pending')" />
@click.native.stop="toggleFinance('pending')" />
</view>
<text
class="fin-amount">{{ financeVisibility.pending ? formatCurrency(otherInfo.pendingAmount) : '*****' }}</text>
@ -123,16 +123,6 @@
queryParams: {
dateRange: [],
},
sectionOrder: ['orders', 'repairing', 'completed', 'settled', 'unsettled', 'delivered', 'inFactory'],
sectionTitle: {
orders: '订单(进厂)数',
repairing: '维修中',
completed: '已竣工',
settled: '竣工已结算',
unsettled: '竣工未结算',
delivered: '已交车',
inFactory: '在厂数'
},
tapList: [{
label: "本日",
value: "day",

View File

@ -877,16 +877,16 @@
getCarList(carId) {
const params = {
userId: this.userInfo.userId,
id: this.userInfo.id,
pageNo: 1,
pageSize: 100000
}
request({
url: '/admin-api/base/carMain/page',
url: '/admin-api/base/custom/get',
method: 'GET',
params: params
}).then(res => {
this.carList = res.data.records
this.carList = res.data.carList
for (let i = 0; i < this.carList.length; i++) {
if (this.carList[i].licenseNumber.toLowerCase() == this.phone.toLowerCase()) {
this.activeCarIndex = i

View File

@ -19,17 +19,21 @@
<view class="list">
<scroll-view style="height: 100%" scroll-y="true" class="itemContent" @scrolltolower="onReachBottomCus"
refresher-enabled @refresherrefresh="onRefresherrefresh" :refresher-triggered="isTriggered">
<view v-for="(item, index) in repairList" :key="index" class="listItem">
<view v-for="(item, index) in repairList" :key="index" class="listItem"
@click="addNewWaresFun(item.id)">
<view class="repairName">{{ item.name }}</view>
<view class="repairBottom">
<text class="repairDesc">单位
<text class="repairUnit">{{ item.unitText }}</text>
</text>
<text class="repairDesc">当前库存
<text class="repairUnit">{{ item.stock }}</text>
</text>
<view class="repairBtns">
<u-icon name="minus-circle-fill" size="24" @click="delNum(item)"></u-icon>
<u-icon name="minus-circle-fill" size="24" @click.native.stop="delNum(item)"></u-icon>
<text class="repairNum">{{ item.num }}</text>
<u-icon color="#0174F6" name="plus-circle-fill" size="24"
@click="addNum(item)"></u-icon>
@click.native.stop="addNum(item)"></u-icon>
</view>
</view>
</view>
@ -481,10 +485,16 @@
/**
* 添加新的配件
*/
addNewWaresFun() {
addNewWaresFun(id) {
if (id) {
uni.navigateTo({
url: '/pages-repair/apply/newWare'
url: `/pages-repair/apply/newWare?id=${id}`
})
} else {
uni.navigateTo({
url: `/pages-repair/apply/newWare`
})
}
},
}
}

View File

@ -1,11 +1,19 @@
<template>
<view class="container">
<VNavigationBar background-color="#fff" title="新增配件" title-color="#333"></VNavigationBar>
<VNavigationBar background-color="#fff" :title="title" title-color="#333"></VNavigationBar>
<view class="listBox">
<view class="list">
<view class="formItem">
<text class="formLabel require">配件名称</text>
<input type="text" style="text-align: right" v-model="formData.name" placeholder="请输入配件名称"/>
<input type="text" style="text-align: right" v-model="formData.name" placeholder="请输入配件名称" />
</view>
<view class="formItem">
<text class="formLabel require">进价</text>
<input type="text" style="text-align: right" v-model="formData.purPrice" placeholder="请输入配件名称" />
</view>
<view class="formItem">
<text class="formLabel require">销售价格</text>
<input type="text" style="text-align: right" v-model="formData.price" placeholder="请输入配件名称" />
</view>
<view class="formItem">
<text class="formLabel require">所属分类</text>
@ -21,7 +29,7 @@
</view>
<view class="formItem">
<text class="formLabel">规格型号</text>
<input type="text" style="text-align: right" v-model="formData.model" placeholder="请输入规格型号"/>
<input type="text" style="text-align: right" v-model="formData.model" placeholder="请输入规格型号" />
</view>
<view class="formItem">
<text class="formLabel">来源</text>
@ -47,11 +55,11 @@
</view>
<view class="formItem">
<text class="formLabel">条形码</text>
<input type="text" style="text-align: right" v-model="formData.barCode" placeholder="请输入条形码"/>
<input type="text" style="text-align: right" v-model="formData.barCode" placeholder="请输入条形码" />
</view>
<view class="formItem">
<text class="formLabel">商品编码</text>
<input type="text" style="text-align: right" v-model="formData.code" placeholder="请输入商品编码"/>
<input type="text" style="text-align: right" v-model="formData.code" placeholder="请输入商品编码" />
</view>
<view class="formItem">
<text class="formLabel">适用子公司</text>
@ -59,7 +67,8 @@
</view>
<view style="padding-bottom: 60rpx;border-bottom: 1px solid #ddd;" class="formItem">
<checkbox-group v-model="checkedCorpIdList" @change="cs">
<checkbox v-for="(item, index) in allCompanyList" :key="index" :value="item.id" :checked="item.checked">{{ item.corpName }}</checkbox>
<checkbox v-for="(item, index) in allCompanyList" :key="index" :value="item.id"
:checked="item.checked">{{ item.corpName }}</checkbox>
</checkbox-group>
</view>
<view class="formItem">
@ -87,167 +96,275 @@
</template>
<script>
import VNavigationBar from "@/components/VNavigationBar.vue";
import request from '@/utils/request';
import {getDictTextByCodeAndValue,createUniqueCodeByHead} from "@/utils/utils";
import {getUserInfo,getJSONData} from '@/utils/auth.js'
import VNavigationBar from "@/components/VNavigationBar.vue";
import request from '@/utils/request';
import {
getDictTextByCodeAndValue,
createUniqueCodeByHead
} from "@/utils/utils";
import {
getUserInfo,
getJSONData
} from '@/utils/auth.js'
export default {
components: {VNavigationBar},
export default {
components: {
VNavigationBar
},
data() {
return {
//
formData:{
name:"",
type:"",
unit:"",
model:"",
dataForm:"",
attribute:"",
status:"",
barCode:"",
code:"",
corpId:"",
carModel:"",
remark:"",
formData: {
name: "",
type: "",
unit: "",
model: "",
dataForm: "",
attribute: "",
status: "",
barCode: "",
code: "",
corpId: "",
carModel: "",
remark: "",
},
//
radioOptions: [
{ label: '启用', value: '01' ,checked:true},
{ label: '禁用', value: '02' ,checked:false}
radioOptions: [{
label: '启用',
value: '01',
checked: true
},
{
label: '禁用',
value: '02',
checked: false
}
],
//
allTypeList:[],
allTypeList: [],
//-
allTypeNameList:[],
allTypeNameList: [],
//
typeIndex:0,
typeIndex: 0,
//
allUnitList:[],
allUnitList: [],
//-
allUnitNameList:[],
allUnitNameList: [],
//
unitIndex:0,
unitIndex: 0,
//
allFromList:[],
allFromList: [],
//-
allFromNameList:[],
allFromNameList: [],
//
fromIndex:0,
fromIndex: 0,
//
allAttributeList:[],
allAttributeList: [],
//-
allAttributeNameList:[],
allAttributeNameList: [],
//
attributeIndex:0,
attributeIndex: 0,
//
allCompanyList:[],
allCompanyList: [],
//id
checkedCorpIdList:[],
checkedCorpIdList: [],
//
title: '新增配件',
};
},
onLoad() {
onLoad(options) {
if (options.id) {
this.title = '修改配件'
//
this.init().then(() => {
this.selectWares(options.id)
})
} else {
this.init()
}
},
computed: {
},
methods: {
cs(e){
this.checkedCorpIdList =e.detail.value
cs(e) {
this.checkedCorpIdList = e.detail.value
},
/**
* 初始化配件数据
*/
init() {
//
this.selectBaseType()
//
this.selectBaseUnit()
//
this.selectDataFrom()
//
this.selectAttribute()
//
async init() {
try {
//
await Promise.all([
this.selectBaseType(),
this.selectBaseUnit(),
this.selectDataFrom(),
this.selectAttribute(),
this.selectCompany()
])
} catch (error) {
console.error('初始化数据失败:', error)
}
},
/**
* 查所有可选分类
*/
selectBaseType(){
selectBaseType() {
request({
url: '/admin-api/conf/baseType/list',
method: 'get',
params: {type:"02"}
params: {
type: "02"
}
}).then((res) => {
console.log(res)
if (res.code == 200 && res.data.length>0) {
if (res.code == 200 && res.data.length > 0) {
this.allTypeList = res.data
this.allTypeNameList = res.data.map((item)=>{return item.name})
this.allTypeNameList = res.data.map((item) => {
return item.name
})
}
})
},
/**
* 查所有可选计量单位
*/
selectBaseUnit(){
selectBaseUnit() {
request({
url: '/admin-api/system/dict-data/type',
method: 'get',
params:{type:"repair_unit"}
params: {
type: "repair_unit"
}
}).then((res) => {
console.log(res)
if (res.code == 200) {
this.allUnitList = res.data
this.allUnitNameList = res.data.map((item)=>{return item.label})
this.allUnitNameList = res.data.map((item) => {
return item.label
})
}
})
},
/**
* 查所有可选来源
* 查询配件信息
*/
selectDataFrom(){
selectWares(id) {
request({
url: '/admin-api/system/dict-data/type',
url: `/admin-api/repair/wares/get`,
method: 'get',
params:{type:"wares_data_form"}
params: {
id
}
}).then((res) => {
console.log(res)
if (res.code == 200) {
this.allFromList = res.data
this.allFromNameList = res.data.map((item)=>{return item.label})
if (res.code === 200 && res.data) {
this.formData = res.data
//
if (this.allTypeList.length > 0 && res.data.type) {
const typeIndex = this.allTypeList.findIndex(item => item.id === res.data.type)
if (typeIndex !== -1) {
this.typeIndex = typeIndex
}
}
//
if (this.allUnitList.length > 0 && res.data.unit) {
const unitIndex = this.allUnitList.findIndex(item => item.value === res.data.unit)
if (unitIndex !== -1) {
this.unitIndex = unitIndex
}
}
//
if (this.allFromList.length > 0 && res.data.dataForm) {
const fromIndex = this.allFromList.findIndex(item => item.value === res.data.dataForm)
if (fromIndex !== -1) {
this.fromIndex = fromIndex
}
}
//
if (this.allAttributeList.length > 0 && res.data.attribute) {
const attributeIndex = this.allAttributeList.findIndex(item => item.value === res.data
.attribute)
if (attributeIndex !== -1) {
this.attributeIndex = attributeIndex
}
}
//
if (res.data.corpIds && res.data.corpIds.length > 0) {
this.checkedCorpIdList = res.data.corpIds
// checkbox
this.allCompanyList.forEach(item => {
item.checked = res.data.corpIds.includes(item.id)
})
}
//
if (res.data.status) {
this.radioOptions.forEach(item => {
item.checked = item.value === res.data.status
})
}
}
})
},
/**
* 查所有可选属性
*/
selectAttribute(){
selectAttribute() {
request({
url: '/admin-api/system/dict-data/type',
method: 'get',
params:{type:"wares_attribute"}
params: {
type: "wares_attribute"
}
}).then((res) => {
console.log(res)
if (res.code == 200) {
this.allAttributeList = res.data
this.allAttributeNameList = res.data.map((item)=>{return item.label})
this.allAttributeNameList = res.data.map((item) => {
return item.label
})
}
})
},
/**
* 查所有可选子公司
*/
selectCompany(){
selectCompany() {
request({
url: '/admin-api/base/company/list',
method: 'get'
}).then((res) => {
console.log(res)
if (res.code == 200 && res.data.length>0) {
if (res.code == 200 && res.data.length > 0) {
this.allCompanyList = res.data
this.allCompanyList.map((item)=>{
item.checked=false
this.allCompanyList.map((item) => {
item.checked = false
})
}
})
},
/**
* 查所有可选来源
*/
selectDataFrom() {
request({
url: '/admin-api/system/dict-data/type',
method: 'get',
params: {
type: "wares_data_form"
}
}).then((res) => {
console.log(res)
if (res.code == 200) {
this.allFromList = res.data
this.allFromNameList = res.data.map((item) => {
return item.label
})
}
})
@ -281,43 +398,49 @@ export default {
this.attributeIndex = e.detail.value
},
/**
* 新增配件
* 新增/修改配件
*/
submit() {
//
if(!this.formData.name){
//
if (!this.formData.name) {
uni.showToast({
title: '请输入配件名称!',
icon: 'none'
})
return
}
//
console.log(this.allCompanyList,"this.checkedCorpIdList")
if(this.checkedCorpIdList.length>0){
//
if (this.checkedCorpIdList.length > 0) {
this.formData.corpId = this.checkedCorpIdList.join()
}
//
this.formData.status = "01"
//
this.formData.type = this.allTypeList[this.typeIndex].id
this.formData.unit = this.allUnitList[this.unitIndex].value
this.formData.dataForm = this.allFromList[this.fromIndex].value
this.formData.attribute = this.allAttributeList[this.attributeIndex].value
//
const isEdit = !!this.formData.id
const url = isEdit ? '/admin-api/repair/wares/update' : '/admin-api/repair/wares/create'
const method = isEdit ? 'put' : 'post'
const successMsg = isEdit ? '修改成功!' : '新增成功!'
request({
url: '/admin-api/repair/wares/create',
method: 'post',
data:this.formData
}).then((res)=>{
if (res.code == 200){
url: url,
method: method,
data: this.formData
}).then((res) => {
if (res.code == 200) {
uni.showToast({
title: '新增成功!',
title: successMsg,
icon: 'none'
})
setTimeout(()=>{
setTimeout(() => {
uni.navigateBack()
},700)
}else{
}, 700)
} else {
uni.showToast({
title: '操作失败,请联系管理员!',
icon: 'none'
@ -327,28 +450,31 @@ export default {
}
}
}
}
</script>
<style lang="scss">
.container {
.container {
height: 100%;
background-color: #F3F5F7;
display: flex;
flex-direction: column;
}
.listBox {
}
.listBox {
padding: 30 rpx 32 rpx;
flex: 1;
height: 0;
}
.list {
}
.list {
background-color: #fff;
padding: 0 30rpx;
height: 100%;
overflow: auto;
}
.formItem {
}
.formItem {
box-sizing: border-box;
margin: 0 auto;
padding: 30rpx;
@ -359,39 +485,42 @@ export default {
column-gap: 20rpx;
border-bottom: 1rpx solid #DDDDDD;
}
.require::before{
}
.require::before {
content: "*";
color: red;
}
.formLabel {
}
.formLabel {
font-size: 32rpx;
color: #333333;
}
}
.formValue {
.formValue {
flex: 1;
width: 0;
text-align: right;
font-size: 32rpx;
color: #999999;
}
.repairBottom {
}
.repairBottom {
display: flex;
align-items: center;
justify-content: space-between;
}
}
.repairDesc {
.repairDesc {
font-size: 28rpx;
color: #858BA0;
}
}
.repairUnit {
.repairUnit {
color: #333333;
}
}
.footer {
.footer {
padding: 14rpx 32rpx;
background-color: #fff;
display: flex;
@ -413,5 +542,5 @@ export default {
font-size: 32rpx;
color: #FFFFFF;
}
}
}
</style>

View File

@ -8,68 +8,42 @@
<u-input v-model="userInfo.cusName" border="none" placeholder="请输入客户姓名"></u-input>
</u-form-item>
<u-form-item borderBottom label="客户性别" label-width="200">
<u-radio-group
v-model="userInfo.sex"
placement="row"
>
<u-radio-group v-model="userInfo.sex" placement="row">
<u-radio key="0" label="男" name="0" style="margin-right: 100rpx"></u-radio>
<u-radio key="1" label="女" name="1"></u-radio>
</u-radio-group>
</u-form-item>
<u-form-item borderBottom label="客户联系方式" label-width="200">
<u-input v-model="userInfo.phoneNumber" border="none" placeholder="请输入客户手机号" type="number"></u-input>
<u-input v-model="userInfo.phoneNumber" border="none" placeholder="请输入客户手机号"
type="number"></u-input>
</u-form-item>
</view>
<view class="card">
<u-form-item borderBottom label="上传行驶证自动识别" labelWidth="200">
<u-upload
:fileList="fileList1"
@afterRead="afterRead"
@delete="deletePic"
name="1"
:maxCount="1"
multiple
></u-upload>
<u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1"
:maxCount="1" multiple></u-upload>
</u-form-item>
<u-form-item borderBottom label="车牌号" labelWidth="200" @click="carInputClick();">
<u-input
@click="carInputClick();"
v-model="car.licenseNumber"
border="none"
disabled
disabledColor="#ffffff"
placeholder="请输入车牌号"
></u-input>
<u-icon
slot="right"
name="arrow-right"
></u-icon>
<u-input @click="carInputClick();" v-model="car.licenseNumber" border="none" disabled
disabledColor="#ffffff" placeholder="请输入车牌号"></u-input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
<!-- @click="brandType = true;"-->
<u-form-item label="车辆品牌" labelWidth="200">
<song-data-picker
ref="songpicker"
style=" width: 100%;"
:localdata="brandList"
popup-title="请选择品牌"
:openSearch="true"
@change="onchange"
@nodeclick="onnodeclick"
></song-data-picker>
<!-- <picker @change="picker($event)" :value="arrayIndex" :range="brandList" range-key="brandName" v-if="brandList">-->
<!-- <view class="uni-input">{{ brandList && brandList[arrayIndex] ? brandList[arrayIndex].brandName : '' }}</view>-->
<!-- </picker>-->
<song-data-picker ref="songpicker" style=" width: 100%;" :localdata="brandList"
popup-title="请选择品牌" :openSearch="true" @change="onchange"
@nodeclick="onnodeclick"></song-data-picker>
<!-- <picker @change="picker($event)" :value="arrayIndex" :range="brandList" range-key="brandName" v-if="brandList">-->
<!-- <view class="uni-input">{{ brandList && brandList[arrayIndex] ? brandList[arrayIndex].brandName : '' }}</view>-->
<!-- </picker>-->
</u-form-item>
<u-form-item label="车辆型号" labelWidth="200">
<u-input
v-model="car.carModel"
border="none"
placeholder="请输入车辆型号"
></u-input>
<u-input v-model="car.carModel" border="none" placeholder="请输入车辆型号"></u-input>
</u-form-item>
<u-form-item v-if="natureList.length>0" class="formItem" label="车辆性质" labelWidth="200">
<picker @change="natureChange" :value="natureIndex" :range="natureList" range-key="value" v-if="natureList">
<picker @change="natureChange" :value="natureIndex" :range="natureList" range-key="value"
v-if="natureList">
<view class="uni-input">{{ natureList[natureIndex].value}}</view>
</picker>
</u-form-item>
@ -83,43 +57,20 @@
<u-input v-model="car.engineNumber" border="none" placeholder="请输入发动机号"></u-input>
</u-form-item>
<u-form-item borderBottom label="年检到期时间" labelWidth="200" @click="openDatePicker('nj'); ">
<u-input
v-model="car.nextInspectionDate"
border="none"
disabled
disabledColor="#ffffff"
placeholder="请选择年检到期时间"
></u-input>
<u-icon
slot="right"
name="arrow-right"
></u-icon>
<u-input v-model="car.nextInspectionDate" 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" @click="openDatePicker('bx'); hideKeyboard()">
<u-input
v-model="car.insuranceExpiryDate"
border="none"
disabled
disabledColor="#ffffff"
placeholder="请选择保险到期时间"
></u-input>
<u-icon
slot="right"
name="arrow-right"
></u-icon>
<u-form-item borderBottom label="保险到期时间" labelWidth="200"
@click="openDatePicker('bx'); hideKeyboard()">
<u-input v-model="car.insuranceExpiryDate" border="none" disabled disabledColor="#ffffff"
placeholder="请选择保险到期时间"></u-input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
<u-form-item label="注册日期时间" labelWidth="200" @click="openDatePicker('zcrq'); hideKeyboard()">
<u-input
v-model="car.carRegisterDate"
border="none"
disabled
disabledColor="#ffffff"
placeholder="请选择注册日期时间"
></u-input>
<u-icon
slot="right"
name="arrow-right"
></u-icon>
<u-input v-model="car.carRegisterDate" border="none" disabled disabledColor="#ffffff"
placeholder="请选择注册日期时间"></u-input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
</view>
</u-form>
@ -127,15 +78,9 @@
<keyboard-plate ref="plateNumber" :plateNum.sync='car.licenseNumber' isShow
@change="getPlateNum"></keyboard-plate>
<u-datetime-picker
v-model="datePickerValue"
:formatter="formatter"
:show="datePickerShow"
:minDate="minDate"
mode="date"
@cancel="datePickerCancel"
@confirm="datePickerConfirm"
></u-datetime-picker>
<u-datetime-picker v-model="datePickerValue" :formatter="formatter" :show="datePickerShow"
:minDate="minDate" mode="date" @cancel="datePickerCancel"
@confirm="datePickerConfirm"></u-datetime-picker>
</view>
<view class="footer">
<view class="btnItem edit" @click="submit">
@ -146,13 +91,16 @@
</template>
<script>
import VNavigationBar from '@/components/VNavigationBar.vue';
import request from "@/utils/request";
import config from '@/config'
import upload from "@/utils/upload";
import {getDictByCode,formatDate} from "@/utils/utils";
import VNavigationBar from '@/components/VNavigationBar.vue';
import request from "@/utils/request";
import config from '@/config'
import upload from "@/utils/upload";
import {
getDictByCode,
formatDate
} from "@/utils/utils";
export default {
export default {
components: {
VNavigationBar
},
@ -176,10 +124,10 @@ export default {
brandAndModel: [],
},
userInfo: {
cusName:"",
sex:"0",
phoneNumber:"",
car:{}
cusName: "",
sex: "0",
phoneNumber: "",
car: {}
},
bo1: false,
bo2: true,
@ -201,20 +149,20 @@ export default {
//
natureList: [],
natureIndex: 0,
minDate:null,
minDate: null,
};
},
onLoad(data) {
this.minDate = Number(new Date('1980-01-01'));
//
if(data && data.hasOwnProperty("userInfo")){
if (data && data.hasOwnProperty("userInfo")) {
let thisUserInfoObj = JSON.parse(data.userInfo)
console.log("thisUserInfoObj",thisUserInfoObj)
console.log("thisUserInfoObj", thisUserInfoObj)
this.userInfo.cusName = thisUserInfoObj.cusName
this.userInfo.sex = thisUserInfoObj.sex
this.userInfo.phoneNumber = thisUserInfoObj.phoneNumber
}
if(data && data.hasOwnProperty("phoneNum")){
if (data && data.hasOwnProperty("phoneNum")) {
this.userInfo.phoneNumber = data.phoneNum
}
this.bo1 = false;
@ -229,10 +177,9 @@ export default {
this.brandName = e.detail.value[0].brandName
},
onnodeclick(node) {
console.log(node,"node")
},
typeSelect(e) {
console.log(node, "node")
},
typeSelect(e) {},
//
natureChange(event) {
const newIndex = event.detail.value;
@ -257,7 +204,7 @@ export default {
if (this.car) {
for (let i = 0; i < this.brandList.length; i++) {
if (this.car.carBrand == this.brandList[i].id) {
this.setCarBrand(this.brandList[i].id,this.brandList[i].brandName)
this.setCarBrand(this.brandList[i].id, this.brandList[i].brandName)
}
}
}
@ -282,7 +229,9 @@ export default {
}
this.datePickerShow = true
},
datePickerConfirm({value}, field, picker) {
datePickerConfirm({
value
}, field, picker) {
let date;
// value
@ -299,7 +248,8 @@ export default {
console.error('Invalid date:', value);
return;
}
this.car[this.pickerConfirmField] = date.getFullYear() + '-' + (Number(date.getMonth()) + 1 + '').padStart(2, '0') + '-' + (date.getDate() + '').padStart(2, '0')
this.car[this.pickerConfirmField] = date.getFullYear() + '-' + (Number(date.getMonth()) + 1 + '').padStart(
2, '0') + '-' + (date.getDate() + '').padStart(2, '0')
this.datePickerCancel(picker)
},
datePickerCancel(picker) {
@ -321,19 +271,19 @@ export default {
//
async submit() {
let jsonData = {}
if(!this.userInfo.cusName){
if (!this.userInfo.cusName) {
uni.showToast({
title: '请输入客户名称',
icon: 'none'
})
}
if(!this.userInfo.phoneNumber){
if (!this.userInfo.phoneNumber) {
uni.showToast({
title: '请输入客户手机号',
icon: 'none'
})
}
if(!this.car.licenseNumber){
if (!this.car.licenseNumber) {
uni.showToast({
title: '请输入车牌号',
icon: 'none'
@ -345,17 +295,17 @@ export default {
//
if (this.car.nextInspectionDate) {
this.car.nextInspectionDate = new Date(this.car.nextInspectionDate).getTime()
}else {
} else {
this.car.nextInspectionDate = undefined
}
if (this.car.insuranceExpiryDate) {
this.car.insuranceExpiryDate = new Date(this.car.insuranceExpiryDate).getTime()
}else {
} else {
this.car.insuranceExpiryDate = undefined
}
if (this.car.carRegisterDate) {
this.car.carRegisterDate = new Date(this.car.carRegisterDate).getTime()
}else {
} else {
this.car.carRegisterDate = undefined
}
this.userInfo.car = this.car
@ -365,18 +315,18 @@ export default {
method: 'POST',
data: this.userInfo,
}).then(res => {
if(res.code==200){
if (res.code == 200) {
//
uni.showToast({
title: "新增成功",
icon: 'none'
})
setTimeout(()=>{
setTimeout(() => {
uni.navigateTo({
url: `/pages-order/addOrder/addOrder?phone=${this.userInfo.phoneNumber}&carId=${res.data.carId}`
});
},700)
}else{
}, 700)
} else {
uni.showToast({
title: res.msg,
icon: 'none'
@ -389,7 +339,9 @@ export default {
request({
url: '/admin-api/system/dict-data/type',
method: 'get',
params:{type:"car_nature"}
params: {
type: "car_nature"
}
}).then((res) => {
console.log(res)
if (res.code == 200) {
@ -439,7 +391,7 @@ export default {
}))
fileListLen++
}
}catch (e){
} catch (e) {
uni.hideLoading()
uni.showToast({
title: '无法识别该行驶证',
@ -453,7 +405,7 @@ export default {
url: '/admin-api/infra/file/upload',
filePath: url
}).then(res => {
resolve(config.baseImageUrl +res.data)
resolve(config.baseImageUrl + res.data)
this.car.carLicenseImg = res.data
this.imageUrl = config.baseImageUrl + res.data
request({
@ -462,20 +414,27 @@ export default {
data: this.imageUrl,
tenantIdFlag: false
}).then((res) => {
//
if (this.userInfo.cusName == '' || this.userInfo.cusName ==
undefined) {
this.userInfo.cusName = res.data.owner
}
this.car.vin = res.data.vin
this.car.licenseNumber = res.data.plateNo
this.car.carRegisterDate = res.data.issueDate
this.car.engineNumber = res.data.engineNo
if(this.car.insuranceExpiryDate){
this.car.insuranceExpiryDate= formatDate(this.car.insuranceExpiryDate)
if (this.car.insuranceExpiryDate) {
this.car.insuranceExpiryDate = formatDate(this.car
.insuranceExpiryDate)
}
if(this.car.nextInspectionDate){
this.car.nextInspectionDate= formatDate(this.car.nextInspectionDate)
if (this.car.nextInspectionDate) {
this.car.nextInspectionDate = formatDate(this.car
.nextInspectionDate)
}
//
this.brandList.forEach((item, index) => {
if (item.brandName == res.data.brand) {
this.setCarBrand(item.id,item.brandName)
this.setCarBrand(item.id, item.brandName)
}
})
//
@ -495,21 +454,22 @@ export default {
* @param id
* @param name
*/
setCarBrand(id,name){
this.$nextTick(()=>{
setCarBrand(id, name) {
this.$nextTick(() => {
this.brandId = id
this.brandName = name
this.$refs.songpicker.inputSelected=[{text:name,value:id}]
this.$refs.songpicker.inputSelected = [{
text: name,
value: id
}]
})
}
}
}
}
</script>
<style lang="less" scoped>
.container {
.container {
box-sizing: border-box;
height: 100%;
background-color: #f3f5f7;
@ -549,5 +509,5 @@ export default {
text-align: center;
}
}
}
}
</style>

View File

@ -5,53 +5,29 @@
<u-form labelPosition="top">
<view class="card">
<u-form-item borderBottom label="上传图片" labelWidth="200">
<u-upload
:fileList="fileList1"
@afterRead="afterRead"
@delete="deletePic"
name="1"
:maxCount="1"
multiple
></u-upload>
<u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1"
:maxCount="1" multiple></u-upload>
</u-form-item>
<u-form-item borderBottom label="车牌号" labelWidth="200" @click="carInputClick();">
<u-input
@click="carInputClick();"
v-model="car.licenseNumber"
border="none"
disabled
disabledColor="#ffffff"
placeholder="请输入车牌号"
></u-input>
<u-icon
slot="right"
name="arrow-right"
></u-icon>
<u-input @click="carInputClick();" v-model="car.licenseNumber" border="none" disabled
disabledColor="#ffffff" placeholder="请输入车牌号"></u-input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
<!-- @click="brandType = true;"-->
<u-form-item label="车辆品牌" labelWidth="200">
<song-data-picker
ref="songpicker"
style=" width: 100%;"
:localdata="brandList"
popup-title="请选择品牌"
:openSearch="true"
@change="onchange"
@nodeclick="onnodeclick"
></song-data-picker>
<!-- <picker @change="picker($event)" :value="arrayIndex" :range="brandList" range-key="brandName" v-if="brandList">-->
<!-- <view class="uni-input">{{ brandList && brandList[arrayIndex] ? brandList[arrayIndex].brandName : '' }}</view>-->
<!-- </picker>-->
<song-data-picker ref="songpicker" style=" width: 100%;" :localdata="brandList"
popup-title="请选择品牌" :openSearch="true" @change="onchange"
@nodeclick="onnodeclick"></song-data-picker>
<!-- <picker @change="picker($event)" :value="arrayIndex" :range="brandList" range-key="brandName" v-if="brandList">-->
<!-- <view class="uni-input">{{ brandList && brandList[arrayIndex] ? brandList[arrayIndex].brandName : '' }}</view>-->
<!-- </picker>-->
</u-form-item>
<u-form-item label="车辆型号" labelWidth="200">
<u-input
v-model="car.carModel"
border="none"
placeholder="请输入车辆型号"
></u-input>
<u-input v-model="car.carModel" border="none" placeholder="请输入车辆型号"></u-input>
</u-form-item>
<u-form-item class="formItem" label="车辆性质" labelWidth="200">
<picker @change="natureChange" :value="natureIndex" :range="natureList" range-key="value" v-if="natureList">
<picker @change="natureChange" :value="natureIndex" :range="natureList" range-key="value"
v-if="natureList">
<view class="uni-input">{{ natureList[natureIndex].value}}</view>
</picker>
</u-form-item>
@ -65,43 +41,20 @@
<u-input v-model="car.engineNumber" border="none" placeholder="请输入发动机号"></u-input>
</u-form-item>
<u-form-item borderBottom label="年检到期时间" labelWidth="200" @click="openDatePicker('nj'); ">
<u-input
v-model="car.nextInspectionDate"
border="none"
disabled
disabledColor="#ffffff"
placeholder="请选择年检到期时间"
></u-input>
<u-icon
slot="right"
name="arrow-right"
></u-icon>
<u-input v-model="car.nextInspectionDate" 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" @click="openDatePicker('bx'); hideKeyboard()">
<u-input
v-model="car.insuranceExpiryDate"
border="none"
disabled
disabledColor="#ffffff"
placeholder="请选择保险到期时间"
></u-input>
<u-icon
slot="right"
name="arrow-right"
></u-icon>
<u-form-item borderBottom label="保险到期时间" labelWidth="200"
@click="openDatePicker('bx'); hideKeyboard()">
<u-input v-model="car.insuranceExpiryDate" border="none" disabled disabledColor="#ffffff"
placeholder="请选择保险到期时间"></u-input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
<u-form-item label="注册日期时间" labelWidth="200" @click="openDatePicker('zcrq'); hideKeyboard()">
<u-input
v-model="car.carRegisterDate"
border="none"
disabled
disabledColor="#ffffff"
placeholder="请选择注册日期时间"
></u-input>
<u-icon
slot="right"
name="arrow-right"
></u-icon>
<u-input v-model="car.carRegisterDate" border="none" disabled disabledColor="#ffffff"
placeholder="请选择注册日期时间"></u-input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
</view>
</u-form>
@ -109,15 +62,8 @@
<keyboard-plate ref="plateNumber" :plateNum.sync='car.licenseNumber' isShow
@change="getPlateNum"></keyboard-plate>
<u-datetime-picker
v-model="datePickerValue"
:formatter="formatter"
:show="datePickerShow"
mode="date"
:minDate="minDate"
@cancel="datePickerCancel"
@confirm="datePickerConfirm"
></u-datetime-picker>
<u-datetime-picker v-model="datePickerValue" :formatter="formatter" :show="datePickerShow" mode="date"
:minDate="minDate" @cancel="datePickerCancel" @confirm="datePickerConfirm"></u-datetime-picker>
</view>
<view class="footer">
<view class="btnItem edit" @click="submit">
@ -128,14 +74,19 @@
</template>
<script>
import VNavigationBar from '@/components/VNavigationBar.vue';
import request from "@/utils/request";
import config from '@/config'
import {bus} from "@/utils/eventBus";
import upload from "@/utils/upload";
import {getDictByCode,formatDate} from "@/utils/utils";
import VNavigationBar from '@/components/VNavigationBar.vue';
import request from "@/utils/request";
import config from '@/config'
import {
bus
} from "@/utils/eventBus";
import upload from "@/utils/upload";
import {
getDictByCode,
formatDate
} from "@/utils/utils";
export default {
export default {
components: {
VNavigationBar
},
@ -179,8 +130,8 @@ export default {
//
natureList: [],
natureIndex: 0,
index:null,
minDate:null,
index: null,
minDate: null,
};
},
onLoad(options) {
@ -215,14 +166,14 @@ export default {
console.log(this.car)
},
methods: {
dealDateTime(){
if(this.car.carRegisterDate){
dealDateTime() {
if (this.car.carRegisterDate) {
this.car.carRegisterDate = formatDate(this.car.carRegisterDate)
}
if(this.car.nextInspectionDate){
if (this.car.nextInspectionDate) {
this.car.nextInspectionDate = formatDate(this.car.nextInspectionDate)
}
if(this.car.insuranceExpiryDate){
if (this.car.insuranceExpiryDate) {
this.car.insuranceExpiryDate = formatDate(this.car.insuranceExpiryDate)
}
},
@ -231,10 +182,9 @@ export default {
this.brandName = e.detail.value[0].brandName
},
onnodeclick(node) {
console.log(node,"node")
},
typeSelect(e) {
console.log(node, "node")
},
typeSelect(e) {},
//
natureChange(event) {
const newIndex = event.detail.value;
@ -259,7 +209,7 @@ export default {
if (this.car) {
for (let i = 0; i < this.brandList.length; i++) {
if (this.car.carBrand == this.brandList[i].id) {
this.setCarBrand(this.brandList[i].id,this.brandList[i].brandName)
this.setCarBrand(this.brandList[i].id, this.brandList[i].brandName)
}
}
}
@ -284,7 +234,9 @@ export default {
}
this.datePickerShow = true
},
datePickerConfirm({value}, field, picker) {
datePickerConfirm({
value
}, field, picker) {
let date;
// value
@ -301,7 +253,8 @@ export default {
console.error('Invalid date:', value);
return;
}
this.car[this.pickerConfirmField] = date.getFullYear() + '-' + (Number(date.getMonth()) + 1 + '').padStart(2, '0') + '-' + (date.getDate() + '').padStart(2, '0')
this.car[this.pickerConfirmField] = date.getFullYear() + '-' + (Number(date.getMonth()) + 1 + '').padStart(
2, '0') + '-' + (date.getDate() + '').padStart(2, '0')
this.datePickerCancel(picker)
},
datePickerCancel(picker) {
@ -323,64 +276,74 @@ export default {
//
async submit() {
this.car.brandAndModel = [this.brandId, this.car.carModel]
this.car.carBrand = this.brandId
this.car.carModel = this.carModel
//
if (this.car.nextInspectionDate) {
this.car.nextInspectionDate = new Date(this.car.nextInspectionDate).getTime()
}else {
} else {
this.car.nextInspectionDate = undefined
}
if (this.car.insuranceExpiryDate) {
this.car.insuranceExpiryDate = new Date(this.car.insuranceExpiryDate).getTime()
}else {
} else {
this.car.insuranceExpiryDate = undefined
}
if (this.car.carRegisterDate) {
this.car.carRegisterDate = new Date(this.car.carRegisterDate).getTime()
}else {
} else {
this.car.carRegisterDate = undefined
}
console.log(this.car,"car")
if (this.car.id != null) {
this.userInfo.car = this.car
request({
url: '/admin-api/base/carMain/update',
method: 'PUT',
data: this.car,
}).then(res => {
bus.$emit('updateCarInfo',this.car.id)
uni.navigateBack();
})
} else {
request({
url: '/admin-api/base/carMain/create',
method: 'POST',
data: this.car,
}).then(res => {
request({
url: '/admin-api/base/carMain/page',
method: 'GET',
params: {
licenseNumber: this.car.licenseNumber
}
}).then(res => {
this.car = res.data.records[0]
request({
url: '/admin-api/base/custom/bindCustomerCar',
url: '/admin-api/base/custom/saveCustomerAndCar',
method: 'post',
data: {
carList: [this.car],
id: this.userInfo.id
}
data: this.userInfo
}).then(res => {
bus.$emit('updateCarInfo', this.car.id)
uni.navigateBack();
})
})
// if (this.car.id != null) {
// request({
// url: '/admin-api/base/carMain/update',
// method: 'PUT',
// data: this.car,
// }).then(res => {
// bus.$emit('updateCarInfo', this.car.id)
// uni.navigateBack();
// })
// } else {
// request({
// url: '/admin-api/base/custom/saveCustomerAndCar',
// method: 'POST',
// data: this.car,
// }).then(res => {
// request({
// url: '/admin-api/base/carMain/page',
// method: 'GET',
// params: {
// licenseNumber: this.car.licenseNumber
// }
// }).then(res => {
// this.car = res.data.records[0]
// request({
// url: '/admin-api/base/custom/bindCustomerCar',
// method: 'post',
// data: {
// carList: [this.car],
// id: this.userInfo.id
// }
// }).then(res => {
// uni.navigateBack();
// })
// })
})
}
// })
// }
},
//
async getNatureList() {
this.natureList= getDictByCode('car_nature')
this.natureList = getDictByCode('car_nature')
if (this.bo2 == true) {
// setTimeout(() => {
// this.car.carNature = this.natureList[0].value;
@ -440,7 +403,7 @@ export default {
url: '/admin-api/infra/file/upload',
filePath: url
}).then(res => {
resolve(config.baseImageUrl +res.data)
resolve(config.baseImageUrl + res.data)
this.car.carLicenseImg = res.data
this.imageUrl = config.baseImageUrl + res.data
request({
@ -456,7 +419,7 @@ export default {
//
this.brandList.forEach((item, index) => {
if (item.brandName == res.data.brand) {
this.setCarBrand(item.id,item.brandName)
this.setCarBrand(item.id, item.brandName)
}
})
//
@ -476,21 +439,22 @@ export default {
* @param id
* @param name
*/
setCarBrand(id,name){
this.$nextTick(()=>{
setCarBrand(id, name) {
this.$nextTick(() => {
this.brandId = id
this.brandName = name
this.$refs.songpicker.inputSelected=[{text:name,value:id}]
this.$refs.songpicker.inputSelected = [{
text: name,
value: id
}]
})
}
}
}
}
</script>
<style lang="less" scoped>
.container {
.container {
box-sizing: border-box;
height: 100%;
background-color: #f3f5f7;
@ -530,5 +494,5 @@ export default {
text-align: center;
}
}
}
}
</style>