MonthGoalMerge.vue 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="编码" prop="code">
  5. <el-input v-model="queryParams.code" placeholder="请输入编码" clearable @keyup.enter.native="handleQuery"/>
  6. </el-form-item>
  7. <el-form-item label="目标名称" prop="goalName">
  8. <el-input v-model="queryParams.goalName" placeholder="请输入目标名称" clearable @keyup.enter.native="handleQuery"/>
  9. </el-form-item>
  10. <el-form-item label="单据日期" prop="documentDate">
  11. <el-date-picker
  12. v-model="documentDateRange"
  13. @change="setBeginAndEnd"
  14. type="daterange"
  15. align="right"
  16. unlink-panels
  17. range-separator="至"
  18. start-placeholder="开始日期"
  19. end-placeholder="结束日期"
  20. value-format="yyyy-MM-dd"
  21. @keyup.enter.native="handleQuery"
  22. :picker-options="pickerOptions">
  23. </el-date-picker>
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  27. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  28. </el-form-item>
  29. <el-form-item label="年度" prop="annual">
  30. <el-date-picker
  31. v-model="queryParams.annual"
  32. type="year"
  33. clearable
  34. value-format="yyyy"
  35. @keyup.enter.native="handleQuery"
  36. placeholder="请输入年度">
  37. </el-date-picker>
  38. </el-form-item>
  39. <el-form-item label="月份" prop="monthly">
  40. <el-date-picker
  41. v-model="queryParams.monthly"
  42. type="month"
  43. clearable
  44. value-format="yyyy-MM"
  45. @keyup.enter.native="handleQuery"
  46. placeholder="请输入月份">
  47. </el-date-picker>
  48. </el-form-item>
  49. <el-form-item label="制单人" prop="creator">
  50. <el-popover-select-v2 v-model="queryParams.creator" title="制单人" valueKey="name"
  51. referName="CONTACTS_PARAM"
  52. :dataMapping="{ creatorCode: 'code', creator: 'name'}"
  53. :source.sync="queryParams" placeholder="请输入制单人">
  54. </el-popover-select-v2>
  55. </el-form-item>
  56. <el-form-item label="部门" prop="dept">
  57. <el-popover-select-v2 v-model="queryParams.dept" title="部门" valueKey="name"
  58. referName="DEPT_PARAM"
  59. :dataMapping="{ deptCode: 'code', dept: 'name'}"
  60. :source.sync="queryParams" placeholder="请输入部门">
  61. </el-popover-select-v2>
  62. </el-form-item>
  63. <el-form-item label="目标类型" prop="goalCategory">
  64. <el-select v-model="queryParams.goalCategory" placeholder="请输入目标类型" @change="changeGoalCategoryQuery" @keyup.enter.native="handleQuery">
  65. <el-option
  66. v-for="item in goalCategoryList"
  67. :key="item.value"
  68. :label="item.label"
  69. :value="item.value">
  70. </el-option>
  71. </el-select>
  72. </el-form-item>
  73. <el-form-item v-if="queryParams.goalCategory === '客户维度'" label="客户" prop="custom">
  74. <el-popover-select-v2 v-model="queryParams.custom" title="客户" valueKey="name"
  75. referName="CUSTOMER_PARAM"
  76. :dataMapping="{ customCode: 'code', custom: 'name'}"
  77. :source.sync="queryParams" placeholder="请输入客户">
  78. </el-popover-select-v2>
  79. </el-form-item>
  80. <el-form-item v-if="queryParams.goalCategory === '销售区域'" label="销售区域" prop="saleZone">
  81. <el-popover-select-v2 v-model="queryParams.saleZoneCode" title="销售区域" valueKey="name"
  82. referName="DEPT_PARAM"
  83. :dataMapping="{ saleZoneCode: 'code', saleZone: 'name'}"
  84. :source.sync="queryParams" placeholder="请输入销售区域">
  85. </el-popover-select-v2>
  86. </el-form-item>
  87. <el-form-item v-if="queryParams.goalCategory === '一级分类'" label="一级分类" prop="oneLevelClassify">
  88. <el-select v-model="queryParams.oneLevelClassify" size="mini" clearable
  89. @focus="chooseTreeReferForQuery('MATERIALCLASSIFY_PARAM', false, '一级物料分类')"
  90. style="width: 200px">
  91. <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
  92. </el-select>
  93. </el-form-item>
  94. <el-form-item v-if="queryParams.goalCategory === '二级分类'" label="二级分类" prop="custom">
  95. <el-select v-model="queryParams.twoLevelClassify" size="mini" clearable
  96. @focus="chooseTreeReferForQuery('MATERIALCLASSIFY_PARAM', false, '二级物料分类')"
  97. style="width: 200px">
  98. <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
  99. </el-select>
  100. </el-form-item>
  101. </el-form>
  102. <el-row :gutter="10" class="mb8">
  103. <el-col :span="1.5">
  104. <el-button
  105. type="primary"
  106. plain
  107. icon="el-icon-plus"
  108. size="mini"
  109. @click="handleAdd"
  110. v-hasPermi="['goal_management:monthGoalMerge:add']"
  111. >新增
  112. </el-button>
  113. </el-col>
  114. <el-col :span="1.5">
  115. <el-button
  116. type="danger"
  117. plain
  118. icon="el-icon-delete"
  119. size="mini"
  120. :disabled="multiple"
  121. @click="handleDelete"
  122. v-hasPermi="['goal_management:monthGoalMerge:remove']"
  123. >删除
  124. </el-button>
  125. </el-col>
  126. <el-col :span="1.5">
  127. <el-button
  128. type="warning"
  129. plain
  130. icon="el-icon-download"
  131. size="mini"
  132. @click="handleExport"
  133. v-hasPermi="['goal_management:monthGoalMerge:export']"
  134. >导出
  135. </el-button>
  136. </el-col>
  137. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  138. </el-row>
  139. <el-table v-loading="loading" :data="monthGoalMergeList" @selection-change="handleSelectionChange">
  140. <el-table-column type="selection" width="55" align="center"/>
  141. <el-table-column label="编码" align="center" prop="code"/>
  142. <el-table-column label="目标名称" align="center" prop="goalName"/>
  143. <el-table-column label="单据日期" align="center" prop="documentDate" width="180">
  144. <template slot-scope="scope">
  145. <span>{{ parseTime(scope.row.documentDate, '{y}-{m}-{d}') }}</span>
  146. </template>
  147. </el-table-column>
  148. <el-table-column label="年度" align="center" prop="annual"/>
  149. <el-table-column label="月份" align="center" prop="monthly"/>
  150. <el-table-column label="客户" align="center" prop="custom"/>
  151. <el-table-column label="制单人" align="center" prop="creator"/>
  152. <el-table-column label="部门" align="center" prop="dept"/>
  153. <el-table-column label="目标类型" align="center" prop="goalCategory"/>
  154. <el-table-column label="目标值合计" align="center" prop="goalSum"/>
  155. <el-table-column label="单据状态" align="center" prop="documentStatus"/>
  156. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  157. <template slot-scope="scope">
  158. <el-button
  159. size="mini"
  160. type="text"
  161. icon="el-icon-edit"
  162. @click="handleUpdate(scope.row)"
  163. v-hasPermi="['goal_management:monthGoalMerge:edit']"
  164. >修改
  165. </el-button>
  166. <el-button
  167. size="mini"
  168. type="text"
  169. icon="el-icon-delete"
  170. @click="handleDelete(scope.row)"
  171. v-hasPermi="['goal_management:monthGoalMerge:remove']"
  172. >删除
  173. </el-button>
  174. </template>
  175. </el-table-column>
  176. </el-table>
  177. <pagination
  178. v-show="total>0"
  179. :total="total"
  180. :page.sync="queryParams.pageNum"
  181. :limit.sync="queryParams.pageSize"
  182. @pagination="getList"
  183. />
  184. <!-- 添加或修改月销售目标合并抽屉 -->
  185. <el-drawer :title="title" :visible.sync="open" direction="rtl" :before-close="handleClose" size="100%">
  186. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  187. <el-row :gutter="20">
  188. <el-col :span="6">
  189. <el-form-item label="编码" prop="code">
  190. <el-input v-model="form.code" placeholder="编码后端自动生成" disabled/>
  191. </el-form-item>
  192. </el-col>
  193. <el-col :span="6">
  194. <el-form-item label="目标名称" prop="goalName">
  195. <el-input v-model="form.goalName" placeholder="目标名称后端自动生成" disabled/>
  196. </el-form-item>
  197. </el-col>
  198. <el-col :span="6">
  199. <el-form-item label="单据日期" prop="documentDate">
  200. <el-date-picker clearable
  201. v-model="form.documentDate"
  202. type="date"
  203. value-format="yyyy-MM-dd"
  204. placeholder="请选择单据日期">
  205. </el-date-picker>
  206. </el-form-item>
  207. </el-col>
  208. <el-col :span="6">
  209. <el-form-item label="年度" prop="annual">
  210. <el-date-picker clearable
  211. v-model="form.annual"
  212. type="year"
  213. value-format="yyyy"
  214. placeholder="请输入年度">
  215. </el-date-picker>
  216. </el-form-item>
  217. </el-col>
  218. </el-row>
  219. <el-row :gutter="20">
  220. <el-col :span="6">
  221. <el-form-item label="月份" prop="monthly">
  222. <el-date-picker clearable
  223. v-model="form.monthly"
  224. type="month"
  225. value-format="yyyy-MM"
  226. placeholder="请输入月份">
  227. </el-date-picker>
  228. </el-form-item>
  229. </el-col>
  230. <el-col :span="6">
  231. <el-form-item label="制单人" prop="creator">
  232. <el-popover-select-v2 v-model="form.creator" title="制单人" valueKey="name"
  233. referName="CONTACTS_PARAM"
  234. :dataMapping="{ creatorCode: 'code', creator: 'name'}"
  235. :source.sync="form" placeholder="请输入制单人">
  236. </el-popover-select-v2>
  237. </el-form-item>
  238. </el-col>
  239. <el-col :span="6">
  240. <el-form-item label="部门" prop="dept">
  241. <el-popover-select-v2 v-model="form.dept" title="部门" valueKey="name"
  242. referName="DEPT_PARAM"
  243. :dataMapping="{ deptCode: 'code', dept: 'name'}"
  244. :source.sync="form" placeholder="请输入部门">
  245. </el-popover-select-v2>
  246. </el-form-item>
  247. </el-col>
  248. <el-col :span="6">
  249. <el-form-item label="目标类型" prop="goalCategory">
  250. <el-select v-model="form.goalCategory" placeholder="请输入目标类型" @change="changeGoalCategoryForm" @keyup.enter.native="handleQuery">
  251. <el-option
  252. v-for="item in goalCategoryList"
  253. :key="item.value"
  254. :label="item.label"
  255. :value="item.value">
  256. </el-option>
  257. </el-select>
  258. </el-form-item>
  259. </el-col>
  260. </el-row>
  261. <el-row :gutter="20">
  262. <el-col :span="6">
  263. <el-form-item label="目标值合计" prop="goalSum">
  264. <el-input v-model="form.goalSum" placeholder="目标值合计自动计算" disabled/>
  265. </el-form-item>
  266. </el-col>
  267. <el-col :span="6">
  268. <el-form-item v-if="form.goalCategory === '客户维度'" label="客户" prop="custom">
  269. <el-popover-select-v2 v-model="form.custom" title="客户" valueKey="name"
  270. referName="CUSTOMER_PARAM"
  271. :dataMapping="{ customCode: 'code', custom: 'name'}"
  272. :source.sync="form" placeholder="请输入客户">
  273. </el-popover-select-v2>
  274. </el-form-item>
  275. <el-form-item v-if="form.goalCategory === '销售区域'" label="销售区域" prop="saleZone">
  276. <el-popover-select-v2 v-model="form.saleZoneCode" title="销售区域" valueKey="name"
  277. referName="ORG_PARAM"
  278. :dataMapping="{ saleZoneCode: 'code', saleZone: 'name'}"
  279. :source.sync="form" placeholder="请输入销售区域">
  280. </el-popover-select-v2>
  281. </el-form-item>
  282. <el-form-item v-if="form.goalCategory === '一级分类'" label="一级分类" prop="oneLevelClassify">
  283. <el-select v-model="form.oneLevelClassify" size="mini" clearable
  284. @focus="chooseTreeReferForMain('MATERIALCLASSIFY_PARAM', false, '一级物料分类')"
  285. style="width: 200px">
  286. <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
  287. </el-select>
  288. </el-form-item>
  289. <el-form-item v-if="form.goalCategory === '二级分类'" label="二级分类" prop="custom">
  290. <el-select v-model="form.twoLevelClassify" size="mini" clearable
  291. @focus="chooseTreeReferForMain('MATERIALCLASSIFY_PARAM', false, '二级物料分类')"
  292. style="width: 200px">
  293. <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
  294. </el-select>
  295. </el-form-item>
  296. </el-col>
  297. <el-col :span="6">
  298. <el-form-item label="操作">
  299. <el-button type="primary" @click="submitForm">确 定</el-button>
  300. <el-button @click="cancel">取 消</el-button>
  301. </el-form-item>
  302. </el-col>
  303. </el-row>
  304. </el-form>
  305. <el-row :gutter="10" class="mb8">
  306. <!-- <el-col :span="1.5">
  307. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAddDetails">增 行</el-button>
  308. </el-col>-->
  309. <el-col :span="1.5">
  310. <el-button type="primary" plain icon="el-icon-folder-opened" size="mini" @click="clickMerge">合 并</el-button>
  311. </el-col>
  312. </el-row>
  313. <el-tabs v-model="activeName">
  314. <el-tab-pane label="月销售目标合并明细" name="monthGoalMergeDetails">
  315. <el-table v-loading="loading" :data="monthGoalMergeDetailsList" @selection-change="handleSelectionChange">
  316. <el-table-column type="selection" width="55" align="center" fixed />
  317. <el-table-column label="销售组织" align="center" prop="saleOrg" width="180">
  318. <template slot-scope="scope">
  319. <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].saleOrg" title="销售组织" valueKey="name"
  320. referName="CUSTOMER_PARAM" disabled
  321. :dataMapping="{ saleOrgCode: 'code', saleOrg: 'name'}"
  322. :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入销售组织">
  323. </el-popover-select-v2>
  324. </template>
  325. </el-table-column>
  326. <el-table-column label="销售区域" align="center" prop="saleZone" width="180">
  327. <template slot-scope="scope">
  328. <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].saleZone" title="销售区域" valueKey="name"
  329. referName="CUSTOMER_PARAM" disabled
  330. :dataMapping="{ saleZoneCode: 'code', saleZone: 'name'}"
  331. :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入销售区域">
  332. </el-popover-select-v2>
  333. </template>
  334. </el-table-column>
  335. <el-table-column label="客户" align="center" prop="custom" width="180">
  336. <template slot-scope="scope">
  337. <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].custom" title="客户" valueKey="name"
  338. referName="CUSTOMER_PARAM" disabled
  339. :dataMapping="{ customCode: 'code', custom: 'name'}"
  340. :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入客户">
  341. </el-popover-select-v2>
  342. </template>
  343. </el-table-column>
  344. <el-table-column label="部门" align="center" prop="dept" width="180">
  345. <template slot-scope="scope">
  346. <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].dept" title="部门" valueKey="name"
  347. referName="DEPT_PARAM" disabled
  348. :dataMapping="{ deptCode: 'code', dept: 'name'}"
  349. :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入客户">
  350. </el-popover-select-v2>
  351. </template>
  352. </el-table-column>
  353. <el-table-column label="制单人" align="center" prop="creator" width="180">
  354. <template slot-scope="scope">
  355. <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].creator" title="负责人" valueKey="name"
  356. referName="CONTACTS_PARAM" disabled
  357. :dataMapping="{ creatorCode: 'code', creator: 'name'}"
  358. :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入负责人">
  359. </el-popover-select-v2>
  360. </template>
  361. </el-table-column>
  362. <el-table-column label="科室" align="center" prop="department" width="180">
  363. <template slot-scope="scope">
  364. <el-input v-model="monthGoalMergeDetailsList[scope.$index].department" placeholder="请输入科室" disabled></el-input>
  365. </template>
  366. </el-table-column>
  367. <el-table-column label="一级分类" align="center" prop="oneLevelClassify" width="220">
  368. <template slot-scope="scope">
  369. <el-select v-model="monthGoalMergeDetailsList[scope.$index].oneLevelClassify" size="mini" clearable
  370. @focus="chooseTreeReferForDetails('MATERIALCLASSIFY_PARAM', false, '一级物料分类', scope.$index)"
  371. style="width: 200px" disabled>
  372. <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
  373. </el-select>
  374. </template>
  375. </el-table-column>
  376. <el-table-column label="二级分类" align="center" prop="twoLevelClassify" width="220">
  377. <template slot-scope="scope">
  378. <el-select v-model="monthGoalMergeDetailsList[scope.$index].twoLevelClassify" size="mini" clearable
  379. @focus="chooseTreeReferForDetails('MATERIALCLASSIFY_PARAM', false, '二级物料分类', scope.$index)"
  380. style="width: 200px" disabled>
  381. <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
  382. </el-select>
  383. </template>
  384. </el-table-column>
  385. <el-table-column label="物料" align="center" prop="material" width="180">
  386. <template slot-scope="scope">
  387. <el-popover-select-v2 v-model="monthGoalMergeDetailsList[scope.$index].material" title="物料" valueKey="name"
  388. referName="MATERIAL_PARAM" disabled
  389. :dataMapping="{ materialCode: 'code', material: 'name'}"
  390. :source.sync="monthGoalMergeDetailsList[scope.$index]" placeholder="请输入物料">
  391. </el-popover-select-v2>
  392. </template>
  393. </el-table-column>
  394. <el-table-column label="月份" align="center" prop="monthly" width="250">
  395. <template slot-scope="scope">
  396. <el-date-picker disabled v-model="monthGoalMergeDetailsList[scope.$index].monthly" value-format="yyyy-MM" type="month" placeholder="选择月份">
  397. </el-date-picker>
  398. </template>
  399. </el-table-column>
  400. <el-table-column label="目标值" align="center" prop="totalGoal" width="220">
  401. <template slot-scope="scope">
  402. <el-input-number @change="computeTotal" v-model="monthGoalMergeDetailsList[scope.$index].goalValue" :precision="2" :step="1" :min="0"></el-input-number>
  403. </template>
  404. </el-table-column>
  405. <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120px" fixed="right">
  406. <template slot-scope="scope">
  407. <el-button
  408. size="mini"
  409. type="text"
  410. icon="el-icon-delete"
  411. @click="handleDeleteDetails(scope.$index, scope.row)"
  412. >删除</el-button>
  413. <el-button
  414. size="mini"
  415. type="text"
  416. icon="el-icon-delete"
  417. @click="handleCopyDetails(scope.row)"
  418. >复制</el-button>
  419. </template>
  420. </el-table-column>-->
  421. </el-table>
  422. </el-tab-pane>
  423. </el-tabs>
  424. </el-drawer>
  425. <TreeRefers ref="treeQuery" @doSubmit="selectionsToInputForQuery" :single="true"/>
  426. <TreeRefers ref="treeMain" @doSubmit="selectionsToInputForMain" :single="true"/>
  427. <TreeRefers ref="treeDetails" @doSubmit="selectionsToInputForDetails" :single="true"/>
  428. </div>
  429. </template>
  430. <script>
  431. import {
  432. listMonthGoalMerge,
  433. getMonthGoalMerge,
  434. delMonthGoalMerge,
  435. addMonthGoalMerge,
  436. updateMonthGoalMerge
  437. } from "@/api/business/spd/goal_management/monthGoalMerge";
  438. import {
  439. getMonthGoalMergeDetails,
  440. delMonthGoalMergeDetails,
  441. mergeMonthSaleMergeDetails
  442. } from "@/api/business/spd/goal_management/monthGoalMergeDetails"
  443. // 树形参照
  444. import TreeRefers from '@/components/Refers/treeRefer.vue'
  445. import ElPopoverSelectV2 from "@/components/popover-select-v2"
  446. export default {
  447. name: "MonthGoalMerge",
  448. components: {
  449. TreeRefers, ElPopoverSelectV2
  450. },
  451. data() {
  452. return {
  453. // 遮罩层
  454. loading: true,
  455. // 选中数组
  456. ids: [],
  457. // 非单个禁用
  458. single: true,
  459. // 非多个禁用
  460. multiple: true,
  461. // 显示搜索条件
  462. showSearch: true,
  463. // 总条数
  464. total: 0,
  465. // 月销售目标合并表格数据
  466. monthGoalMergeList: [],
  467. monthGoalMergeDetailsList: [],
  468. // 弹出层标题
  469. title: "",
  470. // 是否显示弹出层
  471. open: false,
  472. // 查询参数
  473. queryParams: {
  474. pageNum: 1,
  475. pageSize: 10,
  476. code: null,
  477. goalName: null,
  478. documentDate: null,
  479. annual: null,
  480. monthly: null,
  481. customCode: null,
  482. custom: null,
  483. creatorCode: null,
  484. creator: null,
  485. deptCode: null,
  486. dept: null,
  487. goalCategory: null,
  488. goalSum: null,
  489. documentStatus: null,
  490. saleZoneCode: null,
  491. saleZone: null,
  492. oneLevelClassifyCode: null,
  493. oneLevelClassify: null,
  494. twoLevelClassifyCode: null,
  495. twoLevelClassify: null,
  496. params: { beginTime: null, endTime: null }
  497. },
  498. documentDateRange: null,
  499. pickerOptions: {
  500. shortcuts: [{
  501. text: '最近一周',
  502. onClick(picker) {
  503. const end = new Date();
  504. const start = new Date();
  505. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  506. picker.$emit('pick', [start, end]);
  507. }
  508. }, {
  509. text: '最近一个月',
  510. onClick(picker) {
  511. const end = new Date();
  512. const start = new Date();
  513. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  514. picker.$emit('pick', [start, end]);
  515. }
  516. }, {
  517. text: '最近三个月',
  518. onClick(picker) {
  519. const end = new Date();
  520. const start = new Date();
  521. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  522. picker.$emit('pick', [start, end]);
  523. }
  524. }]
  525. },
  526. // 表单参数
  527. form: {
  528. id: null,
  529. code: null,
  530. goalName: null,
  531. documentDate: null,
  532. annual: null,
  533. monthly: null,
  534. customCode: null,
  535. custom: null,
  536. creatorCode: null,
  537. creator: null,
  538. deptCode: null,
  539. dept: null,
  540. goalCategory: null,
  541. goalSum: null,
  542. documentStatus: null,
  543. saleZoneCode: null,
  544. saleZone: null,
  545. oneLevelClassifyCode: null,
  546. oneLevelClassify: null,
  547. twoLevelClassifyCode: null,
  548. twoLevelClassify: null,
  549. monthMergeDetailsList: null
  550. },
  551. formDetails: {
  552. id: null,
  553. code: null,
  554. saleOrg: null,
  555. saleZone: null,
  556. custom: null,
  557. dept: null,
  558. creator: null,
  559. department: null,
  560. oneLevelClassifyCode: null,
  561. oneLevelClassify: null,
  562. twoLevelClassifyCode: null,
  563. twoLevelClassify: null,
  564. materialCode: null,
  565. material: null,
  566. monthly: null,
  567. goalValue: null
  568. },
  569. // 表单校验
  570. rules: {
  571. documentDate: [{ required: true, message: '单据日期不能为空', trigger: 'blur' }],
  572. annual: [{ required: true, message: '年度不能为空', trigger: 'blur' }],
  573. monthly: [{ required: true, message: '月份不能为空', trigger: 'blur' }],
  574. creator: [{ required: true, message: '制单人不能为空', trigger: 'blur' }],
  575. dept: [{ required: true, message: '部门不能为空', trigger: 'blur' }],
  576. goalCategory: [{ required: true, message: '目标类型不能为空', trigger: 'blur' }],
  577. custom: [],
  578. saleZone: [],
  579. oneLevelClassify: [],
  580. twoLevelClassify: []
  581. },
  582. // 目标类型列表
  583. goalCategoryList: [
  584. { value: '客户维度', label: '客户维度' },
  585. { value: '销售区域', label: '销售区域' },
  586. { value: '一级分类', label: '一级分类' },
  587. { value: '二级分类', label: '二级分类' }
  588. ],
  589. // 树形参照
  590. referCondition: { type: '', isPage: true, title: '', index: null },
  591. classOptions: [],
  592. activeName: 'monthGoalMergeDetails'
  593. };
  594. },
  595. created() {
  596. this.getList();
  597. },
  598. methods: {
  599. /** 查询月销售目标合并列表 */
  600. getList() {
  601. this.loading = true;
  602. listMonthGoalMerge(this.queryParams).then(response => {
  603. this.monthGoalMergeList = response.rows;
  604. this.total = response.total;
  605. this.loading = false;
  606. });
  607. },
  608. getListDetails() {
  609. this.loading = true;
  610. getMonthGoalMergeDetails(this.form.id).then(response => {
  611. this.monthGoalMergeDetailsList = response.data;
  612. this.computeTotal()
  613. this.form.monthMergeDetailsList = this.monthGoalMergeDetailsList
  614. updateMonthGoalMerge(this.form).then(response => {})
  615. this.loading = false;
  616. });
  617. },
  618. // 取消按钮
  619. cancel() {
  620. this.open = false;
  621. this.reset();
  622. },
  623. // 表单重置
  624. reset() {
  625. this.form = {
  626. id: null,
  627. code: null,
  628. goalName: null,
  629. documentDate: null,
  630. annual: null,
  631. monthly: null,
  632. customCode: null,
  633. custom: null,
  634. creatorCode: null,
  635. creator: null,
  636. deptCode: null,
  637. dept: null,
  638. goalCategory: null,
  639. goalSum: null,
  640. documentStatus: null,
  641. saleZoneCode: null,
  642. saleZone: null,
  643. oneLevelClassifyCode: null,
  644. oneLevelClassify: null,
  645. twoLevelClassifyCode: null,
  646. twoLevelClassify: null
  647. };
  648. this.resetForm("form");
  649. },
  650. /** 搜索按钮操作 */
  651. handleQuery() {
  652. this.queryParams.pageNum = 1;
  653. this.getList();
  654. },
  655. /** 重置按钮操作 */
  656. resetQuery() {
  657. this.queryParams = {
  658. pageNum: 1,
  659. pageSize: 10,
  660. code: null,
  661. goalName: null,
  662. documentDate: null,
  663. annual: null,
  664. monthly: null,
  665. customCode: null,
  666. custom: null,
  667. creatorCode: null,
  668. creator: null,
  669. deptCode: null,
  670. dept: null,
  671. goalCategory: null,
  672. goalSum: null,
  673. documentStatus: null,
  674. saleZoneCode: null,
  675. saleZone: null,
  676. oneLevelClassifyCode: null,
  677. oneLevelClassify: null,
  678. twoLevelClassifyCode: null,
  679. twoLevelClassify: null,
  680. params: { beginTime: null, endTime: null }
  681. }
  682. this.documentDateRange = null
  683. this.resetForm("queryForm");
  684. this.handleQuery();
  685. },
  686. // 多选框选中数据
  687. handleSelectionChange(selection) {
  688. this.ids = selection.map(item => item.id)
  689. this.single = selection.length !== 1
  690. this.multiple = !selection.length
  691. },
  692. /** 新增按钮操作 */
  693. handleAdd() {
  694. this.reset();
  695. this.monthGoalMergeDetailsList = []
  696. this.open = true;
  697. this.title = "添加月销售目标合并";
  698. },
  699. handleAddDetails() {
  700. let list = {
  701. id: null,
  702. code: null,
  703. saleOrg: null,
  704. saleZone: null,
  705. custom: null,
  706. dept: null,
  707. creator: null,
  708. oneLevelClassifyCode: null,
  709. oneLevelClassify: null,
  710. twoLevelClassifyCode: null,
  711. twoLevelClassify: null,
  712. materialCode: null,
  713. material: null,
  714. department: null,
  715. num: null,
  716. monthly: null,
  717. goalValue: null
  718. }
  719. this.monthGoalMergeDetailsList.push(list)
  720. },
  721. /** 修改按钮操作 */
  722. handleUpdate(row) {
  723. this.reset();
  724. const id = row.id || this.ids
  725. getMonthGoalMerge(id).then(response => {
  726. this.form = response.data;
  727. this.monthGoalMergeDetailsList = this.form.monthMergeDetailsList
  728. this.open = true;
  729. this.title = "修改月销售目标合并";
  730. });
  731. },
  732. /** 提交按钮 */
  733. submitForm() {
  734. this.$refs["form"].validate(valid => {
  735. if (valid) {
  736. if (this.form.id !== null) {
  737. this.form.monthMergeDetailsList = this.monthGoalMergeDetailsList
  738. updateMonthGoalMerge(this.form).then(response => {
  739. this.$modal.msgSuccess("修改成功");
  740. this.open = false;
  741. this.getList();
  742. });
  743. } else {
  744. this.form.documentStatus = '未提交'
  745. this.form.monthMergeDetailsList = this.monthGoalMergeDetailsList
  746. console.log(this.form);
  747. addMonthGoalMerge(this.form).then(response => {
  748. this.$modal.msgSuccess("新增成功");
  749. this.open = false;
  750. this.getList();
  751. });
  752. }
  753. }
  754. });
  755. },
  756. /** 删除按钮操作 */
  757. handleDelete(row) {
  758. const ids = row.id || this.ids;
  759. this.$modal.confirm('是否确认删除月销售目标合并编号为"' + ids + '"的数据项?').then(function () {
  760. return delMonthGoalMerge(ids);
  761. }).then(() => {
  762. this.getList();
  763. this.$modal.msgSuccess("删除成功");
  764. }).catch(() => {
  765. });
  766. },
  767. handleDeleteDetails(index, row) {
  768. if (this.form.id === null) {
  769. this.monthGoalMergeDetailsList.splice(index, 1)
  770. this.computeTotal()
  771. } else {
  772. if (row.id !== null) {
  773. this.$modal.confirm('是否确认删除月销售目标合并明细编号为"' + row.id + '"的数据项?').then(function () {
  774. return delMonthGoalMergeDetails(row.id);
  775. }).then(() => {
  776. this.getListDetails();
  777. this.$modal.msgSuccess("删除成功");
  778. }).catch(() => {
  779. });
  780. } else {
  781. this.monthGoalMergeDetailsList.splice(index, 1)
  782. this.$message.success('删除成功')
  783. this.computeTotal()
  784. }
  785. }
  786. },
  787. /** 导出按钮操作 */
  788. handleExport() {
  789. this.download('goal_management/monthGoalMerge/export', {
  790. ...this.queryParams
  791. }, `monthGoalMerge${new Date().getTime()}.xlsx`)
  792. },
  793. // 树形参照
  794. chooseTreeReferForQuery(type, isPage, title) {
  795. this.referCondition.type = type
  796. this.referCondition.isPage = isPage
  797. this.referCondition.title = title
  798. this.$refs.treeQuery.init(this.referCondition)
  799. },
  800. chooseTreeReferForMain(type, isPage, title) {
  801. this.referCondition.type = type
  802. this.referCondition.isPage = isPage
  803. this.referCondition.title = title
  804. this.$refs.treeMain.init(this.referCondition)
  805. },
  806. chooseTreeReferForDetails(type, isPage, title, index) {
  807. this.referCondition.type = type
  808. this.referCondition.isPage = isPage
  809. this.referCondition.title = title
  810. this.referCondition.index = index
  811. this.$refs.treeDetails.init(this.referCondition)
  812. },
  813. selectionsToInputForQuery(selection) {
  814. this.classOptions.push(selection)
  815. if (this.referCondition.title === '一级物料分类') {
  816. if (selection.code.length !== 1) {
  817. return this.$message.info('请在一级分类下选择')
  818. }
  819. this.queryParams.oneLevelClassifyCode = selection.code
  820. this.queryParams.oneLevelClassify = selection.name
  821. } else if (this.referCondition.title === '二级物料分类') {
  822. if (selection.code.length !== 4) {
  823. return this.$message.info('请在二级分类下选择')
  824. }
  825. this.queryParams.twoLevelClassifyCode = selection.code
  826. this.queryParams.twoLevelClassify = selection.name
  827. }
  828. },
  829. selectionsToInputForMain(selection) {
  830. this.classOptions.push(selection)
  831. if (this.referCondition.title === '一级物料分类') {
  832. if (selection.code.length !== 1) {
  833. return this.$message.info('请在一级分类下选择')
  834. }
  835. this.form.oneLevelClassifyCode = selection.code
  836. this.form.oneLevelClassify = selection.name
  837. } else if (this.referCondition.title === '二级物料分类') {
  838. if (selection.code.length !== 4) {
  839. return this.$message.info('请在二级分类下选择')
  840. }
  841. this.form.twoLevelClassifyCode = selection.code
  842. this.form.twoLevelClassify = selection.name
  843. }
  844. },
  845. selectionsToInputForDetails(selection) {
  846. this.classOptions.push(selection)
  847. if (this.referCondition.title === '一级物料分类') {
  848. if (selection.code.length !== 1) {
  849. return this.$message.info('请在一级分类中选择')
  850. }
  851. if (selection.code !== this.monthGoalMergeDetailsList[this.referCondition.index].oneLevelClassifyCode) {
  852. this.monthGoalMergeDetailsList[this.referCondition.index].twoLevelClassifyCode = null
  853. this.monthGoalMergeDetailsList[this.referCondition.index].twoLevelClassify = null
  854. }
  855. this.monthGoalMergeDetailsList[this.referCondition.index].oneLevelClassifyCode = selection.code
  856. this.monthGoalMergeDetailsList[this.referCondition.index].oneLevelClassify = selection.name
  857. } else if (this.referCondition.title === '二级物料分类') {
  858. if (selection.code.length !== 4) {
  859. return this.$message.info('请在二级分类中选择')
  860. } else if (selection.code[0] !== this.monthGoalMergeDetailsList[this.referCondition.index].oneLevelClassifyCode) {
  861. return this.$message.error('所选择的二级物料分类不属于一级分类')
  862. }
  863. this.monthGoalMergeDetailsList[this.referCondition.index].twoLevelClassifyCode = selection.code
  864. this.monthGoalMergeDetailsList[this.referCondition.index].twoLevelClassify = selection.name
  865. }
  866. },
  867. // 改变查询表单的目标分类
  868. changeGoalCategoryQuery() {
  869. let condition = this.queryParams.goalCategory
  870. if (condition === null) {
  871. this.queryParams.custom = null
  872. this.queryParams.customCode = null
  873. this.queryParams.saleZone = null
  874. this.queryParams.saleZoneCode = null
  875. this.queryParams.oneLevelClassify = null
  876. this.queryParams.oneLevelClassifyCode = null
  877. this.queryParams.twoLevelClassify = null
  878. this.queryParams.twoLevelClassifyCode = null
  879. } else if (condition === '客户维度') {
  880. this.queryParams.saleZone = null
  881. this.queryParams.saleZoneCode = null
  882. this.queryParams.oneLevelClassify = null
  883. this.queryParams.oneLevelClassifyCode = null
  884. this.queryParams.twoLevelClassify = null
  885. this.queryParams.twoLevelClassifyCode = null
  886. } else if (condition === '销售区域') {
  887. this.queryParams.custom = null
  888. this.queryParams.customCode = null
  889. this.queryParams.oneLevelClassify = null
  890. this.queryParams.oneLevelClassifyCode = null
  891. this.queryParams.twoLevelClassify = null
  892. this.queryParams.twoLevelClassifyCode = null
  893. } else if (condition === '一级分类') {
  894. this.queryParams.custom = null
  895. this.queryParams.customCode = null
  896. this.queryParams.saleZone = null
  897. this.queryParams.saleZoneCode = null
  898. this.queryParams.twoLevelClassify = null
  899. this.queryParams.twoLevelClassifyCode = null
  900. } else if (condition === '二级分类') {
  901. this.queryParams.custom = null
  902. this.queryParams.customCode = null
  903. this.queryParams.saleZone = null
  904. this.queryParams.saleZoneCode = null
  905. this.queryParams.oneLevelClassify = null
  906. this.queryParams.oneLevelClassifyCode = null
  907. }
  908. },
  909. changeGoalCategoryForm() {
  910. let condition = this.form.goalCategory
  911. if (condition === null) {
  912. this.form.custom = null
  913. this.form.customCode = null
  914. this.form.saleZone = null
  915. this.form.saleZoneCode = null
  916. this.form.oneLevelClassify = null
  917. this.form.oneLevelClassifyCode = null
  918. this.form.twoLevelClassify = null
  919. this.form.twoLevelClassifyCode = null
  920. this.rules.custom = []
  921. this.rules.saleZone = []
  922. this.rules.oneLevelClassify = []
  923. this.rules.twoLevelClassify = []
  924. } else if (condition === '客户维度') {
  925. this.form.saleZone = null
  926. this.form.saleZoneCode = null
  927. this.form.oneLevelClassify = null
  928. this.form.oneLevelClassifyCode = null
  929. this.form.twoLevelClassify = null
  930. this.form.twoLevelClassifyCode = null
  931. this.rules.custom = [{ required: true, message: '客户不能为空', trigger: 'blur' }]
  932. this.rules.saleZone = []
  933. this.rules.oneLevelClassify = []
  934. this.rules.twoLevelClassify = []
  935. } else if (condition === '销售区域') {
  936. this.form.custom = null
  937. this.form.customCode = null
  938. this.form.oneLevelClassify = null
  939. this.form.oneLevelClassifyCode = null
  940. this.form.twoLevelClassify = null
  941. this.form.twoLevelClassifyCode = null
  942. this.rules.custom = []
  943. this.rules.saleZone = [{ required: true, message: '销售区域不能为空', trigger: 'blur' }]
  944. this.rules.oneLevelClassify = []
  945. this.rules.twoLevelClassify = []
  946. } else if (condition === '一级分类') {
  947. this.form.custom = null
  948. this.form.customCode = null
  949. this.form.saleZone = null
  950. this.form.saleZoneCode = null
  951. this.form.twoLevelClassify = null
  952. this.form.twoLevelClassifyCode = null
  953. this.rules.custom = []
  954. this.rules.saleZone = []
  955. this.rules.oneLevelClassify = [{ required: true, message: '一级分类不能为空', trigger: 'blur' }]
  956. this.rules.twoLevelClassify = []
  957. } else if (condition === '二级分类') {
  958. this.form.custom = null
  959. this.form.customCode = null
  960. this.form.saleZone = null
  961. this.form.saleZoneCode = null
  962. this.form.oneLevelClassify = null
  963. this.form.oneLevelClassifyCode = null
  964. this.rules.custom = []
  965. this.rules.saleZone = []
  966. this.rules.oneLevelClassify = []
  967. this.rules.twoLevelClassify = [{ required: true, message: '二级分类不能为空', trigger: 'blur' }]
  968. }
  969. },
  970. // 关闭抽屉
  971. handleClose(done) {
  972. this.$confirm('确认关闭?')
  973. .then(_ => {
  974. done();
  975. this.resetQuery()
  976. })
  977. .catch(_ => {});
  978. },
  979. // 复制明细
  980. handleCopyDetails(row) {
  981. let list = {
  982. id: null,
  983. code: row.code,
  984. saleOrg: row.saleOrg,
  985. saleZone: row.saleZone,
  986. custom: row.custom,
  987. dept: row.dept,
  988. creator: row.creator,
  989. oneLevelClassifyCode: row.oneLevelClassifyCode,
  990. oneLevelClassify: row.oneLevelClassify,
  991. twoLevelClassifyCode: row.twoLevelClassifyCode,
  992. twoLevelClassify: row.twoLevelClassify,
  993. materialCode: row.materialCode,
  994. material: row.material,
  995. department: row.department,
  996. num: row.num,
  997. monthly: row.monthly,
  998. goalValue: row.goalValue
  999. }
  1000. this.monthGoalMergeDetailsList.push(list)
  1001. this.computeTotal()
  1002. },
  1003. // 计算主表合计
  1004. computeTotal() {
  1005. let list = this.monthGoalMergeDetailsList
  1006. let sum = 0
  1007. for (const listElement of list) {
  1008. sum = (sum * 1000000 + listElement.goalValue * 1000000) / 1000000
  1009. }
  1010. this.form.goalSum = sum
  1011. },
  1012. // 合并数据
  1013. clickMerge() {
  1014. let classify = this.form.goalCategory
  1015. let classifyValue;
  1016. if (classify === null || classify === '') {
  1017. return this.$message.error('请输入目标分类')
  1018. } else if (classify === '销售区域') {
  1019. classifyValue = this.form.saleZone
  1020. if (classifyValue === null) {
  1021. return this.$message.error('请输入销售区域')
  1022. }
  1023. } else if (classify === '一级分类') {
  1024. classifyValue = this.form.oneLevelClassify
  1025. if (classifyValue === null) {
  1026. return this.$message.error('请输入一级分类')
  1027. }
  1028. } else if (classify === '二级分类') {
  1029. classifyValue = this.form.twoLevelClassify
  1030. if (classifyValue === null) {
  1031. return this.$message.error('请输入二级分类')
  1032. }
  1033. } else if (classify === '客户维度') {
  1034. classifyValue = this.form.custom
  1035. if (classifyValue === null) {
  1036. return this.$message.error('请输入客户')
  1037. }
  1038. }
  1039. let query = { classify: classify, classifyValue: classifyValue }
  1040. mergeMonthSaleMergeDetails(query).then(response => {
  1041. console.log(response);
  1042. this.monthGoalMergeDetailsList = response.data.monthGoalMergeDetails
  1043. this.computeTotal()
  1044. })
  1045. },
  1046. setBeginAndEnd() {
  1047. let array = this.documentDateRange
  1048. if (array !== null) {
  1049. this.queryParams.params.beginTime = array[0]
  1050. this.queryParams.params.endTime = array[1]
  1051. } else {
  1052. this.queryParams.beginTime = null
  1053. this.queryParams.endTime = null
  1054. }
  1055. }
  1056. }
  1057. };
  1058. </script>