| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607 |
- <template>
- <div class="app-container">
- <el-descriptions title="检查任务" border :labelStyle="{ width: '180px' }">
- <el-descriptions-item label="任务名称">{{
- taskInfo.taskName
- }}</el-descriptions-item>
- <el-descriptions-item label="任务进度"
- >{{ getLabel(dict.type.safety_check_status, taskInfo.status) }}
- </el-descriptions-item>
- <el-descriptions-item label="任务开始时间"
- >{{ dayjs(taskInfo.planStartTime).format("YYYY年MM月DD") }}
- </el-descriptions-item>
- <el-descriptions-item label="任务结束时间"
- >{{ dayjs(taskInfo.planEndTime).format("YYYY年MM月DD") }}
- </el-descriptions-item>
- <el-descriptions-item label="检查主体">{{
- taskInfo.checkOrgName
- }}</el-descriptions-item>
- <el-descriptions-item label="受检机构">{{
- taskInfo.beCheckedOrgName
- }}</el-descriptions-item>
- <el-descriptions-item label="检查人员"
- >{{
- taskInfo.checkRoles
- ? taskInfo.checkRoles.map((r) => r.name).join(",")
- : ""
- }}
- </el-descriptions-item>
- <el-descriptions-item label="检查组成员"
- ><el-input
- style="width: 80%; margin-top: -8px"
- placeHolder="请输入检查组成员"
- v-model="taskInfo.checkTeam"
- maxlength="100"
- ></el-input>
- </el-descriptions-item>
- </el-descriptions>
- <el-row class="el-row-button">
- <el-col>
- <el-button type="primary" size="mini" @click="onAddPoint()"
- >新增检查内容</el-button
- >
- </el-col>
- </el-row>
- <div class="content">
- <div
- class="area_content"
- style="font-weight: 700; background-color: white"
- >
- <div style="background-color: inherit">检查手册</div>
- <div>
- <div class="safetycheck_item">
- <div style="padding-left: 10px; display: flex">
- <div class="name namePadding" style="text-align: center">
- 检查内容
- </div>
- <div class="point_areaname">检查区域</div>
- <div class="point_btn" style="text-align: center">检查结果</div>
- </div>
- </div>
- </div>
- </div>
- <div
- class="area_content"
- v-for="rule in taskInfo.checkList"
- :key="rule.ruleId"
- >
- <div>
- {{ rule.ruleName }}
- </div>
- <div>
- <div
- class="safetycheck_item"
- v-for="(item, index) in rule.itemList"
- :key="item.itemId"
- >
- <div
- style="
- background-color: #d1e0f1 !important;
- padding-left: 10px;
- display: flex;
- "
- >
- <div class="name namePadding">
- 检查项:{{ arabicToChinese(index + 1) }}、{{ item.itemName }}
- </div>
- <div class="point_areaname"></div>
- <!-- <div class="namePadding" style="padding-left:20px;">检查结果</div> -->
- </div>
- <div
- class="safetycheck_point"
- v-for="(point, pIndex) in item.pointList"
- :key="point.pointId"
- >
- <div class="pointContent name">
- <div class="pointName namePadding">
- <div class="text_nbsp">
- {{ pIndex + 1 + "、" + point.pointName }}
- </div>
- <!-- <i class="circle" /> -->
- </div>
- <div v-if="point.status == 1">
- <el-form
- :ref="'point_' + point.pointId"
- :model="point"
- :rules="exceptionRules"
- label-width="100px"
- >
- <el-form-item label="情况描述" prop="remark">
- <el-input
- v-model="point.remark"
- style="width:250px"
- placeholder="请输入情况描述"
- maxlength="255"
- ></el-input> </el-form-item
- ><el-form-item
- label="整改期限"
- prop="rectificationDeadline"
- >
- <el-select
- style="width:250px"
- v-model="point.rectificationDeadline"
- placeholder="请选择整改期限"
- >
- <el-option
- v-for="item in dict.type.rectification_deadline"
- :key="item.value"
- :value="item.value"
- :label="item.label"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="异常图片" prop="image">
- <imgUpload
- type="more"
- :value="
- point.imgData
- ? point.imgData.map((d) => d.imgPath).join(',')
- : ''
- "
- @input="onImageChanged(point, $event)"
- ></imgUpload>
- </el-form-item>
- </el-form>
- </div>
- </div>
- <div class="point_areaname">
- {{ point.areaName }}
- </div>
- <div class="point_btn">
- <el-radio-group
- v-model="point.status"
- style=" margin-left: 20px"
- >
- <el-radio :label="0">正常</el-radio>
- <el-radio :label="1">异常</el-radio>
- </el-radio-group>
- <div style="margin-top: -5px;">
- <el-button
- type="danger"
- size="mini"
- v-if="point.isAdd"
- style="margin-left: 50px"
- @click="onDeletePoint(rule, item, point)"
- >删除</el-button
- >
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="dialog-footer">
- <el-button type="primary" @click="onSubmit()" v-if="showSaveBtn"
- >提交</el-button
- >
- <el-button @click="onSave" v-if="showSaveBtn">保存</el-button>
- <el-button @click="onGrant" v-if="showGrantBtn">授权</el-button>
- <el-button @click="onClose">关闭</el-button>
- </div>
- <SelectPoint
- ref="SelectPoint"
- :orgType="[taskInfo.beCheckOrgType]"
- @select="onSelectPoint"
- ></SelectPoint>
- <UserSelector
- ref="UserSelector"
- @select="onUserSelect"
- :customTreeRequest="deptTreeWithSameTypeUp"
- :selectLimit="1"
- ></UserSelector>
- </div>
- </template>
- <script>
- import { mapGetters } from "vuex";
- import * as api from "@/api/safetycheck/register.js";
- import dayjs from "dayjs";
- import SelectPoint from "../../ruleManager/dialog.select.point.vue";
- import imgUpload from "@/components/ImageUpload/index.vue";
- import UserSelector from "@/components/userSelector/index.vue";
- import { getLabel } from "@/views/commonOption.js";
- import { checkPermi } from "@/utils/permission.js";
- import { deptTreeWithSameTypeUp } from "@/api/system/org.js";
- import { arabicToChinese } from "@/utils/util.js";
- export default {
- name: "safetyCheckRegister",
- data() {
- return {
- taskInfo: {},
- exceptionRules: {
- remark: [{ required: true, message: "请输入情况描述" }],
- rectificationDeadline: [{ required: true, message: "请选择整改期限" }],
- },
- pointIdsWhenAdd: [],
- };
- },
- dicts: ["rectification_deadline", "sys_user_is_lock", "safety_check_status"],
- components: { SelectPoint, imgUpload, UserSelector },
- computed: {
- ...mapGetters(["orgId", "roleList", "userId"]),
- showSaveBtn() {
- return (
- this.taskInfo.status != 3 &&
- (checkPermi(["core:safetycheck:register"]) ||
- this.taskInfo.grantUserId == this.userId)
- );
- },
- showGrantBtn() {
- let userRoleIds = this.roleList.map((r) => r.roleId);
- let taskRoleIds = this.taskInfo.checkRoles
- ? this.taskInfo.checkRoles.map((r) => r.id)
- : [];
- return (
- this.taskInfo.status != 3 &&
- this.taskInfo.planType == 3 &&
- this.taskInfo.checkOrgId == this.orgId &&
- userRoleIds.find((ur) => taskRoleIds.includes(ur))
- );
- },
- },
- mounted() {
- let id = this.$route.params.taskId;
- let request = api.info;
- request(id).then((r) => {
- if (r.data.status == 3) {
- this.onClose();
- return;
- }
- let userRoleIds = this.roleList.map((r) => r.roleId);
- let taskRoleIds = r.data.checkRoles.map((r) => r.id);
- if (
- (r.data.checkOrgId == this.orgId &&
- userRoleIds.find((ur) => taskRoleIds.includes(ur))) ||
- r.data.grantUserId == this.userId
- ) {
- this.taskInfo = r.data;
- } else {
- this.$message.warning("用户不能执行该任务");
- this.onClose();
- }
- });
- },
- methods: {
- dayjs,
- getLabel,
- deptTreeWithSameTypeUp,
- arabicToChinese,
- onAddPoint() {
- this.pointIdsWhenAdd = [];
- this.taskInfo.checkList.forEach((a) => {
- a.itemList.forEach((i) => {
- i.pointList.forEach((p) => {
- this.pointIdsWhenAdd.push(p.pointId);
- });
- });
- });
- this.$refs.SelectPoint.show(this.pointIdsWhenAdd);
- },
- onSelectPoint(selectedList) {
- let hasNew = false;
- for (let index in selectedList) {
- let p = selectedList[index];
- if (this.pointIdsWhenAdd.indexOf(p.id) >= 0) {
- continue;
- }
- let info = this.taskInfo;
- let rule = info.checkList.find((a) => a.ruleId === p.ruleId);
- if (!rule) {
- rule = { ruleId: p.ruleId, ruleName: p.ruleName, itemList: [] };
- info.checkList.push(rule);
- }
- let item = rule.itemList.find((i) => i.itemId == p.itemId);
- if (!item) {
- item = { itemId: p.itemId, itemName: p.itemName, pointList: [] };
- rule.itemList.push(item);
- }
- let point = item.pointList.find((i) => i.pointId == p.id);
- if (!point) {
- point = {
- pointId: p.id,
- pointName: p.pointName,
- areaId:p.areaId,
- areaName:p.areaName,
- mustCheck: 1,
- isAdd: 1,
- status: 0,
- remark: null,
- imgData: null,
- rectificationDeadline: null,
- submitBy: null,
- submitTime: null,
- };
- item.pointList.push(point);
- hasNew = true;
- }
- }
- if (!hasNew) {
- this.$message.info("没有可新增的检查内容");
- }
- },
- onClose() {
- this.$tab.closePageAndPushPrev();
- },
- onDeletePoint(rule, item, point) {
- if (point.isAdd === 0) {
- this.$message.warning("不可删除计划的检查内容");
- return;
- }
- let index = item.pointList.indexOf(point);
- if (index >= 0) {
- item.pointList.splice(index, 1);
- }
- if (item.pointList.length === 0) {
- index = rule.itemList.indexOf(item);
- rule.itemList.splice(index, 1);
- }
- if (rule.itemList.length === 0) {
- index = this.taskInfo.checkList.indexOf(rule);
- this.taskInfo.checkList.splice(index, 1);
- }
- },
- onImageChanged(point, value) {
- point.imgData = value
- .split(",")
- .map((img) => ({ id: null, imgPath: img }));
- },
- onUserSelect(selected) {
- if (!selected || selected.length === 0) {
- this.$message.warning("请选择要授权的人员");
- return;
- }
- let { planId, beCheckedOrgId, id, ymdDate } = this.taskInfo;
- api
- .grant({
- planId,
- beCheckedOrgId,
- taskId: id,
- ymdDate,
- userId: selected[0].id,
- })
- .then((r) => {
- this.$message.info("授权成功");
- });
- //调用授权
- },
- onGrant() {
- this.$refs.UserSelector.show();
- },
- onSave() {
- if (
- dayjs()
- .startOf("day")
- .isBefore(dayjs(this.taskInfo.planStartTime).startOf("day"))
- ) {
- this.$modal.alert("任务未到开始时间,不能操作");
- return;
- }
- if (
- dayjs()
- .endOf("day")
- .isAfter(dayjs(this.taskInfo.planEndTime).endOf("day"))
- ) {
- this.$modal.alert("任务已逾期,不能操作");
- return;
- }
- this.taskInfo.isSubmit = 0;
- api.submit(this.taskInfo).then((r) => {
- this.$message.info("保存成功");
- });
- },
- async onSubmit() {
- if (
- dayjs()
- .startOf("day")
- .isBefore(dayjs(this.taskInfo.planStartTime).startOf("day"))
- ) {
- this.$modal.alert("任务未到开始时间,不能操作");
- return;
- }
- if (
- dayjs()
- .endOf("day")
- .isAfter(dayjs(this.taskInfo.planEndTime).endOf("day"))
- ) {
- this.$modal.alert("任务已逾期,不能操作");
- return;
- }
- let isOk = true;
- for (let area of this.taskInfo.checkList) {
- for (let item of area.itemList) {
- for (let point of item.pointList) {
- if (point.status == null) {
- this.$modal.alert("检查结果还未登记,请先登记!");
- return;
- }
- }
- }
- }
- let r = this.$refs;
- for (let p in this.$refs) {
- if (p.startsWith("point") && r.length > 0) {
- try {
- isOk &= await r[0].validate();
- } catch (e) {
- isOk &= false;
- console.error(e);
- }
- }
- }
- if (isOk) {
- this.taskInfo.isSubmit = 1;
- api.submit(this.taskInfo).then((r) => {
- this.$message.info("提交成功");
- this.$tab.closePageAndPushPrev();
- });
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .app-container {
- background-color: white;
- }
- .el-row-button {
- margin-top: 20px;
- }
- .content {
- max-height: calc(100% - 350px);
- overflow-y: auto;
- margin-bottom: 20px;
- margin-top: 20px;
- flex-direction: column;
- }
- .itemDetail {
- max-height: calc(100% - 300px);
- overflow-y: auto;
- margin-top: 20px;
- }
- .area_content {
- border: #b8bdc0 1px solid;
- display: flex;
- flex-direction: row;
- width: 100%;
- }
- .content > .area_content:first-child {
- border-bottom: none;
- }
- .content > .area_content:last-child {
- border-bottom: #b8bdc0 1px solid;
- }
- .area_content > div:nth-child(1) {
- background-color: #d1e0f1;
- border-right: #b8bdc0 1px solid;
- padding-top: auto;
- width: 250px;
- display: flex;
- flex-direction: column;
- justify-content: center;
- text-align: center;
- }
- .area_content > div:nth-child(2) {
- width: calc(100% - 250px);
- // padding-left: 10px;
- }
- .safetycheck_item {
- // margin: 10px;
- // padding-bottom: 20px;
- }
- .safetycheck_item > div:first {
- // padding-top: 10px;
- // padding-bottom: 10px;
- }
- .safetycheck_item > div:not(:last-child) {
- border-bottom: #b8bdc0 1px solid;
- }
- .safetycheck_point {
- // padding-top: 8px;
- display: flex;
- padding-left: 40px;
- background-color: #d1e0f188 !important;
- & > div {
- display: flex;
- flex-direction: row;
- }
- }
- .name {
- width: calc(100% - 600px);
- border-right: #b8bdc0 1px solid;
- }
- .namePadding {
- padding-top: 10px;
- padding-bottom: 10px;
- padding-right: 20px;
- }
- .pointContent {
- display: flex;
- flex-direction: column !important;
- & > div {
- display: flex;
- flex-direction: row;
- }
- ::v-deep .el-upload--picture-card {
- width: 100px;
- height: 100px;
- line-height: 100px;
- }
- ::v-deep .el-upload-list--picture-card .el-upload-list__item{
- width: 100px;
- height: 100px;
- line-height: 100px;
- }
- }
- .point_areaname {
- padding-top: 10px;
- width: 150px;
- border-right: #b8bdc0 1px solid;
- text-align: center;
- display: inline-block !important;
- }
- .point_btn {
- // flex-direction: column !important;
- // justify-content: center;
- padding-top:10px;
- width: 450px;
- }
- .pointName {
- display: flex;
- flex-direction: row;
- }
- .dialog-footer {
- width: 100%;
- text-align: right;
- border-top: #b8bdc0 1px solid;
- padding-top: 10px;
- padding-right: 30px;
- position: absolute;
- bottom: 30px;
- right: 0px;
- }
- .circle {
- display: inline-block;
- width: 5px;
- height: 5px;
- border-radius: 5px;
- background-color: #000;
- border: none;
- margin-top: 10px;
- margin-right: 10px;
- }
- .el-descriptions {
- ::v-deep .el-descriptions__body {
- background-color: transparent !important;
- }
- }
- </style>
|