carmapbak.cshtml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. 
  2. @{
  3. ViewBag.Title = "岗位管理";
  4. Layout = "~/Views/Shared/_Lymap.cshtml";
  5. }
  6. @using MES.Production.Service;
  7. @using Central.Control.Domain;
  8. @using Ant.Service.Common;
  9. @using Ant.Service.Common.Enums;
  10. @using MES.Production.Entity;
  11. @using CommonToolHelper;
  12. @model UserCarMapModel
  13. <!-- 重点参数:infoTitle, infoBody -->
  14. <!doctype html>
  15. <html lang="zh-CN">
  16. <head>
  17. <!-- 原始地址://webapi.amap.com/ui/1.0/ui/overlay/SimpleInfoWindow/examples/index.html -->
  18. <base href="http://webapi.amap.com/ui/1.0/ui/overlay/SimpleInfoWindow/examples/" />
  19. <meta charset="utf-8">
  20. <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
  21. <link href="http://@HttpContext.Current.Request.Url.Host:@Request.Url.Port/Content/uploadone/CSS/webuploader.css" rel="stylesheet" />
  22. <link href="http://@HttpContext.Current.Request.Url.Host:@Request.Url.Port/Content/uploadone/CSS/bootstrap.min.css" rel="stylesheet" />
  23. <link href="http://@HttpContext.Current.Request.Url.Host:@Request.Url.Port/Content/uploadone/CSS/uploadstyle.css" rel="stylesheet" />
  24. <link href="http://@HttpContext.Current.Request.Url.Host:@Request.Url.Port/Content/uploadone/CSS/font-awesome.css" rel="stylesheet" />
  25. <script src="http://@HttpContext.Current.Request.Url.Host:@Request.Url.Port/Content/js/jquery/jquery-1.8.2.min.js"></script>
  26. <script src="http://@HttpContext.Current.Request.Url.Host:@Request.Url.Port/Content/uploadone/Script/webuploader.js"></script>
  27. <title>地图</title>
  28. <style>
  29. html,
  30. body,
  31. #container {
  32. width: 100%;
  33. height: 500px;
  34. margin: 0px;
  35. }
  36. p.my-desc {
  37. margin: 5px 0;
  38. line-height: 150%;
  39. }
  40. body {
  41. background-color: white;
  42. }
  43. #div1 {
  44. width: 100px;
  45. height: 30px;
  46. border-radius: 50px;
  47. position: relative;
  48. }
  49. #div2 {
  50. width: 30px;
  51. height: 28px;
  52. border-radius: 30px;
  53. position: absolute;
  54. background: white;
  55. box-shadow: 0px 2px 4px rgba(0,0,0,0.4);
  56. }
  57. .open1 {
  58. background: rgba(0,184,0,0.8);
  59. }
  60. .open2 {
  61. top: 2px;
  62. right: 1px;
  63. }
  64. .close1 {
  65. background: red;
  66. border: 3px solid rgba(136, 11, 11, 0);
  67. border-left: transparent;
  68. }
  69. .close2 {
  70. left: 0px;
  71. top: 0px;
  72. border: 2px solid rgba(0,0,0,0.1);
  73. }
  74. .changeicon {
  75. float: right;
  76. margin-right: -15px;
  77. position: absolute;
  78. right: -7px;
  79. top: 0px;
  80. border: none;
  81. background-color: #18a689;
  82. color: #FFFFFF;
  83. line-height: 33px;
  84. height: 33px;
  85. }
  86. </style>
  87. </head>
  88. <body>
  89. <div id="container"></div>
  90. @Html.Hidden("hidfilename", "")
  91. @Html.Hidden("hidfileid", "")
  92. <div class="row white-bg animated fadeInRight">
  93. <div class="wrapper-content">
  94. <div class="panel-body">
  95. <div class="tab-content">
  96. <div id="tab-1" class="tab-pane active">
  97. <div class="clearfix f-hafl">
  98. <div class="col-hafl">
  99. <div class="form-group">
  100. <label class="col-lg-3 control-label">农机名称:</label>
  101. <div class="col-lg-8" style="width:45% !important">
  102. <label style="margin-top:7px;">@Model.carName</label>
  103. </div>
  104. </div>
  105. </div>
  106. <div class="col-hafl">
  107. <div class="form-group">
  108. <label class="col-lg-3 control-label" style="width:29% !important; padding-left:5px; padding-right:5px;">农机状态:</label>
  109. <div class="col-lg-8">
  110. <label style="margin-top:7px;">@Model.carNote</label>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. <div class="clearfix f-hafl">
  116. <div class="col-hafl">
  117. <div class="form-group">
  118. <label class="col-lg-3 control-label">农机IMEI号:</label>
  119. <div class="col-lg-8" style="width:45% !important">
  120. <label style="margin-top:7px;">@Model.carId</label>
  121. </div>
  122. </div>
  123. </div>
  124. <div class="col-hafl">
  125. <div class="form-group">
  126. <label class="col-lg-3 control-label" style="width:29% !important; padding-left:5px; padding-right:5px;">车架号:</label>
  127. <div class="col-lg-8">
  128. <label style="margin-top:7px;">@Model.barCode</label>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. <div class="clearfix f-hafl">
  134. <div class="col-hafl">
  135. <div class="form-group">
  136. <label class="col-lg-3 control-label">是否在线:</label>
  137. <div class="col-lg-8" style="width:45% !important">
  138. <label style="margin-top:7px;">@(Model.isOnLine == 0 ? "不在线" : "在线")</label>
  139. </div>
  140. </div>
  141. </div>
  142. <div class="col-hafl">
  143. <div class="form-group">
  144. <label class="col-lg-3 control-label" style="width:29% !important; padding-left:5px; padding-right:5px;">所属经销商:</label>
  145. <div class="col-lg-8">
  146. <label style="margin-top:7px;">@Model.distributorsName</label>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. @{
  152. if (Model.carType.ToInt32() != 4)
  153. {
  154. <div class="clearfix f-hafl">
  155. <div class="col-hafl">
  156. <div class="form-group">
  157. <label class="col-lg-3 control-label">农机油压:</label>
  158. <div class="col-lg-8" style="width:45% !important">
  159. <label style="margin-top:7px;">@Model.hydraulic KPa</label>
  160. </div>
  161. </div>
  162. </div>
  163. <div class="col-hafl">
  164. <div class="form-group">
  165. <label class="col-lg-3 control-label" style="width:29% !important; padding-left:5px; padding-right:5px;">农机水温:</label>
  166. <div class="col-lg-8">
  167. <label style="margin-top:7px;">@Model.temperature ℃</label>
  168. </div>
  169. </div>
  170. </div>
  171. </div>
  172. <div class="clearfix f-hafl">
  173. <div class="col-hafl">
  174. <div class="form-group">
  175. <label class="col-lg-3 control-label">农机转速:</label>
  176. <div class="col-lg-8" style="width:45% !important">
  177. <label style="margin-top:7px;">@Model.speed 转</label>
  178. </div>
  179. </div>
  180. </div>
  181. <div class="col-hafl">
  182. <div class="form-group">
  183. <label class="col-lg-3 control-label" style="width:29% !important; padding-left:5px; padding-right:5px;">蓄电池电压:</label>
  184. <div class="col-lg-8">
  185. <label style="margin-top:7px;">@(Model.voltage.ToDou()) V</label>
  186. </div>
  187. </div>
  188. </div>
  189. </div>
  190. }
  191. }
  192. <div class="form-group">
  193. <label class="col-lg-3 control-label">申请人:</label>
  194. <div class="col-lg-8">
  195. @Html.TextBoxFor(p => p.applyName, new { @class = "form-control", @placeholder = "请输入申请人", @datatype = "n15-20", @nullmsg = "请输入申请人", @errormsg = "农机条码必须是15-20位的数字!" })
  196. </div>
  197. </div>
  198. <div class="clearfix f-hafl">
  199. <div class="col-lg-3 col-sm-3 pl0">
  200. <div class="form-group">
  201. </div>
  202. </div>
  203. </div>
  204. <div class="form-group">
  205. <label class="col-lg-3 control-label">申请原因:</label>
  206. <div class="col-lg-8">
  207. @Html.TextAreaFor(p => p.applyReason, new { @class = "form-control", @placeholder = "请输入申请原因", @datatype = "n15-20", @nullmsg = "请输入申请原因", @errormsg = "农机条码必须是15-20位的数字!" })
  208. </div>
  209. </div>
  210. <div class="clearfix f-hafl">
  211. <div class="col-lg-3 col-sm-3 pl0">
  212. <div class="form-group">
  213. </div>
  214. </div>
  215. </div>
  216. <div class="form-group">
  217. <label class="col-lg-3 control-label">申请附件图片:</label>
  218. <div class="col-lg-8">
  219. <div id="fileNameList">
  220. </div>
  221. <div class="cp_img_jia" id="fileNamePicker"></div>
  222. </div>
  223. </div>
  224. <div class="clearfix f-hafl">
  225. <div class="col-lg-3 col-sm-3 pl0">
  226. <div class="form-group">
  227. </div>
  228. </div>
  229. </div>
  230. <div class="form-group">
  231. <label class="col-lg-3 control-label">密码:</label>
  232. <div class="col-lg-8">
  233. @Html.PasswordFor(p => p.applyPwd, new { @class = "form-control", @placeholder = "请输入密码", @datatype = "n15-20", @nullmsg = "请输入密码", @errormsg = "必须是15-20位的数字!" })
  234. </div>
  235. </div>
  236. <div class="clearfix f-hafl">
  237. <div class="col-lg-3 col-sm-3 pl0">
  238. <div class="form-group">
  239. </div>
  240. </div>
  241. </div>
  242. @{
  243. if (Model.carState != MES.Production.Entity.Enum.CarState.Sales.GetHashCode())
  244. {
  245. <div class="clearfix f-hafl">
  246. <div class="col-hafl">
  247. <div class="form-group">
  248. <label class="col-lg-3 control-label">锁车解锁:</label>
  249. <div class="col-lg-8">
  250. <label class="radio-inline">
  251. <div id="div1" class="open1">
  252. <div id="div2" class="open2" onclick="SendLockCarCmd()"></div>
  253. </div>
  254. </label>
  255. @*<label class="radio-inline">
  256. <input type="radio" name="sexcode" id="a1" onchange="SendLockCarCmd()" @(Model.LockState == true ? "checked" : "") value="1">锁车
  257. </label>
  258. <label class="radio-inline">
  259. <input type="radio" name="sexcode" id="a2" onchange="SendUnLockCarCmd()" @(Model.LockState == false ? "checked" : "") value="2">解锁
  260. </label>*@
  261. </div>
  262. </div>
  263. </div>
  264. </div>
  265. }
  266. }
  267. </div>
  268. </div>
  269. </div>
  270. </div>
  271. </div>
  272. <script type="text/javascript" src='http://webapi.amap.com/maps?v=1.4.2&key=fa36ec6323075f37020083ceffe8eb24'></script>
  273. <!-- UI组件库 1.0 -->
  274. <script src="http://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
  275. <script type="text/javascript">
  276. //创建地图
  277. //window.onload = function () {
  278. // var div2 = document.getElementById("div2");
  279. // var div1 = document.getElementById("div1");
  280. // div2.onclick = function () {
  281. // div1.className = (div1.className == "close1") ? "open1" : "close1";
  282. // div2.className = (div2.className == "close2") ? "open2" : "close2";
  283. // }
  284. //}
  285. var applicationPath = "http://" + window.location.host;
  286. $(function () {
  287. var filename = document.getElementById("hidfilename").value;
  288. if (filename != null && filename != "") {
  289. //alert(filename);
  290. var headstr = "<div id=\"WU_FILE_0\" class=\"cpup_img upload-state-done\"><img src=\"";
  291. var footstr = "\"><div class=\"upcp_img_jian\"></div><p class=\"progress hide\"><span style=\"width: 100%;\"></span></p></div>";
  292. document.getElementById("fileNameList").innerHTML = headstr + filename + footstr;
  293. }
  294. var $ = jQuery, fileId,
  295. $list = $('#fileNameList'),
  296. // 优化retina, 在retina下这个值是2
  297. ratio = window.devicePixelRatio || 1,
  298. // 缩略图大小
  299. thumbnailWidth = 90 * ratio,
  300. thumbnailHeight = 90 * ratio,
  301. // Web Uploader实例
  302. uploader;
  303. uploader = WebUploader.create({
  304. // 选完文件后,是否自动上传。
  305. auto: true,
  306. disableGlobalDnd: true,
  307. // swf文件路径
  308. swf: applicationPath + '/Script/Uploader.swf',
  309. // 文件接收服务端。
  310. //server: applicationPath + '/Home/UpLoadProcess',
  311. server: applicationPath + '/Sys/Home/UpLoadProcess',
  312. // 选择文件的按钮。可选。
  313. // 内部根据当前运行是创建,可能是input元素,也可能是flash.
  314. pick: '#fileNamePicker',
  315. //只允许选择图片
  316. accept: {
  317. title: 'Images',
  318. extensions: 'gif,jpg,jpeg,bmp,png',
  319. mimeTypes: 'image/*'
  320. }
  321. });
  322. // 当有文件添加进来的时候
  323. uploader.on('fileQueued', function (file) {
  324. var $li = $(
  325. '<div id="' + file.id + '" class="cpup_img">' +
  326. '<img id="jjgimg">' +
  327. '<div class="upcp_img_jian"></div></div>'
  328. ),
  329. $img = $li.find('img');
  330. $list.children().remove();//先清空元素内容
  331. if (fileId != file.id && fileId != null) {
  332. //alert(fileId);
  333. uploader.removeFile(uploader.getFile(fileId, true));
  334. }
  335. fileId = file.id;
  336. // $list为容器jQuery实例
  337. $list.append($li);
  338. // 创建缩略图
  339. // 如果为非图片文件,可以不用调用此方法。
  340. // thumbnailWidth x thumbnailHeight 为 100 x 100
  341. uploader.makeThumb(file, function (error, src) {
  342. if (error) {
  343. $img.replaceWith('<span>不能预览</span>');
  344. return;
  345. }
  346. //alert(src);
  347. //alert(file);
  348. $img.attr('src', src);
  349. }, thumbnailWidth, thumbnailHeight);
  350. });
  351. //上传压缩宽度
  352. uploader.option('compress', {
  353. width: 700
  354. });
  355. // 文件上传过程中创建进度条实时显示。
  356. uploader.on('uploadProgress', function (file, percentage) {
  357. var $li = $('#' + file.id),
  358. $percent = $li.find('.progress span');
  359. // 避免重复创建
  360. if (!$percent.length) {
  361. $percent = $('<p class="progress"><span></span></p>')
  362. .appendTo($li)
  363. .find('span');
  364. }
  365. $percent.css('width', percentage * 100 + '%');
  366. });
  367. // 文件上传成功,给item添加成功class, 用样式标记上传成功。
  368. uploader.on('uploadSuccess', function (file, response) {
  369. //alert(file.name);//原来文件名
  370. //alert(response.id);//文件路径
  371. var imgurl = response.filePath; //上传图片的路径
  372. var fileid = response.fileid; //上传图片的路径
  373. console.log(response.id);
  374. console.log(imgurl);
  375. $('#' + file.id).addClass('upload-state-done');
  376. //alert(document.getElementById("fileNameList").innerHTML.replace('class="progress"', 'class="progress hide"'));
  377. $("#hidfilename").val(imgurl);
  378. $("#jjgimg").attr('src', imgurl);//季健国加为了解决保存一串字符串
  379. $("#hidfileid").val(fileid);
  380. });
  381. // 文件上传失败,显示上传出错。
  382. uploader.on('uploadError', function (file) {
  383. var $li = $('#' + file.id),
  384. $error = $li.find('div.error');
  385. // 避免重复创建
  386. if (!$error.length) {
  387. $error = $('<div class="error"></div>').appendTo($li);
  388. }
  389. $error.text('上传失败');
  390. });
  391. // 完成上传完了,成功或者失败,先删除进度条。
  392. uploader.on('uploadComplete', function (file) {
  393. $('#' + file.id).find('.progress').remove();
  394. });
  395. //所有文件上传完毕
  396. uploader.on("uploadFinished", function () {
  397. //提交表单
  398. });
  399. //开始上传
  400. $("#ctlUpBtn").click(function () {
  401. uploader.upload();
  402. });
  403. //显示删除按钮
  404. $(".cpup_img").on("mouseover", function () {
  405. $(this).children(".upcp_img_jian").css('display', 'block');
  406. });
  407. //隐藏删除按钮
  408. $(".cpup_img").on("mouseout", function () {
  409. $(this).children(".upcp_img_jian").css('display', 'none');
  410. });
  411. //执行删除方法
  412. $list.on("click", ".upcp_img_jian", function () {
  413. var Id = $(this).parent().attr("id");
  414. try {
  415. uploader.removeFile(uploader.getFile(Id, true));
  416. }
  417. catch (ex) { }
  418. $(this).parent().remove();
  419. });
  420. $('.form-horizontal').initValidform();
  421. $('.select2').select2();
  422. //分配部门
  423. var div2 = document.getElementById("div2");
  424. var div1 = document.getElementById("div1");
  425. var lock = "@Model.LockState.ToString()";
  426. if (lock=="True") {
  427. div1.className = "close1";
  428. div2.className = "close2";
  429. }
  430. else {
  431. div1.className = "open1";
  432. div2.className = "open2";
  433. }
  434. });
  435. function SendLockCarCmd() {
  436. var urlstr = "http://" + window.location.host + "/";
  437. var apply1 = $('#applyName').val();
  438. var apply2 = $('#applyReason').val();
  439. var apply3 = $('#applyPwd').val();
  440. if (apply1 == "") {
  441. dig.msg("申请人不能为空!");
  442. $('#applyName').focus();
  443. return;
  444. }
  445. if (apply2 == "") {
  446. dig.msg("申请原因不能为空!");
  447. $('#applyReason').focus();
  448. return;
  449. }
  450. if (apply3 == "") {
  451. dig.msg("申请密码不能为空!");
  452. $('#applyPwd').focus();
  453. return;
  454. }
  455. var div2 = document.getElementById("div2");
  456. var div1 = document.getElementById("div1");
  457. if (div1.className == "close1") {
  458. div1.className = "open1";
  459. }
  460. else {
  461. div1.className = "close1";
  462. }
  463. if (div2.className == "close2") {
  464. div2.className = "open2";
  465. }
  466. else {
  467. div2.className = "close2";
  468. }
  469. if (div1.className == "close1") {
  470. $.ajax({
  471. url: urlstr + 'Sys/Car/SendLockCarCmd?carid=' +@Model.carId+'&applyName=' + apply1 + '&applyReason=' + apply2 + '&applyPwd=' + apply3,
  472. data: null,
  473. type: 'get',
  474. dataType: 'json',
  475. async: false,
  476. cache: false,
  477. success: function (res) {
  478. if (res.Status == 'y') {
  479. dig.msg("锁车发送成功!");
  480. //alert("锁车发送成功!");
  481. }
  482. else {
  483. dig.msg(res.Msg);
  484. }
  485. }
  486. });
  487. } else {
  488. $.ajax({
  489. url: urlstr + 'Sys/Car/SendUnlockCarCmd?carid=' +@Model.carId+'&applyName=' + apply1 + '&applyReason=' + apply2 + '&applyPwd=' + apply3,
  490. data: null,
  491. type: 'get',
  492. dataType: 'json',
  493. async: false,
  494. cache: false,
  495. success: function (res) {
  496. if (res.Status == 'y') {
  497. //alert("解锁发送成功!");
  498. dig.msg("解锁发送成功!");
  499. }
  500. else {
  501. dig.msg(res.Msg);
  502. }
  503. }
  504. });
  505. }
  506. }
  507. //解锁
  508. function SendUnLockCarCmd() {
  509. var item = $(":radio:checked");
  510. var urlstr = "http://" + window.location.host + "/";
  511. var apply1 = $('#applyName').val();
  512. var apply2 = $('#applyReason').val();
  513. var apply3 = $('#applyPwd').val();
  514. if (apply1 == "") {
  515. dig.msg("申请人不能为空!");
  516. $('#applyName').focus();
  517. return;
  518. }
  519. if (apply2 == "") {
  520. dig.msg("申请原因不能为空!");
  521. $('#applyReason').focus();
  522. return;
  523. }
  524. if (apply3 == "") {
  525. dig.msg("申请密码不能为空!");
  526. $('#applyPwd').focus();
  527. return;
  528. }
  529. //alert(urlstr);
  530. var len = item.length;
  531. if (len > 0) {
  532. if ($(":radio:checked").val() == 2)
  533. {
  534. $.ajax({
  535. url: urlstr + 'Sys/Car/SendUnlockCarCmd?carid=' +@Model.carId+'&applyName=' + apply1 + '&applyReason=' + apply2 + '&applyPwd=' + apply3,
  536. data: null,
  537. type: 'get',
  538. dataType: 'json',
  539. async: false,
  540. cache: false,
  541. success: function (res) {
  542. if (res.Status == 'y') {
  543. alert("解锁发送成功!");
  544. }
  545. }
  546. });
  547. }
  548. else
  549. {
  550. }
  551. }
  552. }
  553. var map = new AMap.Map('container', {
  554. resizeEnable: true,
  555. zoom: 16,
  556. center: [@Model.lng, @Model.lat]
  557. });
  558. //加载缩放条事件
  559. map.plugin(["AMap.ToolBar"], function () {
  560. toolBar = new AMap.ToolBar();
  561. map.addControl(toolBar);
  562. });
  563. AMapUI.loadUI(['overlay/SimpleInfoWindow'], function (SimpleInfoWindow) {
  564. var marker = new AMap.Marker({
  565. map: map,
  566. zIndex: 99999,
  567. offset: new AMap.Pixel(-14, -34),//相对于基点的位置
  568. icon: new AMap.Icon({ //复杂图标
  569. size: new AMap.Size(34, 49),//图标大小
  570. image: "@Model.imageUrl", //大图地址
  571. })
  572. });
  573. var infoWindow = new SimpleInfoWindow({
  574. infoTitle: '<strong>@Model.carName</strong>',
  575. infoBody: '<p class="my-desc"><strong>@Model.Note<br/>@Model.onlineDate<br/>@Model.workHours<br/>@Model.address</strong></p>',
  576. //基点指向marker的头部位置
  577. offset: new AMap.Pixel(0, -31)
  578. });
  579. function openInfoWin() {
  580. infoWindow.open(map, marker.getPosition());
  581. }
  582. //marker 点击时打开
  583. AMap.event.addListener(marker, 'click', function () {
  584. openInfoWin();
  585. });
  586. });
  587. </script>
  588. </body>
  589. </html>