warehouseDetail.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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. <p :class="record.flowType=='PUT' ? 'green':'red'" style="margin: 0;">
  90. <span v-if="record.qty!=0">{{ record.flowType=='PUT' ? '+':'-' }}</span>
  91. {{ record.qty }}
  92. </p>
  93. </template>
  94. </s-table>
  95. </a-card>
  96. </div>
  97. </template>
  98. <script>
  99. import moment from 'moment'
  100. import { STable, VSelect } from '@/components'
  101. import { stockFlowList } from '@/api/stockFlow'
  102. import { stockByProductSn } from '@/api/stock'
  103. import { warehouseAllList } from '@/api/warehouse'
  104. export default {
  105. components: { STable, VSelect },
  106. data () {
  107. return {
  108. advanced: false, // 高级搜索 展开/关闭
  109. queryParam: { // 查询条件
  110. bizType: undefined,
  111. flowType: undefined,
  112. unitName: '',
  113. warehouseSn: undefined
  114. },
  115. exportLoading: false, // 导出loading
  116. disabled: false, // 查询、重置按钮是否可操作
  117. createDate: [],
  118. dateFormat: 'YYYY-MM-DD',
  119. columns: [
  120. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  121. { title: '产品编码', dataIndex: 'product.code', width: 140, align: 'center', fixed: 'left', customRender: function (text) { return text || '--' } },
  122. { title: '产品名称', dataIndex: 'product.name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  123. { title: '原厂编码', dataIndex: 'product.origCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  124. { title: '入库批次时间', dataIndex: 'stockBatchNo', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  125. { title: '单据类型', dataIndex: 'bizTypeDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  126. { title: '单据审核时间', dataIndex: 'auditTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  127. { title: '单位名称', dataIndex: 'unitName', width: 200, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  128. { title: '仓库', dataIndex: 'warehouseName', width: 140, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  129. { title: '仓位', dataIndex: 'warehouseLocationName', width: 140, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  130. { title: '数量', scopedSlots: { customRender: 'qty' }, width: 100, align: 'center' },
  131. { title: '总成本', dataIndex: 'totalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  132. { title: '总售价', dataIndex: 'totalPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  133. ],
  134. // 加载数据方法 必须为 Promise 对象
  135. loadData: parameter => {
  136. this.disabled = true
  137. // 入库时间
  138. if (this.createDate && this.createDate.length > 0) {
  139. this.queryParam.beginDate = moment(this.createDate[0]).format(this.dateFormat)
  140. this.queryParam.endDate = moment(this.createDate[1]).format(this.dateFormat)
  141. } else {
  142. this.queryParam.beginDate = undefined
  143. this.queryParam.endDate = undefined
  144. }
  145. const params = Object.assign(parameter, this.queryParam, { productSn: this.$route.params.sn })
  146. return stockFlowList(params).then(res => {
  147. const data = res.data
  148. const no = (data.pageNo - 1) * data.pageSize
  149. for (var i = 0; i < data.list.length; i++) {
  150. data.list[i].no = no + i + 1
  151. if (data.list[i].flowType == 'PUT') {
  152. data.list[i].qty = data.list[i].putQty
  153. } else if (data.list[i].flowType == 'OUT') {
  154. data.list[i].qty = data.list[i].outQty
  155. }
  156. }
  157. this.disabled = false
  158. this.getTotal(params)
  159. return data
  160. })
  161. },
  162. warehouseList: [], // 仓库 下拉数据
  163. productTotal: {
  164. stockQty: 0,
  165. stockCost: 0
  166. } // 合计
  167. }
  168. },
  169. methods: {
  170. // 不可选日期
  171. disabledDate (date, dateStrings) {
  172. return date && date.valueOf() > Date.now()
  173. },
  174. // 合计
  175. getTotal (param) {
  176. stockByProductSn(param).then(res => {
  177. if (res.status == 200 && res.data) {
  178. this.productTotal = {
  179. stockQty: (Number(res.data.currentStockQty) + Number(res.data.freezeQty)) || 0,
  180. stockCost: (Number(res.data.currentStockCost) + Number(res.data.freezeCost)) || 0
  181. }
  182. } else {
  183. this.productTotal = {
  184. stockQty: 0,
  185. stockCost: 0
  186. }
  187. }
  188. })
  189. },
  190. // 重置
  191. resetSearchForm () {
  192. this.queryParam.bizType = undefined
  193. this.queryParam.flowType = undefined
  194. this.queryParam.unitName = ''
  195. this.queryParam.warehouseSn = undefined
  196. this.createDate = []
  197. this.$refs.table.refresh(true)
  198. },
  199. // 返回列表
  200. handleBack () {
  201. this.$router.push({ path: '/inventoryManagement/inventoryQuery/list' })
  202. },
  203. // 仓库下拉数据
  204. getWarehouseList (type) {
  205. warehouseAllList({}).then(res => {
  206. if (res.status == 200) {
  207. this.warehouseList = res.data
  208. } else {
  209. this.warehouseList = []
  210. }
  211. })
  212. }
  213. },
  214. beforeRouteEnter (to, from, next) {
  215. next(vm => {
  216. vm.getWarehouseList()
  217. })
  218. }
  219. }
  220. </script>
  221. <style lang="less">
  222. .inventoryQueryWarehouseDetail-wrap{
  223. .inventoryQueryWarehouseDetail-back{
  224. margin-bottom: 15px;
  225. }
  226. .inventoryQueryWarehouseDetail-cont{
  227. margin-bottom: 15px;
  228. }
  229. .green{
  230. color: #19be6b;
  231. }
  232. .red{
  233. color: #ed1c24;
  234. }
  235. }
  236. </style>