purchase.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. <!-- 采购列表 -->
  2. <template>
  3. <div class="purchase">
  4. <template v-if="!addOrUpdateVisible && !detailVisible && !operateVisible && !inboundVisible && !noticeChangeAttachVisible && !amountMaskSettingVisible">
  5. <el-form :inline="true" :model="dataForm" @keyup.enter.native="search()">
  6. <el-form-item label="类别">
  7. <el-select
  8. v-model="dataForm.purchaseType"
  9. remote
  10. placeholder="请选择">
  11. <el-option
  12. v-for="item in optionsType"
  13. :key="item.code"
  14. :label="item.value"
  15. :value="item.code">
  16. </el-option>
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item label="物品名称">
  20. <el-input v-model="dataForm.materialName" placeholder="物品名称" clearable/>
  21. </el-form-item>
  22. <el-form-item label="申请时间">
  23. <el-date-picker
  24. v-model="dataForm.date"
  25. value-format="yyyy-MM-dd HH:mm:ss"
  26. type="datetimerange"
  27. range-separator="至"
  28. start-placeholder="开始日期"
  29. end-placeholder="结束日期">
  30. </el-date-picker>
  31. </el-form-item>
  32. <el-form-item label="状态">
  33. <el-select
  34. v-model="dataForm.purchaseState"
  35. remote
  36. placeholder="请选择">
  37. <el-option
  38. v-for="item in optionsState"
  39. :key="item.code"
  40. :label="item.value"
  41. :value="item.code">
  42. </el-option>
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item>
  46. <el-button @click="search()">查询</el-button>
  47. <el-button v-if="isAuth('purchase:detail:save')" type="primary" @click="addOrUpdateHandle(0)">新建采购申请</el-button>
  48. <el-button v-if="isAuth('purchase:detail:noteChangeConfig')" type="primary" @click="setNoticeChangeHandel()">工作提示通知设置</el-button>
  49. <el-button v-if="isAuth('purchase:detail:priceConfig')" type="primary" @click="setAmountMaskHandel()">采购金额屏蔽设置</el-button>
  50. <el-button v-if="isAuth('purchase:detail:updatePurchaseDetail')" type="primary" @click="batchBuyHandel()" :disabled="batchBuyBtnDisabled">批量采购</el-button>
  51. <el-button v-if="isAuth('purchase:detail:infoPutIn')" type="primary" @click="batchIncomeHandel()" :disabled="batchIncomeBtnDisabled">批量入库</el-button>
  52. </el-form-item>
  53. </el-form>
  54. <el-table
  55. @selection-change="handleSelectionChange"
  56. :data="dataList"
  57. border
  58. v-loading="dataListLoading"
  59. style="width: 100%;">
  60. <el-table-column
  61. type="selection"
  62. width="55">
  63. </el-table-column>
  64. <el-table-column
  65. label="序号"
  66. type="index"
  67. width="50"
  68. align="center">
  69. </el-table-column>
  70. <el-table-column
  71. prop="procurementCode"
  72. header-align="center"
  73. align="center"
  74. min-width="180"
  75. :show-tooltip-when-overflow="true"
  76. label="采购编码">
  77. </el-table-column>
  78. <el-table-column
  79. prop="materialName"
  80. header-align="center"
  81. align="center"
  82. width="160"
  83. :show-tooltip-when-overflow="true"
  84. label="物品名称">
  85. </el-table-column>
  86. <el-table-column
  87. prop="purchaseType"
  88. header-align="center"
  89. align="center"
  90. :formatter="formatType"
  91. label="采购类别">
  92. </el-table-column>
  93. <el-table-column
  94. prop="specification"
  95. header-align="center"
  96. align="center"
  97. width="120"
  98. :show-tooltip-when-overflow="true"
  99. label="型号及规格">
  100. </el-table-column>
  101. <el-table-column
  102. prop="cnt"
  103. header-align="center"
  104. align="center"
  105. label="数量">
  106. </el-table-column>
  107. <el-table-column
  108. prop="qualifiedCnt"
  109. header-align="center"
  110. align="center"
  111. label="合格数量">
  112. </el-table-column>
  113. <el-table-column
  114. prop="unitName"
  115. header-align="center"
  116. align="center"
  117. min-width="100"
  118. :show-tooltip-when-overflow="true"
  119. label="单位">
  120. </el-table-column>
  121. <el-table-column
  122. prop="deadline"
  123. header-align="center"
  124. align="center"
  125. min-width="160"
  126. :show-tooltip-when-overflow="true"
  127. label="采购期限">
  128. </el-table-column>
  129. <el-table-column
  130. prop="arrivedTime"
  131. header-align="center"
  132. align="center"
  133. min-width="160"
  134. :show-tooltip-when-overflow="true"
  135. label="到料时间">
  136. </el-table-column>
  137. <el-table-column
  138. prop="batchNumber"
  139. header-align="center"
  140. align="center"
  141. min-width="160"
  142. :show-tooltip-when-overflow="true"
  143. label="批次号">
  144. </el-table-column>
  145. <el-table-column
  146. prop="use"
  147. header-align="center"
  148. align="center"
  149. min-width="160"
  150. :show-tooltip-when-overflow="true"
  151. label="用途">
  152. </el-table-column>
  153. <el-table-column
  154. prop="procurementBasis"
  155. header-align="center"
  156. align="center"
  157. min-width="120"
  158. :show-tooltip-when-overflow="true"
  159. label="采购依据">
  160. <template slot-scope="scope">
  161. <span>{{scope.row.procurementBasis?(Number(scope.row.procurementBasis) === 1?'合同采购':'计划采购'):''}}</span>
  162. </template>
  163. </el-table-column>
  164. <el-table-column
  165. prop="supplierName"
  166. header-align="center"
  167. align="center"
  168. min-width="160"
  169. :show-tooltip-when-overflow="true"
  170. label="供应商">
  171. </el-table-column>
  172. <el-table-column
  173. prop="applyTime"
  174. header-align="center"
  175. align="center"
  176. min-width="160"
  177. :show-tooltip-when-overflow="true"
  178. label="申请时间">
  179. </el-table-column>
  180. <el-table-column
  181. prop="applier"
  182. header-align="center"
  183. align="center"
  184. min-width="100"
  185. :show-tooltip-when-overflow="true"
  186. label="申请人">
  187. </el-table-column>
  188. <el-table-column
  189. prop="orgName"
  190. header-align="center"
  191. align="center"
  192. min-width="120"
  193. :show-tooltip-when-overflow="true"
  194. label="申请部门">
  195. </el-table-column>
  196. <el-table-column
  197. fixed="right"
  198. prop="approvalState"
  199. header-align="center"
  200. align="center"
  201. :formatter="formatState"
  202. label="审批状态">
  203. </el-table-column>
  204. <el-table-column
  205. fixed="right"
  206. prop="purchaseState"
  207. header-align="center"
  208. align="center"
  209. :formatter="formatPurchaseState"
  210. label="采购状态">
  211. </el-table-column>
  212. <el-table-column
  213. prop="notes"
  214. header-align="center"
  215. align="center"
  216. min-width="180"
  217. :show-overflow-tooltip="true"
  218. label="备注">
  219. </el-table-column>
  220. <el-table-column
  221. fixed="right"
  222. header-align="center"
  223. align="center"
  224. width="150"
  225. label="操作">
  226. <template slot-scope="scope">
  227. <el-button v-if="isAuth('purchase:detail:info')" type="text" size="small" @click="detailHandle(scope.row.procurementId)">查看</el-button>
  228. <el-button v-if="isAuth('purchase:detail:update') && (Number(scope.row.approvalState) === 0) && scope.row.creatorId === userId.toString()" type="text" size="small" @click="addOrUpdateHandle(scope.row.procurementId)">编辑</el-button>
  229. <el-button v-if="isAuth('purchase:detail:updatePurchaseDetail')&& (Number(scope.row.approvalState) === 3) && (Number(scope.row.purchaseState) === 1)" type="text" size="small" @click="operateHandle(scope.row)">采购</el-button>
  230. <el-button v-if="isAuth('purchase:detail:infoPutIn') && (Number(scope.row.approvalState) === 3 && (Number(scope.row.purchaseState) === 2 || Number(scope.row.purchaseState) === 5))" type="text" size="small" @click="inboundHandle(scope.row)">入库</el-button>
  231. <el-button v-if="isAuth('purchase:detail:infoPutInAgain') && (Number(scope.row.purchaseState) === 5)" type="text" size="small" @click="inboundHandle(scope.row.procurementId)">再次入库</el-button>
  232. <el-button type="text" size="small" @click="exportHandle(scope.row.procurementId)">导出</el-button>
  233. </template>
  234. </el-table-column>
  235. </el-table>
  236. <el-pagination
  237. @size-change="sizeChangeHandle"
  238. @current-change="currentChangeHandle"
  239. :current-page="pageIndex"
  240. :page-sizes="[10, 20, 50, 100]"
  241. :page-size="pageSize"
  242. :total="totalPage"
  243. layout="total, sizes, prev, pager, next, jumper">
  244. </el-pagination>
  245. </template>
  246. <!-- 弹窗, 新增 / 修改 -->
  247. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" :options-type="optionsType" @refreshDataList="getDataList" @onChose="onChose"></add-or-update>
  248. <detail v-if="detailVisible" ref="detail" @onChose="onChose"/>
  249. <!-- 采购操作 -->
  250. <operate v-if="operateVisible" ref="operate" @onChose="onChose" @refreshDataList="getDataList"/>
  251. <!-- 入库 -->
  252. <inbound v-if="inboundVisible" ref="inbound" @onChose="onChose" @refreshDataList="getDataList"/>
  253. <notice-change-setting v-if="noticeChangeAttachVisible" ref="noticeChangeSetting" @onChose="onChose"/>
  254. <amount-mask-setting v-if="amountMaskSettingVisible" ref="amountMaskSetting" @onChose="onChose"/>
  255. <!-- <change-form v-if="changeFormVisible" ref="changeForm" @refreshDataList="getDataList" @onChose="onChose"/>-->
  256. </div>
  257. </template>
  258. <script>
  259. import AddOrUpdate from './purchase-add-or-update'
  260. import Detail from './purchase-detail'
  261. import Operate from './purchase-operate'
  262. import Inbound from '../warehouse/stock-order-inbound'
  263. import { getDictList } from '@/api/dict'
  264. import { getPurchaseList, revokePurchase } from '@/api/sale'
  265. import NoticeChangeSetting from './purchase-notice-change-setting'
  266. import AmountMaskSetting from './purchase-amount-mask-setting'
  267. import Vue from 'vue'
  268. export default {
  269. name: 'purchase',
  270. components: {
  271. AddOrUpdate, Detail, Operate, Inbound, NoticeChangeSetting, AmountMaskSetting
  272. },
  273. data () {
  274. return {
  275. addOrUpdateVisible: false,
  276. detailVisible: false,
  277. operateVisible: false,
  278. inboundVisible: false,
  279. noticeChangeAttachVisible: false,
  280. amountMaskSettingVisible: false,
  281. dataForm: {},
  282. userId: 0,
  283. dataList: [],
  284. pageIndex: 1,
  285. pageSize: 10,
  286. totalPage: 0,
  287. dataListLoading: false,
  288. dataListSelections: [],
  289. optionsType: [],
  290. // 审批状态:0 待提交 1 待审批 2 审批中 3 审批完成 4 审批不通过
  291. optionsState: [],
  292. // 采购状态:1 待采购 2 采购中 3 已入库 4 入库中 5 入库异常
  293. optionsPurchaseState: [
  294. {code: null, value: '全部'},
  295. {code: '1', value: '待采购'},
  296. {code: '2', value: '采购中'},
  297. {code: '3', value: '已入库'},
  298. {code: '4', value: '入库中'},
  299. {code: '5', value: '入库异常'}
  300. ],
  301. batchIncomeBtnDisabled: false,
  302. batchBuyBtnDisabled: false,
  303. selectedRows: []
  304. }
  305. },
  306. created () {
  307. this.optionsState = this.$store.state.common.approveStates
  308. this.userId = this.$store.state.user.id
  309. this.getTypeList()
  310. this.getDataList()
  311. },
  312. methods: {
  313. onChose () {
  314. this.addOrUpdateVisible = false
  315. this.detailVisible = false
  316. this.operateVisible = false
  317. this.inboundVisible = false
  318. this.noticeChangeAttachVisible = false
  319. this.amountMaskSettingVisible = false
  320. this.batchIncomeBtnDisabled = false
  321. this.batchBuyBtnDisabled = false
  322. this.selectedRows = []
  323. },
  324. // 获取采购类别字典
  325. getTypeList () {
  326. getDictList({type: 'purchase_type'}).then(({data}) => {
  327. if (data) {
  328. this.optionsType = data
  329. }
  330. })
  331. },
  332. // 查询
  333. search () {
  334. this.pageIndex = 1
  335. this.getDataList()
  336. },
  337. // 获取数据列表
  338. getDataList () {
  339. this.selectedRows = []
  340. this.dataListLoading = true
  341. this.addOrUpdateVisible = false
  342. let params = {
  343. 'current': this.pageIndex,
  344. 'size': this.pageSize,
  345. 'materialName': this.dataForm.materialName ? this.dataForm.materialName : null,
  346. 'purchaseState': this.dataForm.purchaseState ? this.dataForm.purchaseState : null,
  347. 'purchaseType': this.dataForm.purchaseType ? this.dataForm.purchaseType : null,
  348. 'beginTime': this.dataForm.date ? this.dataForm.date[0] : null,
  349. 'endTime': this.dataForm.date ? this.dataForm.date[1] : null
  350. }
  351. getPurchaseList(params).then(({data}) => {
  352. if (data && data.code === '200') {
  353. this.dataList = data.data.records
  354. this.totalPage = Number(data.data.total)
  355. } else {
  356. this.dataList = []
  357. this.totalPage = 0
  358. }
  359. this.dataListLoading = false
  360. })
  361. },
  362. revokeHandle (id) {
  363. if (!id) return
  364. let data = {id: id}
  365. this.$confirm(`确定撤回?`, '提示', {
  366. confirmButtonText: '确定',
  367. cancelButtonText: '取消',
  368. type: 'warning'
  369. }).then(() => {
  370. revokePurchase(data).then(({data}) => {
  371. if (data && data.code === '200') {
  372. this.$message({
  373. message: '操作成功',
  374. type: 'success',
  375. duration: 1500,
  376. onClose: () => {
  377. this.getDataList()
  378. }
  379. })
  380. } else {
  381. this.$message.error(data.msg)
  382. }
  383. })
  384. }).catch(() => {})
  385. },
  386. // 每页数
  387. sizeChangeHandle (val) {
  388. this.pageSize = val
  389. this.pageIndex = 1
  390. this.getDataList()
  391. },
  392. // 当前页
  393. currentChangeHandle (val) {
  394. this.pageIndex = val
  395. this.getDataList()
  396. },
  397. // 多选
  398. selectionChangeHandle (val) {
  399. this.dataListSelections = val
  400. },
  401. // 新增 / 修改
  402. addOrUpdateHandle (id) {
  403. this.addOrUpdateVisible = true
  404. this.$nextTick(() => {
  405. this.$refs.addOrUpdate.init(id)
  406. })
  407. },
  408. // 转换属性“类别”
  409. formatType (row) {
  410. if (this.optionsType && row.purchaseType) {
  411. const item1 = this.optionsType.find((item) => item.code === row.purchaseType.toString())
  412. return item1 ? item1.value : ''
  413. }
  414. },
  415. // 转换属性“审批状态”
  416. formatState (row) {
  417. if (!row.approvalState) return ''
  418. const item1 = this.optionsState.find((item) => item.code === row.approvalState.toString())
  419. return item1 ? item1.value : ''
  420. },
  421. // 转换属性“采购状态”
  422. formatPurchaseState (row) {
  423. if (!row.purchaseState) return ''
  424. const item1 = this.optionsPurchaseState.find((item) => item.code === row.purchaseState.toString())
  425. return item1 ? item1.value : ''
  426. },
  427. // 详情
  428. detailHandle (id) {
  429. this.detailVisible = true
  430. this.$nextTick(() => {
  431. this.$refs.detail.init(id)
  432. })
  433. },
  434. // 采购操作
  435. operateHandle (row) {
  436. this.operateVisible = true
  437. this.$nextTick(() => {
  438. this.$refs.operate.init(row)
  439. })
  440. },
  441. // 入库
  442. inboundHandle (row) {
  443. if (!row) return
  444. let dataForm = {
  445. ...row,
  446. buttonType: '1',
  447. sourceCategory: '1', // 入库依据类别
  448. // materialTypeId: row.purchaseType, // 类别
  449. source: row.supplierName, // 来源对应供应商
  450. tableId: row.purchaseDetailId,
  451. specifications: row.specification
  452. }
  453. this.inboundVisible = true
  454. this.$nextTick(() => {
  455. this.$refs.inbound.init(0, false, dataForm)
  456. })
  457. },
  458. // 变更通知人设置
  459. setNoticeChangeHandel () {
  460. this.noticeChangeAttachVisible = true
  461. this.$nextTick(() => {
  462. this.$refs.noticeChangeSetting.init()
  463. })
  464. },
  465. // 采购金额屏蔽设置
  466. setAmountMaskHandel () {
  467. this.amountMaskSettingVisible = true
  468. this.$nextTick(() => {
  469. this.$refs.amountMaskSetting.init()
  470. })
  471. },
  472. exportHandle (procurementId) {
  473. if (!procurementId) {
  474. this.$message.error('参数不正确!')
  475. }
  476. location.href = this.$http.adornUrl(`/biz-service/purchaseDetail/exportExcel2/${procurementId}?_token=${Vue.cookie.get('token')}`)
  477. },
  478. // 监听批量选择的行
  479. handleSelectionChange (rows) {
  480. this.selectedRows = rows
  481. // 控制批量操作按钮
  482. this.batchIncomeBtnDisabled = false
  483. this.batchBuyBtnDisabled = false
  484. for (let index = 0; index < this.selectedRows.length; index++) {
  485. let item = this.selectedRows[index]
  486. if (Number(item.approvalState) === 3 && (Number(item.purchaseState) === 2 || Number(item.purchaseState) === 5)) {
  487. } else {
  488. this.batchIncomeBtnDisabled = true
  489. }
  490. if (Number(item.approvalState) === 3 && Number(item.purchaseState) === 1) {
  491. } else {
  492. this.batchBuyBtnDisabled = true
  493. }
  494. }
  495. },
  496. // 批量采购
  497. batchBuyHandel () {
  498. if (this.selectedRows.length === 0) {
  499. this.$message.error('请先勾选数据')
  500. return
  501. }
  502. this.operateVisible = true
  503. this.$nextTick(() => {
  504. this.$refs.operate.init(this.selectedRows)
  505. })
  506. },
  507. // 批量入库
  508. batchIncomeHandel () {
  509. if (this.selectedRows.length === 0) {
  510. this.$message.error('请先勾选数据')
  511. return
  512. }
  513. let list = []
  514. for (let index = 0; index < this.selectedRows.length; index++) {
  515. let item = this.selectedRows[index]
  516. let dataForm = {
  517. ...item,
  518. buttonType: '1',
  519. sourceCategory: '1', // 入库依据类别
  520. source: item.supplierName, // 来源对应供应商
  521. tableId: item.purchaseDetailId,
  522. specifications: item.specification
  523. }
  524. list.push(dataForm)
  525. }
  526. this.inboundVisible = true
  527. this.$nextTick(() => {
  528. this.$refs.inbound.init(0, false, list)
  529. })
  530. }
  531. }
  532. }
  533. </script>
  534. <style scoped>
  535. </style>