123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- <template>
- <div class="airportInfo scroll-y">
- <div class="wrap">
- <Minheader
- :is-auth="true"
- :is-statuser="true"
- powerData="equipment_addition_button"
- @addForm="addForm"
- >
- <template #header>
- <div class="status flex-wrap">
- <div class="manageTitle">设备维护</div>
- </div>
- </template>
- </Minheader>
- <div class="app-containers">
- <DataTable
- :tableHeader="tableCols"
- :tableData="tableData"
- :tableBtnGroup="tableBtnGroup"
- :tableProperty="{ rowKey: 'ID' }"
- @btnClick="btnClick"
- />
- </div>
- <Dialog
- :flag="flag"
- :type="type"
- :msgTitle="msgTitle"
- :delName="tableForm.deviceName"
- @resetForm="resetForm"
- @delRest="delRest"
- @submitForm="submitForm"
- @delRemove="delRemove"
- >
- <div class="diacont">
- <el-form
- :model="tableForm"
- :rules="formRules"
- ref="equipmentMaintenanceForm"
- >
- <el-row :gutter="24">
- <el-col>
- <el-form-item
- label="设备ID"
- size="default"
- prop="deviceID"
- :rules="formRules.isNotNull"
- >
- <el-input
- v-model="tableForm.deviceID"
- placeholder="请输入设备ID"
- />
- </el-form-item>
- </el-col>
- <el-col>
- <el-form-item
- label="设备名称"
- size="default"
- prop="deviceName"
- :rules="formRules.isNotNull"
- >
- <el-input
- v-model="tableForm.deviceName"
- placeholder="请输入设备名称"
- />
- </el-form-item>
- </el-col>
- <el-col>
- <el-form-item
- label="设备类型"
- size="default"
- :rules="formRules.isNotNull"
- prop="deviceType"
- >
- <el-input
- v-model="tableForm.deviceType"
- placeholder="请输入设备类型"
- />
- </el-form-item>
- </el-col>
- <el-col>
- <el-form-item
- label="设备位置"
- size="default"
- :rules="formRules.isNotNull"
- prop="location"
- >
- <el-input
- v-model="tableForm.location"
- placeholder="请输入设备位置"
- />
- </el-form-item>
- </el-col>
- <el-col>
- <el-form-item
- label="设备编码"
- size="default"
- prop="deviceCode"
- :rules="formRules.isNotNull"
- >
- <el-input
- v-model="tableForm.deviceCode"
- placeholder="请输入设备编码"
- />
- </el-form-item>
- </el-col>
- <el-col>
- <el-form-item
- label="IP"
- size="default"
- prop="deviceIP"
- :rules="formRules.isNotNull"
- >
- <el-input
- type="textarea"
- v-model="tableForm.deviceIP"
- placeholder="请输入IP"
- />
- </el-form-item>
- </el-col>
- <el-col>
- <el-form-item
- label="备注"
- :rules="formRules.isNotNull"
- size="default"
- >
- <el-input
- type="textarea"
- v-model="tableForm.remarks"
- placeholder="请输入备注"
- />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- </div>
- </Dialog>
- </div>
- </div>
- </template>
- <script setup lang="ts">
- import DataTable from "@/components/tableTemp/index.vue";
- import Minheader from "@/components/minheader/index.vue";
- import Dialog from "@/components/dialog/index.vue";
- import { Query, GeneralDataReception } from "@/api/webApi";
- import { ElMessage } from "element-plus";
- const formRules = useElement().formRules;
- const page = ref<number>(0); //分页参数
- const dataContent = ref<object>({});
- const noMore = ref<boolean>(false);
- const rowTitle = ref<string>("");
- const tableCols = ref<any>([]); //表头数据
- const serviceId = ref<any>("");
- const tableObj = ref({}); //增删改数据缓存
- const flag = ref<boolean>(false); //弹窗开关
- const type = ref<string>(""); //判断是否删除
- const msgTitle = ref<string>("新增设备维护"); //弹窗标题
- const tableColsCopys = reactive<Object>({}); //弹窗
- const conditon = ref("");
- const tableForm = reactive<any>({
- deviceID: "",
- deviceName: "",
- deviceType: "",
- deviceIP: "",
- location: "",
- deviceCode: "",
- remarks: "",
- event: "",
- }); //弹窗内容
- //列表
- const tableData = ref<any>([]);
- //表头
- const state = reactive({
- list: [
- { label: "设备名称", key: "name" },
- { label: "所在位置", key: "china" },
- { label: "设备类型", key: "englin" },
- { label: "设备IP", key: "two" },
- { label: "在离线状态", key: "three" },
- { label: "忙碌空闲", key: "text" },
- ],
- listLoading: true,
- });
- const tableBtnGroup = ref([
- {
- name: "编辑",
- className: "editBtn",
- param: 2,
- is: "device_editing_button",
- },
- {
- name: "删除",
- className: "delBtn",
- param: 3,
- is: "device_deletion_button",
- },
- ]);
- //新增
- const addForm = () => {
- msgTitle.value = "新增设备维护";
- flag.value = true;
- type.value = "";
- for (const key in tableForm) {
- tableForm[key] = "";
- }
- tableForm.event = 1;
- };
- //取消
- const resetForm = () => {
- equipmentMaintenanceForm.value?.resetFields();
- flag.value = false;
- // tableForm.deviceID = "";
- // tableForm.deviceName = "";
- // tableForm.deviceType = "";
- // tableForm.deviceIP = "";
- // tableForm.deviceCode = "";
- // tableForm.remarks = "";
- };
- //编辑
- const editDialog = (data) => {
- msgTitle.value = "编辑设备维护";
- flag.value = true;
- type.value = "";
- tableForm.name = data.name;
- tableForm.englin = data.englin;
- tableForm.two = data.two;
- };
- //删除
- const eleDialog = () => {
- msgTitle.value = "删除设备维护";
- flag.value = true;
- type.value = "del";
- };
- const delRemove = () => {
- const obj = {
- deviceID: tableForm.deviceID,
- event: 3,
- };
- generalDataReception(obj);
- };
- //删除
- const delRest = () => {
- flag.value = false;
- };
- //编辑-删除
- const btnClick = (row, index, param) => {
- if (param === 2) {
- msgTitle.value = "编辑设备维护";
- flag.value = true;
- type.value = "";
- tableForm.event = 2;
- tableForm.deviceID = index.deviceID;
- tableForm.deviceName = index.deviceName;
- tableForm.deviceType = index.deviceType;
- tableForm.location = index.location;
- tableForm.deviceIP = index.deviceIP;
- tableForm.deviceCode = index.deviceCode;
- tableForm.remarks = index.remarks;
- } else if (param === 3) {
- msgTitle.value = "删除设备维护";
- flag.value = true;
- type.value = "del";
- tableForm.event = 3;
- tableForm.deviceID = index.deviceID;
- tableForm.deviceName = index.deviceName;
- tableForm.deviceType = index.deviceType;
- tableForm.location = index.location;
- tableForm.deviceIP = index.deviceIP;
- tableForm.deviceCode = index.deviceCode;
- tableForm.deviceCode = index.deviceCode;
- } else if (param === 4) {
- }
- };
- const gueryRoles = async () => {
- const { code, returnData } = await Query({
- id: DATACONTENT_ID.allId,
- needPage: ++page.value,
- dataContent: Object.values(dataContent.value),
- });
- conditon.value = returnData.listValues[0].query_col_conditon;
- getQuery();
- };
- //获取表格数据
- const getQuery = async () => {
- try {
- const { code, returnData } = await Query({
- id: DATACONTENT_ID.equipmentNodeId,
- needPage: ++page.value,
- dataContent: Object.values(dataContent.value),
- });
- if (code === "0") {
- if (returnData.listValues.length === 0) {
- page.value--;
- noMore.value = true;
- }
- const titleColumn = returnData.columnSet.find(
- (item) => item.needShow == 1
- );
- if (titleColumn) {
- rowTitle.value = titleColumn.columnName;
- }
- tableData.value.push(...returnData.listValues);
- tableCols.value = [];
- if (conditon.value == null) {
- tableCols.value = returnData.columnSet;
- } else {
- tableCols.value = [];
- conditon.value.split(",").forEach((element) => {
- returnData.columnSet.forEach((res) => {
- if (element === res.columnName) {
- tableCols.value.push(res);
- }
- });
- });
- }
- tableCols.value.forEach((element) => {
- element.label = element.columnLabel;
- element.key = element.columnName;
- // if (element.columnName === "queryTemplate") {
- // element.width = "300px";
- // }
- });
- serviceId.value = returnData.submitID;
- } else {
- page.value--;
- }
- } catch (error) {
- page.value--;
- }
- };
- //确认提交
- const equipmentMaintenanceForm: any = ref(null);
- const submitForm = () => {
- equipmentMaintenanceForm.value.validate((valid: any) => {
- if (valid) {
- generalDataReception(tableForm);
- } else {
- return false;
- }
- });
- };
- const resetTable = () => {
- page.value = 0;
- noMore.value = false;
- tableData.value = [];
- };
- const btnAuthMap = [
- ,
- "equipment_addition_button",
- "device_editing_button",
- "device_deletion_button",
- ];
- //新增-编辑-删除
- const generalDataReception = async (data) => {
- try {
- const { code } = await GeneralDataReception({
- serviceId: serviceId.value,
- dataContent: JSON.stringify(data),
- btnAuth: btnAuthMap[data.event],
- });
- if (code == 0) {
- ElMessage.success(`操作成功`);
- // this.$message.success("操作成功");
- resetTable();
- gueryRoles();
- resetForm();
- flag.value = false;
- // rmFlag.value = false;
- tableObj.value = {};
- // this.$router.go(0);
- } else {
- ElMessage.error(`操作失败`);
- // this.$message.error("操作失败");
- // this.flag = false;
- // this.rmFlag = false;
- tableObj.value = {};
- resetForm();
- }
- } catch (error) {
- flag.value = false;
- // rmFlag.value = false;
- tableObj.value = {};
- resetForm();
- }
- };
- gueryRoles();
- </script>
- <style lang="scss" scoped>
- ::v-deep .el-form-item__label {
- width: 80px;
- }
- </style>
|