AnnualSaleGoal.vue 49 KB

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