123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840 |
- <!DOCTYPE html>
- <html lang="zh-cn">
- <head>
- <meta charset="UTF-8">
- <meta name="format-detection" content="email=no" />
- <meta name="format-detection" content="telephone=no" />
- <title>新建任务</title>
- <link rel="stylesheet" href="../css/reset.css">
- <link rel="stylesheet" href="../css/style.css">
- <script src="../script/flexible.js"></script>
- <style>
- html,body{
- height: 100%;
- }
- .flex-wrap{
- display: -webkit-box;
- display: -webkit-flex;
- display: flex;
- }
- .flex-con{
- -webkit-box-flex: 1;
- -webkit-flex: 1;
- flex: 1;
- }
- body{
- display: -webkit-box;
- display: -webkit-flex;
- display: flex;
- -webkit-box-orient: vertical;
- -webkit-flex-flow: column;
- flex-flow: column;
- background-color: #fff;
- }
- #header {
- min-height: 1.4rem;
- line-height: 1.4rem;
- background-color: #fff;
- color: #0b0b0b;
- position: relative;
- /*box-sizing: content-box;*/
- }
- #backBtn {
- width: 1.2rem;
- height: 1.4rem;
- line-height: 1rem;
- text-align: center;
- font-size: 1.3rem;
- position: absolute;
- left: 0;
- bottom: 0;
- }
- #backBtn img{
- display: inline-block;
- width: 50%;
- height: 40%;
- }
- .headTit {
- text-align: center;
- line-height: 1.4rem;
- font-size: .5rem;
- font-weight: normal;
- }
- .headGN {
- position: absolute;
- right: 0;
- bottom: 0;
- }
- .headGN li {
- display: none;
- width: 2.3rem;
- line-height: 1.4rem;
- font-size: .42rem;
- text-align: right;
- padding-right: .2rem;
- }
- .headGN li.active {
- display: block;
- }
- ::-webkit-input-placeholder{
- color: #b4b4b4;
- }
- main{
- overflow-x: hidden;
- overflow-y: auto;
- }
- .hr{
- width: 100%;
- height: .23rem;
- background-color: #fafafa;
- }
- .taskXQ{
- padding: .3rem;
- }
- .taskXQ>div{
- margin-bottom: .3rem;
- }
- .taskXQ>div h3{
- font-size: .42rem;
- color: #818181;
- font-weight: normal;
- margin-bottom: .1rem;
- }
- .task_taskCon p {
- margin-bottom: .2rem;
- color: #818181;
- font-size: .42rem;
- }
- .selectDiv>label,.selectTaskDiv>label{
- width: 100%;
- position: relative;
- }
- .selectDiv input,.selectTaskDiv input{
- display: inline-block;
- width: 100%;
- font-size: .42rem;
- padding: .2rem;
- color: #818181;
- background-color: #fafafa;
- border: 1px solid #f0f0f0;
- }
- .xcms,.time1,.time2,.shyy{
- background-color: #fafafa;
- border: 1px solid #f0f0f0;
- padding: .2rem;
- }
- .type_icon{
- color: #818181;
- font-size: .42rem;
- position: absolute;
- right: 0.18rem;
- top: 0;
- }
- .task_text{
- width: 100%;
- height: 2.6rem;
- max-height: 2.6em;
- font-size: .42rem;
- color: #818181;
- background-color: #fafafa;
- resize: none;
- border: none;
- overflow-y: auto;
- }
- .shren,.xzren,.jxren,.xcren{
- background-color: #fafafa;
- border: 1px solid #f0f0f0;
- padding: .2rem;
- }
- .task_text1{
- width: 100%;
- font-size: .42rem;
- color: #818181;
- background-color: #fafafa;
- resize: none;
- border: none;
- overflow-x: auto;
- }
- .task_text2{
- width: 100%;
- height: .66rem;
- line-height: .66rem;
- max-height: .66rem;
- font-size: .42rem;
- color: #818181;
- background-color: #fafafa;
- resize: none;
- border: none;
- overflow-x: auto;
- }
- .task_time{
- width: 60%;
- font-size: .42rem;
- color: #818181;
- background-color: #fafafa;
- border: none;
- outline: none;
- overflow-x: auto;
- }
- .year,.times{
- width: 0;
- overflow: hidden;
- opacity: 0;
- margin: 0;
- padding: 0;
- }
- input[type=button]{
- background-color: #6dcff6;
- color: #fff;
- font-size: .3rem;
- padding: .1rem;
- border: none;
- border-radius: .06rem;
- outline: none;
- }
- .startBtn{
- width: 100%;
- height: 1.3rem;
- line-height: 1.3rem;
- font-size: .5rem;
- text-align: center;
- color: #fff;
- background-color: #22ad38;
- border-radius: .1rem;
- margin-top: .3rem;
- }
- .newBDG{
- background-color: #f0f0f0;
- padding: .1rem;
- }
- .hid{
- display: none;
- }
- .hidden{
- display: none;
- }
- </style>
- </head>
- <body>
- <header>
- <div id="header">
- <i id="backBtn"><img src="../image/backBtn.png" alt=""></i>
- <h3 class="headTit">发起任务</h3>
- <ul class="headGN">
- <!--<li>批量发起</li>-->
- </ul>
- </div>
- </header>
- <main class="flex-con">
- <div class="hr"></div>
- <div class="taskXQ">
- <div class="task_taskCon flex-con">
- <p class="oldBDG">电站名称:<span class="task_name"></span></p>
- </div>
- <div class="selectTaskDiv">
- <label><input type="text" value="检查任务" id="taskType" readonly="readonly"><span class="type_icon">▼</span></label>
- </div>
- <div class="xcms jxname">
- <h3>检修名称:</h3>
- <textarea id="name" class="task_text2"></textarea>
- </div>
- <div class="shyy hid">
- <h3>重审原因:</h3>
- <textarea id="shyy" class="task_text2"></textarea>
- </div>
- <div class="selectDiv">
- <label><input type="text" value="常规" id="type" readonly="readonly"><span class="type_icon">▼</span></label>
- </div>
- <div class="shren hid" rel="main">
- <h3>审核人:</h3>
- <input id="shren" class="task_text1" readonly="readonly">
- </div>
- <div class="jxren hid" rel="main">
- <h3>检修人:</h3>
- <input id="jxren" class="task_text1" readonly="readonly">
- </div>
- <div class="xcren hid hidden" rel="main">
- <h3>巡查人:</h3>
- <input id="xcren" class="task_text1" readonly="readonly">
- </div>
- <div class="xzren" rel="main">
- <h3>协助人:</h3>
- <input id="xzren" class="task_text1" readonly="readonly">
- </div>
- <div class="time1">
- <h3>计划开始时间:</h3>
- <input id="jhks" class="task_time" readonly="readonly">
- <input class=" year" id="jhks_date" type="date"><input class="times" id="jhks_time" type="time"><input
- type="button" value="选择日期" id="selDate1"> <input type="button" value="选择时间"id="selTime1">
- </div>
- <div class="time2">
- <h3>计划结束时间:</h3>
- <input id="jhjs" class="task_time" readonly="readonly">
- <input class=" year" id="jhjs_date" type="date"><input class="times" id="jhjs_time" type="time"><input
- type="button" value="选择日期" id="selDate2"> <input type="button" value="选择时间" id="selTime2">
- </div>
- <div class="xcms jxcontent">
- <h3>检修内容:</h3>
- <textarea id="text"class="task_text"></textarea>
- </div>
- <div>
- <div class="startBtn">发起检修</div>
- </div>
- </div>
- </main>
- <script src="../script/jqueryMin.js"></script>
- <script src="../script/createTime.js"></script>
- <script src="../script/publicData.js"></script>
- <script src="../script/api.js"></script>
- <script>
- apiready=function () {
- var isSend=false,listArr=$api.getStorage("allBDG"),allB=[],shren=[],xzren=[],jxren=[],userList=$api.getStorage("userList"),headmanList=$api.getStorage("headmanList");
- var md="",startTime=0,endTime=0,tasktype=2,startTxt1="请选择日期",endTxt1="请选择日期",startTxt2="请选择时间",endTxt2="请选择时间";
- var tasks=$api.getStorage("CTasks");
- var tasksTit=$api.getStorage("tasksTit");
- var user=$api.getStorage("user");
- if(listArr.length) $(".headGN li").addClass("active");
- var UIMultiSelector = api.require('UIMultiSelector');
- $(".task_name").text(api.pageParam.name);
- var arr=["常规","紧急"],arr2=["检修任务","巡查任务"];
- if(tasks&&tasks!=""){
- for(var i in tasks){
- $(".task_taskCon").append("<P class='newBDG' rel='"+tasks[i]+"'>"+tasksTit[i]+"</p>");
- allB.push(tasks[i])
- }
- }
- if(api.pageParam.taskID){
- $(".shyy").removeClass("hid");
- }
- if(user.user_module_id=="326"){
- $(".shren").removeClass("hid");
- jxren.push(user.id)
- }else {
- $(".jxren").removeClass("hid");
- $(".xcren").removeClass("hid");
- // shren.push(user.id)
- }
- $(".selectDiv label").click(function () {
- api.actionSheet({
- title: '选择任务状态',
- buttons: arr
- }, function (ret, err) {
- if(ret.buttonIndex>arr.length) return;
- $("#type").val(arr[ret.buttonIndex-1])
- });
- })
- $(".selectTaskDiv label").click(function () {
- api.actionSheet({
- title: '选择任务类型',
- buttons: arr2
- }, function (ret, err) {
- if(ret.buttonIndex>arr2.length) return;
- $("#taskType").val(arr2[ret.buttonIndex-1])
- if(ret.buttonIndex==1){
- $(".xcren").addClass("hidden");
- $(".jxren").removeClass("hidden");
- $(".jxname h3").text("检修名称:");
- $(".jxcontent h3").text("检修内容:");
- $(".startBtn").text("发起检修");
- tasktype=2
- }else if(ret.buttonIndex==2){
- $(".jxren").addClass("hidden");
- $(".xcren").removeClass("hidden");
- $(".jxname h3").text("巡查名称:");
- $(".jxcontent h3").text("巡查内容:");
- $(".startBtn").text("发起巡查");
- tasktype=1
- }
- });
- })
- $("#selDate1").click(function () {
- $("#jhks_date")[0].click();
- })
- $("#selDate2").click(function () {
- $("#jhjs_date")[0].click();
- })
- $("#selTime1").click(function () {
- $("#jhks_time")[0].click();
- })
- $("#selTime2").click(function () {
- $("#jhjs_time")[0].click();
- })
- $("#jhks_date").change(function () {
- startTxt1=$(this).val();
- setval($(this),startTxt1+" "+startTxt2)
- })
- $("#jhjs_date").change(function () {
- endTxt1=$(this).val();
- setval($(this),endTxt1+" "+endTxt2)
- })
- $("#jhks_time").change(function () {
- startTxt2=$(this).val();
- setval($(this),startTxt1+" "+startTxt2)
- })
- $("#jhjs_time").change(function () {
- endTxt2=$(this).val();
- setval($(this),endTxt1+" "+endTxt2)
- })
- function setval(that,val) {
- that.parent().find(".task_time").val(val)
- }
- $(".headGN").click(function () {
- allB=[];
- showBox($(".task_taskCon"),listArr,false);
- })
- $(".shren").click(function () {
- showBox($(this),headmanList,true);
- })
- $(".xzren").click(function () {
- showBox($(this),userList,false);
- })
- $(".jxren").click(function () {
- showBox($(this),userList,true);
- })
- $(".xcren").click(function () {
- showBox($(this),userList,true);
- })
- $(".startBtn").click(function () {
- if(isSend){
- return;
- }
- if($("#name").val()==""){
- api.toast({
- msg: '检修名称不能为空',
- duration: 2000,
- location: 'bottom'
- });
- return;
- }
- if($("#text").val()==""){
- api.toast({
- msg: '检修内容不能为空',
- duration: 2000,
- location: 'bottom'
- });
- return;
- }
- if(isNaN(new Date(startTxt1+" "+startTxt2).getTime())){
- api.toast({
- msg: '时间不正确',
- duration: 2000,
- location: 'bottom'
- });
- return;
- }
- if(isNaN(new Date(endTxt1+" "+endTxt2).getTime())){
- api.toast({
- msg: '时间不正确',
- duration: 2000,
- location: 'bottom'
- });
- return;
- }
- if(new Date(startTxt1+" "+startTxt2).getTime()<new Date().getTime()){
- api.toast({
- msg: '开始时间无效',
- duration: 2000,
- location: 'bottom'
- });
- return;
- }
- if(new Date(endTxt1+" "+endTxt2).getTime()<new Date(startTxt1+" "+startTxt2).getTime()){
- api.toast({
- msg: '结束时间无效',
- duration: 2000,
- location: 'bottom'
- });
- return;
- }
- if(allB.length&& !api.pageParam.taskID){
- var postData={
- type:tasktype,
- user_id:$api.getStorage("user").id,
- bdg_id:allB,
- title:$("#name").val(),
- helper_id:xzren,
- aduit_id:shren,
- jxuser_id:jxren[0],
- created_at:startTxt1+" "+startTxt2,
- end_time:endTxt1+" "+endTxt2,
- remark:$("#text").val(),
- task_type:arr.indexOf($("#type").val())
- }
- isSend=true;
- $(".startBtn").text("正在提交中...");
- api.ajax({
- url: pageUrl+"/index/task/moretask",
- method: 'post',
- timeout: 30,
- dataType: 'text',
- returnAll: false,
- data: {
- values: postData
- }
- }, function (data, err) {
- var data=JSON.parse(data);
- // alert(JSON.stringify(data))
- if(data.status=="1"){
- $("#text").val("");
- $("#jhks").val("");
- $("#jhjs").val("");
- startTxt1=endTxt1="请选择日期";
- startTxt2=endTxt2="请选择时间";
- api.toast({
- msg: "发起检修成功",
- duration: 2000,
- location: 'bottom'
- });
- api.execScript({
- name: 'root',
- frameName:"home",
- script: 'setData();'
- });
- api.sendEvent({
- name: 'refeshCheck',
- extra: {key1: 'value'}
- });
- setTimeout(function () {
- api.closeToWin({
- name: 'root'
- });
- },300)
- }else {
- api.toast({
- msg: "发起检修失败",
- duration: 2000,
- location: 'bottom'
- });
- }
- setTimeout(function () {
- $(".startBtn").text("发起检修");
- },300)
- isSend=false;
- api.execScript({
- name: 'root',
- script: 'totalTime(0);'
- });
- });
- }else if(!allB.length&& !api.pageParam.taskID){
- var postData={
- type:tasktype,
- user_id:$api.getStorage("user").id,
- bdg_id:api.pageParam.id,
- title:$("#name").val(),
- helper_id:xzren,
- aduit_id:shren,
- jxuser_id:jxren[0],
- created_at:startTxt1+" "+startTxt2,
- end_time:endTxt1+" "+endTxt2,
- remark:$("#text").val(),
- task_type:arr.indexOf($("#type").val())
- }
- isSend=true;
- $(".startBtn").text("正在提交中...");
- api.ajax({
- url: pageUrl+"/index/task/taskdata",
- method: 'post',
- timeout: 30,
- dataType: 'text',
- returnAll: false,
- data: {
- values: postData
- }
- }, function (data, err) {
- var data=JSON.parse(data)
- // alert(JSON.stringify(data))
- if(data.status=="1"){
- $("#text").val(" ");
- $(".task_time").val("");
- startTxt1=endTxt1="请选择日期";
- startTxt2=endTxt2="请选择时间";
- api.toast({
- msg: "发起检修成功",
- duration: 2000,
- location: 'bottom'
- });
- api.execScript({
- name: 'root',
- frameName:"home",
- script: 'setData();'
- });
- api.sendEvent({
- name: 'refeshCheck',
- extra: {key1: 'value'}
- });
- setTimeout(function () {
- api.closeToWin({
- name: 'root'
- });
- },300)
- }else {
- api.toast({
- msg: "发起检修失败",
- duration: 2000,
- location: 'bottom'
- });
- }
- setTimeout(function () {
- $(".startBtn").text("发起检修");
- },300)
- isSend=false;
- api.execScript({
- name: 'root',
- script: 'totalTime(0);'
- });
- });
- }else if(!allB.length&&api.pageParam.taskID){
- var postData={
- type:tasktype,
- user_id:$api.getStorage("user").id,
- bdg_id:api.pageParam.id,
- task_id:api.pageParam.taskID,
- title:$("#name").val(),
- remark_reason:$("#shyy").val(),
- helper_id:xzren,
- aduit_id:shren,
- jxuser_id:jxren[0],
- created_at:startTxt1+" "+startTxt2,
- end_time:endTxt1+" "+endTxt2,
- remark:$("#text").val(),
- task_type:arr.indexOf($("#type").val())
- }
- isSend=true;
- $(".startBtn").text("正在提交中...");
- api.ajax({
- url: pageUrl+"/index/task/change-taskdata",
- method: 'get',
- timeout: 30,
- dataType: 'text',
- returnAll: false,
- data: {
- values: postData
- }
- }, function (data, err) {
- var data=JSON.parse(data)
- if(data.status=="1"){
- $("#text").val(" ");
- $(".task_time").val("");
- startTxt1=endTxt1="请选择日期";
- startTxt2=endTxt2="请选择时间";
- api.toast({
- msg: "发起检修成功",
- duration: 2000,
- location: 'bottom'
- });
- api.execScript({
- name: 'root',
- frameName:'checkTask',
- script: 'getData()'
- });
- setTimeout(function () {
- api.execScript({
- name: 'root',
- script: 'toFrame(13)'
- });
- },300)
- api.sendEvent({
- name: 'refeshCheckXQ',
- extra: {key1: 'value'}
- });
- setTimeout(function () {
- api.closeToWin({
- name: 'root'
- });
- },300)
- }else {
- api.toast({
- msg: "发起检修失败",
- duration: 2000,
- location: 'bottom'
- });
- }
- setTimeout(function () {
- $(".startBtn").text("发起检修");
- },300)
- isSend=false;
- api.execScript({
- name: 'root',
- script: 'totalTime(0);'
- });
- });
- }
- })
- $("#backBtn").click(function () {
- $api.rmStorage("CTasks");
- $api.rmStorage("tasksTit");
- api.closeWin();
- })
- $(".task_taskCon").on('click','.newBDG',function () {
- if($(".task_taskCon p").length==2){
- api.toast({
- msg: '无法再删除了',
- duration: 2000,
- location: 'bottom'
- });
- return;
- }
- var arr=[];
- for(var i=0;i<allB.length;i++){
- if($(this).attr("rel")!=allB[i]){
- arr.push(allB[i])
- }
- }
- allB=arr;
- $(this).remove();
- })
- function showBox(that,data,bl) {
- if(data.length==0) {
- api.toast({
- msg: '服务器开小差了,请稍等',
- duration: 2000,
- location: 'bottom'
- });
- return;
- }
- var user=$api.getStorage("user");
- UIMultiSelector.open({
- rect: {
- h: 244
- },
- text: {
- title: '',
- leftBtn: '',
- rightBtn: '',
- selectAll: '全选'
- },
- max: 0,
- singleSelection:bl,
- styles: {
- mask: 'rgba(0,0,0,0.2)',
- title: {
- bg: '#efefef',
- h: 44
- },
- leftButton: {
- w: 60,
- h: 30,
- marginT: 5,
- marginL: 8,
- bg:"widget://image/cancel.png"
- },
- rightButton: {
- w: 60,
- h: 30,
- marginT: 5,
- marginR: 8,
- bg:"widget://image/finish.png"
- },
- item: {
- h: 40,
- bg: '#fff',
- bgActive: '#fff',
- bgHighlight: '#fff',
- color: '#818181',
- active: '#818181',
- highlight: '#818181',
- size: 14,
- lineColor: '#efefef',
- textAlign: 'left',
- marginR:5
- },
- icon: {
- w: 20,
- h: 20,
- marginT: 11,
- marginH: 8,
- bg: 'widget://image/select.png',
- bgActive: 'widget://image/selected.png',
- align: 'left'
- }
- },
- animation: true,
- items: data
- }, function(ret, err) {
- if (ret) {
- if(ret.eventType=="clickRight"){
- var nameStr="",arr=[],arr2=[];
- if(ret.items.length!=0&&that.hasClass("task_taskCon")) {
- that.html(" ");
- }else {
- if(allB.length==0&&that.hasClass("task_taskCon")){
- that.html('<p class="oldBDG">电站名称:<span class="task_name">'+api.pageParam.name+'</span></p>');
- }
- }
- try{
- for(var i in ret.items){
- arr[i]={
- type:ret.items[i].id,
- name:ret.items[i].text
- }
- arr2.push(ret.items[i].id);
- if(i==ret.items.length-1||ret.items.length==1){
- nameStr+=ret.items[i].text;
- }else {
- nameStr+=ret.items[i].text+"、";
- }
- if(that.hasClass("task_taskCon")){
- that.append("<P class='newBDG' rel='"+ret.items[i].id+"'>电站名称:"+ret.items[i].text+"</p>");
- allB=arr2;
- }else if(that.hasClass("shren")){
- shren=arr2;
- that.find("input").val(nameStr);
- }else if(that.hasClass("xzren")){
- if(arr2.indexOf(jxren[0])!=-1){
- api.toast({
- msg: '不能重复选择',
- duration: 2000,
- location: 'bottom'
- });
- return;
- }
- xzren=arr2;
- that.find("input").val(nameStr);
- }else if(that.hasClass("jxren")){
- if(xzren.indexOf(arr2[0])!=-1){
- api.toast({
- msg: '不能重复选择',
- duration: 2000,
- location: 'bottom'
- });
- return;
- }
- jxren=arr2;
- that.find("input").val(nameStr);
- }else if(that.hasClass("xcren")){
- if(xzren.indexOf(arr2[0])!=-1){
- api.toast({
- msg: '不能重复选择',
- duration: 2000,
- location: 'bottom'
- });
- return;
- }
- jxren=arr2;
- that.find("input").val(nameStr);
- }
- }
- }catch (e){
- nameStr="";
- }
- UIMultiSelector.close();
- }else if(ret.eventType=="clickLeft"){
- UIMultiSelector.close();
- }
- } else {
- // alert(JSON.stringify(err));
- }
- });
- }
- }
- </script>
- </body>
- </html>
|