12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001 |
- <template>
- <div class="app-container">
- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
- <el-form-item label="编码" prop="code">
- <el-input v-model="queryParams.code" placeholder="请输入编码" clearable @keyup.enter.native="handleQuery"/>
- </el-form-item>
- <el-form-item label="目标名称" prop="goalName">
- <el-input v-model="queryParams.goalName" placeholder="请输入目标名称" clearable @keyup.enter.native="handleQuery"/>
- </el-form-item>
- <el-form-item label="单据日期" prop="documentDate">
- <el-date-picker
- v-model="queryParams.documentDateRange"
- type="daterange"
- align="right"
- unlink-panels
- range-separator="至"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- value-format="yyyy-MM-dd"
- @keyup.enter.native="handleQuery"
- :picker-options="pickerOptions">
- </el-date-picker>
- </el-form-item>
- <el-form-item label="年度" prop="annual">
- <el-date-picker
- v-model="queryParams.annual"
- type="year"
- clearable
- value-format="yyyy"
- @keyup.enter.native="handleQuery"
- placeholder="请输入年度">
- </el-date-picker>
- </el-form-item>
- <el-form-item label="月份" prop="monthly">
- <el-date-picker
- v-model="queryParams.monthly"
- type="month"
- clearable
- value-format="M"
- @keyup.enter.native="handleQuery"
- placeholder="请输入月份">
- </el-date-picker>
- </el-form-item>
- <el-form-item label="制单人" prop="creator">
- <el-popover-select-v2 v-model="queryParams.creator" title="制单人" valueKey="name"
- referName="CONTACTS_PARAM"
- :dataMapping="{ creatorCode: 'code', creator: 'name'}"
- :source.sync="queryParams" placeholder="请输入制单人">
- </el-popover-select-v2>
- </el-form-item>
- <el-form-item label="部门" prop="dept">
- <el-popover-select-v2 v-model="queryParams.dept" title="部门" valueKey="name"
- referName="DEPT_PARAM"
- :dataMapping="{ deptCode: 'code', dept: 'name'}"
- :source.sync="queryParams" placeholder="请输入部门">
- </el-popover-select-v2>
- </el-form-item>
- <el-form-item label="目标类型" prop="goalCategory">
- <el-select v-model="queryParams.goalCategory" placeholder="请输入目标类型" @change="changeGoalCategoryQuery" @keyup.enter.native="handleQuery">
- <el-option
- v-for="item in goalCategoryList"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item v-if="queryParams.goalCategory === '客户维度'" label="客户" prop="custom">
- <el-popover-select-v2 v-model="queryParams.custom" title="客户" valueKey="name"
- referName="CUSTOMER_PARAM"
- :dataMapping="{ customCode: 'code', custom: 'name'}"
- :source.sync="queryParams" placeholder="请输入客户">
- </el-popover-select-v2>
- </el-form-item>
- <el-form-item v-if="queryParams.goalCategory === '销售区域'" label="销售区域" prop="saleZone">
- <el-popover-select-v2 v-model="queryParams.saleZoneCode" title="销售区域" valueKey="name"
- referName="DEPT_PARAM"
- :dataMapping="{ saleZoneCode: 'code', saleZone: 'name'}"
- :source.sync="queryParams" placeholder="请输入销售区域">
- </el-popover-select-v2>
- </el-form-item>
- <el-form-item v-if="queryParams.goalCategory === '一级分类'" label="一级分类" prop="oneLevelClassify">
- <el-select v-model="queryParams.oneLevelClassify" size="mini" clearable
- @focus="chooseTreeReferForQuery('MATERIALCLASSIFY_PARAM', false, '一级物料分类')"
- style="width: 200px">
- <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
- </el-select>
- </el-form-item>
- <el-form-item v-if="queryParams.goalCategory === '二级分类'" label="二级分类" prop="custom">
- <el-select v-model="queryParams.twoLevelClassify" size="mini" clearable
- @focus="chooseTreeReferForQuery('MATERIALCLASSIFY_PARAM', false, '二级物料分类')"
- style="width: 200px">
- <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
- </el-form-item>
- </el-form>
- <el-row :gutter="10" class="mb8">
- <el-col :span="1.5">
- <el-button
- type="primary"
- plain
- icon="el-icon-plus"
- size="mini"
- @click="handleAdd"
- v-hasPermi="['goal_management:monthGoalMerge:add']"
- >新增
- </el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="danger"
- plain
- icon="el-icon-delete"
- size="mini"
- :disabled="multiple"
- @click="handleDelete"
- v-hasPermi="['goal_management:monthGoalMerge:remove']"
- >删除
- </el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="warning"
- plain
- icon="el-icon-download"
- size="mini"
- @click="handleExport"
- v-hasPermi="['goal_management:monthGoalMerge:export']"
- >导出
- </el-button>
- </el-col>
- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
- </el-row>
- <el-table v-loading="loading" :data="monthGoalMergeList" @selection-change="handleSelectionChange">
- <el-table-column type="selection" width="55" align="center"/>
- <el-table-column label="id唯一标识" align="center" prop="id"/>
- <el-table-column label="编码" align="center" prop="code"/>
- <el-table-column label="目标名称" align="center" prop="goalName"/>
- <el-table-column label="单据日期" align="center" prop="documentDate" width="180">
- <template slot-scope="scope">
- <span>{{ parseTime(scope.row.documentDate, '{y}-{m}-{d}') }}</span>
- </template>
- </el-table-column>
- <el-table-column label="年度" align="center" prop="annual"/>
- <el-table-column label="月份" align="center" prop="monthly"/>
- <el-table-column label="客户编码" align="center" prop="customCode"/>
- <el-table-column label="客户" align="center" prop="custom"/>
- <el-table-column label="制单人编码" align="center" prop="creatorCode"/>
- <el-table-column label="制单人" align="center" prop="creator"/>
- <el-table-column label="部门编码" align="center" prop="deptCode"/>
- <el-table-column label="部门" align="center" prop="dept"/>
- <el-table-column label="目标类型" align="center" prop="goalCategory"/>
- <el-table-column label="目标值合计" align="center" prop="goalSum"/>
- <el-table-column label="单据状态" align="center" prop="documentStatus"/>
- <el-table-column label="删除状态" align="center" prop="deleteStatus"/>
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
- <template slot-scope="scope">
- <el-button
- size="mini"
- type="text"
- icon="el-icon-edit"
- @click="handleUpdate(scope.row)"
- v-hasPermi="['goal_management:monthGoalMerge:edit']"
- >修改
- </el-button>
- <el-button
- size="mini"
- type="text"
- icon="el-icon-delete"
- @click="handleDelete(scope.row)"
- v-hasPermi="['goal_management:monthGoalMerge:remove']"
- >删除
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- <pagination
- v-show="total>0"
- :total="total"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
- <!-- 添加或修改月销售目标合并抽屉 -->
- <el-drawer :title="title" :visible.sync="open" direction="rtl" :before-close="handleClose" size="100%">
- <el-form ref="form" :model="form" :rules="rules" label-width="120px">
- <el-row :gutter="20">
- <el-col :span="6">
- <el-form-item label="编码" prop="code">
- <el-input v-model="form.code" placeholder="编码后端自动生成" disabled/>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="目标名称" prop="goalName">
- <el-input v-model="form.goalName" placeholder="目标名称后端自动生成" disabled/>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="单据日期" prop="documentDate">
- <el-date-picker clearable
- v-model="form.documentDate"
- type="date"
- value-format="yyyy-MM-dd"
- placeholder="请选择单据日期">
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="年度" prop="annual">
- <el-date-picker clearable
- v-model="form.annual"
- type="year"
- value-format="yyyy"
- placeholder="请输入年度">
- </el-date-picker>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="6">
- <el-form-item label="月份" prop="monthly">
- <el-date-picker clearable
- v-model="form.monthly"
- type="month"
- value-format="M"
- placeholder="请输入月份">
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="制单人" prop="creator">
- <el-popover-select-v2 v-model="form.creator" title="制单人" valueKey="name"
- referName="CONTACTS_PARAM"
- :dataMapping="{ creatorCode: 'code', creator: 'name'}"
- :source.sync="form" placeholder="请输入制单人">
- </el-popover-select-v2>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="部门" prop="dept">
- <el-popover-select-v2 v-model="form.dept" title="部门" valueKey="name"
- referName="DEPT_PARAM"
- :dataMapping="{ deptCode: 'code', dept: 'name'}"
- :source.sync="form" placeholder="请输入部门">
- </el-popover-select-v2>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="目标类型" prop="goalCategory">
- <el-select v-model="form.goalCategory" placeholder="请输入目标类型" @change="changeGoalCategoryForm" @keyup.enter.native="handleQuery">
- <el-option
- v-for="item in goalCategoryList"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="6">
- <el-form-item label="目标值合计" prop="goalSum">
- <el-input v-model="form.goalSum" placeholder="目标值合计自动计算" disabled/>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item v-if="form.goalCategory === '客户维度'" label="客户" prop="custom">
- <el-popover-select-v2 v-model="form.custom" title="客户" valueKey="name"
- referName="CUSTOMER_PARAM"
- :dataMapping="{ customCode: 'code', custom: 'name'}"
- :source.sync="form" placeholder="请输入客户">
- </el-popover-select-v2>
- </el-form-item>
- <el-form-item v-if="form.goalCategory === '销售区域'" label="销售区域" prop="saleZone">
- <el-popover-select-v2 v-model="form.saleZoneCode" title="销售区域" valueKey="name"
- referName="DEPT_PARAM"
- :dataMapping="{ saleZoneCode: 'code', saleZone: 'name'}"
- :source.sync="form" placeholder="请输入销售区域">
- </el-popover-select-v2>
- </el-form-item>
- <el-form-item v-if="form.goalCategory === '一级分类'" label="一级分类" prop="oneLevelClassify">
- <el-select v-model="form.oneLevelClassify" size="mini" clearable
- @focus="chooseTreeReferForMain('MATERIALCLASSIFY_PARAM', false, '一级物料分类')"
- style="width: 200px">
- <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
- </el-select>
- </el-form-item>
- <el-form-item v-if="form.goalCategory === '二级分类'" label="二级分类" prop="custom">
- <el-select v-model="form.twoLevelClassify" size="mini" clearable
- @focus="chooseTreeReferForMain('MATERIALCLASSIFY_PARAM', false, '二级物料分类')"
- style="width: 200px">
- <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="操作">
- <el-button type="primary" @click="submitForm">确 定</el-button>
- <el-button @click="cancel">取 消</el-button>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <el-row :gutter="10" class="mb8">
- <el-col :span="1.5">
- <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAddDetails">增行</el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button type="primary" plain icon="el-icon-folder-opened" size="mini" @click="clickMerge">合 并</el-button>
- </el-col>
- </el-row>
- <!-- v-loading="loading"-->
- <el-table :data="monthGoalMergeDetailsList" @selection-change="handleSelectionChange">
- <el-table-column type="selection" width="55" align="center" fixed />
- <el-table-column label="销售组织" align="center" prop="saleOrg" width="180">
- <template slot-scope="scope">
- <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].saleOrg" title="销售组织" valueKey="name"
- referName="CUSTOMER_PARAM"
- :dataMapping="{ saleOrgCode: 'code', saleOrg: 'name'}"
- :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入销售组织">
- </el-popover-select-v2>
- </template>
- </el-table-column>
- <el-table-column label="销售区域" align="center" prop="saleZone" width="180">
- <template slot-scope="scope">
- <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].saleZone" title="销售区域" valueKey="name"
- referName="CUSTOMER_PARAM"
- :dataMapping="{ saleZoneCode: 'code', saleZone: 'name'}"
- :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入销售区域">
- </el-popover-select-v2>
- </template>
- </el-table-column>
- <el-table-column label="客户" align="center" prop="custom" width="180">
- <template slot-scope="scope">
- <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].custom" title="客户" valueKey="name"
- referName="CUSTOMER_PARAM"
- :dataMapping="{ customCode: 'code', custom: 'name'}"
- :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入客户">
- </el-popover-select-v2>
- </template>
- </el-table-column>
- <el-table-column label="部门" align="center" prop="dept" width="180">
- <template slot-scope="scope">
- <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].dept" title="部门" valueKey="name"
- referName="DEPT_PARAM"
- :dataMapping="{ deptCode: 'code', dept: 'name'}"
- :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入客户">
- </el-popover-select-v2>
- </template>
- </el-table-column>
- <el-table-column label="制单人" align="center" prop="creator" width="180">
- <template slot-scope="scope">
- <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].creator" title="负责人" valueKey="name"
- referName="CONTACTS_PARAM"
- :dataMapping="{ creatorCode: 'code', creator: 'name'}"
- :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入负责人">
- </el-popover-select-v2>
- </template>
- </el-table-column>
- <el-table-column label="科室" align="center" prop="department" width="180">
- <template slot-scope="scope">
- <el-input v-model="monthGoalMergeDetailsList[scope.$index].department" placeholder="请输入科室"></el-input>
- </template>
- </el-table-column>
- <el-table-column label="一级分类" align="center" prop="oneLevelClassify" width="180">
- <template slot-scope="scope">
- <el-select v-model="monthGoalMergeDetailsList[scope.$index].oneLevelClassify" size="mini" clearable
- @focus="chooseTreeReferForDetails('MATERIALCLASSIFY_PARAM', false, '一级物料分类', scope.$index)"
- style="width: 200px">
- <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
- </el-select>
- </template>
- </el-table-column>
- <el-table-column label="二级分类" align="center" prop="twoLevelClassify" width="180">
- <template slot-scope="scope">
- <el-select v-model="monthGoalMergeDetailsList[scope.$index].twoLevelClassify" size="mini" clearable
- @focus="chooseTreeReferForDetails('MATERIALCLASSIFY_PARAM', false, '二级物料分类', scope.$index)"
- style="width: 200px">
- <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
- </el-select>
- </template>
- </el-table-column>
- <el-table-column label="物料" align="center" prop="material" width="180">
- <template slot-scope="scope">
- <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].material" title="物料" valueKey="name"
- referName="MATERIAL_PARAM"
- :dataMapping="{ materialCode: 'code', material: 'name'}"
- :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入物料">
- </el-popover-select-v2>
- </template>
- </el-table-column>
- <el-table-column label="月份" align="center" prop="num" width="250">
- <template slot-scope="scope">
- <el-date-picker v-model="monthGoalMergeDetailsList[scope.$index].monthly" value-format="M" type="month" placeholder="选择月份">
- </el-date-picker>
- </template>
- </el-table-column>
- <el-table-column label="目标值" align="center" prop="totalGoal" width="220">
- <template slot-scope="scope">
- <el-input-number @change="computeTotal" v-model="monthGoalMergeDetailsList[scope.$index].goalValue" :precision="2" :step="1" :min="0"></el-input-number>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120px" fixed="right">
- <template slot-scope="scope">
- <el-button
- size="mini"
- type="text"
- icon="el-icon-delete"
- @click="handleDeleteDetails(scope.$index, scope.row)"
- >删除</el-button>
- <el-button
- size="mini"
- type="text"
- icon="el-icon-delete"
- @click="handleCopyDetails(scope.row)"
- >复制</el-button>
- </template>
- </el-table-column>
- </el-table>
- </el-drawer>
- <TreeRefers ref="treeQuery" @doSubmit="selectionsToInputForQuery" :single="true"/>
- <TreeRefers ref="treeMain" @doSubmit="selectionsToInputForMain" :single="true"/>
- <TreeRefers ref="treeDetails" @doSubmit="selectionsToInputForDetails" :single="true"/>
- </div>
- </template>
- <script>
- import {
- listMonthGoalMerge,
- getMonthGoalMerge,
- delMonthGoalMerge,
- addMonthGoalMerge,
- updateMonthGoalMerge
- } from "@/api/business/spd/goal_management/monthGoalMerge";
- import {
- getMonthSaleGoalDetails,
- delMonthSaleGoalDetails,
- mergeAnnualSaleMergeDetails
- } from "@/api/business/spd/goal_management/monthSaleGoalDetails"
- // 树形参照
- import TreeRefers from '@/components/Refers/treeRefer.vue'
- import ElPopoverSelectV2 from "@/components/popover-select-v2"
- export default {
- name: "MonthGoalMerge",
- components: {
- TreeRefers, ElPopoverSelectV2
- },
- data() {
- return {
- // 遮罩层
- loading: true,
- // 选中数组
- ids: [],
- // 非单个禁用
- single: true,
- // 非多个禁用
- multiple: true,
- // 显示搜索条件
- showSearch: true,
- // 总条数
- total: 0,
- // 月销售目标合并表格数据
- monthGoalMergeList: [],
- monthGoalMergeDetailsList: [],
- // 弹出层标题
- title: "",
- // 是否显示弹出层
- open: false,
- // 查询参数
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- code: null,
- goalName: null,
- documentDate: null,
- annual: null,
- monthly: null,
- customCode: null,
- custom: null,
- creatorCode: null,
- creator: null,
- deptCode: null,
- dept: null,
- goalCategory: null,
- goalSum: null,
- documentStatus: null,
- deleteStatus: null,
- saleZoneCode: null,
- saleZone: null,
- oneLevelClassifyCode: null,
- oneLevelClassify: null,
- twoLevelClassifyCode: null,
- twoLevelClassify: null,
- documentDateRange: null
- },
- pickerOptions: {
- shortcuts: [{
- text: '最近一周',
- onClick(picker) {
- const end = new Date();
- const start = new Date();
- start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
- picker.$emit('pick', [start, end]);
- }
- }, {
- text: '最近一个月',
- onClick(picker) {
- const end = new Date();
- const start = new Date();
- start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
- picker.$emit('pick', [start, end]);
- }
- }, {
- text: '最近三个月',
- onClick(picker) {
- const end = new Date();
- const start = new Date();
- start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
- picker.$emit('pick', [start, end]);
- }
- }]
- },
- // 表单参数
- form: {
- id: null,
- code: null,
- goalName: null,
- documentDate: null,
- annual: null,
- monthly: null,
- customCode: null,
- custom: null,
- creatorCode: null,
- creator: null,
- deptCode: null,
- dept: null,
- goalCategory: null,
- goalSum: null,
- documentStatus: null,
- saleZoneCode: null,
- saleZone: null,
- oneLevelClassifyCode: null,
- oneLevelClassify: null,
- twoLevelClassifyCode: null,
- twoLevelClassify: null,
- monthMergeDetailsList: null
- },
- formDetails: {
- id: null,
- code: null,
- saleOrg: null,
- saleZone: null,
- custom: null,
- dept: null,
- creator: null,
- department: null,
- oneLevelClassifyCode: null,
- oneLevelClassify: null,
- twoLevelClassifyCode: null,
- twoLevelClassify: null,
- materialCode: null,
- material: null,
- monthly: null,
- goalValue: null
- },
- // 表单校验
- rules: {},
- // 目标类型列表
- goalCategoryList: [
- { value: '客户维度', label: '客户维度' },
- { value: '销售区域', label: '销售区域' },
- { value: '一级分类', label: '一级分类' },
- { value: '二级分类', label: '二级分类' }
- ],
- // 树形参照
- referCondition: { type: '', isPage: true, title: '', index: null },
- classOptions: []
- };
- },
- created() {
- this.getList();
- },
- methods: {
- /** 查询月销售目标合并列表 */
- getList() {
- this.loading = true;
- listMonthGoalMerge(this.queryParams).then(response => {
- this.monthGoalMergeList = response.rows;
- this.total = response.total;
- this.loading = false;
- });
- },
- getListDetails() {
- this.loading = true;
- getMonthSaleGoalDetails(this.form.id).then(response => {
- this.monthGoalMergeDetailsList = response.data;
- this.computeTotal()
- this.form.monthMergeDetailsList = this.monthGoalMergeDetailsList
- updateMonthGoalMerge(this.form).then(response => {})
- this.loading = false;
- });
- },
- // 取消按钮
- cancel() {
- this.open = false;
- this.reset();
- },
- // 表单重置
- reset() {
- this.form = {
- id: null,
- code: null,
- goalName: null,
- documentDate: null,
- annual: null,
- monthly: null,
- customCode: null,
- custom: null,
- creatorCode: null,
- creator: null,
- deptCode: null,
- dept: null,
- goalCategory: null,
- goalSum: null,
- documentStatus: null,
- saleZoneCode: null,
- saleZone: null,
- oneLevelClassifyCode: null,
- oneLevelClassify: null,
- twoLevelClassifyCode: null,
- twoLevelClassify: null
- };
- this.resetForm("form");
- },
- /** 搜索按钮操作 */
- handleQuery() {
- this.queryParams.pageNum = 1;
- this.getList();
- },
- /** 重置按钮操作 */
- resetQuery() {
- this.resetForm("queryForm");
- this.handleQuery();
- },
- // 多选框选中数据
- handleSelectionChange(selection) {
- this.ids = selection.map(item => item.id)
- this.single = selection.length !== 1
- this.multiple = !selection.length
- },
- /** 新增按钮操作 */
- handleAdd() {
- this.reset();
- this.open = true;
- this.title = "添加月销售目标合并";
- },
- handleAddDetails() {
- let list = {
- id: null,
- code: null,
- saleOrg: null,
- saleZone: null,
- custom: null,
- dept: null,
- creator: null,
- oneLevelClassifyCode: null,
- oneLevelClassify: null,
- twoLevelClassifyCode: null,
- twoLevelClassify: null,
- materialCode: null,
- material: null,
- department: null,
- num: null,
- monthly: null,
- goalValue: null
- }
- this.monthGoalMergeDetailsList.push(list)
- },
- /** 修改按钮操作 */
- handleUpdate(row) {
- this.reset();
- const id = row.id || this.ids
- getMonthGoalMerge(id).then(response => {
- this.form = response.data;
- this.open = true;
- this.title = "修改月销售目标合并";
- });
- },
- /** 提交按钮 */
- submitForm() {
- this.$refs["form"].validate(valid => {
- if (valid) {
- if (this.form.id !== null) {
- this.form.monthMergeDetailsList = this.monthGoalMergeDetailsList
- updateMonthGoalMerge(this.form).then(response => {
- this.$modal.msgSuccess("修改成功");
- this.open = false;
- this.getList();
- });
- } else {
- this.form.documentStatus = '未提交'
- this.form.monthMergeDetailsList = this.monthGoalMergeDetailsList
- console.log(this.form);
- addMonthGoalMerge(this.form).then(response => {
- this.$modal.msgSuccess("新增成功");
- this.open = false;
- this.getList();
- });
- }
- }
- });
- },
- /** 删除按钮操作 */
- handleDelete(row) {
- const ids = row.id || this.ids;
- this.$modal.confirm('是否确认删除月销售目标合并编号为"' + ids + '"的数据项?').then(function () {
- return delMonthGoalMerge(ids);
- }).then(() => {
- this.getList();
- this.$modal.msgSuccess("删除成功");
- }).catch(() => {
- });
- },
- handleDeleteDetails(index, row) {
- if (this.form.id === null) {
- this.monthGoalMergeDetailsList.splice(index, 1)
- this.computeTotal()
- } else {
- if (row.id !== null) {
- this.$modal.confirm('是否确认删除月销售目标合并明细编号为"' + row.id + '"的数据项?').then(function () {
- return delMonthSaleGoalDetails(row.id);
- }).then(() => {
- this.getListDetails();
- this.$modal.msgSuccess("删除成功");
- }).catch(() => {
- });
- } else {
- this.monthGoalMergeDetailsList.splice(index, 1)
- this.$message.success('删除成功')
- this.computeTotal()
- }
- }
- },
- /** 导出按钮操作 */
- handleExport() {
- this.download('goal_management/monthGoalMerge/export', {
- ...this.queryParams
- }, `monthGoalMerge${new Date().getTime()}.xlsx`)
- },
- // 树形参照
- chooseTreeReferForQuery(type, isPage, title) {
- this.referCondition.type = type
- this.referCondition.isPage = isPage
- this.referCondition.title = title
- this.$refs.treeQuery.init(this.referCondition)
- },
- chooseTreeReferForMain(type, isPage, title) {
- this.referCondition.type = type
- this.referCondition.isPage = isPage
- this.referCondition.title = title
- this.$refs.treeMain.init(this.referCondition)
- },
- chooseTreeReferForDetails(type, isPage, title, index) {
- this.referCondition.type = type
- this.referCondition.isPage = isPage
- this.referCondition.title = title
- this.referCondition.index = index
- this.$refs.treeDetails.init(this.referCondition)
- },
- selectionsToInputForQuery(selection) {
- this.classOptions.push(selection)
- if (this.referCondition.title === '一级物料分类') {
- if (selection.code.length !== 1) {
- return this.$message.info('请在一级分类下选择')
- }
- this.queryParams.oneLevelClassifyCode = selection.code
- this.queryParams.oneLevelClassify = selection.name
- } else if (this.referCondition.title === '二级物料分类') {
- if (selection.code.length !== 4) {
- return this.$message.info('请在二级分类下选择')
- }
- this.queryParams.twoLevelClassifyCode = selection.code
- this.queryParams.twoLevelClassify = selection.name
- }
- },
- selectionsToInputForMain(selection) {
- this.classOptions.push(selection)
- if (this.referCondition.title === '一级物料分类') {
- if (selection.code.length !== 1) {
- return this.$message.info('请在一级分类下选择')
- }
- this.form.oneLevelClassifyCode = selection.code
- this.form.oneLevelClassify = selection.name
- } else if (this.referCondition.title === '二级物料分类') {
- if (selection.code.length !== 4) {
- return this.$message.info('请在二级分类下选择')
- }
- this.form.twoLevelClassifyCode = selection.code
- this.form.twoLevelClassify = selection.name
- }
- },
- selectionsToInputForDetails(selection) {
- this.classOptions.push(selection)
- if (this.referCondition.title === '一级物料分类') {
- if (selection.code.length !== 1) {
- return this.$message.info('请在一级分类中选择')
- }
- if (selection.code !== this.monthGoalMergeDetailsList[this.referCondition.index].oneLevelClassifyCode) {
- this.monthGoalMergeDetailsList[this.referCondition.index].twoLevelClassifyCode = null
- this.monthGoalMergeDetailsList[this.referCondition.index].twoLevelClassify = null
- }
- this.monthGoalMergeDetailsList[this.referCondition.index].oneLevelClassifyCode = selection.code
- this.monthGoalMergeDetailsList[this.referCondition.index].oneLevelClassify = selection.name
- } else if (this.referCondition.title === '二级物料分类') {
- if (selection.code.length !== 4) {
- return this.$message.info('请在二级分类中选择')
- } else if (selection.code[0] !== this.monthGoalMergeDetailsList[this.referCondition.index].oneLevelClassifyCode) {
- return this.$message.error('所选择的二级物料分类不属于一级分类')
- }
- this.monthGoalMergeDetailsList[this.referCondition.index].twoLevelClassifyCode = selection.code
- this.monthGoalMergeDetailsList[this.referCondition.index].twoLevelClassify = selection.name
- }
- },
- // 改变查询表单的目标分类
- changeGoalCategoryQuery() {
- let condition = this.queryParams.goalCategory
- if (condition === null) {
- this.queryParams.custom = null
- this.queryParams.customCode = null
- this.queryParams.saleZone = null
- this.queryParams.saleZoneCode = null
- this.queryParams.oneLevelClassify = null
- this.queryParams.oneLevelClassifyCode = null
- this.queryParams.twoLevelClassify = null
- this.queryParams.twoLevelClassifyCode = null
- } else if (condition === '客户维度') {
- this.queryParams.saleZone = null
- this.queryParams.saleZoneCode = null
- this.queryParams.oneLevelClassify = null
- this.queryParams.oneLevelClassifyCode = null
- this.queryParams.twoLevelClassify = null
- this.queryParams.twoLevelClassifyCode = null
- } else if (condition === '销售区域') {
- this.queryParams.custom = null
- this.queryParams.customCode = null
- this.queryParams.oneLevelClassify = null
- this.queryParams.oneLevelClassifyCode = null
- this.queryParams.twoLevelClassify = null
- this.queryParams.twoLevelClassifyCode = null
- } else if (condition === '一级分类') {
- this.queryParams.custom = null
- this.queryParams.customCode = null
- this.queryParams.saleZone = null
- this.queryParams.saleZoneCode = null
- this.queryParams.twoLevelClassify = null
- this.queryParams.twoLevelClassifyCode = null
- } else if (condition === '二级分类') {
- this.queryParams.custom = null
- this.queryParams.customCode = null
- this.queryParams.saleZone = null
- this.queryParams.saleZoneCode = null
- this.queryParams.oneLevelClassify = null
- this.queryParams.oneLevelClassifyCode = null
- }
- },
- changeGoalCategoryForm() {
- let condition = this.form.goalCategory
- if (condition === null) {
- this.form.custom = null
- this.form.customCode = null
- this.form.saleZone = null
- this.form.saleZoneCode = null
- this.form.oneLevelClassify = null
- this.form.oneLevelClassifyCode = null
- this.form.twoLevelClassify = null
- this.form.twoLevelClassifyCode = null
- } else if (condition === '客户维度') {
- this.form.saleZone = null
- this.form.saleZoneCode = null
- this.form.oneLevelClassify = null
- this.form.oneLevelClassifyCode = null
- this.form.twoLevelClassify = null
- this.form.twoLevelClassifyCode = null
- } else if (condition === '销售区域') {
- this.form.custom = null
- this.form.customCode = null
- this.form.oneLevelClassify = null
- this.form.oneLevelClassifyCode = null
- this.form.twoLevelClassify = null
- this.form.twoLevelClassifyCode = null
- } else if (condition === '一级分类') {
- this.form.custom = null
- this.form.customCode = null
- this.form.saleZone = null
- this.form.saleZoneCode = null
- this.form.twoLevelClassify = null
- this.form.twoLevelClassifyCode = null
- } else if (condition === '二级分类') {
- this.form.custom = null
- this.form.customCode = null
- this.form.saleZone = null
- this.form.saleZoneCode = null
- this.form.oneLevelClassify = null
- this.form.oneLevelClassifyCode = null
- }
- },
- // 关闭抽屉
- handleClose(done) {
- this.$confirm('确认关闭?')
- .then(_ => {
- done();
- this.resetQuery()
- })
- .catch(_ => {});
- },
- // 复制明细
- handleCopyDetails(row) {
- let list = {
- id: null,
- code: row.code,
- saleOrg: row.saleOrg,
- saleZone: row.saleZone,
- custom: row.custom,
- dept: row.dept,
- creator: row.creator,
- oneLevelClassifyCode: row.oneLevelClassifyCode,
- oneLevelClassify: row.oneLevelClassify,
- twoLevelClassifyCode: row.twoLevelClassifyCode,
- twoLevelClassify: row.twoLevelClassify,
- materialCode: row.materialCode,
- material: row.material,
- department: row.department,
- num: row.num,
- monthly: row.monthly,
- goalValue: row.goalValue
- }
- this.monthGoalMergeDetailsList.push(list)
- this.computeTotal()
- },
- // 计算主表合计
- computeTotal() {
- let list = this.monthGoalMergeDetailsList
- let sum = 0
- for (const listElement of list) {
- sum = (sum * 1000000 + listElement.goalValue * 1000000) / 1000000
- }
- this.form.goalSum = sum
- },
- // 合并数据
- clickMerge() {
- let classify = this.form.goalCategory
- let classifyValue;
- if (classify === null || classify === '') {
- return this.$message.error('请输入目标分类')
- } else if (classify === '销售区域') {
- classifyValue = this.form.saleZone
- if (classifyValue === null) {
- return this.$message.error('请输入销售区域')
- }
- } else if (classify === '一级分类') {
- classifyValue = this.form.oneLevelClassify
- if (classifyValue === null) {
- return this.$message.error('请输入一级分类')
- }
- } else if (classify === '二级分类') {
- classifyValue = this.form.twoLevelClassify
- if (classifyValue === null) {
- return this.$message.error('请输入二级分类')
- }
- }
- let query = { classify: classify, classifyValue: classifyValue }
- mergeAnnualSaleMergeDetails(query).then(response => {
- console.log(response);
- this.annualSaleGoalMergeDetailsList = response.data.consolidatedDetail
- if (classify !== '销售区域') {
- this.areaDetailList = []
- this.customerDetailList = []
- } else {
- this.areaDetailList = response.data.areaDetail
- this.customerDetailList = response.data.customerDetail
- }
- this.computeTotal()
- })
- }
- }
- };
- </script>
|