list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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" labelAlign="right" @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="6" :sm="24">
  19. <a-form-item label="产品品牌">
  20. <ProductBrand id="inventoryQueryList-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="产品分类">
  25. <ProductType id="inventoryQueryList-productType" placeholder="请选择产品分类" @change="changeProductType" v-model="productType"></ProductType>
  26. </a-form-item>
  27. </a-col>
  28. <template v-if="advanced">
  29. <a-col :md="6" :sm="24">
  30. <a-form-item label="产品名称">
  31. <a-input id="inventoryQueryList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  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 style="float:right" v-model="queryParam.zeroQtyFlag" id="inventoryQueryList-zeroQtyFlag">只查看有库存</a-checkbox>
  42. </a-form-item>
  43. </a-col>
  44. </template>
  45. <a-col :md="6" :sm="24" style="text-align: center;">
  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 @click="advanced=!advanced" style="margin-left: 5px" id="inventoryQueryList-advanced">
  49. {{ advanced ? '收起' : '展开' }}
  50. <a-icon :type="advanced ? 'up' : 'down'"/>
  51. </a>
  52. </a-col>
  53. </a-row>
  54. </a-form>
  55. </div>
  56. </a-card>
  57. <a-card size="small" :bordered="false" class="inventoryQueryList-wrap">
  58. <a-spin :spinning="spinning" tip="Loading...">
  59. <!-- 合计 -->
  60. <div class="ftext tongji-bar">
  61. <div>
  62. 可用库存总数量:<strong>{{ (currentStock&&(currentStock.currentStockQty || currentStock.currentStockQty==0)) ? currentStock.currentStockQty : '--' }}个</strong>;
  63. </div>
  64. <div v-if="$hasPermissions('M_inventoryQueryList_costPrice')">可用库存总成本:<strong>{{ (currentStock&&(currentStock.currentStockCost || currentStock.currentStockCost==0)) ? toThousands(currentStock.currentStockCost) : '--' }}</strong>。</div>
  65. </div>
  66. <!-- 列表 -->
  67. <s-table
  68. class="sTable"
  69. ref="table"
  70. size="small"
  71. :rowKey="(record) => record.id"
  72. :columns="columns"
  73. :pageSize="20"
  74. :data="loadData"
  75. :defaultLoadData="false"
  76. >
  77. <template slot="productInfo" slot-scope="text, record">
  78. <div class="tr-row">
  79. <div class="tr-title">{{ record.productName }}</div>
  80. <div>产品编码:<span class="code">{{ record.productCode }}</span></div>
  81. <div>仓库:<span>{{ record.warehouseName }}</span></div>
  82. <div>产品品牌:<span>{{ record.productBrandName }}</span></div>
  83. <div>可用库存数量:<span class="nums">{{ record.currentStockQty }}</span> {{ record.productUnit }}</div>
  84. <div v-if="$hasPermissions('M_inventoryQueryList_costPrice')">可用库存成本:<span>{{ toThousands(record.currentStockCost) }}</span></div>
  85. <div>货位编号:<span>{{ record.stackPlaceEntity && record.stackPlaceEntity.stackPlaceCode||'--' }}</span></div>
  86. <div>最后入库时间:<span>{{ record.lastStockTime }}</span></div>
  87. </div>
  88. </template>
  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. style="margin:10px 0;"
  97. @click="goDetail(record)"
  98. :id="'inventoryQueryList-detail-'+record.id">库存详情</a-button>
  99. <a-button
  100. v-if="$hasPermissions('B_inventoryQuery_rkDetail')"
  101. size="small"
  102. type="link"
  103. class="button-warning"
  104. @click="goWarehouseDetail(record)"
  105. :id="'inventoryQueryList-whousedetail-'+record.id">出入库明细</a-button>
  106. <span v-if="!$hasPermissions('B_inventoryQuery_detail')&&!$hasPermissions('B_inventoryQuery_rkDetail')">--</span>
  107. </template>
  108. </s-table>
  109. </a-spin>
  110. <!-- 库存详情 -->
  111. <inventory-query-detail-modal v-drag :openModal="openModal" :itemId="itemId" @close="closeModal" />
  112. </a-card>
  113. </div>
  114. </template>
  115. <script>
  116. import { commonMixin } from '@/utils/mixin'
  117. // 组件
  118. import { STable, VSelect } from '@/components'
  119. import inventoryQueryDetailModal from './detailModal.vue'
  120. import ProductType from '@/views/common/productType.js'
  121. import ProductBrand from '@/views/common/productBrand.js'
  122. import warehouse from '@/views/common/chooseWarehouse.js'
  123. // 接口
  124. import { stockList, stockCount } from '@/api/stock'
  125. export default {
  126. name: 'InventoryQueryList',
  127. mixins: [commonMixin],
  128. components: { STable, VSelect, inventoryQueryDetailModal, ProductType, ProductBrand, warehouse },
  129. data () {
  130. return {
  131. spinning: false,
  132. advanced: false, // 高级搜索 展开/关闭
  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. }
  198. },
  199. computed: {
  200. // 表头
  201. columns () {
  202. const arr = [
  203. { title: '序号', dataIndex: 'no', width: '40px', align: 'center' },
  204. { title: '产品信息', scopedSlots: { customRender: 'productInfo' }, width: '82%', align: 'center' },
  205. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  206. ]
  207. return arr
  208. }
  209. },
  210. methods: {
  211. // 重置
  212. resetSearchForm () {
  213. this.queryParam.productBrandSn = undefined
  214. this.queryParam.productTypeSn1 = ''
  215. this.queryParam.productTypeSn2 = ''
  216. this.queryParam.productTypeSn3 = ''
  217. this.queryParam.productCode = ''
  218. this.queryParam.productOrigCode = ''
  219. this.queryParam.productName = ''
  220. this.queryParam.warehouseSn = undefined
  221. this.queryParam.zeroQtyFlag = false
  222. this.productType = []
  223. this.$refs.table.refresh(true)
  224. },
  225. // 获取表格数据
  226. getTableData () {
  227. },
  228. // 合计
  229. getTotal (param) {
  230. stockCount(param).then(res => {
  231. if (res.status == 200 && res.data) {
  232. this.currentStock = res.data
  233. } else {
  234. this.currentStock = null
  235. }
  236. })
  237. },
  238. // 库存详情
  239. goDetail (row) {
  240. this.$store.state.app.curActionPermission = 'B_inventoryQuery_detail'
  241. this.itemId = row.stockSn
  242. this.openModal = true
  243. },
  244. // 关闭弹框
  245. closeModal () {
  246. this.itemId = ''
  247. this.openModal = false
  248. },
  249. // 出入库明细
  250. goWarehouseDetail (row) {
  251. this.$router.push({ name: 'inventoryQueryWarehouseDetail', params: { sn: row.productSn, warehouseSn: row.warehouseSn } })
  252. },
  253. // 产品分类 change
  254. changeProductType (val, opt) {
  255. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  256. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  257. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  258. },
  259. // 初始化页面
  260. pageInit () {
  261. const _this = this
  262. this.$nextTick(() => { // 页面渲染完成后的回调
  263. _this.setTableH()
  264. })
  265. },
  266. // 计算表格高度
  267. setTableH () {
  268. const tableSearchH = this.$refs.tableSearch.offsetHeight
  269. this.tableHeight = window.innerHeight - tableSearchH - 226
  270. }
  271. },
  272. watch: {
  273. advanced (newValue, oldValue) {
  274. const _this = this
  275. this.$nextTick(() => { // 页面渲染完成后的回调
  276. _this.setTableH()
  277. })
  278. },
  279. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  280. this.setTableH()
  281. }
  282. },
  283. mounted () {
  284. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  285. this.pageInit()
  286. }
  287. },
  288. activated () {
  289. // 如果是新页签打开,则重置当前页面
  290. if (this.$store.state.app.isNewTab) {
  291. this.pageInit()
  292. }
  293. // 仅刷新列表,不重置页面
  294. if (this.$store.state.app.updateList) {
  295. this.pageInit()
  296. this.$refs.table.refresh()
  297. }
  298. },
  299. beforeRouteEnter (to, from, next) {
  300. next(vm => {})
  301. }
  302. }
  303. </script>
  304. <style lang="less">
  305. .inventoryQueryList-wrap{
  306. margin-top: 10px;
  307. .sTable{
  308. margin-top: 10px;
  309. }
  310. .tr-row{
  311. text-align: left;
  312. .tr-title{
  313. font-weight: bold;
  314. }
  315. > div{
  316. padding: 2px 0;
  317. color: #666;
  318. span{
  319. color: #222;
  320. }
  321. .code{
  322. color: #00aaff;
  323. }
  324. .nums{
  325. color: #ff0000;
  326. }
  327. }
  328. }
  329. }
  330. </style>