AnnualSaleGoal.vue 42 KB

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