list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <a-card size="small" :bordered="false" class="inventoryQueryList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="产品编码">
  10. <a-input id="inventoryQueryList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="原厂编码">
  15. <a-input id="inventoryQueryList-productOrigCode" v-model.trim="queryParam.productOrigCode" allowClear placeholder="请输入原厂编码"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="5" :sm="24">
  19. <a-form-item label="产品名称">
  20. <a-input id="inventoryQueryList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  21. </a-form-item>
  22. </a-col>
  23. <template v-if="advanced">
  24. <a-col :md="6" :sm="24">
  25. <a-form-item label="产品品牌">
  26. <ProductBrand id="inventoryQueryList-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-model-item label="产品分类">
  31. <ProductType id="inventoryQueryList-productType" placeholder="请选择产品分类" @change="changeProductType" v-model="productType"></ProductType>
  32. </a-form-model-item>
  33. </a-col>
  34. <a-col :md="6" :sm="24">
  35. <a-form-item label="仓库">
  36. <warehouse
  37. isPermission
  38. v-model="queryParam.warehouseSn"
  39. id="inventoryQueryList-warehouseSn"
  40. placeholder="请选择仓库"
  41. />
  42. </a-form-item>
  43. </a-col>
  44. <a-col :md="4" :sm="24">
  45. <a-form-item label="库存情况">
  46. <a-checkbox v-model="queryParam.zeroQtyFlag" id="inventoryQueryList-zeroQtyFlag">只查看有库存</a-checkbox>
  47. </a-form-item>
  48. </a-col>
  49. </template>
  50. <a-col :md="7" :sm="24">
  51. <a-button type="primary" @click="$refs.table.refresh()" :disabled="disabled" id="inventoryQueryList-refresh">查询</a-button>
  52. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="inventoryQueryList-reset">重置</a-button>
  53. <a-button
  54. v-if="$hasPermissions('B_inventoryQuery_export')"
  55. type="primary"
  56. style="margin-left: 5px"
  57. class="button-warning"
  58. @click="openExcelModal=true"
  59. :disabled="disabled"
  60. :loading="exportLoading"
  61. id="inventoryQueryList-export">导出</a-button>
  62. <a @click="advanced=!advanced" style="margin-left: 5px">
  63. {{ advanced ? '收起' : '展开' }}
  64. <a-icon :type="advanced ? 'up' : 'down'"/>
  65. </a>
  66. </a-col>
  67. </a-row>
  68. </a-form>
  69. </div>
  70. <!-- 合计 -->
  71. <a-alert type="info" style="margin-bottom:10px">
  72. <div class="ftext" slot="message">
  73. 可用库存总数量:<strong>{{ (currentStock&&(currentStock.currentStockQty || currentStock.currentStockQty==0)) ? currentStock.currentStockQty : '--' }}个</strong>;
  74. <span v-if="$hasPermissions('M_inventoryQueryList_costPrice')">可用库存总成本:<strong>{{ (currentStock&&(currentStock.currentStockCost || currentStock.currentStockCost==0)) ? toThousands(currentStock.currentStockCost) : '--' }}</strong>。</span>
  75. </div>
  76. </a-alert>
  77. <!-- 列表 -->
  78. <s-table
  79. class="sTable fixPagination"
  80. ref="table"
  81. :style="{ height: tableHeight+84.5+'px' }"
  82. size="small"
  83. :rowKey="(record) => record.id"
  84. :columns="columns"
  85. :data="loadData"
  86. :scroll="{ y: tableHeight }"
  87. :defaultLoadData="false"
  88. bordered>
  89. <!-- 操作 -->
  90. <template slot="action" slot-scope="text, record">
  91. <a-button
  92. v-if="$hasPermissions('B_inventoryQuery_detail')"
  93. size="small"
  94. type="link"
  95. class="button-success"
  96. @click="goDetail(record)"
  97. id="inventoryQueryList-detail-btn">库存详情</a-button>
  98. <a-button
  99. v-if="$hasPermissions('B_inventoryQuery_rkDetail')"
  100. size="small"
  101. type="link"
  102. class="button-warning"
  103. @click="goWarehouseDetail(record)"
  104. id="inventoryQueryList-warehouseDetail-btn">出入库明细</a-button>
  105. <span v-if="!$hasPermissions('B_inventoryQuery_detail')&&!$hasPermissions('B_inventoryQuery_rkDetail')">--</span>
  106. </template>
  107. </s-table>
  108. </a-spin>
  109. <!-- 库存详情 -->
  110. <inventory-query-detail-modal v-drag :openModal="openModal" :itemId="itemId" @close="closeModal" />
  111. <!-- 导出Excel -->
  112. <export-excel-modal :openModal="openExcelModal" @ok="handleExcelOk" @close="openExcelModal=false" />
  113. </a-card>
  114. </template>
  115. <script>
  116. import { commonMixin } from '@/utils/mixin'
  117. import { STable, VSelect } from '@/components'
  118. import inventoryQueryDetailModal from './detailModal.vue'
  119. import exportExcelModal from './exportExcelModal.vue'
  120. import { hdExportExcel } from '@/libs/exportExcel'
  121. import ProductType from '../../common/productType.js'
  122. import ProductBrand from '@/views/common/productBrand.js'
  123. import warehouse from '@/views/common/chooseWarehouse.js'
  124. import { stockList, stockCount, stockExport } from '@/api/stock'
  125. export default {
  126. name: 'InventoryQueryList',
  127. mixins: [commonMixin],
  128. components: { STable, VSelect, inventoryQueryDetailModal, exportExcelModal, ProductType, ProductBrand, warehouse },
  129. data () {
  130. return {
  131. spinning: false,
  132. advanced: true, // 高级搜索 展开/关闭
  133. tableHeight: 0,
  134. queryParam: { // 查询条件
  135. productCode: '', // 产品编码
  136. productName: '', // 产品名称
  137. productOrigCode: '', // 原厂编码
  138. productBrandSn: undefined, // 产品品牌
  139. warehouseSn: undefined, // 仓库
  140. productTypeSn1: '', // 产品分类1
  141. productTypeSn2: '', // 产品分类2
  142. productTypeSn3: '', // 产品分类3
  143. zeroQtyFlag: false // 库存情况
  144. },
  145. productType: [],
  146. exportLoading: false, // 导出loading
  147. disabled: false, // 查询、重置按钮是否可操作
  148. zeroQtyData: [ // 库存情况
  149. { name: '库存数量为0', id: '1' },
  150. { name: '库存数量不为0', id: '0' }
  151. ],
  152. // 加载数据方法 必须为 Promise 对象
  153. loadData: parameter => {
  154. this.disabled = true
  155. this.spinning = true
  156. console.log(parameter)
  157. // 排序
  158. if (parameter.sortOrder&&parameter.sortField == 'currentStockQty') {
  159. parameter.sortField = 'qty'
  160. parameter.sortAlias = ''
  161. }
  162. if (parameter.sortOrder&&parameter.sortField == 'currentStockCost') {
  163. parameter.sortField = 'currentStockCost'
  164. parameter.sortAlias = 'stock'
  165. }
  166. if(!parameter.sortOrder){
  167. parameter.sortField = ''
  168. parameter.sortAlias = ''
  169. }
  170. const params = Object.assign(parameter, this.queryParam)
  171. if (params.zeroQtyFlag) {
  172. params.zeroQtyFlag = '0'
  173. } else {
  174. params.zeroQtyFlag = ''
  175. }
  176. return stockList(params).then(res => {
  177. let data
  178. if (res.status == 200) {
  179. data = res.data
  180. const no = (data.pageNo - 1) * data.pageSize
  181. for (var i = 0; i < data.list.length; i++) {
  182. data.list[i].no = no + i + 1
  183. }
  184. this.disabled = false
  185. this.spinning = false
  186. // 总计
  187. this.getTotal(params)
  188. }
  189. return data
  190. })
  191. },
  192. openModal: false, // 查看库存详情 弹框
  193. itemId: '', // 当前库存记录id
  194. currentStock: null,
  195. openExcelModal: false
  196. }
  197. },
  198. computed: {
  199. columns () {
  200. const _this = this
  201. const arr = [
  202. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  203. { title: '产品编码', dataIndex: 'productCode', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  204. { title: '货位编号', dataIndex: 'stackPlaceEntity.stackPlaceCode', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  205. { title: '产品名称', dataIndex: 'productName', width: '20%', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  206. { title: '仓库', dataIndex: 'warehouseName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  207. { title: '最后入库时间', dataIndex: 'lastStockTime', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  208. { title: '单位', dataIndex: 'productUnit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  209. { title: '产品品牌', dataIndex: 'productBrandName', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  210. { title: '可用库存数量', dataIndex: 'currentStockQty', width: '8%', align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  211. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  212. ]
  213. if (this.$hasPermissions('M_inventoryQueryList_costPrice')) { // 成本价权限
  214. arr.splice(9, 0, { title: '可用库存成本', dataIndex: 'currentStockCost', width: '8%', align: 'right', sorter: true, customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  215. }
  216. return arr
  217. }
  218. },
  219. methods: {
  220. // 重置
  221. resetSearchForm () {
  222. this.queryParam.productBrandSn = undefined
  223. this.queryParam.productTypeSn1 = ''
  224. this.queryParam.productTypeSn2 = ''
  225. this.queryParam.productTypeSn3 = ''
  226. this.queryParam.productCode = ''
  227. this.queryParam.productOrigCode = ''
  228. this.queryParam.productName = ''
  229. this.queryParam.warehouseSn = undefined
  230. this.queryParam.zeroQtyFlag = false
  231. this.productType = []
  232. this.$refs.table.refresh(true)
  233. },
  234. // 合计
  235. getTotal (param) {
  236. stockCount(param).then(res => {
  237. if (res.status == 200 && res.data) {
  238. this.currentStock = res.data
  239. } else {
  240. this.currentStock = null
  241. }
  242. })
  243. },
  244. // 库存详情
  245. goDetail (row) {
  246. this.$store.state.app.curActionPermission = 'B_inventoryQuery_detail'
  247. this.itemId = row.stockSn
  248. this.openModal = true
  249. },
  250. // 关闭弹框
  251. closeModal () {
  252. this.itemId = ''
  253. this.openModal = false
  254. },
  255. // 出入库明细
  256. goWarehouseDetail (row) {
  257. this.$router.push({ path: `/inventoryManagement/inventoryQuery/warehouseDetail/${row.productSn}/${row.warehouseSn}` })
  258. },
  259. // 导出Excel
  260. handleExcelOk (exportType) {
  261. const _this = this
  262. const params = JSON.parse(JSON.stringify(this.queryParam))
  263. if (params.zeroQtyFlag) {
  264. params.zeroQtyFlag = '0'
  265. } else {
  266. params.zeroQtyFlag = ''
  267. }
  268. params.exportType = exportType
  269. this.exportLoading = true
  270. this.spinning = true
  271. hdExportExcel(stockExport, params, '库存查询', function () {
  272. _this.exportLoading = false
  273. _this.spinning = false
  274. _this.$store.state.app.curActionPermission = ''
  275. })
  276. },
  277. // 产品分类 change
  278. changeProductType (val, opt) {
  279. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  280. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  281. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  282. },
  283. pageInit () {
  284. const _this = this
  285. this.$nextTick(() => { // 页面渲染完成后的回调
  286. _this.setTableH()
  287. })
  288. },
  289. setTableH () {
  290. const tableSearchH = this.$refs.tableSearch.offsetHeight
  291. this.tableHeight = window.innerHeight - tableSearchH - 240
  292. }
  293. },
  294. watch: {
  295. advanced (newValue, oldValue) {
  296. const _this = this
  297. this.$nextTick(() => { // 页面渲染完成后的回调
  298. _this.setTableH()
  299. })
  300. },
  301. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  302. this.setTableH()
  303. }
  304. },
  305. mounted () {
  306. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  307. this.pageInit()
  308. this.resetSearchForm()
  309. }
  310. },
  311. activated () {
  312. // 如果是新页签打开,则重置当前页面
  313. if (this.$store.state.app.isNewTab) {
  314. this.pageInit()
  315. this.resetSearchForm()
  316. }
  317. // 仅刷新列表,不重置页面
  318. if (this.$store.state.app.updateList) {
  319. this.pageInit()
  320. this.$refs.table.refresh()
  321. }
  322. },
  323. beforeRouteEnter (to, from, next) {
  324. next(vm => {})
  325. }
  326. }
  327. </script>