index.vue 16 KB

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