myAchievement.vue 20.2 KB
Newer Older
huyf's avatar
huyf committed
1 2 3 4 5
<template>
  <div class="app-container">

    <!-- 搜索工作栏 -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
dragondean@qq.com's avatar
dragondean@qq.com committed
6
      <el-form-item :label="$t('关键字')" prop="key">
7
        <el-input v-model="queryParams.key" :placeholder="$t('请输入关键字查找')" clearable/>
8
      </el-form-item>
9
      <el-form-item :label="$t('运输方式')" prop="transportType">
10
        <dict-selector :type="DICT_TYPE.ECW_TRANSPORT_TYPE" v-model="queryParams.transportType" formatter="number" clearable/>
huyf's avatar
huyf committed
11
      </el-form-item>
dragondean@qq.com's avatar
dragondean@qq.com committed
12
      <el-form-item :label="$t('唛头')" prop="marks">
13
        <el-input v-model="queryParams.marks" :placeholder="$t('请输入关键字查找')" clearable />
huyf's avatar
huyf committed
14
      </el-form-item>
15
      <el-form-item :label="$t('资源类型')" prop="customerType">
dragondean@qq.com's avatar
dragondean@qq.com committed
16
        <!-- <el-select clearable  v-model="queryParams.customerType" :placeholder="$t('请选择资源类型')" clearable size="small">
17 18
         <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_ESOURCE_TYPE)"
                :key="dict.value" :label="dict.label" :value="dict.value"/>
dragondean@qq.com's avatar
dragondean@qq.com committed
19 20
         </el-select> -->
        <dict-selector :type="DICT_TYPE.CUSTOMER_ESOURCE_TYPE" v-model="queryParams.customerType" :placeholder="$t('请选择资源类型')" clearable ></dict-selector>
21 22 23 24 25 26 27 28 29
      </el-form-item>
<!--      <el-form-item :label="$t('客户经理')" prop="customerService">
        <el-select clearable  v-model="queryParams.customerService" :placeholder="$t('请选择客户经理')" clearable size="small">
          <el-option v-for="dict in customerServiceList"
                     :key="dict.id" :label="dict.nickname" :value="dict.id"/>
        </el-select>
      </el-form-item> -->
 <!--     <el-form-item prop="customerService">
        <el-select clearable  v-model="queryParams.customerService"  clearable size="small">
Marcus's avatar
Marcus committed
30 31
          <el-option :label="$t('下单时间')" value="createTime"/>
          <el-option :label="$t('装柜时间')" value="ldBoxTime"/>
32 33
        </el-select>
      </el-form-item> -->
dragondean@qq.com's avatar
dragondean@qq.com committed
34
      <el-form-item prop="dateFilter">
35
        <el-date-picker v-model="dateFilter"  type="datetimerange" range-separator="-"  :start-placeholder="$t('开始日期')" :end-placeholder="$t('结束日期')" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
huyufeng's avatar
huyufeng committed
36
<!--        <el-date-picker v-model="queryParams.beginStartTime" :placeholder="$t('请选择开始时间')" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>-->
huyf's avatar
huyf committed
37
      </el-form-item>
huyufeng's avatar
huyufeng committed
38 39 40
<!--      <el-form-item :label="$t('结束时间')" prop="endStartTime">-->
<!--        <el-date-picker v-model="queryParams.endStartTime" :placeholder="$t('请选择结束时间')" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>-->
<!--      </el-form-item>-->
huyf's avatar
huyf committed
41
      <el-form-item>
42
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">{{$t('搜索')}}</el-button>
43
        <el-button type="primary" icon="el-icon-search" @click="resetQuery">{{$t('重置')}}</el-button>
44 45
<!--        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
                  >{{$t('导出')}}</el-button> -->
huyf's avatar
huyf committed
46 47
      </el-form-item>
    </el-form>
48
    <div class="total_num">
Marcus's avatar
Marcus committed
49
      <span>{{ $t('开发客户:') }}</span>
dragondean@qq.com's avatar
dragondean@qq.com committed
50 51 52
      <span>{{$t('总箱数')}} {{totalData.developNum}}{{$t('')}} </span>
      <span>{{$t('总方数')}} {{totalData.developVolume}}</span>
      <span>{{$t('总重量')}} {{totalData.developWeight}}KG </span>
Marcus's avatar
Marcus committed
53
      <span>{{ $t('公司客户:') }}</span>
dragondean@qq.com's avatar
dragondean@qq.com committed
54 55 56
      <span>{{$t('总箱数')}} {{totalData.companyNum}}{{$t('')}} </span>
      <span>{{$t('总方数')}} {{totalData.companyVolume}}</span>
      <span>{{$t('总重量')}} {{totalData.companyWeight}}KG </span>
Marcus's avatar
Marcus committed
57
      <span>{{ $t('汇总:') }}</span>
dragondean@qq.com's avatar
dragondean@qq.com committed
58 59 60
      <span>{{$t('总箱数')}} {{totalData.sumNum}}{{$t('')}} </span>
      <span>{{$t('总方数')}} {{totalData.sumVolume}}</span>
      <span>{{$t('总重量')}} {{totalData.sumWeight}}KG </span>
61
    </div>
huyf's avatar
huyf committed
62
    <!-- 列表 -->
63 64 65 66 67 68 69 70 71 72 73
    <el-table v-loading="loading" :data="list"  @selection-change="handleSelectionChange">
      <!-- <el-table-column :label="$t('序号')" align="center" type="index"></el-table-column> -->
      <el-table-column
        type="selection"
        width="55">
      </el-table-column>
         <el-table-column :label="$t('资源类型')" align="center">
            <template slot-scope="scope">
              <dict-tag :type="DICT_TYPE.CUSTOMER_ESOURCE_TYPE" :value="scope.row.customerType"/>
            </template>
          </el-table-column>
74
      <el-table-column :label="$t('报价单号')" align="center" width="180">
huyf's avatar
huyf committed
75
        <template slot-scope="scope">
76
          <span>{{scope.row.number}}</span>
huyf's avatar
huyf committed
77 78
        </template>
      </el-table-column>
79
<!--      <el-table-column :label="$t('报价结果')" align="center">
huyf's avatar
huyf committed
80
        <template slot-scope="scope">
huyf's avatar
huyf committed
81
          <dict-tag :type="DICT_TYPE.ECW_OFFER_STATUS" :value="scope.row.offerStatus"/>
huyf's avatar
huyf committed
82
        </template>
83
      </el-table-column> -->
huyufeng's avatar
huyufeng committed
84
      <el-table-column :label="$t('订单号')" align="center" prop="orderNo"/>
85 86
      <el-table-column :label="$t('客户名称')" align="center" prop="name"/>
      <el-table-column :label="$t('联系方式')" align="center" prop="phoneNew"/>
87
      <el-table-column :label="$t('唛头')" align="center" prop="marks"/>
88 89 90 91 92
      <el-table-column :label="$t('订单状态')" align="center">
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.ORDER_STATUS" :value="scope.row.status"/>
        </template>
      </el-table-column>
93
      <el-table-column :label="$t('是否控货')" align="center" prop="isCargoControl">
huyf's avatar
huyf committed
94
        <template slot-scope="scope">
95
          {{scope.row.isCargoControl?$t(''):$t('')}}
huyf's avatar
huyf committed
96 97
        </template>
      </el-table-column>
98 99
      <el-table-column :label="$t('重量')" align="center" prop="completeWeight"/>
      <el-table-column :label="$t('方数')" align="center" prop="completeVolume"/>
100
      <el-table-column :label="$t('下单时间')" align="center" prop="createTime"/>
101 102
      <el-table-column :label="$t('装柜时间')" align="center" prop="ldBoxTime"/>
      <el-table-column :label="$t('客户经理')" align="center" prop="userId" :formatter="customerServiceFn">
huyf's avatar
huyf committed
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>
  </div>
</template>

<script>
    import {
        createDeptTarget,
        updateDeptTarget,
        deleteDeptTarget,
        getDeptTarget,
        getDeptTargetPage,
        exportDeptTargetExcel,
        getCreateInitData,
huyufeng's avatar
huyufeng committed
120 121
        getPersonTargetPage,
        myAchievementByPage
huyf's avatar
huyf committed
122 123 124 125
    } from "@/api/ecw/deptTarget";
    import {listSimpleDepts} from "@/api/system/dept";
    import {getChannelList} from '@/api/ecw/channel';
    import dayjs from "dayjs";
126
    import {listServiceUser} from "@/api/system/user";
huyf's avatar
huyf committed
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146

    export default {
        name: "DeptTarget",
        components: {},
        data() {
            return {
                // 遮罩层
                loading: true,
                // 导出遮罩层
                exportLoading: false,
                // 显示搜索条件
                showSearch: true,
                // 总条数
                total: 0,
                tableTotal: 0,
                // 部门业绩目标设置列表
                list: [],
                tableList: [],
                // 弹出层标题
                title: "",
huyufeng's avatar
huyufeng committed
147
              dateFilter:[],
huyf's avatar
huyf committed
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
                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,
huyufeng's avatar
huyufeng committed
172
                  beginStartTime:null,
huyf's avatar
huyf committed
173 174
                    transportType: null,
                    shippingChannel: null,
huyufeng's avatar
huyufeng committed
175
                  endStartTime: null,
huyf's avatar
huyf committed
176 177 178 179 180 181 182 183
                },
                tableQueryParams: {
                    pageNo: 1,
                    pageSize: 10,
                    id: null,
                },
                // 表单参数
                form: {},
184
                 customerServiceList:[],
huyf's avatar
huyf committed
185 186
                // 表单校验
                rules: {
187 188 189
                    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"}],
190 191 192 193 194 195 196 197 198 199 200 201 202
                },
                totalData:{
                    companyWeight:0,
                    companyVolume:0,
                    companyNum:0,
                    developWeight:0,
                    developVolume:0,
                    developNum:0,
                    sumWeight:0,
                    sumVolume:0,
                    sumNum:0,
                },
                myAchievementData:{}
huyf's avatar
huyf committed
203 204 205 206 207 208 209 210
            };
        },
        computed: {
            getShipChannelName() {
                return shippingChannelId => {
                    for (let index in this.channelList) {
                        let channelItem = this.channelList[index];
                        if (channelItem.channelId == shippingChannelId) {
211
                            return this.$l(channelItem, 'name');
huyf's avatar
huyf committed
212 213 214 215 216 217 218 219 220
                        }
                    }
                    return '/'
                }
            }
        },
        created() {
            this.getChannelList();
            this.getList();
221 222 223
            listServiceUser().then(r=>{
              this.customerServiceList = r.data;
            })
huyf's avatar
huyf committed
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
        },
        methods: {
            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;
                    }
                })
            },
252 253 254 255 256 257 258 259
            customerServiceFn(val){
              if(this.customerServiceList.length > 0){
                let index =this.customerServiceList.findIndex(item => item.id === val.userId);
                return index !== -1  ? this.customerServiceList[index]?.nickname :''
              }else {
                return ''
              }
            },
huyf's avatar
huyf committed
260 261 262 263
            /** 查询列表 */
            getList() {
                this.loading = true;
                // 执行查询
huyufeng's avatar
huyufeng committed
264
              myAchievementByPage(this.queryParams).then(response => {
265 266 267 268 269 270
                    this.list = response.data.myAchievementDtos.list;
                    this.total = response.data.myAchievementDtos.total;
                    this.myAchievementData = response.data
                    this.totalData.sumWeight =this.myAchievementData.totalWeight
                    this.totalData.sumVolume =this.myAchievementData.totalVolume
                    this.totalData.sumNum =this.myAchievementData.totalNum
我在何方's avatar
我在何方 committed
271 272 273 274 275
                    this.totalData.companyWeight =this.myAchievementData.companyTotalWeight
                    this.totalData.companyVolume =this.myAchievementData.companyTotalVolume
                    this.totalData.companyNum =this.myAchievementData.companyTotalNum
                    this.totalData.developWeight =this.myAchievementData.devTotalWeight
                    this.totalData.developVolume =this.myAchievementData.devTotalVolume
276
                    this.totalData.developNum =this.myAchievementData.devTotalNum
huyf's avatar
huyf committed
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
                    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;
huyufeng's avatar
huyufeng committed
303 304
                this.queryParams.beginStartTime=this.dateFilter[0];
                this.queryParams.endStartTime=this.dateFilter[1];
huyf's avatar
huyf committed
305

huyf's avatar
huyf committed
306 307 308 309
                this.getList();
            },
            /** 重置按钮操作 */
            resetQuery() {
310
                this.dateFilter = []
huyf's avatar
huyf committed
311 312 313 314 315 316 317 318 319 320 321
                this.dateRangeCreateTime = [];
                this.dateRangeStartTime = [];
                this.dateRangeEndTime = [];
                this.resetForm("queryForm");
                this.handleQuery();
            },
            /** 新增按钮操作 */
            handleAdd() {
                this.targetPeriod = this.monthList;
                this.reset();
                this.open = true;
322
                this.title = this.$t("添加部门业绩目标设置");
huyf's avatar
huyf committed
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
            },
            /** 查看人员目标情况 */
            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;
351
                    this.title = this.$t("修改部门业绩目标设置");
huyf's avatar
huyf committed
352 353 354 355 356 357 358 359 360 361 362
                });
            },
            /** 提交按钮 */
            submitForm() {
                this.$refs["form"].validate(valid => {
                    if (!valid) {
                        return;
                    }
                    // 修改的提交
                    if (this.form.id != null) {
                        updateDeptTarget(this.form).then(response => {
363
                            this.$modal.msgSuccess(this.$t("修改成功"));
huyf's avatar
huyf committed
364 365 366 367 368 369 370
                            this.open = false;
                            this.getList();
                        });
                        return;
                    }
                    // 添加的提交
                    createDeptTarget(this.form).then(response => {
371
                        this.$modal.msgSuccess(this.$t("新增成功"));
huyf's avatar
huyf committed
372 373 374 375 376 377 378 379
                        this.open = false;
                        this.getList();
                    });
                });
            },
            /** 删除按钮操作 */
            handleDelete(row) {
                const id = row.id;
380
                this.$modal.confirm(this.$t('是否确认删除部门业绩目标设置编号为{id}的数据项?', {id})).then(function () {
huyf's avatar
huyf committed
381 382 383
                    return deleteDeptTarget(id);
                }).then(() => {
                    this.getList();
384
                    this.$modal.msgSuccess(this.$t("删除成功"));
huyf's avatar
huyf committed
385 386 387
                }).catch(() => {
                });
            },
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
            handleSelectionChange(val){
              if(val&&val.length>0){
                var data={
                    companyWeight:0,
                    companyVolume:0,
                    companyNum:0,
                    developWeight:0,
                    developVolume:0,
                    developNum:0,
                    sumWeight:0,
                    sumVolume:0,
                    sumNum:0,
                }
                val.forEach(item=>{
                  if(item.customerType==1){
                    data.developWeight += item.completeWeight
404 405
                    data.developVolume += item.completeVolume
                    data.developNum += item.sumNum
406 407 408 409 410 411 412 413 414
                  }else{
                      data.companyWeight += item.completeWeight
                      data.companyVolume += item.completeVolume
                      data.companyNum += item.sumNum
                  }
                  data.sumWeight += item.completeWeight
                  data.sumVolume += item.completeVolume
                  data.sumNum += item.sumNum
                })
huyf's avatar
huyf committed
415 416 417
                  data.developVolume = data.developVolume.toFixed(2);
                  data.companyVolume = data.companyVolume.toFixed(2);
                  data.sumVolume = data.sumVolume.toFixed(2);
418 419 420 421 422
                this.$set(this,'totalData',data)
              }else{
                    this.totalData.sumWeight =this.myAchievementData.totalWeight
                    this.totalData.sumVolume =this.myAchievementData.totalVolume
                    this.totalData.sumNum =this.myAchievementData.totalNum
我在何方's avatar
我在何方 committed
423 424 425 426 427
                    this.totalData.companyWeight =this.myAchievementData.companyTotalWeight
                    this.totalData.companyVolume =this.myAchievementData.companyTotalVolume
                    this.totalData.companyNum =this.myAchievementData.companyTotalNum
                    this.totalData.developWeight =this.myAchievementData.devTotalWeight
                    this.totalData.developVolume =this.myAchievementData.devTotalVolume
428
                    this.totalData.developNum =this.myAchievementData.devTotalNum
429 430
              }
            },
huyf's avatar
huyf committed
431 432 433 434 435 436 437 438 439 440
            /** 导出按钮操作 */
            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');
                // 执行导出
441
                this.$modal.confirm(this.$t('是否确认导出所有部门业绩目标设置数据项?')).then(() => {
huyf's avatar
huyf committed
442 443 444
                    this.exportLoading = true;
                    return exportDeptTargetExcel(params);
                }).then(response => {
445 446
                    this.$download.excel(response, `${this.$t('我的业绩')}.xls`);

huyf's avatar
huyf committed
447 448 449 450 451 452 453
                    this.exportLoading = false;
                }).catch(() => {
                });
            }
        }
    };
</script>
454 455 456 457 458 459 460 461 462 463 464 465 466 467


<style scoped >
  .total_num{
    display:flex;
    align-items: center;
    justify-content: center;
    margin:20px 0;
    font-size:15px;
  }
  .total_num span{
    margin: 0 8px;
  }
</style>