index.vue 43 KB

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