create.vue 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  1. /**
  2. @author:fugy
  3. @date:2018.09.18
  4. @info:项目报警条目添加与编辑
  5. */
  6. <template>
  7. <div class="edit-box">
  8. <h5 class="title">添加报警条目</h5>
  9. <div class="form-box">
  10. <el-form
  11. label-width="150px"
  12. :model="formValue"
  13. :rules="rules"
  14. ref="ruleForm">
  15. <el-form-item label="适用对象类" prop="objTypeRules">
  16. <span class="infoStar">*</span>
  17. <v-obj-type ref="objType" :objType="objTypeComValue" :disabled='true' width='400px'></v-obj-type>
  18. </el-form-item>
  19. <el-form-item label="报警条目编码" prop="code">
  20. <el-input
  21. placeholder="请输入不超过10位的数字"
  22. v-model="formValue.code"
  23. clearable>
  24. </el-input>
  25. </el-form-item>
  26. <el-form-item label="报警条目名称" prop="name">
  27. <el-input
  28. placeholder="名称不超过30个字"
  29. v-model="formValue.name"
  30. clearable>
  31. </el-input>
  32. </el-form-item>
  33. <el-form-item label="报警分类">
  34. <v-alarm-class
  35. ref="alarm-class"
  36. :isAddBtn='true'
  37. :options='alarmClassArr'
  38. :value='alarmClassValue'
  39. @change="alarmClassChange"
  40. @add='alarmClassAdd'
  41. ></v-alarm-class>
  42. </el-form-item>
  43. <el-form-item label="严重程度" prop="level">
  44. <el-select v-model="formValue.level" clearable placeholder="请选择">
  45. <el-option
  46. v-for="item in levelSelectArr"
  47. :key="item.value"
  48. :label="item.label"
  49. :value="item.value">
  50. </el-option>
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item>
  54. <div class="level_describe">
  55. <p>S 严重故障:会导致停机、设备损坏等问题的严重故障;计入设备、系统故障时间统计;</p>
  56. <p>A 故障 :会导致运行故障,但不会引起严重的系统问题,影响范围有限。例如单个污水坑报警;计入设备、系统故障时间统计;</p>
  57. <p>B 一般问题: 不会导致停机, 但对安全运行会造成风险的一般报警, 例如房间温度过高, 传感器不正常等; 不计入故障时间统计;</p>
  58. <p>C 预警: 提前预判故障或问题, 发出警告, 例如算范判断的管道脏堵、 换热器效率下降等; 不计入故障时间统计;</p>
  59. <p>D 数据问题: 断数、 云服务故障等我们的系统产生的问题; 不计入故障时间统计;</p>
  60. </div>
  61. </el-form-item>
  62. <el-form-item label="备注">
  63. <el-input
  64. type="textarea"
  65. :rows="3"
  66. placeholder="不超过100字"
  67. v-model="formValue.remark">
  68. </el-input>
  69. </el-form-item>
  70. <el-form-item label="报警触发时所转问题">
  71. <el-select
  72. v-model="formValue.hasProblem"
  73. clearable
  74. placeholder="请选择"
  75. :disabled="formValue.objTypeRules.length==0"
  76. @change="hasProblemHandle">
  77. <el-option
  78. v-for="item in hasProblemArr"
  79. :key="item.value"
  80. :label="item.label"
  81. :value="item.value"
  82. >
  83. </el-option>
  84. </el-select>
  85. <span v-show="hasProblemInfo">问题为:&nbsp;&nbsp;&nbsp;{{hasProblemInfo}}</span>
  86. </el-form-item>
  87. <el-form-item label="报警所用算法" prop="aligothmType">
  88. <el-select
  89. :disabled="formValue.objTypeRules.length==0"
  90. style="width: 300px;"
  91. v-model="formValue.aligothmType"
  92. clearable
  93. placeholder="请选择">
  94. <el-option
  95. v-for="item in aligothmTypeArr"
  96. :key="item.value"
  97. :label="item.label"
  98. :value="item.value"
  99. >
  100. </el-option>
  101. </el-select>
  102. </el-form-item>
  103. <el-form-item label="取值信息点" prop="funcid">
  104. <span class="infoStar">*</span>
  105. <span>{{selectInfoBtn}}</span>
  106. </el-form-item>
  107. <!-- 阈值算法 -->
  108. <div v-if="formValue.aligothmType == 'threshold'" class="threshold-box">
  109. <el-form-item label="报警诊断启动前提" prop="aligothmTypeInfo.precondition" :rules="rules.precondition">
  110. <el-radio-group class="precondition" v-model="formValue.aligothmTypeInfo.precondition">
  111. <p><el-radio label="running" :disabled="!isRunStatus">只有当设备处于运行状态才启动报警诊断</el-radio></p>
  112. <p><el-radio label="runningEnergy" :disabled="!isElecConsumP">只有当设备的运行能耗大于
  113. <el-input
  114. style="width: 200px; margin: 0 10px;"
  115. placeholder="请输入"
  116. v-model="formValue.aligothmTypeInfo.energyupper"
  117. :disabled="formValue.aligothmTypeInfo.precondition!='runningEnergy'">
  118. <template slot="append">kwh</template>
  119. </el-input>时才启动报警诊断</el-radio></p>
  120. <p><el-radio label="any">设备在任何状态下都启动报警诊断</el-radio></p>
  121. </el-radio-group>
  122. </el-form-item>
  123. <el-form-item label="报警诊断日期及时间" prop="aligothmTypeInfo.dateSet" :rules="rules.dateSet">
  124. <p>
  125. <span style="margin: 0 10px;">日期设定</span>
  126. <el-radio-group v-model="formValue.aligothmTypeInfo.dateSet">
  127. <el-radio label="all">全部日期</el-radio>
  128. <el-radio label="workday">仅工作日</el-radio>
  129. <el-radio label="weekday">仅周末</el-radio>
  130. </el-radio-group>
  131. </p>
  132. <p>
  133. <span style="margin: 0 10px;">时间设定</span>
  134. <el-radio-group v-model="formValue.aligothmTypeInfo.timeSet" @change="timeRadioHandle">
  135. <el-radio label="all">全部时间</el-radio>
  136. <el-radio label="customed">自定义时间段</el-radio>
  137. </el-radio-group>
  138. <el-time-picker
  139. v-if="formValue.aligothmTypeInfo.timeSet=='customed'"
  140. style="margin-left: 10px;"
  141. is-range
  142. v-model="customTimeRange"
  143. range-separator="至"
  144. start-placeholder="开始时间"
  145. end-placeholder="结束时间"
  146. placeholder="选择时间范围"
  147. format="HH:mm"
  148. size="small"
  149. value-format="HHmm"
  150. @change="timeRangeHandle">
  151. </el-time-picker>
  152. </p>
  153. </el-form-item>
  154. <el-form-item label="报警值持续时间要求" prop="aligothmTypeInfo.errorlastperiod" :rules="rules.errorlastperiod">
  155. <p>异常数据持续超过
  156. <el-input
  157. style="width: 200px; margin: 0 10px;"
  158. placeholder="请输入"
  159. v-model="formValue.aligothmTypeInfo.errorlastperiod">
  160. <template slot="append">秒</template>
  161. </el-input>时产生报警
  162. </p>
  163. </el-form-item>
  164. <el-form-item label="报警门限值设定方法" prop="aligothmTypeInfo.thresholdSetType" :rules="rules.thresholdSetType">
  165. <p>
  166. <el-select v-model="formValue.aligothmTypeInfo.thresholdSetTypeInfo.type" clearable placeholder="请选择">
  167. <el-option
  168. v-for="item in thresholdSetTypeInfoArr"
  169. :key="item.value"
  170. :label="item.label"
  171. :value="item.value"
  172. >
  173. </el-option>
  174. </el-select>
  175. </p>
  176. </el-form-item>
  177. <el-radio-group class="precondition precondition-left" v-model="formValue.aligothmTypeInfo.thresholdSetType" @change="thresholdSetTypeChange">
  178. <p><el-radio label="customed">手动设定报警门限值
  179. <el-form-item prop="aligothmTypeInfo.thresholdSetType" :rules="rules.verifyUpperLower">
  180. <p style="margin-left: 10px;">
  181. <el-input
  182. v-if="formValue.aligothmTypeInfo.thresholdSetTypeInfo.type != 'upper'"
  183. style="width: 200px; margin: 0 10px;"
  184. placeholder="请输入"
  185. v-model="formValue.aligothmTypeInfo.thresholdSetTypeInfo.lower">
  186. <template slot="append">{{unit || "单位"}}</template>
  187. </el-input>
  188. <span v-if="formValue.aligothmTypeInfo.thresholdSetTypeInfo.type == 'upperLower'">至</span>
  189. <el-input
  190. v-if="formValue.aligothmTypeInfo.thresholdSetTypeInfo.type != 'lower'"
  191. style="width: 200px; margin: 0 10px;"
  192. placeholder="请输入"
  193. v-model="formValue.aligothmTypeInfo.thresholdSetTypeInfo.upper">
  194. <template slot="append">{{unit || "单位"}}</template>
  195. </el-input>
  196. <!-- 浮动范围
  197. <el-input
  198. style="width: 150px; margin: 0 10px;"
  199. placeholder="请输入"
  200. v-model="formValue.aligothmTypeInfo.thresholdSetTypeInfo.rangefrom">
  201. <template slot="append">%</template>
  202. </el-input> -->
  203. </p>
  204. </el-form-item>
  205. </el-radio>
  206. </p>
  207. <p>
  208. <el-radio label="compareInfoCode">指定数据字典中信息点进行比对
  209. <el-form-item prop="aligothmTypeInfo.thresholdSetType" :rules="rules.verifyCompareInfo">
  210. <el-button @click="selectRatedInfoHandle('lower')"
  211. v-if="formValue.aligothmTypeInfo.thresholdSetTypeInfo.type != 'upper'"
  212. :disabled="formValue.aligothmTypeInfo.thresholdSetType != 'compareInfoCode'">{{selectRatedInfoLowerBtn}}</el-button>
  213. <el-button @click="selectRatedInfoHandle('upper')"
  214. v-if="formValue.aligothmTypeInfo.thresholdSetTypeInfo.type != 'lower'"
  215. :disabled="formValue.aligothmTypeInfo.thresholdSetType != 'compareInfoCode'">{{selectRatedInfoUpperBtn}}</el-button>
  216. </el-form-item>
  217. </el-radio>
  218. </p>
  219. <p><el-radio label="compareHistory">使用历史值进行对比</el-radio></p>
  220. </el-radio-group>
  221. </div>
  222. </el-form>
  223. </div>
  224. <div class="btn-box">
  225. <el-button class="edit-btn" type="primary" :loading="btnLoading" @click="saveHandle('ruleForm')">保存</el-button>
  226. <el-button @click="cancelHandle()">取消</el-button>
  227. </div>
  228. <!-- 所转问题弹窗 -->
  229. <v-has-problem
  230. :hasProblemVisibleFlag="hasProblemVisibleFlag"
  231. :objTypeValue="startCascadeValue"
  232. :startCascadeValue="startCascadeValue"
  233. :endCascadeValue="endCascadeValue"
  234. @has-problem-handle="hasProblemEmitHandle"
  235. @has-problem-close="hasProblemCloseHandle">
  236. </v-has-problem>
  237. <!-- 选择额定信息点 -->
  238. <v-select-rated-info
  239. :selectRatedInfoFlag="selectRatedInfoFlag"
  240. :objTypeValue="startCascadeValue"
  241. :infoPointArr="infoPointArr"
  242. :selectRatedInfoCheckedCode="selectRatedInfoCheckedCode"
  243. @select-info-handle="selectRatedInfoEmitHandle">
  244. </v-select-rated-info>
  245. </div>
  246. </template>
  247. <script>
  248. import fixedApi from '../fixedalarmitem/api';
  249. import alarmApi from '@/api/alarm'
  250. //components
  251. import vHasProblem from './hasproblem'; //所转问题弹窗
  252. // import vSelectInfo from './selectinfo'; //选择信息点
  253. import vSelectRatedInfo from './selectratedinfo'; //选择技术信息点
  254. import vObjType from '@/components/alarm/ObjType'
  255. import vAlarmClass from '@/components/alarm/AlarmClass'
  256. export default {
  257. name: 'edit',
  258. data () {
  259. /******校验规则部分****** */
  260. // 报警编码值code校验
  261. let validatorCode = (rules, value, callback) => {
  262. let num = Number(value);
  263. if(isNaN(num)){
  264. callback(new Error('请输入数字'));
  265. } else {
  266. let reg = /^\d{1,10}$/
  267. if(reg.test(num)){
  268. callback()
  269. }else{
  270. callback(new Error('请输入不超过10位的数字'));
  271. }
  272. }
  273. };
  274. // 报警诊断启动前提
  275. let validatorPrecondition = (rules, value, callback) => {
  276. if(value === 'runningEnergy') {
  277. let reg = /^[1-9]\d*$/;
  278. if(reg.test(this.formValue.aligothmTypeInfo.energyupper)) {
  279. callback()
  280. } else {
  281. callback(new Error('请输入正整数'));
  282. }
  283. } else {
  284. callback();
  285. }
  286. };
  287. // 报警持续要求时间
  288. let validatorErrorLastPeriod = (rules, value, callback) => {
  289. if(value == 0) {
  290. callback()
  291. } else {
  292. let reg = /^[1-9]\d{0,3}$/;
  293. if(reg.test(value)) {
  294. callback()
  295. } else {
  296. callback(new Error('请输入不超4位正整数'));
  297. }
  298. }
  299. };
  300. let validatorupperLower = (rules, value, callback) => {
  301. if(this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.type == 'upperLower' && this.formValue.aligothmTypeInfo.thresholdSetType == "customed" ) { // 上下限
  302. if(/^-?\d{1,8}(?:\.\d{1,3})?$/.test(this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.lower)
  303. && /^-?\d{1,8}(?:\.\d{1,3})?$/.test(this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.upper)){
  304. let lower = Number(this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.lower)
  305. let upper = Number(this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.upper)
  306. if(lower > upper) {
  307. callback(new Error('下限大于上限'));
  308. } else {
  309. callback()
  310. }
  311. } else {
  312. callback(new Error('整数最多8位,小数最多3位'));
  313. }
  314. } else if (this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.type == 'upper' && this.formValue.aligothmTypeInfo.thresholdSetType == "customed"){ //上限
  315. if(/^-?\d{1,8}(?:\.\d{1,3})?$/.test(this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.upper)){
  316. callback()
  317. } else {
  318. callback(new Error('整数最多8位,小数最多3位'));
  319. }
  320. } else if (this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.type == 'lower' && this.formValue.aligothmTypeInfo.thresholdSetType == "customed"){ //下限
  321. if(/^-?\d{1,8}(?:\.\d{1,3})?$/.test(this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.lower)){
  322. callback()
  323. } else {
  324. callback(new Error('整数最多8位,小数最多3位'));
  325. }
  326. } else {
  327. callback();
  328. }
  329. };
  330. let validatorcompareInfo = (rules, value, callback) => {
  331. if( this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.type == 'upperLower' && this.formValue.aligothmTypeInfo.thresholdSetType == "compareInfoCode") { // 上下限
  332. if(this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.lowerCompareInfocode && this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.upperCompareInfocode){
  333. callback()
  334. } else {
  335. callback(new Error('请选择信息点'));
  336. }
  337. } else if (this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.type == 'upper' && this.formValue.aligothmTypeInfo.thresholdSetType == "compareInfoCode"){ //上限
  338. if(this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.upperCompareInfocode){
  339. callback()
  340. } else {
  341. callback(new Error('请选择信息点'));
  342. }
  343. } else if (this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.type == 'lower' && this.formValue.aligothmTypeInfo.thresholdSetType == "compareInfoCode"){ //下限
  344. if(this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.lowerCompareInfocode){
  345. callback()
  346. } else {
  347. callback(new Error('请选择信息点'));
  348. }
  349. } else {
  350. callback();
  351. }
  352. };
  353. return {
  354. /********************* */
  355. objTypeComValue: [],
  356. /********************* */
  357. projectId: null, //项目id
  358. hasProblemVisibleFlag: false, //所转问题的弹窗的flag
  359. slectInfoFlag: false, //选择信息点的flag
  360. selectRatedInfoFlag: false, //选择额定信息点的flag
  361. btnLoading: false, //按钮loading
  362. formValue: {
  363. objType: null, //对象类型,project,floor,space,system,facility, **必须
  364. objTypeRules:[],
  365. category: null, //系统或者设备的category 例如:选系统或者设备时加上前面加上专业编号 其他对象类型为空
  366. code: null, //报警条目编码 **必须
  367. name: null, //报警条目名称 **必须
  368. alarmCategory: undefined, //报警分类
  369. level: null, //严重程度 S A B C D 五级
  370. funcid:[{ //信息点信息,污水坑算法时不用传
  371. funcidId: null, //对应信息点id
  372. funcidName: null //对应信息点名称
  373. }],
  374. hasProblem: null, //'1转问题,0不转问题',int类型
  375. problemId: null, //问题id,hasProblem为1时此项不为空' ,
  376. remark: null, //备注
  377. aligothmType: "none", //算法类型,不需要算法,none 阈值threshold,污水坑sump
  378. aligothmTypeInfo: {
  379. precondition: null,//前提,running(只有当设备处于运行状态时才启动报警诊断),runningEnergy(只有当设备运行能耗大于时启动),any(任何情况都启动)
  380. energyupper: 40, // precondition为runningEnergy时不为空,int类型
  381. dateSet: "all", //日期设定,all,workday,weekday
  382. timeSet: "all", //时间设定,all,customed
  383. startTime: null, //自定义时间设定开始时间hhss,timeSet为customed时不为空
  384. endTime: null, //自定义时间设定结束时间hhss,timeSet为customed时不为空
  385. errorlastperiod: 0, //异常持续时间,单位秒,
  386. thresholdSetType: "customed", //门限设置方式,customed,compareInfoCode,compareHistory
  387. compareInfocode: null, //比对信息点thresholdSetType为compareInfoCode时必须
  388. thresholdSetTypeInfo:{
  389. type: "upperLower", //aligothmType为threshold时必须 upperLower,upper,lower
  390. lower: 0, //下限
  391. upper: 0, //上限
  392. rangefrom: 0, //浮动范围,不是必须
  393. lowerCompareInfocode: null,
  394. upperCompareInfocode: null,
  395. }
  396. }
  397. },
  398. rules: { //表单的规则
  399. objTypeRules: [{ required:true, message: '请选择对象类', trigger: 'change'}],
  400. code: [{ required:true, message: '请填写条目编码', trigger: 'blur'},
  401. {validator: validatorCode, trigger: 'blur'}],
  402. name: [{ required:true, message: '请填写条目名称', trigger: 'blur'},
  403. { min: 1, max: 30, message: '不超过30个字', trigger: 'blur'}],
  404. level: [{ required:true, message: '请选择严重程度', trigger: 'change'}],
  405. aligothmType: [{ required:true, message: '请选择报警所用算法', trigger: 'change'}],
  406. precondition: [{ required:true, message: '请选择报警诊断前提', trigger: 'change'},
  407. {validator: validatorPrecondition, trigger: 'blur'}],
  408. dateSet: [{ required:true, message: '请选择日期和时间', trigger: 'blur'}],
  409. errorlastperiod: [{ required:true, message: '请选择报警持续时间', trigger: 'blur'},
  410. {validator: validatorErrorLastPeriod, trigger: 'blur'}],
  411. verifyUpperLower: [
  412. {validator: validatorupperLower, trigger: 'blur'}],
  413. verifyCompareInfo: [
  414. {validator: validatorcompareInfo, trigger: 'blur'}
  415. ]
  416. },
  417. levelSelectArr: [ //严重级别的下拉数据
  418. {
  419. label: "S",
  420. value: "S",
  421. },{
  422. label: "A",
  423. value: "A",
  424. },{
  425. label: "B",
  426. value: "B",
  427. },{
  428. label: "C",
  429. value: "C",
  430. },{
  431. label: "D",
  432. value: "D",
  433. }
  434. ],
  435. hasProblemArr: [ //报警触发时所转问题的下拉数据
  436. {
  437. label: "不转问题",
  438. value: "0",
  439. },{
  440. label: "选择问题",
  441. value: "1",
  442. }
  443. ],
  444. aligothmTypeArr: [
  445. {
  446. label: "直接从点位值判断,不需要算法",
  447. value: "none"
  448. }, {
  449. label: "使用阈值算法",
  450. value: "threshold",
  451. }
  452. ],
  453. thresholdSetTypeInfoArr: [ //阈值算法的报警们限值设定方式的上下限的数组
  454. {
  455. label: '上下限',
  456. value: 'upperLower'
  457. },{
  458. label: '上限',
  459. value: 'upper'
  460. },{
  461. label: '下限',
  462. value: 'lower'
  463. }
  464. ],
  465. // objTypeOptions: [{ //选择适用对象类的级联框
  466. // value: 'building',
  467. // label: '建筑',
  468. // },{
  469. // value: 'floor',
  470. // label: '楼层',
  471. // },{
  472. // value: 'space',
  473. // label: '空间',
  474. // },{
  475. // value: 'system',
  476. // label: '系统类',
  477. // children: []
  478. // },{
  479. // value: 'facility',
  480. // label: '设备类',
  481. // children: []
  482. // }],
  483. startCascadeValue: null, //级联第一级
  484. endCascadeValue: null, //级联最后一级
  485. infoPointArr:[], //信息点总数组
  486. hasProblemInfo: null, //所转问题详情
  487. selectInfoBtn: null,
  488. customTimeRange: [new Date(), new Date()], //自定义时间段
  489. selectRatedInfoUpperBtn: '请选择上限信息点', //选择固定的信息点
  490. selectRatedInfoLowerBtn: '请选择下限信息点',
  491. selectRatedInfoCodeFlag: null, //选择信息点的flag
  492. selectRatedInfoCheckedCode: null, //被选中的信息点
  493. unit: null, //阈值算法的单位
  494. isRunStatus: false, //是否有RunStatus的信息点
  495. isElecConsumP: false, //是否有ElecConsumP的信息点
  496. createStatus: false, //创建状态
  497. //业务管理v1.1升级
  498. alarmClassArr:[], //报警分类的下拉数据
  499. alarmClassValue: '', //绑定的value
  500. }
  501. },
  502. components: {
  503. vHasProblem,
  504. vSelectRatedInfo,
  505. vObjType,
  506. vAlarmClass
  507. },
  508. methods: {
  509. //保存
  510. saveHandle(formName) {
  511. this.$refs[formName].validate((valid) => {
  512. this.btnLoading = true;
  513. if (valid) {
  514. let params = {
  515. type: "customed", //报警条目类别,fixed 固定,customed 自定义 **必须
  516. projectId: this.projectId, //项目id,自定义类别时不为空
  517. code: this.formValue.code, //报警条目编码 code和name可以只传一个
  518. name: this.formValue.name //报警条目名称
  519. }
  520. fixedApi.isExisted(params).then(res => {
  521. if(res.result == 'success') {
  522. if(res.name || res.code){
  523. this.$message({
  524. message: '报警编码或报警条目重复',
  525. type: 'warning'
  526. });
  527. let name = this.formValue.name;
  528. let code = this.formValue.code;
  529. if(res.name) {
  530. this.formValue.name = null;
  531. }
  532. if(res.code){
  533. this.formValue.code = null;
  534. }
  535. this.$refs[formName].validate((valid) => {
  536. this.formValue.name = name;
  537. this.formValue.code = code;
  538. })
  539. this.btnLoading = false;
  540. return false;
  541. }
  542. //调保存接口
  543. this.formValue.type = "customed";
  544. this.formValue.projectId = this.projectId;
  545. let param = this.formValue;
  546. fixedApi.save(param).then(res => {
  547. if(res.result === "success"){
  548. this.$message({
  549. message: '保存成功',
  550. type: 'success'
  551. });
  552. this.btnLoading = false;
  553. this.$router.push("/projectinit/projectalarmitem?projectId=" +this.projectId)
  554. } else {
  555. this.btnLoading = false;
  556. this.$message({
  557. message: '网络连接超时,请重新提交',
  558. type: 'error'
  559. });
  560. }
  561. })
  562. }
  563. });
  564. } else {
  565. this.$message({
  566. message: '页面有必填项,请填写后提交!',
  567. type: 'warning'
  568. });
  569. this.btnLoading = false;
  570. console.log('error submit!!');
  571. return false;
  572. }
  573. });
  574. },
  575. // 取消
  576. cancelHandle () {
  577. this.$router.push("/projectinit/projectalarmitem?projectId=" +this.projectId)
  578. },
  579. // 获取对象类
  580. // getObjTypeData() {
  581. // fixedApi.getObjectType().then(res => {
  582. // let {sysArr, devArr} = res;
  583. // this.objTypeOptions[3].children = sysArr;
  584. // this.objTypeOptions[4].children = devArr;
  585. // });
  586. // },
  587. // 获取信息的数组接口
  588. getInfoPointArr(type) {
  589. if(this.startCascadeValue == "system") {
  590. type = type.substring(2, 4);
  591. }
  592. if(this.startCascadeValue == "facility") {
  593. type = type.substring(2, 6);
  594. }
  595. let params = {
  596. type: type,
  597. }
  598. fixedApi.getInfoListData(params).then((res) => {
  599. let data = res;
  600. this.infoPointArr = data;
  601. let RunStatusArr = data.filter((ele, index) => {
  602. return ele.infoPointCode == "RunStatus"
  603. });
  604. let ElecConsumPArr = data.filter((ele, index) => {
  605. return ele.infoPointCode == "ElecConsumP"
  606. });
  607. this.isRunStatus = RunStatusArr[0] ? true : false;
  608. this.isElecConsumP = ElecConsumPArr[0] ? true : false;
  609. }).catch(err => {
  610. throw err;
  611. })
  612. },
  613. // 时间日期radiochange事件
  614. timeRadioHandle(val) {
  615. if(val == "customed") {
  616. let startTime = this.customTimeRange[0];
  617. let endTime = this.customTimeRange[1];
  618. this.formValue.aligothmTypeInfo.startTime = "" + startTime.getHours() + startTime.getMinutes();;
  619. this.formValue.aligothmTypeInfo.endTime = "" + endTime.getHours() + endTime.getMinutes();
  620. } else {
  621. this.formValue.aligothmTypeInfo.startTime = null;
  622. this.formValue.aligothmTypeInfo.endTime = null;
  623. }
  624. },
  625. // 时间日期区间change事件
  626. timeRangeHandle(timeArr) {
  627. if(timeArr) {
  628. this.formValue.aligothmTypeInfo.startTime = timeArr[0];
  629. this.formValue.aligothmTypeInfo.endTime = timeArr[1];
  630. } else {
  631. this.formValue.aligothmTypeInfo.startTime = null;
  632. this.formValue.aligothmTypeInfo.endTime = null;
  633. }
  634. },
  635. //报警门限值change事件
  636. thresholdSetTypeChange(val) {
  637. this.formValue.aligothmTypeInfo.compareInfocode = null;
  638. },
  639. // 填写默认值
  640. getDefaultValue(){
  641. let creatParams = this.$route.query;
  642. if(creatParams){
  643. // 处理对象类
  644. let objArr = [];
  645. objArr[0] = creatParams.startCascadeValue;
  646. this.startCascadeValue = creatParams.startCascadeValue;
  647. this.endCascadeValue = creatParams.startCascadeValue;
  648. if(creatParams.startCascadeValue == 'system') {
  649. this.endCascadeValue = creatParams.endCascadeValue;
  650. objArr[1] = creatParams.endCascadeValue.substring(0, 2);
  651. objArr[2] = creatParams.endCascadeValue.substring(0, 4);
  652. }
  653. if (creatParams.startCascadeValue == 'facility') {
  654. this.endCascadeValue = creatParams.endCascadeValue;
  655. objArr[1] = creatParams.endCascadeValue.substring(0, 2);
  656. objArr[2] = creatParams.endCascadeValue.substring(0, 4);
  657. objArr[3] = creatParams.endCascadeValue.substring(0, 6);
  658. }
  659. if(creatParams.startCascadeValue == 'space') {
  660. this.endCascadeValue = creatParams.endCascadeValue;
  661. objArr = ['space', creatParams.endCascadeValue];
  662. }
  663. this.createStatus = true;
  664. this.formValue.objTypeRules = objArr;
  665. this.objTypeComValue = objArr;
  666. this.formValue.objType = creatParams.startCascadeValue;
  667. this.formValue.category = creatParams.endCascadeValue;
  668. this.formValue.name = creatParams.infoPointName;
  669. // 信息点
  670. this.selectInfoBtn = creatParams.infoPointName;
  671. this.formValue.funcid[0].funcidId = creatParams.infoPointCode;
  672. this.formValue.funcid[0].funcidName = creatParams.infoPointName
  673. // 单位
  674. this.unit = creatParams.unit || "单位"
  675. // 获取信息点
  676. let infoParam = creatParams.startCascadeValue == 'space' ? 'space' : this.endCascadeValue;
  677. this.getInfoPointArr(infoParam);
  678. } else {
  679. window.history.go(-1);
  680. }
  681. },
  682. /***************************组件回调时间************************************** */
  683. //触发问题下拉事件
  684. hasProblemHandle(value) {
  685. if(value == 1){
  686. this.hasProblemVisibleFlag = !this.hasProblemVisibleFlag;
  687. } else {
  688. this.hasProblemInfo = null;
  689. }
  690. },
  691. //触发所转问题的回调事件
  692. hasProblemEmitHandle(name, id) {
  693. this.hasProblemInfo = name + '---' + id;
  694. this.formValue.problemId = id;
  695. },
  696. //触发所转问题的关闭事件
  697. hasProblemCloseHandle(radioValue) {
  698. if(!radioValue){
  699. this.formValue.hasProblem = null;
  700. }
  701. },
  702. //选择技术信息点的点击事件
  703. selectRatedInfoHandle(flag) {
  704. this.selectRatedInfoCodeFlag = flag; //标记是上限 or 下限
  705. if (flag == "lower") {
  706. this.selectRatedInfoCheckedCode = this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.lowerCompareInfocode;
  707. } else {
  708. this.selectRatedInfoCheckedCode = this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.upperCompareInfocode;
  709. }
  710. this.selectRatedInfoFlag = !this.selectRatedInfoFlag;
  711. },
  712. //选择技术信息点的回填事件
  713. selectRatedInfoEmitHandle(name, code) {
  714. if (this.selectRatedInfoCodeFlag == "lower") {
  715. this.selectRatedInfoLowerBtn = name + '---' + code;
  716. this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.lowerCompareInfocode = code;
  717. } else {
  718. this.selectRatedInfoUpperBtn = name + '---' + code;
  719. this.formValue.aligothmTypeInfo.thresholdSetTypeInfo.upperCompareInfocode = code;
  720. }
  721. },
  722. init() {
  723. this.projectId = this.$route.query.projectId;
  724. // 填写默认值
  725. this.getDefaultValue();
  726. //获取报警分类的列表
  727. this.getAlarmClassList()
  728. },
  729. /**v1.1********************************* */
  730. //获取报警分类
  731. async getAlarmClassList() {
  732. let params = {
  733. criteria: {
  734. projectId: {$in:[this.projectId,"0"]}
  735. }
  736. }
  737. let res = await alarmApi.alarmClassList(params)
  738. this.alarmClassArr = res
  739. },
  740. //报警分类的change
  741. alarmClassChange(val) {
  742. this.formValue.alarmCategory = val || undefined
  743. },
  744. //报警分类添加
  745. async alarmClassAdd(val) {
  746. let params = {
  747. projectId: this.projectId,
  748. category: val
  749. }
  750. let res = await alarmApi.createAlarmClass(params)
  751. if(res.result == 'success') {
  752. this.$message({
  753. message: '添加成功',
  754. type: 'success'
  755. });
  756. this.$refs['alarm-class'].visible = false
  757. await this.getAlarmClassList()
  758. this.alarmClassValue = val
  759. this.formValue.alarmCategory = val
  760. }
  761. }
  762. },
  763. mounted() {
  764. this.init()
  765. }
  766. }
  767. </script>
  768. <style lang='less' scoped>
  769. .edit-box{
  770. .title {text-align: center;}
  771. .form-box {
  772. margin-top:20px;
  773. margin-left:20%;
  774. width: 50%;
  775. .infoStar{
  776. color: #f56c6c;
  777. position: absolute;
  778. left: -93px;
  779. }
  780. .threshold-box{
  781. .precondition-left{
  782. padding-left:150px;
  783. }
  784. .precondition{
  785. p{
  786. margin:10px 0;
  787. }
  788. }
  789. };
  790. .level_describe {
  791. color: #b2b2b2;
  792. p {
  793. line-height: 24px;
  794. }
  795. }
  796. }
  797. .btn-box{
  798. margin-top: 10px;
  799. text-align: center;
  800. .edit-btn{
  801. margin-right: 50px;
  802. }
  803. }
  804. }
  805. </style>
  806. <style>
  807. .edit-box .form-box .threshold-box .precondition-left .el-form-item__content{margin-left: 0px!important}
  808. </style>