check.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <div class="makeInventoryCheck-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" @back="handleBack" class="makeInventoryCheck-cont" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="makeInventoryCheck-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <span class="billno">单号:{{ detail&&detail.checkWarehouseNo }}</span>
  9. <a-button size="small" type="link" class="button-default" @click="showDetail=!showDetail">
  10. <a-icon :type="showDetail ? 'eye-invisible' : 'eye'"/> {{ showDetail?'隐藏':'查看' }}信息
  11. </a-button>
  12. </template>
  13. <!-- 操作区,位于 title 行的行尾 -->
  14. <template slot="extra">
  15. <a-button
  16. key="1"
  17. type="primary"
  18. class="button-info"
  19. id="makeInventoryCheck-print-btn"
  20. :disabled="list.length==0"
  21. :loading="spinningPrint"
  22. v-if="$hasPermissions('B_inventoryMakeInventoryPrint')"
  23. @click="handlePdPrint">盘点打印</a-button>
  24. </template></a-page-header>
  25. <!-- 基础信息 -->
  26. <a-card size="small" :bordered="false" class="makeInventoryCheck-cont" v-show="showDetail">
  27. <a-descriptions :column="3">
  28. <a-descriptions-item label="创建人">{{ (detail&&detail.creatorName) || '--' }}</a-descriptions-item>
  29. <a-descriptions-item label="创建时间">{{ (detail&&detail.createDate) || '--' }}</a-descriptions-item>
  30. <a-descriptions-item label="盘点类型">{{ (detail&&detail.checkTypeDictValue) || '--' }}</a-descriptions-item>
  31. <a-descriptions-item label="盘点状态">{{ (detail&&detail.checkStateDictValue) || '--' }}</a-descriptions-item>
  32. <a-descriptions-item label="仓库">{{ (detail&&detail.warehouseName) || '--' }}</a-descriptions-item>
  33. <a-descriptions-item label="盘点人">{{ (detail&&detail.checkPersonName) || '--' }}</a-descriptions-item>
  34. <a-descriptions-item label="盘点时间">{{ (detail&&detail.checkTime) || '--' }}</a-descriptions-item>
  35. <a-descriptions-item label="监盘状态">{{ (detail&&detail.checkSuperviseStateDictValue) || '--' }}</a-descriptions-item>
  36. <a-descriptions-item label="监盘人">{{ (detail&&detail.checkSupervisePersonName) || '--' }}</a-descriptions-item>
  37. <a-descriptions-item label="监盘时间">{{ (detail&&detail.checkSuperviseTime) || '--' }}</a-descriptions-item>
  38. <a-descriptions-item label="财务确认时间">{{ (detail&&detail.financeAuditTime) || '--' }}</a-descriptions-item>
  39. </a-descriptions>
  40. </a-card>
  41. <!-- 产品详情 -->
  42. <a-card size="small" :bordered="false" class="makeInventoryCheck-cont">
  43. <!-- 总计 -->
  44. <a-alert type="info" style="margin-bottom:10px">
  45. <div slot="message">
  46. <div style="display: flex;justify-content: space-between;align-items: center;">
  47. <div>
  48. 库存数量:<strong>{{ productTotal && (productTotal.stockQty || productTotal.stockQty==0) ? productTotal.stockQty : '--' }}</strong>,
  49. 盘点数量:<strong>{{ productTotal && (productTotal.checkQty || productTotal.checkQty==0) ? productTotal.checkQty : '--' }}</strong>,
  50. 盘点盈亏数量:<strong>{{ productTotal && (productTotal.profitLossQty || productTotal.profitLossQty==0) ? productTotal.profitLossQty : '--' }}</strong>
  51. </div>
  52. <div>
  53. <span style="color: red;display: inline-block;margin-right: 8px;">红色代表盘盈</span>
  54. <span style="color: green;">绿色代表盘亏</span>
  55. </div>
  56. </div>
  57. </div></a-alert>
  58. <!-- 搜索条件 -->
  59. <div class="table-page-search-wrapper">
  60. <a-row :gutter="15">
  61. <a-col :span="18">
  62. <a-form-model :model="queryParam" layout="inline" @keyup.enter.native="getList(1)" >
  63. <a-row :gutter="15">
  64. <a-col :md="8" :sm="24">
  65. <a-form-model-item label="产品编码">
  66. <a-input v-model.trim="queryParam.productCode" allowClear placeholder="输入产品编码" />
  67. </a-form-model-item>
  68. </a-col>
  69. <a-col :md="8" :sm="24">
  70. <a-button type="primary" @click="getList(1)" :disabled="disabled" id="makeInventoryCheck-refresh">查询</a-button>
  71. <a-button style="margin-left: 5px" @click="resetSearchForm" id="makeInventoryCheck-reset">重置</a-button>
  72. </a-col>
  73. </a-row>
  74. </a-form-model>
  75. </a-col>
  76. <a-col :span="6">
  77. <div style="float:right;overflow: hidden;margin-top:6px;">
  78. <a-checkbox v-model="foldState" @change="foldStateChange"><span style="display: inline-block;margin-top: 1px;">折叠列表</span></a-checkbox>
  79. </div>
  80. </a-col>
  81. </a-row>
  82. </div>
  83. <!-- 列表 -->
  84. <a-table
  85. class="sTable"
  86. ref="table"
  87. size="small"
  88. :rowKey="(record) => record.id + record.type"
  89. :columns="columns"
  90. :pagination="false"
  91. :data-source="list"
  92. :loading="loading"
  93. @expand="handleExpand"
  94. :expandedRowKeys="expandedRowKeys"
  95. bordered>
  96. <!-- 数量 -->
  97. <template slot="checkQty" slot-scope="text, record">
  98. <a-input-number
  99. size="small"
  100. id="makeInventoryCheck-checkQty"
  101. v-model="record.checkQty"
  102. :precision="0"
  103. :min="0"
  104. :max="99999999"
  105. placeholder="请输入"
  106. v-if="record.type=='superior'"
  107. @blur="e => checkQtyBlur(e.target.value, record)"
  108. class="input-number"
  109. style="width: 100%;text-align: center;" />
  110. <span v-else>{{ record.checkQty }}</span>
  111. </template>
  112. <!-- 盈亏数量 -->
  113. <template slot="profitLossQty" slot-scope="text, record">
  114. <span v-if="record.type=='superior'" :style="{ color: record.profitLossQty>0?'red':record.profitLossQty<0?'green':'', fontWeight: record.profitLossQty!=0?'bold':'' }">
  115. {{ record.profitLossQty>0?'盘盈':record.profitLossQty<0?'盘亏':'' }}
  116. {{ (record.profitLossQty || record.profitLossQty==0) ? Math.abs(record.profitLossQty) : '--' }}
  117. </span>
  118. <span v-else></span>
  119. </template>
  120. </a-table>
  121. <!-- 分页 -->
  122. <tablePagination
  123. ref="tablePagination"
  124. :total="paginationProps.total"
  125. :current="paginationProps.current"
  126. :pageSize="paginationProps.pageSize"
  127. @changePageSize="changePageSize"
  128. @changePage="changePage" />
  129. </a-card>
  130. </a-spin>
  131. <div class="affix-cont">
  132. <a-button
  133. type="primary"
  134. id="makeInventoryCheck-submit-btn"
  135. size="large"
  136. class="button-primary"
  137. :disabled="spinning"
  138. @click="handleSubmit"
  139. style="padding: 0 60px;">提交盘点</a-button>
  140. </div>
  141. <!-- 盘点打印确认 -->
  142. <print-modal :openModal="visiblePrint" nowType="CHECK_WAREHOUSE" :itemData="detail" @ok="handlePrint" @close="visiblePrint=false" />
  143. <div id="print"></div>
  144. </div>
  145. </template>
  146. <script>
  147. import { commonMixin } from '@/utils/mixin'
  148. import { STable, VSelect } from '@/components'
  149. import tablePagination from '@/views/common/tablePagination.vue'
  150. import printModal from './printModal.vue'
  151. import { printFun } from '@/libs/JGPrint.js'
  152. import { checkWarehouseDetail, checkWarehouseDetailList, checkWarehouseDetailCount, checkWarehouseDetailPrint, checkWarehousePrintCheck, checkWarehouseDetailSave, checkWarehouseCheck } from '@/api/checkWarehouse'
  153. export default {
  154. name: 'MakeInventoryCheck',
  155. mixins: [commonMixin],
  156. components: { STable, VSelect, tablePagination, printModal },
  157. data () {
  158. return {
  159. spinning: false,
  160. disabled: false,
  161. loading: false,
  162. showDetail: false,
  163. queryParam: {
  164. productCode: ''
  165. },
  166. // 表头
  167. columns: [
  168. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  169. { title: '产品名称', dataIndex: 'productName', width: '16%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  170. { title: '单位', dataIndex: 'productUnit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  171. { title: '仓库', dataIndex: 'warehouseName', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  172. { title: '仓位', dataIndex: 'warehouseLocationName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  173. { title: '入库时间', dataIndex: 'lastStockTime', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  174. { title: '批次', dataIndex: 'stockBatchNo', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  175. { title: '产品编码', dataIndex: 'productCode', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  176. { title: '库存数量', dataIndex: 'stockQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  177. { title: '盘点数量', dataIndex: 'checkQty', scopedSlots: { customRender: 'checkQty' }, width: '6%', align: 'center' },
  178. { title: '盈亏数量', dataIndex: 'profitLossQty', scopedSlots: { customRender: 'profitLossQty' }, width: '6%', align: 'center' }
  179. ],
  180. list: [],
  181. paginationProps: {
  182. total: 0, // 分页总条数
  183. current: 1,
  184. pageSize: 20
  185. },
  186. expandedRowKeys: [],
  187. detail: null, // 详情数据
  188. foldState: false, // 是否折叠列表
  189. productTotal: null, // 合计
  190. spinningPrint: false,
  191. visiblePrint: false
  192. }
  193. },
  194. methods: {
  195. // 返回列表
  196. handleBack () {
  197. this.$router.push({ path: '/inventoryManagement/makeInventory/list', query: { closeLastOldTab: true, isRefresh: true } })
  198. },
  199. // 重置
  200. resetSearchForm () {
  201. this.queryParam.productCode = ''
  202. this.getList(1)
  203. },
  204. // 盘点数量 blur
  205. checkQtyBlur (val, record) {
  206. // 光标移出,值发生改变再调用编辑接口
  207. if (val != record.checkQtyBackups) {
  208. this.handleEdit(record)
  209. }
  210. },
  211. // 编辑
  212. handleEdit (row) {
  213. const params = {
  214. checkWarehouseSn: this.$route.params.sn,
  215. productSn: row.productSn,
  216. reCheckQty: row.checkQty,
  217. stockQty: row.stockQty
  218. }
  219. // 清空数量时,值应保持未清空前的值,因数量不可为空
  220. if (!(row.checkQty || row.checkQty == 0)) {
  221. row.checkQty = row.checkQtyBackups
  222. return
  223. }
  224. this.spinning = true
  225. checkWarehouseDetailSave(params).then(res => {
  226. if (res.status == 200) {
  227. this.$message.success(res.message)
  228. this.getList()
  229. this.spinning = false
  230. } else {
  231. this.spinning = false
  232. }
  233. })
  234. },
  235. // 提交盘点
  236. handleSubmit () {
  237. const _this = this
  238. this.$confirm({
  239. title: '提示',
  240. content: '确认提交盘点吗?',
  241. centered: true,
  242. closable: true,
  243. onOk () {
  244. _this.spinning = true
  245. checkWarehouseCheck({ checkWarehouseSn: _this.$route.params.sn }).then(res => {
  246. if (res.status == 200) {
  247. _this.$message.success(res.message)
  248. _this.handleBack()
  249. _this.spinning = false
  250. } else {
  251. _this.spinning = false
  252. }
  253. })
  254. }
  255. })
  256. },
  257. // 获取列表数据
  258. getList (pageNo) {
  259. this.disabled = true
  260. this.paginationProps.current = pageNo || this.paginationProps.current
  261. const params = {
  262. pageNo: this.paginationProps.current,
  263. pageSize: this.paginationProps.pageSize,
  264. checkWarehouseSn: this.$route.params.sn,
  265. productCode: this.queryParam.productCode
  266. }
  267. this.loading = true
  268. checkWarehouseDetailList(params).then(res => {
  269. this.loading = false
  270. if (res.status == 200) {
  271. this.getCount(params)
  272. const data = res.data
  273. this.paginationProps.total = Number(res.data.count) || 0
  274. this.paginationProps.current = data.pageNo
  275. const no = (data.pageNo - 1) * data.pageSize
  276. this.expandedRowKeys = []
  277. for (var i = 0; i < data.list.length; i++) {
  278. data.list[i].no = no + i + 1
  279. data.list[i].checkQtyBackups = data.list[i].checkQty
  280. if (!this.foldState) {
  281. this.expandedRowKeys.push(data.list[i].id + data.list[i].type)
  282. }
  283. }
  284. this.list = data.list
  285. this.disabled = false
  286. } else {
  287. this.paginationProps.total = 0
  288. this.paginationProps.current = 1
  289. this.paginationProps.pageSize = 20
  290. this.list = []
  291. }
  292. })
  293. },
  294. getCount (params) {
  295. checkWarehouseDetailCount(params).then(res => {
  296. if (res.status == 200) {
  297. this.productTotal = res.data
  298. } else {
  299. this.productTotal = null
  300. }
  301. })
  302. },
  303. // 分页 一页多少条change
  304. changePageSize (current, pageSize) {
  305. this.paginationProps.current = current
  306. this.paginationProps.pageSize = pageSize
  307. this.getList()
  308. },
  309. // 分页 页码change
  310. changePage (current) {
  311. this.paginationProps.current = current
  312. this.getList()
  313. },
  314. // 详情
  315. getDetail () {
  316. checkWarehouseDetail({ sn: this.$route.params.sn }).then(res => {
  317. if (res.status == 200) {
  318. this.detail = res.data
  319. } else {
  320. this.detail = null
  321. }
  322. })
  323. },
  324. // 展开收起
  325. handleExpand (expanded, record) {
  326. if (record.type == 'superior') { // 只处理父级
  327. if (expanded) {
  328. this.expandedRowKeys.push(record.id + record.type)
  329. } else {
  330. if (this.expandedRowKeys.length > 0) {
  331. const expandedRowKeys = this.expandedRowKeys.filter(RowKey => RowKey !== (record.id + record.type))
  332. this.expandedRowKeys = expandedRowKeys
  333. }
  334. }
  335. }
  336. },
  337. // 折叠列表
  338. foldStateChange (e) {
  339. if (e.target.checked) {
  340. this.expandedRowKeys = []
  341. } else {
  342. this.expandedRowKeys = []
  343. this.list.map(item => {
  344. this.expandedRowKeys.push(item.id + item.type)
  345. })
  346. }
  347. },
  348. // 盘点打印
  349. handlePdPrint () {
  350. this.spinning = true
  351. checkWarehousePrintCheck({ checkWarehouseSn: this.$route.params.sn, type: 'CHECK_WAREHOUSE' }).then(res => {
  352. this.spinning = false
  353. if (res.status == 200) {
  354. if (res.data && res.data == 0) { // 无产品
  355. this.$info({
  356. title: '提示',
  357. content: '此盘点单没有产品,无法打印',
  358. centered: true
  359. })
  360. } else { // 有产品
  361. this.detail.printContent = '打印范围 —— 所有盘点产品(批次合并)'
  362. this.visiblePrint = true
  363. }
  364. }
  365. })
  366. },
  367. // 打印预览/快捷打印
  368. handlePrint (objs, type) {
  369. const _this = this
  370. _this.spinningPrint = true
  371. const params = { checkWarehouseSn: this.$route.params.sn, superviseFlag: false, ...objs }
  372. printFun(checkWarehouseDetailPrint, params, type, '盘点单', () => { _this.spinningPrint = false })
  373. }
  374. },
  375. mounted () {
  376. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  377. this.resetSearchForm()
  378. this.getDetail()
  379. }
  380. },
  381. activated () {
  382. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  383. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  384. this.resetSearchForm()
  385. this.getDetail()
  386. }
  387. },
  388. beforeRouteEnter (to, from, next) {
  389. next(vm => {})
  390. }
  391. }
  392. </script>
  393. <style lang="less">
  394. .makeInventoryCheck-wrap{
  395. position: relative;
  396. height: 100%;
  397. padding-bottom: 51px;
  398. box-sizing: border-box;
  399. >.ant-spin-nested-loading{
  400. overflow-y: scroll;
  401. height: 100%;
  402. }
  403. .makeInventoryCheck-cont{
  404. margin-bottom: 6px;
  405. .billno{
  406. font-size: 16px;
  407. font-weight: bold;
  408. margin: 0 15px;
  409. }
  410. .state-c{
  411. color: #ed1c24;
  412. font-size: 13px;
  413. font-weight: bold;
  414. }
  415. }
  416. .input-number{
  417. .ant-input-number-input{
  418. text-align: center;
  419. }
  420. }
  421. }
  422. </style>