spring
2025-02-18 0c296ab5e1e4ed1eaab1940f85959ed66f68fbe7
src/views/performance/manHour/workTimeConfig.vue
@@ -53,7 +53,8 @@
        size="small"
        type="primary"
        style="position: absolute; right: 50px"
        @click="openAdd"
        @click="openAdd('新增')"
        v-if="checkPermi(['performance:manHour:workTimeConfig:add'])"
        >新 增</el-button
      >
    </div>
@@ -63,38 +64,145 @@
        :column="column"
        :page="page"
        :tableLoading="tableLoading"
        :height="'calc(100vh - 150px)'"
        :height="'calc(100vh - 290px)'"
        @pagination="pagination"
      ></lims-table>
    </div>
    <!-- 新增/编辑 -->
    <el-dialog :title="title" :visible.sync="timeDia" width="500px">
      <el-form
        :model="timeForm"
        ref="timeForm"
        :rules="timeRules"
        label-position="right"
        label-width="120px"
      >
        <el-form-item label="编号" prop="number">
          <el-input
            size="small"
            placeholder="请输入"
            clearable
            v-model="timeForm.number"
          ></el-input>
        </el-form-item>
        <el-form-item label="辅助项目名称" prop="auxiliaryProject">
          <el-input
            size="small"
            placeholder="请输入"
            clearable
            v-model="timeForm.auxiliaryProject"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="部门" prop="department">
          <el-input
            size="small"
            placeholder="请输入"
            clearable
            v-model="timeForm.department"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="实验室" prop="laboratory">
          <el-select
            v-model="timeForm.laboratory"
            size="small"
            clearable
            placeholder="请选择"
            style="width: 100%"
          >
            <el-option
              v-for="item in laboratoryList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="单位" prop="unit">
          <el-select
            v-model="timeForm.unit"
            size="small"
            clearable
            placeholder="请选择"
            style="width: 100%"
          >
            <el-option
              v-for="item in unitList"
              :key="item.dictValue"
              :label="item.dictLabel"
              :value="item.dictValue"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="核准工时" prop="approvedWorkingHour">
          <el-input
            size="small"
            placeholder="请输入"
            clearable
            v-model="timeForm.approvedWorkingHour"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="备注" prop="remarks">
          <el-input
            size="small"
            placeholder="请输入"
            type="textarea"
            :rows="2"
            clearable
            v-model="timeForm.remarks"
          >
          </el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="timeDia = false">取 消</el-button>
        <el-button
          :loading="uploading"
          type="primary"
          @click="submitProduct('timeForm')"
          >确 认</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
<script>
import ValueTable from "@/components/Table/value-table.vue";
import limsTable from "@/components/Table/lims-table.vue";
import { checkPermi } from "@/utils/permission"; // 权限判断函数
import {
  selectAuxiliaryWorkingHours,
  insertAuxiliaryWorkingHoursDay,
  insertAuxiliaryWorkingHours,
  obtainItemParameterList,
  upAuxiliaryWorkingHours,
  deleteAuxiliaryWorkingHours,
} from "@/api/performance/manHour";
export default {
  components: {
    ValueTable,
    limsTable,
  },
  dicts: ["sys_unit"],
  data() {
    return {
      laboratoryList: [],
      partList: [],
      addPower: true,
      queryParams: {},
      tableData: [],
      column: [
        { label: "编号", prop: "number" },
        { label: "辅助项目名称", prop: "auxiliaryProject", width: "120px" },
        { label: "实验室", prop: "laboratory" },
        {
          label: "实验室",
          prop: "laboratory",
          dataType: "tag",
          formatData: (params) => {
            return this.laboratoryList.find((m) => m.value == params).label;
          },
        },
        { label: "单位", prop: "unit" },
        { label: "核准工时", prop: "approvedWorkingHour" },
        { label: "部门", prop: "department" },
@@ -109,10 +217,12 @@
              name: "编辑",
              type: "text",
              clickFun: (row) => {
                this.handleEdit(row);
                this.openAdd("编辑", row);
              },
              showHide: (row) => {
                return this.checkPermi(["standard:model:edit"]);
                return this.checkPermi([
                  "performance:manHour:workTimeConfig:edit",
                ]);
              },
            },
            {
@@ -122,7 +232,9 @@
                this.handleDelete(row);
              },
              showHide: (row) => {
                return this.checkPermi(["standard:model:del"]);
                return this.checkPermi([
                  "performance:manHour:workTimeConfig:del",
                ]);
              },
            },
          ],
@@ -135,16 +247,31 @@
      },
      tableLoading: false,
      unitList: [],
      title: "新增",
      timeDia: false,
      timeForm: {},
      timeRules: {
        number: [{ required: true, message: "请输入编号", trigger: "blur" }],
        auxiliaryProject: [
          { required: true, message: "请输入辅助项目名称", trigger: "blur" },
        ],
        laboratory: [
          { required: true, message: "请选择实验室", trigger: "change" },
        ],
        unit: [{ required: true, message: "请选择单位", trigger: "change" }],
        approvedWorkingHour: [
          { required: true, message: "请输入核准工时", trigger: "blur" },
        ],
      },
      uploading: false,
    };
  },
  mounted() {
    this.entityCopy = this.HaveJson(this.componentData.entity);
    this.getPower();
    this.obtainItemParameterList();
    this.selectEnumByCategoryForUnit();
    this.getList();
  },
  methods: {
    checkPermi,
    getList() {
      this.tableLoading = true;
      let param = { ...this.queryParams, ...this.page };
@@ -161,8 +288,9 @@
          this.tableLoading = false;
        });
    },
    pagination(current, size) {
      this.page.current = current;
    pagination({ page, limit }) {
      this.page.current = page;
      this.page.size = limit;
      this.getList();
    },
    refresh() {
@@ -174,34 +302,15 @@
      this.page.current = 1;
      this.getList();
    },
    getPower(radio) {
      let power = JSON.parse(sessionStorage.getItem("power"));
      let up = false;
      let del = false;
      let add = false;
      for (var i = 0; i < power.length; i++) {
        if (power[i].menuMethod == "upDeviceParameter") {
          up = true;
        }
        if (power[i].menuMethod == "delDeviceParameter") {
          del = true;
        }
        if (power[i].menuMethod == "addDeviceParameter") {
          add = true;
        }
    openAdd(title, row) {
      this.title = title;
      if (row) {
        this.timeForm = row;
        this.timeForm.laboratory = Number(this.timeForm.laboratory);
      } else {
        this.timeForm = {};
      }
      if (!up) {
        this.componentData.do.splice(1, 1);
      }
      if (!del) {
        this.componentData.do.splice(0, 1);
      }
      this.addPower = add;
    },
    openAdd() {
      // this.$refs.ValueTable0.openAddDia(
      //   this.$api.auxiliaryWorkingHours.insertAuxiliaryWorkingHours
      // );
      this.timeDia = true;
    },
    obtainItemParameterList() {
      obtainItemParameterList().then((res) => {
@@ -219,6 +328,59 @@
      this.getDicts("sys_unit").then((response) => {
        this.unitList = response.data;
      });
    },
    submitProduct(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.uploading = true;
          if (this.title == "新增") {
            insertAuxiliaryWorkingHours(this.timeForm)
              .then((res) => {
                this.uploading = false;
                if (res.code != 200) {
                  return;
                }
                this.$message.success("提交成功");
                this.refresh();
                this.timeDia = false;
              })
              .catch((err) => {
                this.uploading = false;
              });
          } else {
            upAuxiliaryWorkingHours(this.timeForm)
              .then((res) => {
                this.uploading = false;
                if (res.code != 200) {
                  return;
                }
                this.$message.success("提交成功");
                this.refresh();
                this.timeDia = false;
              })
              .catch((err) => {
                this.uploading = false;
              });
          }
        } else {
          return false;
        }
      });
    },
    handleDelete(row) {
      this.$confirm("是否删除该条数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          deleteAuxiliaryWorkingHours({ id: row.id }).then((res) => {
            if (res.code == 201) return;
            this.$message.success("删除成功");
            this.refresh();
          });
        })
        .catch(() => {});
    },
  },
};
@@ -251,10 +413,7 @@
  width: calc(100% - 70px);
}
.table {
  margin-top: 10px;
  background-color: #fff;
  width: calc(100% - 40px);
  height: calc(100% - 60px - 80px - 10px - 24px);
  padding: 20px;
  padding: 10px;
  padding-top: 0;
}
</style>