addPage.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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">{{index+1}}</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. alarmMode:3,
  159. timeInterval:self.formData.hxpAlarmConfigList[i].timeInterval,
  160. alarmContent:self.formData.hxpAlarmConfigList[i].alarmContent,
  161. }
  162. let phoneList = [];
  163. for(let o=0;o<self.formData.hxpAlarmConfigList[i].alarmPhone.length;o++){
  164. phoneList.push(self.formData.hxpAlarmConfigList[i].alarmPhone[o].phone)
  165. }
  166. minObj.alarmPhone = phoneList+"";
  167. obj.hxpAlarmConfigList.push(minObj)
  168. }
  169. hxpAlarmConfig(obj).then(response => {
  170. if(response.code == 200){
  171. self.msgSuccess(response.msg);
  172. self.$parent.pageToggle(1);
  173. }
  174. })
  175. }
  176. })
  177. },
  178. addItem(){
  179. if(this.formData.hxpAlarmConfigList.length>4){
  180. this.msgError("最多添加5个流程")
  181. return
  182. }
  183. let obj = {
  184. alarmMode:"",
  185. timeInterval:"",
  186. alarmContent:"",
  187. alarmPhone:[{
  188. phone:"",
  189. }]
  190. }
  191. this.formData.hxpAlarmConfigList.push(obj);
  192. },
  193. delItem(index){
  194. this.formData.hxpAlarmConfigList.splice(index,1)
  195. },
  196. deptChange(val){
  197. this.$set(this.formData,'alarmDeptId',val)
  198. this.getDeptDetail(val);
  199. },
  200. // 根据院系获取配置
  201. getDeptDetail(id){
  202. getDeptDetail(id).then(response => {
  203. if (response.data[0]){
  204. for(let i=0;i<response.data.length;i++){
  205. let list = []
  206. if(response.data[i].alarmPhone){
  207. response.data[i].alarmPhone = response.data[i].alarmPhone.split(",");
  208. for(let o=0;o<response.data[i].alarmPhone.length;o++){
  209. let obj = {
  210. phone:response.data[i].alarmPhone[o]
  211. }
  212. list.push(obj);
  213. }
  214. }
  215. response.data[i].alarmPhone = JSON.parse(JSON.stringify(list));
  216. this.$set(this.formData,'hxpAlarmConfigList',response.data)
  217. }
  218. } else {
  219. // let list = [
  220. // {
  221. // alarmMode:"",
  222. // timeInterval:"",
  223. // alarmContent:"",
  224. // alarmPhone:[{
  225. // phone:"",
  226. // }]
  227. // }
  228. // ];
  229. // this.$set(this.formData,'hxpAlarmConfigList',list)
  230. this.$set(this.formData,'hxpAlarmConfigList',[])
  231. }
  232. });
  233. },
  234. //查询当前院系
  235. filterDept(){
  236. filterDept().then(response => {
  237. this.optionsList = response.data;
  238. if(response.data[0]){
  239. this.formData.alarmDeptId = response.data[0].deptId;
  240. this.getDeptDetail(response.data[0].deptId);
  241. }
  242. });
  243. },
  244. backPage(){
  245. this.$parent.pageToggle(1);
  246. },
  247. }
  248. }
  249. </script>
  250. <style scoped lang="scss">
  251. .addPage{
  252. flex:1;
  253. display: flex;
  254. flex-direction: column;
  255. overflow: hidden;
  256. p{
  257. margin:0;
  258. padding:0;
  259. }
  260. .title-box{
  261. display: flex;
  262. height:90px;
  263. border-bottom: 1px solid #D8D8D8;
  264. p:nth-child(1){
  265. flex:1;
  266. font-size:16px;
  267. line-height:90px;
  268. margin-left:18px;
  269. color:#0045AF;
  270. }
  271. p:nth-child(2){
  272. margin:25px 25px 0 0;
  273. }
  274. }
  275. .addPage-min{
  276. flex:1;
  277. display: flex;
  278. flex-direction: column;
  279. padding:20px;
  280. .addPage-min-title-box{
  281. margin:20px 0;
  282. color:#3D3D3D;
  283. font-size:14px;
  284. i{
  285. font-size:16px;
  286. color:#FFC000;
  287. margin-right:10px;
  288. }
  289. }
  290. .for-max-box{
  291. flex:1;
  292. border:1px solid #dedede;
  293. .for-big-box:nth-child(1){
  294. .top-null{
  295. border:none!important;
  296. }
  297. }
  298. .for-big-box:last-child{
  299. .bottom-null{
  300. border:none!important;
  301. }
  302. }
  303. .for-big-box{
  304. display: flex;
  305. .for-left-box{
  306. width:100px;
  307. display: flex;
  308. flex-direction: column;
  309. .top-null{
  310. flex:1;
  311. border-left: 1px dashed #0183FA;
  312. width:0;
  313. margin:0 auto;
  314. }
  315. .center-num{
  316. width:46px;
  317. height:46px;
  318. border-radius:50%;
  319. background: #CCE6FE;
  320. color:#0183FA;
  321. font-size:24px;
  322. text-align: center;
  323. line-height: 46px;
  324. margin:0 auto;
  325. }
  326. .bottom-null{
  327. flex:1;
  328. border-left: 1px dashed #0183FA;
  329. width:0;
  330. margin:0 auto 2px;
  331. }
  332. }
  333. .for-right-box{
  334. flex:1;
  335. padding-top:20px;
  336. border-left:1px solid #dedede;
  337. border-top:1px solid #dedede;
  338. position: relative;
  339. .for-right-box-1{
  340. display: flex;
  341. .for-right-box-1-text{
  342. font-size:14px;
  343. line-height:40px;
  344. color:#999;
  345. margin-left:10px;
  346. font-weight:500;
  347. }
  348. }
  349. .for-right-box-3{
  350. div{
  351. display: flex;
  352. .el-icon-delete{
  353. width:40px;
  354. height:40px;
  355. line-height: 40px;
  356. margin-right:10px;
  357. text-align: center;
  358. cursor: pointer;
  359. }
  360. .el-icon-plus{
  361. width:40px;
  362. height:40px;
  363. line-height: 40px;
  364. text-align: center;
  365. border:1px solid #dedede;
  366. border-radius:6px;
  367. font-size:14px;
  368. cursor: pointer;
  369. }
  370. }
  371. .phone-add-text{
  372. font-size:14px;
  373. color:#999;
  374. margin-left:20px;
  375. line-height:40px;
  376. font-weight:500;
  377. font-style: normal;
  378. }
  379. }
  380. .postion-button-1{
  381. position: absolute;
  382. right:40px;
  383. bottom:40px;
  384. width:40px;
  385. height:40px;
  386. line-height:40px;
  387. text-align: center;
  388. font-size:30px;
  389. cursor: pointer;
  390. color:#666;
  391. }
  392. }
  393. .for-right-box-none-border{
  394. border-top:none!important;
  395. }
  396. }
  397. }
  398. .postion-button-2{
  399. position: absolute;
  400. padding:5px 10px;
  401. border:1px solid #1E90FF;
  402. border-radius:4px;
  403. right:0;
  404. top:20px;
  405. text-align: center;
  406. font-size:14px;
  407. cursor: pointer;
  408. color:#1E90FF;
  409. }
  410. .bottom-button-box{
  411. display: flex;
  412. width:160px;
  413. margin:40px auto;
  414. .left-button{
  415. margin-right:20px;
  416. }
  417. }
  418. }
  419. }
  420. </style>