| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328 |
- <template>
- <el-dialog v-model="dialogVisible" width="80%" top="80px">
- <template #title>
- <div class="dialog-title">
- <div class="title">
- {{ showname }}(<span class="count"> {{ checkList.length }} </span>)
- </div>
- </div>
- </template>
- <div
- class="dialog-body"
- :style="text == 'single' ? 'height: 700px' : 'height: 800px'"
- >
- <img class="dialog-img" src="@/assets/imgs/dialog.png" />
- <div class="dialog-form">
- <el-checkbox
- class="checkall"
- v-model="checkAll"
- :indeterminate="isIndeterminate"
- @change="handleCheckAllChange"
- >全选</el-checkbox
- >
- <el-select
- v-model="selectValue"
- placeholder="请输入..."
- size="mini"
- filterable
- @change="handleSelectedChange"
- @visible-change="handleClearSelected"
- >
- <el-option
- v-for="item in allMoreTargetData.length
- ? allMoreTargetData
- : moreTargetData"
- :key="item.name"
- :label="item.name"
- :value="item.uniformCode"
- />
- </el-select>
- </div>
- <div
- v-if="text == 'single' && type == -1"
- style="height: calc(100% - 72px)"
- >
- <div class="targetNav">
- <ul>
- <li
- :class="{ active: headerIndex == -1, 'li-left': true }"
- @click="getMoreUniformCodesList(-1, -1, '')"
- >
- 全部
- </li>
- <li
- v-for="(item, index) in partList"
- :key="index"
- :class="{
- active: headerIndex == index,
- 'li-right': index == partList.length - 1,
- }"
- @click="getMoreUniformCodesList(-1, index, item.code)"
- >
- {{ item.label }}
- </li>
- </ul>
- </div>
- <div class="box">
- <el-checkbox-group v-model="checkList" @change="handleCheckedChange">
- <el-checkbox
- v-for="(item, index) in moreTargetData"
- :key="index"
- :label="item.name"
- ></el-checkbox>
- </el-checkbox-group>
- </div>
- </div>
- <el-checkbox-group
- v-model="checkList"
- style="height: calc(100% - 72px)"
- v-else
- >
- <el-checkbox
- v-for="(item, index) in moreTargetData"
- :key="index"
- :label="item.name"
- ></el-checkbox>
- </el-checkbox-group>
- <el-row class="footerButton">
- <el-button round @click="cancel">取消</el-button>
- <el-button round @click="tableRefresh">确认</el-button>
- </el-row>
- </div>
- <!-- <template #footer>
- <span class="dialog-footer">
- <el-button size="mini" round @click="cancel">取消</el-button>
- <el-button size="mini" type="primary" round @click="tableRefresh"
- >确认</el-button
- >
- </span>
- </template> -->
- </el-dialog>
- </template>
- <script>
- import { GetWtTargets } from "@/api/factoryMonitor/index.js";
- import { getComprehensiveTargets } from "@/api/monitor/index.js";
- export default {
- name: "zbDialog", //指标弹窗
- components: {},
- props: {
- uniformName: {
- type: String,
- required: true,
- },
- uniformCode: {
- type: String,
- required: true,
- },
- showname: {
- type: String,
- required: true,
- },
- },
- data() {
- return {
- dialogVisible: false,
- text: "",
- type: -1,
- checkAll: false,
- isIndeterminate: true,
- selectValue: "",
- checkList: [],
- moreTargetData: [],
- allMoreTargetData: [],
- headerIndex: -1,
- partList: [
- { label: "发电机", code: "fdj" },
- { label: "齿轮箱", code: "clx" },
- { label: "变桨", code: "bj" },
- { label: "偏航", code: "ph" },
- { label: "液压", code: "yy" },
- { label: "机舱", code: "jc" },
- { label: "其他", code: "qt" },
- ],
- showIt: true,
- };
- },
- created() {},
- methods: {
- // 初始化弹窗数据
- openDialog(type, text, station) {
- this.dialogVisible = true;
- this.text = text;
- this.type = type;
- if (station && station == "SXJ_KGDL_BHB3_FDC_STA") {
- this.partList = [
- { label: "发电机", code: "fdj" },
- { label: "变桨", code: "bj" },
- { label: "偏航", code: "ph" },
- { label: "液压", code: "yy" },
- { label: "机舱", code: "jc" },
- { label: "其他", code: "qt" },
- ];
- } else {
- this.partList = [
- { label: "发电机", code: "fdj" },
- { label: "齿轮箱", code: "clx" },
- { label: "变桨", code: "bj" },
- { label: "偏航", code: "ph" },
- { label: "液压", code: "yy" },
- { label: "机舱", code: "jc" },
- { label: "其他", code: "qt" },
- ];
- }
- this.checkList = this.uniformName;
- // 判断从哪个页面打开 single----数据指标
- if (text == "single") {
- this.getMoreUniformCodesList(type, this.headerIndex, "", true);
- } else {
- this.getComprehensiveTargets(type);
- }
- },
- // 获取综合指标
- getComprehensiveTargets(type) {
- getComprehensiveTargets({
- type,
- }).then((res) => {
- this.getCheckList(res.data.data);
- });
- },
- //获取风机或者光伏的全部指标
- getMoreUniformCodesList(type, index, part = "", flag) {
- if (type == -1) {
- this.headerIndex = index;
- }
- GetWtTargets({ type, part }).then(({ data }) => {
- if (!part.length) {
- this.allMoreTargetData = data.data;
- }
- if (flag) {
- this.getCheckList(data.data);
- } else {
- this.moreTargetData = data.data;
- }
- });
- },
- // 选中指标去重并回填
- getCheckList(data) {
- this.moreTargetData = data;
- // 数据回填处理
- const codeArr = this.uniformCode.split(",");
- var newArr = [...new Set(codeArr)];
- let result = {};
- if (newArr.length > 0) {
- newArr.forEach((str) => {
- result = this.moreTargetData.find((obj) => str == obj.uniformCode);
- if (result) {
- this.checkList.push(result.name);
- }
- });
- }
- this.checkList = [...new Set(this.checkList)];
- },
- // 取消操作
- cancel() {
- this.dialogVisible = false;
- this.allMoreTargetData = [];
- this.moreTargetData = [];
- this.checkList = [];
- },
- // 确定并刷新列表
- tableRefresh() {
- this.dialogVisible = false;
- this.headerIndex = -1;
- this.$emit(
- "tableRefresh",
- this.checkList,
- this.allMoreTargetData.length
- ? this.allMoreTargetData
- : this.moreTargetData
- );
- },
- // 全选按钮变化
- handleCheckAllChange(val) {
- this.checkList = val
- ? this.allMoreTargetData.length
- ? this.allMoreTargetData.map((item) => item.name)
- : this.moreTargetData.map((item) => item.name)
- : [];
- this.isIndeterminate = false;
- },
- //各标签按钮变化
- handleCheckedChange(checked) {
- const checkedCount = checked.length;
- this.checkAll =
- checkedCount ===
- (this.allMoreTargetData.length
- ? this.allMoreTargetData.length
- : this.moreTargetData.length);
- this.isIndeterminate =
- checkedCount > 0 &&
- checkedCount <
- (this.allMoreTargetData.length
- ? this.allMoreTargetData.length
- : this.moreTargetData.length);
- },
- handleSelectedChange(val) {
- let select = this.allMoreTargetData.length
- ? this.allMoreTargetData.find((obj) => val == obj.uniformCode)
- : this.moreTargetData.find((obj) => val == obj.uniformCode);
- if (Object.keys(select).length) {
- this.checkList.push(select.name);
- }
- this.checkList = [...new Set(this.checkList)];
- },
- },
- mounted() {},
- computed: {},
- };
- </script>
- <style lang="less" scoped>
- .dialog-form {
- display: flex;
- align-items: center;
- margin-bottom: 10px;
- .checkall {
- margin-right: 10px;
- width: 80px;
- }
- }
- .el-checkbox {
- width: 180px;
- }
- .targetNav {
- margin-bottom: 16px;
- ul {
- display: flex;
- flex-direction: row;
- justify-content: center;
- li {
- width: 140px;
- height: 100%;
- text-align: center;
- color: #b3bdc0;
- // background: rgba(67, 81, 107, 0.2);
- background: rgba(96, 103, 105, 0.2);
- border-left: 1px solid #3b6c53;
- border-top: 1px solid #3b6c53;
- border-bottom: 1px solid #3b6c53;
- &.li-left {
- border-radius: 15px 0px 0px 15px;
- }
- &.li-right {
- border-right: 1px solid #3b6c53;
- border-radius: 0px 15px 15px 0px;
- }
- &.active {
- background-color: rgba(0, 199, 19, 0.4);
- color: #ffffff;
- }
- }
- }
- }
- </style>
|