associationConfigurationOne.vue 11 KB

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