mui.init({
swipeBack: false,
beforeback: function() {
var list = plus.webview.currentWebview().opener();
//refresh是A页面自定义事件
mui.fire(list, 'refreshPer');
//返回true,继续页面关闭逻辑
return true;
}
})
mui.plusReady(function() {
var wv = plus.webview.currentWebview();
var usercode = localStorage.getItem("user"); //获取本地存储
var files;
var Str = '';
var str_ary;
var reg = /,$/gi;
//提交按钮
$('#submit').on('tap', function() {
$(".image-box").each(function(i, n) {
var a = $(n).attr("indexs");
if(a) {
Str += a + ',';
}
})
var addresText=$("#choworder_rengin").val()+'-'
+$("#shouorder_shi").val()+'-'
+$("#chouorder_xian").val()+'-'
+$("#textarea").val();
if($('#F_CusName').val() == '') {
mui.alert('请输入姓名!')
} else if($('#F_CusPhone').val() == '') {
mui.alert('请输入联系电话!')
} else if($('#F_QualityProblem').val() == '') {
mui.alert('请输入质量问题!')
} else {
$.ajax({
type: "post",
dataType: 'json',
url: huayi.config.callcenter_url + '/WorkorderApp/AddWorkOrder',
async: true,
data: {
F_Type: $('#F_Type').attr('data-index'), //工单类型
F_CusName: $('#F_CusName').val(), //姓名
F_CusPhone: $('#F_CusPhone').val(), //电话
F_AddRess:addresText,//地址
F_ProductType:$('#F_ProductType').val(), //产品代码
F_ProductName:$('#F_ProductName').val(), //产品名称
F_Specifications:$('#F_Specifications').val(), //规格
F_ProductDate:$('#F_ProductDate').val(), //生产日期
F_BatchNumber:$('#F_BatchNumber').val(), //产品编码
F_Manufacturer:$('#F_Manufacturer').val(), //生产厂家
F_ProblemCode:$('#F_ProblemCode').val(), //问题代码
F_QualityProblem:$('#F_QualityProblem').val(), //质量问题
F_DealTimely:$('#F_DealTimely').val(), //工单等级
F_DealTimelyyy:$('#F_DealTimelyyy').val(), //工单等级原因
IsAssign:0,
//F_QualityProblem: $('input[name="opinion"]:checked').val(), //=(1普通2紧急)
//F_Area:$('#F_Area').val(), //大区
//clid:$('#F_Clid').val(), //提交人
F_Content:$('#F_Content').val(), //备注
token:localStorage.getItem("token")
},
success: function(data) {
if(data.state == "success") {
mui.toast('投诉成功!');
$("#name").val('');
$("#phone").val('');
$("#title").val('');
$(".content").val('');
$("#cityResult3").val('');
$("#zhuTiResult").val('');
$("#F_Type").val('');
$('#detail_address').val('');
$('input[name="secret"][value="0"]').prop("checked", "checked");
window.location.reload();
} else {
mui.toast(data.message);
}
}
});
}
})
//工单类型
var typeList = [{
value: '1',
text: '咨询'
}, {
value: '2',
text: '投诉'
}, {
value: '3',
text: '重复'
}]
// 产品代码
var Product = [];
$.ajax({
type: "get",
url: huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag',
async: false,
data: {
flag: "CPDM",
token:localStorage.getItem("token")
},
dataType: 'json',
success: function(res) {
if(res.state.toLowerCase() === "success") {
res = res.data;
if(res && res.length > 0) {
res.forEach(function(v, i) {
var obj = {};
obj.value = v.F_DictionaryValueId;
obj.text = v.F_Name;
Product.push(obj);
});
}
}
}
});
// 问题代码
var Problem = [];
$.ajax({
type: "get",
url: huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag',
async: false,
data: {
flag: "WTDM",
token:localStorage.getItem("token")
},
dataType: 'json',
success: function(res) {
if(res.state.toLowerCase() === "success") {
res = res.data;
if(res && res.length > 0) {
res.forEach(function(v, i) {
var obj = {};
obj.value = v.F_DictionaryValueId;
obj.text = v.F_Name;
Problem.push(obj);
});
}
}
}
});
// 工单等级
var DealTimely = [];
$.ajax({
type: "get",
url: huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag',
async: false,
data: {
flag: "GDDJ",
token:localStorage.getItem("token")
},
dataType: 'json',
success: function(res) {
if(res.state.toLowerCase() === "success") {
res = res.data;
if(res && res.length > 0) {
res.forEach(function(v, i) {
var obj = {};
obj.value = v.F_DictionaryValueId;
obj.text = v.F_Name;
DealTimely.push(obj);
});
}
}
}
});
function gddjyy(){
var DealTimelyyy = []
var flagDJ;
if ($("#F_DealTimely").val()=="普通工单") {
flagDJ="PGYY"
} else if ($("#F_DealTimely").val()=="Ⅰ级") {
flagDJ="YJYY"
} else if ($("#F_DealTimely").val()=="Ⅱ级") {
flagDJ="EJYY"
}
$.ajax({
url: huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag',
type: 'get',
data: {
flag: flagDJ,
token:localStorage.getItem("token")
},
dataType: "json",
async: true,
success: function(res) {
if(res.state.toLowerCase() === "success") {
res = res.data;
if(res && res.length >0) {
res.forEach(function(v, i) {
var obj = {};
obj.value = v.F_DictionaryValueId;
obj.text = v.F_Name;
DealTimelyyy.push(obj);
//$('').appendTo('#order_recive');
});
userPicker5.setData(DealTimelyyy);
}
}
},
});
}
// 大区
var Area = [];
$.ajax({
type: "get",
url: huayi.config.callcenter_url + 'Department/GetCusAreaList',
async: false,
data: {
pid: 1,
F_Layer: 1,
token:localStorage.getItem("token")
},
dataType: 'json',
success: function(res) {
if(res.state.toLowerCase() === "success") {
res = res.data;
if(res && res.length > 0) {
res.forEach(function(v, i) {
var obj = {};
obj.value = v.F_DeptId;
obj.text = v.F_DeptName;
Area.push(obj);
});
}
}
}
});
//市
function getClid(){
var Clid = []
alert($('#F_Area').attr('data-index'))
$.ajax({
url: huayi.config.callcenter_url + 'UserAccount/GetList',
type: 'get',
data: {
type: 1,
dptid: $('#F_Area').attr('data-index'),
token:localStorage.getItem("token")
},
dataType: "json",
async: true,
success: function(res) {
res = res.rows;
if(res && res.length >0) {
res.forEach(function(v, i) {
var obj = {};
obj.value = v.F_UserName;
obj.text = v.F_UserName;
Clid.push(obj);
});
userPicker7.setData(Clid);
}
},
});
}
// 咨询省市县乡
var recives = [];
$.ajax({
type: "get",
url: huayi.config.callcenter_url + 'RegionCategory/GetCountyList',
async: false,
data: {
pid:0,
token:localStorage.getItem("token")
},
dataType: 'json',
success: function(res) {
if(res.state.toLowerCase() === "success") {
res = res.data;
if(res && res.length > 0) {
res.forEach(function(v, i) {
var obj = {};
obj.value = v.F_RegionId;
obj.text = v.F_RegionName;
recives.push(obj);
});
}
}
}
});
//市
function getRece(){
var renyuann = []
$.ajax({
url: huayi.config.callcenter_url + 'RegionCategory/GetCountyList',
type: 'get',
data: {
pid:$('#choworder_rengin').attr('data-index'),
token:localStorage.getItem("token")
},
dataType: "json",
async: true,
success: function(res) {
if(res.state.toLowerCase() === "success") {
res = res.data;
if(res && res.length >0) {
res.forEach(function(v, i) {
var obj = {};
obj.value = v.F_RegionId;
obj.text = v.F_RegionName;
renyuann.push(obj);
//$('').appendTo('#order_recive');
});
RCiPickee1.setData(renyuann);
}
}
},
});
}
//区/县
function getReee(){
var rennn = []
$.ajax({
url: huayi.config.callcenter_url + 'RegionCategory/GetCountyList',
type: 'get',
data: {
pid:$('#shouorder_shi').attr('data-index'),
token:localStorage.getItem("token")
},
dataType: "json",
async: true,
success: function(res) {
if(res.state.toLowerCase() === "success") {
res = res.data;
if(res && res.length >0) {
res.forEach(function(v, i) {
var obj = {};
obj.value = v.F_RegionId;
obj.text = v.F_RegionName;
rennn.push(obj);
//$('').appendTo('#order_recive');
});
RCiPi1.setData(rennn);
}
}
},
});
}
(function($, doc) {
$.init();
$.ready(function() {
//工单类型
var userPicker1 = new $.PopPicker();
userPicker1.setData(typeList);
var showUserPickerButton1 = doc.getElementById('showUserPicker');
var F_Type = doc.getElementById('F_Type');
showUserPickerButton1.addEventListener('tap', function(event) {
userPicker1.show(function(items) {
console.log(items)
F_Type.value = items[0].text;
F_Type.setAttribute("data-index", items[0].value);
//返回 false 可以阻止选择框的关闭
//return false;
});
}, false);
//产品代码
var userPicker2 = new $.PopPicker();
userPicker2.setData(Product);
var showUserPickerButton2 = doc.getElementById('showUserPickerProduct');
var F_Product = doc.getElementById('F_ProductType');
showUserPickerButton2.addEventListener('tap', function(event) {
userPicker2.show(function(items) {
F_Product.value = items[0].text;
F_Product.setAttribute("data-index", items[0].value);
});
}, false);
//问题代码
var userPicker3 = new $.PopPicker();
userPicker3.setData(Problem);
var showUserPickerButton3 = doc.getElementById('showUserPickerProblem');
var F_Problem = doc.getElementById('F_ProblemCode');
showUserPickerButton3.addEventListener('tap', function(event) {
userPicker3.show(function(items) {
F_Problem.value = items[0].text;
F_Problem.setAttribute("data-index", items[0].value);
});
}, false);
//工单等级
var userPicker4 = new $.PopPicker();
userPicker4.setData(DealTimely);
var showUserPickerButton4 = doc.getElementById('showUserPickerDealTimely');
var F_DealTimely = doc.getElementById('F_DealTimely');
showUserPickerButton4.addEventListener('tap', function(event) {
userPicker4.show(function(items) {
F_DealTimely.value = items[0].text;
F_DealTimely.setAttribute("data-index", items[0].value);
});
}, false);
//工单等级原因
userPicker5 = new $.PopPicker({
F_Layer: 1,
});
var showUserPickerButton5 = doc.getElementById('showUserPickerDealTimelyyy');
var F_DealTimelyyy = doc.getElementById('F_DealTimelyyy');
showUserPickerButton5.addEventListener('tap', function(event) {
gddjyy();
userPicker5.show(function(items) {
doc.getElementById('chouorder_xian').value="";
if (items[0].text!=undefined) {
F_DealTimelyyy.value =items[0].text
F_DealTimelyyy.setAttribute("data-index", items[0].value);
}
});
}, false);
//大区
var userPicker6 = new $.PopPicker({
F_Layer: 1,
});
userPicker6.setData(Area);
var showUserPickerButton6 = doc.getElementById('showUserPickerArea');
var F_Area = doc.getElementById('F_Area');
showUserPickerButton6.addEventListener('tap', function(event) {
userPicker6.show(function(items) {
F_Area.value =items[0].text
F_Area.setAttribute("data-index", items[0].value);
});
}, false);
//提交人
userPicker7 = new $.PopPicker({
F_Layer: 1,
});
var showUserPickerButton7 = doc.getElementById('showUserPickeClid');
var F_Clid = doc.getElementById('F_Clid');
showUserPickerButton7.addEventListener('tap', function(event) {
getClid();
userPicker7.show(function(items) {
if (items[0].text!=undefined) {
F_Clid.value =items[0].text
F_Clid.setAttribute("data-index", items[0].value);
}
});
}, false);
//咨询省
var RCiP = new $.PopPicker({
F_Layer: 1,
});
RCiP.setData(recives);
var RCss1 = doc.getElementById('chouhuTi');
var RCResultss = doc.getElementById('choworder_rengin');
RCss1.addEventListener('tap', function(event) {
doc.getElementById('shouorder_shi').value="";
doc.getElementById('chouorder_xian').value="";
RCiP.show(function(items) {
RCResultss.value =items[0].text
RCResultss.setAttribute("data-index", items[0].value);
});
}, false);
//市
RCiPickee1 = new $.PopPicker({
F_Layer: 1,
});
var RCss2 = doc.getElementById('chowZhuTiPicker');
var RCResultss2 = doc.getElementById('shouorder_shi');
RCss2.addEventListener('tap', function(event) {
getRece();
RCiPickee1.show(function(items) {
doc.getElementById('chouorder_xian').value="";
if (items[0].text!=undefined) {
RCResultss2.value =items[0].text
RCResultss2.setAttribute("data-index", items[0].value);
}
});
}, false);
//区/县
RCiPi1 = new $.PopPicker({
F_Layer: 1,
});
var RCs22 = doc.getElementById('chowcounty');
var RCResults22 = doc.getElementById('chouorder_xian');
RCs22.addEventListener('tap', function(event) {
getReee();
RCiPi1.show(function(items) {
if (items[0].text!=undefined) {
RCResults22.value =items[0].text
RCResults22.setAttribute("data-index", items[0].value);
}
});
}, false);
})
})(mui, document);
});