shj
2022-07-25 c21f3d6df8746ec55ab9e7a64e4e130577c49fea
src/views/contingencyManagement/contingency/index.vue
@@ -4,10 +4,10 @@
      <div class="system-user-search mb15">
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
          <el-form-item>
            <el-input size="default" v-model="formInline.name" placeholder="队伍名称"> </el-input>
            <el-input size="default" v-model="formInline.searchParams.teamName" placeholder="队伍名称"> </el-input>
          </el-form-item>
          <el-form-item>
            <el-select size="default" v-model="formInline.level" placeholder="请选择队伍级别">
            <el-select size="default" v-model="formInline.searchParams.teamType" placeholder="请选择队伍级别">
              <el-option label="公司" value="shanghai"></el-option>
              <el-option label="分厂-车间" value="beijing"></el-option>
              <el-option label="工序-班组等" value="beijing"></el-option>
@@ -17,7 +17,7 @@
             <el-button size="default" type="primary" class="ml10" @click="onSubmit">
               查询
             </el-button>
             <el-button size="default" class="ml10" @click="submitReset">
             <el-button size="default" class="ml10">
               重置
             </el-button>
          </el-form-item>
@@ -25,7 +25,7 @@
      </div>
      <div class="button_Line">
        <div class="button_Left">
          <el-button size="default" type="primary"  @click="onOpenAdd('新建')">
          <el-button size="default" type="primary"  @click="onOpenAdd('新建','')">
            <el-icon>
              <Plus />
            </el-icon>新建
@@ -42,17 +42,17 @@
          </el-button>
        </div>
        <div class="button_Right">
          <el-button @click="upButton">
          <el-button size="default" @click="upButton">
            <el-icon>
              <Upload />
            </el-icon>
          </el-button>
          <el-button>
          <el-button size="default">
            <el-icon>
              <Download />
            </el-icon>
          </el-button>
          <el-button>
          <el-button size="default">
            <el-icon>
              <Refresh />
            </el-icon>
@@ -60,7 +60,7 @@
        </div>
      </div>
      <el-table
          :data="tableData"
          :data="tableData.data"
          style="width: 100%"
          ref="multipleTableRef"
      >
@@ -68,19 +68,19 @@
            type="selection"
            width="55"
        />
        <el-table-column prop="teamName" label="队伍名称" show-overflow-tooltip></el-table-column>
        <el-table-column prop="teamLevel" label="队伍级别" show-overflow-tooltip></el-table-column>
        <el-table-column prop="teamDescription" label="队伍描述" show-overflow-tooltip></el-table-column>
        <el-table-column prop="teamPhone" label="负责人手机" show-overflow-tooltip></el-table-column>
        <el-table-column prop="attachments" label="相关附件" show-overflow-tooltip></el-table-column>
        <el-table-column label="操作" width="200" align="center">
        <el-table-column prop="teamName" label="队伍名称" show-overflow-tooltip sortable></el-table-column>
        <el-table-column prop="teamLevel" label="队伍级别" show-overflow-tooltip sortable></el-table-column>
        <el-table-column prop="teamDesc" label="队伍描述" show-overflow-tooltip sortable></el-table-column>
        <el-table-column prop="principalPhone" label="负责人手机" show-overflow-tooltip sortable></el-table-column>
        <el-table-column prop="attachments" label="相关附件" show-overflow-tooltip sortable></el-table-column>
        <el-table-column label="操作" width="200" align="center" fixed="right">
          <template #default="scope">
            <el-button :disabled="scope.row.userName === 'admin'" size="small" text type="primary" @click="onOpenSee(scope.row)">
            <el-button size="small" text type="primary" @click="onOpenAdd('查看',scope.row)">
              <el-icon style="margin-right: 5px;">
                <View />
              </el-icon>查看
            </el-button>
            <el-button :disabled="scope.row.userName === 'admin'" size="small" text type="primary" @click="onOpenEdit(scope.row)">
            <el-button size="small" text type="primary" @click="onOpenAdd('修改',scope.row)">
              <el-icon style="margin-right: 5px;">
                <EditPen />
              </el-icon>修改
@@ -95,31 +95,31 @@
      </el-table>
      <div class="pages">
        <el-pagination
            v-model:currentPage="currentPage"
            v-model:page-size="pageSize"
            :page-sizes="[10,20,50,100]"
            :small="small"
            :disabled="disabled"
            :background="background"
            @size-change="onHandleSizeChange"
            @current-change="onHandleCurrentChange"
            class="mt15"
            :pager-count="5"
            :page-sizes="[10, 20, 30]"
            v-model:current-page="formInline.pageIndex"
            background
            v-model:page-size="formInline.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="400"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
        />
            :total="tableData.total"
        >
        </el-pagination>
      </div>
    </el-card>
    <OpenSee ref="seeRef" />
    <OpenAdd ref="addRef" />
    <OpenEdit ref="editRef" />
    <OpenAdd ref="addRef"  @refreshRoleList="initTableData"/>
    <OpenSee ref="seeRef" @refreshRoleList="initTableData"/>
    <upData ref="upShow"></upData>
  </div>
</template>
<script lang="ts">
import {
  // toRefs,
  toRefs,
  reactive,
  // onMounted,
  onMounted,
  ref,
  defineComponent
} from 'vue';
@@ -138,16 +138,17 @@
  EditPen,
} from '@element-plus/icons-vue'
import OpenAdd from '/@/views/contingencyManagement/contingency/component/openAdd.vue';
import OpenEdit from '/@/views/contingencyManagement/contingency/component/openEdit.vue';
import OpenSee from '/@/views/contingencyManagement/contingency/component/openSee.vue';
import UpData from '/@/views/contingencyManagement/contingency/component/upData.vue';
import {contingencyApi} from "/@/api/contingency";
// 定义表格数据类型
interface User {
  teamName: string
  teamLevel: string
  teamDescription: string
  teamPhone: string
  teamDesc: string
  principalPhone: string
  telephone: string;
  describe: string;
  responsibleDepartment: string
@@ -157,25 +158,22 @@
// 定义接口来定义对象的类型
interface TableDataRow {
  // userName: string;
  // userNickname: string;
  // roleSign: string;
  // department: string[];
  // phone: string;
  // email: string;
  // sex: string;
  // password: string;
  // overdueTime: Date;
  // // describe: string;
  // createTime: string;
}
//
interface TableDataState {
  tableData: {
    data: Array<TableDataRow>;
    total: number;
    loading: boolean;
  };
}
export default defineComponent({
  name: 'systemUser',
  components: {
    OpenAdd,
    OpenSee,
    OpenEdit,
    View,
    EditPen,
    Plus,
@@ -184,20 +182,33 @@
    Upload,
    Download,
    Refresh,
    UpData
    UpData,
    contingencyApi
  },
  setup() {
    // 定义表单搜索
    const formInline = reactive({
      name: '',
      level: '',
      pageIndex: 1,
      pageSize: 10,
      searchParams: {
      teamName: "",
      teamType: "",
    }
    })
    // 搜索按钮
    const onSubmit = () => {
      console.log('submit!')
    const onSubmit = async () => {
      let res = await contingencyApi().getTeamManagementList(formInline)
      if(res.data.code === '200'){
        state.tableData.data = res.data.data;
        state.tableData.total = state.tableData.data.length;
      }else{
        ElMessage({
          type:'warning',
          message:res.data.msg
        })
      }
    }
    const seeRef = ref();
    const editRef = ref();
    const multipleTableRef = ref<InstanceType<typeof ElTable>>()
    const multipleSelection = ref<User[]>([])
@@ -207,102 +218,72 @@
      upShow.value.openDialog()
    }
    // 定义表格数据
    const tableData: User[] = [
      {
        teamName: '应急救援组',
        teamLevel: '公司',
        teamDescription: '实施抢险抢险的应急方案和措施实施 ;',
        telephone: '051383830321',
        teamPhone: '13603812900',
        describe: '(1)实施抢险抢险的应急方案和措施实施 ;\n' +
            '(2)负责现场被困人员、受伤人员抢救工作;\n' +
            '(3)在事故有可能扩大进行抢险抢修或救援时,高度注意避免意外伤害;\n' +
            '(4)抢险抢修或救援结束后,对结果进行复查和评估。',
        responsibleDepartment: '仪表班',
        teamLeader: '王磊',
    const state = reactive<TableDataState>({
      tableData: {
        data: [],
        total: 0,
        loading: false,
      },
      {
        teamName: '应急救援组',
        teamLevel: '公司',
        teamDescription: '实施抢险抢险的应急方案和措施实施 ;',
        telephone: '051383830321',
        teamPhone: '13603812900',
        describe: '(1)实施抢险抢险的应急方案和措施实施 ;\n' +
            '(2)负责现场被困人员、受伤人员抢救工作;\n' +
            '(3)在事故有可能扩大进行抢险抢修或救援时,高度注意避免意外伤害;\n' +
            '(4)抢险抢修或救援结束后,对结果进行复查和评估。',
        responsibleDepartment: '仪表班',
        teamLeader: '王磊',
      },
      {
        teamName: '应急救援组',
        teamLevel: '公司',
        teamDescription: '实施抢险抢险的应急方案和措施实施 ;',
        telephone: '051383830321',
        teamPhone: '13603812900',
        describe: '(1)实施抢险抢险的应急方案和措施实施 ;\n' +
            '(2)负责现场被困人员、受伤人员抢救工作;\n' +
            '(3)在事故有可能扩大进行抢险抢修或救援时,高度注意避免意外伤害;\n' +
            '(4)抢险抢修或救援结束后,对结果进行复查和评估。',
        responsibleDepartment: '仪表班',
        teamLeader: '王磊',
      },
      {
        teamName: '应急救援组',
        teamLevel: '公司',
        teamDescription: '实施抢险抢险的应急方案和措施实施 ;',
        telephone: '051383830321',
        teamPhone: '13603812900',
        describe: '(1)实施抢险抢险的应急方案和措施实施 ;\n' +
            '(2)负责现场被困人员、受伤人员抢救工作;\n' +
            '(3)在事故有可能扩大进行抢险抢修或救援时,高度注意避免意外伤害;\n' +
            '(4)抢险抢修或救援结束后,对结果进行复查和评估。',
        responsibleDepartment: '仪表班',
        teamLeader: '王磊',
    })
    // 初始化表格数据
    const initTableData = async () => {
      let res = await contingencyApi().getTeamManagementList(formInline)
      if(res.data.code === '200'){
        state.tableData.data = res.data.data;
        state.tableData.total = state.tableData.data.length;
      }else{
        ElMessage({
          type:'warning',
          message:res.data.msg
        })
      }
    ]
    };
    //查看用户弹窗
    const onOpenSee = (row: TableDataRow) => {
      seeRef.value.openDialog(row);
    const seeRef = ref();
    const onOpenSee = (type: string, value: any) => {
      seeRef.value.openDialog(type, value);
    };
    // 打开新增用户弹窗
    // 打开新增应急队伍弹窗
    const addRef = ref();
    const onOpenAdd = () => {
      addRef.value.openDialog();
    };
    // 打开修改用户弹窗
    const onOpenEdit = (row: TableDataRow) => {
      editRef.value.openDialog(row);
    const onOpenAdd = (type: string, value: any) => {
      addRef.value.openDialog(type, value);
    };
    // 删除用户
    const onRowDel = (row: TableDataRow) => {
      ElMessageBox.confirm(`此操作将永久删除账户名称:“${row}”,是否继续?`, '提示', {
    const onRowDel = (row: any) => {
      ElMessageBox.confirm(`此操作将永久删除队伍名称:“${row}”,是否继续?`, '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning',
      })
          .then(() => {
            ElMessage.success('删除成功');
          .then(async () => {
            let res = await contingencyApi().deleteEmergencyTeam({principalUid:row.principalUid})
            if(res.data.code ==='200'){
              ElMessage({
                type:'success',
                duration:2000,
                message:'删除成功'
              })
              await initTableData()
            }else{
              ElMessage({
                type:'warning',
                message:res.data.msg
              })
            }
          })
          .catch(() => {});
    };
    // 分页改变
    const currentPage = ref(4);
    const pageSize = ref(10);
    const handleSizeChange = (val: number) => {
      console.log(`${val} items per page`);
    const onHandleSizeChange = (val: number) => {
      formInline.pageSize = val;
    };
    const handleCurrentChange = (val: number) => {
      console.log(`current page: ${val}`);
    const onHandleCurrentChange = (val: number) => {
      formInline.pageIndex = val;
    };
    // const onHandleSizeChange = (val: number) => {
    //   state.tableData.param.pageSize = val;
    // };
    // // 分页改变
    // 页面加载时
    // onMounted(() => {
    //   initTableData();
    // });
    onMounted(() => {
      initTableData();
    });
    return {
      // value,
      // options,
@@ -312,19 +293,16 @@
      multipleTableRef,
      upButton,
      upShow,
      tableData,
      // tableData,
      initTableData,
      onOpenSee, //查看
      seeRef,
      onOpenEdit,  //编辑
      editRef,
      onOpenAdd,  //新增
      addRef,
      onRowDel,
      currentPage,
      pageSize,
      handleSizeChange,
      handleCurrentChange,
      // ...toRefs(state),
      onHandleSizeChange,
      onHandleCurrentChange,
      ...toRefs(state),
    };
  },
});
@@ -342,13 +320,35 @@
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    margin-bottom: 10px;
  }
  .pages{
    padding-top: 20px;
    display: flex;
    justify-content: flex-end;
  }
.el-form .el-form-item:last-of-type{
  margin-bottom: 22px!important;
//分页
.pages{
  display: flex;
  justify-content: flex-end;
  margin-top: 15px;
}
.el-form .el-form-item{
  margin-bottom: 0px!important;
}
//弹窗底部边框线
::v-deep .el-dialog__footer{
  border-top: 1px solid #e8e8e8;
  border-radius: 0 0 4px 4px;
}
//弹窗顶部边框线
::v-deep .el-dialog__header {
  border-bottom: 1px solid #e8e8e8;
  margin-right: 0;
  border-radius: 4px 4px 0 0;
}
//表头
::v-deep .el-table th.el-table__cell {
  background-color: #f6f7fa;
  font-weight: 400;
  color: #909399;
}
.el-table .sort-caret.ascending{
  border-bottom-color: #c0c4cc;
}
</style>