Loading src/utils/common.js +72 −67 Original line number Diff line number Diff line Loading @@ -9,88 +9,93 @@ var args = arguments; var that = this; // 清除上一次延时器 clearTimeout(timer) clearTimeout(timer); timer = setTimeout(function() { fn.apply(that,args) fn.apply(that, args); }, delay); } }; } // 图片旋转处理 -> base64 export const rotateBase64Img = (src, edg, callback) => { try { const canvas = document.createElement('canvas') const ctx = canvas.getContext('2d') const canvas = document.createElement("canvas"); const ctx = canvas.getContext("2d"); let imgW = 0 // 图片宽度 let imgH = 0 // 图片高度 let size = 0 // canvas初始大小 let imgW = 0; // 图片宽度 let imgH = 0; // 图片高度 let size = 0; // canvas初始大小 if (edg % 90 !== 0) { throw new Error('旋转角度必须是90的倍数!') throw new Error("旋转角度必须是90的倍数!"); } (edg < 0) && (edg = (edg % 360) + 360) const quadrant = (edg / 90) % 4 // 旋转象限 const cutCoor = { sx: 0, sy: 0, ex: 0, ey: 0 } // 裁剪坐标 edg < 0 && (edg = (edg % 360) + 360); const quadrant = (edg / 90) % 4; // 旋转象限 const cutCoor = { sx: 0, sy: 0, ex: 0, ey: 0 }; // 裁剪坐标 const image = new Image() image.src = src image.crossOrigin = 'anonymous' const image = new Image(); image.src = src; image.crossOrigin = "anonymous"; image.onload = function() { imgW = image.width imgH = image.height size = imgW > imgH ? imgW : imgH imgW = image.width; imgH = image.height; size = imgW > imgH ? imgW : imgH; canvas.width = size * 2 canvas.height = size * 2 canvas.width = size * 2; canvas.height = size * 2; switch (quadrant) { case 0: cutCoor.sx = size cutCoor.sy = size cutCoor.ex = size + imgW cutCoor.ey = size + imgH break cutCoor.sx = size; cutCoor.sy = size; cutCoor.ex = size + imgW; cutCoor.ey = size + imgH; break; case 1: cutCoor.sx = size - imgH cutCoor.sy = size cutCoor.ex = size cutCoor.ey = size + imgW break cutCoor.sx = size - imgH; cutCoor.sy = size; cutCoor.ex = size; cutCoor.ey = size + imgW; break; case 2: cutCoor.sx = size - imgW cutCoor.sy = size - imgH cutCoor.ex = size cutCoor.ey = size break cutCoor.sx = size - imgW; cutCoor.sy = size - imgH; cutCoor.ex = size; cutCoor.ey = size; break; case 3: cutCoor.sx = size cutCoor.sy = size - imgW cutCoor.ex = size + imgH cutCoor.ey = size + imgW break cutCoor.sx = size; cutCoor.sy = size - imgW; cutCoor.ex = size + imgH; cutCoor.ey = size + imgW; break; } ctx.translate(size, size) ctx.rotate(edg * Math.PI / 180) ctx.drawImage(image, 0, 0) ctx.translate(size, size); ctx.rotate((edg * Math.PI) / 180); ctx.drawImage(image, 0, 0); const imgData = ctx.getImageData(cutCoor.sx, cutCoor.sy, cutCoor.ex, cutCoor.ey) const imgData = ctx.getImageData( cutCoor.sx, cutCoor.sy, cutCoor.ex, cutCoor.ey ); if (quadrant % 2 === 0) { canvas.width = imgW canvas.height = imgH canvas.width = imgW; canvas.height = imgH; } else { canvas.width = imgH canvas.height = imgW canvas.width = imgH; canvas.height = imgW; } ctx.putImageData(imgData, 0, 0) ctx.putImageData(imgData, 0, 0); if (typeof callback === 'function') { callback(canvas.toDataURL('image/png', 0.7)) } if (typeof callback === "function") { callback(canvas.toDataURL("image/png", 0.7)); } }; } catch (e) { console.log(e) } console.log(e); } }; src/views/riskProject/add/index.vue +13 −3 Original line number Diff line number Diff line Loading @@ -216,11 +216,12 @@ <van-checkbox-group v-model="riskList" ref="checkboxGroup" class="building-select" style="width: 100%;font-size: 18px;" > <van-checkbox shape="square" style="margin: 10px 0px;justify-content: center;" style="margin: 10px 0px;" v-for="item in riskModelList" :key="item.id" :name="item" Loading Loading @@ -519,11 +520,14 @@ export default { this.projectDept = true; }, changeDept(id, name) { if(id!=this.form.deptId){ this.form.leaderUserName = '' this.form.workUserNames='' } this.form.deptId = id; this.form.deptName = name; }, closeDept() { console.log(this.form.deptId); this.projectDept = false; }, getExecuteUser() { Loading Loading @@ -827,6 +831,9 @@ export default { this.show = false; }, onSave(e) { if(e.id!=this.form.projectId){ this.form.buildingNames = '' } this.form.projectId = e.id; this.form.projectName = e.name; this.show = false; Loading @@ -839,10 +846,13 @@ export default { } else { this.showSetRankMode = false; } } }, } }; </script> <style scoped> /* @import url(); 引入css类 */ .building-select{ padding: 10px 30px; } </style> src/views/riskProject/add/projectList.vue +8 −1 Original line number Diff line number Diff line Loading @@ -63,7 +63,8 @@ components: { // LHeader }, created() { mounted() { this.getInsideUser() }, data() { return { Loading Loading @@ -115,9 +116,15 @@ }, save() { this.$emit('onSave', this.itemSel) this.destoryList(); }, cancel() { this.destoryList(); this.$emit('onClose') }, destoryList(){ this.searchVal = ''; this.onInput() } } }; Loading src/views/riskProject/manage/index.vue +10 −5 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ v-model="searchValue" show-action placeholder="请输入搜索内容" @search="onSearch" @input="onSearch" > <template #action> <div @click="onSearch">搜索</div> Loading Loading @@ -117,6 +117,7 @@ import { timestampToTime, generateId } from "@/utils/format"; import { getFun, postFun,deleteFun } from "@/service/table.js"; import { Toast ,Dialog} from 'vant'; // import { postriskConList } from "@/service/risk"; import { debounce } from "@/utils/common.js"; export default { name: "risk-confirme", components: { Loading Loading @@ -169,9 +170,10 @@ export default { loadingType: "spinner", duration: 0 }); const name = `&name=${this.searchValue}` // let formdata = new FormData(); // formdata.append("select", select); getFun(this.tabs[this.active]["api"]) getFun(this.tabs[this.active]["api"]+name) .then(res => { this.$toast.clear(); this.messageList = res.data || res.rows; Loading @@ -186,9 +188,12 @@ export default { }); }, onSearch(val) { this.postList(this.searchValue); }, // onSearch(val) { // this.postList(this.searchValue); // }, onSearch:debounce(function (){ this.postList() }, 800), touchstart(index, item) { if (this.showIndex != null) { this.showIndex = null; Loading src/views/riskProject/taskLedger/index.vue +20 −6 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ v-model="searchValue" show-action placeholder="请输入搜索内容" @search="onSearch" @input="onSearch" > <template #action> <div @click="onSearch">搜索</div> Loading Loading @@ -56,7 +56,9 @@ <script type="text/ecmascript-6"> import LHeader from "@/components/header.vue"; import { timestampToTime, generateId } from "@/utils/format"; import { debounce } from "@/utils/common.js"; import { getFun, postFun } from "@/service/table.js"; export default { name: 'taskLedger',//任务台账 data() { Loading @@ -79,9 +81,21 @@ export default { return timestampToTime(new Date(time), "DT2", true); }, getList() { getFun('/risk/plan/details/list').then(res => { console.log('%c [ res ]-77', 'font-size:13px; background:pink; color:#bf2c9f;', res) this.$toast.loading({ message: "加载中...", forbidClick: true, loadingType: "spinner", duration: 0 }); const obj = { name:this.searchValue } getFun('/risk/plan/details/list',obj).then(res => { this.$toast.clear(); this.taskList = res.data }).catch(()=>{ this.$toast.clear(); this.$toast.fail("加载失败,请稍后再试"); }) }, //点击列表 Loading @@ -103,9 +117,9 @@ export default { sessionStorage.setItem("buildingId", ""); }, onSearch(searchValue) { } onSearch:debounce(function (){ this.getList() }, 800), }, } </script> Loading Loading
src/utils/common.js +72 −67 Original line number Diff line number Diff line Loading @@ -9,88 +9,93 @@ var args = arguments; var that = this; // 清除上一次延时器 clearTimeout(timer) clearTimeout(timer); timer = setTimeout(function() { fn.apply(that,args) fn.apply(that, args); }, delay); } }; } // 图片旋转处理 -> base64 export const rotateBase64Img = (src, edg, callback) => { try { const canvas = document.createElement('canvas') const ctx = canvas.getContext('2d') const canvas = document.createElement("canvas"); const ctx = canvas.getContext("2d"); let imgW = 0 // 图片宽度 let imgH = 0 // 图片高度 let size = 0 // canvas初始大小 let imgW = 0; // 图片宽度 let imgH = 0; // 图片高度 let size = 0; // canvas初始大小 if (edg % 90 !== 0) { throw new Error('旋转角度必须是90的倍数!') throw new Error("旋转角度必须是90的倍数!"); } (edg < 0) && (edg = (edg % 360) + 360) const quadrant = (edg / 90) % 4 // 旋转象限 const cutCoor = { sx: 0, sy: 0, ex: 0, ey: 0 } // 裁剪坐标 edg < 0 && (edg = (edg % 360) + 360); const quadrant = (edg / 90) % 4; // 旋转象限 const cutCoor = { sx: 0, sy: 0, ex: 0, ey: 0 }; // 裁剪坐标 const image = new Image() image.src = src image.crossOrigin = 'anonymous' const image = new Image(); image.src = src; image.crossOrigin = "anonymous"; image.onload = function() { imgW = image.width imgH = image.height size = imgW > imgH ? imgW : imgH imgW = image.width; imgH = image.height; size = imgW > imgH ? imgW : imgH; canvas.width = size * 2 canvas.height = size * 2 canvas.width = size * 2; canvas.height = size * 2; switch (quadrant) { case 0: cutCoor.sx = size cutCoor.sy = size cutCoor.ex = size + imgW cutCoor.ey = size + imgH break cutCoor.sx = size; cutCoor.sy = size; cutCoor.ex = size + imgW; cutCoor.ey = size + imgH; break; case 1: cutCoor.sx = size - imgH cutCoor.sy = size cutCoor.ex = size cutCoor.ey = size + imgW break cutCoor.sx = size - imgH; cutCoor.sy = size; cutCoor.ex = size; cutCoor.ey = size + imgW; break; case 2: cutCoor.sx = size - imgW cutCoor.sy = size - imgH cutCoor.ex = size cutCoor.ey = size break cutCoor.sx = size - imgW; cutCoor.sy = size - imgH; cutCoor.ex = size; cutCoor.ey = size; break; case 3: cutCoor.sx = size cutCoor.sy = size - imgW cutCoor.ex = size + imgH cutCoor.ey = size + imgW break cutCoor.sx = size; cutCoor.sy = size - imgW; cutCoor.ex = size + imgH; cutCoor.ey = size + imgW; break; } ctx.translate(size, size) ctx.rotate(edg * Math.PI / 180) ctx.drawImage(image, 0, 0) ctx.translate(size, size); ctx.rotate((edg * Math.PI) / 180); ctx.drawImage(image, 0, 0); const imgData = ctx.getImageData(cutCoor.sx, cutCoor.sy, cutCoor.ex, cutCoor.ey) const imgData = ctx.getImageData( cutCoor.sx, cutCoor.sy, cutCoor.ex, cutCoor.ey ); if (quadrant % 2 === 0) { canvas.width = imgW canvas.height = imgH canvas.width = imgW; canvas.height = imgH; } else { canvas.width = imgH canvas.height = imgW canvas.width = imgH; canvas.height = imgW; } ctx.putImageData(imgData, 0, 0) ctx.putImageData(imgData, 0, 0); if (typeof callback === 'function') { callback(canvas.toDataURL('image/png', 0.7)) } if (typeof callback === "function") { callback(canvas.toDataURL("image/png", 0.7)); } }; } catch (e) { console.log(e) } console.log(e); } };
src/views/riskProject/add/index.vue +13 −3 Original line number Diff line number Diff line Loading @@ -216,11 +216,12 @@ <van-checkbox-group v-model="riskList" ref="checkboxGroup" class="building-select" style="width: 100%;font-size: 18px;" > <van-checkbox shape="square" style="margin: 10px 0px;justify-content: center;" style="margin: 10px 0px;" v-for="item in riskModelList" :key="item.id" :name="item" Loading Loading @@ -519,11 +520,14 @@ export default { this.projectDept = true; }, changeDept(id, name) { if(id!=this.form.deptId){ this.form.leaderUserName = '' this.form.workUserNames='' } this.form.deptId = id; this.form.deptName = name; }, closeDept() { console.log(this.form.deptId); this.projectDept = false; }, getExecuteUser() { Loading Loading @@ -827,6 +831,9 @@ export default { this.show = false; }, onSave(e) { if(e.id!=this.form.projectId){ this.form.buildingNames = '' } this.form.projectId = e.id; this.form.projectName = e.name; this.show = false; Loading @@ -839,10 +846,13 @@ export default { } else { this.showSetRankMode = false; } } }, } }; </script> <style scoped> /* @import url(); 引入css类 */ .building-select{ padding: 10px 30px; } </style>
src/views/riskProject/add/projectList.vue +8 −1 Original line number Diff line number Diff line Loading @@ -63,7 +63,8 @@ components: { // LHeader }, created() { mounted() { this.getInsideUser() }, data() { return { Loading Loading @@ -115,9 +116,15 @@ }, save() { this.$emit('onSave', this.itemSel) this.destoryList(); }, cancel() { this.destoryList(); this.$emit('onClose') }, destoryList(){ this.searchVal = ''; this.onInput() } } }; Loading
src/views/riskProject/manage/index.vue +10 −5 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ v-model="searchValue" show-action placeholder="请输入搜索内容" @search="onSearch" @input="onSearch" > <template #action> <div @click="onSearch">搜索</div> Loading Loading @@ -117,6 +117,7 @@ import { timestampToTime, generateId } from "@/utils/format"; import { getFun, postFun,deleteFun } from "@/service/table.js"; import { Toast ,Dialog} from 'vant'; // import { postriskConList } from "@/service/risk"; import { debounce } from "@/utils/common.js"; export default { name: "risk-confirme", components: { Loading Loading @@ -169,9 +170,10 @@ export default { loadingType: "spinner", duration: 0 }); const name = `&name=${this.searchValue}` // let formdata = new FormData(); // formdata.append("select", select); getFun(this.tabs[this.active]["api"]) getFun(this.tabs[this.active]["api"]+name) .then(res => { this.$toast.clear(); this.messageList = res.data || res.rows; Loading @@ -186,9 +188,12 @@ export default { }); }, onSearch(val) { this.postList(this.searchValue); }, // onSearch(val) { // this.postList(this.searchValue); // }, onSearch:debounce(function (){ this.postList() }, 800), touchstart(index, item) { if (this.showIndex != null) { this.showIndex = null; Loading
src/views/riskProject/taskLedger/index.vue +20 −6 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ v-model="searchValue" show-action placeholder="请输入搜索内容" @search="onSearch" @input="onSearch" > <template #action> <div @click="onSearch">搜索</div> Loading Loading @@ -56,7 +56,9 @@ <script type="text/ecmascript-6"> import LHeader from "@/components/header.vue"; import { timestampToTime, generateId } from "@/utils/format"; import { debounce } from "@/utils/common.js"; import { getFun, postFun } from "@/service/table.js"; export default { name: 'taskLedger',//任务台账 data() { Loading @@ -79,9 +81,21 @@ export default { return timestampToTime(new Date(time), "DT2", true); }, getList() { getFun('/risk/plan/details/list').then(res => { console.log('%c [ res ]-77', 'font-size:13px; background:pink; color:#bf2c9f;', res) this.$toast.loading({ message: "加载中...", forbidClick: true, loadingType: "spinner", duration: 0 }); const obj = { name:this.searchValue } getFun('/risk/plan/details/list',obj).then(res => { this.$toast.clear(); this.taskList = res.data }).catch(()=>{ this.$toast.clear(); this.$toast.fail("加载失败,请稍后再试"); }) }, //点击列表 Loading @@ -103,9 +117,9 @@ export default { sessionStorage.setItem("buildingId", ""); }, onSearch(searchValue) { } onSearch:debounce(function (){ this.getList() }, 800), }, } </script> Loading