index.vue 35 KB

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