MonthGoalMerge.vue 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="mini" :inline="true" label-width="100px">
  4. <el-row :gutter="20">
  5. <el-col :span="6">
  6. <el-form-item label="编码" prop="code">
  7. <el-input v-model="queryParams.code" placeholder="请输入编码" clearable @keyup.enter.native="handleQuery" />
  8. </el-form-item>
  9. </el-col>
  10. <el-col :span="6">
  11. <el-form-item label="目标名称" prop="goalName">
  12. <el-input v-model="queryParams.goalName" placeholder="请输入目标名称" clearable
  13. @keyup.enter.native="handleQuery" />
  14. </el-form-item>
  15. </el-col>
  16. <el-col :span="8">
  17. <el-form-item label="单据日期" prop="documentDate">
  18. <el-date-picker v-model="documentDateRange" @change="setBeginAndEnd" type="daterange" align="right"
  19. range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd"
  20. @keyup.enter.native="handleQuery" :picker-options="pickerOptions">
  21. </el-date-picker>
  22. </el-form-item>
  23. </el-col>
  24. <el-col :span="4">
  25. <el-form-item>
  26. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  27. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  28. <el-tooltip class="item" effect="dark" :content="showSearch?'隐藏搜索':'显示搜索'" placement="top">
  29. <el-button type="warning" :icon="showSearch?'el-icon-caret-top':'el-icon-caret-bottom'" circle
  30. @click="showSearch = !showSearch"></el-button>
  31. </el-tooltip>
  32. </el-form-item>
  33. </el-col>
  34. </el-row>
  35. </el-form>
  36. <el-form :model="queryParams" ref="queryForm" size="mini" :inline="true" v-show="showSearch" label-width="100px">
  37. <el-row :gutter="20">
  38. <el-col :span="6">
  39. <el-form-item label="年度" prop="annual">
  40. <el-date-picker v-model="queryParams.annual" type="year" clearable value-format="yyyy"
  41. @keyup.enter.native="handleQuery" placeholder="请输入年度">
  42. </el-date-picker>
  43. </el-form-item>
  44. </el-col>
  45. <el-col :span="6">
  46. <el-form-item label="月份" prop="monthly">
  47. <el-date-picker v-model="queryParams.monthly" type="month" clearable value-format="yyyy-MM"
  48. @keyup.enter.native="handleQuery" placeholder="请输入月份">
  49. </el-date-picker>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :span="6">
  53. <el-form-item label="制单人" prop="creator">
  54. <el-popover-select-v2 v-model="queryParams.creator" title="制单人" valueKey="name" referName="CONTACTS_PARAM"
  55. :dataMapping="{ creatorCode: 'code', creator: 'name'}" :source.sync="queryParams" placeholder="请输入制单人">
  56. </el-popover-select-v2>
  57. </el-form-item>
  58. </el-col>
  59. <el-col :span="6">
  60. <el-form-item label="部门" prop="dept">
  61. <el-popover-select-v2 v-model="queryParams.dept" title="部门" valueKey="name" referName="DEPT_PARAM"
  62. :dataMapping="{ deptCode: 'id', dept: 'name'}" :source.sync="queryParams" placeholder="请输入部门">
  63. </el-popover-select-v2>
  64. </el-form-item>
  65. </el-col>
  66. </el-row>
  67. <el-row :gutter="20">
  68. <el-col :span="6">
  69. <el-form-item label="单据状态" prop="status">
  70. <el-select v-model="queryParams.status" clearable>
  71. <el-option v-for="dict in dict.type.sys_status" :key="dict.value" :label="dict.label" :value="dict.value">
  72. </el-option>
  73. </el-select>
  74. </el-form-item>
  75. </el-col>
  76. <el-col :span="6">
  77. <el-form-item label="目标类型" prop="goalCategory">
  78. <el-select v-model="queryParams.goalCategory" placeholder="请输入目标类型" @change="changeGoalCategoryQuery"
  79. @keyup.enter.native="handleQuery">
  80. <el-option v-for="item in goalCategoryList" :key="item.value" :label="item.label" :value="item.value">
  81. </el-option>
  82. </el-select>
  83. </el-form-item>
  84. </el-col>
  85. <el-col :span="6">
  86. <el-form-item v-if="queryParams.goalCategory === '客户维度'" label="客户" prop="custom">
  87. <el-popover-select-v2 v-model="queryParams.custom" title="客户" valueKey="name" referName="CUSTOMER_PARAM"
  88. :dataMapping="{ customCode: 'code', custom: 'name'}" :source.sync="queryParams" placeholder="请输入客户">
  89. </el-popover-select-v2>
  90. </el-form-item>
  91. <el-form-item v-if="queryParams.goalCategory === '销售区域'" label="销售区域" prop="saleZone">
  92. <el-popover-select-v2 v-model="queryParams.saleZoneCode" title="销售区域" valueKey="name"
  93. referName="MK_SALESAREA_PARAM" :dataMapping="{ saleZoneCode: 'code', saleZone: 'name'}"
  94. :source.sync="queryParams" placeholder="请输入销售区域">
  95. </el-popover-select-v2>
  96. </el-form-item>
  97. <el-form-item v-if="queryParams.goalCategory === '一级分类'" label="一级分类" prop="oneLevelClassify">
  98. <el-select v-model="queryParams.oneLevelClassify" clearable
  99. @focus="chooseTreeReferForQuery('MATERIALCLASSIFY_PARAM', false, '一级物料分类')" style="width: 200px">
  100. <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.code" />
  101. </el-select>
  102. </el-form-item>
  103. <el-form-item v-if="queryParams.goalCategory === '二级分类'" label="二级分类" prop="twoLevelClassify">
  104. <el-select v-model="queryParams.twoLevelClassify" clearable
  105. @focus="chooseTreeReferForQuery('MATERIALCLASSIFY_PARAM', false, '二级物料分类')" style="width: 200px">
  106. <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.code" />
  107. </el-select>
  108. </el-form-item>
  109. </el-col>
  110. </el-row>
  111. </el-form>
  112. <el-row :gutter="10" class="mb8" style="float: right">
  113. <el-col :span="1.5">
  114. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增
  115. </el-button>
  116. </el-col>
  117. <el-col :span="1.5">
  118. <el-dropdown @command="handleCommand">
  119. <el-button type="warning" plain icon="el-icon-download" size="mini">
  120. 导出<i class="el-icon-arrow-down el-icon--right"></i>
  121. </el-button>
  122. <el-dropdown-menu slot="dropdown">
  123. <el-dropdown-item command="export">导出</el-dropdown-item>
  124. <el-dropdown-item command="exportDetails">导出明细</el-dropdown-item>
  125. </el-dropdown-menu>
  126. </el-dropdown>
  127. </el-col>
  128. </el-row>
  129. <el-table v-loading="loading" :data="monthGoalMergeList" @selection-change="handleSelectionChange"
  130. @row-dblclick="useDoubleClick" v-horizontal-scroll max-height="560">
  131. <el-table-column label="编码" align="center" prop="code" width="180" />
  132. <el-table-column label="目标名称" align="center" prop="goalName" width="240" />
  133. <el-table-column label="单据日期" align="center" prop="documentDate" width="180">
  134. <template slot-scope="scope">
  135. <span>{{ parseTime(scope.row.documentDate, '{y}-{m}-{d}') }}</span>
  136. </template>
  137. </el-table-column>
  138. <el-table-column label="年度" align="center" prop="annual" width="100" />
  139. <el-table-column label="月份" align="center" prop="monthly" width="180" />
  140. <el-table-column label="客户" align="center" prop="custom" width="180" />
  141. <el-table-column label="制单人" align="center" prop="creator" width="180" />
  142. <el-table-column label="部门" align="center" prop="dept" width="180" />
  143. <el-table-column label="目标类型" align="center" prop="goalCategory" width="180" />
  144. <el-table-column label="目标值合计(元)" align="center" prop="goalSum" width="180" />
  145. <el-table-column show-overflow-tooltip label="状态" align="center" width="100" prop="status">
  146. <template slot-scope="scope">
  147. <dict-tag :options="dict.type.sys_status" :value="scope.row.status" />
  148. </template>
  149. </el-table-column>
  150. <el-table-column label="操作" align="center" width="180" class-name="small-padding" fixed="right">
  151. <template slot-scope="scope">
  152. <el-button size="mini" type="text" @click="useDoubleClick(scope.row)">查看
  153. </el-button>
  154. <el-button v-if="scope.row.status == '0' || scope.row.status == '3'" size="mini" type="text"
  155. @click="handleUpdate(scope.row)">修改
  156. </el-button>
  157. <el-button v-if="scope.row.status == '0' || scope.row.status == '3'" size="mini" type="text"
  158. @click="handleDelete(scope.row)">删除
  159. </el-button>
  160. <el-button v-if="scope.row.status == '0' || scope.row.status == '3'" size="mini" type="text"
  161. @click="handleSubmit(scope.row)">提交</el-button>
  162. <el-button v-if="scope.row.status == '1'" size="mini" type="text" @click="handleReback(scope.row)">收回
  163. </el-button>
  164. </template>
  165. </el-table-column>
  166. </el-table>
  167. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  168. :page-sizes="[10, 20, 50, 100]" @pagination="getList" />
  169. <!-- 添加或修改月销售目标合并抽屉 -->
  170. <el-drawer :title="title" :visible.sync="open" direction="rtl" :before-close="handleClose" size="100%"
  171. v-horizontal-scroll>
  172. <el-form ref="form" :model="form" :rules="rules" label-width="120px" :disabled="openStatus == 'see'" size="mini">
  173. <el-row :gutter="20">
  174. <el-col :span="6">
  175. <el-form-item label="编码" prop="code">
  176. <el-input v-model="form.code" placeholder="编码后端自动生成" disabled />
  177. </el-form-item>
  178. </el-col>
  179. <el-col :span="6">
  180. <el-form-item label="目标名称" prop="goalName">
  181. <el-input v-model="form.goalName" placeholder="目标名称后端自动生成" disabled />
  182. </el-form-item>
  183. </el-col>
  184. <el-col :span="6">
  185. <el-form-item label="单据日期" prop="documentDate">
  186. <el-date-picker clearable v-model="form.documentDate" type="date" value-format="yyyy-MM-dd"
  187. placeholder="请选择单据日期">
  188. </el-date-picker>
  189. </el-form-item>
  190. </el-col>
  191. <el-col :span="6">
  192. <el-form-item label="年度" prop="annual">
  193. <el-date-picker clearable v-model="form.annual" type="year" value-format="yyyy" placeholder="请输入年度">
  194. </el-date-picker>
  195. </el-form-item>
  196. </el-col>
  197. </el-row>
  198. <el-row :gutter="20">
  199. <el-col :span="6">
  200. <el-form-item label="月份" prop="monthly">
  201. <el-date-picker clearable v-model="form.monthly" type="month" value-format="yyyy-MM" placeholder="请输入月份">
  202. </el-date-picker>
  203. </el-form-item>
  204. </el-col>
  205. <el-col :span="6">
  206. <el-form-item label="制单人" prop="creator">
  207. <el-popover-select-v2 v-model="form.creator" title="制单人" valueKey="name" referName="CONTACTS_PARAM"
  208. :dataMapping="{ creatorCode: 'code', creator: 'name'}" :source.sync="form" placeholder="请输入制单人">
  209. </el-popover-select-v2>
  210. </el-form-item>
  211. </el-col>
  212. <el-col :span="6">
  213. <el-form-item label="部门" prop="dept">
  214. <el-popover-select-v2 v-model="form.dept" title="部门" valueKey="name" referName="DEPT_PARAM"
  215. :dataMapping="{ deptCode: 'code', dept: 'name'}" :source.sync="form" placeholder="请输入部门">
  216. </el-popover-select-v2>
  217. </el-form-item>
  218. </el-col>
  219. <el-col :span="6">
  220. <el-form-item label="目标类型" prop="goalCategory">
  221. <el-select v-model="form.goalCategory" placeholder="请输入目标类型" @change="changeGoalCategoryForm"
  222. @keyup.enter.native="handleQuery" :disabled="this.openStatus == 'edit'">
  223. <el-option v-for="item in goalCategoryList" :key="item.value" :label="item.label" :value="item.value">
  224. </el-option>
  225. </el-select>
  226. </el-form-item>
  227. </el-col>
  228. </el-row>
  229. <el-row :gutter="20">
  230. <el-col :span="6">
  231. <el-form-item label="目标合计(元)" prop="goalSum" label-width="120px">
  232. <el-input v-model="form.goalSum" placeholder="目标值合计自动计算" disabled />
  233. </el-form-item>
  234. </el-col>
  235. <el-col :span="6">
  236. <el-form-item v-if="form.goalCategory === '客户维度'" label="客户" prop="custom">
  237. <el-popover-select-v2 v-model="form.custom" title="客户" valueKey="name" referName="CUSTOMER_PARAM"
  238. :dataMapping="{custom: 'name'}" :source.sync="form" placeholder="请输入客户">
  239. </el-popover-select-v2>
  240. </el-form-item>
  241. <el-form-item v-if="form.goalCategory === '销售区域'" label="销售区域" prop="saleZone">
  242. <el-popover-select-v2 v-model="form.saleZone" title="销售区域" valueKey="name" referName="MK_SALESAREA_PARAM"
  243. :dataMapping="{saleZone: 'name'}" :source.sync="form" placeholder="请输入销售区域">
  244. </el-popover-select-v2>
  245. </el-form-item>
  246. <el-form-item v-if="form.goalCategory === '一级分类'" label="一级分类" prop="oneLevelClassify">
  247. <el-select v-model="form.oneLevelClassify" clearable
  248. @focus="chooseTreeReferForMain('MATERIALCLASSIFY_PARAM', false, '一级物料分类')" style="width: 200px">
  249. <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.code" />
  250. </el-select>
  251. </el-form-item>
  252. <el-form-item v-if="form.goalCategory === '二级分类'" label="二级分类" prop="twoLevelClassify">
  253. <el-select v-model="form.twoLevelClassify" clearable
  254. @focus="chooseTreeReferForMain('MATERIALCLASSIFY_PARAM', false, '二级物料分类')" style="width: 200px">
  255. <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.code" />
  256. </el-select>
  257. </el-form-item>
  258. </el-col>
  259. <el-col :span="6">
  260. <el-form-item label="单据状态" prop="type">
  261. <el-select v-model="form.status" placeholder="" disabled>
  262. <el-option v-for="dict in dict.type.sys_status" :key="dict.value" :label="dict.label"
  263. :value="dict.value"></el-option>
  264. </el-select>
  265. </el-form-item>
  266. </el-col>
  267. </el-row>
  268. <div>
  269. <el-row :gutter="10" class="mb8" style="margin-left: 94%">
  270. <el-col :span="1.5">
  271. <el-button type="primary" plain icon="el-icon-folder-opened" size="mini" @click="clickMerge">合 并
  272. </el-button>
  273. </el-col>
  274. </el-row>
  275. <el-tabs v-model="activeName" @tab-click="getNewTwoArray">
  276. <el-tab-pane label="月销售目标合并明细" name="monthGoalMergeDetails">
  277. <el-table max-height="560" show-summary :summary-method="getSummaries" v-loading="loading" size="mini"
  278. :data="monthGoalMergeDetailsList" @selection-change="handleSelectionChange" v-horizontal-scroll>
  279. <el-table-column label="序号" type="index" width="70" align="center" fixed />
  280. <el-table-column label="销售组织" align="center" prop="saleOrg" width="180">
  281. <template slot-scope="scope">
  282. <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].saleOrg" title="销售组织"
  283. valueKey="name" referName="ORG_PARAM" disabled
  284. :dataMapping="{ saleOrgCode: 'code', saleOrg: 'name'}"
  285. :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入销售组织">
  286. </el-popover-select-v2>
  287. </template>
  288. </el-table-column>
  289. <el-table-column label="销售区域" align="center" prop="saleZone" width="180">
  290. <template slot-scope="scope">
  291. <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].saleZone" title="销售区域"
  292. valueKey="name" referName="MK_SALESAREA_PARAM" disabled
  293. :dataMapping="{ saleZoneCode: 'code', saleZone: 'name'}"
  294. :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入销售区域">
  295. </el-popover-select-v2>
  296. </template>
  297. </el-table-column>
  298. <el-table-column label="客户" align="center" prop="custom" width="180">
  299. <template slot-scope="scope">
  300. <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].custom" title="客户"
  301. valueKey="name" referName="CUSTOMER_PARAM" disabled
  302. :dataMapping="{ customCode: 'code', custom: 'name'}"
  303. :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入客户">
  304. </el-popover-select-v2>
  305. </template>
  306. </el-table-column>
  307. <el-table-column label="部门" align="center" prop="dept" width="180">
  308. <template slot-scope="scope">
  309. <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].dept" title="部门"
  310. valueKey="name" referName="DEPT_PARAM" disabled :dataMapping="{ deptCode: 'code', dept: 'name'}"
  311. :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入客户">
  312. </el-popover-select-v2>
  313. </template>
  314. </el-table-column>
  315. <el-table-column label="制单人" align="center" prop="creator" width="180">
  316. <template slot-scope="scope">
  317. <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].creator" title="负责人"
  318. valueKey="name" referName="CONTACTS_PARAM" disabled
  319. :dataMapping="{ creatorCode: 'code', creator: 'name'}"
  320. :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入负责人">
  321. </el-popover-select-v2>
  322. </template>
  323. </el-table-column>
  324. <el-table-column label="科室" align="center" width="180">
  325. <template slot-scope="scope">
  326. <el-input v-model="monthGoalMergeDetailsList[scope.$index].department" placeholder="请输入科室" disabled>
  327. </el-input>
  328. </template>
  329. </el-table-column>
  330. <el-table-column label="一级分类" align="center" prop="oneLevelClassify" width="220">
  331. <template slot-scope="scope">
  332. <el-select v-model="monthGoalMergeDetailsList[scope.$index].oneLevelClassify" size="mini" clearable
  333. @focus="chooseTreeReferForDetails('MATERIALCLASSIFY_PARAM', false, '一级物料分类', scope.$index)"
  334. style="width: 200px" disabled>
  335. <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.code" />
  336. </el-select>
  337. </template>
  338. </el-table-column>
  339. <el-table-column label="二级分类" align="center" prop="twoLevelClassify" width="220">
  340. <template slot-scope="scope">
  341. <el-select v-model="monthGoalMergeDetailsList[scope.$index].twoLevelClassify" size="mini" clearable
  342. @focus="chooseTreeReferForDetails('MATERIALCLASSIFY_PARAM', false, '二级物料分类', scope.$index)"
  343. style="width: 200px" disabled>
  344. <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.code" />
  345. </el-select>
  346. </template>
  347. </el-table-column>
  348. <el-table-column label="物料" align="center" prop="material" width="180">
  349. <template slot-scope="scope">
  350. <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].material" title="物料"
  351. valueKey="name" referName="MATERIAL_PARAM" disabled
  352. :dataMapping="{ materialCode: 'code', material: 'name'}"
  353. :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入物料">
  354. </el-popover-select-v2>
  355. </template>
  356. </el-table-column>
  357. <el-table-column label="月份" align="center" prop="monthly" width="250">
  358. <template slot-scope="scope">
  359. <el-date-picker disabled v-model="monthGoalMergeDetailsList[scope.$index].monthly"
  360. value-format="yyyy-MM" type="month" placeholder="选择月份">
  361. </el-date-picker>
  362. </template>
  363. </el-table-column>
  364. <el-table-column label="目标值(元)" align="center" prop="goalValue" width="220">
  365. <template slot-scope="scope">
  366. <el-input-number @change="computeTotal" v-model="monthGoalMergeDetailsList[scope.$index].goalValue"
  367. :precision="2" :step="1" :min="0"></el-input-number>
  368. </template>
  369. </el-table-column>
  370. </el-table>
  371. </el-tab-pane>
  372. <el-tab-pane label="区域目标汇总(月)" name="zoneGoalSum" v-if="this.form.goalCategory == '销售区域'">
  373. <el-table max-height="300" :data="zoneGoalSumList" v-horizontal-scroll>
  374. <el-table-column label="序号" type="index" width="55" align="center" fixed />
  375. <el-table-column label="销售组织" align="center" prop="saleOrg" width="180">
  376. <template slot-scope="scope">
  377. <el-popover-select-v2 v-model="zoneGoalSumList[scope.$index].saleOrg" title="销售组织" valueKey="name"
  378. referName="ORG_PARAM" disabled :dataMapping="{ saleOrgCode: 'code', saleOrg: 'name'}"
  379. :source.sync="zoneGoalSumList[scope.$index]" placeholder="请输入销售组织">
  380. </el-popover-select-v2>
  381. </template>
  382. </el-table-column>
  383. <el-table-column label="销售区域" align="center" prop="saleZone" width="180">
  384. <template slot-scope="scope">
  385. <el-popover-select-v2 v-model="zoneGoalSumList[scope.$index].saleZone" title="销售区域" valueKey="name"
  386. referName="ORG_PARAM" disabled :dataMapping="{ saleZoneCode: 'code', saleZone: 'name'}"
  387. :source.sync="zoneGoalSumList[scope.$index]" placeholder="请输入销售区域">
  388. </el-popover-select-v2>
  389. </template>
  390. </el-table-column>
  391. <el-table-column label="月份" align="center" prop="monthly" width="250">
  392. <template slot-scope="scope">
  393. <el-date-picker disabled v-model="zoneGoalSumList[scope.$index].monthly" value-format="yyyy-MM"
  394. type="month" placeholder="选择月份">
  395. </el-date-picker>
  396. </template>
  397. </el-table-column>
  398. <el-table-column label="目标值(元)" align="center" prop="goalValue" width="220">
  399. <template slot-scope="scope">
  400. <el-input-number @change="computeTotal" v-model="zoneGoalSumList[scope.$index].goalValue"
  401. :precision="2" :step="1" :min="0" disabled></el-input-number>
  402. </template>
  403. </el-table-column>
  404. </el-table>
  405. </el-tab-pane>
  406. <el-tab-pane label="客户目标汇总(月)" name="customGoalSum" v-if="this.form.goalCategory == '销售区域'">
  407. <el-table max-height="300" :data="customGoalSumList" v-horizontal-scroll>
  408. <el-table-column label="序号" type="index" width="55" align="center" fixed />
  409. <el-table-column label="销售组织" align="center" prop="saleOrg" width="180">
  410. <template slot-scope="scope">
  411. <el-popover-select-v2 v-model="customGoalSumList[scope.$index].saleOrg" title="销售组织" valueKey="name"
  412. referName="ORG_PARAM" disabled :dataMapping="{ saleOrgCode: 'code', saleOrg: 'name'}"
  413. :source.sync="customGoalSumList[scope.$index]" placeholder="请输入销售组织">
  414. </el-popover-select-v2>
  415. </template>
  416. </el-table-column>
  417. <el-table-column label="销售区域" align="center" prop="saleZone" width="180">
  418. <template slot-scope="scope">
  419. <el-popover-select-v2 v-model="customGoalSumList[scope.$index].saleZone" title="销售区域"
  420. valueKey="name" referName="ORG_PARAM" disabled
  421. :dataMapping="{ saleZoneCode: 'code', saleZone: 'name'}"
  422. :source.sync="customGoalSumList[scope.$index]" placeholder="请输入销售区域">
  423. </el-popover-select-v2>
  424. </template>
  425. </el-table-column>
  426. <el-table-column label="客户" align="center" prop="custom" width="180">
  427. <template slot-scope="scope">
  428. <el-popover-select-v2 v-model="customGoalSumList[scope.$index].custom" title="客户" valueKey="name"
  429. referName="CUSTOMER_PARAM" disabled :dataMapping="{ customCode: 'code', custom: 'name'}"
  430. :source.sync="customGoalSumList[scope.$index]" placeholder="请输入客户">
  431. </el-popover-select-v2>
  432. </template>
  433. </el-table-column>
  434. <el-table-column label="月份" align="center" prop="monthly" width="250">
  435. <template slot-scope="scope">
  436. <el-date-picker disabled v-model="customGoalSumList[scope.$index].monthly" value-format="yyyy-MM"
  437. type="month" placeholder="选择月份">
  438. </el-date-picker>
  439. </template>
  440. </el-table-column>
  441. <el-table-column label="目标值(元)" align="center" prop="goalValue" width="220">
  442. <template slot-scope="scope">
  443. <el-input-number @change="computeTotal" v-model="customGoalSumList[scope.$index].goalValue"
  444. :precision="2" :step="1" :min="0" disabled></el-input-number>
  445. </template>
  446. </el-table-column>
  447. </el-table>
  448. </el-tab-pane>
  449. </el-tabs>
  450. <div slot="footer" class="dialog-footer" style="margin-left: 88%; margin-top: 1%">
  451. <el-button type="primary" @click="submitForm" size="medium">确 定</el-button>
  452. <el-button @click="cancel" size="medium">返 回</el-button>
  453. </div>
  454. </div>
  455. </el-form>
  456. </el-drawer>
  457. <!-- 用户导入对话框 -->
  458. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  459. <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
  460. :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
  461. :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
  462. <i class="el-icon-upload"></i>
  463. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  464. <div class="el-upload__tip text-center" slot="tip">
  465. <div class="el-upload__tip" slot="tip">
  466. <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
  467. </div>
  468. <span>仅允许导入xls、xlsx格式文件。</span>
  469. <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;"
  470. @click="importTemplate">下载模板</el-link>
  471. </div>
  472. </el-upload>
  473. <div slot="footer">
  474. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  475. <el-button @click="upload.open = false">取 消</el-button>
  476. </div>
  477. </el-dialog>
  478. <TreeRefers ref="treeQuery" @doSubmit="selectionsToInputForQuery" :single="true" />
  479. <TreeRefers ref="treeMain" @doSubmit="selectionsToInputForMain" :single="true" />
  480. <TreeRefers ref="treeDetails" @doSubmit="selectionsToInputForDetails" :single="true" />
  481. </div>
  482. </template>
  483. <script>
  484. import {
  485. listMonthGoalMerge,
  486. getMonthGoalMerge,
  487. delMonthGoalMerge,
  488. addMonthGoalMerge,
  489. updateMonthGoalMerge,
  490. submit
  491. } from "@/api/business/spd/goal_management/monthGoalMerge";
  492. import {
  493. getMonthGoalMergeDetails,
  494. delMonthGoalMergeDetails,
  495. mergeMonthSaleMergeDetails
  496. } from "@/api/business/spd/goal_management/monthGoalMergeDetails"
  497. import {
  498. getToken
  499. } from "@/utils/auth";
  500. import {
  501. getSummary
  502. } from "../../../../api/business/spd/goal_management/commonWays";
  503. import {
  504. rollBack
  505. } from "@/api/business/spd/goal_management/publicInterface";
  506. // 树形参照
  507. import TreeRefers from '@/components/Refers/treeRefer.vue'
  508. import ElPopoverSelectV2 from "@/components/popover-select-v2"
  509. export default {
  510. name: "MonthGoalMerge",
  511. components: {
  512. TreeRefers,
  513. ElPopoverSelectV2
  514. },
  515. dicts: ["sys_status", "oa_templete_id"],
  516. data() {
  517. return {
  518. // 遮罩层
  519. loading: true,
  520. // 选中数组
  521. ids: [],
  522. // 非单个禁用
  523. single: true,
  524. // 非多个禁用
  525. multiple: true,
  526. // 显示搜索条件
  527. showSearch: false,
  528. // 总条数
  529. total: 0,
  530. // 月销售目标合并表格数据
  531. monthGoalMergeList: [],
  532. monthGoalMergeDetailsList: [],
  533. zoneGoalSumList: [],
  534. customGoalSumList: [],
  535. // 弹出层标题
  536. title: "",
  537. // 是否显示弹出层
  538. open: false,
  539. // 查询参数
  540. queryParams: {
  541. pageNum: 1,
  542. pageSize: 10,
  543. code: null,
  544. goalName: null,
  545. documentDate: null,
  546. annual: null,
  547. monthly: null,
  548. customCode: null,
  549. custom: null,
  550. creatorCode: null,
  551. creator: null,
  552. deptCode: null,
  553. dept: null,
  554. goalCategory: null,
  555. goalSum: null,
  556. status: null,
  557. saleZoneCode: null,
  558. saleZone: null,
  559. oneLevelClassifyCode: null,
  560. oneLevelClassify: null,
  561. twoLevelClassifyCode: null,
  562. twoLevelClassify: null,
  563. params: {
  564. beginTime: null,
  565. endTime: null
  566. }
  567. },
  568. documentDateRange: null,
  569. pickerOptions: {
  570. shortcuts: [{
  571. text: '最近一周',
  572. onClick(picker) {
  573. const end = new Date();
  574. const start = new Date();
  575. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  576. picker.$emit('pick', [start, end]);
  577. }
  578. }, {
  579. text: '最近一个月',
  580. onClick(picker) {
  581. const end = new Date();
  582. const start = new Date();
  583. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  584. picker.$emit('pick', [start, end]);
  585. }
  586. }, {
  587. text: '最近三个月',
  588. onClick(picker) {
  589. const end = new Date();
  590. const start = new Date();
  591. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  592. picker.$emit('pick', [start, end]);
  593. }
  594. }]
  595. },
  596. // 表单参数
  597. form: {
  598. id: null,
  599. code: null,
  600. goalName: null,
  601. documentDate: null,
  602. annual: null,
  603. monthly: null,
  604. customCode: null,
  605. custom: null,
  606. creatorCode: null,
  607. creator: null,
  608. deptCode: null,
  609. dept: null,
  610. goalCategory: null,
  611. goalSum: null,
  612. status: null,
  613. saleZoneCode: null,
  614. saleZone: null,
  615. oneLevelClassifyCode: null,
  616. oneLevelClassify: null,
  617. twoLevelClassifyCode: null,
  618. twoLevelClassify: null,
  619. monthMergeDetailsList: null,
  620. oldMonthMergeDetailsList: null
  621. },
  622. formDetails: {
  623. id: null,
  624. code: null,
  625. saleOrg: null,
  626. saleZone: null,
  627. custom: null,
  628. dept: null,
  629. creator: null,
  630. department: null,
  631. oneLevelClassifyCode: null,
  632. oneLevelClassify: null,
  633. twoLevelClassifyCode: null,
  634. twoLevelClassify: null,
  635. materialCode: null,
  636. material: null,
  637. monthly: null,
  638. goalValue: null
  639. },
  640. // 表单校验
  641. rules: {
  642. documentDate: [{
  643. required: true,
  644. message: '单据日期不能为空',
  645. trigger: 'blur'
  646. }],
  647. annual: [{
  648. required: true,
  649. message: '年度不能为空',
  650. trigger: 'blur'
  651. }],
  652. monthly: [{
  653. required: true,
  654. message: '月份不能为空',
  655. trigger: 'blur'
  656. }],
  657. creator: [{
  658. required: true,
  659. message: '制单人不能为空',
  660. trigger: 'blur'
  661. }],
  662. dept: [{
  663. required: true,
  664. message: '部门不能为空',
  665. trigger: 'blur'
  666. }],
  667. goalCategory: [{
  668. required: true,
  669. message: '目标类型不能为空',
  670. trigger: 'blur'
  671. }],
  672. custom: [],
  673. saleZone: [],
  674. oneLevelClassify: [],
  675. twoLevelClassify: []
  676. },
  677. // 目标类型列表
  678. goalCategoryList: [{
  679. value: '客户维度',
  680. label: '客户维度'
  681. },
  682. {
  683. value: '销售区域',
  684. label: '销售区域'
  685. },
  686. {
  687. value: '一级分类',
  688. label: '一级分类'
  689. },
  690. {
  691. value: '二级分类',
  692. label: '二级分类'
  693. }
  694. ],
  695. // 树形参照
  696. referCondition: {
  697. type: '',
  698. isPage: true,
  699. title: '',
  700. index: null
  701. },
  702. classOptions: [],
  703. activeName: 'monthGoalMergeDetails',
  704. // 用户导入参数
  705. upload: {
  706. // 是否显示弹出层(用户导入)
  707. open: false,
  708. // 弹出层标题(用户导入)
  709. title: "",
  710. // 是否禁用上传
  711. isUploading: false,
  712. // 是否更新已经存在的用户数据
  713. updateSupport: 0,
  714. // 设置上传的请求头部
  715. headers: {
  716. Authorization: "Bearer " + getToken()
  717. },
  718. // 上传的地址
  719. url: process.env.VUE_APP_BASE_API + "/goal_management/annualSaleGoalMerge/importData"
  720. },
  721. //打开状态
  722. openStatus: null,
  723. };
  724. },
  725. created() {
  726. this.getList();
  727. },
  728. methods: {
  729. /** 查询月销售目标合并列表 */
  730. getList() {
  731. this.loading = true;
  732. listMonthGoalMerge(this.queryParams).then(response => {
  733. this.monthGoalMergeList = response.rows;
  734. this.total = response.total;
  735. this.monthGoalMergeList.forEach(item => {
  736. item.goalSum = item.goalSum.toFixed(2);
  737. })
  738. this.loading = false;
  739. });
  740. },
  741. getListDetails() {
  742. this.loading = true;
  743. getMonthGoalMergeDetails(this.form.id).then(response => {
  744. this.monthGoalMergeDetailsList = response.data;
  745. this.computeTotal()
  746. this.form.monthMergeDetailsList = this.monthGoalMergeDetailsList
  747. updateMonthGoalMerge(this.form).then(response => {})
  748. this.loading = false;
  749. });
  750. },
  751. // 取消按钮
  752. cancel() {
  753. this.open = false;
  754. this.reset();
  755. },
  756. // 表单重置
  757. reset() {
  758. this.form = {
  759. id: null,
  760. code: null,
  761. goalName: null,
  762. documentDate: null,
  763. annual: null,
  764. monthly: null,
  765. customCode: null,
  766. custom: null,
  767. creatorCode: null,
  768. creator: null,
  769. deptCode: null,
  770. dept: null,
  771. goalCategory: null,
  772. goalSum: null,
  773. status: null,
  774. saleZoneCode: null,
  775. saleZone: null,
  776. oneLevelClassifyCode: null,
  777. oneLevelClassify: null,
  778. twoLevelClassifyCode: null,
  779. twoLevelClassify: null,
  780. monthMergeDetailsList: null,
  781. oldMonthMergeDetailsList: null
  782. };
  783. this.resetForm("form");
  784. },
  785. /** 搜索按钮操作 */
  786. handleQuery() {
  787. this.queryParams.pageNum = 1;
  788. this.getList();
  789. },
  790. /** 重置按钮操作 */
  791. resetQuery() {
  792. this.queryParams = {
  793. pageNum: 1,
  794. pageSize: 10,
  795. code: null,
  796. goalName: null,
  797. documentDate: null,
  798. annual: null,
  799. monthly: null,
  800. customCode: null,
  801. custom: null,
  802. creatorCode: null,
  803. creator: null,
  804. deptCode: null,
  805. dept: null,
  806. goalCategory: null,
  807. goalSum: null,
  808. status: null,
  809. saleZoneCode: null,
  810. saleZone: null,
  811. oneLevelClassifyCode: null,
  812. oneLevelClassify: null,
  813. twoLevelClassifyCode: null,
  814. twoLevelClassify: null,
  815. params: {
  816. beginTime: null,
  817. endTime: null
  818. }
  819. }
  820. this.documentDateRange = null
  821. this.resetForm("queryForm");
  822. this.handleQuery();
  823. },
  824. // 多选框选中数据
  825. handleSelectionChange(selection) {
  826. this.ids = selection.map(item => item.id)
  827. this.single = selection.length !== 1
  828. this.multiple = !selection.length
  829. },
  830. /** 新增按钮操作 */
  831. handleAdd() {
  832. this.openStatus = 'add';
  833. this.reset();
  834. this.monthGoalMergeDetailsList = []
  835. this.customGoalSumList = []
  836. this.zoneGoalSumList = []
  837. this.activeName = 'monthGoalMergeDetails'
  838. this.open = true;
  839. this.title = "添加--月销售目标合并";
  840. this.form.documentDate = new Date().getFullYear().toString() + '-' + (new Date().getMonth() + 1).toString()
  841. .padStart(2, '0') + '-' + new Date().getDate().toString().padStart(2, '0')
  842. this.form.annual = new Date().getFullYear().toString()
  843. this.form.monthly = new Date().getFullYear().toString() + '-' + (new Date().getMonth() + 1).toString().padStart(
  844. 2, '0')
  845. this.form.creatorCode = this.$store.state.user.name
  846. this.form.creator = this.$store.state.user.nickName
  847. this.form.deptCode = this.$store.state.user.deptId
  848. this.form.dept = this.$store.state.user.deptName
  849. },
  850. handleAddDetails() {
  851. let list = {
  852. id: null,
  853. code: null,
  854. saleOrg: null,
  855. saleZone: null,
  856. custom: null,
  857. dept: null,
  858. creator: null,
  859. oneLevelClassifyCode: null,
  860. oneLevelClassify: null,
  861. twoLevelClassifyCode: null,
  862. twoLevelClassify: null,
  863. materialCode: null,
  864. material: null,
  865. department: null,
  866. num: null,
  867. monthly: null,
  868. goalValue: null
  869. }
  870. this.monthGoalMergeDetailsList.push(list)
  871. },
  872. /** 修改按钮操作 */
  873. handleUpdate(row) {
  874. this.openStatus = 'edit';
  875. this.reset();
  876. this.customGoalSumList = []
  877. this.zoneGoalSumList = []
  878. this.activeName = 'monthGoalMergeDetails'
  879. const id = row.id || this.ids
  880. getMonthGoalMerge(id).then(response => {
  881. this.form = response.data;
  882. this.form.goalSum = this.form.goalSum.toFixed(2)
  883. this.monthGoalMergeDetailsList = this.form.monthMergeDetailsList
  884. this.open = true;
  885. this.title = "修改--月销售目标合并";
  886. });
  887. },
  888. useDoubleClick(row) {
  889. this.openStatus = 'see';
  890. this.reset();
  891. this.customGoalSumList = []
  892. this.zoneGoalSumList = []
  893. this.activeName = 'monthGoalMergeDetails'
  894. const id = row.id || this.ids
  895. getMonthGoalMerge(id).then(response => {
  896. this.form = response.data;
  897. this.form.goalSum = this.form.goalSum.toFixed(2)
  898. this.monthGoalMergeDetailsList = this.form.monthMergeDetailsList
  899. this.open = true;
  900. this.title = "查看--月销售目标合并";
  901. });
  902. },
  903. // 复制按钮操作
  904. handleCopy(id) {
  905. this.openStatus = 'edit';
  906. this.reset()
  907. this.monthGoalMergeDetailsList = []
  908. this.customGoalSumList = []
  909. this.zoneGoalSumList = []
  910. this.activeName = 'monthGoalMergeDetails'
  911. getMonthGoalMerge(id).then(response => {
  912. this.form = response.data
  913. this.form.id = null
  914. this.form.code = null
  915. this.title = "添加--月销售目标合并";
  916. this.form.documentDate = new Date().getFullYear().toString() + '-' + (new Date().getMonth() + 1)
  917. .toString().padStart(2, '0') + '-' + new Date().getDate().toString().padStart(2, '0')
  918. this.form.annual = new Date().getFullYear().toString()
  919. this.form.monthly = new Date().getFullYear().toString() + '-' + (new Date().getMonth() + 1).toString()
  920. .padStart(2, '0')
  921. this.form.goalSum = 0
  922. this.form.goalSum = this.form.goalSum.toFixed(2)
  923. this.open = true
  924. this.changeGoalCategoryForm()
  925. })
  926. },
  927. /** 提交按钮 */
  928. submitForm() {
  929. this.$refs["form"].validate(valid => {
  930. if (valid) {
  931. if (this.form.id !== null) {
  932. this.form.monthMergeDetailsList = JSON.parse(JSON.stringify(this.monthGoalMergeDetailsList))
  933. console.log(this.form);
  934. updateMonthGoalMerge(this.form).then(response => {
  935. this.$modal.msgSuccess("修改成功");
  936. this.open = false;
  937. this.getList();
  938. });
  939. } else {
  940. this.form.status = '0'
  941. this.form.monthMergeDetailsList = this.monthGoalMergeDetailsList
  942. console.log(this.form);
  943. addMonthGoalMerge(this.form).then(response => {
  944. this.$modal.msgSuccess("新增成功");
  945. this.open = false;
  946. this.getList();
  947. });
  948. }
  949. }
  950. });
  951. },
  952. /** 删除按钮操作 */
  953. handleDelete(row) {
  954. const ids = row.id || this.ids;
  955. this.$modal.confirm('是否确认删除月销售目标合并单据编号为"' + row.code + '"的数据项?').then(function () {
  956. return delMonthGoalMerge(ids);
  957. }).then(() => {
  958. this.getList();
  959. this.$modal.msgSuccess("删除成功");
  960. }).catch(() => {});
  961. },
  962. handleDeleteDetails(index, row) {
  963. if (this.form.id === null) {
  964. this.monthGoalMergeDetailsList.splice(index, 1)
  965. this.computeTotal()
  966. } else {
  967. if (row.id !== null) {
  968. this.$modal.confirm('是否确认删除月销售目标合并明细序号为"' + (index + 1) + '"的数据项?').then(function () {
  969. return delMonthGoalMergeDetails(row.id);
  970. }).then(() => {
  971. this.getListDetails();
  972. this.$modal.msgSuccess("删除成功");
  973. }).catch(() => {});
  974. } else {
  975. this.monthGoalMergeDetailsList.splice(index, 1)
  976. this.$message.success('删除成功')
  977. this.computeTotal()
  978. }
  979. }
  980. },
  981. /** 导出按钮操作 */
  982. handleExport() {
  983. this.download('goal_management/monthGoalMerge/export', {
  984. ...this.queryParams
  985. }, `monthGoalMerge${new Date().getTime()}.xlsx`)
  986. },
  987. handleExportDetails() {
  988. this.download('goal_management/monthGoalMergeDetails/export', {
  989. ...this.queryParams
  990. }, `monthSaleMergeDetails_${new Date().getTime()}.xlsx`)
  991. },
  992. // 树形参照
  993. chooseTreeReferForQuery(type, isPage, title) {
  994. this.referCondition.type = type
  995. this.referCondition.isPage = isPage
  996. this.referCondition.title = title
  997. this.$refs.treeQuery.init(this.referCondition)
  998. },
  999. chooseTreeReferForMain(type, isPage, title) {
  1000. this.referCondition.type = type
  1001. this.referCondition.isPage = isPage
  1002. this.referCondition.title = title
  1003. this.$refs.treeMain.init(this.referCondition)
  1004. },
  1005. chooseTreeReferForDetails(type, isPage, title, index) {
  1006. this.referCondition.type = type
  1007. this.referCondition.isPage = isPage
  1008. this.referCondition.title = title
  1009. this.referCondition.index = index
  1010. this.$refs.treeDetails.init(this.referCondition)
  1011. },
  1012. selectionsToInputForQuery(selection) {
  1013. this.classOptions = selection;
  1014. if (this.referCondition.title === '一级物料分类') {
  1015. if (this.classOptions[0].code.length > 2) {
  1016. return this.$message.info('请在一级分类下选择');
  1017. }
  1018. this.queryParams.oneLevelClassifyCode = selection[0].code
  1019. this.queryParams.oneLevelClassify = selection[0].name
  1020. console.log(this.queryParams.oneLevelClassifyCode, 'this.queryParams.oneLevelClassifyCode')
  1021. console.log(this.queryParams.oneLevelClassify, 'this.queryParams.oneLevelClassify')
  1022. } else if (this.referCondition.title === '二级物料分类') {
  1023. if (this.classOptions[0].code.lastIndexOf("-") == 3 || this.classOptions[0].code.indexOf("90") == 0) {
  1024. this.queryParams.twoLevelClassifyCode = selection[0].code
  1025. this.queryParams.twoLevelClassify = selection[0].name
  1026. } else {
  1027. return this.$message.info('请在二级分类下选择')
  1028. }
  1029. }
  1030. },
  1031. selectionsToInputForMain(selection) {
  1032. this.classOptions = selection;
  1033. if (this.referCondition.title === '一级物料分类') {
  1034. if (this.classOptions[0].code.length > 2) {
  1035. return this.$message.info('请在一级分类下选择');
  1036. }
  1037. this.form.oneLevelClassifyCode = selection[0].code
  1038. this.form.oneLevelClassify = selection[0].name
  1039. } else if (this.referCondition.title === '二级物料分类') {
  1040. if (this.classOptions[0].code.lastIndexOf("-") == 3 || this.classOptions[0].code.indexOf("90") == 0) {
  1041. this.form.twoLevelClassifyCode = selection[0].code
  1042. this.form.twoLevelClassify = selection[0].name
  1043. } else {
  1044. return this.$message.info('请在二级分类下选择')
  1045. }
  1046. }
  1047. },
  1048. selectionsToInputForDetails(selection) {
  1049. this.classOptions = selection;
  1050. if (this.referCondition.title === '一级物料分类') {
  1051. if (this.classOptions[0].code.length > 2) {
  1052. return this.$message.info('请在一级分类中选择')
  1053. }
  1054. if (selection.code !== this.monthGoalMergeDetailsList[this.referCondition.index].oneLevelClassifyCode) {
  1055. this.monthGoalMergeDetailsList[this.referCondition.index].twoLevelClassifyCode = null
  1056. this.monthGoalMergeDetailsList[this.referCondition.index].twoLevelClassify = null
  1057. }
  1058. this.monthGoalMergeDetailsList[this.referCondition.index].oneLevelClassifyCode = selection.code
  1059. this.monthGoalMergeDetailsList[this.referCondition.index].oneLevelClassify = selection.name
  1060. } else if (this.referCondition.title === '二级物料分类') {
  1061. if (this.classOptions[0].code.lastIndexOf("-") == 3 || this.classOptions[0].code.indexOf("90") == 0) {
  1062. return this.$message.info('请在二级分类中选择')
  1063. } else if (selection.code[0] !== this.monthGoalMergeDetailsList[this.referCondition.index]
  1064. .oneLevelClassifyCode) {
  1065. return this.$message.error('所选择的二级物料分类不属于一级分类')
  1066. }
  1067. this.monthGoalMergeDetailsList[this.referCondition.index].twoLevelClassifyCode = selection.code
  1068. this.monthGoalMergeDetailsList[this.referCondition.index].twoLevelClassify = selection.name
  1069. }
  1070. },
  1071. // 改变查询表单的目标分类
  1072. changeGoalCategoryQuery() {
  1073. let condition = this.queryParams.goalCategory
  1074. if (condition === null) {
  1075. this.queryParams.custom = null
  1076. this.queryParams.customCode = null
  1077. this.queryParams.saleZone = null
  1078. this.queryParams.saleZoneCode = null
  1079. this.queryParams.oneLevelClassify = null
  1080. this.queryParams.oneLevelClassifyCode = null
  1081. this.queryParams.twoLevelClassify = null
  1082. this.queryParams.twoLevelClassifyCode = null
  1083. } else if (condition === '客户维度') {
  1084. this.queryParams.saleZone = null
  1085. this.queryParams.saleZoneCode = null
  1086. this.queryParams.oneLevelClassify = null
  1087. this.queryParams.oneLevelClassifyCode = null
  1088. this.queryParams.twoLevelClassify = null
  1089. this.queryParams.twoLevelClassifyCode = null
  1090. } else if (condition === '销售区域') {
  1091. this.queryParams.custom = null
  1092. this.queryParams.customCode = null
  1093. this.queryParams.oneLevelClassify = null
  1094. this.queryParams.oneLevelClassifyCode = null
  1095. this.queryParams.twoLevelClassify = null
  1096. this.queryParams.twoLevelClassifyCode = null
  1097. } else if (condition === '一级分类') {
  1098. this.queryParams.custom = null
  1099. this.queryParams.customCode = null
  1100. this.queryParams.saleZone = null
  1101. this.queryParams.saleZoneCode = null
  1102. this.queryParams.twoLevelClassify = null
  1103. this.queryParams.twoLevelClassifyCode = null
  1104. } else if (condition === '二级分类') {
  1105. this.queryParams.custom = null
  1106. this.queryParams.customCode = null
  1107. this.queryParams.saleZone = null
  1108. this.queryParams.saleZoneCode = null
  1109. this.queryParams.oneLevelClassify = null
  1110. this.queryParams.oneLevelClassifyCode = null
  1111. }
  1112. },
  1113. changeGoalCategoryForm() {
  1114. let condition = this.form.goalCategory
  1115. if (condition === null) {
  1116. this.form.custom = null
  1117. this.form.customCode = null
  1118. this.form.saleZone = null
  1119. this.form.saleZoneCode = null
  1120. this.form.oneLevelClassify = null
  1121. this.form.oneLevelClassifyCode = null
  1122. this.form.twoLevelClassify = null
  1123. this.form.twoLevelClassifyCode = null
  1124. this.rules.custom = []
  1125. this.rules.saleZone = []
  1126. this.rules.oneLevelClassify = []
  1127. this.rules.twoLevelClassify = []
  1128. } else if (condition === '客户维度') {
  1129. this.form.saleZone = null
  1130. this.form.saleZoneCode = null
  1131. this.form.oneLevelClassify = null
  1132. this.form.oneLevelClassifyCode = null
  1133. this.form.twoLevelClassify = null
  1134. this.form.twoLevelClassifyCode = null
  1135. this.rules.custom = [{
  1136. required: true,
  1137. message: '客户不能为空',
  1138. trigger: 'blur'
  1139. }]
  1140. this.rules.saleZone = []
  1141. this.rules.oneLevelClassify = []
  1142. this.rules.twoLevelClassify = []
  1143. } else if (condition === '销售区域') {
  1144. this.form.custom = null
  1145. this.form.customCode = null
  1146. this.form.oneLevelClassify = null
  1147. this.form.oneLevelClassifyCode = null
  1148. this.form.twoLevelClassify = null
  1149. this.form.twoLevelClassifyCode = null
  1150. this.rules.custom = []
  1151. this.rules.saleZone = [{
  1152. required: true,
  1153. message: '销售区域不能为空',
  1154. trigger: 'blur'
  1155. }]
  1156. this.rules.oneLevelClassify = []
  1157. this.rules.twoLevelClassify = []
  1158. } else if (condition === '一级分类') {
  1159. this.form.custom = null
  1160. this.form.customCode = null
  1161. this.form.saleZone = null
  1162. this.form.saleZoneCode = null
  1163. this.form.twoLevelClassify = null
  1164. this.form.twoLevelClassifyCode = null
  1165. this.rules.custom = []
  1166. this.rules.saleZone = []
  1167. this.rules.oneLevelClassify = [{
  1168. required: true,
  1169. message: '一级分类不能为空',
  1170. trigger: 'blur'
  1171. }]
  1172. this.rules.twoLevelClassify = []
  1173. } else if (condition === '二级分类') {
  1174. this.form.custom = null
  1175. this.form.customCode = null
  1176. this.form.saleZone = null
  1177. this.form.saleZoneCode = null
  1178. this.form.oneLevelClassify = null
  1179. this.form.oneLevelClassifyCode = null
  1180. this.rules.custom = []
  1181. this.rules.saleZone = []
  1182. this.rules.oneLevelClassify = []
  1183. this.rules.twoLevelClassify = [{
  1184. required: true,
  1185. message: '二级分类不能为空',
  1186. trigger: 'blur'
  1187. }]
  1188. }
  1189. },
  1190. // 关闭抽屉
  1191. handleClose(done) {
  1192. this.$confirm('确认关闭?')
  1193. .then(_ => {
  1194. done();
  1195. })
  1196. .catch(_ => {});
  1197. },
  1198. // 复制明细
  1199. handleCopyDetails(row) {
  1200. let list = {
  1201. id: null,
  1202. code: row.code,
  1203. saleOrg: row.saleOrg,
  1204. saleZone: row.saleZone,
  1205. custom: row.custom,
  1206. dept: row.dept,
  1207. creator: row.creator,
  1208. oneLevelClassifyCode: row.oneLevelClassifyCode,
  1209. oneLevelClassify: row.oneLevelClassify,
  1210. twoLevelClassifyCode: row.twoLevelClassifyCode,
  1211. twoLevelClassify: row.twoLevelClassify,
  1212. materialCode: row.materialCode,
  1213. material: row.material,
  1214. department: row.department,
  1215. num: row.num,
  1216. monthly: row.monthly,
  1217. goalValue: row.goalValue
  1218. }
  1219. this.monthGoalMergeDetailsList.push(list)
  1220. this.computeTotal()
  1221. },
  1222. // 计算主表合计
  1223. computeTotal() {
  1224. let list = this.monthGoalMergeDetailsList
  1225. let sum = 0
  1226. for (const listElement of list) {
  1227. sum = (sum * 1000000 + listElement.goalValue * 1000000) / 1000000
  1228. }
  1229. this.form.goalSum = sum.toFixed(2)
  1230. },
  1231. getSummaries(param) {
  1232. return getSummary(param)
  1233. },
  1234. // 合并数据
  1235. clickMerge() {
  1236. if (this.form.id !== null) {
  1237. this.form.oldMonthMergeDetailsList = JSON.parse(JSON.stringify(this.form.monthMergeDetailsList))
  1238. }
  1239. if (this.activeName !== 'monthGoalMergeDetails') {
  1240. return this.$message.error('当前标签不是月销售目标合并明细')
  1241. }
  1242. let query = JSON.parse(JSON.stringify(this.form))
  1243. query.monthGoalMergeDetailsList = []
  1244. if (query.goalCategory === null || query.goalCategory === '') {
  1245. return this.$message.error('请输入目标分类')
  1246. } else if (query.goalCategory === '销售区域') {
  1247. if (query.saleZone === null) {
  1248. return this.$message.error('请输入销售区域')
  1249. }
  1250. } else if (query.goalCategory === '一级分类') {
  1251. if (query.oneLevelClassify === null) {
  1252. return this.$message.error('请输入一级分类')
  1253. }
  1254. } else if (query.goalCategory === '二级分类') {
  1255. if (query.twoLevelClassify === null) {
  1256. return this.$message.error('请输入二级分类')
  1257. }
  1258. } else if (query.goalCategory === '客户维度') {
  1259. if (query.custom === null) {
  1260. return this.$message.error('请输入客户')
  1261. }
  1262. }
  1263. mergeMonthSaleMergeDetails(query).then(response => {
  1264. console.log(response, 'response');
  1265. if (response.data.monthGoalMergeDetails.length > 0) {
  1266. this.monthGoalMergeDetailsList = response.data.monthGoalMergeDetails
  1267. this.computeTotal()
  1268. } else {
  1269. return this.$message.warning('未查到相关数据')
  1270. }
  1271. })
  1272. },
  1273. setBeginAndEnd() {
  1274. let array = this.documentDateRange
  1275. if (array !== null) {
  1276. this.queryParams.params.beginTime = array[0]
  1277. this.queryParams.params.endTime = array[1]
  1278. } else {
  1279. this.queryParams.params.beginTime = null
  1280. this.queryParams.params.endTime = null
  1281. }
  1282. },
  1283. handleCommand(command) {
  1284. // 执行对应的功能
  1285. if (command === 'importModel') {
  1286. // 执行选项1的功能
  1287. console.log('导入模板');
  1288. } else if (command === 'import') {
  1289. // 执行选项2的功能
  1290. console.log('导入');
  1291. } else if (command === 'export') {
  1292. console.log('导出主表');
  1293. this.handleExport()
  1294. } else if (command === 'exportDetails') {
  1295. console.log('导出明细');
  1296. this.handleExportDetails()
  1297. }
  1298. },
  1299. // 获得区域目标汇总or客户目标汇总
  1300. getNewTwoArray() {
  1301. let arr = JSON.parse(JSON.stringify(this.monthGoalMergeDetailsList))
  1302. // 如果子表标签是annualSaleGoalMergeDetails 或者 主表的目标分类是“销售区域”
  1303. if (this.activeName === 'monthGoalMergeDetails' || this.form.goalCategory !== '销售区域') {
  1304. this.zoneGoalSumList = null
  1305. this.customGoalSumList = null
  1306. return
  1307. }
  1308. // 根据某三个属性进行合并并相加totalGoal的函数
  1309. const mergeAndSumTotalGoal = (array) => {
  1310. return Array.from(array.reduce((map, obj) => {
  1311. let key = null
  1312. if (this.activeName === 'zoneGoalSum') {
  1313. key = `${obj.saleOrg}-${obj.saleZone}-${obj.monthly}`
  1314. } else if (this.activeName === 'customerGoalSum') {
  1315. key = `${obj.saleOrg}-${obj.saleZone}-${obj.custom}-${obj.monthly}`
  1316. }
  1317. if (map.has(key)) {
  1318. const existingObj = map.get(key)
  1319. existingObj.goalValue += obj.goalValue
  1320. } else {
  1321. map.set(key, {
  1322. ...obj
  1323. })
  1324. }
  1325. return map
  1326. }, new Map()).values())
  1327. }
  1328. // 调用合并函数
  1329. const mergedArray = mergeAndSumTotalGoal(arr)
  1330. if (this.activeName === 'zoneGoalSum') {
  1331. this.zoneGoalSumList = mergedArray
  1332. } else if (this.activeName === 'customGoalSum') {
  1333. this.customGoalSumList = mergedArray
  1334. }
  1335. },
  1336. /** 导入按钮操作 */
  1337. handleImport() {
  1338. this.upload.open = true;
  1339. this.upload.title = "月销售目标合并导入";
  1340. this.upload.url = process.env.VUE_APP_BASE_API + "goal_management/monthGoalMerge/importData"
  1341. },
  1342. /** 下载模板操作 */
  1343. importTemplate() {
  1344. this.download('goal_management/monthGoalMerge/importTemplate', {},
  1345. `monthGoalMerge_${new Date().getTime()}.xlsx`)
  1346. },
  1347. // 文件上传中处理
  1348. handleFileUploadProgress(event, file, fileList) {
  1349. this.upload.isUploading = true;
  1350. },
  1351. // 文件上传成功处理
  1352. handleFileSuccess(response, file, fileList) {
  1353. console.log(response);
  1354. this.upload.open = false;
  1355. this.upload.isUploading = false;
  1356. this.$refs.upload.clearFiles();
  1357. this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response
  1358. .msg + "</div>", "导入结果", {
  1359. dangerouslyUseHTMLString: true
  1360. });
  1361. this.getList();
  1362. },
  1363. // 提交上传文件
  1364. submitFileForm() {
  1365. this.$refs.upload.submit();
  1366. },
  1367. async handleSubmit(row) {
  1368. this.$modal.loading("提交中...");
  1369. try {
  1370. const {
  1371. msg,
  1372. code
  1373. } = await submit(row.id);
  1374. if (code === 200) {
  1375. this.$modal.notifySuccess("提交成功");
  1376. this.$modal.closeLoading();
  1377. row.status = '1';
  1378. }
  1379. } catch (err) {
  1380. console.error(err);
  1381. this.$modal.closeLoading();
  1382. }
  1383. },
  1384. //收回
  1385. handleReback(row) {
  1386. this.$modal.loading("收回中...");
  1387. let params = {
  1388. billCode: row.code,
  1389. fdId: row.flowId,
  1390. fdTemplateId: this.dict.type.oa_templete_id.find(item => {
  1391. return item.label == "销售目标"
  1392. }).value,
  1393. billMaker: row.createBy,
  1394. type: "4"
  1395. }
  1396. rollBack(params).then(res => {
  1397. if (res.code === 200) {
  1398. this.$modal.notifySuccess("收回成功");
  1399. this.$modal.closeLoading();
  1400. }
  1401. }).catch(err => {
  1402. this.$message.error(err);
  1403. this.$modal.closeLoading();
  1404. })
  1405. },
  1406. }
  1407. };
  1408. </script>