Your Name
2022-04-06 37b718547bc441c7502f0bfcf86209efe253851b
src/views/safetyproduction/reviewXG.vue
对比新文件
@@ -0,0 +1,331 @@
<template>
  <div class="app-container">
    <div class="box">
      <div class="box-right">
        <Titlename title="基础信息"></Titlename>
        <el-form ref="form" :model="form" label-width="120px">
          <div style="width: 80%; margin: auto">
            <el-row class="box-right-content" align="top">
              <el-col :span="11">
                <el-form-item label="A级要素">
                  <el-select
                    v-model="form.elementAName"
                    :disabled="true"
                    style="width: 100%"
                  >
                    <el-option label="区域一" value="shanghai"></el-option>
                    <el-option label="区域二" value="beijing"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="11" :offset="2" style="white-space: nowrap">
                <el-form-item label="B级要素">
                  <el-select
                    v-model="form.elementBName"
                    :disabled="true"
                    style="width: 100%"
                  >
                    <el-option label="区域一" value="shanghai"></el-option>
                    <el-option label="区域二" value="beijing"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="标准化要求">
                  <el-input
                    :rows="3"
                    type="textarea"
                    v-model="form.standardizationRequirements"
                    placeholder=""
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="企业达标标准">
                  <el-input
                    type="textarea"
                    :rows="3"
                    v-model="form.enterpriseStandard"
                    placeholder=""
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="评审方法">
                  <el-input
                    type="textarea"
                    :rows="3"
                    v-model="form.reviewMethod"
                    placeholder=""
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <Titlename title="评选标准"></Titlename>
          <div style="width: 80%; margin: auto">
            <el-row>
              <el-col :span="24">
                <el-form-item label="否决项">
                  <el-input
                    type="textarea"
                    :rows="3"
                    v-model="form.veto"
                    placeholder=""
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row style="padding: 15px 1%">
              <el-col :span="10" :offset="2">
                <span
                  style="font-size: 16px; font-weight: bold; line-height: 29px"
                  >扣分清单</span
                >
              </el-col>
              <el-col :span="12" style="text-align: right">
                <el-button
                  type="primary"
                  @click="coAdd('', '新增')"
                  class="btns"
                  size="mini"
                  icon="el-icon-plus"
                  >新增</el-button
                >
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="22" :offset="2">
                <el-table
                  :data="form.deductionList"
                  border
                  style="width: 99%; margin-left: 1%"
                >
                  <el-table-column
                    type="index"
                    align="center"
                    label="序号"
                    width="150"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="name"
                    align="center"
                    label="说明"
                  ></el-table-column>
                  <el-table-column align="center" label="操作" width="200px">
                    <template slot-scope="scope">
                      <el-button
                        @click="coAdd(scope.row, '编辑')"
                        type="text"
                        size="small"
                        >编辑</el-button
                      >
                      <el-button
                        type="text"
                        size="small"
                        style="color: red"
                        @click="listDel(scope.row)"
                        >删除</el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
              </el-col>
            </el-row>
          </div>
          <el-row>
            <el-col :span="24" style="padding: 20px 0; text-align: center">
              <el-button type="primary" @click="safetyInspectionItemA()" class="btns">提交</el-button>
              <el-button @click="back()">取消</el-button>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div>
    <el-dialog title="扣分详情" :visible.sync="dialogVisible" :close-on-click-modal="false" width="30%">
      <el-form ref="form" :rules="rules" :model="formInline" label-width="54px">
        <el-form-item label="说明" prop="name">
          <el-input v-model="formInline.name"></el-input>
        </el-form-item>
        <el-form-item label="备注">
          <el-input
            v-model="formInline.remark"
            :rows="5"
            type="textarea"
          ></el-input>
        </el-form-item>
      </el-form>
      <span
        slot="footer"
        class="dialog-footer"
        style="text-align: center; display: block"
      >
        <el-button type="primary" class="btns" @click="listAdd"
          >确 定</el-button
        >
        <el-button @click="bacQx">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import Titlename from "../../components/Titlename/index.vue";
import { safetyInspectionItemId } from "@/api/safetySelfInspection.js";
import { safetyInspectionItemMod } from "@/api/safetyInspectionItem.js";
export default {
  components: { Titlename },
  data() {
    return {
      dialogVisible: false,
      id: "",
      resource: "0",
      form: {},
      formInline: {
        name: "",
        remark: "",
      },
      name:"",
      typeid:'',
        rules: {
        name: [
          { required: true, message: "说明不能为空", trigger: "change" },
        ],}
    };
  },
  created() {
    this.id = this.$route.query.idX;
    this.typeid=this.$route.query.id;
    this.name = this.$route.query.name
    this.safeT(this.id);
  },
  methods: {
    safeT(id) {
      safetyInspectionItemId({ id: id }).then((res) => {
        if (res.data.code == 200) {
          this.form = res.data.result;
        }
      });
    },
    coAdd(val, type) {
       this.$nextTick(() => {
        this.$refs["form"].clearValidate();
      });
      this.titleN = type;
      if (type == "新增") {
        this.dialogVisible = true;
        this.formInline = {
          name: "",
          remark: "",
        };
      } else {
        this.dialogVisible = true;
        this.index = this.form.deductionList.findIndex(
          (item) => item.name == val.name
        );
        // this.formInline = val;
          this.formInline=JSON.parse(JSON.stringify(val));
      }
    },
    listAdd() {
       this.$refs["form"].validate((valid) => {
        if (valid) {
      if (this.titleN == "新增") {
        this.form.deductionList.push(this.formInline);
        this.dialogVisible = false;
      } else {
        this.form.deductionList[this.index].name = this.formInline.name;
        this.form.deductionList[this.index].space = this.formInline.space;
        this.dialogVisible = false;
      }
          }
      });
    },
    listDel(val) {
      var i = this.form.deductionList.findIndex(
        (item) => item.name == val.name
      );
      this.form.deductionList.splice(i, 1);
    },
       safetyInspectionItemA() {
        safetyInspectionItemMod(this.form).then((res) => {
          if (res.data.code == 200) {
            this.$notify({
              type: "success",
              duration: 2000,
              message: "修改成功",
              title: "成功",
            });
            this.$router.push({
              path:"/new",
              query:{
                name:this.name,
                id:this.typeid
              }
            })
          } else {
            this.$message({
              type: "warning",
              message: res.data.message,
            });
          }
        });
    },
    back(){
       this.$router.push({
              path:"/new",
               query:{
                name:this.name,
                id:this.typeid
              }
            })
    },
    bacQx(){
      this.dialogVisible = false;
    this.safeT(this.id);
    },
    handleClick() {
      this.dialogVisible = true;
    },
  },
};
</script>
<style scoped>
.app-container {
  padding: 0px;
}
.box {
  width: 100%;
  display: flex;
  justify-content: space-between;
  background-color: #dedede;
}
.box-left {
  width: 20%;
  /* height: 800px; */
  background-color: white;
  border-radius: 5px;
}
.box-left-content {
  padding: 10px;
}
.box-right {
  width: 100%;
  background-color: white;
  border-radius: 5px;
}
.box-right-content {
  padding: 15px 0;
}
.btns {
  background-color: #034ea2;
  border: 1px solid #034ea2;
}
</style>