purchase.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <!-- 采购列表 -->
  2. <template>
  3. <div class="purchase">
  4. <template v-if="!addOrUpdateVisible && !detailVisible && !operateVisible && !inboundVisible && !noticeChangeAttachVisible">
  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-form-item>
  50. </el-form>
  51. <el-table
  52. :data="dataList"
  53. border
  54. v-loading="dataListLoading"
  55. style="width: 100%;">
  56. <el-table-column
  57. label="序号"
  58. type="index"
  59. width="50"
  60. align="center">
  61. </el-table-column>
  62. <el-table-column
  63. prop="procurementCode"
  64. header-align="center"
  65. align="center"
  66. min-width="180"
  67. :show-tooltip-when-overflow="true"
  68. label="采购编码">
  69. </el-table-column>
  70. <el-table-column
  71. prop="materialName"
  72. header-align="center"
  73. align="center"
  74. width="160"
  75. :show-tooltip-when-overflow="true"
  76. label="物品名称">
  77. </el-table-column>
  78. <el-table-column
  79. prop="purchaseType"
  80. header-align="center"
  81. align="center"
  82. :formatter="formatType"
  83. label="采购类别">
  84. </el-table-column>
  85. <el-table-column
  86. prop="specification"
  87. header-align="center"
  88. align="center"
  89. width="120"
  90. :show-tooltip-when-overflow="true"
  91. label="型号及规格">
  92. </el-table-column>
  93. <el-table-column
  94. prop="cnt"
  95. header-align="center"
  96. align="center"
  97. label="数量">
  98. </el-table-column>
  99. <el-table-column
  100. prop="qualifiedCnt"
  101. header-align="center"
  102. align="center"
  103. label="合格数量">
  104. </el-table-column>
  105. <el-table-column
  106. prop="unitName"
  107. header-align="center"
  108. align="center"
  109. min-width="100"
  110. :show-tooltip-when-overflow="true"
  111. label="单位">
  112. </el-table-column>
  113. <el-table-column
  114. prop="deadline"
  115. header-align="center"
  116. align="center"
  117. min-width="160"
  118. :show-tooltip-when-overflow="true"
  119. label="采购期限">
  120. </el-table-column>
  121. <el-table-column
  122. prop="arrivedTime"
  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="batchNumber"
  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="procurementBasis"
  139. header-align="center"
  140. align="center"
  141. min-width="120"
  142. :show-tooltip-when-overflow="true"
  143. label="采购依据">
  144. <template slot-scope="scope">
  145. <span>{{scope.row.procurementBasis?(Number(scope.row.procurementBasis) === 1?'合同采购':'计划采购'):''}}</span>
  146. </template>
  147. </el-table-column>
  148. <el-table-column
  149. prop="supplierName"
  150. header-align="center"
  151. align="center"
  152. min-width="160"
  153. :show-tooltip-when-overflow="true"
  154. label="供应商">
  155. </el-table-column>
  156. <el-table-column
  157. prop="applyTime"
  158. header-align="center"
  159. align="center"
  160. min-width="160"
  161. :show-tooltip-when-overflow="true"
  162. label="申请时间">
  163. </el-table-column>
  164. <el-table-column
  165. prop="applier"
  166. header-align="center"
  167. align="center"
  168. min-width="100"
  169. :show-tooltip-when-overflow="true"
  170. label="申请人">
  171. </el-table-column>
  172. <el-table-column
  173. prop="orgName"
  174. header-align="center"
  175. align="center"
  176. min-width="120"
  177. :show-tooltip-when-overflow="true"
  178. label="申请部门">
  179. </el-table-column>
  180. <el-table-column
  181. prop="approvalState"
  182. header-align="center"
  183. align="center"
  184. :formatter="formatState"
  185. label="审批状态">
  186. </el-table-column>
  187. <el-table-column
  188. prop="purchaseState"
  189. header-align="center"
  190. align="center"
  191. :formatter="formatPurchaseState"
  192. label="采购状态">
  193. </el-table-column>
  194. <el-table-column
  195. prop="notes"
  196. header-align="center"
  197. align="center"
  198. min-width="180"
  199. :show-overflow-tooltip="true"
  200. label="备注">
  201. </el-table-column>
  202. <el-table-column
  203. fixed="right"
  204. header-align="center"
  205. align="center"
  206. width="150"
  207. label="操作">
  208. <template slot-scope="scope">
  209. <el-button v-if="isAuth('purchase:detail:info')" type="text" size="small" @click="detailHandle(scope.row.procurementId)">查看</el-button>
  210. <el-button v-if="isAuth('purchase:detail:update') && (Number(scope.row.approvalState) === 1)" type="text" size="small" @click="addOrUpdateHandle(scope.row.procurementId)">编辑</el-button>
  211. <el-button v-if="isAuth('purchase:detail:updatePurchaseDetail') && (Number(scope.row.purchaseState) === 1)" type="text" size="small" @click="operateHandle(scope.row)">采购</el-button>
  212. <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>
  213. <el-button v-if="isAuth('purchase:detail:infoPutInAgain') && (Number(scope.row.purchaseState) === 5)" type="text" size="small" @click="inboundHandle(scope.row.procurementId)">再次入库</el-button>
  214. </template>
  215. </el-table-column>
  216. </el-table>
  217. <el-pagination
  218. @size-change="sizeChangeHandle"
  219. @current-change="currentChangeHandle"
  220. :current-page="pageIndex"
  221. :page-sizes="[10, 20, 50, 100]"
  222. :page-size="pageSize"
  223. :total="totalPage"
  224. layout="total, sizes, prev, pager, next, jumper">
  225. </el-pagination>
  226. </template>
  227. <!-- 弹窗, 新增 / 修改 -->
  228. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList" @onChose="onChose"></add-or-update>
  229. <detail v-if="detailVisible" ref="detail" @onChose="onChose"/>
  230. <!-- 采购操作 -->
  231. <operate v-if="operateVisible" ref="operate" @onChose="onChose" @refreshDataList="getDataList"/>
  232. <!-- 入库 -->
  233. <inbound v-if="inboundVisible" ref="inbound" @onChose="onChose" @refreshDataList="getDataList"/>
  234. <notice-change-setting v-if="noticeChangeAttachVisible" ref="noticeChangeSetting" @onChose="onChose"/>
  235. <!-- <change-form v-if="changeFormVisible" ref="changeForm" @refreshDataList="getDataList" @onChose="onChose"/>-->
  236. </div>
  237. </template>
  238. <script>
  239. import AddOrUpdate from './purchase-add-or-update'
  240. import Detail from './purchase-detail'
  241. import Operate from './purchase-operate'
  242. import Inbound from '../warehouse/stock-order-inbound'
  243. import { getDictList } from '@/api/dict'
  244. import { getPurchaseList, revokePurchase } from '@/api/sale'
  245. import NoticeChangeSetting from './purchase-notice-change-setting'
  246. export default {
  247. name: 'purchase',
  248. components: {
  249. AddOrUpdate, Detail, Operate, Inbound, NoticeChangeSetting
  250. },
  251. data () {
  252. return {
  253. addOrUpdateVisible: false,
  254. detailVisible: false,
  255. operateVisible: false,
  256. inboundVisible: false,
  257. noticeChangeAttachVisible: false,
  258. dataForm: {},
  259. dataList: [],
  260. pageIndex: 1,
  261. pageSize: 10,
  262. totalPage: 0,
  263. dataListLoading: false,
  264. dataListSelections: [],
  265. optionsType: [],
  266. // 审批状态:0 待提交 1 待审批 2 审批中 3 审批完成 4 审批不通过
  267. optionsState: [],
  268. // 采购状态:1 待采购 2 采购中 3 已入库 4 入库中 5 入库异常
  269. optionsPurchaseState: [
  270. {code: null, value: '全部'},
  271. {code: '1', value: '待采购'},
  272. {code: '2', value: '采购中'},
  273. {code: '3', value: '已入库'},
  274. {code: '4', value: '入库中'},
  275. {code: '5', value: '入库异常'}
  276. ]
  277. }
  278. },
  279. created () {
  280. this.optionsState = this.$store.state.common.approveStates
  281. this.getTypeList()
  282. this.getDataList()
  283. },
  284. methods: {
  285. onChose () {
  286. this.addOrUpdateVisible = false
  287. this.detailVisible = false
  288. this.operateVisible = false
  289. this.inboundVisible = false
  290. this.noticeChangeAttachVisible = false
  291. },
  292. // 获取采购类别字典
  293. getTypeList () {
  294. getDictList({type: 'purchase_type'}).then(({data}) => {
  295. if (data) {
  296. this.optionsType = data
  297. }
  298. })
  299. },
  300. // 查询
  301. search () {
  302. this.pageIndex = 1
  303. this.getDataList()
  304. },
  305. // 获取数据列表
  306. getDataList () {
  307. this.dataListLoading = true
  308. this.addOrUpdateVisible = false
  309. let params = {
  310. 'current': this.pageIndex,
  311. 'size': this.pageSize,
  312. 'materialName': this.dataForm.materialName ? this.dataForm.materialName : null,
  313. 'purchaseState': this.dataForm.purchaseState ? this.dataForm.purchaseState : null,
  314. 'purchaseType': this.dataForm.purchaseType ? this.dataForm.purchaseType : null,
  315. 'beginTime': this.dataForm.date ? this.dataForm.date[0] : null,
  316. 'endTime': this.dataForm.date ? this.dataForm.date[1] : null
  317. }
  318. getPurchaseList(params).then(({data}) => {
  319. if (data && data.code === '200') {
  320. this.dataList = data.data.records
  321. this.totalPage = Number(data.data.total)
  322. } else {
  323. this.dataList = []
  324. this.totalPage = 0
  325. }
  326. this.dataListLoading = false
  327. })
  328. },
  329. revokeHandle (id) {
  330. if (!id) return
  331. let data = {id: id}
  332. this.$confirm(`确定撤回?`, '提示', {
  333. confirmButtonText: '确定',
  334. cancelButtonText: '取消',
  335. type: 'warning'
  336. }).then(() => {
  337. revokePurchase(data).then(({data}) => {
  338. if (data && data.code === '200') {
  339. this.$message({
  340. message: '操作成功',
  341. type: 'success',
  342. duration: 1500,
  343. onClose: () => {
  344. this.getDataList()
  345. }
  346. })
  347. } else {
  348. this.$message.error(data.msg)
  349. }
  350. })
  351. }).catch(() => {})
  352. },
  353. // 每页数
  354. sizeChangeHandle (val) {
  355. this.pageSize = val
  356. this.pageIndex = 1
  357. this.getDataList()
  358. },
  359. // 当前页
  360. currentChangeHandle (val) {
  361. this.pageIndex = val
  362. this.getDataList()
  363. },
  364. // 多选
  365. selectionChangeHandle (val) {
  366. this.dataListSelections = val
  367. },
  368. // 新增 / 修改
  369. addOrUpdateHandle (id) {
  370. this.addOrUpdateVisible = true
  371. this.$nextTick(() => {
  372. this.$refs.addOrUpdate.init(id, this.optionsType)
  373. })
  374. },
  375. // 转换属性“类别”
  376. formatType (row) {
  377. if (this.optionsType && row.purchaseType) {
  378. const item1 = this.optionsType.find((item) => item.code === row.purchaseType.toString())
  379. return item1 ? item1.value : ''
  380. }
  381. },
  382. // 转换属性“审批状态”
  383. formatState (row) {
  384. if (!row.approvalState) return ''
  385. const item1 = this.optionsState.find((item) => item.code === row.approvalState.toString())
  386. return item1 ? item1.value : ''
  387. },
  388. // 转换属性“采购状态”
  389. formatPurchaseState (row) {
  390. if (!row.purchaseState) return ''
  391. const item1 = this.optionsPurchaseState.find((item) => item.code === row.purchaseState.toString())
  392. return item1 ? item1.value : ''
  393. },
  394. // 详情
  395. detailHandle (id) {
  396. this.detailVisible = true
  397. this.$nextTick(() => {
  398. this.$refs.detail.init(id)
  399. })
  400. },
  401. // 采购操作
  402. operateHandle (row) {
  403. this.operateVisible = true
  404. this.$nextTick(() => {
  405. this.$refs.operate.init(row)
  406. })
  407. },
  408. // 入库
  409. inboundHandle (row) {
  410. if (!row) return
  411. let dataForm = {
  412. ...row,
  413. buttonType: '1',
  414. sourceCategory: '1', // 入库依据类别
  415. // materialTypeId: row.purchaseType, // 类别
  416. source: row.supplierName, // 来源对应供应商
  417. tableId: row.purchaseDetailId,
  418. specifications: row.specification
  419. }
  420. this.inboundVisible = true
  421. this.$nextTick(() => {
  422. this.$refs.inbound.init(0, false, dataForm)
  423. })
  424. },
  425. // 变更通知人设置
  426. setNoticeChangeHandel () {
  427. this.noticeChangeAttachVisible = true
  428. this.$nextTick(() => {
  429. this.$refs.noticeChangeSetting.init()
  430. })
  431. }
  432. }
  433. }
  434. </script>
  435. <style scoped>
  436. </style>