warehouseDetail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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="6" :sm="24">
  16. <a-form-item label="单据审核时间">
  17. <rangeDate ref="rangeDate" @change="dateChange" />
  18. </a-form-item>
  19. </a-col>
  20. <a-col :md="6" :sm="24">
  21. <a-form-item label="关联单号">
  22. <a-input id="inventoryQueryWarehouseDetail-bizNo" v-model.trim="queryParam.bizNo" allowClear placeholder="请输入关联单号"/>
  23. </a-form-item>
  24. </a-col>
  25. <a-col :md="6" :sm="24">
  26. <a-form-item label="下推单号">
  27. <a-input id="inventoryQueryWarehouseDetail-bizSubNo" v-model.trim="queryParam.bizSubNo" allowClear placeholder="请输入下推单号"/>
  28. </a-form-item>
  29. </a-col>
  30. <template v-if="advanced">
  31. <a-col :md="6" :sm="24">
  32. <a-form-item label="变动类型">
  33. <v-select
  34. v-model="queryParam.flowType"
  35. ref="flowType"
  36. id="inventoryQueryWarehouseDetail-flowType"
  37. code="STOCK_FLOW_TYPE"
  38. placeholder="请选择变动类型"
  39. allowClear></v-select>
  40. </a-form-item>
  41. </a-col>
  42. <a-col :md="6" :sm="24">
  43. <a-form-item label="单据类型">
  44. <v-select
  45. v-model="queryParam.bizType"
  46. ref="bizType"
  47. id="inventoryQueryWarehouseDetail-bizType"
  48. code="STOCK_FLOW_BIZ_TYPE"
  49. placeholder="请选择单据类型"
  50. allowClear></v-select>
  51. </a-form-item>
  52. </a-col>
  53. <a-col :md="6" :sm="24">
  54. <a-form-item label="单位名称">
  55. <a-input id="inventoryQueryWarehouseDetail-unitName" v-model.trim="queryParam.unitName" allowClear placeholder="请输入单位名称"/>
  56. </a-form-item>
  57. </a-col>
  58. <a-col :md="6" :sm="24">
  59. <a-form-item label="出入库状态">
  60. <v-select
  61. v-model="queryParam.state"
  62. ref="state"
  63. id="inventoryQueryWarehouseDetail-state"
  64. code="STOCK_FLOW_STATE"
  65. placeholder="请选择出入库状态"
  66. allowClear></v-select>
  67. </a-form-item>
  68. </a-col>
  69. </template>
  70. <a-col :md="6" :sm="24">
  71. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="inventoryQueryWarehouseDetail-refresh">查询</a-button>
  72. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="inventoryQueryWarehouseDetail-reset">重置</a-button>
  73. <a-button
  74. type="primary"
  75. style="margin-left: 5px"
  76. class="button-warning"
  77. v-if="$hasPermissions('B_inventoryQuery_rkDetail_export')"
  78. @click="handleExcel"
  79. :disabled="disabled"
  80. :loading="exportLoading"
  81. id="inventoryQueryList-export">导出</a-button>
  82. <a @click="advanced=!advanced" style="margin-left: 5px" id="inventoryQueryList-advanced">
  83. {{ advanced ? '收起' : '展开' }}
  84. <a-icon :type="advanced ? 'up' : 'down'"/>
  85. </a>
  86. </a-col>
  87. </a-row>
  88. </a-form>
  89. </div>
  90. <!-- 合计 -->
  91. <a-alert type="info" style="margin-bottom:10px">
  92. <div class="ftext" slot="message">
  93. 当前库存总数量:<strong>{{ (productTotal&&(productTotal.totalQty || productTotal.totalQty==0)) ? productTotal.totalQty : '--' }}个</strong>;
  94. 入库总数量:<strong>{{ (productTotal&&(productTotal.totalPutQty || productTotal.totalPutQty==0)) ? productTotal.totalPutQty : '--' }}个</strong>;
  95. 出库总数量:<strong>{{ (productTotal&&(productTotal.totalOutQty || productTotal.totalOutQty==0)) ? productTotal.totalOutQty : '--' }}个</strong>;
  96. <span v-if="$hasPermissions('B_inventoryQuery_rkDetail_costPrice')">当前库存总成本:<strong>{{ (productTotal&&(productTotal.totalCost || productTotal.totalCost==0)) ? toThousands(productTotal.totalCost) : '--' }}</strong>。</span>
  97. </div>
  98. </a-alert>
  99. <!-- 列表 -->
  100. <s-table
  101. class="sTable fixPagination"
  102. ref="table"
  103. :style="{ height: tableHeight+70+'px' }"
  104. size="small"
  105. :rowKey="(record) => record.id"
  106. :columns="columns"
  107. :data="loadData"
  108. :scroll="{ y: tableHeight }"
  109. :defaultLoadData="false"
  110. bordered>
  111. <!-- 数量 -->
  112. <template slot="qty" slot-scope="text, record">
  113. <p :class="record.flowType=='PUT' ? 'green':'red'" style="margin: 0;">
  114. <span v-if="record.qty!=0">{{ record.flowType=='PUT' ? '+':'-' }}</span>
  115. {{ record.qty }}
  116. </p>
  117. </template>
  118. <!-- 总售价 -->
  119. <template slot="totalAmount" slot-scope="text, record">
  120. <span v-if="record.bizType!='SPARE_PARTS_RETURN'"> {{ toThousands(record.totalPrice) }}</span>
  121. <span v-else>--</span>
  122. </template>
  123. </s-table>
  124. </a-card>
  125. </a-spin>
  126. </div>
  127. </template>
  128. <script>
  129. import { commonMixin } from '@/utils/mixin'
  130. import { STable, VSelect } from '@/components'
  131. import rangeDate from '@/views/common/rangeDate.vue'
  132. import { hdExportExcel } from '@/libs/exportExcel'
  133. import { stockFlowCount, stockFlowList, stockFlowExport } from '@/api/stock'
  134. export default {
  135. name: 'InventoryQueryWarehouseDetail',
  136. mixins: [commonMixin],
  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, // 仓库sn
  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, warehouseSn: this.$route.params.warehouseSn })
  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, // 导出按钮loading
  181. productTotal: null // 合计
  182. }
  183. },
  184. computed: {
  185. columns () {
  186. const _this = this
  187. const arr = [
  188. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  189. { title: '产品编码', dataIndex: 'productCode', width: '6%', align: 'left', customRender: function (text) { return text || '--' } },
  190. { title: '产品名称', dataIndex: 'productName', width: '10%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  191. { title: '原厂编码', dataIndex: 'productOrigCode', width: '6%', align: 'left', customRender: function (text) { return text || '--' } },
  192. { title: '批次号', dataIndex: 'stockBatchNo', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  193. { title: '单据类型', dataIndex: 'bizTypeDictValue', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  194. { title: '关联单号', dataIndex: 'bizNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  195. { title: '下推单号', dataIndex: 'bizSubNo', width: '10%', 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: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  198. { title: '仓库', dataIndex: 'warehouseName', width: '8%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  199. { title: '仓位', dataIndex: 'warehouseLocationName', width: '8%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  200. { title: '数量', scopedSlots: { customRender: 'qty' }, width: '5%', align: 'center' },
  201. // { title: '总成本', dataIndex: 'totalCost', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  202. // { title: '总售价', dataIndex: 'totalPrice', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  203. { title: '出入库状态', dataIndex: 'stateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } }
  204. ]
  205. if (this.$hasPermissions('B_inventoryQuery_rkDetail_costPrice')) { // 成本价权限
  206. arr.splice(13, 0, { title: '总成本', dataIndex: 'totalCost', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  207. }
  208. if (this.$hasPermissions('B_inventoryQuery_rkDetail_salesPrice')) { // 售价权限
  209. arr.splice(14, 0, { title: '总售价', width: '5%', align: 'right', scopedSlots: { customRender: 'totalAmount' } })
  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. this.$store.state.app.curActionPermission = 'B_inventoryQuery_rkDetail_export'
  248. const params = Object.assign(this.queryParam, { productSn: this.$route.params.sn, warehouseSn: this.$route.params.warehouseSn })
  249. this.exportLoading = true
  250. this.spinning = true
  251. hdExportExcel(stockFlowExport, params, '出入库明细', function () {
  252. _this.exportLoading = false
  253. _this.spinning = false
  254. _this.$store.state.app.curActionPermission = ''
  255. })
  256. },
  257. // 返回列表
  258. handleBack () {
  259. this.$router.push({ name: 'inventoryQueryList', query: { closeLastOldTab: true } })
  260. },
  261. pageInit () {
  262. const _this = this
  263. this.$nextTick(() => { // 页面渲染完成后的回调
  264. _this.setTableH()
  265. })
  266. },
  267. setTableH () {
  268. const tableSearchH = this.$refs.tableSearch.offsetHeight
  269. this.tableHeight = window.innerHeight - tableSearchH - 268
  270. }
  271. },
  272. watch: {
  273. advanced (newValue, oldValue) {
  274. const _this = this
  275. this.$nextTick(() => { // 页面渲染完成后的回调
  276. _this.setTableH()
  277. })
  278. },
  279. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  280. this.setTableH()
  281. }
  282. },
  283. mounted () {
  284. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  285. this.resetSearchForm()
  286. this.pageInit()
  287. }
  288. },
  289. activated () {
  290. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  291. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  292. this.resetSearchForm()
  293. this.pageInit()
  294. }
  295. },
  296. beforeRouteEnter (to, from, next) {
  297. next(vm => {})
  298. }
  299. }
  300. </script>
  301. <style lang="less">
  302. .inventoryQueryWarehouseDetail-wrap{
  303. .inventoryQueryWarehouseDetail-back{
  304. margin-bottom: 6px;
  305. }
  306. .inventoryQueryWarehouseDetail-cont{
  307. margin-bottom: 6px;
  308. }
  309. .green{
  310. color: #19be6b;
  311. }
  312. .red{
  313. color: #ed1c24;
  314. }
  315. }
  316. </style>