makeInventory.vue 21 KB

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