myDeptAchievement.vue 21 KB
Newer Older
lanbaoming's avatar
lanbaoming committed
1 2 3
<template>
  <div class="app-container">
    <!-- 搜索工作栏 -->
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
4 5 6 7 8 9 10 11
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
lanbaoming's avatar
lanbaoming committed
12
      <el-form-item :label="$t('关键字')" prop="key">
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
13 14 15 16
        <el-input
          v-model="queryParams.key"
          :placeholder="$t('请输入关键字查找')"
        />
lanbaoming's avatar
lanbaoming committed
17 18
      </el-form-item>
      <el-form-item :label="$t('运输方式')" prop="transportType">
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
19 20 21 22 23
        <dict-selector
          :type="DICT_TYPE.ECW_TRANSPORT_TYPE"
          v-model="queryParams.transportType"
          formatter="number"
        />
lanbaoming's avatar
lanbaoming committed
24 25
      </el-form-item>
      <el-form-item :label="$t('唛头')" prop="marks">
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
26 27 28 29
        <el-input
          v-model="queryParams.marks"
          :placeholder="$t('请输入关键字查找')"
        />
lanbaoming's avatar
lanbaoming committed
30 31 32 33 34 35
      </el-form-item>
      <el-form-item :label="$t('资源类型')" prop="customerType">
        <!-- <el-select clearable  v-model="queryParams.customerType" :placeholder="$t('请选择资源类型')" clearable size="small">
         <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_ESOURCE_TYPE)"
                :key="dict.value" :label="dict.label" :value="dict.value"/>
         </el-select> -->
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
36 37 38 39 40 41
        <dict-selector
          :type="DICT_TYPE.CUSTOMER_ESOURCE_TYPE"
          v-model="queryParams.customerType"
          :placeholder="$t('请选择资源类型')"
          clearable
        ></dict-selector>
lanbaoming's avatar
lanbaoming committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55
      </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">
               <el-option :label="$t('下单时间')" value="createTime"/>
               <el-option :label="$t('装柜时间')" value="ldBoxTime"/>
             </el-select>
           </el-form-item> -->
      <el-form-item>
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
56 57 58 59 60 61 62 63
        <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>
lanbaoming's avatar
lanbaoming committed
64 65 66 67 68 69 70
        <!--        <el-date-picker v-model="queryParams.beginStartTime" :placeholder="$t('请选择开始时间')" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>-->
      </el-form-item>
      <!--      <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>-->
      <el-form-item>
        <el-form-item :label="$t('报价单号')" prop="key">
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
71 72 73 74 75
          <el-input
            v-model="queryParams.number"
            :placeholder="$t('请输入报价单号')"
            clearable
          />
lanbaoming's avatar
lanbaoming committed
76 77
        </el-form-item>
        <el-form-item :label="$t('客户名称')" prop="key">
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
78 79 80 81 82
          <el-input
            v-model="queryParams.name"
            :placeholder="$t('请输入客户名称')"
            clearable
          />
lanbaoming's avatar
lanbaoming committed
83 84
        </el-form-item>
        <el-form-item :label="$t('联系方式')" prop="key">
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
85 86 87 88 89
          <el-input
            v-model="queryParams.phoneNew"
            :placeholder="$t('请输入联系方式')"
            clearable
          />
lanbaoming's avatar
lanbaoming committed
90 91
        </el-form-item>
        <el-form-item :label="$t('客户经理')" prop="userId">
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
92 93 94 95 96 97 98 99 100 101 102 103 104
          <el-select
            clearable
            v-model="queryParams.userId"
            :placeholder="$t('请选择客户经理')"
            clearable
            size="small"
          >
            <el-option
              v-for="dict in customerServiceList"
              :key="dict.id"
              :label="dict.nickname"
              :value="dict.id"
            />
lanbaoming's avatar
lanbaoming committed
105 106 107
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('始发仓')" prop="startWarehouseId">
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
108 109 110 111 112 113 114 115 116 117 118
          <el-select
            v-model="queryParams.startWarehouseId"
            :placeholder="$t('请选择始发仓')"
            clearable
          >
            <el-option
              v-for="item in exportWarehouseList"
              :label="$l(item, 'title')"
              :value="item.id"
              :key="item.id"
            ></el-option>
lanbaoming's avatar
lanbaoming committed
119 120 121
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('目的仓')" prop="destWarehouseIdArr">
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
122 123 124 125 126 127 128 129 130 131 132 133 134
          <el-select
            :multiple="true"
            v-model="queryParams.destWarehouseIdArr"
            multiple
            :placeholder="$t('请选择目的仓')"
            clearable
          >
            <el-option
              v-for="item in importWarehouseList"
              :label="$l(item, 'title')"
              :value="item.id"
              :key="item.id"
            ></el-option>
lanbaoming's avatar
lanbaoming committed
135 136 137 138 139 140 141 142
          </el-select>
        </el-form-item>
        <el-form-item label="业绩类型">
          <el-select clearable v-model="queryParams.achieveType">
            <el-option :value="1" label="新客户"></el-option>
            <el-option :value="0" label="旧客户"></el-option>
          </el-select>
        </el-form-item>
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
143 144 145 146 147 148
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">{{
          $t("搜索")
        }}</el-button>
        <el-button type="primary" icon="el-icon-search" @click="resetQuery">{{
          $t("重置")
        }}</el-button>
lanbaoming's avatar
lanbaoming committed
149 150 151 152 153 154
        <!--        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
                          >{{$t('导出')}}</el-button> -->
      </el-form-item>
    </el-form>
    <total_num :total-data="totalData"></total_num>
    <!-- 列表 -->
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
155 156 157 158 159
    <el-table
      v-loading="loading"
      :data="list"
      @selection-change="handleSelectionChange"
    >
lanbaoming's avatar
lanbaoming committed
160
      <!-- <el-table-column :label="$t('序号')" align="center" type="index"></el-table-column> -->
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
161
      <el-table-column type="selection" width="55"> </el-table-column>
lanbaoming's avatar
lanbaoming committed
162 163
      <el-table-column :label="$t('资源类型')" align="center">
        <template slot-scope="scope">
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
164 165 166 167
          <dict-tag
            :type="DICT_TYPE.CUSTOMER_ESOURCE_TYPE"
            :value="scope.row.customerType"
          />
lanbaoming's avatar
lanbaoming committed
168 169
        </template>
      </el-table-column>
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
170 171 172 173 174
      <el-table-column
        :label="$t('业绩类型')"
        align="center"
        prop="achieveType"
      />
lanbaoming's avatar
lanbaoming committed
175 176 177 178 179 180 181 182 183 184
      <el-table-column :label="$t('报价单号')" align="center" width="180">
        <template slot-scope="scope">
          <span>{{ scope.row.number }}</span>
        </template>
      </el-table-column>
      <!--      <el-table-column :label="$t('报价结果')" align="center">
              <template slot-scope="scope">
                <dict-tag :type="DICT_TYPE.ECW_OFFER_STATUS" :value="scope.row.offerStatus"/>
              </template>
            </el-table-column> -->
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
185 186 187 188 189 190 191 192 193 194 195 196 197 198
      <el-table-column :label="$t('订单号')" align="center" prop="orderNo" />
      <el-table-column :label="$t('客户名称')" align="center" prop="name" />
      <el-table-column :label="$t('联系方式')" align="center" prop="phoneNew" />
      <el-table-column :label="$t('唛头')" align="center" prop="marks" />
      <el-table-column
        :label="$t('订单状态')"
        align="center"
        prop="statusMsg"
      />
      <el-table-column
        :label="$t('是否控货')"
        align="center"
        prop="isCargoControl"
      >
lanbaoming's avatar
lanbaoming committed
199
        <template slot-scope="scope">
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
200
          {{ scope.row.isCargoControl ? $t("") : $t("") }}
lanbaoming's avatar
lanbaoming committed
201 202
        </template>
      </el-table-column>
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
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
      <el-table-column
        :label="$t('重量')"
        align="center"
        prop="completeWeight"
      />
      <el-table-column
        :label="$t('方数')"
        align="center"
        prop="completeVolume"
      />
      <el-table-column
        :label="$t('下单时间')"
        align="center"
        prop="createTime"
      />
      <el-table-column
        :label="$t('业绩创建时间')"
        align="center"
        prop="ldBoxTime"
      />
      <el-table-column
        :label="$t('客户经理')"
        align="center"
        prop="userId"
        :formatter="customerServiceFn"
      >
lanbaoming's avatar
lanbaoming committed
229 230 231
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
232 233 234 235 236 237 238
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
lanbaoming's avatar
lanbaoming committed
239 240 241 242 243 244 245 246 247 248 249 250 251 252
  </div>
</template>

<script>
import {
  createDeptTarget,
  updateDeptTarget,
  deleteDeptTarget,
  getDeptTarget,
  getDeptTargetPage,
  exportDeptTargetExcel,
  getCreateInitData,
  getPersonTargetPage,
  myAchievementByPage,
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
253
  myDeptAchievementByPage,
lanbaoming's avatar
lanbaoming committed
254
} from "@/api/ecw/deptTarget";
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
255 256
import { listSimpleDepts } from "@/api/system/dept";
import { getChannelList } from "@/api/ecw/channel";
lanbaoming's avatar
lanbaoming committed
257
import dayjs from "dayjs";
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
258 259
import { listServiceUser } from "@/api/system/user";
import { getWarehouseList } from "@/api/ecw/warehouse";
lanbaoming's avatar
lanbaoming committed
260 261 262 263
import Total_num from "@/views/ecw/deptTarget/total_num.vue";

export default {
  name: "EcwDepttargetMydeptachievement",
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
264
  components: { Total_num },
lanbaoming's avatar
lanbaoming committed
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
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      tableTotal: 0,
      // 部门业绩目标设置列表
      list: [],
      tableList: [],
      // 弹出层标题
      title: "",
      dateFilter: [],
      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,
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
310
        destWarehouseIdArr: [],
lanbaoming's avatar
lanbaoming committed
311 312 313 314 315 316 317 318 319 320 321
      },
      tableQueryParams: {
        pageNo: 1,
        pageSize: 10,
        id: null,
      },
      // 表单参数
      form: {},
      customerServiceList: [],
      // 表单校验
      rules: {
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
        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",
          },
        ],
lanbaoming's avatar
lanbaoming committed
343 344 345 346 347 348 349 350 351 352 353 354 355
      },
      totalData: {
        companyWeight: 0,
        companyVolume: 0,
        companyNum: 0,
        developWeight: 0,
        developVolume: 0,
        developNum: 0,
        sumWeight: 0,
        sumVolume: 0,
        sumNum: 0,
      },
      myAchievementData: {},
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
356
      warehouseList: [],
lanbaoming's avatar
lanbaoming committed
357 358 359 360
    };
  },
  computed: {
    getShipChannelName() {
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
361
      return (shippingChannelId) => {
lanbaoming's avatar
lanbaoming committed
362 363 364
        for (let index in this.channelList) {
          let channelItem = this.channelList[index];
          if (channelItem.channelId == shippingChannelId) {
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
365
            return this.$l(channelItem, "name");
lanbaoming's avatar
lanbaoming committed
366 367
          }
        }
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
368 369
        return "/";
      };
lanbaoming's avatar
lanbaoming committed
370 371 372
    },
    exportWarehouseList() {
      /* tradeType 1 进口,2出口,3进出口 */
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
373 374 375
      return this.warehouseList.filter(
        (item) => item.tradeType == 2 || item.tradeType == 3
      );
lanbaoming's avatar
lanbaoming committed
376 377
    },
    importWarehouseList() {
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
378 379 380
      return this.warehouseList.filter(
        (item) => item.tradeType == 1 || item.tradeType == 3
      );
lanbaoming's avatar
lanbaoming committed
381 382 383 384 385
    },
  },
  created() {
    this.getChannelList();
    this.getList();
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
386
    listServiceUser().then((r) => {
lanbaoming's avatar
lanbaoming committed
387
      this.customerServiceList = r.data;
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
388 389 390 391
    });
    getWarehouseList().then((res) => {
      this.warehouseList = res.data;
    });
lanbaoming's avatar
lanbaoming committed
392 393 394
  },
  methods: {
    getChannelList() {
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
395
      getChannelList().then((res) => (this.channelList = res.data));
lanbaoming's avatar
lanbaoming committed
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
    },
    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;
        }
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
418
      });
lanbaoming's avatar
lanbaoming committed
419 420 421
    },
    customerServiceFn(val) {
      if (this.customerServiceList.length > 0) {
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
422 423 424 425
        let index = this.customerServiceList.findIndex(
          (item) => item.id === val.userId
        );
        return index !== -1 ? this.customerServiceList[index]?.nickname : "";
lanbaoming's avatar
lanbaoming committed
426
      } else {
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
427
        return "";
lanbaoming's avatar
lanbaoming committed
428 429 430 431 432
      }
    },
    /** 查询列表 */
    getList() {
      this.loading = true;
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
433
      const params = { ...this.queryParams };
lanbaoming's avatar
lanbaoming committed
434
      if (params.destWarehouseIdArr?.length) {
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
435
        params.destWarehouseIds = params.destWarehouseIdArr.join(",");
lanbaoming's avatar
lanbaoming committed
436 437
      }
      // 执行查询
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
438
      myDeptAchievementByPage(params).then((response) => {
lanbaoming's avatar
lanbaoming committed
439 440
        this.list = response.data.myAchievementDtos.list;
        this.total = response.data.myAchievementDtos.total;
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482
        this.myAchievementData = response.data;
        this.totalData.sumWeight = this.myAchievementData.totalWeight;
        this.totalData.sumVolume = this.myAchievementData.totalVolume;
        this.totalData.sumNum = this.myAchievementData.totalNum;
        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;
        this.totalData.developNum = this.myAchievementData.devTotalNum;
        this.$set(
          this.totalData,
          "newTotalNum",
          this.myAchievementData.newTotalNum
        );
        this.$set(
          this.totalData,
          "newTotalVolume",
          this.myAchievementData.newTotalVolume
        );
        this.$set(
          this.totalData,
          "newTotalWeight",
          this.myAchievementData.newTotalWeight
        );
        this.$set(
          this.totalData,
          "oldTotalNum",
          this.myAchievementData.oldTotalNum
        );
        this.$set(
          this.totalData,
          "oldTotalVolume",
          this.myAchievementData.oldTotalVolume
        );
        this.$set(
          this.totalData,
          "oldTotalWeight",
          this.myAchievementData.oldTotalWeight
        );
lanbaoming's avatar
lanbaoming committed
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502
        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,
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
503
        achieveType: undefined,
lanbaoming's avatar
lanbaoming committed
504 505 506 507 508 509 510 511 512 513 514 515
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.queryParams.beginStartTime = this.dateFilter[0];
      this.queryParams.endStartTime = this.dateFilter[1];
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
516 517
      this.queryParams = { pageNo: 1, pageSize: 10 };
      this.getList();
lanbaoming's avatar
lanbaoming committed
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
    },
    /** 新增按钮操作 */
    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() {
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
534
      getPersonTargetPage(this.tableQueryParams).then((res) => {
lanbaoming's avatar
lanbaoming committed
535 536 537 538 539 540 541 542
        this.tableList = res.data.list;
        this.tableTotal = res.data.total;
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id;
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
543
      getDeptTarget(id).then((response) => {
lanbaoming's avatar
lanbaoming committed
544 545 546 547 548 549 550 551 552 553 554 555 556 557
        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() {
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
558
      this.$refs["form"].validate((valid) => {
lanbaoming's avatar
lanbaoming committed
559 560 561 562 563
        if (!valid) {
          return;
        }
        // 修改的提交
        if (this.form.id != null) {
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
564
          updateDeptTarget(this.form).then((response) => {
lanbaoming's avatar
lanbaoming committed
565 566 567 568 569 570 571
            this.$modal.msgSuccess(this.$t("修改成功"));
            this.open = false;
            this.getList();
          });
          return;
        }
        // 添加的提交
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
572
        createDeptTarget(this.form).then((response) => {
lanbaoming's avatar
lanbaoming committed
573 574 575 576 577 578 579 580 581
          this.$modal.msgSuccess(this.$t("新增成功"));
          this.open = false;
          this.getList();
        });
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const id = row.id;
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
582 583 584 585 586 587 588 589 590 591 592 593
      this.$modal
        .confirm(
          this.$t("是否确认删除部门业绩目标设置编号为{id}的数据项?", { id })
        )
        .then(function () {
          return deleteDeptTarget(id);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess(this.$t("删除成功"));
        })
        .catch(() => {});
lanbaoming's avatar
lanbaoming committed
594 595 596 597 598 599 600 601 602 603 604 605 606
    },
    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,
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
607 608
        };
        val.forEach((item) => {
lanbaoming's avatar
lanbaoming committed
609
          if (item.customerType == 1) {
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
610 611 612
            data.developWeight += item.completeWeight;
            data.developVolume += item.completeVolume;
            data.developNum += item.sumNum;
lanbaoming's avatar
lanbaoming committed
613
          } else {
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
614 615 616
            data.companyWeight += item.completeWeight;
            data.companyVolume += item.completeVolume;
            data.companyNum += item.sumNum;
lanbaoming's avatar
lanbaoming committed
617
          }
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
618 619 620 621
          data.sumWeight += item.completeWeight;
          data.sumVolume += item.completeVolume;
          data.sumNum += item.sumNum;
        });
lanbaoming's avatar
lanbaoming committed
622 623 624
        data.developVolume = data.developVolume.toFixed(2);
        data.companyVolume = data.companyVolume.toFixed(2);
        data.sumVolume = data.sumVolume.toFixed(2);
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
625
        this.$set(this, "totalData", data);
lanbaoming's avatar
lanbaoming committed
626
      } else {
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
627 628 629 630 631 632 633 634 635 636 637
        this.totalData.sumWeight = this.myAchievementData.totalWeight;
        this.totalData.sumVolume = this.myAchievementData.totalVolume;
        this.totalData.sumNum = this.myAchievementData.totalNum;
        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;
        this.totalData.developNum = this.myAchievementData.devTotalNum;
lanbaoming's avatar
lanbaoming committed
638 639 640 641 642
      }
    },
    /** 导出按钮操作 */
    handleExport() {
      // 处理查询参数
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
643
      let params = { ...this.queryParams };
lanbaoming's avatar
lanbaoming committed
644 645
      params.pageNo = undefined;
      params.pageSize = undefined;
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
646 647 648
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, "createTime");
      this.addBeginAndEndTime(params, this.dateRangeStartTime, "startTime");
      this.addBeginAndEndTime(params, this.dateRangeEndTime, "endTime");
lanbaoming's avatar
lanbaoming committed
649
      // 执行导出
1483922988@qq.com's avatar
6  
1483922988@qq.com committed
650 651 652 653 654 655 656 657
      this.$modal
        .confirm(this.$t("是否确认导出所有部门业绩目标设置数据项?"))
        .then(() => {
          this.exportLoading = true;
          return exportDeptTargetExcel(params);
        })
        .then((response) => {
          this.$download.excel(response, `${this.$t("我的业绩")}.xls`);
lanbaoming's avatar
lanbaoming committed
658

1483922988@qq.com's avatar
6  
1483922988@qq.com committed
659 660 661 662 663
          this.exportLoading = false;
        })
        .catch(() => {});
    },
  },
lanbaoming's avatar
lanbaoming committed
664 665 666
};
</script>

1483922988@qq.com's avatar
6  
1483922988@qq.com committed
667
<style scoped></style>