index.vue 40 KB

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