list.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <a-spin :spinning="spinning" tip="Loading...">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form-model
  6. id="storeTransOutReport-form"
  7. ref="ruleForm"
  8. class="form-model-con"
  9. layout="inline"
  10. :model="queryParam"
  11. :rules="rules"
  12. :labelCol="labelCol"
  13. :wrapperCol="wrapperCol"
  14. @keyup.enter.native="handleSearch" >
  15. <a-row :gutter="15">
  16. <a-col :md="6" :sm="24">
  17. <a-form-model-item label="审核时间" prop="time">
  18. <rangeDate ref="rangeDate" @change="dateChange" />
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :md="6" :sm="24">
  22. <a-form-item label="出库时间">
  23. <rangeDate ref="outWareRangeDate" :value="outWareTime" @change="outWareDateChange" />
  24. </a-form-item>
  25. </a-col>
  26. <a-col :md="4" :sm="24">
  27. <a-form-model-item label="店内调出单号">
  28. <a-input id="storeTransOutReport-storeCallOutNo" v-model.trim="queryParam.storeCallOutNo" allowClear placeholder="请输入店内调出单号"/>
  29. </a-form-model-item>
  30. </a-col>
  31. <a-col :md="4" :sm="24">
  32. <a-form-item label="调往对象">
  33. <a-input id="sstoreTransOutReport-putPersonName" v-model.trim="queryParam.putPersonName" allowClear placeholder="请输入调往对象"/>
  34. </a-form-item>
  35. </a-col>
  36. <a-col :md="4" :sm="24">
  37. <a-form-item label="调拨类型">
  38. <a-select id="sstoreTransOutReport-callOutType" v-model="queryParam.callOutType" placeholder="请选择调拨类型" allowClear >
  39. <a-select-option v-for="item in storeCallOutTypeList" :key="item.storeCallOutTypeSn" :value="item.storeCallOutTypeSn">{{ item.name }}</a-select-option>
  40. </a-select>
  41. </a-form-item>
  42. </a-col>
  43. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  44. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="storeTransOutReport-refresh">查询</a-button>
  45. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="storeTransOutReport-reset">重置</a-button>
  46. <a-button
  47. type="primary"
  48. style="margin-left: 5px"
  49. @click="handleExport"
  50. :disabled="disabled"
  51. :loading="exportLoading"
  52. v-if="$hasPermissions('M_storeTransferOutReportExport')"
  53. class="button-warning"
  54. id="storeTransOutReport-export-btn">导出</a-button>
  55. </a-col>
  56. </a-row>
  57. </a-form-model>
  58. </div>
  59. <!-- 合计 -->
  60. <a-alert type="info" style="margin-bottom:10px">
  61. <div class="ftext" slot="message">
  62. 总单数:<strong>{{ (totalData && (totalData.productTotalCategory || totalData.productTotalCategory==0)) ? totalData.productTotalCategory : '--' }}</strong>;
  63. 产品总数量:<strong>{{ (totalData && (totalData.productTotalQty || totalData.productTotalQty==0)) ? totalData.productTotalQty : '--' }}</strong>;
  64. <div v-if="$hasPermissions('M_ShowAllCost')" style="display: inline-block;">
  65. 调出总成本:<strong>{{ (totalData && (totalData.productTotalCost || totalData.productTotalCost==0)) ? toThousands(totalData.productTotalCost) : '--' }}</strong>;
  66. </div>
  67. </div>
  68. </a-alert>
  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. :defaultLoadData="false"
  78. bordered>
  79. </s-table>
  80. </a-spin>
  81. </template>
  82. <script>
  83. import { commonMixin } from '@/utils/mixin'
  84. import { STable, VSelect } from '@/components'
  85. import rangeDate from '@/views/common/rangeDate.vue'
  86. import { downloadExcel } from '@/libs/JGPrint.js'
  87. import { storeCallOutTypeAllList } from '@/api/storeCallOutType'
  88. import { reportStoreCallOutPageList, reportStoreCallOutListTotal, reportStoreCallOutExport } from '@/api/reportData'
  89. export default {
  90. components: { STable, VSelect, rangeDate },
  91. mixins: [commonMixin],
  92. data () {
  93. return {
  94. spinning: false,
  95. labelCol: { span: 8 },
  96. wrapperCol: { span: 16 },
  97. advanced: false, // 高级搜索 展开/关闭
  98. tableHeight: 0,
  99. outWareTime: [],
  100. queryParam: { // 查询条件
  101. time: [],
  102. beginDate: '',
  103. endDate: '',
  104. putPersonName: '',
  105. callOutType: undefined,
  106. storeCallOutNo: ''
  107. },
  108. rules: {
  109. 'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
  110. },
  111. disabled: false, // 查询、重置按钮是否可操作
  112. exportLoading: false,
  113. // 加载数据方法 必须为 Promise 对象
  114. loadData: parameter => {
  115. this.disabled = true
  116. const params = Object.assign(parameter, this.queryParam)
  117. this.spinning = true
  118. delete params.time
  119. return reportStoreCallOutPageList(params).then(res => {
  120. let data
  121. if (res.status == 200) {
  122. data = res.data
  123. // 总计
  124. this.getCount(params)
  125. const no = (data.pageNo - 1) * data.pageSize
  126. for (var i = 0; i < data.list.length; i++) {
  127. data.list[i].no = no + i + 1
  128. }
  129. this.disabled = false
  130. }
  131. this.spinning = false
  132. return data
  133. })
  134. },
  135. totalData: null, // 合计
  136. storeCallOutTypeList: [] // 调拨类型
  137. }
  138. },
  139. computed: {
  140. columns () {
  141. const _this = this
  142. const arr = [
  143. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  144. { title: '店内调出单号', dataIndex: 'storeCallOutNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  145. { title: '调往对象', dataIndex: 'putPersonName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  146. { title: '调拨类型', dataIndex: 'callOutTypeName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  147. { title: '款数', dataIndex: 'productTotalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  148. { title: '数量', dataIndex: 'productTotalQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  149. // { title: '成本', dataIndex: 'productTotalCost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  150. { title: '审核时间', dataIndex: 'auditTime', width: '13%', align: 'center', customRender: function (text) { return text || '--' } }
  151. ]
  152. if (this.$hasPermissions('M_ShowAllCost')) {
  153. arr.splice(6, 0, { title: '成本', dataIndex: 'productTotalCost', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  154. }
  155. return arr
  156. }
  157. },
  158. methods: {
  159. // 合计
  160. getCount (params) {
  161. reportStoreCallOutListTotal(params).then(res => {
  162. if (res.status == 200) {
  163. this.totalData = res.data
  164. } else {
  165. this.totalData = null
  166. }
  167. })
  168. },
  169. // 创建时间 change
  170. dateChange (date) {
  171. this.queryParam.time = date
  172. this.queryParam.beginDate = date[0] || ''
  173. this.queryParam.endDate = date[1] || ''
  174. },
  175. outWareDateChange (date) {
  176. this.queryParam.outWarehouseBeginDate = date[0]
  177. this.queryParam.outWarehouseEndDate = date[1]
  178. },
  179. // 查询
  180. handleSearch () {
  181. this.$refs.ruleForm.validate(valid => {
  182. if (valid) {
  183. this.$refs.table.refresh(true)
  184. } else {
  185. console.log('error submit!!')
  186. return false
  187. }
  188. })
  189. },
  190. // 重置
  191. resetSearchForm () {
  192. this.$refs.rangeDate.resetDate()
  193. this.queryParam.time = []
  194. this.queryParam.beginDate = ''
  195. this.queryParam.endDate = ''
  196. this.$refs.outWareRangeDate.resetDate('')
  197. this.outWareTime = []
  198. this.queryParam.outWarehouseBeginDate = ''
  199. this.queryParam.outWarehouseEndDate = ''
  200. this.queryParam.putPersonName = ''
  201. this.queryParam.storeCallOutNo = ''
  202. this.queryParam.callOutType = undefined
  203. this.$refs.ruleForm.resetFields()
  204. this.totalData = null
  205. this.$refs.table.clearTable()
  206. },
  207. // 导出
  208. handleExport () {
  209. const _this = this
  210. this.$refs.ruleForm.validate(valid => {
  211. if (valid) {
  212. const params = _this.queryParam
  213. params.showCost = this.$hasPermissions('M_ShowAllCost') ? '1' : '0'
  214. _this.exportLoading = true
  215. _this.spinning = true
  216. reportStoreCallOutExport(params).then(res => {
  217. downloadExcel(res, '店内调出报表')
  218. _this.exportLoading = false
  219. _this.spinning = false
  220. })
  221. } else {
  222. console.log('error submit!!')
  223. return false
  224. }
  225. })
  226. },
  227. // 调拨类型
  228. getStoreCallOutTypeAllList () {
  229. storeCallOutTypeAllList().then(res => {
  230. if (res.status == 200) {
  231. this.storeCallOutTypeList = res.data
  232. } else {
  233. this.storeCallOutTypeList = []
  234. }
  235. })
  236. },
  237. pageInit () {
  238. this.getStoreCallOutTypeAllList()
  239. }
  240. },
  241. mounted () {
  242. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  243. this.pageInit()
  244. this.resetSearchForm()
  245. }
  246. },
  247. activated () {
  248. // 如果是新页签打开,则重置当前页面
  249. if (this.$store.state.app.isNewTab) {
  250. this.pageInit()
  251. this.resetSearchForm()
  252. }
  253. },
  254. beforeRouteEnter (to, from, next) {
  255. next(vm => {})
  256. }
  257. }
  258. </script>