addPage.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <div class="addPage">
  3. <div class="title-box">
  4. <p>报警通知配置</p>
  5. <p class="reset-button-one" @click="backPage"><i class="el-icon-arrow-left"></i>返回</p>
  6. </div>
  7. <div class="addPage-min scrollbar-box">
  8. <p class="addPage-min-title-box"><i class="el-icon-question"></i>化学品领用超时未归还,或未领用即携带化学品离开房间报警设置</p>
  9. <el-form :model="formData" ref="form" :inline="true" :rules="rules" label-width="100px" style="position: relative;">
  10. <el-form-item label="适用学院:" >
  11. <el-select v-model="formData.alarmDeptId" clearable placeholder="请选择适用学院" style="width:400px;" @change="deptChange">
  12. <el-option
  13. v-for="item in optionsList"
  14. :key="item.deptId"
  15. :label="item.deptName"
  16. :value="item.deptId">
  17. </el-option>
  18. </el-select>
  19. </el-form-item>
  20. <div class="for-max-box">
  21. <div class="for-big-box" v-for="(item,index) in formData.hxpAlarmConfigList">
  22. <div class="for-left-box">
  23. <p class="top-null"></p>
  24. <p class="center-num">{{item.sort}}</p>
  25. <p class="bottom-null"></p>
  26. </div>
  27. <div class="for-right-box" :class="index==0?'for-right-box-none-border':''">
  28. <div class="for-right-box-1">
  29. <!--<el-form-item label="报警方式:" :prop="'hxpAlarmConfigList.'+ index +'.alarmMode'" :rules="rules.alarmMode">-->
  30. <!--<el-select v-model="item.alarmMode" clearable placeholder="请选择报警方式" style="width:400px;">-->
  31. <!--<el-option-->
  32. <!--v-for="item in optionsListOne"-->
  33. <!--:key="item.id"-->
  34. <!--:label="item.name"-->
  35. <!--:value="item.id">-->
  36. <!--</el-option>-->
  37. <!--</el-select>-->
  38. <!--</el-form-item>-->
  39. <el-form-item label="间隔时间:" :prop="'hxpAlarmConfigList.'+ index +'.timeInterval'" :rules="rules.timeInterval">
  40. <el-input
  41. maxlength="3"
  42. style="width:400px;"
  43. v-model="item.timeInterval"
  44. placeholder="请输入间隔时间"
  45. clearable
  46. size="small">
  47. <template slot="append">分钟</template>
  48. </el-input>
  49. </el-form-item>
  50. <p class="for-right-box-1-text">设定未处理即执行下一步报警的时间间隔</p>
  51. </div>
  52. <!--<div >-->
  53. <!--<el-form-item label="报警内容:" :prop="'hxpAlarmConfigList.'+ index +'.alarmContent'" :rules="rules.alarmContent">-->
  54. <!--<el-input-->
  55. <!--maxlength="50"-->
  56. <!--style="width:910px;"-->
  57. <!--show-word-limit-->
  58. <!--v-model="item.alarmContent"-->
  59. <!--placeholder="请输入报警内容"-->
  60. <!--clearable-->
  61. <!--size="small"/>-->
  62. <!--</el-form-item>-->
  63. <!--</div>-->
  64. <div class="for-right-box-3">
  65. <div v-for="(minItem,minIndex) in item.alarmPhone">
  66. <el-form-item label="联系方式:" :prop="'hxpAlarmConfigList.'+index+'.alarmPhone.'+minIndex+'.phone'" :rules="rules.phone">
  67. <el-input
  68. maxlength="11"
  69. style="width:400px;"
  70. v-model="minItem.phone"
  71. placeholder="请输入联系方式"
  72. clearable
  73. size="small"/>
  74. </el-form-item>
  75. <i class="el-icon-delete" v-if="item.alarmPhone.length>1" @click="delPhone(index,minIndex)"></i>
  76. <i class="el-icon-plus" v-if="minIndex == item.alarmPhone.length-1" @click="addPhone(index)"></i>
  77. <i class="phone-add-text" v-if="minIndex == item.alarmPhone.length-1">最多可添加5个联系方式</i>
  78. </div>
  79. </div>
  80. <p class="el-icon-delete postion-button-1" @click="delItem(index)"></p>
  81. </div>
  82. </div>
  83. </div>
  84. <p class="postion-button-2" @click="addItem">添加处理流程</p>
  85. </el-form>
  86. <img src="@/assets/ZDimages/null-data.png" alt="" style="width:200px;margin:80px auto 0;" v-if="!formData.hxpAlarmConfigList[0]">
  87. <p style="text-align:center;color:#999;margin-top:20px;margin-left:-50px;font-weight:500;font-size:16px;" v-if="!formData.hxpAlarmConfigList[0]">未配置报警通知</p>
  88. <div class="bottom-button-box">
  89. <p class="inquire-button-one right-button" style="margin-left:22px;" @click="upDataButton">保存</p>
  90. </div>
  91. </div>
  92. </div>
  93. </template>
  94. <script>
  95. import { filterDept,getDeptDetail,hxpAlarmConfig } from "@/api/medicUniversity-3_1/index";
  96. export default {
  97. name: "addPage",
  98. data() {
  99. return {
  100. optionsList:[],
  101. optionsListOne:[{id:1,name:"系统通知"},{id:2,name:"声光报警"},{id:3,name:"短信通知"}],
  102. rules:{
  103. alarmMode: [
  104. { required: true, message: "请选择报警方式", trigger: "blur" },
  105. ],
  106. timeInterval: [
  107. { required: true, message: "请输入间隔时间", trigger: "blur" },
  108. { required: true, message: "请输入间隔时间", validator: this.spaceJudgment, trigger: "blur" },
  109. { required: true, message: "只能输入数字", validator: this.isNum, trigger: "blur" },
  110. ],
  111. alarmContent: [
  112. { required: true, message: "请输入报警内容", trigger: "blur" },
  113. { required: true, message: "请输入报警内容", validator: this.spaceJudgment, trigger: "blur" }
  114. ],
  115. phone: [
  116. { pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的联系方式", trigger: "blur"},
  117. { required: true, message: "请输入联系方式", trigger: "blur" },
  118. { required: true, message: "请输入联系方式", validator: this.spaceJudgment, trigger: "blur" },
  119. { required: true, message: "只能输入数字", validator: this.isNum, trigger: "blur" },
  120. ],
  121. },
  122. formData:{
  123. hxpAlarmConfigList:[]
  124. },
  125. };
  126. },
  127. created() {
  128. },
  129. mounted(){
  130. this.filterDept();
  131. },
  132. methods: {
  133. delPhone(index,minIndex){
  134. this.formData.hxpAlarmConfigList[index].alarmPhone.splice(minIndex,1)
  135. },
  136. addPhone(index){
  137. if(this.formData.hxpAlarmConfigList[index].alarmPhone.length>4){
  138. this.msgError("最多可添加5个联系方式");
  139. return
  140. }
  141. let obj = {
  142. phone:"",
  143. }
  144. this.formData.hxpAlarmConfigList[index].alarmPhone.push(obj);
  145. },
  146. //提交
  147. upDataButton(){
  148. let self = this;
  149. this.$refs["form"].validate(valid => {
  150. if (valid) {
  151. let obj = {
  152. alarmDeptId:this.formData.alarmDeptId,
  153. hxpAlarmConfigList:[]
  154. };
  155. for(let i=0;i<self.formData.hxpAlarmConfigList.length;i++){
  156. let minObj = {
  157. // alarmMode:self.formData.hxpAlarmConfigList[i].alarmMode,
  158. sort:i+1,
  159. alarmMode:4,
  160. timeInterval:self.formData.hxpAlarmConfigList[i].timeInterval,
  161. alarmContent:self.formData.hxpAlarmConfigList[i].alarmContent,
  162. }
  163. let phoneList = [];
  164. for(let o=0;o<self.formData.hxpAlarmConfigList[i].alarmPhone.length;o++){
  165. phoneList.push(self.formData.hxpAlarmConfigList[i].alarmPhone[o].phone)
  166. }
  167. minObj.alarmPhone = phoneList+"";
  168. obj.hxpAlarmConfigList.push(minObj)
  169. }
  170. hxpAlarmConfig(obj).then(response => {
  171. if(response.code == 200){
  172. self.msgSuccess(response.msg);
  173. self.$parent.pageToggle(1);
  174. }
  175. })
  176. }
  177. })
  178. },
  179. addItem(){
  180. if(this.formData.hxpAlarmConfigList.length>4){
  181. this.msgError("最多添加5个流程")
  182. return
  183. }
  184. let obj = {
  185. alarmMode:"",
  186. timeInterval:"",
  187. alarmContent:"",
  188. alarmPhone:[{
  189. phone:"",
  190. }]
  191. }
  192. this.formData.hxpAlarmConfigList.push(obj);
  193. },
  194. delItem(index){
  195. this.formData.hxpAlarmConfigList.splice(index,1)
  196. },
  197. deptChange(val){
  198. this.$set(this.formData,'alarmDeptId',val)
  199. this.getDeptDetail(val);
  200. },
  201. // 根据院系获取配置
  202. getDeptDetail(id){
  203. getDeptDetail(id).then(response => {
  204. if (response.data[0]){
  205. for(let i=0;i<response.data.length;i++){
  206. let list = []
  207. if(response.data[i].alarmPhone){
  208. response.data[i].alarmPhone = response.data[i].alarmPhone.split(",");
  209. for(let o=0;o<response.data[i].alarmPhone.length;o++){
  210. let obj = {
  211. phone:response.data[i].alarmPhone[o]
  212. }
  213. list.push(obj);
  214. }
  215. }
  216. response.data[i].alarmPhone = JSON.parse(JSON.stringify(list));
  217. this.$set(this.formData,'hxpAlarmConfigList',response.data)
  218. }
  219. } else {
  220. // let list = [
  221. // {
  222. // alarmMode:"",
  223. // timeInterval:"",
  224. // alarmContent:"",
  225. // alarmPhone:[{
  226. // phone:"",
  227. // }]
  228. // }
  229. // ];
  230. // this.$set(this.formData,'hxpAlarmConfigList',list)
  231. this.$set(this.formData,'hxpAlarmConfigList',[])
  232. }
  233. });
  234. },
  235. //查询当前院系
  236. filterDept(){
  237. filterDept().then(response => {
  238. this.optionsList = response.data;
  239. if(response.data[0]){
  240. this.formData.alarmDeptId = response.data[0].deptId;
  241. this.getDeptDetail(response.data[0].deptId);
  242. }
  243. });
  244. },
  245. backPage(){
  246. this.$parent.pageToggle(1);
  247. },
  248. }
  249. }
  250. </script>
  251. <style scoped lang="scss">
  252. .addPage{
  253. flex:1;
  254. display: flex;
  255. flex-direction: column;
  256. overflow: hidden;
  257. p{
  258. margin:0;
  259. padding:0;
  260. }
  261. .title-box{
  262. display: flex;
  263. height:90px;
  264. border-bottom: 1px solid #D8D8D8;
  265. p:nth-child(1){
  266. flex:1;
  267. font-size:16px;
  268. line-height:90px;
  269. margin-left:18px;
  270. color:#0045AF;
  271. }
  272. p:nth-child(2){
  273. margin:25px 25px 0 0;
  274. }
  275. }
  276. .addPage-min{
  277. flex:1;
  278. display: flex;
  279. flex-direction: column;
  280. padding:20px;
  281. .addPage-min-title-box{
  282. margin:20px 0;
  283. color:#3D3D3D;
  284. font-size:14px;
  285. i{
  286. font-size:16px;
  287. color:#FFC000;
  288. margin-right:10px;
  289. }
  290. }
  291. .for-max-box{
  292. flex:1;
  293. border:1px solid #dedede;
  294. .for-big-box:nth-child(1){
  295. .top-null{
  296. border:none!important;
  297. }
  298. }
  299. .for-big-box:last-child{
  300. .bottom-null{
  301. border:none!important;
  302. }
  303. }
  304. .for-big-box{
  305. display: flex;
  306. .for-left-box{
  307. width:100px;
  308. display: flex;
  309. flex-direction: column;
  310. .top-null{
  311. flex:1;
  312. border-left: 1px dashed #0183FA;
  313. width:0;
  314. margin:0 auto;
  315. }
  316. .center-num{
  317. width:46px;
  318. height:46px;
  319. border-radius:50%;
  320. background: #CCE6FE;
  321. color:#0183FA;
  322. font-size:24px;
  323. text-align: center;
  324. line-height: 46px;
  325. margin:0 auto;
  326. }
  327. .bottom-null{
  328. flex:1;
  329. border-left: 1px dashed #0183FA;
  330. width:0;
  331. margin:0 auto 2px;
  332. }
  333. }
  334. .for-right-box{
  335. flex:1;
  336. padding-top:20px;
  337. border-left:1px solid #dedede;
  338. border-top:1px solid #dedede;
  339. position: relative;
  340. .for-right-box-1{
  341. display: flex;
  342. .for-right-box-1-text{
  343. font-size:14px;
  344. line-height:40px;
  345. color:#999;
  346. margin-left:10px;
  347. font-weight:500;
  348. }
  349. }
  350. .for-right-box-3{
  351. div{
  352. display: flex;
  353. .el-icon-delete{
  354. width:40px;
  355. height:40px;
  356. line-height: 40px;
  357. margin-right:10px;
  358. text-align: center;
  359. cursor: pointer;
  360. }
  361. .el-icon-plus{
  362. width:40px;
  363. height:40px;
  364. line-height: 40px;
  365. text-align: center;
  366. border:1px solid #dedede;
  367. border-radius:6px;
  368. font-size:14px;
  369. cursor: pointer;
  370. }
  371. }
  372. .phone-add-text{
  373. font-size:14px;
  374. color:#999;
  375. margin-left:20px;
  376. line-height:40px;
  377. font-weight:500;
  378. font-style: normal;
  379. }
  380. }
  381. .postion-button-1{
  382. position: absolute;
  383. right:40px;
  384. bottom:40px;
  385. width:40px;
  386. height:40px;
  387. line-height:40px;
  388. text-align: center;
  389. font-size:30px;
  390. cursor: pointer;
  391. color:#666;
  392. }
  393. }
  394. .for-right-box-none-border{
  395. border-top:none!important;
  396. }
  397. }
  398. }
  399. .postion-button-2{
  400. position: absolute;
  401. padding:5px 10px;
  402. border:1px solid #1E90FF;
  403. border-radius:4px;
  404. right:0;
  405. top:20px;
  406. text-align: center;
  407. font-size:14px;
  408. cursor: pointer;
  409. color:#1E90FF;
  410. }
  411. .bottom-button-box{
  412. display: flex;
  413. width:160px;
  414. margin:40px auto;
  415. .left-button{
  416. margin-right:20px;
  417. }
  418. }
  419. }
  420. }
  421. </style>