index.vue 41 KB

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