郑州第一人民医院UI

seedReceiveGoods.js 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. //省市项目三级联动
  2. var Adress = [],
  3. departPicker, departMent = [];
  4. // getPro();
  5. var phone=/^\d{3,12}$/;
  6. var projectid=localStorage.getItem("projectid");
  7. var ids= helper.request.queryString("id");
  8. var floorid= helper.request.queryString("floorid");
  9. var goods= helper.request.queryString("goods");
  10. $(function(){
  11. if(ids){
  12. adressDetail();//获取详情
  13. }
  14. if(floorid){
  15. getQRfloor();//用扫码获取楼层id 获取地址详情
  16. }
  17. getBuild();
  18. })
  19. //楼下拉
  20. function getBuild() {
  21. $.ajax({
  22. type: "get",
  23. url: huayi.config.callcenter_url + 'equipmentapi/api/equipment/getaddresstree',
  24. async: false,
  25. data: {
  26. projectid: projectid
  27. },
  28. dataType: 'json',
  29. success: function(data) {
  30. var type_data = data.data;
  31. if(type_data != null && type_data.length > 0) {
  32. $(type_data).each(function(i, n) {
  33. var obj = {};
  34. obj.value = n.id;
  35. obj.text = n.name;
  36. if(n.entityJson != null && n.entityJson.length > 0) {
  37. var children2 = [];
  38. $(n.entityJson).each(function(j, k) {
  39. var obj2 = {};
  40. obj2.value = k.code;
  41. obj2.text = k.name+" "+k.departmentname;
  42. obj2.floorName = k.name;
  43. obj2.depname = k.departmentname;
  44. children2.push(obj2);
  45. })
  46. obj.children = children2;
  47. }
  48. Adress.push(obj);
  49. })
  50. }
  51. }
  52. });
  53. }
  54. //科室下拉
  55. function GetDepartment() {
  56. departMent = [];
  57. $.ajax({
  58. type: "get",
  59. url: huayi.config.callcenter_url + 'configurationapi/api/Department/getlistdrop',
  60. // url: 'http://192.168.5.46:28000/configurationapi/api/Department/getlistdrop',
  61. async: false,
  62. data: {
  63. projectid: $('#proNameCode').val(),
  64. building: $('#buildCode').val(),
  65. floorid: $('#floorCode').val()
  66. },
  67. dataType: 'json',
  68. success: function(data) {
  69. var result = data.data;
  70. // departMent = JSON.parse(JSON.stringify(defaultDatas).replace(/departmenname/g, "text"));
  71. // departMent = JSON.parse(JSON.stringify(defaultDatas).replace(/id/g, "value"));
  72. // departMent = JSON.parse(JSON.stringify(defaultDatas).replace(/\[\]/g, null));
  73. if(result != null && result.length > 0) {
  74. departMent = filterTreeDatas(result);
  75. departPicker.setData(departMent);
  76. } else {
  77. departPicker.setData(departMent);
  78. }
  79. }
  80. });
  81. }
  82. function filterTreeDatas(treeDatas) {
  83. var accessedRouters = [];
  84. var j = -1;
  85. for(var i in treeDatas) {
  86. j++;
  87. accessedRouters.push({
  88. value: treeDatas[i].id,
  89. text: treeDatas[i].departmenname
  90. });
  91. if(treeDatas[i].children) {
  92. // filterTreeDatas(
  93. // treeDatas[i].children
  94. // );
  95. $.each(treeDatas[i].children, function(k, v) {
  96. accessedRouters.push({
  97. value: v.id,
  98. text: v.departmenname
  99. });
  100. if(v.children) {
  101. $.each(v.children, function(q, r) {
  102. accessedRouters.push({
  103. value: r.id,
  104. text: r.departmenname
  105. });
  106. });
  107. }
  108. });
  109. }
  110. }
  111. return accessedRouters;
  112. }
  113. //填充数据
  114. (function($, doc) {
  115. $.init();
  116. $.ready(function() {
  117. //位置
  118. // var proPicker = new $.PopPicker();
  119. // proPicker.setData(proData);
  120. // var showZhuTiPickerButton_ = doc.getElementById('showLocation');
  121. // var zhuTiPicker_ = doc.getElementById('proNameText');
  122. // showZhuTiPickerButton_.addEventListener('tap', function(event) {
  123. // proPicker.show(function(items) {
  124. // zhuTiPicker_.value = items[0].text;
  125. // doc.getElementById('proNameCode').value = items[0].value;
  126. // doc.getElementById('buildName').value = "";
  127. // doc.getElementById('buildCode').value = "";
  128. // doc.getElementById('floorCode').value = "";
  129. //// getBuild();
  130. // // if (Adress.length == 0) {
  131. // // doc.getElementById('buildName').setAttribute("placeholder", "暂无数据");
  132. // // } else {
  133. // // doc.getElementById('buildName').setAttribute("placeholder", "请选择报修地点");
  134. // // }
  135. //
  136. // //返回 false 可以阻止选择框的关闭
  137. // //return false;
  138. // });
  139. // }, false);
  140. //报修地点 楼
  141. var blildPicker = new $.PopPicker({
  142. layer: 2
  143. });
  144. blildPicker.setData(Adress);
  145. var ShowBuildPickerButton = doc.getElementById('showBuildPicker');
  146. var BuildResult = doc.getElementById('buildName');
  147. ShowBuildPickerButton.addEventListener('tap', function(event) {
  148. if(Adress.length > 0) {
  149. blildPicker.show(function(items) {
  150. BuildResult.value = (items[0].text ? items[0].text : "") + " " + (items[1].floorName ? items[1].floorName : "");
  151. doc.getElementById('buildCode').value = items[0].value ? items[0].value : "";
  152. doc.getElementById('floorCode').value = items[1].value ? items[1].value : "";
  153. // doc.getElementById('departmentCode').value = "";
  154. doc.getElementById('departmentVal').value =items[1].depname ? items[1].depname : "";
  155. //返回 false 可以阻止选择框的关闭
  156. //return false;
  157. // GetDepartment(); //科室
  158. });
  159. }
  160. }, false);
  161. //科室下拉
  162. // departPicker = new $.PopPicker();
  163. // var showDepartPickerButton_ = doc.getElementById('department');
  164. // var departResult = doc.getElementById('departmentVal');
  165. // showDepartPickerButton_.addEventListener('tap', function(event) {
  166. // if(departMent.length > 0) {
  167. // departPicker.show(function(items) {
  168. // departResult.value = items[0].text;
  169. // doc.getElementById('departmentCode').value = items[0].value ? items[0].value : "";
  170. // //返回 false 可以阻止选择框的关闭
  171. // //return false;
  172. // });
  173. // }
  174. //
  175. // }, false);
  176. })
  177. })(mui, document);
  178. //获取地址详情
  179. function adressDetail(){
  180. $.ajax({
  181. type:"get",
  182. url:huayi.config.callcenter_url +"distributionapi/api/DistriAddress/getsingle",
  183. async:true,
  184. dataType:'json',
  185. data:{
  186. id:ids
  187. },
  188. success:function(result){
  189. if(result.state.toLowerCase()=='success'){
  190. $('#buildCode').val(result.data.buildingid), //楼
  191. $('#buildName').val(result.data.buildingname+" "+result.data.floorname), //楼 文本
  192. $('#floorCode').val(result.data.floorid); //楼层
  193. $('#departmentVal').val(result.data.departmentname); //科室文本
  194. // $('#departmentCode').val(result.data.departmentid); //科室id
  195. $("#contactName").val(result.data.fullname);
  196. $('#contactPhone').val(result.data.mobile);
  197. }
  198. }
  199. });
  200. }
  201. //保存地址
  202. function addSaveAdress(type){
  203. var ajaxUrl;
  204. if(ids){
  205. ajaxUrl="distributionapi/api/DistriAddress/update"
  206. }else{
  207. ajaxUrl="distributionapi/api/DistriAddress/add"
  208. }
  209. $.ajax({
  210. type:"post",
  211. url: huayi.config.callcenter_url + ajaxUrl,
  212. async:true,
  213. dataType:'json',
  214. beforeSend: function() { //触发ajax请求开始时执行
  215. mui('#HY_add').button('loading');
  216. // loadIndex = layer.load();
  217. },
  218. data:{
  219. id:ids,
  220. addresstype:type,//0发货/1收货
  221. projectid:projectid,//是 string 项目名称id
  222. buildingid: $('#buildCode').val(), //是 string 楼宇名称id
  223. floorid:$('#floorCode').val(), //是 string 层数id
  224. // departmentid:$('#departmentCode').val(),//否 string 科室id
  225. fullname:$('#contactName').val(), //否 string 姓名
  226. mobile:$('#contactPhone').val() //否 string 电话
  227. },
  228. success:function(result){
  229. if(result.state.toLowerCase()=='success'){
  230. mui.alert('地址保存成功!');
  231. mui('#HY_add').button('reset');
  232. // $('#proNameText').val(''); //项目文本
  233. // $('#proNameCode').val(''); //项目id
  234. $('#buildCode').val(''), //楼
  235. $('#buildName').val(''), //楼 文本
  236. $('#floorCode').val(''); //楼层
  237. $('#departmentVal').val(''); //科室文本
  238. // $('#departmentCode').val(''); //科室id
  239. $("#contactName").val('');
  240. $('#contactPhone').val('');
  241. window.location.href ='./GoodsDelivery.html?id='+ids+'&goods='+goods
  242. }
  243. }
  244. });
  245. }
  246. // 用扫码获取楼层id 获取地址详情
  247. function getQRfloor(){
  248. $.ajax({
  249. type: "get",
  250. url: huayi.config.callcenter_url + 'equipmentapi/api/Equipment/gettreeinfo',
  251. async: true,
  252. data: {
  253. floorid: floorid
  254. },
  255. dataType: 'json',
  256. success: function (data) {
  257. if (data.state.toLowerCase() == "success") {
  258. $('#buildCode').val(data.data.bulidid), //楼
  259. $('#buildName').val(data.data.bulidname+" "+data.data.floorname), //楼 文本
  260. $('#floorCode').val(data.data.floorid); //楼层
  261. $('#departmentVal').val(data.data.remark); //科室文本
  262. }
  263. }
  264. });
  265. }