Files
smartDriveEEUniApp/unpackage/dist/build/mp-weixin/pages-subpackage/furniture_reception/furniture_reception-impl.js
2026-04-18 14:33:16 +08:00

2 lines
16 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";const e=require("../../common/vendor.js"),t=require("../../common/config.js"),o={props:{incomingTab:{type:String,default:""}},components:{CommonBeginReception:()=>"./common_begin_reception.js",ServiceListFurniture:()=>"./serviceListFurniture.js"},data:()=>({activeTab:"status",navbarTop:"88rpx",contentTop:"160rpx",receptionForm:{id:"",customerName:"",contact:"",customerSource:"",gender:"女",age:"",dealershipId:"",dealershipName:"",salesId:"",salesName:"",salesPhone:"",recordingCount:0,intendedModel:"",infoCard:"",remark:"",detailedAddress:"",contactCount:0},tagViewMode:"list",tagList:[],tagLoading:!1,tagTotal:0,tagPage:{current:1,size:10},tagQuery:{industry:"",tagType:"",tagName:""},tagForm:{id:"",industry:"家居行业",tagType:"",name:"",detail:"",remark:"",enabled:!0},tagTypeOptions:["接待客户","质检SOP","客户画像"],showTagTypeDropdown:!1,selectedTagItem:null,showTagActionMenu:!1}),watch:{incomingTab:{immediate:!0,handler(e){this.applyIncomingTab(e)}}},computed:{computedNavbarTop(){const t=e.index.getSystemInfoSync();return((t.statusBarHeight||20)+44)*(750/(t.windowWidth||t.screenWidth||375))+"rpx"},computedContentTop(){const t=e.index.getSystemInfoSync();return((t.statusBarHeight||20)+44)*(750/(t.windowWidth||t.screenWidth||375))+72+"rpx"}},onLoad(){console.log("[FurnitureReception][onLoad] 页面加载"),this.updateNavbarPosition(),this.loadCurrentUserInfo()},onShow(){console.log("[FurnitureReception][onShow] 页面显示"),this.$nextTick((()=>{this.updateNavbarPosition(),setTimeout((()=>{this.updateNavbarPosition(),console.log("[FurnitureReception][onShow] 延迟更新后的位置:",{navbarTop:this.navbarTop,contentTop:this.contentTop,computedNavbarTop:this.computedNavbarTop,computedContentTop:this.computedContentTop})}),50)}))},onReady(){console.log("[FurnitureReception][onReady] 页面渲染完成"),console.log("[FurnitureReception][onReady] activeTab:",this.activeTab),console.log("[FurnitureReception][onReady] navbarTop:",this.navbarTop),console.log("[FurnitureReception][onReady] contentTop:",this.contentTop),console.log("[FurnitureReception][onReady] computedNavbarTop:",this.computedNavbarTop),console.log("[FurnitureReception][onReady] computedContentTop:",this.computedContentTop),this.updateNavbarPosition(),this.initUrlHidingAfterPageLoad();const t=e.index.getSystemInfoSync();console.log("[FurnitureReception][onReady] 系统信息:",{statusBarHeight:t.statusBarHeight,windowHeight:t.windowHeight,screenHeight:t.screenHeight}),setTimeout((()=>{e.index.createSelectorQuery().in(this).select(".tabs").boundingClientRect((e=>{console.log("[FurnitureReception][onReady] tab栏元素信息:",e),e?(console.log("[FurnitureReception][onReady] tab栏位置:",{top:e.top,left:e.left,width:e.width,height:e.height,expectedTop:this.navbarTop,computedNavbarTop:this.computedNavbarTop,isVisible:e.width>0&&e.height>0,isOnScreen:e.top>=0&&e.top<t.windowHeight}),(0===e.width||0===e.height||e.top<0)&&(console.warn("[FurnitureReception][onReady] tab栏不可见强制更新位置"),this.updateNavbarPosition(),this.$forceUpdate())):console.error("[FurnitureReception][onReady] tab栏元素未找到")})).exec()}),100),e.index.onWindowResize((()=>{this.showTagTypeDropdown&&this.updateTagTypeDropdownPosition()}))},methods:{refreshPageData(){this.$nextTick((()=>{const e=this.$refs.serviceListRef;"status"===this.activeTab?e&&"function"==typeof e.onServiceStatusRefresh&&e.onServiceStatusRefresh():"tag"===this.activeTab&&"list"===this.tagViewMode&&this.fetchTagList({force:!0})}))},applyIncomingTab(e){["status","reception","tag"].includes(e)&&(this.activeTab!==e&&(this.activeTab=e),"reception"===e?this.resetReceptionForm():"tag"===e?(this.tagViewMode="list",this.fetchTagList({force:!0})):"status"===e&&this.$nextTick((()=>{this.refreshPageData()})))},updateNavbarPosition(){console.log("[FurnitureReception][updateNavbarPosition] 开始更新导航栏位置");const t=e.index.getSystemInfoSync().statusBarHeight||20,o=2*t+88,a=o+"rpx",i=o+72+"rpx";console.log("[FurnitureReception][updateNavbarPosition] 更新导航栏位置:",{statusBarHeight:t,navbarHeight:44,totalNavbarHeight:o,navbarTop:a,contentTop:i,currentNavbarTop:this.navbarTop,currentContentTop:this.contentTop}),this.$set(this,"navbarTop",a),this.$set(this,"contentTop",i),this.$forceUpdate()},loadCurrentUserInfo(){try{const t=e.index.getStorageSync("backend-login-response")||{};t.userName&&(this.receptionForm.salesName=t.userName),t.phone?this.receptionForm.salesPhone=t.phone:t.userName&&(this.receptionForm.salesPhone=t.userName),t.userId&&(this.receptionForm.salesId=String(t.userId))}catch(t){console.error("加载当前登录用户信息失败:",t)}},goBack(){getCurrentPages().length<=1?e.index.switchTab({url:"/pages/workbench/workbench",fail:e=>{console.error("[FurnitureReception][goBack] 切回工作台失败:",e)}}):e.index.navigateBack({fail:e=>{console.error("[FurnitureReception][goBack] 返回失败:",e)}})},switchTab(e){this.activeTab=e,"reception"===e?this.resetReceptionForm():"tag"===e&&(this.tagViewMode="list",this.fetchTagList())},resetReceptionForm(){this.receptionForm={id:"",customerName:"",contact:"",customerSource:"",gender:"女",age:"",dealershipId:"",dealershipName:"",salesId:"",salesName:"",salesPhone:"",recordingCount:0,intendedModel:"",infoCard:"",remark:"",detailedAddress:"",contactCount:0},this.loadCurrentUserInfo()},onReceptionCancel(){this.resetReceptionForm()},onReceptionSaveSuccess({action:e,data:t}){t&&(this.receptionForm={...this.receptionForm,...t}),this.resetReceptionForm(),"start"===e&&console.log("开始接待成功",t)},onReceptionSaveError({action:e,error:t}){console.error("保存失败:",t)},onTagListSearch(){"tag"!==this.activeTab&&(this.activeTab="tag"),this.tagPage.current=1,this.fetchTagList({force:!0})},onTagListRefresh(){this.tagPage.current=1,this.fetchTagList({force:!0})},onTagListReachBottom(){this.tagLoading||this.tagList.length>=this.tagTotal||(this.tagPage.current+=1,this.fetchTagList())},async fetchTagList({force:o=!1}={}){var a,i,n,s,r;if(!this.tagLoading||o){this.tagLoading=!0;try{const c={current:this.tagPage.current,size:this.tagPage.size},g=null==(i=null==(a=this.tagQuery)?void 0:a.tagType)?void 0:i.trim(),l=null==(s=null==(n=this.tagQuery)?void 0:n.tagName)?void 0:s.trim();g&&(c.tagType=g),l&&(c.tagName=l);const h=t.getApiUrl("/api/industryTags/list");let p="",u="";try{p=e.index.getStorageSync("backend-tenant-id")||"",u=e.index.getStorageSync("backend-token")||""}catch(d){console.error("获取认证信息失败:",d)}const T={"Content-Type":"application/json"};u&&(T.Authorization=`Bearer ${u}`),p&&(T["X-Tenant-Id"]=p);const m=await e.index.request({url:h,method:"POST",data:c,header:T,timeout:3e4});if(200===m.statusCode&&m.data&&m.data.success){const e=Array.isArray(m.data.data)?m.data.data:[];1===this.tagPage.current||o?this.tagList=e:this.tagList=this.tagList.concat(e),this.tagTotal=Number(m.data.total)||0}else this.tagList=[],this.tagTotal=0,e.index.showToast({title:(null==(r=m.data)?void 0:r.message)||"获取标签列表失败",icon:"none"})}catch(c){console.error("获取标签列表失败:",c);let t="获取标签列表失败,请稍后重试";c.errMsg&&(c.errMsg.includes("timeout")?t="请求超时,请检查网络连接后重试":c.errMsg.includes("fail")&&(t="网络请求失败,请检查网络连接")),e.index.showToast({title:t,icon:"none",duration:3e3})}finally{this.tagLoading=!1}}},showAddTag(){this.tagViewMode="add",this.showTagTypeDropdown=!1,this.tagForm={id:"",industry:"家居行业",tagType:"",name:"",detail:"",remark:"",enabled:!0}},onTagItemClick(e){},onTagActionBtnClick(e){this.selectedTagItem&&this.selectedTagItem.id===e.id&&this.showTagActionMenu?this.closeTagActionMenu():(this.selectedTagItem=e,this.showTagActionMenu=!0)},closeTagActionMenu(){this.showTagActionMenu=!1,this.selectedTagItem=null},editTag(e){this.closeTagActionMenu(),this.tagViewMode="edit",this.showTagTypeDropdown=!1,this.tagForm={id:e.id||"",industry:e.industry||"家居行业",tagType:e.tagType||"",name:e.tagName||e.name||"",detail:e.tagDetail||e.detail||"",remark:e.remark||"",enabled:void 0!==e.enabled?e.enabled:void 0===e.isEnabled||e.isEnabled}},async deleteTag(o){this.closeTagActionMenu();const a=o.id;a?e.index.showModal({title:"确认删除",content:`确定要删除标签"${o.tagName||o.name||"未命名标签"}"吗?`,success:async o=>{var i,n;if(o.confirm)try{e.index.showLoading({title:"删除中..."});const o=t.getApiUrl(`/api/industryTags/delete/${a}`);let r="",d="";try{r=e.index.getStorageSync("backend-tenant-id")||"",d=e.index.getStorageSync("backend-token")||""}catch(s){console.error("获取认证信息失败:",s)}const c={};d&&(c.Authorization=`Bearer ${d}`),r&&(c["X-Tenant-Id"]=r);const g=await e.index.request({url:o,method:"DELETE",header:c,timeout:3e4});e.index.hideLoading(),200===g.statusCode&&g.data&&g.data.success?(e.index.showToast({title:(null==(i=g.data)?void 0:i.message)||"删除成功",icon:"success"}),this.tagPage.current=1,this.fetchTagList({force:!0})):e.index.showToast({title:(null==(n=g.data)?void 0:n.message)||"删除失败",icon:"none"})}catch(r){e.index.hideLoading(),console.error("删除标签失败:",r);let t="删除失败,请重试";r.errMsg&&(r.errMsg.includes("timeout")?t="请求超时,请检查网络连接后重试":r.errMsg.includes("fail")&&(t="网络请求失败,请检查网络连接")),e.index.showToast({title:t,icon:"none",duration:3e3})}}}):e.index.showToast({title:"无法获取标签ID",icon:"none"})},cancelAddTag(){this.tagViewMode="list",this.showTagTypeDropdown=!1,this.tagForm={id:"",industry:"家居行业",tagType:"",name:"",detail:"",remark:"",enabled:!0}},toggleTagTypeDropdown(){this.showTagTypeDropdown=!this.showTagTypeDropdown,this.showTagTypeDropdown&&this.$nextTick((()=>{this.updateTagTypeDropdownPosition()}))},updateTagTypeDropdownPosition(){e.index.createSelectorQuery().in(this).select(".tag-select").boundingClientRect((e=>{if(e){const t=this.$refs.tagTypeDropdown;t&&this.$nextTick((()=>{const o=t.$el||t;o&&o.style&&(o.style.top=e.bottom+8+"px",o.style.left=e.left+"px",o.style.width=e.width+"px")}))}})).exec()},selectTagType(e){this.tagForm.tagType=e,this.showTagTypeDropdown=!1},closeTagTypeDropdown(){this.showTagTypeDropdown=!1},onEnabledChange(e){this.tagForm.enabled=e.detail.value},async saveTag(){var o,a,i,n;if(this.tagForm.name&&this.tagForm.name.trim())try{e.index.showLoading({title:"edit"===this.tagViewMode?"更新中...":"保存中..."});const r={industry:(null==(o=this.tagForm.industry)?void 0:o.trim())||"",tagType:(null==(a=this.tagForm.tagType)?void 0:a.trim())||"",tagName:this.tagForm.name.trim(),tagDetail:(null==(i=this.tagForm.detail)?void 0:i.trim())||"",remark:(null==(n=this.tagForm.remark)?void 0:n.trim())||"",enabled:void 0===this.tagForm.enabled||this.tagForm.enabled};"edit"===this.tagViewMode&&this.tagForm.id&&(r.id=this.tagForm.id);const d="edit"===this.tagViewMode?t.getApiUrl("/api/industryTags/update"):t.getApiUrl("/api/industryTags/add"),c="edit"===this.tagViewMode?"PUT":"POST";let g="",l="";try{g=e.index.getStorageSync("backend-tenant-id")||"",l=e.index.getStorageSync("backend-token")||""}catch(s){console.error("获取认证信息失败:",s)}const h={"Content-Type":"application/json"};l&&(h.Authorization=`Bearer ${l}`),g&&(h["X-Tenant-Id"]=g);const p=await e.index.request({url:d,method:c,data:r,header:h,timeout:3e4}),{statusCode:u,data:T}=p;if(200!==u||!T||!T.success&&200!==T.code)throw new Error((null==T?void 0:T.message)||("edit"===this.tagViewMode?"更新失败":"保存失败"));e.index.showToast({title:(null==T?void 0:T.message)||("edit"===this.tagViewMode?"更新成功":"保存成功"),icon:"success"}),this.tagViewMode="list",this.tagPage.current=1,this.fetchTagList({force:!0})}catch(r){console.error("保存标签失败:",r);let t=(null==r?void 0:r.message)||("edit"===this.tagViewMode?"更新失败,请重试":"保存失败,请重试");r.errMsg&&(r.errMsg.includes("timeout")?t="请求超时,请检查网络连接后重试":r.errMsg.includes("fail")&&(t="网络请求失败,请检查网络连接")),e.index.showToast({title:t,icon:"none",duration:3e3})}finally{e.index.hideLoading()}else e.index.showToast({title:"请输入标签名",icon:"none"})},initUrlHidingAfterPageLoad(){},attemptUrlHidingForCurrentPage(){},setupTabNavigationHiding(){},setupBrowserNavigationHiding(){}}};if(!Array){(e.resolveComponent("uni-nav-bar")+e.resolveComponent("service-list-furniture")+e.resolveComponent("common-begin-reception")+e.resolveComponent("uni-icons"))()}Math||((()=>"../../uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.js")+(()=>"../../uni_modules/uni-icons/components/uni-icons/uni-icons.js"))();const a=e._export_sfc(o,[["render",function(t,o,a,i,n,s){return e.e({a:e.o(s.goBack,"4e"),b:e.p({fixed:!0,statusBar:!0,border:!1,title:"AI销冠系统",leftIcon:"left",color:"#333",backgroundColor:"#FFFFFF"}),c:"reception"===n.activeTab?1:"",d:e.o((e=>s.switchTab("reception")),"d3"),e:"status"===n.activeTab?1:"",f:e.o((e=>s.switchTab("status")),"47"),g:"tag"===n.activeTab?1:"",h:e.o((e=>s.switchTab("tag")),"15"),i:s.computedNavbarTop||n.navbarTop,j:"status"===n.activeTab},"status"===n.activeTab?{k:e.sr("serviceListRef","638dc4bb-1"),l:s.computedContentTop||n.contentTop}:{},{m:"reception"===n.activeTab},"reception"===n.activeTab?{n:s.computedContentTop||n.contentTop,o:e.o(s.onReceptionCancel,"ce"),p:e.o(s.onReceptionSaveSuccess,"14"),q:e.o(s.onReceptionSaveError,"b5"),r:e.p({"initial-data":n.receptionForm})}:{},{s:"tag"===n.activeTab&&"list"===n.tagViewMode},"tag"===n.activeTab&&"list"===n.tagViewMode?e.e({t:e.t(n.tagTotal),v:e.o(((...e)=>s.onTagListSearch&&s.onTagListSearch(...e)),"1e"),w:n.tagQuery.tagType,x:e.o((e=>n.tagQuery.tagType=e.detail.value),"c3"),y:e.o(((...e)=>s.onTagListSearch&&s.onTagListSearch(...e)),"86"),z:n.tagQuery.tagName,A:e.o((e=>n.tagQuery.tagName=e.detail.value),"52"),B:e.p({type:"refresh",size:"18",color:"#2A68FF"}),C:e.o(((...e)=>s.onTagListRefresh&&s.onTagListRefresh(...e)),"20"),D:e.p({type:"plus",size:"18",color:"#2A68FF"}),E:e.o(((...e)=>s.showAddTag&&s.showAddTag(...e)),"f2"),F:e.f(n.tagList,((t,o,a)=>e.e({a:e.t((t.tagName||t.name||"标").charAt(0)),b:e.t(t.tagName||t.name||"未命名标签"),c:e.o((e=>s.onTagItemClick(t)),o),d:"638dc4bb-5-"+a,e:e.o((e=>s.onTagActionBtnClick(t)),o),f:t.industry},t.industry?{g:e.t(t.industry)}:{},{h:e.o((e=>s.onTagItemClick(t)),o),i:t.tagDetail||t.detail||t.remark},t.tagDetail||t.detail||t.remark?e.e({j:t.tagDetail||t.detail},t.tagDetail||t.detail?{k:e.t(t.tagDetail||t.detail)}:{},{l:t.remark},t.remark?{m:e.t(t.remark)}:{},{n:e.o((e=>s.onTagItemClick(t)),o)}):{},{o:n.selectedTagItem&&n.selectedTagItem.id===t.id&&n.showTagActionMenu},n.selectedTagItem&&n.selectedTagItem.id===t.id&&n.showTagActionMenu?{p:e.o((e=>s.editTag(t)),o),q:e.o((e=>s.deleteTag(t)),o),r:e.o((()=>{}),o)}:{},{s:o,t:n.selectedTagItem&&n.selectedTagItem.id===t.id?1:""}))),G:e.p({type:"more-filled",size:"20",color:"#999"}),H:n.showTagActionMenu},n.showTagActionMenu?{I:e.o(((...e)=>s.closeTagActionMenu&&s.closeTagActionMenu(...e)),"f8")}:{},{J:!n.tagLoading&&!n.tagList.length},(n.tagLoading||n.tagList.length,{}),{K:n.tagLoading&&n.tagList.length},(n.tagLoading&&n.tagList.length,{}),{L:s.computedContentTop||n.contentTop,M:e.o(((...e)=>s.onTagListReachBottom&&s.onTagListReachBottom(...e)),"86")}):{},{N:"tag"===n.activeTab&&("add"===n.tagViewMode||"edit"===n.tagViewMode)},"tag"!==n.activeTab||"add"!==n.tagViewMode&&"edit"!==n.tagViewMode?{}:e.e({O:"add"===n.tagViewMode},"add"===n.tagViewMode?{P:n.tagForm.industry,Q:e.o((e=>n.tagForm.industry=e.detail.value),"63")}:{},{R:e.t(n.tagForm.tagType||"请选择标签分类"),S:e.n(n.tagForm.tagType?"form-item__picker-text":"form-item__picker-placeholder"),T:e.p({type:"bottom",size:"16",color:"#9ca3af"}),U:e.o(((...e)=>s.toggleTagTypeDropdown&&s.toggleTagTypeDropdown(...e)),"c9"),V:n.showTagTypeDropdown},n.showTagTypeDropdown?{W:e.f(n.tagTypeOptions,((t,o,a)=>({a:e.t(t),b:t===n.tagForm.tagType?1:"",c:t,d:e.o((e=>s.selectTagType(t)),t)}))),X:e.o((()=>{}),"87")}:{},{Y:n.tagForm.name,Z:e.o((e=>n.tagForm.name=e.detail.value),"14"),aa:n.tagForm.detail,ab:e.o((e=>n.tagForm.detail=e.detail.value),"4f"),ac:n.tagForm.remark,ad:e.o((e=>n.tagForm.remark=e.detail.value),"a5"),ae:n.tagForm.enabled,af:e.o(((...e)=>s.onEnabledChange&&s.onEnabledChange(...e)),"09"),ag:e.o(((...e)=>s.cancelAddTag&&s.cancelAddTag(...e)),"8b"),ah:e.t("edit"===n.tagViewMode?"更新":"保存"),ai:e.o(((...e)=>s.saveTag&&s.saveTag(...e)),"26"),aj:n.showTagTypeDropdown},n.showTagTypeDropdown?{ak:e.o(((...e)=>s.closeTagTypeDropdown&&s.closeTagTypeDropdown(...e)),"19")}:{},{al:s.computedContentTop||n.contentTop}))}]]);wx.createComponent(a);