index.vue 16 KB

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