addCheck.vue 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000
  1. <!--录入检查-->
  2. <template>
  3. <div class="app-container addCheckPage">
  4. <el-form :model="form" ref="form" :inline="true" :rules="rules" class="addCheckPage-min">
  5. <div class="top-addCheckPage-title">基本信息</div>
  6. <div class="top-addCheckPage">
  7. <el-form-item label="房间号:" prop="fjNumber" label-width="130px" class="el-form-item-top">
  8. <el-select
  9. style="width:230px;"
  10. v-model="form.fjNumber"
  11. filterable
  12. remote
  13. reserve-keyword
  14. placeholder="请输入实验室房间号"
  15. :remote-method="getSelectInfoByRoom"
  16. @change="selectChange"
  17. >
  18. <el-option
  19. v-for="item in optionsSelect"
  20. :key="item.room"
  21. :label="item.room"
  22. :value="item.room">
  23. </el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item label="实验楼:" prop="buildingName" label-width="130px" class="el-form-item-top">
  27. <el-input
  28. disabled
  29. style="width:230px;"
  30. maxlength="20"
  31. v-model="form.buildingName"
  32. placeholder="请选择房间号"
  33. clearable
  34. size="small"
  35. />
  36. </el-form-item>
  37. <el-form-item label="实验室:" prop="laboratoryName" label-width="130px" class="el-form-item-top">
  38. <el-input
  39. disabled
  40. style="width:230px;"
  41. maxlength="20"
  42. v-model="form.laboratoryName"
  43. placeholder="请选择房间号"
  44. clearable
  45. size="small"
  46. />
  47. </el-form-item>
  48. <el-form-item label="负责人:" prop="fzrName" label-width="130px" class="el-form-item-top">
  49. <el-input
  50. disabled
  51. style="width:230px;"
  52. maxlength="10"
  53. v-model="form.fzrName"
  54. placeholder="请选择房间号"
  55. clearable
  56. size="small"
  57. />
  58. </el-form-item>
  59. <el-form-item label="联系方式:" prop="fzrLxfs" label-width="130px" class="el-form-item-top">
  60. <el-input
  61. oninput="value=value.replace(/[^\d]/g,'')"
  62. style="width:230px;"
  63. maxlength="11"
  64. v-model="form.fzrLxfs"
  65. placeholder="请输入联系方式"
  66. clearable
  67. size="small"
  68. />
  69. </el-form-item>
  70. <el-form-item label="整改截止时间:" prop="zgjzTime" label-width="130px" class="el-form-item-top">
  71. <el-date-picker style="width:230px;"
  72. v-model="form.zgjzTime"
  73. type="date"
  74. value-format="yyyy-MM-dd"
  75. :picker-options="pickerBeginOption"
  76. placeholder="选择整改截止时间">
  77. </el-date-picker>
  78. </el-form-item>
  79. <el-form-item label="整改类型:" prop="zgType" class="el-form-item-top" label-width="130px">
  80. <el-select v-model="form.zgType" placeholder="请选择整改类型" style="width:230px;">
  81. <el-option label="一般整改" value="0" />
  82. <el-option label="重大整改" value="1" />
  83. </el-select>
  84. </el-form-item>
  85. <el-form-item label="检查单位:" prop="jcDw" class="el-form-item-top" label-width="130px">
  86. <el-select v-model="form.jcDw" @change="jcDwChange" placeholder="请选择检查单位" style="width:230px;">
  87. <el-option v-for="(item,index) in inspectionUnitArrayData" :key="index" :label="item.label" :value="item.id" />
  88. </el-select>
  89. </el-form-item>
  90. </div>
  91. <div class="top-addCheckPage-title" style="border-top:10px solid #dedede;">隐患信息</div>
  92. <div class="center-addCheckPage scrollbar-box">
  93. <div v-for="(item,index) in form.detailsList" :key="index" class="form-list-for-box">
  94. <el-form-item label="隐患照片:" :prop="'detailsList.'+ index +'.yhImg'" :rules="rules.yhImg" label-width="150px" class="el-form-item-bottom">
  95. <div class="el-form-item-bottom-up">
  96. <div class="form-up-img-box">
  97. <div v-for="(imgUrl,imgIndex) in item.yhImg" :key="imgIndex" class="up-img-for-box">
  98. <img :src="imgUrl">
  99. <i class="el-icon-close del-i" @click="imgDel(index,imgIndex)"></i>
  100. </div>
  101. </div>
  102. <el-upload
  103. v-if="!item.yhImg[4]"
  104. class="certificate-avatar-uploader"
  105. style="margin-top:10px;"
  106. :action="uploadImgUrl"
  107. :show-file-list="false"
  108. accept="image/jpeg,image/gif,image/png"
  109. :on-success="function (res, file){return handleAvatarSuccess(res, file, index)}"
  110. :headers="headers"
  111. :before-upload="beforeAvatarUpload">
  112. <i class="el-icon-plus avatar-uploader-icon"></i>
  113. </el-upload>
  114. </div>
  115. </el-form-item>
  116. <el-form-item label="隐患描述:" :prop="'detailsList.'+ index +'.yhMs'" :rules="rules.yhMs" label-width="150px" class="el-form-item-bottom">
  117. <el-input
  118. style="width:450px;"
  119. maxlength="50"
  120. v-model="item.yhMs"
  121. type="textarea"
  122. placeholder="请输入隐患描述">
  123. </el-input>
  124. </el-form-item>
  125. <el-form-item label="对应检查项:" :prop="'detailsList.'+ index +'.jcxId'" :rules="rules.jcxId" label-width="150px" class="el-form-item-bottom">
  126. <el-cascader
  127. placeholder="请输入检查项名称或点击箭头选择"
  128. :before-filter="(value)=>filterRegion(value,index)"
  129. filterable
  130. clearable
  131. maxlength="10"
  132. :show-all-levels="false"
  133. ref="cascaderGet"
  134. style="width:300px;"
  135. v-model="item.jcxId"
  136. :options="checkOptionList[index]"
  137. @change="(val)=>cascaderChange(val,index)"
  138. @blur="blurCheck(index)"
  139. :props="{ expandTrigger: 'hover',value: 'id', label: 'name' }">
  140. <template slot-scope="{ node, data }">
  141. <el-tooltip :disabled="data.name.length < 14" class="item" effect="dark" :content="data.name" placement="top-start">
  142. <p style="max-width:200px;overflow: hidden;display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">{{ data.name}}</p>
  143. </el-tooltip>
  144. </template>
  145. </el-cascader>
  146. <!--<span class="add-span" style="margin-left:20px;" @click="blurCheck(index)">重置检查项</span>-->
  147. <span class="text-span">没有找到对应的隐患</span>
  148. <span class="add-span" @click="dialogClick(index)">手动添加</span>
  149. <p style="color:#999999;" v-if="item.yhcount">此检查项在当前实验室累计出现<span style="color:#FF2D2D;">{{item.yhcount}}</span>次隐患</p>
  150. </el-form-item>
  151. <p class="del-button-p" @click="delDanger(index)">删除隐患项</p>
  152. </div>
  153. <p class="add-button-p" :class="form.detailsList[0]?'add-button-p-one':''" @click="addDanger">+ 新增隐患项</p>
  154. </div>
  155. <div class="bottom-addCheckPage">
  156. <p></p>
  157. <p class="add-button-one-90" @click="submitForm(1)" v-hasPermi="['laboratory:checkRecord:add']">保存草稿</p>
  158. <p class="inquire-button-one" @click="submitForm(2)" v-hasPermi="['laboratory:checkRecord:add']">提交发布</p>
  159. </div>
  160. </el-form>
  161. <!--新增检查项-->
  162. <el-dialog title="添加检查项" :visible.sync="open" width="500px" append-to-body>
  163. <el-form ref="form" :model="examinationForm" :rules="rules" label-width="100px">
  164. <el-form-item label="检查项名称" prop="name">
  165. <el-input type="textarea" maxlength="20" v-model="examinationForm.name" placeholder="请输入检查项名称" rows="3" resize="none"></el-input>
  166. </el-form-item>
  167. <el-form-item label="目录" prop="idList">
  168. <el-cascader
  169. :show-all-levels="false"
  170. style="width:360px;"
  171. v-model="examinationForm.idList"
  172. :options="checkOptionListExamination"
  173. :props="{ expandTrigger: 'hover',value: 'id', label: 'name' }"
  174. @change="handleChange">
  175. <template slot-scope="{ node, data }">
  176. <el-tooltip :disabled="data.name.length < 14" class="item" effect="dark" :content="data.name" placement="top-start">
  177. <p style="max-width:200px;overflow: hidden;display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">{{ data.name}}</p>
  178. </el-tooltip>
  179. </template>
  180. </el-cascader>
  181. </el-form-item>
  182. </el-form>
  183. <div slot="footer" class="dialog-footer">
  184. <el-button @click="cancel">取 消</el-button>
  185. <el-button type="primary" @click="dialogSubmitForm">确 定</el-button>
  186. </div>
  187. </el-dialog>
  188. <!--检查重复提示-->
  189. <el-dialog title="提示" :visible.sync="remindOpen" width="600px" append-to-body class="remind-dialog-box">
  190. <div class="for-max-box scrollbar-box">
  191. <div v-for="(item,index) in remindList" :key="index" class="for-box">
  192. <div class="for-min-box" style="margin-top:20px;">
  193. <p class="for-min-title">检查时间:</p>
  194. <p class="for-min-text" style="flex:1;">{{item.createTime}}<span style="margin-left:30px;">检查人:{{item.jcRyxm}}</span></p>
  195. </div>
  196. <div class="for-min-box">
  197. <p class="for-min-title">隐患描述:</p>
  198. <p class="for-min-text" style="flex:1;">{{item.yhMs}}</p>
  199. </div>
  200. <div class="for-min-box" v-if="item.yhImg[0]">
  201. <p class="for-min-title">照片:</p>
  202. <div class="for-img-box">
  203. <img :src="minItem" v-for="(minItem,minIndex) in item.yhImg" :key="minIndex">
  204. </div>
  205. </div>
  206. </div>
  207. </div>
  208. <div slot="footer" class="dialog-footer">
  209. <!--<el-button @click="remindOff">取 消</el-button>-->
  210. <el-button type="primary" @click="remindButton">确 定</el-button>
  211. </div>
  212. </el-dialog>
  213. <el-dialog title="发布" :visible.sync="nameOpen" width="600px" append-to-body class="remind-dialog-box">
  214. <el-form ref="nameForm" :model="nameForm" :rules="rules" label-width="100px">
  215. <el-form-item label="检查名称" prop="checkName" style="margin-top:20px;">
  216. <el-input maxlength="20" v-model="nameForm.checkName" placeholder="请输入检查名称" rows="3" resize="none"></el-input>
  217. </el-form-item>
  218. </el-form>
  219. <div slot="footer" class="dialog-footer">
  220. <el-button @click="nameFormButton(1)">取 消</el-button>
  221. <el-button type="primary" @click="nameFormButton(2)">确 定</el-button>
  222. </div>
  223. </el-dialog>
  224. </div>
  225. </template>
  226. <script>
  227. import { listCheckOption } from "@/api/laboratory/checkOption";
  228. import { treeselect,listCheckRecord, getCheckRecord, delCheckRecord, addCheckRecord, updateCheckRecord, selectInfoByRoom,
  229. checkRecordAddC, checkRecordAdd, addTempCheckOption,selectDeptListUserDeptId,hiddenDangerCount } from "@/api/laboratory/checkRecord";
  230. import { getToken } from "@/utils/auth";
  231. export default {
  232. name: "CheckRecord",
  233. data() {
  234. return {
  235. //限制时间范围
  236. pickerBeginOption: {
  237. disabledDate: (time) => {
  238. return time.getTime() < Date.now()-1 * 24 * 60 * 60 * 1000
  239. }
  240. },
  241. //上传设置
  242. uploadImgUrl: window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API + "/file/upload", // 上传的图片服务器地址
  243. headers: {
  244. Authorization: "Bearer " + getToken(),
  245. },
  246. // 遮罩层
  247. loading: true,
  248. //实验室懒加载数据
  249. optionsSelect:[],
  250. // 安全检查表格数据
  251. checkRecordList: [],
  252. // 表单参数
  253. form: {
  254. fjNumber:"",
  255. buildingId:"",
  256. buildingName:"",
  257. laboratoryId:"",
  258. laboratoryName:"",
  259. fzrName:"",
  260. fzrLxfs:"",
  261. detailsList:[
  262. // {
  263. // isLingshi:0,
  264. // yhImg:[],
  265. // yhMs:"",
  266. // jcxId:"",
  267. // jcxName:"",
  268. // }
  269. ],
  270. },
  271. imgIndex:"",
  272. //临时存储房间号
  273. fjNumber:"",
  274. // 表单校验
  275. rules: {
  276. fjNumber: [
  277. { required: true, message: "请输入实验室房间号", trigger: "blur" },
  278. { required: true, message: "请输入实验室房间号", validator: this.spaceJudgment, trigger: "blur" }
  279. ],
  280. buildingName: [
  281. { required: true, message: "请选择房间自动匹配实验楼", trigger: "blur" }
  282. ],
  283. laboratoryName: [
  284. { required: true, message: "请选择房间自动匹配实验室", trigger: "blur" }
  285. ],
  286. fzrName: [
  287. { required: true, message: "请选择房间自动匹配负责人", trigger: "blur" }
  288. ],
  289. zgjzTime: [
  290. { required: true, message: "选择整改截止时间", trigger: "blur" }
  291. ],
  292. zgType: [
  293. { required: true, message: "请选择整改类型", trigger: "blur" }
  294. ],
  295. jcDw: [
  296. { required: true, message: "请选择检查单位", trigger: "blur" }
  297. ],
  298. yhMs: [
  299. { required: true, message: "请输入隐患描述", trigger: "blur" },
  300. { required: true, message: "请输入隐患描述", validator: this.spaceJudgment, trigger: "blur" }
  301. ],
  302. // yhImg: [
  303. // { required: true, message: "请上传隐患照片", trigger: "blur" }
  304. // ],
  305. jcxId: [
  306. { required: true, message: "请选择检项", trigger: "blur" }
  307. ],
  308. name: [
  309. { required: true, message: "请输入检查项名称", trigger: "blur" },
  310. { required: true, message: "请输入检查项名称", validator: this.spaceJudgment, trigger: "blur" }
  311. ],
  312. idList: [
  313. { required: true, message: "请选择目录", trigger: "blur" }
  314. ],
  315. checkName: [
  316. { required: true, message: "请输入检查名称", trigger: "blur" },
  317. { required: true, message: "请输入检查名称", validator: this.spaceJudgment, trigger: "blur" }
  318. ],
  319. },
  320. // 检查先搜索列表
  321. optionsUser:[],
  322. open:false,
  323. openIndex:"",
  324. //检查项联机
  325. examinationForm:{
  326. laboratoryName:"",
  327. idList:[],
  328. },
  329. //检查项
  330. defaultCheckOptionList:[],
  331. checkOptionList:[],
  332. checkOptionListExamination:[],
  333. //临时数据组
  334. temporaryIdList:[],
  335. //检查单位
  336. inspectionUnitArrayData:[],
  337. //提醒页面开关
  338. remindOpen:false,
  339. remindList:[],
  340. nameOpen:false,
  341. nameForm:{
  342. checkName:"",
  343. },
  344. formData:{},
  345. };
  346. },
  347. created() {
  348. // this.getListCheckOption();
  349. this.getListCheckOptionData();
  350. this.getListCheckOptionTwo();
  351. this.treeselect();
  352. // this.selectDeptListUserDeptId();
  353. },
  354. methods: {
  355. remindOff(){
  356. this.remindOpen = false;
  357. },
  358. remindButton(){
  359. this.remindOpen = false;
  360. },
  361. blurCheck(index){
  362. // this.getListCheckOptionData(index);
  363. let list = JSON.parse(JSON.stringify(this.checkOptionList));
  364. list[index] = JSON.parse(JSON.stringify(this.defaultCheckOptionList));
  365. this.$set(this,'checkOptionList',JSON.parse(JSON.stringify(list)))
  366. },
  367. filterRegion(value,index){
  368. this.getListCheckOptionOne(value,index);
  369. return false
  370. },
  371. jcDwChange(val){
  372. let self = this;
  373. for(let i=0;i<self.inspectionUnitArrayData.length;i++){
  374. if(val == self.inspectionUnitArrayData[i].id){
  375. this.form.jcDwName = self.inspectionUnitArrayData[i].label;
  376. }
  377. }
  378. },
  379. //根据用户获取对应检查单位列表
  380. selectDeptListUserDeptId(){
  381. selectDeptListUserDeptId().then( data => {
  382. this.inspectionUnitArrayData = data.data;
  383. })
  384. },
  385. treeselect(){
  386. treeselect().then( data => {
  387. // let list = [];
  388. // for(let i=0;i<data.data[0].children.length;i++){
  389. // let obj = {
  390. // id:data.data[0].children[i].id,
  391. // label:data.data[0].children[i].label,
  392. // }
  393. // list.push(obj);
  394. // for(let o=0;o<data.data[0].children[i].children.length;o++){
  395. // let obj = {
  396. // id:data.data[0].children[i].children[o].id,
  397. // label:data.data[0].children[i].children[o].label,
  398. // }
  399. // list.push(obj);
  400. // }
  401. // }
  402. // this.inspectionUnitArrayData = list;
  403. this.inspectionUnitArrayData = this.toArray(data.data);
  404. });
  405. },
  406. toArray(data){
  407. let list = [];
  408. let newList = JSON.parse(JSON.stringify(data));
  409. for(let i=0;i<newList.length;i++){
  410. pushNode(newList[i]);
  411. }
  412. function pushNode(node){
  413. if(node.children){
  414. for (let nodeItem of node.children){
  415. pushNode(nodeItem)
  416. }
  417. delete node.children;
  418. list.push(node)
  419. }else{
  420. if(node.children){
  421. delete node.children
  422. }
  423. list.push(node)
  424. }
  425. }
  426. return list
  427. },
  428. //删除隐患
  429. delDanger(index){
  430. this.checkOptionList.splice(index,1)
  431. this.form.detailsList.splice(index,1)
  432. this.$forceUpdate();
  433. },
  434. //新增隐患项
  435. addDanger(){
  436. if(!this.form.fjNumber){
  437. this.msgError("请先选择房间")
  438. return
  439. }
  440. if(this.form.detailsList.length>19){
  441. this.msgError("最多添加20个隐患")
  442. return
  443. }
  444. let obj = {
  445. yhImg:[],
  446. yhMs:"",
  447. };
  448. this.form.detailsList.push(obj);
  449. this.getListCheckOption();
  450. },
  451. //上传
  452. handleAvatarSuccess(res, file, index) {
  453. //let url=window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API+"/"+res.data.url;
  454. this.form.detailsList[index].yhImg.push(res.data.url);
  455. this.$forceUpdate()
  456. },
  457. beforeAvatarUpload(file) {
  458. let type = false;
  459. console.log('file',file);
  460. if (file.type == 'image/png' || file.type == 'image/jpeg' || file.type == 'image/gif') {
  461. type = true;
  462. }else{
  463. this.$message.error('只能上传png/jpeg/gif格式图片');
  464. type = false;
  465. }
  466. return type;
  467. },
  468. //删除
  469. imgDel(index,minIndex){
  470. this.form.detailsList[index].yhImg.splice(minIndex,1);
  471. },
  472. /** 查询安全检查列表 */
  473. getList() {
  474. this.loading = true;
  475. listCheckRecord({}).then( response => {
  476. this.checkRecordList = response.rows;
  477. this.total = response.total;
  478. this.loading = false;
  479. });
  480. },
  481. //发布按钮
  482. nameFormButton(type){
  483. if(type == 1){
  484. this.nameOpen = false;
  485. }else if(type == 2){
  486. this.$refs["nameForm"].validate(valid => {
  487. if (valid) {
  488. this.loading = true;
  489. this.formData.checkName = this.nameForm.checkName;
  490. checkRecordAdd(this.formData).then( response => {
  491. this.msgSuccess('提交成功')
  492. this.delForm();
  493. this.$set(this,'checkOptionList',[]);
  494. // this.getListCheckOption();
  495. this.nameOpen = false;
  496. this.loading = false;
  497. });
  498. }
  499. })
  500. }
  501. },
  502. /** 提交按钮 */
  503. submitForm(type) {
  504. let self = this;
  505. if(!this.form.detailsList[0]){
  506. this.msgError('请添加至少一个隐患项')
  507. return
  508. }
  509. this.$refs["form"].validate(valid => {
  510. if (valid) {
  511. let obj = JSON.parse(JSON.stringify(self.form));
  512. for(let i=0;i<obj.detailsList.length;i++){
  513. if(obj.detailsList[i].jcxName.indexOf("/") != -1){
  514. let list = obj.detailsList[i].jcxName.split("/");
  515. obj.detailsList[i].jcxName = list[list.length-1];
  516. }
  517. obj.detailsList[i].jcxId = obj.detailsList[i].jcxId + ',';
  518. obj.detailsList[i].yhImg = obj.detailsList[i].yhImg + '';
  519. }
  520. obj.zgStatus = 0;
  521. if(type == 1){
  522. obj.isCg = 1;
  523. }else if(type == 2){
  524. obj.isCg = 0;
  525. }
  526. this.formData = JSON.parse(JSON.stringify(obj));
  527. if(type == 1){
  528. this.loading = true;
  529. checkRecordAddC(this.formData).then( response => {
  530. this.msgSuccess('保存草稿成功')
  531. this.delForm();
  532. this.$set(this,'checkOptionList',[]);
  533. // this.getListCheckOption();
  534. this.loading = false;
  535. });
  536. }else{
  537. this.nameForm.checkName = "";
  538. this.nameOpen = true;
  539. }
  540. }
  541. });
  542. },
  543. delForm(){
  544. let obj = {
  545. fjNumber:"",
  546. buildingId:"",
  547. buildingName:"",
  548. laboratoryId:"",
  549. laboratoryName:"",
  550. fzrName:"",
  551. fzrLxfs:"",
  552. detailsList:[
  553. // {
  554. // isLingshi:0,
  555. // yhImg:[],
  556. // yhMs:"",
  557. // jcxId:"",
  558. // jcxName:"",
  559. // }
  560. ],
  561. }
  562. this.fjNumber = "";
  563. this.$set(this,"form",obj)
  564. },
  565. /** 下列人员-懒加载 */
  566. userSelectList(query) {
  567. // if (query !== '' && query.length>1) {
  568. // this.loading = true;
  569. // this.userSelectList.nickName=query;
  570. // selectListUser(this.userSelectList).then(response => {
  571. // this.optionsUser = response.data;
  572. // this.loading = false;
  573. // });
  574. // } else {
  575. // this.optionsUser = [];
  576. // }
  577. },
  578. //新增检查项
  579. dialogClick(index){
  580. this.openIndex = index;
  581. this.examinationForm = {};
  582. this.open = true;
  583. },
  584. //检查项联机触发
  585. handleChange() {
  586. },
  587. //检查项确定
  588. cascaderChange(val,index){
  589. let self = this;
  590. if (val[0]){
  591. let text = "";
  592. let cascaderList = this.$refs['cascaderGet'][index].getCheckedNodes()[0].pathLabels // 获取label值
  593. let nodesList = this.$refs['cascaderGet'][index].getCheckedNodes()[0].pathNodes // 获取label值
  594. let jcxSstkNum = nodesList[nodesList.length-1].data.code;
  595. let jcxSstkMs = "";
  596. for(let i=0;i<nodesList.length-1;i++){
  597. if(i == 0){
  598. jcxSstkMs = jcxSstkMs + nodesList[i].data.name
  599. }else{
  600. jcxSstkMs = jcxSstkMs + '-' + nodesList[i].data.name
  601. }
  602. }
  603. let num = 0;
  604. for(let i=0;i<self.temporaryIdList.length;i++){
  605. if(self.temporaryIdList[i] == val){
  606. num++
  607. }
  608. }
  609. if(num == 0){
  610. this.$set(this.form.detailsList[index],'isLingshi',0);
  611. }else{
  612. this.$set(this.form.detailsList[index],'isLingshi',1);
  613. }
  614. this.$set(this.form.detailsList[index],'jcxName',cascaderList[cascaderList.length-1]);
  615. this.$set(this.form.detailsList[index],'jcxSstkNum',jcxSstkNum);
  616. this.$set(this.form.detailsList[index],'jcxSstkMs',jcxSstkMs);
  617. }else{
  618. this.$set(this.form.detailsList[index],'isLingshi',0);
  619. this.$set(this.form.detailsList[index],'jcxName',"");
  620. this.$set(this.form.detailsList[index],'jcxSstkNum',"");
  621. this.$set(this.form.detailsList[index],'jcxSstkMs',"");
  622. // this.getListCheckOption();
  623. }
  624. console.log('val',val);
  625. if(val[0]){
  626. let obj = {
  627. laboratoryId:this.form.laboratoryId,
  628. checkId:val[val.length-1],
  629. };
  630. hiddenDangerCount(obj).then( response => {
  631. this.$set(this.form.detailsList[index],'yhcount',response.data.yhcount);
  632. if(response.data.yhflg){
  633. for(let i=0;i<response.data.yhlist.length;i++){
  634. response.data.yhlist[i].yhImg = response.data.yhlist[i].yhImg.split(',')
  635. }
  636. this.$set(this,'remindList',response.data.yhlist);
  637. this.remindOpen = true;
  638. }
  639. });
  640. }else{
  641. this.$set(this.form.detailsList[index],'yhcount','');
  642. }
  643. },
  644. //新增检查项
  645. dialogSubmitForm(){
  646. this.$refs["form"].validate(valid => {
  647. if (valid) {
  648. let obj = {
  649. name:this.examinationForm.name,
  650. parentId:this.examinationForm.idList[this.examinationForm.idList.length-1]
  651. };
  652. addTempCheckOption(obj).then( response => {
  653. let list = JSON.parse(JSON.stringify(this.checkOptionList));
  654. let obj = {
  655. id:response.data.id,
  656. name:response.data.name,
  657. };
  658. list[this.openIndex].push(obj);
  659. this.$set(this,'checkOptionList',JSON.parse(JSON.stringify(list)));
  660. this.temporaryIdList.push(response.data.id);
  661. this.$set(this.form.detailsList[this.openIndex],'jcxId',response.data.id);
  662. this.$set(this.form.detailsList[this.openIndex],'jcxName',response.data.name);
  663. this.$set(this.form.detailsList[this.openIndex],'isLingshi',1);
  664. this.msgSuccess("新增成功");
  665. this.open = false;
  666. });
  667. }
  668. });
  669. },
  670. //关闭检查项
  671. cancel(){
  672. this.open = false;
  673. },
  674. //实验室数据懒加载
  675. getSelectInfoByRoom(query){
  676. console.log("query",query);
  677. if (query !== '' && query.length>0) {
  678. this.loading = true;
  679. let obj = {
  680. room:query,
  681. }
  682. selectInfoByRoom(obj).then(response => {
  683. this.optionsSelect = response.data;
  684. this.loading = false;
  685. });
  686. } else {
  687. this.optionsSelect = [];
  688. }
  689. },
  690. //清除实验室选中
  691. delSelect(){
  692. },
  693. //实验室房间懒加载选中
  694. selectChange(name){
  695. let self = this;
  696. if(!this.fjNumber){
  697. if(name){
  698. for(let i=0;i<self.optionsSelect.length;i++){
  699. if(name == self.optionsSelect[i].room){
  700. self.$set(self,"fjNumber",self.optionsSelect[i].room)
  701. self.$set(self.form,"fjNumber",self.optionsSelect[i].room)
  702. // self.$set(self.form,"laboratoryId",self.optionsSelect[i].building)
  703. // self.$set(self.form,"buildingId",self.optionsSelect[i].deptId)
  704. // self.$set(self.form,"deptId",self.optionsSelect[i].id)
  705. self.$set(self.form,"laboratoryId",self.optionsSelect[i].id)
  706. self.$set(self.form,"buildingId",self.optionsSelect[i].building)
  707. self.$set(self.form,"deptId",self.optionsSelect[i].deptId)
  708. self.$set(self.form,"deptName",self.optionsSelect[i].deptName)
  709. self.$set(self.form,"buildingName",self.optionsSelect[i].buildName)
  710. self.$set(self.form,"laboratoryName",self.optionsSelect[i].name)
  711. self.$set(self.form,"fzrId",self.optionsSelect[i].userId)
  712. self.$set(self.form,"fzrName",self.optionsSelect[i].safeUserName)
  713. self.$set(self.form,"fzrLxfs",self.optionsSelect[i].safeUserPhone)
  714. }
  715. }
  716. }
  717. else{
  718. self.$set(self.form,"fjNumber","")
  719. self.$set(self.form,"buildingId","")
  720. self.$set(self.form,"deptName","")
  721. self.$set(self.form,"deptId","")
  722. self.$set(self.form,"buildingName","")
  723. self.$set(self.form,"laboratoryId","")
  724. self.$set(self.form,"laboratoryName","")
  725. self.$set(self.form,"fzrId","")
  726. self.$set(self.form,"fzrName","")
  727. self.$set(self.form,"fzrLxfs","")
  728. }
  729. }else{
  730. if(this.fjNumber != name){
  731. this.$confirm('更换实验室后需要从新选择检查项,是否确认更换实验室?', "警告", {
  732. confirmButtonText: "确定",
  733. cancelButtonText: "取消",
  734. type: "warning"
  735. }).then(function() {
  736. }).then(() => {
  737. for(let i=0;i<self.optionsSelect.length;i++){
  738. if(name == self.optionsSelect[i].room){
  739. self.$set(self,"fjNumber",self.optionsSelect[i].room)
  740. self.$set(self.form,"fjNumber",self.optionsSelect[i].room)
  741. self.$set(self.form,"buildingId",self.optionsSelect[i].deptId)
  742. self.$set(self.form,"deptName",self.optionsSelect[i].deptName)
  743. self.$set(self.form,"deptId",self.optionsSelect[i].id)
  744. self.$set(self.form,"buildingName",self.optionsSelect[i].buildName)
  745. self.$set(self.form,"laboratoryId",self.optionsSelect[i].building)
  746. self.$set(self.form,"laboratoryName",self.optionsSelect[i].name)
  747. self.$set(self.form,"fzrId",self.optionsSelect[i].userId)
  748. self.$set(self.form,"fzrName",self.optionsSelect[i].safeUserName)
  749. self.$set(self.form,"fzrLxfs",self.optionsSelect[i].safeUserPhone)
  750. self.$set(self.form,"detailsList",[])
  751. }
  752. }
  753. }).catch(() => {
  754. self.$set(self.form,"fjNumber",self.fjNumber)
  755. this.getSelectInfoByRoom(self.fjNumber)
  756. });
  757. }
  758. }
  759. },
  760. //获取检查项
  761. getListCheckOption() {
  762. let newObj = {
  763. level:4,
  764. }
  765. listCheckOption(newObj).then( response => {
  766. let list = this.getTreeData(response.data);
  767. this.checkOptionList.push(JSON.parse(JSON.stringify(list)));
  768. });
  769. this.$forceUpdate();
  770. },
  771. getListCheckOptionData(){
  772. let newObj = {
  773. level:4,
  774. }
  775. listCheckOption(newObj).then( response => {
  776. this.defaultCheckOptionList = this.getTreeData(response.data);
  777. // let list = JSON.parse(JSON.stringify(this.checkOptionList));
  778. // list[index] = this.getTreeData(response.data);
  779. // this.$set(this,'checkOptionList',JSON.parse(JSON.stringify(list)))
  780. });
  781. },
  782. //获取检查项
  783. getListCheckOptionOne(data,index) {
  784. let newObj = {
  785. level:4,
  786. searchValue:data
  787. }
  788. listCheckOption(newObj).then( response => {
  789. let list = JSON.parse(JSON.stringify(this.checkOptionList));
  790. list[index] = this.getTreeData(response.data);
  791. if(list[index][0]){
  792. this.$set(this,'checkOptionList',JSON.parse(JSON.stringify(list)))
  793. this.$forceUpdate()
  794. }else{
  795. this.msgError('未找到相关检查项')
  796. }
  797. });
  798. },
  799. getListCheckOptionTwo(){
  800. let newObj = {
  801. level:3,
  802. }
  803. listCheckOption(newObj).then( response => {
  804. let list = this.getTreeData(response.data);
  805. this.checkOptionListExamination = JSON.parse(JSON.stringify(list));
  806. });
  807. },
  808. getTreeData(data){
  809. for(var i=0;i<data.length>0;i++){
  810. if(data[i].children == null||data[i].children.length<=0){
  811. // children若为空数组,则将children设为undefined
  812. data[i].children = undefined;
  813. }else {
  814. // children若不为空数组,则继续 递归调用 本方法
  815. this.getTreeData(data[i].children);
  816. }
  817. }
  818. return data;
  819. },
  820. }
  821. };
  822. </script>
  823. <style scoped lang="scss">
  824. .addCheckPage{
  825. flex:1;
  826. display: flex;
  827. flex-direction: column;
  828. overflow: hidden !important;
  829. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  830. .addCheckPage-min{
  831. flex:1;
  832. display: flex;
  833. flex-direction: column;
  834. overflow: hidden !important;
  835. .top-addCheckPage-title{
  836. line-height:60px;
  837. padding:0 20px;
  838. font-size:16px;
  839. border-bottom:1px solid #dedede;
  840. }
  841. .top-addCheckPage{
  842. padding:20px 20px 10px;
  843. .el-form-item-top{
  844. margin:10px 24px 20px 0;
  845. }
  846. }
  847. .center-addCheckPage{
  848. flex:1;
  849. display: flex;
  850. flex-direction: column;
  851. overflow-y: scroll;
  852. border-top:1px solid #dedede;
  853. border-bottom:1px solid #dedede;
  854. .form-list-for-box:nth-child(1){
  855. border:none;
  856. }
  857. .form-list-for-box{
  858. border-top:1px solid #dedede;
  859. .el-form-item-bottom{
  860. display: block;
  861. margin:20px 0 30px 0;
  862. .el-form-item-bottom-up{
  863. display: flex;
  864. min-width:200px;
  865. .form-up-img-box{
  866. .up-img-for-box{
  867. display: inline-block;
  868. width:80px;
  869. height:80px;
  870. position: relative;
  871. margin:10px 10px 0 0;
  872. img{
  873. width:80px;
  874. height:80px;
  875. }
  876. .del-i{
  877. position: absolute;
  878. top:0;
  879. right:0;
  880. width:20px;
  881. height:20px;
  882. line-height:20px;
  883. background: rgba(0,0,0,0.4);
  884. color:#fff;
  885. font-size:14px;
  886. text-align: center;
  887. cursor:pointer;
  888. }
  889. .del-i:hover{
  890. background: #FF6666;
  891. }
  892. }
  893. .certificate-avatar-uploader{
  894. width:80px;
  895. height:80px;
  896. }
  897. }
  898. }
  899. }
  900. .text-span{
  901. margin-left:20px;
  902. color:#999;
  903. }
  904. .add-span{
  905. margin-left:10px;
  906. color:#0183FA;
  907. cursor:pointer;
  908. }
  909. }
  910. .del-button-p{
  911. width:300px;
  912. line-height:40px;
  913. text-align: center;
  914. border-radius:6px;
  915. border:1px dashed #999;
  916. font-size:14px;
  917. color:#999;
  918. cursor:pointer;
  919. margin:20px 0 30px 146px;
  920. }
  921. .add-button-p{
  922. width:300px;
  923. line-height:40px;
  924. text-align: center;
  925. border-radius:6px;
  926. border:1px dashed #999;
  927. font-size:14px;
  928. color:#999;
  929. cursor:pointer;
  930. margin:20px 0 30px 146px;
  931. }
  932. .add-button-p-one{
  933. margin-top:-17px;
  934. }
  935. }
  936. .bottom-addCheckPage{
  937. padding:20px;
  938. height:80px;
  939. display: flex;
  940. p:nth-child(1){
  941. flex:1;
  942. }
  943. p:nth-child(2){
  944. width:100px;
  945. margin-right:20px;
  946. }
  947. p:nth-child(3){
  948. width:100px;
  949. }
  950. }
  951. }
  952. }
  953. </style>
  954. <style lang="scss">
  955. .remind-dialog-box{
  956. .el-dialog__body{
  957. padding: 0 20px;
  958. }
  959. .for-box:nth-child(1){
  960. border:none;
  961. }
  962. .for-max-box{
  963. max-height:500px;
  964. }
  965. .for-box{
  966. border-top:1px dashed #dedede;
  967. *{
  968. margin:0;
  969. }
  970. .for-min-box{
  971. display: flex;
  972. margin-bottom:20px;
  973. .for-min-title{
  974. width:80px;
  975. text-align: right;
  976. }
  977. .for-min-text{
  978. flex:1;
  979. }
  980. .for-img-box{
  981. img{
  982. display: inline-block;
  983. width:60px;
  984. height:60px;
  985. border:1px solid #dedede;
  986. overflow: hidden;
  987. margin:0 10px 10px 0;
  988. }
  989. }
  990. }
  991. }
  992. }
  993. </style>