rectificationComponent.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. <!--整改-->
  2. <template>
  3. <div class="page-container initiateInspect-rectificationComponent">
  4. <!--当前整改-->
  5. <el-form class="add-form-box" :model="addForm" ref="addForm" :rules="rules" label-width="110px">
  6. <p class="content-right-title-min-p">
  7. 隐患整改
  8. <span :class="itemShowType?'el-icon-arrow-down':'el-icon-arrow-up'" @click="itemShowButton()"></span>
  9. </p>
  10. <div v-if="itemShowType" style="margin-top:20px;">
  11. <el-form-item label="整改结果" prop="rectifyResult">
  12. <div class="right-text-box">
  13. <div :class="addForm.rectifyResult == 1?'right-check-box':'right-no-check-box'" @click="checkButton(1)">
  14. <div>
  15. <p></p>
  16. </div>
  17. <p class="right-check-title-p">已整改</p>
  18. </div>
  19. <div :class="addForm.rectifyResult == 0?'right-check-box':'right-no-check-box'" @click="checkButton(0)">
  20. <div>
  21. <p></p>
  22. </div>
  23. <p class="right-check-title-p">暂无法整改</p>
  24. </div>
  25. </div>
  26. </el-form-item>
  27. <el-form-item label="整改措施" prop="rectifyMeasure">
  28. <el-input placeholder="立整立改的请填写相关文字及整改前后照片对比等,不能立整立改的请说明因并附整改计划、措施等" maxlength='500' type="textarea" style="width:704px;"
  29. resize="none" v-model="addForm.rectifyMeasure" :show-word-limit="true" :rows="3"></el-input>
  30. </el-form-item>
  31. <el-form-item label="现场照片" prop="rectifyUploadList">
  32. <div class="snapshotManagement-for-img-box" v-for="(img,imgIndex) in addForm.rectifyUploadList" :key="imgIndex">
  33. <img class="for-img" :src="img.fileUrl" @click="lookImg(addForm.rectifyUploadList,imgIndex)">
  34. <p class="for-del-button el-icon-circle-close" @click="delImg(imgIndex)"></p>
  35. </div>
  36. <el-upload
  37. v-if="addForm.rectifyUploadList.length<6"
  38. style="display: inline-block;overflow: hidden"
  39. class="avatar-uploader"
  40. :action="uploadImgUrl"
  41. :show-file-list="false"
  42. :on-success="(res)=>handleAvatarSuccess('img',res)"
  43. :headers="headers"
  44. :before-upload="(res)=>beforeAvatarUpload('img',res)">
  45. <p class="el-icon-plus up-img-p" style="display: inline-block"></p>
  46. </el-upload>
  47. <p class="up-img-text">支持jpg/png/bmp/gif格式,且不超过2M,最多上传6张</p>
  48. </el-form-item>
  49. <!--<div v-if="addForm.rectifyResult == 0">-->
  50. <!--<el-form-item label="整改方案" prop="rectifyMaterialUrl">-->
  51. <!--<div class="up-file-button" v-if="!addForm.rectifyMaterialUrl">-->
  52. <!--<el-upload-->
  53. <!--v-if="addForm.rectifyUploadList.length<6"-->
  54. <!--style="display: inline-block;overflow: hidden"-->
  55. <!--class="avatar-uploader"-->
  56. <!--:action="uploadImgUrl"-->
  57. <!--:show-file-list="false"-->
  58. <!--:on-success="(res)=>handleAvatarSuccess('file',res)"-->
  59. <!--:headers="headers"-->
  60. <!--:before-upload="(res)=>beforeAvatarUpload('file',res)">-->
  61. <!--<p class="up-file-min-button">+ 上传文件</p>-->
  62. <!--</el-upload>-->
  63. <!--<p class="up-file-text">支持docx/xlsx/pdf格式文件</p>-->
  64. <!--</div>-->
  65. <!--<div class="up-file-box" v-if="addForm.rectifyMaterialUrl">-->
  66. <!--<img src="@/assets/ZDimages/safetyCheck/icon_dr_wj.png">-->
  67. <!--<p @click="lookFile">{{addForm.rectifyMaterialName}}</p>-->
  68. <!--<p class="el-icon-close" @click="delFileButton"></p>-->
  69. <!--</div>-->
  70. <!--</el-form-item>-->
  71. <!--</div>-->
  72. </div>
  73. </el-form>
  74. </div>
  75. </template>
  76. <script>
  77. import { getToken } from "@/utils/auth";
  78. export default {
  79. name: 'rectificationComponent',
  80. props:{
  81. rectificationComponentPropsData:{},
  82. },
  83. data(){
  84. return{
  85. loading:false,
  86. //上传相关
  87. uploadImgUrl: this.uploadUrl(), // 上传的图片服务器地址
  88. headers: {
  89. Authorization:getToken(),
  90. },
  91. //图片组件数据
  92. fullScreenViewProps:[],
  93. itemShowType:true,
  94. addForm:{
  95. rectifyResult:null,
  96. rectifyMeasure:'',
  97. rectifyUploadList:[],
  98. rectifyMaterialUrl:'',
  99. },
  100. rules:{
  101. rectifyResult: [
  102. { required: true, message: "请选择整改结果", trigger: "blur" },
  103. ],
  104. rectifyMeasure: [
  105. { required: true, message: "请输入整改措施", trigger: "blur" },
  106. { required: true, message: "请输入整改措施", validator: this.spaceJudgment, trigger: "blur" }
  107. ],
  108. rectifyUploadList: [
  109. { required: true, message: "请上传现场照片", trigger: "blur" },
  110. ],
  111. rectifyMaterialUrl: [
  112. { required: true, message: "请上传整改方案", trigger: "blur" },
  113. ],
  114. },
  115. upDataName:'',
  116. }
  117. },
  118. created(){
  119. },
  120. mounted(){
  121. },
  122. methods:{
  123. submitData(){
  124. return new Promise(resolve=>{
  125. this.$refs["addForm"].validate(valid => {
  126. if (valid) {
  127. resolve(this.addForm)
  128. }
  129. })
  130. })
  131. },
  132. //子项展开隐藏按钮
  133. itemShowButton(){
  134. this.$set(this,'itemShowType',!this.itemShowType);
  135. },
  136. //整改选择按钮
  137. checkButton(type){
  138. if(this.addForm.rectifyResult != type){
  139. this.$set(this.addForm,'rectifyResult',type);
  140. this.$forceUpdate();
  141. }
  142. },
  143. /*==========上传相关==========*/
  144. handleAvatarSuccess(srt,res) {
  145. this.$set(this,'loading',false);
  146. if(srt == 'img'){
  147. if(this.addForm.rectifyUploadList.length>5){
  148. this.msgError('最多只可上传6张')
  149. return
  150. }
  151. let suffixName= this.upDataName.split('.')[this.upDataName.split('.').length - 2]
  152. //判断文件名中是否有逗号和分号
  153. if(suffixName.indexOf(',')==-1 && suffixName.indexOf(';')==-1){
  154. }else{
  155. this.msgError('文件名里包含逗号或分号,请修改后重新上传!')
  156. return
  157. }
  158. let obj ={
  159. fileName:this.upDataName,
  160. fileUrl:res.data.url,
  161. fileType:2,
  162. };
  163. this.addForm.rectifyUploadList.push(obj);
  164. } else if(srt == 'file'){
  165. this.$set(this,'loading',false);
  166. let suffixName= this.upDataName.split('.')[this.upDataName.split('.').length - 2]
  167. //判断文件名中是否有逗号和分号
  168. if(suffixName.indexOf(',')==-1 && suffixName.indexOf(';')==-1){
  169. }else{
  170. this.msgError('文件名里包含逗号或分号,请修改后重新上传!')
  171. return
  172. }
  173. this.$set(this.addForm,'rectifyMaterialUrl',res.data.url);
  174. this.$set(this.addForm,'rectifyMaterialName',suffixName);
  175. }
  176. this.$forceUpdate()
  177. },
  178. beforeAvatarUpload(srt,file) {
  179. if(srt == 'img'){
  180. if(this.addForm.rectifyUploadList.length>5){
  181. this.msgError('最多只可上传6张')
  182. return false
  183. }
  184. let type = false;
  185. if (file.type == 'image/png' || file.type == 'image/jpeg' || file.type == 'image/jpg' || file.type == 'image/gif' || file.type == 'image/bmp') {
  186. if(file.size> 2100000){
  187. this.msgError('上传图片大小不能超过2M')
  188. return false
  189. }
  190. this.$set(this,'loading',true);
  191. this.upDataName = file.name;
  192. type = true;
  193. }else{
  194. this.msgError('仅支持jpeg/jpg/png/bmp/gif格式')
  195. type = false;
  196. }
  197. return type;
  198. }else if(srt == 'file'){
  199. let type = false;
  200. let num = 0;
  201. for(let i=0;i<file.name.length;i++){
  202. if(file.name[i] == '.'){
  203. num++
  204. }
  205. }
  206. if(num != 1){
  207. this.msgError('文件名称不能包含 " . "')
  208. return false
  209. }
  210. if (file.type == 'application/pdf' || file.type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' || file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
  211. if(file.size> 5250000){
  212. this.msgError('上传大小不能超过5M')
  213. return false
  214. }
  215. this.$set(this,'loading',true);
  216. this.upDataName = file.name;
  217. type = true;
  218. }else{
  219. this.msgError('只能上传docx/xlsx/pdf格式');
  220. type = false;
  221. }
  222. return type;
  223. }
  224. },
  225. //删除文件
  226. delFileButton(){
  227. this.$set(this.addForm,'rectifyMaterialUrl','');
  228. this.$set(this.addForm,'rectifyMaterialName','');
  229. },
  230. //删除照片
  231. delImg(imgIndex){
  232. this.addForm.rectifyUploadList.splice(imgIndex,1);
  233. },
  234. //照片预览
  235. lookImg(list,index){
  236. this.$parent.fullScreenViewClick(list,index);
  237. },
  238. //文件预览
  239. lookFile(){
  240. let obj = {
  241. fileName:this.addForm.rectifyMaterialName,
  242. fileUrl:this.addForm.rectifyMaterialUrl,
  243. };
  244. this.$parent.fullScreenFileLookClick(obj);
  245. },
  246. },
  247. }
  248. </script>
  249. <style scoped lang="scss">
  250. .initiateInspect-rectificationComponent{
  251. .add-form-box{
  252. border:1px solid #E0E0E0;
  253. border-top:none;
  254. .content-right-title-min-p{
  255. line-height:40px;
  256. background: #F5F5F5;
  257. padding-left:23px;
  258. border-top:1px solid #E0E0E0;
  259. border-bottom:1px solid #E0E0E0;
  260. span{
  261. float: right;
  262. font-size:20px;
  263. line-height:40px;
  264. margin-right:20px;
  265. cursor: pointer;
  266. }
  267. }
  268. .right-text-box{
  269. display: flex;
  270. .right-text-name-p{
  271. width:90px;
  272. line-height:40px;
  273. text-align: right;
  274. margin-right:14px;
  275. font-size:16px;
  276. }
  277. .right-text-title-box{
  278. font-size:14px;
  279. width:300px;
  280. padding:10px 20px;
  281. background-color: #f5f5f5;
  282. border: 1px solid #E0E0E0;
  283. border-radius: 4px 4px 4px 4px;
  284. p{
  285. line-height:20px;
  286. /*单行省略号*/
  287. display:block;
  288. overflow:hidden;
  289. text-overflow:ellipsis;
  290. white-space:nowrap;
  291. }
  292. }
  293. .right-text-text-box{
  294. font-size:14px;
  295. width:300px;
  296. padding:10px 20px;
  297. background-color: #f5f5f5;
  298. border: 1px solid #E0E0E0;
  299. border-radius: 4px 4px 4px 4px;
  300. p{
  301. line-height:20px;
  302. }
  303. }
  304. .right-no-check-box{
  305. height:40px;
  306. margin-right:20px;
  307. overflow: hidden;
  308. display: flex;
  309. cursor: pointer;
  310. div{
  311. margin:13px 0 0;
  312. width:16px;
  313. height:16px;
  314. border:1px solid #999;
  315. border-radius:50%;
  316. p{
  317. height:10px;
  318. width:10px;
  319. margin:2px;
  320. border-radius:50%;
  321. }
  322. }
  323. .right-check-title-p{
  324. margin-left:8px;
  325. height:40px;
  326. line-height:40px;
  327. color:#333;
  328. font-size:16px;
  329. }
  330. }
  331. .right-check-box{
  332. height:40px;
  333. margin-right:20px;
  334. overflow: hidden;
  335. display: flex;
  336. cursor: pointer;
  337. div{
  338. margin:13px 0 0;
  339. width:16px;
  340. height:16px;
  341. border:1px solid #0183FA;
  342. border-radius:50%;
  343. p{
  344. height:10px;
  345. width:10px;
  346. margin:2px;
  347. border-radius:50%;
  348. background-color: #0183FA;
  349. }
  350. }
  351. .right-check-title-p{
  352. margin-left:8px;
  353. height:40px;
  354. line-height:40px;
  355. color:#0183FA;
  356. font-size:16px;
  357. }
  358. }
  359. img{
  360. cursor: pointer;
  361. display: block;
  362. width:100px;
  363. height:100px;
  364. margin-right:20px;
  365. }
  366. }
  367. ::v-deep .snapshotManagement-for-img-box{
  368. width:80px;
  369. height:80px;
  370. border-radius:4px;
  371. display: inline-block;
  372. overflow: hidden;
  373. margin-right:20px;
  374. position: relative;
  375. .for-img{
  376. width:80px;
  377. height:80px;
  378. display: inline-block;
  379. overflow: hidden;
  380. }
  381. .for-del-button{
  382. background: rgba(0,0,0,0.7);
  383. width:20px;
  384. height:20px;
  385. line-height: 20px;
  386. text-align: center;
  387. color:#fff;
  388. border-bottom-left-radius:4px;
  389. cursor: pointer;
  390. position: absolute;
  391. top:0;
  392. right:0;
  393. }
  394. }
  395. ::v-deep .up-img-p{
  396. height:80px;
  397. width:80px;
  398. line-height:80px;
  399. text-align: center;
  400. font-size:16px;
  401. border-radius:4px;
  402. border:1px dashed #E0E0E0;
  403. }
  404. .up-img-text{
  405. line-height:40px;
  406. font-size:14px;
  407. color:#999;
  408. }
  409. .up-file-button{
  410. display: flex;
  411. }
  412. .up-file-min-button{
  413. border:1px solid #0183FA;
  414. color:#0183FA;
  415. border-radius:4px;
  416. height:30px;
  417. line-height:30px;
  418. width:100px;
  419. text-align: center;
  420. margin:5px 20px 0 0;
  421. }
  422. .up-file-text{
  423. color:#999;
  424. height:40px;
  425. line-height:40px;
  426. }
  427. .up-file-box{
  428. display: flex;
  429. height:40px;
  430. img{
  431. margin-top:12px;
  432. width:16px;
  433. height:16px;
  434. display: block;
  435. }
  436. p:nth-child(2){
  437. line-height:40px;
  438. font-size:14px;
  439. margin:0 30px 0 15px;
  440. cursor: pointer;
  441. }
  442. p:nth-child(3){
  443. cursor: pointer;
  444. color:red;
  445. font-size:16px;
  446. height:16px;
  447. width:16px;
  448. line-height:16px;
  449. margin-top:12px;
  450. text-align: center
  451. }
  452. }
  453. }
  454. }
  455. </style>