作者 曹东东

审核

@@ -311,6 +311,8 @@ class Ajax extends TeacherBase @@ -311,6 +311,8 @@ class Ajax extends TeacherBase
311 } 311 }
312 312
313 //手写签名板 313 //手写签名板
  314 +
  315 +
314 public function canvas(){ 316 public function canvas(){
315 $id = input('id'); 317 $id = input('id');
316 if ($this->request->isPost()){ 318 if ($this->request->isPost()){
1 <!DOCTYPE html> 1 <!DOCTYPE html>
  2 +<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
  3 +<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
  4 +<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
  5 +<!--[if gt IE 8]><!-->
2 <html> 6 <html>
  7 +<!--<![endif]-->
3 8
4 <head> 9 <head>
  10 + <meta name="viewport"
  11 + content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,user-scalable=no,viewport-fit=cover">
  12 + <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
  13 + <meta http-equiv="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
  14 + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  15 + <meta http-equiv="X-UA-Compatible" content="IE=edge">
  16 + <meta http-equiv="Pragma" content="no-cache">
  17 + <meta http-equiv="Cache" content="no-cache">
  18 + <meta http-equiv="Expires" content="0">
5 <meta charset="utf-8"> 19 <meta charset="utf-8">
6 - <title>签名页</title>  
7 - <script src="__CDN__/assets/js/signature.js"></script>  
8 - <script src="__CDN__/assets/js/jquery-3.4.1.min.js"></script> 20 + <title>项目审核</title>
  21 + <link rel="stylesheet" href="http://i.gtimg.cn/vipstyle/frozenui/2.0.0/css/frozen.css">
  22 +
  23 + <style>
  24 + [v-cloak] {
  25 + display: none;
  26 + }
  27 +
  28 + canvas{
  29 + width: 100vh;
  30 + }
  31 +
  32 + * {
  33 + margin: 0;
  34 + padding: 0;
  35 + }
  36 +
  37 + html,
  38 + body {
  39 + width: 100%;
  40 + height: 100%;
  41 + text-align: center;
  42 + background-color: #FFFFFF;
  43 + }
  44 +
  45 + canvas {
  46 + max-width: 100%;
  47 + border: 2px dotted #ccc;
  48 + }
  49 +
  50 + .opinion {
  51 + width: 100%;
  52 + height: 235px;
  53 + font-size: 16px;
  54 + border: 1px solid #000;
  55 + }
  56 +
  57 + .opinion::-webkit-input-placeholder {
  58 + line-height: 235px;
  59 + text-align: center;
  60 + }
  61 +
  62 + /* 使用webkit内核的浏览器 */
  63 + .opinion:-moz-placeholder {
  64 + line-height: 235px;
  65 + text-align: center;
  66 + }
  67 +
  68 + /* Firefox版本4-18 */
  69 + .opinion::-moz-placeholder {
  70 + line-height: 235px;
  71 + text-align: center;
  72 + }
  73 +
  74 + /* Firefox版本19+ */
  75 + .opinion:-ms-input-placeholder {
  76 + line-height: 235px;
  77 + text-align: center;
  78 + }
  79 +
  80 + /*elmeentui文本 textarea字体*/
  81 + .is-disabled .el-input__inner {
  82 + font-weight: bold !important;
  83 + font-size: 14px !important;
  84 + color: #4A5560 !important;
  85 + }
  86 + .is-disabled .el-textarea__inner {
  87 + font-weight: bold !important;
  88 + font-size: 14px !important;
  89 + color: #4A5560 !important;
  90 + }
  91 + .el-form-item__label {
  92 + color: black !important;
  93 + font-weight: bold !important;
  94 + }
  95 + </style>
  96 +
9 </head> 97 </head>
  98 +<body>
  99 +<script src="__CDN__/assets/js/jquery-3.4.1.min.js"></script>
  100 +<script src="/assets/js/index.js"></script>
  101 +<script src="/assets/ele/vue.js"></script>
  102 +
  103 +<link rel="stylesheet" href="__CDN__/assets/ele/element/element.css">
  104 +<script src="__CDN__/assets/ele/element/element.js"></script>
  105 +<script src="__CDN__/assets/ele/Sortable.min.js"></script>
  106 +<script src="__CDN__/assets/ele/vuedraggable.js"></script>
  107 +<script src="__CDN__/assets/ele/moment.js"></script>
10 108
11 -<body style="margin: 0;">  
12 -<div class="popverBox">  
13 - <div class="titleBox">项目审核</div>  
14 - <div id="signSure" class="signSure">  
15 - <input type="hidden" name="id" id="id" value="{$id}">  
16 - <div class="topBtnBox">  
17 - <div class="topTitle">电子签名</div>  
18 - <canvas class="whiteBord" id="whiteBord">  
19 - 您的浏览器不支持canvas技术,请升级浏览器!  
20 - </canvas>  
21 -  
22 - </div>  
23 - <div>  
24 - <div class="topTitle">审核意见</div>  
25 - <textarea class="opinion" placeholder="输入审核意见,不超过200个字" name="opinion" id="opinion"></textarea>  
26 - </div>  
27 - <div class="bottomBtnBox">  
28 - <button class="primaryBtn" id="againWrite">重写</button>  
29 - <button class="primaryBtn activeBtn" id="sureWrite">通过</button>  
30 - <button class="primaryBtn backBtn" id="back">退回</button>  
31 - </div> 109 +<div id="app">
  110 +
  111 + <input type="hidden" name="id" id="id" value="{$id}">
  112 + <div v-if="step==1" style="padding:0 15px;margin-top: 25px;">
  113 + <el-form size="mini">
  114 + <div>
  115 + <el-form-item label="审核状态">
  116 + <div>
  117 + <el-radio v-model="v_status" label="1" border>通过</el-radio>
  118 + <el-radio v-model="v_status" label="2" border>退回</el-radio>
  119 + </div>
  120 + </el-form-item>
  121 + </div>
  122 + <div>
  123 + <el-form-item label="审核意见">
  124 + <el-input type="textarea" rows="8" v-model="option"></el-input>
  125 + </el-form-item>
  126 + </div>
  127 + </el-form>
  128 + <button @click="draw" class="ui-btn-lg ui-btn-primary">确认</button>
  129 + </div>
  130 +
  131 + <div v-if="step==3" class="buttons" style="position: absolute;left:15px;bottom:100px;">
  132 + <button type="button" style="width:40px;height:130px;background-color:#C2C7CC;" @click="clear" class="ui-btn clear">重签</button>
  133 + <button type="button" @click="toDetail" style="width:40px;height:130px;margin-top:8px" class="ui-btn ui-btn-primary ouput back">项目详情</button>
  134 + <button type="button" @click="pass" style="width:40px;height:130px;margin-top:10px" class="ui-btn ui-btn-primary ouput pass">确认签名</button>
32 </div> 135 </div>
33 </div> 136 </div>
34 -</body>  
35 137
36 <script> 138 <script>
37 - function sureWriteCallback(imageBase64,type){  
38 - // 签名完成后的的逻辑代码  
39 - $.ajax({  
40 - type : "POST", //提交方式  
41 - url : "canvas",//路径  
42 - data : {  
43 - "imgbase64" : imageBase64,  
44 - 'type' : type,  
45 - 'id' : $('#id').val(),  
46 - 'opinion' : $('#opinion').val()  
47 - },//数据,这里使用的是Json格式进行传输  
48 - success:function (data) {  
49 - console.log('成功');  
50 - alert(data.msg) 139 + new Vue({
  140 + el: '#app',
  141 + data: {
  142 + step: 1,
  143 + sign : null,
  144 + id : "{$id}",
  145 + option:'',
  146 + v_status:'1',
  147 + },
  148 + mounted(){
  149 + var _this = this;
  150 +
  151 + },
  152 + methods:{
  153 + clear:function(){
  154 + this.sign.clear();
  155 + },
  156 + draw :function(){
  157 + this.step = 3;
  158 + //初始化
  159 + this.sign = sign = new Draw({
  160 + lineWidth: 10, // 线条宽度
  161 + width: 400, // canvas 宽
  162 + height: window.screen.height, //canvas 高
  163 + strokeStyle: '#333333' // 线条颜色
  164 + });
  165 + },
  166 + toDetail(){
  167 + var _this = this;
  168 + _this.sign.destroyed();
  169 + $('canvas').remove();
  170 + window.location.href = '/teacher/container/container_detail/detail_view?id=' + _this.id;
51 }, 171 },
52 - error:function (data) {  
53 - console.log('失败')  
54 - alert(data.msg) 172 + pass:function(){
  173 + var img = new Image();
  174 + img.style.width = '200px';
  175 + img.src = this.sign.ouput();
  176 + this.sureWriteCallback(this.sign.ouput(), 1);
  177 + },
  178 + sureWriteCallback:function(imageBase64, type) {
  179 + // 签名完成后的的逻辑代码
  180 +
  181 + if(this.sign.state.undopath.length <= 0){
  182 + alert("还没有签名");
  183 + return false;
  184 + }
  185 + var _this = this;
  186 + $.ajax({
  187 + type: "POST", //提交方式
  188 + url: "canvas", //路径
  189 + data: {
  190 + "imgbase64": imageBase64,
  191 + 'type': _this.v_status,
  192 + 'id': _this.id,
  193 + 'opinion': _this.option,
  194 + 'status':_this.v_status
  195 + }, //数据,这里使用的是Json格式进行传输
  196 + success: function(data) {
  197 + alert(data.msg)
  198 + // window.location.href = '/teacher/container/container_detail/detail_view?id=' + _this.id;
  199 + },
  200 + error: function(data) {
  201 + alert(data.msg)
  202 + }
  203 + })
  204 +
55 } 205 }
56 - })  
57 - }  
58 -  
59 - let params = {  
60 - whiteBord:'whiteBord',//canvas标签的id名称  
61 - againWrite:'againWrite',//重写按钮id名  
62 - sureWrite:'sureWrite',//确认按钮id名  
63 - back:'back',//退回按钮id名  
64 - whiteBordPtions:{},//白板的配置项(空对象时取默认值)  
65 - sureWriteCallback,// 签名完成后的回调函数  
66 - }  
67 - signature(params) // signature.js里封装好的函数,把参数传进去,调用一下即可 206 + }
  207 + })
  208 +
68 </script> 209 </script>
69 210
70 -<style>  
71 - .popverBox{  
72 - background: #f2f2f2;  
73 - position: relative;  
74 - font-size: 30px;  
75 - display: flex;  
76 - align-items: center;  
77 - flex-direction: column;  
78 - height: 100vh;  
79 - }  
80 - .signSure{  
81 - width: 90%;  
82 - border-radius: 16px;  
83 - padding: 20px 12px 28px 12px;  
84 - }  
85 - .titleBox{  
86 - color: #fff;  
87 - background-color: #4285dc;  
88 - display: flex;  
89 - align-items: center;  
90 - justify-content: center;  
91 - width: 100%;  
92 - height: 7rem;  
93 - font-size: 2.5rem;  
94 - }  
95 - .topTitle{  
96 - margin: 20px 0 12px 12px;  
97 - font-size: 2.3rem;  
98 - }  
99 - .whiteBord{  
100 - width: 100%;  
101 - height: 95%;  
102 - border: 1px solid #000;  
103 - background: #fff;  
104 - margin: 0 auto;  
105 - border-radius: 4px;  
106 - margin-bottom: 12px;  
107 - }  
108 - .bottomBtnBox{  
109 - padding: 60px 7px;  
110 - display: flex;  
111 - justify-content: space-between;  
112 - }  
113 - .primaryBtn{  
114 - width: 25%;  
115 - height: 80px;  
116 - color: #666;  
117 - border: 1px solid #ccc;  
118 - border-radius: 4px;  
119 - background: #fff;  
120 - font-size: 30px;  
121 - }  
122 - .activeBtn{  
123 - /*background: #315294;*/  
124 - background: rgb(38,198,218);  
125 - color: #fff;  
126 - border: none;  
127 - }  
128 - .backBtn{  
129 - /*background: #315294;*/  
130 - background: rgb(252,75,108);  
131 - color: #fff;  
132 - border: none;  
133 - }  
134 - .opinion{  
135 - width: 100%;  
136 - height: 235px;  
137 - font-size: 30px;  
138 - border: 1px solid #000;  
139 - }  
140 -  
141 - .opinion::-webkit-input-placeholder{  
142 - line-height: 235px;text-align: center;  
143 - }/* 使用webkit内核的浏览器 */  
144 - .opinion:-moz-placeholder{  
145 - line-height: 235px;text-align: center;  
146 - }/* Firefox版本4-18 */  
147 - .opinion::-moz-placeholder{  
148 - line-height: 235px;text-align: center;  
149 - }/* Firefox版本19+ */  
150 - .opinion:-ms-input-placeholder{  
151 - line-height: 235px;text-align: center;  
152 - }  
153 -  
154 -</style>  
155 -</html>  
  211 +</body>
  212 +
  213 +</html>
1 -var main = new Vue({  
2 - el:"#main",  
3 - data:function(){  
4 - return{  
5 - // 公共数据  
6 - allData:__data,  
7 - // 左侧tab栏active  
8 - leftKey:'course',  
9 - // 右侧部分需要的数据  
10 - nowData: {}, 1 +( function ( global, factory ) {
  2 + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  3 + typeof define === 'function' && define.amd ? define( factory ) :
  4 + ( global = global || self, global.Draw = factory() );
  5 +}( this, ( function () {
  6 + 'use strict';
  7 +
  8 + var classCallCheck = function ( instance, Constructor ) {
  9 + if ( !( instance instanceof Constructor ) ) {
  10 + throw new TypeError( "Cannot call a class as a function" );
11 } 11 }
12 - },  
13 - // 计算属性  
14 - computed: {  
15 - videoList: function () {  
16 - return this.nowData.videoList || [] 12 + };
  13 +
  14 + var createClass = function () {
  15 + function defineProperties ( target, props ) {
  16 + for ( var i = 0; i < props.length; i++ ) {
  17 + var descriptor = props[i];
  18 + descriptor.enumerable = descriptor.enumerable || false;
  19 + descriptor.configurable = true;
  20 + if ( "value" in descriptor ) descriptor.writable = true;
  21 + Object.defineProperty( target, descriptor.key, descriptor );
  22 + }
17 } 23 }
18 24
19 - },  
20 - // 钩子函数  
21 - mounted() {  
22 - this.nowData = __data[this.leftKey]  
23 - console.log("右侧数据",this.nowData)  
24 - },  
25 - // 监控属性  
26 - watch: {  
27 - // 监听导航按钮下标改变,使用导航对应的平台数据  
28 - leftKey: function (newVal, oldVal) {  
29 - this.nowData = __data[newVal]  
30 - },  
31 - },  
32 - methods: {  
33 - changeTabIndex: function (key) {  
34 - console.log(this.leftKey)  
35 - console.log(Key)  
36 - this.leftKey = key; 25 + return function ( Constructor, protoProps, staticProps ) {
  26 + if ( protoProps ) defineProperties( Constructor.prototype, protoProps );
  27 + if ( staticProps ) defineProperties( Constructor, staticProps );
  28 + return Constructor;
  29 + };
  30 + }();
  31 +
  32 + /**
  33 + * @github https://github.com/929467350/draw
  34 + * @description 手写签字版
  35 + */
  36 + var Draw = function () {
  37 + function Draw () {
  38 + var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  39 + classCallCheck( this, Draw );
  40 +
  41 + this.el = params.el || document.createElement( 'canvas' );
  42 + this.state = {
  43 + undopath: [],
  44 + index: -1,
  45 + old: void 0,
  46 + isStart: false,
  47 + width: params.width || 400,
  48 + height: params.height || 400,
  49 + lineWidth: params.lineWidth || 1,
  50 + isTouch: 'ontouchstart' in window,
  51 + strokeStyle: params.strokeStyle || '#333333'
  52 + };
  53 + var _state = this.state,
  54 + width = _state.width,
  55 + height = _state.height,
  56 + lineWidth = _state.lineWidth;
  57 +
  58 + this.el.width = width * 2;
  59 + this.el.height = height * 2;
  60 + document.body.appendChild( this.el );
  61 + this.ctx = this.el.getContext( '2d' );
  62 + this.ctx.scale( 2, 2 );
  63 + this.ctx.lineWidth = lineWidth;
  64 + this.ctx.lineJoin = 'round';
  65 + this.ctx.lineCap = 'round';
  66 + this.init();
37 } 67 }
38 - },  
39 -})  
  68 +
  69 + createClass( Draw, [{
  70 + key: 'onStart',
  71 + value: function onStart () {
  72 + ++this.state.index;
  73 + this.state.isStart = true;
  74 + }
  75 + }, {
  76 + key: 'onMove',
  77 + value: function onMove ( e ) {
  78 + e.preventDefault();
  79 + if ( !this.state.isStart ) return;
  80 + var pos = this.pos( e );
  81 + var index = this.state.index;
  82 +
  83 + this.ctx.strokeStyle = this.state.strokeStyle;
  84 + if ( this.state.old ) {
  85 + this.ctx.beginPath();
  86 + this.ctx.moveTo( this.state.old.x, this.state.old.y );
  87 + this.ctx.lineTo( pos.x, pos.y );
  88 + this.ctx.stroke();
  89 + }
  90 + this.state.old = pos;
  91 + if ( this.state.undopath[index] ) {
  92 + this.state.undopath[index].push( { x: this.state.old.x, y: this.state.old.y } );
  93 + } else {
  94 + this.state.undopath[index] = [{
  95 + x: this.state.old.x,
  96 + y: this.state.old.y,
  97 + strokeStyle: this.ctx.strokeStyle,
  98 + lineWidth: this.ctx.lineWidth
  99 + }];
  100 + }
  101 + }
  102 + }, {
  103 + key: 'onEnd',
  104 + value: function onEnd () {
  105 + this.state.old = void 0;
  106 + this.state.isStart = false;
  107 + }
  108 + }, {
  109 + key: 'pos',
  110 + value: function pos ( e ) {
  111 + var x = 0,
  112 + y = 0;
  113 + if ( e.touches ) {
  114 + x = e.touches[0].pageX;
  115 + y = e.touches[0].pageY;
  116 + } else {
  117 + x = e.offsetX / 2;
  118 + y = e.offsetY / 2;
  119 + }
  120 + return { x: x, y: y };
  121 + }
  122 + }, {
  123 + key: 'ouput',
  124 + value: function ouput () {
  125 + // 输出图片
  126 + return this.el.toDataURL();
  127 + }
  128 + }, {
  129 + key: 'init',
  130 + value: function init () {
  131 + // 绑定事件
  132 + var isTouch = this.state.isTouch;
  133 +
  134 + this.el.addEventListener( isTouch ? 'touchstart' : 'mousedown', this.onStart.bind( this ), false );
  135 + this.el.addEventListener( isTouch ? 'touchmove' : 'mousemove', this.onMove.bind( this ), false );
  136 + this.el.addEventListener( isTouch ? 'touchend' : 'mouseup', this.onEnd.bind( this ), false );
  137 + this.el.addEventListener( isTouch ? 'touchcancel' : 'mouseout', this.onEnd.bind( this ), false );
  138 + }
  139 + }, {
  140 + key: 'destroyed',
  141 + value: function destroyed () {
  142 + if ( this.el ) {
  143 + var isTouch = this.state.isTouch;
  144 + this.el.removeEventListener( isTouch ? 'touchstart' : 'mousedown', this.onStart.bind( this ) );
  145 + this.el.removeEventListener( isTouch ? 'touchmove' : 'mousemove', this.onMove.bind( this ) );
  146 + this.el.removeEventListener( isTouch ? 'touchend' : 'mouseup', this.onEnd.bind( this ) );
  147 + this.el.removeEventListener( isTouch ? 'touchcancel' : 'mouseout', this.onEnd.bind( this ) );
  148 + }
  149 + }
  150 + }, {
  151 + key: 'clear',
  152 + value: function clear () {
  153 + // 清除画布
  154 + this.state.index = -1;
  155 + this.state.undopath = [];
  156 + this.ctx.clearRect( 0, 0, this.el.width, this.el.height );
  157 + }
  158 + }, {
  159 + key: 'undo',
  160 + value: function undo () {
  161 + // 撤销
  162 + this.state.index >= 0 && --this.state.index;
  163 + var undopath = this.state.undopath;
  164 + this.state.undopath.pop();
  165 + this.ctx.clearRect( 0, 0, this.el.width, this.el.height );
  166 + if ( undopath ) {
  167 + this.ctx.beginPath();
  168 + for ( var z = 0; z < undopath.length; ++z ) {
  169 + this.ctx.moveTo( undopath[z][0].x, undopath[z][0].y );
  170 + this.ctx.lineWidth = undopath[z][0].lineWidth;
  171 + this.ctx.strokeStyle = undopath[z][0].strokeStyle;
  172 + for ( var i = 0; i < undopath[z].length; ++i ) {
  173 + this.ctx.lineTo( undopath[z][i].x, undopath[z][i].y );
  174 + }
  175 + }
  176 + this.ctx.stroke();
  177 + this.ctx.closePath();
  178 + } else {
  179 + this.state.undopath = [];
  180 + }
  181 + }
  182 + }] );
  183 + return Draw;
  184 + }();
  185 +
  186 + return Draw;
  187 +
  188 +} ) ) );