AnnualSaleGoal.vue 63 KB

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