warehouseDetail.vue 13 KB

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