windturbine_components.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <template>
  2. <el-dialog
  3. v-model="isShow"
  4. width="65%"
  5. :before-close="dialogClose"
  6. @closed="resetOptions"
  7. >
  8. <el-form
  9. :model="dialogOptions"
  10. :rules="rules"
  11. label-width="120px"
  12. ref="formRef"
  13. inline
  14. >
  15. <el-form-item label="报警类别" prop="deviceType">
  16. <el-select
  17. v-model="dialogOptions.deviceType"
  18. style="width: 120px"
  19. filterable
  20. placeholder="请选择"
  21. @change="
  22. (res) => {
  23. dialogOptions.stationId = '';
  24. checkRules();
  25. getWpList();
  26. }
  27. "
  28. >
  29. <el-option
  30. v-for="item in categoryArray"
  31. :key="item.id"
  32. :label="item.label"
  33. :value="item.id"
  34. />
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="序列号">
  38. <el-input
  39. v-model="dialogOptions.id"
  40. placeholder="自动生成"
  41. clearable
  42. readonly
  43. />
  44. </el-form-item>
  45. <el-form-item label="场站" prop="stationId">
  46. <el-select
  47. v-model="dialogOptions.stationId"
  48. style="width: 120px"
  49. filterable
  50. placeholder="请选择"
  51. :disabled="!wpArray?.length"
  52. @change="
  53. (res) => {
  54. dialogOptions.modelId = '';
  55. getWtModel();
  56. }
  57. "
  58. >
  59. <el-option
  60. v-for="item in wpArray"
  61. :key="item.id"
  62. :label="item.aname"
  63. :value="item.id"
  64. />
  65. </el-select>
  66. </el-form-item>
  67. <el-form-item
  68. label="设备型号"
  69. prop="modelId"
  70. v-if="dialogOptions.deviceType !== 'booststation'"
  71. >
  72. <el-select
  73. v-model="dialogOptions.modelId"
  74. filterable
  75. placeholder="请选择"
  76. :disabled="!modelArray?.length"
  77. >
  78. <el-option
  79. v-for="item in modelArray"
  80. :key="item"
  81. :label="item"
  82. :value="item"
  83. />
  84. </el-select>
  85. </el-form-item>
  86. <el-form-item label="统一编码" prop="uniformCode">
  87. <el-input v-model="dialogOptions.uniformCode" clearable />
  88. </el-form-item>
  89. <el-form-item label="特性" prop="characteristic">
  90. <el-select
  91. v-model="dialogOptions.characteristic"
  92. style="width: 120px"
  93. filterable
  94. placeholder="请选择"
  95. >
  96. <el-option
  97. v-for="item in characteristicArray"
  98. :key="item"
  99. :label="item"
  100. :value="item"
  101. />
  102. </el-select>
  103. </el-form-item>
  104. <el-form-item label="故障编码">
  105. <el-input v-model="dialogOptions.nemCode" clearable />
  106. </el-form-item>
  107. <el-form-item label="描述" prop="description">
  108. <el-input
  109. v-model="dialogOptions.description"
  110. placeholder="请输入"
  111. clearable
  112. />
  113. </el-form-item>
  114. <el-form-item label="报警级别">
  115. <el-select
  116. v-model="dialogOptions.rank"
  117. style="width: 120px"
  118. filterable
  119. placeholder="请选择"
  120. >
  121. <el-option
  122. v-for="item in levelArray"
  123. :key="item.id"
  124. :label="item.label"
  125. :value="item.id"
  126. />
  127. </el-select>
  128. </el-form-item>
  129. <el-form-item
  130. label="测点"
  131. prop="tagId"
  132. v-if="dialogOptions.deviceType === 'booststation'"
  133. >
  134. <el-select
  135. v-model="dialogOptions.tagId"
  136. style="width: 120px"
  137. filterable
  138. placeholder="请选择"
  139. >
  140. <el-option
  141. v-for="item in pointArray"
  142. :key="item.nemCode"
  143. :label="item.name"
  144. :value="item.nemCode"
  145. />
  146. </el-select>
  147. </el-form-item>
  148. <el-form-item
  149. label="关键部件"
  150. prop="components"
  151. v-if="dialogOptions.deviceType !== 'booststation'"
  152. >
  153. <el-select v-model="dialogOptions.components" filterable>
  154. <el-option-group
  155. v-for="group in associatedComponentsArray"
  156. :key="group.label"
  157. :label="group.label"
  158. >
  159. <el-option
  160. v-for="item in group.options"
  161. :key="item.nemCode"
  162. :label="item.name"
  163. :value="item.nemCode"
  164. />
  165. </el-option-group>
  166. </el-select>
  167. </el-form-item>
  168. <el-form-item label="是否启用">
  169. <el-radio-group size="mini" v-model="dialogOptions.enable">
  170. <el-radio-button :label="true">是</el-radio-button>
  171. <el-radio-button :label="false">否</el-radio-button>
  172. </el-radio-group>
  173. </el-form-item>
  174. <el-form-item label="是否可复位">
  175. <el-radio-group size="mini" v-model="dialogOptions.resetTable">
  176. <el-radio-button :label="true">是</el-radio-button>
  177. <el-radio-button :label="false">否</el-radio-button>
  178. </el-radio-group>
  179. </el-form-item>
  180. </el-form>
  181. <template #footer>
  182. <span class="footerButton">
  183. <el-button size="mini" round @click="cancle">取 消</el-button>
  184. <el-button size="mini" round @click="checkData">确 定</el-button>
  185. </span>
  186. </template>
  187. </el-dialog>
  188. </template>
  189. <script>
  190. import {
  191. getWpList,
  192. getBpList,
  193. getWtModel,
  194. getPointList,
  195. fetchRelatePartAndAlarmType,
  196. saveAlarmconfiguration,
  197. } from "@/api/zhbj/index.js";
  198. export default {
  199. props: {
  200. isVisible: {
  201. type: Boolean,
  202. default: () => false,
  203. },
  204. form: {
  205. type: Object,
  206. default: () => {
  207. return {};
  208. },
  209. },
  210. },
  211. data() {
  212. return {
  213. isShow: false,
  214. dialogOptions: {
  215. deviceType: "",
  216. id: "",
  217. stationId: "",
  218. modelId: "",
  219. uniformCode: "",
  220. nemCode: "",
  221. characteristic: "正常停机",
  222. description: "",
  223. rank: 1,
  224. tagId: "",
  225. components: "",
  226. enable: false,
  227. resetTable: false,
  228. },
  229. rules: {
  230. deviceType: [
  231. {
  232. required: true,
  233. message: "报警类型不可为空",
  234. trigger: "change",
  235. },
  236. ],
  237. stationId: [
  238. {
  239. required: true,
  240. message: "场站不可为空",
  241. trigger: "change",
  242. },
  243. ],
  244. modelId: [
  245. {
  246. required: true,
  247. message: "设备型号不可为空",
  248. trigger: "change",
  249. },
  250. ],
  251. uniformCode: [
  252. {
  253. required: true,
  254. message: "统一编码不可为空",
  255. trigger: "change",
  256. },
  257. ],
  258. characteristic: [
  259. {
  260. required: true,
  261. message: "统一编码不可为空",
  262. trigger: "change",
  263. },
  264. ],
  265. tagId: [
  266. {
  267. required: true,
  268. message: "测点不可为空",
  269. trigger: "change",
  270. },
  271. ],
  272. description: [
  273. {
  274. required: true,
  275. message: "描述不可为空",
  276. trigger: "change",
  277. },
  278. ],
  279. components: [
  280. {
  281. required: true,
  282. message: "部件不可为空",
  283. trigger: "change",
  284. },
  285. ],
  286. },
  287. categoryArray: [
  288. { id: "windturbine", label: "风机报警" },
  289. { id: "booststation", label: "升压站报警" },
  290. // { id: "inverter", label: "光伏报警" },
  291. ],
  292. wpArray: [],
  293. modelArray: [],
  294. characteristicArray: ["正常停机", "正常启动", "快速停机", "紧急停机"],
  295. levelArray: [
  296. { id: 1, label: "低级" },
  297. { id: 2, label: "低中级" },
  298. { id: 3, label: "中级" },
  299. { id: 4, label: "中高级" },
  300. { id: 5, label: "高级" },
  301. ],
  302. pointArray: [],
  303. associatedComponentsArray: [],
  304. };
  305. },
  306. created() {
  307. this.isShow = this.isVisible;
  308. this.dialogOptions = Object.assign(this.dialogOptions, this.form);
  309. this.checkRules();
  310. this.getWpList();
  311. this.getfetchRelatePart();
  312. },
  313. methods: {
  314. dialogClose(done) {
  315. this.$confirm("确认关闭?")
  316. .then(() => {
  317. done();
  318. })
  319. .catch(() => {});
  320. },
  321. cancle() {
  322. this.$confirm("确认关闭?")
  323. .then(() => {
  324. this.isShow = false;
  325. })
  326. .catch(() => {});
  327. },
  328. checkRules() {
  329. const isBp = this.dialogOptions.deviceType === "booststation";
  330. const isWt = this.dialogOptions.deviceType === "windturbine";
  331. const isInv = this.dialogOptions.deviceType === "inverter";
  332. this.rules.tagId.forEach((ele) => {
  333. ele.required = isBp;
  334. });
  335. this.rules.modelId.forEach((ele) => {
  336. ele.required = !isBp;
  337. });
  338. this.rules.components.forEach((ele) => {
  339. ele.required = isWt || isInv;
  340. });
  341. },
  342. getWpList() {
  343. if (
  344. this.dialogOptions.deviceType === "windturbine" ||
  345. this.dialogOptions.deviceType === "inverter"
  346. ) {
  347. getWpList(this.dialogOptions.deviceType).then((res) => {
  348. this.dialogOptions.stationId = res?.data?.[0]?.id || "";
  349. this.wpArray = res.data;
  350. this.getWtModel();
  351. });
  352. } else {
  353. getBpList().then((res) => {
  354. this.dialogOptions.stationId = res?.data?.[0]?.id || "";
  355. this.wpArray = res.data;
  356. this.getWtModel();
  357. });
  358. }
  359. },
  360. getWtModel() {
  361. getWtModel(this.dialogOptions.stationId).then((res) => {
  362. this.dialogOptions.modelId = res?.data?.[0] || "";
  363. this.modelArray = res.data;
  364. if (this.dialogOptions.deviceType === "booststation") {
  365. this.getPointList();
  366. }
  367. });
  368. },
  369. getPointList() {
  370. getPointList({
  371. subId: this.dialogOptions.stationId,
  372. }).then((res) => {
  373. this.pointArray = res.data.total;
  374. });
  375. },
  376. getfetchRelatePart() {
  377. fetchRelatePartAndAlarmType().then((res) => {
  378. if (res.data) {
  379. const keyMap = {
  380. fjbj: "风机部件",
  381. gfbj: "光伏部件",
  382. };
  383. let associatedComponentsArray = [];
  384. for (let key in keyMap) {
  385. associatedComponentsArray.push({
  386. id: key,
  387. label: keyMap[key],
  388. options: res.data[key] || [],
  389. });
  390. }
  391. this.dialogOptions.components =
  392. associatedComponentsArray?.[0]?.options?.[0]?.nemCode || "";
  393. this.associatedComponentsArray = associatedComponentsArray;
  394. }
  395. });
  396. },
  397. checkData() {
  398. this.$refs.formRef.validate((valid, fields) => {
  399. if (valid) {
  400. saveAlarmconfiguration(
  401. Object.assign(this.dialogOptions, {
  402. alarmType:
  403. this.dialogOptions.alarmType || this.dialogOptions.deviceType,
  404. })
  405. ).then((res) => {
  406. if (res.code === 200) {
  407. this.BASE.showMsg({
  408. type: "success",
  409. msg: "提交成功",
  410. });
  411. this.isShow = false;
  412. }
  413. });
  414. }
  415. });
  416. },
  417. resetOptions() {
  418. this.dialogOptions = {
  419. deviceType: "",
  420. id: "",
  421. stationId: "",
  422. modelId: "",
  423. uniformCode: "",
  424. characteristic: "正常停机",
  425. nemCode: "",
  426. description: "",
  427. rank: 1,
  428. tagId: "",
  429. components: "",
  430. enable: false,
  431. resetTable: false,
  432. };
  433. this.resetForm();
  434. },
  435. resetForm() {
  436. this.$refs.formRef.resetFields();
  437. },
  438. },
  439. watch: {
  440. isVisible(value) {
  441. this.isShow = value;
  442. },
  443. form(value) {
  444. this.dialogOptions = value;
  445. this.checkRules();
  446. this.getWpList();
  447. },
  448. },
  449. };
  450. </script>