pengwei
2025-03-24 f90fbbc76d23340e4568dd4dadbab5f7f02a030f
ÏîÄ¿´úÂë/client/src/views/tts/TaskManagement/Taskmanagement.vue
@@ -25,13 +25,13 @@
            size="small"
          />
        </div>
        <!-- <div class="serch_box">
        <div class="serch_box">
          <div class="serchb">
            <el-select
              v-model="queryForm.selectType"
              placeholder="请选择"
              size="small"
              style="width: 100%; height: 100%; font-size: 0.15rem"
              style="width: 8rem; height: 2rem; font-size: 0.15rem"
            >
              <el-option
                v-for="item in selectoptions"
@@ -46,7 +46,7 @@
            placeholder="请输入关键词搜索"
            style="border-left: 0.06rem solid #e2e2e2"
          />
        </div> -->
        </div>
        <el-button
          type="primary"
          size="small"
@@ -63,7 +63,7 @@
          <el-button
            type="primary"
            size="small"
            @click="dialogVisible1 = true"
            @click="addData"
            style="
              width: 5.5rem;
              height: 2rem;
@@ -71,7 +71,7 @@
              display: flex;
              align-items: center;
            "
            ><el-icon style="margin-right: 0.2rem"><Plus /></el-icon
            ><el-icon style="margin-right: 0.2rem"> <Plus /> </el-icon
            >新建</el-button
          >
          <el-button
@@ -85,7 +85,7 @@
              display: flex;
              align-items: center;
            "
            ><el-icon style="margin-right: 0.2rem"><Plus /></el-icon
            ><el-icon style="margin-right: 0.2rem"> <Plus /> </el-icon
            >手动获取</el-button
          >
          <el-button
@@ -122,6 +122,7 @@
      </div>
      <div style="margin-top: 1rem; height: 100%">
        <el-table
          empty-text="暂无数据"
          :data="tableData"
          height="500"
          style="width: 100%"
@@ -212,7 +213,9 @@
                @click="Send(scope.row)"
                >派任务</el-button
              >
              <!-- <el-button size="small" type="text" @click="delt">编辑</el-button> -->
              <el-button size="small" type="text" @click="Editdata(scope.row)"
                >编辑</el-button
              >
            </template>
          </el-table-column>
        </el-table>
@@ -238,12 +241,12 @@
        />
      </div>
    </div>
    <!-- ä»»åŠ¡ä¿¡æ¯å¼¹å‡ºæ¡† -->
    <!-- æ–°å»º/编辑任务信息弹出框 -->
    <el-dialog
      v-model="dialogVisible1"
      title=""
      width="60%"
      @close="handleClose(ruleFormRef)"
      @close="resetForm(ruleFormRef)"
      style="margin-top: 15.625rem"
    >
      <template #title>
@@ -268,6 +271,26 @@
        ref="ruleFormRef"
        :hide-required-asterisk="true"
      >
        <el-row>
          <el-col :span="24">
            <el-form-item prop="takeName">
              <template #label>
                <div style="display: flex; align-items: flex-end">
                  <span style="color: red; margin-right: 0.2rem">*</span>
                  <span
                    style="font-size: 0.88rem; color: black; font-weight: bold"
                    >任务名称</span
                  >
                </div>
              </template>
              <el-input
                size="small"
                v-model="form.takeName"
                placeholder="请输入"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item prop="trainKind">
@@ -406,7 +429,7 @@
      v-model="SenddialogVisible"
      title=""
      width="60%"
      @close="handleClose(sendformRef)"
      @close="resetForm(sendformRef)"
      top="2%"
    >
      <template #title>
@@ -865,13 +888,13 @@
        </div>
      </template>
    </el-dialog> -->
    <!-- æ¡†æž¶æ‰¹é‡å¯¼å…¥å¼¹å‡ºæ¡† -->
    <el-dialog v-model="importDialogVisible">
      <UploadExcel
        @importExcelAfter="importExcelAfter"
        url="/api/NjTask/Import"
        url="api/NjTask/Import"
        :template="{
          url: '/api/NjTask/DownLoadTemplate',
          url: 'api/NjTask/DownLoadTemplate',
          fileName: '任务模板',
        }"
      />
@@ -879,7 +902,7 @@
  </div>
</template>
<script setup>
import { ref, reactive, onMounted } from "vue";
import { ref, reactive, onMounted, toRef } from "vue";
import { useRouter } from "vue-router";
import {
  GetPageData,
@@ -890,25 +913,26 @@
  GetTemplateList,
  Delete,
  ExportApi,
  Update,
} from "@/api/newapi/NjTask";
import { GetUerType } from "@/api/user";
import { formatTime } from "@/utils/index.js";
import { ElMessage } from "element-plus";
import UploadExcel from "@/components/basic/UploadExcel.vue";
//使用路由
const router = useRouter();
// åˆå§‹åŒ–数据
const obj = {
  selectName: "",
  selectTime: [], // æ—¶é—´èŒƒå›´
  selectType: "",
  selectInput: "",
  selectType: "", //选择的类型
  selectInput: "", //输入的数据
};
const queryForm = ref({
  selectName: "",
  selectTime: [], // æ—¶é—´èŒƒå›´
  selectType: "",
  selectInput: "",
});
//搜索传的数据
const queryForm = toRef({ ...obj });
//页面的数量
const pageTotal = ref(0);
//表单的数据
const tableData = ref([]);
const UerTypeoptions = ref({
  quality: [], //质检
@@ -916,7 +940,10 @@
  mechanical: [], //机械
  trench: [], //地沟
});
//表单验证规则
const rules = reactive({
  takeName: [{ required: true, message: "请输入任务名称", trigger: "blur" }],
  bogie: [{ required: true, message: "请输入转向架", trigger: "blur" }],
  coachNum: [{ required: true, message: "请输入车厢号", trigger: "blur" }],
  processDept: [{ required: true, message: "请输入检修班组", trigger: "blur" }],
@@ -924,56 +951,100 @@
  trainKind: [{ required: true, message: "请输入车型", trigger: "blur" }],
  trainNum: [{ required: true, message: "请输入车组号", trigger: "blur" }],
});
//新建编辑表单ref值
const ruleFormRef = ref();
const options = ref([]);
const props = { multiple: true };
const table = ref(false);
const selectoptions = reactive([
  { label: "车型", value: "trainkind" },
  { label: "车组", value: "trainNum" },
  { label: "股道", value: "track" },
  { label: "检修班组", value: "processkept" },
]);
//添加/编辑的表单数据
const form = ref({
  takeName: "", //任务名称
  bogie: "", //转向架
  coachNum: "", //车厢
  processDept: "", //检修班组
  track: "", //股道
  trainKind: "", //车型
  trainNum: "", //车组号
  createTime: formatTime(new Date()), //创建时间
  createDate: formatTime(new Date()), //创建时间
  creater: JSON.parse(localStorage.getItem("user")).userName, //创建人
});
//删除
const dialogVisible1 = ref(false);
//派任务
const SenddialogVisible = ref(false);
//派任务表单ref值
const sendformRef = ref();
//批量导入
const dialogVisible = ref(false);
//批量导入数据
const gridtableData = ref([]);
//模板列表
const temopitions = ref([]);
const props = { multiple: true };
const table = ref(false);
const type = ref("新建");
//搜索选择的字段
const selectoptions = reactive([
  { label: "车型", value: "trainkind" },
  { label: "车组", value: "trainNum" },
  { label: "股道", value: "track" },
  { label: "检修班组", value: "processkept" },
]);
//提交的数据变量
const sendform = ref({});
//批量导入
const importDialogVisible = ref(false);
//监听文件上传成功的回调
const importExcelAfter = () => {
  importDialogVisible.value = false;
  initData();
};
//新建任务信息
const AddNJinfomclick = async (formEl) => {
  if (!formEl) return;
  await formEl.validate((valid, fields) => {
    if (valid) {
      AddNJinfom(form.value).then((res) => {
        if (res.code == 0) {
          ElMessage({
            message: "创建成功",
            type: "success",
          });
          dialogVisible1.value = false;
        }
      });
      if (type.value == "新建") {
        AddNJinfom(form.value).then((res) => {
          if (res.code == 0) {
            ElMessage({
              message: "创建成功",
              type: "success",
            });
            dialogVisible1.value = false;
            initData();
          }
        });
      } else {
        //编辑
        Update(form.value).then((res) => {
          if (res.code == 0) {
            ElMessage({
              message: "修改成功",
              type: "success",
            });
            dialogVisible1.value = false;
            initData();
          }
        });
      }
    } else {
      console.log("error submit!", fields);
    }
  });
};
//删除
const dialogVisible1 = ref(false);
//派任务
const SenddialogVisible = ref(false);
const sendformRef = ref();
//新建任务信息
const addData = () => {
  type.value = "新建";
  dialogVisible1.value = true;
};
//编辑任务信息
const Editdata = (row) => {
  let obj = Object.assign({}, row);
  type.value = "编辑";
  dialogVisible1.value = true;
  form.value = obj;
};
//提交
const sublit = async (formEl) => {
  let data = {
@@ -1000,6 +1071,7 @@
          type: "success",
        });
        SenddialogVisible.value = false;
        initData();
      });
    } else {
      console.log("error submit!", fields);
@@ -1032,6 +1104,7 @@
          message: res.message,
          type: "success",
        });
        initData();
        SenddialogVisible.value = false;
      });
    } else {
@@ -1039,16 +1112,16 @@
    }
  });
};
//批量导入
const dialogVisible = ref(false);
//数据导出的方法
const printExcel = () => {
  // æŸ¥è¯¢æ¡ä»¶
  const startTime = formatTime(queryForm.selectTime[0]);
  const endTime = formatTime(queryForm.selectTime[1]);
  const startTime = formatTime(queryForm.value.selectTime[0]);
  const endTime = formatTime(queryForm.value.selectTime[1]);
  const filter = [
    {
      name: queryForm.selectType,
      value: queryForm.selectInput,
      name: queryForm.value.selectType,
      value: queryForm.value.selectInput,
      displayType: "String",
    },
@@ -1060,49 +1133,40 @@
    filter,
  });
};
//批量导入数据
const gridtableData = ref([]);
// quality: [], //质检
// electric: [], //电气
// mechanical: [], //机械
// trench: [], //地沟
//派任务方法
const Send = (val) => {
  SenddialogVisible.value = true;
  sendform.value = { ...val };
  getTemplateList();
  GetUerType().then((res) => {
    UerTypeoptions.value.quality = res.data.filter(
      (item) => item.roleId != 1 && item.roleId == 2
    );
    UerTypeoptions.value.quality = res.data.filter((item) => {
      return item.user_Id != 1 && item.roleName.substring(2, 4) == "质检";
    });
    UerTypeoptions.value.electric = res.data.filter(
      (item) => item.roleId != 1 && item.roleId == 3
      (item) =>
        item.user_Id != 1 &&
        item.roleName.substring(2, 4) != "质检" &&
        item.roleName.substring(0, 2) == "电气"
    );
    UerTypeoptions.value.mechanical = res.data.filter(
      (item) => item.roleId != 1 && item.roleId == 4
      (item) =>
        item.user_Id != 1 &&
        item.roleName.substring(2, 4) != "质检" &&
        item.roleName.substring(0, 2) == "机械"
    );
    UerTypeoptions.value.trench = res.data.filter(
      (item) => item.roleId != 1 && item.roleId == 5
      (item) =>
        item.user_Id != 1 &&
        item.roleName.substring(2, 4) != "质检" &&
        item.roleName.substring(0, 2) == "地沟"
    );
  });
  console.log(UerTypeoptions.value);
};
//删除方法
const delt = () => {
  dialogVisible1.value = true;
};
//批量删除
const ids = ref([]);
const SelectionChange = (val) => {
  ids.value = [];
  ids.value = val.map((item) => item.id);
};
const deleteAll = () => {
  if (ids.value.length == 0) {
    ElMessage({ message: "请选择要删除的数据", type: "error" });
    return;
  }
  Delete(ids.value).then((res) => {
    ElMessage({ message: "删除成功", type: "success" });
    initData();
  });
};
const temopitions = ref([]);
//获取所有模板
const getTemplateList = () => {
  GetTemplateList({
@@ -1132,13 +1196,31 @@
    sendform.value = { ...sendform.value, ...res.data[0] };
  });
};
//批量删除
const ids = ref([]); //批量删除的id
const SelectionChange = (val) => {
  //获取批量删除的id
  ids.value = [];
  ids.value = val.map((item) => item.id);
};
//删除选中的数据
const deleteAll = () => {
  if (ids.value.length == 0) {
    ElMessage({ message: "请选择要删除的数据", type: "error" });
    return;
  }
  Delete(ids.value).then((res) => {
    ElMessage({ message: "删除成功", type: "success" });
    initData();
  });
};
//分页请求参数
const pageQuery = ref({
  page: 1, //当前页面
  rows: 10, //每页显示条数
  order: "createTime", //排序方式
  sort: "desc", //排序字段
  order: "desc", //排序方式
  sort: "", //排序字段
  wheres: "", //条件查询
});
@@ -1153,7 +1235,8 @@
  pageQuery.value.page = val;
  initData();
};
const pageTotal = ref(0);
//页面初始化方法
const initData = () => {
  // æŸ¥è¯¢æ¡ä»¶
  const startTime = formatTime(queryForm.value.selectTime[0]);
@@ -1162,7 +1245,7 @@
    {
      name: queryForm.value.selectType,
      value: queryForm.value.selectInput,
      displayType: "String",
      displayType: "like",
    },
    { name: "createtime", value: startTime, displayType: "ThanOrEqual" },
    { name: "createtime", value: endTime, displayType: "LessOrEqual" },
@@ -1181,37 +1264,76 @@
  pageQuery.value.page = 1;
  initData();
};
//重置表单
const resetForm = (formEl) => {
  if (!formEl) return;
  formEl.resetFields();
  form.value = {
    bogie: "", //转向架
    coachNum: "", //车厢
    processDept: "", //检修班组
    track: "", //股道
    trainKind: "", //车型
    trainNum: "", //车组号
    creater: "",
    createDate: formatTime(new Date()), //创建时间
  };
};
//重置方法
const resetQuery = () => {
  queryForm.value = Object.assign({}, obj);
  pageQuery.value.page = 1;
  initData();
};
//重置表单
const handleClose = (formEl) => {
  if (!formEl) return;
  formEl.resetFields();
};
onMounted(() => {
  initData();
  GetUerType().then((res) => {
    UerTypeoptions.value.quality = res.data.filter(
      (item) => item.roleId != 1 && item.roleName.substring(2, 2) == "质检"
    );
    UerTypeoptions.value.electric = res.data.filter(
      (item) =>
        item.roleId != 1 &&
        item.roleName.substring(2, 2) != "质检" &&
        item.roleName.substring(0, 2) == "电气"
    );
    UerTypeoptions.value.mechanical = res.data.filter(
      (item) =>
        item.roleId != 1 &&
        item.roleName.substring(2, 2) != "质检" &&
        item.roleName.substring(0, 2) == "机械"
    );
    UerTypeoptions.value.trench = res.data.filter(
      (item) =>
        item.roleId != 1 &&
        item.roleName.substring(2, 2) != "质检" &&
        item.roleName.substring(0, 2) == "地沟"
    );
  });
});
</script>
<style lang="scss" scoped>
.Taskmanagement {
  display: flex;
  background-color: #fff;
  .content {
    width: 100%;
    display: flex;
    flex-direction: column;
    .serch {
      display: flex;
      margin-top: 1.31rem;
      align-items: center;
      .time_box {
        display: flex;
        align-items: center;
        text-align: center;
        margin-left: 0.98rem;
        .time {
          box-sizing: border-box;
          width: 6.88rem;
@@ -1225,12 +1347,14 @@
          justify-content: center;
        }
      }
      .serch_box {
        display: flex;
        align-items: center;
        text-align: center;
        margin-left: 0.98rem;
        border-radius: 0.38rem;
        .serchb {
          box-sizing: border-box;
          width: 6.88rem;
@@ -1242,6 +1366,7 @@
          align-items: center;
          justify-content: center;
        }
        input {
          box-sizing: border-box;
          outline: none;
@@ -1254,6 +1379,7 @@
        }
      }
    }
    .btns {
      display: flex;
      justify-content: space-between;
@@ -1270,6 +1396,7 @@
.confirmButtonClass {
  margin-right: 10px;
}
.el-message-box .el-message-box__btns {
  flex-direction: row-reverse !important;
  justify-content: normal !important;