associationConfigurationOne.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <!--关联配置-->
  2. <template>
  3. <div class="associationConfiguration scrollbar-box">
  4. <el-form ref="form" :model="form" label-width="160px" :rules="rules" >
  5. <!--<div class="title-box">-->
  6. <!--<p class="left-title">检查项信息</p>-->
  7. <!--</div>-->
  8. <!--<div>-->
  9. <!--<el-form-item label="穿戴检查项" prop="checkIn" class="form-item">-->
  10. <!--<el-select v-model="form.checkIn" multiple placeholder="请选择穿戴检查项目" @change="radioChange" style="width:320px;">-->
  11. <!--<el-option-->
  12. <!--v-for="dict in onepcOutcheckIn"-->
  13. <!--:key="dict.dictValue"-->
  14. <!--:label="dict.dictLabel"-->
  15. <!--:value="dict.dictValue"-->
  16. <!--&gt;</el-option>-->
  17. <!--</el-select>-->
  18. <!--</el-form-item>-->
  19. <!--<el-form-item label="穿戴检查可跳过" prop="skipped" class="form-item">-->
  20. <!--<el-radio-group v-model="form.skipped" style="width:260px;" @change="radioChange">-->
  21. <!--<el-radio :label="1" style="width:100px;margin-left:50px;margin-top:4px;">是</el-radio>-->
  22. <!--<el-radio :label="0" style="width:100px;margin-top:4px;">否</el-radio>-->
  23. <!--</el-radio-group>-->
  24. <!--</el-form-item>-->
  25. <!--<el-form-item label="穿戴检查识别上限" prop="checkCount" class="form-item" v-if="form.skipped == 1 && form.checkIn[0]">-->
  26. <!--<el-input placeholder="请输入内容" oninput="value=value.replace(/[^0-9.]/g,'')" maxlength="2" v-model="form.checkCount" style="width:320px;">-->
  27. <!--<template slot="prepend" style="height:20px;">次</template>-->
  28. <!--<div slot="append" style="display: flex;flex-direction: column;">-->
  29. <!--<p class="el-icon-arrow-up" @click="addNum" style="line-height:18px;width:30px;font-size:14px;text-align: center;border-bottom:1px solid #E0E0E0;cursor: pointer;"></p>-->
  30. <!--<p class="el-icon-arrow-down" @click="reduceNum" style="line-height:19px;width:30px;font-size:14px;text-align: center;cursor: pointer;"></p>-->
  31. <!--</div>-->
  32. <!--</el-input>-->
  33. <!--</el-form-item>-->
  34. <!--</div>-->
  35. <!--<div>-->
  36. <!--<el-form-item label="离开时检查项" prop="checkOutArr" class="form-item">-->
  37. <!--<el-select v-model="form.checkOut" multiple placeholder="请选择离开检查项" style="width:320px;">-->
  38. <!--<el-option-->
  39. <!--v-for="dict in onepcOutcheck"-->
  40. <!--:key="dict.dictValue"-->
  41. <!--:label="dict.dictLabel"-->
  42. <!--:value="dict.dictValue"-->
  43. <!--&gt;</el-option>-->
  44. <!--</el-select>-->
  45. <!--</el-form-item>-->
  46. <!--<el-form-item label="签到有效时间" prop="signTime" class="form-item">-->
  47. <!--<el-input placeholder="请输入内容" oninput="value=value.replace(/[^0-9.]/g,'')" maxlength="2" v-model="form.signTime" style="width:320px;">-->
  48. <!--<template slot="prepend" style="height:20px;">小时</template>-->
  49. <!--<div slot="append" style="display: flex;flex-direction: column;">-->
  50. <!--<p class="el-icon-arrow-up" @click="addNumOne" style="line-height:18px;width:30px;font-size:14px;text-align: center;border-bottom:1px solid #E0E0E0;cursor: pointer;"></p>-->
  51. <!--<p class="el-icon-arrow-down" @click="reduceNumOne" style="line-height:19px;width:30px;font-size:14px;text-align: center;cursor: pointer;"></p>-->
  52. <!--</div>-->
  53. <!--</el-input>-->
  54. <!--</el-form-item>-->
  55. <!--</div>-->
  56. <div class="title-box">
  57. <p class="left-title">危险源信息</p>
  58. </div>
  59. <el-form-item label="气瓶存放总量" prop="bottleTotal" class="form-item input-number-none-box-left">
  60. <el-input-number
  61. style="width:320px;"
  62. v-model="form.bottleTotal"
  63. placeholder="请输入数量"
  64. :max="999"
  65. clearable
  66. />
  67. </el-form-item>
  68. <el-form-item label="气瓶单人可存放总量" prop="bottleUserTotal" class="form-item input-number-none-box-left">
  69. <el-input-number
  70. style="width:320px;"
  71. v-model="form.bottleUserTotal"
  72. placeholder="请输入数量"
  73. clearable
  74. :max="999"
  75. />
  76. </el-form-item>
  77. <div>
  78. <el-form-item label="危险源" prop="hazardId" class="form-item">
  79. <el-select placeholder="请选择危险源" v-model="hazardId" style="width:320px;" @change="hazardClick">
  80. <el-option
  81. v-for="dict in hazardList"
  82. :key="dict.id"
  83. :label="dict.text"
  84. :value="dict.id"
  85. ></el-option>
  86. </el-select>
  87. </el-form-item>
  88. </div>
  89. <div class="hazard-for-box" v-for="(item,index) in form.hazardRelations">
  90. <el-form-item label="危险源名称" :prop="'hazardRelations.'+ index +'.anotherName'" :rules="rules.anotherName"
  91. class="form-item" label-width="160px">
  92. <el-input placeholder="请输入危险源名称" maxlength="20" v-model="item.anotherName"/>
  93. </el-form-item>
  94. <el-form-item label="型号" :prop="'hazardRelations.'+ index +'.anotherCode'" :rules="rules.anotherCode"
  95. class="form-item" label-width="60px">
  96. <el-input placeholder="请输入型号" maxlength="10" v-model="item.anotherCode"/>
  97. </el-form-item>
  98. <el-form-item label="" class="form-item" label-width="20px">
  99. <span class="del-hazard el-icon-error" style="line-height:40px;font-size:24px;" @click="delHazard(index)"></span>
  100. </el-form-item>
  101. </div>
  102. <div class="bottom-button-box">
  103. <p class="reset-button-one left-button" @click="backPage">取消</p>
  104. <p class="inquire-button-one right-button" @click="upData">提交</p>
  105. </div>
  106. </el-form>
  107. </div>
  108. </template>
  109. <script>
  110. import { listHazard } from "@/api/permissionRequired";
  111. import { updateSubjectEditJoinHazard } from "@/api/laboratory/subject";
  112. import { getBottleInfo} from "@/api/gasManage3_0/gasManage";
  113. export default {
  114. name: "associationConfiguration",
  115. props:{
  116. subjectData:{},
  117. },
  118. data() {
  119. return {
  120. onepcOutcheckIn:[],
  121. onepcOutcheck:[],
  122. hazardList:[],
  123. form:{},
  124. rules:{
  125. anotherName:[
  126. {required: true, message: '请输入危险源名称', trigger: 'blur'},
  127. { required: true, message: "请输入危险源名称", validator: this.spaceJudgment, trigger: "blur" }
  128. ],
  129. anotherCode:[
  130. {required: true, message: '请输入型号', trigger: 'blur'},
  131. { required: true, message: "请输入型号", validator: this.spaceJudgment, trigger: "blur" }
  132. ],
  133. },
  134. hazardId:"",
  135. }
  136. },
  137. created() {
  138. },
  139. mounted(){
  140. let self = this;
  141. //获取气瓶存放总量
  142. this.getBottleInfo();
  143. this.getDicts("sub_check_in").then(response => {
  144. this.onepcOutcheckIn = response.data;
  145. });
  146. this.getDicts("lab_onepc_outcheck").then(response => {
  147. this.onepcOutcheck = response.data;
  148. });
  149. this.listHazard();
  150. if(this.subjectData.id){
  151. this.form.id = this.subjectData.id;
  152. }
  153. // if(this.subjectData.signTime) {
  154. // this.$set(this.form,'signTime',this.subjectData.signTime);
  155. // }
  156. // if(this.subjectData.checkIn){
  157. // let list = this.subjectData.checkIn.split(",");
  158. // this.$set(this.form,'checkIn',list);
  159. // // this.form.checkIn = this.subjectData.checkIn.split(",");
  160. // }
  161. // if(this.subjectData.checkOut){
  162. // let list = this.subjectData.checkOut.split(",");
  163. // this.$set(this.form,'checkOut',list);
  164. // // this.form.checkOut = this.subjectData.checkOut.split(",");
  165. // }
  166. // if(this.subjectData.skipped && this.subjectData.skipped!=null){
  167. // this.$set(this.form,'skipped',this.subjectData.skipped)
  168. // }else{
  169. // this.$set(this.form,'skipped',0)
  170. // }
  171. // if(this.subjectData.checkCount){
  172. // this.$set(this.form,'checkCount',this.subjectData.checkCount)
  173. // }else{
  174. // this.$set(this.form,'checkCount',0)
  175. // }
  176. if(this.subjectData.labHazardList){
  177. let list = [];
  178. for(let i=0;i<self.subjectData.labHazardList.length;i++){
  179. list.push({
  180. hazardId:self.subjectData.labHazardList[i].id,
  181. anotherName:self.subjectData.labHazardList[i].anotherName,
  182. anotherCode:self.subjectData.labHazardList[i].anotherCode
  183. })
  184. }
  185. this.$set(this.form,'hazardRelations',list)
  186. }
  187. // this.radioChange();
  188. },
  189. methods:{
  190. //删除选中危险源
  191. delHazard(index){
  192. console.log(index);
  193. this.form.hazardRelations.splice(index, 1);
  194. this.$forceUpdate();
  195. },
  196. //危险源选中事件
  197. hazardClick(e){
  198. console.log("e",e);
  199. let self = this;
  200. for(let i=0;i<self.hazardList.length;i++){
  201. if(e == self.hazardList[i].id){
  202. this.form.hazardRelations.push({
  203. hazardId:self.hazardList[i].id,
  204. anotherName:self.hazardList[i].anotherName,
  205. anotherCode:self.hazardList[i].anotherCode
  206. });
  207. console.log("self.hazardList[i]",self.hazardList[i])
  208. }
  209. }
  210. console.log("self.hazardList[i]",self.form.hazardRelations)
  211. this.$forceUpdate();
  212. },
  213. radioChange(){
  214. if(this.form.skipped == 0){
  215. let obj = {
  216. checkIn:[
  217. {required: true, message: '请选择穿戴检查项目', trigger: 'blur'}
  218. ]
  219. };
  220. this.$set(this,'rules',obj);
  221. }else if(this.form.skipped == 1){
  222. if(this.form.checkIn[0]){
  223. let obj = {
  224. checkIn:[
  225. {required: true, message: '请选择穿戴检查项目', trigger: 'blur'}
  226. ]
  227. };
  228. this.$set(this,'rules',obj);
  229. }else{
  230. this.$set(this,'rules',{});
  231. this.$refs['form'].clearValidate();
  232. }
  233. }
  234. // if(e == 1){
  235. // this.$set(this,'rules',{});
  236. // this.$refs['form'].clearValidate();
  237. // }else if(e == 0){
  238. // let obj = {
  239. // checkIn:[
  240. // {required: true, message: '请选择穿戴检查项目', trigger: 'blur'}
  241. // ]
  242. // }
  243. // this.$set(this,'rules',obj);
  244. // }
  245. },
  246. addNum(){
  247. if(this.form.checkCount<99){
  248. this.form.checkCount++
  249. }
  250. },
  251. reduceNum(){
  252. if(this.form.checkCount>2){
  253. this.form.checkCount--
  254. }
  255. },
  256. addNumOne(){
  257. console.log("1")
  258. if(this.form.signTime<99){
  259. this.form.signTime++
  260. }
  261. },
  262. reduceNumOne(){
  263. console.log("2")
  264. if(this.form.signTime>2){
  265. this.form.signTime--
  266. }
  267. },
  268. //获取气瓶存放总量
  269. getBottleInfo(){
  270. getBottleInfo({subjectId:this.subjectData.id}).then(response=>{
  271. let res=response.data;
  272. if(response.code==200){
  273. if(res.bottleTotal && res.bottleUserTotal){
  274. this.$set(this.form,'bottleUserTotal',res.bottleUserTotal);
  275. this.$set(this.form,'bottleTotal',res.bottleTotal);
  276. // this.form.bottleUserTotal=res.bottleUserTotal;
  277. // this.form.bottleTotal=res.bottleTotal;
  278. }
  279. }
  280. })
  281. },
  282. //获取危险源列表
  283. listHazard(){
  284. listHazard({}).then(response=>{
  285. for(let i=0;i<response.data.length;i++){
  286. response.data[i].text = response.data[i].anotherName+'-'+response.data[i].anotherCode
  287. }
  288. this.$set(this,'hazardList',response.data);
  289. })
  290. },
  291. upData(){
  292. let self = this;
  293. this.$refs["form"].validate(valid => {
  294. if (valid) {
  295. if(self.form.skipped == 1 && self.form.checkCount<2 && self.form.checkIn[0]){
  296. this.msgError('穿戴检查识别上限不能小于2')
  297. return
  298. }
  299. self.$confirm('是否确认提交?', "", {
  300. confirmButtonText: "确定",
  301. cancelButtonText: "取消",
  302. type: "warning"
  303. }).then(function() {
  304. self.updateSubjectEditJoinHazard();
  305. }).then(() => {}).catch(() => {});
  306. }
  307. })
  308. },
  309. updateSubjectEditJoinHazard(){
  310. let self = this;
  311. let obj = {
  312. id:self.form.id,
  313. // skipped:self.form.skipped,
  314. }
  315. // if(self.form.skipped == 1 && self.form.checkIn[0]){
  316. // obj.checkCount = self.form.checkCount
  317. // }
  318. // if(self.form.checkIn) {
  319. // obj.checkIn = self.form.checkIn.join() ;
  320. // }
  321. // if(self.form.signTime) {
  322. // obj.signTime = self.form.signTime;
  323. // }
  324. // if(self.form.checkOut) {
  325. // obj.checkOut = self.form.checkOut.join() ;
  326. // }
  327. if (self.form.hazardRelations[0]){
  328. obj.hazardRelations = self.form.hazardRelations
  329. }
  330. if(self.form.bottleUserTotal) {
  331. obj.bottleUserTotal = self.form.bottleUserTotal;
  332. }
  333. if(self.form.bottleTotal) {
  334. obj.bottleTotal = self.form.bottleTotal;
  335. }
  336. // if(self.form.hazardRelations) {
  337. // let list = self.form.hazardRelations;
  338. // let newList = [];
  339. // for(let i=0;i<list.length;i++){
  340. // let newObj = {
  341. // hazardId:list[i],
  342. // };
  343. // newList.push(newObj);
  344. // }
  345. // obj.hazardRelations = newList;
  346. // }
  347. updateSubjectEditJoinHazard(obj).then(response => {
  348. this.msgSuccess("修改成功");
  349. this.$parent.clickPage(1);
  350. });
  351. },
  352. //返回上一页
  353. backPage(){
  354. this.$parent.clickPage(1);
  355. },
  356. }
  357. }
  358. </script>
  359. <style lang="scss" scoped>
  360. .associationConfiguration{
  361. flex:1;
  362. display: flex;
  363. flex-direction: column;
  364. border-radius:10px!important;
  365. margin:5px 20px 20px 10px!important;
  366. box-shadow: 0 0 8px 1px rgba(0, 0, 0, 0.1) !important;
  367. *{
  368. margin:0;
  369. }
  370. .title-box{
  371. display: flex;
  372. margin:0 20px 30px;
  373. border-bottom:1px solid #E0E0E0;
  374. .left-title{
  375. flex:1;
  376. height:80px;
  377. line-height:80px;
  378. color:#0045AF;
  379. font-size:18px;
  380. }
  381. .right-button{
  382. margin:20px 0;
  383. }
  384. }
  385. .form-item{
  386. display: inline-block;
  387. overflow: hidden;
  388. min-height:70px;
  389. }
  390. .hazard-for-box{
  391. .del-hazard{
  392. color:#dedede;
  393. }
  394. .del-hazard:hover{
  395. cursor: pointer;
  396. color:#FF6666;
  397. }
  398. }
  399. .bottom-button-box{
  400. display: flex;
  401. width:400px;
  402. margin:10px auto 40px;
  403. .null-p{
  404. flex:1;
  405. }
  406. .left-button{
  407. margin-right:20px;
  408. }
  409. }
  410. }
  411. </style>