|
|
@@ -4,7 +4,7 @@
|
|
|
<view class="title" style="margin-top: 0;">
|
|
|
服务信息
|
|
|
</view>
|
|
|
- <up-form-item label="产品品类" prop="class1">
|
|
|
+ <up-form-item label="产品品类" :required="rules.class1[0].required" prop="class1">
|
|
|
<up-radio-group v-model="form.class1">
|
|
|
<up-radio :customStyle="{ marginLeft: '12px' }" v-for="(item) in class1" :key="item.value"
|
|
|
:label="item.value" :name="item.value">
|
|
|
@@ -12,7 +12,7 @@
|
|
|
</up-radio-group>
|
|
|
</up-form-item>
|
|
|
|
|
|
- <up-form-item label="服务类型" prop="servicetype">
|
|
|
+ <up-form-item label="服务类型" :required="rules.servicetype[0].required" prop="servicetype">
|
|
|
<up-radio-group v-model="form.servicetype">
|
|
|
<up-radio :customStyle="{ marginLeft: '12px' }" v-for="(item) in ['安装', '维修', '清洗']" :key="item"
|
|
|
:label="item" :name="item">
|
|
|
@@ -20,7 +20,7 @@
|
|
|
</up-radio-group>
|
|
|
</up-form-item>
|
|
|
|
|
|
- <up-form-item label="服务地址" prop="province">
|
|
|
+ <up-form-item label="服务地址" :required="rules.province[0].required" prop="province">
|
|
|
<picker class="picker" mode="region" :value="[form.province, form.city, form.county]"
|
|
|
@change="changeRegion">
|
|
|
{{ [form.province, form.city, form.county].join("-") || '选择省市县' }}
|
|
|
@@ -33,11 +33,12 @@
|
|
|
</up-form-item>
|
|
|
</view>
|
|
|
|
|
|
- <up-form-item label="联系人" prop="scenecontact">
|
|
|
+ <up-form-item label="联系人" :required="rules.scenecontact[0].required" prop="scenecontact">
|
|
|
<up-input v-model="form.scenecontact" placeholder="联系人" clearable />
|
|
|
</up-form-item>
|
|
|
|
|
|
- <up-form-item label="联系人电话" prop="scenecontactphonenumber">
|
|
|
+ <up-form-item label="联系人电话" :required="rules.scenecontactphonenumber[0].required"
|
|
|
+ prop="scenecontactphonenumber">
|
|
|
<up-input type="number" v-model="form.scenecontactphonenumber" placeholder="联系人电话" clearable />
|
|
|
</up-form-item>
|
|
|
|
|
|
@@ -45,18 +46,18 @@
|
|
|
产品信息
|
|
|
</view>
|
|
|
|
|
|
- <up-form-item label="序列号" prop="sku">
|
|
|
- <up-input v-model="form.sku" :disabled="disabled" placeholder="序列号" clearable @blur="skuConfirm">
|
|
|
+ <up-form-item label="序列号" :required="rules.sku[0].required" prop="sku">
|
|
|
+ <up-input v-model="form.sku" :disabled="detail.sku" placeholder="序列号" clearable @blur="skuConfirm">
|
|
|
<template #suffix>
|
|
|
- <up-icon v-if="!disabled" name="scan" color="#2979ff" size="28" @click="openScan" />
|
|
|
+ <up-icon v-if="!detail.sku" name="scan" color="#2979ff" size="28" @click="openScan" />
|
|
|
</template>
|
|
|
</up-input>
|
|
|
</up-form-item>
|
|
|
<up-form-item label="产品名称" prop="itemname">
|
|
|
<up-input v-model="form.itemname" disabled placeholder="选择产品">
|
|
|
- <template #suffix>
|
|
|
+ <!-- <template #suffix>
|
|
|
<up-button v-if="!disabled" type="success" size="mini" text="选择产品" @click="toSelectProduct" />
|
|
|
- </template>
|
|
|
+ </template> -->
|
|
|
</up-input>
|
|
|
</up-form-item>
|
|
|
|
|
|
@@ -65,13 +66,18 @@
|
|
|
</up-form-item>
|
|
|
|
|
|
<up-form-item label="经销商" prop="serviceenterprisename">
|
|
|
- <up-input v-model="form.serviceenterprisename" disabled placeholder="经销商" />
|
|
|
+ <up-textarea v-model="form.serviceenterprisename" disabled placeholder="经销商" autoHeight height="20" />
|
|
|
</up-form-item>
|
|
|
<up-form-item label="客户名称" prop="contact">
|
|
|
<up-input v-model="form.contact" disabled placeholder="客户名称" />
|
|
|
</up-form-item>
|
|
|
<up-form-item label="客户电话" prop="phonenumber">
|
|
|
- <up-input v-model="form.phonenumber" disabled placeholder="客户电话" />
|
|
|
+ <up-input v-model="form.phonenumber" :disabled="detail.sku" placeholder="客户电话">
|
|
|
+ <template #suffix>
|
|
|
+ <up-button v-if="!detail.sku" type="success" :disabled="!form.phonenumber" size="mini" text="查询"
|
|
|
+ @click="phonenumberConfirm" />
|
|
|
+ </template>
|
|
|
+ </up-input>
|
|
|
</up-form-item>
|
|
|
<up-form-item label="保修卡号" prop="cardno">
|
|
|
<up-input v-model="form.cardno" disabled placeholder="保修卡号" />
|
|
|
@@ -81,6 +87,35 @@
|
|
|
<My-button text="保存" :loading="loading" />
|
|
|
</view>
|
|
|
</view>
|
|
|
+
|
|
|
+ <up-popup :show="products.length" @close="closePopup" :customStyle="{
|
|
|
+ width: '80vw',
|
|
|
+ }" mode="right">
|
|
|
+ <scroll-view :safeAreaInsetBottom="false" scroll-y style="width: 100%;height: 100vh;">
|
|
|
+ <view class="product" v-for="item in products" :key="item.itemid" hover-class="navigator-hover"
|
|
|
+ @click="changeItem(item)">
|
|
|
+ <view class="itemname">
|
|
|
+ {{ item.itemname }}
|
|
|
+ </view>
|
|
|
+ <view class="row">
|
|
|
+ 序列号: {{ item.sku || '--' }}
|
|
|
+ </view>
|
|
|
+ <view class="row">
|
|
|
+ 产品编号: {{ item.itemno || '--' }}
|
|
|
+ </view>
|
|
|
+ <view class="row">
|
|
|
+ 产品型号: {{ item.model || '--' }}
|
|
|
+ </view>
|
|
|
+ <view class="row">
|
|
|
+ 经销商: {{ item.enterprisename || '--' }}
|
|
|
+ </view>
|
|
|
+ <view class="row">
|
|
|
+ 用户信息: {{ item.name || '--' }} {{ item.phonenumber || '--' }}
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view style="height: 30px;" />
|
|
|
+ </scroll-view>
|
|
|
+ </up-popup>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
@@ -116,7 +151,7 @@ const rules = reactive({
|
|
|
province: [{ required: true, message: '请选择省市县', trigger: 'change' }],
|
|
|
address: [{ required: true, message: '请输入详细地址', trigger: 'blur' }],
|
|
|
scenecontact: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
|
|
|
- sku: [{ required: form.servicetype == '安装', message: '请输入序列号', trigger: 'blur' }],
|
|
|
+ sku: [{ required: true, message: '请输入序列号', trigger: 'blur' }],
|
|
|
scenecontactphonenumber: [{ required: true, message: '请输入联系人电话', trigger: 'blur', pattern: /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/, message: '请输入正确的手机号码' }],
|
|
|
});
|
|
|
|
|
|
@@ -140,6 +175,7 @@ let detail = reactive({});
|
|
|
let loading = ref(false);
|
|
|
|
|
|
function save() {
|
|
|
+ if (querySku.value === false) return uni.showToast({ title: '序列号不正确', icon: 'none' });
|
|
|
if (loading.value) return;
|
|
|
uFormRef.value.validate().then(valid => {
|
|
|
if (valid) {
|
|
|
@@ -178,7 +214,7 @@ function getDetail() {
|
|
|
form[key] = detail[key];
|
|
|
}
|
|
|
}
|
|
|
- disabled.value = form.sku || form.itemid ? true : false
|
|
|
+ disabled.value = detail.item ? true : false
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -188,13 +224,15 @@ function changeRegion(e) {
|
|
|
form.county = e.detail.value[2];
|
|
|
}
|
|
|
|
|
|
+let querySku = ref(true); // SKU是否正确
|
|
|
+
|
|
|
function skuConfirm() {
|
|
|
- ['contact', 'serviceenterprisename', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'phonenumber', 'unitname', 'spec'].forEach(key => {
|
|
|
- form[key] = '';
|
|
|
- });
|
|
|
if (form.sku) {
|
|
|
+ ['contact', 'serviceenterprisename', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'phonenumber', 'unitname', 'spec'].forEach(key => {
|
|
|
+ form[key] = '';
|
|
|
+ });
|
|
|
$Http.basic({
|
|
|
- "id": 2025080813465203 || 20230105110003,
|
|
|
+ "id": 2025080813465203,
|
|
|
"content": {
|
|
|
"pageNumber": 1,
|
|
|
"pageSize": 1,
|
|
|
@@ -207,17 +245,80 @@ function skuConfirm() {
|
|
|
if (res.code !== 1) return uni.showToast({ title: res.msg, icon: 'none' });
|
|
|
if (res.data.length === 0 || res.data[0].sku !== form.sku) {
|
|
|
uni.showToast({ title: '未找到对应的产品信息', icon: 'none' });
|
|
|
+ querySku.value = false;
|
|
|
return;
|
|
|
}
|
|
|
- ['contact', 'serviceenterprisename', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'phonenumber', 'unitname', 'spec'].forEach(key => {
|
|
|
+ querySku.value = true;
|
|
|
+ res.data[0].contact = res.data[0].name;
|
|
|
+ res.data[0].serviceenterprisename = res.data[0].serviceenterprisename || res.data[0].enterprisename;
|
|
|
+ ['contact', 'phonenumber', 'serviceenterprisename', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'unitname', 'spec'].forEach(key => {
|
|
|
form[key] = res.data[0][key] || '';
|
|
|
});
|
|
|
+ uni.showToast({ title: '已填充表单', icon: 'none' });
|
|
|
})
|
|
|
} else {
|
|
|
form.sku = '';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+let products = ref([]); // 产品列表
|
|
|
+function closePopup() {
|
|
|
+ products.value = [];
|
|
|
+}
|
|
|
+function changeItem(item) {
|
|
|
+ item.contact = item.name;
|
|
|
+
|
|
|
+ if (item.itemid == detail.itemid) {
|
|
|
+ handle();
|
|
|
+ } else {
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: `当前选择的产品与工单中的产品不一致,是否继续?`,
|
|
|
+ success: function ({ confirm }) {
|
|
|
+ if (confirm) handle()
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function handle() {
|
|
|
+ item.serviceenterprisename = item.serviceenterprisename || item.enterprisename;
|
|
|
+ ['contact', 'serviceenterprisename', 'sku', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'phonenumber', 'unitname', 'spec'].forEach(key => {
|
|
|
+ form[key] = item[key] || '';
|
|
|
+ });
|
|
|
+ uni.showToast({ title: '已填充表单', icon: 'none' });
|
|
|
+ querySku.value = true;
|
|
|
+ closePopup();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function phonenumberConfirm() {
|
|
|
+ // 校验手机号
|
|
|
+ let reg = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/;
|
|
|
+ if (!reg.test(form.phonenumber)) {
|
|
|
+ return uni.showToast({ title: '请输入正确的手机号', icon: 'none' });
|
|
|
+ }
|
|
|
+ $Http.basic({
|
|
|
+ "id": 2025080813465203,
|
|
|
+ "content": {
|
|
|
+ "pageNumber": 1,
|
|
|
+ "pageSize": 50,
|
|
|
+ phonenumber: form.phonenumber,
|
|
|
+ "where": {
|
|
|
+ // phonenumber: form.phonenumber,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("根据用户手机查询", res)
|
|
|
+ if (res.code !== 1) return uni.showToast({ title: res.msg, icon: 'none' });
|
|
|
+ if (res.data.length === 0) return uni.showToast({ title: '未找到对应的客户信息', icon: 'none' });
|
|
|
+ if (res.data.length == 1 && detail.itemid == res.data[0].itemid) {
|
|
|
+ changeItem(res.data[0]);
|
|
|
+ } else {
|
|
|
+ products.value = res.data;
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
function openScan() {
|
|
|
uni.scanCode({
|
|
|
onlyFromCamera: true,
|
|
|
@@ -278,4 +379,25 @@ function toSelectProduct() {
|
|
|
font-weight: bold;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+.product {
|
|
|
+ padding: 20rpx;
|
|
|
+ background: #fff;
|
|
|
+ margin: 10rpx 0;
|
|
|
+ border-radius: 8rpx;
|
|
|
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
|
+
|
|
|
+ .itemname {
|
|
|
+ font-size: 32rpx;
|
|
|
+ color: #333;
|
|
|
+ font-weight: bold;
|
|
|
+ margin-bottom: 10rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .row {
|
|
|
+ font-size: 28rpx;
|
|
|
+ color: #666;
|
|
|
+ margin-top: 8rpx;
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|