index.vue 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016
  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" @clear="cleanBuyer" @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.materialClassifyFour"
  26. size="mini"
  27. multiple
  28. collapse-tags
  29. clearable
  30. @focus="chooseTreeRefer('MATERIALCLASSIFY_PARAM', false, '选择品类')"
  31. style="width: 200px"
  32. >
  33. <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
  34. </el-select>
  35. </el-form-item>
  36. </el-col>
  37. <el-col :span="1.5">
  38. <el-form-item label="生产厂家">
  39. <el-input
  40. v-model.trim="queryParams.manufacturer"
  41. size="mini"
  42. clearable
  43. style="width: 200px"
  44. />
  45. </el-form-item>
  46. </el-col>
  47. <!-- <el-col :span="1.5"> -->
  48. <!-- <el-form-item label="" label-width="20px"> -->
  49. <div style="position: absolute;top: 3px;right: 10px;">
  50. <el-button type="primary" size="mini" @click="search">搜索</el-button>
  51. <el-button size="mini" plain @click="reset">重置</el-button>
  52. </div>
  53. <!-- </el-form-item> -->
  54. <!-- </el-col> -->
  55. </el-row>
  56. <CollapseTransition>
  57. <div v-show="expanded">
  58. <el-row :gutter="10">
  59. <el-col :span="1.5">
  60. <el-form-item label="预测分类">
  61. <el-select v-model="queryParams.forecastClassification" size="mini" style="width: 200px" clearable>
  62. <el-option
  63. v-for="dict in dict.type.predictive_classify" :key="dict.value" :label="dict.label" :value="dict.label">
  64. </el-option>
  65. </el-select>
  66. </el-form-item>
  67. </el-col>
  68. <el-col :span="1.5">
  69. <el-form-item label="审核人">
  70. <el-select clearable size="mini" v-model="queryParams.puManagerAuditor" @focus="chooseRefer('CONTACTS_PARAM', true, '审核人')" style="width: 200px">
  71. <el-option v-for="item in auditOptions" :key="item.id" :label="item.name" :value="item.code" />
  72. </el-select>
  73. </el-form-item>
  74. </el-col>
  75. <el-col :span="1.5">
  76. <el-form-item label="注册人">
  77. <el-input
  78. v-model.trim="queryParams.registrant"
  79. size="mini"
  80. clearable
  81. style="width: 200px"
  82. />
  83. </el-form-item>
  84. </el-col>
  85. <el-col :span="1.5">
  86. <el-form-item label="业务类型">
  87. <el-select v-model="queryParams.businessType" size="mini" style="width: 200px" clearable>
  88. <el-option
  89. v-for="dict in dict.type.sys_business" :key="dict.value" :label="dict.label" :value="dict.value">
  90. </el-option>
  91. </el-select>
  92. </el-form-item>
  93. </el-col>
  94. </el-row>
  95. <el-row :gutter="10">
  96. <el-col :span="1.5">
  97. <el-form-item label="单据来源">
  98. <el-select v-model="queryParams.billSource" size="mini" style="width: 200px" clearable>
  99. <el-option
  100. v-for="dict in dict.type.sys_bill_source" :key="dict.value" :label="dict.label" :value="dict.value">
  101. </el-option>
  102. </el-select>
  103. </el-form-item>
  104. </el-col>
  105. <el-col :span="1.5">
  106. <el-form-item label="需求客户">
  107. <el-select clearable size="mini" v-model="queryParams.customer" @focus="chooseRefer('CUSTOMER_PARAM', true, '需求客户')" style="width: 200px">
  108. <el-option v-for="item in customerOptions" :key="item.id" :label="item.name" :value="item.id" />
  109. </el-select>
  110. </el-form-item>
  111. </el-col>
  112. <el-col :span="1.5">
  113. <el-form-item label="供应仓库">
  114. <el-select clearable size="mini" v-model="queryParams.lastWarehouse" @focus="chooseRefer('WAREHOUSE_PARAM', true, '供应仓库')" style="width: 200px">
  115. <el-option v-for="item in lastWarehouseOptions" :key="item.id" :label="item.name" :value="item.id" />
  116. </el-select>
  117. </el-form-item>
  118. </el-col>
  119. <el-col :span="1.5">
  120. <el-form-item label="供应库位">
  121. <el-select clearable size="mini" v-model="queryParams.lastAllocation" @focus="chooseRefer('ALLOCATION_PARAM', true, '供应库位', queryParams.lastWarehouse)" style="width: 200px">
  122. <el-option v-for="item in lastAllocationOptions" :key="item.id" :label="item.name" :value="item.id" />
  123. </el-select>
  124. </el-form-item>
  125. </el-col>
  126. </el-row>
  127. <el-row :gutter="10">
  128. <el-col :span="1.5">
  129. <el-form-item label="物料编码">
  130. <el-popover
  131. placement="top-start"
  132. width="500"
  133. trigger="hover"
  134. :content="queryParams.names">
  135. <el-input slot="reference" clearable size="mini" v-model="queryParams.names" @clear="clearMaterial" style="width: 200px" @paste.native="pasteMe($event)">
  136. <el-button size="mini" slot="append" icon="el-icon-more" @click="chooseMaterial"></el-button>
  137. </el-input>
  138. </el-popover>
  139. </el-form-item>
  140. </el-col>
  141. <el-col :span="1.5">
  142. <el-form-item label="默认采购组织">
  143. <el-select clearable size="mini" v-model="queryParams.purchaseOrg" @focus="chooseRefer('ORG_PARAM', true, '默认采购组织')" style="width: 200px">
  144. <el-option v-for="item in orgOptions" :key="item.id" :label="item.name" :value="item.id" />
  145. </el-select>
  146. </el-form-item>
  147. </el-col>
  148. <el-col :span="1.5">
  149. <el-form-item label="需求日期">
  150. <el-date-picker
  151. v-model="queryParams.demandDate"
  152. type="date"
  153. value-format="yyyy-MM-dd"
  154. size="mini"
  155. style="width: 200px"
  156. >
  157. </el-date-picker>
  158. </el-form-item>
  159. </el-col>
  160. <el-col :span="1.5">
  161. <el-form-item label="采购需求单号">
  162. <el-input
  163. v-model.trim="queryParams.code"
  164. size="mini"
  165. clearable
  166. style="width: 200px"
  167. />
  168. </el-form-item>
  169. </el-col>
  170. </el-row>
  171. <el-row :gutter="10">
  172. <el-col :span="1.5">
  173. <el-form-item label="审批结束日期">
  174. <el-date-picker
  175. v-model="queryParams.approverFinishTime"
  176. type="date"
  177. clearable
  178. value-format="yyyy-MM-dd"
  179. size="mini"
  180. style="width: 200px"
  181. >
  182. </el-date-picker>
  183. </el-form-item>
  184. </el-col>
  185. <el-col :span="1.5">
  186. <el-form-item label="是否客户指定">
  187. <el-select clearable v-model="queryParams.isCustomerSpecified" size="mini" style="width: 200px">
  188. <el-option
  189. v-for="item in options"
  190. :key="item.value"
  191. :label="item.label"
  192. :value="item.value">
  193. </el-option>
  194. </el-select>
  195. </el-form-item>
  196. </el-col>
  197. <el-col :span="1.5">
  198. <el-form-item label="是否紧急需求">
  199. <el-select clearable v-model="queryParams.isUrgency" size="mini" style="width: 200px">
  200. <el-option
  201. v-for="item in options"
  202. :key="item.value"
  203. :label="item.label"
  204. :value="item.value">
  205. </el-option>
  206. </el-select>
  207. </el-form-item>
  208. </el-col>
  209. </el-row>
  210. </div>
  211. </CollapseTransition>
  212. </el-form>
  213. <el-divider class="lines"><i style="cursor: pointer;" :class="expanded?'el-icon-arrow-up':'el-icon-arrow-down'" @click="drop"></i></el-divider>
  214. <div class="btn_grooup">
  215. <el-button type="primary" size="mini" @click="editList">编辑</el-button>
  216. <el-button type="danger" size="mini" v-if="!lineDisable" @click="cancelEdit">取消编辑</el-button>
  217. <el-button type="success" size="mini" v-if="!lineDisable" @click="saveList">保存</el-button>
  218. <el-button type="primary" size="mini" v-if="lineDisable" @click="confirms">确认</el-button>
  219. <el-button type="primary" size="mini" v-if="lineDisable" @click="cancels">取消</el-button>
  220. <!-- <el-button type="primary" size="mini" v-if="lineDisable" @click="cancelAudit">取消审批</el-button> -->
  221. <el-button type="primary" size="mini" v-if="lineDisable" @click="audits">审核</el-button>
  222. <el-button type="primary" size="mini" v-if="lineDisable" @click="closeLine">行关闭</el-button>
  223. <el-button size="mini" type="primary" style="margin: 0 10px;" v-if="lineDisable" @click="handleCommand">
  224. 导出
  225. </el-button>
  226. <!-- <el-button type="primary" size="mini">转请购</el-button> -->
  227. </div>
  228. <vxe-toolbar ref="xToolbar1" custom>
  229. </vxe-toolbar>
  230. <vxe-table
  231. id="toolbar_demo5"
  232. :custom-config="{storage: true, checkMethod: checkColumnMethod}"
  233. @resizable-change="resizableChangeEvent"
  234. v-loading="loading"
  235. :data="tableList"
  236. :cell-style="{ borderColor: '#c0c0c0' }"
  237. :header-cell-style="{ borderColor: '#c0c0c0' }"
  238. class="exporttable"
  239. border
  240. show-summary
  241. show-footer
  242. :footer-method="getSummaries"
  243. highlight-current-row
  244. max-height="620"
  245. style="font-size: 12px;"
  246. :cell-class-name="cellClassName"
  247. @checkbox-all="selectAllEvent"
  248. @checkbox-change="handleSelectionChange"
  249. @cell-dblclick="doubleClick"
  250. ref="table"
  251. :checkbox-config="{trigger:'row', highlight: true, range: true}"
  252. :column-config="{resizable: true}"
  253. >
  254. <vxe-column type="checkbox" width="50" fixed="left"/>
  255. <vxe-column show-header-overflow show-overflow title="序号" type="seq" align="center" width="50px" fixed="left"/>
  256. <!-- <vxe-column show-header-overflow show-overflow title="行号" align="center" field="rowNo"/> -->
  257. <vxe-column show-header-overflow show-overflow title="行状态" align="center" field="status" width="50px" :formatter="hangStatus"/>
  258. <vxe-column show-header-overflow show-overflow title="最终采购量" align="center" field="finalBuyQty" width="80px">
  259. <template slot-scope="scope">
  260. <el-input size="mini" :disabled="scope.row.status !== '1' || lineDisable" v-model="scope.row.finalBuyQty" @change="jilu(scope.$rowIndex)"/>
  261. </template>
  262. </vxe-column>
  263. <vxe-column show-header-overflow show-overflow title="关闭数量" align="center" field="closeQty" width="50px"/>
  264. <vxe-column show-header-overflow show-overflow title="人工调整数" align="center" field="artificialAdjust" width="50px">
  265. <template slot-scope="scope">
  266. {{scope.row.artificialAdjust = scope.row.finalBuyQty - scope.row.suggestionPurchase}}
  267. </template>
  268. </vxe-column>
  269. <vxe-column show-header-overflow show-overflow title="一级品类" align="center" field="materialClassifyOneName" width="80"/>
  270. <vxe-column show-header-overflow show-overflow title="物料编码" align="center" field="materialCode" width="100px"/>
  271. <vxe-column show-header-overflow show-overflow title="品名" align="center" field="materialName" width="100px"/>
  272. <vxe-column show-header-overflow show-overflow title="规格" align="center" field="specification" width="100px"/>
  273. <vxe-column show-header-overflow show-overflow title="单位" align="center" field="unit" width="50"/>
  274. <vxe-column show-header-overflow show-overflow title="生产厂家/代理人" align="center" field="manufacturer" width="100px"/>
  275. <vxe-column show-header-overflow show-overflow title="需求单位数" align="center" field="demandNum" width="50px"/>
  276. <vxe-column show-header-overflow show-overflow title="总最终净需求量" align="center" field="netDemandNum" width="80px">
  277. <template slot-scope="scope">
  278. {{scope.row.netDemandNum ? parseFloat(scope.row.netDemandNum).toFixed(2) : '0.00'}}
  279. </template>
  280. </vxe-column>
  281. <vxe-column show-header-overflow show-overflow title="近1月月均需求" align="center" field="evensalesforyear" width="50">
  282. <template slot-scope="scope">
  283. {{scope.row.evensalesforyear ? parseFloat(scope.row.evensalesforyear).toFixed(2) : '0.00'}}
  284. </template>
  285. </vxe-column>
  286. <vxe-column show-header-overflow show-overflow title="近3月月均需求" align="center" field="evensalesforthrmonth" width="50">
  287. <template slot-scope="scope">
  288. {{scope.row.evensalesforthrmonth ? parseFloat(scope.row.evensalesforthrmonth).toFixed(2) : '0.00'}}
  289. </template>
  290. </vxe-column>
  291. <vxe-column show-header-overflow show-overflow title="总月销量" align="center" field="totalMonthlySales" width="50">
  292. <template slot-scope="scope">
  293. {{scope.row.totalMonthlySales ? parseFloat(scope.row.totalMonthlySales).toFixed(2) : '0.00'}}
  294. </template>
  295. </vxe-column>
  296. <vxe-column show-header-overflow show-overflow title="需求可用周期" align="center" field="demandCycle" width="50px">
  297. <template slot-scope="scope">
  298. {{scope.row.demandCycle ? parseFloat(scope.row.demandCycle).toFixed(1) : '-'}}
  299. </template>
  300. </vxe-column>
  301. <vxe-column show-header-overflow show-overflow title="呆滞量" align="center" field="dullQut" width="50px">
  302. <template slot-scope="scope">
  303. {{parseFloat(scope.row.dullQut).toFixed(2)}}
  304. </template>
  305. </vxe-column>
  306. <vxe-column show-header-overflow show-overflow title="采购周期" align="center" field="buyPeriod" width="50px" />
  307. <vxe-column show-header-overflow show-overflow title="中心公共库存" align="center" field="centralPublicStock" width="50"/>
  308. <vxe-column show-header-overflow show-overflow title="中心仓专属货位" align="center" field="centralWarehouse" width="50"/>
  309. <vxe-column show-header-overflow show-overflow title="各项目仓库存" align="center" field="eachWarehouseStock" width="50"/>
  310. <vxe-column show-header-overflow show-overflow title="电商仓库" align="center" field="commerceWarehouse" width="50" />
  311. <vxe-column show-header-overflow show-overflow title="区域分仓公共库存" align="center" field="regionPublicStock" width="50"/>
  312. <vxe-column show-header-overflow show-overflow title="采购在途" align="center" field="buyTransit" width="80px" />
  313. <vxe-column show-header-overflow show-overflow title="借出在途" align="center" field="lendTransit" width="80px" />
  314. <vxe-column show-header-overflow show-overflow title="调拨在途" align="center" field="transferTransit" width="80px"/>
  315. <vxe-column show-header-overflow show-overflow title="库存总计" align="center" field="stockTotal" width="80px"/>
  316. <vxe-column show-header-overflow show-overflow title="最小包装量" align="center" field="minPackage" width="80px"/>
  317. <vxe-column show-header-overflow show-overflow title="最小订货量" align="center" field="minOrder" width="80px"/>
  318. <vxe-column show-header-overflow show-overflow title="最小批量" align="center" field="minBatch" width="80px"/>
  319. <vxe-column show-header-overflow show-overflow title="修改原因" align="center" field="modifyReason" width="150px">
  320. <template slot-scope="scope">
  321. <el-input size="mini" :disabled="scope.row.status !== '1'|| lineDisable || scope.row.artificialAdjust == '0'" v-model="scope.row.modifyReason" @change="jilu(scope.$rowIndex)"/>
  322. </template>
  323. </vxe-column>
  324. <vxe-column show-header-overflow show-overflow title="建议采购量" align="center" field="suggestionPurchase" width="80px"/>
  325. <!-- <vxe-column show-header-overflow show-overflow title="建议净采购量" align="center" field="suggestBuyQty" width="100px"/> -->
  326. <vxe-column show-header-overflow show-overflow title="二级品类" align="center" field="materialClassifyTwoName" width="120px"/>
  327. <vxe-column show-header-overflow show-overflow title="三级品类" align="center" field="materialClassifyThreeName" width="120px"/>
  328. <vxe-column show-header-overflow show-overflow title="四级品类" align="center" field="materialClassifyFourName" width="120px"/>
  329. <vxe-column show-header-overflow show-overflow title="采购员" align="center" field="buyerName" width="150px">
  330. <template slot-scope="scope">
  331. <el-input readonly :disabled="scope.row.status !== '1' || lineDisable" size="mini" v-model="scope.row.buyerName">
  332. <el-button size="mini" :disabled="scope.row.status !== '1' || lineDisable" slot="append" icon="el-icon-more" @click="chooseSon(scope.$rowIndex, 'CONTACTS_PARAM', true, '明细采购员')"></el-button>
  333. </el-input>
  334. </template>
  335. </vxe-column>
  336. <vxe-column show-header-overflow show-overflow title="默认采购组织" align="center" field="purchaseOrgName" width="150px">
  337. <!-- <template slot-scope="scope">
  338. <el-input readonly :disabled="scope.row.status !== '1' || lineDisable" size="mini" v-model="scope.row.purchaseOrgName">
  339. <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>
  340. </el-input>
  341. </template> -->
  342. </vxe-column>
  343. <vxe-column show-header-overflow show-overflow title="有效期" align="center" field="validityPeriod"/>
  344. <vxe-column show-header-overflow show-overflow title="有效期单位" align="center" field="validityPeriodUnit" width="80px"/>
  345. <vxe-column show-header-overflow show-overflow title="业务类型" align="center" field="businessType" :formatter="formatterBusinessType"/>
  346. <vxe-column show-header-overflow show-overflow title="安全库存量" align="center" field="safetyStock" width="80px">
  347. <template slot-scope="scope">
  348. {{scope.row.safetyStock ? parseFloat(scope.row.safetyStock).toFixed(2) : '0.00'}}
  349. </template>
  350. </vxe-column>
  351. <vxe-column show-header-overflow show-overflow title="单据来源" align="center" field="billSource" :formatter="formatterSource"/>
  352. <vxe-column show-header-overflow show-overflow title="注册人" align="center" field="registrant" width="120px"/>
  353. <!-- <vxe-column title="可用量" align="center" field="qty"/> -->
  354. <vxe-column show-header-overflow show-overflow title="总需与终采差异" align="center" field="buyDiscrepancy" width="80px"/>
  355. <vxe-column show-header-overflow show-overflow title="集团预测分类" align="center" field="forecastClassification" width="80px"/>
  356. <vxe-column show-header-overflow show-overflow title="中心仓占有量" align="center" field="centerBinPossession" width="80px"/>
  357. <vxe-column show-header-overflow show-overflow title="中心仓可用量" align="center" field="centralWarehouseAvailable" width="80px"/>
  358. <!-- <vxe-column title="物料类别" align="center" field="materialCategory" width="150px"/> -->
  359. <!-- <vxe-column title="业务部门" align="center" field="departmentName" width="150px"/> -->
  360. <!-- <vxe-column show-header-overflow show-overflow title="需求单位" align="center" field="demandUnit"/> -->
  361. <vxe-column show-header-overflow show-overflow title="采购经理审核人" align="center" field="puManagerAuditor" width="120px"/>
  362. <vxe-column
  363. fixed="right"
  364. title="操作"
  365. align="center"
  366. width="50"
  367. >
  368. <template slot-scope="scope">
  369. <el-button type="text" size="mini" @click="check(scope.row)">查看</el-button>
  370. </template>
  371. </vxe-column>
  372. </vxe-table>
  373. <!-- <el-button size="mini" style="position: absolute;left: 20px;bottom: 20px;" @click="tols.open = true">隐藏列</el-button> -->
  374. <colTol :isVisible.sync="tols.open" @reDraw="reDraw" :showColumn.sync="showColumn" :arrs.sync="arrs"/>
  375. <el-pagination
  376. background
  377. @size-change="handleSizeChange"
  378. @current-change="handleCurrentChange"
  379. :current-page="queryParams.pageNum"
  380. :page-sizes="[10, 20, 50, 100, 200, 500]"
  381. :page-size="50"
  382. layout="total, sizes, prev, pager, next, jumper"
  383. :total=total>
  384. </el-pagination>
  385. </el-card>
  386. </div>
  387. <Add v-model="isList" v-if="!isList" :pageStu="page" :disable="disable" :row="rowDetail" :query="queryParams" @refresh="search"/>
  388. <Refers ref="refer" @doSubmit="selectionsToInput" :single="true"/>
  389. <TreeRefers ref="tree" @doSubmit="selectionsToInput2" :single="true"/>
  390. <popDialog ref="materialRefer" @doSubmit="selectMaterial" :single="false" />
  391. </div>
  392. </template>
  393. <script>
  394. import Add from './add'
  395. import colTol from './colTol.vue'
  396. import Refers from '@/components/Refers/refers.vue'
  397. import TreeRefers from '@/components/Refers/treeRefer.vue'
  398. import popDialog from '@/components/PopDialog/index.vue'
  399. import CollapseTransition from '@/components/MyCollapse/collapse.vue'
  400. // 用于物料参照框数据
  401. import {getRefer} from '@/api/purchase/basic.js'
  402. import {getSummaryList, auditSummary, cancelAudits, confirmSummary , cancelSummary , shutDownSummary, editSummaryList, exportList, exportItems } from '@/api/purchase/DemandSummary.js'
  403. export default {
  404. name: 'demandSummary',
  405. dicts: ['sys_row_status', 'predictive_classify', 'sys_period_unit', 'sys_business', 'sys_bill_source'],
  406. components: {
  407. Add,
  408. colTol,
  409. CollapseTransition,
  410. Refers,
  411. TreeRefers,
  412. popDialog
  413. },
  414. data() {
  415. return {
  416. loading: true,
  417. showColumn: {},
  418. arrs:[],
  419. tols: {
  420. open: false
  421. },
  422. hangStatus(row) {
  423. switch (row.row.status) {
  424. case '0':
  425. return '需补货'
  426. case '1':
  427. return '待计划确认'
  428. case '2':
  429. return '计划已确认'
  430. case '3':
  431. return '计划已审核'
  432. case '4':
  433. return '行关闭'
  434. case '5':
  435. return '总供应可满足'
  436. }
  437. },
  438. formatterBusinessType(row) {
  439. switch (row.row.businessType) {
  440. case 'ZQBH':
  441. return '周期备货'
  442. case 'FXXQ':
  443. return '分销需求'
  444. case 'TSXQ':
  445. return '特殊采购需求'
  446. case 'BDXQ':
  447. return '补单需求'
  448. case 'JJXQ':
  449. return '紧急需求单'
  450. case 'XPXQ':
  451. return '新品需求'
  452. case 'HZBM':
  453. return '合作部门需求'
  454. }
  455. },
  456. formatterSource(row) {
  457. switch (row.row.billSource) {
  458. case '1':
  459. return '手工导入'
  460. case '2':
  461. return '按客户计算'
  462. case '3':
  463. return '按仓库计算'
  464. case '4':
  465. return '手工新增'
  466. }
  467. },
  468. expanded: false,
  469. // 页面配置
  470. isList: true,
  471. // 页面状态
  472. page: '',
  473. queryParams: {
  474. rowStatus: ['1'],
  475. buyer: '',
  476. buyerName: '',
  477. materialClassifyFour: [],
  478. manufacturer: '',
  479. forecastClassification: '',
  480. periodUnit: '',
  481. departmentName: '',
  482. puManagerAuditor: '',
  483. // zqgdh: '',
  484. code: '',
  485. registrant: '',
  486. businessType: '',
  487. billSource: '',
  488. customer: '',
  489. lastWarehouse: '',
  490. lastAllocation: '',
  491. materialCodeList: [],
  492. names: '',
  493. purchaseOrg: '',
  494. demandDate: '',
  495. approverFinishTime: '',
  496. isCustomerSpecified: '',
  497. isUrgency: '',
  498. pageNum: 1,
  499. pageSize: 50
  500. },
  501. personOptions: [],
  502. classOptions: [],
  503. deptOptions: [],
  504. auditOptions: [],
  505. customerOptions: [],
  506. lastWarehouseOptions: [],
  507. lastAllocationOptions: [],
  508. orgOptions: [],
  509. options: [{
  510. value: 'Y', label: '是',
  511. }, {
  512. value: 'N', label: '否'
  513. }],
  514. referCondition: {
  515. type: '',
  516. isPage: true,
  517. title: ''
  518. },
  519. tableList: [],
  520. total: 0,
  521. rowDetail: {},
  522. disable: false,
  523. lineDisable: true,
  524. ids: [],
  525. allSelection: [],
  526. // 子表index
  527. tableIndex: null,
  528. // referConditionMx: {
  529. // type: '',
  530. // isPage: true,
  531. // title: ''
  532. // }
  533. // 用于保存临时记录修改行的数组
  534. record:[]
  535. }
  536. },
  537. created() {
  538. this.$nextTick(() => {
  539. // 手动将表格和工具栏进行关联
  540. this.$refs.table.connect(this.$refs.xToolbar1)
  541. this.getList(this.queryParams)
  542. })
  543. },
  544. methods: {
  545. checkColumnMethod ({ column }) {
  546. if (column.property === 'role') {
  547. return false
  548. }
  549. return true
  550. },
  551. resizableChangeEvent () {
  552. const columns = this.$refs.table.getColumns()
  553. const customData = columns.map(column => {
  554. return {
  555. width: column.renderWidth
  556. }
  557. })
  558. console.log(customData)
  559. },
  560. reDraw() {
  561. // this.$refs.table.doLayout();
  562. },
  563. // 单元格标红
  564. cellClassName({row, column, rowIndex, columnIndex}) {
  565. if(column.title == "需求可用周期" && Number(row.demandCycle) > 1.5 ) {
  566. return 'success-row';
  567. }
  568. },
  569. // 指定列合计
  570. getSummaries(param) {
  571. const { columns, data } = param;
  572. const sums = [];
  573. columns.forEach((column, index) => {
  574. if (index === 0) {
  575. sums.push('合计');
  576. return;
  577. }
  578. const values = data.map(item => Number(item[column.property]));
  579. if (column.property === 'demandNum' || column.property === 'netDemandNum' || column.property === 'artificialAdjust' || column.property === 'suggestBuyQty' || column.property === 'finalBuyQty') {
  580. sums[index] = values.reduce((prev, curr) => {
  581. const value = Number(curr);
  582. if (!isNaN(value)) {
  583. return prev + curr;
  584. } else {
  585. return prev;
  586. }
  587. }, 0);
  588. sums[index];
  589. }
  590. });
  591. return [sums]
  592. },
  593. // 搜索
  594. search() {
  595. this.getList(this.queryParams)
  596. },
  597. reset() {
  598. this.queryParams = {
  599. rowStatus: ['1'],
  600. buyer: '',
  601. buyerName: '',
  602. materialClassifyFour: [],
  603. manufacturer: '',
  604. forecastClassification: '',
  605. periodUnit: '',
  606. departmentName: '',
  607. puManagerAuditor: '',
  608. // zqgdh: '',
  609. code: '',
  610. registrant: '',
  611. businessType: '',
  612. billSource: '',
  613. customer: '',
  614. lastWarehouse: '',
  615. lastAllocation: '',
  616. materialCodeList: [],
  617. names: '',
  618. purchaseOrg: '',
  619. demandDate: '',
  620. approverFinishTime: '',
  621. isCustomerSpecified: '',
  622. isUrgency: '',
  623. pageNum: 1,
  624. pageSize: 50
  625. }
  626. this.getList(this.queryParams)
  627. },
  628. getList(params){
  629. getSummaryList(params).then(res => {
  630. if (res.code === 200) {
  631. this.tableList = res.rows
  632. this.total = res.total
  633. // let arrs = []
  634. // this.$refs.table.$children.forEach(item => {
  635. // if (item.label != undefined && item.prop != undefined) {
  636. // arrs.push({
  637. // label: item.label,
  638. // prop: item.prop
  639. // })
  640. // }
  641. // })
  642. // this.arrs = arrs
  643. }
  644. }).then(() => {
  645. // 合计不显示重绘
  646. this.$refs.table.doLayout()
  647. this.loading = false
  648. }).catch(err => {
  649. this.loading = false
  650. })
  651. },
  652. selectAllEvent({checked}) {
  653. const selection = this.$refs.table.getCheckboxRecords()
  654. console.log('选中', selection)
  655. this.allSelection = selection
  656. this.ids = selection.map(item => item.demandItemId)
  657. console.log('选中数组', this.ids.join())
  658. },
  659. handleSelectionChange({checked}) {
  660. const selection = this.$refs.table.getCheckboxRecords()
  661. console.log('选中', selection)
  662. this.allSelection = selection
  663. this.ids = selection.map(item => item.demandItemId)
  664. console.log('选中数组', this.ids.join())
  665. },
  666. handleCommand() {
  667. this.$modal.loading("正在导出数据,请稍后...");
  668. let param = this.queryParams
  669. param.pageSize = this.total
  670. exportItems(param).then(res => {
  671. this.$modal.closeLoading();
  672. const blob = new Blob([res], {
  673. type: "application/vnd.ms-excel;charset=UTF-8",
  674. });// 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
  675. const downloadElement = document.createElement("a"); //创建a标签
  676. const href = window.URL.createObjectURL(blob); // 创建下载的链接
  677. // var temp = res.headers["content-disposition"];
  678. // var fileName = decodeURIComponent(temp.split("filename=")[1]); // 中文需要转码 (前端乱码)
  679. // var name = fileName.split(";")[0]; //切割成文件名
  680. downloadElement.href = href; //下载地址
  681. downloadElement.download = '采购需求处理导出'+ this.parseTime(new Date().getTime()) + ".xlsx"; // 下载后文件名
  682. document.body.appendChild(downloadElement);
  683. downloadElement.click(); // 点击下载
  684. document.body.removeChild(downloadElement); // 下载完成移除元素
  685. window.URL.revokeObjectURL(href); // 释放blob对象
  686. })
  687. },
  688. check(row) {
  689. this.isList = false
  690. this.page = 'check'
  691. this.rowDetail = row
  692. this.disable = true
  693. },
  694. doubleClick({row}) {
  695. this.isList = false
  696. this.page = 'check'
  697. this.rowDetail = row
  698. this.disable = true
  699. },
  700. // 表格选中数据
  701. rowSelect(row) {
  702. // console.log(row)
  703. this.$refs.table.toggleCheckboxRow(row.row);
  704. },
  705. handleSizeChange(val) {
  706. console.log(`每页 ${val} 条`);
  707. this.queryParams.pageSize = val
  708. this.getList(this.queryParams)
  709. },
  710. handleCurrentChange(val) {
  711. console.log(`当前页: ${val}`);
  712. this.queryParams.pageNum = val
  713. this.getList(this.queryParams)
  714. },
  715. drop() {
  716. this.expanded = !this.expanded
  717. },
  718. editList() {
  719. console.log('Lists`````',this.tableList)
  720. this.lineDisable = false
  721. },
  722. cancelEdit() {
  723. this.lineDisable = true
  724. this.getList(this.queryParams)
  725. },
  726. saveList() {
  727. // console.log('记录',this.record)
  728. // 对记录的数据进行去重
  729. let newRecord = Array.from(new Set(this.record))
  730. // console.log('去重后的', newRecord)
  731. let changeList = newRecord.map(i => {
  732. return this.tableList[i]
  733. })
  734. // console.log('shuzu', changeList)
  735. editSummaryList(changeList).then(res => {
  736. if (res.code === 200) {
  737. this.$modal.notifySuccess("保存成功");
  738. this.lineDisable = true
  739. this.getList(this.queryParams)
  740. }
  741. })
  742. },
  743. confirms() {
  744. if (this.ids.length == 0) {
  745. this.$modal.notifyWarning("请选中至少一条数据");
  746. } else {
  747. confirmSummary(this.allSelection).then(res => {
  748. if (res.code === 200) {
  749. this.$modal.notifySuccess("确认成功");
  750. this.getList(this.queryParams)
  751. }
  752. })
  753. }
  754. },
  755. cancels() {
  756. if (this.ids.length == 0) {
  757. this.$modal.notifyWarning("请选中至少一条数据");
  758. } else {
  759. let param = this.ids.join()
  760. cancelSummary(param).then(res => {
  761. if (res.code === 200) {
  762. this.$modal.notifySuccess("取消成功");
  763. this.getList(this.queryParams)
  764. }
  765. })
  766. }
  767. },
  768. cancelAudit() {
  769. if(this.ids.length == 0) {
  770. this.$modal.notifyWarning("请选中至少一条数据");
  771. } else {
  772. let param = this.ids.join()
  773. cancelAudits(param).then(res => {
  774. if (res.code === 200) {
  775. this.$modal.notifySuccess("审核成功");
  776. this.getList(this.queryParams)
  777. }
  778. })
  779. }
  780. },
  781. audits() {
  782. if(this.ids.length == 0) {
  783. this.$modal.notifyWarning("请选中至少一条数据");
  784. } else {
  785. let param = this.ids.join()
  786. auditSummary(param).then(res => {
  787. if (res.code === 200) {
  788. this.$modal.notifySuccess("审核成功");
  789. this.getList(this.queryParams)
  790. }
  791. }).catch(err => {
  792. this.getList(this.queryParams)
  793. })
  794. }
  795. },
  796. // 行关闭
  797. closeitem() {
  798. let param = this.ids.join()
  799. shutDownSummary(param).then(res => {
  800. if (res.code === 200) {
  801. this.$modal.notifySuccess("操作成功");
  802. this.getList(this.queryParams)
  803. }
  804. })
  805. },
  806. closeLine() {
  807. if (this.ids.length == 0) {
  808. this.$modal.notifyWarning("请选中至少一条数据");
  809. } else {
  810. console.log('选中数组', this.allSelection)
  811. let item = this.allSelection.some(item => {
  812. return item.demandNum >= 2
  813. })
  814. if (item) {
  815. this.$modal.confirm('选中项有多个需求单位,是否确定关闭?').then(function () {
  816. }).then(() => {
  817. this.closeitem()
  818. }).catch(() => {})
  819. } else {
  820. this.closeitem()
  821. }
  822. }
  823. },
  824. // 搜索区参照选择
  825. chooseRefer(type, isPage, title, stordocId) {
  826. this.referCondition.type = type
  827. this.referCondition.isPage = isPage
  828. this.referCondition.title = title
  829. this.referCondition.stordocId = stordocId
  830. this.$refs.refer.init(this.referCondition)
  831. },
  832. selectionsToInput(selection) {
  833. if (this.referCondition.title == '采购员') {
  834. this.personOptions = selection
  835. this.queryParams.buyer = selection[0].code
  836. this.queryParams.buyerName = selection[0].name
  837. }
  838. if (this.referCondition.title == '业务部门') {
  839. this.deptOptions = selection
  840. this.queryParams.departmentName = selection[0].id
  841. }
  842. if (this.referCondition.title == '审核人') {
  843. this.auditOptions = selection
  844. this.queryParams.puManagerAuditor = selection[0].code
  845. }
  846. if (this.referCondition.title == '需求客户') {
  847. this.customerOptions = selection
  848. this.queryParams.customer = selection[0].id
  849. }
  850. if (this.referCondition.title == '供应仓库') {
  851. this.lastWarehouseOptions = selection
  852. this.queryParams.lastWarehouse = selection[0].id
  853. }
  854. if (this.referCondition.title == '供应库位') {
  855. this.lastAllocationOptions = selection
  856. this.queryParams.lastAllocation = selection[0].id
  857. }
  858. if (this.referCondition.title == '默认采购组织') {
  859. this.orgOptions = selection
  860. this.queryParams.purchaseOrg = selection[0].id
  861. }
  862. if (this.referCondition.title == '明细采购员') {
  863. console.log('选择进了吗',this.tableList)
  864. this.record.push(this.tableIndex)
  865. this.tableList[this.tableIndex].buyer = selection[0].code
  866. this.tableList[this.tableIndex].buyerName = selection[0].name
  867. }
  868. // if (this.referCondition.title == '明细默认采购组织') {
  869. // console.log('选择进了吗',this.tableList)
  870. // this.tableList[this.tableIndex].purchaseOrg = selection[0].id
  871. // this.tableList[this.tableIndex].purchaseOrgName = selection[0].name
  872. // }
  873. },
  874. // 搜索区树形选择
  875. chooseTreeRefer(type, isPage, title) {
  876. this.referCondition.type = type
  877. this.referCondition.isPage = isPage
  878. this.referCondition.title = title
  879. this.$refs.tree.init(this.referCondition)
  880. },
  881. selectionsToInput2(selection) {
  882. this.classOptions = selection
  883. this.queryParams.materialClassifyFour = selection.map(item => {return item.id})
  884. },
  885. // 搜索区物料编码
  886. chooseMaterial() {
  887. this.$refs.materialRefer.init()
  888. },
  889. selectMaterial(selection) {
  890. console.log('选择的物料', selection)
  891. this.queryParams.materialCodeList = selection.map(item => {return item.code})
  892. console.log(this.queryParams.materialCodeList)
  893. this.queryParams.names = (selection.map(item => {return item.name})).join(',')
  894. },
  895. // 清空物料搜索框
  896. clearMaterial() {
  897. this.queryParams.names = ''
  898. this.queryParams.materialCodeList = []
  899. },
  900. // 粘贴来的数据
  901. async pasteMe(e) {
  902. this.$modal.loading("正在粘贴数据...");
  903. e.preventDefault() //阻止默认粘贴事件
  904. let source = e.clipboardData.getData("Text");
  905. console.log('source', source)
  906. // 这里区分普通复制和在表格内复制,判断是否包含','
  907. // 没找到,就通过表格复制
  908. if (source.indexOf(",") === -1) {
  909. // 首先对源头进行解析
  910. let rows = source.split("\r\n"); // 拆成一个数组
  911. // 数组去除空字符串
  912. rows = rows.filter(item => {
  913. return item && item.trim()
  914. })
  915. await getRefer({ type: 'MATERIAL_PARAM', materialCodeList: rows }).then(res => {
  916. this.$modal.closeLoading();
  917. if (res.code === 200) {
  918. let rowList = res.rows
  919. console.log('粘贴的', rowList)
  920. this.queryParams.materialCodeList = rowList.map(item => {return item.code})
  921. this.queryParams.names = (rowList.map(item => {return item.code})).join(',')
  922. }
  923. }).catch(err => {
  924. this.$modal.closeLoading();
  925. })
  926. } else {
  927. // 找到了,按,分割
  928. let codelist = source.split(',')
  929. console.log('按照逗号分隔', codelist)
  930. // 数组去除空字符串
  931. codelist = codelist.filter(item => {
  932. return item && item.trim()
  933. })
  934. this.queryParams.materialCodeList = codelist
  935. this.queryParams.names = codelist.join(',')
  936. this.$modal.closeLoading();
  937. }
  938. },
  939. // 明细行选择业务部门参照带出业务部门数据
  940. chooseSon(index, type, isPage, title) {
  941. this.tableIndex = index
  942. this.referCondition.type = type
  943. this.referCondition.isPage = isPage
  944. this.referCondition.title = title
  945. this.$refs.refer.init(this.referCondition)
  946. },
  947. jilu(index) {
  948. this.record.push(index)
  949. },
  950. // 清空搜索区采购员
  951. cleanBuyer() {
  952. this.queryParams.buyer = ''
  953. this.queryParams.buyerName = ''
  954. }
  955. }
  956. }
  957. </script>
  958. <style lang="scss" scoped>
  959. #demandSummary {
  960. padding: 12px;
  961. box-sizing: border-box;
  962. overflow-y: scroll;
  963. }
  964. .btn_grooup {
  965. margin-bottom: 10px;
  966. display: flex;
  967. justify-content: flex-end;
  968. }
  969. .lines {
  970. margin-top: 0;
  971. }
  972. .hang {
  973. margin: auto;
  974. }
  975. .hang ::v-deep .el-form-item__content{
  976. margin-left: 0px !important;
  977. }
  978. .el-pagination {
  979. margin-top: 10px;
  980. text-align: right;
  981. }
  982. ::v-deep .vxe-body--row > td {
  983. border-right: none;
  984. }
  985. ::v-deep .el-card .el-form-item {
  986. margin-bottom: 3px;
  987. }
  988. ::v-deep .vxe-body--row .success-row {
  989. background-color: #ff8a8a!important;
  990. }
  991. </style>
  992. <style>
  993. .exporttable {
  994. border: solid 1px #c0c0c0;
  995. }
  996. </style>