MonthGoalMerge.vue 54 KB

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