addCheck.vue 34 KB

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