AnnualSaleGoal.vue 39 KB

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