Newer
Older
KaiFengPC / src / views / floodSys / scada / deviceInfo / todoDon.vue
@zhangdeliang zhangdeliang on 23 May 4 KB 初始化项目
<template>
  <div class="water-analysis-page">
    <el-table :key="isFlag" :data="tableData" v-loading="tableLoading" max-height="600">
      <el-table-column type="index" width="70" label="序号" />
      <el-table-column :label="i.label" :prop="i.prop" show-overflow-tooltip v-for="i in deviceInfoCloum">
        <template #default="{ row }" v-if="i.prop == 'deviceType'">
          <dict-tag :options="device_type" :value="row.deviceType" />
        </template>
        <template #default="{ row }" v-if="i.prop == 'areaName'">
          {{ getstationName(row.areaCode) }}
        </template>
        <template #default="{ row }" v-if="i.prop == 'status'">
          <el-tag class="ml-2" :type="row.status == 1 ? 'success' : 'danger'"> {{ row.status == 1 ? '启用' : '停用' }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="250">
        <template #default="{ row }">
          <el-button link type="primary" icon="View" @click="onCheck(row, 1, '详情')">详情</el-button>
          <el-button link icon="Edit" type="warning" @click="onCheck(row, 2, '修改')">修改</el-button>
          <el-button link icon="Delete" type="danger" @click="onCheck(row, 3)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="totals > 0"
      :total="totals"
      v-model:page="FormList.pageNum"
      v-model:limit="FormList.pageSize"
      @pagination="getInfoList(FormList)"
    />
  </div>
  <el-dialog
    v-model="visible"
    :title="'PLC设备信息' + FormList.title"
    :modal-append-to-body="false"
    :close-on-click-modal="false"
    width="51%"
  >
    <tableDalgo ref="tableDalgoRef" v-if="visible" @onModalClose="onModalClose" :typeList="typeList" :key="isFlag"></tableDalgo>
    <template #footer>
      <div class="dialog-footer">
        <el-button v-show="typeList.type == '2'" @click="open2" type="primary">保存</el-button>
        <el-button @click="visible = false">关闭</el-button>
      </div>
    </template>
  </el-dialog>
</template>
<script setup>
import { areaInfolist } from '@/api/scada/areaInfo';
import { ElMessage, ElMessageBox } from 'element-plus';
import { getInfo, projectInfoDelete, projectInfoGet } from '@/api/scada/deviceInfo';
import { FileSystemList } from '@/api/project/tenderReview';
import tableDalgo from './tableDalgo.vue';
import { deviceInfoCloum } from '@/utils/cloums';
const { proxy } = getCurrentInstance();
const { device_type } = proxy.useDict('device_type');
import { reactive } from 'vue';
const { typeListList } = defineProps(['typeListList']);
let visible = ref(false);
let isFlag = ref(1);
const tableDalgoRef = ref();
const FormList = ref({});
const totals = ref(0);
let dataForm = reactive({
  tableData: [],
  tableDateTwo: '',
  tableLoading: true,
});
let { tableData, tableLoading } = toRefs(dataForm);
//获取列表数据
const getInfoList = async prams => {
  tableLoading.value = true;
  let { data, total } = await getInfo(prams);
  tableData.value = data;
  totals.value = total;
  tableLoading.value = false;
};
//搜索
const search = p => {
  FormList.value = p;
  FormList.value.pageNum = 1;
  getInfoList(p);
  isFlag.value++;
};
defineExpose({ search });
// 查看上报数据
let typeList = ref({});
const onCheck = (row, ty, t) => {
  FormList.value.title = t;
  if (ty == 1 || ty == 2) {
    projectInfoGet(row.id).then(({ code, data }) => {
      if (code == 200) {
        typeList.value = { ...typeListList, type: ty, ...data };
        visible.value = true;
        FileSystemList({
          refId: row.id,
          refType: 'plcDevicePictures',
        }).then(({ data }) => {
          typeList.value.fileSaveRequestList = data;
        });
      }
    });
    // 获取文件列表
  } else if (ty == 3) {
    ElMessageBox.confirm(`您确定删除吗?`, '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
    })
      .then(() => {
        proxy.$modal.msgSuccess('操作成功!');
        projectInfoDeleteM(row.id);
      })
      .catch(() => {});
    // emgBox(row.id, projectInfoDeleteM, "您确定删除吗?");
  }
};
//删除
const projectInfoDeleteM = async id => {
  let { code } = await projectInfoDelete(id);
  getInfoList();
};
function onModalClose() {
  visible.value = false;
  getInfoList();
}

function open2() {
  tableDalgoRef.value.submit();
}
function getstationName(v) {
  let arrr = arrrOne.value.filter(i => {
    return i.areaCode == v;
  });
  return arrr[0]?.areaName;
}
const arrrOne = ref([]);

const areaInfolistM = async p => {
  let { data } = await areaInfolist(p);
  arrrOne.value = data;
};
onMounted(() => {
  areaInfolistM();
});
</script>
<style lang="scss" scoped></style>