index.vue 16 KB

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