|
|
@@ -13,6 +13,14 @@
|
|
|
</up-radio-group>
|
|
|
</up-form-item>
|
|
|
|
|
|
+ <up-form-item v-if="form.isonlinesales || userType == 1" label="保修状态" prop="warrantystatus">
|
|
|
+ <up-radio-group v-model="form.warrantystatus">
|
|
|
+ <up-radio :customStyle="{ marginLeft: '12px' }" v-for="(item) in [{ label: '保内' }, { label: '保外' }]"
|
|
|
+ :key="item.label" :label="item.label" :name="item.label">
|
|
|
+ </up-radio>
|
|
|
+ </up-radio-group>
|
|
|
+ </up-form-item>
|
|
|
+
|
|
|
<up-form-item v-if="userType == 1" label="网销工单" prop="isonlinesales">
|
|
|
<up-radio-group v-model="form.isonlinesales">
|
|
|
<up-radio :customStyle="{ marginLeft: '12px' }"
|
|
|
@@ -22,7 +30,7 @@
|
|
|
</up-radio-group>
|
|
|
</up-form-item>
|
|
|
|
|
|
- <up-form-item v-if="form.isonlinesales || userType == 1" label="指定服务商">
|
|
|
+ <up-form-item v-if="!isEdit && (form.isonlinesales || userType == 1)" label="指定服务商">
|
|
|
<view class="picker" hover-class="navigator-hover" @click="selectServiceProvider">
|
|
|
{{ serviceProviders.name || '选择指定的服务商进行服务' }}
|
|
|
</view>
|
|
|
@@ -65,14 +73,6 @@
|
|
|
</up-input>
|
|
|
</up-form-item>
|
|
|
|
|
|
- <up-form-item label="保修状态" v-if="userType == 1" prop="warrantystatus">
|
|
|
- <up-radio-group v-model="form.warrantystatus">
|
|
|
- <up-radio :customStyle="{ marginLeft: '12px' }" v-for="(item) in [{ label: '保内' }, { label: '保外' }]"
|
|
|
- :key="item.label" :label="item.label" :name="item.label">
|
|
|
- </up-radio>
|
|
|
- </up-radio-group>
|
|
|
- </up-form-item>
|
|
|
-
|
|
|
<up-form-item label="客户名称" :required="rules.scenecontact[0].required" prop="scenecontact">
|
|
|
<up-input v-model="form.scenecontact" placeholder="客户名称" clearable />
|
|
|
</up-form-item>
|
|
|
@@ -159,11 +159,12 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, reactive, getCurrentInstance } from 'vue';
|
|
|
+import { ref, reactive, watch, getCurrentInstance } from 'vue';
|
|
|
const { $Http } = getCurrentInstance().proxy;
|
|
|
import { onShow, onLoad } from '@dcloudio/uni-app';
|
|
|
|
|
|
const userType = ref(uni.getStorageSync('userMsg').usertype || 0);
|
|
|
+const isEdit = ref(false);
|
|
|
|
|
|
const uFormRef = ref(null);
|
|
|
const form = reactive({
|
|
|
@@ -314,6 +315,11 @@ const class1 = ref(''),
|
|
|
|
|
|
onLoad((options) => {
|
|
|
console.log(options)
|
|
|
+ if (options.id) {
|
|
|
+ isEdit.value = true;
|
|
|
+ uni.setNavigationBarTitle({ title: '编辑服务申请' });
|
|
|
+ loadExistingData(options.id);
|
|
|
+ }
|
|
|
if (options.sku) {
|
|
|
form.sku = options.sku;
|
|
|
skuConfirm();
|
|
|
@@ -338,6 +344,68 @@ onShow(() => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+// 编辑模式:加载已有数据
|
|
|
+function loadExistingData(id) {
|
|
|
+ $Http.basic({
|
|
|
+ id: "20230206091603",
|
|
|
+ content: { nocache: true, sa_serviceorderid: id }
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code !== 1) {
|
|
|
+ uni.showToast({ title: res.msg || '获取数据失败', icon: 'none' });
|
|
|
+ setTimeout(() => uni.navigateBack(), 1500);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const data = res.data;
|
|
|
+ form.sa_serviceorderid = data.sa_serviceorderid || 0;
|
|
|
+ form.sa_orderid = data.sa_orderid || 0;
|
|
|
+ form.servicetype = data.servicetype || '';
|
|
|
+ form.class1 = data.class1 || '';
|
|
|
+ form.class2 = data.class2 || '';
|
|
|
+ form.sku = data.sku || '';
|
|
|
+ form.itemid = data.itemid || '';
|
|
|
+ form.itemname = data.itemname || '';
|
|
|
+ form.itemno = data.itemno || '';
|
|
|
+ form.model = data.model || '';
|
|
|
+ form.cardno = data.cardno || '';
|
|
|
+ form.scenecontact = data.scenecontact || '';
|
|
|
+ form.scenecontactphonenumber = data.scenecontactphonenumber || '';
|
|
|
+ form.province = data.province || '';
|
|
|
+ form.city = data.city || '';
|
|
|
+ form.county = data.county || '';
|
|
|
+ form.address = data.address || '';
|
|
|
+ form.remarks = data.remarks || '';
|
|
|
+ form.sys_enterpriseid = data.sys_enterpriseid || 0;
|
|
|
+ form.customername = data.customername || '';
|
|
|
+ form.customerphonenumber = data.customerphonenumber || '';
|
|
|
+ form.sa_customersid = data.sa_customersid || 0;
|
|
|
+ form.isonlinesales = data.isonlinesales || 0;
|
|
|
+ form.isallowance = data.isallowance || 0;
|
|
|
+ form.warrantystatus = data.warrantystatus || '';
|
|
|
+ // 编辑模式下保留服务商ID(UI隐藏但值保留)
|
|
|
+ serviceProviders.value.id = data.sys_enterpriseid_service || 0;
|
|
|
+ // 联动故障类型必填状态
|
|
|
+ rules.class2[0].required = form.servicetype == '维修';
|
|
|
+ uFormRef.value.setRules(rules);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// 监听网销工单切换(仅新建模式生效)
|
|
|
+watch(() => form.isonlinesales, (newVal, oldVal) => {
|
|
|
+ if (!isEdit.value && oldVal === 1 && newVal === 0 && serviceProviders.value.id) {
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '切换为非网销工单将清除已指定的服务商信息,是否继续?',
|
|
|
+ success: ({ confirm }) => {
|
|
|
+ if (confirm) {
|
|
|
+ serviceProviders.value = { name: '', id: '' };
|
|
|
+ } else {
|
|
|
+ form.isonlinesales = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
function changeRegion(e) {
|
|
|
form.province = e.detail.value[0];
|
|
|
form.city = e.detail.value[1];
|
|
|
@@ -354,8 +422,9 @@ function save() {
|
|
|
}
|
|
|
if (loading.value) return;
|
|
|
uFormRef.value.validate().then(valid => {
|
|
|
- if (valid) wx.showModal({
|
|
|
- content: '请确认预约信息正确以便后续服务,是否确认提交?',
|
|
|
+ if (!valid) return;
|
|
|
+ wx.showModal({
|
|
|
+ content: isEdit.value ? '请确认修改信息正确,是否确认保存?' : '请确认预约信息正确以便后续服务,是否确认提交?',
|
|
|
title: '提示',
|
|
|
success: ({ confirm }) => {
|
|
|
if (confirm) {
|
|
|
@@ -377,8 +446,15 @@ function save() {
|
|
|
loading.value = false;
|
|
|
console.log("提交申请单", res);
|
|
|
if (res.code !== 1) {
|
|
|
- uni.showToast({ title: res.code !== 1 ? res.msg : "保存成功", icon: 'none', mask: res.code == 1 });
|
|
|
+ uni.showToast({ title: res.msg, icon: 'none' });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (isEdit.value) {
|
|
|
+ // 编辑模式:不自动提交,直接返回详情页
|
|
|
+ uni.showToast({ title: '保存成功', icon: 'success' });
|
|
|
+ setTimeout(() => uni.navigateBack(), 800);
|
|
|
} else {
|
|
|
+ // 新建模式:自动提交并弹出对话框
|
|
|
$Http.basic({
|
|
|
id: 20230206101403,
|
|
|
content: {
|