MonthGoalMerge.vue 58 KB

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