AnnualSaleGoal.vue 38 KB

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