index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <el-dialog v-model="dialogVisible" width="80%" top="80px">
  3. <template #title>
  4. <div class="dialog-title">
  5. <div class="title">
  6. {{ showname }}(<span class="count"> {{ checkList.length }} </span>)
  7. </div>
  8. </div>
  9. </template>
  10. <div
  11. class="dialog-body"
  12. :style="text == 'single' ? 'height: 700px' : 'height: 800px'"
  13. >
  14. <img class="dialog-img" src="@/assets/imgs/dialog.png" />
  15. <div class="dialog-form">
  16. <el-checkbox
  17. class="checkall"
  18. v-model="checkAll"
  19. :indeterminate="isIndeterminate"
  20. @change="handleCheckAllChange"
  21. >全选</el-checkbox
  22. >
  23. <el-select
  24. v-model="selectValue"
  25. placeholder="请输入..."
  26. size="mini"
  27. filterable
  28. @change="handleSelectedChange"
  29. @visible-change="handleClearSelected"
  30. >
  31. <el-option
  32. v-for="item in allMoreTargetData.length
  33. ? allMoreTargetData
  34. : moreTargetData"
  35. :key="item.name"
  36. :label="item.name"
  37. :value="item.uniformCode"
  38. />
  39. </el-select>
  40. </div>
  41. <div
  42. v-if="text == 'single' && type == -1"
  43. style="height: calc(100% - 72px)"
  44. >
  45. <div class="targetNav">
  46. <ul>
  47. <li
  48. :class="{ active: headerIndex == -1, 'li-left': true }"
  49. @click="getMoreUniformCodesList(-1, -1, '')"
  50. >
  51. 全部
  52. </li>
  53. <li
  54. v-for="(item, index) in partList"
  55. :key="index"
  56. :class="{
  57. active: headerIndex == index,
  58. 'li-right': index == partList.length - 1,
  59. }"
  60. @click="getMoreUniformCodesList(-1, index, item.code)"
  61. >
  62. {{ item.label }}
  63. </li>
  64. </ul>
  65. </div>
  66. <div class="box">
  67. <el-checkbox-group v-model="checkList" @change="handleCheckedChange">
  68. <el-checkbox
  69. v-for="(item, index) in moreTargetData"
  70. :key="index"
  71. :label="item.name"
  72. ></el-checkbox>
  73. </el-checkbox-group>
  74. </div>
  75. </div>
  76. <el-checkbox-group
  77. v-model="checkList"
  78. style="height: calc(100% - 72px)"
  79. v-else
  80. >
  81. <el-checkbox
  82. v-for="(item, index) in moreTargetData"
  83. :key="index"
  84. :label="item.name"
  85. ></el-checkbox>
  86. </el-checkbox-group>
  87. <el-row class="footerButton">
  88. <el-button round @click="cancel">取消</el-button>
  89. <el-button round @click="tableRefresh">确认</el-button>
  90. </el-row>
  91. </div>
  92. <!-- <template #footer>
  93. <span class="dialog-footer">
  94. <el-button size="mini" round @click="cancel">取消</el-button>
  95. <el-button size="mini" type="primary" round @click="tableRefresh"
  96. >确认</el-button
  97. >
  98. </span>
  99. </template> -->
  100. </el-dialog>
  101. </template>
  102. <script>
  103. import { GetWtTargets } from "@/api/factoryMonitor/index.js";
  104. import { getComprehensiveTargets } from "@/api/monitor/index.js";
  105. export default {
  106. name: "zbDialog", //指标弹窗
  107. components: {},
  108. props: {
  109. uniformName: {
  110. type: String,
  111. required: true,
  112. },
  113. uniformCode: {
  114. type: String,
  115. required: true,
  116. },
  117. showname: {
  118. type: String,
  119. required: true,
  120. },
  121. },
  122. data() {
  123. return {
  124. dialogVisible: false,
  125. text: "",
  126. type: -1,
  127. checkAll: false,
  128. isIndeterminate: true,
  129. selectValue: "",
  130. checkList: [],
  131. moreTargetData: [],
  132. allMoreTargetData: [],
  133. headerIndex: -1,
  134. partList: [
  135. { label: "发电机", code: "fdj" },
  136. { label: "齿轮箱", code: "clx" },
  137. { label: "变桨", code: "bj" },
  138. { label: "偏航", code: "ph" },
  139. { label: "液压", code: "yy" },
  140. { label: "机舱", code: "jc" },
  141. { label: "其他", code: "qt" },
  142. ],
  143. showIt: true,
  144. };
  145. },
  146. created() {},
  147. methods: {
  148. // 初始化弹窗数据
  149. openDialog(type, text, station) {
  150. this.dialogVisible = true;
  151. this.text = text;
  152. this.type = type;
  153. if (station && station == "SXJ_KGDL_BHB3_FDC_STA") {
  154. this.partList = [
  155. { label: "发电机", code: "fdj" },
  156. { label: "变桨", code: "bj" },
  157. { label: "偏航", code: "ph" },
  158. { label: "液压", code: "yy" },
  159. { label: "机舱", code: "jc" },
  160. { label: "其他", code: "qt" },
  161. ];
  162. } else {
  163. this.partList = [
  164. { label: "发电机", code: "fdj" },
  165. { label: "齿轮箱", code: "clx" },
  166. { label: "变桨", code: "bj" },
  167. { label: "偏航", code: "ph" },
  168. { label: "液压", code: "yy" },
  169. { label: "机舱", code: "jc" },
  170. { label: "其他", code: "qt" },
  171. ];
  172. }
  173. this.checkList = this.uniformName;
  174. // 判断从哪个页面打开 single----数据指标
  175. if (text == "single") {
  176. this.getMoreUniformCodesList(type, this.headerIndex, "", true);
  177. } else {
  178. this.getComprehensiveTargets(type);
  179. }
  180. },
  181. // 获取综合指标
  182. getComprehensiveTargets(type) {
  183. getComprehensiveTargets({
  184. type,
  185. }).then((res) => {
  186. this.getCheckList(res.data.data);
  187. });
  188. },
  189. //获取风机或者光伏的全部指标
  190. getMoreUniformCodesList(type, index, part = "", flag) {
  191. if (type == -1) {
  192. this.headerIndex = index;
  193. }
  194. GetWtTargets({ type, part }).then(({ data }) => {
  195. if (!part.length) {
  196. this.allMoreTargetData = data.data;
  197. }
  198. if (flag) {
  199. this.getCheckList(data.data);
  200. } else {
  201. this.moreTargetData = data.data;
  202. }
  203. });
  204. },
  205. // 选中指标去重并回填
  206. getCheckList(data) {
  207. this.moreTargetData = data;
  208. // 数据回填处理
  209. const codeArr = this.uniformCode.split(",");
  210. var newArr = [...new Set(codeArr)];
  211. let result = {};
  212. if (newArr.length > 0) {
  213. newArr.forEach((str) => {
  214. result = this.moreTargetData.find((obj) => str == obj.uniformCode);
  215. if (result) {
  216. this.checkList.push(result.name);
  217. }
  218. });
  219. }
  220. this.checkList = [...new Set(this.checkList)];
  221. },
  222. // 取消操作
  223. cancel() {
  224. this.dialogVisible = false;
  225. this.allMoreTargetData = [];
  226. this.moreTargetData = [];
  227. this.checkList = [];
  228. },
  229. // 确定并刷新列表
  230. tableRefresh() {
  231. this.dialogVisible = false;
  232. this.headerIndex = -1;
  233. this.$emit(
  234. "tableRefresh",
  235. this.checkList,
  236. this.allMoreTargetData.length
  237. ? this.allMoreTargetData
  238. : this.moreTargetData
  239. );
  240. },
  241. // 全选按钮变化
  242. handleCheckAllChange(val) {
  243. this.checkList = val
  244. ? this.allMoreTargetData.length
  245. ? this.allMoreTargetData.map((item) => item.name)
  246. : this.moreTargetData.map((item) => item.name)
  247. : [];
  248. this.isIndeterminate = false;
  249. },
  250. //各标签按钮变化
  251. handleCheckedChange(checked) {
  252. const checkedCount = checked.length;
  253. this.checkAll =
  254. checkedCount ===
  255. (this.allMoreTargetData.length
  256. ? this.allMoreTargetData.length
  257. : this.moreTargetData.length);
  258. this.isIndeterminate =
  259. checkedCount > 0 &&
  260. checkedCount <
  261. (this.allMoreTargetData.length
  262. ? this.allMoreTargetData.length
  263. : this.moreTargetData.length);
  264. },
  265. handleSelectedChange(val) {
  266. let select = this.allMoreTargetData.length
  267. ? this.allMoreTargetData.find((obj) => val == obj.uniformCode)
  268. : this.moreTargetData.find((obj) => val == obj.uniformCode);
  269. if (Object.keys(select).length) {
  270. this.checkList.push(select.name);
  271. }
  272. this.checkList = [...new Set(this.checkList)];
  273. },
  274. },
  275. mounted() {},
  276. computed: {},
  277. };
  278. </script>
  279. <style lang="less" scoped>
  280. .dialog-form {
  281. display: flex;
  282. align-items: center;
  283. margin-bottom: 10px;
  284. .checkall {
  285. margin-right: 10px;
  286. width: 80px;
  287. }
  288. }
  289. .el-checkbox {
  290. width: 180px;
  291. }
  292. .targetNav {
  293. margin-bottom: 16px;
  294. ul {
  295. display: flex;
  296. flex-direction: row;
  297. justify-content: center;
  298. li {
  299. width: 140px;
  300. height: 100%;
  301. text-align: center;
  302. color: #b3bdc0;
  303. // background: rgba(67, 81, 107, 0.2);
  304. background: rgba(96, 103, 105, 0.2);
  305. border-left: 1px solid #3b6c53;
  306. border-top: 1px solid #3b6c53;
  307. border-bottom: 1px solid #3b6c53;
  308. &.li-left {
  309. border-radius: 15px 0px 0px 15px;
  310. }
  311. &.li-right {
  312. border-right: 1px solid #3b6c53;
  313. border-radius: 0px 15px 15px 0px;
  314. }
  315. &.active {
  316. background-color: rgba(0, 199, 19, 0.4);
  317. color: #ffffff;
  318. }
  319. }
  320. }
  321. }
  322. </style>