| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483 | <template>  <div class="app-container">    <el-descriptions title="检查任务" border>      <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>        <span style="margin-right: 20px">检查区域</span>        <el-button type="primary" size="mini" @click="onAddPoint()"          >新增检查内容</el-button        >      </el-col>    </el-row>    <div class="content">      <div class="area_content" v-for="area in taskInfo.checkList">        <div>          {{ area.areaName }}        </div>        <div>          <div class="safetycheck_item" v-for="(item, index) in area.itemList">            <span>{{ index + 1 }}、{{ item.itemName }}</span>            <div class="safetycheck_point" v-for="point in item.pointList">              <div>                <div class="pointName">                  <div style="display: flex; flex-direction: row">                    <i class="circle" />                    <pre>{{ point.pointName }}</pre>                  </div>                </div>                <el-radio-group v-model="point.status">                  <el-radio :label="0">正常</el-radio>                  <el-radio :label="1">异常</el-radio>                </el-radio-group>                <el-button                  type="danger"                  size="mini"                  v-if="point.isAdd"                  style="margin-left: 50px"                  @click="onDeletePoint(area, item, point)"                  >删除</el-button                >              </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.trim="point.remark"                      style="width: 250px"                      placeholder="请输入情况描述"                      maxlength="255"                    ></el-input>                  </el-form-item>                  <el-form-item label="整改期限" prop="rectificationDeadline">                    <el-select                      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>        </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";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,    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 area = info.checkList.find((a) => a.areaId === p.areaId);        if (!area) {          area = { areaId: p.areaId, areaName: p.areaName, itemList: [] };          info.checkList.push(area);        }        let item = area.itemList.find((i) => i.itemId == p.itemId);        if (!item) {          item = { itemId: p.itemId, itemName: p.itemName, pointList: [] };          area.itemList.push(item);        }        let point = item.pointList.find((i) => i.pointId == p.id);        if (!point) {          point = {            pointId: p.id,            pointName: p.pointName,            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(area, 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 = area.itemList.indexOf(item);        area.itemList.splice(index, 1);      }      if (area.itemList.length === 0) {        index = this.taskInfo.checkList.indexOf(area);        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;      let r = this.$refs;      for (let p in this.$refs) {        if (p.startsWith("point")) {          try {            isOk &= await this.$refs[p][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>.el-row-button {  margin-top: 20px;}.content {  max-height: calc(100% - 300px);  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: #f7f7f7;  border-right: #b8bdc0 1px solid;  padding-top: auto;  width: 15%;  display: flex;  flex-direction: column;  justify-content: center;  text-align: center;}.area_content > div:nth-child(2) {  width: 80%;  padding-left: 10px;}.safetycheck_item {  margin: 10px;  margin-bottom: 20px;}.safetycheck_point {  padding-top: 10px;  padding-left: 30px;}// .safetycheck_point > div:nth-child(1) {//   margin-bottom: 15px;// }.pointName {  width: 400px;  display: inline-block;  margin-right: 50px;}.pointName pre {  margin-left: 10px;  width: calc(100% - 15px);}.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: #b8bdc0;  border: none;  margin-bottom: 3px;  margin-top: 6px;}.el-descriptions {  ::v-deep .el-descriptions__body {    background-color: transparent !important;  }}</style>
 |