app-xiangsonghua/app-saas-src/script/systemOrder/systemOrderDetail.js
2024-12-26 17:00:06 +08:00

148 lines
4.1 KiB
JavaScript

apiready = function() {
var ctrl = {
init: {},
bind: {},
prefix: 'https://cdyfile.saas.dianwutong.com/',
orderData: {
pics: [],
serverPicUrls: [],
uploadPicNum: 0,
desc: '',
prId: null,
},
};
ctrl.init = function() {
CommonModel.fitInStatusBar();
ctrl.orderId = api.pageParam.orderid;
ctrl.status = api.pageParam.status;
if (ctrl.status == 0) { // 未接单
$('.handle-detail').hide();
} else if (ctrl.status == 3) { // 已完成
$('.handle-detail').show();
}
ctrl.bind();
ctrl.initOrderDetail();
}
ctrl.bind = function() {
//点击返回按钮
$api.addEvt($api.dom("#back"), "touchend", function() {
api.closeWin();
});
// 点击图片预览
$("#content").on("touchend", ".pic", function (e) {
e.stopPropagation();
var src = $(this).attr('src');
$('#pic-review img').attr('src', src);
$('#pic-review').css('display', 'block');
});
// 点击处理结果图片预览
// $("#result-pic-content").on("touchend", ".pic", function (e) {
// console.log(3322323)
// e.stopPropagation();
// var src = $(this).attr('src');
// $('#pic-review img').attr('src', src);
// $('#pic-review').css('display', 'block');
// });
// 点击预览图片 关闭预览
$('#pic-review').on("touchend", function () {
$(this).css('display', 'none');
});
};
/**
* 弹出提示框
*/
ctrl.toast = function (msg) {
api.toast({
msg: msg,
duration: 3000,
locaiton: 'top'
});
};
// 初始化 工单详情
ctrl.initOrderDetail = function () {
ctrl.getOrderDetail();
};
// 获取工单详情
ctrl.getOrderDetail = function () {
var url = '/test/gong-dan/queryById/' + ctrl.orderId;
api.showProgress({
title: '载入中...',
text: '请稍后',
modal: false
});
$api.get(url, function(res, err) {
api.hideProgress();
if (err) {
ctrl.toast("网络请求失败");
} else {
if (!res.code || res.code != "200" || !res.data) {
ctrl.toast("服务器响应错误" + (res.code ? (",错误码:" + res.code) : ""));
} else {
ctrl.renderOrderDetail(res.data);
}
}
});
};
// 渲染工单详情
ctrl.renderOrderDetail = function (data) {
$('#pr-name').text(data.prName);
$('#person').text(data.tiJiaoRenName);
$('#create-time').text(data.tiJiaoShiJian);
$('#desc').text(data.miaoShu);
$('#result-desc').text(data.chuLiMiaoShu || '无');
$('#result-person').text(data.chuLiRenName || '无');
$('#handle-time').text(data.chuLiShiJian || '无');
$('#complete-time').text(data.wanChengShiJian || '无');
// 渲染问题照片
var picContentDom = $('#pic-content');
if (data.zhaoPian) {
ctrl.renderPics(picContentDom, data.zhaoPian);
} else {
picContentDom.html('无');
};
// 渲染处理照片
var resultPicContentDom = $('#result-pic-content');
if (data.chuLiZhaoPian) {
ctrl.renderPics(resultPicContentDom, data.chuLiZhaoPian);
} else {
resultPicContentDom.html('无');
};
};
// 渲染 图片
ctrl.renderPics = function(dom, pics) {
dom.empty();
var picsArr = pics.split(',');
var length = picsArr.length;
for (var i = 0; i < length; i++) {
var picUrl = ctrl.prefix + picsArr[i];
var picDom = '<span class="pic-item"><img class="pic" src="'+ picUrl +'" alt=""></span>';
dom.append(picDom);
}
};
ctrl.init();
}