warehouseDetail.vue 14 KB

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