makeInventory.vue 19 KB

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