addCheck.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979
  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="defaultCheckOptionList"
  137. @change="(val)=>cascaderChange(val,index)"
  138. @focus="focusClick()"
  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="focusCheck(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="addForm" :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. defaultCheckOption:[],
  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. addList:[],
  346. };
  347. },
  348. created() {
  349. this.getListCheckOptionData();
  350. this.getListCheckOptionTwo();
  351. this.treeselect();
  352. },
  353. methods: {
  354. remindOff(){
  355. this.remindOpen = false;
  356. },
  357. remindButton(){
  358. this.remindOpen = false;
  359. },
  360. jcDwChange(val){
  361. let self = this;
  362. for(let i=0;i<self.inspectionUnitArrayData.length;i++){
  363. if(val == self.inspectionUnitArrayData[i].id){
  364. this.form.jcDwName = self.inspectionUnitArrayData[i].label;
  365. }
  366. }
  367. },
  368. //根据用户获取对应检查单位列表
  369. selectDeptListUserDeptId(){
  370. selectDeptListUserDeptId().then( data => {
  371. this.inspectionUnitArrayData = data.data;
  372. })
  373. },
  374. treeselect(){
  375. treeselect().then( data => {
  376. // let list = [];
  377. // for(let i=0;i<data.data[0].children.length;i++){
  378. // let obj = {
  379. // id:data.data[0].children[i].id,
  380. // label:data.data[0].children[i].label,
  381. // }
  382. // list.push(obj);
  383. // for(let o=0;o<data.data[0].children[i].children.length;o++){
  384. // let obj = {
  385. // id:data.data[0].children[i].children[o].id,
  386. // label:data.data[0].children[i].children[o].label,
  387. // }
  388. // list.push(obj);
  389. // }
  390. // }
  391. // this.inspectionUnitArrayData = list;
  392. this.inspectionUnitArrayData = this.toArray(data.data);
  393. });
  394. },
  395. toArray(data){
  396. let list = [];
  397. let newList = JSON.parse(JSON.stringify(data));
  398. for(let i=0;i<newList.length;i++){
  399. pushNode(newList[i]);
  400. }
  401. function pushNode(node){
  402. if(node.children){
  403. for (let nodeItem of node.children){
  404. pushNode(nodeItem)
  405. }
  406. delete node.children;
  407. list.push(node)
  408. }else{
  409. if(node.children){
  410. delete node.children
  411. }
  412. list.push(node)
  413. }
  414. }
  415. return list
  416. },
  417. //删除隐患
  418. delDanger(index){
  419. this.form.detailsList.splice(index,1)
  420. this.$forceUpdate();
  421. },
  422. //新增隐患项
  423. addDanger(){
  424. if(!this.form.fjNumber){
  425. this.msgError("请先选择房间")
  426. return
  427. }
  428. if(this.form.detailsList.length>19){
  429. this.msgError("最多添加20个隐患")
  430. return
  431. }
  432. let obj = {
  433. yhImg:[],
  434. yhMs:"",
  435. };
  436. this.form.detailsList.push(obj);
  437. },
  438. //上传
  439. handleAvatarSuccess(res, file, index) {
  440. //let url=window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API+"/"+res.data.url;
  441. this.form.detailsList[index].yhImg.push(res.data.url);
  442. this.$forceUpdate()
  443. },
  444. beforeAvatarUpload(file) {
  445. let type = false;
  446. console.log('file',file);
  447. if (file.type == 'image/png' || file.type == 'image/jpeg' || file.type == 'image/gif') {
  448. type = true;
  449. }else{
  450. this.$message.error('只能上传png/jpeg/gif格式图片');
  451. type = false;
  452. }
  453. return type;
  454. },
  455. //删除
  456. imgDel(index,minIndex){
  457. this.form.detailsList[index].yhImg.splice(minIndex,1);
  458. },
  459. /** 查询安全检查列表 */
  460. getList() {
  461. this.loading = true;
  462. listCheckRecord({}).then( response => {
  463. this.checkRecordList = response.rows;
  464. this.total = response.total;
  465. this.loading = false;
  466. });
  467. },
  468. //发布按钮
  469. nameFormButton(type){
  470. if(type == 1){
  471. this.nameOpen = false;
  472. }else if(type == 2){
  473. this.$refs["nameForm"].validate(valid => {
  474. if (valid) {
  475. this.loading = true;
  476. this.formData.checkName = this.nameForm.checkName;
  477. checkRecordAdd(this.formData).then( response => {
  478. this.msgSuccess('提交成功')
  479. this.addList = [];
  480. this.getListCheckOptionData();
  481. this.delForm();
  482. this.nameOpen = false;
  483. this.loading = false;
  484. });
  485. }
  486. })
  487. }
  488. },
  489. /** 提交按钮 */
  490. submitForm(type) {
  491. let self = this;
  492. if(!this.form.detailsList[0]){
  493. this.msgError('请添加至少一个隐患项')
  494. return
  495. }
  496. this.$refs["form"].validate(valid => {
  497. if (valid) {
  498. let obj = JSON.parse(JSON.stringify(self.form));
  499. for(let i=0;i<obj.detailsList.length;i++){
  500. if(obj.detailsList[i].jcxName.indexOf("/") != -1){
  501. let list = obj.detailsList[i].jcxName.split("/");
  502. obj.detailsList[i].jcxName = list[list.length-1];
  503. }
  504. obj.detailsList[i].jcxId = obj.detailsList[i].jcxId + ',';
  505. obj.detailsList[i].yhImg = obj.detailsList[i].yhImg + '';
  506. }
  507. obj.zgStatus = 0;
  508. if(type == 1){
  509. obj.isCg = 1;
  510. }else if(type == 2){
  511. obj.isCg = 0;
  512. }
  513. this.formData = JSON.parse(JSON.stringify(obj));
  514. if(type == 1){
  515. this.loading = true;
  516. checkRecordAddC(this.formData).then( response => {
  517. this.msgSuccess('保存草稿成功')
  518. this.addList = [];
  519. this.getListCheckOptionData();
  520. this.delForm();
  521. this.loading = false;
  522. });
  523. }else{
  524. this.nameForm.checkName = "";
  525. this.nameOpen = true;
  526. }
  527. }
  528. });
  529. },
  530. delForm(){
  531. let obj = {
  532. fjNumber:"",
  533. buildingId:"",
  534. buildingName:"",
  535. laboratoryId:"",
  536. laboratoryName:"",
  537. fzrName:"",
  538. fzrLxfs:"",
  539. detailsList:[
  540. // {
  541. // isLingshi:0,
  542. // yhImg:[],
  543. // yhMs:"",
  544. // jcxId:"",
  545. // jcxName:"",
  546. // }
  547. ],
  548. }
  549. this.fjNumber = "";
  550. this.$set(this,"form",obj)
  551. },
  552. /** 下列人员-懒加载 */
  553. userSelectList(query) {
  554. // if (query !== '' && query.length>1) {
  555. // this.loading = true;
  556. // this.userSelectList.nickName=query;
  557. // selectListUser(this.userSelectList).then(response => {
  558. // this.optionsUser = response.data;
  559. // this.loading = false;
  560. // });
  561. // } else {
  562. // this.optionsUser = [];
  563. // }
  564. },
  565. //新增检查项
  566. dialogClick(index){
  567. this.openIndex = index;
  568. this.examinationForm = {};
  569. this.open = true;
  570. },
  571. //检查项联机触发
  572. handleChange() {
  573. },
  574. //检查项确定
  575. cascaderChange(val,index){
  576. let self = this;
  577. if (val[0]){
  578. let text = "";
  579. let cascaderList = this.$refs['cascaderGet'][index].getCheckedNodes()[0].pathLabels // 获取label值
  580. let nodesList = this.$refs['cascaderGet'][index].getCheckedNodes()[0].pathNodes // 获取label值
  581. let jcxSstkNum = nodesList[nodesList.length-1].data.code;
  582. let jcxSstkMs = "";
  583. for(let i=0;i<nodesList.length-1;i++){
  584. if(i == 0){
  585. jcxSstkMs = jcxSstkMs + nodesList[i].data.name
  586. }else{
  587. jcxSstkMs = jcxSstkMs + '-' + nodesList[i].data.name
  588. }
  589. }
  590. let num = 0;
  591. for(let i=0;i<self.temporaryIdList.length;i++){
  592. if(self.temporaryIdList[i] == val){
  593. num++
  594. }
  595. }
  596. if(num == 0){
  597. this.$set(this.form.detailsList[index],'isLingshi',0);
  598. }else{
  599. this.$set(this.form.detailsList[index],'isLingshi',1);
  600. }
  601. this.$set(this.form.detailsList[index],'jcxName',cascaderList[cascaderList.length-1]);
  602. this.$set(this.form.detailsList[index],'jcxSstkNum',jcxSstkNum);
  603. this.$set(this.form.detailsList[index],'jcxSstkMs',jcxSstkMs);
  604. }else{
  605. this.$set(this.form.detailsList[index],'isLingshi',0);
  606. this.$set(this.form.detailsList[index],'jcxName',"");
  607. this.$set(this.form.detailsList[index],'jcxSstkNum',"");
  608. this.$set(this.form.detailsList[index],'jcxSstkMs',"");
  609. }
  610. console.log('val',val);
  611. if(val[0]){
  612. let obj = {
  613. laboratoryId:this.form.laboratoryId,
  614. checkId:val[val.length-1],
  615. };
  616. hiddenDangerCount(obj).then( response => {
  617. this.$set(this.form.detailsList[index],'yhcount',response.data.yhcount);
  618. if(response.data.yhflg){
  619. for(let i=0;i<response.data.yhlist.length;i++){
  620. response.data.yhlist[i].yhImg = response.data.yhlist[i].yhImg.split(',')
  621. }
  622. this.$set(this,'remindList',response.data.yhlist);
  623. this.remindOpen = true;
  624. }
  625. });
  626. }else{
  627. this.$set(this.form.detailsList[index],'yhcount','');
  628. }
  629. },
  630. //新增检查项
  631. dialogSubmitForm(){
  632. this.$refs["addForm"].validate(valid => {
  633. if (valid) {
  634. let obj = {
  635. name:this.examinationForm.name,
  636. parentId:this.examinationForm.idList[this.examinationForm.idList.length-1]
  637. };
  638. addTempCheckOption(obj).then( response => {
  639. let obj = {
  640. id:response.data.id,
  641. name:response.data.name,
  642. };
  643. this.defaultCheckOptionList.push(obj);
  644. this.addList.push(obj);
  645. this.temporaryIdList.push(response.data.id);
  646. this.$set(this.form.detailsList[this.openIndex],'jcxId',response.data.id);
  647. this.$set(this.form.detailsList[this.openIndex],'jcxName',response.data.name);
  648. this.$set(this.form.detailsList[this.openIndex],'isLingshi',1);
  649. this.msgSuccess("新增成功");
  650. this.open = false;
  651. });
  652. }
  653. });
  654. },
  655. //关闭检查项
  656. cancel(){
  657. this.open = false;
  658. },
  659. //实验室数据懒加载
  660. getSelectInfoByRoom(query){
  661. console.log("query",query);
  662. if (query !== '' && query.length>0) {
  663. this.loading = true;
  664. let obj = {
  665. room:query,
  666. }
  667. selectInfoByRoom(obj).then(response => {
  668. this.optionsSelect = response.data;
  669. this.loading = false;
  670. });
  671. } else {
  672. this.optionsSelect = [];
  673. }
  674. },
  675. //清除实验室选中
  676. delSelect(){
  677. },
  678. //实验室房间懒加载选中
  679. selectChange(name){
  680. let self = this;
  681. if(!this.fjNumber){
  682. if(name){
  683. for(let i=0;i<self.optionsSelect.length;i++){
  684. if(name == self.optionsSelect[i].room){
  685. self.$set(self,"fjNumber",self.optionsSelect[i].room)
  686. self.$set(self.form,"fjNumber",self.optionsSelect[i].room)
  687. // self.$set(self.form,"laboratoryId",self.optionsSelect[i].building)
  688. // self.$set(self.form,"buildingId",self.optionsSelect[i].deptId)
  689. // self.$set(self.form,"deptId",self.optionsSelect[i].id)
  690. self.$set(self.form,"laboratoryId",self.optionsSelect[i].id)
  691. self.$set(self.form,"buildingId",self.optionsSelect[i].building)
  692. self.$set(self.form,"deptId",self.optionsSelect[i].deptId)
  693. self.$set(self.form,"deptName",self.optionsSelect[i].deptName)
  694. self.$set(self.form,"buildingName",self.optionsSelect[i].buildName)
  695. self.$set(self.form,"laboratoryName",self.optionsSelect[i].name)
  696. self.$set(self.form,"fzrId",self.optionsSelect[i].userId)
  697. self.$set(self.form,"fzrName",self.optionsSelect[i].safeUserName)
  698. self.$set(self.form,"fzrLxfs",self.optionsSelect[i].safeUserPhone)
  699. }
  700. }
  701. }
  702. else{
  703. self.$set(self.form,"fjNumber","")
  704. self.$set(self.form,"buildingId","")
  705. self.$set(self.form,"deptName","")
  706. self.$set(self.form,"deptId","")
  707. self.$set(self.form,"buildingName","")
  708. self.$set(self.form,"laboratoryId","")
  709. self.$set(self.form,"laboratoryName","")
  710. self.$set(self.form,"fzrId","")
  711. self.$set(self.form,"fzrName","")
  712. self.$set(self.form,"fzrLxfs","")
  713. }
  714. }else{
  715. if(this.fjNumber != name){
  716. this.$confirm('更换实验室后需要从新选择检查项,是否确认更换实验室?', "警告", {
  717. confirmButtonText: "确定",
  718. cancelButtonText: "取消",
  719. type: "warning"
  720. }).then(function() {
  721. }).then(() => {
  722. for(let i=0;i<self.optionsSelect.length;i++){
  723. if(name == self.optionsSelect[i].room){
  724. self.$set(self,"fjNumber",self.optionsSelect[i].room)
  725. self.$set(self.form,"fjNumber",self.optionsSelect[i].room)
  726. self.$set(self.form,"buildingId",self.optionsSelect[i].deptId)
  727. self.$set(self.form,"deptName",self.optionsSelect[i].deptName)
  728. self.$set(self.form,"deptId",self.optionsSelect[i].id)
  729. self.$set(self.form,"buildingName",self.optionsSelect[i].buildName)
  730. self.$set(self.form,"laboratoryId",self.optionsSelect[i].building)
  731. self.$set(self.form,"laboratoryName",self.optionsSelect[i].name)
  732. self.$set(self.form,"fzrId",self.optionsSelect[i].userId)
  733. self.$set(self.form,"fzrName",self.optionsSelect[i].safeUserName)
  734. self.$set(self.form,"fzrLxfs",self.optionsSelect[i].safeUserPhone)
  735. self.$set(self.form,"detailsList",[])
  736. }
  737. }
  738. }).catch(() => {
  739. self.$set(self.form,"fjNumber",self.fjNumber)
  740. this.getSelectInfoByRoom(self.fjNumber)
  741. });
  742. }
  743. }
  744. },
  745. getListCheckOptionData(){
  746. let newObj = {
  747. level:4,
  748. }
  749. listCheckOption(newObj).then( response => {
  750. this.defaultCheckOptionList = this.getTreeData(response.data);
  751. this.$set(this,'defaultCheckOption',this.defaultCheckOptionList);
  752. });
  753. },
  754. focusClick(){
  755. this.$set(this,'defaultCheckOptionList',JSON.parse(JSON.stringify(this.defaultCheckOption.concat(this.addList))));
  756. },
  757. filterRegion(value,index){
  758. this.getListCheckOptionOne(value,index);
  759. return false
  760. },
  761. //获取检查项
  762. getListCheckOptionOne(data,index) {
  763. let newObj = {
  764. level:4,
  765. searchValue:data
  766. }
  767. listCheckOption(newObj).then( response => {
  768. let list = this.getTreeData(response.data);
  769. if(list[0]){
  770. list = list.concat(this.addList);
  771. this.$set(this,'defaultCheckOptionList',JSON.parse(JSON.stringify(list)))
  772. this.$forceUpdate()
  773. }else{
  774. this.msgError('未找到相关检查项')
  775. }
  776. });
  777. },
  778. getListCheckOptionTwo(){
  779. let newObj = {
  780. level:3,
  781. }
  782. listCheckOption(newObj).then( response => {
  783. let list = this.getTreeData(response.data);
  784. this.checkOptionListExamination = JSON.parse(JSON.stringify(list));
  785. });
  786. },
  787. getTreeData(data){
  788. for(var i=0;i<data.length>0;i++){
  789. if(data[i].children == null||data[i].children.length<=0){
  790. // children若为空数组,则将children设为undefined
  791. data[i].children = undefined;
  792. }else {
  793. // children若不为空数组,则继续 递归调用 本方法
  794. this.getTreeData(data[i].children);
  795. }
  796. }
  797. return data;
  798. },
  799. }
  800. };
  801. </script>
  802. <style scoped lang="scss">
  803. .addCheckPage{
  804. flex:1;
  805. display: flex;
  806. flex-direction: column;
  807. overflow: hidden !important;
  808. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  809. .addCheckPage-min{
  810. flex:1;
  811. display: flex;
  812. flex-direction: column;
  813. overflow: hidden !important;
  814. .top-addCheckPage-title{
  815. line-height:60px;
  816. padding:0 20px;
  817. font-size:16px;
  818. border-bottom:1px solid #dedede;
  819. }
  820. .top-addCheckPage{
  821. padding:20px 20px 10px;
  822. .el-form-item-top{
  823. margin:10px 24px 20px 0;
  824. }
  825. }
  826. .center-addCheckPage{
  827. flex:1;
  828. display: flex;
  829. flex-direction: column;
  830. overflow-y: scroll;
  831. border-top:1px solid #dedede;
  832. border-bottom:1px solid #dedede;
  833. .form-list-for-box:nth-child(1){
  834. border:none;
  835. }
  836. .form-list-for-box{
  837. border-top:1px solid #dedede;
  838. .el-form-item-bottom{
  839. display: block;
  840. margin:20px 0 30px 0;
  841. .el-form-item-bottom-up{
  842. display: flex;
  843. min-width:200px;
  844. .form-up-img-box{
  845. .up-img-for-box{
  846. display: inline-block;
  847. width:80px;
  848. height:80px;
  849. position: relative;
  850. margin:10px 10px 0 0;
  851. img{
  852. width:80px;
  853. height:80px;
  854. }
  855. .del-i{
  856. position: absolute;
  857. top:0;
  858. right:0;
  859. width:20px;
  860. height:20px;
  861. line-height:20px;
  862. background: rgba(0,0,0,0.4);
  863. color:#fff;
  864. font-size:14px;
  865. text-align: center;
  866. cursor:pointer;
  867. }
  868. .del-i:hover{
  869. background: #FF6666;
  870. }
  871. }
  872. .certificate-avatar-uploader{
  873. width:80px;
  874. height:80px;
  875. }
  876. }
  877. }
  878. }
  879. .text-span{
  880. margin-left:20px;
  881. color:#999;
  882. }
  883. .add-span{
  884. margin-left:10px;
  885. color:#0183FA;
  886. cursor:pointer;
  887. }
  888. }
  889. .del-button-p{
  890. width:300px;
  891. line-height:40px;
  892. text-align: center;
  893. border-radius:6px;
  894. border:1px dashed #999;
  895. font-size:14px;
  896. color:#999;
  897. cursor:pointer;
  898. margin:20px 0 30px 146px;
  899. }
  900. .add-button-p{
  901. width:300px;
  902. line-height:40px;
  903. text-align: center;
  904. border-radius:6px;
  905. border:1px dashed #999;
  906. font-size:14px;
  907. color:#999;
  908. cursor:pointer;
  909. margin:20px 0 30px 146px;
  910. }
  911. .add-button-p-one{
  912. margin-top:-17px;
  913. }
  914. }
  915. .bottom-addCheckPage{
  916. padding:20px;
  917. height:80px;
  918. display: flex;
  919. p:nth-child(1){
  920. flex:1;
  921. }
  922. p:nth-child(2){
  923. width:100px;
  924. margin-right:20px;
  925. }
  926. p:nth-child(3){
  927. width:100px;
  928. }
  929. }
  930. }
  931. }
  932. </style>
  933. <style lang="scss">
  934. .remind-dialog-box{
  935. .el-dialog__body{
  936. padding: 0 20px;
  937. }
  938. .for-box:nth-child(1){
  939. border:none;
  940. }
  941. .for-max-box{
  942. max-height:500px;
  943. }
  944. .for-box{
  945. border-top:1px dashed #dedede;
  946. *{
  947. margin:0;
  948. }
  949. .for-min-box{
  950. display: flex;
  951. margin-bottom:20px;
  952. .for-min-title{
  953. width:80px;
  954. text-align: right;
  955. }
  956. .for-min-text{
  957. flex:1;
  958. }
  959. .for-img-box{
  960. img{
  961. display: inline-block;
  962. width:60px;
  963. height:60px;
  964. border:1px solid #dedede;
  965. overflow: hidden;
  966. margin:0 10px 10px 0;
  967. }
  968. }
  969. }
  970. }
  971. }
  972. </style>