AnnualSaleGoal.vue 37 KB

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