index.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820
  1. <template>
  2. <div id="demandSummary">
  3. <div v-if="isList">
  4. <el-card style="position: relative;">
  5. <el-form class="search_area" label-width="100px">
  6. <el-row :gutter="10">
  7. <el-col :span="1.5">
  8. <el-form-item label="行状态">
  9. <el-select multiple v-model="queryParams.rowStatus" size="mini" style="width: 200px" clearable>
  10. <el-option v-for="dict in dict.type.sys_row_status" :key="dict.value" :label="dict.label" :value="dict.value">
  11. </el-option>
  12. </el-select>
  13. </el-form-item>
  14. </el-col>
  15. <el-col :span="1.5">
  16. <el-form-item label="采购员">
  17. <el-select clearable size="mini" v-model="queryParams.buyer" @focus="chooseRefer('CONTACTS_PARAM', true, '采购员')" style="width: 200px">
  18. <el-option v-for="item in personOptions" :key="item.id" :label="item.name" :value="item.code" />
  19. </el-select>
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="1.5">
  23. <el-form-item label="品类">
  24. <el-select
  25. v-model="queryParams.materialClassifyFourName"
  26. size="mini"
  27. clearable
  28. @focus="chooseTreeRefer('MATERIALCLASSIFY_PARAM', false, '选择品类')"
  29. style="width: 200px"
  30. >
  31. <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.name" />
  32. </el-select>
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="1.5">
  36. <el-form-item label="生产厂家">
  37. <el-input
  38. v-model.trim="queryParams.manufacturer"
  39. size="mini"
  40. clearable
  41. style="width: 200px"
  42. />
  43. </el-form-item>
  44. </el-col>
  45. <!-- <el-col :span="1.5"> -->
  46. <!-- <el-form-item label="" label-width="20px"> -->
  47. <div style="position: absolute;top: 3px;right: 10px;">
  48. <el-button type="primary" size="mini" icon="el-icon-search" @click="search">搜索</el-button>
  49. <el-button size="mini" icon="el-icon-refresh" plain @click="reset">重置</el-button>
  50. </div>
  51. <!-- </el-form-item> -->
  52. <!-- </el-col> -->
  53. </el-row>
  54. <CollapseTransition>
  55. <div v-show="expanded">
  56. <el-row :gutter="10">
  57. <el-col :span="1.5">
  58. <el-form-item label="预测分类">
  59. <el-select v-model="queryParams.forecastClassification" size="mini" style="width: 200px" clearable>
  60. <el-option
  61. v-for="dict in dict.type.predictive_classify" :key="dict.value" :label="dict.label" :value="dict.label">
  62. </el-option>
  63. </el-select>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="1.5">
  67. <el-form-item label="审核人">
  68. <el-select clearable size="mini" v-model="queryParams.puManagerAuditor" @focus="chooseRefer('CONTACTS_PARAM', true, '审核人')" style="width: 200px">
  69. <el-option v-for="item in auditOptions" :key="item.id" :label="item.name" :value="item.code" />
  70. </el-select>
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="1.5">
  74. <el-form-item label="注册人">
  75. <el-input
  76. v-model.trim="queryParams.registrant"
  77. size="mini"
  78. clearable
  79. style="width: 200px"
  80. />
  81. </el-form-item>
  82. </el-col>
  83. <el-col :span="1.5">
  84. <el-form-item label="业务类型">
  85. <el-select v-model="queryParams.businessType" size="mini" style="width: 200px" clearable>
  86. <el-option
  87. v-for="dict in dict.type.sys_business" :key="dict.value" :label="dict.label" :value="dict.value">
  88. </el-option>
  89. </el-select>
  90. </el-form-item>
  91. </el-col>
  92. </el-row>
  93. <el-row :gutter="10">
  94. <el-col :span="1.5">
  95. <el-form-item label="单据来源">
  96. <el-select v-model="queryParams.billSource" size="mini" style="width: 200px" clearable>
  97. <el-option
  98. v-for="dict in dict.type.sys_bill_source" :key="dict.value" :label="dict.label" :value="dict.value">
  99. </el-option>
  100. </el-select>
  101. </el-form-item>
  102. </el-col>
  103. <el-col :span="1.5">
  104. <el-form-item label="需求客户">
  105. <el-select clearable size="mini" v-model="queryParams.customer" @focus="chooseRefer('CUSTOMER_PARAM', true, '需求客户')" style="width: 200px">
  106. <el-option v-for="item in customerOptions" :key="item.id" :label="item.name" :value="item.id" />
  107. </el-select>
  108. </el-form-item>
  109. </el-col>
  110. <el-col :span="1.5">
  111. <el-form-item label="供应仓库">
  112. <el-select clearable size="mini" v-model="queryParams.lastWarehouse" @focus="chooseRefer('WAREHOUSE_PARAM', true, '供应仓库')" style="width: 200px">
  113. <el-option v-for="item in lastWarehouseOptions" :key="item.id" :label="item.name" :value="item.id" />
  114. </el-select>
  115. </el-form-item>
  116. </el-col>
  117. <el-col :span="1.5">
  118. <el-form-item label="供应库位">
  119. <el-select clearable size="mini" v-model="queryParams.lastAllocation" @focus="chooseRefer('ALLOCATION_PARAM', true, '供应库位', queryParams.lastWarehouse)" style="width: 200px">
  120. <el-option v-for="item in lastAllocationOptions" :key="item.id" :label="item.name" :value="item.id" />
  121. </el-select>
  122. </el-form-item>
  123. </el-col>
  124. <!-- <el-col :span="1.5">
  125. <el-form-item label="转请购时间">
  126. <el-select v-model="queryParams.ywlx" size="mini" style="width: 200px" clearable>
  127. <el-option
  128. v-for="item in options"
  129. :key="item.value"
  130. :label="item.label"
  131. :value="item.value">
  132. </el-option>
  133. </el-select>
  134. </el-form-item>
  135. </el-col> -->
  136. </el-row>
  137. <el-row :gutter="10">
  138. <el-col :span="1.5">
  139. <el-form-item label="物料编码">
  140. <el-input clearable size="mini" v-model="queryParams.names" @clear="queryParams.materialCode = ''" @focus="chooseMaterial" style="width: 200px">
  141. <el-button size="mini" slot="append" icon="el-icon-more" @click="chooseMaterial"></el-button>
  142. </el-input>
  143. <el-input v-show="false" v-model="queryParams.materialCode"></el-input>
  144. </el-form-item>
  145. </el-col>
  146. <el-col :span="1.5">
  147. <el-form-item label="默认采购组织">
  148. <el-select clearable size="mini" v-model="queryParams.purchaseOrg" @focus="chooseRefer('ORG_PARAM', true, '默认采购组织')" style="width: 200px">
  149. <el-option v-for="item in orgOptions" :key="item.id" :label="item.name" :value="item.id" />
  150. </el-select>
  151. </el-form-item>
  152. </el-col>
  153. <el-col :span="1.5">
  154. <el-form-item label="需求日期">
  155. <el-date-picker
  156. v-model="queryParams.demandDate"
  157. type="date"
  158. value-format="yyyy-MM-dd"
  159. size="mini"
  160. style="width: 200px"
  161. >
  162. </el-date-picker>
  163. </el-form-item>
  164. </el-col>
  165. <el-col :span="1.5">
  166. <el-form-item label="采购需求单号">
  167. <el-input
  168. v-model.trim="queryParams.code"
  169. size="mini"
  170. clearable
  171. style="width: 200px"
  172. />
  173. </el-form-item>
  174. </el-col>
  175. </el-row>
  176. <el-row :gutter="10">
  177. <el-col :span="1.5">
  178. <el-form-item label="审批结束日期">
  179. <el-date-picker
  180. v-model="queryParams.approverFinishTime"
  181. type="date"
  182. clearable
  183. value-format="yyyy-MM-dd"
  184. size="mini"
  185. style="width: 200px"
  186. >
  187. </el-date-picker>
  188. </el-form-item>
  189. </el-col>
  190. </el-row>
  191. </div>
  192. </CollapseTransition>
  193. </el-form>
  194. <el-divider class="lines"><i style="cursor: pointer;" :class="expanded?'el-icon-arrow-up':'el-icon-arrow-down'" @click="drop"></i></el-divider>
  195. <div class="btn_grooup">
  196. <el-button type="primary" size="mini" @click="editList">编辑</el-button>
  197. <el-button type="danger" size="mini" v-if="!lineDisable" @click="cancelEdit">取消编辑</el-button>
  198. <el-button type="success" size="mini" v-if="!lineDisable" @click="saveList">保存</el-button>
  199. <el-button type="primary" size="mini" v-if="lineDisable" @click="confirms">确认</el-button>
  200. <el-button type="primary" size="mini" v-if="lineDisable" @click="cancels">取消</el-button>
  201. <el-button type="primary" size="mini" v-if="lineDisable" @click="audits">审核</el-button>
  202. <el-button type="primary" size="mini" v-if="lineDisable" @click="closeLine">行关闭</el-button>
  203. <el-dropdown size="mini" v-if="lineDisable" @command="handleCommand">
  204. <el-button size="mini" type="primary" style="margin: 0 10px;">
  205. 导出<i class="el-icon-arrow-down el-icon--right"></i>
  206. </el-button>
  207. <el-dropdown-menu slot="dropdown">
  208. <el-dropdown-item command="Excel导出">Excel导出</el-dropdown-item>
  209. <el-dropdown-item command="导出明细">导出明细</el-dropdown-item>
  210. </el-dropdown-menu>
  211. </el-dropdown>
  212. <!-- <el-button type="primary" size="mini">转请购</el-button> -->
  213. </div>
  214. <el-table
  215. :data="tableList"
  216. fit
  217. :cell-style="{ borderColor: '#c0c0c0' }"
  218. :header-cell-style="{ borderColor: '#c0c0c0' }"
  219. class="exporttable"
  220. border
  221. show-summary
  222. :summary-method="getSummaries"
  223. max-height="550"
  224. style="font-size: 12px;"
  225. @selection-change="handleSelectionChange"
  226. :key="isUpdate"
  227. >
  228. <el-table-column type="selection" width="60" fixed="left"/>
  229. <el-table-column show-overflow-tooltip label="序号" type="index" align="center" width="50px" fixed="left"/>
  230. <!-- <el-table-column show-overflow-tooltip label="行号" align="center" prop="rowNo"/> -->
  231. <el-table-column show-overflow-tooltip label="行状态" align="center" prop="status" width="100px" :formatter="hangStatus"/>
  232. <el-table-column show-overflow-tooltip label="一级品类" align="center" prop="materialClassifyOneName" width="100px"/>
  233. <el-table-column show-overflow-tooltip label="物料编码" align="center" prop="materialCode" width="150px"/>
  234. <el-table-column show-overflow-tooltip label="品名" align="center" prop="materialName" width="150px"/>
  235. <el-table-column show-overflow-tooltip label="规格" align="center" prop="specification" width="150px"/>
  236. <el-table-column show-overflow-tooltip label="单位" align="center" prop="unit"/>
  237. <el-table-column show-overflow-tooltip label="生产厂家/代理人" align="center" prop="manufacturer" width="200px"/>
  238. <el-table-column show-overflow-tooltip label="需求单位数" align="center" prop="demandNum" width="100px"/>
  239. <el-table-column show-overflow-tooltip label="近1月月均需求" align="center" prop="evensalesforyear" width="120px"/>
  240. <el-table-column show-overflow-tooltip label="近3月月均需求" align="center" prop="evensalesforthrmonth" width="120px"/>
  241. <el-table-column show-overflow-tooltip label="总最终净需求量" align="center" prop="netDemandNum" width="120px"/>
  242. <el-table-column show-overflow-tooltip label="总月销量" align="center" prop="totalMonthlySales"/>
  243. <el-table-column show-overflow-tooltip label="需求可用周期" align="center" prop="demandCycle" width="120px"/>
  244. <el-table-column show-overflow-tooltip label="呆滞量" align="center" prop="dullQut"/>
  245. <el-table-column show-overflow-tooltip label="采购周期" align="center" prop="buyPeriod"/>
  246. <el-table-column show-overflow-tooltip label="中心公共库存" align="center" prop="centralPublicStock" width="120px"/>
  247. <el-table-column show-overflow-tooltip label="中心仓专属货位" align="center" prop="centralWarehouse" width="120px"/>
  248. <el-table-column show-overflow-tooltip label="区域分仓公共库存" align="center" prop="regionPublicStock" width="150px"/>
  249. <el-table-column show-overflow-tooltip label="各项目仓库存" align="center" prop="eachWarehouseStock" width="120px"/>
  250. <el-table-column show-overflow-tooltip label="电商仓库" align="center" prop="commerceWarehouse"/>
  251. <el-table-column show-overflow-tooltip label="采购在途" align="center" prop="buyTransit"/>
  252. <el-table-column show-overflow-tooltip label="借出在途" align="center" prop="lendTransit"/>
  253. <el-table-column show-overflow-tooltip label="调拨在途" align="center" prop="transferTransit"/>
  254. <el-table-column show-overflow-tooltip label="库存总计" align="center" prop="stockTotal"/>
  255. <el-table-column show-overflow-tooltip label="最小包装量" align="center" prop="minPackage" width="100px"/>
  256. <el-table-column show-overflow-tooltip label="最小订货量" align="center" prop="minOrder" width="100px"/>
  257. <el-table-column show-overflow-tooltip label="最小批量" align="center" prop="minBatch"/>
  258. <el-table-column show-overflow-tooltip label="人工调整数" align="center" prop="artificialAdjust" width="100px"/>
  259. <el-table-column show-overflow-tooltip label="修改原因" align="center" prop="modifyReason" width="150px">
  260. <template slot-scope="scope">
  261. <el-input :disabled="scope.row.status !== '1'|| lineDisable || scope.row.artificialAdjust == '0'" v-model="scope.row.modifyReason"/>
  262. </template>
  263. </el-table-column>
  264. <el-table-column show-overflow-tooltip label="建议采购量" align="center" prop="suggestionPurchase" width="100px"/>
  265. <!-- <el-table-column show-overflow-tooltip label="建议净采购量" align="center" prop="suggestBuyQty" width="100px"/> -->
  266. <el-table-column show-overflow-tooltip label="最终采购量" align="center" prop="finalBuyQty" width="100">
  267. <template slot-scope="scope">
  268. <el-input :disabled="scope.row.status !== '1' || lineDisable" v-model="scope.row.finalBuyQty"/>
  269. </template>
  270. </el-table-column>
  271. <el-table-column show-overflow-tooltip label="二级品类" align="center" prop="materialClassifyTwoName" width="120px"/>
  272. <el-table-column show-overflow-tooltip label="三级品类" align="center" prop="materialClassifyThreeName" width="120px"/>
  273. <el-table-column show-overflow-tooltip label="四级品类" align="center" prop="materialClassifyFourName" width="120px"/>
  274. <el-table-column show-overflow-tooltip label="采购员" align="center" prop="buyerName" width="150px">
  275. <template slot-scope="scope">
  276. <el-input readonly :disabled="scope.row.status !== '1' || lineDisable" size="mini" v-model="scope.row.buyerName">
  277. <el-button size="mini" :disabled="scope.row.status !== '1' || lineDisable" slot="append" icon="el-icon-more" @click="chooseSon(scope.$index, 'CONTACTS_PARAM', true, '明细采购员')"></el-button>
  278. </el-input>
  279. </template>
  280. </el-table-column>
  281. <el-table-column show-overflow-tooltip label="默认采购组织" align="center" prop="purchaseOrgName" width="230px">
  282. <!-- <template slot-scope="scope">
  283. <el-input readonly :disabled="scope.row.status !== '1' || lineDisable" size="mini" v-model="scope.row.purchaseOrgName">
  284. <el-button size="mini" :disabled="scope.row.status !== '1' || lineDisable" slot="append" icon="el-icon-more" @click="chooseSon(scope.$index, 'ORG_PARAM', true, '明细默认采购组织')"></el-button>
  285. </el-input>
  286. </template> -->
  287. </el-table-column>
  288. <el-table-column show-overflow-tooltip label="有效期" align="center" prop="validityPeriod"/>
  289. <el-table-column show-overflow-tooltip label="有效期单位" align="center" prop="validityPeriodUnit" width="100px"/>
  290. <el-table-column show-overflow-tooltip label="业务类型" align="center" prop="businessType" :formatter="formatterBusinessType"/>
  291. <el-table-column show-overflow-tooltip label="安全库存量" align="center" prop="safetyStock" width="100px"/>
  292. <el-table-column show-overflow-tooltip label="单据来源" align="center" prop="billSource" :formatter="formatterSource"/>
  293. <el-table-column show-overflow-tooltip label="注册人" align="center" prop="registrant" width="120px"/>
  294. <!-- <el-table-column label="可用量" align="center" prop="qty"/> -->
  295. <el-table-column show-overflow-tooltip label="总需与终采差异" align="center" prop="buyDiscrepancy" width="120px"/>
  296. <el-table-column show-overflow-tooltip label="集团预测分类" align="center" prop="forecastClassification" width="120px"/>
  297. <el-table-column show-overflow-tooltip label="中心仓占有量" align="center" prop="centerBinPossession" width="120px"/>
  298. <el-table-column show-overflow-tooltip label="中心仓可用量" align="center" prop="centralWarehouseAvailable" width="120px"/>
  299. <!-- <el-table-column label="物料类别" align="center" prop="materialCategory" width="150px"/> -->
  300. <!-- <el-table-column label="业务部门" align="center" prop="departmentName" width="150px"/> -->
  301. <!-- <el-table-column show-overflow-tooltip label="需求单位" align="center" prop="demandUnit"/> -->
  302. <el-table-column show-overflow-tooltip label="采购经理审核人" align="center" prop="puManagerAuditor" width="120px"/>
  303. <el-table-column
  304. fixed="right"
  305. label="操作"
  306. align="center"
  307. width="100"
  308. >
  309. <template slot-scope="scope">
  310. <el-button type="text" size="mini" @click="check(scope.row)">查看</el-button>
  311. </template>
  312. </el-table-column>
  313. </el-table>
  314. <el-pagination
  315. background
  316. @size-change="handleSizeChange"
  317. @current-change="handleCurrentChange"
  318. :current-page="queryParams.pageNum"
  319. :page-sizes="[10, 20, 50, 100]"
  320. :page-size="10"
  321. layout="total, sizes, prev, pager, next, jumper"
  322. :total=total>
  323. </el-pagination>
  324. </el-card>
  325. </div>
  326. <Add v-model="isList" v-if="!isList" :pageStu="page" :disable="disable" :row="rowDetail" :query="queryParams" @refresh="search"/>
  327. <Refers ref="refer" @doSubmit="selectionsToInput" :single="true"/>
  328. <TreeRefers ref="tree" @doSubmit="selectionsToInput2" :single="true"/>
  329. <popDialog ref="materialRefer" @doSubmit="selectMaterial" :single="true" />
  330. </div>
  331. </template>
  332. <script>
  333. import Add from './add.vue'
  334. import Refers from '@/components/Refers/refers.vue'
  335. import TreeRefers from '@/components/Refers/treeRefer.vue'
  336. import popDialog from '@/components/PopDialog/index.vue'
  337. import CollapseTransition from '@/components/MyCollapse/collapse.vue'
  338. import {getSummaryList, auditSummary, confirmSummary , cancelSummary , shutDownSummary, editSummaryList, exportList, exportItems } from '@/api/purchase/DemandSummary.js'
  339. export default {
  340. name: 'demandSummary',
  341. dicts: ['sys_row_status', 'predictive_classify', 'sys_period_unit', 'sys_business', 'sys_bill_source'],
  342. components: {
  343. Add,
  344. CollapseTransition,
  345. Refers,
  346. TreeRefers,
  347. popDialog
  348. },
  349. data() {
  350. return {
  351. hangStatus(row) {
  352. switch (row.status) {
  353. case '0':
  354. return '需补货'
  355. case '1':
  356. return '待计划确认'
  357. case '2':
  358. return '计划已确认'
  359. case '3':
  360. return '计划已审核'
  361. case '4':
  362. return '行关闭'
  363. case '5':
  364. return '总供应可满足'
  365. }
  366. },
  367. formatterBusinessType(row) {
  368. switch (row.businessType) {
  369. case 'ZQBH':
  370. return '周期备货'
  371. case 'FXXQ':
  372. return '分销需求'
  373. case 'TSXQ':
  374. return '特殊采购需求'
  375. case 'BDXQ':
  376. return '补单需求'
  377. case 'JJXQ':
  378. return '紧急需求单'
  379. case 'XPXQ':
  380. return '新品需求'
  381. case 'HZBM':
  382. return '合作部门需求'
  383. }
  384. },
  385. formatterSource(row) {
  386. switch (row.billSource) {
  387. case '1':
  388. return '手工导入'
  389. case '2':
  390. return '按客户计算'
  391. case '3':
  392. return '按仓库计算'
  393. case '4':
  394. return '手工新增'
  395. }
  396. },
  397. isUpdate: false,
  398. expanded: false,
  399. // 页面配置
  400. isList: true,
  401. // 页面状态
  402. page: '',
  403. queryParams: {
  404. rowStatus: ['1'],
  405. buyer: '',
  406. buyerName: '',
  407. materialClassifyFourName: '',
  408. manufacturer: '',
  409. forecastClassification: '',
  410. periodUnit: '',
  411. departmentName: '',
  412. puManagerAuditor: '',
  413. // zqgdh: '',
  414. code: '',
  415. registrant: '',
  416. businessType: '',
  417. billSource: '',
  418. customer: '',
  419. lastWarehouse: '',
  420. lastAllocation: '',
  421. materialCode: '',
  422. names: '',
  423. purchaseOrg: '',
  424. demandDate: '',
  425. approverFinishTime: '',
  426. pageNum: 1,
  427. pageSize: 10
  428. },
  429. personOptions: [],
  430. classOptions: [],
  431. deptOptions: [],
  432. auditOptions: [],
  433. customerOptions: [],
  434. lastWarehouseOptions: [],
  435. lastAllocationOptions: [],
  436. orgOptions: [],
  437. options: [{
  438. value: 'Y', label: '是',
  439. }, {
  440. value: 'N', label: '否'
  441. }],
  442. referCondition: {
  443. type: '',
  444. isPage: true,
  445. title: ''
  446. },
  447. tableList: [],
  448. total: 0,
  449. rowDetail: {},
  450. disable: false,
  451. lineDisable: true,
  452. ids: [],
  453. allSelection: [],
  454. // 子表index
  455. tableIndex: null,
  456. // referConditionMx: {
  457. // type: '',
  458. // isPage: true,
  459. // title: ''
  460. // }
  461. }
  462. },
  463. created() {
  464. this.getList(this.queryParams)
  465. },
  466. methods: {
  467. // 指定列合计
  468. getSummaries(param) {
  469. const { columns, data } = param;
  470. const sums = [];
  471. columns.forEach((column, index) => {
  472. if (index === 0) {
  473. sums[index] = '合计';
  474. return;
  475. }
  476. const values = data.map(item => Number(item[column.property]));
  477. if (column.property === 'demandNum' || column.property === 'netDemandNum' || column.property === 'artificialAdjust' || column.property === 'suggestBuyQty' || column.property === 'finalBuyQty') {
  478. sums[index] = values.reduce((prev, curr) => {
  479. const value = Number(curr);
  480. if (!isNaN(value)) {
  481. return prev + curr;
  482. } else {
  483. return prev;
  484. }
  485. }, 0);
  486. sums[index];
  487. }
  488. });
  489. return sums
  490. },
  491. // 搜索
  492. search() {
  493. this.getList(this.queryParams)
  494. },
  495. reset() {
  496. this.queryParams = {
  497. rowStatus: ['1'],
  498. buyer: '',
  499. buyerName: '',
  500. materialClassifyFourName: '',
  501. manufacturer: '',
  502. forecastClassification: '',
  503. periodUnit: '',
  504. departmentName: '',
  505. puManagerAuditor: '',
  506. // zqgdh: '',
  507. code: '',
  508. registrant: '',
  509. businessType: '',
  510. billSource: '',
  511. customer: '',
  512. lastWarehouse: '',
  513. lastAllocation: '',
  514. materialCode: '',
  515. names: '',
  516. purchaseOrg: '',
  517. demandDate: '',
  518. approverFinishTime: '',
  519. pageNum: 1,
  520. pageSize: 10
  521. }
  522. this.getList(this.queryParams)
  523. },
  524. getList(params){
  525. getSummaryList(params).then(res => {
  526. if (res.code === 200) {
  527. this.tableList = res.rows
  528. this.total = res.total
  529. }
  530. })
  531. },
  532. handleSelectionChange(selection) {
  533. console.log('选中', selection)
  534. this.allSelection = selection
  535. this.ids = selection.map(item => item.demandItemId)
  536. console.log('选中数组', this.ids.join())
  537. },
  538. handleCommand(command) {
  539. if(command == 'Excel导出') {
  540. if(this.allSelection.length == 0) {
  541. this.$modal.notifyWarning("请选中至少一条数据");
  542. } else {
  543. exportList(this.allSelection).then(res => {
  544. const blob = new Blob([res], {
  545. type: "application/vnd.ms-excel;charset=UTF-8",
  546. });// 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
  547. const downloadElement = document.createElement("a"); //创建a标签
  548. const href = window.URL.createObjectURL(blob); // 创建下载的链接
  549. // var temp = res.headers["content-disposition"];
  550. // var fileName = decodeURIComponent(temp.split("filename=")[1]); // 中文需要转码 (前端乱码)
  551. // var name = fileName.split(";")[0]; //切割成文件名
  552. downloadElement.href = href; //下载地址
  553. downloadElement.download = '导出Excel'; // 下载后文件名
  554. document.body.appendChild(downloadElement);
  555. downloadElement.click(); // 点击下载
  556. document.body.removeChild(downloadElement); // 下载完成移除元素
  557. window.URL.revokeObjectURL(href); // 释放blob对象
  558. })
  559. }
  560. }
  561. if (command == '导出明细') {
  562. if (this.allSelection.length == 0 || this.allSelection.length > 1) {
  563. this.$modal.notifyWarning("明细只能进行单条导出!");
  564. } else {
  565. let param = this.queryParams
  566. param.sumFlag = this.allSelection[0].sumFlag
  567. exportItems(param).then(res => {
  568. const blob = new Blob([res], {
  569. type: "application/vnd.ms-excel;charset=UTF-8",
  570. });// 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
  571. const downloadElement = document.createElement("a"); //创建a标签
  572. const href = window.URL.createObjectURL(blob); // 创建下载的链接
  573. // var temp = res.headers["content-disposition"];
  574. // var fileName = decodeURIComponent(temp.split("filename=")[1]); // 中文需要转码 (前端乱码)
  575. // var name = fileName.split(";")[0]; //切割成文件名
  576. downloadElement.href = href; //下载地址
  577. downloadElement.download = '导出明细'; // 下载后文件名
  578. document.body.appendChild(downloadElement);
  579. downloadElement.click(); // 点击下载
  580. document.body.removeChild(downloadElement); // 下载完成移除元素
  581. window.URL.revokeObjectURL(href); // 释放blob对象
  582. })
  583. }
  584. }
  585. },
  586. check(row) {
  587. this.isList = false
  588. this.page = 'check'
  589. this.rowDetail = row
  590. this.disable = true
  591. },
  592. handleSizeChange(val) {
  593. console.log(`每页 ${val} 条`);
  594. this.queryParams.pageSize = val
  595. this.getList(this.queryParams)
  596. },
  597. handleCurrentChange(val) {
  598. console.log(`当前页: ${val}`);
  599. this.queryParams.pageNum = val
  600. this.getList(this.queryParams)
  601. },
  602. drop() {
  603. this.expanded = !this.expanded
  604. },
  605. editList() {
  606. console.log('Lists`````',this.tableList)
  607. this.lineDisable = false
  608. },
  609. cancelEdit() {
  610. this.lineDisable = true
  611. this.getList(this.queryParams)
  612. },
  613. saveList() {
  614. editSummaryList(this.tableList).then(res => {
  615. if (res.code === 200) {
  616. this.$modal.notifySuccess("保存成功");
  617. this.lineDisable = true
  618. this.getList(this.queryParams)
  619. }
  620. })
  621. },
  622. confirms() {
  623. if (this.ids.length == 0) {
  624. this.$modal.notifyWarning("请选中至少一条数据");
  625. } else {
  626. confirmSummary(this.allSelection).then(res => {
  627. if (res.code === 200) {
  628. this.$modal.notifySuccess("确认成功");
  629. this.getList(this.queryParams)
  630. }
  631. })
  632. }
  633. },
  634. cancels() {
  635. if (this.ids.length == 0) {
  636. this.$modal.notifyWarning("请选中至少一条数据");
  637. } else {
  638. let param = this.ids.join()
  639. cancelSummary(param).then(res => {
  640. if (res.code === 200) {
  641. this.$modal.notifySuccess("取消成功");
  642. this.getList(this.queryParams)
  643. }
  644. })
  645. }
  646. },
  647. audits() {
  648. if(this.ids.length == 0) {
  649. this.$modal.notifyWarning("请选中至少一条数据");
  650. } else {
  651. let param = this.ids.join()
  652. auditSummary(param).then(res => {
  653. if (res.code === 200) {
  654. this.$modal.notifySuccess("审核成功");
  655. this.getList(this.queryParams)
  656. }
  657. })
  658. }
  659. },
  660. // 行关闭
  661. closeitem() {
  662. let param = this.ids.join()
  663. shutDownSummary(param).then(res => {
  664. if (res.code === 200) {
  665. this.$modal.notifySuccess("操作成功");
  666. this.getList(this.queryParams)
  667. }
  668. })
  669. },
  670. closeLine() {
  671. if (this.ids.length == 0) {
  672. this.$modal.notifyWarning("请选中至少一条数据");
  673. } else {
  674. console.log('选中数组', this.allSelection)
  675. let item = this.allSelection.some(item => {
  676. return item.demandNum >= 2
  677. })
  678. if (item) {
  679. this.$modal.confirm('选中项有多个需求单位,是否确定关闭?').then(function () {
  680. }).then(() => {
  681. this.closeitem()
  682. }).catch(() => {})
  683. } else {
  684. this.closeitem()
  685. }
  686. }
  687. },
  688. // 搜索区参照选择
  689. chooseRefer(type, isPage, title, stordocId) {
  690. this.referCondition.type = type
  691. this.referCondition.isPage = isPage
  692. this.referCondition.title = title
  693. this.referCondition.stordocId = stordocId
  694. this.$refs.refer.init(this.referCondition)
  695. },
  696. selectionsToInput(selection) {
  697. if (this.referCondition.title == '采购员') {
  698. this.personOptions = selection
  699. this.queryParams.buyer = selection[0].code
  700. this.queryParams.buyerName = selection[0].name
  701. }
  702. if (this.referCondition.title == '业务部门') {
  703. this.deptOptions = selection
  704. this.queryParams.departmentName = selection[0].id
  705. }
  706. if (this.referCondition.title == '审核人') {
  707. this.auditOptions = selection
  708. this.queryParams.puManagerAuditor = selection[0].code
  709. }
  710. if (this.referCondition.title == '需求客户') {
  711. this.customerOptions = selection
  712. this.queryParams.customer = selection[0].id
  713. }
  714. if (this.referCondition.title == '供应仓库') {
  715. this.lastWarehouseOptions = selection
  716. this.queryParams.lastWarehouse = selection[0].id
  717. }
  718. if (this.referCondition.title == '供应库位') {
  719. this.lastAllocationOptions = selection
  720. this.queryParams.lastAllocation = selection[0].id
  721. }
  722. if (this.referCondition.title == '默认采购组织') {
  723. this.orgOptions = selection
  724. this.queryParams.purchaseOrg = selection[0].id
  725. }
  726. if (this.referCondition.title == '明细采购员') {
  727. console.log('选择进了吗',this.tableList)
  728. this.tableList[this.tableIndex].buyer = selection[0].code
  729. this.tableList[this.tableIndex].buyerName = selection[0].name
  730. }
  731. // if (this.referCondition.title == '明细默认采购组织') {
  732. // console.log('选择进了吗',this.tableList)
  733. // this.tableList[this.tableIndex].purchaseOrg = selection[0].id
  734. // this.tableList[this.tableIndex].purchaseOrgName = selection[0].name
  735. // }
  736. },
  737. // 搜索区树形选择
  738. chooseTreeRefer(type, isPage, title) {
  739. this.referCondition.type = type
  740. this.referCondition.isPage = isPage
  741. this.referCondition.title = title
  742. this.$refs.tree.init(this.referCondition)
  743. },
  744. selectionsToInput2(selection) {
  745. this.classOptions.push(selection)
  746. this.queryParams.materialClassifyFourName = selection.name
  747. },
  748. // 搜索区物料编码
  749. chooseMaterial() {
  750. this.$refs.materialRefer.init()
  751. },
  752. selectMaterial(selection) {
  753. this.queryParams.materialCode = selection[0].code
  754. this.queryParams.names = selection[0].name
  755. },
  756. // 明细行选择业务部门参照带出业务部门数据
  757. chooseSon(index, type, isPage, title) {
  758. this.tableIndex = index
  759. this.referCondition.type = type
  760. this.referCondition.isPage = isPage
  761. this.referCondition.title = title
  762. this.$refs.refer.init(this.referCondition)
  763. }
  764. }
  765. }
  766. </script>
  767. <style lang="scss" scoped>
  768. #demandSummary {
  769. height: calc(100vh - 84px);
  770. padding: 12px;
  771. box-sizing: border-box;
  772. overflow-y: scroll;
  773. }
  774. .btn_grooup {
  775. margin-bottom: 10px;
  776. display: flex;
  777. justify-content: flex-end;
  778. }
  779. .lines {
  780. margin-top: 0;
  781. }
  782. .hang {
  783. margin: auto;
  784. }
  785. .hang ::v-deep .el-form-item__content{
  786. margin-left: 0px !important;
  787. }
  788. .el-pagination {
  789. margin-top: 10px;
  790. text-align: right;
  791. }
  792. ::v-deep .el-table__row > td {
  793. border: none;
  794. }
  795. ::v-deep .el-card .el-form-item {
  796. margin-bottom: 10px;
  797. }
  798. </style>
  799. <style>
  800. .exporttable {
  801. border: solid 1px #c0c0c0;
  802. }
  803. </style>