list.vue 14 KB

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