createTask.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <!DOCTYPE html>
  2. <html lang="zh-cn">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
  6. <meta name="format-detection" content="email=no" />
  7. <meta name="format-detection" content="telephone=no" />
  8. <title>新建任务</title>
  9. <link rel="stylesheet" href="../css/reset.css">
  10. <link rel="stylesheet" href="../css/style.css">
  11. <style>
  12. html{font-size:10px}
  13. html,body{
  14. height: 100%;
  15. overflow: hidden;
  16. }
  17. .flex-wrap{
  18. display: -webkit-box;
  19. display: -webkit-flex;
  20. display: flex;
  21. }
  22. .flex-con{
  23. -webkit-box-flex: 1;
  24. -webkit-flex: 1;
  25. flex: 1;
  26. }
  27. body{
  28. display: -webkit-box;
  29. display: -webkit-flex;
  30. display: flex;
  31. -webkit-box-orient: vertical;
  32. -webkit-flex-flow: column;
  33. flex-flow: column;
  34. background-color: #fff;
  35. }
  36. #header {
  37. min-height: 4.4rem;
  38. line-height: 4.4rem;
  39. background-color: #51c4d4;
  40. color: #fff;
  41. position: relative;
  42. /*box-sizing: content-box;*/
  43. }
  44. #backBtn {
  45. width: 3.6rem;
  46. height: 4.1rem;
  47. line-height: 3rem;
  48. text-align: center;
  49. font-size: 3.9rem;
  50. position: absolute;
  51. left: 0;
  52. bottom: 0;
  53. }
  54. #backBtn img{
  55. display: inline-block;
  56. width: 50%;
  57. height: 40%;
  58. }
  59. .headTit {
  60. text-align: center;
  61. line-height: 4.4rem;
  62. font-size: 1.7rem;
  63. font-weight: normal;
  64. }
  65. .headGN {
  66. position: absolute;
  67. right: 0;
  68. bottom: 0;
  69. }
  70. .headGN li {
  71. display: none;
  72. width: 3.5rem;
  73. line-height: 4.2rem;
  74. font-size: 1.4rem;
  75. }
  76. .headGN li.active {
  77. display: block;
  78. }
  79. .inputDiv,.text{
  80. color: #212121;
  81. padding-left:1.1rem;
  82. position: relative;
  83. background-color: #fff;
  84. }
  85. .inputDiv{
  86. padding-top: .3rem;
  87. border-bottom: .3rem solid #f7f7f7;
  88. }
  89. .inputDiv label,.text label{
  90. display: block;
  91. height: 3.8rem;
  92. line-height: 3.8rem;
  93. font-size: 1.4rem;
  94. white-space: nowrap;
  95. border-bottom: 1px solid #dfdfdf;
  96. margin-bottom: .3rem;
  97. padding-left: 1rem;
  98. display: -webkit-box;
  99. display: -webkit-flex;
  100. display: flex;
  101. }
  102. .inputDiv label:last-of-type{
  103. border-bottom: none;
  104. }
  105. label>input{
  106. width: 90%;
  107. height: 100%;
  108. background-color: rgba(0,0,0,0);
  109. border: none;
  110. outline: none;
  111. font-size: 1.3rem;
  112. padding-left: 2.6rem;
  113. -webkit-box-flex: 1;
  114. -webkit-flex: 1;
  115. flex: 1;
  116. }
  117. label:nth-of-type(2)>input{
  118. padding-left: 3.9rem;
  119. }
  120. label:nth-of-type(4)>input{
  121. padding-left: 3.9rem;
  122. }
  123. label:nth-of-type(5)>input{
  124. padding-left: 2.6rem;
  125. }
  126. label:nth-of-type(9)>input{
  127. padding-left: 2.6rem;
  128. }
  129. .text label:last-of-type>input{
  130. padding-left: 3.6rem;
  131. }
  132. .jt{
  133. color: #b5b5b5;
  134. padding: 0 1rem;
  135. }
  136. ::-webkit-input-placeholder{
  137. color: #b4b4b4;
  138. }
  139. </style>
  140. </head>
  141. <body>
  142. <header>
  143. <div id="header">
  144. <i id="backBtn"><img src="../image/backBtn.png" alt=""></i>
  145. <h3 class="headTit">新建任务</h3>
  146. <ul class="headGN">
  147. <li class="active" id="save">保存</li>
  148. </ul>
  149. </div>
  150. </header>
  151. <main class="flex-con">
  152. <div class="inputDiv">
  153. <form action="#">
  154. <label>任务名称<input type="text" id="name" placeholder="请输入任务名称"></label>
  155. <label id="xj">分管县领导<input type="text" id="fxz" disabled="disabled"><span class="jt">〉</span></label>
  156. <label id="zrdw">执行单位<input type="text" id="dw" disabled="disabled"><span class="jt">〉</span></label>
  157. <label id="zrr">执行人<input type="text" id="ren" disabled="disabled"><span class="jt">〉</span></label>
  158. <label id="hyfl">行业分类<input type="text" id="fl" disabled="disabled"><span class="jt">〉</span></label>
  159. <label id="kssj">计划开始时间<input type="text" disabled="disabled"><span class="jt">〉</span></label>
  160. <label id="jssj">计划结束时间<input type="text" disabled="disabled"><span class="jt">〉</span></label>
  161. </form>
  162. </div>
  163. <div class="text">
  164. <label id="work_nr">工作内容</label>
  165. <label id="work_yq">工作要求<input type="text" id="yq" disabled="disabled"><span class="jt">〉</span></label>
  166. <label id="work_bz">备注<input type="text" id="bz" disabled="disabled"><span class="jt">〉</span></label>
  167. </div>
  168. </main>
  169. <script src="../script/jquery-3.1.0.min.js"></script>
  170. <script src="../script/createTime.js"></script>
  171. <script src="../script/publicData.js"></script>
  172. <script src="../script/api.js"></script>
  173. <script>
  174. apiready=function () {
  175. var timedata={
  176. start:"",
  177. end:""
  178. }
  179. var userdata=[];
  180. var department=[];
  181. var fxzdata=[];
  182. var fldata=[];
  183. var flArr=[];
  184. var duty=[];
  185. var depArr=[];
  186. var depUserArr=[];
  187. var UIActionSelector = api.require('UIActionSelector');
  188. var UIMultiSelector = api.require('UIMultiSelector');
  189. $.get(pageUrl+"danwei",function (data) {
  190. var data=data.data;
  191. for(var i in data['fuxianzhang']){
  192. duty[i]={
  193. id:data['fuxianzhang'][i]['user_id'],
  194. text: data['fuxianzhang'][i]['user_name'],
  195. status: 'normal'
  196. }
  197. }
  198. for(var n in data['department']){
  199. depArr[n]={
  200. id:data['department'][n]['department_id'],
  201. text: data['department'][n]['department_name'],
  202. status: 'normal'
  203. }
  204. }
  205. for(var n in data['tradeclass']){
  206. flArr[n]={
  207. id:data['tradeclass'][n]['tradeclass_id'],
  208. text: data['tradeclass'][n]['tradeclass_name'],
  209. status: 'normal'
  210. }
  211. }
  212. $("#hyfl").click(function () {
  213. showBox($(this),flArr,true);
  214. })
  215. $("#xj").click(function () {
  216. showBox($(this),duty,true);
  217. })
  218. })
  219. $(".text").on('click','label',function () {
  220. api.openWin({
  221. name: 'textWin',
  222. url: './textWin.html',
  223. bgColor:'rgba(0,0,0,0.2)',
  224. animation: {
  225. type: 'movein',
  226. subType: 'from_bottom',
  227. duration: 500
  228. },
  229. pageParam:{
  230. this:$(this)[0].id
  231. },
  232. delay:300
  233. });
  234. })
  235. $("#save").click(function () {
  236. var conData={};
  237. conData.user_department_id=[];
  238. conData.user_name=[];
  239. conData.task_title=$("#name").val();
  240. conData.fxz_id=fxzdata[0];
  241. conData.user_id=userdata;
  242. conData.tradeclass_id=fldata;
  243. conData.user_department_id=department;
  244. conData.task_start_time=timedata.start;
  245. conData.task_end_time=timedata.end;
  246. conData.task_content=$api.getStorage("work_nr");
  247. conData.task_list_content=$api.getStorage("work_yq");
  248. conData.task_beizhu=$api.getStorage("work_bz");
  249. $.post(pageUrl+"newTask",conData,function (data) {
  250. if(data.status=="200"){
  251. api.toast({
  252. msg: '新建成功',
  253. duration: 2000,
  254. location: 'bottom'
  255. });
  256. var reload = 'toFrame(1);';
  257. api.execScript({
  258. name: 'root',
  259. script: reload
  260. });
  261. $("input").val("");
  262. $api.rmStorage("work_nr");
  263. $api.rmStorage("work_yq");
  264. $api.rmStorage("work_bz");
  265. }else {
  266. api.toast({
  267. msg: data.message,
  268. duration: 2000,
  269. location: 'bottom'
  270. });
  271. }
  272. })
  273. })
  274. $("#kssj,#jssj").click(function () {
  275. showTime($(this));
  276. })
  277. $("#backBtn").click(function () {
  278. $api.rmStorage("work_nr");
  279. $api.rmStorage("work_yq");
  280. $api.rmStorage("work_bz");
  281. api.closeToWin({
  282. name: 'root',
  283. animation: {
  284. type: 'push',
  285. subType: 'from_left',
  286. duration: 300
  287. },
  288. delay:300
  289. });
  290. })
  291. function showBox(that,data,bl) {
  292. if(data.length==0) {
  293. api.toast({
  294. msg: '服务器开小差了,请稍等',
  295. duration: 2000,
  296. location: 'bottom'
  297. });
  298. return;
  299. }
  300. var user=$api.getStorage("user");
  301. UIMultiSelector.open({
  302. rect: {
  303. h: api.winHeight
  304. },
  305. text: {
  306. title: '',
  307. leftBtn: '',
  308. rightBtn: '',
  309. selectAll: '全选'
  310. },
  311. max: 0,
  312. singleSelection:bl,
  313. styles: {
  314. mask: 'rgba(0,0,0,0.2)',
  315. title: {
  316. bg: '#efefef',
  317. h: 44
  318. },
  319. leftButton: {
  320. w: 60,
  321. h: 30,
  322. marginT: 5,
  323. marginL: 8,
  324. bg:"widget://image/cancel.png"
  325. },
  326. rightButton: {
  327. w: 60,
  328. h: 30,
  329. marginT: 5,
  330. marginR: 8,
  331. bg:"widget://image/finish.png"
  332. },
  333. item: {
  334. h: 40,
  335. bg: '#fff',
  336. bgActive: '#fff',
  337. bgHighlight: '#fff',
  338. color: '#818181',
  339. active: '#818181',
  340. highlight: '#818181',
  341. size: 14,
  342. lineColor: '#efefef',
  343. textAlign: 'left',
  344. marginR:5
  345. },
  346. icon: {
  347. w: 20,
  348. h: 20,
  349. marginT: 11,
  350. marginH: 8,
  351. bg: 'widget://image/select.png',
  352. bgActive: 'widget://image/selected.png',
  353. align: 'left'
  354. }
  355. },
  356. animation: true,
  357. items: data
  358. }, function(ret, err) {
  359. if (ret) {
  360. if(ret.eventType=="clickRight"){
  361. var nameStr="",arr=[],arr2=[];
  362. try{
  363. for(var i in ret.items){
  364. arr[i]={
  365. type:ret.items[i].id,
  366. name:ret.items[i].text
  367. }
  368. arr2.push(ret.items[i].id)
  369. if(i==ret.items.length-1||ret.items.length==1){
  370. nameStr+=ret.items[i].text;
  371. }else {
  372. nameStr+=ret.items[i].text+"、";
  373. }
  374. }
  375. }catch (e){
  376. nameStr="";
  377. }
  378. if(that.find("input")[0].id=="dw"){
  379. department= arr2;
  380. $.post(pageUrl+"danwei",{department_id:arr2},function (data) {
  381. var data=data.data;
  382. depUserArr=[];
  383. for(var i in data){
  384. depUserArr[i]={
  385. id:data[i]['user_id'],
  386. text: data[i]['user_name']+"("+data[i]['department_name']+")",
  387. status: 'normal'
  388. }
  389. }
  390. $("#zrr").click(function () {
  391. showBox($(this),depUserArr,false);
  392. })
  393. })
  394. }else if(that.find("input")[0].id=="ren"){
  395. userdata=arr2;
  396. }else if(that.find("input")[0].id=="fxz"){
  397. fxzdata=arr2;
  398. $("#zrdw").click(function () {
  399. showBox($(this),depArr,false);
  400. })
  401. }else if(that.find("input")[0].id=="fl"){
  402. fldata=arr2;
  403. }
  404. that.find("input").val(nameStr);
  405. UIMultiSelector.close();
  406. }else if(ret.eventType=="clickLeft"){
  407. UIMultiSelector.close();
  408. }
  409. } else {
  410. alert(JSON.stringify(err));
  411. }
  412. });
  413. }
  414. function showTime(that) {
  415. UIActionSelector.open({
  416. datas: timeJson,
  417. layout: {
  418. row: 5,
  419. col: 3,
  420. height: 30,
  421. size: 12,
  422. sizeActive: 14,
  423. rowSpacing: 5,
  424. colSpacing: 10,
  425. maskBg: 'rgba(0,0,0,0.2)',
  426. bg: '#fff',
  427. color: '#e0e0e0',
  428. colorActive: '#838383',
  429. colorSelected: '#838383'
  430. },
  431. animation: true,
  432. cancel: {
  433. text:"",
  434. w: 60,
  435. h: 30,
  436. bg: 'widget://image/cancel.png',
  437. bgActive: 'widget://image/cancel.png'
  438. },
  439. ok: {
  440. text:"",
  441. w: 60,
  442. h: 30,
  443. bg: 'widget://image/finish.png',
  444. bgActive: 'widget://image/finish.png'
  445. },
  446. title: {
  447. text:"",
  448. h: 44,
  449. bg: '#efefef'
  450. }
  451. }, function(ret, err) {
  452. if (ret) {
  453. if(ret.eventType=="ok"){
  454. var val=ret.level1+"年"+ret.level2+"月"+ret.level3+"日";
  455. var time=ret.level1+"/"+ret.level2+"/"+ret.level3;
  456. that.find("input").val(val);
  457. if(that[0].id=="kssj"){
  458. timedata.start=new Date(time).getTime()/1000;
  459. }else {
  460. timedata.end=new Date(time).getTime()/1000;
  461. }
  462. }
  463. } else {
  464. api.toast({
  465. msg: '选择失败',
  466. duration: 2000,
  467. location: 'bottom'
  468. });
  469. }
  470. });
  471. }
  472. }
  473. function getVal(val,that) {
  474. if($("#"+that)[0].id=="work_nr"){
  475. $api.setStorage("work_nr",val)
  476. }else if($("#"+that)[0].id=="work_yq"){
  477. $("#"+that).find('input').val(val);
  478. $api.setStorage("work_yq",val)
  479. }else if($("#"+that)[0].id=="work_bz"){
  480. $('#'+that).find('input').val(val);
  481. $api.setStorage("work_bz",val)
  482. }
  483. }
  484. </script>
  485. </body>
  486. </html>