detailModal.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  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="handlePrint('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. </a-modal>
  156. </template>
  157. <script>
  158. import { commonMixin } from '@/utils/mixin'
  159. import { hdPrint } from '@/libs/JGPrint.js'
  160. import { STable } from '@/components'
  161. import printModal from './printModal.vue'
  162. import ProductType from '@/views/common/productType.js'
  163. import { formatDecimal } from '@/libs/tools'
  164. import { checkWarehouseDetailList, checkWarehouseDetail, checkWarehouseDetailCount, checkWarehouseDetailExport, checkWarehouseDetailPrint, checkWarehouseWarehouse } from '@/api/checkWarehouse'
  165. export default {
  166. name: 'InventoryCheckingDetailModal',
  167. components: { STable, ProductType, printModal },
  168. mixins: [commonMixin],
  169. props: {
  170. openModal: { // 弹框显示状态
  171. type: Boolean,
  172. default: false
  173. },
  174. itemSn: {
  175. type: String || Number,
  176. default: ''
  177. }
  178. },
  179. data () {
  180. return {
  181. spinning: false,
  182. isShow: this.openModal, // 是否打开弹框
  183. disabled: false,
  184. advanced: false,
  185. queryParam: {
  186. productName: '',
  187. productCode: '',
  188. productTypeSn1: undefined,
  189. productTypeSn2: undefined,
  190. productTypeSn3: undefined,
  191. warehouseSn: undefined
  192. },
  193. // 加载数据方法 必须为 Promise 对象
  194. loadData: parameter => {
  195. this.disabled = true
  196. this.spinning = true
  197. const params = Object.assign(parameter, this.queryParam, { checkWarehouseSn: this.itemSn })
  198. if (this.isPrice) {
  199. params.profitLossFlag = 1
  200. }
  201. return checkWarehouseDetailList(params).then(res => {
  202. let data
  203. if (res.status == 200) {
  204. data = res.data
  205. this.getDetailCount(params)
  206. const no = (data.pageNo - 1) * data.pageSize
  207. for (var i = 0; i < data.list.length; i++) {
  208. data.list[i].no = no + i + 1
  209. }
  210. this.localDataSource = data.list || []
  211. this.disabled = false
  212. }
  213. this.spinning = false
  214. return data
  215. })
  216. },
  217. basicInfoData: null, // 基本信息
  218. productTotal: null,
  219. productType: [],
  220. warehouseList: [], // 仓库 下拉数据
  221. localDataSource: [],
  222. isPrice: false, // 仅显示盈亏
  223. openPrintModal: false,
  224. nowType: null,
  225. printerType: 'NEEDLE' // 打印机类型
  226. }
  227. },
  228. computed: {
  229. columns () {
  230. const arr = [
  231. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  232. { title: '产品编码', dataIndex: 'productCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  233. { title: '产品名称', dataIndex: 'productName', width: '17%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  234. { title: '产品分类', scopedSlots: { customRender: 'productType' }, align: 'center', width: '11%' },
  235. { title: '单位', dataIndex: 'productUnit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  236. { title: '库存数量', dataIndex: 'stockQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  237. { title: '盘点数量', dataIndex: 'checkQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  238. { title: '盈亏数量', scopedSlots: { customRender: 'checkProfitLossQty' }, width: '6%', align: 'center' }
  239. // { title: '盈亏成本', scopedSlots: { customRender: 'checkProfitLossCost' }, width: '6%', align: 'right' }
  240. ]
  241. if (this.basicInfoData && this.basicInfoData.warehouseFlag == '1') {
  242. arr.splice(4, 0, { title: '仓库', dataIndex: 'warehouseName', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true })
  243. arr.splice(5, 0, { title: '仓位', dataIndex: 'warehouseLocationName', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true })
  244. }
  245. if (this.basicInfoData && this.basicInfoData.state == 'FINISH') {
  246. arr.push({ title: '盈亏成本', scopedSlots: { customRender: 'checkProfitLossCost' }, width: '6%', align: 'right' })
  247. }
  248. return arr
  249. }
  250. },
  251. methods: {
  252. // 保留两位小数(不四舍五入)
  253. formatDecimal,
  254. // 详情
  255. getDetail () {
  256. checkWarehouseDetail({ sn: this.itemSn }).then(res => {
  257. if (res.status == 200) {
  258. this.basicInfoData = res.data || null
  259. } else {
  260. this.basicInfoData = null
  261. }
  262. })
  263. },
  264. // 合计
  265. getDetailCount (params) {
  266. checkWarehouseDetailCount(params).then(res => {
  267. if (res.status == 200) {
  268. this.productTotal = res.data
  269. if (res.data && res.data.checkLossQty) {
  270. this.productTotal.checkLossQty = Math.abs(this.productTotal.checkLossQty || 0)
  271. }
  272. } else {
  273. this.productTotal = null
  274. }
  275. })
  276. },
  277. // 重置
  278. resetSearchForm () {
  279. this.queryParam.productName = ''
  280. this.queryParam.productCode = ''
  281. this.queryParam.warehouseSn = undefined
  282. this.queryParam.productTypeSn1 = undefined
  283. this.queryParam.productTypeSn2 = undefined
  284. this.queryParam.productTypeSn3 = undefined
  285. this.productType = []
  286. this.$refs.table.refresh(true)
  287. },
  288. // 产品分类 change
  289. changeProductType (val, opt) {
  290. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  291. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  292. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  293. },
  294. // 仓库下拉数据
  295. getWarehouseList () {
  296. checkWarehouseWarehouse({}).then(res => {
  297. if (res.status == 200) {
  298. this.warehouseList = res.data
  299. } else {
  300. this.warehouseList = []
  301. }
  302. })
  303. },
  304. // 打印导出
  305. handlePrint (type) {
  306. if (type == 'export') {
  307. this.nowType = type
  308. this.handleOk()
  309. } else {
  310. this.nowType = type
  311. this.openPrintModal = true
  312. }
  313. },
  314. handleOk (objs) {
  315. const _this = this
  316. let params, type
  317. let url = checkWarehouseDetailPrint // 打印
  318. if (this.nowType == 'export') { // 导出
  319. url = checkWarehouseDetailExport
  320. params = { checkWarehouseSn: this.itemSn }
  321. type = 'export'
  322. } else { // 打印
  323. params = JSON.parse(JSON.stringify(objs))
  324. params.printType = this.printerType
  325. type = params.type
  326. delete params.type
  327. }
  328. _this.spinning = true
  329. // 打印或导出
  330. hdPrint(this.printerType, type, url, params, '库存盘点', function () {
  331. _this.spinning = false
  332. })
  333. }
  334. },
  335. watch: {
  336. // 父页面传过来的弹框状态
  337. openModal (newValue, oldValue) {
  338. this.isShow = newValue
  339. },
  340. // 重定义的弹框状态
  341. isShow (newValue, oldValue) {
  342. if (!newValue) {
  343. this.$emit('close')
  344. this.printerType = 'NEEDLE'
  345. this.$refs.table.clearTable()
  346. this.basicInfoData = null
  347. } else {
  348. const _this = this
  349. setTimeout(() => (
  350. _this.resetSearchForm()
  351. ), 300)
  352. }
  353. },
  354. itemSn (newValue, oldValue) {
  355. if (this.isShow && newValue) {
  356. this.isPrice = false
  357. this.getDetail()
  358. this.getWarehouseList()
  359. }
  360. },
  361. isPrice (newValue, oldValue) {
  362. this.$refs.table.refresh(true)
  363. }
  364. }
  365. }
  366. </script>
  367. <style lang="less">
  368. .inventoryCheckingDetail-modal{
  369. .ant-modal-body{
  370. padding: 0 24px 24px;
  371. }
  372. .print-cont{
  373. text-align: right;
  374. padding: 5px 0 10px;
  375. }
  376. .redBg-row{
  377. background-color: #f5cdc8;
  378. }
  379. }
  380. </style>