check.vue 18 KB

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