MonthGoalMerge.vue 57 KB

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