index.vue 33 KB

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