index.js 8.1 KB

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