AnnualSaleGoal.vue 42 KB

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