associationConfigurationOne.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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. console.log(index);
  142. this.form.hazardRelations.splice(index, 1);
  143. this.$forceUpdate();
  144. },
  145. //危险源选中事件
  146. hazardClick(e){
  147. console.log("e",e);
  148. let self = this;
  149. for(let i=0;i<self.hazardList.length;i++){
  150. if(e == self.hazardList[i].id){
  151. this.form.hazardRelations.push({
  152. hazardId:self.hazardList[i].id,
  153. anotherName:self.hazardList[i].anotherName,
  154. anotherCode:self.hazardList[i].anotherCode
  155. });
  156. console.log("self.hazardList[i]",self.hazardList[i])
  157. }
  158. }
  159. console.log("self.hazardList[i]",self.form.hazardRelations)
  160. this.$forceUpdate();
  161. },
  162. radioChange(){
  163. if(this.form.skipped == 0){
  164. let obj = {
  165. checkIn:[
  166. {required: true, message: '请选择穿戴检查项目', trigger: 'blur'}
  167. ]
  168. };
  169. this.$set(this,'rules',obj);
  170. }else if(this.form.skipped == 1){
  171. if(this.form.checkIn[0]){
  172. let obj = {
  173. checkIn:[
  174. {required: true, message: '请选择穿戴检查项目', trigger: 'blur'}
  175. ]
  176. };
  177. this.$set(this,'rules',obj);
  178. }else{
  179. this.$set(this,'rules',{});
  180. this.$refs['form'].clearValidate();
  181. }
  182. }
  183. // if(e == 1){
  184. // this.$set(this,'rules',{});
  185. // this.$refs['form'].clearValidate();
  186. // }else if(e == 0){
  187. // let obj = {
  188. // checkIn:[
  189. // {required: true, message: '请选择穿戴检查项目', trigger: 'blur'}
  190. // ]
  191. // }
  192. // this.$set(this,'rules',obj);
  193. // }
  194. },
  195. addNum(){
  196. if(this.form.checkCount<99){
  197. this.form.checkCount++
  198. }
  199. },
  200. reduceNum(){
  201. if(this.form.checkCount>2){
  202. this.form.checkCount--
  203. }
  204. },
  205. addNumOne(){
  206. console.log("1")
  207. if(this.form.signTime<99){
  208. this.form.signTime++
  209. }
  210. },
  211. reduceNumOne(){
  212. console.log("2")
  213. if(this.form.signTime>2){
  214. this.form.signTime--
  215. }
  216. },
  217. //获取气瓶存放总量
  218. getBottleInfo(){
  219. getBottleInfo({subjectId:this.subjectData.id}).then(response=>{
  220. let res=response.data;
  221. if(response.code==200){
  222. if(res.bottleTotal && res.bottleUserTotal){
  223. this.$set(this.form,'bottleUserTotal',res.bottleUserTotal);
  224. this.$set(this.form,'bottleTotal',res.bottleTotal);
  225. // this.form.bottleUserTotal=res.bottleUserTotal;
  226. // this.form.bottleTotal=res.bottleTotal;
  227. }
  228. }
  229. })
  230. },
  231. //获取危险源列表
  232. listHazard(){
  233. listHazard({}).then(response=>{
  234. for(let i=0;i<response.data.length;i++){
  235. response.data[i].text = response.data[i].anotherName+'-'+response.data[i].anotherCode
  236. }
  237. this.$set(this,'hazardList',response.data);
  238. })
  239. },
  240. upData(){
  241. let self = this;
  242. this.$refs["form"].validate(valid => {
  243. if (valid) {
  244. if(self.form.skipped == 1 && self.form.checkCount<2 && self.form.checkIn[0]){
  245. this.msgError('穿戴检查识别上限不能小于2')
  246. return
  247. }
  248. self.$confirm('是否确认提交?', "", {
  249. confirmButtonText: "确定",
  250. cancelButtonText: "取消",
  251. type: "warning"
  252. }).then(function() {
  253. self.updateSubjectEditJoinHazard();
  254. }).then(() => {}).catch(() => {});
  255. }
  256. })
  257. },
  258. updateSubjectEditJoinHazard(){
  259. let self = this;
  260. let obj = {
  261. id:self.form.id,
  262. // skipped:self.form.skipped,
  263. }
  264. // if(self.form.skipped == 1 && self.form.checkIn[0]){
  265. // obj.checkCount = self.form.checkCount
  266. // }
  267. // if(self.form.checkIn) {
  268. // obj.checkIn = self.form.checkIn.join() ;
  269. // }
  270. // if(self.form.signTime) {
  271. // obj.signTime = self.form.signTime;
  272. // }
  273. // if(self.form.checkOut) {
  274. // obj.checkOut = self.form.checkOut.join() ;
  275. // }
  276. if (self.form.hazardRelations[0]){
  277. obj.hazardRelations = self.form.hazardRelations
  278. }
  279. if(self.form.bottleUserTotal) {
  280. obj.bottleUserTotal = self.form.bottleUserTotal;
  281. }
  282. if(self.form.bottleTotal) {
  283. obj.bottleTotal = self.form.bottleTotal;
  284. }
  285. // if(self.form.hazardRelations) {
  286. // let list = self.form.hazardRelations;
  287. // let newList = [];
  288. // for(let i=0;i<list.length;i++){
  289. // let newObj = {
  290. // hazardId:list[i],
  291. // };
  292. // newList.push(newObj);
  293. // }
  294. // obj.hazardRelations = newList;
  295. // }
  296. updateSubjectEditJoinHazard(obj).then(response => {
  297. this.msgSuccess("修改成功");
  298. this.$parent.clickPage(1);
  299. });
  300. },
  301. //返回上一页
  302. backPage(){
  303. this.$parent.clickPage(1);
  304. },
  305. }
  306. }
  307. </script>
  308. <style lang="scss" scoped>
  309. .associationConfiguration{
  310. flex:1;
  311. display: flex;
  312. flex-direction: column;
  313. border-radius:10px!important;
  314. margin:5px 20px 20px 10px!important;
  315. box-shadow: 0 0 8px 1px rgba(0, 0, 0, 0.1) !important;
  316. *{
  317. margin:0;
  318. }
  319. .title-box{
  320. display: flex;
  321. margin:0 20px 30px;
  322. border-bottom:1px solid #E0E0E0;
  323. .left-title{
  324. flex:1;
  325. height:80px;
  326. line-height:80px;
  327. color:#0045AF;
  328. font-size:18px;
  329. }
  330. .right-button{
  331. margin:20px 0;
  332. }
  333. }
  334. .form-item{
  335. display: inline-block;
  336. overflow: hidden;
  337. min-height:70px;
  338. }
  339. .hazard-for-box{
  340. .del-hazard{
  341. color:#dedede;
  342. }
  343. .del-hazard:hover{
  344. cursor: pointer;
  345. color:#FF6666;
  346. }
  347. }
  348. .bottom-button-box{
  349. display: flex;
  350. width:400px;
  351. margin:10px auto 40px;
  352. .null-p{
  353. flex:1;
  354. }
  355. .left-button{
  356. margin-right:20px;
  357. }
  358. }
  359. }
  360. </style>