123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- import {
- AES,
- mode,
- pad,
- enc
- } from "crypto-js";
- import {
- WORKORDER_EVALUATION
- } from "./enum.workorderEvaluation.js";
- import {
- reqDelWorkOrder,
- reqUrge,
- reqEvaluate,
- reqDirectStartOrder,
- } from "../request/api.js";
- // 生成一个从 start 到 end 的连续数组
- export function generateArray(start, end) {
- return Array.from(new Array(end + 1).keys()).slice(start).map(v => v.toString().padStart(2, '0'));
- }
- //aes加密
- export function encryptByEnAES(data = '') {
- let Key = "dsadmin";
- let tmpAES = AES.encrypt(data, Key, {
- mode: mode.CBC,
- padding: pad.Pkcs7,
- });
- return tmpAES.toString();
- }
- //aes解密
- export function encryptByDeAES(data = '') {
- let Key = "dsadmin";
- let tmpDeAES = AES.decrypt(data, Key, {
- mode: mode.CBC,
- padding: pad.Pkcs7,
- });
- return tmpDeAES.toString(enc.Utf8);
- }
- // 简单的模拟枚举
- export function createEnum(arr = []) {
- let obj = {}
- arr.forEach(v => {
- obj[obj[v.name] = v.value] = v.name;
- })
- return Object.freeze(obj);
- };
- // 获取页面栈,默认0是当前页面栈
- export function getCurrentPagesSeimin(num = 0) {
- let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
- let curRoute = routes[routes.length - 1 - num].route // 获取当前页面路由,也就是最后一个打开的页面路由
- return curRoute;
- };
- //评价
- export function showAppraise(id, callBack) {
- this.$refs.seiminModel.show({
- skin: 'evaluate',
- content: "工单已完成,请对本次服务做出评价!",
- btns: [{
- click: () => {
- console.log('取消');
- this.$refs.seiminModel.close();
- }
- },
- {
- click: () => {
- console.log('确定');
- let serviceEvaluationId;
- this.$refs.seiminModel.close();
- uni.showLoading({
- title: '加载中',
- mask: true,
- })
- //算出评级
- switch (this.$refs.seiminModel.stars.indexOf('pda-haoping1')) {
- case -1:
- //五星
- serviceEvaluationId = WORKORDER_EVALUATION['非常好评'];
- break;
- case 1:
- //一星
- serviceEvaluationId = WORKORDER_EVALUATION['极差'];
- break;
- case 2:
- //二星
- serviceEvaluationId = WORKORDER_EVALUATION['差'];
- break;
- case 3:
- //三星
- serviceEvaluationId = WORKORDER_EVALUATION['一般'];
- break;
- case 4:
- //四星
- serviceEvaluationId = WORKORDER_EVALUATION['好评'];
- break;
- }
- let postData = {
- serviceEvaluation: {
- id: serviceEvaluationId
- },
- remark: this.$refs.seiminModel.evaluateTextArea,
- };
- reqEvaluate(id, postData).then(res => {
- uni.hideLoading();
- if (res.status == 200) {
- this.$refs.seiminModel.show({
- skin: 'toast',
- icon: 'success',
- content: '评价成功',
- btns: [{
- click: () => {
- callBack && callBack();
- }
- }]
- })
- } else {
- this.$refs.seiminModel.show({
- skin: 'toast',
- icon: 'error',
- content: '评价失败',
- })
- }
- })
- }
- }
- ]
- });
- };
- //撤销
- export function openRecallModal(id, callBack) {
- this.$refs.seiminModel.show({
- icon: "warn",
- content: "您确认要撤销工单吗?撤销工单我们会通知服务台、支助人员不再执行此工单,请谨慎操作,如确认撤销请点击确认。",
- btns: [{
- click: () => {
- console.log('取消');
- this.$refs.seiminModel.close();
- }
- },
- {
- click: () => {
- console.log('确定');
- this.$refs.seiminModel.close();
- uni.showLoading({
- title: '加载中',
- mask: true,
- })
- reqDelWorkOrder(id).then(res => {
- uni.hideLoading();
- if (res.status == 200) {
- this.$refs.seiminModel.show({
- skin: 'toast',
- icon: 'success',
- content: '撤销成功',
- btns: [{
- click: () => {
- callBack && callBack();
- }
- }]
- })
- } else {
- this.$refs.seiminModel.show({
- skin: 'toast',
- icon: 'error',
- content: '撤销失败',
- })
- }
- })
- }
- }
- ]
- });
- };
- //立即执行
- export function openExecModal(id, callBack) {
- this.$refs.seiminModel.show({
- icon: 'warn',
- content: '您确认要立即执行该工单吗?',
- btns: [{
- click: () => {
- console.log('取消');
- this.$refs.seiminModel.close();
- }
- }, {
- click: () => {
- console.log('确认');
- this.$refs.seiminModel.close();
- uni.showLoading({
- title: '加载中',
- mask: true,
- })
- reqDirectStartOrder(id).then(res => {
- uni.hideLoading();
- if (res.status == 200) {
- this.$refs.seiminModel.show({
- skin: 'toast',
- icon: 'success',
- content: '立即执行成功',
- btns: [{
- click: () => {
- callBack && callBack();
- }
- }]
- })
- } else {
- this.$refs.seiminModel.show({
- skin: 'toast',
- icon: 'error',
- content: '立即执行失败',
- })
- }
- })
- }
- }, ]
- })
- };
- //加急
- export function showJiaji(id, callBack) {
- this.$refs.seiminModel.urgentTextArea = '';
- this.$refs.seiminModel.show({
- title: '',
- skin: 'urgent',
- content: "请填写加急原因,填写后我们会根据您的诉求优先处理",
- btns: [{
- click: () => {
- console.log('取消');
- this.$refs.seiminModel.close();
- }
- },
- {
- click: () => {
- console.log('确定', this.$refs.seiminModel.urgentTextArea);
- const urgentTextArea = this.$refs.seiminModel.urgentTextArea;
- if (urgentTextArea.trim() === '') {
- uni.showToast({
- icon: 'none',
- title: '请填写加急原因',
- })
- return;
- }
- this.$refs.seiminModel.close();
- uni.showLoading({
- title: '加载中',
- mask: true,
- })
- let postData = {
- urgentDetails: {
- workerOrder: id,
- checkStatus: {
- id: 330
- },
- urgentReason: urgentTextArea,
- },
- };
- reqUrge(postData).then(res => {
- uni.hideLoading();
- if (res.status == 200) {
- this.$refs.seiminModel.show({
- skin: 'toast',
- icon: 'success',
- content: '您的加急申请已成功,调度人员会紧急处理!',
- btns: [{
- click: () => {
- callBack && callBack();
- }
- }]
- })
- } else {
- this.$refs.seiminModel.show({
- skin: 'toast',
- icon: 'error',
- content: '加急失败',
- })
- }
- })
- }
- }
- ]
- });
- };
- // 返回上一页
- export const backPress = function() {
- let pages = getCurrentPages() //页面栈
- let prePage = pages[pages.length - 2] //上一页
- prePage.$vm.reFresh = Math.random() //触发上一页监听器
- }
- // 获取页面栈,默认0是当前页面栈,包含参数
- export function getCurrentPagesSeiminAll(num = 0) {
- let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
- let curRoute = routes[routes.length - 1 - num].$page.fullPath // 获取当前页面路由,也就是最后一个打开的页面路由
- return curRoute;
- };
|