stock.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <!-- 库存管理 -->
  2. <template>
  3. <div class="stock">
  4. <template v-if="!detailVisible && !addOrUpdateVisible && !noticeChangeAttachVisible">
  5. <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
  6. <el-form-item label="名称">
  7. <el-input v-model="dataForm.materialName" placeholder="请输入名称" clearable/>
  8. </el-form-item>
  9. <el-form-item label="类别">
  10. <el-cascader
  11. v-model="dataForm.materialTypeId"
  12. placeholder="请输入"
  13. :options="optionsCate"
  14. :props="{ expandTrigger: 'hover' }">
  15. </el-cascader>
  16. </el-form-item>
  17. <el-form-item>
  18. <el-button @click="getDataList()">查询</el-button>
  19. <!-- <el-button v-if="isAuth('wh:stockmanagement:exported')" type="primary" @click="exportExcel()">导出Excel</el-button>-->
  20. <el-button v-if="isAuth('wh:stockmanagement:noteChangeConfig')" type="primary" @click="setNoticeChangeHandel()">库存更改通知设置</el-button>
  21. </el-form-item>
  22. </el-form>
  23. <el-table
  24. :data="dataList"
  25. border
  26. v-loading="dataListLoading"
  27. @selection-change="selectionChangeHandle"
  28. style="width: 100%;">
  29. <el-table-column
  30. type="selection"
  31. header-align="center"
  32. align="center"
  33. width="50">
  34. </el-table-column>
  35. <el-table-column
  36. label="序号"
  37. type="index"
  38. width="50"
  39. align="center">
  40. </el-table-column>
  41. <el-table-column
  42. prop="materialCode"
  43. header-align="center"
  44. align="center"
  45. min-width="180"
  46. :show-tooltip-when-overflow="true"
  47. label="编码">
  48. </el-table-column>
  49. <el-table-column
  50. prop="categoryName"
  51. header-align="center"
  52. align="center"
  53. label="类别">
  54. </el-table-column>
  55. <el-table-column
  56. prop="materialName"
  57. header-align="center"
  58. align="center"
  59. min-width="180"
  60. :show-overflow-tooltip="true"
  61. label="名称">
  62. </el-table-column>
  63. <el-table-column
  64. prop="specifications"
  65. header-align="center"
  66. align="center"
  67. width="140"
  68. :show-overflow-tooltip="true"
  69. label="规格">
  70. </el-table-column>
  71. <el-table-column
  72. prop="isInventory"
  73. header-align="center"
  74. align="center"
  75. :formatter="formatState"
  76. label="状态">
  77. </el-table-column>
  78. <el-table-column
  79. prop="lockCnt"
  80. header-align="center"
  81. align="center"
  82. label="锁库数量">
  83. </el-table-column>
  84. <el-table-column
  85. prop="unitName"
  86. header-align="center"
  87. align="center"
  88. label="单位">
  89. </el-table-column>
  90. <el-table-column
  91. prop="cnt"
  92. header-align="center"
  93. align="center"
  94. label="库存">
  95. </el-table-column>
  96. <el-table-column
  97. prop="safeQuantity"
  98. header-align="center"
  99. align="center"
  100. label="安全库存">
  101. </el-table-column>
  102. <el-table-column
  103. prop="amount"
  104. header-align="center"
  105. align="center"
  106. label="金额">
  107. </el-table-column>
  108. <el-table-column
  109. prop="shelveName"
  110. header-align="center"
  111. align="center"
  112. width="140"
  113. :show-overflow-tooltip="true"
  114. label="存放货架">
  115. </el-table-column>
  116. <el-table-column
  117. prop="notes"
  118. header-align="center"
  119. align="center"
  120. width="160"
  121. :show-overflow-tooltip="true"
  122. label="备注">
  123. </el-table-column>
  124. <el-table-column
  125. fixed="right"
  126. header-align="center"
  127. align="center"
  128. width="150"
  129. label="操作">
  130. <template slot-scope="scope">
  131. <el-button v-if="isAuth('wh:stockmanagement:info')" type="text" size="small" @click="details(scope.row.materialId)">查看</el-button>
  132. <el-button v-if="isAuth('wh:stockmanagement:editor')" type="text" size="small" @click="addOrUpdateHandle(scope.row.materialId)">编辑</el-button>
  133. </template>
  134. </el-table-column>
  135. </el-table>
  136. <el-pagination
  137. @size-change="sizeChangeHandle"
  138. @current-change="currentChangeHandle"
  139. :current-page="pageIndex"
  140. :page-sizes="[10, 20, 50, 100]"
  141. :page-size="pageSize"
  142. :total="totalPage"
  143. layout="total, sizes, prev, pager, next, jumper">
  144. </el-pagination>
  145. </template>
  146. <stock-details v-if="detailVisible" ref="details" @onChose="onChose"/>
  147. <stock-add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList" @onChose="onChose"/>
  148. <notice-change-setting v-if="noticeChangeAttachVisible" ref="noticeChangeSetting" @onChose="onChose"/>
  149. </div>
  150. </template>
  151. <script>
  152. import StockDetails from './stock-details'
  153. import StockAddOrUpdate from './stock-add-or-update'
  154. import NoticeChangeSetting from './stock-notice-change-setting'
  155. import Vue from 'vue'
  156. export default {
  157. name: 'stock',
  158. components: {
  159. StockAddOrUpdate,
  160. StockDetails,
  161. NoticeChangeSetting
  162. },
  163. data () {
  164. return {
  165. dataForm: {
  166. materialName: ''
  167. },
  168. dataList: [],
  169. pageIndex: 1,
  170. pageSize: 10,
  171. totalPage: 0,
  172. dataListLoading: false,
  173. dataListSelections: [],
  174. detailVisible: false,
  175. addOrUpdateVisible: false,
  176. noticeChangeAttachVisible: false,
  177. optionsCate: [] // 类别
  178. }
  179. },
  180. activated () {
  181. this.getCate()
  182. this.getDataList()
  183. },
  184. methods: {
  185. onChose () {
  186. this.addOrUpdateVisible = false
  187. this.detailVisible = false
  188. this.noticeChangeAttachVisible = false
  189. },
  190. // 获取类别
  191. getCate () {
  192. this.$http({
  193. url: this.$http.adornUrl('/biz-service/stock-mg-ctl/listCategory'),
  194. method: 'get'
  195. }).then(({data}) => {
  196. if (data && data.code === '200') {
  197. this.optionsCate = data.data
  198. }
  199. })
  200. },
  201. // 获取数据列表
  202. getDataList () {
  203. this.dataListLoading = true
  204. this.$http({
  205. url: this.$http.adornUrl('/biz-service/stock-mg-ctl/list'),
  206. method: 'get',
  207. params: this.$http.adornParams({
  208. 'current': this.pageIndex,
  209. 'size': this.pageSize,
  210. 'materialName': this.dataForm.materialName,
  211. 'materialTypeId': this.dataForm.materialTypeId ? this.dataForm.materialTypeId[0] : ''
  212. })
  213. }).then(({data}) => {
  214. if (data && data.code === '200') {
  215. this.dataList = data.data.records
  216. this.totalPage = Number(data.data.total)
  217. } else {
  218. this.dataList = []
  219. this.totalPage = 0
  220. }
  221. this.dataListLoading = false
  222. })
  223. },
  224. exportExcel () {
  225. let url = this.$http.adornUrl('/biz-service/stock-mg-ctl/exportedExcel')
  226. this.$http({
  227. url: url,
  228. method: 'get',
  229. params: this.$http.adornParams({
  230. 'materialName': this.dataForm.materialName
  231. })
  232. }).then(({data}) => {
  233. if (data && data.code && data.code !== '200') {
  234. this.$message.error(data.msg || '系统错误,请联系管理员')
  235. } else {
  236. window.open(url + '?_token=' + Vue.cookie.get('token') + '&materialName=' + this.dataForm.materialName, '_blank')
  237. }
  238. })
  239. },
  240. // 每页数
  241. sizeChangeHandle (val) {
  242. this.pageSize = val
  243. this.pageIndex = 1
  244. this.getDataList()
  245. },
  246. // 当前页
  247. currentChangeHandle (val) {
  248. this.pageIndex = val
  249. this.getDataList()
  250. },
  251. // 多选
  252. selectionChangeHandle (val) {
  253. this.dataListSelections = val
  254. },
  255. details (id) {
  256. this.detailVisible = true
  257. this.$nextTick(() => {
  258. this.$refs.details.init(id)
  259. })
  260. },
  261. // 新增、修改
  262. addOrUpdateHandle (id) {
  263. this.addOrUpdateVisible = true
  264. this.$nextTick(() => {
  265. this.$refs.addOrUpdate.init(id)
  266. })
  267. },
  268. // 转换属性“状态”
  269. formatState (row) {
  270. if (row.isInventory && Number(row.isInventory) === 1 && row.lockCnt && Number(row.lockCnt) > 0) {
  271. return '盘点中'
  272. } else if (row.isInventory && Number(row.isInventory) === 1) {
  273. return '盘点中'
  274. } else if (row.lockCnt && Number(row.lockCnt) > 0) {
  275. return '锁定中'
  276. } else {
  277. return '正常'
  278. }
  279. },
  280. // 变更通知人设置
  281. setNoticeChangeHandel () {
  282. this.noticeChangeAttachVisible = true
  283. this.$nextTick(() => {
  284. this.$refs.noticeChangeSetting.init()
  285. })
  286. }
  287. }
  288. }
  289. </script>
  290. <style scoped>
  291. </style>