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