empAchievement.vue 12.7 KB
Newer Older
lanbaoming's avatar
lanbaoming committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
<template>
  <div class="app-container">
    <!--人员目标进度-->
      <el-card class="card">
        <div slot="header" class="card-title">
          {{$t('人员目标进度')}}
        </div>
        <el-form>
          <el-form-item>
            {{detail.deptName}}-{{getDictDataLabel(DICT_TYPE.TARGET_TYPE,detail.targetType)}}
          </el-form-item>
          <el-form-item :label="$t('运输方式')">{{getDictDataLabel(DICT_TYPE.TRANSPORT_TYPE,detail.transportType)}}</el-form-item>
          <el-form-item :label="$t('出货渠道')">{{ getShipChannelName(detail.shippingChannel) }}</el-form-item>
          <el-form-item :label="$t('部门目标')">{{detail.cubeNum}}</el-form-item>
        </el-form>
      </el-card>
    <el-card class="card">
      <el-table v-loading="loading" :data="tableList">
        <el-table-column :label="$t('员工名称')" align="center" width="180">
          <template slot-scope="scope">
            <span>{{scope.row.userName}}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('部门')" align="center">
          <template>
            <span>{{detail.deptName}}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('目标类型')" align="center" prop="targetType">
          <template slot-scope="scope">
            <dict-tag :type="DICT_TYPE.TARGET_TYPE" :value="scope.row.targetType"/>
          </template>
        </el-table-column>
        <el-table-column :label="$t('时间范围')" align="center" prop="targetPeriodName">
          <template slot-scope="scope">
            <span>{{dateFormat(scope.row.startTime)}}~{{dateFormat(scope.row.endTime)}}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('个人目标方数')" align="center" prop="personalCubeNum"/>
        <el-table-column :label="$t('已完成方数')" align="center" prop="personalCompleteCubeNum"/>
        <el-table-column :label="$t('完成比例')" align="center">
          <template slot-scope="scope">
            <span>{{ (scope.row.personalCompleteCubeNum/scope.row.personalCubeNum*100).toFixed(2)+'%' }}</span>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
      <!-- 分页组件 -->
      <pagination v-show="tableTotal > 0" :total="tableTotal" :page.sync="tableQueryParams.pageNo"
                  :limit.sync="tableQueryParams.pageSize"
                  @pagination="getTableList"/>
  </div>
</template>

<script>
    import {
        createDeptTarget,
        updateDeptTarget,
        deleteDeptTarget,
        getDeptTarget,
        getDeptTargetPage,
        exportDeptTargetExcel,
        getCreateInitData,
        getPersonTargetPage,
        myAchievementByPage
    } from "@/api/ecw/deptTarget";
    import {listSimpleDepts} from "@/api/system/dept";
    import {getChannelList} from '@/api/ecw/channel';
    import dayjs from "dayjs";

    export default {
        name: "DeptTarget",
        components: {},
        data() {
            return {
                // 遮罩层
                loading: false,
                // 导出遮罩层
                exportLoading: false,
                // 显示搜索条件
                showSearch: true,
                // 总条数
                total: 0,
                tableTotal: 0,
                // 部门业绩目标设置列表
                list: [],
                tableList: [],
                // 弹出层标题
                title: "",
                detail: {
                    deptName: null,
                    targetType: null,
                    cubeNum: null,
                    shippingChannel: null,
                    transportType: null,
                },
                // 是否显示弹出层
                open: false,
                tableOpen: false,
                dateRangeCreateTime: [],
                dateRangeStartTime: [],
                dateRangeEndTime: [],
                deptData: [],
                deptArr: [],
                channelList: [],
                monthList: [],
                quarterList: [],
                yearList: [],
                targetPeriod: [],
                // 查询参数
                queryParams: {
                    pageNo: 1,
                    pageSize: 10,
                  beginStartTime:null,
                    transportType: null,
                    shippingChannel: null,
                  endStartTime: null,
                },
                tableQueryParams: {
                    pageNo: 1,
                    pageSize: 10,
                    id: null,
                },
                // 表单参数
                form: {},
                // 表单校验
                rules: {
                    deptId: [{required: true, message: this.$t("部门ID不能为空"), trigger: "blur"}],
                    targetType: [{required: true, message: this.$t("目标类型不能为空"), trigger: "change"}],
                    cubeNum: [{required: true, message: this.$t("立方数不能为空"), trigger: "blur"}],
                }
            };
        },
        computed: {
            getShipChannelName() {
                return shippingChannelId => {
                    for (let index in this.channelList) {
                        let channelItem = this.channelList[index];
                        if (channelItem.channelId == shippingChannelId) {
                            return this.$l(channelItem, 'name');
                        }
                    }
                    return '/'
                }
            }
        },
        created() {
            if (this.$route.query) {
                this.tableQueryParams.id = this.$route.query.row.id
                this.detail=this.$route.query.row
                this.getTableList();
                this.getChannelList();
            }
        },
        methods: {
            getTableList() {
                getPersonTargetPage(this.tableQueryParams).then(res => {
                    this.tableList = res.data.list;
                    this.tableTotal = res.data.total;
                });
            },
            getChannelList() {
                getChannelList().then(res => this.channelList = res.data)
            },
            dateFormat(val) {
                return dayjs(val).format("YYYY-MM-DD");
            },
            changeList(val) {
                if (val === 1) {
                    this.form.targetPeriodName = undefined;
                    this.targetPeriod = this.monthList;
                } else if (val === 2) {
                    this.form.targetPeriodName = undefined;
                    this.targetPeriod = this.quarterList;
                } else {
                    this.form.targetPeriodName = undefined;
                    this.targetPeriod = this.yearList;
                }
            },
            setTime(item) {
                this.targetPeriod.forEach((i, index) => {
                    if (i.name === item) {
                        this.form.startTime = i.startDate;
                        this.form.endTime = i.endDate;
                    }
                })
            },
            /** 查询列表 */
            getList() {
                this.loading = true;
                // 执行查询
              myAchievementByPage(this.queryParams).then(response => {
                    this.list = response.data.list;
                    this.total = response.data.total;
                    this.loading = false;
                });
            },
            /** 取消按钮 */
            cancel() {
                this.open = false;
                this.reset();
            },
            /** 表单重置 */
            reset() {
                this.form = {
                    id: undefined,
                    deptId: undefined,
                    targetType: undefined,
                    targetPeriodName: undefined,
                    startTime: undefined,
                    endTime: undefined,
                    transportType: undefined,
                    shippingChannel: undefined,
                    cubeNum: undefined,
                };
                this.resetForm("form");
            },
            /** 搜索按钮操作 */
            handleQuery() {
                this.queryParams.pageNo = 1;
                this.getList();
            },
            /** 重置按钮操作 */
            resetQuery() {
                this.dateRangeCreateTime = [];
                this.dateRangeStartTime = [];
                this.dateRangeEndTime = [];
                this.resetForm("queryForm");
                this.handleQuery();
            },
            /** 新增按钮操作 */
            handleAdd() {
                this.targetPeriod = this.monthList;
                this.reset();
                this.open = true;
                this.title = this.$t("添加部门业绩目标设置");
            },
            /** 查看人员目标情况 */
            handleView(row) {
                this.detail = row;
                this.tableQueryParams.id = row.id;
                this.getTableList();
                this.tableOpen = true;
            },
            getTableList() {
                getPersonTargetPage(this.tableQueryParams).then(res => {
                    this.tableList = res.data.list;
                    this.tableTotal = res.data.total;
                });
            },
            /** 修改按钮操作 */
            handleUpdate(row) {
                this.reset();
                const id = row.id;
                getDeptTarget(id).then(response => {
                    this.form = response.data;
                    if (response.data.targetType === 1) {
                        this.targetPeriod = this.monthList;
                    } else if (response.data.targetType === 2) {
                        this.targetPeriod = this.quarterList;
                    } else {
                        this.targetPeriod = this.yearList;
                    }
                    this.open = true;
                    this.title = this.$t("修改部门业绩目标设置");
                });
            },
            /** 提交按钮 */
            submitForm() {
                this.$refs["form"].validate(valid => {
                    if (!valid) {
                        return;
                    }
                    // 修改的提交
                    if (this.form.id != null) {
                        updateDeptTarget(this.form).then(response => {
                            this.$modal.msgSuccess(this.$t("修改成功"));
                            this.open = false;
                            this.getList();
                        });
                        return;
                    }
                    // 添加的提交
                    createDeptTarget(this.form).then(response => {
                        this.$modal.msgSuccess(this.$t("新增成功"));
                        this.open = false;
                        this.getList();
                    });
                });
            },
            /** 删除按钮操作 */
            handleDelete(row) {
                const id = row.id;
                this.$modal.confirm(this.$t('是否确认删除部门业绩目标设置编号为{id}的数据项?', {id})).then(function () {
                    return deleteDeptTarget(id);
                }).then(() => {
                    this.getList();
                    this.$modal.msgSuccess(this.$t("删除成功"));
                }).catch(() => {
                });
            },
            /** 导出按钮操作 */
            handleExport() {
                // 处理查询参数
                let params = {...this.queryParams};
                params.pageNo = undefined;
                params.pageSize = undefined;
                this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
                this.addBeginAndEndTime(params, this.dateRangeStartTime, 'startTime');
                this.addBeginAndEndTime(params, this.dateRangeEndTime, 'endTime');
                // 执行导出
                this.$modal.confirm(this.$t('是否确认导出所有部门业绩目标设置数据项?')).then(() => {
                    this.exportLoading = true;
                    return exportDeptTargetExcel(params);
                }).then(response => {
                    this.$download.excel(response, '${table.classComment}.xls');
                    this.exportLoading = false;
                }).catch(() => {
                });
            }
        }
    };
</script>
<style scoped>
  .card {
    margin-bottom: 20px;
  }
  .card-title{
    font-size: 18px;
    font-weight: bold;
  }

  .el-dropdown-link {
    cursor: pointer;
    color: #409EFF;
  }

  .el-icon-arrow-down {
    font-size: 12px;
  }

  .el-form-item {
    margin-bottom: 0px;
  }
</style>