addPage.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  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="collegeName">
  19. <el-input disabled v-model="addForm.collegeName" 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.roomNumber?addForm.subjectName+'-'+addForm.roomNumber: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;min-height:40px;">{{addForm.checkDemand}}<span v-if="!addForm.checkDemand" style="color:#999;">未输入</span></p>
  27. </el-form-item>
  28. <el-form-item label="检查类型" prop="checkCategory">
  29. <p style="background-color: #f5f5f5;width:690px;padding:0 15px;line-height:40px;border-radius:4px;">{{addForm.checkCategory==1?'综合检查':(addForm.checkCategory==2?'专项检查':'')}}</p>
  30. </el-form-item>
  31. <el-form-item label="检查结果" prop="checkResult" v-if="addForm.checkCategory==1">
  32. <el-select v-model="addForm.checkResult" @change="checkResultChange" placeholder="请选择检查结果" style="width: 690px">
  33. <el-option :key="0" label="不符合" :value="0"></el-option>
  34. <el-option :key="1" label="符合" :value="1"></el-option>
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="整改通知" prop="rectifyNotice" v-if="addForm.checkResult === 0 || addForm.checkCategory==2">
  38. <el-radio-group v-model="addForm.rectifyNotice" style="margin-top:5px;">
  39. <el-radio :label="1">整改告知书</el-radio>
  40. <el-radio :label="2">整改通知书</el-radio>
  41. </el-radio-group>
  42. </el-form-item>
  43. </div>
  44. <div class="top-form-right-box">
  45. <el-form-item label="检查组织" prop="checkType">
  46. <p style="background-color: #f5f5f5;width:450px;padding:0 15px;line-height:40px;border-radius:4px;">{{addForm.checkType==1?'校院巡查':(addForm.checkType==2?'实验室自查':'')}}</p>
  47. </el-form-item>
  48. <el-form-item label="楼栋" prop="buildName">
  49. <el-input disabled v-model="addForm.buildName" placeholder="未填写" maxLength="10" style="width: 450px"/>
  50. </el-form-item>
  51. <el-form-item :label="addForm.checkType==1?'计划周期':(addForm.checkType==2?'任务周期':'')" prop="data9">
  52. <el-input disabled v-model="addForm.cycleStartTime+' 至 '+addForm.cycleEndTime" placeholder="未填写" maxLength="10" style="width: 450px"/>
  53. </el-form-item>
  54. <el-form-item label="整改期限" prop="rectifyDeadline" v-if="addForm.checkResult === 0 || addForm.checkCategory==2">
  55. <el-date-picker
  56. style="width: 450px"
  57. v-model="addForm.rectifyDeadline"
  58. type="date"
  59. value-format="yyyy-MM-dd"
  60. :picker-options="pickerOptions"
  61. :clearable="false"
  62. placeholder="选择整改期限">
  63. </el-date-picker>
  64. </el-form-item>
  65. </div>
  66. </div>
  67. <!--综合检查-->
  68. <div class="bottom-form-box" v-if="addForm.checkResult === 0 && addForm.checkCategory==1">
  69. <div class="bottom-form-title-box">
  70. <p>不符合项</p>
  71. <p>隐患数:{{addForm.checkHazardDtoList.length}}</p>
  72. </div>
  73. <div class="for-max-big-box" v-for="(item,index) in addForm.checkHazardDtoList" :key="index">
  74. <div class="for-title-box">
  75. <p class="for-title-p">第{{index+1}}隐患项</p>
  76. <div class="for-del-box">
  77. <p class="el-icon-delete"></p>
  78. <p @click="delCheckHazardDtoList(index)">删除此项</p>
  79. </div>
  80. <div class="for-button-box" @click="dataLookButton(item)">
  81. <p :class="item.lookType?'el-icon-arrow-up':'el-icon-arrow-down'"></p>
  82. <p>{{item.lookType?'收起':'展开'}}</p>
  83. </div>
  84. </div>
  85. <div class="for-big-box" v-if="item.lookType">
  86. <el-form-item label="隐患等级" :prop="'checkHazardDtoList.'+index+'.hazardLevel'" :rules="rules.hazardLevel" label-width="123px">
  87. <el-select v-model="item.hazardLevel" clearable placeholder="请选择隐患等级" style="width: 408px">
  88. <el-option :key="2" label="一般隐患" :value="2"></el-option>
  89. <el-option :key="1" label="重大隐患" :value="1"></el-option>
  90. <el-option :key="3" label="管理问题" :value="3"></el-option>
  91. </el-select>
  92. </el-form-item>
  93. <el-form-item label="检查项目" :prop="'checkHazardDtoList.'+index+'.hazardCheckPro'" :rules="rules.hazardCheckPro" label-width="123px">
  94. <el-cascader
  95. @change="(val)=>cascaderChange(val,'',index)"
  96. v-model="item.hazardCheckPro"
  97. style="width: 898px"
  98. placeholder="请选择检查项"
  99. :options="options"
  100. :props="{ checkStrictly: false, value: 'id', label: 'labelName',emitPath:false }"
  101. filterable>
  102. <template slot-scope="{data}">
  103. <el-tooltip :content="data.labelName" v-if="data.labelName.length>22">
  104. <p style="max-width:300px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;">{{data.labelName}}</p>
  105. </el-tooltip>
  106. <p v-else style="max-width:300px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;">{{data.labelName}}</p>
  107. </template>
  108. </el-cascader>
  109. <p class="hazard-check-count-p" v-if="hazardCheckCount>0">此检查项在当前实验室累计出现 <span>{{hazardCheckCount}}</span> 次隐患</p>
  110. </el-form-item>
  111. <el-form-item label="检查要点" label-width="123px">
  112. <el-input
  113. style="width: 898px"
  114. type="textarea"
  115. :autosize="{ minRows: 6, maxRows: 6}"
  116. placeholder="未查到此项检查要点,可在此输入添加"
  117. resize="none"
  118. maxlength="300"
  119. show-word-limit
  120. v-model="item.hazardCheckPoint">
  121. </el-input>
  122. </el-form-item>
  123. <el-form-item label="隐患描述" :prop="'checkHazardDtoList.'+index+'.hazardDescribe'" :rules="rules.hazardDescribe" label-width="123px">
  124. <el-input
  125. style="width: 898px"
  126. type="textarea"
  127. :autosize="{ minRows: 4, maxRows: 4}"
  128. placeholder="请输入隐患描述"
  129. resize="none"
  130. maxlength="100"
  131. show-word-limit
  132. v-model="item.hazardDescribe">
  133. </el-input>
  134. </el-form-item>
  135. <el-form-item label="隐患照片" :prop="'checkHazardDtoList.'+index+'.uploadDtoList'" :rules="rules.uploadDtoList" label-width="123px">
  136. <div class="for-img-box" v-for="(img,imgIndex) in item.uploadDtoList" :key="imgIndex">
  137. <img class="for-img" :src="img.fileUrl" @click="lookImg(item.uploadDtoList,imgIndex)">
  138. <p class="for-del-button el-icon-circle-close" @click="delImg('',index,imgIndex)"></p>
  139. </div>
  140. <el-upload
  141. style="display: inline-block;overflow: hidden"
  142. v-if="item.uploadDtoList.length<5"
  143. class="avatar-uploader"
  144. :action="uploadImgUrl"
  145. :show-file-list="false"
  146. :on-success="(res)=>handleAvatarSuccess(res,item)"
  147. :headers="headers"
  148. :before-upload="(res)=>beforeAvatarUpload(res,item)">
  149. <p class="el-icon-plus up-img-p" style="display: inline-block"></p>
  150. </el-upload>
  151. </el-form-item>
  152. <el-form-item label="" label-width="123px" style="margin-bottom:40px;">
  153. <p>支持jpg/png/bmp/gif格式,且不超过2M,最多上传5张</p>
  154. </el-form-item>
  155. </div>
  156. </div>
  157. <p class="add-bottom-button" @click="addObject">+新增隐患检查项</p>
  158. </div>
  159. <!--专项检查项-->
  160. <div class="bottom-form-box" v-if="addForm.checkCategory==2">
  161. <div class="bottom-form-title-box">
  162. <p>检查项</p>
  163. <p>检查项:{{addForm.checkHazardInfoVoList.length}}</p>
  164. </div>
  165. <div class="for-max-big-box for-max-big-box-special" v-for="(item,index) in addForm.checkHazardInfoVoList" :key="index">
  166. <div class="for-title-box">
  167. <p class="for-title-p">{{index+1}}、【{{item.hazardName}}-{{item.code}}】专项检查</p>
  168. <div class="for-button-box" @click="dataLookButton(item)">
  169. <p :class="item.lookType?'el-icon-arrow-up':'el-icon-arrow-down'"></p>
  170. <p>{{item.lookType?'收起':'展开'}}</p>
  171. </div>
  172. </div>
  173. <div class="for-big-box for-big-box-special" v-if="item.lookType" v-for="(item2,index2) in item.checkHazardDtoList">
  174. <el-form-item label="检查项目" :prop="'checkHazardInfoVoList.'+index+'.checkHazardDtoList.'+index2+'.hazardCheckPro'" :rules="rules.hazardCheckPro" label-width="123px">
  175. <el-radio-group v-model="item2.checkFlag" style="margin-right: 20px;">
  176. <el-radio :label="1">符合</el-radio>
  177. <el-radio :label="0">不符合</el-radio>
  178. </el-radio-group>
  179. <el-cascader
  180. @change="(val)=>cascaderChange(val,item2,index2)"
  181. v-model="item2.hazardCheckPro"
  182. style="width: 730px"
  183. placeholder="请选择检查项"
  184. :options="options"
  185. :props="{ checkStrictly: false, value: 'id', label: 'labelName',emitPath:false }"
  186. filterable>
  187. <template slot-scope="{data}">
  188. <el-tooltip :content="data.labelName" v-if="data.labelName.length>22">
  189. <p style="max-width:300px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;">{{data.labelName}}</p>
  190. </el-tooltip>
  191. <p v-else style="max-width:300px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;">{{data.labelName}}</p>
  192. </template>
  193. </el-cascader>
  194. <p class="hazard-check-count-p" v-if="hazardCheckCount>0">此检查项在当前实验室累计出现 <span>{{hazardCheckCount}}</span> 次隐患</p>
  195. </el-form-item>
  196. <el-form-item v-if="item2.checkFlag==0" label="隐患等级" :prop="'checkHazardInfoVoList.'+index+'.checkHazardDtoList.'+index2+'.hazardLevel'" :rules="rules.hazardLevel" label-width="123px">
  197. <el-select v-model="item2.hazardLevel" clearable placeholder="请选择隐患等级" style="width: 408px">
  198. <el-option :key="2" label="一般隐患" :value="2"></el-option>
  199. <el-option :key="1" label="重大隐患" :value="1"></el-option>
  200. <el-option :key="3" label="管理问题" :value="3"></el-option>
  201. </el-select>
  202. </el-form-item>
  203. <el-form-item v-if="item2.checkFlag==0" label="隐患描述" label-width="123px">
  204. <el-input
  205. style="width: 898px"
  206. type="textarea"
  207. :autosize="{ minRows: 4, maxRows: 4}"
  208. placeholder="请输入隐患描述"
  209. resize="none"
  210. maxlength="100"
  211. show-word-limit
  212. v-model="item2.hazardDescribe">
  213. </el-input>
  214. </el-form-item>
  215. <el-form-item v-if="item2.checkFlag==0" label="隐患照片" :prop="'checkHazardInfoVoList.'+index+'.checkHazardDtoList.'+index2+'.uploadDtoList'" :rules="rules.uploadDtoList" label-width="123px">
  216. <div class="for-img-box" v-for="(img,imgIndex) in item2.uploadDtoList" :key="imgIndex">
  217. <img class="for-img" :src="img.fileUrl" @click="lookImg(item2.uploadDtoList,imgIndex)">
  218. <p class="for-del-button el-icon-circle-close" @click="delImg(item2,index,imgIndex)"></p>
  219. </div>
  220. <el-upload
  221. v-if="item2.uploadDtoList.length<5"
  222. style="display: inline-block;overflow: hidden"
  223. class="avatar-uploader"
  224. :action="uploadImgUrl"
  225. :show-file-list="false"
  226. :on-success="(res)=>handleAvatarSuccess(res,item2)"
  227. :headers="headers"
  228. :before-upload="(res)=>beforeAvatarUpload(res,item2)">
  229. <p class="el-icon-plus up-img-p" style="display: inline-block"></p>
  230. </el-upload>
  231. </el-form-item>
  232. <el-form-item v-if="item2.checkFlag==0" label="" label-width="123px" style="margin-bottom:40px;color:#999;">
  233. <p>支持jpg/png/bmp/gif格式,且不超过2M,最多上传5张</p>
  234. </el-form-item>
  235. </div>
  236. </div>
  237. </div>
  238. </el-form>
  239. </div>
  240. <div class="bottom-button-max-box">
  241. <p class="null-p"></p>
  242. <p class="reset-button-one" @click="outButton">取消</p>
  243. <p class="add-button-two-90" @click="upDataButton(1)">保存</p>
  244. <p class="inquire-button-one" @click="upDataButton(2)">提交</p>
  245. <p class="null-p"></p>
  246. </div>
  247. <lookImgDialog ref="lookImgDialog"></lookImgDialog>
  248. </div>
  249. </template>
  250. <script>
  251. import { getToken } from "@/utils/auth";
  252. import lookImgDialog from '@/components/lookImgDialog/lookImgDialog.vue'
  253. import { findCheckManage,checkOptionList,checkManageUpdate,countHazardNum } from '@/api/safetyCheck/index'
  254. export default {
  255. name: 'addPage',
  256. props:{
  257. propsAddData:{},
  258. },
  259. components: {
  260. lookImgDialog,
  261. },
  262. data(){
  263. return{
  264. loading:false,
  265. uploadImgUrl: this.uploadUrl(), // 上传的图片服务器地址
  266. headers: {
  267. Authorization: "Bearer " + getToken(),
  268. },
  269. //期限时间
  270. pickerOptions: {
  271. disabledDate(time) {
  272. return time.getTime() < Date.now() - 8.64e7;//如果没有后面的-8.64e7就是不可以选择今天的
  273. }
  274. },
  275. addPageTitle:"",
  276. //新增-编辑
  277. options:[],
  278. addForm:{},
  279. //上传用名称保存
  280. upDataName:"",
  281. // 表单校验
  282. rules: {
  283. checkResult: [
  284. { required: true, message: "请选择检查结果", trigger: "blur" },
  285. ],
  286. rectifyNotice: [
  287. { required: true, message: "请选择整改通知", trigger: "blur" },
  288. ],
  289. rectifyDeadline: [
  290. { required: true, message: "请选择整改期限", trigger: "blur" },
  291. ],
  292. hazardLevel: [
  293. { required: true, message: "请选择隐患等级", trigger: "blur" },
  294. ],
  295. hazardCheckPro: [
  296. { required: true, message: "请选择检查项目", trigger: "blur" },
  297. ],
  298. hazardDescribe: [
  299. { required: true, message: "请输入隐患描述", trigger: "blur" },
  300. { required: true, message: "请输入隐患描述", validator: this.spaceJudgment, trigger: "blur" },
  301. ],
  302. uploadDtoList: [
  303. { required: true, message: "请上传隐患照片", trigger: "blur" },
  304. ],
  305. },
  306. //隐患发生次数
  307. hazardCheckCount:0,
  308. }
  309. },
  310. created(){
  311. this.$set(this,'addPageTitle',this.propsAddData.title);
  312. this.findCheckManage();
  313. },
  314. mounted(){},
  315. methods:{
  316. //保存/提交按钮
  317. upDataButton(type){
  318. this.$refs["addForm"].validate(valid => {
  319. if (valid) {
  320. let obj = JSON.parse(JSON.stringify(this.addForm));
  321. obj.manageStatus = type
  322. if(this.addForm.checkCategory==1){//综合检查
  323. if(obj.checkResult === 0){
  324. if(!obj.checkHazardDtoList[0]){
  325. this.msgError('请添加隐患检查项')
  326. return
  327. }
  328. for(let i=0;i<obj.checkHazardDtoList.length;i++){
  329. obj.checkHazardDtoList[i].checkCategory=this.addForm.checkCategory
  330. delete obj.checkHazardDtoList[i].lookType
  331. }
  332. obj.dangerNum = obj.checkHazardDtoList.length
  333. }else{
  334. obj.checkHazardDtoList = [];
  335. }
  336. }else if(this.addForm.checkCategory==2){//专项检查
  337. let list=[]
  338. let checkFlagList=[];
  339. for(let i=0;i<this.addForm.checkHazardInfoVoList.length;i++){
  340. for(let b=0;b<this.addForm.checkHazardInfoVoList[i].checkHazardDtoList.length;b++){
  341. checkFlagList.push(this.addForm.checkHazardInfoVoList[i].checkHazardDtoList[b].checkFlag)
  342. let obj={
  343. checkFlag:this.addForm.checkHazardInfoVoList[i].checkHazardDtoList[b].checkFlag,
  344. checkCategory:this.addForm.checkHazardInfoVoList[i].checkHazardDtoList[b].checkCategory,
  345. hazardCheckCode:this.addForm.checkHazardInfoVoList[i].checkHazardDtoList[b].hazardCheckCode,
  346. hazardCheckName:this.addForm.checkHazardInfoVoList[i].checkHazardDtoList[b].hazardCheckName,
  347. hazardCheckPro:this.addForm.checkHazardInfoVoList[i].checkHazardDtoList[b].hazardCheckPro,
  348. hazardDescribe:this.addForm.checkHazardInfoVoList[i].checkHazardDtoList[b].hazardDescribe,
  349. hazardLevel:this.addForm.checkHazardInfoVoList[i].checkHazardDtoList[b].hazardLevel,
  350. uploadDtoList:this.addForm.checkHazardInfoVoList[i].checkHazardDtoList[b].uploadDtoList,
  351. code:this.addForm.checkHazardInfoVoList[i].code,
  352. hazardId:this.addForm.checkHazardInfoVoList[i].hazardId,
  353. hazardName:this.addForm.checkHazardInfoVoList[i].hazardName,
  354. hazardTypeMode:this.addForm.checkHazardInfoVoList[i].hazardTypeMode,
  355. hazardTypeModeName:this.addForm.checkHazardInfoVoList[i].hazardTypeModeName,
  356. joinHazardId:this.addForm.checkHazardInfoVoList[i].joinHazardId,
  357. }
  358. list.push(obj)
  359. }
  360. }
  361. if(checkFlagList.every(item=>{return item==1})){//符合
  362. obj.checkResult=1;
  363. }else{//不符合
  364. obj.checkResult=0;
  365. }
  366. obj.checkHazardDtoList=list;
  367. }
  368. checkManageUpdate(obj).then(response => {
  369. this.msgSuccess(response.msg);
  370. this.$parent.goAddPage(4);
  371. });
  372. }
  373. })
  374. },
  375. //查询详情
  376. findCheckManage(){
  377. findCheckManage({id:this.propsAddData.id}).then(response => {
  378. if(response.data.checkCategory==1){//综合检查
  379. response.data.checkResult = response.data.checkResult === 0 || response.data.checkResult === 1?response.data.checkResult:"";
  380. response.data.rectifyNotice = response.data.rectifyNotice?response.data.rectifyNotice:"";
  381. response.data.rectifyDeadline = response.data.rectifyDeadline?response.data.rectifyDeadline:"";
  382. for(let i=0;i<response.data.checkHazardDtoList.length;i++){
  383. response.data.checkHazardDtoList[i].lookType = true;
  384. }
  385. }else if(response.data.checkCategory==2){//专项检查
  386. response.data.rectifyNotice = response.data.rectifyNotice?response.data.rectifyNotice:"";
  387. response.data.rectifyDeadline = response.data.rectifyDeadline?response.data.rectifyDeadline:"";
  388. if(response.data.checkHazardInfoVoList[0]){
  389. response.data.checkHazardInfoVoList.forEach(function(item) {
  390. item.lookType = true;
  391. item.checkHazardDtoList.forEach(function(item2) {
  392. item2.hazardCheckCode=item2.code
  393. })
  394. })
  395. }
  396. }
  397. this.$set(this,'addForm',response.data);
  398. this.checkOptionList();//获取检查项
  399. });
  400. },
  401. //返回事件
  402. outButton(){
  403. this.$parent.goAddPage(1);
  404. },
  405. // 删除图片
  406. delImg(item,index,imgIndex){
  407. console.log(item)
  408. if(this.addForm.checkCategory==1){//综合检查
  409. this.addForm.checkHazardDtoList[index].uploadDtoList.splice(imgIndex,1);
  410. }else if(this.addForm.checkCategory==2){//专项检查
  411. item.uploadDtoList.splice(imgIndex,1);
  412. }
  413. },
  414. //收起/展开
  415. dataLookButton(item){
  416. item.lookType = !item.lookType
  417. },
  418. //检查结果选中
  419. checkResultChange(val){
  420. if(val == 0){
  421. //不符合时如果没有检查项则写入一条
  422. if(!this.addForm.checkHazardDtoList[0]){
  423. this.addObject();
  424. }
  425. }
  426. },
  427. //新增检查
  428. addObject(){
  429. if(this.addForm.checkHazardDtoList.length<10){
  430. let obj = {
  431. hazardCheckCode:'',
  432. hazardCheckName:'',
  433. hazardCheckPoint:'',
  434. hazardCheckPro:'',
  435. hazardDescribe:'',
  436. hazardLevel:'',
  437. lookType:true,
  438. uploadDtoList:[],
  439. };
  440. this.addForm.checkHazardDtoList.push(obj);
  441. }
  442. },
  443. //删除检查项
  444. delCheckHazardDtoList(index){
  445. let self = this;
  446. this.$confirm('是否确认删除?', "警告", {
  447. confirmButtonText: "确定",
  448. cancelButtonText: "取消",
  449. type: "warning"
  450. }).then(function() {
  451. self.addForm.checkHazardDtoList.splice(index,1);
  452. }).then(() => {
  453. }).catch(() => {});
  454. },
  455. //检查项选中
  456. cascaderChange(val,item,index){
  457. let obj = this.getCascaderDataQuery(val,this.options);
  458. console.log(item.hazardCheckPro)
  459. if(this.addForm.checkCategory==1){//综合检查
  460. if(!obj){
  461. this.$set(this.addForm.checkHazardDtoList[index],'hazardCheckPro','');
  462. this.msgError('未找到相关项目')
  463. return
  464. }
  465. this.$set(this.addForm.checkHazardDtoList[index],'hazardCheckCode',obj.code);
  466. this.$set(this.addForm.checkHazardDtoList[index],'hazardCheckName',obj.name);
  467. this.$set(this.addForm.checkHazardDtoList[index],'hazardCheckPoint',obj.mainPoint);
  468. countHazardNum({subId:this.addForm.subId, hazardCheckPro:val}).then( response => {
  469. this.$set(this,'hazardCheckCount',response.data);
  470. })
  471. }else if(this.addForm.checkCategory==2){//专项检查
  472. if(!obj){
  473. this.$set(this.addForm.specialCheckHazardDtoList[index],'hazardCheckPro','');
  474. this.msgError('未找到相关项目')
  475. return
  476. }
  477. item.hazardCheckCode=obj.code;
  478. item.hazardCheckName=obj.name;
  479. countHazardNum({subId:this.addForm.subId, hazardCheckPro:val}).then( response => {
  480. this.$set(this,'hazardCheckCount',response.data);
  481. })
  482. }
  483. },
  484. //查看图片
  485. lookImg(list,index){
  486. for(let i=0;i<list.length;i++){
  487. list[i].name = list[i].fileName;
  488. list[i].url = list[i].fileUrl;
  489. }
  490. this.$refs.lookImgDialog.lookImgDialogOpen(1,list,index);
  491. },
  492. /*==========上传相关==========*/
  493. handleAvatarSuccess(res,item) {
  494. this.$set(this,'loading',false);
  495. if(item.uploadDtoList.length>4){
  496. this.msgError('最多只可上传5张')
  497. return
  498. }
  499. let suffixName= this.upDataName.split('.')[this.upDataName.split('.').length - 2]
  500. //判断文件名中是否有逗号和分号
  501. if(suffixName.indexOf(',')==-1 && suffixName.indexOf(';')==-1){
  502. }else{
  503. this.msgError('文件名里包含逗号或分号,请修改后重新上传!')
  504. return
  505. }
  506. let obj ={
  507. fileName:this.upDataName,
  508. fileUrl:res.data.url,
  509. fileType:2,
  510. source:2,
  511. };
  512. item.uploadDtoList.push(obj);
  513. this.$forceUpdate()
  514. },
  515. beforeAvatarUpload(file,item) {
  516. if(item.uploadDtoList.length>4){
  517. this.msgError('最多只可上传5张')
  518. return false
  519. }
  520. let type = false;
  521. if (file.type == 'image/png' || file.type == 'image/jpeg' || file.type == 'image/gif' || file.type == 'image/bmp') {
  522. if(file.size> 2100000){
  523. this.msgError('上传图片大小不能超过2M')
  524. return false
  525. }
  526. this.$set(this,'loading',true);
  527. this.upDataName = file.name;
  528. type = true;
  529. }else{
  530. this.msgError('仅支持jpg/png/bmp/gif格式')
  531. type = false;
  532. }
  533. return type;
  534. },
  535. //获取检查项
  536. checkOptionList(){
  537. checkOptionList().then( response => {
  538. this.$set(this,'options',response.data);
  539. this.getCascaderData(this.options);
  540. })
  541. },
  542. //联级选择器数据处理
  543. getCascaderData(list){
  544. let self = this;
  545. if(this.addForm.checkCategory==1){//综合检查
  546. for(let i=0;i<list.length;i++){
  547. list[i].labelName = list[i].code? list[i].code +' '+ list[i].name:list[i].name
  548. if(list[i].level == 0 || list[i].level == 1 || list[i].level == 2){
  549. if(list[i].children){
  550. if(list[i].children[0]){
  551. self.getCascaderData(list[i].children)
  552. if(list[i].children){
  553. if(!list[i].children[0]){
  554. list.splice(i,1)
  555. i--
  556. }
  557. }else{
  558. list.splice(i,1)
  559. i--
  560. }
  561. }else{
  562. list.splice(i,1)
  563. i--
  564. }
  565. }else{
  566. list.splice(i,1)
  567. i--
  568. }
  569. }else{
  570. delete list[i].children
  571. }
  572. }
  573. }else if(this.addForm.checkCategory==2){//专项检查
  574. for(let i=0;i<list.length;i++){
  575. list[i].labelName = list[i].code? list[i].code +' '+ list[i].name:list[i].name
  576. if(list[i].level == 0 || list[i].level == 1 || list[i].level == 2 || list[i].level == 3){
  577. if(list[i].children){
  578. if(list[i].children[0]){
  579. self.getCascaderData(list[i].children)
  580. if(list[i].children){
  581. if(!list[i].children[0]){
  582. list.splice(i,1)
  583. i--
  584. }
  585. }else{
  586. list.splice(i,1)
  587. i--
  588. }
  589. }else{
  590. list.splice(i,1)
  591. i--
  592. }
  593. }else{
  594. list.splice(i,1)
  595. i--
  596. }
  597. }else{
  598. delete list[i].children
  599. }
  600. }
  601. }
  602. },
  603. //获取学院列表
  604. getCascaderDataQuery(text,list){
  605. let self = this;
  606. for(let i=0;i<list.length;i++){
  607. if(list[i].id == text){
  608. return list[i]
  609. }else{
  610. if(list[i].children){
  611. let obj = self.getCascaderDataQuery(text,list[i].children)
  612. if(obj){
  613. return obj
  614. }
  615. }
  616. }
  617. }
  618. },
  619. }
  620. }
  621. </script>
  622. <style scoped lang="scss">
  623. .inspectionManagement-addPage{
  624. flex: 1;
  625. display: flex !important;
  626. flex-direction: column;
  627. overflow: hidden;
  628. *{
  629. font-weight:500;
  630. }
  631. .title-max-box{
  632. position: relative;
  633. height:90px;
  634. display: flex;
  635. border-bottom:1px solid #dedede;
  636. .title-p{
  637. flex:1;
  638. color:#0045AF;
  639. margin-left:64px;
  640. line-height:90px;
  641. font-size:16px;
  642. }
  643. .title-button{
  644. width:70px;
  645. margin:24px 31px;
  646. }
  647. .position-img{
  648. width:80px;
  649. height:80px;
  650. position: absolute;
  651. top:0;
  652. left:0;
  653. }
  654. }
  655. .content-max-box{
  656. flex:1;
  657. display: flex;
  658. flex-direction: column;
  659. .top-form-box{
  660. padding:40px 85px 20px;
  661. display: flex;
  662. .top-form-left-box{
  663. min-height:317px;
  664. width:770px;
  665. margin-right:90px;
  666. }
  667. .top-form-right-box{
  668. min-height:317px;
  669. width:534px;
  670. }
  671. }
  672. .bottom-form-box{
  673. .bottom-form-title-box{
  674. background: #F5F5F5;
  675. display: flex;
  676. margin-bottom:31px;
  677. p{
  678. font-size:16px;
  679. line-height:50px;
  680. }
  681. p:nth-child(1){
  682. color:#333;
  683. margin-left:30px;
  684. flex:1;
  685. }
  686. p:nth-child(2){
  687. color:#0183FA;
  688. margin-right:37px;
  689. }
  690. }
  691. .add-bottom-button{
  692. cursor: pointer;
  693. color:#0183FA;
  694. border-radius:4px;
  695. border:1px dashed #0183FA;
  696. width:800px;
  697. line-height:40px;
  698. text-align: center;
  699. font-size:14px;
  700. margin: 20px auto;
  701. }
  702. }
  703. }
  704. .for-max-big-box{
  705. border:1px solid #dedede;
  706. overflow: hidden;
  707. margin:0 81px;
  708. .for-title-box{
  709. display: flex;
  710. background: #F5F5F5;
  711. border-bottom:1px solid #dedede;
  712. line-height:50px;
  713. .for-title-p{
  714. color:#333333;
  715. font-size:16px;
  716. margin-left: 30px;
  717. flex:1;
  718. }
  719. .for-del-box{
  720. color:#0183FA;
  721. margin-left:46px;
  722. cursor: pointer;
  723. display: flex;
  724. p{
  725. font-size:14px;
  726. line-height:50px;
  727. margin-right:8px;
  728. }
  729. }
  730. .for-button-box{
  731. color:#0183FA;
  732. margin-left:46px;
  733. margin-right:43px;
  734. cursor: pointer;
  735. display: flex;
  736. p{
  737. font-size:14px;
  738. line-height:50px;
  739. margin-right:8px;
  740. }
  741. }
  742. }
  743. .for-big-box{
  744. padding-top:27px;
  745. .up-img-p{
  746. height:80px;
  747. width:80px;
  748. line-height:80px;
  749. text-align: center;
  750. font-size:16px;
  751. border-radius:4px;
  752. border:1px dashed #E0E0E0;
  753. }
  754. .for-img-box{
  755. width:80px;
  756. height:80px;
  757. border-radius:4px;
  758. display: inline-block;
  759. overflow: hidden;
  760. margin-right:20px;
  761. position: relative;
  762. .for-img{
  763. width:80px;
  764. height:80px;
  765. display: inline-block;
  766. overflow: hidden;
  767. cursor: pointer;
  768. }
  769. .for-del-button{
  770. background: rgba(0,0,0,0.7);
  771. width:20px;
  772. height:20px;
  773. line-height: 20px;
  774. text-align: center;
  775. color:#fff;
  776. border-bottom-left-radius:4px;
  777. cursor: pointer;
  778. position: absolute;
  779. top:0;
  780. right:0;
  781. }
  782. }
  783. .hazard-check-count-p{
  784. display: inline-block;
  785. margin-left: 20px;
  786. font-size: 14px;
  787. line-height: 40px;
  788. span{
  789. color:#FF0000;
  790. }
  791. }
  792. }
  793. }
  794. /*专项检查*/
  795. .for-max-big-box-special{
  796. margin-bottom: 20px;
  797. .for-big-box-special{
  798. border-bottom: 1px dotted #D8D8D8;
  799. margin:30px;
  800. }
  801. .for-big-box-special:last-of-type{
  802. border-bottom: none;
  803. }
  804. }
  805. .bottom-button-max-box{
  806. height:80px;
  807. display: flex;
  808. border-top:1px solid #dedede;
  809. p{
  810. margin-top:20px;
  811. }
  812. .null-p{
  813. flex:1;
  814. }
  815. p:nth-child(2){
  816. width:90px;
  817. margin-right:20px;
  818. }
  819. p:nth-child(3){
  820. width:90px;
  821. margin-right:20px;
  822. }
  823. p:nth-child(4){
  824. width:90px;
  825. margin-right:20px;
  826. }
  827. }
  828. }
  829. ::v-deep .is-disabled{
  830. .el-input__inner{
  831. background-color: #f5f5f5;
  832. color: #333;
  833. border-color: #f5f5f5;
  834. cursor:auto;
  835. }
  836. }
  837. </style>