makeInventory.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  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="handlePrint('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="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="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. </div>
  168. </template>
  169. <script>
  170. import { STable, VSelect } from '@/components'
  171. import ProductType from '@/views/common/productType.js'
  172. import printModal from './printModal.vue'
  173. import { downloadExcel } from '@/libs/JGPrint.js'
  174. import { checkWarehouseDetailList, checkWarehouseDetailCount, checkWarehouseInventory, checkWarehouseDetail, checkWarehouseDetailSave, checkWarehouseCheckZero, checkWarehouseWarehouse, checkWarehouseDetailExport, checkWarehouseDetailPrint } from '@/api/checkWarehouse'
  175. export default {
  176. components: { STable, VSelect, ProductType, printModal },
  177. props: {},
  178. data () {
  179. return {
  180. spinning: false,
  181. disabled: false,
  182. advanced: false,
  183. queryParam: {
  184. productName: '',
  185. productCode: '',
  186. productTypeSn1: undefined,
  187. productTypeSn2: undefined,
  188. productTypeSn3: undefined,
  189. warehouseSn: undefined
  190. },
  191. basicInfoData: null, // 基础信息
  192. productTotal: null,
  193. // 加载数据方法 必须为 Promise 对象
  194. loadData: parameter => {
  195. this.disabled = true
  196. this.spinning = true
  197. return checkWarehouseDetailList(Object.assign(parameter, this.queryParam, { checkWarehouseSn: this.$route.params.sn })).then(res => {
  198. let data
  199. if (res.status == 200) {
  200. data = res.data
  201. const no = (data.pageNo - 1) * data.pageSize
  202. for (var i = 0; i < data.list.length; i++) {
  203. data.list[i].no = no + i + 1
  204. data.list[i].checkQtyBackups = data.list[i].checkQty
  205. }
  206. this.localDataSource = data.list || []
  207. this.getProduceTotal()
  208. this.disabled = false
  209. }
  210. this.spinning = false
  211. return data
  212. })
  213. },
  214. productType: [],
  215. warehouseList: [], // 仓库 下拉数据
  216. localDataSource: [],
  217. openPrintModal: false,
  218. nowType: null,
  219. printerType: 'NEEDLE' // 打印机类型
  220. }
  221. },
  222. computed: {
  223. columns () {
  224. const arr = [
  225. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  226. { title: '产品编码', dataIndex: 'productCode', width: '21%', align: 'center', customRender: function (text) { return text || '--' } },
  227. { title: '产品名称', dataIndex: 'productName', width: '21%', align: 'left', customRender: function (text) { return text || '--' } },
  228. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '14%' },
  229. { title: '单位', dataIndex: 'productUnit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  230. { title: '库存数量', dataIndex: 'stockQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  231. { title: '盘点数量', scopedSlots: { customRender: 'checkQty' }, width: '8%', align: 'center' },
  232. { title: '盈亏数量', scopedSlots: { customRender: 'checkProfitLossQty' }, width: '8%', align: 'center' }
  233. ]
  234. if (this.basicInfoData && this.basicInfoData.warehouseFlag == '1') {
  235. arr.splice(4, 0, { title: '仓库', dataIndex: 'warehouseName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } })
  236. }
  237. return arr
  238. }
  239. },
  240. methods: {
  241. // 重置
  242. resetSearchForm () {
  243. this.queryParam.productName = ''
  244. this.queryParam.productCode = ''
  245. this.queryParam.warehouseSn = undefined
  246. this.queryParam.productTypeSn1 = undefined
  247. this.queryParam.productTypeSn2 = undefined
  248. this.queryParam.productTypeSn3 = undefined
  249. this.productType = []
  250. this.$refs.table.refresh(true)
  251. },
  252. // 盘点完成
  253. handleSubmit () {
  254. const _this = this
  255. _this.spinning = true
  256. checkWarehouseInventory({ id: this.$route.params.id }).then(res => {
  257. if (res.status == 200) {
  258. this.$message.success(res.message)
  259. setTimeout(() => {
  260. _this.handleBack()
  261. _this.spinning = false
  262. }, 1000)
  263. } else {
  264. _this.spinning = false
  265. }
  266. })
  267. },
  268. // 数量 blur
  269. checkQtyBlur (val, record) {
  270. if ((val != record.checkQtyBackups) || (!val && record.checkQtyBackups == 0)) {
  271. this.handleAdd(record, 'edit')
  272. }
  273. },
  274. // 添加/编辑
  275. handleAdd (row, isEdit) {
  276. if (!isEdit && !row.checkQty) {
  277. this.$message.warning('请输入盘点数量!')
  278. return
  279. }
  280. const params = {
  281. checkWarehouseSn: this.$route.params.sn,
  282. id: row.id,
  283. checkCost: row.checkCost,
  284. checkQty: row.checkQty,
  285. productSn: row.productSn,
  286. productCode: row.productCode,
  287. productOrigCode: row.productOrigCode || undefined,
  288. productTypeSn1: row.productTypeSn1,
  289. productTypeSn2: row.productTypeSn2,
  290. productTypeSn3: row.productTypeSn3,
  291. brandSn: row.brandSn,
  292. stockQty: row.stockQty,
  293. lastStockTime: row.lastStockTime,
  294. checkProfitLossCost: row.checkProfitLossCost,
  295. stockBatchNo: row.stockBatchNo || undefined,
  296. productProduceDate: row.productProduceDate || undefined,
  297. productExpiryDate: row.productExpiryDate || undefined,
  298. warehouseSn: row.warehouseSn || undefined,
  299. warehouseLocationSn: row.warehouseLocationSn || undefined
  300. }
  301. if (isEdit) { // 编辑
  302. // 清空数量时,值应保持未清空前的值,因数量都不可为空
  303. if (!(row.checkQty || row.checkQty == 0)) {
  304. row.checkQty = row.checkQtyBackups
  305. return
  306. }
  307. }
  308. this.spinning = true
  309. checkWarehouseDetailSave(params).then(res => {
  310. if (res.status == 200) {
  311. this.$message.success(res.message)
  312. this.$refs.table.refresh()
  313. this.spinning = false
  314. } else {
  315. this.spinning = false
  316. }
  317. })
  318. },
  319. // 整单盘零
  320. handleCheckZero () {
  321. const _this = this
  322. this.$confirm({
  323. title: '提示',
  324. content: '确定要进行 整单盘零 操作吗?',
  325. centered: true,
  326. onOk () {
  327. _this.spinning = true
  328. checkWarehouseCheckZero({ checkWarehouseSn: _this.$route.params.sn }).then(res => {
  329. if (res.status == 200) {
  330. _this.$message.success(res.message)
  331. _this.$refs.table.refresh(true)
  332. _this.spinning = false
  333. } else {
  334. _this.spinning = false
  335. }
  336. })
  337. }
  338. })
  339. },
  340. // 返回列表
  341. handleBack () {
  342. this.$router.push({ path: '/inventoryManagement/inventoryChecking/list' })
  343. },
  344. // 查询基础信息
  345. getDetail () {
  346. checkWarehouseDetail({ sn: this.$route.params.sn }).then(res => {
  347. if (res.status == 200 && res.data) {
  348. this.basicInfoData = res.data
  349. this.warehouseList = res.data.warehouseList || []
  350. } else {
  351. this.basicInfoData = null
  352. this.warehouseList = []
  353. }
  354. })
  355. },
  356. // 已选产品总计查询
  357. getProduceTotal () {
  358. checkWarehouseDetailCount(Object.assign(this.queryParam, { checkWarehouseSn: this.$route.params.sn })).then(res => {
  359. if (res.status == 200) {
  360. this.productTotal = res.data
  361. } else {
  362. this.productTotal = null
  363. }
  364. })
  365. },
  366. // 产品分类 change
  367. changeProductType (val, opt) {
  368. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  369. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  370. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  371. },
  372. // 打印导出
  373. handlePrint (type) {
  374. if (type == 'export') {
  375. this.nowType = type
  376. this.handleOk()
  377. } else {
  378. this.nowType = type
  379. this.openPrintModal = true
  380. }
  381. },
  382. handleOk (objs) {
  383. const _this = this
  384. let params
  385. let url = checkWarehouseDetailPrint // 打印
  386. if (this.nowType == 'export') { // 导出
  387. url = checkWarehouseDetailExport
  388. params = { checkWarehouseSn: this.$route.params.sn }
  389. } else { // 打印
  390. params = JSON.parse(JSON.stringify(objs))
  391. params.printType = this.printerType
  392. delete params.type
  393. }
  394. _this.spinning = true
  395. url(params).then(res => {
  396. _this.spinning = false
  397. if (res.type == 'application/json') {
  398. var reader = new FileReader()
  399. reader.addEventListener('loadend', function () {
  400. const obj = JSON.parse(reader.result)
  401. _this.$notification.error({
  402. message: '提示',
  403. description: obj.message
  404. })
  405. })
  406. reader.readAsText(res)
  407. } else {
  408. if (this.nowType == 'export' || this.nowType == 'typeExport') {
  409. downloadExcel(res, '库存盘点')
  410. } else {
  411. this.print(res, objs.type)
  412. }
  413. }
  414. })
  415. },
  416. print (data, type) {
  417. if (!data) {
  418. return
  419. }
  420. const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
  421. document.getElementById('print').innerHTML = '<iframe id="printficm" name="printficm" src="' + url + '" hidden></iframe>'
  422. if (type == 'preview') { // 预览
  423. window.open(url)
  424. } else if (type == 'print') { // 打印
  425. window.frames['printficm'].focus()
  426. window.frames['printficm'].print()
  427. }
  428. }
  429. },
  430. mounted () {
  431. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  432. this.getDetail()
  433. this.resetSearchForm()
  434. }
  435. },
  436. activated () {
  437. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  438. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  439. this.getDetail()
  440. this.resetSearchForm()
  441. }
  442. },
  443. beforeRouteEnter (to, from, next) {
  444. next(vm => {})
  445. }
  446. }
  447. </script>
  448. <style lang="less">
  449. .inventoryCheckMakeInventoryList-wrap{
  450. position: relative;
  451. height: 100%;
  452. padding-bottom: 51px;
  453. box-sizing: border-box;
  454. .inventoryCheckMakeInventoryList-cont, .inventoryCheckMakeInventoryList-back{
  455. margin-bottom: 10px;
  456. }
  457. .billno{
  458. font-size: 16px;
  459. font-weight: bold;
  460. margin: 0 15px;
  461. }
  462. >.ant-spin-nested-loading{
  463. overflow-y: scroll;
  464. height: 100%;
  465. }
  466. }
  467. </style>