addPage.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. <template>
  2. <div class="inspectionManagement-addPage" v-loading.fullscreen.lock="loading">
  3. <div class="title-max-box">
  4. <p class="title-p">{{addPageTitle}}</p>
  5. <p class="title-button add-button-one-90" @click="outButton">返回</p>
  6. <img class="position-img" v-if="addForm.checkRange == 1" src="@/assets/ZDimages/safetyCheck/icon_xyxc_qx.png">
  7. <img class="position-img" v-if="addForm.checkRange == 2" src="@/assets/ZDimages/safetyCheck/icon_xyxc_xy.png">
  8. <img class="position-img" v-if="addForm.checkRange == 3" src="@/assets/ZDimages/safetyCheck/icon_xyxc_sys.png">
  9. </div>
  10. <div class="content-max-box scrollbar-box">
  11. <el-form ref="addForm" :model="addForm" :rules="rules" label-width="82px">
  12. <div class="top-form-box">
  13. <div class="top-form-left-box">
  14. <el-form-item label="计划标题" prop="title">
  15. <el-input disabled v-model="addForm.title" placeholder="未填写" style="width: 690px"/>
  16. </el-form-item>
  17. <div style="display: flex">
  18. <el-form-item label="学院" prop="subjectName">
  19. <el-input disabled v-model="addForm.subjectName" placeholder="未填写" style="width: 300px"/>
  20. </el-form-item>
  21. <el-form-item label="实验室" prop="subjectName" label-width="110px">
  22. <el-input disabled v-model="addForm.subjectName" placeholder="未填写" style="width: 280px"/>
  23. </el-form-item>
  24. </div>
  25. <el-form-item label="检查要求" prop="checkDemand">
  26. <p style="background-color: #f5f5f5;color:#333;border-radius:4px;width:690px;padding:10px 15px;font-size:14px;line-height:20px;">{{addForm.checkDemand}}</p>
  27. <!--<el-input disabled v-model="addForm.checkDemand" placeholder="未填写" style="width: 690px"/>-->
  28. </el-form-item>
  29. <el-form-item label="检查结果" prop="checkResult">
  30. <el-select v-model="addForm.checkResult" placeholder="请选择检查结果" style="width: 690px">
  31. <el-option :key="0" label="不符合" :value="0"></el-option>
  32. <el-option :key="1" label="符合" :value="1"></el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="整改通知" prop="rectifyNotice" v-if="addForm.checkResult === 0">
  36. <el-radio-group v-model="addForm.rectifyNotice" style="margin-top:5px;">
  37. <el-radio :label="1">整改告知书</el-radio>
  38. <el-radio :label="2">整改通知书</el-radio>
  39. </el-radio-group>
  40. </el-form-item>
  41. </div>
  42. <div class="top-form-right-box">
  43. <el-form-item label="检查类型" prop="checkType">
  44. <p style="background-color: #f5f5f5;width:450px;padding:0 15px;line-height:40px;border-radius:4px;">{{addForm.checkType==1?'校院巡查':(addForm.checkType==2?'实验室自查':'')}}</p>
  45. </el-form-item>
  46. <el-form-item label="楼栋" prop="buildName">
  47. <el-input disabled v-model="addForm.buildName" placeholder="未填写" maxLength="10" style="width: 450px"/>
  48. </el-form-item>
  49. <el-form-item :label="addForm.checkType==1?'计划周期':(addForm.checkType==2?'任务周期':'')" prop="data9">
  50. <el-input disabled v-model="addForm.cycleStartTime+' 至 '+addForm.cycleEndTime" placeholder="未填写" maxLength="10" style="width: 450px"/>
  51. </el-form-item>
  52. <el-form-item label="整改期限" prop="rectifyDeadline" v-if="addForm.checkResult === 0">
  53. <el-date-picker
  54. style="width: 450px"
  55. v-model="addForm.rectifyDeadline"
  56. type="date"
  57. :picker-options="pickerOptions"
  58. :clearable="false"
  59. placeholder="选择整改期限">
  60. </el-date-picker>
  61. </el-form-item>
  62. </div>
  63. </div>
  64. <div class="bottom-form-box" v-if="addForm.checkResult === 0">
  65. <div class="bottom-form-title-box">
  66. <p>不符合项</p>
  67. <p>隐患数:{{addForm.checkHazardDtoList.length}}</p>
  68. </div>
  69. <div class="for-max-big-box" v-for="(item,index) in addForm.checkHazardDtoList" :key="index">
  70. <div class="for-title-box">
  71. <p class="for-title-p">第{{index+1}}隐患项</p>
  72. <div class="for-del-box">
  73. <p class="el-icon-delete"></p>
  74. <p @click="delCheckHazardDtoList(index)">删除此项</p>
  75. </div>
  76. <div class="for-button-box" @click="dataLookButton(item)">
  77. <p :class="item.lookType?'el-icon-arrow-up':'el-icon-arrow-down'"></p>
  78. <p>{{item.lookType?'收起':'展开'}}</p>
  79. </div>
  80. </div>
  81. <div class="for-big-box" v-if="item.lookType">
  82. <el-form-item label="隐患等级" :prop="'checkHazardDtoList.'+index+'.hazardLevel'" :rules="rules.hazardLevel" label-width="123px">
  83. <el-select v-model="item.hazardLevel" clearable placeholder="请选择隐患等级" style="width: 408px">
  84. <el-option :key="2" label="一般隐患" :value="2"></el-option>
  85. <el-option :key="1" label="重大隐患" :value="1"></el-option>
  86. <el-option :key="3" label="管理问题" :value="3"></el-option>
  87. </el-select>
  88. </el-form-item>
  89. <el-form-item label="检查项目" :prop="'checkHazardDtoList.'+index+'.hazardCheckPro'" :rules="rules.hazardCheckPro" label-width="123px">
  90. <el-cascader
  91. @change="(val)=>cascaderChange(val,index)"
  92. v-model="item.hazardCheckPro"
  93. style="width: 898px"
  94. placeholder="请选择检查项"
  95. :options="options"
  96. :props="{ checkStrictly: false, value: 'id', label: 'labelName',emitPath:false }"
  97. filterable></el-cascader>
  98. <p class="hazard-check-count-p" v-if="hazardCheckCount>0">此检查项在当前实验室累计出现 <span>{{hazardCheckCount}}</span> 次隐患</p>
  99. </el-form-item>
  100. <el-form-item label="检查要点" label-width="123px">
  101. <el-input
  102. style="width: 898px"
  103. type="textarea"
  104. :autosize="{ minRows: 6, maxRows: 6}"
  105. placeholder="请输入检查要点"
  106. resize="none"
  107. maxlength="100"
  108. show-word-limit
  109. v-model="item.hazardCheckPoint">
  110. </el-input>
  111. </el-form-item>
  112. <el-form-item label="隐患描述" :prop="'checkHazardDtoList.'+index+'.hazardDescribe'" :rules="rules.hazardDescribe" label-width="123px">
  113. <el-input
  114. style="width: 898px"
  115. type="textarea"
  116. :autosize="{ minRows: 4, maxRows: 4}"
  117. placeholder="请输入隐患描述"
  118. resize="none"
  119. maxlength="100"
  120. show-word-limit
  121. v-model="item.hazardDescribe">
  122. </el-input>
  123. </el-form-item>
  124. <el-form-item label="隐患照片" :prop="'checkHazardDtoList.'+index+'.uploadDtoList'" :rules="rules.uploadDtoList" label-width="123px">
  125. <div class="for-img-box" v-for="(img,imgIndex) in item.uploadDtoList" :key="imgIndex">
  126. <img class="for-img" :src="img.fileUrl" @click="lookImg(item.uploadDtoList,imgIndex)">
  127. <p class="for-del-button el-icon-circle-close" @click="delImg(index,imgIndex)"></p>
  128. </div>
  129. <el-upload
  130. style="display: inline-block;overflow: hidden"
  131. v-if="item.uploadDtoList.length<5"
  132. class="avatar-uploader"
  133. :action="uploadImgUrl"
  134. :show-file-list="false"
  135. :on-success="(res)=>handleAvatarSuccess(res,item)"
  136. :headers="headers"
  137. :before-upload="(res)=>beforeAvatarUpload(res,item)">
  138. <p class="el-icon-plus up-img-p" style="display: inline-block"></p>
  139. </el-upload>
  140. </el-form-item>
  141. <el-form-item label="" label-width="123px" style="margin-bottom:40px;">
  142. <p>支持jpg/png/bmp/gif格式,且不超过2M,最多上传5张</p>
  143. </el-form-item>
  144. </div>
  145. </div>
  146. <p class="add-bottom-button" @click="addObject">+新增隐患检查项</p>
  147. </div>
  148. </el-form>
  149. </div>
  150. <div class="bottom-button-max-box">
  151. <p></p>
  152. <p class="reset-button-one" @click="outButton">取消</p>
  153. <p class="add-button-two-90" @click="upDataButton(1)">保存</p>
  154. <p class="inquire-button-one" @click="upDataButton(2)">提交</p>
  155. </div>
  156. <lookImgDialog ref="lookImgDialog"></lookImgDialog>
  157. </div>
  158. </template>
  159. <script>
  160. import { getToken } from "@/utils/auth";
  161. import lookImgDialog from '@/components/lookImgDialog/lookImgDialog.vue'
  162. import { findCheckManage,checkOptionList,checkManageUpdate,countHazardNum } from '@/api/safetyCheck/index'
  163. export default {
  164. name: 'addPage',
  165. props:{
  166. propsAddData:{},
  167. },
  168. components: {
  169. lookImgDialog,
  170. },
  171. data(){
  172. return{
  173. loading:false,
  174. uploadImgUrl: this.uploadUrl(), // 上传的图片服务器地址
  175. headers: {
  176. Authorization: "Bearer " + getToken(),
  177. },
  178. //期限时间
  179. pickerOptions: {
  180. disabledDate(time) {
  181. return time.getTime() < Date.now() - 8.64e7;//如果没有后面的-8.64e7就是不可以选择今天的
  182. }
  183. },
  184. addPageTitle:"",
  185. //新增-编辑
  186. options:[],
  187. addForm:{},
  188. //上传用名称保存
  189. upDataName:"",
  190. // 表单校验
  191. rules: {
  192. checkResult: [
  193. { required: true, message: "请选择检查结果", trigger: "blur" },
  194. ],
  195. rectifyNotice: [
  196. { required: true, message: "请选择整改通知", trigger: "blur" },
  197. ],
  198. rectifyDeadline: [
  199. { required: true, message: "请选择整改期限", trigger: "blur" },
  200. ],
  201. hazardLevel: [
  202. { required: true, message: "请选择隐患等级", trigger: "blur" },
  203. ],
  204. hazardCheckPro: [
  205. { required: true, message: "请选择检查项目", trigger: "blur" },
  206. ],
  207. hazardDescribe: [
  208. { required: true, message: "请输入隐患描述", trigger: "blur" },
  209. { required: true, message: "请输入隐患描述", validator: this.spaceJudgment, trigger: "blur" },
  210. ],
  211. uploadDtoList: [
  212. { required: true, message: "请上传隐患照片", trigger: "blur" },
  213. ],
  214. },
  215. //隐患发生次数
  216. hazardCheckCount:0,
  217. }
  218. },
  219. created(){
  220. this.$set(this,'addPageTitle',this.propsAddData.title);
  221. this.checkOptionList();
  222. this.findCheckManage();
  223. },
  224. mounted(){},
  225. methods:{
  226. //保存/提交按钮
  227. upDataButton(type){
  228. this.$refs["addForm"].validate(valid => {
  229. if (valid) {
  230. let obj = JSON.parse(JSON.stringify(this.addForm));
  231. if(obj.checkResult === 0){
  232. if(!obj.checkHazardDtoList[0]){
  233. this.msgError('请添加隐患检查项')
  234. return
  235. }
  236. for(let i=0;i<obj.checkHazardDtoList.length;i++){
  237. delete obj.checkHazardDtoList[i].lookType
  238. }
  239. obj.dangerNum = obj.checkHazardDtoList.length
  240. }else{
  241. obj.checkHazardDtoList = [];
  242. }
  243. obj.manageStatus = type
  244. checkManageUpdate(obj).then(response => {
  245. this.msgSuccess(response.msg);
  246. this.$parent.goAddPage(4);
  247. });
  248. }
  249. })
  250. },
  251. //查询详情
  252. findCheckManage(){
  253. findCheckManage({id:this.propsAddData.id}).then(response => {
  254. response.data.checkResult = response.data.checkResult === 0 || response.data.checkResult === 1?response.data.checkResult:"";
  255. response.data.rectifyNotice = response.data.rectifyNotice?response.data.rectifyNotice:"";
  256. response.data.rectifyDeadline = response.data.rectifyDeadline?response.data.rectifyDeadline:"";
  257. for(let i=0;i<response.data.checkHazardDtoList.length;i++){
  258. response.data.checkHazardDtoList[i].lookType = true;
  259. }
  260. this.$set(this,'addForm',response.data);
  261. });
  262. },
  263. //返回事件
  264. outButton(){
  265. this.$parent.goAddPage(1);
  266. },
  267. // 删除图片
  268. delImg(index,imgIndex){
  269. this.addForm.checkHazardDtoList[index].uploadDtoList.splice(imgIndex,1);
  270. },
  271. //收起/展开
  272. dataLookButton(item){
  273. item.lookType = !item.lookType
  274. },
  275. //新增检查
  276. addObject(){
  277. if(this.addForm.checkHazardDtoList.length<10){
  278. let obj = {
  279. hazardCheckCode:'',
  280. hazardCheckName:'',
  281. hazardCheckPoint:'',
  282. hazardCheckPro:'',
  283. hazardDescribe:'',
  284. hazardLevel:'',
  285. lookType:true,
  286. uploadDtoList:[],
  287. };
  288. this.addForm.checkHazardDtoList.push(obj);
  289. }
  290. },
  291. //删除检查项
  292. delCheckHazardDtoList(index){
  293. let self = this;
  294. this.$confirm('是否确认删除?', "警告", {
  295. confirmButtonText: "确定",
  296. cancelButtonText: "取消",
  297. type: "warning"
  298. }).then(function() {
  299. self.addForm.checkHazardDtoList.splice(index,1);
  300. }).then(() => {
  301. }).catch(() => {});
  302. },
  303. //检查项选中
  304. cascaderChange(val,index){
  305. let obj = this.getCascaderDataQuery(val,this.options);
  306. this.$set(this.addForm.checkHazardDtoList[index],'hazardCheckCode',obj.code);
  307. this.$set(this.addForm.checkHazardDtoList[index],'hazardCheckName',obj.name);
  308. countHazardNum({subId:this.addForm.subId, hazardCheckPro:val}).then( response => {
  309. this.$set(this,'hazardCheckCount',response.data);
  310. })
  311. },
  312. //查看图片
  313. lookImg(list,index){
  314. for(let i=0;i<list.length;i++){
  315. list[i].name = list[i].fileName;
  316. list[i].url = list[i].fileUrl;
  317. }
  318. this.$refs.lookImgDialog.lookImgDialogOpen(1,list,index);
  319. },
  320. /*==========上传相关==========*/
  321. handleAvatarSuccess(res,item) {
  322. this.$set(this,'loading',false);
  323. if(item.uploadDtoList.length>4){
  324. this.msgError('最多只可上传5张')
  325. return
  326. }
  327. let suffixName= this.upDataName.split('.')[this.upDataName.split('.').length - 2]
  328. //判断文件名中是否有逗号和分号
  329. if(suffixName.indexOf(',')==-1 && suffixName.indexOf(';')==-1){
  330. }else{
  331. this.msgError('文件名里包含逗号或分号,请修改后重新上传!')
  332. return
  333. }
  334. let obj ={
  335. fileName:this.upDataName,
  336. fileUrl:res.data.url,
  337. fileType:2,
  338. source:2,
  339. };
  340. item.uploadDtoList.push(obj);
  341. this.$forceUpdate()
  342. },
  343. beforeAvatarUpload(file,item) {
  344. if(item.uploadDtoList.length>4){
  345. this.msgError('最多只可上传5张')
  346. return false
  347. }
  348. let type = false;
  349. if (file.type == 'image/png' || file.type == 'image/jpeg' || file.type == 'image/gif' || file.type == 'image/bmp') {
  350. if(file.size> 2000000){
  351. this.msgError('上传图片大小不能超过2M')
  352. return false
  353. }
  354. this.$set(this,'loading',true);
  355. this.upDataName = file.name;
  356. type = true;
  357. }else{
  358. this.msgError('仅支持jpg/png/bmp/gif格式')
  359. type = false;
  360. }
  361. return type;
  362. },
  363. //获取检查项
  364. checkOptionList(){
  365. checkOptionList().then( response => {
  366. this.$set(this,'options',response.data);
  367. this.getCascaderData(this.options);
  368. })
  369. },
  370. //联级选择器数据处理
  371. getCascaderData(list){
  372. let self = this;
  373. for(let i=0;i<list.length;i++){
  374. list[i].labelName = list[i].code? list[i].code +' '+ list[i].name:list[i].name
  375. if(list[i].level == 0 || list[i].level == 1 || list[i].level == 2){
  376. self.getCascaderData(list[i].children)
  377. }else{
  378. delete list[i].children
  379. }
  380. }
  381. },
  382. //联级选择器数据查询
  383. getCascaderDataQuery(text,list){
  384. let self = this;
  385. for(let i=0;i<list.length;i++){
  386. if(list[i].id == text){
  387. return list[i]
  388. }else{
  389. if(list[i].children){
  390. let obj = self.getCascaderDataQuery(text,list[i].children)
  391. if(obj){
  392. return obj
  393. }else{
  394. return false
  395. }
  396. }else{
  397. console.log('false = 2')
  398. return false
  399. }
  400. }
  401. }
  402. },
  403. }
  404. }
  405. </script>
  406. <style scoped lang="scss">
  407. .inspectionManagement-addPage{
  408. flex: 1;
  409. display: flex !important;
  410. flex-direction: column;
  411. overflow: hidden;
  412. *{
  413. font-weight:500;
  414. }
  415. .title-max-box{
  416. position: relative;
  417. height:90px;
  418. display: flex;
  419. border-bottom:1px solid #dedede;
  420. .title-p{
  421. flex:1;
  422. color:#0045AF;
  423. margin-left:64px;
  424. line-height:90px;
  425. font-size:16px;
  426. }
  427. .title-button{
  428. width:70px;
  429. margin:24px 31px;
  430. }
  431. .position-img{
  432. width:80px;
  433. height:80px;
  434. position: absolute;
  435. top:0;
  436. left:0;
  437. }
  438. }
  439. .content-max-box{
  440. flex:1;
  441. display: flex;
  442. flex-direction: column;
  443. .top-form-box{
  444. padding:40px 85px 20px;
  445. display: flex;
  446. .top-form-left-box{
  447. min-height:317px;
  448. width:770px;
  449. margin-right:90px;
  450. }
  451. .top-form-right-box{
  452. min-height:317px;
  453. width:534px;
  454. }
  455. }
  456. .bottom-form-box{
  457. .bottom-form-title-box{
  458. background: #F5F5F5;
  459. display: flex;
  460. margin-bottom:31px;
  461. p{
  462. font-size:16px;
  463. line-height:50px;
  464. }
  465. p:nth-child(1){
  466. color:#333;
  467. margin-left:30px;
  468. flex:1;
  469. }
  470. p:nth-child(2){
  471. color:#0183FA;
  472. margin-right:37px;
  473. }
  474. }
  475. .add-bottom-button{
  476. cursor: pointer;
  477. color:#0183FA;
  478. border-radius:4px;
  479. border:1px dashed #0183FA;
  480. width:800px;
  481. line-height:40px;
  482. text-align: center;
  483. font-size:14px;
  484. margin: 20px auto;
  485. }
  486. }
  487. }
  488. .for-max-big-box{
  489. border:1px solid #dedede;
  490. overflow: hidden;
  491. margin:0 81px;
  492. .for-title-box{
  493. display: flex;
  494. background: #F5F5F5;
  495. border-bottom:1px solid #dedede;
  496. line-height:50px;
  497. .for-title-p{
  498. color:#333333;
  499. font-size:16px;
  500. margin-left: 30px;
  501. flex:1;
  502. }
  503. .for-del-box{
  504. color:#0183FA;
  505. margin-left:46px;
  506. cursor: pointer;
  507. display: flex;
  508. p{
  509. font-size:14px;
  510. line-height:50px;
  511. margin-right:8px;
  512. }
  513. }
  514. .for-button-box{
  515. color:#0183FA;
  516. margin-left:46px;
  517. margin-right:43px;
  518. cursor: pointer;
  519. display: flex;
  520. p{
  521. font-size:14px;
  522. line-height:50px;
  523. margin-right:8px;
  524. }
  525. }
  526. }
  527. .for-big-box{
  528. height:540px;
  529. padding-top:27px;
  530. .up-img-p{
  531. height:80px;
  532. width:80px;
  533. line-height:80px;
  534. text-align: center;
  535. font-size:16px;
  536. border-radius:4px;
  537. border:1px dashed #E0E0E0;
  538. }
  539. .for-img-box{
  540. width:80px;
  541. height:80px;
  542. border-radius:4px;
  543. display: inline-block;
  544. overflow: hidden;
  545. margin-right:20px;
  546. position: relative;
  547. .for-img{
  548. width:80px;
  549. height:80px;
  550. display: inline-block;
  551. overflow: hidden;
  552. cursor: pointer;
  553. }
  554. .for-del-button{
  555. background: rgba(0,0,0,0.7);
  556. width:20px;
  557. height:20px;
  558. line-height: 20px;
  559. text-align: center;
  560. color:#fff;
  561. border-bottom-left-radius:4px;
  562. cursor: pointer;
  563. position: absolute;
  564. top:0;
  565. right:0;
  566. }
  567. }
  568. .hazard-check-count-p{
  569. display: inline-block;
  570. margin-left: 20px;
  571. font-size: 14px;
  572. line-height: 40px;
  573. span{
  574. color:#FF0000;
  575. }
  576. }
  577. }
  578. }
  579. .bottom-button-max-box{
  580. height:80px;
  581. display: flex;
  582. border-top:1px solid #dedede;
  583. p{
  584. margin-top:20px;
  585. }
  586. p:nth-child(1){
  587. flex:1;
  588. }
  589. p:nth-child(2){
  590. width:90px;
  591. margin-right:20px;
  592. }
  593. p:nth-child(3){
  594. width:90px;
  595. margin-right:20px;
  596. }
  597. p:nth-child(4){
  598. width:90px;
  599. margin-right:20px;
  600. }
  601. }
  602. }
  603. ::v-deep .is-disabled{
  604. .el-input__inner{
  605. background-color: #f5f5f5;
  606. color: #333;
  607. border-color: #f5f5f5;
  608. cursor:auto;
  609. }
  610. }
  611. </style>