| | |
| | | <div class="head-container"> |
| | | <div v-if="crud.props.searchToggle"> |
| | | <!-- 搜索 --> |
| | | <el-select v-model="query.projectId" clearable filterable placeholder="请选择项目" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-select v-model="query.projectId" clearable filterable placeholder="所属项目" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in projectList" |
| | | :key="item.id" |
| | |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.userId" clearable filterable placeholder="请选择用户" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-select v-model="query.userId" clearable filterable placeholder="所属员工" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in userList" |
| | | :key="item.id" |
| | |
| | | <!--表单组件--> |
| | | <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="projectId"> |
| | | <el-select v-model="form.projectId" clearable filterable placeholder="请选择" style="width: 340px;"> |
| | | <el-form-item label="所属项目" prop="projectId"> |
| | | <el-select v-model="form.projectId" clearable filterable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagByApprove"> |
| | | <el-option |
| | | v-for="item in projectList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | :disabled="item.approveStatus == approveStatusAcknowledged" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="用户" prop="userId"> |
| | | <el-select v-model="form.userId" clearable filterable placeholder="请选择" style="width: 340px;" @change="timeChange"> |
| | | <el-form-item label="所属员工" prop="userId"> |
| | | <el-select v-model="form.userId" clearable filterable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagByApprove" @change="getProjectCost"> |
| | | <el-option |
| | | v-for="item in userList" |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | :disabled="!item.enabled" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="进入项目时间" prop="enterProjectTime"> |
| | | <el-date-picker v-model="form.enterProjectTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" style="width: 340px;" @change="timeChange" /> |
| | | <el-date-picker v-model="form.enterProjectTime" type="datetime" :picker-options="pickerOptionsStart" style="width: 340px;" :disabled="disabledFlagByApprove" @change="getProjectCost" /> |
| | | </el-form-item> |
| | | <el-form-item label="退出项目时间" prop="exitProjectTime"> |
| | | <el-date-picker v-model="form.exitProjectTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" style="width: 340px;" @change="timeChange" /> |
| | | <el-date-picker v-model="form.exitProjectTime" type="datetime" :picker-options="pickerOptionsEnd" style="width: 340px;" :disabled="disabledFlagByApprove" @change="getProjectCost" /> |
| | | </el-form-item> |
| | | <el-form-item label="项目成本" prop="projectCost"> |
| | | <!-- <el-input v-model="form.projectCost" style="width: 340px;" /> --> |
| | | <money-input :key="random" v-model="form.projectCost" :width="340" /> |
| | | <money-input :key="random" v-model="form.projectCost" :width="340" :disabled="disabledFlagByApprove" /> |
| | | </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"> |
| | |
| | | <!--表格渲染--> |
| | | <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler"> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column prop="projectName" label="项目" show-overflow-tooltip> |
| | | <el-table-column prop="projectName" label="所属项目" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.projectName }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="userName" label="用户" show-overflow-tooltip> |
| | | <el-table-column prop="userName" label="所属员工" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.userName }}</el-tag> |
| | | </template> |
| | |
| | | import udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | | import moneyInput from '../../assembly/moneyInput/index.vue' |
| | | import constant from '../../../utils/constant' |
| | | |
| | | const defaultForm = { id: null, projectId: null, userId: null, enterProjectTime: null, exitProjectTime: null, projectCost: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | |
| | | return CRUD({ title: '项目成本', url: 'api/projectCost', idField: 'id', sort: 'id,desc', crudMethod: { ...crudProjectCost }}) |
| | | }, |
| | | data() { |
| | | // 指针重指向 |
| | | const _this = this |
| | | return { |
| | | permission: { |
| | | add: ['admin', 'projectCost:add'], |
| | |
| | | }, |
| | | rules: { |
| | | projectId: [ |
| | | { required: true, message: '项目不能为空', trigger: 'blur' } |
| | | { required: true, message: '所属项目不能为空', trigger: 'blur' } |
| | | ], |
| | | userId: [ |
| | | { required: true, message: '用户不能为空', trigger: 'blur' } |
| | | { required: true, message: '所属员工不能为空', trigger: 'blur' } |
| | | ], |
| | | enterProjectTime: [ |
| | | { required: true, message: '进入项目时间不能为空', trigger: 'blur' } |
| | |
| | | ] |
| | | }, |
| | | queryTypeOptions: [ |
| | | { key: 'projectId', display_name: '项目' }, |
| | | { key: 'userId', display_name: '用户' }, |
| | | { key: 'projectId', display_name: '所属项目' }, |
| | | { key: 'userId', display_name: '所属员工' }, |
| | | { key: 'enterProjectTime', display_name: '进入项目时间' }, |
| | | { key: 'exitProjectTime', display_name: '退出项目时间' } |
| | | ], |
| | | // 承认状态:已承认 |
| | | approveStatusAcknowledged: constant.APPROVE_STATUS_ACKNOWLEDGED, |
| | | // 用户列表 |
| | | userList: [], |
| | | // 项目列表 |
| | | projectList: [], |
| | | // 随机数 |
| | | random: 0, |
| | | // 选中结束时间之后不可选 |
| | | pickerOptionsStart: { |
| | | disabledDate: (time) => { |
| | | if (this.form.exitProjectTime) { |
| | | return time.getTime() > this.form.exitProjectTime |
| | | } |
| | | return _this.form.exitProjectTime != null && _this.form.exitProjectTime !== '' ? time.getTime() > new Date(_this.form.exitProjectTime).getTime() : false |
| | | } |
| | | }, |
| | | // 选中开始时间之后不可选 |
| | | pickerOptionsEnd: { |
| | | disabledDate: (time) => { |
| | | return time.getTime() < this.form.enterProjectTime |
| | | return _this.form.enterProjectTime != null && _this.form.enterProjectTime !== '' ? time.getTime() < new Date(_this.form.enterProjectTime).getTime() - (86400000 - 1) : false |
| | | } |
| | | } |
| | | }, |
| | | // 表单禁用标记(承认状态) |
| | | disabledFlagByApprove: false |
| | | } |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 判断传参是否为空 |
| | | if (this.$route.params.projectId != null && this.$route.params.projectId !== '' && this.crud.query.projectId === undefined) { |
| | | // 检索条件赋值 |
| | | this.$set(this.crud.query, 'projectId', Number(this.$route.params.projectId)) |
| | | } |
| | | // 获取用户列表 |
| | | this.getUserList() |
| | | // 获取项目列表 |
| | | this.getProjectList() |
| | | return true |
| | | }, |
| | | // 新增与编辑前做的操作 |
| | | [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() |
| | | }, |
| | | // 获取用户列表 |
| | | getUserList() { |
| | | // 获取用户列表 |
| | | crudUser.getAll().then(res => { |
| | | // 用户列表 |
| | | this.userList = res |
| | | }).catch(() => { |
| | | |
| | | }) |
| | | }, |
| | | // 获取项目列表 |
| | | getProjectList() { |
| | | // 获取项目列表 |
| | | crudProject.getAll().then(res => { |
| | | // 项目列表 |
| | | this.projectList = res |
| | | }) |
| | | }, |
| | | timeChange() { |
| | | if (this.form.enterProjectTime != null && this.form.exitProjectTime != null) { |
| | | this.getProjectCost() |
| | | } |
| | | }, |
| | | // 获取项目成本 |
| | | getProjectCost() { |
| | | if (this.form.userId != null) { |
| | | // 判断所属员工、进入项目时间、离开项目时间是否为空 |
| | | if (this.form.userId != null && this.form.enterProjectTime != null && this.form.exitProjectTime != null) { |
| | | // 获取项目成本 |
| | | crudProjectCost.getCost({ |
| | | userId: this.form.userId, |
| | | enterProjectTime: this.form.enterProjectTime, |
| | | exitProjectTime: this.form.exitProjectTime |
| | | }).then(res => { |
| | | // 项目成本 |
| | | this.form.projectCost = res.projectCost |
| | | // 随机数 |
| | | this.random = Math.random() |
| | | }) |
| | | } |