index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <a-card size="small" :bordered="false" class="receivedSendStorageReport-wrap">
  3. <div ref="tableSearch" class="table-page-search-wrapper newTableSearchName">
  4. <a-form-model
  5. layout="inline"
  6. ref="ruleForm"
  7. :rules="rules"
  8. :model="form">
  9. <a-row :gutter="15">
  10. <a-col :md="5" :sm="24">
  11. <a-form-model-item label="选择月份" prop="time">
  12. <div class="monthBox" style="display:flex;align-item:center;">
  13. <a-month-picker
  14. :disabled-date="disabledStartDate"
  15. format="YYYY-MM"
  16. placeholder="开始月份"
  17. @openChange="handleStartOpenChange"
  18. @change="getStartDate"
  19. />
  20. <span>~</span>
  21. <a-month-picker
  22. :disabled-date="disabledEndDate"
  23. format="YYYY-MM"
  24. placeholder="结束月份"
  25. :open="endOpen"
  26. @openChange="handleEndOpenChange"
  27. @change="getEndDate"
  28. />
  29. </div>
  30. </a-form-model-item>
  31. </a-col>
  32. <a-col :md="5" :sm="24">
  33. <a-form-model-item label="产品名称">
  34. <a-input id="receivedSendStorageReport-name" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  35. </a-form-model-item>
  36. </a-col>
  37. <a-col :md="4" :sm="24">
  38. <a-form-model-item label="产品编码">
  39. <a-input id="receivedSendStorageReport-queryWord" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  40. </a-form-model-item>
  41. </a-col>
  42. <a-col :md="5" :sm="24">
  43. <a-form-model-item label="产品品牌">
  44. <ProductBrand id="receivedSendStorageReport-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  45. </a-form-model-item>
  46. </a-col>
  47. <a-col :md="5" :sm="24">
  48. <a-form-model-item label="产品分类">
  49. <productTypeAll placeholder="请选择产品分类" @change="changeProductType" v-model="productType" id="receivedSendStorageReport-productType"></productTypeAll>
  50. </a-form-model-item>
  51. </a-col>
  52. <a-col :md="24" :sm="24" style="margin-bottom: 10px;display:flex;align-item:center;justify-content:center;">
  53. <a-button type="primary" @click="testForm('search')" :disabled="disabled" id="receivedSendStorageReport-refresh">查询</a-button>
  54. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="receivedSendStorageReport-reset">重置</a-button>
  55. <a-button
  56. style="margin-left: 5px"
  57. type="primary"
  58. class="button-warning"
  59. @click="testForm('export')"
  60. :disabled="disabled"
  61. v-if="$hasPermissions('B_ProductPriceExoprt')"
  62. id="productInfoList-export">导出</a-button>
  63. </a-col>
  64. </a-row>
  65. </a-form-model>
  66. </div>
  67. <a-tabs default-active-key="1" @change="handleChange" :style="{ height: tableHeight+84.5+'px' }">
  68. <a-tab-pane key="1" tab="明细">
  69. <!-- 列表 -->
  70. <s-table
  71. class="sTable"
  72. ref="table"
  73. size="small"
  74. :rowKey="(record) => record.id"
  75. :columns="columns"
  76. :data="loadData"
  77. :scroll="{ y: tableHeight-120 }"
  78. :defaultLoadData="false"
  79. bordered>
  80. <template slot="footer">
  81. <a-row>
  82. <a-col span="2">合计:</a-col>
  83. <a-col span="22">
  84. <a-row>
  85. <a-col span="4">期初结存数量:{{ (totalData && (totalData.beginQty || totalData.beginQty==0)) ? totalData.beginQty : '--' }}</a-col>
  86. <a-col span="4">期初结存单价:{{ (totalData && (totalData.beginPrice || totalData.beginPrice==0)) ? toThousands(totalData.beginPrice) : '--' }}</a-col>
  87. <a-col span="4">期初结存金额:{{ (totalData && (totalData.beginAmount || totalData.beginAmount==0)) ? toThousands(totalData.beginAmount) : '--' }}</a-col>
  88. <a-col span="4">本期收入数量:{{ (totalData && (totalData.putQty || totalData.putQty==0)) ?totalData.putQty : '--' }}</a-col>
  89. <a-col span="4">本期收入单价:{{ (totalData && (totalData.putPrice || totalData.putPrice==0)) ? toThousands(totalData.putPrice) : '--' }}</a-col>
  90. <a-col span="4">本期收入金额:{{ (totalData && (totalData.putAmount || totalData.putAmount==0)) ? toThousands(totalData.putAmount) : '--' }}</a-col>
  91. <a-col span="4">本期发出数量:{{ (totalData && (totalData.outQty || totalData.outQty==0)) ? totalData.outQty : '--' }}</a-col>
  92. <a-col span="4">本期发出单价:{{ (totalData && (totalData.outPrice || totalData.outPrice==0)) ? toThousands(totalData.outPrice) : '--' }}</a-col>
  93. <a-col span="4">本期发出金额:{{ (totalData && (totalData.outAmount || totalData.outAmount==0)) ? toThousands(totalData.outAmount) : '--' }}</a-col>
  94. <a-col span="4">本期结存数量:{{ (totalData && (totalData.endQty || totalData.endQty==0)) ? totalData.endQty : '--' }}</a-col>
  95. <a-col span="4">本期结存单价:{{ (totalData && (totalData.endPrice || totalData.endPrice==0)) ? toThousands(totalData.endPrice) : '--' }}</a-col>
  96. <a-col span="4">本期结存金额:{{ (totalData && (totalData.endAmount || totalData.endAmount==0)) ? toThousands(totalData.endAmount) : '--' }}</a-col>
  97. </a-row>
  98. </a-col>
  99. </a-row>
  100. </template>
  101. </s-table>
  102. </a-tab-pane>
  103. <a-tab-pane key="2" tab="汇总" force-render>
  104. <gatherList ref="gatherBox" :tableHeight="tableHeight" :queryParam="queryParam"></gatherList>
  105. </a-tab-pane>
  106. </a-tabs>
  107. <!-- 导出提示框 -->
  108. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  109. </a-card>
  110. </template>
  111. <script>
  112. import { commonMixin } from '@/utils/mixin'
  113. import ProductBrand from '@/views/common/productBrand.js'
  114. import productTypeAll from '@/views/common/productTypeAll.js'
  115. import { STable, VSelect } from '@/components'
  116. import reportModal from '@/views/common/reportModal.vue'
  117. import { queryDetailReportPage, exportDetailReport, exportGroupByProductTypeReport, queryReportCount } from '@/api/reportData'
  118. import { hdExportExcel } from '@/libs/exportExcel'
  119. import gatherList from './list'
  120. import moment from 'moment'
  121. export default {
  122. name: 'PriceDifferenceDetailReportList',
  123. mixins: [commonMixin],
  124. components: { STable, VSelect, ProductBrand, gatherList, productTypeAll, reportModal },
  125. data () {
  126. return {
  127. moment,
  128. queryParam: {
  129. beginDate: undefined,
  130. endDate: undefined,
  131. productCode: '', // 产品编码
  132. productName: '', // 产品名称
  133. productBrandSn: undefined,
  134. productTypeSn1: undefined,
  135. productTypeSn2: undefined,
  136. productTypeSn3: undefined
  137. },
  138. form: {
  139. time: []
  140. },
  141. totalData: null,
  142. tabVal: 1,
  143. rules: {
  144. time: [{ required: true, message: '请选择月份', trigger: 'change' }]
  145. },
  146. productType: [],
  147. disabled: false,
  148. tableHeight: 0,
  149. endOpen: false,
  150. showExport: false,
  151. columns: [
  152. { title: '产品编码', dataIndex: 'productCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  153. { title: '产品名称', dataIndex: 'productName', width: '30%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  154. { title: '原厂编码', dataIndex: 'productOrigCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  155. { title: '品牌', dataIndex: 'productBrandName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  156. { title: '二级分类', dataIndex: 'productTypeName2', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  157. { title: '三级分类', dataIndex: 'productTypeName3', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  158. { title: '单位', dataIndex: 'productUnit', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  159. { title: '期初结存数量', dataIndex: 'beginQty', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  160. { title: '期初结存单价', dataIndex: 'beginPrice', width: '12%', align: 'center', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  161. { title: '期初结存金额', dataIndex: 'beginAmount', width: '12%', align: 'center', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  162. { title: '本期收入数量', dataIndex: 'putQty', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  163. { title: '本期收入单价', dataIndex: 'putPrice', width: '12%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  164. { title: '本期收入金额', dataIndex: 'putAmount', width: '12%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  165. { title: '本期发出数量', dataIndex: 'outQty', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  166. { title: '本期发出单价', dataIndex: 'outPrice', width: '12%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  167. { title: '本期发出金额', dataIndex: 'outAmount', width: '12%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  168. { title: '期末结存数量', dataIndex: 'endQty', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  169. { title: '期末结存单价', dataIndex: 'endPrice', width: '12%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  170. { title: '期末结存金额', dataIndex: 'endAmount', width: '12%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') }
  171. ],
  172. // 加载数据方法 必须为 Promise 对象
  173. loadData: parameter => {
  174. this.disabled = true
  175. const params = Object.assign(parameter, this.queryParam)
  176. this.spinning = true
  177. return queryDetailReportPage(params).then(res => {
  178. let data
  179. if (res.status == 200) {
  180. data = res.data
  181. const no = (data.pageNo - 1) * data.pageSize
  182. for (var i = 0; i < data.list.length; i++) {
  183. data.list[i].no = no + i + 1
  184. }
  185. this.disabled = false
  186. // 总计
  187. this.getCount(params)
  188. }
  189. this.spinning = false
  190. return data
  191. })
  192. }
  193. }
  194. },
  195. methods: {
  196. getCount (params) {
  197. queryReportCount(params).then(res => {
  198. if (res.status == 200) {
  199. this.totalData = res.data
  200. } else {
  201. this.totalData = null
  202. }
  203. })
  204. },
  205. // 选择月份限制
  206. disabledStartDate (startValue) {
  207. const endValue = this.endMonthVal
  208. if (!startValue || !endValue) {
  209. return startValue.valueOf() > this.moment().valueOf()
  210. }
  211. return startValue.valueOf() >= endValue.valueOf()
  212. },
  213. disabledEndDate (endValue) {
  214. const startValue = this.startMonthVal
  215. if (!startValue) {
  216. return endValue.valueOf() > this.moment().valueOf()
  217. }
  218. return endValue.valueOf() < startValue.valueOf() || endValue.valueOf() > this.moment().valueOf()
  219. },
  220. // 开始时间
  221. handleStartOpenChange (open) {
  222. if (!open) {
  223. this.endOpen = true
  224. }
  225. },
  226. getStartDate (date, dateString) {
  227. this.form.time[0] = dateString
  228. this.queryParam.beginDate = this.moment(dateString).startOf('month').format('YYYY-MM-DD') + ' 00:00:00'
  229. },
  230. // 结束时间
  231. handleEndOpenChange (open) {
  232. this.endOpen = open
  233. },
  234. getEndDate (date, dateString) {
  235. this.form.time[1] = dateString
  236. this.queryParam.endDate = this.moment(dateString).endOf('month').format('YYYY-MM-DD') + ' 59:59:59'
  237. },
  238. // 产品分类 change
  239. changeProductType (val, opt) {
  240. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  241. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  242. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  243. },
  244. handleChange (val) {
  245. this.tabVal = val
  246. },
  247. // 导出
  248. handleExport () {
  249. const _this = this
  250. const params = this.queryParam
  251. _this.exportLoading = true
  252. _this.spinning = true
  253. _this.showExport = true
  254. if (this.tabVal == 1) {
  255. hdExportExcel(exportDetailReport, params, '进销存明细报表', function () {
  256. _this.exportLoading = false
  257. _this.spinning = false
  258. })
  259. } else {
  260. hdExportExcel(exportGroupByProductTypeReport, params, '进销存明细报表', function () {
  261. _this.exportLoading = false
  262. _this.spinning = false
  263. })
  264. }
  265. },
  266. // 验证表单 type值 search查询 export导出
  267. testForm (type) {
  268. const _this = this
  269. if (_this.form.time.length != 2) {
  270. _this.$message.error('请选择月份')
  271. return
  272. }
  273. _this.$refs.ruleForm.validate(valid => {
  274. if (valid) {
  275. if (type == 'search') {
  276. _this.handleSearch()
  277. } else {
  278. _this.handleExport()
  279. }
  280. } else {
  281. _this.$message.error('请选择月份')
  282. return false
  283. }
  284. })
  285. },
  286. // 查询
  287. handleSearch () {
  288. const _this = this
  289. if (_this.tabVal == 1) {
  290. _this.$refs.table.refresh(true)
  291. } else {
  292. _this.$refs.gatherBox.resetCurForm()
  293. }
  294. },
  295. // 重置
  296. resetSearchForm () {
  297. this.$refs.ruleForm.resetFields()
  298. this.queryParam.productCode = undefined
  299. this.queryParam.productName = undefined
  300. this.queryParam.productBrandSn = undefined
  301. this.queryParam.productTypeSn1 = undefined
  302. this.queryParam.productTypeSn2 = undefined
  303. this.queryParam.productTypeSn3 = undefined
  304. this.$refs.table.clearTable()
  305. this.productType = []
  306. this.$refs.table.refresh(true)
  307. this.$refs.gatherBox.resetCurForm()
  308. },
  309. pageInit () {
  310. const _this = this
  311. this.$nextTick(() => { // 页面渲染完成后的回调
  312. _this.setTableH()
  313. })
  314. },
  315. setTableH () {
  316. const tableSearchH = this.$refs.tableSearch.offsetHeight
  317. this.tableHeight = window.innerHeight - tableSearchH - 200
  318. }
  319. },
  320. mounted () {
  321. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  322. this.pageInit()
  323. }
  324. },
  325. activated () {
  326. // 如果是新页签打开,则重置当前页面
  327. if (this.$store.state.app.isNewTab) {
  328. this.pageInit()
  329. }
  330. }
  331. }
  332. </script>
  333. <style lang="less" scoped>
  334. .monthBox{
  335. /deep/.ant-calendar-picker-icon{
  336. display:none !important;
  337. }
  338. /deep/.ant-calendar-picker input{
  339. text-align:center;
  340. }
  341. }
  342. </style>