stock-order.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <!-- 出入库管理 -->
  2. <template>
  3. <div class="stock-order">
  4. <template v-if="!inboundVisible && !outboundVisible && !detailVisible">
  5. <el-form :inline="true" :model="dataForm" @keyup.enter.native="queryData()">
  6. <el-form-item label="出入库类型">
  7. <el-select
  8. v-model="dataForm.recordType"
  9. @change="recordTypeChanged"
  10. placeholder="请选择">
  11. <el-option
  12. v-for="item in recordTypeOptions"
  13. :key="item.value"
  14. :label="item.label"
  15. :value="item.value">
  16. </el-option>
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item label="编码">
  20. <el-input v-model="dataForm.recordCode" placeholder="请输入出入库编码" clearable/>
  21. </el-form-item>
  22. <el-form-item label="申请人姓名">
  23. <user-component v-model="dataForm.userId"/>
  24. </el-form-item>
  25. <el-form-item label="申请日期">
  26. <el-date-picker
  27. v-model="dataForm.date"
  28. value-format="yyyy-MM-dd"
  29. type="daterange"
  30. range-separator="至"
  31. start-placeholder="开始日期"
  32. end-placeholder="结束日期">
  33. </el-date-picker>
  34. </el-form-item>
  35. <el-form-item>
  36. <el-button @click="queryData()">查询</el-button>
  37. </el-form-item>
  38. <el-form-item>
  39. <el-button v-if="isAuth('wh:in:inbound')" type="primary" @click="inBound(0, false)">入库申请</el-button>
  40. <el-button v-if="isAuth('wh:on:outbound')" type="primary" @click="outBound()">出库申请</el-button>
  41. <!-- <el-button v-if="isAuth('wh:in-out-bound-ctl:outbound')" type="primary" @click="outBound()">模板出库</el-button>-->
  42. </el-form-item>
  43. </el-form>
  44. <el-table
  45. :data="dataList"
  46. border
  47. v-loading="dataListLoading"
  48. @selection-change="selectionChangeHandle"
  49. style="width: 100%;">
  50. <el-table-column
  51. type="selection"
  52. header-align="center"
  53. align="center"
  54. width="50">
  55. </el-table-column>
  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="recordCode"
  64. header-align="center"
  65. align="center"
  66. min-width="160"
  67. :show-tooltip-when-overflow="true"
  68. label="编码">
  69. </el-table-column>
  70. <el-table-column
  71. prop="recordType"
  72. header-align="center"
  73. align="center"
  74. :formatter="formatRecordType"
  75. width="100"
  76. label="申请单类别">
  77. </el-table-column>
  78. <el-table-column
  79. prop="state"
  80. header-align="center"
  81. align="center"
  82. :formatter="formatState"
  83. width="100"
  84. label="申请状态">
  85. </el-table-column>
  86. <el-table-column
  87. prop="approver"
  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="createTime"
  96. header-align="center"
  97. align="center"
  98. min-width="160"
  99. label="申请时间">
  100. </el-table-column>
  101. <el-table-column
  102. prop="recordTime"
  103. header-align="center"
  104. align="center"
  105. min-width="160"
  106. label="入库时间">
  107. </el-table-column>
  108. <el-table-column
  109. prop="applicant"
  110. header-align="center"
  111. align="center"
  112. min-width="140"
  113. :show-tooltip-when-overflow="true"
  114. label="申请人">
  115. </el-table-column>
  116. <el-table-column
  117. fixed="right"
  118. header-align="center"
  119. align="center"
  120. width="150"
  121. label="操作">
  122. <template slot-scope="scope">
  123. <el-button v-if="isAuth('wh:inon:info')" type="text" size="small" @click="detailHandle(scope.row.id)">查看</el-button>
  124. <el-button v-if="false" type="text" size="small" @click="exportItem(scope.row.id)">导出</el-button>
  125. <el-button v-if="isAuth('wh:in:editor') && (Number(scope.row.state) === 0 || Number(scope.row.state) === 4)" type="text" size="small" @click="editBound(scope.row.id)">编辑</el-button>
  126. <el-button v-if="isAuth('wh:in:revoke') && (Number(scope.row.state) === 1 || Number(scope.row.state) === 2)" type="text" size="small" @click="cancelItem(scope.row)">撤回</el-button>
  127. </template>
  128. </el-table-column>
  129. </el-table>
  130. <el-pagination
  131. @size-change="sizeChangeHandle"
  132. @current-change="currentChangeHandle"
  133. :current-page="pageIndex"
  134. :page-sizes="[10, 20, 50, 100]"
  135. :page-size="pageSize"
  136. :total="totalPage"
  137. layout="total, sizes, prev, pager, next, jumper">
  138. </el-pagination>
  139. </template>
  140. <!-- 入库-->
  141. <stock-order-inbound v-if="inboundVisible" ref="inbound" @refreshDataList="getDataList" @onChose="onChose"></stock-order-inbound>
  142. <stock-order-outbound v-if="outboundVisible" ref="outbound" @refreshDataList="getDataList" @onChose="onChose"></stock-order-outbound>
  143. <detail v-if="detailVisible" ref="details" @onChose="onChose"/>
  144. </div>
  145. </template>
  146. <script>
  147. import UserComponent from '../common/user-component'
  148. import StockOrderInbound from './stock-order-inbound'
  149. import StockOrderOutbound from './stock-order-outbound'
  150. import Detail from './stock-order-detail'
  151. import { revokeInOutBound } from '@/api/warehouse'
  152. export default {
  153. name: 'stock-order',
  154. components: {StockOrderInbound, UserComponent, StockOrderOutbound, Detail},
  155. created () {
  156. this.optionsState = this.$store.state.common.approveStates
  157. this.queryData()
  158. },
  159. data () {
  160. return {
  161. inboundVisible: false,
  162. outboundVisible: false,
  163. detailVisible: false,
  164. dataForm: {
  165. userId: '',
  166. date: '',
  167. recordType: '0'
  168. },
  169. optionsState: [],
  170. recordTypeOptions: [
  171. {
  172. value: null,
  173. label: '请选择'
  174. },
  175. {
  176. value: '0',
  177. label: '入库'
  178. },
  179. {
  180. value: '1',
  181. label: '出库'
  182. }
  183. ],
  184. dataList: [],
  185. pageIndex: 1,
  186. pageSize: 10,
  187. totalPage: 0,
  188. dataListLoading: false,
  189. dataListSelections: []
  190. }
  191. },
  192. methods: {
  193. onChose () {
  194. this.inboundVisible = false
  195. this.outboundVisible = false
  196. this.detailVisible = false
  197. },
  198. queryData () {
  199. this.pageIndex = 1
  200. this.getDataList()
  201. },
  202. // 获取数据列表
  203. getDataList () {
  204. this.dataListLoading = true
  205. this.$http({
  206. url: this.$http.adornUrl('/biz-service/in-out-bound-ctl/my-submit-inbound-apply'),
  207. method: 'get',
  208. params: this.$http.adornParams({
  209. 'current': this.pageIndex,
  210. 'size': this.pageSize,
  211. 'userId': this.dataForm.userId ? this.dataForm.userId : '',
  212. 'beginTime': this.dataForm.date ? this.dataForm.date[0] : null,
  213. 'endTime': this.dataForm.date ? this.dataForm.date[1] : null,
  214. 'recordType': this.dataForm.recordType,
  215. 'recordCode': this.dataForm.recordCode
  216. })
  217. }).then(({data}) => {
  218. if (data && data.code === '200') {
  219. this.dataList = data.data.records
  220. this.totalPage = Number(data.data.total)
  221. } else {
  222. this.dataList = []
  223. this.totalPage = 0
  224. }
  225. this.dataListLoading = false
  226. })
  227. },
  228. // 每页数
  229. sizeChangeHandle (val) {
  230. this.pageSize = val
  231. this.pageIndex = 1
  232. this.getDataList()
  233. },
  234. // 当前页
  235. currentChangeHandle (val) {
  236. this.pageIndex = val
  237. this.getDataList()
  238. },
  239. // 多选
  240. selectionChangeHandle (val) {
  241. this.dataListSelections = val
  242. },
  243. // 编辑
  244. editBound (id) {
  245. if (Number(this.dataForm.recordType) === 1) {
  246. // 出库
  247. this.outBound(id, false)
  248. } else {
  249. // 入库
  250. this.inBound(id, false)
  251. }
  252. },
  253. // 入库申请
  254. inBound (id, display) {
  255. this.inboundVisible = true
  256. this.$nextTick(() => {
  257. this.$refs.inbound.init(id, display)
  258. })
  259. },
  260. outBound (id) {
  261. this.outboundVisible = true
  262. this.$nextTick(() => {
  263. this.$refs.outbound.init(id)
  264. })
  265. },
  266. // 申请单类型
  267. formatRecordType (row) {
  268. if (!row.recordType) return ''
  269. if (row.recordType === '0') return '入库'
  270. if (row.recordType === '1') return '出库'
  271. return ''
  272. },
  273. // 转换属性“状态”
  274. formatState (row) {
  275. if (!row.state) return ''
  276. const item1 = this.optionsState.find((item) => item.code === row.state.toString())
  277. return item1 ? item1.value : ''
  278. },
  279. // 导出
  280. exportItem (id) {
  281. // todo
  282. this.$message.warning('功能暂未开放')
  283. },
  284. // 撤回
  285. async cancelItem (row) {
  286. if (row.state === '0') {
  287. this.$message.warning('不允许撤回,请先提交!')
  288. return
  289. }
  290. await revokeInOutBound({'id': row.id}).then(({data}) => {
  291. if (data && data.code === '200') {
  292. this.$message({
  293. message: '操作成功',
  294. type: 'success',
  295. duration: 1500,
  296. onClose: () => {
  297. this.getDataList()
  298. }
  299. })
  300. } else {
  301. this.$message.error(data.msg)
  302. }
  303. })
  304. },
  305. detailHandle (id) {
  306. this.detailVisible = true
  307. this.$nextTick(() => {
  308. this.$refs.details.init(id)
  309. })
  310. },
  311. recordTypeChanged () {
  312. this.getDataList()
  313. }
  314. }
  315. }
  316. </script>
  317. <style scoped>
  318. </style>