AnnualSaleGoal.vue 63 KB

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