detailModal.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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" id="inventoryCheckingDetail-pd-print-opts">
  15. <a-radio value="NEEDLE" id="inventoryCheckingDetail-pd-print-needle">针式</a-radio>
  16. <a-radio value="INK" id="inventoryCheckingDetail-pd-print-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 v-if="productTotal">
  58. <div>
  59. 总款数: <strong>{{ (productTotal.totalCategory || productTotal.totalCategory==0) ? productTotal.totalCategory : '--' }}</strong> ,
  60. 总数量: <strong>{{ (productTotal.stockQty || productTotal.stockQty==0) ? productTotal.stockQty : '--' }}</strong> ,
  61. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  62. 总成本: <strong>{{ (productTotal.checkCost || productTotal.checkCost==0) ? toThousands(productTotal.checkCost) : '--' }}</strong>
  63. </div>
  64. </div>
  65. <div>
  66. 盘盈总数量: <strong>{{ (productTotal.checkProfitQty || productTotal.checkProfitQty==0) ? productTotal.checkProfitQty : '--' }}</strong>,
  67. <span v-if="basicInfoData&&basicInfoData.state=='FINISH'">盘盈总成本: <strong>{{ (productTotal.checkProfitCost || productTotal.checkProfitCost==0) ? toThousands(productTotal.checkProfitCost) : '--' }}</strong>,</span>
  68. 盘亏总数量: <strong>{{ (productTotal.checkLossQty||productTotal.checkLossQty==0)?productTotal.checkLossQty>0?('-'+productTotal.checkLossQty):productTotal.checkLossQty: '--' }}</strong>,
  69. <span v-if="basicInfoData&&basicInfoData.state=='FINISH'">盘亏总成本: <strong>{{ (productTotal.checkLossCost || productTotal.checkLossCost==0) ? toThousands(productTotal.checkLossCost) : '--' }}</strong>,</span>
  70. 盈亏总数量: <strong>{{ (productTotal.totalCheckProfitLossQty || productTotal.totalCheckProfitLossQty==0) ? productTotal.totalCheckProfitLossQty : '--' }}</strong>,
  71. <span v-if="basicInfoData&&basicInfoData.state=='FINISH'">盈亏总成本: <strong>{{ (productTotal.totalCheckProfitLossCost || productTotal.totalCheckProfitLossCost==0) ? toThousands(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="inventoryCheckingDetail-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="inventoryCheckingDetail-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="inventoryCheckingDetail-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="inventoryCheckingDetail-warehouseSn" allowClear placeholder="请选择仓库" v-model="queryParam.warehouseSn" >
  105. <a-select-option v-for="item in warehouseList" :id="'inventoryCheckingDetail-warehouseSn-'+item.warehouseSn" :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="6" :sm="24" style="margin-bottom: 10px;">
  111. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="inventoryCheckingDetail-refresh">查询</a-button>
  112. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="inventoryCheckingDetail-reset">重置</a-button>
  113. <a @click="advanced=!advanced" style="margin-left: 5px" v-if="basicInfoData&&basicInfoData.warehouseFlag=='1'" id="inventoryCheckingDetail-advanced">
  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;">
  121. <a-checkbox id="inventoryCheckingDetail-checkbox" v-model="isPrice"><span style="display: inline-block;margin-top: 1px;">仅显示盈亏</span></a-checkbox>
  122. </div>
  123. </div>
  124. </div>
  125. <!-- 列表 -->
  126. <s-table
  127. class="sTable"
  128. ref="table"
  129. size="small"
  130. :rowKey="(record) => record.id"
  131. :columns="columns"
  132. :data="loadData"
  133. :defaultLoadData="false"
  134. :scroll="{ y: 450 }"
  135. :rowClassName="(record, index) => record.checkProfitLossQty < 0 ? 'redBg-row':''"
  136. bordered>
  137. <!-- 产品分类 -->
  138. <template slot="productType" slot-scope="text, record">
  139. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  140. <span v-else>--</span>
  141. </template>
  142. <!-- 盈亏数量 -->
  143. <template slot="checkProfitLossQty" slot-scope="text, record">
  144. <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>
  145. </template>
  146. <!-- 盈亏成本 -->
  147. <template slot="checkProfitLossCost" slot-scope="text, record">
  148. <span :style="{ color: record.checkProfitLossCost>0?'red':record.checkProfitLossCost<0?'green':'', fontWeight: record.checkProfitLossCost!=0?'bold':'' }">{{ (record.checkProfitLossCost || record.checkProfitLossCost==0) ? toThousands(record.checkProfitLossCost) : '--' }}</span>
  149. </template>
  150. </s-table>
  151. </a-card>
  152. </a-spin>
  153. <!-- 打印导出 -->
  154. <print-modal :openModal="openPrintModal" :itemData="basicInfoData" :nowType="nowType" @ok="handleOk" @close="openPrintModal=false" />
  155. <!-- 打印 -->
  156. <div id="print"></div>
  157. <!-- 导出选择弹框 -->
  158. <exportModal :openModal="exportShow" :itemData="basicInfoData" :nowType="nowType" @ok="handlePrint" @close="exportShow=false" />
  159. </a-modal>
  160. </template>
  161. <script>
  162. import { commonMixin } from '@/utils/mixin'
  163. import { hdPrint } from '@/libs/JGPrint.js'
  164. import { STable } from '@/components'
  165. import printModal from './printModal.vue'
  166. import exportModal from './exportModal.vue'
  167. import ProductType from '@/views/common/productType.js'
  168. import { checkWarehouseDetailList, checkWarehouseDetail, checkWarehouseDetailCount, checkWarehouseDetailExport, checkWarehouseDetailPrint, checkWarehouseWarehouse } from '@/api/checkWarehouse'
  169. export default {
  170. name: 'InventoryCheckingDetailModal',
  171. components: { STable, ProductType, printModal, exportModal },
  172. mixins: [commonMixin],
  173. props: {
  174. openModal: { // 弹框显示状态
  175. type: Boolean,
  176. default: false
  177. },
  178. itemSn: { // 单据sn
  179. type: String || Number,
  180. default: ''
  181. }
  182. },
  183. data () {
  184. return {
  185. spinning: false,
  186. isShow: this.openModal, // 是否打开弹框
  187. disabled: false,
  188. advanced: false, // 展开收起
  189. exportShow: false, // 打开导出选项弹框
  190. queryParam: {
  191. productName: '', // 产品名称
  192. productCode: '', // 产品编码
  193. productTypeSn1: undefined, // 产品分类1
  194. productTypeSn2: undefined, // 产品分类2
  195. productTypeSn3: undefined, // 产品分类3
  196. warehouseSn: undefined// 仓库sn
  197. },
  198. // 加载数据方法 必须为 Promise 对象
  199. loadData: parameter => {
  200. this.disabled = true
  201. this.spinning = true
  202. const params = Object.assign(parameter, this.queryParam, { checkWarehouseSn: this.itemSn })
  203. if (this.isPrice) {
  204. params.profitLossFlag = 1
  205. }
  206. return checkWarehouseDetailList(params).then(res => {
  207. let data
  208. if (res.status == 200) {
  209. data = res.data
  210. this.getDetailCount(params)
  211. const no = (data.pageNo - 1) * data.pageSize
  212. for (var i = 0; i < data.list.length; i++) {
  213. data.list[i].no = no + i + 1
  214. }
  215. this.localDataSource = data.list || []
  216. this.disabled = false
  217. }
  218. this.spinning = false
  219. return data
  220. })
  221. },
  222. basicInfoData: null, // 基本信息
  223. productTotal: null, // 合计数据
  224. productType: [], // 产品分类默认值
  225. warehouseList: [], // 仓库 下拉数据
  226. localDataSource: [], // 列表原始数据
  227. isPrice: false, // 仅显示盈亏
  228. openPrintModal: false, // 打印弹框
  229. nowType: null, // 打印or导出
  230. printerType: 'NEEDLE' // 打印机类型
  231. }
  232. },
  233. computed: {
  234. columns () {
  235. const arr = [
  236. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  237. { title: '产品编码', dataIndex: 'productCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  238. { title: '产品名称', dataIndex: 'productName', width: '17%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  239. { title: '产品分类', scopedSlots: { customRender: 'productType' }, align: 'center', width: '11%' },
  240. { title: '单位', dataIndex: 'productUnit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  241. { title: '库存数量', dataIndex: 'stockQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  242. { title: '盘点数量', dataIndex: 'checkQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  243. { title: '盈亏数量', scopedSlots: { customRender: 'checkProfitLossQty' }, width: '6%', align: 'center' }
  244. // { title: '盈亏成本', scopedSlots: { customRender: 'checkProfitLossCost' }, width: '6%', align: 'right' }
  245. ]
  246. // 是否显示仓库
  247. if (this.basicInfoData && this.basicInfoData.warehouseFlag == '1') {
  248. arr.splice(4, 0, { title: '仓库', dataIndex: 'warehouseName', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true })
  249. arr.splice(5, 0, { title: '仓位', dataIndex: 'warehouseLocationName', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true })
  250. }
  251. // 成本只有单据完成时显示
  252. if (this.basicInfoData && this.basicInfoData.state == 'FINISH') {
  253. arr.push({ title: '盈亏成本', scopedSlots: { customRender: 'checkProfitLossCost' }, width: '6%', align: 'right' })
  254. }
  255. return arr
  256. }
  257. },
  258. methods: {
  259. // 详情
  260. getDetail () {
  261. checkWarehouseDetail({ sn: this.itemSn }).then(res => {
  262. if (res.status == 200) {
  263. this.basicInfoData = res.data || null
  264. } else {
  265. this.basicInfoData = null
  266. }
  267. })
  268. },
  269. // 合计
  270. getDetailCount (params) {
  271. checkWarehouseDetailCount(params).then(res => {
  272. if (res.status == 200) {
  273. this.productTotal = res.data
  274. if (res.data && res.data.checkLossQty) {
  275. this.productTotal.checkLossQty = Math.abs(this.productTotal.checkLossQty || 0)
  276. }
  277. } else {
  278. this.productTotal = null
  279. }
  280. })
  281. },
  282. // 重置
  283. resetSearchForm () {
  284. this.queryParam.productName = ''
  285. this.queryParam.productCode = ''
  286. this.queryParam.warehouseSn = undefined
  287. this.queryParam.productTypeSn1 = undefined
  288. this.queryParam.productTypeSn2 = undefined
  289. this.queryParam.productTypeSn3 = undefined
  290. this.productType = []
  291. this.$refs.table.refresh(true)
  292. },
  293. // 产品分类 change
  294. changeProductType (val, opt) {
  295. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  296. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  297. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  298. },
  299. // 仓库下拉数据
  300. getWarehouseList () {
  301. checkWarehouseWarehouse({}).then(res => {
  302. if (res.status == 200) {
  303. this.warehouseList = res.data
  304. } else {
  305. this.warehouseList = []
  306. }
  307. })
  308. },
  309. // 导出弹框
  310. handleExport () {
  311. this.exportShow = true
  312. },
  313. // 打印导出
  314. handlePrint (type, data) {
  315. if (type == 'export') {
  316. this.exportShow = false
  317. this.nowType = type
  318. this.handleOk(data)
  319. } else {
  320. this.nowType = type
  321. this.openPrintModal = true
  322. }
  323. },
  324. // 开始打印or导出
  325. handleOk (objs) {
  326. const _this = this
  327. let params, type
  328. let url = checkWarehouseDetailPrint // 打印
  329. if (this.nowType == 'export') { // 导出
  330. url = checkWarehouseDetailExport
  331. params = { checkWarehouseSn: this.itemSn, ...objs }
  332. type = 'export'
  333. } else { // 打印
  334. params = JSON.parse(JSON.stringify(objs))
  335. params.printType = this.printerType
  336. type = params.type
  337. delete params.type
  338. }
  339. _this.spinning = true
  340. // 打印或导出
  341. hdPrint(this.printerType, type, url, params, '库存盘点', function () {
  342. _this.spinning = false
  343. })
  344. }
  345. },
  346. watch: {
  347. // 父页面传过来的弹框状态
  348. openModal (newValue, oldValue) {
  349. this.isShow = newValue
  350. },
  351. // 重定义的弹框状态
  352. isShow (newValue, oldValue) {
  353. if (!newValue) {
  354. this.$emit('close')
  355. this.printerType = 'NEEDLE'
  356. this.$refs.table.clearTable()
  357. this.basicInfoData = null
  358. } else {
  359. const _this = this
  360. setTimeout(() => (
  361. _this.resetSearchForm()
  362. ), 300)
  363. }
  364. },
  365. itemSn (newValue, oldValue) {
  366. if (this.isShow && newValue) {
  367. this.isPrice = false
  368. this.getDetail()
  369. this.getWarehouseList()
  370. }
  371. },
  372. // 仅显示盈亏勾选
  373. isPrice (newValue, oldValue) {
  374. this.$refs.table.refresh(true)
  375. }
  376. }
  377. }
  378. </script>
  379. <style lang="less">
  380. .inventoryCheckingDetail-modal{
  381. .ant-modal-body{
  382. padding: 0 24px 24px;
  383. }
  384. .print-cont{
  385. text-align: right;
  386. padding: 5px 0 10px;
  387. }
  388. .redBg-row{
  389. background-color: #f5cdc8;
  390. }
  391. }
  392. </style>