list.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <a-card size="small" :bordered="false" class="inventoryQueryList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="产品编码">
  9. <a-input id="inventoryQueryList-productCode" v-model="queryParam.dealerProduct.code" allowClear placeholder="请输入产品编码"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="原厂编码">
  14. <a-input id="inventoryQueryList-productOrigCode" v-model.trim="queryParam.dealerProduct.origCode" allowClear placeholder="请输入原厂编码"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="产品名称">
  19. <a-input id="inventoryQueryList-productName" v-model.trim="queryParam.dealerProduct.name" allowClear placeholder="请输入产品名称"/>
  20. </a-form-item>
  21. </a-col>
  22. <template v-if="advanced">
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="产品品牌">
  25. <a-select id="inventoryQueryList-productBrandSn" placeholder="请选择产品品牌" allowClear v-model="queryParam.productBrandSn">
  26. <a-select-option v-for="item in brandData" :key="item.stationNo" :value="item.stationNo">{{ item.name }}</a-select-option>
  27. </a-select>
  28. </a-form-item>
  29. </a-col>
  30. <a-col :md="6" :sm="24">
  31. <a-form-item label="产品分类">
  32. <a-cascader :options="typeData" placeholder="请选择产品分类" allowClear v-model="productTypeSn" @change="changeType" />
  33. </a-form-item>
  34. </a-col>
  35. <a-col :md="6" :sm="24">
  36. <a-form-item label="库存数量是否为0">
  37. <v-select code="FLAG" id="inventoryQueryList-zeroQtyFlag" v-model="queryParam.zeroQtyFlag" allowClear placeholder="请选择"></v-select>
  38. </a-form-item>
  39. </a-col>
  40. </template>
  41. <a-col :md="6" :sm="24">
  42. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="inventoryQueryList-refresh">查询</a-button>
  43. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="inventoryQueryList-reset">重置</a-button>
  44. <!-- <a-button
  45. style="margin-left: 8px"
  46. type="danger"
  47. @click="handleExport"
  48. :disabled="disabled"
  49. :loading="exportLoading"
  50. id="inventoryQueryList-export">导出</a-button> -->
  51. <a @click="advanced=!advanced" style="margin-left: 8px">
  52. {{ advanced ? '收起' : '展开' }}
  53. <a-icon :type="advanced ? 'up' : 'down'"/>
  54. </a>
  55. </a-col>
  56. </a-row>
  57. </a-form>
  58. </div>
  59. <!-- 合计 -->
  60. <a-alert type="info" showIcon style="margin-bottom:15px">
  61. <div class="ftext" slot="message">现有库存总数量(个):<strong>{{ currentStock.currentStockQty || 0 }}</strong>;现有库存总成本(¥):<strong>{{ currentStock.currentStockCost || 0 }}</strong>。</div>
  62. </a-alert>
  63. <!-- 列表 -->
  64. <s-table
  65. class="sTable"
  66. ref="table"
  67. size="default"
  68. :rowKey="(record) => record.id"
  69. :columns="columns"
  70. :data="loadData"
  71. :scroll="{ x: 1430 }"
  72. bordered>
  73. <!-- 产品分类 -->
  74. <template slot="productTypeName" slot-scope="text, record">
  75. <span v-if="record.dealerProduct">{{ record.dealerProduct.productTypeName2 || '' }}</span> >
  76. <span v-if="record.dealerProduct">{{ record.dealerProduct.productTypeName3 || '' }}</span>
  77. </template>
  78. <!-- 操作 -->
  79. <template slot="action" slot-scope="text, record">
  80. <a-button size="small" type="link" @click="goDetail(record)" id="inventoryQueryList-detail-btn">库存详情</a-button>
  81. <a-divider type="vertical" style="margin: 0;" />
  82. <a-button size="small" type="link" style="margin-left: 8px" @click="goWarehouseDetail(record)" id="inventoryQueryList-warehouseDetail-btn">出入库明细</a-button>
  83. </template>
  84. </s-table>
  85. <!-- 库存详情 -->
  86. <inventory-query-detail-modal :openModal="openModal" :itemId="itemId" @close="closeModal" />
  87. </a-card>
  88. </template>
  89. <script>
  90. import moment from 'moment'
  91. import { stockList, stockCount } from '@/api/stock'
  92. import { STable, VSelect } from '@/components'
  93. import inventoryQueryDetailModal from './detailModal.vue'
  94. export default {
  95. components: { STable, VSelect, inventoryQueryDetailModal },
  96. data () {
  97. return {
  98. advanced: false, // 高级搜索 展开/关闭
  99. queryParam: { // 查询条件
  100. dealerProduct: {
  101. code: '', // 产品编码
  102. name: '', // 产品名称
  103. origCode: '', // 原厂编码
  104. productBrandSn: '', // 产品品牌
  105. productTypeSn1: '', // 产品分类1
  106. productTypeSn2: '', // 产品分类2
  107. productTypeSn3: '' // 产品分类3
  108. },
  109. zeroQtyFlag: undefined // 库存数量是否为0
  110. },
  111. productTypeSn: [],
  112. exportLoading: false, // 导出loading
  113. disabled: false, // 查询、重置按钮是否可操作
  114. brandData: [], // 产品品牌下拉数据
  115. typeData: [], // 产品分类下拉数据
  116. columns: [
  117. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  118. { title: '产品编码', dataIndex: 'dealerProduct.code', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  119. { title: '产品名称', dataIndex: 'dealerProduct.name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  120. { title: '原厂编码', dataIndex: 'dealerProduct.origCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  121. { title: '产品品牌', dataIndex: 'dealerProduct.productBrandName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  122. { title: '产品分类', scopedSlots: { customRender: 'productTypeName' }, width: 200, align: 'center' },
  123. { title: '现有库存数量(个)', dataIndex: 'currentStockQty', width: 165, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  124. { title: '现有库存成本(¥)', dataIndex: 'currentStockCost', width: 165, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  125. // { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
  126. ],
  127. // 加载数据方法 必须为 Promise 对象
  128. loadData: parameter => {
  129. this.disabled = true
  130. return stockList(Object.assign(parameter, this.queryParam)).then(res => {
  131. const data = res.data
  132. const no = (data.pageNo - 1) * data.pageSize
  133. for (var i = 0; i < data.list.length; i++) {
  134. data.list[i].no = no + i + 1
  135. }
  136. this.disabled = false
  137. // 总计
  138. this.getTotal(Object.assign(parameter, this.queryParam))
  139. return data
  140. })
  141. },
  142. openModal: false, // 查看库存详情 弹框
  143. itemId: '', // 当前库存记录id
  144. currentStock: { // 合计信息
  145. currentStockQty: '',
  146. currentStockCost: ''
  147. }
  148. }
  149. },
  150. methods: {
  151. // 重置
  152. resetSearchForm () {
  153. this.queryParam.productCode = ''
  154. this.queryParam.productOrigCode = ''
  155. this.queryParam.productName = ''
  156. this.queryParam.brandName = undefined
  157. this.queryParam.productTypeName = undefined
  158. this.queryParam.currentStockQty = false
  159. this.$refs.table.refresh(true)
  160. },
  161. // 分类 changeType
  162. changeType (val) {
  163. console.log(val)
  164. },
  165. // 合计
  166. getTotal (param) {
  167. stockCount(param).then(res => {
  168. if (res.status == 200) {
  169. this.currentStock = res.data
  170. } else {
  171. this.currentStock = null
  172. }
  173. })
  174. },
  175. // 库存详情
  176. goDetail (row) {
  177. this.itemId = row.id
  178. this.openModal = true
  179. },
  180. // 关闭弹框
  181. closeModal () {
  182. this.itemId = ''
  183. this.openModal = false
  184. },
  185. // 出入库明细
  186. goWarehouseDetail (row) {
  187. this.$router.push({ path: `/inventoryManagement/inventoryQuery/warehouseDetail/${row.id}` })
  188. },
  189. // 导出
  190. handleExport () {
  191. const params = this.queryParam
  192. this.exportLoading = true
  193. // customerBundleExportDelay(params).then(res => {
  194. // this.exportLoading = false
  195. // this.download(res)
  196. // })
  197. },
  198. download (data) {
  199. if (!data) { return }
  200. const url = window.URL.createObjectURL(new Blob([data]))
  201. const link = document.createElement('a')
  202. link.style.display = 'none'
  203. link.href = url
  204. const a = moment().format('YYYYMMDDHHmmss')
  205. const fname = '库存查询' + a
  206. link.setAttribute('download', fname + '.xlsx')
  207. document.body.appendChild(link)
  208. link.click()
  209. }
  210. }
  211. }
  212. </script>