detailModal.vue 18 KB

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