index.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. import {
  2. AES,
  3. mode,
  4. pad,
  5. enc
  6. } from "crypto-js";
  7. import {
  8. WORKORDEREVALUATION
  9. } from "./enum.workorderEvaluation.js";
  10. import {
  11. reqDelWorkOrder,
  12. reqUrge,
  13. reqEvaluate,
  14. reqDirectStartOrder,
  15. } from "../request/api.js";
  16. //aes加密
  17. export function encryptByEnAES(data = '') {
  18. let Key = "dsadmin";
  19. let tmpAES = AES.encrypt(data, Key, {
  20. mode: mode.CBC,
  21. padding: pad.Pkcs7,
  22. });
  23. return tmpAES.toString();
  24. }
  25. //aes解密
  26. export function encryptByDeAES(data = '') {
  27. let Key = "dsadmin";
  28. let tmpDeAES = AES.decrypt(data, Key, {
  29. mode: mode.CBC,
  30. padding: pad.Pkcs7,
  31. });
  32. return tmpDeAES.toString(enc.Utf8);
  33. }
  34. // 简单的模拟枚举
  35. export function createEnum(arr = []) {
  36. let obj = {}
  37. arr.forEach(v => {
  38. obj[obj[v.name] = v.value] = v.name;
  39. })
  40. return Object.freeze(obj);
  41. };
  42. // 获取页面栈,默认0是当前页面栈
  43. export function getCurrentPagesSeimin(num = 0) {
  44. let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
  45. let curRoute = routes[routes.length - 1 - num].route // 获取当前页面路由,也就是最后一个打开的页面路由
  46. return curRoute;
  47. };
  48. //评价
  49. export function showAppraise(id, callBack) {
  50. this.$refs.seiminModel.show({
  51. skin: 'evaluate',
  52. content: "工单已完成,请对本次服务做出评价!",
  53. btns: [{
  54. click: () => {
  55. console.log('取消');
  56. this.$refs.seiminModel.close();
  57. }
  58. },
  59. {
  60. click: () => {
  61. console.log('确定');
  62. let serviceEvaluationId;
  63. this.$refs.seiminModel.close();
  64. uni.showLoading({
  65. title: '加载中',
  66. mask: true,
  67. })
  68. //算出评级
  69. switch (this.$refs.seiminModel.stars.indexOf('pda-haoping1')) {
  70. case -1:
  71. //五星
  72. serviceEvaluationId = WORKORDEREVALUATION['非常好评'];
  73. break;
  74. case 1:
  75. //一星
  76. serviceEvaluationId = WORKORDEREVALUATION['极差'];
  77. break;
  78. case 2:
  79. //二星
  80. serviceEvaluationId = WORKORDEREVALUATION['差'];
  81. break;
  82. case 3:
  83. //三星
  84. serviceEvaluationId = WORKORDEREVALUATION['一般'];
  85. break;
  86. case 4:
  87. //四星
  88. serviceEvaluationId = WORKORDEREVALUATION['好评'];
  89. break;
  90. }
  91. let postData = {
  92. serviceEvaluation: {
  93. id: serviceEvaluationId
  94. },
  95. remark: this.$refs.seiminModel.evaluateTextArea,
  96. };
  97. reqEvaluate(id, postData).then(res => {
  98. uni.hideLoading();
  99. if (res.status == 200) {
  100. this.$refs.seiminModel.show({
  101. skin: 'toast',
  102. icon: 'success',
  103. content: '评价成功',
  104. btns: [{
  105. click: () => {
  106. callBack && callBack();
  107. }
  108. }]
  109. })
  110. } else {
  111. this.$refs.seiminModel.show({
  112. skin: 'toast',
  113. icon: 'error',
  114. content: '评价失败',
  115. })
  116. }
  117. })
  118. }
  119. }
  120. ]
  121. });
  122. };
  123. //撤销
  124. export function openRecallModal(id, callBack) {
  125. this.$refs.seiminModel.show({
  126. icon: "warn",
  127. content: "您确认要撤销工单吗?撤销工单我们会通知服务台、支助人员不再执行此工单,请谨慎操作,如确认撤销请点击确认。",
  128. btns: [{
  129. click: () => {
  130. console.log('取消');
  131. this.$refs.seiminModel.close();
  132. }
  133. },
  134. {
  135. click: () => {
  136. console.log('确定');
  137. this.$refs.seiminModel.close();
  138. uni.showLoading({
  139. title: '加载中',
  140. mask: true,
  141. })
  142. reqDelWorkOrder(id).then(res => {
  143. uni.hideLoading();
  144. if (res.status == 200) {
  145. this.$refs.seiminModel.show({
  146. skin: 'toast',
  147. icon: 'success',
  148. content: '撤销成功',
  149. btns: [{
  150. click: () => {
  151. callBack && callBack();
  152. }
  153. }]
  154. })
  155. } else {
  156. this.$refs.seiminModel.show({
  157. skin: 'toast',
  158. icon: 'error',
  159. content: '撤销失败',
  160. })
  161. }
  162. })
  163. }
  164. }
  165. ]
  166. });
  167. };
  168. //立即执行
  169. export function openExecModal(id, callBack) {
  170. this.$refs.seiminModel.show({
  171. icon: 'warn',
  172. content: '您确认要立即执行该工单吗?',
  173. btns: [{
  174. click: () => {
  175. console.log('取消');
  176. this.$refs.seiminModel.close();
  177. }
  178. }, {
  179. click: () => {
  180. console.log('确认');
  181. this.$refs.seiminModel.close();
  182. uni.showLoading({
  183. title: '加载中',
  184. mask: true,
  185. })
  186. reqDirectStartOrder(id).then(res => {
  187. uni.hideLoading();
  188. if (res.status == 200) {
  189. this.$refs.seiminModel.show({
  190. skin: 'toast',
  191. icon: 'success',
  192. content: '立即执行成功',
  193. btns: [{
  194. click: () => {
  195. callBack && callBack();
  196. }
  197. }]
  198. })
  199. } else {
  200. this.$refs.seiminModel.show({
  201. skin: 'toast',
  202. icon: 'error',
  203. content: '立即执行失败',
  204. })
  205. }
  206. })
  207. }
  208. }, ]
  209. })
  210. };
  211. //加急
  212. export function showJiaji(id, callBack) {
  213. this.$refs.seiminModel.urgentTextArea = '';
  214. this.$refs.seiminModel.show({
  215. title: '',
  216. skin: 'urgent',
  217. content: "请填写加急原因,填写后我们会根据您的诉求优先处理",
  218. btns: [{
  219. click: () => {
  220. console.log('取消');
  221. this.$refs.seiminModel.close();
  222. }
  223. },
  224. {
  225. click: () => {
  226. console.log('确定', this.$refs.seiminModel.urgentTextArea);
  227. const urgentTextArea = this.$refs.seiminModel.urgentTextArea;
  228. if (urgentTextArea.trim() === '') {
  229. uni.showToast({
  230. icon: 'none',
  231. title: '请填写加急原因',
  232. })
  233. return;
  234. }
  235. this.$refs.seiminModel.close();
  236. uni.showLoading({
  237. title: '加载中',
  238. mask: true,
  239. })
  240. let postData = {
  241. urgentDetails: {
  242. workerOrder: id,
  243. checkStatus: {
  244. id: this.checkStatus[1]
  245. },
  246. urgentReason: urgentTextArea,
  247. },
  248. };
  249. reqUrge(postData).then(res => {
  250. uni.hideLoading();
  251. if (res.status == 200) {
  252. this.$refs.seiminModel.show({
  253. skin: 'toast',
  254. icon: 'success',
  255. content: '您的加急申请已成功,调度人员会紧急处理!',
  256. btns: [{
  257. click: () => {
  258. callBack && callBack();
  259. }
  260. }]
  261. })
  262. } else {
  263. this.$refs.seiminModel.show({
  264. skin: 'toast',
  265. icon: 'error',
  266. content: '加急失败',
  267. })
  268. }
  269. })
  270. }
  271. }
  272. ]
  273. });
  274. };