index.vue 16 KB

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