Browse Source

设备类型管理修改-更新

lxh 3 months ago
parent
commit
487f35e29b
1 changed files with 229 additions and 226 deletions
  1. 229 226
      src/views/vent/deviceManager/equipManager/component/normalBtnTable.vue

+ 229 - 226
src/views/vent/deviceManager/equipManager/component/normalBtnTable.vue

@@ -14,11 +14,10 @@
               </a-menu-item>
             </a-menu>
           </template>
-          <a-button
-            >批量操作
-            <Icon style="fontsize: 12px" icon="ant-design:down-outlined" />
-          </a-button>
-        </a-dropdown> -->
+<a-button>批量操作
+  <Icon style="fontsize: 12px" icon="ant-design:down-outlined" />
+</a-button>
+</a-dropdown> -->
       </template>
       <template #action="{ record }">
         <a class="table-action-link" @click="handleEdit(record)">编辑</a>
@@ -38,249 +37,253 @@
 </template>
 
 <script lang="ts" name="system-user" setup>
-  //ts语法
-  import { ref, provide, reactive, toRaw, defineExpose } from 'vue';
-  import { BasicTable, TableAction } from '/@/components/Table';
-  import { useModal } from '/@/components/Modal';
-  import DeviceModal from './DeviceModal.vue';
-  import { getTableHeaderColumns } from '/@/hooks/web/useWebColumns';
-  import { useListPage } from '/@/hooks/system/useListPage';
+//ts语法
+import { ref, provide, reactive, toRaw, defineExpose } from 'vue';
+import { BasicTable, TableAction } from '/@/components/Table';
+import { useModal } from '/@/components/Modal';
+import DeviceModal from './DeviceModal.vue';
+import { getTableHeaderColumns } from '/@/hooks/web/useWebColumns';
+import { useListPage } from '/@/hooks/system/useListPage';
 
-  const props = defineProps({
-    columnsType: {
-      type: String,
-      // required: true,
-    },
-    columns: {
-      type: Array,
-      // required: true,
-      default: () => [],
-    },
-    formSchema: {
-      type: Array,
-      required: true,
-    },
-    list: {
-      type: Function,
-      required: true,
-    },
-    deleteById: {
-      type: Function,
-      required: true,
-    },
-    saveOrUpdate: {
-      type: Function,
-      required: true,
-    },
-    showTab: {
-      type: Boolean,
-      default: false,
-    },
-    designScope: {
-      type: String,
-    },
-    title: {
-      type: String,
-    },
-    deviceType: {
-      type: String,
-    },
-  });
-  const emit = defineEmits(['submitSuccess']);
-  const isUpdate = ref(false);
-  //lxh
-  let dictId = ref(null);
-  const record = reactive({});
+const props = defineProps({
+  columnsType: {
+    type: String,
+    // required: true,
+  },
+  columns: {
+    type: Array,
+    // required: true,
+    default: () => [],
+  },
+  formSchema: {
+    type: Array,
+    required: true,
+  },
+  list: {
+    type: Function,
+    required: true,
+  },
+  deleteById: {
+    type: Function,
+    required: true,
+  },
+  saveOrUpdate: {
+    type: Function,
+    required: true,
+  },
+  showTab: {
+    type: Boolean,
+    default: false,
+  },
+  designScope: {
+    type: String,
+  },
+  title: {
+    type: String,
+  },
+  deviceType: {
+    type: String,
+  },
+});
+const emit = defineEmits(['submitSuccess']);
+const isUpdate = ref(false);
+//lxh
+let dictId = ref(null);
+const record = reactive({});
 
-  // const glob = useGlobSetting();
-  const [registerModal, { openModal, closeModal }] = useModal();
+// const glob = useGlobSetting();
+const [registerModal, { openModal, closeModal }] = useModal();
 
-  const columnList = getTableHeaderColumns(props.columnsType);
+const columnList = getTableHeaderColumns(props.columnsType);
 
-  // 列表页面公共参数、方法
-  const { prefixCls, tableContext, onExportXls, onImportXls, doRequest } = useListPage({
-    designScope: props.designScope,
-    tableProps: {
-      title: props.title, //table标题
-      api: props.list, //api请求
-      columns: props.columns.length > 0 ? (props.columns as any[]) : columnList, //列信息
-      showTableSetting: false,
-      // size: 'small',
-      // bordered: false,
-      formConfig: {
-        //表单配置
-        // labelWidth: 100,
-        labelAlign: 'left',
-        labelCol: {
-          xs: 24,
-          sm: 24,
-          md: 24,
-          lg: 9,
-          xl: 7,
-          xxl: 5,
-        },
-        schemas: props.searchFormSchema as any[],
-        showActionButtonGroup: false,
-      },
-      striped: true, //斑马纹
-      showIndexColumn: false, //是否显示序号列
-      actionColumn: {
-        //操作列配置
-        width: 180,
-      },
-      beforeFetch: (params) => {
-        return Object.assign({ column: 'createTime', order: 'desc' }, params);
+// 列表页面公共参数、方法
+const { prefixCls, tableContext, onExportXls, onImportXls, doRequest } = useListPage({
+  designScope: props.designScope,
+  tableProps: {
+    title: props.title, //table标题
+    api: props.list, //api请求
+    columns: props.columns.length > 0 ? (props.columns as any[]) : columnList, //列信息
+    showTableSetting: false,
+    // size: 'small',
+    // bordered: false,
+    formConfig: {
+      //表单配置
+      // labelWidth: 100,
+      labelAlign: 'left',
+      labelCol: {
+        xs: 24,
+        sm: 24,
+        md: 24,
+        lg: 9,
+        xl: 7,
+        xxl: 5,
       },
+      schemas: props.searchFormSchema as any[],
+      showActionButtonGroup: false,
     },
-    exportConfig: {
-      name: props.title,
-      url: props.getExportUrl,
+    striped: true, //斑马纹
+    showIndexColumn: false, //是否显示序号列
+    actionColumn: {
+      //操作列配置
+      width: 180,
     },
-    importConfig: {
-      url: props.getImportUrl,
+    beforeFetch: (params) => {
+      return Object.assign({ column: 'createTime', order: 'desc' }, params);
     },
-  });
+  },
+  exportConfig: {
+    name: props.title,
+    url: props.getExportUrl,
+  },
+  importConfig: {
+    url: props.getImportUrl,
+  },
+});
 
-  //注册table数据
-  const [registerTable, { reload }] = tableContext;
+//注册table数据
+const [registerTable, { reload }] = tableContext;
 
-  const saveOrUpdateHandler = async (params) => {
-    if (!params['description']) params['description'] = '';
-    Object.assign(params, { dictId: dictId.value });
-    try {
-      await props.saveOrUpdate(params, isUpdate.value);
-      !props.showTab ? closeModal() : '';
-      await doRequest(props.list, { confirm: false });
-    } catch (error) {
-      message.error('保存失败,请联系管理员');
-    }
+const saveOrUpdateHandler = async (params) => {
+  if (!params['description']) params['description'] = '';
+  Object.assign(params, { dictId: dictId.value });
+  try {
+    await props.saveOrUpdate(params, isUpdate.value);
+    !props.showTab ? closeModal() : '';
+    await doRequest(props.list, { confirm: false });
     // 清除数据
     dictId.value = null;
-  };
-
-  /**
-   * 新增事件
-   */
-  function handleAdd() {
-    dictId.value = null;
-    for (let key in record) {
-      delete record[key];
-    }
-    isUpdate.value = false;
-    openModal(true, { addParent: true });
-  }
-  /**
-   * 新增下级
-   */
-  function handleAdds(data) {
-    // debugger;
-    console.log(data, '添加下级');
-    dictId.value = data.subDictId;
-    for (let key in record) {
-      delete record[key];
-    }
-    isUpdate.value = false;
-    openModal(true, { addParent: false });
-  }
-  /**
-   * 编辑事件
-   */
-  function handleEdit(data) {
-    isUpdate.value = true;
-    dictId.value = data.dictId;
-    Object.assign(record, toRaw(data));
-    openModal(true, {
-      record,
-    });
+  } catch (error) {
+    message.error('保存失败,请联系管理员');
   }
 
-  /**
-   * 删除事件
-   */
-  async function handleDelete(record) {
-    await props.deleteById({ id: record.id }, reload);
-  }
+};
 
-  /**
-   * 批量删除事件
-   */
-  async function batchHandleDelete() {
-    doRequest(() => props.batchDelete({ ids: selectedRowKeys.value }));
-  }
-  /**
-   * 查看
-   */
-  // function handleDetail(record) {
-  //   iframeUrl.value = `${glob.uploadUrl}/sys/annountCement/show/${record.id}?token=${getToken()}`;
-  //   openDetail(true);
-  // }
-  /**
-   * 操作列定义
-   * @param record
-   */
-  function getActions(record) {
-    return [
-      {
-        label: '编辑',
-        onClick: handleEdit.bind(null, record),
-      },
-      {
-        label: '新增下级',
-        onClick: handleAdds.bind(null, record),
-      },
-      {
-        label: '删除',
-        popConfirm: {
-          title: '是否确认删除',
-          confirm: handleDelete.bind(null, record.id),
-        },
-      },
-      // {
-      //   label: '查看',
-      //   onClick: handleDetail.bind(null, record),
-      // },
-    ];
+/**
+ * 新增事件
+ */
+function handleAdd() {
+  dictId.value = null;
+  for (let key in record) {
+    delete record[key];
   }
-  /**
-   * 下拉操作栏
-   */
-  function getDropDownAction(record) {
-    return [
-      // {
-      //   label: '删除',
-      //   popConfirm: {
-      //     title: '是否确认删除',
-      //     confirm: handleDelete.bind(null, record),
-      //   },
-      // },
-      // {
-      //   label: '查看',
-      //   onClick: handleDetail.bind(null, record),
-      // },
-    ];
+  isUpdate.value = false;
+  openModal(true, { addParent: true });
+}
+/**
+ * 新增下级
+ */
+function handleAdds(data) {
+  // debugger;
+  console.log(data, '添加下级');
+  dictId.value = data.subDictId;
+  for (let key in record) {
+    delete record[key];
   }
-  defineExpose({
-    doRequest,
+  isUpdate.value = false;
+  openModal(true, { addParent: false });
+}
+/**
+ * 编辑事件
+ */
+function handleEdit(data) {
+  isUpdate.value = true;
+  dictId.value = data.dictId;
+  Object.assign(record, toRaw(data));
+  openModal(true, {
+    record,
   });
+}
+
+/**
+ * 删除事件
+ */
+async function handleDelete(record) {
+  await props.deleteById({ id: record.id }, reload);
+}
+
+/**
+ * 批量删除事件
+ */
+async function batchHandleDelete() {
+  doRequest(() => props.batchDelete({ ids: selectedRowKeys.value }));
+}
+/**
+ * 查看
+ */
+// function handleDetail(record) {
+//   iframeUrl.value = `${glob.uploadUrl}/sys/annountCement/show/${record.id}?token=${getToken()}`;
+//   openDetail(true);
+// }
+/**
+ * 操作列定义
+ * @param record
+ */
+function getActions(record) {
+  return [
+    {
+      label: '编辑',
+      onClick: handleEdit.bind(null, record),
+    },
+    {
+      label: '新增下级',
+      onClick: handleAdds.bind(null, record),
+    },
+    {
+      label: '删除',
+      popConfirm: {
+        title: '是否确认删除',
+        confirm: handleDelete.bind(null, record.id),
+      },
+    },
+    // {
+    //   label: '查看',
+    //   onClick: handleDetail.bind(null, record),
+    // },
+  ];
+}
+/**
+ * 下拉操作栏
+ */
+function getDropDownAction(record) {
+  return [
+    // {
+    //   label: '删除',
+    //   popConfirm: {
+    //     title: '是否确认删除',
+    //     confirm: handleDelete.bind(null, record),
+    //   },
+    // },
+    // {
+    //   label: '查看',
+    //   onClick: handleDetail.bind(null, record),
+    // },
+  ];
+}
+defineExpose({
+  doRequest,
+});
 </script>
 
 <style scoped lang="less">
-  @ventSpace: zxm;
+@ventSpace: zxm;
 
-  @vent-table-no-hover: #00bfff10;
-  :deep(.@{ventSpace}-table-cell-row-hover) {
-    background: #264d8833 !important;
-  }
-  :deep(.@{ventSpace}-table-row-selected) {
-    background: #268bc522 !important;
-  }
+@vent-table-no-hover: #00bfff10;
 
-  :deep(.@{ventSpace}-table-tbody > tr > td) {
-    background-color: #0dc3ff05;
-  }
-  :deep(.jeecg-basic-table-row__striped) {
-    td {
-      background-color: @vent-table-no-hover !important;
-    }
+:deep(.@{ventSpace}-table-cell-row-hover) {
+  background: #264d8833 !important;
+}
+
+:deep(.@{ventSpace}-table-row-selected) {
+  background: #268bc522 !important;
+}
+
+:deep(.@{ventSpace}-table-tbody > tr > td) {
+  background-color: #0dc3ff05;
+}
+
+:deep(.jeecg-basic-table-row__striped) {
+  td {
+    background-color: @vent-table-no-hover !important;
   }
+}
 </style>