newAddPlan.vue 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055
  1. <template>
  2. <div class="newAddPlan">
  3. <div class="newAddPlan-title-box">
  4. <p>定制预案1</p>
  5. <p class="add-button-two-90" @click="backButton">返回</p>
  6. <!--<p class="inquire-button-one" @click="upDataButton(1)">不关联仅保存</p>-->
  7. <p class="inquire-button-one" @click="associatedDialogClick">关联实验室</p>
  8. </div>
  9. <div class="plan-for-max-box scrollbar-box">
  10. <el-form :model="form" ref="form" :rules="rules" :inline="true" label-width="90px" class="form-box">
  11. <div class="plan-for-max-box-name-box">
  12. <el-form-item label="预案名称:" prop="name" style="margin:40px 0;">
  13. <el-input
  14. v-model="form.name"
  15. placeholder="请输入预案名称"
  16. size="small"
  17. maxLength="15"
  18. :disabled="inputType"
  19. />
  20. </el-form-item>
  21. <p v-if="inputType" class="plan-for-max-box-name-button-one add-button-two-90" @click="setNameButton(1)">编辑</p>
  22. <p v-if="!inputType" class="plan-for-max-box-name-button-two reset-button-one" @click="setNameButton(2)">取消</p>
  23. <p v-if="!inputType" class="plan-for-max-box-name-button-three add-button-two-90" @click="setNameButton(3)">保存</p>
  24. </div>
  25. <div class="for-plan-box" v-for="(item,index) in form.labRiskPlanLevels" :key="index">
  26. <p class="position-title-type" :class="item.riskPlanLevel==1?'type-color-a':(item.riskPlanLevel==2?'type-color-b':(item.riskPlanLevel==3?'type-color-c':(item.riskPlanLevel==4?'type-color-d':'')))">
  27. {{item.riskPlanLevel==1?'低风险':(item.riskPlanLevel==2?'中风险':(item.riskPlanLevel==3?'较高风险':(item.riskPlanLevel==4?'高风险':'')))}}
  28. </p>
  29. <div class="for-plan-img-box">
  30. <p class="for-plan-img-null-p"></p>
  31. <div class="for-plan-img-box-big">
  32. <div class="for-plan-img-box-one">
  33. <img v-if="item.riskPlanLevel==1" src="@/assets/ZDimages/evacuation3_2/icon_dzya_dfx.png">
  34. <img v-if="item.riskPlanLevel==2" src="@/assets/ZDimages/evacuation3_2/icon_dzya_zfx.png">
  35. <img v-if="item.riskPlanLevel==3" src="@/assets/ZDimages/evacuation3_2/icon_dzya_jgfx.png">
  36. <img v-if="item.riskPlanLevel==4" src="@/assets/ZDimages/evacuation3_2/icon_dzya_gfx.png">
  37. <!-- <p>联动疏散</p>-->
  38. </div>
  39. <!--<div class="for-plan-img-box-two">-->
  40. <!--<img src="@/assets/ZDimages/evacuation3_2/img_dzya_hzyj.png">-->
  41. <!--<p>火灾预案</p>-->
  42. <!--</div>-->
  43. </div>
  44. <p class="for-plan-img-null-p"></p>
  45. </div>
  46. <div class="min-for-text-box">
  47. <div>
  48. <div class="min-for-text-box-one" v-for="(minItemOne,minIndexOne) in item.riskPlanSensorList" :key="minItemOne.sensorType">
  49. <div>
  50. <p>启动条件:<span v-for="(sensorItem,sensorIndex) in sensorList" :key="'sensor'+sensorIndex" v-if="sensorItem.hardwareTypeCode == minItemOne.sensorType">{{sensorItem.hardwareTypeName}}</span></p>
  51. <p>监测区间:{{minItemOne.minMonitor}}-{{minItemOne.maxMonitor}}</p>
  52. </div>
  53. </div>
  54. </div>
  55. <div>
  56. <div class="min-for-text-box-two" v-for="(minItemTwo,minIndexTwo) in item.riskPlanHardwareList" :key="minIndexTwo">
  57. <div v-for="(hardwareItem,hardwareIndex) in hardwareList" :key="hardwareIndex" v-if="hardwareItem.hardwareTypeEnum.code == minItemTwo.hardwareType">
  58. <p>执行动作:{{hardwareItem.hardwareTypeEnum.hardwareTypeName}}</p>
  59. <p>执行办法:<span v-for="(functionItem,functionIndex) in hardwareItem.functionStatusList" :key="functionIndex" v-if="functionItem.code == minItemTwo.operate">{{functionItem.code == 0?'关闭':'开启'}}</span></p>
  60. <p>结束操作:<span v-for="(functionItem,functionIndex) in hardwareItem.functionStatusList" :key="functionIndex" v-if="functionItem.code == minItemTwo.overAct">{{functionItem.code == 0?'关闭':'开启'}}</span></p>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="for-button-max-box">
  66. <div @click="buttonClick(2,item,index)">
  67. <img src="@/assets/ZDimages/evacuation3_2/icon_znwl_bj.png">
  68. <p>编辑</p>
  69. </div>
  70. <div @click="buttonClick(3,item,index)">
  71. <img src="@/assets/ZDimages/evacuation3_2/icon_znwl_sc.png">
  72. <p>删除</p>
  73. </div>
  74. </div>
  75. </div>
  76. </el-form>
  77. <div class="plan-for-max-button-box">
  78. <p class="plan-for-max-button-null"></p>
  79. <p class="plan-for-max-button" v-if="!form.labRiskPlanLevels[3]" @click="buttonClick(1)">+ 新增预案规则</p>
  80. <p class="plan-for-max-button-null"></p>
  81. </div>
  82. </div>
  83. <el-dialog :title='dialogTitle' v-if="dialogOpen" :visible.sync="dialogOpen" width="800px" @close='closeDialog'
  84. :close-on-click-modal="false">
  85. <div class="scrollbar-box" style="height:600px;">
  86. <el-form :model="dialogForm" ref="dialogForm" :rules="rules" label-width="100px">
  87. <el-form-item label="预案等级:" prop="riskPlanLevel">
  88. <el-radio-group v-model="dialogForm.riskPlanLevel" style="width:500px;">
  89. <el-radio :label="1">低风险</el-radio>
  90. <el-radio :label="2">中风险</el-radio>
  91. <el-radio :label="3">较高风险</el-radio>
  92. <el-radio :label="4">高风险</el-radio>
  93. </el-radio-group>
  94. </el-form-item>
  95. <div style="display: flex">
  96. <el-form-item label="执行疏散:" prop="ifExit">
  97. <el-radio-group v-model="dialogForm.ifExit" style="width:500px;">
  98. <el-radio :label="0">否</el-radio>
  99. <el-radio :label="1">是</el-radio>
  100. </el-radio-group>
  101. </el-form-item>
  102. <!--<el-form-item label="火灾预案:" prop="name" style="margin-left:220px;">-->
  103. <!--<el-radio-group v-model="dialogForm.type3">-->
  104. <!--<el-radio :label="1">否</el-radio>-->
  105. <!--<el-radio :label="2">是</el-radio>-->
  106. <!--</el-radio-group>-->
  107. <!--</el-form-item>-->
  108. </div>
  109. <el-form-item label="报警通知方式:" prop="expandType">
  110. <el-checkbox-group v-model="dialogForm.alarmType">
  111. <el-checkbox label="1">电话报警</el-checkbox>
  112. <el-checkbox label="2">短信报警</el-checkbox>
  113. </el-checkbox-group>
  114. </el-form-item>
  115. <div class="autoClose">
  116. <p class="autoClose_l">自动关闭:</p>
  117. <p class="autoClose_l2">传感器监测数值恢复正常</p>
  118. <el-input v-model="dialogForm.riskAutoOff" style="width:120px;" :min="1" :max="600" :controls="false" >
  119. <template slot="append">秒</template>
  120. </el-input>
  121. <p class="autoClose_l5">以后预案自动关闭</p>
  122. </div>
  123. <div style="border-top:1px solid #e0e0e0;">
  124. <p style="line-height:60px;font-size:14px;margin-left:19px;">启动条件:</p>
  125. <div style="display: flex" v-for="(item,index) in dialogForm.riskPlanSensorList" :key="index">
  126. <div style="flex:1;">
  127. <el-form-item label="监测设备:" :prop="'riskPlanSensorList.'+index+'.sensorType'" :rules="rules.sensorType">
  128. <el-select v-model="item.sensorType" placeholder="请选择监测设备" @change="(val)=>sensorChange(val,index)">
  129. <el-option
  130. v-for="item in sensorList"
  131. :key="item.hardwareTypeCode"
  132. :label="item.hardwareTypeName"
  133. :value="item.hardwareTypeCode">
  134. </el-option>
  135. </el-select>
  136. </el-form-item>
  137. </div>
  138. <div style="flex:1;display: flex">
  139. <el-form-item label="监测区间:" :prop="'riskPlanSensorList.'+index+'.minMonitor'" :rules="rules.minMonitor">
  140. <el-input-number v-model="item.minMonitor" style="width:90px;" :disabled="item.suoType"
  141. :min="1" :max="99999" :controls="false" placeholder="监测区间"></el-input-number>
  142. </el-form-item>
  143. <p style="width:30px;text-align: center;line-height:40px;">-</p>
  144. <el-form-item label="" :prop="'riskPlanSensorList.'+index+'.maxMonitor'" :rules="rules.maxMonitor" label-width="0">
  145. <el-input-number v-model="item.maxMonitor" style="width:90px;" :disabled="item.suoType"
  146. :min="1" :max="99999" :controls="false" placeholder="监测区间"></el-input-number>
  147. </el-form-item>
  148. <p class="el-icon-delete"
  149. @click="delMinData(1,index)"
  150. style="cursor: pointer;line-height:30px;width:30px;text-align:center;margin:5px 0 0 20px;"></p>
  151. </div>
  152. </div>
  153. <p style="cursor: pointer;width:200px;line-height:30px;border-radius:4px;border: 1px dashed #E0E0E0;color:#333333;text-align: center;margin:20px auto;"
  154. @click="addMinData(1)" :class="dialogForm.riskPlanSensorList.length>8?'add-plan-max-button-color':''">+ 新增监测规则</p>
  155. </div>
  156. <div style="border-top:1px solid #e0e0e0;">
  157. <p style="line-height:60px;font-size:14px;margin-left:19px;">执行动作:</p>
  158. <div style="display: flex" v-for="(item,index) in dialogForm.riskPlanHardwareList" :key="index">
  159. <div style="flex:1;display: flex">
  160. <el-form-item label="执行设备:" :prop="'riskPlanHardwareList.'+index+'.hardwareType'" :rules="rules.hardwareType">
  161. <el-select v-model="item.hardwareType" placeholder="选择执行设备" style="width:130px;" @change="(val)=>controlTypeList(val,index)">
  162. <el-option
  163. v-show="!optionItem.checkType"
  164. v-for="optionItem in hardwareList"
  165. :key="optionItem.hardwareTypeEnum.code"
  166. :label="optionItem.hardwareTypeEnum.hardwareTypeName"
  167. :value="optionItem.hardwareTypeEnum.code">
  168. </el-option>
  169. <p v-show="hardwareShowType" style="text-align: center;color:#999;font-size:12px;line-height:30px;">暂无更多</p>
  170. </el-select>
  171. </el-form-item>
  172. <el-form-item label="执行办法:" :prop="'riskPlanHardwareList.'+index+'.operate'" :rules="rules.operate">
  173. <el-select v-model="item.operate" placeholder="选择执行办法" style="width:130px;">
  174. <el-option
  175. v-for="optionItem in item.hardwareList"
  176. :key="optionItem.code"
  177. :label="optionItem.describe"
  178. :value="optionItem.code">
  179. </el-option>
  180. </el-select>
  181. </el-form-item>
  182. <el-form-item label="结束操作:" :prop="'riskPlanHardwareList.'+index+'.overAct'" :rules="rules.overAct">
  183. <el-select v-model="item.overAct" placeholder="选择结束操作" style="width:130px;">
  184. <el-option
  185. v-for="optionItem in item.hardwareList"
  186. :key="optionItem.code"
  187. :label="optionItem.describe"
  188. :value="optionItem.code">
  189. </el-option>
  190. </el-select>
  191. </el-form-item>
  192. <p class="el-icon-delete"
  193. @click="delMinData(2,index)"
  194. style="cursor: pointer;line-height:30px;width:30px;text-align:center;margin:5px 0 0 20px;"></p>
  195. </div>
  196. </div>
  197. <p style="cursor: pointer;width:200px;line-height:30px;border-radius:4px;border: 1px dashed #E0E0E0;color:#333333;text-align: center;margin:20px auto;"
  198. @click="addMinData(2)" :class="dialogForm.riskPlanHardwareList.length>8?'add-plan-max-button-color':''">+ 新增执行动作</p>
  199. </div>
  200. </el-form>
  201. </div>
  202. <div slot="footer" class="dialog-footer">
  203. <div style="display: flex">
  204. <p style="flex:1;"></p>
  205. <p style="cursor: pointer;border-radius:6px;width:70px;line-height:30px;font-size:12px;text-align:center;margin-right:17px;color:#999999;background:#E0E0E0;" @click="cancel">取消</p>
  206. <p style="cursor: pointer;border-radius:6px;width:70px;line-height:30px;font-size:12px;text-align:center;color:#fff;background:#0045AF;" @click="submitForm">确定</p>
  207. <p style="flex:1;"></p>
  208. </div>
  209. </div>
  210. </el-dialog>
  211. </div>
  212. </template>
  213. <script>
  214. import { listClassifiedAll } from "@/api/laboratory/classified";
  215. import { listClasstypeAll } from "@/api/laboratory/classtype";
  216. import { optionHardware } from "@/api/laboratory/hardware";
  217. import { getSensorList } from "@/api/laboratory/sensor";
  218. import { selectRiskPlanLeveListRiskPlanId,putPlan,planLevelAdd,planLevelPut,planLevelDel,getLabRiskPlanJoinSub } from "@/api/evacuation3_2/index";
  219. export default {
  220. name: "newAddPlan",
  221. props:{
  222. addPlanData:{},
  223. },
  224. data() {
  225. const exportconstvalidateContacts = (rule, value, callback) => {
  226. if(!/^[\u0391-\uFFE5_a-zA-Z0-9]+$/.test(value)) {
  227. callback(new Error("只可输入中文/英文与数字"));
  228. } else {
  229. callback()
  230. }
  231. };
  232. return {
  233. form:{
  234. name:"",
  235. labRiskPlanLevels:[],
  236. },
  237. dialogTitle:'',
  238. dialogIndex:null,
  239. dialogOpen:false,
  240. dialogForm:{
  241. },
  242. // 表单校验
  243. rules: {
  244. name: [
  245. { required: true, message: "请输入预案名称", trigger: "change" },
  246. { required: true, message: "请输入预案名称", validator: this.spaceJudgment, trigger: "change" },
  247. { required: true, validator: exportconstvalidateContacts, trigger: "blur" },
  248. ],
  249. riskPlanLevel: [
  250. { required: true, message: "请选择预案等级", trigger: "change" },
  251. ],
  252. ifExit: [
  253. { required: true, message: "请选择是否执行疏散", trigger: "change" },
  254. ],
  255. sensorType: [
  256. { required: true, message: "请选择监测设备", trigger: "change" },
  257. ],
  258. minMonitor: [
  259. { required: true, message: "请选择监测区间", trigger: "blur" },
  260. ],
  261. maxMonitor: [
  262. { required: true, message: "请选择监测区间", trigger: "blur" },
  263. ],
  264. hardwareType: [
  265. { required: true, message: "请选择执行设备", trigger: "change" },
  266. ],
  267. operate: [
  268. { required: true, message: "请选择执行办法", trigger: "change" },
  269. ],
  270. overAct: [
  271. { required: true, message: "请选择结束操作", trigger: "change" },
  272. ],
  273. riskAutoOff:[
  274. { required: true, message: "请选择关闭时间", trigger: "change" },
  275. ]
  276. },
  277. //检测设备列表
  278. options:[{value: '选项1', label: '黄金糕'},{value: '选项1', label: '黄金糕'},],
  279. //选择数据
  280. //传感器
  281. sensorList:[],
  282. sensorListData:[],
  283. //设备
  284. hardwareList:[],
  285. hardwareShowType:false,
  286. //分类
  287. typeList:[],
  288. //分级
  289. levelList:[],
  290. // 关联实验室本地数据
  291. labSensorHazardRelations:[],
  292. // 新增/编辑时本地数据
  293. labRiskPlanLevels:[],
  294. //名称修改状态锁
  295. inputType:true,
  296. inputName:"",
  297. }
  298. },
  299. created(){
  300. },
  301. mounted(){
  302. this.getOptionData();
  303. },
  304. methods: {
  305. closeDialog(){
  306. this.getOptionData()
  307. },
  308. //传感器选中事件
  309. sensorChange(val,index){
  310. let self = this;
  311. for(let i=0;i<self.sensorList.length;i++){
  312. if(self.sensorList[i].hardwareTypeCode == val){
  313. this.$set(self.dialogForm.riskPlanSensorList[index],'funNum',self.sensorList[i].hardwareTypeName);
  314. if(self.sensorList[i].enumName == "FLAME"){
  315. self.dialogForm.riskPlanSensorList[index].minMonitor = 1;
  316. self.dialogForm.riskPlanSensorList[index].maxMonitor = 2;
  317. self.$set(self.dialogForm.riskPlanSensorList[index],'minMonitor',1);
  318. self.$set(self.dialogForm.riskPlanSensorList[index],'maxMonitor',2);
  319. self.$set(self.dialogForm.riskPlanSensorList[index],'suoType',true);
  320. }else{
  321. self.$set(self.dialogForm.riskPlanSensorList[index],'suoType',false);
  322. }
  323. }
  324. }
  325. },
  326. //修改预案名称
  327. setNameButton(type){
  328. if(type == 1){
  329. this.$set(this,'inputType',false);
  330. this.$set(this,'inputName',this.form.name);
  331. }else if(type == 2){
  332. this.$set(this,'inputType',true);
  333. this.$set(this.form,'name',this.inputName);
  334. }else if(type == 3){
  335. this.$refs["form"].validate(valid => {
  336. if (valid) {
  337. putPlan({ id:this.addPlanData.id, name:this.form.name }).then((response) => {
  338. this.msgSuccess(response.msg)
  339. this.$set(this,'inputType',true);
  340. });
  341. }
  342. })
  343. }
  344. },
  345. //提交
  346. upDataButton(){
  347. this.$refs["form"].validate(valid => {
  348. if (valid) {
  349. if(!this.form.labRiskPlanLevels[0]){
  350. this.msgError('请添加至少一个预案规则')
  351. return
  352. }
  353. setPlanData(this.form).then(response => {
  354. this.msgSuccess(response.msg);
  355. this.$parent.tableClickButton(5);
  356. });
  357. }
  358. })
  359. },
  360. //新增验证是否可继续添加执行设备
  361. addFiltration(){
  362. let self = this;
  363. let num = 0;
  364. for(let i=0;i<self.dialogForm.riskPlanHardwareList.length;i++){
  365. if(self.dialogForm.riskPlanHardwareList[i].hardwareType){
  366. num++
  367. }
  368. }
  369. if(num<self.hardwareList.length){
  370. return true
  371. }else{
  372. this.msgError('暂无更多的执行设备可选则')
  373. return false
  374. }
  375. },
  376. //处理选中后的设备是否继续展示
  377. actionFiltration(){
  378. let self = this;
  379. let age = 0;
  380. for(let o=0;o<self.hardwareList.length;o++){
  381. let num =0;
  382. for(let i=0;i<self.dialogForm.riskPlanHardwareList.length;i++){
  383. if(self.dialogForm.riskPlanHardwareList[i].hardwareType == self.hardwareList[o].hardwareTypeEnum.code){
  384. num++
  385. age++
  386. }
  387. }
  388. self.hardwareList[o].checkType = num != 0;
  389. }
  390. //验证
  391. if(age < self.hardwareList.length){
  392. this.$set(this,'hardwareShowType',false);
  393. }else{
  394. for(let i=0;i<self.dialogForm.riskPlanHardwareList.length;i++){
  395. if(!self.dialogForm.riskPlanHardwareList[i].hardwareType){
  396. self.dialogForm.riskPlanHardwareList.splice(i,1);
  397. }
  398. }
  399. this.$set(this,'hardwareShowType',true);
  400. }
  401. },
  402. //查询设备功能
  403. controlTypeList(val,index) {
  404. let self = this;
  405. for(let i=0;i<self.hardwareList.length;i++){
  406. if(self.hardwareList[i].hardwareTypeEnum.code == val){
  407. this.$set(self.dialogForm.riskPlanHardwareList[index],'hardwareList',self.hardwareList[i].functionStatusList);
  408. this.actionFiltration()
  409. return
  410. }
  411. }
  412. },
  413. //查询传感器/设备下啦列表
  414. getOptionData(){
  415. getSensorList({}).then(response => {
  416. this.sensorList = response.data;
  417. this.sensorListData = JSON.parse(JSON.stringify(response.data))
  418. });
  419. optionHardware({}).then(response => {
  420. this.$set(this,'hardwareList',response.data)
  421. });
  422. listClassifiedAll().then(response=>{
  423. if(response.code==200){
  424. this.levelList=response.data
  425. }
  426. })
  427. listClasstypeAll().then(response=>{
  428. if(response.code==200){
  429. this.typeList=response.data;
  430. }
  431. })
  432. this.selectRiskPlanLeveListRiskPlanId(1);
  433. },
  434. selectRiskPlanLeveListRiskPlanId(type){
  435. selectRiskPlanLeveListRiskPlanId(this.addPlanData.id).then((response) => {
  436. if(type == 1){
  437. this.$set(this.form,'name',this.addPlanData.name);
  438. this.$set(this,'inputType',true);
  439. }
  440. this.$set(this.form,'labRiskPlanLevels',response.data);
  441. });
  442. },
  443. //返回
  444. backButton(){
  445. this.$parent.tableClickButton(5)
  446. },
  447. //实验室关联开关
  448. associatedDialogClick(type){
  449. this.$parent.tableClickButton(1,{id:this.addPlanData.id,type:1,})
  450. },
  451. //查询
  452. onSearch(){
  453. },
  454. //重置
  455. resetForm(){
  456. },
  457. addMinData(type){
  458. if(this.addFiltration()){
  459. if(type == 1){
  460. if(this.dialogForm.riskPlanSensorList.length>8){
  461. this.msgError('新增失败,最多只能新增九条监测规则')
  462. return
  463. }
  464. this.dialogForm.riskPlanSensorList.push({
  465. sensorType:null,
  466. })
  467. }else if(type == 2){
  468. if(this.dialogForm.riskPlanHardwareList.length>8){
  469. this.msgError('新增失败,最多只能新增九条处置规则')
  470. return
  471. }
  472. this.dialogForm.riskPlanHardwareList.push({
  473. hardwareType:null,
  474. operate:null,
  475. overAct:null,
  476. })
  477. }
  478. this.actionFiltration();
  479. }
  480. },
  481. delMinData(type,index){
  482. if(type == 1){
  483. this.dialogForm.riskPlanSensorList.splice(index,1);
  484. }else if (type == 2){
  485. this.dialogForm.riskPlanHardwareList.splice(index,1);
  486. }
  487. this.actionFiltration();
  488. },
  489. //提交
  490. submitForm(){
  491. let self = this;
  492. this.$refs["dialogForm"].validate(valid => {
  493. if (valid) {
  494. if(!this.dialogForm.riskPlanSensorList[0]){
  495. this.msgError('请添加至少一个启动条件')
  496. return
  497. }
  498. //提交数据检测条件区间是否重复(dialog本身数据查重)
  499. for(let i=0;i<self.dialogForm.riskPlanSensorList.length;i++){
  500. if(self.dialogForm.riskPlanSensorList[i].minMonitor >= self.dialogForm.riskPlanSensorList[i].maxMonitor){
  501. self.msgError('监测区间数值异常,请重新输入');
  502. return
  503. }
  504. for(let x=0;x<self.dialogForm.riskPlanSensorList.length;x++){
  505. if(self.dialogForm.riskPlanSensorList[i].sensorType == self.dialogForm.riskPlanSensorList[x].sensorType && i != x){
  506. if(self.dialogForm.riskPlanSensorList[i].minMonitor >= self.dialogForm.riskPlanSensorList[x].minMonitor &&
  507. self.dialogForm.riskPlanSensorList[i].minMonitor <= self.dialogForm.riskPlanSensorList[x].maxMonitor){
  508. self.msgError('监测区间不能重复,请重新输入');
  509. return
  510. }
  511. if(self.dialogForm.riskPlanSensorList[i].maxMonitor >= self.dialogForm.riskPlanSensorList[x].minMonitor &&
  512. self.dialogForm.riskPlanSensorList[i].maxMonitor <= self.dialogForm.riskPlanSensorList[x].maxMonitor){
  513. self.msgError('监测区间不能重复,请重新输入');
  514. return
  515. }
  516. }
  517. }
  518. }
  519. //判断 当前为修改还是新增
  520. if(this.dialogIndex != null){
  521. //编辑
  522. //判断是否已有同等级预案
  523. for(let i=0;i<self.labRiskPlanLevels.length;i++){
  524. if(self.labRiskPlanLevels[i].riskPlanLevel == self.dialogForm.riskPlanLevel){
  525. this.msgError('无法添加多个相同等级的预案.')
  526. return
  527. }
  528. }
  529. for(let i=0;i<self.labRiskPlanLevels.length;i++){
  530. if(self.labRiskPlanLevels[i].riskPlanSensorList.length == self.dialogForm.riskPlanSensorList.length){
  531. let age = 0;
  532. for(let o=0;o<self.labRiskPlanLevels[i].riskPlanSensorList.length;o++){
  533. for(let x=0;x<self.dialogForm.riskPlanSensorList.length;x++){
  534. if(self.dialogForm.riskPlanSensorList[x].sensorType==self.labRiskPlanLevels[i].riskPlanSensorList[o].sensorType){
  535. if(self.dialogForm.riskPlanSensorList[x].minMonitor>=self.labRiskPlanLevels[i].riskPlanSensorList[o].minMonitor&&
  536. self.dialogForm.riskPlanSensorList[x].minMonitor<=self.labRiskPlanLevels[i].riskPlanSensorList[o].maxMonitor){
  537. age++
  538. }else if(self.dialogForm.riskPlanSensorList[x].maxMonitor>=self.labRiskPlanLevels[i].riskPlanSensorList[o].minMonitor&&
  539. self.dialogForm.riskPlanSensorList[x].maxMonitor<=self.labRiskPlanLevels[i].riskPlanSensorList[o].maxMonitor){
  540. age++
  541. }else if(self.labRiskPlanLevels[i].riskPlanSensorList[o].minMonitor>=self.dialogForm.riskPlanSensorList[x].minMonitor&&
  542. self.labRiskPlanLevels[i].riskPlanSensorList[o].minMonitor<=self.dialogForm.riskPlanSensorList[x].maxMonitor){
  543. age++
  544. }else if(self.labRiskPlanLevels[i].riskPlanSensorList[o].maxMonitor>=self.dialogForm.riskPlanSensorList[x].minMonitor&&
  545. self.labRiskPlanLevels[i].riskPlanSensorList[o].maxMonitor<=self.dialogForm.riskPlanSensorList[x].maxMonitor){
  546. age++
  547. }
  548. }
  549. }
  550. }
  551. if(self.dialogForm.riskPlanSensorList.length == age){
  552. self.msgError('监测区间不能与其他级别检测条件完全重复,请重新输入');
  553. return
  554. }
  555. }
  556. }
  557. }else{
  558. //新增
  559. for(let i=0;i<self.form.labRiskPlanLevels.length;i++){
  560. if(self.form.labRiskPlanLevels[i].riskPlanLevel == self.dialogForm.riskPlanLevel){
  561. this.msgError('无法添加多个相同等级的预案.')
  562. return
  563. }
  564. }
  565. for(let i=0;i<self.form.labRiskPlanLevels.length;i++){
  566. if(self.form.labRiskPlanLevels[i].riskPlanSensorList.length == self.dialogForm.riskPlanSensorList.length){
  567. let age = 0;
  568. for(let o=0;o<self.form.labRiskPlanLevels[i].riskPlanSensorList.length;o++){
  569. for(let x=0;x<self.dialogForm.riskPlanSensorList.length;x++){
  570. if(self.dialogForm.riskPlanSensorList[x].sensorType==self.form.labRiskPlanLevels[i].riskPlanSensorList[o].sensorType){
  571. if(self.dialogForm.riskPlanSensorList[x].minMonitor>=self.form.labRiskPlanLevels[i].riskPlanSensorList[o].minMonitor&&
  572. self.dialogForm.riskPlanSensorList[x].minMonitor<=self.form.labRiskPlanLevels[i].riskPlanSensorList[o].maxMonitor){
  573. age++
  574. }else if(self.dialogForm.riskPlanSensorList[x].maxMonitor>=self.form.labRiskPlanLevels[i].riskPlanSensorList[o].minMonitor&&
  575. self.dialogForm.riskPlanSensorList[x].maxMonitor<=self.form.labRiskPlanLevels[i].riskPlanSensorList[o].maxMonitor){
  576. age++
  577. }else if(self.form.labRiskPlanLevels[i].riskPlanSensorList[o].minMonitor>=self.dialogForm.riskPlanSensorList[x].minMonitor&&
  578. self.form.labRiskPlanLevels[i].riskPlanSensorList[o].minMonitor<=self.dialogForm.riskPlanSensorList[x].maxMonitor){
  579. age++
  580. }else if(self.form.labRiskPlanLevels[i].riskPlanSensorList[o].maxMonitor>=self.dialogForm.riskPlanSensorList[x].minMonitor&&
  581. self.form.labRiskPlanLevels[i].riskPlanSensorList[o].maxMonitor<=self.dialogForm.riskPlanSensorList[x].maxMonitor){
  582. age++
  583. }
  584. }
  585. }
  586. }
  587. if(self.dialogForm.riskPlanSensorList.length == age){
  588. self.msgError('监测区间不能与其他级别检测条件完全重复,请重新输入');
  589. return
  590. }
  591. }
  592. }
  593. }
  594. // this.$refs["dialogForm"].validate(valid => {
  595. // if (valid) {
  596. if(this.dialogIndex != null){
  597. //修改预案级别数据
  598. let text = [];
  599. for(let i=0;i<self.form.labRiskPlanLevels.length;i++){
  600. if(this.dialogIndex != i){
  601. for(let o=0;o<self.form.labRiskPlanLevels[i].riskPlanSensorList.length;o++){
  602. for(let x=0;x<self.sensorList.length;x++){
  603. if(self.form.labRiskPlanLevels[i].riskPlanSensorList[o].sensorType == self.sensorList[x].hardwareTypeCode){
  604. text.push(self.sensorList[x].hardwareTypeName);
  605. }
  606. }
  607. }
  608. }
  609. }
  610. for(let i=0;i<self.dialogForm.riskPlanSensorList.length;i++){
  611. for(let x=0;x<self.sensorList.length;x++){
  612. if(self.dialogForm.riskPlanSensorList[i].sensorType == self.sensorList[x].hardwareTypeCode){
  613. text.push(self.sensorList[x].hardwareTypeName);
  614. }
  615. }
  616. }
  617. text = Array.from(new Set(text));
  618. text = text+''
  619. text = text.replace(",","+")
  620. let obj = JSON.parse(JSON.stringify(this.dialogForm))
  621. obj.riskAutoOff =Number(obj.riskAutoOff);
  622. obj.alarmType =obj.alarmType.toString();
  623. obj.startCondition = text+'';
  624. planLevelPut(obj).then((response) => {
  625. this.msgSuccess(response.msg)
  626. this.selectRiskPlanLeveListRiskPlanId();
  627. this.$set(this,'dialogOpen',false);
  628. });
  629. }else{
  630. //新增预案级别数据
  631. let text = [];
  632. for(let i=0;i<self.form.labRiskPlanLevels.length;i++){
  633. for(let o=0;o<self.form.labRiskPlanLevels[i].riskPlanSensorList.length;o++){
  634. for(let x=0;x<self.sensorList.length;x++){
  635. if(self.form.labRiskPlanLevels[i].riskPlanSensorList[o].sensorType == self.sensorList[x].hardwareTypeCode){
  636. text.push(self.sensorList[x].hardwareTypeName);
  637. }
  638. }
  639. }
  640. }
  641. for(let i=0;i<self.dialogForm.riskPlanSensorList.length;i++){
  642. for(let x=0;x<self.sensorList.length;x++){
  643. if(self.dialogForm.riskPlanSensorList[i].sensorType == self.sensorList[x].hardwareTypeCode){
  644. text.push(self.sensorList[x].hardwareTypeName);
  645. }
  646. }
  647. }
  648. text = Array.from(new Set(text));
  649. text = text+''
  650. text = text.replace(",","+")
  651. let obj = JSON.parse(JSON.stringify(this.dialogForm))
  652. obj.riskAutoOff =Number(obj.riskAutoOff);
  653. obj.alarmType =obj.alarmType.toString();
  654. obj.riskPlanId = this.addPlanData.id;
  655. obj.startCondition = text+'';
  656. planLevelAdd(obj).then((response) => {
  657. this.msgSuccess(response.msg)
  658. this.selectRiskPlanLeveListRiskPlanId();
  659. this.$set(this,'dialogOpen',false);
  660. });
  661. }
  662. // }
  663. // })
  664. }
  665. })
  666. },
  667. //取消
  668. cancel(){
  669. this.$set(this,'dialogOpen',false);
  670. },
  671. //新增/编辑预案
  672. buttonClick(type,item,index){
  673. let self = this;
  674. if(type == 1){
  675. let a = 0;
  676. let b = 0;
  677. let c = 0;
  678. let d = 0;
  679. for(let i=0;i<self.form.labRiskPlanLevels.length;i++){
  680. if(self.form.labRiskPlanLevels[i].riskPlanLevel == 1){
  681. a++
  682. }else if(self.form.labRiskPlanLevels[i].riskPlanLevel == 2){
  683. b++
  684. }else if(self.form.labRiskPlanLevels[i].riskPlanLevel == 3){
  685. c++
  686. }else if(self.form.labRiskPlanLevels[i].riskPlanLevel == 4){
  687. d++
  688. }
  689. }
  690. this.$set(this,'dialogIndex',null);
  691. this.$set(this,'dialogTitle','新增预案规则');
  692. this.$set(this,'dialogForm',{
  693. riskPlanLevel:a==0?1:(b==0?2:(c==0?3:(d==0?4:''))),
  694. ifExit:0,
  695. alarmType:['1','2'],
  696. riskAutoOff:'60',
  697. riskPlanSensorList:[],
  698. riskPlanHardwareList:[],
  699. });
  700. this.$set(this,'dialogOpen',true);
  701. }else if(type == 2){
  702. this.$set(this,'dialogTitle','编辑预案规则');
  703. this.$set(this,'dialogIndex',index);
  704. let obj = JSON.parse(JSON.stringify(item))
  705. for(let i=0;i<obj.riskPlanHardwareList.length;i++){
  706. for(let o=0;o<self.hardwareList.length;o++){
  707. if(obj.riskPlanHardwareList[i].hardwareType == self.hardwareList[o].hardwareTypeEnum.code){
  708. obj.riskPlanHardwareList[i].hardwareList = self.hardwareList[o].functionStatusList
  709. }
  710. }
  711. }
  712. this.$set(this,'dialogForm',{
  713. id:obj.id,
  714. riskPlanId:obj.riskPlanId,
  715. riskPlanLevel:obj.riskPlanLevel,
  716. ifExit:obj.ifExit,
  717. alarmType:obj.alarmType.split(','),
  718. riskAutoOff:obj.riskAutoOff+'',
  719. riskPlanSensorList:obj.riskPlanSensorList,
  720. riskPlanHardwareList:obj.riskPlanHardwareList,
  721. });
  722. let list = [];
  723. for(let i=0;i<self.form.labRiskPlanLevels.length;i++){
  724. if(i!=index){
  725. list.push(self.form.labRiskPlanLevels[i]);
  726. }
  727. }
  728. this.$set(this,'labRiskPlanLevels',JSON.parse(JSON.stringify(list)));
  729. this.$set(this,'dialogOpen',true);
  730. }else if(type == 3){
  731. this.$confirm('确定要删除该预案规则吗?', "警告", {
  732. confirmButtonText: "确定",
  733. cancelButtonText: "取消",
  734. type: "warning"
  735. }).then(function() {
  736. let text = [];
  737. for(let i=0;i<self.form.labRiskPlanLevels.length;i++){
  738. if(index != i){
  739. for(let o=0;o<self.form.labRiskPlanLevels[i].riskPlanSensorList.length;o++){
  740. for(let x=0;x<self.sensorList.length;x++){
  741. if(self.form.labRiskPlanLevels[i].riskPlanSensorList[o].sensorType == self.sensorList[x].hardwareTypeCode){
  742. text.push(self.sensorList[x].hardwareTypeName);
  743. }
  744. }
  745. }
  746. }
  747. }
  748. text = Array.from(new Set(text));
  749. text = text+''
  750. text = text.replace(",","+")
  751. let obj = {
  752. id:item.id,
  753. startCondition:text,
  754. riskPlanId:item.riskPlanId
  755. }
  756. planLevelDel(obj).then((response) => {
  757. self.msgSuccess(response.msg)
  758. self.selectRiskPlanLeveListRiskPlanId();
  759. });
  760. }).then(() => {
  761. }).catch(() => {});
  762. }
  763. },
  764. }
  765. }
  766. </script>
  767. <style lang="scss">
  768. .add-plan-max-button-color{
  769. color:#dedede!important;
  770. }
  771. //.el-form-item__content{
  772. // margin-left: 0px!important;
  773. // display: flex;
  774. //}
  775. </style>
  776. <style scoped lang="scss">
  777. .autoClose{
  778. display: flex;
  779. align-items: center;
  780. margin-bottom: 24px;
  781. .autoClose_l{
  782. width: 100px;
  783. color: #333;
  784. font-weight: 500;
  785. font-size: 14px;
  786. line-height: 40px !important;
  787. text-align: right;
  788. padding: 0 12px 0 0;
  789. box-sizing: border-box;
  790. }
  791. .autoClose_l:before{
  792. content: "*";
  793. color: #ff4949;
  794. margin-right: 4px;
  795. }
  796. .autoClose_l2{
  797. color: #333;
  798. font-weight: 500;
  799. font-size: 14px;
  800. line-height: 40px !important;
  801. margin-right: 8px;
  802. }
  803. .el-form-item{
  804. margin: 0px!important;
  805. }
  806. .autoClose_l3{
  807. }
  808. .autoClose_l4{
  809. color: #333;
  810. font-weight: 500;
  811. font-size: 14px;
  812. line-height: 40px;
  813. background: #f5f7fa;
  814. border: 1px solid #DCDFE6;
  815. border-left: none;
  816. width: 40px;
  817. height: 40px;
  818. text-align: center;
  819. }
  820. .autoClose_l5{
  821. color: #333;
  822. font-weight: 500;
  823. font-size: 14px;
  824. margin-left: 8px;
  825. }
  826. }
  827. .newAddPlan {
  828. flex: 1;
  829. display: flex !important;
  830. flex-direction: column;
  831. overflow: hidden;
  832. p {
  833. margin: 0;
  834. font-weight: 500;
  835. }
  836. .newAddPlan-title-box {
  837. height: 80px;
  838. display: flex;
  839. border-bottom: 1px solid #E0E0E0;
  840. p:nth-child(1) {
  841. flex: 1;
  842. margin-left: 20px;
  843. font-size: 16px;
  844. color: #0045AF;
  845. line-height: 80px;
  846. font-weight: 700;
  847. }
  848. p:nth-child(2) {
  849. font-size: 14px;
  850. margin-top: 20px;
  851. margin-right: 20px;
  852. }
  853. p:nth-child(3) {
  854. font-size: 14px;
  855. width: 130px;
  856. margin-top: 20px;
  857. margin-right: 20px;
  858. }
  859. p:nth-child(4) {
  860. font-size: 14px;
  861. width: 150px;
  862. margin: 20px;
  863. }
  864. }
  865. .plan-for-max-box {
  866. flex: 1;
  867. padding:0 20px 20px 20px;
  868. .plan-for-max-box-name-box{
  869. display: flex;
  870. .plan-for-max-box-name-button-one{
  871. width:80px;
  872. text-align: center;
  873. font-size:14px;
  874. line-height:40px;
  875. margin:40px 0 0 40px;
  876. }
  877. .plan-for-max-box-name-button-two{
  878. width:80px;
  879. text-align: center;
  880. font-size:14px;
  881. line-height:40px;
  882. margin:40px 0 0 40px;
  883. }
  884. .plan-for-max-box-name-button-three{
  885. width:80px;
  886. text-align: center;
  887. font-size:14px;
  888. line-height:40px;
  889. margin:40px 0 0 20px;
  890. }
  891. }
  892. .for-plan-box{
  893. position: relative;
  894. border-radius:10px;
  895. overflow: hidden;
  896. box-shadow: 0px 4px 10px 0px rgba(0,0,0,0.302);
  897. margin-bottom:24px;
  898. display: flex;
  899. .position-title-type{
  900. position:absolute;
  901. left:0;
  902. top:0;
  903. border-bottom-right-radius: 10px;
  904. width:84px;
  905. line-height:30px;
  906. font-size:14px;
  907. text-align: center;
  908. }
  909. .type-color-a{
  910. color:#0183FA;
  911. background: #CCE6FE;
  912. }
  913. .type-color-b{
  914. color:#FF9900;
  915. background: rgb(256,232,206);
  916. }
  917. .type-color-c{
  918. color:#FF4800;
  919. background: rgb(251,228,206);
  920. }
  921. .type-color-d{
  922. color:#FF0000;
  923. background: rgba(248,206,205);;
  924. }
  925. .for-plan-img-box{
  926. width:220px;
  927. display: flex;
  928. flex-direction: column;
  929. .for-plan-img-null-p{
  930. flex:1;
  931. }
  932. .for-plan-img-box-big{
  933. display: flex;
  934. .for-plan-img-box-one{
  935. margin-left:100px;
  936. width:168px;
  937. display: flex;
  938. img{
  939. height:60px;
  940. width:60px;
  941. }
  942. p{
  943. margin-left:20px;
  944. line-height:50px;
  945. font-size:14px;
  946. color:#333;
  947. }
  948. }
  949. .for-plan-img-box-two{
  950. display: flex;
  951. img{
  952. height:50px;
  953. width:50px;
  954. }
  955. p{
  956. line-height:50px;
  957. font-size:14px;
  958. color:#333;
  959. }
  960. }
  961. }
  962. }
  963. .min-for-text-box{
  964. width:1030px;
  965. padding-top:21px;
  966. .min-for-text-box-one{
  967. width:460px;
  968. line-height:30px;
  969. margin-bottom:21px;
  970. margin-right:40px;
  971. border-radius:6px;
  972. color:#0183FA;
  973. background:rgb(209,229,253);
  974. display: inline-block;
  975. div{
  976. display: flex;
  977. p:nth-child(1){
  978. margin-right:15px;
  979. margin-left:9px;
  980. }
  981. }
  982. }
  983. .min-for-text-box-two{
  984. width:460px;
  985. line-height:30px;
  986. margin-bottom:21px;
  987. margin-right:40px;
  988. border-radius:6px;
  989. color:#333;
  990. background:rgb(253,242,227);
  991. display: inline-block;
  992. div{
  993. display: flex;
  994. p:nth-child(1){
  995. margin-right:15px;
  996. margin-left:9px;
  997. }
  998. p:nth-child(2){
  999. margin-right:15px;
  1000. }
  1001. }
  1002. }
  1003. }
  1004. .for-button-max-box{
  1005. flex:1;
  1006. margin:19px 0;
  1007. border-left:1px dashed #D8D8D8;
  1008. display: flex;
  1009. div{
  1010. margin:auto 0 auto 34px;
  1011. width:85px;
  1012. display: flex;
  1013. height:20px;
  1014. cursor: pointer;
  1015. img{
  1016. height:14px;
  1017. margin-top:3px;
  1018. }
  1019. p{
  1020. font-size:14px;
  1021. margin-left:9px;
  1022. }
  1023. }
  1024. }
  1025. }
  1026. .plan-for-max-button-box{
  1027. margin:30px auto;
  1028. display: flex;
  1029. .plan-for-max-button-null{
  1030. flex:1;
  1031. }
  1032. .plan-for-max-button{
  1033. cursor: pointer;
  1034. color:#0183FA;
  1035. border:1px dashed #0183FA;
  1036. border-radius:4px;
  1037. width:300px;
  1038. line-height:40px;
  1039. text-align: center;
  1040. font-size:14px;
  1041. }
  1042. }
  1043. }
  1044. }
  1045. </style>