warehouseDetail.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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 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="请选择仓库" 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. <a-range-picker
  47. style="width:100%"
  48. id="inventoryQueryWarehouseDetail-createDate"
  49. :disabledDate="disabledDate"
  50. v-model="createDate"
  51. :format="dateFormat"
  52. :placeholder="['开始时间', '结束时间']" />
  53. </a-form-item>
  54. </a-form-item>
  55. </a-col>
  56. <a-col :md="6" :sm="24">
  57. <a-form-item label="单位名称">
  58. <a-input id="inventoryQueryWarehouseDetail-unitName" v-model.trim="queryParam.unitName" allowClear placeholder="请输入单位名称"/>
  59. </a-form-item>
  60. </a-col>
  61. </template>
  62. <a-col :md="6" :sm="24">
  63. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="inventoryQueryWarehouseDetail-refresh">查询</a-button>
  64. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="inventoryQueryWarehouseDetail-reset">重置</a-button>
  65. <a @click="advanced=!advanced" style="margin-left: 8px">
  66. {{ advanced ? '收起' : '展开' }}
  67. <a-icon :type="advanced ? 'up' : 'down'"/>
  68. </a>
  69. </a-col>
  70. </a-row>
  71. </a-form>
  72. </div>
  73. <!-- 合计 -->
  74. <a-alert type="info" showIcon style="margin-bottom:15px">
  75. <div class="ftext" slot="message">当前库存总数量(个):<strong>{{ productTotal.stockQty }}</strong>;当前库存总成本(¥):<strong>{{ productTotal.stockCost }}</strong>。</div>
  76. </a-alert>
  77. <!-- 列表 -->
  78. <s-table
  79. class="sTable"
  80. ref="table"
  81. size="default"
  82. :rowKey="(record) => record.id"
  83. :columns="columns"
  84. :data="loadData"
  85. :scroll="{ x: 1760 }"
  86. bordered>
  87. <!-- 数量 -->
  88. <template slot="qty" slot-scope="text, record">
  89. <span :class="record.flowType=='PUT' ? 'green':'red'">{{ record.flowType=='PUT' ? '+':'-' }}{{ record.qty }}</span>
  90. </template>
  91. </s-table>
  92. </a-card>
  93. </div>
  94. </template>
  95. <script>
  96. import moment from 'moment'
  97. import { STable, VSelect } from '@/components'
  98. import { stockFlowList } from '@/api/stockFlow'
  99. import { stockByProductSn } from '@/api/stock'
  100. import { warehouseAllList } from '@/api/warehouse'
  101. export default {
  102. components: { STable, VSelect },
  103. data () {
  104. return {
  105. advanced: false, // 高级搜索 展开/关闭
  106. queryParam: { // 查询条件
  107. bizType: undefined,
  108. flowType: undefined,
  109. unitName: '',
  110. warehouseSn: undefined
  111. },
  112. exportLoading: false, // 导出loading
  113. disabled: false, // 查询、重置按钮是否可操作
  114. createDate: [],
  115. dateFormat: 'YYYY-MM-DD',
  116. columns: [
  117. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  118. { title: '产品编码', dataIndex: 'product.code', width: 140, align: 'center', fixed: 'left', customRender: function (text) { return text || '--' } },
  119. { title: '产品名称', dataIndex: 'product.name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  120. { title: '原厂编码', dataIndex: 'product.origCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  121. { title: '入库批次时间', dataIndex: 'stockBatchNo', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  122. { title: '单据类型', dataIndex: 'bizTypeDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  123. { title: '单据审核时间', dataIndex: 'auditTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  124. { title: '单位名称', dataIndex: 'unitName', width: 200, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  125. { title: '仓库', dataIndex: 'warehouseName', width: 140, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  126. { title: '仓位', dataIndex: 'warehouseLocationName', width: 140, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  127. { title: '数量', scopedSlots: { customRender: 'qty' }, width: 100, align: 'center' },
  128. { title: '总成本', dataIndex: 'totalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  129. { title: '总售价', dataIndex: 'totalPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  130. ],
  131. // 加载数据方法 必须为 Promise 对象
  132. loadData: parameter => {
  133. this.disabled = true
  134. // 入库时间
  135. if (this.createDate && this.createDate.length > 0) {
  136. this.queryParam.beginDate = moment(this.createDate[0]).format(this.dateFormat)
  137. this.queryParam.endDate = moment(this.createDate[1]).format(this.dateFormat)
  138. } else {
  139. this.queryParam.beginDate = undefined
  140. this.queryParam.endDate = undefined
  141. }
  142. const params = Object.assign(parameter, this.queryParam, { productSn: this.$route.params.sn })
  143. return stockFlowList(params).then(res => {
  144. const data = res.data
  145. const no = (data.pageNo - 1) * data.pageSize
  146. for (var i = 0; i < data.list.length; i++) {
  147. data.list[i].no = no + i + 1
  148. if (data.list[i].flowType == 'PUT') {
  149. data.list[i].qty = data.list[i].putQty
  150. } else if (data.list[i].flowType == 'OUT') {
  151. data.list[i].qty = data.list[i].outQty
  152. }
  153. }
  154. this.disabled = false
  155. this.getTotal(params)
  156. return data
  157. })
  158. },
  159. warehouseList: [], // 仓库 下拉数据
  160. productTotal: {
  161. stockQty: 0,
  162. stockCost: 0
  163. } // 合计
  164. }
  165. },
  166. methods: {
  167. // 不可选日期
  168. disabledDate (date, dateStrings) {
  169. return date && date.valueOf() > Date.now()
  170. },
  171. // 合计
  172. getTotal (param) {
  173. stockByProductSn(param).then(res => {
  174. if (res.status == 200 && res.data) {
  175. this.productTotal = {
  176. stockQty: (Number(res.data.currentStockQty) + Number(res.data.freezeQty)) || 0,
  177. stockCost: (Number(res.data.currentStockCost) + Number(res.data.freezeCost)) || 0
  178. }
  179. } else {
  180. this.productTotal = {
  181. stockQty: 0,
  182. stockCost: 0
  183. }
  184. }
  185. })
  186. },
  187. // 重置
  188. resetSearchForm () {
  189. this.queryParam.bizType = undefined
  190. this.queryParam.flowType = undefined
  191. this.queryParam.unitName = ''
  192. this.queryParam.warehouseSn = undefined
  193. this.createDate = []
  194. this.$refs.table.refresh(true)
  195. },
  196. // 返回列表
  197. handleBack () {
  198. this.$router.push({ path: '/inventoryManagement/inventoryQuery/list' })
  199. },
  200. // 仓库下拉数据
  201. getWarehouseList (type) {
  202. warehouseAllList({}).then(res => {
  203. if (res.status == 200) {
  204. this.warehouseList = res.data
  205. } else {
  206. this.warehouseList = []
  207. }
  208. })
  209. }
  210. },
  211. beforeRouteEnter (to, from, next) {
  212. next(vm => {
  213. vm.getWarehouseList()
  214. })
  215. }
  216. }
  217. </script>
  218. <style lang="less">
  219. .inventoryQueryWarehouseDetail-wrap{
  220. .inventoryQueryWarehouseDetail-back{
  221. margin-bottom: 15px;
  222. }
  223. .inventoryQueryWarehouseDetail-cont{
  224. margin-bottom: 15px;
  225. }
  226. .green{
  227. color: #19be6b;
  228. }
  229. .red{
  230. color: #ed1c24;
  231. }
  232. }
  233. </style>