check.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. <template>
  2. <div class="supervisionDiskCheck-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" @back="handleBack" class="supervisionDiskCheck-cont" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="supervisionDiskCheck-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="supervisionDiskCheck-print-btn"
  20. :disabled="list.length==0"
  21. :loading="spinningPrint"
  22. v-if="$hasPermissions('B_supervisionDiskPrint')"
  23. @click="handlePdPrint">监盘打印</a-button>
  24. </template></a-page-header>
  25. <!-- 基础信息 -->
  26. <a-card size="small" :bordered="false" class="supervisionDiskCheck-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="supervisionDiskCheck-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.checkSuperviseQty || productTotal.checkSuperviseQty==0) ? productTotal.checkSuperviseQty : '--' }}</strong>,
  51. 监盘盈亏数量:<strong :style="{ color: productTotal && productTotal.profitLossQty>0?'red':productTotal && productTotal.profitLossQty<0?'green':'' }">{{ productTotal && (productTotal.profitLossQty || productTotal.profitLossQty==0) ? productTotal.profitLossQty : '--' }}</strong>
  52. </div>
  53. <div>
  54. <span style="color: red;display: inline-block;margin-right: 8px;">红色代表盘盈</span>
  55. <span style="color: green;">绿色代表盘亏</span>
  56. </div>
  57. </div>
  58. </div></a-alert>
  59. <!-- 搜索条件 -->
  60. <div class="table-page-search-wrapper">
  61. <a-row :gutter="15">
  62. <a-col :span="18">
  63. <a-form-model :model="queryParam" layout="inline" @keyup.enter.native="getList(1)" >
  64. <a-row :gutter="15">
  65. <a-col :md="8" :sm="24">
  66. <a-form-model-item label="产品编码">
  67. <a-input v-model.trim="queryParam.productCode" allowClear placeholder="输入产品编码" />
  68. </a-form-model-item>
  69. </a-col>
  70. <a-col :md="8" :sm="24">
  71. <a-button type="primary" @click="getList(1)" :disabled="disabled" id="supervisionDiskCheck-refresh">查询</a-button>
  72. <a-button style="margin-left: 5px" @click="resetSearchForm" id="supervisionDiskCheck-reset">重置</a-button>
  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;margin-top:6px;">
  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="checkSuperviseQty" slot-scope="text, record">
  99. <a-input-number
  100. size="small"
  101. id="supervisionDiskCheck-checkSuperviseQty"
  102. v-model="record.checkSuperviseQty"
  103. :precision="0"
  104. :min="0"
  105. :max="999999"
  106. placeholder="请输入"
  107. v-if="record.type=='superior'"
  108. @blur="e => checkSuperviseQtyBlur(e.target.value, record)"
  109. class="input-number"
  110. style="width: 100%;text-align: center;" />
  111. <span v-else>{{ record.checkSuperviseQty }}</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="default"
  135. id="supervisionDiskCheck-check-btn"
  136. size="large"
  137. class="button-primary"
  138. :disabled="spinning"
  139. @click="handleCheck"
  140. style="padding: 0 50px;">重新盘点</a-button>
  141. <a-button
  142. type="primary"
  143. id="supervisionDiskCheck-submit-btn"
  144. size="large"
  145. class="button-primary"
  146. :disabled="spinning"
  147. @click="handleSubmit"
  148. style="padding: 0 60px;margin-left: 15px">提交监盘</a-button>
  149. </div>
  150. <!-- 盘点打印确认 -->
  151. <print-modal :openModal="visiblePrint" nowType="CHECK_WAREHOUSE_SUPERVISE" :itemData="detail" @ok="handlePrint" @close="visiblePrint=false" />
  152. <div id="print"></div>
  153. </div>
  154. </template>
  155. <script>
  156. import { commonMixin } from '@/utils/mixin'
  157. import { STable, VSelect } from '@/components'
  158. import tablePagination from '@/views/common/tablePagination.vue'
  159. import printModal from '../makeInventory/printModal.vue'
  160. import { printFun } from '@/libs/JGPrint.js'
  161. import { checkWarehouseDetail, checkWarehouseDetailList, checkWarehouseDetailCount, checkWarehouseDetailPrint, checkWarehousePrintCheck, checkWarehouseDetailSave, checkWarehouseSupervise, checkWarehouseReCheck } from '@/api/checkWarehouse'
  162. export default {
  163. name: 'SupervisionDiskCheck',
  164. mixins: [commonMixin],
  165. components: { STable, VSelect, tablePagination, printModal },
  166. data () {
  167. return {
  168. spinning: false,
  169. disabled: false,
  170. loading: false,
  171. showDetail: false,
  172. queryParam: {
  173. productCode: ''
  174. },
  175. // 表头
  176. columns: [
  177. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  178. { title: '产品名称', dataIndex: 'productName', width: '16%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  179. { title: '单位', dataIndex: 'productUnit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  180. { title: '仓库', dataIndex: 'warehouseName', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  181. { title: '仓位', dataIndex: 'warehouseLocationName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  182. { title: '入库时间', dataIndex: 'lastStockTime', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  183. { title: '批次', dataIndex: 'stockBatchNo', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  184. { title: '产品编码', dataIndex: 'productCode', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  185. { title: '库存数量', dataIndex: 'stockQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  186. { title: '盘点数量', dataIndex: 'checkQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  187. { title: '监盘数量', dataIndex: 'checkSuperviseQty', width: '8%', scopedSlots: { customRender: 'checkSuperviseQty' }, align: 'center' },
  188. { title: '盈亏数量', dataIndex: 'profitLossQty', scopedSlots: { customRender: 'profitLossQty' }, width: '6%', align: 'center' }
  189. ],
  190. list: [],
  191. paginationProps: {
  192. total: 0, // 分页总条数
  193. current: 1,
  194. pageSize: 20
  195. },
  196. expandedRowKeys: [],
  197. detail: null, // 详情数据
  198. foldState: false, // 是否折叠列表
  199. productTotal: null, // 合计
  200. spinningPrint: false,
  201. visiblePrint: false
  202. }
  203. },
  204. methods: {
  205. // 返回列表
  206. handleBack () {
  207. this.$router.push({ path: '/inventoryManagement/supervisionDisk/list', query: { closeLastOldTab: true, isRefresh: true } })
  208. },
  209. // 重置
  210. resetSearchForm () {
  211. this.queryParam.productCode = ''
  212. this.getList(1)
  213. },
  214. // 盘点数量 blur
  215. checkSuperviseQtyBlur (val, record) {
  216. // 光标移出,值发生改变再调用编辑接口
  217. if (val != record.checkSuperviseQtyBackups) {
  218. this.handleEdit(record)
  219. }
  220. },
  221. // 编辑
  222. handleEdit (row) {
  223. const params = {
  224. checkWarehouseSn: this.$route.params.sn,
  225. productSn: row.productSn,
  226. reCheckSuperviseQty: row.checkSuperviseQty,
  227. stockQty: row.stockQty
  228. }
  229. // 清空数量时,值应保持未清空前的值,因数量不可为空
  230. if (!(row.checkSuperviseQty || row.checkSuperviseQty == 0)) {
  231. row.checkSuperviseQty = row.checkSuperviseQtyBackups
  232. return
  233. }
  234. this.spinning = true
  235. checkWarehouseDetailSave(params).then(res => {
  236. if (res.status == 200) {
  237. this.$message.success(res.message)
  238. this.getList()
  239. this.spinning = false
  240. } else {
  241. this.spinning = false
  242. }
  243. })
  244. },
  245. // 提交监盘
  246. handleSubmit () {
  247. const _this = this
  248. this.$confirm({
  249. title: '提示',
  250. content: '确认提交盘点吗?',
  251. centered: true,
  252. closable: true,
  253. onOk () {
  254. _this.spinning = true
  255. checkWarehouseSupervise({ checkWarehouseSn: _this.$route.params.sn }).then(res => {
  256. if (res.status == 200) {
  257. _this.$message.success(res.message)
  258. _this.handleBack()
  259. _this.spinning = false
  260. } else {
  261. _this.spinning = false
  262. }
  263. })
  264. }
  265. })
  266. },
  267. // 重新盘点
  268. handleCheck () {
  269. const _this = this
  270. this.$confirm({
  271. title: '提示',
  272. content: '确认要重新盘点吗?',
  273. centered: true,
  274. closable: true,
  275. onOk () {
  276. _this.spinning = true
  277. checkWarehouseReCheck({ checkWarehouseSn: _this.$route.params.sn }).then(res => {
  278. if (res.status == 200) {
  279. _this.$message.success(res.message)
  280. _this.handleBack()
  281. _this.spinning = false
  282. } else {
  283. _this.spinning = false
  284. }
  285. })
  286. }
  287. })
  288. },
  289. // 获取列表数据
  290. getList (pageNo) {
  291. this.disabled = true
  292. this.paginationProps.current = pageNo || this.paginationProps.current
  293. const params = {
  294. pageNo: this.paginationProps.current,
  295. pageSize: this.paginationProps.pageSize,
  296. checkWarehouseSn: this.$route.params.sn,
  297. productCode: this.queryParam.productCode
  298. }
  299. this.loading = true
  300. checkWarehouseDetailList(params).then(res => {
  301. this.loading = false
  302. if (res.status == 200) {
  303. this.getCount(params)
  304. const data = res.data
  305. this.paginationProps.total = Number(res.data.count) || 0
  306. this.paginationProps.current = data.pageNo
  307. const no = (data.pageNo - 1) * data.pageSize
  308. this.expandedRowKeys = []
  309. for (var i = 0; i < data.list.length; i++) {
  310. data.list[i].no = no + i + 1
  311. data.list[i].checkSuperviseQtyBackups = data.list[i].checkSuperviseQty
  312. if (!this.foldState) {
  313. this.expandedRowKeys.push(data.list[i].id + data.list[i].type)
  314. }
  315. }
  316. this.list = data.list
  317. this.disabled = false
  318. } else {
  319. this.paginationProps.total = 0
  320. this.paginationProps.current = 1
  321. this.paginationProps.pageSize = 20
  322. this.list = []
  323. }
  324. })
  325. },
  326. getCount (params) {
  327. checkWarehouseDetailCount(params).then(res => {
  328. if (res.status == 200) {
  329. this.productTotal = res.data
  330. } else {
  331. this.productTotal = null
  332. }
  333. })
  334. },
  335. // 分页 一页多少条change
  336. changePageSize (current, pageSize) {
  337. this.paginationProps.current = current
  338. this.paginationProps.pageSize = pageSize
  339. this.getList()
  340. },
  341. // 分页 页码change
  342. changePage (current) {
  343. this.paginationProps.current = current
  344. this.getList()
  345. },
  346. // 详情
  347. getDetail () {
  348. checkWarehouseDetail({ sn: this.$route.params.sn }).then(res => {
  349. if (res.status == 200) {
  350. this.detail = res.data
  351. } else {
  352. this.detail = null
  353. }
  354. })
  355. },
  356. // 展开收起
  357. handleExpand (expanded, record) {
  358. if (record.type == 'superior') { // 只处理父级
  359. if (expanded) {
  360. this.expandedRowKeys.push(record.id + record.type)
  361. } else {
  362. if (this.expandedRowKeys.length > 0) {
  363. const expandedRowKeys = this.expandedRowKeys.filter(RowKey => RowKey !== (record.id + record.type))
  364. this.expandedRowKeys = expandedRowKeys
  365. }
  366. }
  367. }
  368. },
  369. // 折叠列表
  370. foldStateChange (e) {
  371. if (e.target.checked) {
  372. this.expandedRowKeys = []
  373. } else {
  374. this.expandedRowKeys = []
  375. this.list.map(item => {
  376. this.expandedRowKeys.push(item.id + item.type)
  377. })
  378. }
  379. },
  380. // 盘点打印
  381. handlePdPrint () {
  382. this.spinning = true
  383. checkWarehousePrintCheck({ checkWarehouseSn: this.$route.params.sn, type: 'CHECK_WAREHOUSE_SUPERVISE' }).then(res => {
  384. this.spinning = false
  385. if (res.status == 200) {
  386. if (res.data && res.data == 0) { // 无产品
  387. this.$info({
  388. title: '提示',
  389. content: '打印模板内容是所有有盈亏的产品,此单盘点人盘点无盈亏记录,无法打印',
  390. centered: true
  391. })
  392. } else { // 有产品
  393. this.detail.printContent = '打印范围 —— 有盈亏(批次合并)'
  394. this.visiblePrint = true
  395. }
  396. }
  397. })
  398. },
  399. // 打印预览/快捷打印
  400. handlePrint (objs, type) {
  401. const _this = this
  402. _this.spinningPrint = true
  403. const params = { checkWarehouseSn: this.$route.params.sn, superviseFlag: true, ...objs }
  404. printFun(checkWarehouseDetailPrint, params, type, '盘点单', () => { _this.spinningPrint = false })
  405. }
  406. },
  407. mounted () {
  408. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  409. this.resetSearchForm()
  410. this.getDetail()
  411. }
  412. },
  413. activated () {
  414. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  415. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  416. this.resetSearchForm()
  417. this.getDetail()
  418. }
  419. },
  420. beforeRouteEnter (to, from, next) {
  421. next(vm => {})
  422. }
  423. }
  424. </script>
  425. <style lang="less">
  426. .supervisionDiskCheck-wrap{
  427. position: relative;
  428. height: 100%;
  429. padding-bottom: 51px;
  430. box-sizing: border-box;
  431. >.ant-spin-nested-loading{
  432. overflow-y: scroll;
  433. height: 100%;
  434. }
  435. .supervisionDiskCheck-cont{
  436. margin-bottom: 6px;
  437. .billno{
  438. font-size: 16px;
  439. font-weight: bold;
  440. margin: 0 15px;
  441. }
  442. .state-c{
  443. color: #ed1c24;
  444. font-size: 13px;
  445. font-weight: bold;
  446. }
  447. }
  448. .input-number{
  449. .ant-input-number-input{
  450. text-align: center;
  451. }
  452. }
  453. }
  454. </style>