detailModal.vue 17 KB

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