思念食品 UI

xgWork.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. var id = helper.request.queryString("id");
  2. $(document).ready(function () {
  3. var groupcode = $('#groupcode', top.document).val();
  4. if (groupcode == 'SCZ') {
  5. $("#usedate").text("饮用日期:");
  6. $("#vipid").text("对接人:");
  7. $("#vipphone").text("对接人电话:");
  8. }
  9. laydate.render({
  10. elem: '.userDate',
  11. theme: '#1ab394',
  12. calendar: 'true'
  13. });
  14. laydate.render({
  15. elem: '.buyDate',
  16. theme: '#1ab394',
  17. calendar: 'true'
  18. });
  19. laydate.render({
  20. elem: '#productDate',
  21. theme: '#1ab394',
  22. calendar: 'true'
  23. });
  24. $.ajaxSettings.async = false;
  25. //工单来源
  26. getOrderSource();
  27. //工单类型
  28. getOrderType();
  29. //投诉类型
  30. complaintType();
  31. //产品类别
  32. getProductType();
  33. //区域
  34. getAreaType();
  35. //客诉专员
  36. ComplaintVip();
  37. //保存
  38. $('.customerSubmit').click(function() {
  39. saveCustomer();
  40. });
  41. $.ajaxSettings.async = true;
  42. var id = helper.request.queryString("id");
  43. $.ajax({
  44. type: "get",
  45. url: huayi.config.callcenter_url + "WorkOrder/GetWorkOrder",
  46. dataType: 'json',
  47. async: true,
  48. cache: false,
  49. data: {
  50. "workid": id,
  51. "token": $.cookie("token")
  52. },
  53. success: function(result) {
  54. if (result.data.data.length > 0) {
  55. var data = result.data.data[0];
  56. $('#name').val(data.F_CusName); //姓名
  57. $('#tel').val(data.F_CusPhone); //号码
  58. $('#productDate').val(data.F_ProductDate); //购买日期
  59. $('.buyDate').val(data.F_BuyDate); //购买日期
  60. $('.orderType').val(data.F_Type + ''); //工单类型ID
  61. $('.orderType').trigger("change");
  62. $('.complaintType').val(data.F_SmallType + '');
  63. $('#productname').val(data.F_ProductName); //产品名称
  64. $('#buyAddress').val(data.F_BuyAddress); //购买地址 data.
  65. $('#productType').val(data.F_ProductType + ''); //产品类别ID
  66. $('#batchNumber').val(data.F_BatchNumber); //生产批号
  67. $('.userDate').val(data.F_UserDate); //使用日期
  68. $('#DicValueList').val(data.F_Source + ''); //工单来源
  69. $("#areaInps").val(data.F_Area);
  70. $('#typeclass').val(data.F_Province + "/" + data.F_City); //区域
  71. $('.inps2').val(data.F_Province); //省
  72. $('.inps3').val(data.F_City); //市
  73. $('#content').val(data.F_Content); //事件描述
  74. $('#vipName').val(data.F_VIPId+''); //专员姓名
  75. $('#vipTel').val(data.F_VIPPhone); //专员号码
  76. $("input[name='sendBack'][value='" + data.F_IsBack+"']").attr("checked", true);
  77. }
  78. }
  79. });
  80. $('.areaDown').click(function() {
  81. if ($('.treeList1').css('display') == 'block') {
  82. $('.treeList1').css('display', 'none')
  83. } else {
  84. $('.treeList1').css('display', 'block')
  85. }
  86. })
  87. $('#typeclass').click(function() {
  88. $('.treeList1').css('display', 'block')
  89. })
  90. $('.treeList1').mouseleave(function() {
  91. $(this).css('display', 'none')
  92. })
  93. $(".orderType").change(function() {
  94. if ($(".orderType option:selected").text() != "投诉") {
  95. $(".complainDiv").hide();
  96. } else {
  97. $(".complainDiv").show();
  98. }
  99. });
  100. //获取专员手机号
  101. $("#vipName").change(function() {
  102. $("#vipTel").val($("#vipName option:selected").attr("index"));
  103. //$("#areaInps").val($("#vipName option:selected").attr("areaText"));
  104. $("#typeclass").val($("#vipName option:selected").attr("province") + "/" + $("#vipName option:selected").attr("city"));
  105. $(".inps2").val($("#vipName option:selected").attr("province"));
  106. $(".inps3").val($("#vipName option:selected").attr("city"));
  107. });
  108. })
  109. //工单类型
  110. function getOrderType() {
  111. $.get(huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag', {
  112. "token": $.cookie("token"),
  113. flag: "GDLX"
  114. }, function(result) {
  115. result = $.parseJSON(result);
  116. var Count = result.data;
  117. $(Count).each(function(i, n) {
  118. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($(".orderType"));
  119. })
  120. });
  121. }
  122. //工单类型
  123. function complaintType() {
  124. $.get(huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag', {
  125. "token": $.cookie("token"),
  126. flag: "TSLX"
  127. }, function(result) {
  128. result = $.parseJSON(result);
  129. var Count = result.data;
  130. $(Count).each(function(i, n) {
  131. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($(".complaintType"));
  132. })
  133. });
  134. }
  135. //产品类别
  136. function getProductType() {
  137. $.get(huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag', {
  138. "token": $.cookie("token"),
  139. flag: "CPLB"
  140. }, function(result) {
  141. result = $.parseJSON(result);
  142. var Count = result.data;
  143. $(Count).each(function(i, n) {
  144. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($(".productType"));
  145. })
  146. });
  147. }
  148. //区域
  149. function getAreaType() {
  150. $.get(huayi.config.callcenter_url + 'Area/GetAreaList', {
  151. "token": $.cookie("token"),
  152. }, function(result) {
  153. result = $.parseJSON(result);
  154. $.fn.zTree.init($("#TreeDemo1"), setting, result.data); //实例化树形图
  155. });
  156. }
  157. var setting = {
  158. data: {
  159. key: {
  160. name: "F_AreaName"
  161. },
  162. simpleData: {
  163. enable: true,
  164. idKey: "F_Id",
  165. pIdKey: "F_ParentId",
  166. rootPId: 0
  167. }
  168. },
  169. callback: {
  170. onClick: changeTreeClick
  171. }
  172. }
  173. function changeTreeClick(event, treeId, treeNode) {
  174. var areaParent = treeNode.getPath();
  175. if (areaParent[1]) {
  176. areaParent1 = areaParent[0].F_AreaName
  177. areaParent2 = areaParent[1].F_AreaName
  178. $('#typeclass').val(areaParent1 + "/" + areaParent2);
  179. $('.inps2').val(areaParent1);
  180. $('.inps3').val(areaParent2);
  181. ComplaintVip();
  182. } else {
  183. layer.msg("请选择最下级菜单");
  184. }
  185. $('.addTree1').hide();
  186. };
  187. //工单来源
  188. function getOrderSource(obj) {
  189. $.ajax({
  190. type: "get",
  191. url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
  192. dataType: 'json',
  193. async: true,
  194. data: {
  195. token: $.cookie("token"),
  196. flag: "GDLY"
  197. },
  198. success: function(data) {
  199. var Count = data.data;
  200. $(Count).each(function(i, n) {
  201. $('<option value="' + n.F_DictionaryValueId + '">' + n.F_Name + '</option>').appendTo($("#DicValueList"));
  202. })
  203. }
  204. });
  205. }
  206. //客诉专员
  207. function ComplaintVip() {
  208. $.ajax({
  209. type: "get",
  210. url: huayi.config.callcenter_url + "Customer/GetAllList",
  211. dataType: 'json',
  212. async: true,
  213. data: {
  214. token: $.cookie("token"),
  215. type: 2,
  216. province: $('.inps2').val(), //省
  217. city: $('.inps3').val() //市
  218. },
  219. success: function(data) {
  220. $("#vipName").empty();
  221. var Count = data.data;
  222. $('<option value="">请选择专员</option>').appendTo($("#vipName"));
  223. $(Count).each(function(i, n) {
  224. $('<option value="' + n.F_Id
  225. + '" index="' + n.F_Phone
  226. + '" areaText="' + n.F_Area
  227. + '" province="' + n.F_Province
  228. + '" city="' + n.F_City + '">' + n.F_Name
  229. + '</option>').appendTo($("#vipName"));
  230. })
  231. }
  232. });
  233. }
  234. //保存
  235. function saveCustomer() {
  236. if (!$('#name').val()) {
  237. layer.confirm('请输入姓名!', {
  238. icon: 2,
  239. btn: ['确定']
  240. });
  241. return;
  242. }
  243. if (!$('#tel').val()) {
  244. layer.confirm('请输入电话!', {
  245. icon: 2,
  246. btn: ['确定']
  247. });
  248. return;
  249. }
  250. if (!$('#DicValueList').val()) {
  251. layer.confirm('请选择工单来源!', {
  252. icon: 2,
  253. btn: ['确定']
  254. });
  255. return;
  256. }
  257. if (!$('.orderType').val()) {
  258. layer.confirm('请选择工单类型!', {
  259. icon: 2,
  260. btn: ['确定']
  261. });
  262. return;
  263. }
  264. $.ajax({
  265. type: "post",
  266. url: huayi.config.callcenter_url + "WorkOrder/EditWorkOrder",
  267. dataType: 'json',
  268. async: true,
  269. beforeSend: function() { //触发ajax请求开始时执行
  270. $('.customerSubmit').attr("disabled", true);
  271. $('.customerSubmit').text('保存中...');
  272. },
  273. data: {
  274. token: $.cookie("token"),
  275. workid: id,
  276. cusname: $('#name').val(), //姓名
  277. cusphone: $('#tel').val(), //号码
  278. productdate: $('#productDate').val(),
  279. buydate: $('.buyDate').val(), //购买日期
  280. productname: $('#productname').val(), //产品名称
  281. buyaddress: $('#buyAddress').val(), //购买地址
  282. producttype: $('#productType').val(), //产品类别
  283. batchnumber: $('#batchNumber').val(), //生产批号
  284. userdate: $('.userDate').val(), //使用日期 userDate
  285. source: $('#DicValueList').val(), //工单来源
  286. type: $('.orderType').val(), //工单类型id
  287. smalltype: $(".complaintType").val(), //投诉类型
  288. area: $('#areaInps').val(), //区域
  289. province: $('.inps2').val(), //省
  290. city: $('.inps3').val(), //市
  291. content: $('#content').val(), //事件描述
  292. vipid: $('#vipName').val(), //专员id
  293. vipphone: $('#vipTel').val(), //专员号码
  294. isback: $('input[name="sendBack"]:checked').val(),
  295. callid: $("#CallID").val()
  296. },
  297. success: function(data) {
  298. if (data.state.toLowerCase() == 'success') {
  299. $('.customerSubmit').attr("disabled", false);
  300. $('.customerSubmit').text('保存');
  301. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  302. parent.layer.close(index); //再执行关闭
  303. parent.layer.msg("保存成功!");
  304. parent.$('#workorderlist').bootstrapTable('refresh');
  305. parent.$('#workorderlist_').bootstrapTable('refresh');
  306. }
  307. }
  308. });
  309. }