makeInventory.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. <template>
  2. <div class="inventoryCheckMakeInventoryList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="inventoryCheckMakeInventoryList-back" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="inventoryCheckMakeInventoryList-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <span class="billno">单号:{{ basicInfoData&&basicInfoData.checkWarehouseNo }}</span>
  9. <a-tag color="blue">{{ basicInfoData&&basicInfoData.stateDictValue }}</a-tag>
  10. </template>
  11. <template slot="extra" v-if="$hasPermissions('B_inventoryCheckingPrint')">
  12. <a-radio-group v-model="printerType">
  13. <a-radio value="NEEDLE">针式</a-radio>
  14. <a-radio value="INK">喷墨</a-radio>
  15. </a-radio-group>
  16. <a-button
  17. type="primary"
  18. class="button-error"
  19. id="inventoryCheckingDetail-pd-print-btn"
  20. :disabled="localDataSource.length==0"
  21. @click="handlePrint('pddy')">盘点打印</a-button>
  22. <a-button
  23. type="primary"
  24. class="button-info"
  25. id="inventoryCheckingDetail-sh-print-btn"
  26. :disabled="localDataSource.length==0"
  27. @click="handlePrint('shdy')">审核打印</a-button>
  28. <a-button
  29. type="primary"
  30. class="button-warning"
  31. id="inventoryCheckingDetail-export-btn"
  32. :disabled="localDataSource.length==0"
  33. @click="handleExport('export')">导出Excel</a-button>
  34. </template>
  35. </a-page-header>
  36. <!-- 基础信息 -->
  37. <a-card size="small" :bordered="false" class="inventoryCheckMakeInventoryList-cont">
  38. <a-collapse defaultActiveKey="1">
  39. <a-collapse-panel key="1" header="基础信息">
  40. <a-descriptions :column="3">
  41. <a-descriptions-item label="盘点类型">{{ (basicInfoData&&basicInfoData.checkTypeDictValue) || '--' }}</a-descriptions-item>
  42. <a-descriptions-item label="是否区分仓库" v-if="basicInfoData&&basicInfoData.checkType=='SELECT'">{{ (basicInfoData&&basicInfoData.warehouseFlagDictValue) || '--' }}</a-descriptions-item>
  43. <a-descriptions-item label="盘点仓库" v-if="basicInfoData&&basicInfoData.warehouseFlag=='1'">{{ (basicInfoData&&basicInfoData.warehouseNameList) || '--' }}</a-descriptions-item>
  44. <a-descriptions-item label="创建人">{{ (basicInfoData&&basicInfoData.creatorName) || '--' }}</a-descriptions-item>
  45. <a-descriptions-item label="创建时间">{{ (basicInfoData&&basicInfoData.createDate) || '--' }}</a-descriptions-item>
  46. <a-descriptions-item label="审核时间">{{ (basicInfoData&&basicInfoData.checkSuperviseTime) || '--' }}</a-descriptions-item>
  47. </a-descriptions>
  48. </a-collapse-panel>
  49. </a-collapse>
  50. </a-card>
  51. <a-card size="small" :bordered="false" class="inventoryCheckMakeInventoryList-cont">
  52. <!-- 总计 -->
  53. <a-alert type="info" style="margin-bottom:10px">
  54. <div slot="message">
  55. <div style="display: flex;justify-content: space-between;align-items: center;">
  56. <div>
  57. 总款数: <strong>{{ productTotal&&(productTotal.totalCategory || productTotal.totalCategory==0) ? productTotal.totalCategory : '--' }}</strong> ,
  58. 总数量: <strong>{{ productTotal&&(productTotal.stockQty || productTotal.stockQty==0) ? productTotal.stockQty : '--' }}</strong> ,
  59. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  60. 总成本: <strong>{{ productTotal&&(productTotal.checkCost || productTotal.checkCost==0) ? '¥'+productTotal.checkCost : '--' }}</strong> ,
  61. </div>
  62. 盘盈数量: <strong>{{ productTotal&&(productTotal.checkProfitQty || productTotal.checkProfitQty==0) ? productTotal.checkProfitQty : '--' }}</strong> ,
  63. 盘亏数量: <strong>{{ productTotal&&(productTotal.checkLossQty || productTotal.checkLossQty==0) ? productTotal.checkLossQty : '--' }}</strong>
  64. </div>
  65. <div>
  66. <span style="color: red;display: inline-block;margin-right: 8px;">红色代表盘盈</span>
  67. <span style="color: green;">绿色代表盘亏</span>
  68. </div>
  69. </div>
  70. </div>
  71. </a-alert>
  72. <!-- 筛选条件 -->
  73. <div class="table-page-search-wrapper">
  74. <a-row :gutter="15">
  75. <a-col :span="19">
  76. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  77. <a-row :gutter="15">
  78. <a-col :md="6" :sm="24">
  79. <a-form-item label="产品编码" prop="productCode">
  80. <a-input id="inventoryCheckMakeInventoryList-productCode" v-model.trim="queryParam.productCode" placeholder="请输入" allowClear />
  81. </a-form-item>
  82. </a-col>
  83. <a-col :md="6" :sm="24">
  84. <a-form-item label="产品名称" prop="productName">
  85. <a-input id="inventoryCheckMakeInventoryList-productName" v-model.trim="queryParam.productName" placeholder="请输入" allowClear />
  86. </a-form-item>
  87. </a-col>
  88. <a-col :md="6" :sm="24">
  89. <a-form-item label="产品分类">
  90. <ProductType id="inventoryCheckMakeInventoryList-productType" @change="changeProductType" v-model="productType"></ProductType>
  91. </a-form-item>
  92. </a-col>
  93. <template v-if="advanced && (basicInfoData&&basicInfoData.warehouseFlag=='1')">
  94. <a-col :md="6" :sm="24" v-if="basicInfoData&&basicInfoData.warehouseFlag=='1'">
  95. <a-form-item label="仓库">
  96. <a-select id="inventoryCheckMakeInventoryList-warehouseSn" allowClear placeholder="请选择仓库" v-model="queryParam.warehouseSn" >
  97. <a-select-option v-for="item in warehouseList" :key="item.warehouseSn" :value="item.warehouseSn">{{ item.name }}</a-select-option>
  98. </a-select>
  99. </a-form-item>
  100. </a-col>
  101. </template>
  102. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  103. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="inventoryCheckMakeInventoryList-refresh">查询</a-button>
  104. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="inventoryCheckMakeInventoryList-reset">重置</a-button>
  105. <a @click="advanced=!advanced" style="margin-left: 5px" v-if="basicInfoData&&basicInfoData.warehouseFlag=='1'">
  106. {{ advanced ? '收起' : '展开' }}
  107. <a-icon :type="advanced ? 'up' : 'down'"/>
  108. </a>
  109. </a-col>
  110. </a-row>
  111. </a-form>
  112. </a-col>
  113. <a-col :span="5">
  114. <div style="float:right;overflow: hidden;">
  115. <a-button size="small" type="primary" class="button-info" id="inventoryCheckMakeInventoryList-checkZero-btn" @click="handleCheckZero">整单盘零</a-button>
  116. </div>
  117. </a-col>
  118. </a-row>
  119. </div>
  120. <!-- 列表 -->
  121. <s-table
  122. class="sTable"
  123. ref="table"
  124. size="small"
  125. :rowKey="(record) => record.id"
  126. :columns="columns"
  127. :data="loadData"
  128. :defaultLoadData="false"
  129. bordered>
  130. <!-- 产品分类 -->
  131. <template slot="productType" slot-scope="text, record">
  132. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  133. <span v-else>--</span>
  134. </template>
  135. <!-- 数量 -->
  136. <template slot="checkQty" slot-scope="text, record">
  137. <a-input-number
  138. size="small"
  139. id="inventoryCheckMakeInventoryList-choose-checkQty"
  140. v-model="record.checkQty"
  141. :precision="0"
  142. :min="0"
  143. :max="999999"
  144. placeholder="请输入"
  145. @blur="e => checkQtyBlur(e.target.value, record)"
  146. style="width: 100%;" />
  147. </template>
  148. <!-- 盈亏数量 -->
  149. <template slot="checkProfitLossQty" slot-scope="text, record">
  150. <span :style="{ color: record.checkProfitLossQty>0?'red':record.checkProfitLossQty<0?'green':'', fontWeight: record.checkProfitLossQty!=0?'bold':'' }">{{ (record.checkProfitLossQty || record.checkProfitLossQty==0) ? Math.abs(record.checkProfitLossQty) : '--' }}</span>
  151. </template>
  152. </s-table>
  153. </a-card>
  154. </a-spin>
  155. <div class="affix-cont">
  156. <a-button
  157. type="primary"
  158. id="inventoryCheckMakeInventoryList-submit"
  159. size="large"
  160. :disabled="spinning"
  161. class="button-primary"
  162. @click="handleSubmit"
  163. style="padding: 0 60px;">盘点完成</a-button>
  164. </div>
  165. <!-- 打印导出 -->
  166. <print-modal :openModal="openPrintModal" :itemData="basicInfoData" :nowType="nowType" @ok="handleOk" @close="openPrintModal=false" />
  167. <!-- 打印 -->
  168. <div id="print"></div>
  169. <!-- 导出选择弹框 -->
  170. <a-modal
  171. v-model="exportShow"
  172. :footer="null"
  173. :maskClosable="false"
  174. centered
  175. title="导出excel"
  176. @cancel="exportShow=false"
  177. >
  178. <div style="line-height: 48px;padding: 0 30px;">
  179. <div>盘点单号:{{ basicInfoData&&basicInfoData.checkWarehouseNo }}</div>
  180. <div>盘点类型:{{ (basicInfoData&&basicInfoData.checkTypeDictValue) || '--' }}
  181. <span v-if="basicInfoData&&basicInfoData.checkType=='SELECT'">({{ (basicInfoData&&basicInfoData.warehouseFlagDictValue) || '--' }})</span>
  182. </div>
  183. <div>产品范围:
  184. <a-radio-group v-model="productScopeFlag">
  185. <a-radio :value="true">
  186. 所有盘点产品
  187. </a-radio>
  188. <a-radio :value="false">
  189. 有盈亏的产品
  190. </a-radio>
  191. </a-radio-group>
  192. </div>
  193. <div class="btn-cont" style="text-align: center;padding-top: 40px;">
  194. <a-button id="inventoryChecking-export-save" @click="exportShow=false">取消</a-button>
  195. <a-button type="primary" id="inventoryChecking-export-back" @click="handlePrint('export')" style="margin-left: 15px;">确定导出</a-button>
  196. </div>
  197. </div>
  198. </a-modal>
  199. </div>
  200. </template>
  201. <script>
  202. import { commonMixin } from '@/utils/mixin'
  203. import { STable, VSelect } from '@/components'
  204. import ProductType from '@/views/common/productType.js'
  205. import printModal from './printModal.vue'
  206. import { hdPrint } from '@/libs/JGPrint.js'
  207. import { checkWarehouseDetailList, checkWarehouseDetailCount, checkWarehouseInventory, checkWarehouseDetail, checkWarehouseDetailSave, checkWarehouseCheckZero, checkWarehouseWarehouse, checkWarehouseDetailExport, checkWarehouseDetailPrint } from '@/api/checkWarehouse'
  208. export default {
  209. name: 'MakeInventory',
  210. components: { STable, VSelect, ProductType, printModal },
  211. mixins: [commonMixin],
  212. props: {},
  213. data () {
  214. return {
  215. spinning: false,
  216. disabled: false,
  217. advanced: false,
  218. exportShow: false,
  219. queryParam: {
  220. productName: '',
  221. productCode: '',
  222. productTypeSn1: undefined,
  223. productTypeSn2: undefined,
  224. productTypeSn3: undefined,
  225. warehouseSn: undefined
  226. },
  227. basicInfoData: null, // 基础信息
  228. productTotal: null,
  229. // 加载数据方法 必须为 Promise 对象
  230. loadData: parameter => {
  231. this.disabled = true
  232. this.spinning = true
  233. return checkWarehouseDetailList(Object.assign(parameter, this.queryParam, { checkWarehouseSn: this.$route.params.sn })).then(res => {
  234. let data
  235. if (res.status == 200) {
  236. data = res.data
  237. const no = (data.pageNo - 1) * data.pageSize
  238. for (var i = 0; i < data.list.length; i++) {
  239. data.list[i].no = no + i + 1
  240. data.list[i].checkQtyBackups = data.list[i].checkQty
  241. }
  242. this.localDataSource = data.list || []
  243. this.getProduceTotal()
  244. this.disabled = false
  245. }
  246. this.spinning = false
  247. return data
  248. })
  249. },
  250. productType: [],
  251. warehouseList: [], // 仓库 下拉数据
  252. localDataSource: [],
  253. openPrintModal: false,
  254. nowType: null,
  255. printerType: 'NEEDLE', // 打印机类型
  256. productScopeFlag: true
  257. }
  258. },
  259. computed: {
  260. columns () {
  261. const arr = [
  262. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  263. { title: '产品编码', dataIndex: 'productCode', width: '21%', align: 'center', customRender: function (text) { return text || '--' } },
  264. { title: '产品名称', dataIndex: 'productName', width: '21%', align: 'left', customRender: function (text) { return text || '--' } },
  265. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '14%' },
  266. { title: '单位', dataIndex: 'productUnit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  267. { title: '库存数量', dataIndex: 'stockQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  268. { title: '盘点数量', scopedSlots: { customRender: 'checkQty' }, width: '8%', align: 'center' },
  269. { title: '盈亏数量', scopedSlots: { customRender: 'checkProfitLossQty' }, width: '8%', align: 'center' }
  270. ]
  271. if (this.basicInfoData && this.basicInfoData.warehouseFlag == '1') {
  272. arr.splice(4, 0, { title: '仓库', dataIndex: 'warehouseName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } })
  273. }
  274. return arr
  275. }
  276. },
  277. methods: {
  278. // 重置
  279. resetSearchForm () {
  280. this.productScopeFlag = true
  281. this.queryParam.productName = ''
  282. this.queryParam.productCode = ''
  283. this.queryParam.warehouseSn = undefined
  284. this.queryParam.productTypeSn1 = undefined
  285. this.queryParam.productTypeSn2 = undefined
  286. this.queryParam.productTypeSn3 = undefined
  287. this.productType = []
  288. this.$refs.table.refresh(true)
  289. },
  290. // 盘点完成
  291. handleSubmit () {
  292. const _this = this
  293. _this.spinning = true
  294. checkWarehouseInventory({ id: this.$route.params.id }).then(res => {
  295. if (res.status == 200) {
  296. this.$message.success(res.message)
  297. setTimeout(() => {
  298. _this.handleBack()
  299. _this.spinning = false
  300. }, 1000)
  301. } else {
  302. _this.spinning = false
  303. }
  304. })
  305. },
  306. // 数量 blur
  307. checkQtyBlur (val, record) {
  308. if ((val != record.checkQtyBackups) || (!val && record.checkQtyBackups == 0)) {
  309. this.handleAdd(record, 'edit')
  310. }
  311. },
  312. // 添加/编辑
  313. handleAdd (row, isEdit) {
  314. if (!isEdit && !row.checkQty) {
  315. this.$message.warning('请输入盘点数量!')
  316. return
  317. }
  318. const params = {
  319. checkWarehouseSn: this.$route.params.sn,
  320. id: row.id,
  321. checkCost: row.checkCost,
  322. checkQty: row.checkQty,
  323. productSn: row.productSn,
  324. productCode: row.productCode,
  325. productOrigCode: row.productOrigCode || undefined,
  326. productTypeSn1: row.productTypeSn1,
  327. productTypeSn2: row.productTypeSn2,
  328. productTypeSn3: row.productTypeSn3,
  329. brandSn: row.brandSn,
  330. stockQty: row.stockQty,
  331. lastStockTime: row.lastStockTime,
  332. checkProfitLossCost: row.checkProfitLossCost,
  333. stockBatchNo: row.stockBatchNo || undefined,
  334. productProduceDate: row.productProduceDate || undefined,
  335. productExpiryDate: row.productExpiryDate || undefined,
  336. warehouseSn: row.warehouseSn || undefined,
  337. warehouseLocationSn: row.warehouseLocationSn || undefined
  338. }
  339. if (isEdit) { // 编辑
  340. // 清空数量时,值应保持未清空前的值,因数量都不可为空
  341. if (!(row.checkQty || row.checkQty == 0)) {
  342. row.checkQty = row.checkQtyBackups
  343. return
  344. }
  345. }
  346. this.spinning = true
  347. checkWarehouseDetailSave(params).then(res => {
  348. if (res.status == 200) {
  349. this.$message.success(res.message)
  350. this.$refs.table.refresh()
  351. this.spinning = false
  352. } else {
  353. this.spinning = false
  354. }
  355. })
  356. },
  357. // 整单盘零
  358. handleCheckZero () {
  359. const _this = this
  360. this.$confirm({
  361. title: '提示',
  362. content: '确定要进行 整单盘零 操作吗?',
  363. centered: true,
  364. onOk () {
  365. _this.spinning = true
  366. checkWarehouseCheckZero({ checkWarehouseSn: _this.$route.params.sn }).then(res => {
  367. if (res.status == 200) {
  368. _this.$message.success(res.message)
  369. _this.$refs.table.refresh(true)
  370. _this.spinning = false
  371. } else {
  372. _this.spinning = false
  373. }
  374. })
  375. }
  376. })
  377. },
  378. // 返回列表
  379. handleBack () {
  380. this.$router.push({ path: '/inventoryManagement/inventoryChecking/list' })
  381. },
  382. // 查询基础信息
  383. getDetail () {
  384. checkWarehouseDetail({ sn: this.$route.params.sn }).then(res => {
  385. if (res.status == 200 && res.data) {
  386. this.basicInfoData = res.data
  387. this.warehouseList = res.data.warehouseList || []
  388. } else {
  389. this.basicInfoData = null
  390. this.warehouseList = []
  391. }
  392. })
  393. },
  394. // 已选产品总计查询
  395. getProduceTotal () {
  396. checkWarehouseDetailCount(Object.assign(this.queryParam, { checkWarehouseSn: this.$route.params.sn })).then(res => {
  397. if (res.status == 200) {
  398. this.productTotal = res.data
  399. } else {
  400. this.productTotal = null
  401. }
  402. })
  403. },
  404. // 产品分类 change
  405. changeProductType (val, opt) {
  406. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  407. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  408. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  409. },
  410. handleExport () {
  411. this.exportShow = true
  412. },
  413. // 打印导出
  414. handlePrint (type) {
  415. if (type == 'export') {
  416. this.exportShow = false
  417. this.nowType = type
  418. this.handleOk()
  419. } else {
  420. this.nowType = type
  421. this.openPrintModal = true
  422. }
  423. },
  424. handleOk (objs) {
  425. const _this = this
  426. let params, type
  427. let url = checkWarehouseDetailPrint // 打印
  428. if (this.nowType == 'export') { // 导出
  429. url = checkWarehouseDetailExport
  430. type = 'export'
  431. params = { checkWarehouseSn: this.$route.params.sn, productScopeFlag: this.productScopeFlag }
  432. } else { // 打印
  433. params = JSON.parse(JSON.stringify(objs))
  434. params.printType = this.printerType
  435. type = params.type
  436. delete params.type
  437. }
  438. _this.spinning = true
  439. // 打印或导出
  440. hdPrint(this.printerType, type, url, params, '库存盘点', function () {
  441. _this.spinning = false
  442. })
  443. }
  444. },
  445. mounted () {
  446. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  447. this.getDetail()
  448. this.resetSearchForm()
  449. }
  450. },
  451. activated () {
  452. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  453. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  454. this.getDetail()
  455. this.resetSearchForm()
  456. }
  457. },
  458. beforeRouteEnter (to, from, next) {
  459. next(vm => {})
  460. }
  461. }
  462. </script>
  463. <style lang="less">
  464. .inventoryCheckMakeInventoryList-wrap{
  465. position: relative;
  466. height: 100%;
  467. padding-bottom: 51px;
  468. box-sizing: border-box;
  469. .inventoryCheckMakeInventoryList-cont, .inventoryCheckMakeInventoryList-back{
  470. margin-bottom: 10px;
  471. }
  472. .billno{
  473. font-size: 16px;
  474. font-weight: bold;
  475. margin: 0 15px;
  476. }
  477. >.ant-spin-nested-loading{
  478. overflow-y: auto;
  479. height: 100%;
  480. }
  481. }
  482. </style>