MonthGoalMerge.vue 45 KB

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