Servicesupport.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. const { createApp, ref ,onMounted,createVNode, render,computed,watch} = Vue
  2. createApp({
  3. setup() {
  4. watch(() => tool.loading,(to, from) => {
  5. })
  6. onMounted(()=>{
  7. serviceOption()
  8. getEnterpriseData()
  9. })
  10. const formData = ref({
  11. sa_endcustserviceorderid:0,
  12. siteid:"HY",
  13. servicetype:"",
  14. sys_enterpriseid:"0",
  15. enterprisename:"",
  16. class1:"",
  17. class2:"",
  18. province:"",
  19. city:"",
  20. county:"",
  21. address:"",
  22. name:"",
  23. phonenumber:"",
  24. scenecontactphonenumber:'',
  25. hassncode:false,
  26. sncodereason:"",
  27. remarks:'',
  28. sncodeinfos0:'',
  29. sncodeinfos:[{
  30. "sa_endcustserviceorder_snid": 0,
  31. "sncode":"",
  32. "sa_orderid":"", //后期不用传,前期测试传
  33. "sonum":"" //后期不用传
  34. }]
  35. })
  36. const restForm = ()=>{
  37. formData.value = {
  38. sa_endcustserviceorderid:0,
  39. siteid:"HY",
  40. servicetype:"",
  41. sys_enterpriseid:"0",
  42. enterprisename:"",
  43. class1:"",
  44. class2:"",
  45. province:"",
  46. city:"",
  47. county:"",
  48. address:"",
  49. name:"",
  50. phonenumber:"",
  51. scenecontactphonenumber:'',
  52. hassncode:false,
  53. sncodereason:"",
  54. remarks:'',
  55. sncodeinfos0:'',
  56. sncodeinfos:[{
  57. "sa_endcustserviceorder_snid": 0,
  58. "sncode":"",
  59. "sa_orderid":"", //后期不用传,前期测试传
  60. "sonum":"" //后期不用传
  61. }]
  62. }
  63. }
  64. // 判断是否登陆,根据登陆角色类型跳转不同页面
  65. const isLogin = (type)=>{
  66. sessionStorage.setItem('supporttype',type)
  67. if (!sessionStorage.getItem('loginInfo')){
  68. $('#myModal').modal('show')
  69. } else {
  70. let user = sessionStorage.getItem('loginInfo')
  71. user = JSON.parse(user)
  72. if (type == 'apply') {
  73. $('#myModal').modal('hide')
  74. let link = {
  75. Official:'./ServiceOfficialApplyForm.html',
  76. tourist:'./ServiceOfficial.html'
  77. }
  78. linkOf(link[user.type])
  79. } else {
  80. let link = {
  81. Official:'./ServiceOfficialApplyList.html',
  82. tourist:'./ServiceOfficialReservation.html'
  83. }
  84. linkOf(link[user.type])
  85. }
  86. }
  87. }
  88. // 跳转
  89. const linkOf = (url)=> {
  90. window.location.href = url
  91. }
  92. // 登陆账号验证码数据
  93. const form = ref({
  94. phoneNumber:'',
  95. verifyCode:''
  96. })
  97. const isSend = computed(()=>{
  98. return time.value === 0 ? false : true
  99. })
  100. // 服务类型数据
  101. const serviceOptionData = ref({})
  102. const serviceOption = async ()=>{
  103. const res = await instance.post('',{
  104. "id":20240902102603,
  105. "content": {
  106. "siteid":"HY",
  107. "customerphone":JSON.parse(sessionStorage.getItem('loginInfo')).customerphone,
  108. }
  109. })
  110. serviceOptionData.value = res.data.data
  111. }
  112. // 选择服务类型
  113. const onChangeService = (item,key)=>{
  114. formData.value[key] = item
  115. console.log(formData.value)
  116. }
  117. // 客诉大类数据
  118. const serviceKSOptionData = ["内漏", "外漏", "性能失效", "配件损坏或遗失", "外观问题", "异响或抖动", "打不开/不通水", "扭矩大", "其他"]
  119. // 应用系统数据
  120. const serviceSysOptionData = ["暖通系统", "消防系统", "其他"]
  121. //无码原因
  122. const noCodeReasonData = ['sn码丢失','sn码模糊','其他']
  123. // 根据登录手机查询企业信息
  124. const getEnterpriseData = async ()=>{
  125. if (!JSON.parse(sessionStorage.getItem('loginInfo'))) return false
  126. const res = await instance.post('',{
  127. "id":20240902144803,
  128. "content": {
  129. "siteid":"HY",
  130. "phonenumber":JSON.parse(sessionStorage.getItem('loginInfo')).customerphone,
  131. }
  132. })
  133. if (res.data.data[0]) {
  134. const {rowindex, ...obj } = res.data.data[0]
  135. formData.value = Object.assign({},formData.value,obj)
  136. }
  137. }
  138. // 监听sn码切换
  139. const onCheckbox = ()=>{
  140. sncodeBool.value = true
  141. sncodeinfos.value = formData.value.sncodeinfos = [{
  142. "sa_endcustserviceorder_snid": 0,
  143. "sncode":"",
  144. "sa_orderid":"", //后期不用传,前期测试传
  145. "sonum":"" //后期不用传
  146. }]
  147. }
  148. // 插入SN码
  149. const addSNcode = ()=>{
  150. formData.value.sncodeinfos.push({
  151. "sa_endcustserviceorder_snid": 0,
  152. "sncode":"",
  153. "sa_orderid":"", //后期不用传,前期测试传
  154. "sonum":"" //后期不用传
  155. })
  156. formData.value.sncodeinfos.forEach((e,index)=>{
  157. formData.value['sncodeinfos' + index] = e
  158. })
  159. }
  160. //删除SN码
  161. const deleteSNinput = (index)=>{
  162. formData.value.sncodeinfos.splice(index,1)
  163. delete formData.value[`sncodeinfos${index}`]
  164. snChange()
  165. }
  166. // 监听SN码输入
  167. const snChange = (data,index)=>{
  168. formData.value['sncodeinfos' + index] = data
  169. if (!data) return false
  170. querySnCode(data,index)
  171. }
  172. const sncodeinfos = ref([])
  173. const sncodeBool = ref(false)
  174. // 查询SNcode有效性
  175. const querySnCode = async (data,index)=>{
  176. if (formData.value.sncodeinfos.map(e=>e.sncode).lenght == 0) return false
  177. const res = await instance.post('',{
  178. "id":20240921142903,
  179. "content": {
  180. "siteid":"HY",
  181. "sa_endcustserviceorderid":0,
  182. "sncodes":formData.value.sncodeinfos.map(e=>e.sncode)
  183. }
  184. })
  185. if (res.data.code == 1) {
  186. sncodeBool.value = true
  187. sncodeinfos.value = res.data.data.sncodeinfos
  188. formData.value.sys_enterpriseid = res.data.data.sys_enterpriseid
  189. } else {
  190. sncodeBool.value = false
  191. alert(res.data.msg)
  192. }
  193. }
  194. // 附件上传
  195. const previewList = ref([])
  196. const fileChange = ()=>{
  197. tool.fileChange((rs)=>{
  198. // 监听loading变化
  199. function createObservable(obj) {
  200. return new Proxy(obj, {
  201. get(target, property) {
  202. return target[property];
  203. },
  204. set(target, property, value) {
  205. previewList.value = previewList.value.filter(e=>{if(e.file.name == rs.file.name){e.loading = rs.loading} return e})
  206. target[property] = value;
  207. return true;
  208. }
  209. });
  210. }
  211. rs.createObservable = createObservable
  212. // tool.getUploadUrl(rs)
  213. previewList.value.push(rs)
  214. })
  215. }
  216. // 提交单据
  217. const submitData = async ()=>{
  218. if (!sncodeBool.value) return tool.alert('未填写SN码')
  219. if (!sessionStorage.getItem('loginInfo')){
  220. $('#myModal').modal('show')
  221. } else {
  222. const rs = await tool.validateFormData(formData.value)
  223. if (!rs) return false
  224. formData.value.phonenumber = JSON.parse(sessionStorage.getItem('loginInfo')).customerphone
  225. formData.value.sncodeinfos = sncodeinfos.value
  226. const res = await instance.post('',{
  227. "id":20240902095803,
  228. "content": formData.value
  229. })
  230. if (res.data.code == 1) {
  231. // alert('提交成功')
  232. // tool.alert('提交成功')
  233. beginUpload(res.data.data.sa_endcustserviceorderid)
  234. } else {
  235. alert(res.data.msg)
  236. }
  237. }
  238. }
  239. // 数据提交后开始附件上传
  240. const beginUpload = (id)=>{
  241. if (previewList.value.length == 0 ){
  242. localStorage.clear()
  243. sessionStorage.clear()
  244. alert('提交成功')
  245. tool.linkOf('./Servicesupport.html')
  246. } else {
  247. previewList.value.forEach(e=>{
  248. e.loading = true
  249. e.dataid = id
  250. tool.getUploadUrl(e,'sa_endcustserviceorder',()=>{
  251. localStorage.clear()
  252. sessionStorage.clear()
  253. alert('提交成功')
  254. tool.linkOf('./Servicesupport.html')
  255. })
  256. })
  257. }
  258. }
  259. const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg'];
  260. const deleteFile = (index)=>{
  261. previewList.value.splice(index,1)
  262. console.log(previewList.value)
  263. document.getElementById('fileInput').value = '';
  264. }
  265. const chineseToEnglishMapArr = ref({})
  266. return {
  267. isLogin,
  268. linkOf,
  269. onChangeService,
  270. formData,
  271. serviceOptionData,
  272. serviceKSOptionData,
  273. serviceSysOptionData,
  274. noCodeReasonData,
  275. addSNcode,
  276. onCheckbox,
  277. fileChange,
  278. previewList,
  279. submitData,
  280. snChange,
  281. querySnCode,
  282. imageExtensions,
  283. deleteFile,
  284. deleteSNinput,
  285. restForm,
  286. }
  287. }
  288. }).mount('#app')