detailModal.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <a-modal
  3. centered
  4. class="inventoryCheckingDetail-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="详情"
  8. v-model="isShow"
  9. @cancle="isShow = false"
  10. width="80%">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-card size="small" :bordered="false" class="inventoryCheckingDetail-cont">
  13. <div class="print-cont" v-if="$hasPermissions('B_inventoryCheckingPrint')">
  14. <a-radio-group v-model="printerType">
  15. <a-radio value="NEEDLE">针式</a-radio>
  16. <a-radio value="INK">喷墨</a-radio>
  17. </a-radio-group>
  18. <a-button
  19. type="primary"
  20. class="button-error"
  21. id="inventoryCheckingDetail-pd-print-btn"
  22. :disabled="localDataSource.length==0"
  23. @click="handlePrint('pddy')">盘点打印</a-button>
  24. <a-button
  25. type="primary"
  26. class="button-info"
  27. id="inventoryCheckingDetail-sh-print-btn"
  28. :disabled="localDataSource.length==0"
  29. @click="handlePrint('shdy')">审核打印</a-button>
  30. <a-button
  31. type="primary"
  32. class="button-warning"
  33. id="inventoryCheckingDetail-export-btn"
  34. :disabled="localDataSource.length==0"
  35. @click="handlePrint('export')">导出Excel</a-button>
  36. </div>
  37. <a-descriptions size="small" :column="3">
  38. <a-descriptions-item label="盘点单号" :span="3">
  39. {{ (basicInfoData&&basicInfoData.checkWarehouseNo) || '--' }}
  40. <div style="display: inline-block;margin-left: 10px;">
  41. <a-tag color="red" v-if="basicInfoData&&basicInfoData.stateDictValue">{{ basicInfoData.stateDictValue }}</a-tag>
  42. </div>
  43. </a-descriptions-item>
  44. <a-descriptions-item label="盘点类型">{{ (basicInfoData&&basicInfoData.checkTypeDictValue) || '--' }}</a-descriptions-item>
  45. <a-descriptions-item label="是否区分仓库" v-if="basicInfoData&&basicInfoData.checkType=='SELECT'">{{ (basicInfoData&&basicInfoData.warehouseFlagDictValue) || '--' }}</a-descriptions-item>
  46. <a-descriptions-item label="盘点仓库" v-if="basicInfoData&&basicInfoData.warehouseFlag=='1'">{{ (basicInfoData&&basicInfoData.warehouseNameList) || '--' }}</a-descriptions-item>
  47. <a-descriptions-item label="创建人">{{ (basicInfoData&&basicInfoData.creatorName) || '--' }}</a-descriptions-item>
  48. <a-descriptions-item label="创建时间">{{ (basicInfoData&&basicInfoData.createDate) || '--' }}</a-descriptions-item>
  49. <a-descriptions-item label="审核时间">{{ (basicInfoData&&basicInfoData.checkSuperviseTime) || '--' }}</a-descriptions-item>
  50. </a-descriptions>
  51. </a-card>
  52. <a-card size="small" :bordered="false" class="inventoryCheckingDetail-cont">
  53. <!-- 总计 -->
  54. <a-alert type="info" style="margin-bottom:10px">
  55. <div slot="message">
  56. <div style="display: flex;justify-content: space-between;align-items: center;">
  57. <div>
  58. 总款数: <strong>{{ productTotal&&(productTotal.totalCategory || productTotal.totalCategory==0) ? productTotal.totalCategory : '--' }}</strong> ,
  59. 总数量: <strong>{{ productTotal&&(productTotal.stockQty || productTotal.stockQty==0) ? productTotal.stockQty : '--' }}</strong> ,
  60. 总成本: <strong>{{ productTotal&&(productTotal.checkCost || productTotal.checkCost==0) ? '¥'+productTotal.checkCost : '--' }}</strong> ,
  61. 盘盈数量: <strong>{{ productTotal&&(productTotal.checkProfitQty || productTotal.checkProfitQty==0) ? productTotal.checkProfitQty : '--' }}</strong> ,
  62. 盘亏数量: <strong>{{ productTotal&&(productTotal.checkLossQty || productTotal.checkLossQty==0) ? productTotal.checkLossQty : '--' }}</strong>
  63. </div>
  64. <div>
  65. <span style="color: red;display: inline-block;margin-right: 8px;">红色代表盘盈</span>
  66. <span style="color: green;">绿色代表盘亏</span>
  67. </div>
  68. </div>
  69. </div>
  70. </a-alert>
  71. <!-- 筛选条件 -->
  72. <div class="table-page-search-wrapper">
  73. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  74. <a-row :gutter="15">
  75. <a-col :md="7" :sm="24">
  76. <a-form-item label="产品编码/产品名称" prop="productName">
  77. <a-input id="inventoryCheckMakeInventoryList-productName" v-model="queryParam.productName" placeholder="请输入" allowClear />
  78. </a-form-item>
  79. </a-col>
  80. <a-col :md="6" :sm="24">
  81. <a-form-item label="产品分类">
  82. <ProductType id="inventoryCheckMakeInventoryList-productType" @change="changeProductType" v-model="productType"></ProductType>
  83. </a-form-item>
  84. </a-col>
  85. <a-col :md="6" :sm="24" v-if="basicInfoData&&basicInfoData.warehouseFlag=='1'">
  86. <a-form-item label="仓库">
  87. <a-select id="inventoryCheckMakeInventoryList-warehouseSn" allowClear placeholder="请选择仓库" v-model="queryParam.warehouseSn" >
  88. <a-select-option v-for="item in warehouseList" :key="item.warehouseSn" :value="item.warehouseSn">{{ item.name }}</a-select-option>
  89. </a-select>
  90. </a-form-item>
  91. </a-col>
  92. <a-col :md="5" :sm="24" style="margin-bottom: 10px;">
  93. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="inventoryCheckMakeInventoryList-refresh">查询</a-button>
  94. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="inventoryCheckMakeInventoryList-reset">重置</a-button>
  95. </a-col>
  96. </a-row>
  97. </a-form>
  98. </div>
  99. <!-- 列表 -->
  100. <s-table
  101. class="sTable"
  102. ref="table"
  103. size="small"
  104. :rowKey="(record) => record.id"
  105. :columns="columns"
  106. :data="loadData"
  107. :defaultLoadData="false"
  108. :scroll="{ x: 1200, y: 450 }"
  109. :rowClassName="(record, index) => record.checkProfitLossQty < 0 ? 'redBg-row':''"
  110. bordered>
  111. <!-- 产品分类 -->
  112. <template slot="productType" slot-scope="text, record">
  113. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  114. <span v-else>--</span>
  115. </template>
  116. <!-- 盈亏数量 -->
  117. <template slot="checkProfitLossQty" slot-scope="text, record">
  118. <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>
  119. </template>
  120. </s-table>
  121. </a-card>
  122. </a-spin>
  123. <!-- 打印导出 -->
  124. <print-modal :openModal="openPrintModal" :itemData="basicInfoData" :nowType="nowType" @ok="handleOk" @close="openPrintModal=false" />
  125. <!-- 打印 -->
  126. <div id="print"></div>
  127. </a-modal>
  128. </template>
  129. <script>
  130. import moment from 'moment'
  131. import { STable } from '@/components'
  132. import printModal from './printModal.vue'
  133. import ProductType from '@/views/common/productType.js'
  134. import { checkWarehouseDetailList, checkWarehouseDetail, checkWarehouseDetailCount, checkWarehouseDetailExport, checkWarehouseDetailPrint, checkWarehouseWarehouse } from '@/api/checkWarehouse'
  135. export default {
  136. name: 'InventoryCheckingDetailModal',
  137. components: { STable, ProductType, printModal },
  138. props: {
  139. openModal: { // 弹框显示状态
  140. type: Boolean,
  141. default: false
  142. },
  143. itemSn: {
  144. type: String || Number,
  145. default: ''
  146. }
  147. },
  148. data () {
  149. return {
  150. spinning: false,
  151. isShow: this.openModal, // 是否打开弹框
  152. disabled: false,
  153. queryParam: {
  154. productName: '',
  155. productTypeSn1: undefined,
  156. productTypeSn2: undefined,
  157. productTypeSn3: undefined,
  158. warehouseSn: undefined
  159. },
  160. // 加载数据方法 必须为 Promise 对象
  161. loadData: parameter => {
  162. this.disabled = true
  163. return checkWarehouseDetailList(Object.assign(parameter, this.queryParam, { checkWarehouseSn: this.itemSn })).then(res => {
  164. this.getDetailCount()
  165. const data = res.data
  166. const no = (data.pageNo - 1) * data.pageSize
  167. for (var i = 0; i < data.list.length; i++) {
  168. data.list[i].no = no + i + 1
  169. }
  170. this.localDataSource = data.list || []
  171. this.disabled = false
  172. return data
  173. })
  174. },
  175. basicInfoData: null, // 基本信息
  176. productTotal: null,
  177. productType: [],
  178. warehouseList: [], // 仓库 下拉数据
  179. localDataSource: [],
  180. openPrintModal: false,
  181. nowType: null,
  182. printerType: 'NEEDLE' // 打印机类型
  183. }
  184. },
  185. computed: {
  186. columns () {
  187. const arr = [
  188. { title: '序号', dataIndex: 'no', width: 50, align: 'center' },
  189. { title: '产品编码', dataIndex: 'productCode', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
  190. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' } },
  191. { title: '产品分类', scopedSlots: { customRender: 'productType' }, align: 'center', width: 140 },
  192. { title: '单位', dataIndex: 'productUnit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  193. { title: '库存数量', dataIndex: 'stockQty', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  194. { title: '盘点数量', dataIndex: 'checkQty', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  195. { title: '盈亏数量', scopedSlots: { customRender: 'checkProfitLossQty' }, width: 80, align: 'center' }
  196. ]
  197. if (this.basicInfoData && this.basicInfoData.warehouseFlag == '1') {
  198. arr.splice(4, 0, { title: '仓库', dataIndex: 'warehouseName', width: 140, align: 'center', customRender: function (text) { return text || '--' } })
  199. arr.splice(5, 0, { title: '仓位', dataIndex: 'warehouseLocationName', width: 140, align: 'center', customRender: function (text) { return text || '--' } })
  200. }
  201. return arr
  202. }
  203. },
  204. methods: {
  205. // 详情
  206. getDetail () {
  207. checkWarehouseDetail({ sn: this.itemSn }).then(res => {
  208. if (res.status == 200) {
  209. this.basicInfoData = res.data || null
  210. } else {
  211. this.basicInfoData = null
  212. }
  213. })
  214. },
  215. // 合计
  216. getDetailCount () {
  217. checkWarehouseDetailCount(Object.assign(this.queryParam, { checkWarehouseSn: this.itemSn })).then(res => {
  218. if (res.status == 200) {
  219. this.productTotal = res.data
  220. this.productTotal.checkLossQty = Math.abs(this.productTotal.checkLossQty || 0)
  221. } else {
  222. this.productTotal = null
  223. }
  224. })
  225. },
  226. // 重置
  227. resetSearchForm () {
  228. this.queryParam.productName = ''
  229. this.queryParam.warehouseSn = undefined
  230. this.queryParam.productTypeSn1 = undefined
  231. this.queryParam.productTypeSn2 = undefined
  232. this.queryParam.productTypeSn3 = undefined
  233. this.productType = []
  234. this.$refs.table.refresh(true)
  235. },
  236. // 产品分类 change
  237. changeProductType (val, opt) {
  238. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  239. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  240. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  241. },
  242. // 仓库下拉数据
  243. getWarehouseList () {
  244. checkWarehouseWarehouse({}).then(res => {
  245. if (res.status == 200) {
  246. this.warehouseList = res.data
  247. } else {
  248. this.warehouseList = []
  249. }
  250. })
  251. },
  252. // 打印导出
  253. handlePrint (type) {
  254. if (type == 'export') {
  255. this.nowType = type
  256. this.handleOk()
  257. } else {
  258. this.nowType = type
  259. this.openPrintModal = true
  260. }
  261. },
  262. handleOk (objs) {
  263. const _this = this
  264. let params
  265. let url = checkWarehouseDetailPrint // 打印
  266. if (this.nowType == 'export') { // 导出
  267. url = checkWarehouseDetailExport
  268. params = { checkWarehouseSn: this.itemSn }
  269. } else { // 打印
  270. params = JSON.parse(JSON.stringify(objs))
  271. params.printType = this.printerType
  272. delete params.type
  273. }
  274. _this.spinning = true
  275. url(params).then(res => {
  276. _this.spinning = false
  277. if (res.type == 'application/json') {
  278. var reader = new FileReader()
  279. reader.addEventListener('loadend', function () {
  280. const obj = JSON.parse(reader.result)
  281. _this.$notification.error({
  282. message: '提示',
  283. description: obj.message
  284. })
  285. })
  286. reader.readAsText(res)
  287. } else {
  288. if (this.nowType == 'export' || this.nowType == 'typeExport') {
  289. this.download(res)
  290. } else {
  291. this.print(res, objs.type)
  292. }
  293. }
  294. })
  295. },
  296. print (data, type) {
  297. if (!data) {
  298. return
  299. }
  300. const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
  301. document.getElementById('print').innerHTML = '<iframe id="printficd" name="printficd" src="' + url + '" hidden></iframe>'
  302. if (type == 'preview') { // 预览
  303. window.open(url)
  304. } else if (type == 'print') { // 打印
  305. window.frames['printficd'].focus()
  306. window.frames['printficd'].print()
  307. }
  308. },
  309. download (data) {
  310. if (!data) { return }
  311. const url = window.URL.createObjectURL(new Blob([data]))
  312. const link = document.createElement('a')
  313. link.style.display = 'none'
  314. link.href = url
  315. const a = moment().format('YYYYMMDDHHmmss')
  316. const fname = '库存盘点' + a
  317. link.setAttribute('download', fname + '.xlsx')
  318. document.body.appendChild(link)
  319. link.click()
  320. }
  321. },
  322. watch: {
  323. // 父页面传过来的弹框状态
  324. openModal (newValue, oldValue) {
  325. this.isShow = newValue
  326. },
  327. // 重定义的弹框状态
  328. isShow (newValue, oldValue) {
  329. if (!newValue) {
  330. this.$emit('close')
  331. this.printerType = 'NEEDLE'
  332. } else {
  333. const _this = this
  334. setTimeout(() => (
  335. _this.$refs.table.refresh(true)
  336. ), 300)
  337. }
  338. },
  339. itemSn (newValue, oldValue) {
  340. if (this.isShow && newValue) {
  341. this.getDetail()
  342. this.getWarehouseList()
  343. }
  344. }
  345. }
  346. }
  347. </script>
  348. <style lang="less">
  349. .inventoryCheckingDetail-modal{
  350. .ant-modal-body{
  351. padding: 0 24px 24px;
  352. }
  353. .print-cont{
  354. text-align: right;
  355. padding: 5px 0 10px;
  356. }
  357. .redBg-row{
  358. background-color: #f5cdc8;
  359. }
  360. }
  361. </style>