warehouseDetail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <div class="inventoryQueryWarehouseDetail-wrap">
  3. <a-page-header :ghost="false" :backIcon="false" class="inventoryQueryWarehouseDetail-back">
  4. <!-- 自定义的二级文字标题 -->
  5. <template slot="subTitle">
  6. <a id="inventoryQueryWarehouseDetail-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  7. </template>
  8. </a-page-header>
  9. <a-card size="small" :bordered="false" class="inventoryQueryWarehouseDetail-cont">
  10. <!-- 搜索条件 -->
  11. <div ref="tableSearch" class="table-page-search-wrapper">
  12. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  13. <a-row :gutter="15">
  14. <a-col :md="6" :sm="24">
  15. <a-form-item label="变动类型">
  16. <v-select
  17. v-model="queryParam.flowType"
  18. ref="flowType"
  19. id="warehousingAuditList-flowType"
  20. code="STOCK_FLOW_TYPE"
  21. placeholder="请选择变动类型"
  22. allowClear></v-select>
  23. </a-form-item>
  24. </a-col>
  25. <a-col :md="6" :sm="24">
  26. <a-form-item label="单据类型">
  27. <v-select
  28. v-model="queryParam.bizType"
  29. ref="bizType"
  30. id="inventoryQueryWarehouseDetail-bizType"
  31. code="STOCK_FLOW_BIZ_TYPE"
  32. placeholder="请选择单据类型"
  33. allowClear></v-select>
  34. </a-form-item>
  35. </a-col>
  36. <a-col :md="6" :sm="24">
  37. <a-form-item label="仓库">
  38. <a-select id="inventoryQueryWarehouseDetail-warehouseSn" placeholder="请选择仓库" allowClear v-model="queryParam.warehouseSn" >
  39. <a-select-option v-for="item in warehouseList" :key="item.warehouseSn" :value="item.warehouseSn">{{ item.name }}</a-select-option>
  40. </a-select>
  41. </a-form-item>
  42. </a-col>
  43. <template v-if="advanced">
  44. <a-col :md="6" :sm="24">
  45. <a-form-item label="单据审核时间">
  46. <rangeDate ref="rangeDate" @change="dateChange" />
  47. </a-form-item>
  48. </a-col>
  49. <a-col :md="6" :sm="24">
  50. <a-form-item label="单位名称">
  51. <a-input id="inventoryQueryWarehouseDetail-unitName" v-model.trim="queryParam.unitName" allowClear placeholder="请输入单位名称"/>
  52. </a-form-item>
  53. </a-col>
  54. </template>
  55. <a-col :md="6" :sm="24">
  56. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="inventoryQueryWarehouseDetail-refresh">查询</a-button>
  57. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="inventoryQueryWarehouseDetail-reset">重置</a-button>
  58. <a @click="advanced=!advanced" style="margin-left: 8px">
  59. {{ advanced ? '收起' : '展开' }}
  60. <a-icon :type="advanced ? 'up' : 'down'"/>
  61. </a>
  62. </a-col>
  63. </a-row>
  64. </a-form>
  65. </div>
  66. <!-- 合计 -->
  67. <a-alert type="info" style="margin-bottom:10px">
  68. <div class="ftext" slot="message">
  69. 当前库存总数量(个):<strong>{{ (productTotal&&(productTotal.currentStockQty || productTotal.currentStockQty==0)) ? productTotal.currentStockQty : '--' }}</strong>;
  70. 当前库存总成本(¥):<strong>{{ (productTotal&&(productTotal.currentStockCost || productTotal.currentStockCost==0)) ? productTotal.currentStockCost : '--' }}</strong>。
  71. </div>
  72. </a-alert>
  73. <!-- 列表 -->
  74. <s-table
  75. class="sTable fixPagination"
  76. ref="table"
  77. :style="{ height: tableHeight+84.5+'px' }"
  78. size="small"
  79. :rowKey="(record) => record.id"
  80. :columns="columns"
  81. :data="loadData"
  82. :scroll="{ y: tableHeight }"
  83. :defaultLoadData="false"
  84. bordered>
  85. <!-- 数量 -->
  86. <template slot="qty" slot-scope="text, record">
  87. <p :class="record.flowType=='PUT' ? 'green':'red'" style="margin: 0;">
  88. <span v-if="record.qty!=0">{{ record.flowType=='PUT' ? '+':'-' }}</span>
  89. {{ record.qty }}
  90. </p>
  91. </template>
  92. </s-table>
  93. </a-card>
  94. </div>
  95. </template>
  96. <script>
  97. import { STable, VSelect } from '@/components'
  98. import rangeDate from '@/views/common/rangeDate.vue'
  99. import { stockFlowList } from '@/api/stockFlow'
  100. import { stockByProductSn } from '@/api/stock'
  101. import { warehouseAllList } from '@/api/warehouse'
  102. export default {
  103. components: { STable, VSelect, rangeDate },
  104. data () {
  105. return {
  106. advanced: false, // 高级搜索 展开/关闭
  107. tableHeight: 0,
  108. queryParam: { // 查询条件
  109. beginDate: '',
  110. endDate: '',
  111. bizType: undefined,
  112. flowType: undefined,
  113. unitName: '',
  114. warehouseSn: undefined
  115. },
  116. disabled: false, // 查询、重置按钮是否可操作
  117. columns: [
  118. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  119. { title: '产品编码', dataIndex: 'product.code', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  120. { title: '产品名称', dataIndex: 'product.name', width: '12%', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  121. { title: '原厂编码', dataIndex: 'product.origCode', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  122. { title: '批次号', dataIndex: 'stockBatchNo', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  123. { title: '单据类型', dataIndex: 'bizTypeDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  124. { title: '单据审核时间', dataIndex: 'auditTime', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  125. { title: '单位名称', dataIndex: 'unitName', width: '9%', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  126. { title: '仓库', dataIndex: 'warehouseName', width: '9%', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  127. { title: '仓位', dataIndex: 'warehouseLocationName', width: '9%', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  128. { title: '数量', scopedSlots: { customRender: 'qty' }, width: '5%', align: 'center' },
  129. { title: '总成本', dataIndex: 'totalCost', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  130. { title: '总售价', dataIndex: 'totalPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  131. ],
  132. // 加载数据方法 必须为 Promise 对象
  133. loadData: parameter => {
  134. this.disabled = true
  135. const params = Object.assign(parameter, this.queryParam, { productSn: this.$route.params.sn })
  136. return stockFlowList(params).then(res => {
  137. const data = res.data
  138. const no = (data.pageNo - 1) * data.pageSize
  139. for (var i = 0; i < data.list.length; i++) {
  140. data.list[i].no = no + i + 1
  141. if (data.list[i].flowType == 'PUT') {
  142. data.list[i].qty = data.list[i].putQty
  143. } else if (data.list[i].flowType == 'OUT') {
  144. data.list[i].qty = data.list[i].outQty
  145. }
  146. }
  147. this.disabled = false
  148. this.getTotal(params)
  149. return data
  150. })
  151. },
  152. warehouseList: [], // 仓库 下拉数据
  153. productTotal: null // 合计
  154. }
  155. },
  156. methods: {
  157. // 时间 change
  158. dateChange (date) {
  159. this.queryParam.beginDate = date[0]
  160. this.queryParam.endDate = date[1]
  161. },
  162. // 合计
  163. getTotal (param) {
  164. stockByProductSn({ productSn: this.$route.params.sn }).then(res => {
  165. if (res.status == 200 && res.data) {
  166. this.productTotal = res.data
  167. } else {
  168. this.productTotal = null
  169. }
  170. })
  171. },
  172. // 重置
  173. resetSearchForm () {
  174. if (this.advanced) {
  175. this.$refs.rangeDate.resetDate()
  176. }
  177. this.queryParam.beginDate = ''
  178. this.queryParam.endDate = ''
  179. this.queryParam.bizType = undefined
  180. this.queryParam.flowType = undefined
  181. this.queryParam.unitName = ''
  182. this.queryParam.warehouseSn = undefined
  183. this.$refs.table.refresh(true)
  184. },
  185. // 返回列表
  186. handleBack () {
  187. this.$router.push({ path: '/inventoryManagement/inventoryQuery/list', query: { closeLastOldTab: true } })
  188. },
  189. // 仓库下拉数据
  190. getWarehouseList (type) {
  191. warehouseAllList({}).then(res => {
  192. if (res.status == 200) {
  193. this.warehouseList = res.data
  194. } else {
  195. this.warehouseList = []
  196. }
  197. })
  198. },
  199. pageInit () {
  200. const _this = this
  201. this.$nextTick(() => { // 页面渲染完成后的回调
  202. _this.setTableH()
  203. })
  204. this.getWarehouseList()
  205. this.resetSearchForm()
  206. },
  207. setTableH () {
  208. const tableSearchH = this.$refs.tableSearch.offsetHeight
  209. this.tableHeight = window.innerHeight - tableSearchH - 298
  210. }
  211. },
  212. watch: {
  213. advanced (newValue, oldValue) {
  214. const _this = this
  215. setTimeout(() => {
  216. _this.setTableH()
  217. }, 400)
  218. },
  219. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  220. this.setTableH()
  221. }
  222. },
  223. mounted () {
  224. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  225. this.pageInit()
  226. }
  227. },
  228. activated () {
  229. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  230. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  231. this.pageInit()
  232. }
  233. },
  234. beforeRouteEnter (to, from, next) {
  235. next(vm => {})
  236. }
  237. }
  238. </script>
  239. <style lang="less">
  240. .inventoryQueryWarehouseDetail-wrap{
  241. .inventoryQueryWarehouseDetail-back, .inventoryQueryWarehouseDetail-cont{
  242. margin-bottom: 10px;
  243. }
  244. .green{
  245. color: #19be6b;
  246. }
  247. .red{
  248. color: #ed1c24;
  249. }
  250. }
  251. </style>