makeInventory.vue 21 KB

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