123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- <template>
- <div>
- <div class="traBox">
- <span
- style="line-height: 22px;height: 22px;float: left;width: 92%;margin: 4%;font-weight: bold;border-bottom: 1px solid #e4e2e2;">
- <img style="width: 20px;height: 20px;margin-right: 5px;float: left;" src="../../../assets/icon/pice_set.png"
- alt="">
- <span style="float: left;font-size: 16px;font-weight: 500;">一次性接线方式</span>
- </span>
- <el-tree v-if="vif" node-key="id" style="float: left;width: 100%;margin: 0 auto;background-color: #F7F8FB;"
- :data="lineData" :props="defaultProps" @node-click="handleNodeClick" />
- <el-tree v-else node-key="id" style="float: left;width: 100%;margin: 0 auto;background-color: #F7F8FB;"
- :data="lineData" :props="defaultProps" @node-click="handleModelNodeClick" ref="tree2">
- <template #default="{ node, data }">
- <span>
- <!-- 正常情况 -->
- <span v-if="data.datatype == 'linkstyle'"><img
- style="width: 20px;height: 20px;margin-right: 5px;float: left;"
- src="../../../assets/icon/pice_set.png" alt="" /></span>
- <span>
- {{ node.label }}
- </span>
- </span>
- </template>
- </el-tree>
- <!--
- <p v-else v-for="(item,index) in pList" :class="selectIndex == index?'result':'chooseP'" @click="pClick(item,index)">
- {{ item.name }}
- </p>
- -->
- </div>
- </div>
- </template>
- <script>
- import { ref, onMounted, toRefs, watch } from 'vue'
- import litLine from '@/api/litLine'
- import systemRow from '@/api/systemRow';
- import LitLine from './LitLine.vue';
- import { ElMessage } from 'element-plus';
- export default {
- props: {
- selectIndex: {
- type: Number,
- required: true
- },
- moduleSize: {
- type: Number,
- required: true
- },
- moduleIndex: {
- type: Number,
- required: true
- }
- },
- setup(props, { emit }) {
- let lineData = ref([])//树形数据
- let defaultProps = ref({
- children: "children",
- label: "name",
- id: 'id'
- })
- let pushList = ref([])
- let result = ref(0)
- let pList = ref([])
- let selectIndex = ref(null)
- let vif = ref(true)
- let loading = ref(false)
- let counts = ref(0)//总条数
- let size = ref(0)
- let index = ref(10)
- let intE = ref("")
- watch(() => props.selectIndex, (newVal) => {
- result.value = newVal
- searchFlashLel()
- })
- watch(() => props.moduleIndex, (newVal) => {
- size.value = newVal
- litLine.getAllm({ pageno: index.value, pagesize: size.value, vol_id: intE.value - 0 }).then(res => {
- if (res.code == 0) {
- loading.value = true
- counts.value = res.count
- console.log(counts.value, 'linetree');
- emit("lineBack", loading.value)
- emit("volBack", res.data, intE.value - 0, counts.value)
- } else {
- ElMessage({
- message: res.msg,
- type: "error"
- })
- }
- })
- })
- watch(() => props.moduleSize, (newVal) => {
- index.value = newVal
- litLine.getAllm({ pageno: index.value, pagesize: size.value, vol_id: intE.value - 0 }).then(res => {
- if (res.code == 0) {
- loading.value = true
- counts.value = res.count
- console.log(counts.value, 'linetree');
- emit("lineBack", loading.value)
- emit("volBack", res.data, intE.value - 0, counts.value)
- } else {
- ElMessage({
- message: res.msg,
- type: "error"
- })
- }
- })
- })
- function searchLine() {
- size.value = props.moduleIndex
- index.value = props.moduleSize
- }
- function searchFlashLel() {//拿到电压等级
- systemRow.getChildren({ code: "voltage_level" }).then(res => {
- vif.value = true
- if (props.selectIndex == 1) {
- vif.value = false
- // 获取每个电压等级下的接线方式
- litLine.getAllLine({ pageno: 1, pagesize: 20 }).then(res2 => {
- for (let i = 0; i < res2.data.length; i++) {
- const vol_level_id = res2.data[i].vol_level_id
- res.data.filter((item) => {
- if (item.id == vol_level_id) {
- res2.data[i]['datatype'] = 'linkstyle'
- item['children'] == null ? item['children'] = [res2.data[i]] : item['children'].push(res2.data[i])
- return item
- }
- })
- }
- lineData.value = res.data
- })
- } else {
- lineData.value = res.data
- }
- })
- }
- function handleNodeClick(e) {
- litLine.getAllLine({ pageno: 1, pagesize: 20, vol_id: e.id - 0 }).then(res => {
- if (res.code == 0) {
- loading.value = true
- emit("lineBack", loading.value)
- pushList.value = res.data
- emit("listBack", res.data)
- } else {
- ElMessage({
- message: res.msg,
- type: "error"
- })
- }
- })
- }
- function handleModelNodeClick(e) {
- // 模型管理
- if (e.datatype === 'linkstyle') {
- // 接线方式
- litLine.getAllm({ pageno: 1, pagesize: 20, line_link_style: e.id }).then(res => {
- if (res.code == 0) {
- loading.value = true
- emit("lineBack", loading.value)
- emit("listBack", res.data, e.id)
- } else {
- ElMessage({
- message: res.msg,
- type: "error"
- })
- }
- })
- } else {
- // 电压等级
- intE.value = e.id
- litLine.getAllm({ pageno: 1, pagesize: 20, vol_id: intE.value - 0 }).then(res => {
- if (res.code == 0) {
- loading.value = true
- counts.value = res.count
- console.log(counts.value, 'linetree');
- emit("lineBack", loading.value)
- emit("volBack", res.data, e.id, counts.value)
- } else {
- ElMessage({
- message: res.msg,
- type: "error"
- })
- }
- })
- }
- }
- function pClick(row, num) {
- selectIndex.value = num
- litLine.getAllLine({ pageno: 1, pagesize: 20, vol_id: row.id - 0 }).then(res => {
- if (res.code == 0) {
- pushList.value = res.data
- emit("listBack", pushList.value, row.id)
- }
- })
- }
- onMounted(() => {
- searchLine()
- searchFlashLel()
- })
- return {
- lineData,//树形数据
- searchLine,//获取数据
- defaultProps,
- searchFlashLel,
- handleNodeClick,
- handleModelNodeClick,
- pushList,
- result,
- pList,
- selectIndex,
- pClick,
- vif,
- loading,
- counts,//总条数
- size,
- index,
- intE,
- }
- },
- components: {
- LitLine
- }
- }
- </script>
- <style scoped>
- .traBox {
- text-align: center;
- }
- .result {
- font-size: 12px;
- color: #5D7FDA;
- }
- .chooseP {
- font-size: 12px;
- }
- .el-tree {
- --el-tree-node-content-height: 32px;
- --el-tree-node-hover-bg-color: #b2b4ef80 !important;
- }
- .el-tree-node:hover {
- background-color: #b2b4ef80 !important;
- color: #fff;
- }
- .is-current {
- background: #b2b4ef !important;
- color: #fff !important;
- font-weight: bold;
- }
- </style>
|