马宇豪
2023-09-06 e5b31f6979672ab876a82ae344d500bc9e0ad533
src/views/index.vue
@@ -1,87 +1,327 @@
<template>
  <div class="app-container home">
    <el-row :gutter="20">
      666
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="专业类别">
        <el-cascader
          v-model="classiFy"
          :options="expertTypes"
          :props="{ expandTrigger: 'hover', value: 'id',label: 'label'}"
          @change="handleChange"></el-cascader>
      </el-form-item>
      <el-form-item label="在岗情况" prop="dutyStatus">
        <el-select v-model="queryParams.dutyStatus" placeholder="岗位状态" clearable>
          <el-option
            v-for="dict in dict.type.expert_dudy_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="时间范围" prop="searchTime">
        <el-date-picker
          v-model="searchTime"
          @change="changeTime"
          type="daterange"
          range-separator="至"
          value-format="yyyy-MM-dd"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:experts:add']"
        >新增</el-button>
      </el-col>
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="warning"-->
<!--          plain-->
<!--          icon="el-icon-download"-->
<!--          size="mini"-->
<!--          @click="handleExport"-->
<!--          v-hasPermi="['system:experts:export']"-->
<!--        >导出</el-button>-->
<!--      </el-col>-->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="expertList">
      <el-table-column type="index" width="55" align="center" />
      <el-table-column label="姓名" align="center" prop="name" />
      <el-table-column label="出生日期" align="center" prop="birthday" />
      <el-table-column label="学历" align="center" prop="degree" />
      <el-table-column label="职称/职业资格/职务" align="center" prop="job" />
      <el-table-column label="专业" align="center" prop="speciality" />
      <el-table-column label="推荐类别组别" align="center">
        <template #default="scope">
          {{findNodeById(expertTypes,scope.row.bigClassify)}}/{{findNodeById(expertTypes,scope.row.smallClassify)}}
        </template>
      </el-table-column>
      <el-table-column label="联系电话" align="center" prop="phone"/>
      <el-table-column label="申请时间" align="center" prop="createTime">
        <template #default="scope">
          {{scope.row.createTime.substring(0,10)}}
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleUpdate(scope.row)"
          >查看</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:experts:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageIndex"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <form-dialog ref="formDialog"></form-dialog>
    <el-dialog title="新增信息" :visible.sync="addForm" width="75%" append-to-body>
      <form-fill ref="formFill"></form-fill>
    </el-dialog>
  </div>
</template>
<script>
import {getExpertsList, getExpertTypes, delExpert, getInfo} from "@/api/system/form";
import formDialog from './components/formDialog'
import formFill from './form'
export default {
  name: "Index",
  name: "Experts",
  dicts: ['expert_dudy_status'],
  components: {formDialog,formFill},
  data() {
    return {
      // 版本号
      version: "3.8.6"
      loading: true,
      single: true,
      multiple: true,
      showSearch: true,
      addForm: false,
      total: 0,
      expertTypes: [],
      expertList: [],
      queryParams: {
        pageIndex: 1,
        pageSize: 10,
        bigClassify: null,
        smallClassify: null,
        dutyStatus: null,
        startTime: '',
        endTime: ''
      },
      classiFy: [],
      searchTime: [],
      form: {},
      rules: {
        classifyName: [
          { required: true, message: "分类名称不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    this.getList();
    this.getTypes()
  },
  methods: {
    async getList() {
      this.loading = true;
      const res = await getExpertsList(this.queryParams)
      if(res.code == 200){
        this.expertList = res.rows
        this.total = res.total
      }else{
        this.$message({
          type: 'warning',
          message: res.msg
        });
      }
      this.loading = false;
    },
    async getTypes() {
      const res = await getExpertTypes()
      if(res.code == 200){
        this.expertTypes = res.data
      }else{
        this.$message({
          type: 'warning',
          message: res.msg
        });
      }
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    handleChange(value) {
      console.log(value);
    },
    changeTime(value){
      console.log(value);
    },
    // 根据id查对象
    findNodeById(data,value) {
      for (const node of data) {
        if (node.id === value) {
          return node.label;
        }
        if (node.children) {
          const foundNode = this.findNodeById(node.children, value);
          if (foundNode) {
            return foundNode;
          }
        }
      }
      return null;
    },
    handleQuery() {
      this.queryParams.pageIndex = 1
      if(this.classiFy.length>0){
        this.queryParams.bigClassify = this.classiFy[0]
        this.queryParams.smallClassify = this.classiFy[1]
      }
      if(this.searchTime.length>0){
        this.queryParams.startTime = this.searchTime[0]
        this.queryParams.endTime = this.searchTime[1]
      }
      this.getList();
    },
    resetQuery() {
      const t = this
      t.resetForm("queryForm");
      t.classiFy = []
      t.searchTime = []
      t.handleQuery();
    },
    // 表单重置
    reset() {
      this.queryParams = {
        parentId: 0,
        classifyId: null,
        classifyName: ''
      };
      this.resetForm("form");
    },
    handleExport() {
      this.download('system/experts/export', {
        ...this.queryParams
      }, `post_${new Date().getTime()}.xlsx`)
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.addForm = true
      setTimeout(()=>{
        this.$refs.formFill.changeSource(2)
      },1000)
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      getInfo(row.expertId).then((res)=>{
        if(res.code == 200){
          this.$refs.formDialog.openDialog(res.data)
        }else{
          this.$message({
            type: 'warning',
            message: res.msg
          });
        }
      })
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.title == '修改分类') {
            updateType(this.form).then(res => {
              if(res.code == 200){
                this.$message({
                  type: 'success',
                  message: '修改成功'
                });
                this.open = false;
                this.getList();
              }else{
                this.$message({
                  type: 'warning',
                  message: res.msg
                });
              }
            });
          } else {
            const {classifyId,...data} = this.form
            addType(data).then(res => {
              if(res.code == 200){
                this.$message({
                  type: 'success',
                  message: '添加成功'
                });
                this.open = false;
                this.getList();
              }else{
                this.$message({
                  type: 'warning',
                  message: res.msg
                });
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      console.log(row,'row')
      this.$modal.confirm('是否确认删除姓名为"' + row.name + '"的数据项?').then(function() {
        return delExpert(row.expertId);
      }).then((res) => {
        if(res.code == 200){
          this.getList();
          this.$message({
            type: 'success',
            message: '删除成功'
          });
        }else{
          this.$message({
            type: 'warning',
            message: res.msg
          });
        }
      }).catch(() => {});
    }
  }
};
</script>
<style scoped lang="scss">
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }
  ul {
    padding: 0;
    margin: 0;
  }
  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;
  ul {
    list-style-type: none;
  }
  h4 {
    margin-top: 0px;
  }
  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }
  p {
    margin-top: 10px;
    b {
      font-weight: 700;
    }
  }
  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
</style>