Просмотр исходного кода

feat: 网销经销商服务申请编辑功能及保修状态显示优化

- 保修状态移至是否补贴下方,显示条件与是否补贴一致
- 详情页新增编辑按钮(新建/待分配状态,网销用户可见)
- 编辑模式:加载已有数据、隐藏指定服务商、保存后返回详情页
- 新增 isonlinesales 切换监听(仅新建模式)
xiaohaizhao 5 дней назад
Родитель
Сommit
f2b8a85658
2 измененных файлов с 109 добавлено и 14 удалено
  1. 20 1
      pages/generalServices/detail.vue
  2. 89 13
      pages/launchApplication/index.vue

+ 20 - 1
pages/generalServices/detail.vue

@@ -137,6 +137,9 @@
                     'color': '#3874F6',
                 }" text="删除" @onClick="deleteItem" />
             </view>
+            <view class="but-box-item" v-if="isOnlineSalesUser">
+                <My-button text="编辑" @onClick="editItem" />
+            </view>
             <view class="but-box-item">
                 <My-button text="提交" @onClick="submitItem" />
             </view>
@@ -159,6 +162,12 @@
                 <view class="but-box-item">
                     <My-button :text="detail.status == '待分配' ? '分配' : '重新指派'" @onClick="changeUser" />
                 </view>
+                <view class="but-box-item" v-if="isOnlineSalesUser && detail.status == '待分配'">
+                    <My-button :customStyle="{
+                        'background-color': '#FFFFFF',
+                        'color': '#3874F6',
+                    }" text="编辑" @onClick="editItem" />
+                </view>
                 <view v-if="userInfo.sys_enterpriseid == detail.sys_enterpriseid_initiate" class="but-box-item">
                     <My-button :customStyle="{
                         'background-color': '#FFFFFF',
@@ -192,7 +201,7 @@
 </template>
 
 <script setup>
-import { ref, reactive, getCurrentInstance } from 'vue';
+import { ref, reactive, computed, getCurrentInstance } from 'vue';
 const { $Http } = getCurrentInstance().proxy;
 import { onLoad, onShow, onUnload } from '@dcloudio/uni-app';
 import handle from './modules/handle.vue';
@@ -227,6 +236,10 @@ function completion() {
 let userInfo = reactive({
     sys_enterpriseid: 0
 });
+const userTypeFromStorage = uni.getStorageSync('userMsg').usertype || 0;
+const isOnlineSalesUser = computed(() => {
+    return userInfo.type == '网销' || userTypeFromStorage == 1;
+});
 $Http.basic({
     "classname": "common.usercenter.usercenter",
     "method": "queryUserMsg",
@@ -333,6 +346,12 @@ function changeUser() {
     openAllot()
 }
 
+function editItem() {
+    uni.navigateTo({
+        url: `/pages/launchApplication/index?id=${sa_serviceorderid}`
+    });
+}
+
 function callBack(e) {
     if (e.status == 'refused') {
         uni.navigateBack();

+ 89 - 13
pages/launchApplication/index.vue

@@ -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: {