purchase.vue 16 KB

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