warehouseDetail.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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="请选择仓库" 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" showIcon style="margin-bottom:10px">
  68. <div class="ftext" slot="message">
  69. 当前库存总数量(个):<strong>{{ (productTotal&&(productTotal.totalQty || productTotal.totalQty==0)) ? productTotal.totalQty : '--' }}</strong>;
  70. 当前库存总成本(¥):<strong>{{ (productTotal&&(productTotal.totalCost || productTotal.totalCost==0)) ? productTotal.totalCost : '--' }}</strong>。
  71. </div>
  72. </a-alert>
  73. <!-- 列表 -->
  74. <s-table
  75. class="sTable"
  76. ref="table"
  77. size="small"
  78. :rowKey="(record) => record.id"
  79. :columns="columns"
  80. :data="loadData"
  81. :scroll="{ x: 1760 }"
  82. bordered>
  83. <!-- 数量 -->
  84. <template slot="qty" slot-scope="text, record">
  85. <p :class="record.flowType=='PUT' ? 'green':'red'" style="margin: 0;">
  86. <span v-if="record.qty!=0">{{ record.flowType=='PUT' ? '+':'-' }}</span>
  87. {{ record.qty }}
  88. </p>
  89. </template>
  90. </s-table>
  91. </a-card>
  92. </div>
  93. </template>
  94. <script>
  95. import { STable, VSelect } from '@/components'
  96. import rangeDate from '@/views/common/rangeDate.vue'
  97. import { stockFlowList, stockFlowCount } from '@/api/stockFlow'
  98. import { warehouseAllList } from '@/api/warehouse'
  99. export default {
  100. components: { STable, VSelect, rangeDate },
  101. data () {
  102. return {
  103. advanced: false, // 高级搜索 展开/关闭
  104. queryParam: { // 查询条件
  105. beginDate: '',
  106. endDate: '',
  107. bizType: undefined,
  108. flowType: undefined,
  109. unitName: '',
  110. warehouseSn: undefined
  111. },
  112. disabled: false, // 查询、重置按钮是否可操作
  113. columns: [
  114. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  115. { title: '产品编码', dataIndex: 'product.code', width: 140, align: 'center', fixed: 'left', customRender: function (text) { return text || '--' } },
  116. { title: '产品名称', dataIndex: 'product.name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  117. { title: '原厂编码', dataIndex: 'product.origCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  118. { title: '批次号', dataIndex: 'stockBatchNo', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  119. { title: '单据类型', dataIndex: 'bizTypeDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  120. { title: '单据审核时间', dataIndex: 'auditTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  121. { title: '单位名称', dataIndex: 'unitName', width: 200, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  122. { title: '仓库', dataIndex: 'warehouseName', width: 140, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  123. { title: '仓位', dataIndex: 'warehouseLocationName', width: 140, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  124. { title: '数量', scopedSlots: { customRender: 'qty' }, width: 100, align: 'center' },
  125. { title: '总成本', dataIndex: 'totalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  126. { title: '总售价', dataIndex: 'totalPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  127. ],
  128. // 加载数据方法 必须为 Promise 对象
  129. loadData: parameter => {
  130. this.disabled = true
  131. const params = Object.assign(parameter, this.queryParam, { productSn: this.$route.params.sn })
  132. return stockFlowList(params).then(res => {
  133. const data = res.data
  134. const no = (data.pageNo - 1) * data.pageSize
  135. for (var i = 0; i < data.list.length; i++) {
  136. data.list[i].no = no + i + 1
  137. if (data.list[i].flowType == 'PUT') {
  138. data.list[i].qty = data.list[i].putQty
  139. } else if (data.list[i].flowType == 'OUT') {
  140. data.list[i].qty = data.list[i].outQty
  141. }
  142. }
  143. this.disabled = false
  144. this.getTotal(params)
  145. return data
  146. })
  147. },
  148. warehouseList: [], // 仓库 下拉数据
  149. productTotal: null // 合计
  150. }
  151. },
  152. methods: {
  153. // 时间 change
  154. dateChange (date) {
  155. this.queryParam.beginDate = date[0]
  156. this.queryParam.endDate = date[1]
  157. },
  158. // 合计
  159. getTotal (param) {
  160. stockFlowCount(param).then(res => {
  161. if (res.status == 200 && res.data) {
  162. this.productTotal = res.data
  163. } else {
  164. this.productTotal = null
  165. }
  166. })
  167. },
  168. // 重置
  169. resetSearchForm () {
  170. if (this.advanced) {
  171. this.$refs.rangeDate.resetDate()
  172. }
  173. this.queryParam.beginDate = ''
  174. this.queryParam.endDate = ''
  175. this.queryParam.bizType = undefined
  176. this.queryParam.flowType = undefined
  177. this.queryParam.unitName = ''
  178. this.queryParam.warehouseSn = undefined
  179. this.$refs.table.refresh(true)
  180. },
  181. // 返回列表
  182. handleBack () {
  183. this.$router.push({ path: '/inventoryManagement/inventoryQuery/list', query: { closeLastOldTab: true } })
  184. },
  185. // 仓库下拉数据
  186. getWarehouseList (type) {
  187. warehouseAllList({}).then(res => {
  188. if (res.status == 200) {
  189. this.warehouseList = res.data
  190. } else {
  191. this.warehouseList = []
  192. }
  193. })
  194. }
  195. },
  196. beforeRouteEnter (to, from, next) {
  197. next(vm => {
  198. vm.getWarehouseList()
  199. })
  200. }
  201. }
  202. </script>
  203. <style lang="less">
  204. .inventoryQueryWarehouseDetail-wrap{
  205. .inventoryQueryWarehouseDetail-back{
  206. margin-bottom: 15px;
  207. }
  208. .inventoryQueryWarehouseDetail-cont{
  209. margin-bottom: 15px;
  210. }
  211. .green{
  212. color: #19be6b;
  213. }
  214. .red{
  215. color: #ed1c24;
  216. }
  217. }
  218. </style>