123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769 |
- <!DOCTYPE html>
- <html lang="zh-cn">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
- <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">
- <style>
- html{font-size:10px}
- html,body{
- height: 100%;
- overflow: auto;
- }
- .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;
- }
- .headGN li {
- display: none;
- width: 3.5rem;
- line-height: 4.1rem;
- }
- .headGN li.active {
- display: block;
- }
- main{
- background-color: #f7f7f7;
- }
- .inputDiv{
- padding: 1.1rem 1.6rem;
- position: relative;
- background-color: #fff;
- display: none;
- }
- .inputDiv label{
- display: block;
- height: 3.8rem;
- line-height: 3.8rem;
- font-size: 1.5rem;
- white-space: nowrap;
- border-bottom: 1px solid #dfdfdf;
- margin-bottom: .3rem;
- padding-left: 1rem;
- }
- .inputDiv label:last-of-type{
- border-bottom: none;
- }
- label>input{
- height: 100%;
- background-color: rgba(0,0,0,0);
- border: none;
- outline: none;
- font-size: 1.3rem;
- padding-left: 3.7rem;
- -webkit-box-flex: 1;
- -webkit-flex: 1;
- flex: 1;
- }
- .SC{
- width: 2.4rem;
- height: 2.4rem;
- background: url("../image/big_add.png") no-repeat 100%/100%;
- -webkit-transform: translateY(.7rem);
- transform: translateY(.7rem);
- }
- .TP_status,.FJ_status{
- color: #f21;
- font-size: 1.3rem;
- margin-left: 2rem;
- }
- .banner li{
- float: left;
- margin-bottom: .3rem;
- }
- .fileDiv p{
- font-size: 1.4rem;
- background-color: #f8f8f8;
- border-radius: .3rem;
- padding: .6rem;
- margin-bottom: .2rem;
- }
- #content{
- width: 100%;
- height: 12rem;
- font-size: 1.3rem;
- padding: .6rem;
- border: 1px solid #dfdfdf;
- resize: none;
- border-radius: .3rem;
- overflow-y: auto;
- }
- .reBtn{
- width: 100%;
- height: 3.5rem;
- line-height: 3.5rem;
- text-align: center;
- font-size: 1.5rem;
- color: #fff;
- background-color: #51c4d4;
- border-radius: 2rem;
- margin: 1.5rem 0;
- }
- ::-webkit-input-placeholder{
- color: #b4b4b4;
- }
- </style>
- </head>
- <body>
- <main class="flex-con">
- <div class="inputDiv">
- <form action="#">
- <label class="title">内容</label>
- <pre id="content" contenteditable="true"></pre>
- </form>
- <div class="reBtn">完成批示</div>
- </div>
- </main>
- <script src="../script/jquery-3.1.0.min.js"></script>
- <script src="../script/publicData.js"></script>
- <script src="../script/api.js"></script>
- <script>
- apiready=function () {
- $(".inputDiv").css("display","block");
- var imgData=[],fileUrl=[],imgUpload=[],fileUpload=[],nowImgArr=[],nowFileArr=[],delArr=[],num=0,FKId=0,isXG=false;
- var dialogBox = api.require('dialogBox');
- var UIMediaScanner = api.require('UIMediaScanner');
- var winWidth= api.winWidth/3-10;
- var taskid=$api.getStorage("taskXQ").taskID;
- if(true){
- isXG=false;
- $(".reBtn").click(function () {
- var data={
- task_dynamic_content:$("#content").html(),
- photolujing:imgUpload,
- attachmentlujing:fileUpload,
- task_id:taskid,
- task_dynamic_ispishi:1
- }
- // if(imgData.length!=0||fileUrl.length!=0){
- // api.toast({
- // msg: '还有文件未上传',
- // duration: 2000,
- // location: 'bottom'
- // });
- // return;
- // }
- if(!data.task_dynamic_content&&data.photolujing.length==0&&data.attachmentlujing.length==0){
- api.toast({
- msg: '未添加任何批示信息',
- duration: 2000,
- location: 'bottom'
- });
- }else {
- if(num) return;
- num++;
- $(".reBtn").text("正在提交...");
- $.post(pageUrl+"shangchuan",data,function (data) {
- if(data.status=="200"){
- $(".reBtn").text("提交成功");
- api.toast({
- msg: '提交成功,正在返回',
- duration: 2000,
- location: 'bottom'
- });
- var upload = 'toFrame(5);';
- setTimeout(function () {
- api.execScript({
- name: 'root',
- script: upload
- });
- api.closeFrame({
- name: 'instructions'
- });
- },2000)
- $("#content").html("");
- $(".banner").html("");
- $(".fileDiv").html("");
- imgData=imgUpload=fileUpload=delArr=[];
- fileUrl="";
- }else {
- api.toast({
- msg: data.message,
- duration: 2000,
- location: 'bottom'
- });
- }
- })
- }
- })
- }
- $(".banner").on("click",'li',function () {
- var that=$(this)
- popups("确认删除该图片吗?",function (ret) {
- if (ret.eventType == 'right') {
- var newimg=[];
- if(isXG){
- for(var i=0;i<nowImgArr.length;i++){
- if(that.index()==i){
- delArr.push(nowImgArr[i])
- }
- }
- }else {
- for(var i=0;i<imgUpload.length;i++){
- if(that.index()==i) continue;
- newimg.push(imgUpload[i])
- }
- imgUpload=newimg;
- }
- that.remove();
- dialogBox.close({
- dialogName: 'alert'
- });
- }else if (ret.eventType == 'left') {
- dialogBox.close({
- dialogName: 'alert'
- });
- }
- })
- // popups("确认删除该图片吗?",function (ret) {
- // if (ret.eventType == 'right') {
- // var newimg=[];
- // if(isXG){
- // for(var i=0;i<nowImgArr.length;i++){
- // if(that.index()==i){
- // delArr.push(nowImgArr[i])
- // }
- // }
- // }else {
- // for(var i=0;i<imgData.length;i++){
- // if(that.index()==i) continue;
- // newimg.push(imgData[i])
- // }
- // imgData=newimg;
- // }
- // if(!imgData.length){
- // $(".TP_status").text(" ")
- // }
- // that.remove();
- // dialogBox.close({
- // dialogName: 'alert'
- // });
- // }else if (ret.eventType == 'left') {
- // dialogBox.close({
- // dialogName: 'alert'
- // });
- // }
- // })
- })
- $(".fileDiv").on("click","p",function () {
- var that=$(this)
- popups("确认删除该文件吗?",function (ret) {
- if (ret.eventType == 'right') {
- var newfile=[];
- if(isXG){
- for(var i=0;i<nowFileArr.length;i++){
- if(that.index()==i){
- delArr.push(nowFileArr[i])
- }
- }
- }else {
- for(var i=0;i<fileUpload.length;i++){
- if(that.index()==i) continue;
- newfile.push(fileUpload[i])
- }
- fileUpload=newfile;
- }
- that.remove();
- dialogBox.close({
- dialogName: 'alert'
- });
- }else if (ret.eventType == 'left') {
- dialogBox.close({
- dialogName: 'alert'
- });
- }
- })
- // popups("确认删除该文件吗?",function (ret) {
- // if (ret.eventType == 'right') {
- // var newfile=[];
- // if(isXG){
- // for(var i=0;i<nowFileArr.length;i++){
- // if(that.index()==i){
- // delArr.push(nowFileArr[i])
- // }
- // }
- // }else {
- // for(var i=0;i<fileUrl.length;i++){
- // if(that.index()==i) continue;
- // newfile.push(fileUrl[i])
- // }
- // fileUrl=newfile;
- // }
- // if(!fileUrl.length){
- // $(".FJ_status").text(" ")
- // }
- // that.remove();
- // dialogBox.close({
- // dialogName: 'alert'
- // });
- // }else if (ret.eventType == 'left') {
- // dialogBox.close({
- // dialogName: 'alert'
- // });
- // }
- // })
- })
- $("#TP").click(function () {
- api.actionSheet({
- title: '上传图片',
- cancelTitle: '取消',
- buttons: ['相册', '相机']
- }, function(ret, err) {
- var index = ret.buttonIndex;
- if(index==1){
- UIMediaScanner.open({
- type: 'picture',
- column: 4,
- max: 4,
- sort: {
- key: 'time',
- order: 'desc'
- },
- texts: {
- stateText: '已选择*项',
- cancelText: '取消',
- finishText: '完成'
- },
- styles: {
- bg: '#fff',
- mark: {
- icon: '',
- position: 'bottom_left',
- size: 20
- },
- nav: {
- bg: '#eee',
- stateColor: '#000',
- stateSize: 18,
- cancelBg: 'rgba(0,0,0,0)',
- cancelColor: '#000',
- cancelSize: 18,
- finishBg: 'rgba(0,0,0,0)',
- finishColor: '#000',
- finishSize: 18
- }
- },
- exchange: true
- }, function(ret) {
- if (ret.eventType=="confirm") {
- for(var i in ret.list){
- if(api.systemType=="ios"){
- UIMediaScanner.transPath({
- path: ret.list[i]["path"]
- }, function(ret, err) {
- if (ret) {
- // $(".banner ul").append("<li style='width:32%;height:"+winWidth+"px;margin-right: 1%'><img src='file://"+ret.path+"' style='width:100%;height:100%' /></li>");
- imgData.push("file://"+ret.path);
- uploadImg("file://"+ret.path)
- } else {
- alert(JSON.stringify(err));
- }
- });
- }else {
- // $(".banner ul").append("<li style='width:32%;height:"+winWidth+"px;margin-right: 1%'><img src='file://"+ret.list[i]["path"]+"' style='width:100%;height:100%' /></li>");
- imgData.push("file://"+ret.list[i]["path"]);
- uploadImg("file://"+ret.list[i]["path"])
- }
- }
- // $(".TP_status").text("点击上传全部图片")
- }
- });
- }else if(index==2){
- api.getPicture({
- sourceType: 'camera',
- encodingType: 'jpg',
- mediaValue: 'pic',
- saveToPhotoAlbum:'true',
- destinationType: 'url',
- quality: 50
- }, function(ret, err) {
- if (ret) {
- if(!ret.data) return;
- imgData.push("file://"+ret.data);
- // $(".TP_status").text("点击上传全部图片");
- // $(".banner ul").append("<li style='width:32%;height:"+winWidth+"px;margin-right: 1%'><img src='"+imgData[imgData.length-1]+"' style='width:100%;height:100%' /></li>");
- uploadImg("file://"+ret.data)
- } else {
- alert(JSON.stringify(err));
- }
- });
- }else {}
- });
- })
- function uploadImg(url) {
- var imageFilter = api.require('imageFilter');
- var imageName = "rwdcimg";
- var imageCachePath = api.cacheDir;
- var newimg="";
- imageFilter.compress({
- img: url,
- quality:0.8,
- size:{
- w:550,
- h:480
- },
- save: {
- album: false,
- imgPath: imageCachePath,
- imgName: imageName + '.jpg'
- }
- }, function(ret, err) {
- var tx = imageCachePath + '/' + imageName + '.jpg';
- $(".TP_status").text("正在上传中...");
- api.ajax({
- url: pageUrl+"upload",
- method: 'post',
- timeout: 30,
- dataType: 'json',
- returnAll: false,
- data: {
- files:{
- "file[]":tx
- },
- values:{
- task_id:taskid,
- type:"1"
- }
- }
- }, function (ret, err) {
- if(ret.status=="200"){
- if(ret.message.indexOf(false)!=-1){
- for(var i=0;i<ret.message.length;i++){
- if(ret.message[i]!=false){
- imgUpload.push(ret.message[i]);
- }else {
- api.toast({
- msg: "上传失败,请重试",
- duration: 2000,
- location: 'bottom'
- });
- }
- }
- }else {
- for(var msgI in ret['message']){
- imgUpload.push(ret['message'][msgI])
- }
- $(".banner ul").append("<li style='width:32%;height:"+winWidth+"px;margin-right: 1%'><img src='"+url+"' style='width:100%;height:100%' /></li>");
- imgData=[];
- }
- }else {
- api.toast({
- msg: "上传失败,请重试",
- duration: 2000,
- location: 'bottom'
- });
- }
- $(".TP_status").text("");
- });
- })
- }
- function uploadFile(url,name) {
- $(".FJ_status").text("正在上传中...");
- api.ajax({
- url: pageUrl+"upload",
- method: 'post',
- timeout: 30,
- dataType: 'json',
- returnAll: false,
- data: {
- "files":{
- "file[]":url
- },
- "values":{
- task_id:taskid,
- type:"2"
- }
- }
- }, function (ret, err) {
- if(ret.status=="200"){
- if(ret.message.indexOf(false)!=-1){
- for(var i=0;i<ret.message.length;i++){
- if(ret.message[i]!=false){
- fileUpload.push(ret.message[i]);
- }else {
- api.toast({
- msg: "上传失败,请重试",
- duration: 2000,
- location: 'bottom'
- });
- }
- }
- }else {
- for(var msgI in ret['message']){
- fileUpload.push(ret['message'][msgI])
- }
- $(".fileDiv ul").append("<li><p>"+name+"</p></li>");
- fileUrl=[];
- }
- }else {
- api.toast({
- msg: "上传失败,请重试",
- duration: 2000,
- location: 'bottom'
- });
- }
- $(".FJ_status").text("");
- });
- }
- $(".TP_status").click(function () {
- if($(this).text()!="点击上传全部图片") return;
- popups("确认上传吗?",function (ret) {
- if (ret.eventType == 'right') {
- var Data={
- file:imgData,
- type:"1",
- task_id:taskid
- }
- $(".TP_status").text("正在上传中...");
- api.ajax({
- url: pageUrl+"upload",
- method: 'post',
- timeout: 30,
- dataType: 'json',
- returnAll: false,
- data: {
- files:{
- "file[]":imgData
- },
- values:{
- task_id:taskid,
- type:"1"
- }
- }
- }, function (ret, err) {
- var newImg=[];
- if(ret.status=="200"){
- if(ret.message.indexOf(false)!=-1){
- for(var i=0;i<ret.message.length;i++){
- if(ret.message[i]!=false){
- imgUpload.push(ret.message[i]);
- $(".banner li:eq("+i+")").remove();
- }else {
- newImg.push(imgData[i]);
- }
- }
- $(".TP_status").text("以下图片上传失败");
- imgData=newImg;
- }else {
- for(var msgI in ret['message']){
- imgUpload.push(ret['message'][msgI])
- }
- imgData=[];
- $(".banner ul").html(" ");
- $(".TP_status").text("上传成功");
- setTimeout(function () {
- if($(".TP_status").text()=="上传成功"){
- $(".TP_status").text(" ");
- }
- },10000)
- }
- }else {
- $(".TP_status").text("点击上传全部图片");
- api.toast({
- msg: ret.message,
- duration: 2000,
- location: 'bottom'
- });
- }
- });
- dialogBox.close({
- dialogName: 'alert'
- });
- }else if (ret.eventType == 'left') {
- dialogBox.close({
- dialogName: 'alert'
- });
- }
- })
- })
- $("#FJ").click(function () {
- var fileBrowser = api.require('fileBrowser');
- fileBrowser.open(function(ret, err) {
- if (ret) {
- fileBrowser.close();
- if(fileUrl.indexOf(ret.url)!=-1){
- api.toast({
- msg: '已有该文件',
- duration: 2000,
- location: 'bottom'
- });
- return;
- }
- var url11 = ret.url;
- var i = url11.lastIndexOf('/');
- var j = url11.length;
- var name11 = url11.slice(i+1,j);
- // $(".fileDiv ul").append("<li><p>"+name11+"</p></li>")
- // $(".FJ_status").text("点击上传全部附件");
- uploadFile(url11,name11);
- fileUrl.push(ret.url);
- } else {
- alert(JSON.stringify(err));
- }
- });
- })
- $(".FJ_status").click(function () {
- if($(this).text()!="点击上传全部附件") return;
- popups("确认上传吗?",function (ret) {
- if (ret.eventType == 'right') {
- var Data={
- file:fileUrl
- }
- $(".FJ_status").text("正在上传中...");
- api.ajax({
- url: pageUrl+"upload",
- method: 'post',
- timeout: 30,
- dataType: 'json',
- returnAll: false,
- data: {
- "files":{
- "file[]":fileUrl
- },
- "values":{
- task_id:taskid,
- type:"2"
- }
- }
- }, function (ret, err) {
- var newFile=[];
- if(ret.status=="200"){
- if(ret.message.indexOf(false)!=-1){
- for(var i=0;i<ret.message.length;i++){
- if(ret.message[i]!=false){
- fileUpload.push(ret.message[i]);
- $(".fileDiv li:eq("+i+")").remove();
- }else {
- newFile.push(fileUrl[i]);
- }
- }
- $(".FJ_status").text("以下附件上传失败");
- fileUrl=newFile;
- }else {
- for(var msgI in ret['message']){
- fileUpload.push(ret['message'][msgI])
- }
- fileUrl=[];
- $(".fileDiv ul").html(" ");
- $(".FJ_status").text("上传成功");
- setTimeout(function () {
- if($(".FJ_status").text()=="上传成功"){
- $(".FJ_status").text(" ");
- }
- },10000)
- }
- }else {
- $(".FJ_status").text("点击上传全部附件");
- api.toast({
- msg: ret.message,
- duration: 2000,
- location: 'bottom'
- });
- }
- });
- dialogBox.close({
- dialogName: 'alert'
- });
- }else if (ret.eventType == 'left') {
- dialogBox.close({
- dialogName: 'alert'
- });
- }
- })
- });
- $("#backBtn").click(function () {
- api.closeWin();
- })
- function toHtml(str) {
- var a="<",b=">",c=" ",d="&nbsp;",text=str;
- if(text.match(a)) {
- toChange(a,"<")
- }
- if(text.match(b)) {
- toChange(b,">")
- }
- if(text.match(c)) {
- toChange(c," ")
- }
- if(text.match(d)) {
- toChange(d," ")
- }
- function toChange(type,type1) {
- text=text.replace(type,type1);
- if(text.match(type)) {
- toChange(type,type1)
- }
- }
- return text;
- }
- function popups(val,fn) {
- dialogBox.alert({
- texts: {
- title: '确认',
- content: val,
- leftBtnTitle: '取消',
- rightBtnTitle: '确认'
- },
- styles: {
- bg: '#fff',
- w: 300,
- title: {
- marginT: 20,
- icon: 'widget://res/gou.png',
- iconSize: 40,
- titleSize: 13,
- titleColor: '#000'
- },
- content: {
- color: '#000',
- size: 16
- },
- left: {
- marginB: 0,
- marginL: 0,
- w: 150,
- h: 60,
- corner: 2,
- bg: '#f9f9f9',
- color: '#818181',
- size: 12
- },
- right: {
- marginB: 0,
- marginL: 0,
- w: 150,
- h:60,
- corner: 2,
- bg: '#51c4d4',
- color: '#fff',
- size: 12
- }
- }
- }, function(ret) {
- fn(ret)
- });
- }
- }
- </script>
- </body>
- </html>
|