MonthGoalMerge.vue 57 KB

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