yaozc
2023-07-07 c752e33fe402e2179e7e6795f567d41c044ca3c6
eladmin-web-master/src/views/project/projectTask/index.vue
@@ -29,10 +29,10 @@
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px">
          <el-form-item label="名称" prop="name">
            <el-input v-model="form.name" style="width: 340px;" />
            <el-input v-model="form.name" style="width: 340px;" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="所属项目" prop="projectId">
            <el-select v-model="form.projectId" clearable filterable placeholder="请选择" style="width: 340px;">
            <el-select v-model="form.projectId" clearable filterable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagByApprove">
              <el-option
                v-for="item in projectList"
                :key="item.id"
@@ -43,7 +43,7 @@
            </el-select>
          </el-form-item>
          <el-form-item label="任务分类" prop="taskClassification">
            <el-select v-model="form.taskClassification" clearable filterable placeholder="请选择" style="width: 340px;">
            <el-select v-model="form.taskClassification" clearable filterable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagByApprove">
              <el-option
                v-for="item in dict[taskClassification]"
                :key="item.id"
@@ -53,22 +53,22 @@
            </el-select>
          </el-form-item>
          <el-form-item label="描述">
            <el-input v-model="form.description" :rows="3" type="textarea" style="width: 340px;" />
            <el-input v-model="form.description" :rows="3" type="textarea" style="width: 340px;" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="计划开始时间">
            <el-date-picker v-model="form.planStartTime" type="datetime" :picker-options="pickerOptionsStart" style="width: 340px;" />
            <el-date-picker v-model="form.planStartTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" :default-time="$store.state.user.user.sysRostering.workStartTime + ':00'" :picker-options="pickerOptionsStart" style="width: 340px;" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="计划结束时间">
            <el-date-picker v-model="form.planEndTime" type="datetime" :picker-options="pickerOptionsEnd" style="width: 340px;" />
            <el-date-picker v-model="form.planEndTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" :default-time="$store.state.user.user.sysRostering.workEndTime + ':00'" :picker-options="pickerOptionsEnd" style="width: 340px;" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="计划工时" prop="planHours">
            <el-input v-model="form.planHours" style="width: 340px;" />
            <el-input v-model="form.planHours" style="width: 340px;" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="计划工作量" prop="planWorkload">
            <el-input v-model="form.planWorkload" style="width: 340px;" />
            <el-input v-model="form.planWorkload" style="width: 340px;" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="计划工作量单位">
            <el-select v-model="form.planWorkloadUnit" filterable placeholder="请选择" style="width: 340px;">
            <el-select v-model="form.planWorkloadUnit" filterable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagByApprove">
              <el-option
                v-for="item in dict[standardWorkloadUnit]"
                :key="item.id"
@@ -78,7 +78,7 @@
            </el-select>
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 340px;" />
            <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 340px;" :disabled="disabledFlagByApprove" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
@@ -87,7 +87,7 @@
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
      <el-table ref="table" v-loading="crud.loading" :summary-method="getSummaries" show-summary :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column show-overflow-tooltip prop="name" label="名称" width="180" />
        <el-table-column show-overflow-tooltip prop="projectName" label="所属项目" width="180">
@@ -137,7 +137,7 @@
import pagination from '@crud/Pagination'
import constant from '../../../utils/constant'
const defaultForm = { id: null, projectId: null, name: null, taskClassification: null, description: null, planStartTime: null, planEndTime: null, planHours: null, planWorkload: null, planWorkloadUnit: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
const defaultForm = { id: null, projectId: null, name: null, taskClassification: null, performanceType: '1', description: null, planStartTime: null, planEndTime: null, planHours: null, planWorkload: null, planWorkloadUnit: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
export default {
  name: 'ProjectTask',
  components: { pagination, crudOperation, rrOperation, udOperation },
@@ -149,11 +149,11 @@
  data() {
    // 指针重指向
    const _this = this
    // 时长(千内)验证
    // 时长(万内)验证
    var durationValidate = (rule, value, callback) => {
      const reg = /^([0-9]|[1-9]\d{1,2})(\.\d{1,2})?$|1000$/
      const reg = /^([0-9]|[1-9]\d{1,3})(\.\d{1,2})?$/
      if (value != null && value !== '' && !reg.test(value)) {
        callback(new Error('请输入 一千 以内的正整数或两位小数'))
        callback(new Error('请输入 一万 以内的正整数或两位小数'))
      } else {
        callback()
      }
@@ -210,7 +210,9 @@
        disabledDate: (time) => {
          return _this.form.planStartTime != null && _this.form.planStartTime !== '' ? time.getTime() < new Date(_this.form.planStartTime).getTime() - (86400000 - 1) : false
        }
      }
      },
      // 表单禁用标记(承认状态)
      disabledFlagByApprove: false
    }
  },
  methods: {
@@ -227,6 +229,16 @@
    },
    // 新增与编辑前做的操作
    [CRUD.HOOK.afterToCU](crud, form) {
      // 表单禁用标记(承认状态)
      this.disabledFlagByApprove = false
      // 循环项目列表
      for (let i = 0; i < this.projectList.length; i++) {
        // 判断是否为同一项目
        if (this.form.projectId === this.projectList[i].id && this.projectList[i].approveStatus === constant.APPROVE_STATUS_ACKNOWLEDGED) {
          // 表单禁用标记(承认状态)
          this.disabledFlagByApprove = true
        }
      }
      // 随机数
      this.random = Math.random()
    },
@@ -237,6 +249,28 @@
        // 项目列表
        this.projectList = res
      })
    },
    // 表格统计
    getSummaries(param) {
      const { columns, data } = param
      const sums = []
      columns.forEach((column, index) => {
        // 7/8号单元格
        if (index === 7 || index === 8) {
          const values = data.map(item => Number(item[column.property]))
          if (!values.every(value => isNaN(value))) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr)
              if (!isNaN(value)) {
                return prev + curr
              } else {
                return prev
              }
            }, 0)
          }
        }
      })
      return sums
    }
  }
}