|
|
@@ -36,9 +36,9 @@
|
|
|
<up-input v-model="form.sku" placeholder="序列号" clearable @blur="skuConfirm">
|
|
|
<template #suffix>
|
|
|
<view style="display: flex;align-items: center;">
|
|
|
- <view v-if="form.servicetype && form.servicetype != '安装' && WuserRecord.sa_customersid"
|
|
|
+ <view v-if="form.servicetype && form.servicetype != '安装' && WuserRecord.myProducts >= 2"
|
|
|
class="my-but" hover-class="navigator-hover" @click="toSelectMyProduct">
|
|
|
- 选择我的产品
|
|
|
+ 选择其他产品
|
|
|
</view>
|
|
|
<up-icon name="scan" color="#2979ff" size="28" @click="openScan" />
|
|
|
</view>
|
|
|
@@ -48,14 +48,6 @@
|
|
|
|
|
|
<up-form-item label="产品名称" prop="itemname" :required="rules.itemname[0].required">
|
|
|
<up-input v-model="form.itemname" disabled placeholder="请输入序列号或选择产品">
|
|
|
- <template #suffix>
|
|
|
- <view style="display: flex;align-items: center;">
|
|
|
- <view v-if="!rules.sku[0].required && !form.sku && form.class1" class="my-but"
|
|
|
- hover-class="navigator-hover" @click="toSelectProduct">
|
|
|
- 选择产品
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </template>
|
|
|
</up-input>
|
|
|
</up-form-item>
|
|
|
|
|
|
@@ -105,16 +97,39 @@
|
|
|
}" 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)">
|
|
|
+ @click="onselectSku(item)">
|
|
|
+ <view class="itemname">
|
|
|
+ {{ item.itemname }}
|
|
|
+ </view>
|
|
|
+ <view class="row">
|
|
|
+ 序列号: {{ item.sku || '--' }}
|
|
|
+ </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>
|
|
|
+
|
|
|
+ <up-popup :show="myProducts.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 myProducts" :key="item.itemid" hover-class="navigator-hover"
|
|
|
+ @click="onSelectedProduct(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>
|
|
|
@@ -159,13 +174,17 @@ const form = reactive({
|
|
|
itemno: '', // 产品编号
|
|
|
model: '', // 产品型号
|
|
|
cardno: '', // 保修卡号
|
|
|
- scenecontact: '', // 联系人
|
|
|
+ scenecontact: '', // 现场联系人
|
|
|
scenecontactphonenumber: WuserRecord.value.phonenumber || WuserMsg.phonenumber || '', // 联系人电话
|
|
|
+ customername: WuserRecord.value.name || "", // 客户名称
|
|
|
+ customerphonenumber: WuserRecord.value.phonenumber || "", // 客户电话
|
|
|
province: '', // 省
|
|
|
city: '', // 市
|
|
|
county: '', // 县
|
|
|
address: '', // 详细地址
|
|
|
- remarks: ''
|
|
|
+ remarks: '',
|
|
|
+ sa_customersid: WuserRecord.value.sa_customersid || 0,
|
|
|
+ sys_enterpriseid: WuserRecord.value.sys_enterpriseid || 0,
|
|
|
});
|
|
|
|
|
|
const rules = reactive({
|
|
|
@@ -174,7 +193,7 @@ const rules = reactive({
|
|
|
class2: [{ required: false, message: "请选择故障类型", trigger: 'change' }],
|
|
|
sku: [{ required: false, message: '请输入序列号', trigger: 'blur' }],
|
|
|
itemno: [{ required: false, message: '请输入产品编号', trigger: 'blur' }],
|
|
|
- itemname: [{ required: true, message: '请选择产品', trigger: 'blur' }],
|
|
|
+ itemname: [{ required: false, message: '请选择产品', trigger: 'blur' }],
|
|
|
model: [{ required: false, message: '请输入产品型号', trigger: 'blur' }],
|
|
|
cardno: [{ required: false, message: '请输入保修卡号', trigger: 'blur' }],
|
|
|
province: [{ required: true, message: '请选择省市县', trigger: 'change' }],
|
|
|
@@ -234,8 +253,8 @@ function save() {
|
|
|
form.customerphonenumber = form.scenecontactphonenumber;
|
|
|
form.name = form.customername;
|
|
|
form.phonenumber = form.scenecontactphonenumber;
|
|
|
- form.sa_customersid = WuserRecord.value.sa_customersid || 0;
|
|
|
- form.sys_enterpriseid = WuserRecord.value.sys_enterpriseid || 0;
|
|
|
+ form.sa_customersid = form.sa_customersid || 0;
|
|
|
+ form.sys_enterpriseid = form.sys_enterpriseid || 0;
|
|
|
let content = {
|
|
|
...form,
|
|
|
};
|
|
|
@@ -316,40 +335,31 @@ function skuConfirm() {
|
|
|
return;
|
|
|
}
|
|
|
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', 'sys_enterpriseid'].forEach(key => {
|
|
|
- if ('sys_enterpriseid' == key) {
|
|
|
- WuserRecord.value.sys_enterpriseid = res.data[0][key] || 0;
|
|
|
- } else {
|
|
|
- form[key] = res.data[0][key] || '';
|
|
|
- }
|
|
|
- });
|
|
|
- uni.showToast({ title: '已填充表单', icon: 'none' });
|
|
|
+ onselectSku(res.data[0])
|
|
|
})
|
|
|
} else {
|
|
|
form.sku = '';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-let products = ref([]); // 产品列表
|
|
|
-function closePopup() {
|
|
|
- products.value = [];
|
|
|
-}
|
|
|
-function changeItem(item) {
|
|
|
+function onselectSku(item) {
|
|
|
item.contact = item.name;
|
|
|
item.serviceenterprisename = item.serviceenterprisename || item.enterprisename;
|
|
|
- ['contact', 'serviceenterprisename', 'sku', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'phonenumber', 'unitname', 'spec', 'sys_enterpriseid'].forEach(key => {
|
|
|
- if ('sys_enterpriseid' == key) {
|
|
|
- WuserRecord.value.sys_enterpriseid = item[key] || 0;
|
|
|
+ ['customername', 'customerphonenumber', 'cardno', 'itemid', 'model', 'itemname', 'itemno', 'sa_customersid', 'sys_enterpriseid'].forEach(key => {
|
|
|
+ if (key == 'sa_customersid' && (item.sa_customersid == 0 || item.sa_customersid == '')) {
|
|
|
} else {
|
|
|
form[key] = item[key] || '';
|
|
|
}
|
|
|
});
|
|
|
- uni.showToast({ title: '已填充表单', icon: 'none' });
|
|
|
+ uni.showToast({ title: '成功带入产品信息', icon: 'none' });
|
|
|
querySku.value = true;
|
|
|
closePopup();
|
|
|
}
|
|
|
+let products = ref([]); // 产品列表
|
|
|
+function closePopup() {
|
|
|
+ products.value = [];
|
|
|
+ myProducts.value = [];
|
|
|
+}
|
|
|
|
|
|
function openScan() {
|
|
|
uni.navigateTo({
|
|
|
@@ -363,9 +373,90 @@ function openScan() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function validatePhoneNumber(value) {
|
|
|
+ // 空值/非字符串直接返回false
|
|
|
+ if (!value || typeof value !== 'string') return false;
|
|
|
+ const trimmedValue = value.trim();
|
|
|
+
|
|
|
+ // 1. 精准手机号校验(使用你提供的规则)
|
|
|
+ const mobileReg = /^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 (mobileReg.test(trimmedValue)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 手机号不通过,校验座机号(0开头区号+3-4位区号+7-8位号码)
|
|
|
+ const cleanedTel = trimmedValue.replace(/[- ]/g, ''); // 去除分隔符
|
|
|
+ const telReg = /^0\d{2,3}\d{7,8}$/; // 座机号规则:0开头区号(3-4位)+ 7-8位号码
|
|
|
+ return telReg.test(cleanedTel);
|
|
|
+}
|
|
|
+
|
|
|
+function phonenumberConfirm() {
|
|
|
+ if (!validatePhoneNumber(form.customerphonenumber)) return wx.showToast({
|
|
|
+ title: '手机号不符合规格',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ $Http.basic({
|
|
|
+ "id": 2025090809202003,
|
|
|
+ "content": {
|
|
|
+ "pageNumber": 1,
|
|
|
+ "pageSize": 50,
|
|
|
+ "where": {
|
|
|
+ phonenumber: form.customerphonenumber,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ uni.hideLoading();
|
|
|
+ console.log("根据用户手机查询客户档案", res)
|
|
|
+ if (res.code !== 1) {
|
|
|
+ phonenumberConfirmSku()
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (res.data.length === 0) {
|
|
|
+ phonenumberConfirmSku()
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let item = res.data[0];
|
|
|
+ item.customername = item.name;
|
|
|
+ item.customerphonenumber = item.phonenumber;
|
|
|
+ ['customername', 'customerphonenumber', 'sa_customersid'].forEach(key => {
|
|
|
+ if (key == 'sa_customersid' && (item.sa_customersid == 0 || item.sa_customersid == '')) {
|
|
|
+ } else {
|
|
|
+ form[key] = item[key] || '';
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function phonenumberConfirmSku() {
|
|
|
+ $Http.basic({
|
|
|
+ "id": 2025080813465203,
|
|
|
+ "content": {
|
|
|
+ "pageNumber": 1,
|
|
|
+ "pageSize": 50,
|
|
|
+ "where": {
|
|
|
+ phonenumber: form.customerphonenumber,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("根据用户手机查询SKU", res)
|
|
|
+ if (res.code !== 1) return uni.showToast({ title: res.msg, icon: 'none' });
|
|
|
+ if (res.data.length === 0) return wx.showModal({
|
|
|
+ content: '未找到购买人信息,请确认序列号或手机号是否正确,如有疑问请联系购买单位。',
|
|
|
+ title: '提示',
|
|
|
+ showCancel: false,
|
|
|
+ })
|
|
|
+ let item = res.data[0];
|
|
|
+ ['customername', 'customerphonenumber', 'sa_customersid', 'sys_enterpriseid'].forEach(key => {
|
|
|
+ if (key == 'sa_customersid' && (item.sa_customersid == 0 || item.sa_customersid == '')) {
|
|
|
+ } else {
|
|
|
+ form[key] = item[key] || '';
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
//去选择产品
|
|
|
function toSelectProduct() {
|
|
|
- // return console.log('选择我的产品', form.class1);
|
|
|
uni.navigateTo({
|
|
|
url: '/pages/select/product?topclassnum=' + form.class1
|
|
|
});
|
|
|
@@ -377,23 +468,49 @@ function toSelectProduct() {
|
|
|
delete $Http.onSelected
|
|
|
}
|
|
|
}
|
|
|
+let myProducts = ref([]); // 我的产品列表
|
|
|
+if (WuserRecord.value.sa_customersid) $Http.basic({
|
|
|
+ id: 2025082115363003,
|
|
|
+ content: {
|
|
|
+ sa_customersid: WuserRecord.value.sa_customersid,
|
|
|
+ "pageNumber": 1,
|
|
|
+ "pageSize": 20,
|
|
|
+ "where": {
|
|
|
+ "status": '',
|
|
|
+ "condition": ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+}).then(res => {
|
|
|
+ console.log("我的产品", res)
|
|
|
+ myProducts.value = res.data;
|
|
|
+ if (res.code == 1) {
|
|
|
+ if (res.data.length == 1) {
|
|
|
+ onSelectedProduct(res.data[0]);
|
|
|
+ } else {
|
|
|
+ myProducts.value = res.data;
|
|
|
+ WuserRecord.value.myProducts = res.data.length;
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|
|
|
|
|
|
function toSelectMyProduct() {
|
|
|
uni.navigateTo({
|
|
|
url: '/pages/select/myProduct'
|
|
|
});
|
|
|
$Http.onSelected = (item) => {
|
|
|
- ['contact', 'phonenumber', 'sku', 'serviceenterprisename', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'unitname', 'spec', 'sys_enterpriseid'].forEach(key => {
|
|
|
- if ('sys_enterpriseid' == key) {
|
|
|
- WuserRecord.value.sys_enterpriseid = item[key] || 0;
|
|
|
- } else {
|
|
|
- form[key] = item[key] || '';
|
|
|
- }
|
|
|
- });
|
|
|
+ onSelectedProduct(item)
|
|
|
uni.navigateBack()
|
|
|
delete $Http.onSelected
|
|
|
}
|
|
|
}
|
|
|
+function onSelectedProduct(item) {
|
|
|
+ console.log("选择我的产品", item);
|
|
|
+ ['contact', 'phonenumber', 'sku', 'serviceenterprisename', 'cardno', 'itemid', 'itemname', 'itemno', 'model', 'unitname', 'spec', 'sys_enterpriseid'].forEach(key => {
|
|
|
+ form[key] = item[key] || '';
|
|
|
+ });
|
|
|
+ closePopup();
|
|
|
+}
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|